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|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 portid_t pid; 1881 1882 if (!all_ports_stopped()) { 1883 printf("Please stop all ports first\n"); 1884 return; 1885 } 1886 1887 RTE_ETH_FOREACH_DEV(pid) { 1888 struct rte_port *port = &ports[pid]; 1889 1890 if (!strcmp(res->name, "max-pkt-len")) { 1891 if (res->value < RTE_ETHER_MIN_LEN) { 1892 printf("max-pkt-len can not be less than %d\n", 1893 RTE_ETHER_MIN_LEN); 1894 return; 1895 } 1896 if (res->value == port->dev_conf.rxmode.max_rx_pkt_len) 1897 return; 1898 1899 port->dev_conf.rxmode.max_rx_pkt_len = res->value; 1900 } else { 1901 printf("Unknown parameter\n"); 1902 return; 1903 } 1904 } 1905 1906 init_port_config(); 1907 1908 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1); 1909 } 1910 1911 cmdline_parse_token_string_t cmd_config_max_pkt_len_port = 1912 TOKEN_STRING_INITIALIZER(struct cmd_config_max_pkt_len_result, port, 1913 "port"); 1914 cmdline_parse_token_string_t cmd_config_max_pkt_len_keyword = 1915 TOKEN_STRING_INITIALIZER(struct cmd_config_max_pkt_len_result, keyword, 1916 "config"); 1917 cmdline_parse_token_string_t cmd_config_max_pkt_len_all = 1918 TOKEN_STRING_INITIALIZER(struct cmd_config_max_pkt_len_result, all, 1919 "all"); 1920 cmdline_parse_token_string_t cmd_config_max_pkt_len_name = 1921 TOKEN_STRING_INITIALIZER(struct cmd_config_max_pkt_len_result, name, 1922 "max-pkt-len"); 1923 cmdline_parse_token_num_t cmd_config_max_pkt_len_value = 1924 TOKEN_NUM_INITIALIZER(struct cmd_config_max_pkt_len_result, value, 1925 RTE_UINT32); 1926 1927 cmdline_parse_inst_t cmd_config_max_pkt_len = { 1928 .f = cmd_config_max_pkt_len_parsed, 1929 .data = NULL, 1930 .help_str = "port config all max-pkt-len <value>", 1931 .tokens = { 1932 (void *)&cmd_config_max_pkt_len_port, 1933 (void *)&cmd_config_max_pkt_len_keyword, 1934 (void *)&cmd_config_max_pkt_len_all, 1935 (void *)&cmd_config_max_pkt_len_name, 1936 (void *)&cmd_config_max_pkt_len_value, 1937 NULL, 1938 }, 1939 }; 1940 1941 /* *** config max LRO aggregated packet size *** */ 1942 struct cmd_config_max_lro_pkt_size_result { 1943 cmdline_fixed_string_t port; 1944 cmdline_fixed_string_t keyword; 1945 cmdline_fixed_string_t all; 1946 cmdline_fixed_string_t name; 1947 uint32_t value; 1948 }; 1949 1950 static void 1951 cmd_config_max_lro_pkt_size_parsed(void *parsed_result, 1952 __rte_unused struct cmdline *cl, 1953 __rte_unused void *data) 1954 { 1955 struct cmd_config_max_lro_pkt_size_result *res = parsed_result; 1956 portid_t pid; 1957 1958 if (!all_ports_stopped()) { 1959 printf("Please stop all ports first\n"); 1960 return; 1961 } 1962 1963 RTE_ETH_FOREACH_DEV(pid) { 1964 struct rte_port *port = &ports[pid]; 1965 1966 if (!strcmp(res->name, "max-lro-pkt-size")) { 1967 if (res->value == 1968 port->dev_conf.rxmode.max_lro_pkt_size) 1969 return; 1970 1971 port->dev_conf.rxmode.max_lro_pkt_size = res->value; 1972 } else { 1973 printf("Unknown parameter\n"); 1974 return; 1975 } 1976 } 1977 1978 init_port_config(); 1979 1980 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1); 1981 } 1982 1983 cmdline_parse_token_string_t cmd_config_max_lro_pkt_size_port = 1984 TOKEN_STRING_INITIALIZER(struct cmd_config_max_lro_pkt_size_result, 1985 port, "port"); 1986 cmdline_parse_token_string_t cmd_config_max_lro_pkt_size_keyword = 1987 TOKEN_STRING_INITIALIZER(struct cmd_config_max_lro_pkt_size_result, 1988 keyword, "config"); 1989 cmdline_parse_token_string_t cmd_config_max_lro_pkt_size_all = 1990 TOKEN_STRING_INITIALIZER(struct cmd_config_max_lro_pkt_size_result, 1991 all, "all"); 1992 cmdline_parse_token_string_t cmd_config_max_lro_pkt_size_name = 1993 TOKEN_STRING_INITIALIZER(struct cmd_config_max_lro_pkt_size_result, 1994 name, "max-lro-pkt-size"); 1995 cmdline_parse_token_num_t cmd_config_max_lro_pkt_size_value = 1996 TOKEN_NUM_INITIALIZER(struct cmd_config_max_lro_pkt_size_result, 1997 value, RTE_UINT32); 1998 1999 cmdline_parse_inst_t cmd_config_max_lro_pkt_size = { 2000 .f = cmd_config_max_lro_pkt_size_parsed, 2001 .data = NULL, 2002 .help_str = "port config all max-lro-pkt-size <value>", 2003 .tokens = { 2004 (void *)&cmd_config_max_lro_pkt_size_port, 2005 (void *)&cmd_config_max_lro_pkt_size_keyword, 2006 (void *)&cmd_config_max_lro_pkt_size_all, 2007 (void *)&cmd_config_max_lro_pkt_size_name, 2008 (void *)&cmd_config_max_lro_pkt_size_value, 2009 NULL, 2010 }, 2011 }; 2012 2013 /* *** configure port MTU *** */ 2014 struct cmd_config_mtu_result { 2015 cmdline_fixed_string_t port; 2016 cmdline_fixed_string_t keyword; 2017 cmdline_fixed_string_t mtu; 2018 portid_t port_id; 2019 uint16_t value; 2020 }; 2021 2022 static void 2023 cmd_config_mtu_parsed(void *parsed_result, 2024 __rte_unused struct cmdline *cl, 2025 __rte_unused void *data) 2026 { 2027 struct cmd_config_mtu_result *res = parsed_result; 2028 2029 if (res->value < RTE_ETHER_MIN_LEN) { 2030 printf("mtu cannot be less than %d\n", RTE_ETHER_MIN_LEN); 2031 return; 2032 } 2033 port_mtu_set(res->port_id, res->value); 2034 } 2035 2036 cmdline_parse_token_string_t cmd_config_mtu_port = 2037 TOKEN_STRING_INITIALIZER(struct cmd_config_mtu_result, port, 2038 "port"); 2039 cmdline_parse_token_string_t cmd_config_mtu_keyword = 2040 TOKEN_STRING_INITIALIZER(struct cmd_config_mtu_result, keyword, 2041 "config"); 2042 cmdline_parse_token_string_t cmd_config_mtu_mtu = 2043 TOKEN_STRING_INITIALIZER(struct cmd_config_mtu_result, keyword, 2044 "mtu"); 2045 cmdline_parse_token_num_t cmd_config_mtu_port_id = 2046 TOKEN_NUM_INITIALIZER(struct cmd_config_mtu_result, port_id, 2047 RTE_UINT16); 2048 cmdline_parse_token_num_t cmd_config_mtu_value = 2049 TOKEN_NUM_INITIALIZER(struct cmd_config_mtu_result, value, 2050 RTE_UINT16); 2051 2052 cmdline_parse_inst_t cmd_config_mtu = { 2053 .f = cmd_config_mtu_parsed, 2054 .data = NULL, 2055 .help_str = "port config mtu <port_id> <value>", 2056 .tokens = { 2057 (void *)&cmd_config_mtu_port, 2058 (void *)&cmd_config_mtu_keyword, 2059 (void *)&cmd_config_mtu_mtu, 2060 (void *)&cmd_config_mtu_port_id, 2061 (void *)&cmd_config_mtu_value, 2062 NULL, 2063 }, 2064 }; 2065 2066 /* *** configure rx mode *** */ 2067 struct cmd_config_rx_mode_flag { 2068 cmdline_fixed_string_t port; 2069 cmdline_fixed_string_t keyword; 2070 cmdline_fixed_string_t all; 2071 cmdline_fixed_string_t name; 2072 cmdline_fixed_string_t value; 2073 }; 2074 2075 static void 2076 cmd_config_rx_mode_flag_parsed(void *parsed_result, 2077 __rte_unused struct cmdline *cl, 2078 __rte_unused void *data) 2079 { 2080 struct cmd_config_rx_mode_flag *res = parsed_result; 2081 2082 if (!all_ports_stopped()) { 2083 printf("Please stop all ports first\n"); 2084 return; 2085 } 2086 2087 if (!strcmp(res->name, "drop-en")) { 2088 if (!strcmp(res->value, "on")) 2089 rx_drop_en = 1; 2090 else if (!strcmp(res->value, "off")) 2091 rx_drop_en = 0; 2092 else { 2093 printf("Unknown parameter\n"); 2094 return; 2095 } 2096 } else { 2097 printf("Unknown parameter\n"); 2098 return; 2099 } 2100 2101 init_port_config(); 2102 2103 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1); 2104 } 2105 2106 cmdline_parse_token_string_t cmd_config_rx_mode_flag_port = 2107 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_mode_flag, port, "port"); 2108 cmdline_parse_token_string_t cmd_config_rx_mode_flag_keyword = 2109 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_mode_flag, keyword, 2110 "config"); 2111 cmdline_parse_token_string_t cmd_config_rx_mode_flag_all = 2112 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_mode_flag, all, "all"); 2113 cmdline_parse_token_string_t cmd_config_rx_mode_flag_name = 2114 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_mode_flag, name, 2115 "drop-en"); 2116 cmdline_parse_token_string_t cmd_config_rx_mode_flag_value = 2117 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_mode_flag, value, 2118 "on#off"); 2119 2120 cmdline_parse_inst_t cmd_config_rx_mode_flag = { 2121 .f = cmd_config_rx_mode_flag_parsed, 2122 .data = NULL, 2123 .help_str = "port config all drop-en on|off", 2124 .tokens = { 2125 (void *)&cmd_config_rx_mode_flag_port, 2126 (void *)&cmd_config_rx_mode_flag_keyword, 2127 (void *)&cmd_config_rx_mode_flag_all, 2128 (void *)&cmd_config_rx_mode_flag_name, 2129 (void *)&cmd_config_rx_mode_flag_value, 2130 NULL, 2131 }, 2132 }; 2133 2134 /* *** configure rss *** */ 2135 struct cmd_config_rss { 2136 cmdline_fixed_string_t port; 2137 cmdline_fixed_string_t keyword; 2138 cmdline_fixed_string_t all; 2139 cmdline_fixed_string_t name; 2140 cmdline_fixed_string_t value; 2141 }; 2142 2143 static void 2144 cmd_config_rss_parsed(void *parsed_result, 2145 __rte_unused struct cmdline *cl, 2146 __rte_unused void *data) 2147 { 2148 struct cmd_config_rss *res = parsed_result; 2149 struct rte_eth_rss_conf rss_conf = { .rss_key_len = 0, }; 2150 struct rte_eth_dev_info dev_info = { .flow_type_rss_offloads = 0, }; 2151 int use_default = 0; 2152 int all_updated = 1; 2153 int diag; 2154 uint16_t i; 2155 int ret; 2156 2157 if (!strcmp(res->value, "all")) 2158 rss_conf.rss_hf = ETH_RSS_ETH | ETH_RSS_VLAN | ETH_RSS_IP | 2159 ETH_RSS_TCP | ETH_RSS_UDP | ETH_RSS_SCTP | 2160 ETH_RSS_L2_PAYLOAD | ETH_RSS_L2TPV3 | ETH_RSS_ESP | 2161 ETH_RSS_AH | ETH_RSS_PFCP | ETH_RSS_GTPU | 2162 ETH_RSS_ECPRI; 2163 else if (!strcmp(res->value, "eth")) 2164 rss_conf.rss_hf = ETH_RSS_ETH; 2165 else if (!strcmp(res->value, "vlan")) 2166 rss_conf.rss_hf = ETH_RSS_VLAN; 2167 else if (!strcmp(res->value, "ip")) 2168 rss_conf.rss_hf = ETH_RSS_IP; 2169 else if (!strcmp(res->value, "udp")) 2170 rss_conf.rss_hf = ETH_RSS_UDP; 2171 else if (!strcmp(res->value, "tcp")) 2172 rss_conf.rss_hf = ETH_RSS_TCP; 2173 else if (!strcmp(res->value, "sctp")) 2174 rss_conf.rss_hf = ETH_RSS_SCTP; 2175 else if (!strcmp(res->value, "ether")) 2176 rss_conf.rss_hf = ETH_RSS_L2_PAYLOAD; 2177 else if (!strcmp(res->value, "port")) 2178 rss_conf.rss_hf = ETH_RSS_PORT; 2179 else if (!strcmp(res->value, "vxlan")) 2180 rss_conf.rss_hf = ETH_RSS_VXLAN; 2181 else if (!strcmp(res->value, "geneve")) 2182 rss_conf.rss_hf = ETH_RSS_GENEVE; 2183 else if (!strcmp(res->value, "nvgre")) 2184 rss_conf.rss_hf = ETH_RSS_NVGRE; 2185 else if (!strcmp(res->value, "l3-pre32")) 2186 rss_conf.rss_hf = RTE_ETH_RSS_L3_PRE32; 2187 else if (!strcmp(res->value, "l3-pre40")) 2188 rss_conf.rss_hf = RTE_ETH_RSS_L3_PRE40; 2189 else if (!strcmp(res->value, "l3-pre48")) 2190 rss_conf.rss_hf = RTE_ETH_RSS_L3_PRE48; 2191 else if (!strcmp(res->value, "l3-pre56")) 2192 rss_conf.rss_hf = RTE_ETH_RSS_L3_PRE56; 2193 else if (!strcmp(res->value, "l3-pre64")) 2194 rss_conf.rss_hf = RTE_ETH_RSS_L3_PRE64; 2195 else if (!strcmp(res->value, "l3-pre96")) 2196 rss_conf.rss_hf = RTE_ETH_RSS_L3_PRE96; 2197 else if (!strcmp(res->value, "l3-src-only")) 2198 rss_conf.rss_hf = ETH_RSS_L3_SRC_ONLY; 2199 else if (!strcmp(res->value, "l3-dst-only")) 2200 rss_conf.rss_hf = ETH_RSS_L3_DST_ONLY; 2201 else if (!strcmp(res->value, "l4-src-only")) 2202 rss_conf.rss_hf = ETH_RSS_L4_SRC_ONLY; 2203 else if (!strcmp(res->value, "l4-dst-only")) 2204 rss_conf.rss_hf = ETH_RSS_L4_DST_ONLY; 2205 else if (!strcmp(res->value, "l2-src-only")) 2206 rss_conf.rss_hf = ETH_RSS_L2_SRC_ONLY; 2207 else if (!strcmp(res->value, "l2-dst-only")) 2208 rss_conf.rss_hf = ETH_RSS_L2_DST_ONLY; 2209 else if (!strcmp(res->value, "l2tpv3")) 2210 rss_conf.rss_hf = ETH_RSS_L2TPV3; 2211 else if (!strcmp(res->value, "esp")) 2212 rss_conf.rss_hf = ETH_RSS_ESP; 2213 else if (!strcmp(res->value, "ah")) 2214 rss_conf.rss_hf = ETH_RSS_AH; 2215 else if (!strcmp(res->value, "pfcp")) 2216 rss_conf.rss_hf = ETH_RSS_PFCP; 2217 else if (!strcmp(res->value, "pppoe")) 2218 rss_conf.rss_hf = ETH_RSS_PPPOE; 2219 else if (!strcmp(res->value, "gtpu")) 2220 rss_conf.rss_hf = ETH_RSS_GTPU; 2221 else if (!strcmp(res->value, "ecpri")) 2222 rss_conf.rss_hf = ETH_RSS_ECPRI; 2223 else if (!strcmp(res->value, "none")) 2224 rss_conf.rss_hf = 0; 2225 else if (!strcmp(res->value, "level-default")) { 2226 rss_hf &= (~ETH_RSS_LEVEL_MASK); 2227 rss_conf.rss_hf = (rss_hf | ETH_RSS_LEVEL_PMD_DEFAULT); 2228 } else if (!strcmp(res->value, "level-outer")) { 2229 rss_hf &= (~ETH_RSS_LEVEL_MASK); 2230 rss_conf.rss_hf = (rss_hf | ETH_RSS_LEVEL_OUTERMOST); 2231 } else if (!strcmp(res->value, "level-inner")) { 2232 rss_hf &= (~ETH_RSS_LEVEL_MASK); 2233 rss_conf.rss_hf = (rss_hf | ETH_RSS_LEVEL_INNERMOST); 2234 } else if (!strcmp(res->value, "default")) 2235 use_default = 1; 2236 else if (isdigit(res->value[0]) && atoi(res->value) > 0 && 2237 atoi(res->value) < 64) 2238 rss_conf.rss_hf = 1ULL << atoi(res->value); 2239 else { 2240 printf("Unknown parameter\n"); 2241 return; 2242 } 2243 rss_conf.rss_key = NULL; 2244 /* Update global configuration for RSS types. */ 2245 RTE_ETH_FOREACH_DEV(i) { 2246 struct rte_eth_rss_conf local_rss_conf; 2247 2248 ret = eth_dev_info_get_print_err(i, &dev_info); 2249 if (ret != 0) 2250 return; 2251 2252 if (use_default) 2253 rss_conf.rss_hf = dev_info.flow_type_rss_offloads; 2254 2255 local_rss_conf = rss_conf; 2256 local_rss_conf.rss_hf = rss_conf.rss_hf & 2257 dev_info.flow_type_rss_offloads; 2258 if (local_rss_conf.rss_hf != rss_conf.rss_hf) { 2259 printf("Port %u modified RSS hash function based on hardware support," 2260 "requested:%#"PRIx64" configured:%#"PRIx64"\n", 2261 i, rss_conf.rss_hf, local_rss_conf.rss_hf); 2262 } 2263 diag = rte_eth_dev_rss_hash_update(i, &local_rss_conf); 2264 if (diag < 0) { 2265 all_updated = 0; 2266 printf("Configuration of RSS hash at ethernet port %d " 2267 "failed with error (%d): %s.\n", 2268 i, -diag, strerror(-diag)); 2269 } 2270 } 2271 if (all_updated && !use_default) { 2272 rss_hf = rss_conf.rss_hf; 2273 printf("rss_hf %#"PRIx64"\n", rss_hf); 2274 } 2275 } 2276 2277 cmdline_parse_token_string_t cmd_config_rss_port = 2278 TOKEN_STRING_INITIALIZER(struct cmd_config_rss, port, "port"); 2279 cmdline_parse_token_string_t cmd_config_rss_keyword = 2280 TOKEN_STRING_INITIALIZER(struct cmd_config_rss, keyword, "config"); 2281 cmdline_parse_token_string_t cmd_config_rss_all = 2282 TOKEN_STRING_INITIALIZER(struct cmd_config_rss, all, "all"); 2283 cmdline_parse_token_string_t cmd_config_rss_name = 2284 TOKEN_STRING_INITIALIZER(struct cmd_config_rss, name, "rss"); 2285 cmdline_parse_token_string_t cmd_config_rss_value = 2286 TOKEN_STRING_INITIALIZER(struct cmd_config_rss, value, NULL); 2287 2288 cmdline_parse_inst_t cmd_config_rss = { 2289 .f = cmd_config_rss_parsed, 2290 .data = NULL, 2291 .help_str = "port config all rss " 2292 "all|default|eth|vlan|ip|tcp|udp|sctp|ether|port|vxlan|geneve|" 2293 "nvgre|vxlan-gpe|l2tpv3|esp|ah|pfcp|ecpri|none|level-default|" 2294 "level-outer|level-inner|<flowtype_id>", 2295 .tokens = { 2296 (void *)&cmd_config_rss_port, 2297 (void *)&cmd_config_rss_keyword, 2298 (void *)&cmd_config_rss_all, 2299 (void *)&cmd_config_rss_name, 2300 (void *)&cmd_config_rss_value, 2301 NULL, 2302 }, 2303 }; 2304 2305 /* *** configure rss hash key *** */ 2306 struct cmd_config_rss_hash_key { 2307 cmdline_fixed_string_t port; 2308 cmdline_fixed_string_t config; 2309 portid_t port_id; 2310 cmdline_fixed_string_t rss_hash_key; 2311 cmdline_fixed_string_t rss_type; 2312 cmdline_fixed_string_t key; 2313 }; 2314 2315 static uint8_t 2316 hexa_digit_to_value(char hexa_digit) 2317 { 2318 if ((hexa_digit >= '0') && (hexa_digit <= '9')) 2319 return (uint8_t) (hexa_digit - '0'); 2320 if ((hexa_digit >= 'a') && (hexa_digit <= 'f')) 2321 return (uint8_t) ((hexa_digit - 'a') + 10); 2322 if ((hexa_digit >= 'A') && (hexa_digit <= 'F')) 2323 return (uint8_t) ((hexa_digit - 'A') + 10); 2324 /* Invalid hexa digit */ 2325 return 0xFF; 2326 } 2327 2328 static uint8_t 2329 parse_and_check_key_hexa_digit(char *key, int idx) 2330 { 2331 uint8_t hexa_v; 2332 2333 hexa_v = hexa_digit_to_value(key[idx]); 2334 if (hexa_v == 0xFF) 2335 printf("invalid key: character %c at position %d is not a " 2336 "valid hexa digit\n", key[idx], idx); 2337 return hexa_v; 2338 } 2339 2340 static void 2341 cmd_config_rss_hash_key_parsed(void *parsed_result, 2342 __rte_unused struct cmdline *cl, 2343 __rte_unused void *data) 2344 { 2345 struct cmd_config_rss_hash_key *res = parsed_result; 2346 uint8_t hash_key[RSS_HASH_KEY_LENGTH]; 2347 uint8_t xdgt0; 2348 uint8_t xdgt1; 2349 int i; 2350 struct rte_eth_dev_info dev_info; 2351 uint8_t hash_key_size; 2352 uint32_t key_len; 2353 int ret; 2354 2355 ret = eth_dev_info_get_print_err(res->port_id, &dev_info); 2356 if (ret != 0) 2357 return; 2358 2359 if (dev_info.hash_key_size > 0 && 2360 dev_info.hash_key_size <= sizeof(hash_key)) 2361 hash_key_size = dev_info.hash_key_size; 2362 else { 2363 printf("dev_info did not provide a valid hash key size\n"); 2364 return; 2365 } 2366 /* Check the length of the RSS hash key */ 2367 key_len = strlen(res->key); 2368 if (key_len != (hash_key_size * 2)) { 2369 printf("key length: %d invalid - key must be a string of %d" 2370 " hexa-decimal numbers\n", 2371 (int) key_len, hash_key_size * 2); 2372 return; 2373 } 2374 /* Translate RSS hash key into binary representation */ 2375 for (i = 0; i < hash_key_size; i++) { 2376 xdgt0 = parse_and_check_key_hexa_digit(res->key, (i * 2)); 2377 if (xdgt0 == 0xFF) 2378 return; 2379 xdgt1 = parse_and_check_key_hexa_digit(res->key, (i * 2) + 1); 2380 if (xdgt1 == 0xFF) 2381 return; 2382 hash_key[i] = (uint8_t) ((xdgt0 * 16) + xdgt1); 2383 } 2384 port_rss_hash_key_update(res->port_id, res->rss_type, hash_key, 2385 hash_key_size); 2386 } 2387 2388 cmdline_parse_token_string_t cmd_config_rss_hash_key_port = 2389 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_hash_key, port, "port"); 2390 cmdline_parse_token_string_t cmd_config_rss_hash_key_config = 2391 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_hash_key, config, 2392 "config"); 2393 cmdline_parse_token_num_t cmd_config_rss_hash_key_port_id = 2394 TOKEN_NUM_INITIALIZER(struct cmd_config_rss_hash_key, port_id, 2395 RTE_UINT16); 2396 cmdline_parse_token_string_t cmd_config_rss_hash_key_rss_hash_key = 2397 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_hash_key, 2398 rss_hash_key, "rss-hash-key"); 2399 cmdline_parse_token_string_t cmd_config_rss_hash_key_rss_type = 2400 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_hash_key, rss_type, 2401 "ipv4#ipv4-frag#ipv4-tcp#ipv4-udp#ipv4-sctp#" 2402 "ipv4-other#ipv6#ipv6-frag#ipv6-tcp#ipv6-udp#" 2403 "ipv6-sctp#ipv6-other#l2-payload#ipv6-ex#" 2404 "ipv6-tcp-ex#ipv6-udp-ex#" 2405 "l3-src-only#l3-dst-only#l4-src-only#l4-dst-only#" 2406 "l2-src-only#l2-dst-only#s-vlan#c-vlan#" 2407 "l2tpv3#esp#ah#pfcp#pppoe#gtpu#ecpri"); 2408 cmdline_parse_token_string_t cmd_config_rss_hash_key_value = 2409 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_hash_key, key, NULL); 2410 2411 cmdline_parse_inst_t cmd_config_rss_hash_key = { 2412 .f = cmd_config_rss_hash_key_parsed, 2413 .data = NULL, 2414 .help_str = "port config <port_id> rss-hash-key " 2415 "ipv4|ipv4-frag|ipv4-tcp|ipv4-udp|ipv4-sctp|ipv4-other|" 2416 "ipv6|ipv6-frag|ipv6-tcp|ipv6-udp|ipv6-sctp|ipv6-other|" 2417 "l2-payload|ipv6-ex|ipv6-tcp-ex|ipv6-udp-ex|" 2418 "l3-src-only|l3-dst-only|l4-src-only|l4-dst-only|" 2419 "l2-src-only|l2-dst-only|s-vlan|c-vlan|" 2420 "l2tpv3|esp|ah|pfcp|pppoe|gtpu|ecpri " 2421 "<string of hex digits (variable length, NIC dependent)>", 2422 .tokens = { 2423 (void *)&cmd_config_rss_hash_key_port, 2424 (void *)&cmd_config_rss_hash_key_config, 2425 (void *)&cmd_config_rss_hash_key_port_id, 2426 (void *)&cmd_config_rss_hash_key_rss_hash_key, 2427 (void *)&cmd_config_rss_hash_key_rss_type, 2428 (void *)&cmd_config_rss_hash_key_value, 2429 NULL, 2430 }, 2431 }; 2432 2433 /* *** configure port rxq/txq ring size *** */ 2434 struct cmd_config_rxtx_ring_size { 2435 cmdline_fixed_string_t port; 2436 cmdline_fixed_string_t config; 2437 portid_t portid; 2438 cmdline_fixed_string_t rxtxq; 2439 uint16_t qid; 2440 cmdline_fixed_string_t rsize; 2441 uint16_t size; 2442 }; 2443 2444 static void 2445 cmd_config_rxtx_ring_size_parsed(void *parsed_result, 2446 __rte_unused struct cmdline *cl, 2447 __rte_unused void *data) 2448 { 2449 struct cmd_config_rxtx_ring_size *res = parsed_result; 2450 struct rte_port *port; 2451 uint8_t isrx; 2452 2453 if (port_id_is_invalid(res->portid, ENABLED_WARN)) 2454 return; 2455 2456 if (res->portid == (portid_t)RTE_PORT_ALL) { 2457 printf("Invalid port id\n"); 2458 return; 2459 } 2460 2461 port = &ports[res->portid]; 2462 2463 if (!strcmp(res->rxtxq, "rxq")) 2464 isrx = 1; 2465 else if (!strcmp(res->rxtxq, "txq")) 2466 isrx = 0; 2467 else { 2468 printf("Unknown parameter\n"); 2469 return; 2470 } 2471 2472 if (isrx && rx_queue_id_is_invalid(res->qid)) 2473 return; 2474 else if (!isrx && tx_queue_id_is_invalid(res->qid)) 2475 return; 2476 2477 if (isrx && res->size != 0 && res->size <= rx_free_thresh) { 2478 printf("Invalid rx ring_size, must > rx_free_thresh: %d\n", 2479 rx_free_thresh); 2480 return; 2481 } 2482 2483 if (isrx) 2484 port->nb_rx_desc[res->qid] = res->size; 2485 else 2486 port->nb_tx_desc[res->qid] = res->size; 2487 2488 cmd_reconfig_device_queue(res->portid, 0, 1); 2489 } 2490 2491 cmdline_parse_token_string_t cmd_config_rxtx_ring_size_port = 2492 TOKEN_STRING_INITIALIZER(struct cmd_config_rxtx_ring_size, 2493 port, "port"); 2494 cmdline_parse_token_string_t cmd_config_rxtx_ring_size_config = 2495 TOKEN_STRING_INITIALIZER(struct cmd_config_rxtx_ring_size, 2496 config, "config"); 2497 cmdline_parse_token_num_t cmd_config_rxtx_ring_size_portid = 2498 TOKEN_NUM_INITIALIZER(struct cmd_config_rxtx_ring_size, 2499 portid, RTE_UINT16); 2500 cmdline_parse_token_string_t cmd_config_rxtx_ring_size_rxtxq = 2501 TOKEN_STRING_INITIALIZER(struct cmd_config_rxtx_ring_size, 2502 rxtxq, "rxq#txq"); 2503 cmdline_parse_token_num_t cmd_config_rxtx_ring_size_qid = 2504 TOKEN_NUM_INITIALIZER(struct cmd_config_rxtx_ring_size, 2505 qid, RTE_UINT16); 2506 cmdline_parse_token_string_t cmd_config_rxtx_ring_size_rsize = 2507 TOKEN_STRING_INITIALIZER(struct cmd_config_rxtx_ring_size, 2508 rsize, "ring_size"); 2509 cmdline_parse_token_num_t cmd_config_rxtx_ring_size_size = 2510 TOKEN_NUM_INITIALIZER(struct cmd_config_rxtx_ring_size, 2511 size, RTE_UINT16); 2512 2513 cmdline_parse_inst_t cmd_config_rxtx_ring_size = { 2514 .f = cmd_config_rxtx_ring_size_parsed, 2515 .data = NULL, 2516 .help_str = "port config <port_id> rxq|txq <queue_id> ring_size <value>", 2517 .tokens = { 2518 (void *)&cmd_config_rxtx_ring_size_port, 2519 (void *)&cmd_config_rxtx_ring_size_config, 2520 (void *)&cmd_config_rxtx_ring_size_portid, 2521 (void *)&cmd_config_rxtx_ring_size_rxtxq, 2522 (void *)&cmd_config_rxtx_ring_size_qid, 2523 (void *)&cmd_config_rxtx_ring_size_rsize, 2524 (void *)&cmd_config_rxtx_ring_size_size, 2525 NULL, 2526 }, 2527 }; 2528 2529 /* *** configure port rxq/txq start/stop *** */ 2530 struct cmd_config_rxtx_queue { 2531 cmdline_fixed_string_t port; 2532 portid_t portid; 2533 cmdline_fixed_string_t rxtxq; 2534 uint16_t qid; 2535 cmdline_fixed_string_t opname; 2536 }; 2537 2538 static void 2539 cmd_config_rxtx_queue_parsed(void *parsed_result, 2540 __rte_unused struct cmdline *cl, 2541 __rte_unused void *data) 2542 { 2543 struct cmd_config_rxtx_queue *res = parsed_result; 2544 uint8_t isrx; 2545 uint8_t isstart; 2546 int ret = 0; 2547 2548 if (test_done == 0) { 2549 printf("Please stop forwarding first\n"); 2550 return; 2551 } 2552 2553 if (port_id_is_invalid(res->portid, ENABLED_WARN)) 2554 return; 2555 2556 if (port_is_started(res->portid) != 1) { 2557 printf("Please start port %u first\n", res->portid); 2558 return; 2559 } 2560 2561 if (!strcmp(res->rxtxq, "rxq")) 2562 isrx = 1; 2563 else if (!strcmp(res->rxtxq, "txq")) 2564 isrx = 0; 2565 else { 2566 printf("Unknown parameter\n"); 2567 return; 2568 } 2569 2570 if (isrx && rx_queue_id_is_invalid(res->qid)) 2571 return; 2572 else if (!isrx && tx_queue_id_is_invalid(res->qid)) 2573 return; 2574 2575 if (!strcmp(res->opname, "start")) 2576 isstart = 1; 2577 else if (!strcmp(res->opname, "stop")) 2578 isstart = 0; 2579 else { 2580 printf("Unknown parameter\n"); 2581 return; 2582 } 2583 2584 if (isstart && isrx) 2585 ret = rte_eth_dev_rx_queue_start(res->portid, res->qid); 2586 else if (!isstart && isrx) 2587 ret = rte_eth_dev_rx_queue_stop(res->portid, res->qid); 2588 else if (isstart && !isrx) 2589 ret = rte_eth_dev_tx_queue_start(res->portid, res->qid); 2590 else 2591 ret = rte_eth_dev_tx_queue_stop(res->portid, res->qid); 2592 2593 if (ret == -ENOTSUP) 2594 printf("Function not supported in PMD driver\n"); 2595 } 2596 2597 cmdline_parse_token_string_t cmd_config_rxtx_queue_port = 2598 TOKEN_STRING_INITIALIZER(struct cmd_config_rxtx_queue, port, "port"); 2599 cmdline_parse_token_num_t cmd_config_rxtx_queue_portid = 2600 TOKEN_NUM_INITIALIZER(struct cmd_config_rxtx_queue, portid, RTE_UINT16); 2601 cmdline_parse_token_string_t cmd_config_rxtx_queue_rxtxq = 2602 TOKEN_STRING_INITIALIZER(struct cmd_config_rxtx_queue, rxtxq, "rxq#txq"); 2603 cmdline_parse_token_num_t cmd_config_rxtx_queue_qid = 2604 TOKEN_NUM_INITIALIZER(struct cmd_config_rxtx_queue, qid, RTE_UINT16); 2605 cmdline_parse_token_string_t cmd_config_rxtx_queue_opname = 2606 TOKEN_STRING_INITIALIZER(struct cmd_config_rxtx_queue, opname, 2607 "start#stop"); 2608 2609 cmdline_parse_inst_t cmd_config_rxtx_queue = { 2610 .f = cmd_config_rxtx_queue_parsed, 2611 .data = NULL, 2612 .help_str = "port <port_id> rxq|txq <queue_id> start|stop", 2613 .tokens = { 2614 (void *)&cmd_config_rxtx_queue_port, 2615 (void *)&cmd_config_rxtx_queue_portid, 2616 (void *)&cmd_config_rxtx_queue_rxtxq, 2617 (void *)&cmd_config_rxtx_queue_qid, 2618 (void *)&cmd_config_rxtx_queue_opname, 2619 NULL, 2620 }, 2621 }; 2622 2623 /* *** configure port rxq/txq deferred start on/off *** */ 2624 struct cmd_config_deferred_start_rxtx_queue { 2625 cmdline_fixed_string_t port; 2626 portid_t port_id; 2627 cmdline_fixed_string_t rxtxq; 2628 uint16_t qid; 2629 cmdline_fixed_string_t opname; 2630 cmdline_fixed_string_t state; 2631 }; 2632 2633 static void 2634 cmd_config_deferred_start_rxtx_queue_parsed(void *parsed_result, 2635 __rte_unused struct cmdline *cl, 2636 __rte_unused void *data) 2637 { 2638 struct cmd_config_deferred_start_rxtx_queue *res = parsed_result; 2639 struct rte_port *port; 2640 uint8_t isrx; 2641 uint8_t ison; 2642 uint8_t needreconfig = 0; 2643 2644 if (port_id_is_invalid(res->port_id, ENABLED_WARN)) 2645 return; 2646 2647 if (port_is_started(res->port_id) != 0) { 2648 printf("Please stop port %u first\n", res->port_id); 2649 return; 2650 } 2651 2652 port = &ports[res->port_id]; 2653 2654 isrx = !strcmp(res->rxtxq, "rxq"); 2655 2656 if (isrx && rx_queue_id_is_invalid(res->qid)) 2657 return; 2658 else if (!isrx && tx_queue_id_is_invalid(res->qid)) 2659 return; 2660 2661 ison = !strcmp(res->state, "on"); 2662 2663 if (isrx && port->rx_conf[res->qid].rx_deferred_start != ison) { 2664 port->rx_conf[res->qid].rx_deferred_start = ison; 2665 needreconfig = 1; 2666 } else if (!isrx && port->tx_conf[res->qid].tx_deferred_start != ison) { 2667 port->tx_conf[res->qid].tx_deferred_start = ison; 2668 needreconfig = 1; 2669 } 2670 2671 if (needreconfig) 2672 cmd_reconfig_device_queue(res->port_id, 0, 1); 2673 } 2674 2675 cmdline_parse_token_string_t cmd_config_deferred_start_rxtx_queue_port = 2676 TOKEN_STRING_INITIALIZER(struct cmd_config_deferred_start_rxtx_queue, 2677 port, "port"); 2678 cmdline_parse_token_num_t cmd_config_deferred_start_rxtx_queue_port_id = 2679 TOKEN_NUM_INITIALIZER(struct cmd_config_deferred_start_rxtx_queue, 2680 port_id, RTE_UINT16); 2681 cmdline_parse_token_string_t cmd_config_deferred_start_rxtx_queue_rxtxq = 2682 TOKEN_STRING_INITIALIZER(struct cmd_config_deferred_start_rxtx_queue, 2683 rxtxq, "rxq#txq"); 2684 cmdline_parse_token_num_t cmd_config_deferred_start_rxtx_queue_qid = 2685 TOKEN_NUM_INITIALIZER(struct cmd_config_deferred_start_rxtx_queue, 2686 qid, RTE_UINT16); 2687 cmdline_parse_token_string_t cmd_config_deferred_start_rxtx_queue_opname = 2688 TOKEN_STRING_INITIALIZER(struct cmd_config_deferred_start_rxtx_queue, 2689 opname, "deferred_start"); 2690 cmdline_parse_token_string_t cmd_config_deferred_start_rxtx_queue_state = 2691 TOKEN_STRING_INITIALIZER(struct cmd_config_deferred_start_rxtx_queue, 2692 state, "on#off"); 2693 2694 cmdline_parse_inst_t cmd_config_deferred_start_rxtx_queue = { 2695 .f = cmd_config_deferred_start_rxtx_queue_parsed, 2696 .data = NULL, 2697 .help_str = "port <port_id> rxq|txq <queue_id> deferred_start on|off", 2698 .tokens = { 2699 (void *)&cmd_config_deferred_start_rxtx_queue_port, 2700 (void *)&cmd_config_deferred_start_rxtx_queue_port_id, 2701 (void *)&cmd_config_deferred_start_rxtx_queue_rxtxq, 2702 (void *)&cmd_config_deferred_start_rxtx_queue_qid, 2703 (void *)&cmd_config_deferred_start_rxtx_queue_opname, 2704 (void *)&cmd_config_deferred_start_rxtx_queue_state, 2705 NULL, 2706 }, 2707 }; 2708 2709 /* *** configure port rxq/txq setup *** */ 2710 struct cmd_setup_rxtx_queue { 2711 cmdline_fixed_string_t port; 2712 portid_t portid; 2713 cmdline_fixed_string_t rxtxq; 2714 uint16_t qid; 2715 cmdline_fixed_string_t setup; 2716 }; 2717 2718 /* Common CLI fields for queue setup */ 2719 cmdline_parse_token_string_t cmd_setup_rxtx_queue_port = 2720 TOKEN_STRING_INITIALIZER(struct cmd_setup_rxtx_queue, port, "port"); 2721 cmdline_parse_token_num_t cmd_setup_rxtx_queue_portid = 2722 TOKEN_NUM_INITIALIZER(struct cmd_setup_rxtx_queue, portid, RTE_UINT16); 2723 cmdline_parse_token_string_t cmd_setup_rxtx_queue_rxtxq = 2724 TOKEN_STRING_INITIALIZER(struct cmd_setup_rxtx_queue, rxtxq, "rxq#txq"); 2725 cmdline_parse_token_num_t cmd_setup_rxtx_queue_qid = 2726 TOKEN_NUM_INITIALIZER(struct cmd_setup_rxtx_queue, qid, RTE_UINT16); 2727 cmdline_parse_token_string_t cmd_setup_rxtx_queue_setup = 2728 TOKEN_STRING_INITIALIZER(struct cmd_setup_rxtx_queue, setup, "setup"); 2729 2730 static void 2731 cmd_setup_rxtx_queue_parsed( 2732 void *parsed_result, 2733 __rte_unused struct cmdline *cl, 2734 __rte_unused void *data) 2735 { 2736 struct cmd_setup_rxtx_queue *res = parsed_result; 2737 struct rte_port *port; 2738 struct rte_mempool *mp; 2739 unsigned int socket_id; 2740 uint8_t isrx = 0; 2741 int ret; 2742 2743 if (port_id_is_invalid(res->portid, ENABLED_WARN)) 2744 return; 2745 2746 if (res->portid == (portid_t)RTE_PORT_ALL) { 2747 printf("Invalid port id\n"); 2748 return; 2749 } 2750 2751 if (!strcmp(res->rxtxq, "rxq")) 2752 isrx = 1; 2753 else if (!strcmp(res->rxtxq, "txq")) 2754 isrx = 0; 2755 else { 2756 printf("Unknown parameter\n"); 2757 return; 2758 } 2759 2760 if (isrx && rx_queue_id_is_invalid(res->qid)) { 2761 printf("Invalid rx queue\n"); 2762 return; 2763 } else if (!isrx && tx_queue_id_is_invalid(res->qid)) { 2764 printf("Invalid tx queue\n"); 2765 return; 2766 } 2767 2768 port = &ports[res->portid]; 2769 if (isrx) { 2770 socket_id = rxring_numa[res->portid]; 2771 if (!numa_support || socket_id == NUMA_NO_CONFIG) 2772 socket_id = port->socket_id; 2773 2774 mp = mbuf_pool_find(socket_id, 0); 2775 if (mp == NULL) { 2776 printf("Failed to setup RX queue: " 2777 "No mempool allocation" 2778 " on the socket %d\n", 2779 rxring_numa[res->portid]); 2780 return; 2781 } 2782 ret = rx_queue_setup(res->portid, 2783 res->qid, 2784 port->nb_rx_desc[res->qid], 2785 socket_id, 2786 &port->rx_conf[res->qid], 2787 mp); 2788 if (ret) 2789 printf("Failed to setup RX queue\n"); 2790 } else { 2791 socket_id = txring_numa[res->portid]; 2792 if (!numa_support || socket_id == NUMA_NO_CONFIG) 2793 socket_id = port->socket_id; 2794 2795 ret = rte_eth_tx_queue_setup(res->portid, 2796 res->qid, 2797 port->nb_tx_desc[res->qid], 2798 socket_id, 2799 &port->tx_conf[res->qid]); 2800 if (ret) 2801 printf("Failed to setup TX queue\n"); 2802 } 2803 } 2804 2805 cmdline_parse_inst_t cmd_setup_rxtx_queue = { 2806 .f = cmd_setup_rxtx_queue_parsed, 2807 .data = NULL, 2808 .help_str = "port <port_id> rxq|txq <queue_idx> setup", 2809 .tokens = { 2810 (void *)&cmd_setup_rxtx_queue_port, 2811 (void *)&cmd_setup_rxtx_queue_portid, 2812 (void *)&cmd_setup_rxtx_queue_rxtxq, 2813 (void *)&cmd_setup_rxtx_queue_qid, 2814 (void *)&cmd_setup_rxtx_queue_setup, 2815 NULL, 2816 }, 2817 }; 2818 2819 2820 /* *** Configure RSS RETA *** */ 2821 struct cmd_config_rss_reta { 2822 cmdline_fixed_string_t port; 2823 cmdline_fixed_string_t keyword; 2824 portid_t port_id; 2825 cmdline_fixed_string_t name; 2826 cmdline_fixed_string_t list_name; 2827 cmdline_fixed_string_t list_of_items; 2828 }; 2829 2830 static int 2831 parse_reta_config(const char *str, 2832 struct rte_eth_rss_reta_entry64 *reta_conf, 2833 uint16_t nb_entries) 2834 { 2835 int i; 2836 unsigned size; 2837 uint16_t hash_index, idx, shift; 2838 uint16_t nb_queue; 2839 char s[256]; 2840 const char *p, *p0 = str; 2841 char *end; 2842 enum fieldnames { 2843 FLD_HASH_INDEX = 0, 2844 FLD_QUEUE, 2845 _NUM_FLD 2846 }; 2847 unsigned long int_fld[_NUM_FLD]; 2848 char *str_fld[_NUM_FLD]; 2849 2850 while ((p = strchr(p0,'(')) != NULL) { 2851 ++p; 2852 if((p0 = strchr(p,')')) == NULL) 2853 return -1; 2854 2855 size = p0 - p; 2856 if(size >= sizeof(s)) 2857 return -1; 2858 2859 snprintf(s, sizeof(s), "%.*s", size, p); 2860 if (rte_strsplit(s, sizeof(s), str_fld, _NUM_FLD, ',') != _NUM_FLD) 2861 return -1; 2862 for (i = 0; i < _NUM_FLD; i++) { 2863 errno = 0; 2864 int_fld[i] = strtoul(str_fld[i], &end, 0); 2865 if (errno != 0 || end == str_fld[i] || 2866 int_fld[i] > 65535) 2867 return -1; 2868 } 2869 2870 hash_index = (uint16_t)int_fld[FLD_HASH_INDEX]; 2871 nb_queue = (uint16_t)int_fld[FLD_QUEUE]; 2872 2873 if (hash_index >= nb_entries) { 2874 printf("Invalid RETA hash index=%d\n", hash_index); 2875 return -1; 2876 } 2877 2878 idx = hash_index / RTE_RETA_GROUP_SIZE; 2879 shift = hash_index % RTE_RETA_GROUP_SIZE; 2880 reta_conf[idx].mask |= (1ULL << shift); 2881 reta_conf[idx].reta[shift] = nb_queue; 2882 } 2883 2884 return 0; 2885 } 2886 2887 static void 2888 cmd_set_rss_reta_parsed(void *parsed_result, 2889 __rte_unused struct cmdline *cl, 2890 __rte_unused void *data) 2891 { 2892 int ret; 2893 struct rte_eth_dev_info dev_info; 2894 struct rte_eth_rss_reta_entry64 reta_conf[8]; 2895 struct cmd_config_rss_reta *res = parsed_result; 2896 2897 ret = eth_dev_info_get_print_err(res->port_id, &dev_info); 2898 if (ret != 0) 2899 return; 2900 2901 if (dev_info.reta_size == 0) { 2902 printf("Redirection table size is 0 which is " 2903 "invalid for RSS\n"); 2904 return; 2905 } else 2906 printf("The reta size of port %d is %u\n", 2907 res->port_id, dev_info.reta_size); 2908 if (dev_info.reta_size > ETH_RSS_RETA_SIZE_512) { 2909 printf("Currently do not support more than %u entries of " 2910 "redirection table\n", ETH_RSS_RETA_SIZE_512); 2911 return; 2912 } 2913 2914 memset(reta_conf, 0, sizeof(reta_conf)); 2915 if (!strcmp(res->list_name, "reta")) { 2916 if (parse_reta_config(res->list_of_items, reta_conf, 2917 dev_info.reta_size)) { 2918 printf("Invalid RSS Redirection Table " 2919 "config entered\n"); 2920 return; 2921 } 2922 ret = rte_eth_dev_rss_reta_update(res->port_id, 2923 reta_conf, dev_info.reta_size); 2924 if (ret != 0) 2925 printf("Bad redirection table parameter, " 2926 "return code = %d \n", ret); 2927 } 2928 } 2929 2930 cmdline_parse_token_string_t cmd_config_rss_reta_port = 2931 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_reta, port, "port"); 2932 cmdline_parse_token_string_t cmd_config_rss_reta_keyword = 2933 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_reta, keyword, "config"); 2934 cmdline_parse_token_num_t cmd_config_rss_reta_port_id = 2935 TOKEN_NUM_INITIALIZER(struct cmd_config_rss_reta, port_id, RTE_UINT16); 2936 cmdline_parse_token_string_t cmd_config_rss_reta_name = 2937 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_reta, name, "rss"); 2938 cmdline_parse_token_string_t cmd_config_rss_reta_list_name = 2939 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_reta, list_name, "reta"); 2940 cmdline_parse_token_string_t cmd_config_rss_reta_list_of_items = 2941 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_reta, list_of_items, 2942 NULL); 2943 cmdline_parse_inst_t cmd_config_rss_reta = { 2944 .f = cmd_set_rss_reta_parsed, 2945 .data = NULL, 2946 .help_str = "port config <port_id> rss reta <hash,queue[,hash,queue]*>", 2947 .tokens = { 2948 (void *)&cmd_config_rss_reta_port, 2949 (void *)&cmd_config_rss_reta_keyword, 2950 (void *)&cmd_config_rss_reta_port_id, 2951 (void *)&cmd_config_rss_reta_name, 2952 (void *)&cmd_config_rss_reta_list_name, 2953 (void *)&cmd_config_rss_reta_list_of_items, 2954 NULL, 2955 }, 2956 }; 2957 2958 /* *** SHOW PORT RETA INFO *** */ 2959 struct cmd_showport_reta { 2960 cmdline_fixed_string_t show; 2961 cmdline_fixed_string_t port; 2962 portid_t port_id; 2963 cmdline_fixed_string_t rss; 2964 cmdline_fixed_string_t reta; 2965 uint16_t size; 2966 cmdline_fixed_string_t list_of_items; 2967 }; 2968 2969 static int 2970 showport_parse_reta_config(struct rte_eth_rss_reta_entry64 *conf, 2971 uint16_t nb_entries, 2972 char *str) 2973 { 2974 uint32_t size; 2975 const char *p, *p0 = str; 2976 char s[256]; 2977 char *end; 2978 char *str_fld[8]; 2979 uint16_t i; 2980 uint16_t num = (nb_entries + RTE_RETA_GROUP_SIZE - 1) / 2981 RTE_RETA_GROUP_SIZE; 2982 int ret; 2983 2984 p = strchr(p0, '('); 2985 if (p == NULL) 2986 return -1; 2987 p++; 2988 p0 = strchr(p, ')'); 2989 if (p0 == NULL) 2990 return -1; 2991 size = p0 - p; 2992 if (size >= sizeof(s)) { 2993 printf("The string size exceeds the internal buffer size\n"); 2994 return -1; 2995 } 2996 snprintf(s, sizeof(s), "%.*s", size, p); 2997 ret = rte_strsplit(s, sizeof(s), str_fld, num, ','); 2998 if (ret <= 0 || ret != num) { 2999 printf("The bits of masks do not match the number of " 3000 "reta entries: %u\n", num); 3001 return -1; 3002 } 3003 for (i = 0; i < ret; i++) 3004 conf[i].mask = (uint64_t)strtoul(str_fld[i], &end, 0); 3005 3006 return 0; 3007 } 3008 3009 static void 3010 cmd_showport_reta_parsed(void *parsed_result, 3011 __rte_unused struct cmdline *cl, 3012 __rte_unused void *data) 3013 { 3014 struct cmd_showport_reta *res = parsed_result; 3015 struct rte_eth_rss_reta_entry64 reta_conf[8]; 3016 struct rte_eth_dev_info dev_info; 3017 uint16_t max_reta_size; 3018 int ret; 3019 3020 ret = eth_dev_info_get_print_err(res->port_id, &dev_info); 3021 if (ret != 0) 3022 return; 3023 3024 max_reta_size = RTE_MIN(dev_info.reta_size, ETH_RSS_RETA_SIZE_512); 3025 if (res->size == 0 || res->size > max_reta_size) { 3026 printf("Invalid redirection table size: %u (1-%u)\n", 3027 res->size, max_reta_size); 3028 return; 3029 } 3030 3031 memset(reta_conf, 0, sizeof(reta_conf)); 3032 if (showport_parse_reta_config(reta_conf, res->size, 3033 res->list_of_items) < 0) { 3034 printf("Invalid string: %s for reta masks\n", 3035 res->list_of_items); 3036 return; 3037 } 3038 port_rss_reta_info(res->port_id, reta_conf, res->size); 3039 } 3040 3041 cmdline_parse_token_string_t cmd_showport_reta_show = 3042 TOKEN_STRING_INITIALIZER(struct cmd_showport_reta, show, "show"); 3043 cmdline_parse_token_string_t cmd_showport_reta_port = 3044 TOKEN_STRING_INITIALIZER(struct cmd_showport_reta, port, "port"); 3045 cmdline_parse_token_num_t cmd_showport_reta_port_id = 3046 TOKEN_NUM_INITIALIZER(struct cmd_showport_reta, port_id, RTE_UINT16); 3047 cmdline_parse_token_string_t cmd_showport_reta_rss = 3048 TOKEN_STRING_INITIALIZER(struct cmd_showport_reta, rss, "rss"); 3049 cmdline_parse_token_string_t cmd_showport_reta_reta = 3050 TOKEN_STRING_INITIALIZER(struct cmd_showport_reta, reta, "reta"); 3051 cmdline_parse_token_num_t cmd_showport_reta_size = 3052 TOKEN_NUM_INITIALIZER(struct cmd_showport_reta, size, RTE_UINT16); 3053 cmdline_parse_token_string_t cmd_showport_reta_list_of_items = 3054 TOKEN_STRING_INITIALIZER(struct cmd_showport_reta, 3055 list_of_items, NULL); 3056 3057 cmdline_parse_inst_t cmd_showport_reta = { 3058 .f = cmd_showport_reta_parsed, 3059 .data = NULL, 3060 .help_str = "show port <port_id> rss reta <size> <mask0[,mask1]*>", 3061 .tokens = { 3062 (void *)&cmd_showport_reta_show, 3063 (void *)&cmd_showport_reta_port, 3064 (void *)&cmd_showport_reta_port_id, 3065 (void *)&cmd_showport_reta_rss, 3066 (void *)&cmd_showport_reta_reta, 3067 (void *)&cmd_showport_reta_size, 3068 (void *)&cmd_showport_reta_list_of_items, 3069 NULL, 3070 }, 3071 }; 3072 3073 /* *** Show RSS hash configuration *** */ 3074 struct cmd_showport_rss_hash { 3075 cmdline_fixed_string_t show; 3076 cmdline_fixed_string_t port; 3077 portid_t port_id; 3078 cmdline_fixed_string_t rss_hash; 3079 cmdline_fixed_string_t rss_type; 3080 cmdline_fixed_string_t key; /* optional argument */ 3081 }; 3082 3083 static void cmd_showport_rss_hash_parsed(void *parsed_result, 3084 __rte_unused struct cmdline *cl, 3085 void *show_rss_key) 3086 { 3087 struct cmd_showport_rss_hash *res = parsed_result; 3088 3089 port_rss_hash_conf_show(res->port_id, show_rss_key != NULL); 3090 } 3091 3092 cmdline_parse_token_string_t cmd_showport_rss_hash_show = 3093 TOKEN_STRING_INITIALIZER(struct cmd_showport_rss_hash, show, "show"); 3094 cmdline_parse_token_string_t cmd_showport_rss_hash_port = 3095 TOKEN_STRING_INITIALIZER(struct cmd_showport_rss_hash, port, "port"); 3096 cmdline_parse_token_num_t cmd_showport_rss_hash_port_id = 3097 TOKEN_NUM_INITIALIZER(struct cmd_showport_rss_hash, port_id, 3098 RTE_UINT16); 3099 cmdline_parse_token_string_t cmd_showport_rss_hash_rss_hash = 3100 TOKEN_STRING_INITIALIZER(struct cmd_showport_rss_hash, rss_hash, 3101 "rss-hash"); 3102 cmdline_parse_token_string_t cmd_showport_rss_hash_rss_key = 3103 TOKEN_STRING_INITIALIZER(struct cmd_showport_rss_hash, key, "key"); 3104 3105 cmdline_parse_inst_t cmd_showport_rss_hash = { 3106 .f = cmd_showport_rss_hash_parsed, 3107 .data = NULL, 3108 .help_str = "show port <port_id> rss-hash", 3109 .tokens = { 3110 (void *)&cmd_showport_rss_hash_show, 3111 (void *)&cmd_showport_rss_hash_port, 3112 (void *)&cmd_showport_rss_hash_port_id, 3113 (void *)&cmd_showport_rss_hash_rss_hash, 3114 NULL, 3115 }, 3116 }; 3117 3118 cmdline_parse_inst_t cmd_showport_rss_hash_key = { 3119 .f = cmd_showport_rss_hash_parsed, 3120 .data = (void *)1, 3121 .help_str = "show port <port_id> rss-hash key", 3122 .tokens = { 3123 (void *)&cmd_showport_rss_hash_show, 3124 (void *)&cmd_showport_rss_hash_port, 3125 (void *)&cmd_showport_rss_hash_port_id, 3126 (void *)&cmd_showport_rss_hash_rss_hash, 3127 (void *)&cmd_showport_rss_hash_rss_key, 3128 NULL, 3129 }, 3130 }; 3131 3132 /* *** Configure DCB *** */ 3133 struct cmd_config_dcb { 3134 cmdline_fixed_string_t port; 3135 cmdline_fixed_string_t config; 3136 portid_t port_id; 3137 cmdline_fixed_string_t dcb; 3138 cmdline_fixed_string_t vt; 3139 cmdline_fixed_string_t vt_en; 3140 uint8_t num_tcs; 3141 cmdline_fixed_string_t pfc; 3142 cmdline_fixed_string_t pfc_en; 3143 }; 3144 3145 static void 3146 cmd_config_dcb_parsed(void *parsed_result, 3147 __rte_unused struct cmdline *cl, 3148 __rte_unused void *data) 3149 { 3150 struct cmd_config_dcb *res = parsed_result; 3151 portid_t port_id = res->port_id; 3152 struct rte_port *port; 3153 uint8_t pfc_en; 3154 int ret; 3155 3156 port = &ports[port_id]; 3157 /** Check if the port is not started **/ 3158 if (port->port_status != RTE_PORT_STOPPED) { 3159 printf("Please stop port %d first\n", port_id); 3160 return; 3161 } 3162 3163 if ((res->num_tcs != ETH_4_TCS) && (res->num_tcs != ETH_8_TCS)) { 3164 printf("The invalid number of traffic class," 3165 " only 4 or 8 allowed.\n"); 3166 return; 3167 } 3168 3169 if (nb_fwd_lcores < res->num_tcs) { 3170 printf("nb_cores shouldn't be less than number of TCs.\n"); 3171 return; 3172 } 3173 if (!strncmp(res->pfc_en, "on", 2)) 3174 pfc_en = 1; 3175 else 3176 pfc_en = 0; 3177 3178 /* DCB in VT mode */ 3179 if (!strncmp(res->vt_en, "on", 2)) 3180 ret = init_port_dcb_config(port_id, DCB_VT_ENABLED, 3181 (enum rte_eth_nb_tcs)res->num_tcs, 3182 pfc_en); 3183 else 3184 ret = init_port_dcb_config(port_id, DCB_ENABLED, 3185 (enum rte_eth_nb_tcs)res->num_tcs, 3186 pfc_en); 3187 3188 3189 if (ret != 0) { 3190 printf("Cannot initialize network ports.\n"); 3191 return; 3192 } 3193 3194 cmd_reconfig_device_queue(port_id, 1, 1); 3195 } 3196 3197 cmdline_parse_token_string_t cmd_config_dcb_port = 3198 TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, port, "port"); 3199 cmdline_parse_token_string_t cmd_config_dcb_config = 3200 TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, config, "config"); 3201 cmdline_parse_token_num_t cmd_config_dcb_port_id = 3202 TOKEN_NUM_INITIALIZER(struct cmd_config_dcb, port_id, RTE_UINT16); 3203 cmdline_parse_token_string_t cmd_config_dcb_dcb = 3204 TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, dcb, "dcb"); 3205 cmdline_parse_token_string_t cmd_config_dcb_vt = 3206 TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, vt, "vt"); 3207 cmdline_parse_token_string_t cmd_config_dcb_vt_en = 3208 TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, vt_en, "on#off"); 3209 cmdline_parse_token_num_t cmd_config_dcb_num_tcs = 3210 TOKEN_NUM_INITIALIZER(struct cmd_config_dcb, num_tcs, RTE_UINT8); 3211 cmdline_parse_token_string_t cmd_config_dcb_pfc= 3212 TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, pfc, "pfc"); 3213 cmdline_parse_token_string_t cmd_config_dcb_pfc_en = 3214 TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, pfc_en, "on#off"); 3215 3216 cmdline_parse_inst_t cmd_config_dcb = { 3217 .f = cmd_config_dcb_parsed, 3218 .data = NULL, 3219 .help_str = "port config <port-id> dcb vt on|off <num_tcs> pfc on|off", 3220 .tokens = { 3221 (void *)&cmd_config_dcb_port, 3222 (void *)&cmd_config_dcb_config, 3223 (void *)&cmd_config_dcb_port_id, 3224 (void *)&cmd_config_dcb_dcb, 3225 (void *)&cmd_config_dcb_vt, 3226 (void *)&cmd_config_dcb_vt_en, 3227 (void *)&cmd_config_dcb_num_tcs, 3228 (void *)&cmd_config_dcb_pfc, 3229 (void *)&cmd_config_dcb_pfc_en, 3230 NULL, 3231 }, 3232 }; 3233 3234 /* *** configure number of packets per burst *** */ 3235 struct cmd_config_burst { 3236 cmdline_fixed_string_t port; 3237 cmdline_fixed_string_t keyword; 3238 cmdline_fixed_string_t all; 3239 cmdline_fixed_string_t name; 3240 uint16_t value; 3241 }; 3242 3243 static void 3244 cmd_config_burst_parsed(void *parsed_result, 3245 __rte_unused struct cmdline *cl, 3246 __rte_unused void *data) 3247 { 3248 struct cmd_config_burst *res = parsed_result; 3249 struct rte_eth_dev_info dev_info; 3250 uint16_t rec_nb_pkts; 3251 int ret; 3252 3253 if (!all_ports_stopped()) { 3254 printf("Please stop all ports first\n"); 3255 return; 3256 } 3257 3258 if (!strcmp(res->name, "burst")) { 3259 if (res->value == 0) { 3260 /* If user gives a value of zero, query the PMD for 3261 * its recommended Rx burst size. Testpmd uses a single 3262 * size for all ports, so assume all ports are the same 3263 * NIC model and use the values from Port 0. 3264 */ 3265 ret = eth_dev_info_get_print_err(0, &dev_info); 3266 if (ret != 0) 3267 return; 3268 3269 rec_nb_pkts = dev_info.default_rxportconf.burst_size; 3270 3271 if (rec_nb_pkts == 0) { 3272 printf("PMD does not recommend a burst size.\n" 3273 "User provided value must be between" 3274 " 1 and %d\n", MAX_PKT_BURST); 3275 return; 3276 } else if (rec_nb_pkts > MAX_PKT_BURST) { 3277 printf("PMD recommended burst size of %d" 3278 " exceeds maximum value of %d\n", 3279 rec_nb_pkts, MAX_PKT_BURST); 3280 return; 3281 } 3282 printf("Using PMD-provided burst value of %d\n", 3283 rec_nb_pkts); 3284 nb_pkt_per_burst = rec_nb_pkts; 3285 } else if (res->value > MAX_PKT_BURST) { 3286 printf("burst must be >= 1 && <= %d\n", MAX_PKT_BURST); 3287 return; 3288 } else 3289 nb_pkt_per_burst = res->value; 3290 } else { 3291 printf("Unknown parameter\n"); 3292 return; 3293 } 3294 3295 init_port_config(); 3296 3297 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1); 3298 } 3299 3300 cmdline_parse_token_string_t cmd_config_burst_port = 3301 TOKEN_STRING_INITIALIZER(struct cmd_config_burst, port, "port"); 3302 cmdline_parse_token_string_t cmd_config_burst_keyword = 3303 TOKEN_STRING_INITIALIZER(struct cmd_config_burst, keyword, "config"); 3304 cmdline_parse_token_string_t cmd_config_burst_all = 3305 TOKEN_STRING_INITIALIZER(struct cmd_config_burst, all, "all"); 3306 cmdline_parse_token_string_t cmd_config_burst_name = 3307 TOKEN_STRING_INITIALIZER(struct cmd_config_burst, name, "burst"); 3308 cmdline_parse_token_num_t cmd_config_burst_value = 3309 TOKEN_NUM_INITIALIZER(struct cmd_config_burst, value, RTE_UINT16); 3310 3311 cmdline_parse_inst_t cmd_config_burst = { 3312 .f = cmd_config_burst_parsed, 3313 .data = NULL, 3314 .help_str = "port config all burst <value>", 3315 .tokens = { 3316 (void *)&cmd_config_burst_port, 3317 (void *)&cmd_config_burst_keyword, 3318 (void *)&cmd_config_burst_all, 3319 (void *)&cmd_config_burst_name, 3320 (void *)&cmd_config_burst_value, 3321 NULL, 3322 }, 3323 }; 3324 3325 /* *** configure rx/tx queues *** */ 3326 struct cmd_config_thresh { 3327 cmdline_fixed_string_t port; 3328 cmdline_fixed_string_t keyword; 3329 cmdline_fixed_string_t all; 3330 cmdline_fixed_string_t name; 3331 uint8_t value; 3332 }; 3333 3334 static void 3335 cmd_config_thresh_parsed(void *parsed_result, 3336 __rte_unused struct cmdline *cl, 3337 __rte_unused void *data) 3338 { 3339 struct cmd_config_thresh *res = parsed_result; 3340 3341 if (!all_ports_stopped()) { 3342 printf("Please stop all ports first\n"); 3343 return; 3344 } 3345 3346 if (!strcmp(res->name, "txpt")) 3347 tx_pthresh = res->value; 3348 else if(!strcmp(res->name, "txht")) 3349 tx_hthresh = res->value; 3350 else if(!strcmp(res->name, "txwt")) 3351 tx_wthresh = res->value; 3352 else if(!strcmp(res->name, "rxpt")) 3353 rx_pthresh = res->value; 3354 else if(!strcmp(res->name, "rxht")) 3355 rx_hthresh = res->value; 3356 else if(!strcmp(res->name, "rxwt")) 3357 rx_wthresh = res->value; 3358 else { 3359 printf("Unknown parameter\n"); 3360 return; 3361 } 3362 3363 init_port_config(); 3364 3365 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1); 3366 } 3367 3368 cmdline_parse_token_string_t cmd_config_thresh_port = 3369 TOKEN_STRING_INITIALIZER(struct cmd_config_thresh, port, "port"); 3370 cmdline_parse_token_string_t cmd_config_thresh_keyword = 3371 TOKEN_STRING_INITIALIZER(struct cmd_config_thresh, keyword, "config"); 3372 cmdline_parse_token_string_t cmd_config_thresh_all = 3373 TOKEN_STRING_INITIALIZER(struct cmd_config_thresh, all, "all"); 3374 cmdline_parse_token_string_t cmd_config_thresh_name = 3375 TOKEN_STRING_INITIALIZER(struct cmd_config_thresh, name, 3376 "txpt#txht#txwt#rxpt#rxht#rxwt"); 3377 cmdline_parse_token_num_t cmd_config_thresh_value = 3378 TOKEN_NUM_INITIALIZER(struct cmd_config_thresh, value, RTE_UINT8); 3379 3380 cmdline_parse_inst_t cmd_config_thresh = { 3381 .f = cmd_config_thresh_parsed, 3382 .data = NULL, 3383 .help_str = "port config all txpt|txht|txwt|rxpt|rxht|rxwt <value>", 3384 .tokens = { 3385 (void *)&cmd_config_thresh_port, 3386 (void *)&cmd_config_thresh_keyword, 3387 (void *)&cmd_config_thresh_all, 3388 (void *)&cmd_config_thresh_name, 3389 (void *)&cmd_config_thresh_value, 3390 NULL, 3391 }, 3392 }; 3393 3394 /* *** configure free/rs threshold *** */ 3395 struct cmd_config_threshold { 3396 cmdline_fixed_string_t port; 3397 cmdline_fixed_string_t keyword; 3398 cmdline_fixed_string_t all; 3399 cmdline_fixed_string_t name; 3400 uint16_t value; 3401 }; 3402 3403 static void 3404 cmd_config_threshold_parsed(void *parsed_result, 3405 __rte_unused struct cmdline *cl, 3406 __rte_unused void *data) 3407 { 3408 struct cmd_config_threshold *res = parsed_result; 3409 3410 if (!all_ports_stopped()) { 3411 printf("Please stop all ports first\n"); 3412 return; 3413 } 3414 3415 if (!strcmp(res->name, "txfreet")) 3416 tx_free_thresh = res->value; 3417 else if (!strcmp(res->name, "txrst")) 3418 tx_rs_thresh = res->value; 3419 else if (!strcmp(res->name, "rxfreet")) 3420 rx_free_thresh = res->value; 3421 else { 3422 printf("Unknown parameter\n"); 3423 return; 3424 } 3425 3426 init_port_config(); 3427 3428 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1); 3429 } 3430 3431 cmdline_parse_token_string_t cmd_config_threshold_port = 3432 TOKEN_STRING_INITIALIZER(struct cmd_config_threshold, port, "port"); 3433 cmdline_parse_token_string_t cmd_config_threshold_keyword = 3434 TOKEN_STRING_INITIALIZER(struct cmd_config_threshold, keyword, 3435 "config"); 3436 cmdline_parse_token_string_t cmd_config_threshold_all = 3437 TOKEN_STRING_INITIALIZER(struct cmd_config_threshold, all, "all"); 3438 cmdline_parse_token_string_t cmd_config_threshold_name = 3439 TOKEN_STRING_INITIALIZER(struct cmd_config_threshold, name, 3440 "txfreet#txrst#rxfreet"); 3441 cmdline_parse_token_num_t cmd_config_threshold_value = 3442 TOKEN_NUM_INITIALIZER(struct cmd_config_threshold, value, RTE_UINT16); 3443 3444 cmdline_parse_inst_t cmd_config_threshold = { 3445 .f = cmd_config_threshold_parsed, 3446 .data = NULL, 3447 .help_str = "port config all txfreet|txrst|rxfreet <value>", 3448 .tokens = { 3449 (void *)&cmd_config_threshold_port, 3450 (void *)&cmd_config_threshold_keyword, 3451 (void *)&cmd_config_threshold_all, 3452 (void *)&cmd_config_threshold_name, 3453 (void *)&cmd_config_threshold_value, 3454 NULL, 3455 }, 3456 }; 3457 3458 /* *** stop *** */ 3459 struct cmd_stop_result { 3460 cmdline_fixed_string_t stop; 3461 }; 3462 3463 static void cmd_stop_parsed(__rte_unused void *parsed_result, 3464 __rte_unused struct cmdline *cl, 3465 __rte_unused void *data) 3466 { 3467 stop_packet_forwarding(); 3468 } 3469 3470 cmdline_parse_token_string_t cmd_stop_stop = 3471 TOKEN_STRING_INITIALIZER(struct cmd_stop_result, stop, "stop"); 3472 3473 cmdline_parse_inst_t cmd_stop = { 3474 .f = cmd_stop_parsed, 3475 .data = NULL, 3476 .help_str = "stop: Stop packet forwarding", 3477 .tokens = { 3478 (void *)&cmd_stop_stop, 3479 NULL, 3480 }, 3481 }; 3482 3483 /* *** SET CORELIST and PORTLIST CONFIGURATION *** */ 3484 3485 unsigned int 3486 parse_item_list(char* str, const char* item_name, unsigned int max_items, 3487 unsigned int *parsed_items, int check_unique_values) 3488 { 3489 unsigned int nb_item; 3490 unsigned int value; 3491 unsigned int i; 3492 unsigned int j; 3493 int value_ok; 3494 char c; 3495 3496 /* 3497 * First parse all items in the list and store their value. 3498 */ 3499 value = 0; 3500 nb_item = 0; 3501 value_ok = 0; 3502 for (i = 0; i < strnlen(str, STR_TOKEN_SIZE); i++) { 3503 c = str[i]; 3504 if ((c >= '0') && (c <= '9')) { 3505 value = (unsigned int) (value * 10 + (c - '0')); 3506 value_ok = 1; 3507 continue; 3508 } 3509 if (c != ',') { 3510 printf("character %c is not a decimal digit\n", c); 3511 return 0; 3512 } 3513 if (! value_ok) { 3514 printf("No valid value before comma\n"); 3515 return 0; 3516 } 3517 if (nb_item < max_items) { 3518 parsed_items[nb_item] = value; 3519 value_ok = 0; 3520 value = 0; 3521 } 3522 nb_item++; 3523 } 3524 if (nb_item >= max_items) { 3525 printf("Number of %s = %u > %u (maximum items)\n", 3526 item_name, nb_item + 1, max_items); 3527 return 0; 3528 } 3529 parsed_items[nb_item++] = value; 3530 if (! check_unique_values) 3531 return nb_item; 3532 3533 /* 3534 * Then, check that all values in the list are differents. 3535 * No optimization here... 3536 */ 3537 for (i = 0; i < nb_item; i++) { 3538 for (j = i + 1; j < nb_item; j++) { 3539 if (parsed_items[j] == parsed_items[i]) { 3540 printf("duplicated %s %u at index %u and %u\n", 3541 item_name, parsed_items[i], i, j); 3542 return 0; 3543 } 3544 } 3545 } 3546 return nb_item; 3547 } 3548 3549 struct cmd_set_list_result { 3550 cmdline_fixed_string_t cmd_keyword; 3551 cmdline_fixed_string_t list_name; 3552 cmdline_fixed_string_t list_of_items; 3553 }; 3554 3555 static void cmd_set_list_parsed(void *parsed_result, 3556 __rte_unused struct cmdline *cl, 3557 __rte_unused void *data) 3558 { 3559 struct cmd_set_list_result *res; 3560 union { 3561 unsigned int lcorelist[RTE_MAX_LCORE]; 3562 unsigned int portlist[RTE_MAX_ETHPORTS]; 3563 } parsed_items; 3564 unsigned int nb_item; 3565 3566 if (test_done == 0) { 3567 printf("Please stop forwarding first\n"); 3568 return; 3569 } 3570 3571 res = parsed_result; 3572 if (!strcmp(res->list_name, "corelist")) { 3573 nb_item = parse_item_list(res->list_of_items, "core", 3574 RTE_MAX_LCORE, 3575 parsed_items.lcorelist, 1); 3576 if (nb_item > 0) { 3577 set_fwd_lcores_list(parsed_items.lcorelist, nb_item); 3578 fwd_config_setup(); 3579 } 3580 return; 3581 } 3582 if (!strcmp(res->list_name, "portlist")) { 3583 nb_item = parse_item_list(res->list_of_items, "port", 3584 RTE_MAX_ETHPORTS, 3585 parsed_items.portlist, 1); 3586 if (nb_item > 0) { 3587 set_fwd_ports_list(parsed_items.portlist, nb_item); 3588 fwd_config_setup(); 3589 } 3590 } 3591 } 3592 3593 cmdline_parse_token_string_t cmd_set_list_keyword = 3594 TOKEN_STRING_INITIALIZER(struct cmd_set_list_result, cmd_keyword, 3595 "set"); 3596 cmdline_parse_token_string_t cmd_set_list_name = 3597 TOKEN_STRING_INITIALIZER(struct cmd_set_list_result, list_name, 3598 "corelist#portlist"); 3599 cmdline_parse_token_string_t cmd_set_list_of_items = 3600 TOKEN_STRING_INITIALIZER(struct cmd_set_list_result, list_of_items, 3601 NULL); 3602 3603 cmdline_parse_inst_t cmd_set_fwd_list = { 3604 .f = cmd_set_list_parsed, 3605 .data = NULL, 3606 .help_str = "set corelist|portlist <list0[,list1]*>", 3607 .tokens = { 3608 (void *)&cmd_set_list_keyword, 3609 (void *)&cmd_set_list_name, 3610 (void *)&cmd_set_list_of_items, 3611 NULL, 3612 }, 3613 }; 3614 3615 /* *** SET COREMASK and PORTMASK CONFIGURATION *** */ 3616 3617 struct cmd_setmask_result { 3618 cmdline_fixed_string_t set; 3619 cmdline_fixed_string_t mask; 3620 uint64_t hexavalue; 3621 }; 3622 3623 static void cmd_set_mask_parsed(void *parsed_result, 3624 __rte_unused struct cmdline *cl, 3625 __rte_unused void *data) 3626 { 3627 struct cmd_setmask_result *res = parsed_result; 3628 3629 if (test_done == 0) { 3630 printf("Please stop forwarding first\n"); 3631 return; 3632 } 3633 if (!strcmp(res->mask, "coremask")) { 3634 set_fwd_lcores_mask(res->hexavalue); 3635 fwd_config_setup(); 3636 } else if (!strcmp(res->mask, "portmask")) { 3637 set_fwd_ports_mask(res->hexavalue); 3638 fwd_config_setup(); 3639 } 3640 } 3641 3642 cmdline_parse_token_string_t cmd_setmask_set = 3643 TOKEN_STRING_INITIALIZER(struct cmd_setmask_result, set, "set"); 3644 cmdline_parse_token_string_t cmd_setmask_mask = 3645 TOKEN_STRING_INITIALIZER(struct cmd_setmask_result, mask, 3646 "coremask#portmask"); 3647 cmdline_parse_token_num_t cmd_setmask_value = 3648 TOKEN_NUM_INITIALIZER(struct cmd_setmask_result, hexavalue, RTE_UINT64); 3649 3650 cmdline_parse_inst_t cmd_set_fwd_mask = { 3651 .f = cmd_set_mask_parsed, 3652 .data = NULL, 3653 .help_str = "set coremask|portmask <hexadecimal value>", 3654 .tokens = { 3655 (void *)&cmd_setmask_set, 3656 (void *)&cmd_setmask_mask, 3657 (void *)&cmd_setmask_value, 3658 NULL, 3659 }, 3660 }; 3661 3662 /* 3663 * SET NBPORT, NBCORE, PACKET BURST, and VERBOSE LEVEL CONFIGURATION 3664 */ 3665 struct cmd_set_result { 3666 cmdline_fixed_string_t set; 3667 cmdline_fixed_string_t what; 3668 uint16_t value; 3669 }; 3670 3671 static void cmd_set_parsed(void *parsed_result, 3672 __rte_unused struct cmdline *cl, 3673 __rte_unused void *data) 3674 { 3675 struct cmd_set_result *res = parsed_result; 3676 if (!strcmp(res->what, "nbport")) { 3677 set_fwd_ports_number(res->value); 3678 fwd_config_setup(); 3679 } else if (!strcmp(res->what, "nbcore")) { 3680 set_fwd_lcores_number(res->value); 3681 fwd_config_setup(); 3682 } else if (!strcmp(res->what, "burst")) 3683 set_nb_pkt_per_burst(res->value); 3684 else if (!strcmp(res->what, "verbose")) 3685 set_verbose_level(res->value); 3686 } 3687 3688 cmdline_parse_token_string_t cmd_set_set = 3689 TOKEN_STRING_INITIALIZER(struct cmd_set_result, set, "set"); 3690 cmdline_parse_token_string_t cmd_set_what = 3691 TOKEN_STRING_INITIALIZER(struct cmd_set_result, what, 3692 "nbport#nbcore#burst#verbose"); 3693 cmdline_parse_token_num_t cmd_set_value = 3694 TOKEN_NUM_INITIALIZER(struct cmd_set_result, value, RTE_UINT16); 3695 3696 cmdline_parse_inst_t cmd_set_numbers = { 3697 .f = cmd_set_parsed, 3698 .data = NULL, 3699 .help_str = "set nbport|nbcore|burst|verbose <value>", 3700 .tokens = { 3701 (void *)&cmd_set_set, 3702 (void *)&cmd_set_what, 3703 (void *)&cmd_set_value, 3704 NULL, 3705 }, 3706 }; 3707 3708 /* *** SET LOG LEVEL CONFIGURATION *** */ 3709 3710 struct cmd_set_log_result { 3711 cmdline_fixed_string_t set; 3712 cmdline_fixed_string_t log; 3713 cmdline_fixed_string_t type; 3714 uint32_t level; 3715 }; 3716 3717 static void 3718 cmd_set_log_parsed(void *parsed_result, 3719 __rte_unused struct cmdline *cl, 3720 __rte_unused void *data) 3721 { 3722 struct cmd_set_log_result *res; 3723 int ret; 3724 3725 res = parsed_result; 3726 if (!strcmp(res->type, "global")) 3727 rte_log_set_global_level(res->level); 3728 else { 3729 ret = rte_log_set_level_regexp(res->type, res->level); 3730 if (ret < 0) 3731 printf("Unable to set log level\n"); 3732 } 3733 } 3734 3735 cmdline_parse_token_string_t cmd_set_log_set = 3736 TOKEN_STRING_INITIALIZER(struct cmd_set_log_result, set, "set"); 3737 cmdline_parse_token_string_t cmd_set_log_log = 3738 TOKEN_STRING_INITIALIZER(struct cmd_set_log_result, log, "log"); 3739 cmdline_parse_token_string_t cmd_set_log_type = 3740 TOKEN_STRING_INITIALIZER(struct cmd_set_log_result, type, NULL); 3741 cmdline_parse_token_num_t cmd_set_log_level = 3742 TOKEN_NUM_INITIALIZER(struct cmd_set_log_result, level, RTE_UINT32); 3743 3744 cmdline_parse_inst_t cmd_set_log = { 3745 .f = cmd_set_log_parsed, 3746 .data = NULL, 3747 .help_str = "set log global|<type> <level>", 3748 .tokens = { 3749 (void *)&cmd_set_log_set, 3750 (void *)&cmd_set_log_log, 3751 (void *)&cmd_set_log_type, 3752 (void *)&cmd_set_log_level, 3753 NULL, 3754 }, 3755 }; 3756 3757 /* *** SET SEGMENT OFFSETS OF RX PACKETS SPLIT *** */ 3758 3759 struct cmd_set_rxoffs_result { 3760 cmdline_fixed_string_t cmd_keyword; 3761 cmdline_fixed_string_t rxoffs; 3762 cmdline_fixed_string_t seg_offsets; 3763 }; 3764 3765 static void 3766 cmd_set_rxoffs_parsed(void *parsed_result, 3767 __rte_unused struct cmdline *cl, 3768 __rte_unused void *data) 3769 { 3770 struct cmd_set_rxoffs_result *res; 3771 unsigned int seg_offsets[MAX_SEGS_BUFFER_SPLIT]; 3772 unsigned int nb_segs; 3773 3774 res = parsed_result; 3775 nb_segs = parse_item_list(res->seg_offsets, "segment offsets", 3776 MAX_SEGS_BUFFER_SPLIT, seg_offsets, 0); 3777 if (nb_segs > 0) 3778 set_rx_pkt_offsets(seg_offsets, nb_segs); 3779 } 3780 3781 cmdline_parse_token_string_t cmd_set_rxoffs_keyword = 3782 TOKEN_STRING_INITIALIZER(struct cmd_set_rxoffs_result, 3783 cmd_keyword, "set"); 3784 cmdline_parse_token_string_t cmd_set_rxoffs_name = 3785 TOKEN_STRING_INITIALIZER(struct cmd_set_rxoffs_result, 3786 rxoffs, "rxoffs"); 3787 cmdline_parse_token_string_t cmd_set_rxoffs_offsets = 3788 TOKEN_STRING_INITIALIZER(struct cmd_set_rxoffs_result, 3789 seg_offsets, NULL); 3790 3791 cmdline_parse_inst_t cmd_set_rxoffs = { 3792 .f = cmd_set_rxoffs_parsed, 3793 .data = NULL, 3794 .help_str = "set rxoffs <len0[,len1]*>", 3795 .tokens = { 3796 (void *)&cmd_set_rxoffs_keyword, 3797 (void *)&cmd_set_rxoffs_name, 3798 (void *)&cmd_set_rxoffs_offsets, 3799 NULL, 3800 }, 3801 }; 3802 3803 /* *** SET SEGMENT LENGTHS OF RX PACKETS SPLIT *** */ 3804 3805 struct cmd_set_rxpkts_result { 3806 cmdline_fixed_string_t cmd_keyword; 3807 cmdline_fixed_string_t rxpkts; 3808 cmdline_fixed_string_t seg_lengths; 3809 }; 3810 3811 static void 3812 cmd_set_rxpkts_parsed(void *parsed_result, 3813 __rte_unused struct cmdline *cl, 3814 __rte_unused void *data) 3815 { 3816 struct cmd_set_rxpkts_result *res; 3817 unsigned int seg_lengths[MAX_SEGS_BUFFER_SPLIT]; 3818 unsigned int nb_segs; 3819 3820 res = parsed_result; 3821 nb_segs = parse_item_list(res->seg_lengths, "segment lengths", 3822 MAX_SEGS_BUFFER_SPLIT, seg_lengths, 0); 3823 if (nb_segs > 0) 3824 set_rx_pkt_segments(seg_lengths, nb_segs); 3825 } 3826 3827 cmdline_parse_token_string_t cmd_set_rxpkts_keyword = 3828 TOKEN_STRING_INITIALIZER(struct cmd_set_rxpkts_result, 3829 cmd_keyword, "set"); 3830 cmdline_parse_token_string_t cmd_set_rxpkts_name = 3831 TOKEN_STRING_INITIALIZER(struct cmd_set_rxpkts_result, 3832 rxpkts, "rxpkts"); 3833 cmdline_parse_token_string_t cmd_set_rxpkts_lengths = 3834 TOKEN_STRING_INITIALIZER(struct cmd_set_rxpkts_result, 3835 seg_lengths, NULL); 3836 3837 cmdline_parse_inst_t cmd_set_rxpkts = { 3838 .f = cmd_set_rxpkts_parsed, 3839 .data = NULL, 3840 .help_str = "set rxpkts <len0[,len1]*>", 3841 .tokens = { 3842 (void *)&cmd_set_rxpkts_keyword, 3843 (void *)&cmd_set_rxpkts_name, 3844 (void *)&cmd_set_rxpkts_lengths, 3845 NULL, 3846 }, 3847 }; 3848 3849 /* *** SET SEGMENT LENGTHS OF TXONLY PACKETS *** */ 3850 3851 struct cmd_set_txpkts_result { 3852 cmdline_fixed_string_t cmd_keyword; 3853 cmdline_fixed_string_t txpkts; 3854 cmdline_fixed_string_t seg_lengths; 3855 }; 3856 3857 static void 3858 cmd_set_txpkts_parsed(void *parsed_result, 3859 __rte_unused struct cmdline *cl, 3860 __rte_unused void *data) 3861 { 3862 struct cmd_set_txpkts_result *res; 3863 unsigned seg_lengths[RTE_MAX_SEGS_PER_PKT]; 3864 unsigned int nb_segs; 3865 3866 res = parsed_result; 3867 nb_segs = parse_item_list(res->seg_lengths, "segment lengths", 3868 RTE_MAX_SEGS_PER_PKT, seg_lengths, 0); 3869 if (nb_segs > 0) 3870 set_tx_pkt_segments(seg_lengths, nb_segs); 3871 } 3872 3873 cmdline_parse_token_string_t cmd_set_txpkts_keyword = 3874 TOKEN_STRING_INITIALIZER(struct cmd_set_txpkts_result, 3875 cmd_keyword, "set"); 3876 cmdline_parse_token_string_t cmd_set_txpkts_name = 3877 TOKEN_STRING_INITIALIZER(struct cmd_set_txpkts_result, 3878 txpkts, "txpkts"); 3879 cmdline_parse_token_string_t cmd_set_txpkts_lengths = 3880 TOKEN_STRING_INITIALIZER(struct cmd_set_txpkts_result, 3881 seg_lengths, NULL); 3882 3883 cmdline_parse_inst_t cmd_set_txpkts = { 3884 .f = cmd_set_txpkts_parsed, 3885 .data = NULL, 3886 .help_str = "set txpkts <len0[,len1]*>", 3887 .tokens = { 3888 (void *)&cmd_set_txpkts_keyword, 3889 (void *)&cmd_set_txpkts_name, 3890 (void *)&cmd_set_txpkts_lengths, 3891 NULL, 3892 }, 3893 }; 3894 3895 /* *** SET COPY AND SPLIT POLICY ON TX PACKETS *** */ 3896 3897 struct cmd_set_txsplit_result { 3898 cmdline_fixed_string_t cmd_keyword; 3899 cmdline_fixed_string_t txsplit; 3900 cmdline_fixed_string_t mode; 3901 }; 3902 3903 static void 3904 cmd_set_txsplit_parsed(void *parsed_result, 3905 __rte_unused struct cmdline *cl, 3906 __rte_unused void *data) 3907 { 3908 struct cmd_set_txsplit_result *res; 3909 3910 res = parsed_result; 3911 set_tx_pkt_split(res->mode); 3912 } 3913 3914 cmdline_parse_token_string_t cmd_set_txsplit_keyword = 3915 TOKEN_STRING_INITIALIZER(struct cmd_set_txsplit_result, 3916 cmd_keyword, "set"); 3917 cmdline_parse_token_string_t cmd_set_txsplit_name = 3918 TOKEN_STRING_INITIALIZER(struct cmd_set_txsplit_result, 3919 txsplit, "txsplit"); 3920 cmdline_parse_token_string_t cmd_set_txsplit_mode = 3921 TOKEN_STRING_INITIALIZER(struct cmd_set_txsplit_result, 3922 mode, NULL); 3923 3924 cmdline_parse_inst_t cmd_set_txsplit = { 3925 .f = cmd_set_txsplit_parsed, 3926 .data = NULL, 3927 .help_str = "set txsplit on|off|rand", 3928 .tokens = { 3929 (void *)&cmd_set_txsplit_keyword, 3930 (void *)&cmd_set_txsplit_name, 3931 (void *)&cmd_set_txsplit_mode, 3932 NULL, 3933 }, 3934 }; 3935 3936 /* *** SET TIMES FOR TXONLY PACKETS SCHEDULING ON TIMESTAMPS *** */ 3937 3938 struct cmd_set_txtimes_result { 3939 cmdline_fixed_string_t cmd_keyword; 3940 cmdline_fixed_string_t txtimes; 3941 cmdline_fixed_string_t tx_times; 3942 }; 3943 3944 static void 3945 cmd_set_txtimes_parsed(void *parsed_result, 3946 __rte_unused struct cmdline *cl, 3947 __rte_unused void *data) 3948 { 3949 struct cmd_set_txtimes_result *res; 3950 unsigned int tx_times[2] = {0, 0}; 3951 unsigned int n_times; 3952 3953 res = parsed_result; 3954 n_times = parse_item_list(res->tx_times, "tx times", 3955 2, tx_times, 0); 3956 if (n_times == 2) 3957 set_tx_pkt_times(tx_times); 3958 } 3959 3960 cmdline_parse_token_string_t cmd_set_txtimes_keyword = 3961 TOKEN_STRING_INITIALIZER(struct cmd_set_txtimes_result, 3962 cmd_keyword, "set"); 3963 cmdline_parse_token_string_t cmd_set_txtimes_name = 3964 TOKEN_STRING_INITIALIZER(struct cmd_set_txtimes_result, 3965 txtimes, "txtimes"); 3966 cmdline_parse_token_string_t cmd_set_txtimes_value = 3967 TOKEN_STRING_INITIALIZER(struct cmd_set_txtimes_result, 3968 tx_times, NULL); 3969 3970 cmdline_parse_inst_t cmd_set_txtimes = { 3971 .f = cmd_set_txtimes_parsed, 3972 .data = NULL, 3973 .help_str = "set txtimes <inter_burst>,<intra_burst>", 3974 .tokens = { 3975 (void *)&cmd_set_txtimes_keyword, 3976 (void *)&cmd_set_txtimes_name, 3977 (void *)&cmd_set_txtimes_value, 3978 NULL, 3979 }, 3980 }; 3981 3982 /* *** ADD/REMOVE ALL VLAN IDENTIFIERS TO/FROM A PORT VLAN RX FILTER *** */ 3983 struct cmd_rx_vlan_filter_all_result { 3984 cmdline_fixed_string_t rx_vlan; 3985 cmdline_fixed_string_t what; 3986 cmdline_fixed_string_t all; 3987 portid_t port_id; 3988 }; 3989 3990 static void 3991 cmd_rx_vlan_filter_all_parsed(void *parsed_result, 3992 __rte_unused struct cmdline *cl, 3993 __rte_unused void *data) 3994 { 3995 struct cmd_rx_vlan_filter_all_result *res = parsed_result; 3996 3997 if (!strcmp(res->what, "add")) 3998 rx_vlan_all_filter_set(res->port_id, 1); 3999 else 4000 rx_vlan_all_filter_set(res->port_id, 0); 4001 } 4002 4003 cmdline_parse_token_string_t cmd_rx_vlan_filter_all_rx_vlan = 4004 TOKEN_STRING_INITIALIZER(struct cmd_rx_vlan_filter_all_result, 4005 rx_vlan, "rx_vlan"); 4006 cmdline_parse_token_string_t cmd_rx_vlan_filter_all_what = 4007 TOKEN_STRING_INITIALIZER(struct cmd_rx_vlan_filter_all_result, 4008 what, "add#rm"); 4009 cmdline_parse_token_string_t cmd_rx_vlan_filter_all_all = 4010 TOKEN_STRING_INITIALIZER(struct cmd_rx_vlan_filter_all_result, 4011 all, "all"); 4012 cmdline_parse_token_num_t cmd_rx_vlan_filter_all_portid = 4013 TOKEN_NUM_INITIALIZER(struct cmd_rx_vlan_filter_all_result, 4014 port_id, RTE_UINT16); 4015 4016 cmdline_parse_inst_t cmd_rx_vlan_filter_all = { 4017 .f = cmd_rx_vlan_filter_all_parsed, 4018 .data = NULL, 4019 .help_str = "rx_vlan add|rm all <port_id>: " 4020 "Add/Remove all identifiers to/from the set of VLAN " 4021 "identifiers filtered by a port", 4022 .tokens = { 4023 (void *)&cmd_rx_vlan_filter_all_rx_vlan, 4024 (void *)&cmd_rx_vlan_filter_all_what, 4025 (void *)&cmd_rx_vlan_filter_all_all, 4026 (void *)&cmd_rx_vlan_filter_all_portid, 4027 NULL, 4028 }, 4029 }; 4030 4031 /* *** VLAN OFFLOAD SET ON A PORT *** */ 4032 struct cmd_vlan_offload_result { 4033 cmdline_fixed_string_t vlan; 4034 cmdline_fixed_string_t set; 4035 cmdline_fixed_string_t vlan_type; 4036 cmdline_fixed_string_t what; 4037 cmdline_fixed_string_t on; 4038 cmdline_fixed_string_t port_id; 4039 }; 4040 4041 static void 4042 cmd_vlan_offload_parsed(void *parsed_result, 4043 __rte_unused struct cmdline *cl, 4044 __rte_unused void *data) 4045 { 4046 int on; 4047 struct cmd_vlan_offload_result *res = parsed_result; 4048 char *str; 4049 int i, len = 0; 4050 portid_t port_id = 0; 4051 unsigned int tmp; 4052 4053 str = res->port_id; 4054 len = strnlen(str, STR_TOKEN_SIZE); 4055 i = 0; 4056 /* Get port_id first */ 4057 while(i < len){ 4058 if(str[i] == ',') 4059 break; 4060 4061 i++; 4062 } 4063 str[i]='\0'; 4064 tmp = strtoul(str, NULL, 0); 4065 /* If port_id greater that what portid_t can represent, return */ 4066 if(tmp >= RTE_MAX_ETHPORTS) 4067 return; 4068 port_id = (portid_t)tmp; 4069 4070 if (!strcmp(res->on, "on")) 4071 on = 1; 4072 else 4073 on = 0; 4074 4075 if (!strcmp(res->what, "strip")) 4076 rx_vlan_strip_set(port_id, on); 4077 else if(!strcmp(res->what, "stripq")){ 4078 uint16_t queue_id = 0; 4079 4080 /* No queue_id, return */ 4081 if(i + 1 >= len) { 4082 printf("must specify (port,queue_id)\n"); 4083 return; 4084 } 4085 tmp = strtoul(str + i + 1, NULL, 0); 4086 /* If queue_id greater that what 16-bits can represent, return */ 4087 if(tmp > 0xffff) 4088 return; 4089 4090 queue_id = (uint16_t)tmp; 4091 rx_vlan_strip_set_on_queue(port_id, queue_id, on); 4092 } 4093 else if (!strcmp(res->what, "filter")) 4094 rx_vlan_filter_set(port_id, on); 4095 else if (!strcmp(res->what, "qinq_strip")) 4096 rx_vlan_qinq_strip_set(port_id, on); 4097 else 4098 vlan_extend_set(port_id, on); 4099 4100 return; 4101 } 4102 4103 cmdline_parse_token_string_t cmd_vlan_offload_vlan = 4104 TOKEN_STRING_INITIALIZER(struct cmd_vlan_offload_result, 4105 vlan, "vlan"); 4106 cmdline_parse_token_string_t cmd_vlan_offload_set = 4107 TOKEN_STRING_INITIALIZER(struct cmd_vlan_offload_result, 4108 set, "set"); 4109 cmdline_parse_token_string_t cmd_vlan_offload_what = 4110 TOKEN_STRING_INITIALIZER(struct cmd_vlan_offload_result, 4111 what, "strip#filter#qinq_strip#extend#stripq"); 4112 cmdline_parse_token_string_t cmd_vlan_offload_on = 4113 TOKEN_STRING_INITIALIZER(struct cmd_vlan_offload_result, 4114 on, "on#off"); 4115 cmdline_parse_token_string_t cmd_vlan_offload_portid = 4116 TOKEN_STRING_INITIALIZER(struct cmd_vlan_offload_result, 4117 port_id, NULL); 4118 4119 cmdline_parse_inst_t cmd_vlan_offload = { 4120 .f = cmd_vlan_offload_parsed, 4121 .data = NULL, 4122 .help_str = "vlan set strip|filter|qinq_strip|extend|stripq on|off " 4123 "<port_id[,queue_id]>: " 4124 "Strip/Filter/QinQ for rx side Extend for both rx/tx sides", 4125 .tokens = { 4126 (void *)&cmd_vlan_offload_vlan, 4127 (void *)&cmd_vlan_offload_set, 4128 (void *)&cmd_vlan_offload_what, 4129 (void *)&cmd_vlan_offload_on, 4130 (void *)&cmd_vlan_offload_portid, 4131 NULL, 4132 }, 4133 }; 4134 4135 /* *** VLAN TPID SET ON A PORT *** */ 4136 struct cmd_vlan_tpid_result { 4137 cmdline_fixed_string_t vlan; 4138 cmdline_fixed_string_t set; 4139 cmdline_fixed_string_t vlan_type; 4140 cmdline_fixed_string_t what; 4141 uint16_t tp_id; 4142 portid_t port_id; 4143 }; 4144 4145 static void 4146 cmd_vlan_tpid_parsed(void *parsed_result, 4147 __rte_unused struct cmdline *cl, 4148 __rte_unused void *data) 4149 { 4150 struct cmd_vlan_tpid_result *res = parsed_result; 4151 enum rte_vlan_type vlan_type; 4152 4153 if (!strcmp(res->vlan_type, "inner")) 4154 vlan_type = ETH_VLAN_TYPE_INNER; 4155 else if (!strcmp(res->vlan_type, "outer")) 4156 vlan_type = ETH_VLAN_TYPE_OUTER; 4157 else { 4158 printf("Unknown vlan type\n"); 4159 return; 4160 } 4161 vlan_tpid_set(res->port_id, vlan_type, res->tp_id); 4162 } 4163 4164 cmdline_parse_token_string_t cmd_vlan_tpid_vlan = 4165 TOKEN_STRING_INITIALIZER(struct cmd_vlan_tpid_result, 4166 vlan, "vlan"); 4167 cmdline_parse_token_string_t cmd_vlan_tpid_set = 4168 TOKEN_STRING_INITIALIZER(struct cmd_vlan_tpid_result, 4169 set, "set"); 4170 cmdline_parse_token_string_t cmd_vlan_type = 4171 TOKEN_STRING_INITIALIZER(struct cmd_vlan_tpid_result, 4172 vlan_type, "inner#outer"); 4173 cmdline_parse_token_string_t cmd_vlan_tpid_what = 4174 TOKEN_STRING_INITIALIZER(struct cmd_vlan_tpid_result, 4175 what, "tpid"); 4176 cmdline_parse_token_num_t cmd_vlan_tpid_tpid = 4177 TOKEN_NUM_INITIALIZER(struct cmd_vlan_tpid_result, 4178 tp_id, RTE_UINT16); 4179 cmdline_parse_token_num_t cmd_vlan_tpid_portid = 4180 TOKEN_NUM_INITIALIZER(struct cmd_vlan_tpid_result, 4181 port_id, RTE_UINT16); 4182 4183 cmdline_parse_inst_t cmd_vlan_tpid = { 4184 .f = cmd_vlan_tpid_parsed, 4185 .data = NULL, 4186 .help_str = "vlan set inner|outer tpid <tp_id> <port_id>: " 4187 "Set the VLAN Ether type", 4188 .tokens = { 4189 (void *)&cmd_vlan_tpid_vlan, 4190 (void *)&cmd_vlan_tpid_set, 4191 (void *)&cmd_vlan_type, 4192 (void *)&cmd_vlan_tpid_what, 4193 (void *)&cmd_vlan_tpid_tpid, 4194 (void *)&cmd_vlan_tpid_portid, 4195 NULL, 4196 }, 4197 }; 4198 4199 /* *** ADD/REMOVE A VLAN IDENTIFIER TO/FROM A PORT VLAN RX FILTER *** */ 4200 struct cmd_rx_vlan_filter_result { 4201 cmdline_fixed_string_t rx_vlan; 4202 cmdline_fixed_string_t what; 4203 uint16_t vlan_id; 4204 portid_t port_id; 4205 }; 4206 4207 static void 4208 cmd_rx_vlan_filter_parsed(void *parsed_result, 4209 __rte_unused struct cmdline *cl, 4210 __rte_unused void *data) 4211 { 4212 struct cmd_rx_vlan_filter_result *res = parsed_result; 4213 4214 if (!strcmp(res->what, "add")) 4215 rx_vft_set(res->port_id, res->vlan_id, 1); 4216 else 4217 rx_vft_set(res->port_id, res->vlan_id, 0); 4218 } 4219 4220 cmdline_parse_token_string_t cmd_rx_vlan_filter_rx_vlan = 4221 TOKEN_STRING_INITIALIZER(struct cmd_rx_vlan_filter_result, 4222 rx_vlan, "rx_vlan"); 4223 cmdline_parse_token_string_t cmd_rx_vlan_filter_what = 4224 TOKEN_STRING_INITIALIZER(struct cmd_rx_vlan_filter_result, 4225 what, "add#rm"); 4226 cmdline_parse_token_num_t cmd_rx_vlan_filter_vlanid = 4227 TOKEN_NUM_INITIALIZER(struct cmd_rx_vlan_filter_result, 4228 vlan_id, RTE_UINT16); 4229 cmdline_parse_token_num_t cmd_rx_vlan_filter_portid = 4230 TOKEN_NUM_INITIALIZER(struct cmd_rx_vlan_filter_result, 4231 port_id, RTE_UINT16); 4232 4233 cmdline_parse_inst_t cmd_rx_vlan_filter = { 4234 .f = cmd_rx_vlan_filter_parsed, 4235 .data = NULL, 4236 .help_str = "rx_vlan add|rm <vlan_id> <port_id>: " 4237 "Add/Remove a VLAN identifier to/from the set of VLAN " 4238 "identifiers filtered by a port", 4239 .tokens = { 4240 (void *)&cmd_rx_vlan_filter_rx_vlan, 4241 (void *)&cmd_rx_vlan_filter_what, 4242 (void *)&cmd_rx_vlan_filter_vlanid, 4243 (void *)&cmd_rx_vlan_filter_portid, 4244 NULL, 4245 }, 4246 }; 4247 4248 /* *** ENABLE HARDWARE INSERTION OF VLAN HEADER IN TX PACKETS *** */ 4249 struct cmd_tx_vlan_set_result { 4250 cmdline_fixed_string_t tx_vlan; 4251 cmdline_fixed_string_t set; 4252 portid_t port_id; 4253 uint16_t vlan_id; 4254 }; 4255 4256 static void 4257 cmd_tx_vlan_set_parsed(void *parsed_result, 4258 __rte_unused struct cmdline *cl, 4259 __rte_unused void *data) 4260 { 4261 struct cmd_tx_vlan_set_result *res = parsed_result; 4262 4263 if (port_id_is_invalid(res->port_id, ENABLED_WARN)) 4264 return; 4265 4266 if (!port_is_stopped(res->port_id)) { 4267 printf("Please stop port %d first\n", res->port_id); 4268 return; 4269 } 4270 4271 tx_vlan_set(res->port_id, res->vlan_id); 4272 4273 cmd_reconfig_device_queue(res->port_id, 1, 1); 4274 } 4275 4276 cmdline_parse_token_string_t cmd_tx_vlan_set_tx_vlan = 4277 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_result, 4278 tx_vlan, "tx_vlan"); 4279 cmdline_parse_token_string_t cmd_tx_vlan_set_set = 4280 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_result, 4281 set, "set"); 4282 cmdline_parse_token_num_t cmd_tx_vlan_set_portid = 4283 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_result, 4284 port_id, RTE_UINT16); 4285 cmdline_parse_token_num_t cmd_tx_vlan_set_vlanid = 4286 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_result, 4287 vlan_id, RTE_UINT16); 4288 4289 cmdline_parse_inst_t cmd_tx_vlan_set = { 4290 .f = cmd_tx_vlan_set_parsed, 4291 .data = NULL, 4292 .help_str = "tx_vlan set <port_id> <vlan_id>: " 4293 "Enable hardware insertion of a single VLAN header " 4294 "with a given TAG Identifier in packets sent on a port", 4295 .tokens = { 4296 (void *)&cmd_tx_vlan_set_tx_vlan, 4297 (void *)&cmd_tx_vlan_set_set, 4298 (void *)&cmd_tx_vlan_set_portid, 4299 (void *)&cmd_tx_vlan_set_vlanid, 4300 NULL, 4301 }, 4302 }; 4303 4304 /* *** ENABLE HARDWARE INSERTION OF Double VLAN HEADER IN TX PACKETS *** */ 4305 struct cmd_tx_vlan_set_qinq_result { 4306 cmdline_fixed_string_t tx_vlan; 4307 cmdline_fixed_string_t set; 4308 portid_t port_id; 4309 uint16_t vlan_id; 4310 uint16_t vlan_id_outer; 4311 }; 4312 4313 static void 4314 cmd_tx_vlan_set_qinq_parsed(void *parsed_result, 4315 __rte_unused struct cmdline *cl, 4316 __rte_unused void *data) 4317 { 4318 struct cmd_tx_vlan_set_qinq_result *res = parsed_result; 4319 4320 if (port_id_is_invalid(res->port_id, ENABLED_WARN)) 4321 return; 4322 4323 if (!port_is_stopped(res->port_id)) { 4324 printf("Please stop port %d first\n", res->port_id); 4325 return; 4326 } 4327 4328 tx_qinq_set(res->port_id, res->vlan_id, res->vlan_id_outer); 4329 4330 cmd_reconfig_device_queue(res->port_id, 1, 1); 4331 } 4332 4333 cmdline_parse_token_string_t cmd_tx_vlan_set_qinq_tx_vlan = 4334 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_qinq_result, 4335 tx_vlan, "tx_vlan"); 4336 cmdline_parse_token_string_t cmd_tx_vlan_set_qinq_set = 4337 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_qinq_result, 4338 set, "set"); 4339 cmdline_parse_token_num_t cmd_tx_vlan_set_qinq_portid = 4340 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_qinq_result, 4341 port_id, RTE_UINT16); 4342 cmdline_parse_token_num_t cmd_tx_vlan_set_qinq_vlanid = 4343 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_qinq_result, 4344 vlan_id, RTE_UINT16); 4345 cmdline_parse_token_num_t cmd_tx_vlan_set_qinq_vlanid_outer = 4346 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_qinq_result, 4347 vlan_id_outer, RTE_UINT16); 4348 4349 cmdline_parse_inst_t cmd_tx_vlan_set_qinq = { 4350 .f = cmd_tx_vlan_set_qinq_parsed, 4351 .data = NULL, 4352 .help_str = "tx_vlan set <port_id> <vlan_id> <outer_vlan_id>: " 4353 "Enable hardware insertion of double VLAN header " 4354 "with given TAG Identifiers in packets sent on a port", 4355 .tokens = { 4356 (void *)&cmd_tx_vlan_set_qinq_tx_vlan, 4357 (void *)&cmd_tx_vlan_set_qinq_set, 4358 (void *)&cmd_tx_vlan_set_qinq_portid, 4359 (void *)&cmd_tx_vlan_set_qinq_vlanid, 4360 (void *)&cmd_tx_vlan_set_qinq_vlanid_outer, 4361 NULL, 4362 }, 4363 }; 4364 4365 /* *** ENABLE/DISABLE PORT BASED TX VLAN INSERTION *** */ 4366 struct cmd_tx_vlan_set_pvid_result { 4367 cmdline_fixed_string_t tx_vlan; 4368 cmdline_fixed_string_t set; 4369 cmdline_fixed_string_t pvid; 4370 portid_t port_id; 4371 uint16_t vlan_id; 4372 cmdline_fixed_string_t mode; 4373 }; 4374 4375 static void 4376 cmd_tx_vlan_set_pvid_parsed(void *parsed_result, 4377 __rte_unused struct cmdline *cl, 4378 __rte_unused void *data) 4379 { 4380 struct cmd_tx_vlan_set_pvid_result *res = parsed_result; 4381 4382 if (strcmp(res->mode, "on") == 0) 4383 tx_vlan_pvid_set(res->port_id, res->vlan_id, 1); 4384 else 4385 tx_vlan_pvid_set(res->port_id, res->vlan_id, 0); 4386 } 4387 4388 cmdline_parse_token_string_t cmd_tx_vlan_set_pvid_tx_vlan = 4389 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_pvid_result, 4390 tx_vlan, "tx_vlan"); 4391 cmdline_parse_token_string_t cmd_tx_vlan_set_pvid_set = 4392 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_pvid_result, 4393 set, "set"); 4394 cmdline_parse_token_string_t cmd_tx_vlan_set_pvid_pvid = 4395 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_pvid_result, 4396 pvid, "pvid"); 4397 cmdline_parse_token_num_t cmd_tx_vlan_set_pvid_port_id = 4398 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_pvid_result, 4399 port_id, RTE_UINT16); 4400 cmdline_parse_token_num_t cmd_tx_vlan_set_pvid_vlan_id = 4401 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_pvid_result, 4402 vlan_id, RTE_UINT16); 4403 cmdline_parse_token_string_t cmd_tx_vlan_set_pvid_mode = 4404 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_pvid_result, 4405 mode, "on#off"); 4406 4407 cmdline_parse_inst_t cmd_tx_vlan_set_pvid = { 4408 .f = cmd_tx_vlan_set_pvid_parsed, 4409 .data = NULL, 4410 .help_str = "tx_vlan set pvid <port_id> <vlan_id> on|off", 4411 .tokens = { 4412 (void *)&cmd_tx_vlan_set_pvid_tx_vlan, 4413 (void *)&cmd_tx_vlan_set_pvid_set, 4414 (void *)&cmd_tx_vlan_set_pvid_pvid, 4415 (void *)&cmd_tx_vlan_set_pvid_port_id, 4416 (void *)&cmd_tx_vlan_set_pvid_vlan_id, 4417 (void *)&cmd_tx_vlan_set_pvid_mode, 4418 NULL, 4419 }, 4420 }; 4421 4422 /* *** DISABLE HARDWARE INSERTION OF VLAN HEADER IN TX PACKETS *** */ 4423 struct cmd_tx_vlan_reset_result { 4424 cmdline_fixed_string_t tx_vlan; 4425 cmdline_fixed_string_t reset; 4426 portid_t port_id; 4427 }; 4428 4429 static void 4430 cmd_tx_vlan_reset_parsed(void *parsed_result, 4431 __rte_unused struct cmdline *cl, 4432 __rte_unused void *data) 4433 { 4434 struct cmd_tx_vlan_reset_result *res = parsed_result; 4435 4436 if (port_id_is_invalid(res->port_id, ENABLED_WARN)) 4437 return; 4438 4439 if (!port_is_stopped(res->port_id)) { 4440 printf("Please stop port %d first\n", res->port_id); 4441 return; 4442 } 4443 4444 tx_vlan_reset(res->port_id); 4445 4446 cmd_reconfig_device_queue(res->port_id, 1, 1); 4447 } 4448 4449 cmdline_parse_token_string_t cmd_tx_vlan_reset_tx_vlan = 4450 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_reset_result, 4451 tx_vlan, "tx_vlan"); 4452 cmdline_parse_token_string_t cmd_tx_vlan_reset_reset = 4453 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_reset_result, 4454 reset, "reset"); 4455 cmdline_parse_token_num_t cmd_tx_vlan_reset_portid = 4456 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_reset_result, 4457 port_id, RTE_UINT16); 4458 4459 cmdline_parse_inst_t cmd_tx_vlan_reset = { 4460 .f = cmd_tx_vlan_reset_parsed, 4461 .data = NULL, 4462 .help_str = "tx_vlan reset <port_id>: Disable hardware insertion of a " 4463 "VLAN header in packets sent on a port", 4464 .tokens = { 4465 (void *)&cmd_tx_vlan_reset_tx_vlan, 4466 (void *)&cmd_tx_vlan_reset_reset, 4467 (void *)&cmd_tx_vlan_reset_portid, 4468 NULL, 4469 }, 4470 }; 4471 4472 4473 /* *** ENABLE HARDWARE INSERTION OF CHECKSUM IN TX PACKETS *** */ 4474 struct cmd_csum_result { 4475 cmdline_fixed_string_t csum; 4476 cmdline_fixed_string_t mode; 4477 cmdline_fixed_string_t proto; 4478 cmdline_fixed_string_t hwsw; 4479 portid_t port_id; 4480 }; 4481 4482 static void 4483 csum_show(int port_id) 4484 { 4485 struct rte_eth_dev_info dev_info; 4486 uint64_t tx_offloads; 4487 int ret; 4488 4489 tx_offloads = ports[port_id].dev_conf.txmode.offloads; 4490 printf("Parse tunnel is %s\n", 4491 (ports[port_id].parse_tunnel) ? "on" : "off"); 4492 printf("IP checksum offload is %s\n", 4493 (tx_offloads & DEV_TX_OFFLOAD_IPV4_CKSUM) ? "hw" : "sw"); 4494 printf("UDP checksum offload is %s\n", 4495 (tx_offloads & DEV_TX_OFFLOAD_UDP_CKSUM) ? "hw" : "sw"); 4496 printf("TCP checksum offload is %s\n", 4497 (tx_offloads & DEV_TX_OFFLOAD_TCP_CKSUM) ? "hw" : "sw"); 4498 printf("SCTP checksum offload is %s\n", 4499 (tx_offloads & DEV_TX_OFFLOAD_SCTP_CKSUM) ? "hw" : "sw"); 4500 printf("Outer-Ip checksum offload is %s\n", 4501 (tx_offloads & DEV_TX_OFFLOAD_OUTER_IPV4_CKSUM) ? "hw" : "sw"); 4502 printf("Outer-Udp checksum offload is %s\n", 4503 (tx_offloads & DEV_TX_OFFLOAD_OUTER_UDP_CKSUM) ? "hw" : "sw"); 4504 4505 /* display warnings if configuration is not supported by the NIC */ 4506 ret = eth_dev_info_get_print_err(port_id, &dev_info); 4507 if (ret != 0) 4508 return; 4509 4510 if ((tx_offloads & DEV_TX_OFFLOAD_IPV4_CKSUM) && 4511 (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_IPV4_CKSUM) == 0) { 4512 printf("Warning: hardware IP checksum enabled but not " 4513 "supported by port %d\n", port_id); 4514 } 4515 if ((tx_offloads & DEV_TX_OFFLOAD_UDP_CKSUM) && 4516 (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_UDP_CKSUM) == 0) { 4517 printf("Warning: hardware UDP checksum enabled but not " 4518 "supported by port %d\n", port_id); 4519 } 4520 if ((tx_offloads & DEV_TX_OFFLOAD_TCP_CKSUM) && 4521 (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_TCP_CKSUM) == 0) { 4522 printf("Warning: hardware TCP checksum enabled but not " 4523 "supported by port %d\n", port_id); 4524 } 4525 if ((tx_offloads & DEV_TX_OFFLOAD_SCTP_CKSUM) && 4526 (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_SCTP_CKSUM) == 0) { 4527 printf("Warning: hardware SCTP checksum enabled but not " 4528 "supported by port %d\n", port_id); 4529 } 4530 if ((tx_offloads & DEV_TX_OFFLOAD_OUTER_IPV4_CKSUM) && 4531 (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_OUTER_IPV4_CKSUM) == 0) { 4532 printf("Warning: hardware outer IP checksum enabled but not " 4533 "supported by port %d\n", port_id); 4534 } 4535 if ((tx_offloads & DEV_TX_OFFLOAD_OUTER_UDP_CKSUM) && 4536 (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_OUTER_UDP_CKSUM) 4537 == 0) { 4538 printf("Warning: hardware outer UDP checksum enabled but not " 4539 "supported by port %d\n", port_id); 4540 } 4541 } 4542 4543 static void 4544 cmd_config_queue_tx_offloads(struct rte_port *port) 4545 { 4546 int k; 4547 4548 /* Apply queue tx offloads configuration */ 4549 for (k = 0; k < port->dev_info.max_rx_queues; k++) 4550 port->tx_conf[k].offloads = 4551 port->dev_conf.txmode.offloads; 4552 } 4553 4554 static void 4555 cmd_csum_parsed(void *parsed_result, 4556 __rte_unused struct cmdline *cl, 4557 __rte_unused void *data) 4558 { 4559 struct cmd_csum_result *res = parsed_result; 4560 int hw = 0; 4561 uint64_t csum_offloads = 0; 4562 struct rte_eth_dev_info dev_info; 4563 int ret; 4564 4565 if (port_id_is_invalid(res->port_id, ENABLED_WARN)) { 4566 printf("invalid port %d\n", res->port_id); 4567 return; 4568 } 4569 if (!port_is_stopped(res->port_id)) { 4570 printf("Please stop port %d first\n", res->port_id); 4571 return; 4572 } 4573 4574 ret = eth_dev_info_get_print_err(res->port_id, &dev_info); 4575 if (ret != 0) 4576 return; 4577 4578 if (!strcmp(res->mode, "set")) { 4579 4580 if (!strcmp(res->hwsw, "hw")) 4581 hw = 1; 4582 4583 if (!strcmp(res->proto, "ip")) { 4584 if (hw == 0 || (dev_info.tx_offload_capa & 4585 DEV_TX_OFFLOAD_IPV4_CKSUM)) { 4586 csum_offloads |= DEV_TX_OFFLOAD_IPV4_CKSUM; 4587 } else { 4588 printf("IP checksum offload is not supported " 4589 "by port %u\n", res->port_id); 4590 } 4591 } else if (!strcmp(res->proto, "udp")) { 4592 if (hw == 0 || (dev_info.tx_offload_capa & 4593 DEV_TX_OFFLOAD_UDP_CKSUM)) { 4594 csum_offloads |= DEV_TX_OFFLOAD_UDP_CKSUM; 4595 } else { 4596 printf("UDP checksum offload is not supported " 4597 "by port %u\n", res->port_id); 4598 } 4599 } else if (!strcmp(res->proto, "tcp")) { 4600 if (hw == 0 || (dev_info.tx_offload_capa & 4601 DEV_TX_OFFLOAD_TCP_CKSUM)) { 4602 csum_offloads |= DEV_TX_OFFLOAD_TCP_CKSUM; 4603 } else { 4604 printf("TCP checksum offload is not supported " 4605 "by port %u\n", res->port_id); 4606 } 4607 } else if (!strcmp(res->proto, "sctp")) { 4608 if (hw == 0 || (dev_info.tx_offload_capa & 4609 DEV_TX_OFFLOAD_SCTP_CKSUM)) { 4610 csum_offloads |= DEV_TX_OFFLOAD_SCTP_CKSUM; 4611 } else { 4612 printf("SCTP checksum offload is not supported " 4613 "by port %u\n", res->port_id); 4614 } 4615 } else if (!strcmp(res->proto, "outer-ip")) { 4616 if (hw == 0 || (dev_info.tx_offload_capa & 4617 DEV_TX_OFFLOAD_OUTER_IPV4_CKSUM)) { 4618 csum_offloads |= 4619 DEV_TX_OFFLOAD_OUTER_IPV4_CKSUM; 4620 } else { 4621 printf("Outer IP checksum offload is not " 4622 "supported by port %u\n", res->port_id); 4623 } 4624 } else if (!strcmp(res->proto, "outer-udp")) { 4625 if (hw == 0 || (dev_info.tx_offload_capa & 4626 DEV_TX_OFFLOAD_OUTER_UDP_CKSUM)) { 4627 csum_offloads |= 4628 DEV_TX_OFFLOAD_OUTER_UDP_CKSUM; 4629 } else { 4630 printf("Outer UDP checksum offload is not " 4631 "supported by port %u\n", res->port_id); 4632 } 4633 } 4634 4635 if (hw) { 4636 ports[res->port_id].dev_conf.txmode.offloads |= 4637 csum_offloads; 4638 } else { 4639 ports[res->port_id].dev_conf.txmode.offloads &= 4640 (~csum_offloads); 4641 } 4642 cmd_config_queue_tx_offloads(&ports[res->port_id]); 4643 } 4644 csum_show(res->port_id); 4645 4646 cmd_reconfig_device_queue(res->port_id, 1, 1); 4647 } 4648 4649 cmdline_parse_token_string_t cmd_csum_csum = 4650 TOKEN_STRING_INITIALIZER(struct cmd_csum_result, 4651 csum, "csum"); 4652 cmdline_parse_token_string_t cmd_csum_mode = 4653 TOKEN_STRING_INITIALIZER(struct cmd_csum_result, 4654 mode, "set"); 4655 cmdline_parse_token_string_t cmd_csum_proto = 4656 TOKEN_STRING_INITIALIZER(struct cmd_csum_result, 4657 proto, "ip#tcp#udp#sctp#outer-ip#outer-udp"); 4658 cmdline_parse_token_string_t cmd_csum_hwsw = 4659 TOKEN_STRING_INITIALIZER(struct cmd_csum_result, 4660 hwsw, "hw#sw"); 4661 cmdline_parse_token_num_t cmd_csum_portid = 4662 TOKEN_NUM_INITIALIZER(struct cmd_csum_result, 4663 port_id, RTE_UINT16); 4664 4665 cmdline_parse_inst_t cmd_csum_set = { 4666 .f = cmd_csum_parsed, 4667 .data = NULL, 4668 .help_str = "csum set ip|tcp|udp|sctp|outer-ip|outer-udp hw|sw <port_id>: " 4669 "Enable/Disable hardware calculation of L3/L4 checksum when " 4670 "using csum forward engine", 4671 .tokens = { 4672 (void *)&cmd_csum_csum, 4673 (void *)&cmd_csum_mode, 4674 (void *)&cmd_csum_proto, 4675 (void *)&cmd_csum_hwsw, 4676 (void *)&cmd_csum_portid, 4677 NULL, 4678 }, 4679 }; 4680 4681 cmdline_parse_token_string_t cmd_csum_mode_show = 4682 TOKEN_STRING_INITIALIZER(struct cmd_csum_result, 4683 mode, "show"); 4684 4685 cmdline_parse_inst_t cmd_csum_show = { 4686 .f = cmd_csum_parsed, 4687 .data = NULL, 4688 .help_str = "csum show <port_id>: Show checksum offload configuration", 4689 .tokens = { 4690 (void *)&cmd_csum_csum, 4691 (void *)&cmd_csum_mode_show, 4692 (void *)&cmd_csum_portid, 4693 NULL, 4694 }, 4695 }; 4696 4697 /* Enable/disable tunnel parsing */ 4698 struct cmd_csum_tunnel_result { 4699 cmdline_fixed_string_t csum; 4700 cmdline_fixed_string_t parse; 4701 cmdline_fixed_string_t onoff; 4702 portid_t port_id; 4703 }; 4704 4705 static void 4706 cmd_csum_tunnel_parsed(void *parsed_result, 4707 __rte_unused struct cmdline *cl, 4708 __rte_unused void *data) 4709 { 4710 struct cmd_csum_tunnel_result *res = parsed_result; 4711 4712 if (port_id_is_invalid(res->port_id, ENABLED_WARN)) 4713 return; 4714 4715 if (!strcmp(res->onoff, "on")) 4716 ports[res->port_id].parse_tunnel = 1; 4717 else 4718 ports[res->port_id].parse_tunnel = 0; 4719 4720 csum_show(res->port_id); 4721 } 4722 4723 cmdline_parse_token_string_t cmd_csum_tunnel_csum = 4724 TOKEN_STRING_INITIALIZER(struct cmd_csum_tunnel_result, 4725 csum, "csum"); 4726 cmdline_parse_token_string_t cmd_csum_tunnel_parse = 4727 TOKEN_STRING_INITIALIZER(struct cmd_csum_tunnel_result, 4728 parse, "parse-tunnel"); 4729 cmdline_parse_token_string_t cmd_csum_tunnel_onoff = 4730 TOKEN_STRING_INITIALIZER(struct cmd_csum_tunnel_result, 4731 onoff, "on#off"); 4732 cmdline_parse_token_num_t cmd_csum_tunnel_portid = 4733 TOKEN_NUM_INITIALIZER(struct cmd_csum_tunnel_result, 4734 port_id, RTE_UINT16); 4735 4736 cmdline_parse_inst_t cmd_csum_tunnel = { 4737 .f = cmd_csum_tunnel_parsed, 4738 .data = NULL, 4739 .help_str = "csum parse-tunnel on|off <port_id>: " 4740 "Enable/Disable parsing of tunnels for csum engine", 4741 .tokens = { 4742 (void *)&cmd_csum_tunnel_csum, 4743 (void *)&cmd_csum_tunnel_parse, 4744 (void *)&cmd_csum_tunnel_onoff, 4745 (void *)&cmd_csum_tunnel_portid, 4746 NULL, 4747 }, 4748 }; 4749 4750 /* *** ENABLE HARDWARE SEGMENTATION IN TX NON-TUNNELED PACKETS *** */ 4751 struct cmd_tso_set_result { 4752 cmdline_fixed_string_t tso; 4753 cmdline_fixed_string_t mode; 4754 uint16_t tso_segsz; 4755 portid_t port_id; 4756 }; 4757 4758 static void 4759 cmd_tso_set_parsed(void *parsed_result, 4760 __rte_unused struct cmdline *cl, 4761 __rte_unused void *data) 4762 { 4763 struct cmd_tso_set_result *res = parsed_result; 4764 struct rte_eth_dev_info dev_info; 4765 int ret; 4766 4767 if (port_id_is_invalid(res->port_id, ENABLED_WARN)) 4768 return; 4769 if (!port_is_stopped(res->port_id)) { 4770 printf("Please stop port %d first\n", res->port_id); 4771 return; 4772 } 4773 4774 if (!strcmp(res->mode, "set")) 4775 ports[res->port_id].tso_segsz = res->tso_segsz; 4776 4777 ret = eth_dev_info_get_print_err(res->port_id, &dev_info); 4778 if (ret != 0) 4779 return; 4780 4781 if ((ports[res->port_id].tso_segsz != 0) && 4782 (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_TCP_TSO) == 0) { 4783 printf("Error: TSO is not supported by port %d\n", 4784 res->port_id); 4785 return; 4786 } 4787 4788 if (ports[res->port_id].tso_segsz == 0) { 4789 ports[res->port_id].dev_conf.txmode.offloads &= 4790 ~DEV_TX_OFFLOAD_TCP_TSO; 4791 printf("TSO for non-tunneled packets is disabled\n"); 4792 } else { 4793 ports[res->port_id].dev_conf.txmode.offloads |= 4794 DEV_TX_OFFLOAD_TCP_TSO; 4795 printf("TSO segment size for non-tunneled packets is %d\n", 4796 ports[res->port_id].tso_segsz); 4797 } 4798 cmd_config_queue_tx_offloads(&ports[res->port_id]); 4799 4800 /* display warnings if configuration is not supported by the NIC */ 4801 ret = eth_dev_info_get_print_err(res->port_id, &dev_info); 4802 if (ret != 0) 4803 return; 4804 4805 if ((ports[res->port_id].tso_segsz != 0) && 4806 (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_TCP_TSO) == 0) { 4807 printf("Warning: TSO enabled but not " 4808 "supported by port %d\n", res->port_id); 4809 } 4810 4811 cmd_reconfig_device_queue(res->port_id, 1, 1); 4812 } 4813 4814 cmdline_parse_token_string_t cmd_tso_set_tso = 4815 TOKEN_STRING_INITIALIZER(struct cmd_tso_set_result, 4816 tso, "tso"); 4817 cmdline_parse_token_string_t cmd_tso_set_mode = 4818 TOKEN_STRING_INITIALIZER(struct cmd_tso_set_result, 4819 mode, "set"); 4820 cmdline_parse_token_num_t cmd_tso_set_tso_segsz = 4821 TOKEN_NUM_INITIALIZER(struct cmd_tso_set_result, 4822 tso_segsz, RTE_UINT16); 4823 cmdline_parse_token_num_t cmd_tso_set_portid = 4824 TOKEN_NUM_INITIALIZER(struct cmd_tso_set_result, 4825 port_id, RTE_UINT16); 4826 4827 cmdline_parse_inst_t cmd_tso_set = { 4828 .f = cmd_tso_set_parsed, 4829 .data = NULL, 4830 .help_str = "tso set <tso_segsz> <port_id>: " 4831 "Set TSO segment size of non-tunneled packets for csum engine " 4832 "(0 to disable)", 4833 .tokens = { 4834 (void *)&cmd_tso_set_tso, 4835 (void *)&cmd_tso_set_mode, 4836 (void *)&cmd_tso_set_tso_segsz, 4837 (void *)&cmd_tso_set_portid, 4838 NULL, 4839 }, 4840 }; 4841 4842 cmdline_parse_token_string_t cmd_tso_show_mode = 4843 TOKEN_STRING_INITIALIZER(struct cmd_tso_set_result, 4844 mode, "show"); 4845 4846 4847 cmdline_parse_inst_t cmd_tso_show = { 4848 .f = cmd_tso_set_parsed, 4849 .data = NULL, 4850 .help_str = "tso show <port_id>: " 4851 "Show TSO segment size of non-tunneled packets for csum engine", 4852 .tokens = { 4853 (void *)&cmd_tso_set_tso, 4854 (void *)&cmd_tso_show_mode, 4855 (void *)&cmd_tso_set_portid, 4856 NULL, 4857 }, 4858 }; 4859 4860 /* *** ENABLE HARDWARE SEGMENTATION IN TX TUNNELED PACKETS *** */ 4861 struct cmd_tunnel_tso_set_result { 4862 cmdline_fixed_string_t tso; 4863 cmdline_fixed_string_t mode; 4864 uint16_t tso_segsz; 4865 portid_t port_id; 4866 }; 4867 4868 static struct rte_eth_dev_info 4869 check_tunnel_tso_nic_support(portid_t port_id) 4870 { 4871 struct rte_eth_dev_info dev_info; 4872 4873 if (eth_dev_info_get_print_err(port_id, &dev_info) != 0) 4874 return dev_info; 4875 4876 if (!(dev_info.tx_offload_capa & DEV_TX_OFFLOAD_VXLAN_TNL_TSO)) 4877 printf("Warning: VXLAN TUNNEL TSO not supported therefore " 4878 "not enabled for port %d\n", port_id); 4879 if (!(dev_info.tx_offload_capa & DEV_TX_OFFLOAD_GRE_TNL_TSO)) 4880 printf("Warning: GRE TUNNEL TSO not supported therefore " 4881 "not enabled for port %d\n", port_id); 4882 if (!(dev_info.tx_offload_capa & DEV_TX_OFFLOAD_IPIP_TNL_TSO)) 4883 printf("Warning: IPIP TUNNEL TSO not supported therefore " 4884 "not enabled for port %d\n", port_id); 4885 if (!(dev_info.tx_offload_capa & DEV_TX_OFFLOAD_GENEVE_TNL_TSO)) 4886 printf("Warning: GENEVE TUNNEL TSO not supported therefore " 4887 "not enabled for port %d\n", port_id); 4888 if (!(dev_info.tx_offload_capa & DEV_TX_OFFLOAD_IP_TNL_TSO)) 4889 printf("Warning: IP TUNNEL TSO not supported therefore " 4890 "not enabled for port %d\n", port_id); 4891 if (!(dev_info.tx_offload_capa & DEV_TX_OFFLOAD_UDP_TNL_TSO)) 4892 printf("Warning: UDP TUNNEL TSO not supported therefore " 4893 "not enabled for port %d\n", port_id); 4894 return dev_info; 4895 } 4896 4897 static void 4898 cmd_tunnel_tso_set_parsed(void *parsed_result, 4899 __rte_unused struct cmdline *cl, 4900 __rte_unused void *data) 4901 { 4902 struct cmd_tunnel_tso_set_result *res = parsed_result; 4903 struct rte_eth_dev_info dev_info; 4904 4905 if (port_id_is_invalid(res->port_id, ENABLED_WARN)) 4906 return; 4907 if (!port_is_stopped(res->port_id)) { 4908 printf("Please stop port %d first\n", res->port_id); 4909 return; 4910 } 4911 4912 if (!strcmp(res->mode, "set")) 4913 ports[res->port_id].tunnel_tso_segsz = res->tso_segsz; 4914 4915 dev_info = check_tunnel_tso_nic_support(res->port_id); 4916 if (ports[res->port_id].tunnel_tso_segsz == 0) { 4917 ports[res->port_id].dev_conf.txmode.offloads &= 4918 ~(DEV_TX_OFFLOAD_VXLAN_TNL_TSO | 4919 DEV_TX_OFFLOAD_GRE_TNL_TSO | 4920 DEV_TX_OFFLOAD_IPIP_TNL_TSO | 4921 DEV_TX_OFFLOAD_GENEVE_TNL_TSO | 4922 DEV_TX_OFFLOAD_IP_TNL_TSO | 4923 DEV_TX_OFFLOAD_UDP_TNL_TSO); 4924 printf("TSO for tunneled packets is disabled\n"); 4925 } else { 4926 uint64_t tso_offloads = (DEV_TX_OFFLOAD_VXLAN_TNL_TSO | 4927 DEV_TX_OFFLOAD_GRE_TNL_TSO | 4928 DEV_TX_OFFLOAD_IPIP_TNL_TSO | 4929 DEV_TX_OFFLOAD_GENEVE_TNL_TSO | 4930 DEV_TX_OFFLOAD_IP_TNL_TSO | 4931 DEV_TX_OFFLOAD_UDP_TNL_TSO); 4932 4933 ports[res->port_id].dev_conf.txmode.offloads |= 4934 (tso_offloads & dev_info.tx_offload_capa); 4935 printf("TSO segment size for tunneled packets is %d\n", 4936 ports[res->port_id].tunnel_tso_segsz); 4937 4938 /* Below conditions are needed to make it work: 4939 * (1) tunnel TSO is supported by the NIC; 4940 * (2) "csum parse_tunnel" must be set so that tunneled pkts 4941 * are recognized; 4942 * (3) for tunneled pkts with outer L3 of IPv4, 4943 * "csum set outer-ip" must be set to hw, because after tso, 4944 * total_len of outer IP header is changed, and the checksum 4945 * of outer IP header calculated by sw should be wrong; that 4946 * is not necessary for IPv6 tunneled pkts because there's no 4947 * checksum in IP header anymore. 4948 */ 4949 4950 if (!ports[res->port_id].parse_tunnel) 4951 printf("Warning: csum parse_tunnel must be set " 4952 "so that tunneled packets are recognized\n"); 4953 if (!(ports[res->port_id].dev_conf.txmode.offloads & 4954 DEV_TX_OFFLOAD_OUTER_IPV4_CKSUM)) 4955 printf("Warning: csum set outer-ip must be set to hw " 4956 "if outer L3 is IPv4; not necessary for IPv6\n"); 4957 } 4958 4959 cmd_config_queue_tx_offloads(&ports[res->port_id]); 4960 cmd_reconfig_device_queue(res->port_id, 1, 1); 4961 } 4962 4963 cmdline_parse_token_string_t cmd_tunnel_tso_set_tso = 4964 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_tso_set_result, 4965 tso, "tunnel_tso"); 4966 cmdline_parse_token_string_t cmd_tunnel_tso_set_mode = 4967 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_tso_set_result, 4968 mode, "set"); 4969 cmdline_parse_token_num_t cmd_tunnel_tso_set_tso_segsz = 4970 TOKEN_NUM_INITIALIZER(struct cmd_tunnel_tso_set_result, 4971 tso_segsz, RTE_UINT16); 4972 cmdline_parse_token_num_t cmd_tunnel_tso_set_portid = 4973 TOKEN_NUM_INITIALIZER(struct cmd_tunnel_tso_set_result, 4974 port_id, RTE_UINT16); 4975 4976 cmdline_parse_inst_t cmd_tunnel_tso_set = { 4977 .f = cmd_tunnel_tso_set_parsed, 4978 .data = NULL, 4979 .help_str = "tunnel_tso set <tso_segsz> <port_id>: " 4980 "Set TSO segment size of tunneled packets for csum engine " 4981 "(0 to disable)", 4982 .tokens = { 4983 (void *)&cmd_tunnel_tso_set_tso, 4984 (void *)&cmd_tunnel_tso_set_mode, 4985 (void *)&cmd_tunnel_tso_set_tso_segsz, 4986 (void *)&cmd_tunnel_tso_set_portid, 4987 NULL, 4988 }, 4989 }; 4990 4991 cmdline_parse_token_string_t cmd_tunnel_tso_show_mode = 4992 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_tso_set_result, 4993 mode, "show"); 4994 4995 4996 cmdline_parse_inst_t cmd_tunnel_tso_show = { 4997 .f = cmd_tunnel_tso_set_parsed, 4998 .data = NULL, 4999 .help_str = "tunnel_tso show <port_id> " 5000 "Show TSO segment size of tunneled packets for csum engine", 5001 .tokens = { 5002 (void *)&cmd_tunnel_tso_set_tso, 5003 (void *)&cmd_tunnel_tso_show_mode, 5004 (void *)&cmd_tunnel_tso_set_portid, 5005 NULL, 5006 }, 5007 }; 5008 5009 /* *** SET GRO FOR A PORT *** */ 5010 struct cmd_gro_enable_result { 5011 cmdline_fixed_string_t cmd_set; 5012 cmdline_fixed_string_t cmd_port; 5013 cmdline_fixed_string_t cmd_keyword; 5014 cmdline_fixed_string_t cmd_onoff; 5015 portid_t cmd_pid; 5016 }; 5017 5018 static void 5019 cmd_gro_enable_parsed(void *parsed_result, 5020 __rte_unused struct cmdline *cl, 5021 __rte_unused void *data) 5022 { 5023 struct cmd_gro_enable_result *res; 5024 5025 res = parsed_result; 5026 if (!strcmp(res->cmd_keyword, "gro")) 5027 setup_gro(res->cmd_onoff, res->cmd_pid); 5028 } 5029 5030 cmdline_parse_token_string_t cmd_gro_enable_set = 5031 TOKEN_STRING_INITIALIZER(struct cmd_gro_enable_result, 5032 cmd_set, "set"); 5033 cmdline_parse_token_string_t cmd_gro_enable_port = 5034 TOKEN_STRING_INITIALIZER(struct cmd_gro_enable_result, 5035 cmd_keyword, "port"); 5036 cmdline_parse_token_num_t cmd_gro_enable_pid = 5037 TOKEN_NUM_INITIALIZER(struct cmd_gro_enable_result, 5038 cmd_pid, RTE_UINT16); 5039 cmdline_parse_token_string_t cmd_gro_enable_keyword = 5040 TOKEN_STRING_INITIALIZER(struct cmd_gro_enable_result, 5041 cmd_keyword, "gro"); 5042 cmdline_parse_token_string_t cmd_gro_enable_onoff = 5043 TOKEN_STRING_INITIALIZER(struct cmd_gro_enable_result, 5044 cmd_onoff, "on#off"); 5045 5046 cmdline_parse_inst_t cmd_gro_enable = { 5047 .f = cmd_gro_enable_parsed, 5048 .data = NULL, 5049 .help_str = "set port <port_id> gro on|off", 5050 .tokens = { 5051 (void *)&cmd_gro_enable_set, 5052 (void *)&cmd_gro_enable_port, 5053 (void *)&cmd_gro_enable_pid, 5054 (void *)&cmd_gro_enable_keyword, 5055 (void *)&cmd_gro_enable_onoff, 5056 NULL, 5057 }, 5058 }; 5059 5060 /* *** DISPLAY GRO CONFIGURATION *** */ 5061 struct cmd_gro_show_result { 5062 cmdline_fixed_string_t cmd_show; 5063 cmdline_fixed_string_t cmd_port; 5064 cmdline_fixed_string_t cmd_keyword; 5065 portid_t cmd_pid; 5066 }; 5067 5068 static void 5069 cmd_gro_show_parsed(void *parsed_result, 5070 __rte_unused struct cmdline *cl, 5071 __rte_unused void *data) 5072 { 5073 struct cmd_gro_show_result *res; 5074 5075 res = parsed_result; 5076 if (!strcmp(res->cmd_keyword, "gro")) 5077 show_gro(res->cmd_pid); 5078 } 5079 5080 cmdline_parse_token_string_t cmd_gro_show_show = 5081 TOKEN_STRING_INITIALIZER(struct cmd_gro_show_result, 5082 cmd_show, "show"); 5083 cmdline_parse_token_string_t cmd_gro_show_port = 5084 TOKEN_STRING_INITIALIZER(struct cmd_gro_show_result, 5085 cmd_port, "port"); 5086 cmdline_parse_token_num_t cmd_gro_show_pid = 5087 TOKEN_NUM_INITIALIZER(struct cmd_gro_show_result, 5088 cmd_pid, RTE_UINT16); 5089 cmdline_parse_token_string_t cmd_gro_show_keyword = 5090 TOKEN_STRING_INITIALIZER(struct cmd_gro_show_result, 5091 cmd_keyword, "gro"); 5092 5093 cmdline_parse_inst_t cmd_gro_show = { 5094 .f = cmd_gro_show_parsed, 5095 .data = NULL, 5096 .help_str = "show port <port_id> gro", 5097 .tokens = { 5098 (void *)&cmd_gro_show_show, 5099 (void *)&cmd_gro_show_port, 5100 (void *)&cmd_gro_show_pid, 5101 (void *)&cmd_gro_show_keyword, 5102 NULL, 5103 }, 5104 }; 5105 5106 /* *** SET FLUSH CYCLES FOR GRO *** */ 5107 struct cmd_gro_flush_result { 5108 cmdline_fixed_string_t cmd_set; 5109 cmdline_fixed_string_t cmd_keyword; 5110 cmdline_fixed_string_t cmd_flush; 5111 uint8_t cmd_cycles; 5112 }; 5113 5114 static void 5115 cmd_gro_flush_parsed(void *parsed_result, 5116 __rte_unused struct cmdline *cl, 5117 __rte_unused void *data) 5118 { 5119 struct cmd_gro_flush_result *res; 5120 5121 res = parsed_result; 5122 if ((!strcmp(res->cmd_keyword, "gro")) && 5123 (!strcmp(res->cmd_flush, "flush"))) 5124 setup_gro_flush_cycles(res->cmd_cycles); 5125 } 5126 5127 cmdline_parse_token_string_t cmd_gro_flush_set = 5128 TOKEN_STRING_INITIALIZER(struct cmd_gro_flush_result, 5129 cmd_set, "set"); 5130 cmdline_parse_token_string_t cmd_gro_flush_keyword = 5131 TOKEN_STRING_INITIALIZER(struct cmd_gro_flush_result, 5132 cmd_keyword, "gro"); 5133 cmdline_parse_token_string_t cmd_gro_flush_flush = 5134 TOKEN_STRING_INITIALIZER(struct cmd_gro_flush_result, 5135 cmd_flush, "flush"); 5136 cmdline_parse_token_num_t cmd_gro_flush_cycles = 5137 TOKEN_NUM_INITIALIZER(struct cmd_gro_flush_result, 5138 cmd_cycles, RTE_UINT8); 5139 5140 cmdline_parse_inst_t cmd_gro_flush = { 5141 .f = cmd_gro_flush_parsed, 5142 .data = NULL, 5143 .help_str = "set gro flush <cycles>", 5144 .tokens = { 5145 (void *)&cmd_gro_flush_set, 5146 (void *)&cmd_gro_flush_keyword, 5147 (void *)&cmd_gro_flush_flush, 5148 (void *)&cmd_gro_flush_cycles, 5149 NULL, 5150 }, 5151 }; 5152 5153 /* *** ENABLE/DISABLE GSO *** */ 5154 struct cmd_gso_enable_result { 5155 cmdline_fixed_string_t cmd_set; 5156 cmdline_fixed_string_t cmd_port; 5157 cmdline_fixed_string_t cmd_keyword; 5158 cmdline_fixed_string_t cmd_mode; 5159 portid_t cmd_pid; 5160 }; 5161 5162 static void 5163 cmd_gso_enable_parsed(void *parsed_result, 5164 __rte_unused struct cmdline *cl, 5165 __rte_unused void *data) 5166 { 5167 struct cmd_gso_enable_result *res; 5168 5169 res = parsed_result; 5170 if (!strcmp(res->cmd_keyword, "gso")) 5171 setup_gso(res->cmd_mode, res->cmd_pid); 5172 } 5173 5174 cmdline_parse_token_string_t cmd_gso_enable_set = 5175 TOKEN_STRING_INITIALIZER(struct cmd_gso_enable_result, 5176 cmd_set, "set"); 5177 cmdline_parse_token_string_t cmd_gso_enable_port = 5178 TOKEN_STRING_INITIALIZER(struct cmd_gso_enable_result, 5179 cmd_port, "port"); 5180 cmdline_parse_token_string_t cmd_gso_enable_keyword = 5181 TOKEN_STRING_INITIALIZER(struct cmd_gso_enable_result, 5182 cmd_keyword, "gso"); 5183 cmdline_parse_token_string_t cmd_gso_enable_mode = 5184 TOKEN_STRING_INITIALIZER(struct cmd_gso_enable_result, 5185 cmd_mode, "on#off"); 5186 cmdline_parse_token_num_t cmd_gso_enable_pid = 5187 TOKEN_NUM_INITIALIZER(struct cmd_gso_enable_result, 5188 cmd_pid, RTE_UINT16); 5189 5190 cmdline_parse_inst_t cmd_gso_enable = { 5191 .f = cmd_gso_enable_parsed, 5192 .data = NULL, 5193 .help_str = "set port <port_id> gso on|off", 5194 .tokens = { 5195 (void *)&cmd_gso_enable_set, 5196 (void *)&cmd_gso_enable_port, 5197 (void *)&cmd_gso_enable_pid, 5198 (void *)&cmd_gso_enable_keyword, 5199 (void *)&cmd_gso_enable_mode, 5200 NULL, 5201 }, 5202 }; 5203 5204 /* *** SET MAX PACKET LENGTH FOR GSO SEGMENTS *** */ 5205 struct cmd_gso_size_result { 5206 cmdline_fixed_string_t cmd_set; 5207 cmdline_fixed_string_t cmd_keyword; 5208 cmdline_fixed_string_t cmd_segsz; 5209 uint16_t cmd_size; 5210 }; 5211 5212 static void 5213 cmd_gso_size_parsed(void *parsed_result, 5214 __rte_unused struct cmdline *cl, 5215 __rte_unused void *data) 5216 { 5217 struct cmd_gso_size_result *res = parsed_result; 5218 5219 if (test_done == 0) { 5220 printf("Before setting GSO segsz, please first" 5221 " stop forwarding\n"); 5222 return; 5223 } 5224 5225 if (!strcmp(res->cmd_keyword, "gso") && 5226 !strcmp(res->cmd_segsz, "segsz")) { 5227 if (res->cmd_size < RTE_GSO_SEG_SIZE_MIN) 5228 printf("gso_size should be larger than %zu." 5229 " Please input a legal value\n", 5230 RTE_GSO_SEG_SIZE_MIN); 5231 else 5232 gso_max_segment_size = res->cmd_size; 5233 } 5234 } 5235 5236 cmdline_parse_token_string_t cmd_gso_size_set = 5237 TOKEN_STRING_INITIALIZER(struct cmd_gso_size_result, 5238 cmd_set, "set"); 5239 cmdline_parse_token_string_t cmd_gso_size_keyword = 5240 TOKEN_STRING_INITIALIZER(struct cmd_gso_size_result, 5241 cmd_keyword, "gso"); 5242 cmdline_parse_token_string_t cmd_gso_size_segsz = 5243 TOKEN_STRING_INITIALIZER(struct cmd_gso_size_result, 5244 cmd_segsz, "segsz"); 5245 cmdline_parse_token_num_t cmd_gso_size_size = 5246 TOKEN_NUM_INITIALIZER(struct cmd_gso_size_result, 5247 cmd_size, RTE_UINT16); 5248 5249 cmdline_parse_inst_t cmd_gso_size = { 5250 .f = cmd_gso_size_parsed, 5251 .data = NULL, 5252 .help_str = "set gso segsz <length>", 5253 .tokens = { 5254 (void *)&cmd_gso_size_set, 5255 (void *)&cmd_gso_size_keyword, 5256 (void *)&cmd_gso_size_segsz, 5257 (void *)&cmd_gso_size_size, 5258 NULL, 5259 }, 5260 }; 5261 5262 /* *** SHOW GSO CONFIGURATION *** */ 5263 struct cmd_gso_show_result { 5264 cmdline_fixed_string_t cmd_show; 5265 cmdline_fixed_string_t cmd_port; 5266 cmdline_fixed_string_t cmd_keyword; 5267 portid_t cmd_pid; 5268 }; 5269 5270 static void 5271 cmd_gso_show_parsed(void *parsed_result, 5272 __rte_unused struct cmdline *cl, 5273 __rte_unused void *data) 5274 { 5275 struct cmd_gso_show_result *res = parsed_result; 5276 5277 if (!rte_eth_dev_is_valid_port(res->cmd_pid)) { 5278 printf("invalid port id %u\n", res->cmd_pid); 5279 return; 5280 } 5281 if (!strcmp(res->cmd_keyword, "gso")) { 5282 if (gso_ports[res->cmd_pid].enable) { 5283 printf("Max GSO'd packet size: %uB\n" 5284 "Supported GSO types: TCP/IPv4, " 5285 "UDP/IPv4, VxLAN with inner " 5286 "TCP/IPv4 packet, GRE with inner " 5287 "TCP/IPv4 packet\n", 5288 gso_max_segment_size); 5289 } else 5290 printf("GSO is not enabled on Port %u\n", res->cmd_pid); 5291 } 5292 } 5293 5294 cmdline_parse_token_string_t cmd_gso_show_show = 5295 TOKEN_STRING_INITIALIZER(struct cmd_gso_show_result, 5296 cmd_show, "show"); 5297 cmdline_parse_token_string_t cmd_gso_show_port = 5298 TOKEN_STRING_INITIALIZER(struct cmd_gso_show_result, 5299 cmd_port, "port"); 5300 cmdline_parse_token_string_t cmd_gso_show_keyword = 5301 TOKEN_STRING_INITIALIZER(struct cmd_gso_show_result, 5302 cmd_keyword, "gso"); 5303 cmdline_parse_token_num_t cmd_gso_show_pid = 5304 TOKEN_NUM_INITIALIZER(struct cmd_gso_show_result, 5305 cmd_pid, RTE_UINT16); 5306 5307 cmdline_parse_inst_t cmd_gso_show = { 5308 .f = cmd_gso_show_parsed, 5309 .data = NULL, 5310 .help_str = "show port <port_id> gso", 5311 .tokens = { 5312 (void *)&cmd_gso_show_show, 5313 (void *)&cmd_gso_show_port, 5314 (void *)&cmd_gso_show_pid, 5315 (void *)&cmd_gso_show_keyword, 5316 NULL, 5317 }, 5318 }; 5319 5320 /* *** ENABLE/DISABLE FLUSH ON RX STREAMS *** */ 5321 struct cmd_set_flush_rx { 5322 cmdline_fixed_string_t set; 5323 cmdline_fixed_string_t flush_rx; 5324 cmdline_fixed_string_t mode; 5325 }; 5326 5327 static void 5328 cmd_set_flush_rx_parsed(void *parsed_result, 5329 __rte_unused struct cmdline *cl, 5330 __rte_unused void *data) 5331 { 5332 struct cmd_set_flush_rx *res = parsed_result; 5333 no_flush_rx = (uint8_t)((strcmp(res->mode, "on") == 0) ? 0 : 1); 5334 } 5335 5336 cmdline_parse_token_string_t cmd_setflushrx_set = 5337 TOKEN_STRING_INITIALIZER(struct cmd_set_flush_rx, 5338 set, "set"); 5339 cmdline_parse_token_string_t cmd_setflushrx_flush_rx = 5340 TOKEN_STRING_INITIALIZER(struct cmd_set_flush_rx, 5341 flush_rx, "flush_rx"); 5342 cmdline_parse_token_string_t cmd_setflushrx_mode = 5343 TOKEN_STRING_INITIALIZER(struct cmd_set_flush_rx, 5344 mode, "on#off"); 5345 5346 5347 cmdline_parse_inst_t cmd_set_flush_rx = { 5348 .f = cmd_set_flush_rx_parsed, 5349 .help_str = "set flush_rx on|off: Enable/Disable flush on rx streams", 5350 .data = NULL, 5351 .tokens = { 5352 (void *)&cmd_setflushrx_set, 5353 (void *)&cmd_setflushrx_flush_rx, 5354 (void *)&cmd_setflushrx_mode, 5355 NULL, 5356 }, 5357 }; 5358 5359 /* *** ENABLE/DISABLE LINK STATUS CHECK *** */ 5360 struct cmd_set_link_check { 5361 cmdline_fixed_string_t set; 5362 cmdline_fixed_string_t link_check; 5363 cmdline_fixed_string_t mode; 5364 }; 5365 5366 static void 5367 cmd_set_link_check_parsed(void *parsed_result, 5368 __rte_unused struct cmdline *cl, 5369 __rte_unused void *data) 5370 { 5371 struct cmd_set_link_check *res = parsed_result; 5372 no_link_check = (uint8_t)((strcmp(res->mode, "on") == 0) ? 0 : 1); 5373 } 5374 5375 cmdline_parse_token_string_t cmd_setlinkcheck_set = 5376 TOKEN_STRING_INITIALIZER(struct cmd_set_link_check, 5377 set, "set"); 5378 cmdline_parse_token_string_t cmd_setlinkcheck_link_check = 5379 TOKEN_STRING_INITIALIZER(struct cmd_set_link_check, 5380 link_check, "link_check"); 5381 cmdline_parse_token_string_t cmd_setlinkcheck_mode = 5382 TOKEN_STRING_INITIALIZER(struct cmd_set_link_check, 5383 mode, "on#off"); 5384 5385 5386 cmdline_parse_inst_t cmd_set_link_check = { 5387 .f = cmd_set_link_check_parsed, 5388 .help_str = "set link_check on|off: Enable/Disable link status check " 5389 "when starting/stopping a port", 5390 .data = NULL, 5391 .tokens = { 5392 (void *)&cmd_setlinkcheck_set, 5393 (void *)&cmd_setlinkcheck_link_check, 5394 (void *)&cmd_setlinkcheck_mode, 5395 NULL, 5396 }, 5397 }; 5398 5399 /* *** SET NIC BYPASS MODE *** */ 5400 struct cmd_set_bypass_mode_result { 5401 cmdline_fixed_string_t set; 5402 cmdline_fixed_string_t bypass; 5403 cmdline_fixed_string_t mode; 5404 cmdline_fixed_string_t value; 5405 portid_t port_id; 5406 }; 5407 5408 static void 5409 cmd_set_bypass_mode_parsed(void *parsed_result, 5410 __rte_unused struct cmdline *cl, 5411 __rte_unused void *data) 5412 { 5413 struct cmd_set_bypass_mode_result *res = parsed_result; 5414 portid_t port_id = res->port_id; 5415 int32_t rc = -EINVAL; 5416 5417 #if defined RTE_NET_IXGBE && defined RTE_LIBRTE_IXGBE_BYPASS 5418 uint32_t bypass_mode = RTE_PMD_IXGBE_BYPASS_MODE_NORMAL; 5419 5420 if (!strcmp(res->value, "bypass")) 5421 bypass_mode = RTE_PMD_IXGBE_BYPASS_MODE_BYPASS; 5422 else if (!strcmp(res->value, "isolate")) 5423 bypass_mode = RTE_PMD_IXGBE_BYPASS_MODE_ISOLATE; 5424 else 5425 bypass_mode = RTE_PMD_IXGBE_BYPASS_MODE_NORMAL; 5426 5427 /* Set the bypass mode for the relevant port. */ 5428 rc = rte_pmd_ixgbe_bypass_state_set(port_id, &bypass_mode); 5429 #endif 5430 if (rc != 0) 5431 printf("\t Failed to set bypass mode for port = %d.\n", port_id); 5432 } 5433 5434 cmdline_parse_token_string_t cmd_setbypass_mode_set = 5435 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_mode_result, 5436 set, "set"); 5437 cmdline_parse_token_string_t cmd_setbypass_mode_bypass = 5438 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_mode_result, 5439 bypass, "bypass"); 5440 cmdline_parse_token_string_t cmd_setbypass_mode_mode = 5441 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_mode_result, 5442 mode, "mode"); 5443 cmdline_parse_token_string_t cmd_setbypass_mode_value = 5444 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_mode_result, 5445 value, "normal#bypass#isolate"); 5446 cmdline_parse_token_num_t cmd_setbypass_mode_port = 5447 TOKEN_NUM_INITIALIZER(struct cmd_set_bypass_mode_result, 5448 port_id, RTE_UINT16); 5449 5450 cmdline_parse_inst_t cmd_set_bypass_mode = { 5451 .f = cmd_set_bypass_mode_parsed, 5452 .help_str = "set bypass mode normal|bypass|isolate <port_id>: " 5453 "Set the NIC bypass mode for port_id", 5454 .data = NULL, 5455 .tokens = { 5456 (void *)&cmd_setbypass_mode_set, 5457 (void *)&cmd_setbypass_mode_bypass, 5458 (void *)&cmd_setbypass_mode_mode, 5459 (void *)&cmd_setbypass_mode_value, 5460 (void *)&cmd_setbypass_mode_port, 5461 NULL, 5462 }, 5463 }; 5464 5465 /* *** SET NIC BYPASS EVENT *** */ 5466 struct cmd_set_bypass_event_result { 5467 cmdline_fixed_string_t set; 5468 cmdline_fixed_string_t bypass; 5469 cmdline_fixed_string_t event; 5470 cmdline_fixed_string_t event_value; 5471 cmdline_fixed_string_t mode; 5472 cmdline_fixed_string_t mode_value; 5473 portid_t port_id; 5474 }; 5475 5476 static void 5477 cmd_set_bypass_event_parsed(void *parsed_result, 5478 __rte_unused struct cmdline *cl, 5479 __rte_unused void *data) 5480 { 5481 int32_t rc = -EINVAL; 5482 struct cmd_set_bypass_event_result *res = parsed_result; 5483 portid_t port_id = res->port_id; 5484 5485 #if defined RTE_NET_IXGBE && defined RTE_LIBRTE_IXGBE_BYPASS 5486 uint32_t bypass_event = RTE_PMD_IXGBE_BYPASS_EVENT_NONE; 5487 uint32_t bypass_mode = RTE_PMD_IXGBE_BYPASS_MODE_NORMAL; 5488 5489 if (!strcmp(res->event_value, "timeout")) 5490 bypass_event = RTE_PMD_IXGBE_BYPASS_EVENT_TIMEOUT; 5491 else if (!strcmp(res->event_value, "os_on")) 5492 bypass_event = RTE_PMD_IXGBE_BYPASS_EVENT_OS_ON; 5493 else if (!strcmp(res->event_value, "os_off")) 5494 bypass_event = RTE_PMD_IXGBE_BYPASS_EVENT_OS_OFF; 5495 else if (!strcmp(res->event_value, "power_on")) 5496 bypass_event = RTE_PMD_IXGBE_BYPASS_EVENT_POWER_ON; 5497 else if (!strcmp(res->event_value, "power_off")) 5498 bypass_event = RTE_PMD_IXGBE_BYPASS_EVENT_POWER_OFF; 5499 else 5500 bypass_event = RTE_PMD_IXGBE_BYPASS_EVENT_NONE; 5501 5502 if (!strcmp(res->mode_value, "bypass")) 5503 bypass_mode = RTE_PMD_IXGBE_BYPASS_MODE_BYPASS; 5504 else if (!strcmp(res->mode_value, "isolate")) 5505 bypass_mode = RTE_PMD_IXGBE_BYPASS_MODE_ISOLATE; 5506 else 5507 bypass_mode = RTE_PMD_IXGBE_BYPASS_MODE_NORMAL; 5508 5509 /* Set the watchdog timeout. */ 5510 if (bypass_event == RTE_PMD_IXGBE_BYPASS_EVENT_TIMEOUT) { 5511 5512 rc = -EINVAL; 5513 if (RTE_PMD_IXGBE_BYPASS_TMT_VALID(bypass_timeout)) { 5514 rc = rte_pmd_ixgbe_bypass_wd_timeout_store(port_id, 5515 bypass_timeout); 5516 } 5517 if (rc != 0) { 5518 printf("Failed to set timeout value %u " 5519 "for port %d, errto code: %d.\n", 5520 bypass_timeout, port_id, rc); 5521 } 5522 } 5523 5524 /* Set the bypass event to transition to bypass mode. */ 5525 rc = rte_pmd_ixgbe_bypass_event_store(port_id, bypass_event, 5526 bypass_mode); 5527 #endif 5528 5529 if (rc != 0) 5530 printf("\t Failed to set bypass event for port = %d.\n", 5531 port_id); 5532 } 5533 5534 cmdline_parse_token_string_t cmd_setbypass_event_set = 5535 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_event_result, 5536 set, "set"); 5537 cmdline_parse_token_string_t cmd_setbypass_event_bypass = 5538 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_event_result, 5539 bypass, "bypass"); 5540 cmdline_parse_token_string_t cmd_setbypass_event_event = 5541 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_event_result, 5542 event, "event"); 5543 cmdline_parse_token_string_t cmd_setbypass_event_event_value = 5544 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_event_result, 5545 event_value, "none#timeout#os_off#os_on#power_on#power_off"); 5546 cmdline_parse_token_string_t cmd_setbypass_event_mode = 5547 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_event_result, 5548 mode, "mode"); 5549 cmdline_parse_token_string_t cmd_setbypass_event_mode_value = 5550 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_event_result, 5551 mode_value, "normal#bypass#isolate"); 5552 cmdline_parse_token_num_t cmd_setbypass_event_port = 5553 TOKEN_NUM_INITIALIZER(struct cmd_set_bypass_event_result, 5554 port_id, RTE_UINT16); 5555 5556 cmdline_parse_inst_t cmd_set_bypass_event = { 5557 .f = cmd_set_bypass_event_parsed, 5558 .help_str = "set bypass event none|timeout|os_on|os_off|power_on|" 5559 "power_off mode normal|bypass|isolate <port_id>: " 5560 "Set the NIC bypass event mode for port_id", 5561 .data = NULL, 5562 .tokens = { 5563 (void *)&cmd_setbypass_event_set, 5564 (void *)&cmd_setbypass_event_bypass, 5565 (void *)&cmd_setbypass_event_event, 5566 (void *)&cmd_setbypass_event_event_value, 5567 (void *)&cmd_setbypass_event_mode, 5568 (void *)&cmd_setbypass_event_mode_value, 5569 (void *)&cmd_setbypass_event_port, 5570 NULL, 5571 }, 5572 }; 5573 5574 5575 /* *** SET NIC BYPASS TIMEOUT *** */ 5576 struct cmd_set_bypass_timeout_result { 5577 cmdline_fixed_string_t set; 5578 cmdline_fixed_string_t bypass; 5579 cmdline_fixed_string_t timeout; 5580 cmdline_fixed_string_t value; 5581 }; 5582 5583 static void 5584 cmd_set_bypass_timeout_parsed(void *parsed_result, 5585 __rte_unused struct cmdline *cl, 5586 __rte_unused void *data) 5587 { 5588 __rte_unused struct cmd_set_bypass_timeout_result *res = parsed_result; 5589 5590 #if defined RTE_NET_IXGBE && defined RTE_LIBRTE_IXGBE_BYPASS 5591 if (!strcmp(res->value, "1.5")) 5592 bypass_timeout = RTE_PMD_IXGBE_BYPASS_TMT_1_5_SEC; 5593 else if (!strcmp(res->value, "2")) 5594 bypass_timeout = RTE_PMD_IXGBE_BYPASS_TMT_2_SEC; 5595 else if (!strcmp(res->value, "3")) 5596 bypass_timeout = RTE_PMD_IXGBE_BYPASS_TMT_3_SEC; 5597 else if (!strcmp(res->value, "4")) 5598 bypass_timeout = RTE_PMD_IXGBE_BYPASS_TMT_4_SEC; 5599 else if (!strcmp(res->value, "8")) 5600 bypass_timeout = RTE_PMD_IXGBE_BYPASS_TMT_8_SEC; 5601 else if (!strcmp(res->value, "16")) 5602 bypass_timeout = RTE_PMD_IXGBE_BYPASS_TMT_16_SEC; 5603 else if (!strcmp(res->value, "32")) 5604 bypass_timeout = RTE_PMD_IXGBE_BYPASS_TMT_32_SEC; 5605 else 5606 bypass_timeout = RTE_PMD_IXGBE_BYPASS_TMT_OFF; 5607 #endif 5608 } 5609 5610 cmdline_parse_token_string_t cmd_setbypass_timeout_set = 5611 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_timeout_result, 5612 set, "set"); 5613 cmdline_parse_token_string_t cmd_setbypass_timeout_bypass = 5614 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_timeout_result, 5615 bypass, "bypass"); 5616 cmdline_parse_token_string_t cmd_setbypass_timeout_timeout = 5617 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_timeout_result, 5618 timeout, "timeout"); 5619 cmdline_parse_token_string_t cmd_setbypass_timeout_value = 5620 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_timeout_result, 5621 value, "0#1.5#2#3#4#8#16#32"); 5622 5623 cmdline_parse_inst_t cmd_set_bypass_timeout = { 5624 .f = cmd_set_bypass_timeout_parsed, 5625 .help_str = "set bypass timeout 0|1.5|2|3|4|8|16|32: " 5626 "Set the NIC bypass watchdog timeout in seconds", 5627 .data = NULL, 5628 .tokens = { 5629 (void *)&cmd_setbypass_timeout_set, 5630 (void *)&cmd_setbypass_timeout_bypass, 5631 (void *)&cmd_setbypass_timeout_timeout, 5632 (void *)&cmd_setbypass_timeout_value, 5633 NULL, 5634 }, 5635 }; 5636 5637 /* *** SHOW NIC BYPASS MODE *** */ 5638 struct cmd_show_bypass_config_result { 5639 cmdline_fixed_string_t show; 5640 cmdline_fixed_string_t bypass; 5641 cmdline_fixed_string_t config; 5642 portid_t port_id; 5643 }; 5644 5645 static void 5646 cmd_show_bypass_config_parsed(void *parsed_result, 5647 __rte_unused struct cmdline *cl, 5648 __rte_unused void *data) 5649 { 5650 struct cmd_show_bypass_config_result *res = parsed_result; 5651 portid_t port_id = res->port_id; 5652 int rc = -EINVAL; 5653 #if defined RTE_NET_IXGBE && defined RTE_LIBRTE_IXGBE_BYPASS 5654 uint32_t event_mode; 5655 uint32_t bypass_mode; 5656 uint32_t timeout = bypass_timeout; 5657 unsigned int i; 5658 5659 static const char * const timeouts[RTE_PMD_IXGBE_BYPASS_TMT_NUM] = 5660 {"off", "1.5", "2", "3", "4", "8", "16", "32"}; 5661 static const char * const modes[RTE_PMD_IXGBE_BYPASS_MODE_NUM] = 5662 {"UNKNOWN", "normal", "bypass", "isolate"}; 5663 static const char * const events[RTE_PMD_IXGBE_BYPASS_EVENT_NUM] = { 5664 "NONE", 5665 "OS/board on", 5666 "power supply on", 5667 "OS/board off", 5668 "power supply off", 5669 "timeout"}; 5670 5671 /* Display the bypass mode.*/ 5672 if (rte_pmd_ixgbe_bypass_state_show(port_id, &bypass_mode) != 0) { 5673 printf("\tFailed to get bypass mode for port = %d\n", port_id); 5674 return; 5675 } 5676 else { 5677 if (!RTE_PMD_IXGBE_BYPASS_MODE_VALID(bypass_mode)) 5678 bypass_mode = RTE_PMD_IXGBE_BYPASS_MODE_NONE; 5679 5680 printf("\tbypass mode = %s\n", modes[bypass_mode]); 5681 } 5682 5683 /* Display the bypass timeout.*/ 5684 if (!RTE_PMD_IXGBE_BYPASS_TMT_VALID(timeout)) 5685 timeout = RTE_PMD_IXGBE_BYPASS_TMT_OFF; 5686 5687 printf("\tbypass timeout = %s\n", timeouts[timeout]); 5688 5689 /* Display the bypass events and associated modes. */ 5690 for (i = RTE_PMD_IXGBE_BYPASS_EVENT_START; i < RTE_DIM(events); i++) { 5691 5692 if (rte_pmd_ixgbe_bypass_event_show(port_id, i, &event_mode)) { 5693 printf("\tFailed to get bypass mode for event = %s\n", 5694 events[i]); 5695 } else { 5696 if (!RTE_PMD_IXGBE_BYPASS_MODE_VALID(event_mode)) 5697 event_mode = RTE_PMD_IXGBE_BYPASS_MODE_NONE; 5698 5699 printf("\tbypass event: %-16s = %s\n", events[i], 5700 modes[event_mode]); 5701 } 5702 } 5703 #endif 5704 if (rc != 0) 5705 printf("\tFailed to get bypass configuration for port = %d\n", 5706 port_id); 5707 } 5708 5709 cmdline_parse_token_string_t cmd_showbypass_config_show = 5710 TOKEN_STRING_INITIALIZER(struct cmd_show_bypass_config_result, 5711 show, "show"); 5712 cmdline_parse_token_string_t cmd_showbypass_config_bypass = 5713 TOKEN_STRING_INITIALIZER(struct cmd_show_bypass_config_result, 5714 bypass, "bypass"); 5715 cmdline_parse_token_string_t cmd_showbypass_config_config = 5716 TOKEN_STRING_INITIALIZER(struct cmd_show_bypass_config_result, 5717 config, "config"); 5718 cmdline_parse_token_num_t cmd_showbypass_config_port = 5719 TOKEN_NUM_INITIALIZER(struct cmd_show_bypass_config_result, 5720 port_id, RTE_UINT16); 5721 5722 cmdline_parse_inst_t cmd_show_bypass_config = { 5723 .f = cmd_show_bypass_config_parsed, 5724 .help_str = "show bypass config <port_id>: " 5725 "Show the NIC bypass config for port_id", 5726 .data = NULL, 5727 .tokens = { 5728 (void *)&cmd_showbypass_config_show, 5729 (void *)&cmd_showbypass_config_bypass, 5730 (void *)&cmd_showbypass_config_config, 5731 (void *)&cmd_showbypass_config_port, 5732 NULL, 5733 }, 5734 }; 5735 5736 #ifdef RTE_NET_BOND 5737 /* *** SET BONDING MODE *** */ 5738 struct cmd_set_bonding_mode_result { 5739 cmdline_fixed_string_t set; 5740 cmdline_fixed_string_t bonding; 5741 cmdline_fixed_string_t mode; 5742 uint8_t value; 5743 portid_t port_id; 5744 }; 5745 5746 static void cmd_set_bonding_mode_parsed(void *parsed_result, 5747 __rte_unused struct cmdline *cl, 5748 __rte_unused void *data) 5749 { 5750 struct cmd_set_bonding_mode_result *res = parsed_result; 5751 portid_t port_id = res->port_id; 5752 5753 /* Set the bonding mode for the relevant port. */ 5754 if (0 != rte_eth_bond_mode_set(port_id, res->value)) 5755 printf("\t Failed to set bonding mode for port = %d.\n", port_id); 5756 } 5757 5758 cmdline_parse_token_string_t cmd_setbonding_mode_set = 5759 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_mode_result, 5760 set, "set"); 5761 cmdline_parse_token_string_t cmd_setbonding_mode_bonding = 5762 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_mode_result, 5763 bonding, "bonding"); 5764 cmdline_parse_token_string_t cmd_setbonding_mode_mode = 5765 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_mode_result, 5766 mode, "mode"); 5767 cmdline_parse_token_num_t cmd_setbonding_mode_value = 5768 TOKEN_NUM_INITIALIZER(struct cmd_set_bonding_mode_result, 5769 value, RTE_UINT8); 5770 cmdline_parse_token_num_t cmd_setbonding_mode_port = 5771 TOKEN_NUM_INITIALIZER(struct cmd_set_bonding_mode_result, 5772 port_id, RTE_UINT16); 5773 5774 cmdline_parse_inst_t cmd_set_bonding_mode = { 5775 .f = cmd_set_bonding_mode_parsed, 5776 .help_str = "set bonding mode <mode_value> <port_id>: " 5777 "Set the bonding mode for port_id", 5778 .data = NULL, 5779 .tokens = { 5780 (void *) &cmd_setbonding_mode_set, 5781 (void *) &cmd_setbonding_mode_bonding, 5782 (void *) &cmd_setbonding_mode_mode, 5783 (void *) &cmd_setbonding_mode_value, 5784 (void *) &cmd_setbonding_mode_port, 5785 NULL 5786 } 5787 }; 5788 5789 /* *** SET BONDING SLOW_QUEUE SW/HW *** */ 5790 struct cmd_set_bonding_lacp_dedicated_queues_result { 5791 cmdline_fixed_string_t set; 5792 cmdline_fixed_string_t bonding; 5793 cmdline_fixed_string_t lacp; 5794 cmdline_fixed_string_t dedicated_queues; 5795 portid_t port_id; 5796 cmdline_fixed_string_t mode; 5797 }; 5798 5799 static void cmd_set_bonding_lacp_dedicated_queues_parsed(void *parsed_result, 5800 __rte_unused struct cmdline *cl, 5801 __rte_unused void *data) 5802 { 5803 struct cmd_set_bonding_lacp_dedicated_queues_result *res = parsed_result; 5804 portid_t port_id = res->port_id; 5805 struct rte_port *port; 5806 5807 port = &ports[port_id]; 5808 5809 /** Check if the port is not started **/ 5810 if (port->port_status != RTE_PORT_STOPPED) { 5811 printf("Please stop port %d first\n", port_id); 5812 return; 5813 } 5814 5815 if (!strcmp(res->mode, "enable")) { 5816 if (rte_eth_bond_8023ad_dedicated_queues_enable(port_id) == 0) 5817 printf("Dedicate queues for LACP control packets" 5818 " enabled\n"); 5819 else 5820 printf("Enabling dedicate queues for LACP control " 5821 "packets on port %d failed\n", port_id); 5822 } else if (!strcmp(res->mode, "disable")) { 5823 if (rte_eth_bond_8023ad_dedicated_queues_disable(port_id) == 0) 5824 printf("Dedicated queues for LACP control packets " 5825 "disabled\n"); 5826 else 5827 printf("Disabling dedicated queues for LACP control " 5828 "traffic on port %d failed\n", port_id); 5829 } 5830 } 5831 5832 cmdline_parse_token_string_t cmd_setbonding_lacp_dedicated_queues_set = 5833 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_lacp_dedicated_queues_result, 5834 set, "set"); 5835 cmdline_parse_token_string_t cmd_setbonding_lacp_dedicated_queues_bonding = 5836 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_lacp_dedicated_queues_result, 5837 bonding, "bonding"); 5838 cmdline_parse_token_string_t cmd_setbonding_lacp_dedicated_queues_lacp = 5839 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_lacp_dedicated_queues_result, 5840 lacp, "lacp"); 5841 cmdline_parse_token_string_t cmd_setbonding_lacp_dedicated_queues_dedicated_queues = 5842 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_lacp_dedicated_queues_result, 5843 dedicated_queues, "dedicated_queues"); 5844 cmdline_parse_token_num_t cmd_setbonding_lacp_dedicated_queues_port_id = 5845 TOKEN_NUM_INITIALIZER(struct cmd_set_bonding_lacp_dedicated_queues_result, 5846 port_id, RTE_UINT16); 5847 cmdline_parse_token_string_t cmd_setbonding_lacp_dedicated_queues_mode = 5848 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_lacp_dedicated_queues_result, 5849 mode, "enable#disable"); 5850 5851 cmdline_parse_inst_t cmd_set_lacp_dedicated_queues = { 5852 .f = cmd_set_bonding_lacp_dedicated_queues_parsed, 5853 .help_str = "set bonding lacp dedicated_queues <port_id> " 5854 "enable|disable: " 5855 "Enable/disable dedicated queues for LACP control traffic for port_id", 5856 .data = NULL, 5857 .tokens = { 5858 (void *)&cmd_setbonding_lacp_dedicated_queues_set, 5859 (void *)&cmd_setbonding_lacp_dedicated_queues_bonding, 5860 (void *)&cmd_setbonding_lacp_dedicated_queues_lacp, 5861 (void *)&cmd_setbonding_lacp_dedicated_queues_dedicated_queues, 5862 (void *)&cmd_setbonding_lacp_dedicated_queues_port_id, 5863 (void *)&cmd_setbonding_lacp_dedicated_queues_mode, 5864 NULL 5865 } 5866 }; 5867 5868 /* *** SET BALANCE XMIT POLICY *** */ 5869 struct cmd_set_bonding_balance_xmit_policy_result { 5870 cmdline_fixed_string_t set; 5871 cmdline_fixed_string_t bonding; 5872 cmdline_fixed_string_t balance_xmit_policy; 5873 portid_t port_id; 5874 cmdline_fixed_string_t policy; 5875 }; 5876 5877 static void cmd_set_bonding_balance_xmit_policy_parsed(void *parsed_result, 5878 __rte_unused struct cmdline *cl, 5879 __rte_unused void *data) 5880 { 5881 struct cmd_set_bonding_balance_xmit_policy_result *res = parsed_result; 5882 portid_t port_id = res->port_id; 5883 uint8_t policy; 5884 5885 if (!strcmp(res->policy, "l2")) { 5886 policy = BALANCE_XMIT_POLICY_LAYER2; 5887 } else if (!strcmp(res->policy, "l23")) { 5888 policy = BALANCE_XMIT_POLICY_LAYER23; 5889 } else if (!strcmp(res->policy, "l34")) { 5890 policy = BALANCE_XMIT_POLICY_LAYER34; 5891 } else { 5892 printf("\t Invalid xmit policy selection"); 5893 return; 5894 } 5895 5896 /* Set the bonding mode for the relevant port. */ 5897 if (0 != rte_eth_bond_xmit_policy_set(port_id, policy)) { 5898 printf("\t Failed to set bonding balance xmit policy for port = %d.\n", 5899 port_id); 5900 } 5901 } 5902 5903 cmdline_parse_token_string_t cmd_setbonding_balance_xmit_policy_set = 5904 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_balance_xmit_policy_result, 5905 set, "set"); 5906 cmdline_parse_token_string_t cmd_setbonding_balance_xmit_policy_bonding = 5907 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_balance_xmit_policy_result, 5908 bonding, "bonding"); 5909 cmdline_parse_token_string_t cmd_setbonding_balance_xmit_policy_balance_xmit_policy = 5910 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_balance_xmit_policy_result, 5911 balance_xmit_policy, "balance_xmit_policy"); 5912 cmdline_parse_token_num_t cmd_setbonding_balance_xmit_policy_port = 5913 TOKEN_NUM_INITIALIZER(struct cmd_set_bonding_balance_xmit_policy_result, 5914 port_id, RTE_UINT16); 5915 cmdline_parse_token_string_t cmd_setbonding_balance_xmit_policy_policy = 5916 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_balance_xmit_policy_result, 5917 policy, "l2#l23#l34"); 5918 5919 cmdline_parse_inst_t cmd_set_balance_xmit_policy = { 5920 .f = cmd_set_bonding_balance_xmit_policy_parsed, 5921 .help_str = "set bonding balance_xmit_policy <port_id> " 5922 "l2|l23|l34: " 5923 "Set the bonding balance_xmit_policy for port_id", 5924 .data = NULL, 5925 .tokens = { 5926 (void *)&cmd_setbonding_balance_xmit_policy_set, 5927 (void *)&cmd_setbonding_balance_xmit_policy_bonding, 5928 (void *)&cmd_setbonding_balance_xmit_policy_balance_xmit_policy, 5929 (void *)&cmd_setbonding_balance_xmit_policy_port, 5930 (void *)&cmd_setbonding_balance_xmit_policy_policy, 5931 NULL 5932 } 5933 }; 5934 5935 /* *** SHOW NIC BONDING CONFIGURATION *** */ 5936 struct cmd_show_bonding_config_result { 5937 cmdline_fixed_string_t show; 5938 cmdline_fixed_string_t bonding; 5939 cmdline_fixed_string_t config; 5940 portid_t port_id; 5941 }; 5942 5943 static void cmd_show_bonding_config_parsed(void *parsed_result, 5944 __rte_unused struct cmdline *cl, 5945 __rte_unused void *data) 5946 { 5947 struct cmd_show_bonding_config_result *res = parsed_result; 5948 int bonding_mode, agg_mode; 5949 portid_t slaves[RTE_MAX_ETHPORTS]; 5950 int num_slaves, num_active_slaves; 5951 int primary_id; 5952 int i; 5953 portid_t port_id = res->port_id; 5954 5955 /* Display the bonding mode.*/ 5956 bonding_mode = rte_eth_bond_mode_get(port_id); 5957 if (bonding_mode < 0) { 5958 printf("\tFailed to get bonding mode for port = %d\n", port_id); 5959 return; 5960 } else 5961 printf("\tBonding mode: %d\n", bonding_mode); 5962 5963 if (bonding_mode == BONDING_MODE_BALANCE) { 5964 int balance_xmit_policy; 5965 5966 balance_xmit_policy = rte_eth_bond_xmit_policy_get(port_id); 5967 if (balance_xmit_policy < 0) { 5968 printf("\tFailed to get balance xmit policy for port = %d\n", 5969 port_id); 5970 return; 5971 } else { 5972 printf("\tBalance Xmit Policy: "); 5973 5974 switch (balance_xmit_policy) { 5975 case BALANCE_XMIT_POLICY_LAYER2: 5976 printf("BALANCE_XMIT_POLICY_LAYER2"); 5977 break; 5978 case BALANCE_XMIT_POLICY_LAYER23: 5979 printf("BALANCE_XMIT_POLICY_LAYER23"); 5980 break; 5981 case BALANCE_XMIT_POLICY_LAYER34: 5982 printf("BALANCE_XMIT_POLICY_LAYER34"); 5983 break; 5984 } 5985 printf("\n"); 5986 } 5987 } 5988 5989 if (bonding_mode == BONDING_MODE_8023AD) { 5990 agg_mode = rte_eth_bond_8023ad_agg_selection_get(port_id); 5991 printf("\tIEEE802.3AD Aggregator Mode: "); 5992 switch (agg_mode) { 5993 case AGG_BANDWIDTH: 5994 printf("bandwidth"); 5995 break; 5996 case AGG_STABLE: 5997 printf("stable"); 5998 break; 5999 case AGG_COUNT: 6000 printf("count"); 6001 break; 6002 } 6003 printf("\n"); 6004 } 6005 6006 num_slaves = rte_eth_bond_slaves_get(port_id, slaves, RTE_MAX_ETHPORTS); 6007 6008 if (num_slaves < 0) { 6009 printf("\tFailed to get slave list for port = %d\n", port_id); 6010 return; 6011 } 6012 if (num_slaves > 0) { 6013 printf("\tSlaves (%d): [", num_slaves); 6014 for (i = 0; i < num_slaves - 1; i++) 6015 printf("%d ", slaves[i]); 6016 6017 printf("%d]\n", slaves[num_slaves - 1]); 6018 } else { 6019 printf("\tSlaves: []\n"); 6020 6021 } 6022 6023 num_active_slaves = rte_eth_bond_active_slaves_get(port_id, slaves, 6024 RTE_MAX_ETHPORTS); 6025 6026 if (num_active_slaves < 0) { 6027 printf("\tFailed to get active slave list for port = %d\n", port_id); 6028 return; 6029 } 6030 if (num_active_slaves > 0) { 6031 printf("\tActive Slaves (%d): [", num_active_slaves); 6032 for (i = 0; i < num_active_slaves - 1; i++) 6033 printf("%d ", slaves[i]); 6034 6035 printf("%d]\n", slaves[num_active_slaves - 1]); 6036 6037 } else { 6038 printf("\tActive Slaves: []\n"); 6039 6040 } 6041 6042 primary_id = rte_eth_bond_primary_get(port_id); 6043 if (primary_id < 0) { 6044 printf("\tFailed to get primary slave for port = %d\n", port_id); 6045 return; 6046 } else 6047 printf("\tPrimary: [%d]\n", primary_id); 6048 6049 } 6050 6051 cmdline_parse_token_string_t cmd_showbonding_config_show = 6052 TOKEN_STRING_INITIALIZER(struct cmd_show_bonding_config_result, 6053 show, "show"); 6054 cmdline_parse_token_string_t cmd_showbonding_config_bonding = 6055 TOKEN_STRING_INITIALIZER(struct cmd_show_bonding_config_result, 6056 bonding, "bonding"); 6057 cmdline_parse_token_string_t cmd_showbonding_config_config = 6058 TOKEN_STRING_INITIALIZER(struct cmd_show_bonding_config_result, 6059 config, "config"); 6060 cmdline_parse_token_num_t cmd_showbonding_config_port = 6061 TOKEN_NUM_INITIALIZER(struct cmd_show_bonding_config_result, 6062 port_id, RTE_UINT16); 6063 6064 cmdline_parse_inst_t cmd_show_bonding_config = { 6065 .f = cmd_show_bonding_config_parsed, 6066 .help_str = "show bonding config <port_id>: " 6067 "Show the bonding config for port_id", 6068 .data = NULL, 6069 .tokens = { 6070 (void *)&cmd_showbonding_config_show, 6071 (void *)&cmd_showbonding_config_bonding, 6072 (void *)&cmd_showbonding_config_config, 6073 (void *)&cmd_showbonding_config_port, 6074 NULL 6075 } 6076 }; 6077 6078 /* *** SET BONDING PRIMARY *** */ 6079 struct cmd_set_bonding_primary_result { 6080 cmdline_fixed_string_t set; 6081 cmdline_fixed_string_t bonding; 6082 cmdline_fixed_string_t primary; 6083 portid_t slave_id; 6084 portid_t port_id; 6085 }; 6086 6087 static void cmd_set_bonding_primary_parsed(void *parsed_result, 6088 __rte_unused struct cmdline *cl, 6089 __rte_unused void *data) 6090 { 6091 struct cmd_set_bonding_primary_result *res = parsed_result; 6092 portid_t master_port_id = res->port_id; 6093 portid_t slave_port_id = res->slave_id; 6094 6095 /* Set the primary slave for a bonded device. */ 6096 if (0 != rte_eth_bond_primary_set(master_port_id, slave_port_id)) { 6097 printf("\t Failed to set primary slave for port = %d.\n", 6098 master_port_id); 6099 return; 6100 } 6101 init_port_config(); 6102 } 6103 6104 cmdline_parse_token_string_t cmd_setbonding_primary_set = 6105 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_primary_result, 6106 set, "set"); 6107 cmdline_parse_token_string_t cmd_setbonding_primary_bonding = 6108 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_primary_result, 6109 bonding, "bonding"); 6110 cmdline_parse_token_string_t cmd_setbonding_primary_primary = 6111 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_primary_result, 6112 primary, "primary"); 6113 cmdline_parse_token_num_t cmd_setbonding_primary_slave = 6114 TOKEN_NUM_INITIALIZER(struct cmd_set_bonding_primary_result, 6115 slave_id, RTE_UINT16); 6116 cmdline_parse_token_num_t cmd_setbonding_primary_port = 6117 TOKEN_NUM_INITIALIZER(struct cmd_set_bonding_primary_result, 6118 port_id, RTE_UINT16); 6119 6120 cmdline_parse_inst_t cmd_set_bonding_primary = { 6121 .f = cmd_set_bonding_primary_parsed, 6122 .help_str = "set bonding primary <slave_id> <port_id>: " 6123 "Set the primary slave for port_id", 6124 .data = NULL, 6125 .tokens = { 6126 (void *)&cmd_setbonding_primary_set, 6127 (void *)&cmd_setbonding_primary_bonding, 6128 (void *)&cmd_setbonding_primary_primary, 6129 (void *)&cmd_setbonding_primary_slave, 6130 (void *)&cmd_setbonding_primary_port, 6131 NULL 6132 } 6133 }; 6134 6135 /* *** ADD SLAVE *** */ 6136 struct cmd_add_bonding_slave_result { 6137 cmdline_fixed_string_t add; 6138 cmdline_fixed_string_t bonding; 6139 cmdline_fixed_string_t slave; 6140 portid_t slave_id; 6141 portid_t port_id; 6142 }; 6143 6144 static void cmd_add_bonding_slave_parsed(void *parsed_result, 6145 __rte_unused struct cmdline *cl, 6146 __rte_unused void *data) 6147 { 6148 struct cmd_add_bonding_slave_result *res = parsed_result; 6149 portid_t master_port_id = res->port_id; 6150 portid_t slave_port_id = res->slave_id; 6151 6152 /* add the slave for a bonded device. */ 6153 if (0 != rte_eth_bond_slave_add(master_port_id, slave_port_id)) { 6154 printf("\t Failed to add slave %d to master port = %d.\n", 6155 slave_port_id, master_port_id); 6156 return; 6157 } 6158 init_port_config(); 6159 set_port_slave_flag(slave_port_id); 6160 } 6161 6162 cmdline_parse_token_string_t cmd_addbonding_slave_add = 6163 TOKEN_STRING_INITIALIZER(struct cmd_add_bonding_slave_result, 6164 add, "add"); 6165 cmdline_parse_token_string_t cmd_addbonding_slave_bonding = 6166 TOKEN_STRING_INITIALIZER(struct cmd_add_bonding_slave_result, 6167 bonding, "bonding"); 6168 cmdline_parse_token_string_t cmd_addbonding_slave_slave = 6169 TOKEN_STRING_INITIALIZER(struct cmd_add_bonding_slave_result, 6170 slave, "slave"); 6171 cmdline_parse_token_num_t cmd_addbonding_slave_slaveid = 6172 TOKEN_NUM_INITIALIZER(struct cmd_add_bonding_slave_result, 6173 slave_id, RTE_UINT16); 6174 cmdline_parse_token_num_t cmd_addbonding_slave_port = 6175 TOKEN_NUM_INITIALIZER(struct cmd_add_bonding_slave_result, 6176 port_id, RTE_UINT16); 6177 6178 cmdline_parse_inst_t cmd_add_bonding_slave = { 6179 .f = cmd_add_bonding_slave_parsed, 6180 .help_str = "add bonding slave <slave_id> <port_id>: " 6181 "Add a slave device to a bonded device", 6182 .data = NULL, 6183 .tokens = { 6184 (void *)&cmd_addbonding_slave_add, 6185 (void *)&cmd_addbonding_slave_bonding, 6186 (void *)&cmd_addbonding_slave_slave, 6187 (void *)&cmd_addbonding_slave_slaveid, 6188 (void *)&cmd_addbonding_slave_port, 6189 NULL 6190 } 6191 }; 6192 6193 /* *** REMOVE SLAVE *** */ 6194 struct cmd_remove_bonding_slave_result { 6195 cmdline_fixed_string_t remove; 6196 cmdline_fixed_string_t bonding; 6197 cmdline_fixed_string_t slave; 6198 portid_t slave_id; 6199 portid_t port_id; 6200 }; 6201 6202 static void cmd_remove_bonding_slave_parsed(void *parsed_result, 6203 __rte_unused struct cmdline *cl, 6204 __rte_unused void *data) 6205 { 6206 struct cmd_remove_bonding_slave_result *res = parsed_result; 6207 portid_t master_port_id = res->port_id; 6208 portid_t slave_port_id = res->slave_id; 6209 6210 /* remove the slave from a bonded device. */ 6211 if (0 != rte_eth_bond_slave_remove(master_port_id, slave_port_id)) { 6212 printf("\t Failed to remove slave %d from master port = %d.\n", 6213 slave_port_id, master_port_id); 6214 return; 6215 } 6216 init_port_config(); 6217 clear_port_slave_flag(slave_port_id); 6218 } 6219 6220 cmdline_parse_token_string_t cmd_removebonding_slave_remove = 6221 TOKEN_STRING_INITIALIZER(struct cmd_remove_bonding_slave_result, 6222 remove, "remove"); 6223 cmdline_parse_token_string_t cmd_removebonding_slave_bonding = 6224 TOKEN_STRING_INITIALIZER(struct cmd_remove_bonding_slave_result, 6225 bonding, "bonding"); 6226 cmdline_parse_token_string_t cmd_removebonding_slave_slave = 6227 TOKEN_STRING_INITIALIZER(struct cmd_remove_bonding_slave_result, 6228 slave, "slave"); 6229 cmdline_parse_token_num_t cmd_removebonding_slave_slaveid = 6230 TOKEN_NUM_INITIALIZER(struct cmd_remove_bonding_slave_result, 6231 slave_id, RTE_UINT16); 6232 cmdline_parse_token_num_t cmd_removebonding_slave_port = 6233 TOKEN_NUM_INITIALIZER(struct cmd_remove_bonding_slave_result, 6234 port_id, RTE_UINT16); 6235 6236 cmdline_parse_inst_t cmd_remove_bonding_slave = { 6237 .f = cmd_remove_bonding_slave_parsed, 6238 .help_str = "remove bonding slave <slave_id> <port_id>: " 6239 "Remove a slave device from a bonded device", 6240 .data = NULL, 6241 .tokens = { 6242 (void *)&cmd_removebonding_slave_remove, 6243 (void *)&cmd_removebonding_slave_bonding, 6244 (void *)&cmd_removebonding_slave_slave, 6245 (void *)&cmd_removebonding_slave_slaveid, 6246 (void *)&cmd_removebonding_slave_port, 6247 NULL 6248 } 6249 }; 6250 6251 /* *** CREATE BONDED DEVICE *** */ 6252 struct cmd_create_bonded_device_result { 6253 cmdline_fixed_string_t create; 6254 cmdline_fixed_string_t bonded; 6255 cmdline_fixed_string_t device; 6256 uint8_t mode; 6257 uint8_t socket; 6258 }; 6259 6260 static int bond_dev_num = 0; 6261 6262 static void cmd_create_bonded_device_parsed(void *parsed_result, 6263 __rte_unused struct cmdline *cl, 6264 __rte_unused void *data) 6265 { 6266 struct cmd_create_bonded_device_result *res = parsed_result; 6267 char ethdev_name[RTE_ETH_NAME_MAX_LEN]; 6268 int port_id; 6269 int ret; 6270 6271 if (test_done == 0) { 6272 printf("Please stop forwarding first\n"); 6273 return; 6274 } 6275 6276 snprintf(ethdev_name, RTE_ETH_NAME_MAX_LEN, "net_bonding_testpmd_%d", 6277 bond_dev_num++); 6278 6279 /* Create a new bonded device. */ 6280 port_id = rte_eth_bond_create(ethdev_name, res->mode, res->socket); 6281 if (port_id < 0) { 6282 printf("\t Failed to create bonded device.\n"); 6283 return; 6284 } else { 6285 printf("Created new bonded device %s on (port %d).\n", ethdev_name, 6286 port_id); 6287 6288 /* Update number of ports */ 6289 nb_ports = rte_eth_dev_count_avail(); 6290 reconfig(port_id, res->socket); 6291 ret = rte_eth_promiscuous_enable(port_id); 6292 if (ret != 0) 6293 printf("Failed to enable promiscuous mode for port %u: %s - ignore\n", 6294 port_id, rte_strerror(-ret)); 6295 6296 ports[port_id].need_setup = 0; 6297 ports[port_id].port_status = RTE_PORT_STOPPED; 6298 } 6299 6300 } 6301 6302 cmdline_parse_token_string_t cmd_createbonded_device_create = 6303 TOKEN_STRING_INITIALIZER(struct cmd_create_bonded_device_result, 6304 create, "create"); 6305 cmdline_parse_token_string_t cmd_createbonded_device_bonded = 6306 TOKEN_STRING_INITIALIZER(struct cmd_create_bonded_device_result, 6307 bonded, "bonded"); 6308 cmdline_parse_token_string_t cmd_createbonded_device_device = 6309 TOKEN_STRING_INITIALIZER(struct cmd_create_bonded_device_result, 6310 device, "device"); 6311 cmdline_parse_token_num_t cmd_createbonded_device_mode = 6312 TOKEN_NUM_INITIALIZER(struct cmd_create_bonded_device_result, 6313 mode, RTE_UINT8); 6314 cmdline_parse_token_num_t cmd_createbonded_device_socket = 6315 TOKEN_NUM_INITIALIZER(struct cmd_create_bonded_device_result, 6316 socket, RTE_UINT8); 6317 6318 cmdline_parse_inst_t cmd_create_bonded_device = { 6319 .f = cmd_create_bonded_device_parsed, 6320 .help_str = "create bonded device <mode> <socket>: " 6321 "Create a new bonded device with specific bonding mode and socket", 6322 .data = NULL, 6323 .tokens = { 6324 (void *)&cmd_createbonded_device_create, 6325 (void *)&cmd_createbonded_device_bonded, 6326 (void *)&cmd_createbonded_device_device, 6327 (void *)&cmd_createbonded_device_mode, 6328 (void *)&cmd_createbonded_device_socket, 6329 NULL 6330 } 6331 }; 6332 6333 /* *** SET MAC ADDRESS IN BONDED DEVICE *** */ 6334 struct cmd_set_bond_mac_addr_result { 6335 cmdline_fixed_string_t set; 6336 cmdline_fixed_string_t bonding; 6337 cmdline_fixed_string_t mac_addr; 6338 uint16_t port_num; 6339 struct rte_ether_addr address; 6340 }; 6341 6342 static void cmd_set_bond_mac_addr_parsed(void *parsed_result, 6343 __rte_unused struct cmdline *cl, 6344 __rte_unused void *data) 6345 { 6346 struct cmd_set_bond_mac_addr_result *res = parsed_result; 6347 int ret; 6348 6349 if (port_id_is_invalid(res->port_num, ENABLED_WARN)) 6350 return; 6351 6352 ret = rte_eth_bond_mac_address_set(res->port_num, &res->address); 6353 6354 /* check the return value and print it if is < 0 */ 6355 if (ret < 0) 6356 printf("set_bond_mac_addr error: (%s)\n", strerror(-ret)); 6357 } 6358 6359 cmdline_parse_token_string_t cmd_set_bond_mac_addr_set = 6360 TOKEN_STRING_INITIALIZER(struct cmd_set_bond_mac_addr_result, set, "set"); 6361 cmdline_parse_token_string_t cmd_set_bond_mac_addr_bonding = 6362 TOKEN_STRING_INITIALIZER(struct cmd_set_bond_mac_addr_result, bonding, 6363 "bonding"); 6364 cmdline_parse_token_string_t cmd_set_bond_mac_addr_mac = 6365 TOKEN_STRING_INITIALIZER(struct cmd_set_bond_mac_addr_result, mac_addr, 6366 "mac_addr"); 6367 cmdline_parse_token_num_t cmd_set_bond_mac_addr_portnum = 6368 TOKEN_NUM_INITIALIZER(struct cmd_set_bond_mac_addr_result, 6369 port_num, RTE_UINT16); 6370 cmdline_parse_token_etheraddr_t cmd_set_bond_mac_addr_addr = 6371 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_bond_mac_addr_result, address); 6372 6373 cmdline_parse_inst_t cmd_set_bond_mac_addr = { 6374 .f = cmd_set_bond_mac_addr_parsed, 6375 .data = (void *) 0, 6376 .help_str = "set bonding mac_addr <port_id> <mac_addr>", 6377 .tokens = { 6378 (void *)&cmd_set_bond_mac_addr_set, 6379 (void *)&cmd_set_bond_mac_addr_bonding, 6380 (void *)&cmd_set_bond_mac_addr_mac, 6381 (void *)&cmd_set_bond_mac_addr_portnum, 6382 (void *)&cmd_set_bond_mac_addr_addr, 6383 NULL 6384 } 6385 }; 6386 6387 6388 /* *** SET LINK STATUS MONITORING POLLING PERIOD ON BONDED DEVICE *** */ 6389 struct cmd_set_bond_mon_period_result { 6390 cmdline_fixed_string_t set; 6391 cmdline_fixed_string_t bonding; 6392 cmdline_fixed_string_t mon_period; 6393 uint16_t port_num; 6394 uint32_t period_ms; 6395 }; 6396 6397 static void cmd_set_bond_mon_period_parsed(void *parsed_result, 6398 __rte_unused struct cmdline *cl, 6399 __rte_unused void *data) 6400 { 6401 struct cmd_set_bond_mon_period_result *res = parsed_result; 6402 int ret; 6403 6404 ret = rte_eth_bond_link_monitoring_set(res->port_num, res->period_ms); 6405 6406 /* check the return value and print it if is < 0 */ 6407 if (ret < 0) 6408 printf("set_bond_mac_addr error: (%s)\n", strerror(-ret)); 6409 } 6410 6411 cmdline_parse_token_string_t cmd_set_bond_mon_period_set = 6412 TOKEN_STRING_INITIALIZER(struct cmd_set_bond_mon_period_result, 6413 set, "set"); 6414 cmdline_parse_token_string_t cmd_set_bond_mon_period_bonding = 6415 TOKEN_STRING_INITIALIZER(struct cmd_set_bond_mon_period_result, 6416 bonding, "bonding"); 6417 cmdline_parse_token_string_t cmd_set_bond_mon_period_mon_period = 6418 TOKEN_STRING_INITIALIZER(struct cmd_set_bond_mon_period_result, 6419 mon_period, "mon_period"); 6420 cmdline_parse_token_num_t cmd_set_bond_mon_period_portnum = 6421 TOKEN_NUM_INITIALIZER(struct cmd_set_bond_mon_period_result, 6422 port_num, RTE_UINT16); 6423 cmdline_parse_token_num_t cmd_set_bond_mon_period_period_ms = 6424 TOKEN_NUM_INITIALIZER(struct cmd_set_bond_mon_period_result, 6425 period_ms, RTE_UINT32); 6426 6427 cmdline_parse_inst_t cmd_set_bond_mon_period = { 6428 .f = cmd_set_bond_mon_period_parsed, 6429 .data = (void *) 0, 6430 .help_str = "set bonding mon_period <port_id> <period_ms>", 6431 .tokens = { 6432 (void *)&cmd_set_bond_mon_period_set, 6433 (void *)&cmd_set_bond_mon_period_bonding, 6434 (void *)&cmd_set_bond_mon_period_mon_period, 6435 (void *)&cmd_set_bond_mon_period_portnum, 6436 (void *)&cmd_set_bond_mon_period_period_ms, 6437 NULL 6438 } 6439 }; 6440 6441 6442 6443 struct cmd_set_bonding_agg_mode_policy_result { 6444 cmdline_fixed_string_t set; 6445 cmdline_fixed_string_t bonding; 6446 cmdline_fixed_string_t agg_mode; 6447 uint16_t port_num; 6448 cmdline_fixed_string_t policy; 6449 }; 6450 6451 6452 static void 6453 cmd_set_bonding_agg_mode(void *parsed_result, 6454 __rte_unused struct cmdline *cl, 6455 __rte_unused void *data) 6456 { 6457 struct cmd_set_bonding_agg_mode_policy_result *res = parsed_result; 6458 uint8_t policy = AGG_BANDWIDTH; 6459 6460 if (!strcmp(res->policy, "bandwidth")) 6461 policy = AGG_BANDWIDTH; 6462 else if (!strcmp(res->policy, "stable")) 6463 policy = AGG_STABLE; 6464 else if (!strcmp(res->policy, "count")) 6465 policy = AGG_COUNT; 6466 6467 rte_eth_bond_8023ad_agg_selection_set(res->port_num, policy); 6468 } 6469 6470 6471 cmdline_parse_token_string_t cmd_set_bonding_agg_mode_set = 6472 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_agg_mode_policy_result, 6473 set, "set"); 6474 cmdline_parse_token_string_t cmd_set_bonding_agg_mode_bonding = 6475 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_agg_mode_policy_result, 6476 bonding, "bonding"); 6477 6478 cmdline_parse_token_string_t cmd_set_bonding_agg_mode_agg_mode = 6479 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_agg_mode_policy_result, 6480 agg_mode, "agg_mode"); 6481 6482 cmdline_parse_token_num_t cmd_set_bonding_agg_mode_portnum = 6483 TOKEN_NUM_INITIALIZER(struct cmd_set_bonding_agg_mode_policy_result, 6484 port_num, RTE_UINT16); 6485 6486 cmdline_parse_token_string_t cmd_set_bonding_agg_mode_policy_string = 6487 TOKEN_STRING_INITIALIZER( 6488 struct cmd_set_bonding_balance_xmit_policy_result, 6489 policy, "stable#bandwidth#count"); 6490 6491 cmdline_parse_inst_t cmd_set_bonding_agg_mode_policy = { 6492 .f = cmd_set_bonding_agg_mode, 6493 .data = (void *) 0, 6494 .help_str = "set bonding mode IEEE802.3AD aggregator policy <port_id> <agg_name>", 6495 .tokens = { 6496 (void *)&cmd_set_bonding_agg_mode_set, 6497 (void *)&cmd_set_bonding_agg_mode_bonding, 6498 (void *)&cmd_set_bonding_agg_mode_agg_mode, 6499 (void *)&cmd_set_bonding_agg_mode_portnum, 6500 (void *)&cmd_set_bonding_agg_mode_policy_string, 6501 NULL 6502 } 6503 }; 6504 6505 6506 #endif /* RTE_NET_BOND */ 6507 6508 /* *** SET FORWARDING MODE *** */ 6509 struct cmd_set_fwd_mode_result { 6510 cmdline_fixed_string_t set; 6511 cmdline_fixed_string_t fwd; 6512 cmdline_fixed_string_t mode; 6513 }; 6514 6515 static void cmd_set_fwd_mode_parsed(void *parsed_result, 6516 __rte_unused struct cmdline *cl, 6517 __rte_unused void *data) 6518 { 6519 struct cmd_set_fwd_mode_result *res = parsed_result; 6520 6521 retry_enabled = 0; 6522 set_pkt_forwarding_mode(res->mode); 6523 } 6524 6525 cmdline_parse_token_string_t cmd_setfwd_set = 6526 TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_mode_result, set, "set"); 6527 cmdline_parse_token_string_t cmd_setfwd_fwd = 6528 TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_mode_result, fwd, "fwd"); 6529 cmdline_parse_token_string_t cmd_setfwd_mode = 6530 TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_mode_result, mode, 6531 "" /* defined at init */); 6532 6533 cmdline_parse_inst_t cmd_set_fwd_mode = { 6534 .f = cmd_set_fwd_mode_parsed, 6535 .data = NULL, 6536 .help_str = NULL, /* defined at init */ 6537 .tokens = { 6538 (void *)&cmd_setfwd_set, 6539 (void *)&cmd_setfwd_fwd, 6540 (void *)&cmd_setfwd_mode, 6541 NULL, 6542 }, 6543 }; 6544 6545 static void cmd_set_fwd_mode_init(void) 6546 { 6547 char *modes, *c; 6548 static char token[128]; 6549 static char help[256]; 6550 cmdline_parse_token_string_t *token_struct; 6551 6552 modes = list_pkt_forwarding_modes(); 6553 snprintf(help, sizeof(help), "set fwd %s: " 6554 "Set packet forwarding mode", modes); 6555 cmd_set_fwd_mode.help_str = help; 6556 6557 /* string token separator is # */ 6558 for (c = token; *modes != '\0'; modes++) 6559 if (*modes == '|') 6560 *c++ = '#'; 6561 else 6562 *c++ = *modes; 6563 token_struct = (cmdline_parse_token_string_t*)cmd_set_fwd_mode.tokens[2]; 6564 token_struct->string_data.str = token; 6565 } 6566 6567 /* *** SET RETRY FORWARDING MODE *** */ 6568 struct cmd_set_fwd_retry_mode_result { 6569 cmdline_fixed_string_t set; 6570 cmdline_fixed_string_t fwd; 6571 cmdline_fixed_string_t mode; 6572 cmdline_fixed_string_t retry; 6573 }; 6574 6575 static void cmd_set_fwd_retry_mode_parsed(void *parsed_result, 6576 __rte_unused struct cmdline *cl, 6577 __rte_unused void *data) 6578 { 6579 struct cmd_set_fwd_retry_mode_result *res = parsed_result; 6580 6581 retry_enabled = 1; 6582 set_pkt_forwarding_mode(res->mode); 6583 } 6584 6585 cmdline_parse_token_string_t cmd_setfwd_retry_set = 6586 TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_retry_mode_result, 6587 set, "set"); 6588 cmdline_parse_token_string_t cmd_setfwd_retry_fwd = 6589 TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_retry_mode_result, 6590 fwd, "fwd"); 6591 cmdline_parse_token_string_t cmd_setfwd_retry_mode = 6592 TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_retry_mode_result, 6593 mode, 6594 "" /* defined at init */); 6595 cmdline_parse_token_string_t cmd_setfwd_retry_retry = 6596 TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_retry_mode_result, 6597 retry, "retry"); 6598 6599 cmdline_parse_inst_t cmd_set_fwd_retry_mode = { 6600 .f = cmd_set_fwd_retry_mode_parsed, 6601 .data = NULL, 6602 .help_str = NULL, /* defined at init */ 6603 .tokens = { 6604 (void *)&cmd_setfwd_retry_set, 6605 (void *)&cmd_setfwd_retry_fwd, 6606 (void *)&cmd_setfwd_retry_mode, 6607 (void *)&cmd_setfwd_retry_retry, 6608 NULL, 6609 }, 6610 }; 6611 6612 static void cmd_set_fwd_retry_mode_init(void) 6613 { 6614 char *modes, *c; 6615 static char token[128]; 6616 static char help[256]; 6617 cmdline_parse_token_string_t *token_struct; 6618 6619 modes = list_pkt_forwarding_retry_modes(); 6620 snprintf(help, sizeof(help), "set fwd %s retry: " 6621 "Set packet forwarding mode with retry", modes); 6622 cmd_set_fwd_retry_mode.help_str = help; 6623 6624 /* string token separator is # */ 6625 for (c = token; *modes != '\0'; modes++) 6626 if (*modes == '|') 6627 *c++ = '#'; 6628 else 6629 *c++ = *modes; 6630 token_struct = (cmdline_parse_token_string_t *) 6631 cmd_set_fwd_retry_mode.tokens[2]; 6632 token_struct->string_data.str = token; 6633 } 6634 6635 /* *** SET BURST TX DELAY TIME RETRY NUMBER *** */ 6636 struct cmd_set_burst_tx_retry_result { 6637 cmdline_fixed_string_t set; 6638 cmdline_fixed_string_t burst; 6639 cmdline_fixed_string_t tx; 6640 cmdline_fixed_string_t delay; 6641 uint32_t time; 6642 cmdline_fixed_string_t retry; 6643 uint32_t retry_num; 6644 }; 6645 6646 static void cmd_set_burst_tx_retry_parsed(void *parsed_result, 6647 __rte_unused struct cmdline *cl, 6648 __rte_unused void *data) 6649 { 6650 struct cmd_set_burst_tx_retry_result *res = parsed_result; 6651 6652 if (!strcmp(res->set, "set") && !strcmp(res->burst, "burst") 6653 && !strcmp(res->tx, "tx")) { 6654 if (!strcmp(res->delay, "delay")) 6655 burst_tx_delay_time = res->time; 6656 if (!strcmp(res->retry, "retry")) 6657 burst_tx_retry_num = res->retry_num; 6658 } 6659 6660 } 6661 6662 cmdline_parse_token_string_t cmd_set_burst_tx_retry_set = 6663 TOKEN_STRING_INITIALIZER(struct cmd_set_burst_tx_retry_result, set, "set"); 6664 cmdline_parse_token_string_t cmd_set_burst_tx_retry_burst = 6665 TOKEN_STRING_INITIALIZER(struct cmd_set_burst_tx_retry_result, burst, 6666 "burst"); 6667 cmdline_parse_token_string_t cmd_set_burst_tx_retry_tx = 6668 TOKEN_STRING_INITIALIZER(struct cmd_set_burst_tx_retry_result, tx, "tx"); 6669 cmdline_parse_token_string_t cmd_set_burst_tx_retry_delay = 6670 TOKEN_STRING_INITIALIZER(struct cmd_set_burst_tx_retry_result, delay, "delay"); 6671 cmdline_parse_token_num_t cmd_set_burst_tx_retry_time = 6672 TOKEN_NUM_INITIALIZER(struct cmd_set_burst_tx_retry_result, time, 6673 RTE_UINT32); 6674 cmdline_parse_token_string_t cmd_set_burst_tx_retry_retry = 6675 TOKEN_STRING_INITIALIZER(struct cmd_set_burst_tx_retry_result, retry, "retry"); 6676 cmdline_parse_token_num_t cmd_set_burst_tx_retry_retry_num = 6677 TOKEN_NUM_INITIALIZER(struct cmd_set_burst_tx_retry_result, retry_num, 6678 RTE_UINT32); 6679 6680 cmdline_parse_inst_t cmd_set_burst_tx_retry = { 6681 .f = cmd_set_burst_tx_retry_parsed, 6682 .help_str = "set burst tx delay <delay_usec> retry <num_retry>", 6683 .tokens = { 6684 (void *)&cmd_set_burst_tx_retry_set, 6685 (void *)&cmd_set_burst_tx_retry_burst, 6686 (void *)&cmd_set_burst_tx_retry_tx, 6687 (void *)&cmd_set_burst_tx_retry_delay, 6688 (void *)&cmd_set_burst_tx_retry_time, 6689 (void *)&cmd_set_burst_tx_retry_retry, 6690 (void *)&cmd_set_burst_tx_retry_retry_num, 6691 NULL, 6692 }, 6693 }; 6694 6695 /* *** SET PROMISC MODE *** */ 6696 struct cmd_set_promisc_mode_result { 6697 cmdline_fixed_string_t set; 6698 cmdline_fixed_string_t promisc; 6699 cmdline_fixed_string_t port_all; /* valid if "allports" argument == 1 */ 6700 uint16_t port_num; /* valid if "allports" argument == 0 */ 6701 cmdline_fixed_string_t mode; 6702 }; 6703 6704 static void cmd_set_promisc_mode_parsed(void *parsed_result, 6705 __rte_unused struct cmdline *cl, 6706 void *allports) 6707 { 6708 struct cmd_set_promisc_mode_result *res = parsed_result; 6709 int enable; 6710 portid_t i; 6711 6712 if (!strcmp(res->mode, "on")) 6713 enable = 1; 6714 else 6715 enable = 0; 6716 6717 /* all ports */ 6718 if (allports) { 6719 RTE_ETH_FOREACH_DEV(i) 6720 eth_set_promisc_mode(i, enable); 6721 } else { 6722 eth_set_promisc_mode(res->port_num, enable); 6723 } 6724 } 6725 6726 cmdline_parse_token_string_t cmd_setpromisc_set = 6727 TOKEN_STRING_INITIALIZER(struct cmd_set_promisc_mode_result, set, "set"); 6728 cmdline_parse_token_string_t cmd_setpromisc_promisc = 6729 TOKEN_STRING_INITIALIZER(struct cmd_set_promisc_mode_result, promisc, 6730 "promisc"); 6731 cmdline_parse_token_string_t cmd_setpromisc_portall = 6732 TOKEN_STRING_INITIALIZER(struct cmd_set_promisc_mode_result, port_all, 6733 "all"); 6734 cmdline_parse_token_num_t cmd_setpromisc_portnum = 6735 TOKEN_NUM_INITIALIZER(struct cmd_set_promisc_mode_result, port_num, 6736 RTE_UINT16); 6737 cmdline_parse_token_string_t cmd_setpromisc_mode = 6738 TOKEN_STRING_INITIALIZER(struct cmd_set_promisc_mode_result, mode, 6739 "on#off"); 6740 6741 cmdline_parse_inst_t cmd_set_promisc_mode_all = { 6742 .f = cmd_set_promisc_mode_parsed, 6743 .data = (void *)1, 6744 .help_str = "set promisc all on|off: Set promisc mode for all ports", 6745 .tokens = { 6746 (void *)&cmd_setpromisc_set, 6747 (void *)&cmd_setpromisc_promisc, 6748 (void *)&cmd_setpromisc_portall, 6749 (void *)&cmd_setpromisc_mode, 6750 NULL, 6751 }, 6752 }; 6753 6754 cmdline_parse_inst_t cmd_set_promisc_mode_one = { 6755 .f = cmd_set_promisc_mode_parsed, 6756 .data = (void *)0, 6757 .help_str = "set promisc <port_id> on|off: Set promisc mode on port_id", 6758 .tokens = { 6759 (void *)&cmd_setpromisc_set, 6760 (void *)&cmd_setpromisc_promisc, 6761 (void *)&cmd_setpromisc_portnum, 6762 (void *)&cmd_setpromisc_mode, 6763 NULL, 6764 }, 6765 }; 6766 6767 /* *** SET ALLMULTI MODE *** */ 6768 struct cmd_set_allmulti_mode_result { 6769 cmdline_fixed_string_t set; 6770 cmdline_fixed_string_t allmulti; 6771 cmdline_fixed_string_t port_all; /* valid if "allports" argument == 1 */ 6772 uint16_t port_num; /* valid if "allports" argument == 0 */ 6773 cmdline_fixed_string_t mode; 6774 }; 6775 6776 static void cmd_set_allmulti_mode_parsed(void *parsed_result, 6777 __rte_unused struct cmdline *cl, 6778 void *allports) 6779 { 6780 struct cmd_set_allmulti_mode_result *res = parsed_result; 6781 int enable; 6782 portid_t i; 6783 6784 if (!strcmp(res->mode, "on")) 6785 enable = 1; 6786 else 6787 enable = 0; 6788 6789 /* all ports */ 6790 if (allports) { 6791 RTE_ETH_FOREACH_DEV(i) { 6792 eth_set_allmulticast_mode(i, enable); 6793 } 6794 } 6795 else { 6796 eth_set_allmulticast_mode(res->port_num, enable); 6797 } 6798 } 6799 6800 cmdline_parse_token_string_t cmd_setallmulti_set = 6801 TOKEN_STRING_INITIALIZER(struct cmd_set_allmulti_mode_result, set, "set"); 6802 cmdline_parse_token_string_t cmd_setallmulti_allmulti = 6803 TOKEN_STRING_INITIALIZER(struct cmd_set_allmulti_mode_result, allmulti, 6804 "allmulti"); 6805 cmdline_parse_token_string_t cmd_setallmulti_portall = 6806 TOKEN_STRING_INITIALIZER(struct cmd_set_allmulti_mode_result, port_all, 6807 "all"); 6808 cmdline_parse_token_num_t cmd_setallmulti_portnum = 6809 TOKEN_NUM_INITIALIZER(struct cmd_set_allmulti_mode_result, port_num, 6810 RTE_UINT16); 6811 cmdline_parse_token_string_t cmd_setallmulti_mode = 6812 TOKEN_STRING_INITIALIZER(struct cmd_set_allmulti_mode_result, mode, 6813 "on#off"); 6814 6815 cmdline_parse_inst_t cmd_set_allmulti_mode_all = { 6816 .f = cmd_set_allmulti_mode_parsed, 6817 .data = (void *)1, 6818 .help_str = "set allmulti all on|off: Set allmulti mode for all ports", 6819 .tokens = { 6820 (void *)&cmd_setallmulti_set, 6821 (void *)&cmd_setallmulti_allmulti, 6822 (void *)&cmd_setallmulti_portall, 6823 (void *)&cmd_setallmulti_mode, 6824 NULL, 6825 }, 6826 }; 6827 6828 cmdline_parse_inst_t cmd_set_allmulti_mode_one = { 6829 .f = cmd_set_allmulti_mode_parsed, 6830 .data = (void *)0, 6831 .help_str = "set allmulti <port_id> on|off: " 6832 "Set allmulti mode on port_id", 6833 .tokens = { 6834 (void *)&cmd_setallmulti_set, 6835 (void *)&cmd_setallmulti_allmulti, 6836 (void *)&cmd_setallmulti_portnum, 6837 (void *)&cmd_setallmulti_mode, 6838 NULL, 6839 }, 6840 }; 6841 6842 /* *** SETUP ETHERNET LINK FLOW CONTROL *** */ 6843 struct cmd_link_flow_ctrl_set_result { 6844 cmdline_fixed_string_t set; 6845 cmdline_fixed_string_t flow_ctrl; 6846 cmdline_fixed_string_t rx; 6847 cmdline_fixed_string_t rx_lfc_mode; 6848 cmdline_fixed_string_t tx; 6849 cmdline_fixed_string_t tx_lfc_mode; 6850 cmdline_fixed_string_t mac_ctrl_frame_fwd; 6851 cmdline_fixed_string_t mac_ctrl_frame_fwd_mode; 6852 cmdline_fixed_string_t autoneg_str; 6853 cmdline_fixed_string_t autoneg; 6854 cmdline_fixed_string_t hw_str; 6855 uint32_t high_water; 6856 cmdline_fixed_string_t lw_str; 6857 uint32_t low_water; 6858 cmdline_fixed_string_t pt_str; 6859 uint16_t pause_time; 6860 cmdline_fixed_string_t xon_str; 6861 uint16_t send_xon; 6862 portid_t port_id; 6863 }; 6864 6865 cmdline_parse_token_string_t cmd_lfc_set_set = 6866 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result, 6867 set, "set"); 6868 cmdline_parse_token_string_t cmd_lfc_set_flow_ctrl = 6869 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result, 6870 flow_ctrl, "flow_ctrl"); 6871 cmdline_parse_token_string_t cmd_lfc_set_rx = 6872 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result, 6873 rx, "rx"); 6874 cmdline_parse_token_string_t cmd_lfc_set_rx_mode = 6875 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result, 6876 rx_lfc_mode, "on#off"); 6877 cmdline_parse_token_string_t cmd_lfc_set_tx = 6878 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result, 6879 tx, "tx"); 6880 cmdline_parse_token_string_t cmd_lfc_set_tx_mode = 6881 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result, 6882 tx_lfc_mode, "on#off"); 6883 cmdline_parse_token_string_t cmd_lfc_set_high_water_str = 6884 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result, 6885 hw_str, "high_water"); 6886 cmdline_parse_token_num_t cmd_lfc_set_high_water = 6887 TOKEN_NUM_INITIALIZER(struct cmd_link_flow_ctrl_set_result, 6888 high_water, RTE_UINT32); 6889 cmdline_parse_token_string_t cmd_lfc_set_low_water_str = 6890 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result, 6891 lw_str, "low_water"); 6892 cmdline_parse_token_num_t cmd_lfc_set_low_water = 6893 TOKEN_NUM_INITIALIZER(struct cmd_link_flow_ctrl_set_result, 6894 low_water, RTE_UINT32); 6895 cmdline_parse_token_string_t cmd_lfc_set_pause_time_str = 6896 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result, 6897 pt_str, "pause_time"); 6898 cmdline_parse_token_num_t cmd_lfc_set_pause_time = 6899 TOKEN_NUM_INITIALIZER(struct cmd_link_flow_ctrl_set_result, 6900 pause_time, RTE_UINT16); 6901 cmdline_parse_token_string_t cmd_lfc_set_send_xon_str = 6902 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result, 6903 xon_str, "send_xon"); 6904 cmdline_parse_token_num_t cmd_lfc_set_send_xon = 6905 TOKEN_NUM_INITIALIZER(struct cmd_link_flow_ctrl_set_result, 6906 send_xon, RTE_UINT16); 6907 cmdline_parse_token_string_t cmd_lfc_set_mac_ctrl_frame_fwd_mode = 6908 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result, 6909 mac_ctrl_frame_fwd, "mac_ctrl_frame_fwd"); 6910 cmdline_parse_token_string_t cmd_lfc_set_mac_ctrl_frame_fwd = 6911 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result, 6912 mac_ctrl_frame_fwd_mode, "on#off"); 6913 cmdline_parse_token_string_t cmd_lfc_set_autoneg_str = 6914 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result, 6915 autoneg_str, "autoneg"); 6916 cmdline_parse_token_string_t cmd_lfc_set_autoneg = 6917 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result, 6918 autoneg, "on#off"); 6919 cmdline_parse_token_num_t cmd_lfc_set_portid = 6920 TOKEN_NUM_INITIALIZER(struct cmd_link_flow_ctrl_set_result, 6921 port_id, RTE_UINT16); 6922 6923 /* forward declaration */ 6924 static void 6925 cmd_link_flow_ctrl_set_parsed(void *parsed_result, struct cmdline *cl, 6926 void *data); 6927 6928 cmdline_parse_inst_t cmd_link_flow_control_set = { 6929 .f = cmd_link_flow_ctrl_set_parsed, 6930 .data = NULL, 6931 .help_str = "set flow_ctrl rx on|off tx on|off <high_water> " 6932 "<low_water> <pause_time> <send_xon> mac_ctrl_frame_fwd on|off " 6933 "autoneg on|off <port_id>: Configure the Ethernet flow control", 6934 .tokens = { 6935 (void *)&cmd_lfc_set_set, 6936 (void *)&cmd_lfc_set_flow_ctrl, 6937 (void *)&cmd_lfc_set_rx, 6938 (void *)&cmd_lfc_set_rx_mode, 6939 (void *)&cmd_lfc_set_tx, 6940 (void *)&cmd_lfc_set_tx_mode, 6941 (void *)&cmd_lfc_set_high_water, 6942 (void *)&cmd_lfc_set_low_water, 6943 (void *)&cmd_lfc_set_pause_time, 6944 (void *)&cmd_lfc_set_send_xon, 6945 (void *)&cmd_lfc_set_mac_ctrl_frame_fwd_mode, 6946 (void *)&cmd_lfc_set_mac_ctrl_frame_fwd, 6947 (void *)&cmd_lfc_set_autoneg_str, 6948 (void *)&cmd_lfc_set_autoneg, 6949 (void *)&cmd_lfc_set_portid, 6950 NULL, 6951 }, 6952 }; 6953 6954 cmdline_parse_inst_t cmd_link_flow_control_set_rx = { 6955 .f = cmd_link_flow_ctrl_set_parsed, 6956 .data = (void *)&cmd_link_flow_control_set_rx, 6957 .help_str = "set flow_ctrl rx on|off <port_id>: " 6958 "Change rx flow control parameter", 6959 .tokens = { 6960 (void *)&cmd_lfc_set_set, 6961 (void *)&cmd_lfc_set_flow_ctrl, 6962 (void *)&cmd_lfc_set_rx, 6963 (void *)&cmd_lfc_set_rx_mode, 6964 (void *)&cmd_lfc_set_portid, 6965 NULL, 6966 }, 6967 }; 6968 6969 cmdline_parse_inst_t cmd_link_flow_control_set_tx = { 6970 .f = cmd_link_flow_ctrl_set_parsed, 6971 .data = (void *)&cmd_link_flow_control_set_tx, 6972 .help_str = "set flow_ctrl tx on|off <port_id>: " 6973 "Change tx flow control parameter", 6974 .tokens = { 6975 (void *)&cmd_lfc_set_set, 6976 (void *)&cmd_lfc_set_flow_ctrl, 6977 (void *)&cmd_lfc_set_tx, 6978 (void *)&cmd_lfc_set_tx_mode, 6979 (void *)&cmd_lfc_set_portid, 6980 NULL, 6981 }, 6982 }; 6983 6984 cmdline_parse_inst_t cmd_link_flow_control_set_hw = { 6985 .f = cmd_link_flow_ctrl_set_parsed, 6986 .data = (void *)&cmd_link_flow_control_set_hw, 6987 .help_str = "set flow_ctrl high_water <value> <port_id>: " 6988 "Change high water flow control parameter", 6989 .tokens = { 6990 (void *)&cmd_lfc_set_set, 6991 (void *)&cmd_lfc_set_flow_ctrl, 6992 (void *)&cmd_lfc_set_high_water_str, 6993 (void *)&cmd_lfc_set_high_water, 6994 (void *)&cmd_lfc_set_portid, 6995 NULL, 6996 }, 6997 }; 6998 6999 cmdline_parse_inst_t cmd_link_flow_control_set_lw = { 7000 .f = cmd_link_flow_ctrl_set_parsed, 7001 .data = (void *)&cmd_link_flow_control_set_lw, 7002 .help_str = "set flow_ctrl low_water <value> <port_id>: " 7003 "Change low water flow control parameter", 7004 .tokens = { 7005 (void *)&cmd_lfc_set_set, 7006 (void *)&cmd_lfc_set_flow_ctrl, 7007 (void *)&cmd_lfc_set_low_water_str, 7008 (void *)&cmd_lfc_set_low_water, 7009 (void *)&cmd_lfc_set_portid, 7010 NULL, 7011 }, 7012 }; 7013 7014 cmdline_parse_inst_t cmd_link_flow_control_set_pt = { 7015 .f = cmd_link_flow_ctrl_set_parsed, 7016 .data = (void *)&cmd_link_flow_control_set_pt, 7017 .help_str = "set flow_ctrl pause_time <value> <port_id>: " 7018 "Change pause time flow control parameter", 7019 .tokens = { 7020 (void *)&cmd_lfc_set_set, 7021 (void *)&cmd_lfc_set_flow_ctrl, 7022 (void *)&cmd_lfc_set_pause_time_str, 7023 (void *)&cmd_lfc_set_pause_time, 7024 (void *)&cmd_lfc_set_portid, 7025 NULL, 7026 }, 7027 }; 7028 7029 cmdline_parse_inst_t cmd_link_flow_control_set_xon = { 7030 .f = cmd_link_flow_ctrl_set_parsed, 7031 .data = (void *)&cmd_link_flow_control_set_xon, 7032 .help_str = "set flow_ctrl send_xon <value> <port_id>: " 7033 "Change send_xon flow control parameter", 7034 .tokens = { 7035 (void *)&cmd_lfc_set_set, 7036 (void *)&cmd_lfc_set_flow_ctrl, 7037 (void *)&cmd_lfc_set_send_xon_str, 7038 (void *)&cmd_lfc_set_send_xon, 7039 (void *)&cmd_lfc_set_portid, 7040 NULL, 7041 }, 7042 }; 7043 7044 cmdline_parse_inst_t cmd_link_flow_control_set_macfwd = { 7045 .f = cmd_link_flow_ctrl_set_parsed, 7046 .data = (void *)&cmd_link_flow_control_set_macfwd, 7047 .help_str = "set flow_ctrl mac_ctrl_frame_fwd on|off <port_id>: " 7048 "Change mac ctrl fwd flow control parameter", 7049 .tokens = { 7050 (void *)&cmd_lfc_set_set, 7051 (void *)&cmd_lfc_set_flow_ctrl, 7052 (void *)&cmd_lfc_set_mac_ctrl_frame_fwd_mode, 7053 (void *)&cmd_lfc_set_mac_ctrl_frame_fwd, 7054 (void *)&cmd_lfc_set_portid, 7055 NULL, 7056 }, 7057 }; 7058 7059 cmdline_parse_inst_t cmd_link_flow_control_set_autoneg = { 7060 .f = cmd_link_flow_ctrl_set_parsed, 7061 .data = (void *)&cmd_link_flow_control_set_autoneg, 7062 .help_str = "set flow_ctrl autoneg on|off <port_id>: " 7063 "Change autoneg flow control parameter", 7064 .tokens = { 7065 (void *)&cmd_lfc_set_set, 7066 (void *)&cmd_lfc_set_flow_ctrl, 7067 (void *)&cmd_lfc_set_autoneg_str, 7068 (void *)&cmd_lfc_set_autoneg, 7069 (void *)&cmd_lfc_set_portid, 7070 NULL, 7071 }, 7072 }; 7073 7074 static void 7075 cmd_link_flow_ctrl_set_parsed(void *parsed_result, 7076 __rte_unused struct cmdline *cl, 7077 void *data) 7078 { 7079 struct cmd_link_flow_ctrl_set_result *res = parsed_result; 7080 cmdline_parse_inst_t *cmd = data; 7081 struct rte_eth_fc_conf fc_conf; 7082 int rx_fc_en = 0; 7083 int tx_fc_en = 0; 7084 int ret; 7085 7086 /* 7087 * Rx on/off, flow control is enabled/disabled on RX side. This can indicate 7088 * the RTE_FC_TX_PAUSE, Transmit pause frame at the Rx side. 7089 * Tx on/off, flow control is enabled/disabled on TX side. This can indicate 7090 * the RTE_FC_RX_PAUSE, Respond to the pause frame at the Tx side. 7091 */ 7092 static enum rte_eth_fc_mode rx_tx_onoff_2_lfc_mode[2][2] = { 7093 {RTE_FC_NONE, RTE_FC_TX_PAUSE}, {RTE_FC_RX_PAUSE, RTE_FC_FULL} 7094 }; 7095 7096 /* Partial command line, retrieve current configuration */ 7097 if (cmd) { 7098 ret = rte_eth_dev_flow_ctrl_get(res->port_id, &fc_conf); 7099 if (ret != 0) { 7100 printf("cannot get current flow ctrl parameters, return" 7101 "code = %d\n", ret); 7102 return; 7103 } 7104 7105 if ((fc_conf.mode == RTE_FC_RX_PAUSE) || 7106 (fc_conf.mode == RTE_FC_FULL)) 7107 rx_fc_en = 1; 7108 if ((fc_conf.mode == RTE_FC_TX_PAUSE) || 7109 (fc_conf.mode == RTE_FC_FULL)) 7110 tx_fc_en = 1; 7111 } 7112 7113 if (!cmd || cmd == &cmd_link_flow_control_set_rx) 7114 rx_fc_en = (!strcmp(res->rx_lfc_mode, "on")) ? 1 : 0; 7115 7116 if (!cmd || cmd == &cmd_link_flow_control_set_tx) 7117 tx_fc_en = (!strcmp(res->tx_lfc_mode, "on")) ? 1 : 0; 7118 7119 fc_conf.mode = rx_tx_onoff_2_lfc_mode[rx_fc_en][tx_fc_en]; 7120 7121 if (!cmd || cmd == &cmd_link_flow_control_set_hw) 7122 fc_conf.high_water = res->high_water; 7123 7124 if (!cmd || cmd == &cmd_link_flow_control_set_lw) 7125 fc_conf.low_water = res->low_water; 7126 7127 if (!cmd || cmd == &cmd_link_flow_control_set_pt) 7128 fc_conf.pause_time = res->pause_time; 7129 7130 if (!cmd || cmd == &cmd_link_flow_control_set_xon) 7131 fc_conf.send_xon = res->send_xon; 7132 7133 if (!cmd || cmd == &cmd_link_flow_control_set_macfwd) { 7134 if (!strcmp(res->mac_ctrl_frame_fwd_mode, "on")) 7135 fc_conf.mac_ctrl_frame_fwd = 1; 7136 else 7137 fc_conf.mac_ctrl_frame_fwd = 0; 7138 } 7139 7140 if (!cmd || cmd == &cmd_link_flow_control_set_autoneg) 7141 fc_conf.autoneg = (!strcmp(res->autoneg, "on")) ? 1 : 0; 7142 7143 ret = rte_eth_dev_flow_ctrl_set(res->port_id, &fc_conf); 7144 if (ret != 0) 7145 printf("bad flow contrl parameter, return code = %d \n", ret); 7146 } 7147 7148 /* *** SETUP ETHERNET PRIORITY FLOW CONTROL *** */ 7149 struct cmd_priority_flow_ctrl_set_result { 7150 cmdline_fixed_string_t set; 7151 cmdline_fixed_string_t pfc_ctrl; 7152 cmdline_fixed_string_t rx; 7153 cmdline_fixed_string_t rx_pfc_mode; 7154 cmdline_fixed_string_t tx; 7155 cmdline_fixed_string_t tx_pfc_mode; 7156 uint32_t high_water; 7157 uint32_t low_water; 7158 uint16_t pause_time; 7159 uint8_t priority; 7160 portid_t port_id; 7161 }; 7162 7163 static void 7164 cmd_priority_flow_ctrl_set_parsed(void *parsed_result, 7165 __rte_unused struct cmdline *cl, 7166 __rte_unused void *data) 7167 { 7168 struct cmd_priority_flow_ctrl_set_result *res = parsed_result; 7169 struct rte_eth_pfc_conf pfc_conf; 7170 int rx_fc_enable, tx_fc_enable; 7171 int ret; 7172 7173 /* 7174 * Rx on/off, flow control is enabled/disabled on RX side. This can indicate 7175 * the RTE_FC_TX_PAUSE, Transmit pause frame at the Rx side. 7176 * Tx on/off, flow control is enabled/disabled on TX side. This can indicate 7177 * the RTE_FC_RX_PAUSE, Respond to the pause frame at the Tx side. 7178 */ 7179 static enum rte_eth_fc_mode rx_tx_onoff_2_pfc_mode[2][2] = { 7180 {RTE_FC_NONE, RTE_FC_TX_PAUSE}, {RTE_FC_RX_PAUSE, RTE_FC_FULL} 7181 }; 7182 7183 memset(&pfc_conf, 0, sizeof(struct rte_eth_pfc_conf)); 7184 rx_fc_enable = (!strncmp(res->rx_pfc_mode, "on",2)) ? 1 : 0; 7185 tx_fc_enable = (!strncmp(res->tx_pfc_mode, "on",2)) ? 1 : 0; 7186 pfc_conf.fc.mode = rx_tx_onoff_2_pfc_mode[rx_fc_enable][tx_fc_enable]; 7187 pfc_conf.fc.high_water = res->high_water; 7188 pfc_conf.fc.low_water = res->low_water; 7189 pfc_conf.fc.pause_time = res->pause_time; 7190 pfc_conf.priority = res->priority; 7191 7192 ret = rte_eth_dev_priority_flow_ctrl_set(res->port_id, &pfc_conf); 7193 if (ret != 0) 7194 printf("bad priority flow contrl parameter, return code = %d \n", ret); 7195 } 7196 7197 cmdline_parse_token_string_t cmd_pfc_set_set = 7198 TOKEN_STRING_INITIALIZER(struct cmd_priority_flow_ctrl_set_result, 7199 set, "set"); 7200 cmdline_parse_token_string_t cmd_pfc_set_flow_ctrl = 7201 TOKEN_STRING_INITIALIZER(struct cmd_priority_flow_ctrl_set_result, 7202 pfc_ctrl, "pfc_ctrl"); 7203 cmdline_parse_token_string_t cmd_pfc_set_rx = 7204 TOKEN_STRING_INITIALIZER(struct cmd_priority_flow_ctrl_set_result, 7205 rx, "rx"); 7206 cmdline_parse_token_string_t cmd_pfc_set_rx_mode = 7207 TOKEN_STRING_INITIALIZER(struct cmd_priority_flow_ctrl_set_result, 7208 rx_pfc_mode, "on#off"); 7209 cmdline_parse_token_string_t cmd_pfc_set_tx = 7210 TOKEN_STRING_INITIALIZER(struct cmd_priority_flow_ctrl_set_result, 7211 tx, "tx"); 7212 cmdline_parse_token_string_t cmd_pfc_set_tx_mode = 7213 TOKEN_STRING_INITIALIZER(struct cmd_priority_flow_ctrl_set_result, 7214 tx_pfc_mode, "on#off"); 7215 cmdline_parse_token_num_t cmd_pfc_set_high_water = 7216 TOKEN_NUM_INITIALIZER(struct cmd_priority_flow_ctrl_set_result, 7217 high_water, RTE_UINT32); 7218 cmdline_parse_token_num_t cmd_pfc_set_low_water = 7219 TOKEN_NUM_INITIALIZER(struct cmd_priority_flow_ctrl_set_result, 7220 low_water, RTE_UINT32); 7221 cmdline_parse_token_num_t cmd_pfc_set_pause_time = 7222 TOKEN_NUM_INITIALIZER(struct cmd_priority_flow_ctrl_set_result, 7223 pause_time, RTE_UINT16); 7224 cmdline_parse_token_num_t cmd_pfc_set_priority = 7225 TOKEN_NUM_INITIALIZER(struct cmd_priority_flow_ctrl_set_result, 7226 priority, RTE_UINT8); 7227 cmdline_parse_token_num_t cmd_pfc_set_portid = 7228 TOKEN_NUM_INITIALIZER(struct cmd_priority_flow_ctrl_set_result, 7229 port_id, RTE_UINT16); 7230 7231 cmdline_parse_inst_t cmd_priority_flow_control_set = { 7232 .f = cmd_priority_flow_ctrl_set_parsed, 7233 .data = NULL, 7234 .help_str = "set pfc_ctrl rx on|off tx on|off <high_water> <low_water> " 7235 "<pause_time> <priority> <port_id>: " 7236 "Configure the Ethernet priority flow control", 7237 .tokens = { 7238 (void *)&cmd_pfc_set_set, 7239 (void *)&cmd_pfc_set_flow_ctrl, 7240 (void *)&cmd_pfc_set_rx, 7241 (void *)&cmd_pfc_set_rx_mode, 7242 (void *)&cmd_pfc_set_tx, 7243 (void *)&cmd_pfc_set_tx_mode, 7244 (void *)&cmd_pfc_set_high_water, 7245 (void *)&cmd_pfc_set_low_water, 7246 (void *)&cmd_pfc_set_pause_time, 7247 (void *)&cmd_pfc_set_priority, 7248 (void *)&cmd_pfc_set_portid, 7249 NULL, 7250 }, 7251 }; 7252 7253 /* *** RESET CONFIGURATION *** */ 7254 struct cmd_reset_result { 7255 cmdline_fixed_string_t reset; 7256 cmdline_fixed_string_t def; 7257 }; 7258 7259 static void cmd_reset_parsed(__rte_unused void *parsed_result, 7260 struct cmdline *cl, 7261 __rte_unused void *data) 7262 { 7263 cmdline_printf(cl, "Reset to default forwarding configuration...\n"); 7264 set_def_fwd_config(); 7265 } 7266 7267 cmdline_parse_token_string_t cmd_reset_set = 7268 TOKEN_STRING_INITIALIZER(struct cmd_reset_result, reset, "set"); 7269 cmdline_parse_token_string_t cmd_reset_def = 7270 TOKEN_STRING_INITIALIZER(struct cmd_reset_result, def, 7271 "default"); 7272 7273 cmdline_parse_inst_t cmd_reset = { 7274 .f = cmd_reset_parsed, 7275 .data = NULL, 7276 .help_str = "set default: Reset default forwarding configuration", 7277 .tokens = { 7278 (void *)&cmd_reset_set, 7279 (void *)&cmd_reset_def, 7280 NULL, 7281 }, 7282 }; 7283 7284 /* *** START FORWARDING *** */ 7285 struct cmd_start_result { 7286 cmdline_fixed_string_t start; 7287 }; 7288 7289 cmdline_parse_token_string_t cmd_start_start = 7290 TOKEN_STRING_INITIALIZER(struct cmd_start_result, start, "start"); 7291 7292 static void cmd_start_parsed(__rte_unused void *parsed_result, 7293 __rte_unused struct cmdline *cl, 7294 __rte_unused void *data) 7295 { 7296 start_packet_forwarding(0); 7297 } 7298 7299 cmdline_parse_inst_t cmd_start = { 7300 .f = cmd_start_parsed, 7301 .data = NULL, 7302 .help_str = "start: Start packet forwarding", 7303 .tokens = { 7304 (void *)&cmd_start_start, 7305 NULL, 7306 }, 7307 }; 7308 7309 /* *** START FORWARDING WITH ONE TX BURST FIRST *** */ 7310 struct cmd_start_tx_first_result { 7311 cmdline_fixed_string_t start; 7312 cmdline_fixed_string_t tx_first; 7313 }; 7314 7315 static void 7316 cmd_start_tx_first_parsed(__rte_unused void *parsed_result, 7317 __rte_unused struct cmdline *cl, 7318 __rte_unused void *data) 7319 { 7320 start_packet_forwarding(1); 7321 } 7322 7323 cmdline_parse_token_string_t cmd_start_tx_first_start = 7324 TOKEN_STRING_INITIALIZER(struct cmd_start_tx_first_result, start, 7325 "start"); 7326 cmdline_parse_token_string_t cmd_start_tx_first_tx_first = 7327 TOKEN_STRING_INITIALIZER(struct cmd_start_tx_first_result, 7328 tx_first, "tx_first"); 7329 7330 cmdline_parse_inst_t cmd_start_tx_first = { 7331 .f = cmd_start_tx_first_parsed, 7332 .data = NULL, 7333 .help_str = "start tx_first: Start packet forwarding, " 7334 "after sending 1 burst of packets", 7335 .tokens = { 7336 (void *)&cmd_start_tx_first_start, 7337 (void *)&cmd_start_tx_first_tx_first, 7338 NULL, 7339 }, 7340 }; 7341 7342 /* *** START FORWARDING WITH N TX BURST FIRST *** */ 7343 struct cmd_start_tx_first_n_result { 7344 cmdline_fixed_string_t start; 7345 cmdline_fixed_string_t tx_first; 7346 uint32_t tx_num; 7347 }; 7348 7349 static void 7350 cmd_start_tx_first_n_parsed(void *parsed_result, 7351 __rte_unused struct cmdline *cl, 7352 __rte_unused void *data) 7353 { 7354 struct cmd_start_tx_first_n_result *res = parsed_result; 7355 7356 start_packet_forwarding(res->tx_num); 7357 } 7358 7359 cmdline_parse_token_string_t cmd_start_tx_first_n_start = 7360 TOKEN_STRING_INITIALIZER(struct cmd_start_tx_first_n_result, 7361 start, "start"); 7362 cmdline_parse_token_string_t cmd_start_tx_first_n_tx_first = 7363 TOKEN_STRING_INITIALIZER(struct cmd_start_tx_first_n_result, 7364 tx_first, "tx_first"); 7365 cmdline_parse_token_num_t cmd_start_tx_first_n_tx_num = 7366 TOKEN_NUM_INITIALIZER(struct cmd_start_tx_first_n_result, 7367 tx_num, RTE_UINT32); 7368 7369 cmdline_parse_inst_t cmd_start_tx_first_n = { 7370 .f = cmd_start_tx_first_n_parsed, 7371 .data = NULL, 7372 .help_str = "start tx_first <num>: " 7373 "packet forwarding, after sending <num> bursts of packets", 7374 .tokens = { 7375 (void *)&cmd_start_tx_first_n_start, 7376 (void *)&cmd_start_tx_first_n_tx_first, 7377 (void *)&cmd_start_tx_first_n_tx_num, 7378 NULL, 7379 }, 7380 }; 7381 7382 /* *** SET LINK UP *** */ 7383 struct cmd_set_link_up_result { 7384 cmdline_fixed_string_t set; 7385 cmdline_fixed_string_t link_up; 7386 cmdline_fixed_string_t port; 7387 portid_t port_id; 7388 }; 7389 7390 cmdline_parse_token_string_t cmd_set_link_up_set = 7391 TOKEN_STRING_INITIALIZER(struct cmd_set_link_up_result, set, "set"); 7392 cmdline_parse_token_string_t cmd_set_link_up_link_up = 7393 TOKEN_STRING_INITIALIZER(struct cmd_set_link_up_result, link_up, 7394 "link-up"); 7395 cmdline_parse_token_string_t cmd_set_link_up_port = 7396 TOKEN_STRING_INITIALIZER(struct cmd_set_link_up_result, port, "port"); 7397 cmdline_parse_token_num_t cmd_set_link_up_port_id = 7398 TOKEN_NUM_INITIALIZER(struct cmd_set_link_up_result, port_id, 7399 RTE_UINT16); 7400 7401 static void cmd_set_link_up_parsed(__rte_unused void *parsed_result, 7402 __rte_unused struct cmdline *cl, 7403 __rte_unused void *data) 7404 { 7405 struct cmd_set_link_up_result *res = parsed_result; 7406 dev_set_link_up(res->port_id); 7407 } 7408 7409 cmdline_parse_inst_t cmd_set_link_up = { 7410 .f = cmd_set_link_up_parsed, 7411 .data = NULL, 7412 .help_str = "set link-up port <port id>", 7413 .tokens = { 7414 (void *)&cmd_set_link_up_set, 7415 (void *)&cmd_set_link_up_link_up, 7416 (void *)&cmd_set_link_up_port, 7417 (void *)&cmd_set_link_up_port_id, 7418 NULL, 7419 }, 7420 }; 7421 7422 /* *** SET LINK DOWN *** */ 7423 struct cmd_set_link_down_result { 7424 cmdline_fixed_string_t set; 7425 cmdline_fixed_string_t link_down; 7426 cmdline_fixed_string_t port; 7427 portid_t port_id; 7428 }; 7429 7430 cmdline_parse_token_string_t cmd_set_link_down_set = 7431 TOKEN_STRING_INITIALIZER(struct cmd_set_link_down_result, set, "set"); 7432 cmdline_parse_token_string_t cmd_set_link_down_link_down = 7433 TOKEN_STRING_INITIALIZER(struct cmd_set_link_down_result, link_down, 7434 "link-down"); 7435 cmdline_parse_token_string_t cmd_set_link_down_port = 7436 TOKEN_STRING_INITIALIZER(struct cmd_set_link_down_result, port, "port"); 7437 cmdline_parse_token_num_t cmd_set_link_down_port_id = 7438 TOKEN_NUM_INITIALIZER(struct cmd_set_link_down_result, port_id, 7439 RTE_UINT16); 7440 7441 static void cmd_set_link_down_parsed( 7442 __rte_unused void *parsed_result, 7443 __rte_unused struct cmdline *cl, 7444 __rte_unused void *data) 7445 { 7446 struct cmd_set_link_down_result *res = parsed_result; 7447 dev_set_link_down(res->port_id); 7448 } 7449 7450 cmdline_parse_inst_t cmd_set_link_down = { 7451 .f = cmd_set_link_down_parsed, 7452 .data = NULL, 7453 .help_str = "set link-down port <port id>", 7454 .tokens = { 7455 (void *)&cmd_set_link_down_set, 7456 (void *)&cmd_set_link_down_link_down, 7457 (void *)&cmd_set_link_down_port, 7458 (void *)&cmd_set_link_down_port_id, 7459 NULL, 7460 }, 7461 }; 7462 7463 /* *** SHOW CFG *** */ 7464 struct cmd_showcfg_result { 7465 cmdline_fixed_string_t show; 7466 cmdline_fixed_string_t cfg; 7467 cmdline_fixed_string_t what; 7468 }; 7469 7470 static void cmd_showcfg_parsed(void *parsed_result, 7471 __rte_unused struct cmdline *cl, 7472 __rte_unused void *data) 7473 { 7474 struct cmd_showcfg_result *res = parsed_result; 7475 if (!strcmp(res->what, "rxtx")) 7476 rxtx_config_display(); 7477 else if (!strcmp(res->what, "cores")) 7478 fwd_lcores_config_display(); 7479 else if (!strcmp(res->what, "fwd")) 7480 pkt_fwd_config_display(&cur_fwd_config); 7481 else if (!strcmp(res->what, "rxoffs")) 7482 show_rx_pkt_offsets(); 7483 else if (!strcmp(res->what, "rxpkts")) 7484 show_rx_pkt_segments(); 7485 else if (!strcmp(res->what, "txpkts")) 7486 show_tx_pkt_segments(); 7487 else if (!strcmp(res->what, "txtimes")) 7488 show_tx_pkt_times(); 7489 } 7490 7491 cmdline_parse_token_string_t cmd_showcfg_show = 7492 TOKEN_STRING_INITIALIZER(struct cmd_showcfg_result, show, "show"); 7493 cmdline_parse_token_string_t cmd_showcfg_port = 7494 TOKEN_STRING_INITIALIZER(struct cmd_showcfg_result, cfg, "config"); 7495 cmdline_parse_token_string_t cmd_showcfg_what = 7496 TOKEN_STRING_INITIALIZER(struct cmd_showcfg_result, what, 7497 "rxtx#cores#fwd#rxoffs#rxpkts#txpkts#txtimes"); 7498 7499 cmdline_parse_inst_t cmd_showcfg = { 7500 .f = cmd_showcfg_parsed, 7501 .data = NULL, 7502 .help_str = "show config rxtx|cores|fwd|rxoffs|rxpkts|txpkts|txtimes", 7503 .tokens = { 7504 (void *)&cmd_showcfg_show, 7505 (void *)&cmd_showcfg_port, 7506 (void *)&cmd_showcfg_what, 7507 NULL, 7508 }, 7509 }; 7510 7511 /* *** SHOW ALL PORT INFO *** */ 7512 struct cmd_showportall_result { 7513 cmdline_fixed_string_t show; 7514 cmdline_fixed_string_t port; 7515 cmdline_fixed_string_t what; 7516 cmdline_fixed_string_t all; 7517 }; 7518 7519 static void cmd_showportall_parsed(void *parsed_result, 7520 __rte_unused struct cmdline *cl, 7521 __rte_unused void *data) 7522 { 7523 portid_t i; 7524 7525 struct cmd_showportall_result *res = parsed_result; 7526 if (!strcmp(res->show, "clear")) { 7527 if (!strcmp(res->what, "stats")) 7528 RTE_ETH_FOREACH_DEV(i) 7529 nic_stats_clear(i); 7530 else if (!strcmp(res->what, "xstats")) 7531 RTE_ETH_FOREACH_DEV(i) 7532 nic_xstats_clear(i); 7533 } else if (!strcmp(res->what, "info")) 7534 RTE_ETH_FOREACH_DEV(i) 7535 port_infos_display(i); 7536 else if (!strcmp(res->what, "summary")) { 7537 port_summary_header_display(); 7538 RTE_ETH_FOREACH_DEV(i) 7539 port_summary_display(i); 7540 } 7541 else if (!strcmp(res->what, "stats")) 7542 RTE_ETH_FOREACH_DEV(i) 7543 nic_stats_display(i); 7544 else if (!strcmp(res->what, "xstats")) 7545 RTE_ETH_FOREACH_DEV(i) 7546 nic_xstats_display(i); 7547 #if defined(RTE_NET_I40E) || defined(RTE_NET_IXGBE) 7548 else if (!strcmp(res->what, "fdir")) 7549 RTE_ETH_FOREACH_DEV(i) 7550 fdir_get_infos(i); 7551 #endif 7552 else if (!strcmp(res->what, "dcb_tc")) 7553 RTE_ETH_FOREACH_DEV(i) 7554 port_dcb_info_display(i); 7555 else if (!strcmp(res->what, "cap")) 7556 RTE_ETH_FOREACH_DEV(i) 7557 port_offload_cap_display(i); 7558 } 7559 7560 cmdline_parse_token_string_t cmd_showportall_show = 7561 TOKEN_STRING_INITIALIZER(struct cmd_showportall_result, show, 7562 "show#clear"); 7563 cmdline_parse_token_string_t cmd_showportall_port = 7564 TOKEN_STRING_INITIALIZER(struct cmd_showportall_result, port, "port"); 7565 cmdline_parse_token_string_t cmd_showportall_what = 7566 TOKEN_STRING_INITIALIZER(struct cmd_showportall_result, what, 7567 "info#summary#stats#xstats#fdir#dcb_tc#cap"); 7568 cmdline_parse_token_string_t cmd_showportall_all = 7569 TOKEN_STRING_INITIALIZER(struct cmd_showportall_result, all, "all"); 7570 cmdline_parse_inst_t cmd_showportall = { 7571 .f = cmd_showportall_parsed, 7572 .data = NULL, 7573 .help_str = "show|clear port " 7574 "info|summary|stats|xstats|fdir|dcb_tc|cap all", 7575 .tokens = { 7576 (void *)&cmd_showportall_show, 7577 (void *)&cmd_showportall_port, 7578 (void *)&cmd_showportall_what, 7579 (void *)&cmd_showportall_all, 7580 NULL, 7581 }, 7582 }; 7583 7584 /* *** SHOW PORT INFO *** */ 7585 struct cmd_showport_result { 7586 cmdline_fixed_string_t show; 7587 cmdline_fixed_string_t port; 7588 cmdline_fixed_string_t what; 7589 uint16_t portnum; 7590 }; 7591 7592 static void cmd_showport_parsed(void *parsed_result, 7593 __rte_unused struct cmdline *cl, 7594 __rte_unused void *data) 7595 { 7596 struct cmd_showport_result *res = parsed_result; 7597 if (!strcmp(res->show, "clear")) { 7598 if (!strcmp(res->what, "stats")) 7599 nic_stats_clear(res->portnum); 7600 else if (!strcmp(res->what, "xstats")) 7601 nic_xstats_clear(res->portnum); 7602 } else if (!strcmp(res->what, "info")) 7603 port_infos_display(res->portnum); 7604 else if (!strcmp(res->what, "summary")) { 7605 port_summary_header_display(); 7606 port_summary_display(res->portnum); 7607 } 7608 else if (!strcmp(res->what, "stats")) 7609 nic_stats_display(res->portnum); 7610 else if (!strcmp(res->what, "xstats")) 7611 nic_xstats_display(res->portnum); 7612 #if defined(RTE_NET_I40E) || defined(RTE_NET_IXGBE) 7613 else if (!strcmp(res->what, "fdir")) 7614 fdir_get_infos(res->portnum); 7615 #endif 7616 else if (!strcmp(res->what, "dcb_tc")) 7617 port_dcb_info_display(res->portnum); 7618 else if (!strcmp(res->what, "cap")) 7619 port_offload_cap_display(res->portnum); 7620 } 7621 7622 cmdline_parse_token_string_t cmd_showport_show = 7623 TOKEN_STRING_INITIALIZER(struct cmd_showport_result, show, 7624 "show#clear"); 7625 cmdline_parse_token_string_t cmd_showport_port = 7626 TOKEN_STRING_INITIALIZER(struct cmd_showport_result, port, "port"); 7627 cmdline_parse_token_string_t cmd_showport_what = 7628 TOKEN_STRING_INITIALIZER(struct cmd_showport_result, what, 7629 "info#summary#stats#xstats#fdir#dcb_tc#cap"); 7630 cmdline_parse_token_num_t cmd_showport_portnum = 7631 TOKEN_NUM_INITIALIZER(struct cmd_showport_result, portnum, RTE_UINT16); 7632 7633 cmdline_parse_inst_t cmd_showport = { 7634 .f = cmd_showport_parsed, 7635 .data = NULL, 7636 .help_str = "show|clear port " 7637 "info|summary|stats|xstats|fdir|dcb_tc|cap " 7638 "<port_id>", 7639 .tokens = { 7640 (void *)&cmd_showport_show, 7641 (void *)&cmd_showport_port, 7642 (void *)&cmd_showport_what, 7643 (void *)&cmd_showport_portnum, 7644 NULL, 7645 }, 7646 }; 7647 7648 /* *** SHOW DEVICE INFO *** */ 7649 struct cmd_showdevice_result { 7650 cmdline_fixed_string_t show; 7651 cmdline_fixed_string_t device; 7652 cmdline_fixed_string_t what; 7653 cmdline_fixed_string_t identifier; 7654 }; 7655 7656 static void cmd_showdevice_parsed(void *parsed_result, 7657 __rte_unused struct cmdline *cl, 7658 __rte_unused void *data) 7659 { 7660 struct cmd_showdevice_result *res = parsed_result; 7661 if (!strcmp(res->what, "info")) { 7662 if (!strcmp(res->identifier, "all")) 7663 device_infos_display(NULL); 7664 else 7665 device_infos_display(res->identifier); 7666 } 7667 } 7668 7669 cmdline_parse_token_string_t cmd_showdevice_show = 7670 TOKEN_STRING_INITIALIZER(struct cmd_showdevice_result, show, 7671 "show"); 7672 cmdline_parse_token_string_t cmd_showdevice_device = 7673 TOKEN_STRING_INITIALIZER(struct cmd_showdevice_result, device, "device"); 7674 cmdline_parse_token_string_t cmd_showdevice_what = 7675 TOKEN_STRING_INITIALIZER(struct cmd_showdevice_result, what, 7676 "info"); 7677 cmdline_parse_token_string_t cmd_showdevice_identifier = 7678 TOKEN_STRING_INITIALIZER(struct cmd_showdevice_result, 7679 identifier, NULL); 7680 7681 cmdline_parse_inst_t cmd_showdevice = { 7682 .f = cmd_showdevice_parsed, 7683 .data = NULL, 7684 .help_str = "show device info <identifier>|all", 7685 .tokens = { 7686 (void *)&cmd_showdevice_show, 7687 (void *)&cmd_showdevice_device, 7688 (void *)&cmd_showdevice_what, 7689 (void *)&cmd_showdevice_identifier, 7690 NULL, 7691 }, 7692 }; 7693 7694 /* *** SHOW MODULE EEPROM/EEPROM port INFO *** */ 7695 struct cmd_showeeprom_result { 7696 cmdline_fixed_string_t show; 7697 cmdline_fixed_string_t port; 7698 uint16_t portnum; 7699 cmdline_fixed_string_t type; 7700 }; 7701 7702 static void cmd_showeeprom_parsed(void *parsed_result, 7703 __rte_unused struct cmdline *cl, 7704 __rte_unused void *data) 7705 { 7706 struct cmd_showeeprom_result *res = parsed_result; 7707 7708 if (!strcmp(res->type, "eeprom")) 7709 port_eeprom_display(res->portnum); 7710 else if (!strcmp(res->type, "module_eeprom")) 7711 port_module_eeprom_display(res->portnum); 7712 else 7713 printf("Unknown argument\n"); 7714 } 7715 7716 cmdline_parse_token_string_t cmd_showeeprom_show = 7717 TOKEN_STRING_INITIALIZER(struct cmd_showeeprom_result, show, "show"); 7718 cmdline_parse_token_string_t cmd_showeeprom_port = 7719 TOKEN_STRING_INITIALIZER(struct cmd_showeeprom_result, port, "port"); 7720 cmdline_parse_token_num_t cmd_showeeprom_portnum = 7721 TOKEN_NUM_INITIALIZER(struct cmd_showeeprom_result, portnum, 7722 RTE_UINT16); 7723 cmdline_parse_token_string_t cmd_showeeprom_type = 7724 TOKEN_STRING_INITIALIZER(struct cmd_showeeprom_result, type, "module_eeprom#eeprom"); 7725 7726 cmdline_parse_inst_t cmd_showeeprom = { 7727 .f = cmd_showeeprom_parsed, 7728 .data = NULL, 7729 .help_str = "show port <port_id> module_eeprom|eeprom", 7730 .tokens = { 7731 (void *)&cmd_showeeprom_show, 7732 (void *)&cmd_showeeprom_port, 7733 (void *)&cmd_showeeprom_portnum, 7734 (void *)&cmd_showeeprom_type, 7735 NULL, 7736 }, 7737 }; 7738 7739 /* *** SHOW QUEUE INFO *** */ 7740 struct cmd_showqueue_result { 7741 cmdline_fixed_string_t show; 7742 cmdline_fixed_string_t type; 7743 cmdline_fixed_string_t what; 7744 uint16_t portnum; 7745 uint16_t queuenum; 7746 }; 7747 7748 static void 7749 cmd_showqueue_parsed(void *parsed_result, 7750 __rte_unused struct cmdline *cl, 7751 __rte_unused void *data) 7752 { 7753 struct cmd_showqueue_result *res = parsed_result; 7754 7755 if (!strcmp(res->type, "rxq")) 7756 rx_queue_infos_display(res->portnum, res->queuenum); 7757 else if (!strcmp(res->type, "txq")) 7758 tx_queue_infos_display(res->portnum, res->queuenum); 7759 } 7760 7761 cmdline_parse_token_string_t cmd_showqueue_show = 7762 TOKEN_STRING_INITIALIZER(struct cmd_showqueue_result, show, "show"); 7763 cmdline_parse_token_string_t cmd_showqueue_type = 7764 TOKEN_STRING_INITIALIZER(struct cmd_showqueue_result, type, "rxq#txq"); 7765 cmdline_parse_token_string_t cmd_showqueue_what = 7766 TOKEN_STRING_INITIALIZER(struct cmd_showqueue_result, what, "info"); 7767 cmdline_parse_token_num_t cmd_showqueue_portnum = 7768 TOKEN_NUM_INITIALIZER(struct cmd_showqueue_result, portnum, 7769 RTE_UINT16); 7770 cmdline_parse_token_num_t cmd_showqueue_queuenum = 7771 TOKEN_NUM_INITIALIZER(struct cmd_showqueue_result, queuenum, 7772 RTE_UINT16); 7773 7774 cmdline_parse_inst_t cmd_showqueue = { 7775 .f = cmd_showqueue_parsed, 7776 .data = NULL, 7777 .help_str = "show rxq|txq info <port_id> <queue_id>", 7778 .tokens = { 7779 (void *)&cmd_showqueue_show, 7780 (void *)&cmd_showqueue_type, 7781 (void *)&cmd_showqueue_what, 7782 (void *)&cmd_showqueue_portnum, 7783 (void *)&cmd_showqueue_queuenum, 7784 NULL, 7785 }, 7786 }; 7787 7788 /* show/clear fwd engine statistics */ 7789 struct fwd_result { 7790 cmdline_fixed_string_t action; 7791 cmdline_fixed_string_t fwd; 7792 cmdline_fixed_string_t stats; 7793 cmdline_fixed_string_t all; 7794 }; 7795 7796 cmdline_parse_token_string_t cmd_fwd_action = 7797 TOKEN_STRING_INITIALIZER(struct fwd_result, action, "show#clear"); 7798 cmdline_parse_token_string_t cmd_fwd_fwd = 7799 TOKEN_STRING_INITIALIZER(struct fwd_result, fwd, "fwd"); 7800 cmdline_parse_token_string_t cmd_fwd_stats = 7801 TOKEN_STRING_INITIALIZER(struct fwd_result, stats, "stats"); 7802 cmdline_parse_token_string_t cmd_fwd_all = 7803 TOKEN_STRING_INITIALIZER(struct fwd_result, all, "all"); 7804 7805 static void 7806 cmd_showfwdall_parsed(void *parsed_result, 7807 __rte_unused struct cmdline *cl, 7808 __rte_unused void *data) 7809 { 7810 struct fwd_result *res = parsed_result; 7811 7812 if (!strcmp(res->action, "show")) 7813 fwd_stats_display(); 7814 else 7815 fwd_stats_reset(); 7816 } 7817 7818 static cmdline_parse_inst_t cmd_showfwdall = { 7819 .f = cmd_showfwdall_parsed, 7820 .data = NULL, 7821 .help_str = "show|clear fwd stats all", 7822 .tokens = { 7823 (void *)&cmd_fwd_action, 7824 (void *)&cmd_fwd_fwd, 7825 (void *)&cmd_fwd_stats, 7826 (void *)&cmd_fwd_all, 7827 NULL, 7828 }, 7829 }; 7830 7831 /* *** READ PORT REGISTER *** */ 7832 struct cmd_read_reg_result { 7833 cmdline_fixed_string_t read; 7834 cmdline_fixed_string_t reg; 7835 portid_t port_id; 7836 uint32_t reg_off; 7837 }; 7838 7839 static void 7840 cmd_read_reg_parsed(void *parsed_result, 7841 __rte_unused struct cmdline *cl, 7842 __rte_unused void *data) 7843 { 7844 struct cmd_read_reg_result *res = parsed_result; 7845 port_reg_display(res->port_id, res->reg_off); 7846 } 7847 7848 cmdline_parse_token_string_t cmd_read_reg_read = 7849 TOKEN_STRING_INITIALIZER(struct cmd_read_reg_result, read, "read"); 7850 cmdline_parse_token_string_t cmd_read_reg_reg = 7851 TOKEN_STRING_INITIALIZER(struct cmd_read_reg_result, reg, "reg"); 7852 cmdline_parse_token_num_t cmd_read_reg_port_id = 7853 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_result, port_id, RTE_UINT16); 7854 cmdline_parse_token_num_t cmd_read_reg_reg_off = 7855 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_result, reg_off, RTE_UINT32); 7856 7857 cmdline_parse_inst_t cmd_read_reg = { 7858 .f = cmd_read_reg_parsed, 7859 .data = NULL, 7860 .help_str = "read reg <port_id> <reg_off>", 7861 .tokens = { 7862 (void *)&cmd_read_reg_read, 7863 (void *)&cmd_read_reg_reg, 7864 (void *)&cmd_read_reg_port_id, 7865 (void *)&cmd_read_reg_reg_off, 7866 NULL, 7867 }, 7868 }; 7869 7870 /* *** READ PORT REGISTER BIT FIELD *** */ 7871 struct cmd_read_reg_bit_field_result { 7872 cmdline_fixed_string_t read; 7873 cmdline_fixed_string_t regfield; 7874 portid_t port_id; 7875 uint32_t reg_off; 7876 uint8_t bit1_pos; 7877 uint8_t bit2_pos; 7878 }; 7879 7880 static void 7881 cmd_read_reg_bit_field_parsed(void *parsed_result, 7882 __rte_unused struct cmdline *cl, 7883 __rte_unused void *data) 7884 { 7885 struct cmd_read_reg_bit_field_result *res = parsed_result; 7886 port_reg_bit_field_display(res->port_id, res->reg_off, 7887 res->bit1_pos, res->bit2_pos); 7888 } 7889 7890 cmdline_parse_token_string_t cmd_read_reg_bit_field_read = 7891 TOKEN_STRING_INITIALIZER(struct cmd_read_reg_bit_field_result, read, 7892 "read"); 7893 cmdline_parse_token_string_t cmd_read_reg_bit_field_regfield = 7894 TOKEN_STRING_INITIALIZER(struct cmd_read_reg_bit_field_result, 7895 regfield, "regfield"); 7896 cmdline_parse_token_num_t cmd_read_reg_bit_field_port_id = 7897 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_field_result, port_id, 7898 RTE_UINT16); 7899 cmdline_parse_token_num_t cmd_read_reg_bit_field_reg_off = 7900 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_field_result, reg_off, 7901 RTE_UINT32); 7902 cmdline_parse_token_num_t cmd_read_reg_bit_field_bit1_pos = 7903 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_field_result, bit1_pos, 7904 RTE_UINT8); 7905 cmdline_parse_token_num_t cmd_read_reg_bit_field_bit2_pos = 7906 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_field_result, bit2_pos, 7907 RTE_UINT8); 7908 7909 cmdline_parse_inst_t cmd_read_reg_bit_field = { 7910 .f = cmd_read_reg_bit_field_parsed, 7911 .data = NULL, 7912 .help_str = "read regfield <port_id> <reg_off> <bit_x> <bit_y>: " 7913 "Read register bit field between bit_x and bit_y included", 7914 .tokens = { 7915 (void *)&cmd_read_reg_bit_field_read, 7916 (void *)&cmd_read_reg_bit_field_regfield, 7917 (void *)&cmd_read_reg_bit_field_port_id, 7918 (void *)&cmd_read_reg_bit_field_reg_off, 7919 (void *)&cmd_read_reg_bit_field_bit1_pos, 7920 (void *)&cmd_read_reg_bit_field_bit2_pos, 7921 NULL, 7922 }, 7923 }; 7924 7925 /* *** READ PORT REGISTER BIT *** */ 7926 struct cmd_read_reg_bit_result { 7927 cmdline_fixed_string_t read; 7928 cmdline_fixed_string_t regbit; 7929 portid_t port_id; 7930 uint32_t reg_off; 7931 uint8_t bit_pos; 7932 }; 7933 7934 static void 7935 cmd_read_reg_bit_parsed(void *parsed_result, 7936 __rte_unused struct cmdline *cl, 7937 __rte_unused void *data) 7938 { 7939 struct cmd_read_reg_bit_result *res = parsed_result; 7940 port_reg_bit_display(res->port_id, res->reg_off, res->bit_pos); 7941 } 7942 7943 cmdline_parse_token_string_t cmd_read_reg_bit_read = 7944 TOKEN_STRING_INITIALIZER(struct cmd_read_reg_bit_result, read, "read"); 7945 cmdline_parse_token_string_t cmd_read_reg_bit_regbit = 7946 TOKEN_STRING_INITIALIZER(struct cmd_read_reg_bit_result, 7947 regbit, "regbit"); 7948 cmdline_parse_token_num_t cmd_read_reg_bit_port_id = 7949 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_result, port_id, 7950 RTE_UINT16); 7951 cmdline_parse_token_num_t cmd_read_reg_bit_reg_off = 7952 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_result, reg_off, 7953 RTE_UINT32); 7954 cmdline_parse_token_num_t cmd_read_reg_bit_bit_pos = 7955 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_result, bit_pos, 7956 RTE_UINT8); 7957 7958 cmdline_parse_inst_t cmd_read_reg_bit = { 7959 .f = cmd_read_reg_bit_parsed, 7960 .data = NULL, 7961 .help_str = "read regbit <port_id> <reg_off> <bit_x>: 0 <= bit_x <= 31", 7962 .tokens = { 7963 (void *)&cmd_read_reg_bit_read, 7964 (void *)&cmd_read_reg_bit_regbit, 7965 (void *)&cmd_read_reg_bit_port_id, 7966 (void *)&cmd_read_reg_bit_reg_off, 7967 (void *)&cmd_read_reg_bit_bit_pos, 7968 NULL, 7969 }, 7970 }; 7971 7972 /* *** WRITE PORT REGISTER *** */ 7973 struct cmd_write_reg_result { 7974 cmdline_fixed_string_t write; 7975 cmdline_fixed_string_t reg; 7976 portid_t port_id; 7977 uint32_t reg_off; 7978 uint32_t value; 7979 }; 7980 7981 static void 7982 cmd_write_reg_parsed(void *parsed_result, 7983 __rte_unused struct cmdline *cl, 7984 __rte_unused void *data) 7985 { 7986 struct cmd_write_reg_result *res = parsed_result; 7987 port_reg_set(res->port_id, res->reg_off, res->value); 7988 } 7989 7990 cmdline_parse_token_string_t cmd_write_reg_write = 7991 TOKEN_STRING_INITIALIZER(struct cmd_write_reg_result, write, "write"); 7992 cmdline_parse_token_string_t cmd_write_reg_reg = 7993 TOKEN_STRING_INITIALIZER(struct cmd_write_reg_result, reg, "reg"); 7994 cmdline_parse_token_num_t cmd_write_reg_port_id = 7995 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_result, port_id, RTE_UINT16); 7996 cmdline_parse_token_num_t cmd_write_reg_reg_off = 7997 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_result, reg_off, RTE_UINT32); 7998 cmdline_parse_token_num_t cmd_write_reg_value = 7999 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_result, value, RTE_UINT32); 8000 8001 cmdline_parse_inst_t cmd_write_reg = { 8002 .f = cmd_write_reg_parsed, 8003 .data = NULL, 8004 .help_str = "write reg <port_id> <reg_off> <reg_value>", 8005 .tokens = { 8006 (void *)&cmd_write_reg_write, 8007 (void *)&cmd_write_reg_reg, 8008 (void *)&cmd_write_reg_port_id, 8009 (void *)&cmd_write_reg_reg_off, 8010 (void *)&cmd_write_reg_value, 8011 NULL, 8012 }, 8013 }; 8014 8015 /* *** WRITE PORT REGISTER BIT FIELD *** */ 8016 struct cmd_write_reg_bit_field_result { 8017 cmdline_fixed_string_t write; 8018 cmdline_fixed_string_t regfield; 8019 portid_t port_id; 8020 uint32_t reg_off; 8021 uint8_t bit1_pos; 8022 uint8_t bit2_pos; 8023 uint32_t value; 8024 }; 8025 8026 static void 8027 cmd_write_reg_bit_field_parsed(void *parsed_result, 8028 __rte_unused struct cmdline *cl, 8029 __rte_unused void *data) 8030 { 8031 struct cmd_write_reg_bit_field_result *res = parsed_result; 8032 port_reg_bit_field_set(res->port_id, res->reg_off, 8033 res->bit1_pos, res->bit2_pos, res->value); 8034 } 8035 8036 cmdline_parse_token_string_t cmd_write_reg_bit_field_write = 8037 TOKEN_STRING_INITIALIZER(struct cmd_write_reg_bit_field_result, write, 8038 "write"); 8039 cmdline_parse_token_string_t cmd_write_reg_bit_field_regfield = 8040 TOKEN_STRING_INITIALIZER(struct cmd_write_reg_bit_field_result, 8041 regfield, "regfield"); 8042 cmdline_parse_token_num_t cmd_write_reg_bit_field_port_id = 8043 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_field_result, port_id, 8044 RTE_UINT16); 8045 cmdline_parse_token_num_t cmd_write_reg_bit_field_reg_off = 8046 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_field_result, reg_off, 8047 RTE_UINT32); 8048 cmdline_parse_token_num_t cmd_write_reg_bit_field_bit1_pos = 8049 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_field_result, bit1_pos, 8050 RTE_UINT8); 8051 cmdline_parse_token_num_t cmd_write_reg_bit_field_bit2_pos = 8052 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_field_result, bit2_pos, 8053 RTE_UINT8); 8054 cmdline_parse_token_num_t cmd_write_reg_bit_field_value = 8055 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_field_result, value, 8056 RTE_UINT32); 8057 8058 cmdline_parse_inst_t cmd_write_reg_bit_field = { 8059 .f = cmd_write_reg_bit_field_parsed, 8060 .data = NULL, 8061 .help_str = "write regfield <port_id> <reg_off> <bit_x> <bit_y> " 8062 "<reg_value>: " 8063 "Set register bit field between bit_x and bit_y included", 8064 .tokens = { 8065 (void *)&cmd_write_reg_bit_field_write, 8066 (void *)&cmd_write_reg_bit_field_regfield, 8067 (void *)&cmd_write_reg_bit_field_port_id, 8068 (void *)&cmd_write_reg_bit_field_reg_off, 8069 (void *)&cmd_write_reg_bit_field_bit1_pos, 8070 (void *)&cmd_write_reg_bit_field_bit2_pos, 8071 (void *)&cmd_write_reg_bit_field_value, 8072 NULL, 8073 }, 8074 }; 8075 8076 /* *** WRITE PORT REGISTER BIT *** */ 8077 struct cmd_write_reg_bit_result { 8078 cmdline_fixed_string_t write; 8079 cmdline_fixed_string_t regbit; 8080 portid_t port_id; 8081 uint32_t reg_off; 8082 uint8_t bit_pos; 8083 uint8_t value; 8084 }; 8085 8086 static void 8087 cmd_write_reg_bit_parsed(void *parsed_result, 8088 __rte_unused struct cmdline *cl, 8089 __rte_unused void *data) 8090 { 8091 struct cmd_write_reg_bit_result *res = parsed_result; 8092 port_reg_bit_set(res->port_id, res->reg_off, res->bit_pos, res->value); 8093 } 8094 8095 cmdline_parse_token_string_t cmd_write_reg_bit_write = 8096 TOKEN_STRING_INITIALIZER(struct cmd_write_reg_bit_result, write, 8097 "write"); 8098 cmdline_parse_token_string_t cmd_write_reg_bit_regbit = 8099 TOKEN_STRING_INITIALIZER(struct cmd_write_reg_bit_result, 8100 regbit, "regbit"); 8101 cmdline_parse_token_num_t cmd_write_reg_bit_port_id = 8102 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_result, port_id, 8103 RTE_UINT16); 8104 cmdline_parse_token_num_t cmd_write_reg_bit_reg_off = 8105 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_result, reg_off, 8106 RTE_UINT32); 8107 cmdline_parse_token_num_t cmd_write_reg_bit_bit_pos = 8108 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_result, bit_pos, 8109 RTE_UINT8); 8110 cmdline_parse_token_num_t cmd_write_reg_bit_value = 8111 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_result, value, 8112 RTE_UINT8); 8113 8114 cmdline_parse_inst_t cmd_write_reg_bit = { 8115 .f = cmd_write_reg_bit_parsed, 8116 .data = NULL, 8117 .help_str = "write regbit <port_id> <reg_off> <bit_x> 0|1: " 8118 "0 <= bit_x <= 31", 8119 .tokens = { 8120 (void *)&cmd_write_reg_bit_write, 8121 (void *)&cmd_write_reg_bit_regbit, 8122 (void *)&cmd_write_reg_bit_port_id, 8123 (void *)&cmd_write_reg_bit_reg_off, 8124 (void *)&cmd_write_reg_bit_bit_pos, 8125 (void *)&cmd_write_reg_bit_value, 8126 NULL, 8127 }, 8128 }; 8129 8130 /* *** READ A RING DESCRIPTOR OF A PORT RX/TX QUEUE *** */ 8131 struct cmd_read_rxd_txd_result { 8132 cmdline_fixed_string_t read; 8133 cmdline_fixed_string_t rxd_txd; 8134 portid_t port_id; 8135 uint16_t queue_id; 8136 uint16_t desc_id; 8137 }; 8138 8139 static void 8140 cmd_read_rxd_txd_parsed(void *parsed_result, 8141 __rte_unused struct cmdline *cl, 8142 __rte_unused void *data) 8143 { 8144 struct cmd_read_rxd_txd_result *res = parsed_result; 8145 8146 if (!strcmp(res->rxd_txd, "rxd")) 8147 rx_ring_desc_display(res->port_id, res->queue_id, res->desc_id); 8148 else if (!strcmp(res->rxd_txd, "txd")) 8149 tx_ring_desc_display(res->port_id, res->queue_id, res->desc_id); 8150 } 8151 8152 cmdline_parse_token_string_t cmd_read_rxd_txd_read = 8153 TOKEN_STRING_INITIALIZER(struct cmd_read_rxd_txd_result, read, "read"); 8154 cmdline_parse_token_string_t cmd_read_rxd_txd_rxd_txd = 8155 TOKEN_STRING_INITIALIZER(struct cmd_read_rxd_txd_result, rxd_txd, 8156 "rxd#txd"); 8157 cmdline_parse_token_num_t cmd_read_rxd_txd_port_id = 8158 TOKEN_NUM_INITIALIZER(struct cmd_read_rxd_txd_result, port_id, 8159 RTE_UINT16); 8160 cmdline_parse_token_num_t cmd_read_rxd_txd_queue_id = 8161 TOKEN_NUM_INITIALIZER(struct cmd_read_rxd_txd_result, queue_id, 8162 RTE_UINT16); 8163 cmdline_parse_token_num_t cmd_read_rxd_txd_desc_id = 8164 TOKEN_NUM_INITIALIZER(struct cmd_read_rxd_txd_result, desc_id, 8165 RTE_UINT16); 8166 8167 cmdline_parse_inst_t cmd_read_rxd_txd = { 8168 .f = cmd_read_rxd_txd_parsed, 8169 .data = NULL, 8170 .help_str = "read rxd|txd <port_id> <queue_id> <desc_id>", 8171 .tokens = { 8172 (void *)&cmd_read_rxd_txd_read, 8173 (void *)&cmd_read_rxd_txd_rxd_txd, 8174 (void *)&cmd_read_rxd_txd_port_id, 8175 (void *)&cmd_read_rxd_txd_queue_id, 8176 (void *)&cmd_read_rxd_txd_desc_id, 8177 NULL, 8178 }, 8179 }; 8180 8181 /* *** QUIT *** */ 8182 struct cmd_quit_result { 8183 cmdline_fixed_string_t quit; 8184 }; 8185 8186 static void cmd_quit_parsed(__rte_unused void *parsed_result, 8187 struct cmdline *cl, 8188 __rte_unused void *data) 8189 { 8190 cmdline_quit(cl); 8191 } 8192 8193 cmdline_parse_token_string_t cmd_quit_quit = 8194 TOKEN_STRING_INITIALIZER(struct cmd_quit_result, quit, "quit"); 8195 8196 cmdline_parse_inst_t cmd_quit = { 8197 .f = cmd_quit_parsed, 8198 .data = NULL, 8199 .help_str = "quit: Exit application", 8200 .tokens = { 8201 (void *)&cmd_quit_quit, 8202 NULL, 8203 }, 8204 }; 8205 8206 /* *** ADD/REMOVE MAC ADDRESS FROM A PORT *** */ 8207 struct cmd_mac_addr_result { 8208 cmdline_fixed_string_t mac_addr_cmd; 8209 cmdline_fixed_string_t what; 8210 uint16_t port_num; 8211 struct rte_ether_addr address; 8212 }; 8213 8214 static void cmd_mac_addr_parsed(void *parsed_result, 8215 __rte_unused struct cmdline *cl, 8216 __rte_unused void *data) 8217 { 8218 struct cmd_mac_addr_result *res = parsed_result; 8219 int ret; 8220 8221 if (strcmp(res->what, "add") == 0) 8222 ret = rte_eth_dev_mac_addr_add(res->port_num, &res->address, 0); 8223 else if (strcmp(res->what, "set") == 0) 8224 ret = rte_eth_dev_default_mac_addr_set(res->port_num, 8225 &res->address); 8226 else 8227 ret = rte_eth_dev_mac_addr_remove(res->port_num, &res->address); 8228 8229 /* check the return value and print it if is < 0 */ 8230 if(ret < 0) 8231 printf("mac_addr_cmd error: (%s)\n", strerror(-ret)); 8232 8233 } 8234 8235 cmdline_parse_token_string_t cmd_mac_addr_cmd = 8236 TOKEN_STRING_INITIALIZER(struct cmd_mac_addr_result, mac_addr_cmd, 8237 "mac_addr"); 8238 cmdline_parse_token_string_t cmd_mac_addr_what = 8239 TOKEN_STRING_INITIALIZER(struct cmd_mac_addr_result, what, 8240 "add#remove#set"); 8241 cmdline_parse_token_num_t cmd_mac_addr_portnum = 8242 TOKEN_NUM_INITIALIZER(struct cmd_mac_addr_result, port_num, 8243 RTE_UINT16); 8244 cmdline_parse_token_etheraddr_t cmd_mac_addr_addr = 8245 TOKEN_ETHERADDR_INITIALIZER(struct cmd_mac_addr_result, address); 8246 8247 cmdline_parse_inst_t cmd_mac_addr = { 8248 .f = cmd_mac_addr_parsed, 8249 .data = (void *)0, 8250 .help_str = "mac_addr add|remove|set <port_id> <mac_addr>: " 8251 "Add/Remove/Set MAC address on port_id", 8252 .tokens = { 8253 (void *)&cmd_mac_addr_cmd, 8254 (void *)&cmd_mac_addr_what, 8255 (void *)&cmd_mac_addr_portnum, 8256 (void *)&cmd_mac_addr_addr, 8257 NULL, 8258 }, 8259 }; 8260 8261 /* *** SET THE PEER ADDRESS FOR CERTAIN PORT *** */ 8262 struct cmd_eth_peer_result { 8263 cmdline_fixed_string_t set; 8264 cmdline_fixed_string_t eth_peer; 8265 portid_t port_id; 8266 cmdline_fixed_string_t peer_addr; 8267 }; 8268 8269 static void cmd_set_eth_peer_parsed(void *parsed_result, 8270 __rte_unused struct cmdline *cl, 8271 __rte_unused void *data) 8272 { 8273 struct cmd_eth_peer_result *res = parsed_result; 8274 8275 if (test_done == 0) { 8276 printf("Please stop forwarding first\n"); 8277 return; 8278 } 8279 if (!strcmp(res->eth_peer, "eth-peer")) { 8280 set_fwd_eth_peer(res->port_id, res->peer_addr); 8281 fwd_config_setup(); 8282 } 8283 } 8284 cmdline_parse_token_string_t cmd_eth_peer_set = 8285 TOKEN_STRING_INITIALIZER(struct cmd_eth_peer_result, set, "set"); 8286 cmdline_parse_token_string_t cmd_eth_peer = 8287 TOKEN_STRING_INITIALIZER(struct cmd_eth_peer_result, eth_peer, "eth-peer"); 8288 cmdline_parse_token_num_t cmd_eth_peer_port_id = 8289 TOKEN_NUM_INITIALIZER(struct cmd_eth_peer_result, port_id, 8290 RTE_UINT16); 8291 cmdline_parse_token_string_t cmd_eth_peer_addr = 8292 TOKEN_STRING_INITIALIZER(struct cmd_eth_peer_result, peer_addr, NULL); 8293 8294 cmdline_parse_inst_t cmd_set_fwd_eth_peer = { 8295 .f = cmd_set_eth_peer_parsed, 8296 .data = NULL, 8297 .help_str = "set eth-peer <port_id> <peer_mac>", 8298 .tokens = { 8299 (void *)&cmd_eth_peer_set, 8300 (void *)&cmd_eth_peer, 8301 (void *)&cmd_eth_peer_port_id, 8302 (void *)&cmd_eth_peer_addr, 8303 NULL, 8304 }, 8305 }; 8306 8307 /* *** CONFIGURE QUEUE STATS COUNTER MAPPINGS *** */ 8308 struct cmd_set_qmap_result { 8309 cmdline_fixed_string_t set; 8310 cmdline_fixed_string_t qmap; 8311 cmdline_fixed_string_t what; 8312 portid_t port_id; 8313 uint16_t queue_id; 8314 uint8_t map_value; 8315 }; 8316 8317 static void 8318 cmd_set_qmap_parsed(void *parsed_result, 8319 __rte_unused struct cmdline *cl, 8320 __rte_unused void *data) 8321 { 8322 struct cmd_set_qmap_result *res = parsed_result; 8323 int is_rx = (strcmp(res->what, "tx") == 0) ? 0 : 1; 8324 8325 set_qmap(res->port_id, (uint8_t)is_rx, res->queue_id, res->map_value); 8326 } 8327 8328 cmdline_parse_token_string_t cmd_setqmap_set = 8329 TOKEN_STRING_INITIALIZER(struct cmd_set_qmap_result, 8330 set, "set"); 8331 cmdline_parse_token_string_t cmd_setqmap_qmap = 8332 TOKEN_STRING_INITIALIZER(struct cmd_set_qmap_result, 8333 qmap, "stat_qmap"); 8334 cmdline_parse_token_string_t cmd_setqmap_what = 8335 TOKEN_STRING_INITIALIZER(struct cmd_set_qmap_result, 8336 what, "tx#rx"); 8337 cmdline_parse_token_num_t cmd_setqmap_portid = 8338 TOKEN_NUM_INITIALIZER(struct cmd_set_qmap_result, 8339 port_id, RTE_UINT16); 8340 cmdline_parse_token_num_t cmd_setqmap_queueid = 8341 TOKEN_NUM_INITIALIZER(struct cmd_set_qmap_result, 8342 queue_id, RTE_UINT16); 8343 cmdline_parse_token_num_t cmd_setqmap_mapvalue = 8344 TOKEN_NUM_INITIALIZER(struct cmd_set_qmap_result, 8345 map_value, RTE_UINT8); 8346 8347 cmdline_parse_inst_t cmd_set_qmap = { 8348 .f = cmd_set_qmap_parsed, 8349 .data = NULL, 8350 .help_str = "set stat_qmap rx|tx <port_id> <queue_id> <map_value>: " 8351 "Set statistics mapping value on tx|rx queue_id of port_id", 8352 .tokens = { 8353 (void *)&cmd_setqmap_set, 8354 (void *)&cmd_setqmap_qmap, 8355 (void *)&cmd_setqmap_what, 8356 (void *)&cmd_setqmap_portid, 8357 (void *)&cmd_setqmap_queueid, 8358 (void *)&cmd_setqmap_mapvalue, 8359 NULL, 8360 }, 8361 }; 8362 8363 /* *** SET OPTION TO HIDE ZERO VALUES FOR XSTATS DISPLAY *** */ 8364 struct cmd_set_xstats_hide_zero_result { 8365 cmdline_fixed_string_t keyword; 8366 cmdline_fixed_string_t name; 8367 cmdline_fixed_string_t on_off; 8368 }; 8369 8370 static void 8371 cmd_set_xstats_hide_zero_parsed(void *parsed_result, 8372 __rte_unused struct cmdline *cl, 8373 __rte_unused void *data) 8374 { 8375 struct cmd_set_xstats_hide_zero_result *res; 8376 uint16_t on_off = 0; 8377 8378 res = parsed_result; 8379 on_off = !strcmp(res->on_off, "on") ? 1 : 0; 8380 set_xstats_hide_zero(on_off); 8381 } 8382 8383 cmdline_parse_token_string_t cmd_set_xstats_hide_zero_keyword = 8384 TOKEN_STRING_INITIALIZER(struct cmd_set_xstats_hide_zero_result, 8385 keyword, "set"); 8386 cmdline_parse_token_string_t cmd_set_xstats_hide_zero_name = 8387 TOKEN_STRING_INITIALIZER(struct cmd_set_xstats_hide_zero_result, 8388 name, "xstats-hide-zero"); 8389 cmdline_parse_token_string_t cmd_set_xstats_hide_zero_on_off = 8390 TOKEN_STRING_INITIALIZER(struct cmd_set_xstats_hide_zero_result, 8391 on_off, "on#off"); 8392 8393 cmdline_parse_inst_t cmd_set_xstats_hide_zero = { 8394 .f = cmd_set_xstats_hide_zero_parsed, 8395 .data = NULL, 8396 .help_str = "set xstats-hide-zero on|off", 8397 .tokens = { 8398 (void *)&cmd_set_xstats_hide_zero_keyword, 8399 (void *)&cmd_set_xstats_hide_zero_name, 8400 (void *)&cmd_set_xstats_hide_zero_on_off, 8401 NULL, 8402 }, 8403 }; 8404 8405 /* *** SET OPTION TO ENABLE MEASUREMENT OF CPU CYCLES *** */ 8406 struct cmd_set_record_core_cycles_result { 8407 cmdline_fixed_string_t keyword; 8408 cmdline_fixed_string_t name; 8409 cmdline_fixed_string_t on_off; 8410 }; 8411 8412 static void 8413 cmd_set_record_core_cycles_parsed(void *parsed_result, 8414 __rte_unused struct cmdline *cl, 8415 __rte_unused void *data) 8416 { 8417 struct cmd_set_record_core_cycles_result *res; 8418 uint16_t on_off = 0; 8419 8420 res = parsed_result; 8421 on_off = !strcmp(res->on_off, "on") ? 1 : 0; 8422 set_record_core_cycles(on_off); 8423 } 8424 8425 cmdline_parse_token_string_t cmd_set_record_core_cycles_keyword = 8426 TOKEN_STRING_INITIALIZER(struct cmd_set_record_core_cycles_result, 8427 keyword, "set"); 8428 cmdline_parse_token_string_t cmd_set_record_core_cycles_name = 8429 TOKEN_STRING_INITIALIZER(struct cmd_set_record_core_cycles_result, 8430 name, "record-core-cycles"); 8431 cmdline_parse_token_string_t cmd_set_record_core_cycles_on_off = 8432 TOKEN_STRING_INITIALIZER(struct cmd_set_record_core_cycles_result, 8433 on_off, "on#off"); 8434 8435 cmdline_parse_inst_t cmd_set_record_core_cycles = { 8436 .f = cmd_set_record_core_cycles_parsed, 8437 .data = NULL, 8438 .help_str = "set record-core-cycles on|off", 8439 .tokens = { 8440 (void *)&cmd_set_record_core_cycles_keyword, 8441 (void *)&cmd_set_record_core_cycles_name, 8442 (void *)&cmd_set_record_core_cycles_on_off, 8443 NULL, 8444 }, 8445 }; 8446 8447 /* *** SET OPTION TO ENABLE DISPLAY OF RX AND TX BURSTS *** */ 8448 struct cmd_set_record_burst_stats_result { 8449 cmdline_fixed_string_t keyword; 8450 cmdline_fixed_string_t name; 8451 cmdline_fixed_string_t on_off; 8452 }; 8453 8454 static void 8455 cmd_set_record_burst_stats_parsed(void *parsed_result, 8456 __rte_unused struct cmdline *cl, 8457 __rte_unused void *data) 8458 { 8459 struct cmd_set_record_burst_stats_result *res; 8460 uint16_t on_off = 0; 8461 8462 res = parsed_result; 8463 on_off = !strcmp(res->on_off, "on") ? 1 : 0; 8464 set_record_burst_stats(on_off); 8465 } 8466 8467 cmdline_parse_token_string_t cmd_set_record_burst_stats_keyword = 8468 TOKEN_STRING_INITIALIZER(struct cmd_set_record_burst_stats_result, 8469 keyword, "set"); 8470 cmdline_parse_token_string_t cmd_set_record_burst_stats_name = 8471 TOKEN_STRING_INITIALIZER(struct cmd_set_record_burst_stats_result, 8472 name, "record-burst-stats"); 8473 cmdline_parse_token_string_t cmd_set_record_burst_stats_on_off = 8474 TOKEN_STRING_INITIALIZER(struct cmd_set_record_burst_stats_result, 8475 on_off, "on#off"); 8476 8477 cmdline_parse_inst_t cmd_set_record_burst_stats = { 8478 .f = cmd_set_record_burst_stats_parsed, 8479 .data = NULL, 8480 .help_str = "set record-burst-stats on|off", 8481 .tokens = { 8482 (void *)&cmd_set_record_burst_stats_keyword, 8483 (void *)&cmd_set_record_burst_stats_name, 8484 (void *)&cmd_set_record_burst_stats_on_off, 8485 NULL, 8486 }, 8487 }; 8488 8489 /* *** CONFIGURE UNICAST HASH TABLE *** */ 8490 struct cmd_set_uc_hash_table { 8491 cmdline_fixed_string_t set; 8492 cmdline_fixed_string_t port; 8493 portid_t port_id; 8494 cmdline_fixed_string_t what; 8495 struct rte_ether_addr address; 8496 cmdline_fixed_string_t mode; 8497 }; 8498 8499 static void 8500 cmd_set_uc_hash_parsed(void *parsed_result, 8501 __rte_unused struct cmdline *cl, 8502 __rte_unused void *data) 8503 { 8504 int ret=0; 8505 struct cmd_set_uc_hash_table *res = parsed_result; 8506 8507 int is_on = (strcmp(res->mode, "on") == 0) ? 1 : 0; 8508 8509 if (strcmp(res->what, "uta") == 0) 8510 ret = rte_eth_dev_uc_hash_table_set(res->port_id, 8511 &res->address,(uint8_t)is_on); 8512 if (ret < 0) 8513 printf("bad unicast hash table parameter, return code = %d \n", ret); 8514 8515 } 8516 8517 cmdline_parse_token_string_t cmd_set_uc_hash_set = 8518 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_hash_table, 8519 set, "set"); 8520 cmdline_parse_token_string_t cmd_set_uc_hash_port = 8521 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_hash_table, 8522 port, "port"); 8523 cmdline_parse_token_num_t cmd_set_uc_hash_portid = 8524 TOKEN_NUM_INITIALIZER(struct cmd_set_uc_hash_table, 8525 port_id, RTE_UINT16); 8526 cmdline_parse_token_string_t cmd_set_uc_hash_what = 8527 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_hash_table, 8528 what, "uta"); 8529 cmdline_parse_token_etheraddr_t cmd_set_uc_hash_mac = 8530 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_uc_hash_table, 8531 address); 8532 cmdline_parse_token_string_t cmd_set_uc_hash_mode = 8533 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_hash_table, 8534 mode, "on#off"); 8535 8536 cmdline_parse_inst_t cmd_set_uc_hash_filter = { 8537 .f = cmd_set_uc_hash_parsed, 8538 .data = NULL, 8539 .help_str = "set port <port_id> uta <mac_addr> on|off)", 8540 .tokens = { 8541 (void *)&cmd_set_uc_hash_set, 8542 (void *)&cmd_set_uc_hash_port, 8543 (void *)&cmd_set_uc_hash_portid, 8544 (void *)&cmd_set_uc_hash_what, 8545 (void *)&cmd_set_uc_hash_mac, 8546 (void *)&cmd_set_uc_hash_mode, 8547 NULL, 8548 }, 8549 }; 8550 8551 struct cmd_set_uc_all_hash_table { 8552 cmdline_fixed_string_t set; 8553 cmdline_fixed_string_t port; 8554 portid_t port_id; 8555 cmdline_fixed_string_t what; 8556 cmdline_fixed_string_t value; 8557 cmdline_fixed_string_t mode; 8558 }; 8559 8560 static void 8561 cmd_set_uc_all_hash_parsed(void *parsed_result, 8562 __rte_unused struct cmdline *cl, 8563 __rte_unused void *data) 8564 { 8565 int ret=0; 8566 struct cmd_set_uc_all_hash_table *res = parsed_result; 8567 8568 int is_on = (strcmp(res->mode, "on") == 0) ? 1 : 0; 8569 8570 if ((strcmp(res->what, "uta") == 0) && 8571 (strcmp(res->value, "all") == 0)) 8572 ret = rte_eth_dev_uc_all_hash_table_set(res->port_id,(uint8_t) is_on); 8573 if (ret < 0) 8574 printf("bad unicast hash table parameter," 8575 "return code = %d \n", ret); 8576 } 8577 8578 cmdline_parse_token_string_t cmd_set_uc_all_hash_set = 8579 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_all_hash_table, 8580 set, "set"); 8581 cmdline_parse_token_string_t cmd_set_uc_all_hash_port = 8582 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_all_hash_table, 8583 port, "port"); 8584 cmdline_parse_token_num_t cmd_set_uc_all_hash_portid = 8585 TOKEN_NUM_INITIALIZER(struct cmd_set_uc_all_hash_table, 8586 port_id, RTE_UINT16); 8587 cmdline_parse_token_string_t cmd_set_uc_all_hash_what = 8588 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_all_hash_table, 8589 what, "uta"); 8590 cmdline_parse_token_string_t cmd_set_uc_all_hash_value = 8591 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_all_hash_table, 8592 value,"all"); 8593 cmdline_parse_token_string_t cmd_set_uc_all_hash_mode = 8594 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_all_hash_table, 8595 mode, "on#off"); 8596 8597 cmdline_parse_inst_t cmd_set_uc_all_hash_filter = { 8598 .f = cmd_set_uc_all_hash_parsed, 8599 .data = NULL, 8600 .help_str = "set port <port_id> uta all on|off", 8601 .tokens = { 8602 (void *)&cmd_set_uc_all_hash_set, 8603 (void *)&cmd_set_uc_all_hash_port, 8604 (void *)&cmd_set_uc_all_hash_portid, 8605 (void *)&cmd_set_uc_all_hash_what, 8606 (void *)&cmd_set_uc_all_hash_value, 8607 (void *)&cmd_set_uc_all_hash_mode, 8608 NULL, 8609 }, 8610 }; 8611 8612 /* *** CONFIGURE VF TRAFFIC CONTROL *** */ 8613 struct cmd_set_vf_traffic { 8614 cmdline_fixed_string_t set; 8615 cmdline_fixed_string_t port; 8616 portid_t port_id; 8617 cmdline_fixed_string_t vf; 8618 uint8_t vf_id; 8619 cmdline_fixed_string_t what; 8620 cmdline_fixed_string_t mode; 8621 }; 8622 8623 static void 8624 cmd_set_vf_traffic_parsed(void *parsed_result, 8625 __rte_unused struct cmdline *cl, 8626 __rte_unused void *data) 8627 { 8628 struct cmd_set_vf_traffic *res = parsed_result; 8629 int is_rx = (strcmp(res->what, "rx") == 0) ? 1 : 0; 8630 int is_on = (strcmp(res->mode, "on") == 0) ? 1 : 0; 8631 8632 set_vf_traffic(res->port_id, (uint8_t)is_rx, res->vf_id,(uint8_t) is_on); 8633 } 8634 8635 cmdline_parse_token_string_t cmd_setvf_traffic_set = 8636 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_traffic, 8637 set, "set"); 8638 cmdline_parse_token_string_t cmd_setvf_traffic_port = 8639 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_traffic, 8640 port, "port"); 8641 cmdline_parse_token_num_t cmd_setvf_traffic_portid = 8642 TOKEN_NUM_INITIALIZER(struct cmd_set_vf_traffic, 8643 port_id, RTE_UINT16); 8644 cmdline_parse_token_string_t cmd_setvf_traffic_vf = 8645 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_traffic, 8646 vf, "vf"); 8647 cmdline_parse_token_num_t cmd_setvf_traffic_vfid = 8648 TOKEN_NUM_INITIALIZER(struct cmd_set_vf_traffic, 8649 vf_id, RTE_UINT8); 8650 cmdline_parse_token_string_t cmd_setvf_traffic_what = 8651 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_traffic, 8652 what, "tx#rx"); 8653 cmdline_parse_token_string_t cmd_setvf_traffic_mode = 8654 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_traffic, 8655 mode, "on#off"); 8656 8657 cmdline_parse_inst_t cmd_set_vf_traffic = { 8658 .f = cmd_set_vf_traffic_parsed, 8659 .data = NULL, 8660 .help_str = "set port <port_id> vf <vf_id> rx|tx on|off", 8661 .tokens = { 8662 (void *)&cmd_setvf_traffic_set, 8663 (void *)&cmd_setvf_traffic_port, 8664 (void *)&cmd_setvf_traffic_portid, 8665 (void *)&cmd_setvf_traffic_vf, 8666 (void *)&cmd_setvf_traffic_vfid, 8667 (void *)&cmd_setvf_traffic_what, 8668 (void *)&cmd_setvf_traffic_mode, 8669 NULL, 8670 }, 8671 }; 8672 8673 /* *** CONFIGURE VF RECEIVE MODE *** */ 8674 struct cmd_set_vf_rxmode { 8675 cmdline_fixed_string_t set; 8676 cmdline_fixed_string_t port; 8677 portid_t port_id; 8678 cmdline_fixed_string_t vf; 8679 uint8_t vf_id; 8680 cmdline_fixed_string_t what; 8681 cmdline_fixed_string_t mode; 8682 cmdline_fixed_string_t on; 8683 }; 8684 8685 static void 8686 cmd_set_vf_rxmode_parsed(void *parsed_result, 8687 __rte_unused struct cmdline *cl, 8688 __rte_unused void *data) 8689 { 8690 int ret = -ENOTSUP; 8691 uint16_t vf_rxmode = 0; 8692 struct cmd_set_vf_rxmode *res = parsed_result; 8693 8694 int is_on = (strcmp(res->on, "on") == 0) ? 1 : 0; 8695 if (!strcmp(res->what,"rxmode")) { 8696 if (!strcmp(res->mode, "AUPE")) 8697 vf_rxmode |= ETH_VMDQ_ACCEPT_UNTAG; 8698 else if (!strcmp(res->mode, "ROPE")) 8699 vf_rxmode |= ETH_VMDQ_ACCEPT_HASH_UC; 8700 else if (!strcmp(res->mode, "BAM")) 8701 vf_rxmode |= ETH_VMDQ_ACCEPT_BROADCAST; 8702 else if (!strncmp(res->mode, "MPE",3)) 8703 vf_rxmode |= ETH_VMDQ_ACCEPT_MULTICAST; 8704 } 8705 8706 RTE_SET_USED(is_on); 8707 8708 #ifdef RTE_NET_IXGBE 8709 if (ret == -ENOTSUP) 8710 ret = rte_pmd_ixgbe_set_vf_rxmode(res->port_id, res->vf_id, 8711 vf_rxmode, (uint8_t)is_on); 8712 #endif 8713 #ifdef RTE_NET_BNXT 8714 if (ret == -ENOTSUP) 8715 ret = rte_pmd_bnxt_set_vf_rxmode(res->port_id, res->vf_id, 8716 vf_rxmode, (uint8_t)is_on); 8717 #endif 8718 if (ret < 0) 8719 printf("bad VF receive mode parameter, return code = %d \n", 8720 ret); 8721 } 8722 8723 cmdline_parse_token_string_t cmd_set_vf_rxmode_set = 8724 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_rxmode, 8725 set, "set"); 8726 cmdline_parse_token_string_t cmd_set_vf_rxmode_port = 8727 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_rxmode, 8728 port, "port"); 8729 cmdline_parse_token_num_t cmd_set_vf_rxmode_portid = 8730 TOKEN_NUM_INITIALIZER(struct cmd_set_vf_rxmode, 8731 port_id, RTE_UINT16); 8732 cmdline_parse_token_string_t cmd_set_vf_rxmode_vf = 8733 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_rxmode, 8734 vf, "vf"); 8735 cmdline_parse_token_num_t cmd_set_vf_rxmode_vfid = 8736 TOKEN_NUM_INITIALIZER(struct cmd_set_vf_rxmode, 8737 vf_id, RTE_UINT8); 8738 cmdline_parse_token_string_t cmd_set_vf_rxmode_what = 8739 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_rxmode, 8740 what, "rxmode"); 8741 cmdline_parse_token_string_t cmd_set_vf_rxmode_mode = 8742 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_rxmode, 8743 mode, "AUPE#ROPE#BAM#MPE"); 8744 cmdline_parse_token_string_t cmd_set_vf_rxmode_on = 8745 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_rxmode, 8746 on, "on#off"); 8747 8748 cmdline_parse_inst_t cmd_set_vf_rxmode = { 8749 .f = cmd_set_vf_rxmode_parsed, 8750 .data = NULL, 8751 .help_str = "set port <port_id> vf <vf_id> rxmode " 8752 "AUPE|ROPE|BAM|MPE on|off", 8753 .tokens = { 8754 (void *)&cmd_set_vf_rxmode_set, 8755 (void *)&cmd_set_vf_rxmode_port, 8756 (void *)&cmd_set_vf_rxmode_portid, 8757 (void *)&cmd_set_vf_rxmode_vf, 8758 (void *)&cmd_set_vf_rxmode_vfid, 8759 (void *)&cmd_set_vf_rxmode_what, 8760 (void *)&cmd_set_vf_rxmode_mode, 8761 (void *)&cmd_set_vf_rxmode_on, 8762 NULL, 8763 }, 8764 }; 8765 8766 /* *** ADD MAC ADDRESS FILTER FOR A VF OF A PORT *** */ 8767 struct cmd_vf_mac_addr_result { 8768 cmdline_fixed_string_t mac_addr_cmd; 8769 cmdline_fixed_string_t what; 8770 cmdline_fixed_string_t port; 8771 uint16_t port_num; 8772 cmdline_fixed_string_t vf; 8773 uint8_t vf_num; 8774 struct rte_ether_addr address; 8775 }; 8776 8777 static void cmd_vf_mac_addr_parsed(void *parsed_result, 8778 __rte_unused struct cmdline *cl, 8779 __rte_unused void *data) 8780 { 8781 struct cmd_vf_mac_addr_result *res = parsed_result; 8782 int ret = -ENOTSUP; 8783 8784 if (strcmp(res->what, "add") != 0) 8785 return; 8786 8787 #ifdef RTE_NET_I40E 8788 if (ret == -ENOTSUP) 8789 ret = rte_pmd_i40e_add_vf_mac_addr(res->port_num, res->vf_num, 8790 &res->address); 8791 #endif 8792 #ifdef RTE_NET_BNXT 8793 if (ret == -ENOTSUP) 8794 ret = rte_pmd_bnxt_mac_addr_add(res->port_num, &res->address, 8795 res->vf_num); 8796 #endif 8797 8798 if(ret < 0) 8799 printf("vf_mac_addr_cmd error: (%s)\n", strerror(-ret)); 8800 8801 } 8802 8803 cmdline_parse_token_string_t cmd_vf_mac_addr_cmd = 8804 TOKEN_STRING_INITIALIZER(struct cmd_vf_mac_addr_result, 8805 mac_addr_cmd,"mac_addr"); 8806 cmdline_parse_token_string_t cmd_vf_mac_addr_what = 8807 TOKEN_STRING_INITIALIZER(struct cmd_vf_mac_addr_result, 8808 what,"add"); 8809 cmdline_parse_token_string_t cmd_vf_mac_addr_port = 8810 TOKEN_STRING_INITIALIZER(struct cmd_vf_mac_addr_result, 8811 port,"port"); 8812 cmdline_parse_token_num_t cmd_vf_mac_addr_portnum = 8813 TOKEN_NUM_INITIALIZER(struct cmd_vf_mac_addr_result, 8814 port_num, RTE_UINT16); 8815 cmdline_parse_token_string_t cmd_vf_mac_addr_vf = 8816 TOKEN_STRING_INITIALIZER(struct cmd_vf_mac_addr_result, 8817 vf,"vf"); 8818 cmdline_parse_token_num_t cmd_vf_mac_addr_vfnum = 8819 TOKEN_NUM_INITIALIZER(struct cmd_vf_mac_addr_result, 8820 vf_num, RTE_UINT8); 8821 cmdline_parse_token_etheraddr_t cmd_vf_mac_addr_addr = 8822 TOKEN_ETHERADDR_INITIALIZER(struct cmd_vf_mac_addr_result, 8823 address); 8824 8825 cmdline_parse_inst_t cmd_vf_mac_addr_filter = { 8826 .f = cmd_vf_mac_addr_parsed, 8827 .data = (void *)0, 8828 .help_str = "mac_addr add port <port_id> vf <vf_id> <mac_addr>: " 8829 "Add MAC address filtering for a VF on port_id", 8830 .tokens = { 8831 (void *)&cmd_vf_mac_addr_cmd, 8832 (void *)&cmd_vf_mac_addr_what, 8833 (void *)&cmd_vf_mac_addr_port, 8834 (void *)&cmd_vf_mac_addr_portnum, 8835 (void *)&cmd_vf_mac_addr_vf, 8836 (void *)&cmd_vf_mac_addr_vfnum, 8837 (void *)&cmd_vf_mac_addr_addr, 8838 NULL, 8839 }, 8840 }; 8841 8842 /* *** ADD/REMOVE A VLAN IDENTIFIER TO/FROM A PORT VLAN RX FILTER *** */ 8843 struct cmd_vf_rx_vlan_filter { 8844 cmdline_fixed_string_t rx_vlan; 8845 cmdline_fixed_string_t what; 8846 uint16_t vlan_id; 8847 cmdline_fixed_string_t port; 8848 portid_t port_id; 8849 cmdline_fixed_string_t vf; 8850 uint64_t vf_mask; 8851 }; 8852 8853 static void 8854 cmd_vf_rx_vlan_filter_parsed(void *parsed_result, 8855 __rte_unused struct cmdline *cl, 8856 __rte_unused void *data) 8857 { 8858 struct cmd_vf_rx_vlan_filter *res = parsed_result; 8859 int ret = -ENOTSUP; 8860 8861 __rte_unused int is_add = (strcmp(res->what, "add") == 0) ? 1 : 0; 8862 8863 #ifdef RTE_NET_IXGBE 8864 if (ret == -ENOTSUP) 8865 ret = rte_pmd_ixgbe_set_vf_vlan_filter(res->port_id, 8866 res->vlan_id, res->vf_mask, is_add); 8867 #endif 8868 #ifdef RTE_NET_I40E 8869 if (ret == -ENOTSUP) 8870 ret = rte_pmd_i40e_set_vf_vlan_filter(res->port_id, 8871 res->vlan_id, res->vf_mask, is_add); 8872 #endif 8873 #ifdef RTE_NET_BNXT 8874 if (ret == -ENOTSUP) 8875 ret = rte_pmd_bnxt_set_vf_vlan_filter(res->port_id, 8876 res->vlan_id, res->vf_mask, is_add); 8877 #endif 8878 8879 switch (ret) { 8880 case 0: 8881 break; 8882 case -EINVAL: 8883 printf("invalid vlan_id %d or vf_mask %"PRIu64"\n", 8884 res->vlan_id, res->vf_mask); 8885 break; 8886 case -ENODEV: 8887 printf("invalid port_id %d\n", res->port_id); 8888 break; 8889 case -ENOTSUP: 8890 printf("function not implemented or supported\n"); 8891 break; 8892 default: 8893 printf("programming error: (%s)\n", strerror(-ret)); 8894 } 8895 } 8896 8897 cmdline_parse_token_string_t cmd_vf_rx_vlan_filter_rx_vlan = 8898 TOKEN_STRING_INITIALIZER(struct cmd_vf_rx_vlan_filter, 8899 rx_vlan, "rx_vlan"); 8900 cmdline_parse_token_string_t cmd_vf_rx_vlan_filter_what = 8901 TOKEN_STRING_INITIALIZER(struct cmd_vf_rx_vlan_filter, 8902 what, "add#rm"); 8903 cmdline_parse_token_num_t cmd_vf_rx_vlan_filter_vlanid = 8904 TOKEN_NUM_INITIALIZER(struct cmd_vf_rx_vlan_filter, 8905 vlan_id, RTE_UINT16); 8906 cmdline_parse_token_string_t cmd_vf_rx_vlan_filter_port = 8907 TOKEN_STRING_INITIALIZER(struct cmd_vf_rx_vlan_filter, 8908 port, "port"); 8909 cmdline_parse_token_num_t cmd_vf_rx_vlan_filter_portid = 8910 TOKEN_NUM_INITIALIZER(struct cmd_vf_rx_vlan_filter, 8911 port_id, RTE_UINT16); 8912 cmdline_parse_token_string_t cmd_vf_rx_vlan_filter_vf = 8913 TOKEN_STRING_INITIALIZER(struct cmd_vf_rx_vlan_filter, 8914 vf, "vf"); 8915 cmdline_parse_token_num_t cmd_vf_rx_vlan_filter_vf_mask = 8916 TOKEN_NUM_INITIALIZER(struct cmd_vf_rx_vlan_filter, 8917 vf_mask, RTE_UINT64); 8918 8919 cmdline_parse_inst_t cmd_vf_rxvlan_filter = { 8920 .f = cmd_vf_rx_vlan_filter_parsed, 8921 .data = NULL, 8922 .help_str = "rx_vlan add|rm <vlan_id> port <port_id> vf <vf_mask>: " 8923 "(vf_mask = hexadecimal VF mask)", 8924 .tokens = { 8925 (void *)&cmd_vf_rx_vlan_filter_rx_vlan, 8926 (void *)&cmd_vf_rx_vlan_filter_what, 8927 (void *)&cmd_vf_rx_vlan_filter_vlanid, 8928 (void *)&cmd_vf_rx_vlan_filter_port, 8929 (void *)&cmd_vf_rx_vlan_filter_portid, 8930 (void *)&cmd_vf_rx_vlan_filter_vf, 8931 (void *)&cmd_vf_rx_vlan_filter_vf_mask, 8932 NULL, 8933 }, 8934 }; 8935 8936 /* *** SET RATE LIMIT FOR A QUEUE OF A PORT *** */ 8937 struct cmd_queue_rate_limit_result { 8938 cmdline_fixed_string_t set; 8939 cmdline_fixed_string_t port; 8940 uint16_t port_num; 8941 cmdline_fixed_string_t queue; 8942 uint8_t queue_num; 8943 cmdline_fixed_string_t rate; 8944 uint16_t rate_num; 8945 }; 8946 8947 static void cmd_queue_rate_limit_parsed(void *parsed_result, 8948 __rte_unused struct cmdline *cl, 8949 __rte_unused void *data) 8950 { 8951 struct cmd_queue_rate_limit_result *res = parsed_result; 8952 int ret = 0; 8953 8954 if ((strcmp(res->set, "set") == 0) && (strcmp(res->port, "port") == 0) 8955 && (strcmp(res->queue, "queue") == 0) 8956 && (strcmp(res->rate, "rate") == 0)) 8957 ret = set_queue_rate_limit(res->port_num, res->queue_num, 8958 res->rate_num); 8959 if (ret < 0) 8960 printf("queue_rate_limit_cmd error: (%s)\n", strerror(-ret)); 8961 8962 } 8963 8964 cmdline_parse_token_string_t cmd_queue_rate_limit_set = 8965 TOKEN_STRING_INITIALIZER(struct cmd_queue_rate_limit_result, 8966 set, "set"); 8967 cmdline_parse_token_string_t cmd_queue_rate_limit_port = 8968 TOKEN_STRING_INITIALIZER(struct cmd_queue_rate_limit_result, 8969 port, "port"); 8970 cmdline_parse_token_num_t cmd_queue_rate_limit_portnum = 8971 TOKEN_NUM_INITIALIZER(struct cmd_queue_rate_limit_result, 8972 port_num, RTE_UINT16); 8973 cmdline_parse_token_string_t cmd_queue_rate_limit_queue = 8974 TOKEN_STRING_INITIALIZER(struct cmd_queue_rate_limit_result, 8975 queue, "queue"); 8976 cmdline_parse_token_num_t cmd_queue_rate_limit_queuenum = 8977 TOKEN_NUM_INITIALIZER(struct cmd_queue_rate_limit_result, 8978 queue_num, RTE_UINT8); 8979 cmdline_parse_token_string_t cmd_queue_rate_limit_rate = 8980 TOKEN_STRING_INITIALIZER(struct cmd_queue_rate_limit_result, 8981 rate, "rate"); 8982 cmdline_parse_token_num_t cmd_queue_rate_limit_ratenum = 8983 TOKEN_NUM_INITIALIZER(struct cmd_queue_rate_limit_result, 8984 rate_num, RTE_UINT16); 8985 8986 cmdline_parse_inst_t cmd_queue_rate_limit = { 8987 .f = cmd_queue_rate_limit_parsed, 8988 .data = (void *)0, 8989 .help_str = "set port <port_id> queue <queue_id> rate <rate_value>: " 8990 "Set rate limit for a queue on port_id", 8991 .tokens = { 8992 (void *)&cmd_queue_rate_limit_set, 8993 (void *)&cmd_queue_rate_limit_port, 8994 (void *)&cmd_queue_rate_limit_portnum, 8995 (void *)&cmd_queue_rate_limit_queue, 8996 (void *)&cmd_queue_rate_limit_queuenum, 8997 (void *)&cmd_queue_rate_limit_rate, 8998 (void *)&cmd_queue_rate_limit_ratenum, 8999 NULL, 9000 }, 9001 }; 9002 9003 /* *** SET RATE LIMIT FOR A VF OF A PORT *** */ 9004 struct cmd_vf_rate_limit_result { 9005 cmdline_fixed_string_t set; 9006 cmdline_fixed_string_t port; 9007 uint16_t port_num; 9008 cmdline_fixed_string_t vf; 9009 uint8_t vf_num; 9010 cmdline_fixed_string_t rate; 9011 uint16_t rate_num; 9012 cmdline_fixed_string_t q_msk; 9013 uint64_t q_msk_val; 9014 }; 9015 9016 static void cmd_vf_rate_limit_parsed(void *parsed_result, 9017 __rte_unused struct cmdline *cl, 9018 __rte_unused void *data) 9019 { 9020 struct cmd_vf_rate_limit_result *res = parsed_result; 9021 int ret = 0; 9022 9023 if ((strcmp(res->set, "set") == 0) && (strcmp(res->port, "port") == 0) 9024 && (strcmp(res->vf, "vf") == 0) 9025 && (strcmp(res->rate, "rate") == 0) 9026 && (strcmp(res->q_msk, "queue_mask") == 0)) 9027 ret = set_vf_rate_limit(res->port_num, res->vf_num, 9028 res->rate_num, res->q_msk_val); 9029 if (ret < 0) 9030 printf("vf_rate_limit_cmd error: (%s)\n", strerror(-ret)); 9031 9032 } 9033 9034 cmdline_parse_token_string_t cmd_vf_rate_limit_set = 9035 TOKEN_STRING_INITIALIZER(struct cmd_vf_rate_limit_result, 9036 set, "set"); 9037 cmdline_parse_token_string_t cmd_vf_rate_limit_port = 9038 TOKEN_STRING_INITIALIZER(struct cmd_vf_rate_limit_result, 9039 port, "port"); 9040 cmdline_parse_token_num_t cmd_vf_rate_limit_portnum = 9041 TOKEN_NUM_INITIALIZER(struct cmd_vf_rate_limit_result, 9042 port_num, RTE_UINT16); 9043 cmdline_parse_token_string_t cmd_vf_rate_limit_vf = 9044 TOKEN_STRING_INITIALIZER(struct cmd_vf_rate_limit_result, 9045 vf, "vf"); 9046 cmdline_parse_token_num_t cmd_vf_rate_limit_vfnum = 9047 TOKEN_NUM_INITIALIZER(struct cmd_vf_rate_limit_result, 9048 vf_num, RTE_UINT8); 9049 cmdline_parse_token_string_t cmd_vf_rate_limit_rate = 9050 TOKEN_STRING_INITIALIZER(struct cmd_vf_rate_limit_result, 9051 rate, "rate"); 9052 cmdline_parse_token_num_t cmd_vf_rate_limit_ratenum = 9053 TOKEN_NUM_INITIALIZER(struct cmd_vf_rate_limit_result, 9054 rate_num, RTE_UINT16); 9055 cmdline_parse_token_string_t cmd_vf_rate_limit_q_msk = 9056 TOKEN_STRING_INITIALIZER(struct cmd_vf_rate_limit_result, 9057 q_msk, "queue_mask"); 9058 cmdline_parse_token_num_t cmd_vf_rate_limit_q_msk_val = 9059 TOKEN_NUM_INITIALIZER(struct cmd_vf_rate_limit_result, 9060 q_msk_val, RTE_UINT64); 9061 9062 cmdline_parse_inst_t cmd_vf_rate_limit = { 9063 .f = cmd_vf_rate_limit_parsed, 9064 .data = (void *)0, 9065 .help_str = "set port <port_id> vf <vf_id> rate <rate_value> " 9066 "queue_mask <queue_mask_value>: " 9067 "Set rate limit for queues of VF on port_id", 9068 .tokens = { 9069 (void *)&cmd_vf_rate_limit_set, 9070 (void *)&cmd_vf_rate_limit_port, 9071 (void *)&cmd_vf_rate_limit_portnum, 9072 (void *)&cmd_vf_rate_limit_vf, 9073 (void *)&cmd_vf_rate_limit_vfnum, 9074 (void *)&cmd_vf_rate_limit_rate, 9075 (void *)&cmd_vf_rate_limit_ratenum, 9076 (void *)&cmd_vf_rate_limit_q_msk, 9077 (void *)&cmd_vf_rate_limit_q_msk_val, 9078 NULL, 9079 }, 9080 }; 9081 9082 /* *** CONFIGURE TUNNEL UDP PORT *** */ 9083 struct cmd_tunnel_udp_config { 9084 cmdline_fixed_string_t cmd; 9085 cmdline_fixed_string_t what; 9086 uint16_t udp_port; 9087 portid_t port_id; 9088 }; 9089 9090 static void 9091 cmd_tunnel_udp_config_parsed(void *parsed_result, 9092 __rte_unused struct cmdline *cl, 9093 __rte_unused void *data) 9094 { 9095 struct cmd_tunnel_udp_config *res = parsed_result; 9096 struct rte_eth_udp_tunnel tunnel_udp; 9097 int ret; 9098 9099 tunnel_udp.udp_port = res->udp_port; 9100 9101 if (!strcmp(res->cmd, "rx_vxlan_port")) 9102 tunnel_udp.prot_type = RTE_TUNNEL_TYPE_VXLAN; 9103 9104 if (!strcmp(res->what, "add")) 9105 ret = rte_eth_dev_udp_tunnel_port_add(res->port_id, 9106 &tunnel_udp); 9107 else 9108 ret = rte_eth_dev_udp_tunnel_port_delete(res->port_id, 9109 &tunnel_udp); 9110 9111 if (ret < 0) 9112 printf("udp tunneling add error: (%s)\n", strerror(-ret)); 9113 } 9114 9115 cmdline_parse_token_string_t cmd_tunnel_udp_config_cmd = 9116 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_udp_config, 9117 cmd, "rx_vxlan_port"); 9118 cmdline_parse_token_string_t cmd_tunnel_udp_config_what = 9119 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_udp_config, 9120 what, "add#rm"); 9121 cmdline_parse_token_num_t cmd_tunnel_udp_config_udp_port = 9122 TOKEN_NUM_INITIALIZER(struct cmd_tunnel_udp_config, 9123 udp_port, RTE_UINT16); 9124 cmdline_parse_token_num_t cmd_tunnel_udp_config_port_id = 9125 TOKEN_NUM_INITIALIZER(struct cmd_tunnel_udp_config, 9126 port_id, RTE_UINT16); 9127 9128 cmdline_parse_inst_t cmd_tunnel_udp_config = { 9129 .f = cmd_tunnel_udp_config_parsed, 9130 .data = (void *)0, 9131 .help_str = "rx_vxlan_port add|rm <udp_port> <port_id>: " 9132 "Add/Remove a tunneling UDP port filter", 9133 .tokens = { 9134 (void *)&cmd_tunnel_udp_config_cmd, 9135 (void *)&cmd_tunnel_udp_config_what, 9136 (void *)&cmd_tunnel_udp_config_udp_port, 9137 (void *)&cmd_tunnel_udp_config_port_id, 9138 NULL, 9139 }, 9140 }; 9141 9142 struct cmd_config_tunnel_udp_port { 9143 cmdline_fixed_string_t port; 9144 cmdline_fixed_string_t config; 9145 portid_t port_id; 9146 cmdline_fixed_string_t udp_tunnel_port; 9147 cmdline_fixed_string_t action; 9148 cmdline_fixed_string_t tunnel_type; 9149 uint16_t udp_port; 9150 }; 9151 9152 static void 9153 cmd_cfg_tunnel_udp_port_parsed(void *parsed_result, 9154 __rte_unused struct cmdline *cl, 9155 __rte_unused void *data) 9156 { 9157 struct cmd_config_tunnel_udp_port *res = parsed_result; 9158 struct rte_eth_udp_tunnel tunnel_udp; 9159 int ret = 0; 9160 9161 if (port_id_is_invalid(res->port_id, ENABLED_WARN)) 9162 return; 9163 9164 tunnel_udp.udp_port = res->udp_port; 9165 9166 if (!strcmp(res->tunnel_type, "vxlan")) { 9167 tunnel_udp.prot_type = RTE_TUNNEL_TYPE_VXLAN; 9168 } else if (!strcmp(res->tunnel_type, "geneve")) { 9169 tunnel_udp.prot_type = RTE_TUNNEL_TYPE_GENEVE; 9170 } else if (!strcmp(res->tunnel_type, "vxlan-gpe")) { 9171 tunnel_udp.prot_type = RTE_TUNNEL_TYPE_VXLAN_GPE; 9172 } else if (!strcmp(res->tunnel_type, "ecpri")) { 9173 tunnel_udp.prot_type = RTE_TUNNEL_TYPE_ECPRI; 9174 } else { 9175 printf("Invalid tunnel type\n"); 9176 return; 9177 } 9178 9179 if (!strcmp(res->action, "add")) 9180 ret = rte_eth_dev_udp_tunnel_port_add(res->port_id, 9181 &tunnel_udp); 9182 else 9183 ret = rte_eth_dev_udp_tunnel_port_delete(res->port_id, 9184 &tunnel_udp); 9185 9186 if (ret < 0) 9187 printf("udp tunneling port add error: (%s)\n", strerror(-ret)); 9188 } 9189 9190 cmdline_parse_token_string_t cmd_config_tunnel_udp_port_port = 9191 TOKEN_STRING_INITIALIZER(struct cmd_config_tunnel_udp_port, port, 9192 "port"); 9193 cmdline_parse_token_string_t cmd_config_tunnel_udp_port_config = 9194 TOKEN_STRING_INITIALIZER(struct cmd_config_tunnel_udp_port, config, 9195 "config"); 9196 cmdline_parse_token_num_t cmd_config_tunnel_udp_port_port_id = 9197 TOKEN_NUM_INITIALIZER(struct cmd_config_tunnel_udp_port, port_id, 9198 RTE_UINT16); 9199 cmdline_parse_token_string_t cmd_config_tunnel_udp_port_tunnel_port = 9200 TOKEN_STRING_INITIALIZER(struct cmd_config_tunnel_udp_port, 9201 udp_tunnel_port, 9202 "udp_tunnel_port"); 9203 cmdline_parse_token_string_t cmd_config_tunnel_udp_port_action = 9204 TOKEN_STRING_INITIALIZER(struct cmd_config_tunnel_udp_port, action, 9205 "add#rm"); 9206 cmdline_parse_token_string_t cmd_config_tunnel_udp_port_tunnel_type = 9207 TOKEN_STRING_INITIALIZER(struct cmd_config_tunnel_udp_port, tunnel_type, 9208 "vxlan#geneve#vxlan-gpe#ecpri"); 9209 cmdline_parse_token_num_t cmd_config_tunnel_udp_port_value = 9210 TOKEN_NUM_INITIALIZER(struct cmd_config_tunnel_udp_port, udp_port, 9211 RTE_UINT16); 9212 9213 cmdline_parse_inst_t cmd_cfg_tunnel_udp_port = { 9214 .f = cmd_cfg_tunnel_udp_port_parsed, 9215 .data = NULL, 9216 .help_str = "port config <port_id> udp_tunnel_port add|rm vxlan|" 9217 "geneve|vxlan-gpe|ecpri <udp_port>", 9218 .tokens = { 9219 (void *)&cmd_config_tunnel_udp_port_port, 9220 (void *)&cmd_config_tunnel_udp_port_config, 9221 (void *)&cmd_config_tunnel_udp_port_port_id, 9222 (void *)&cmd_config_tunnel_udp_port_tunnel_port, 9223 (void *)&cmd_config_tunnel_udp_port_action, 9224 (void *)&cmd_config_tunnel_udp_port_tunnel_type, 9225 (void *)&cmd_config_tunnel_udp_port_value, 9226 NULL, 9227 }, 9228 }; 9229 9230 /* *** CONFIGURE VM MIRROR VLAN/POOL RULE *** */ 9231 struct cmd_set_mirror_mask_result { 9232 cmdline_fixed_string_t set; 9233 cmdline_fixed_string_t port; 9234 portid_t port_id; 9235 cmdline_fixed_string_t mirror; 9236 uint8_t rule_id; 9237 cmdline_fixed_string_t what; 9238 cmdline_fixed_string_t value; 9239 cmdline_fixed_string_t dstpool; 9240 uint8_t dstpool_id; 9241 cmdline_fixed_string_t on; 9242 }; 9243 9244 cmdline_parse_token_string_t cmd_mirror_mask_set = 9245 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result, 9246 set, "set"); 9247 cmdline_parse_token_string_t cmd_mirror_mask_port = 9248 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result, 9249 port, "port"); 9250 cmdline_parse_token_num_t cmd_mirror_mask_portid = 9251 TOKEN_NUM_INITIALIZER(struct cmd_set_mirror_mask_result, 9252 port_id, RTE_UINT16); 9253 cmdline_parse_token_string_t cmd_mirror_mask_mirror = 9254 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result, 9255 mirror, "mirror-rule"); 9256 cmdline_parse_token_num_t cmd_mirror_mask_ruleid = 9257 TOKEN_NUM_INITIALIZER(struct cmd_set_mirror_mask_result, 9258 rule_id, RTE_UINT8); 9259 cmdline_parse_token_string_t cmd_mirror_mask_what = 9260 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result, 9261 what, "pool-mirror-up#pool-mirror-down" 9262 "#vlan-mirror"); 9263 cmdline_parse_token_string_t cmd_mirror_mask_value = 9264 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result, 9265 value, NULL); 9266 cmdline_parse_token_string_t cmd_mirror_mask_dstpool = 9267 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result, 9268 dstpool, "dst-pool"); 9269 cmdline_parse_token_num_t cmd_mirror_mask_poolid = 9270 TOKEN_NUM_INITIALIZER(struct cmd_set_mirror_mask_result, 9271 dstpool_id, RTE_UINT8); 9272 cmdline_parse_token_string_t cmd_mirror_mask_on = 9273 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result, 9274 on, "on#off"); 9275 9276 static void 9277 cmd_set_mirror_mask_parsed(void *parsed_result, 9278 __rte_unused struct cmdline *cl, 9279 __rte_unused void *data) 9280 { 9281 int ret,nb_item,i; 9282 struct cmd_set_mirror_mask_result *res = parsed_result; 9283 struct rte_eth_mirror_conf mr_conf; 9284 9285 memset(&mr_conf, 0, sizeof(struct rte_eth_mirror_conf)); 9286 9287 unsigned int vlan_list[ETH_MIRROR_MAX_VLANS]; 9288 9289 mr_conf.dst_pool = res->dstpool_id; 9290 9291 if (!strcmp(res->what, "pool-mirror-up")) { 9292 mr_conf.pool_mask = strtoull(res->value, NULL, 16); 9293 mr_conf.rule_type = ETH_MIRROR_VIRTUAL_POOL_UP; 9294 } else if (!strcmp(res->what, "pool-mirror-down")) { 9295 mr_conf.pool_mask = strtoull(res->value, NULL, 16); 9296 mr_conf.rule_type = ETH_MIRROR_VIRTUAL_POOL_DOWN; 9297 } else if (!strcmp(res->what, "vlan-mirror")) { 9298 mr_conf.rule_type = ETH_MIRROR_VLAN; 9299 nb_item = parse_item_list(res->value, "vlan", 9300 ETH_MIRROR_MAX_VLANS, vlan_list, 1); 9301 if (nb_item <= 0) 9302 return; 9303 9304 for (i = 0; i < nb_item; i++) { 9305 if (vlan_list[i] > RTE_ETHER_MAX_VLAN_ID) { 9306 printf("Invalid vlan_id: must be < 4096\n"); 9307 return; 9308 } 9309 9310 mr_conf.vlan.vlan_id[i] = (uint16_t)vlan_list[i]; 9311 mr_conf.vlan.vlan_mask |= 1ULL << i; 9312 } 9313 } 9314 9315 if (!strcmp(res->on, "on")) 9316 ret = rte_eth_mirror_rule_set(res->port_id, &mr_conf, 9317 res->rule_id, 1); 9318 else 9319 ret = rte_eth_mirror_rule_set(res->port_id, &mr_conf, 9320 res->rule_id, 0); 9321 if (ret < 0) 9322 printf("mirror rule add error: (%s)\n", strerror(-ret)); 9323 } 9324 9325 cmdline_parse_inst_t cmd_set_mirror_mask = { 9326 .f = cmd_set_mirror_mask_parsed, 9327 .data = NULL, 9328 .help_str = "set port <port_id> mirror-rule <rule_id> " 9329 "pool-mirror-up|pool-mirror-down|vlan-mirror " 9330 "<pool_mask|vlan_id[,vlan_id]*> dst-pool <pool_id> on|off", 9331 .tokens = { 9332 (void *)&cmd_mirror_mask_set, 9333 (void *)&cmd_mirror_mask_port, 9334 (void *)&cmd_mirror_mask_portid, 9335 (void *)&cmd_mirror_mask_mirror, 9336 (void *)&cmd_mirror_mask_ruleid, 9337 (void *)&cmd_mirror_mask_what, 9338 (void *)&cmd_mirror_mask_value, 9339 (void *)&cmd_mirror_mask_dstpool, 9340 (void *)&cmd_mirror_mask_poolid, 9341 (void *)&cmd_mirror_mask_on, 9342 NULL, 9343 }, 9344 }; 9345 9346 /* *** CONFIGURE VM MIRROR UPLINK/DOWNLINK RULE *** */ 9347 struct cmd_set_mirror_link_result { 9348 cmdline_fixed_string_t set; 9349 cmdline_fixed_string_t port; 9350 portid_t port_id; 9351 cmdline_fixed_string_t mirror; 9352 uint8_t rule_id; 9353 cmdline_fixed_string_t what; 9354 cmdline_fixed_string_t dstpool; 9355 uint8_t dstpool_id; 9356 cmdline_fixed_string_t on; 9357 }; 9358 9359 cmdline_parse_token_string_t cmd_mirror_link_set = 9360 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_link_result, 9361 set, "set"); 9362 cmdline_parse_token_string_t cmd_mirror_link_port = 9363 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_link_result, 9364 port, "port"); 9365 cmdline_parse_token_num_t cmd_mirror_link_portid = 9366 TOKEN_NUM_INITIALIZER(struct cmd_set_mirror_link_result, 9367 port_id, RTE_UINT16); 9368 cmdline_parse_token_string_t cmd_mirror_link_mirror = 9369 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_link_result, 9370 mirror, "mirror-rule"); 9371 cmdline_parse_token_num_t cmd_mirror_link_ruleid = 9372 TOKEN_NUM_INITIALIZER(struct cmd_set_mirror_link_result, 9373 rule_id, RTE_UINT8); 9374 cmdline_parse_token_string_t cmd_mirror_link_what = 9375 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_link_result, 9376 what, "uplink-mirror#downlink-mirror"); 9377 cmdline_parse_token_string_t cmd_mirror_link_dstpool = 9378 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_link_result, 9379 dstpool, "dst-pool"); 9380 cmdline_parse_token_num_t cmd_mirror_link_poolid = 9381 TOKEN_NUM_INITIALIZER(struct cmd_set_mirror_link_result, 9382 dstpool_id, RTE_UINT8); 9383 cmdline_parse_token_string_t cmd_mirror_link_on = 9384 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_link_result, 9385 on, "on#off"); 9386 9387 static void 9388 cmd_set_mirror_link_parsed(void *parsed_result, 9389 __rte_unused struct cmdline *cl, 9390 __rte_unused void *data) 9391 { 9392 int ret; 9393 struct cmd_set_mirror_link_result *res = parsed_result; 9394 struct rte_eth_mirror_conf mr_conf; 9395 9396 memset(&mr_conf, 0, sizeof(struct rte_eth_mirror_conf)); 9397 if (!strcmp(res->what, "uplink-mirror")) 9398 mr_conf.rule_type = ETH_MIRROR_UPLINK_PORT; 9399 else 9400 mr_conf.rule_type = ETH_MIRROR_DOWNLINK_PORT; 9401 9402 mr_conf.dst_pool = res->dstpool_id; 9403 9404 if (!strcmp(res->on, "on")) 9405 ret = rte_eth_mirror_rule_set(res->port_id, &mr_conf, 9406 res->rule_id, 1); 9407 else 9408 ret = rte_eth_mirror_rule_set(res->port_id, &mr_conf, 9409 res->rule_id, 0); 9410 9411 /* check the return value and print it if is < 0 */ 9412 if (ret < 0) 9413 printf("mirror rule add error: (%s)\n", strerror(-ret)); 9414 9415 } 9416 9417 cmdline_parse_inst_t cmd_set_mirror_link = { 9418 .f = cmd_set_mirror_link_parsed, 9419 .data = NULL, 9420 .help_str = "set port <port_id> mirror-rule <rule_id> " 9421 "uplink-mirror|downlink-mirror dst-pool <pool_id> on|off", 9422 .tokens = { 9423 (void *)&cmd_mirror_link_set, 9424 (void *)&cmd_mirror_link_port, 9425 (void *)&cmd_mirror_link_portid, 9426 (void *)&cmd_mirror_link_mirror, 9427 (void *)&cmd_mirror_link_ruleid, 9428 (void *)&cmd_mirror_link_what, 9429 (void *)&cmd_mirror_link_dstpool, 9430 (void *)&cmd_mirror_link_poolid, 9431 (void *)&cmd_mirror_link_on, 9432 NULL, 9433 }, 9434 }; 9435 9436 /* *** RESET VM MIRROR RULE *** */ 9437 struct cmd_rm_mirror_rule_result { 9438 cmdline_fixed_string_t reset; 9439 cmdline_fixed_string_t port; 9440 portid_t port_id; 9441 cmdline_fixed_string_t mirror; 9442 uint8_t rule_id; 9443 }; 9444 9445 cmdline_parse_token_string_t cmd_rm_mirror_rule_reset = 9446 TOKEN_STRING_INITIALIZER(struct cmd_rm_mirror_rule_result, 9447 reset, "reset"); 9448 cmdline_parse_token_string_t cmd_rm_mirror_rule_port = 9449 TOKEN_STRING_INITIALIZER(struct cmd_rm_mirror_rule_result, 9450 port, "port"); 9451 cmdline_parse_token_num_t cmd_rm_mirror_rule_portid = 9452 TOKEN_NUM_INITIALIZER(struct cmd_rm_mirror_rule_result, 9453 port_id, RTE_UINT16); 9454 cmdline_parse_token_string_t cmd_rm_mirror_rule_mirror = 9455 TOKEN_STRING_INITIALIZER(struct cmd_rm_mirror_rule_result, 9456 mirror, "mirror-rule"); 9457 cmdline_parse_token_num_t cmd_rm_mirror_rule_ruleid = 9458 TOKEN_NUM_INITIALIZER(struct cmd_rm_mirror_rule_result, 9459 rule_id, RTE_UINT8); 9460 9461 static void 9462 cmd_reset_mirror_rule_parsed(void *parsed_result, 9463 __rte_unused struct cmdline *cl, 9464 __rte_unused void *data) 9465 { 9466 int ret; 9467 struct cmd_set_mirror_link_result *res = parsed_result; 9468 /* check rule_id */ 9469 ret = rte_eth_mirror_rule_reset(res->port_id,res->rule_id); 9470 if(ret < 0) 9471 printf("mirror rule remove error: (%s)\n", strerror(-ret)); 9472 } 9473 9474 cmdline_parse_inst_t cmd_reset_mirror_rule = { 9475 .f = cmd_reset_mirror_rule_parsed, 9476 .data = NULL, 9477 .help_str = "reset port <port_id> mirror-rule <rule_id>", 9478 .tokens = { 9479 (void *)&cmd_rm_mirror_rule_reset, 9480 (void *)&cmd_rm_mirror_rule_port, 9481 (void *)&cmd_rm_mirror_rule_portid, 9482 (void *)&cmd_rm_mirror_rule_mirror, 9483 (void *)&cmd_rm_mirror_rule_ruleid, 9484 NULL, 9485 }, 9486 }; 9487 9488 /* ******************************************************************************** */ 9489 9490 struct cmd_dump_result { 9491 cmdline_fixed_string_t dump; 9492 }; 9493 9494 static void 9495 dump_struct_sizes(void) 9496 { 9497 #define DUMP_SIZE(t) printf("sizeof(" #t ") = %u\n", (unsigned)sizeof(t)); 9498 DUMP_SIZE(struct rte_mbuf); 9499 DUMP_SIZE(struct rte_mempool); 9500 DUMP_SIZE(struct rte_ring); 9501 #undef DUMP_SIZE 9502 } 9503 9504 9505 /* Dump the socket memory statistics on console */ 9506 static void 9507 dump_socket_mem(FILE *f) 9508 { 9509 struct rte_malloc_socket_stats socket_stats; 9510 unsigned int i; 9511 size_t total = 0; 9512 size_t alloc = 0; 9513 size_t free = 0; 9514 unsigned int n_alloc = 0; 9515 unsigned int n_free = 0; 9516 static size_t last_allocs; 9517 static size_t last_total; 9518 9519 9520 for (i = 0; i < RTE_MAX_NUMA_NODES; i++) { 9521 if (rte_malloc_get_socket_stats(i, &socket_stats) || 9522 !socket_stats.heap_totalsz_bytes) 9523 continue; 9524 total += socket_stats.heap_totalsz_bytes; 9525 alloc += socket_stats.heap_allocsz_bytes; 9526 free += socket_stats.heap_freesz_bytes; 9527 n_alloc += socket_stats.alloc_count; 9528 n_free += socket_stats.free_count; 9529 fprintf(f, 9530 "Socket %u: size(M) total: %.6lf alloc: %.6lf(%.3lf%%) free: %.6lf \tcount alloc: %-4u free: %u\n", 9531 i, 9532 (double)socket_stats.heap_totalsz_bytes / (1024 * 1024), 9533 (double)socket_stats.heap_allocsz_bytes / (1024 * 1024), 9534 (double)socket_stats.heap_allocsz_bytes * 100 / 9535 (double)socket_stats.heap_totalsz_bytes, 9536 (double)socket_stats.heap_freesz_bytes / (1024 * 1024), 9537 socket_stats.alloc_count, 9538 socket_stats.free_count); 9539 } 9540 fprintf(f, 9541 "Total : size(M) total: %.6lf alloc: %.6lf(%.3lf%%) free: %.6lf \tcount alloc: %-4u free: %u\n", 9542 (double)total / (1024 * 1024), (double)alloc / (1024 * 1024), 9543 (double)alloc * 100 / (double)total, 9544 (double)free / (1024 * 1024), 9545 n_alloc, n_free); 9546 if (last_allocs) 9547 fprintf(stdout, "Memory total change: %.6lf(M), allocation change: %.6lf(M)\n", 9548 ((double)total - (double)last_total) / (1024 * 1024), 9549 (double)(alloc - (double)last_allocs) / 1024 / 1024); 9550 last_allocs = alloc; 9551 last_total = total; 9552 } 9553 9554 static void cmd_dump_parsed(void *parsed_result, 9555 __rte_unused struct cmdline *cl, 9556 __rte_unused void *data) 9557 { 9558 struct cmd_dump_result *res = parsed_result; 9559 9560 if (!strcmp(res->dump, "dump_physmem")) 9561 rte_dump_physmem_layout(stdout); 9562 else if (!strcmp(res->dump, "dump_socket_mem")) 9563 dump_socket_mem(stdout); 9564 else if (!strcmp(res->dump, "dump_memzone")) 9565 rte_memzone_dump(stdout); 9566 else if (!strcmp(res->dump, "dump_struct_sizes")) 9567 dump_struct_sizes(); 9568 else if (!strcmp(res->dump, "dump_ring")) 9569 rte_ring_list_dump(stdout); 9570 else if (!strcmp(res->dump, "dump_mempool")) 9571 rte_mempool_list_dump(stdout); 9572 else if (!strcmp(res->dump, "dump_devargs")) 9573 rte_devargs_dump(stdout); 9574 else if (!strcmp(res->dump, "dump_log_types")) 9575 rte_log_dump(stdout); 9576 } 9577 9578 cmdline_parse_token_string_t cmd_dump_dump = 9579 TOKEN_STRING_INITIALIZER(struct cmd_dump_result, dump, 9580 "dump_physmem#" 9581 "dump_memzone#" 9582 "dump_socket_mem#" 9583 "dump_struct_sizes#" 9584 "dump_ring#" 9585 "dump_mempool#" 9586 "dump_devargs#" 9587 "dump_log_types"); 9588 9589 cmdline_parse_inst_t cmd_dump = { 9590 .f = cmd_dump_parsed, /* function to call */ 9591 .data = NULL, /* 2nd arg of func */ 9592 .help_str = "Dump status", 9593 .tokens = { /* token list, NULL terminated */ 9594 (void *)&cmd_dump_dump, 9595 NULL, 9596 }, 9597 }; 9598 9599 /* ******************************************************************************** */ 9600 9601 struct cmd_dump_one_result { 9602 cmdline_fixed_string_t dump; 9603 cmdline_fixed_string_t name; 9604 }; 9605 9606 static void cmd_dump_one_parsed(void *parsed_result, struct cmdline *cl, 9607 __rte_unused void *data) 9608 { 9609 struct cmd_dump_one_result *res = parsed_result; 9610 9611 if (!strcmp(res->dump, "dump_ring")) { 9612 struct rte_ring *r; 9613 r = rte_ring_lookup(res->name); 9614 if (r == NULL) { 9615 cmdline_printf(cl, "Cannot find ring\n"); 9616 return; 9617 } 9618 rte_ring_dump(stdout, r); 9619 } else if (!strcmp(res->dump, "dump_mempool")) { 9620 struct rte_mempool *mp; 9621 mp = rte_mempool_lookup(res->name); 9622 if (mp == NULL) { 9623 cmdline_printf(cl, "Cannot find mempool\n"); 9624 return; 9625 } 9626 rte_mempool_dump(stdout, mp); 9627 } 9628 } 9629 9630 cmdline_parse_token_string_t cmd_dump_one_dump = 9631 TOKEN_STRING_INITIALIZER(struct cmd_dump_one_result, dump, 9632 "dump_ring#dump_mempool"); 9633 9634 cmdline_parse_token_string_t cmd_dump_one_name = 9635 TOKEN_STRING_INITIALIZER(struct cmd_dump_one_result, name, NULL); 9636 9637 cmdline_parse_inst_t cmd_dump_one = { 9638 .f = cmd_dump_one_parsed, /* function to call */ 9639 .data = NULL, /* 2nd arg of func */ 9640 .help_str = "dump_ring|dump_mempool <name>: Dump one ring/mempool", 9641 .tokens = { /* token list, NULL terminated */ 9642 (void *)&cmd_dump_one_dump, 9643 (void *)&cmd_dump_one_name, 9644 NULL, 9645 }, 9646 }; 9647 9648 /* *** queue region set *** */ 9649 struct cmd_queue_region_result { 9650 cmdline_fixed_string_t set; 9651 cmdline_fixed_string_t port; 9652 portid_t port_id; 9653 cmdline_fixed_string_t cmd; 9654 cmdline_fixed_string_t region; 9655 uint8_t region_id; 9656 cmdline_fixed_string_t queue_start_index; 9657 uint8_t queue_id; 9658 cmdline_fixed_string_t queue_num; 9659 uint8_t queue_num_value; 9660 }; 9661 9662 static void 9663 cmd_queue_region_parsed(void *parsed_result, 9664 __rte_unused struct cmdline *cl, 9665 __rte_unused void *data) 9666 { 9667 struct cmd_queue_region_result *res = parsed_result; 9668 int ret = -ENOTSUP; 9669 #ifdef RTE_NET_I40E 9670 struct rte_pmd_i40e_queue_region_conf region_conf; 9671 enum rte_pmd_i40e_queue_region_op op_type; 9672 #endif 9673 9674 if (port_id_is_invalid(res->port_id, ENABLED_WARN)) 9675 return; 9676 9677 #ifdef RTE_NET_I40E 9678 memset(®ion_conf, 0, sizeof(region_conf)); 9679 op_type = RTE_PMD_I40E_RSS_QUEUE_REGION_SET; 9680 region_conf.region_id = res->region_id; 9681 region_conf.queue_num = res->queue_num_value; 9682 region_conf.queue_start_index = res->queue_id; 9683 9684 ret = rte_pmd_i40e_rss_queue_region_conf(res->port_id, 9685 op_type, ®ion_conf); 9686 #endif 9687 9688 switch (ret) { 9689 case 0: 9690 break; 9691 case -ENOTSUP: 9692 printf("function not implemented or supported\n"); 9693 break; 9694 default: 9695 printf("queue region config error: (%s)\n", strerror(-ret)); 9696 } 9697 } 9698 9699 cmdline_parse_token_string_t cmd_queue_region_set = 9700 TOKEN_STRING_INITIALIZER(struct cmd_queue_region_result, 9701 set, "set"); 9702 cmdline_parse_token_string_t cmd_queue_region_port = 9703 TOKEN_STRING_INITIALIZER(struct cmd_queue_region_result, port, "port"); 9704 cmdline_parse_token_num_t cmd_queue_region_port_id = 9705 TOKEN_NUM_INITIALIZER(struct cmd_queue_region_result, 9706 port_id, RTE_UINT16); 9707 cmdline_parse_token_string_t cmd_queue_region_cmd = 9708 TOKEN_STRING_INITIALIZER(struct cmd_queue_region_result, 9709 cmd, "queue-region"); 9710 cmdline_parse_token_string_t cmd_queue_region_id = 9711 TOKEN_STRING_INITIALIZER(struct cmd_queue_region_result, 9712 region, "region_id"); 9713 cmdline_parse_token_num_t cmd_queue_region_index = 9714 TOKEN_NUM_INITIALIZER(struct cmd_queue_region_result, 9715 region_id, RTE_UINT8); 9716 cmdline_parse_token_string_t cmd_queue_region_queue_start_index = 9717 TOKEN_STRING_INITIALIZER(struct cmd_queue_region_result, 9718 queue_start_index, "queue_start_index"); 9719 cmdline_parse_token_num_t cmd_queue_region_queue_id = 9720 TOKEN_NUM_INITIALIZER(struct cmd_queue_region_result, 9721 queue_id, RTE_UINT8); 9722 cmdline_parse_token_string_t cmd_queue_region_queue_num = 9723 TOKEN_STRING_INITIALIZER(struct cmd_queue_region_result, 9724 queue_num, "queue_num"); 9725 cmdline_parse_token_num_t cmd_queue_region_queue_num_value = 9726 TOKEN_NUM_INITIALIZER(struct cmd_queue_region_result, 9727 queue_num_value, RTE_UINT8); 9728 9729 cmdline_parse_inst_t cmd_queue_region = { 9730 .f = cmd_queue_region_parsed, 9731 .data = NULL, 9732 .help_str = "set port <port_id> queue-region region_id <value> " 9733 "queue_start_index <value> queue_num <value>: Set a queue region", 9734 .tokens = { 9735 (void *)&cmd_queue_region_set, 9736 (void *)&cmd_queue_region_port, 9737 (void *)&cmd_queue_region_port_id, 9738 (void *)&cmd_queue_region_cmd, 9739 (void *)&cmd_queue_region_id, 9740 (void *)&cmd_queue_region_index, 9741 (void *)&cmd_queue_region_queue_start_index, 9742 (void *)&cmd_queue_region_queue_id, 9743 (void *)&cmd_queue_region_queue_num, 9744 (void *)&cmd_queue_region_queue_num_value, 9745 NULL, 9746 }, 9747 }; 9748 9749 /* *** queue region and flowtype set *** */ 9750 struct cmd_region_flowtype_result { 9751 cmdline_fixed_string_t set; 9752 cmdline_fixed_string_t port; 9753 portid_t port_id; 9754 cmdline_fixed_string_t cmd; 9755 cmdline_fixed_string_t region; 9756 uint8_t region_id; 9757 cmdline_fixed_string_t flowtype; 9758 uint8_t flowtype_id; 9759 }; 9760 9761 static void 9762 cmd_region_flowtype_parsed(void *parsed_result, 9763 __rte_unused struct cmdline *cl, 9764 __rte_unused void *data) 9765 { 9766 struct cmd_region_flowtype_result *res = parsed_result; 9767 int ret = -ENOTSUP; 9768 #ifdef RTE_NET_I40E 9769 struct rte_pmd_i40e_queue_region_conf region_conf; 9770 enum rte_pmd_i40e_queue_region_op op_type; 9771 #endif 9772 9773 if (port_id_is_invalid(res->port_id, ENABLED_WARN)) 9774 return; 9775 9776 #ifdef RTE_NET_I40E 9777 memset(®ion_conf, 0, sizeof(region_conf)); 9778 9779 op_type = RTE_PMD_I40E_RSS_QUEUE_REGION_FLOWTYPE_SET; 9780 region_conf.region_id = res->region_id; 9781 region_conf.hw_flowtype = res->flowtype_id; 9782 9783 ret = rte_pmd_i40e_rss_queue_region_conf(res->port_id, 9784 op_type, ®ion_conf); 9785 #endif 9786 9787 switch (ret) { 9788 case 0: 9789 break; 9790 case -ENOTSUP: 9791 printf("function not implemented or supported\n"); 9792 break; 9793 default: 9794 printf("region flowtype config error: (%s)\n", strerror(-ret)); 9795 } 9796 } 9797 9798 cmdline_parse_token_string_t cmd_region_flowtype_set = 9799 TOKEN_STRING_INITIALIZER(struct cmd_region_flowtype_result, 9800 set, "set"); 9801 cmdline_parse_token_string_t cmd_region_flowtype_port = 9802 TOKEN_STRING_INITIALIZER(struct cmd_region_flowtype_result, 9803 port, "port"); 9804 cmdline_parse_token_num_t cmd_region_flowtype_port_index = 9805 TOKEN_NUM_INITIALIZER(struct cmd_region_flowtype_result, 9806 port_id, RTE_UINT16); 9807 cmdline_parse_token_string_t cmd_region_flowtype_cmd = 9808 TOKEN_STRING_INITIALIZER(struct cmd_region_flowtype_result, 9809 cmd, "queue-region"); 9810 cmdline_parse_token_string_t cmd_region_flowtype_index = 9811 TOKEN_STRING_INITIALIZER(struct cmd_region_flowtype_result, 9812 region, "region_id"); 9813 cmdline_parse_token_num_t cmd_region_flowtype_id = 9814 TOKEN_NUM_INITIALIZER(struct cmd_region_flowtype_result, 9815 region_id, RTE_UINT8); 9816 cmdline_parse_token_string_t cmd_region_flowtype_flow_index = 9817 TOKEN_STRING_INITIALIZER(struct cmd_region_flowtype_result, 9818 flowtype, "flowtype"); 9819 cmdline_parse_token_num_t cmd_region_flowtype_flow_id = 9820 TOKEN_NUM_INITIALIZER(struct cmd_region_flowtype_result, 9821 flowtype_id, RTE_UINT8); 9822 cmdline_parse_inst_t cmd_region_flowtype = { 9823 .f = cmd_region_flowtype_parsed, 9824 .data = NULL, 9825 .help_str = "set port <port_id> queue-region region_id <value> " 9826 "flowtype <value>: Set a flowtype region index", 9827 .tokens = { 9828 (void *)&cmd_region_flowtype_set, 9829 (void *)&cmd_region_flowtype_port, 9830 (void *)&cmd_region_flowtype_port_index, 9831 (void *)&cmd_region_flowtype_cmd, 9832 (void *)&cmd_region_flowtype_index, 9833 (void *)&cmd_region_flowtype_id, 9834 (void *)&cmd_region_flowtype_flow_index, 9835 (void *)&cmd_region_flowtype_flow_id, 9836 NULL, 9837 }, 9838 }; 9839 9840 /* *** User Priority (UP) to queue region (region_id) set *** */ 9841 struct cmd_user_priority_region_result { 9842 cmdline_fixed_string_t set; 9843 cmdline_fixed_string_t port; 9844 portid_t port_id; 9845 cmdline_fixed_string_t cmd; 9846 cmdline_fixed_string_t user_priority; 9847 uint8_t user_priority_id; 9848 cmdline_fixed_string_t region; 9849 uint8_t region_id; 9850 }; 9851 9852 static void 9853 cmd_user_priority_region_parsed(void *parsed_result, 9854 __rte_unused struct cmdline *cl, 9855 __rte_unused void *data) 9856 { 9857 struct cmd_user_priority_region_result *res = parsed_result; 9858 int ret = -ENOTSUP; 9859 #ifdef RTE_NET_I40E 9860 struct rte_pmd_i40e_queue_region_conf region_conf; 9861 enum rte_pmd_i40e_queue_region_op op_type; 9862 #endif 9863 9864 if (port_id_is_invalid(res->port_id, ENABLED_WARN)) 9865 return; 9866 9867 #ifdef RTE_NET_I40E 9868 memset(®ion_conf, 0, sizeof(region_conf)); 9869 op_type = RTE_PMD_I40E_RSS_QUEUE_REGION_USER_PRIORITY_SET; 9870 region_conf.user_priority = res->user_priority_id; 9871 region_conf.region_id = res->region_id; 9872 9873 ret = rte_pmd_i40e_rss_queue_region_conf(res->port_id, 9874 op_type, ®ion_conf); 9875 #endif 9876 9877 switch (ret) { 9878 case 0: 9879 break; 9880 case -ENOTSUP: 9881 printf("function not implemented or supported\n"); 9882 break; 9883 default: 9884 printf("user_priority region config error: (%s)\n", 9885 strerror(-ret)); 9886 } 9887 } 9888 9889 cmdline_parse_token_string_t cmd_user_priority_region_set = 9890 TOKEN_STRING_INITIALIZER(struct cmd_user_priority_region_result, 9891 set, "set"); 9892 cmdline_parse_token_string_t cmd_user_priority_region_port = 9893 TOKEN_STRING_INITIALIZER(struct cmd_user_priority_region_result, 9894 port, "port"); 9895 cmdline_parse_token_num_t cmd_user_priority_region_port_index = 9896 TOKEN_NUM_INITIALIZER(struct cmd_user_priority_region_result, 9897 port_id, RTE_UINT16); 9898 cmdline_parse_token_string_t cmd_user_priority_region_cmd = 9899 TOKEN_STRING_INITIALIZER(struct cmd_user_priority_region_result, 9900 cmd, "queue-region"); 9901 cmdline_parse_token_string_t cmd_user_priority_region_UP = 9902 TOKEN_STRING_INITIALIZER(struct cmd_user_priority_region_result, 9903 user_priority, "UP"); 9904 cmdline_parse_token_num_t cmd_user_priority_region_UP_id = 9905 TOKEN_NUM_INITIALIZER(struct cmd_user_priority_region_result, 9906 user_priority_id, RTE_UINT8); 9907 cmdline_parse_token_string_t cmd_user_priority_region_region = 9908 TOKEN_STRING_INITIALIZER(struct cmd_user_priority_region_result, 9909 region, "region_id"); 9910 cmdline_parse_token_num_t cmd_user_priority_region_region_id = 9911 TOKEN_NUM_INITIALIZER(struct cmd_user_priority_region_result, 9912 region_id, RTE_UINT8); 9913 9914 cmdline_parse_inst_t cmd_user_priority_region = { 9915 .f = cmd_user_priority_region_parsed, 9916 .data = NULL, 9917 .help_str = "set port <port_id> queue-region UP <value> " 9918 "region_id <value>: Set the mapping of User Priority (UP) " 9919 "to queue region (region_id) ", 9920 .tokens = { 9921 (void *)&cmd_user_priority_region_set, 9922 (void *)&cmd_user_priority_region_port, 9923 (void *)&cmd_user_priority_region_port_index, 9924 (void *)&cmd_user_priority_region_cmd, 9925 (void *)&cmd_user_priority_region_UP, 9926 (void *)&cmd_user_priority_region_UP_id, 9927 (void *)&cmd_user_priority_region_region, 9928 (void *)&cmd_user_priority_region_region_id, 9929 NULL, 9930 }, 9931 }; 9932 9933 /* *** flush all queue region related configuration *** */ 9934 struct cmd_flush_queue_region_result { 9935 cmdline_fixed_string_t set; 9936 cmdline_fixed_string_t port; 9937 portid_t port_id; 9938 cmdline_fixed_string_t cmd; 9939 cmdline_fixed_string_t flush; 9940 cmdline_fixed_string_t what; 9941 }; 9942 9943 static void 9944 cmd_flush_queue_region_parsed(void *parsed_result, 9945 __rte_unused struct cmdline *cl, 9946 __rte_unused void *data) 9947 { 9948 struct cmd_flush_queue_region_result *res = parsed_result; 9949 int ret = -ENOTSUP; 9950 #ifdef RTE_NET_I40E 9951 struct rte_pmd_i40e_queue_region_conf region_conf; 9952 enum rte_pmd_i40e_queue_region_op op_type; 9953 #endif 9954 9955 if (port_id_is_invalid(res->port_id, ENABLED_WARN)) 9956 return; 9957 9958 #ifdef RTE_NET_I40E 9959 memset(®ion_conf, 0, sizeof(region_conf)); 9960 9961 if (strcmp(res->what, "on") == 0) 9962 op_type = RTE_PMD_I40E_RSS_QUEUE_REGION_ALL_FLUSH_ON; 9963 else 9964 op_type = RTE_PMD_I40E_RSS_QUEUE_REGION_ALL_FLUSH_OFF; 9965 9966 ret = rte_pmd_i40e_rss_queue_region_conf(res->port_id, 9967 op_type, ®ion_conf); 9968 #endif 9969 9970 switch (ret) { 9971 case 0: 9972 break; 9973 case -ENOTSUP: 9974 printf("function not implemented or supported\n"); 9975 break; 9976 default: 9977 printf("queue region config flush error: (%s)\n", 9978 strerror(-ret)); 9979 } 9980 } 9981 9982 cmdline_parse_token_string_t cmd_flush_queue_region_set = 9983 TOKEN_STRING_INITIALIZER(struct cmd_flush_queue_region_result, 9984 set, "set"); 9985 cmdline_parse_token_string_t cmd_flush_queue_region_port = 9986 TOKEN_STRING_INITIALIZER(struct cmd_flush_queue_region_result, 9987 port, "port"); 9988 cmdline_parse_token_num_t cmd_flush_queue_region_port_index = 9989 TOKEN_NUM_INITIALIZER(struct cmd_flush_queue_region_result, 9990 port_id, RTE_UINT16); 9991 cmdline_parse_token_string_t cmd_flush_queue_region_cmd = 9992 TOKEN_STRING_INITIALIZER(struct cmd_flush_queue_region_result, 9993 cmd, "queue-region"); 9994 cmdline_parse_token_string_t cmd_flush_queue_region_flush = 9995 TOKEN_STRING_INITIALIZER(struct cmd_flush_queue_region_result, 9996 flush, "flush"); 9997 cmdline_parse_token_string_t cmd_flush_queue_region_what = 9998 TOKEN_STRING_INITIALIZER(struct cmd_flush_queue_region_result, 9999 what, "on#off"); 10000 10001 cmdline_parse_inst_t cmd_flush_queue_region = { 10002 .f = cmd_flush_queue_region_parsed, 10003 .data = NULL, 10004 .help_str = "set port <port_id> queue-region flush on|off" 10005 ": flush all queue region related configuration", 10006 .tokens = { 10007 (void *)&cmd_flush_queue_region_set, 10008 (void *)&cmd_flush_queue_region_port, 10009 (void *)&cmd_flush_queue_region_port_index, 10010 (void *)&cmd_flush_queue_region_cmd, 10011 (void *)&cmd_flush_queue_region_flush, 10012 (void *)&cmd_flush_queue_region_what, 10013 NULL, 10014 }, 10015 }; 10016 10017 /* *** get all queue region related configuration info *** */ 10018 struct cmd_show_queue_region_info { 10019 cmdline_fixed_string_t show; 10020 cmdline_fixed_string_t port; 10021 portid_t port_id; 10022 cmdline_fixed_string_t cmd; 10023 }; 10024 10025 static void 10026 cmd_show_queue_region_info_parsed(void *parsed_result, 10027 __rte_unused struct cmdline *cl, 10028 __rte_unused void *data) 10029 { 10030 struct cmd_show_queue_region_info *res = parsed_result; 10031 int ret = -ENOTSUP; 10032 #ifdef RTE_NET_I40E 10033 struct rte_pmd_i40e_queue_regions rte_pmd_regions; 10034 enum rte_pmd_i40e_queue_region_op op_type; 10035 #endif 10036 10037 if (port_id_is_invalid(res->port_id, ENABLED_WARN)) 10038 return; 10039 10040 #ifdef RTE_NET_I40E 10041 memset(&rte_pmd_regions, 0, sizeof(rte_pmd_regions)); 10042 10043 op_type = RTE_PMD_I40E_RSS_QUEUE_REGION_INFO_GET; 10044 10045 ret = rte_pmd_i40e_rss_queue_region_conf(res->port_id, 10046 op_type, &rte_pmd_regions); 10047 10048 port_queue_region_info_display(res->port_id, &rte_pmd_regions); 10049 #endif 10050 10051 switch (ret) { 10052 case 0: 10053 break; 10054 case -ENOTSUP: 10055 printf("function not implemented or supported\n"); 10056 break; 10057 default: 10058 printf("queue region config info show error: (%s)\n", 10059 strerror(-ret)); 10060 } 10061 } 10062 10063 cmdline_parse_token_string_t cmd_show_queue_region_info_get = 10064 TOKEN_STRING_INITIALIZER(struct cmd_show_queue_region_info, 10065 show, "show"); 10066 cmdline_parse_token_string_t cmd_show_queue_region_info_port = 10067 TOKEN_STRING_INITIALIZER(struct cmd_show_queue_region_info, 10068 port, "port"); 10069 cmdline_parse_token_num_t cmd_show_queue_region_info_port_index = 10070 TOKEN_NUM_INITIALIZER(struct cmd_show_queue_region_info, 10071 port_id, RTE_UINT16); 10072 cmdline_parse_token_string_t cmd_show_queue_region_info_cmd = 10073 TOKEN_STRING_INITIALIZER(struct cmd_show_queue_region_info, 10074 cmd, "queue-region"); 10075 10076 cmdline_parse_inst_t cmd_show_queue_region_info_all = { 10077 .f = cmd_show_queue_region_info_parsed, 10078 .data = NULL, 10079 .help_str = "show port <port_id> queue-region" 10080 ": show all queue region related configuration info", 10081 .tokens = { 10082 (void *)&cmd_show_queue_region_info_get, 10083 (void *)&cmd_show_queue_region_info_port, 10084 (void *)&cmd_show_queue_region_info_port_index, 10085 (void *)&cmd_show_queue_region_info_cmd, 10086 NULL, 10087 }, 10088 }; 10089 10090 /* *** Filters Control *** */ 10091 10092 #define IPV4_ADDR_TO_UINT(ip_addr, ip) \ 10093 do { \ 10094 if ((ip_addr).family == AF_INET) \ 10095 (ip) = (ip_addr).addr.ipv4.s_addr; \ 10096 else { \ 10097 printf("invalid parameter.\n"); \ 10098 return; \ 10099 } \ 10100 } while (0) 10101 10102 #define IPV6_ADDR_TO_ARRAY(ip_addr, ip) \ 10103 do { \ 10104 if ((ip_addr).family == AF_INET6) \ 10105 rte_memcpy(&(ip), \ 10106 &((ip_addr).addr.ipv6), \ 10107 sizeof(struct in6_addr)); \ 10108 else { \ 10109 printf("invalid parameter.\n"); \ 10110 return; \ 10111 } \ 10112 } while (0) 10113 10114 #ifdef RTE_NET_I40E 10115 10116 static uint16_t 10117 str2flowtype(char *string) 10118 { 10119 uint8_t i = 0; 10120 static const struct { 10121 char str[32]; 10122 uint16_t type; 10123 } flowtype_str[] = { 10124 {"raw", RTE_ETH_FLOW_RAW}, 10125 {"ipv4", RTE_ETH_FLOW_IPV4}, 10126 {"ipv4-frag", RTE_ETH_FLOW_FRAG_IPV4}, 10127 {"ipv4-tcp", RTE_ETH_FLOW_NONFRAG_IPV4_TCP}, 10128 {"ipv4-udp", RTE_ETH_FLOW_NONFRAG_IPV4_UDP}, 10129 {"ipv4-sctp", RTE_ETH_FLOW_NONFRAG_IPV4_SCTP}, 10130 {"ipv4-other", RTE_ETH_FLOW_NONFRAG_IPV4_OTHER}, 10131 {"ipv6", RTE_ETH_FLOW_IPV6}, 10132 {"ipv6-frag", RTE_ETH_FLOW_FRAG_IPV6}, 10133 {"ipv6-tcp", RTE_ETH_FLOW_NONFRAG_IPV6_TCP}, 10134 {"ipv6-udp", RTE_ETH_FLOW_NONFRAG_IPV6_UDP}, 10135 {"ipv6-sctp", RTE_ETH_FLOW_NONFRAG_IPV6_SCTP}, 10136 {"ipv6-other", RTE_ETH_FLOW_NONFRAG_IPV6_OTHER}, 10137 {"l2_payload", RTE_ETH_FLOW_L2_PAYLOAD}, 10138 }; 10139 10140 for (i = 0; i < RTE_DIM(flowtype_str); i++) { 10141 if (!strcmp(flowtype_str[i].str, string)) 10142 return flowtype_str[i].type; 10143 } 10144 10145 if (isdigit(string[0]) && atoi(string) > 0 && atoi(string) < 64) 10146 return (uint16_t)atoi(string); 10147 10148 return RTE_ETH_FLOW_UNKNOWN; 10149 } 10150 10151 /* *** deal with flow director filter *** */ 10152 struct cmd_flow_director_result { 10153 cmdline_fixed_string_t flow_director_filter; 10154 portid_t port_id; 10155 cmdline_fixed_string_t mode; 10156 cmdline_fixed_string_t mode_value; 10157 cmdline_fixed_string_t ops; 10158 cmdline_fixed_string_t flow; 10159 cmdline_fixed_string_t flow_type; 10160 cmdline_fixed_string_t drop; 10161 cmdline_fixed_string_t queue; 10162 uint16_t queue_id; 10163 cmdline_fixed_string_t fd_id; 10164 uint32_t fd_id_value; 10165 cmdline_fixed_string_t packet; 10166 char filepath[]; 10167 }; 10168 10169 static void 10170 cmd_flow_director_filter_parsed(void *parsed_result, 10171 __rte_unused struct cmdline *cl, 10172 __rte_unused void *data) 10173 { 10174 struct cmd_flow_director_result *res = parsed_result; 10175 int ret = 0; 10176 struct rte_pmd_i40e_flow_type_mapping 10177 mapping[RTE_PMD_I40E_FLOW_TYPE_MAX]; 10178 struct rte_pmd_i40e_pkt_template_conf conf; 10179 uint16_t flow_type = str2flowtype(res->flow_type); 10180 uint16_t i, port = res->port_id; 10181 uint8_t add; 10182 10183 memset(&conf, 0, sizeof(conf)); 10184 10185 if (flow_type == RTE_ETH_FLOW_UNKNOWN) { 10186 printf("Invalid flow type specified.\n"); 10187 return; 10188 } 10189 ret = rte_pmd_i40e_flow_type_mapping_get(res->port_id, 10190 mapping); 10191 if (ret) 10192 return; 10193 if (mapping[flow_type].pctype == 0ULL) { 10194 printf("Invalid flow type specified.\n"); 10195 return; 10196 } 10197 for (i = 0; i < RTE_PMD_I40E_PCTYPE_MAX; i++) { 10198 if (mapping[flow_type].pctype & (1ULL << i)) { 10199 conf.input.pctype = i; 10200 break; 10201 } 10202 } 10203 10204 conf.input.packet = open_file(res->filepath, 10205 &conf.input.length); 10206 if (!conf.input.packet) 10207 return; 10208 if (!strcmp(res->drop, "drop")) 10209 conf.action.behavior = 10210 RTE_PMD_I40E_PKT_TEMPLATE_REJECT; 10211 else 10212 conf.action.behavior = 10213 RTE_PMD_I40E_PKT_TEMPLATE_ACCEPT; 10214 conf.action.report_status = 10215 RTE_PMD_I40E_PKT_TEMPLATE_REPORT_ID; 10216 conf.action.rx_queue = res->queue_id; 10217 conf.soft_id = res->fd_id_value; 10218 add = strcmp(res->ops, "del") ? 1 : 0; 10219 ret = rte_pmd_i40e_flow_add_del_packet_template(port, 10220 &conf, 10221 add); 10222 if (ret < 0) 10223 printf("flow director config error: (%s)\n", 10224 strerror(-ret)); 10225 close_file(conf.input.packet); 10226 } 10227 10228 cmdline_parse_token_string_t cmd_flow_director_filter = 10229 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result, 10230 flow_director_filter, "flow_director_filter"); 10231 cmdline_parse_token_num_t cmd_flow_director_port_id = 10232 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result, 10233 port_id, RTE_UINT16); 10234 cmdline_parse_token_string_t cmd_flow_director_ops = 10235 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result, 10236 ops, "add#del#update"); 10237 cmdline_parse_token_string_t cmd_flow_director_flow = 10238 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result, 10239 flow, "flow"); 10240 cmdline_parse_token_string_t cmd_flow_director_flow_type = 10241 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result, 10242 flow_type, NULL); 10243 cmdline_parse_token_string_t cmd_flow_director_drop = 10244 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result, 10245 drop, "drop#fwd"); 10246 cmdline_parse_token_string_t cmd_flow_director_queue = 10247 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result, 10248 queue, "queue"); 10249 cmdline_parse_token_num_t cmd_flow_director_queue_id = 10250 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result, 10251 queue_id, RTE_UINT16); 10252 cmdline_parse_token_string_t cmd_flow_director_fd_id = 10253 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result, 10254 fd_id, "fd_id"); 10255 cmdline_parse_token_num_t cmd_flow_director_fd_id_value = 10256 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result, 10257 fd_id_value, RTE_UINT32); 10258 10259 cmdline_parse_token_string_t cmd_flow_director_mode = 10260 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result, 10261 mode, "mode"); 10262 cmdline_parse_token_string_t cmd_flow_director_mode_raw = 10263 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result, 10264 mode_value, "raw"); 10265 cmdline_parse_token_string_t cmd_flow_director_packet = 10266 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result, 10267 packet, "packet"); 10268 cmdline_parse_token_string_t cmd_flow_director_filepath = 10269 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result, 10270 filepath, NULL); 10271 10272 cmdline_parse_inst_t cmd_add_del_raw_flow_director = { 10273 .f = cmd_flow_director_filter_parsed, 10274 .data = NULL, 10275 .help_str = "flow_director_filter ... : Add or delete a raw flow " 10276 "director entry on NIC", 10277 .tokens = { 10278 (void *)&cmd_flow_director_filter, 10279 (void *)&cmd_flow_director_port_id, 10280 (void *)&cmd_flow_director_mode, 10281 (void *)&cmd_flow_director_mode_raw, 10282 (void *)&cmd_flow_director_ops, 10283 (void *)&cmd_flow_director_flow, 10284 (void *)&cmd_flow_director_flow_type, 10285 (void *)&cmd_flow_director_drop, 10286 (void *)&cmd_flow_director_queue, 10287 (void *)&cmd_flow_director_queue_id, 10288 (void *)&cmd_flow_director_fd_id, 10289 (void *)&cmd_flow_director_fd_id_value, 10290 (void *)&cmd_flow_director_packet, 10291 (void *)&cmd_flow_director_filepath, 10292 NULL, 10293 }, 10294 }; 10295 10296 #endif /* RTE_NET_I40E */ 10297 10298 /* *** deal with flow director mask *** */ 10299 struct cmd_flow_director_mask_result { 10300 cmdline_fixed_string_t flow_director_mask; 10301 portid_t port_id; 10302 cmdline_fixed_string_t mode; 10303 cmdline_fixed_string_t mode_value; 10304 cmdline_fixed_string_t vlan; 10305 uint16_t vlan_mask; 10306 cmdline_fixed_string_t src_mask; 10307 cmdline_ipaddr_t ipv4_src; 10308 cmdline_ipaddr_t ipv6_src; 10309 uint16_t port_src; 10310 cmdline_fixed_string_t dst_mask; 10311 cmdline_ipaddr_t ipv4_dst; 10312 cmdline_ipaddr_t ipv6_dst; 10313 uint16_t port_dst; 10314 cmdline_fixed_string_t mac; 10315 uint8_t mac_addr_byte_mask; 10316 cmdline_fixed_string_t tunnel_id; 10317 uint32_t tunnel_id_mask; 10318 cmdline_fixed_string_t tunnel_type; 10319 uint8_t tunnel_type_mask; 10320 }; 10321 10322 static void 10323 cmd_flow_director_mask_parsed(void *parsed_result, 10324 __rte_unused struct cmdline *cl, 10325 __rte_unused void *data) 10326 { 10327 struct cmd_flow_director_mask_result *res = parsed_result; 10328 struct rte_eth_fdir_masks *mask; 10329 struct rte_port *port; 10330 10331 port = &ports[res->port_id]; 10332 /** Check if the port is not started **/ 10333 if (port->port_status != RTE_PORT_STOPPED) { 10334 printf("Please stop port %d first\n", res->port_id); 10335 return; 10336 } 10337 10338 mask = &port->dev_conf.fdir_conf.mask; 10339 10340 if (fdir_conf.mode == RTE_FDIR_MODE_PERFECT_MAC_VLAN) { 10341 if (strcmp(res->mode_value, "MAC-VLAN")) { 10342 printf("Please set mode to MAC-VLAN.\n"); 10343 return; 10344 } 10345 10346 mask->vlan_tci_mask = rte_cpu_to_be_16(res->vlan_mask); 10347 } else if (fdir_conf.mode == RTE_FDIR_MODE_PERFECT_TUNNEL) { 10348 if (strcmp(res->mode_value, "Tunnel")) { 10349 printf("Please set mode to Tunnel.\n"); 10350 return; 10351 } 10352 10353 mask->vlan_tci_mask = rte_cpu_to_be_16(res->vlan_mask); 10354 mask->mac_addr_byte_mask = res->mac_addr_byte_mask; 10355 mask->tunnel_id_mask = rte_cpu_to_be_32(res->tunnel_id_mask); 10356 mask->tunnel_type_mask = res->tunnel_type_mask; 10357 } else { 10358 if (strcmp(res->mode_value, "IP")) { 10359 printf("Please set mode to IP.\n"); 10360 return; 10361 } 10362 10363 mask->vlan_tci_mask = rte_cpu_to_be_16(res->vlan_mask); 10364 IPV4_ADDR_TO_UINT(res->ipv4_src, mask->ipv4_mask.src_ip); 10365 IPV4_ADDR_TO_UINT(res->ipv4_dst, mask->ipv4_mask.dst_ip); 10366 IPV6_ADDR_TO_ARRAY(res->ipv6_src, mask->ipv6_mask.src_ip); 10367 IPV6_ADDR_TO_ARRAY(res->ipv6_dst, mask->ipv6_mask.dst_ip); 10368 mask->src_port_mask = rte_cpu_to_be_16(res->port_src); 10369 mask->dst_port_mask = rte_cpu_to_be_16(res->port_dst); 10370 } 10371 10372 cmd_reconfig_device_queue(res->port_id, 1, 1); 10373 } 10374 10375 cmdline_parse_token_string_t cmd_flow_director_mask = 10376 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result, 10377 flow_director_mask, "flow_director_mask"); 10378 cmdline_parse_token_num_t cmd_flow_director_mask_port_id = 10379 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_mask_result, 10380 port_id, RTE_UINT16); 10381 cmdline_parse_token_string_t cmd_flow_director_mask_vlan = 10382 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result, 10383 vlan, "vlan"); 10384 cmdline_parse_token_num_t cmd_flow_director_mask_vlan_value = 10385 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_mask_result, 10386 vlan_mask, RTE_UINT16); 10387 cmdline_parse_token_string_t cmd_flow_director_mask_src = 10388 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result, 10389 src_mask, "src_mask"); 10390 cmdline_parse_token_ipaddr_t cmd_flow_director_mask_ipv4_src = 10391 TOKEN_IPADDR_INITIALIZER(struct cmd_flow_director_mask_result, 10392 ipv4_src); 10393 cmdline_parse_token_ipaddr_t cmd_flow_director_mask_ipv6_src = 10394 TOKEN_IPADDR_INITIALIZER(struct cmd_flow_director_mask_result, 10395 ipv6_src); 10396 cmdline_parse_token_num_t cmd_flow_director_mask_port_src = 10397 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_mask_result, 10398 port_src, RTE_UINT16); 10399 cmdline_parse_token_string_t cmd_flow_director_mask_dst = 10400 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result, 10401 dst_mask, "dst_mask"); 10402 cmdline_parse_token_ipaddr_t cmd_flow_director_mask_ipv4_dst = 10403 TOKEN_IPADDR_INITIALIZER(struct cmd_flow_director_mask_result, 10404 ipv4_dst); 10405 cmdline_parse_token_ipaddr_t cmd_flow_director_mask_ipv6_dst = 10406 TOKEN_IPADDR_INITIALIZER(struct cmd_flow_director_mask_result, 10407 ipv6_dst); 10408 cmdline_parse_token_num_t cmd_flow_director_mask_port_dst = 10409 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_mask_result, 10410 port_dst, RTE_UINT16); 10411 10412 cmdline_parse_token_string_t cmd_flow_director_mask_mode = 10413 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result, 10414 mode, "mode"); 10415 cmdline_parse_token_string_t cmd_flow_director_mask_mode_ip = 10416 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result, 10417 mode_value, "IP"); 10418 cmdline_parse_token_string_t cmd_flow_director_mask_mode_mac_vlan = 10419 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result, 10420 mode_value, "MAC-VLAN"); 10421 cmdline_parse_token_string_t cmd_flow_director_mask_mode_tunnel = 10422 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result, 10423 mode_value, "Tunnel"); 10424 cmdline_parse_token_string_t cmd_flow_director_mask_mac = 10425 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result, 10426 mac, "mac"); 10427 cmdline_parse_token_num_t cmd_flow_director_mask_mac_value = 10428 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_mask_result, 10429 mac_addr_byte_mask, RTE_UINT8); 10430 cmdline_parse_token_string_t cmd_flow_director_mask_tunnel_type = 10431 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result, 10432 tunnel_type, "tunnel-type"); 10433 cmdline_parse_token_num_t cmd_flow_director_mask_tunnel_type_value = 10434 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_mask_result, 10435 tunnel_type_mask, RTE_UINT8); 10436 cmdline_parse_token_string_t cmd_flow_director_mask_tunnel_id = 10437 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result, 10438 tunnel_id, "tunnel-id"); 10439 cmdline_parse_token_num_t cmd_flow_director_mask_tunnel_id_value = 10440 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_mask_result, 10441 tunnel_id_mask, RTE_UINT32); 10442 10443 cmdline_parse_inst_t cmd_set_flow_director_ip_mask = { 10444 .f = cmd_flow_director_mask_parsed, 10445 .data = NULL, 10446 .help_str = "flow_director_mask ... : " 10447 "Set IP mode flow director's mask on NIC", 10448 .tokens = { 10449 (void *)&cmd_flow_director_mask, 10450 (void *)&cmd_flow_director_mask_port_id, 10451 (void *)&cmd_flow_director_mask_mode, 10452 (void *)&cmd_flow_director_mask_mode_ip, 10453 (void *)&cmd_flow_director_mask_vlan, 10454 (void *)&cmd_flow_director_mask_vlan_value, 10455 (void *)&cmd_flow_director_mask_src, 10456 (void *)&cmd_flow_director_mask_ipv4_src, 10457 (void *)&cmd_flow_director_mask_ipv6_src, 10458 (void *)&cmd_flow_director_mask_port_src, 10459 (void *)&cmd_flow_director_mask_dst, 10460 (void *)&cmd_flow_director_mask_ipv4_dst, 10461 (void *)&cmd_flow_director_mask_ipv6_dst, 10462 (void *)&cmd_flow_director_mask_port_dst, 10463 NULL, 10464 }, 10465 }; 10466 10467 cmdline_parse_inst_t cmd_set_flow_director_mac_vlan_mask = { 10468 .f = cmd_flow_director_mask_parsed, 10469 .data = NULL, 10470 .help_str = "flow_director_mask ... : Set MAC VLAN mode " 10471 "flow director's mask on NIC", 10472 .tokens = { 10473 (void *)&cmd_flow_director_mask, 10474 (void *)&cmd_flow_director_mask_port_id, 10475 (void *)&cmd_flow_director_mask_mode, 10476 (void *)&cmd_flow_director_mask_mode_mac_vlan, 10477 (void *)&cmd_flow_director_mask_vlan, 10478 (void *)&cmd_flow_director_mask_vlan_value, 10479 NULL, 10480 }, 10481 }; 10482 10483 cmdline_parse_inst_t cmd_set_flow_director_tunnel_mask = { 10484 .f = cmd_flow_director_mask_parsed, 10485 .data = NULL, 10486 .help_str = "flow_director_mask ... : Set tunnel mode " 10487 "flow director's mask on NIC", 10488 .tokens = { 10489 (void *)&cmd_flow_director_mask, 10490 (void *)&cmd_flow_director_mask_port_id, 10491 (void *)&cmd_flow_director_mask_mode, 10492 (void *)&cmd_flow_director_mask_mode_tunnel, 10493 (void *)&cmd_flow_director_mask_vlan, 10494 (void *)&cmd_flow_director_mask_vlan_value, 10495 (void *)&cmd_flow_director_mask_mac, 10496 (void *)&cmd_flow_director_mask_mac_value, 10497 (void *)&cmd_flow_director_mask_tunnel_type, 10498 (void *)&cmd_flow_director_mask_tunnel_type_value, 10499 (void *)&cmd_flow_director_mask_tunnel_id, 10500 (void *)&cmd_flow_director_mask_tunnel_id_value, 10501 NULL, 10502 }, 10503 }; 10504 10505 /* *** deal with flow director flexible payload configuration *** */ 10506 struct cmd_flow_director_flexpayload_result { 10507 cmdline_fixed_string_t flow_director_flexpayload; 10508 portid_t port_id; 10509 cmdline_fixed_string_t payload_layer; 10510 cmdline_fixed_string_t payload_cfg; 10511 }; 10512 10513 static inline int 10514 parse_offsets(const char *q_arg, uint16_t *offsets, uint16_t max_num) 10515 { 10516 char s[256]; 10517 const char *p, *p0 = q_arg; 10518 char *end; 10519 unsigned long int_fld; 10520 char *str_fld[max_num]; 10521 int i; 10522 unsigned size; 10523 int ret = -1; 10524 10525 p = strchr(p0, '('); 10526 if (p == NULL) 10527 return -1; 10528 ++p; 10529 p0 = strchr(p, ')'); 10530 if (p0 == NULL) 10531 return -1; 10532 10533 size = p0 - p; 10534 if (size >= sizeof(s)) 10535 return -1; 10536 10537 snprintf(s, sizeof(s), "%.*s", size, p); 10538 ret = rte_strsplit(s, sizeof(s), str_fld, max_num, ','); 10539 if (ret < 0 || ret > max_num) 10540 return -1; 10541 for (i = 0; i < ret; i++) { 10542 errno = 0; 10543 int_fld = strtoul(str_fld[i], &end, 0); 10544 if (errno != 0 || *end != '\0' || int_fld > UINT16_MAX) 10545 return -1; 10546 offsets[i] = (uint16_t)int_fld; 10547 } 10548 return ret; 10549 } 10550 10551 static void 10552 cmd_flow_director_flxpld_parsed(void *parsed_result, 10553 __rte_unused struct cmdline *cl, 10554 __rte_unused void *data) 10555 { 10556 struct cmd_flow_director_flexpayload_result *res = parsed_result; 10557 struct rte_eth_flex_payload_cfg flex_cfg; 10558 struct rte_port *port; 10559 int ret = 0; 10560 10561 port = &ports[res->port_id]; 10562 /** Check if the port is not started **/ 10563 if (port->port_status != RTE_PORT_STOPPED) { 10564 printf("Please stop port %d first\n", res->port_id); 10565 return; 10566 } 10567 10568 memset(&flex_cfg, 0, sizeof(struct rte_eth_flex_payload_cfg)); 10569 10570 if (!strcmp(res->payload_layer, "raw")) 10571 flex_cfg.type = RTE_ETH_RAW_PAYLOAD; 10572 else if (!strcmp(res->payload_layer, "l2")) 10573 flex_cfg.type = RTE_ETH_L2_PAYLOAD; 10574 else if (!strcmp(res->payload_layer, "l3")) 10575 flex_cfg.type = RTE_ETH_L3_PAYLOAD; 10576 else if (!strcmp(res->payload_layer, "l4")) 10577 flex_cfg.type = RTE_ETH_L4_PAYLOAD; 10578 10579 ret = parse_offsets(res->payload_cfg, flex_cfg.src_offset, 10580 RTE_ETH_FDIR_MAX_FLEXLEN); 10581 if (ret < 0) { 10582 printf("error: Cannot parse flex payload input.\n"); 10583 return; 10584 } 10585 10586 fdir_set_flex_payload(res->port_id, &flex_cfg); 10587 cmd_reconfig_device_queue(res->port_id, 1, 1); 10588 } 10589 10590 cmdline_parse_token_string_t cmd_flow_director_flexpayload = 10591 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_flexpayload_result, 10592 flow_director_flexpayload, 10593 "flow_director_flex_payload"); 10594 cmdline_parse_token_num_t cmd_flow_director_flexpayload_port_id = 10595 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_flexpayload_result, 10596 port_id, RTE_UINT16); 10597 cmdline_parse_token_string_t cmd_flow_director_flexpayload_payload_layer = 10598 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_flexpayload_result, 10599 payload_layer, "raw#l2#l3#l4"); 10600 cmdline_parse_token_string_t cmd_flow_director_flexpayload_payload_cfg = 10601 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_flexpayload_result, 10602 payload_cfg, NULL); 10603 10604 cmdline_parse_inst_t cmd_set_flow_director_flex_payload = { 10605 .f = cmd_flow_director_flxpld_parsed, 10606 .data = NULL, 10607 .help_str = "flow_director_flexpayload ... : " 10608 "Set flow director's flex payload on NIC", 10609 .tokens = { 10610 (void *)&cmd_flow_director_flexpayload, 10611 (void *)&cmd_flow_director_flexpayload_port_id, 10612 (void *)&cmd_flow_director_flexpayload_payload_layer, 10613 (void *)&cmd_flow_director_flexpayload_payload_cfg, 10614 NULL, 10615 }, 10616 }; 10617 10618 /* Generic flow interface command. */ 10619 extern cmdline_parse_inst_t cmd_flow; 10620 10621 /* *** ADD/REMOVE A MULTICAST MAC ADDRESS TO/FROM A PORT *** */ 10622 struct cmd_mcast_addr_result { 10623 cmdline_fixed_string_t mcast_addr_cmd; 10624 cmdline_fixed_string_t what; 10625 uint16_t port_num; 10626 struct rte_ether_addr mc_addr; 10627 }; 10628 10629 static void cmd_mcast_addr_parsed(void *parsed_result, 10630 __rte_unused struct cmdline *cl, 10631 __rte_unused void *data) 10632 { 10633 struct cmd_mcast_addr_result *res = parsed_result; 10634 10635 if (!rte_is_multicast_ether_addr(&res->mc_addr)) { 10636 printf("Invalid multicast addr %02X:%02X:%02X:%02X:%02X:%02X\n", 10637 res->mc_addr.addr_bytes[0], res->mc_addr.addr_bytes[1], 10638 res->mc_addr.addr_bytes[2], res->mc_addr.addr_bytes[3], 10639 res->mc_addr.addr_bytes[4], res->mc_addr.addr_bytes[5]); 10640 return; 10641 } 10642 if (strcmp(res->what, "add") == 0) 10643 mcast_addr_add(res->port_num, &res->mc_addr); 10644 else 10645 mcast_addr_remove(res->port_num, &res->mc_addr); 10646 } 10647 10648 cmdline_parse_token_string_t cmd_mcast_addr_cmd = 10649 TOKEN_STRING_INITIALIZER(struct cmd_mcast_addr_result, 10650 mcast_addr_cmd, "mcast_addr"); 10651 cmdline_parse_token_string_t cmd_mcast_addr_what = 10652 TOKEN_STRING_INITIALIZER(struct cmd_mcast_addr_result, what, 10653 "add#remove"); 10654 cmdline_parse_token_num_t cmd_mcast_addr_portnum = 10655 TOKEN_NUM_INITIALIZER(struct cmd_mcast_addr_result, port_num, 10656 RTE_UINT16); 10657 cmdline_parse_token_etheraddr_t cmd_mcast_addr_addr = 10658 TOKEN_ETHERADDR_INITIALIZER(struct cmd_mac_addr_result, address); 10659 10660 cmdline_parse_inst_t cmd_mcast_addr = { 10661 .f = cmd_mcast_addr_parsed, 10662 .data = (void *)0, 10663 .help_str = "mcast_addr add|remove <port_id> <mcast_addr>: " 10664 "Add/Remove multicast MAC address on port_id", 10665 .tokens = { 10666 (void *)&cmd_mcast_addr_cmd, 10667 (void *)&cmd_mcast_addr_what, 10668 (void *)&cmd_mcast_addr_portnum, 10669 (void *)&cmd_mcast_addr_addr, 10670 NULL, 10671 }, 10672 }; 10673 10674 /* vf vlan anti spoof configuration */ 10675 10676 /* Common result structure for vf vlan anti spoof */ 10677 struct cmd_vf_vlan_anti_spoof_result { 10678 cmdline_fixed_string_t set; 10679 cmdline_fixed_string_t vf; 10680 cmdline_fixed_string_t vlan; 10681 cmdline_fixed_string_t antispoof; 10682 portid_t port_id; 10683 uint32_t vf_id; 10684 cmdline_fixed_string_t on_off; 10685 }; 10686 10687 /* Common CLI fields for vf vlan anti spoof enable disable */ 10688 cmdline_parse_token_string_t cmd_vf_vlan_anti_spoof_set = 10689 TOKEN_STRING_INITIALIZER 10690 (struct cmd_vf_vlan_anti_spoof_result, 10691 set, "set"); 10692 cmdline_parse_token_string_t cmd_vf_vlan_anti_spoof_vf = 10693 TOKEN_STRING_INITIALIZER 10694 (struct cmd_vf_vlan_anti_spoof_result, 10695 vf, "vf"); 10696 cmdline_parse_token_string_t cmd_vf_vlan_anti_spoof_vlan = 10697 TOKEN_STRING_INITIALIZER 10698 (struct cmd_vf_vlan_anti_spoof_result, 10699 vlan, "vlan"); 10700 cmdline_parse_token_string_t cmd_vf_vlan_anti_spoof_antispoof = 10701 TOKEN_STRING_INITIALIZER 10702 (struct cmd_vf_vlan_anti_spoof_result, 10703 antispoof, "antispoof"); 10704 cmdline_parse_token_num_t cmd_vf_vlan_anti_spoof_port_id = 10705 TOKEN_NUM_INITIALIZER 10706 (struct cmd_vf_vlan_anti_spoof_result, 10707 port_id, RTE_UINT16); 10708 cmdline_parse_token_num_t cmd_vf_vlan_anti_spoof_vf_id = 10709 TOKEN_NUM_INITIALIZER 10710 (struct cmd_vf_vlan_anti_spoof_result, 10711 vf_id, RTE_UINT32); 10712 cmdline_parse_token_string_t cmd_vf_vlan_anti_spoof_on_off = 10713 TOKEN_STRING_INITIALIZER 10714 (struct cmd_vf_vlan_anti_spoof_result, 10715 on_off, "on#off"); 10716 10717 static void 10718 cmd_set_vf_vlan_anti_spoof_parsed( 10719 void *parsed_result, 10720 __rte_unused struct cmdline *cl, 10721 __rte_unused void *data) 10722 { 10723 struct cmd_vf_vlan_anti_spoof_result *res = parsed_result; 10724 int ret = -ENOTSUP; 10725 10726 __rte_unused int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0; 10727 10728 if (port_id_is_invalid(res->port_id, ENABLED_WARN)) 10729 return; 10730 10731 #ifdef RTE_NET_IXGBE 10732 if (ret == -ENOTSUP) 10733 ret = rte_pmd_ixgbe_set_vf_vlan_anti_spoof(res->port_id, 10734 res->vf_id, is_on); 10735 #endif 10736 #ifdef RTE_NET_I40E 10737 if (ret == -ENOTSUP) 10738 ret = rte_pmd_i40e_set_vf_vlan_anti_spoof(res->port_id, 10739 res->vf_id, is_on); 10740 #endif 10741 #ifdef RTE_NET_BNXT 10742 if (ret == -ENOTSUP) 10743 ret = rte_pmd_bnxt_set_vf_vlan_anti_spoof(res->port_id, 10744 res->vf_id, is_on); 10745 #endif 10746 10747 switch (ret) { 10748 case 0: 10749 break; 10750 case -EINVAL: 10751 printf("invalid vf_id %d\n", res->vf_id); 10752 break; 10753 case -ENODEV: 10754 printf("invalid port_id %d\n", res->port_id); 10755 break; 10756 case -ENOTSUP: 10757 printf("function not implemented\n"); 10758 break; 10759 default: 10760 printf("programming error: (%s)\n", strerror(-ret)); 10761 } 10762 } 10763 10764 cmdline_parse_inst_t cmd_set_vf_vlan_anti_spoof = { 10765 .f = cmd_set_vf_vlan_anti_spoof_parsed, 10766 .data = NULL, 10767 .help_str = "set vf vlan antispoof <port_id> <vf_id> on|off", 10768 .tokens = { 10769 (void *)&cmd_vf_vlan_anti_spoof_set, 10770 (void *)&cmd_vf_vlan_anti_spoof_vf, 10771 (void *)&cmd_vf_vlan_anti_spoof_vlan, 10772 (void *)&cmd_vf_vlan_anti_spoof_antispoof, 10773 (void *)&cmd_vf_vlan_anti_spoof_port_id, 10774 (void *)&cmd_vf_vlan_anti_spoof_vf_id, 10775 (void *)&cmd_vf_vlan_anti_spoof_on_off, 10776 NULL, 10777 }, 10778 }; 10779 10780 /* vf mac anti spoof configuration */ 10781 10782 /* Common result structure for vf mac anti spoof */ 10783 struct cmd_vf_mac_anti_spoof_result { 10784 cmdline_fixed_string_t set; 10785 cmdline_fixed_string_t vf; 10786 cmdline_fixed_string_t mac; 10787 cmdline_fixed_string_t antispoof; 10788 portid_t port_id; 10789 uint32_t vf_id; 10790 cmdline_fixed_string_t on_off; 10791 }; 10792 10793 /* Common CLI fields for vf mac anti spoof enable disable */ 10794 cmdline_parse_token_string_t cmd_vf_mac_anti_spoof_set = 10795 TOKEN_STRING_INITIALIZER 10796 (struct cmd_vf_mac_anti_spoof_result, 10797 set, "set"); 10798 cmdline_parse_token_string_t cmd_vf_mac_anti_spoof_vf = 10799 TOKEN_STRING_INITIALIZER 10800 (struct cmd_vf_mac_anti_spoof_result, 10801 vf, "vf"); 10802 cmdline_parse_token_string_t cmd_vf_mac_anti_spoof_mac = 10803 TOKEN_STRING_INITIALIZER 10804 (struct cmd_vf_mac_anti_spoof_result, 10805 mac, "mac"); 10806 cmdline_parse_token_string_t cmd_vf_mac_anti_spoof_antispoof = 10807 TOKEN_STRING_INITIALIZER 10808 (struct cmd_vf_mac_anti_spoof_result, 10809 antispoof, "antispoof"); 10810 cmdline_parse_token_num_t cmd_vf_mac_anti_spoof_port_id = 10811 TOKEN_NUM_INITIALIZER 10812 (struct cmd_vf_mac_anti_spoof_result, 10813 port_id, RTE_UINT16); 10814 cmdline_parse_token_num_t cmd_vf_mac_anti_spoof_vf_id = 10815 TOKEN_NUM_INITIALIZER 10816 (struct cmd_vf_mac_anti_spoof_result, 10817 vf_id, RTE_UINT32); 10818 cmdline_parse_token_string_t cmd_vf_mac_anti_spoof_on_off = 10819 TOKEN_STRING_INITIALIZER 10820 (struct cmd_vf_mac_anti_spoof_result, 10821 on_off, "on#off"); 10822 10823 static void 10824 cmd_set_vf_mac_anti_spoof_parsed( 10825 void *parsed_result, 10826 __rte_unused struct cmdline *cl, 10827 __rte_unused void *data) 10828 { 10829 struct cmd_vf_mac_anti_spoof_result *res = parsed_result; 10830 int ret = -ENOTSUP; 10831 10832 __rte_unused int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0; 10833 10834 if (port_id_is_invalid(res->port_id, ENABLED_WARN)) 10835 return; 10836 10837 #ifdef RTE_NET_IXGBE 10838 if (ret == -ENOTSUP) 10839 ret = rte_pmd_ixgbe_set_vf_mac_anti_spoof(res->port_id, 10840 res->vf_id, is_on); 10841 #endif 10842 #ifdef RTE_NET_I40E 10843 if (ret == -ENOTSUP) 10844 ret = rte_pmd_i40e_set_vf_mac_anti_spoof(res->port_id, 10845 res->vf_id, is_on); 10846 #endif 10847 #ifdef RTE_NET_BNXT 10848 if (ret == -ENOTSUP) 10849 ret = rte_pmd_bnxt_set_vf_mac_anti_spoof(res->port_id, 10850 res->vf_id, is_on); 10851 #endif 10852 10853 switch (ret) { 10854 case 0: 10855 break; 10856 case -EINVAL: 10857 printf("invalid vf_id %d or is_on %d\n", res->vf_id, is_on); 10858 break; 10859 case -ENODEV: 10860 printf("invalid port_id %d\n", res->port_id); 10861 break; 10862 case -ENOTSUP: 10863 printf("function not implemented\n"); 10864 break; 10865 default: 10866 printf("programming error: (%s)\n", strerror(-ret)); 10867 } 10868 } 10869 10870 cmdline_parse_inst_t cmd_set_vf_mac_anti_spoof = { 10871 .f = cmd_set_vf_mac_anti_spoof_parsed, 10872 .data = NULL, 10873 .help_str = "set vf mac antispoof <port_id> <vf_id> on|off", 10874 .tokens = { 10875 (void *)&cmd_vf_mac_anti_spoof_set, 10876 (void *)&cmd_vf_mac_anti_spoof_vf, 10877 (void *)&cmd_vf_mac_anti_spoof_mac, 10878 (void *)&cmd_vf_mac_anti_spoof_antispoof, 10879 (void *)&cmd_vf_mac_anti_spoof_port_id, 10880 (void *)&cmd_vf_mac_anti_spoof_vf_id, 10881 (void *)&cmd_vf_mac_anti_spoof_on_off, 10882 NULL, 10883 }, 10884 }; 10885 10886 /* vf vlan strip queue configuration */ 10887 10888 /* Common result structure for vf mac anti spoof */ 10889 struct cmd_vf_vlan_stripq_result { 10890 cmdline_fixed_string_t set; 10891 cmdline_fixed_string_t vf; 10892 cmdline_fixed_string_t vlan; 10893 cmdline_fixed_string_t stripq; 10894 portid_t port_id; 10895 uint16_t vf_id; 10896 cmdline_fixed_string_t on_off; 10897 }; 10898 10899 /* Common CLI fields for vf vlan strip enable disable */ 10900 cmdline_parse_token_string_t cmd_vf_vlan_stripq_set = 10901 TOKEN_STRING_INITIALIZER 10902 (struct cmd_vf_vlan_stripq_result, 10903 set, "set"); 10904 cmdline_parse_token_string_t cmd_vf_vlan_stripq_vf = 10905 TOKEN_STRING_INITIALIZER 10906 (struct cmd_vf_vlan_stripq_result, 10907 vf, "vf"); 10908 cmdline_parse_token_string_t cmd_vf_vlan_stripq_vlan = 10909 TOKEN_STRING_INITIALIZER 10910 (struct cmd_vf_vlan_stripq_result, 10911 vlan, "vlan"); 10912 cmdline_parse_token_string_t cmd_vf_vlan_stripq_stripq = 10913 TOKEN_STRING_INITIALIZER 10914 (struct cmd_vf_vlan_stripq_result, 10915 stripq, "stripq"); 10916 cmdline_parse_token_num_t cmd_vf_vlan_stripq_port_id = 10917 TOKEN_NUM_INITIALIZER 10918 (struct cmd_vf_vlan_stripq_result, 10919 port_id, RTE_UINT16); 10920 cmdline_parse_token_num_t cmd_vf_vlan_stripq_vf_id = 10921 TOKEN_NUM_INITIALIZER 10922 (struct cmd_vf_vlan_stripq_result, 10923 vf_id, RTE_UINT16); 10924 cmdline_parse_token_string_t cmd_vf_vlan_stripq_on_off = 10925 TOKEN_STRING_INITIALIZER 10926 (struct cmd_vf_vlan_stripq_result, 10927 on_off, "on#off"); 10928 10929 static void 10930 cmd_set_vf_vlan_stripq_parsed( 10931 void *parsed_result, 10932 __rte_unused struct cmdline *cl, 10933 __rte_unused void *data) 10934 { 10935 struct cmd_vf_vlan_stripq_result *res = parsed_result; 10936 int ret = -ENOTSUP; 10937 10938 __rte_unused int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0; 10939 10940 if (port_id_is_invalid(res->port_id, ENABLED_WARN)) 10941 return; 10942 10943 #ifdef RTE_NET_IXGBE 10944 if (ret == -ENOTSUP) 10945 ret = rte_pmd_ixgbe_set_vf_vlan_stripq(res->port_id, 10946 res->vf_id, is_on); 10947 #endif 10948 #ifdef RTE_NET_I40E 10949 if (ret == -ENOTSUP) 10950 ret = rte_pmd_i40e_set_vf_vlan_stripq(res->port_id, 10951 res->vf_id, is_on); 10952 #endif 10953 #ifdef RTE_NET_BNXT 10954 if (ret == -ENOTSUP) 10955 ret = rte_pmd_bnxt_set_vf_vlan_stripq(res->port_id, 10956 res->vf_id, is_on); 10957 #endif 10958 10959 switch (ret) { 10960 case 0: 10961 break; 10962 case -EINVAL: 10963 printf("invalid vf_id %d or is_on %d\n", res->vf_id, is_on); 10964 break; 10965 case -ENODEV: 10966 printf("invalid port_id %d\n", res->port_id); 10967 break; 10968 case -ENOTSUP: 10969 printf("function not implemented\n"); 10970 break; 10971 default: 10972 printf("programming error: (%s)\n", strerror(-ret)); 10973 } 10974 } 10975 10976 cmdline_parse_inst_t cmd_set_vf_vlan_stripq = { 10977 .f = cmd_set_vf_vlan_stripq_parsed, 10978 .data = NULL, 10979 .help_str = "set vf vlan stripq <port_id> <vf_id> on|off", 10980 .tokens = { 10981 (void *)&cmd_vf_vlan_stripq_set, 10982 (void *)&cmd_vf_vlan_stripq_vf, 10983 (void *)&cmd_vf_vlan_stripq_vlan, 10984 (void *)&cmd_vf_vlan_stripq_stripq, 10985 (void *)&cmd_vf_vlan_stripq_port_id, 10986 (void *)&cmd_vf_vlan_stripq_vf_id, 10987 (void *)&cmd_vf_vlan_stripq_on_off, 10988 NULL, 10989 }, 10990 }; 10991 10992 /* vf vlan insert configuration */ 10993 10994 /* Common result structure for vf vlan insert */ 10995 struct cmd_vf_vlan_insert_result { 10996 cmdline_fixed_string_t set; 10997 cmdline_fixed_string_t vf; 10998 cmdline_fixed_string_t vlan; 10999 cmdline_fixed_string_t insert; 11000 portid_t port_id; 11001 uint16_t vf_id; 11002 uint16_t vlan_id; 11003 }; 11004 11005 /* Common CLI fields for vf vlan insert enable disable */ 11006 cmdline_parse_token_string_t cmd_vf_vlan_insert_set = 11007 TOKEN_STRING_INITIALIZER 11008 (struct cmd_vf_vlan_insert_result, 11009 set, "set"); 11010 cmdline_parse_token_string_t cmd_vf_vlan_insert_vf = 11011 TOKEN_STRING_INITIALIZER 11012 (struct cmd_vf_vlan_insert_result, 11013 vf, "vf"); 11014 cmdline_parse_token_string_t cmd_vf_vlan_insert_vlan = 11015 TOKEN_STRING_INITIALIZER 11016 (struct cmd_vf_vlan_insert_result, 11017 vlan, "vlan"); 11018 cmdline_parse_token_string_t cmd_vf_vlan_insert_insert = 11019 TOKEN_STRING_INITIALIZER 11020 (struct cmd_vf_vlan_insert_result, 11021 insert, "insert"); 11022 cmdline_parse_token_num_t cmd_vf_vlan_insert_port_id = 11023 TOKEN_NUM_INITIALIZER 11024 (struct cmd_vf_vlan_insert_result, 11025 port_id, RTE_UINT16); 11026 cmdline_parse_token_num_t cmd_vf_vlan_insert_vf_id = 11027 TOKEN_NUM_INITIALIZER 11028 (struct cmd_vf_vlan_insert_result, 11029 vf_id, RTE_UINT16); 11030 cmdline_parse_token_num_t cmd_vf_vlan_insert_vlan_id = 11031 TOKEN_NUM_INITIALIZER 11032 (struct cmd_vf_vlan_insert_result, 11033 vlan_id, RTE_UINT16); 11034 11035 static void 11036 cmd_set_vf_vlan_insert_parsed( 11037 void *parsed_result, 11038 __rte_unused struct cmdline *cl, 11039 __rte_unused void *data) 11040 { 11041 struct cmd_vf_vlan_insert_result *res = parsed_result; 11042 int ret = -ENOTSUP; 11043 11044 if (port_id_is_invalid(res->port_id, ENABLED_WARN)) 11045 return; 11046 11047 #ifdef RTE_NET_IXGBE 11048 if (ret == -ENOTSUP) 11049 ret = rte_pmd_ixgbe_set_vf_vlan_insert(res->port_id, res->vf_id, 11050 res->vlan_id); 11051 #endif 11052 #ifdef RTE_NET_I40E 11053 if (ret == -ENOTSUP) 11054 ret = rte_pmd_i40e_set_vf_vlan_insert(res->port_id, res->vf_id, 11055 res->vlan_id); 11056 #endif 11057 #ifdef RTE_NET_BNXT 11058 if (ret == -ENOTSUP) 11059 ret = rte_pmd_bnxt_set_vf_vlan_insert(res->port_id, res->vf_id, 11060 res->vlan_id); 11061 #endif 11062 11063 switch (ret) { 11064 case 0: 11065 break; 11066 case -EINVAL: 11067 printf("invalid vf_id %d or vlan_id %d\n", res->vf_id, res->vlan_id); 11068 break; 11069 case -ENODEV: 11070 printf("invalid port_id %d\n", res->port_id); 11071 break; 11072 case -ENOTSUP: 11073 printf("function not implemented\n"); 11074 break; 11075 default: 11076 printf("programming error: (%s)\n", strerror(-ret)); 11077 } 11078 } 11079 11080 cmdline_parse_inst_t cmd_set_vf_vlan_insert = { 11081 .f = cmd_set_vf_vlan_insert_parsed, 11082 .data = NULL, 11083 .help_str = "set vf vlan insert <port_id> <vf_id> <vlan_id>", 11084 .tokens = { 11085 (void *)&cmd_vf_vlan_insert_set, 11086 (void *)&cmd_vf_vlan_insert_vf, 11087 (void *)&cmd_vf_vlan_insert_vlan, 11088 (void *)&cmd_vf_vlan_insert_insert, 11089 (void *)&cmd_vf_vlan_insert_port_id, 11090 (void *)&cmd_vf_vlan_insert_vf_id, 11091 (void *)&cmd_vf_vlan_insert_vlan_id, 11092 NULL, 11093 }, 11094 }; 11095 11096 /* tx loopback configuration */ 11097 11098 /* Common result structure for tx loopback */ 11099 struct cmd_tx_loopback_result { 11100 cmdline_fixed_string_t set; 11101 cmdline_fixed_string_t tx; 11102 cmdline_fixed_string_t loopback; 11103 portid_t port_id; 11104 cmdline_fixed_string_t on_off; 11105 }; 11106 11107 /* Common CLI fields for tx loopback enable disable */ 11108 cmdline_parse_token_string_t cmd_tx_loopback_set = 11109 TOKEN_STRING_INITIALIZER 11110 (struct cmd_tx_loopback_result, 11111 set, "set"); 11112 cmdline_parse_token_string_t cmd_tx_loopback_tx = 11113 TOKEN_STRING_INITIALIZER 11114 (struct cmd_tx_loopback_result, 11115 tx, "tx"); 11116 cmdline_parse_token_string_t cmd_tx_loopback_loopback = 11117 TOKEN_STRING_INITIALIZER 11118 (struct cmd_tx_loopback_result, 11119 loopback, "loopback"); 11120 cmdline_parse_token_num_t cmd_tx_loopback_port_id = 11121 TOKEN_NUM_INITIALIZER 11122 (struct cmd_tx_loopback_result, 11123 port_id, RTE_UINT16); 11124 cmdline_parse_token_string_t cmd_tx_loopback_on_off = 11125 TOKEN_STRING_INITIALIZER 11126 (struct cmd_tx_loopback_result, 11127 on_off, "on#off"); 11128 11129 static void 11130 cmd_set_tx_loopback_parsed( 11131 void *parsed_result, 11132 __rte_unused struct cmdline *cl, 11133 __rte_unused void *data) 11134 { 11135 struct cmd_tx_loopback_result *res = parsed_result; 11136 int ret = -ENOTSUP; 11137 11138 __rte_unused int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0; 11139 11140 if (port_id_is_invalid(res->port_id, ENABLED_WARN)) 11141 return; 11142 11143 #ifdef RTE_NET_IXGBE 11144 if (ret == -ENOTSUP) 11145 ret = rte_pmd_ixgbe_set_tx_loopback(res->port_id, is_on); 11146 #endif 11147 #ifdef RTE_NET_I40E 11148 if (ret == -ENOTSUP) 11149 ret = rte_pmd_i40e_set_tx_loopback(res->port_id, is_on); 11150 #endif 11151 #ifdef RTE_NET_BNXT 11152 if (ret == -ENOTSUP) 11153 ret = rte_pmd_bnxt_set_tx_loopback(res->port_id, is_on); 11154 #endif 11155 #if defined RTE_BUS_DPAA && defined RTE_NET_DPAA 11156 if (ret == -ENOTSUP) 11157 ret = rte_pmd_dpaa_set_tx_loopback(res->port_id, is_on); 11158 #endif 11159 11160 switch (ret) { 11161 case 0: 11162 break; 11163 case -EINVAL: 11164 printf("invalid is_on %d\n", is_on); 11165 break; 11166 case -ENODEV: 11167 printf("invalid port_id %d\n", res->port_id); 11168 break; 11169 case -ENOTSUP: 11170 printf("function not implemented\n"); 11171 break; 11172 default: 11173 printf("programming error: (%s)\n", strerror(-ret)); 11174 } 11175 } 11176 11177 cmdline_parse_inst_t cmd_set_tx_loopback = { 11178 .f = cmd_set_tx_loopback_parsed, 11179 .data = NULL, 11180 .help_str = "set tx loopback <port_id> on|off", 11181 .tokens = { 11182 (void *)&cmd_tx_loopback_set, 11183 (void *)&cmd_tx_loopback_tx, 11184 (void *)&cmd_tx_loopback_loopback, 11185 (void *)&cmd_tx_loopback_port_id, 11186 (void *)&cmd_tx_loopback_on_off, 11187 NULL, 11188 }, 11189 }; 11190 11191 /* all queues drop enable configuration */ 11192 11193 /* Common result structure for all queues drop enable */ 11194 struct cmd_all_queues_drop_en_result { 11195 cmdline_fixed_string_t set; 11196 cmdline_fixed_string_t all; 11197 cmdline_fixed_string_t queues; 11198 cmdline_fixed_string_t drop; 11199 portid_t port_id; 11200 cmdline_fixed_string_t on_off; 11201 }; 11202 11203 /* Common CLI fields for tx loopback enable disable */ 11204 cmdline_parse_token_string_t cmd_all_queues_drop_en_set = 11205 TOKEN_STRING_INITIALIZER 11206 (struct cmd_all_queues_drop_en_result, 11207 set, "set"); 11208 cmdline_parse_token_string_t cmd_all_queues_drop_en_all = 11209 TOKEN_STRING_INITIALIZER 11210 (struct cmd_all_queues_drop_en_result, 11211 all, "all"); 11212 cmdline_parse_token_string_t cmd_all_queues_drop_en_queues = 11213 TOKEN_STRING_INITIALIZER 11214 (struct cmd_all_queues_drop_en_result, 11215 queues, "queues"); 11216 cmdline_parse_token_string_t cmd_all_queues_drop_en_drop = 11217 TOKEN_STRING_INITIALIZER 11218 (struct cmd_all_queues_drop_en_result, 11219 drop, "drop"); 11220 cmdline_parse_token_num_t cmd_all_queues_drop_en_port_id = 11221 TOKEN_NUM_INITIALIZER 11222 (struct cmd_all_queues_drop_en_result, 11223 port_id, RTE_UINT16); 11224 cmdline_parse_token_string_t cmd_all_queues_drop_en_on_off = 11225 TOKEN_STRING_INITIALIZER 11226 (struct cmd_all_queues_drop_en_result, 11227 on_off, "on#off"); 11228 11229 static void 11230 cmd_set_all_queues_drop_en_parsed( 11231 void *parsed_result, 11232 __rte_unused struct cmdline *cl, 11233 __rte_unused void *data) 11234 { 11235 struct cmd_all_queues_drop_en_result *res = parsed_result; 11236 int ret = -ENOTSUP; 11237 int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0; 11238 11239 if (port_id_is_invalid(res->port_id, ENABLED_WARN)) 11240 return; 11241 11242 #ifdef RTE_NET_IXGBE 11243 if (ret == -ENOTSUP) 11244 ret = rte_pmd_ixgbe_set_all_queues_drop_en(res->port_id, is_on); 11245 #endif 11246 #ifdef RTE_NET_BNXT 11247 if (ret == -ENOTSUP) 11248 ret = rte_pmd_bnxt_set_all_queues_drop_en(res->port_id, is_on); 11249 #endif 11250 switch (ret) { 11251 case 0: 11252 break; 11253 case -EINVAL: 11254 printf("invalid is_on %d\n", is_on); 11255 break; 11256 case -ENODEV: 11257 printf("invalid port_id %d\n", res->port_id); 11258 break; 11259 case -ENOTSUP: 11260 printf("function not implemented\n"); 11261 break; 11262 default: 11263 printf("programming error: (%s)\n", strerror(-ret)); 11264 } 11265 } 11266 11267 cmdline_parse_inst_t cmd_set_all_queues_drop_en = { 11268 .f = cmd_set_all_queues_drop_en_parsed, 11269 .data = NULL, 11270 .help_str = "set all queues drop <port_id> on|off", 11271 .tokens = { 11272 (void *)&cmd_all_queues_drop_en_set, 11273 (void *)&cmd_all_queues_drop_en_all, 11274 (void *)&cmd_all_queues_drop_en_queues, 11275 (void *)&cmd_all_queues_drop_en_drop, 11276 (void *)&cmd_all_queues_drop_en_port_id, 11277 (void *)&cmd_all_queues_drop_en_on_off, 11278 NULL, 11279 }, 11280 }; 11281 11282 /* vf split drop enable configuration */ 11283 11284 /* Common result structure for vf split drop enable */ 11285 struct cmd_vf_split_drop_en_result { 11286 cmdline_fixed_string_t set; 11287 cmdline_fixed_string_t vf; 11288 cmdline_fixed_string_t split; 11289 cmdline_fixed_string_t drop; 11290 portid_t port_id; 11291 uint16_t vf_id; 11292 cmdline_fixed_string_t on_off; 11293 }; 11294 11295 /* Common CLI fields for vf split drop enable disable */ 11296 cmdline_parse_token_string_t cmd_vf_split_drop_en_set = 11297 TOKEN_STRING_INITIALIZER 11298 (struct cmd_vf_split_drop_en_result, 11299 set, "set"); 11300 cmdline_parse_token_string_t cmd_vf_split_drop_en_vf = 11301 TOKEN_STRING_INITIALIZER 11302 (struct cmd_vf_split_drop_en_result, 11303 vf, "vf"); 11304 cmdline_parse_token_string_t cmd_vf_split_drop_en_split = 11305 TOKEN_STRING_INITIALIZER 11306 (struct cmd_vf_split_drop_en_result, 11307 split, "split"); 11308 cmdline_parse_token_string_t cmd_vf_split_drop_en_drop = 11309 TOKEN_STRING_INITIALIZER 11310 (struct cmd_vf_split_drop_en_result, 11311 drop, "drop"); 11312 cmdline_parse_token_num_t cmd_vf_split_drop_en_port_id = 11313 TOKEN_NUM_INITIALIZER 11314 (struct cmd_vf_split_drop_en_result, 11315 port_id, RTE_UINT16); 11316 cmdline_parse_token_num_t cmd_vf_split_drop_en_vf_id = 11317 TOKEN_NUM_INITIALIZER 11318 (struct cmd_vf_split_drop_en_result, 11319 vf_id, RTE_UINT16); 11320 cmdline_parse_token_string_t cmd_vf_split_drop_en_on_off = 11321 TOKEN_STRING_INITIALIZER 11322 (struct cmd_vf_split_drop_en_result, 11323 on_off, "on#off"); 11324 11325 static void 11326 cmd_set_vf_split_drop_en_parsed( 11327 void *parsed_result, 11328 __rte_unused struct cmdline *cl, 11329 __rte_unused void *data) 11330 { 11331 struct cmd_vf_split_drop_en_result *res = parsed_result; 11332 int ret = -ENOTSUP; 11333 int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0; 11334 11335 if (port_id_is_invalid(res->port_id, ENABLED_WARN)) 11336 return; 11337 11338 #ifdef RTE_NET_IXGBE 11339 ret = rte_pmd_ixgbe_set_vf_split_drop_en(res->port_id, res->vf_id, 11340 is_on); 11341 #endif 11342 switch (ret) { 11343 case 0: 11344 break; 11345 case -EINVAL: 11346 printf("invalid vf_id %d or is_on %d\n", res->vf_id, is_on); 11347 break; 11348 case -ENODEV: 11349 printf("invalid port_id %d\n", res->port_id); 11350 break; 11351 case -ENOTSUP: 11352 printf("not supported on port %d\n", res->port_id); 11353 break; 11354 default: 11355 printf("programming error: (%s)\n", strerror(-ret)); 11356 } 11357 } 11358 11359 cmdline_parse_inst_t cmd_set_vf_split_drop_en = { 11360 .f = cmd_set_vf_split_drop_en_parsed, 11361 .data = NULL, 11362 .help_str = "set vf split drop <port_id> <vf_id> on|off", 11363 .tokens = { 11364 (void *)&cmd_vf_split_drop_en_set, 11365 (void *)&cmd_vf_split_drop_en_vf, 11366 (void *)&cmd_vf_split_drop_en_split, 11367 (void *)&cmd_vf_split_drop_en_drop, 11368 (void *)&cmd_vf_split_drop_en_port_id, 11369 (void *)&cmd_vf_split_drop_en_vf_id, 11370 (void *)&cmd_vf_split_drop_en_on_off, 11371 NULL, 11372 }, 11373 }; 11374 11375 /* vf mac address configuration */ 11376 11377 /* Common result structure for vf mac address */ 11378 struct cmd_set_vf_mac_addr_result { 11379 cmdline_fixed_string_t set; 11380 cmdline_fixed_string_t vf; 11381 cmdline_fixed_string_t mac; 11382 cmdline_fixed_string_t addr; 11383 portid_t port_id; 11384 uint16_t vf_id; 11385 struct rte_ether_addr mac_addr; 11386 11387 }; 11388 11389 /* Common CLI fields for vf split drop enable disable */ 11390 cmdline_parse_token_string_t cmd_set_vf_mac_addr_set = 11391 TOKEN_STRING_INITIALIZER 11392 (struct cmd_set_vf_mac_addr_result, 11393 set, "set"); 11394 cmdline_parse_token_string_t cmd_set_vf_mac_addr_vf = 11395 TOKEN_STRING_INITIALIZER 11396 (struct cmd_set_vf_mac_addr_result, 11397 vf, "vf"); 11398 cmdline_parse_token_string_t cmd_set_vf_mac_addr_mac = 11399 TOKEN_STRING_INITIALIZER 11400 (struct cmd_set_vf_mac_addr_result, 11401 mac, "mac"); 11402 cmdline_parse_token_string_t cmd_set_vf_mac_addr_addr = 11403 TOKEN_STRING_INITIALIZER 11404 (struct cmd_set_vf_mac_addr_result, 11405 addr, "addr"); 11406 cmdline_parse_token_num_t cmd_set_vf_mac_addr_port_id = 11407 TOKEN_NUM_INITIALIZER 11408 (struct cmd_set_vf_mac_addr_result, 11409 port_id, RTE_UINT16); 11410 cmdline_parse_token_num_t cmd_set_vf_mac_addr_vf_id = 11411 TOKEN_NUM_INITIALIZER 11412 (struct cmd_set_vf_mac_addr_result, 11413 vf_id, RTE_UINT16); 11414 cmdline_parse_token_etheraddr_t cmd_set_vf_mac_addr_mac_addr = 11415 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_vf_mac_addr_result, 11416 mac_addr); 11417 11418 static void 11419 cmd_set_vf_mac_addr_parsed( 11420 void *parsed_result, 11421 __rte_unused struct cmdline *cl, 11422 __rte_unused void *data) 11423 { 11424 struct cmd_set_vf_mac_addr_result *res = parsed_result; 11425 int ret = -ENOTSUP; 11426 11427 if (port_id_is_invalid(res->port_id, ENABLED_WARN)) 11428 return; 11429 11430 #ifdef RTE_NET_IXGBE 11431 if (ret == -ENOTSUP) 11432 ret = rte_pmd_ixgbe_set_vf_mac_addr(res->port_id, res->vf_id, 11433 &res->mac_addr); 11434 #endif 11435 #ifdef RTE_NET_I40E 11436 if (ret == -ENOTSUP) 11437 ret = rte_pmd_i40e_set_vf_mac_addr(res->port_id, res->vf_id, 11438 &res->mac_addr); 11439 #endif 11440 #ifdef RTE_NET_BNXT 11441 if (ret == -ENOTSUP) 11442 ret = rte_pmd_bnxt_set_vf_mac_addr(res->port_id, res->vf_id, 11443 &res->mac_addr); 11444 #endif 11445 11446 switch (ret) { 11447 case 0: 11448 break; 11449 case -EINVAL: 11450 printf("invalid vf_id %d or mac_addr\n", res->vf_id); 11451 break; 11452 case -ENODEV: 11453 printf("invalid port_id %d\n", res->port_id); 11454 break; 11455 case -ENOTSUP: 11456 printf("function not implemented\n"); 11457 break; 11458 default: 11459 printf("programming error: (%s)\n", strerror(-ret)); 11460 } 11461 } 11462 11463 cmdline_parse_inst_t cmd_set_vf_mac_addr = { 11464 .f = cmd_set_vf_mac_addr_parsed, 11465 .data = NULL, 11466 .help_str = "set vf mac addr <port_id> <vf_id> <mac_addr>", 11467 .tokens = { 11468 (void *)&cmd_set_vf_mac_addr_set, 11469 (void *)&cmd_set_vf_mac_addr_vf, 11470 (void *)&cmd_set_vf_mac_addr_mac, 11471 (void *)&cmd_set_vf_mac_addr_addr, 11472 (void *)&cmd_set_vf_mac_addr_port_id, 11473 (void *)&cmd_set_vf_mac_addr_vf_id, 11474 (void *)&cmd_set_vf_mac_addr_mac_addr, 11475 NULL, 11476 }, 11477 }; 11478 11479 /* MACsec configuration */ 11480 11481 /* Common result structure for MACsec offload enable */ 11482 struct cmd_macsec_offload_on_result { 11483 cmdline_fixed_string_t set; 11484 cmdline_fixed_string_t macsec; 11485 cmdline_fixed_string_t offload; 11486 portid_t port_id; 11487 cmdline_fixed_string_t on; 11488 cmdline_fixed_string_t encrypt; 11489 cmdline_fixed_string_t en_on_off; 11490 cmdline_fixed_string_t replay_protect; 11491 cmdline_fixed_string_t rp_on_off; 11492 }; 11493 11494 /* Common CLI fields for MACsec offload disable */ 11495 cmdline_parse_token_string_t cmd_macsec_offload_on_set = 11496 TOKEN_STRING_INITIALIZER 11497 (struct cmd_macsec_offload_on_result, 11498 set, "set"); 11499 cmdline_parse_token_string_t cmd_macsec_offload_on_macsec = 11500 TOKEN_STRING_INITIALIZER 11501 (struct cmd_macsec_offload_on_result, 11502 macsec, "macsec"); 11503 cmdline_parse_token_string_t cmd_macsec_offload_on_offload = 11504 TOKEN_STRING_INITIALIZER 11505 (struct cmd_macsec_offload_on_result, 11506 offload, "offload"); 11507 cmdline_parse_token_num_t cmd_macsec_offload_on_port_id = 11508 TOKEN_NUM_INITIALIZER 11509 (struct cmd_macsec_offload_on_result, 11510 port_id, RTE_UINT16); 11511 cmdline_parse_token_string_t cmd_macsec_offload_on_on = 11512 TOKEN_STRING_INITIALIZER 11513 (struct cmd_macsec_offload_on_result, 11514 on, "on"); 11515 cmdline_parse_token_string_t cmd_macsec_offload_on_encrypt = 11516 TOKEN_STRING_INITIALIZER 11517 (struct cmd_macsec_offload_on_result, 11518 encrypt, "encrypt"); 11519 cmdline_parse_token_string_t cmd_macsec_offload_on_en_on_off = 11520 TOKEN_STRING_INITIALIZER 11521 (struct cmd_macsec_offload_on_result, 11522 en_on_off, "on#off"); 11523 cmdline_parse_token_string_t cmd_macsec_offload_on_replay_protect = 11524 TOKEN_STRING_INITIALIZER 11525 (struct cmd_macsec_offload_on_result, 11526 replay_protect, "replay-protect"); 11527 cmdline_parse_token_string_t cmd_macsec_offload_on_rp_on_off = 11528 TOKEN_STRING_INITIALIZER 11529 (struct cmd_macsec_offload_on_result, 11530 rp_on_off, "on#off"); 11531 11532 static void 11533 cmd_set_macsec_offload_on_parsed( 11534 void *parsed_result, 11535 __rte_unused struct cmdline *cl, 11536 __rte_unused void *data) 11537 { 11538 struct cmd_macsec_offload_on_result *res = parsed_result; 11539 int ret = -ENOTSUP; 11540 portid_t port_id = res->port_id; 11541 int en = (strcmp(res->en_on_off, "on") == 0) ? 1 : 0; 11542 int rp = (strcmp(res->rp_on_off, "on") == 0) ? 1 : 0; 11543 struct rte_eth_dev_info dev_info; 11544 11545 if (port_id_is_invalid(port_id, ENABLED_WARN)) 11546 return; 11547 if (!port_is_stopped(port_id)) { 11548 printf("Please stop port %d first\n", port_id); 11549 return; 11550 } 11551 11552 ret = eth_dev_info_get_print_err(port_id, &dev_info); 11553 if (ret != 0) 11554 return; 11555 11556 if (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_MACSEC_INSERT) { 11557 #ifdef RTE_NET_IXGBE 11558 ret = rte_pmd_ixgbe_macsec_enable(port_id, en, rp); 11559 #endif 11560 } 11561 RTE_SET_USED(en); 11562 RTE_SET_USED(rp); 11563 11564 switch (ret) { 11565 case 0: 11566 ports[port_id].dev_conf.txmode.offloads |= 11567 DEV_TX_OFFLOAD_MACSEC_INSERT; 11568 cmd_reconfig_device_queue(port_id, 1, 1); 11569 break; 11570 case -ENODEV: 11571 printf("invalid port_id %d\n", port_id); 11572 break; 11573 case -ENOTSUP: 11574 printf("not supported on port %d\n", port_id); 11575 break; 11576 default: 11577 printf("programming error: (%s)\n", strerror(-ret)); 11578 } 11579 } 11580 11581 cmdline_parse_inst_t cmd_set_macsec_offload_on = { 11582 .f = cmd_set_macsec_offload_on_parsed, 11583 .data = NULL, 11584 .help_str = "set macsec offload <port_id> on " 11585 "encrypt on|off replay-protect on|off", 11586 .tokens = { 11587 (void *)&cmd_macsec_offload_on_set, 11588 (void *)&cmd_macsec_offload_on_macsec, 11589 (void *)&cmd_macsec_offload_on_offload, 11590 (void *)&cmd_macsec_offload_on_port_id, 11591 (void *)&cmd_macsec_offload_on_on, 11592 (void *)&cmd_macsec_offload_on_encrypt, 11593 (void *)&cmd_macsec_offload_on_en_on_off, 11594 (void *)&cmd_macsec_offload_on_replay_protect, 11595 (void *)&cmd_macsec_offload_on_rp_on_off, 11596 NULL, 11597 }, 11598 }; 11599 11600 /* Common result structure for MACsec offload disable */ 11601 struct cmd_macsec_offload_off_result { 11602 cmdline_fixed_string_t set; 11603 cmdline_fixed_string_t macsec; 11604 cmdline_fixed_string_t offload; 11605 portid_t port_id; 11606 cmdline_fixed_string_t off; 11607 }; 11608 11609 /* Common CLI fields for MACsec offload disable */ 11610 cmdline_parse_token_string_t cmd_macsec_offload_off_set = 11611 TOKEN_STRING_INITIALIZER 11612 (struct cmd_macsec_offload_off_result, 11613 set, "set"); 11614 cmdline_parse_token_string_t cmd_macsec_offload_off_macsec = 11615 TOKEN_STRING_INITIALIZER 11616 (struct cmd_macsec_offload_off_result, 11617 macsec, "macsec"); 11618 cmdline_parse_token_string_t cmd_macsec_offload_off_offload = 11619 TOKEN_STRING_INITIALIZER 11620 (struct cmd_macsec_offload_off_result, 11621 offload, "offload"); 11622 cmdline_parse_token_num_t cmd_macsec_offload_off_port_id = 11623 TOKEN_NUM_INITIALIZER 11624 (struct cmd_macsec_offload_off_result, 11625 port_id, RTE_UINT16); 11626 cmdline_parse_token_string_t cmd_macsec_offload_off_off = 11627 TOKEN_STRING_INITIALIZER 11628 (struct cmd_macsec_offload_off_result, 11629 off, "off"); 11630 11631 static void 11632 cmd_set_macsec_offload_off_parsed( 11633 void *parsed_result, 11634 __rte_unused struct cmdline *cl, 11635 __rte_unused void *data) 11636 { 11637 struct cmd_macsec_offload_off_result *res = parsed_result; 11638 int ret = -ENOTSUP; 11639 struct rte_eth_dev_info dev_info; 11640 portid_t port_id = res->port_id; 11641 11642 if (port_id_is_invalid(port_id, ENABLED_WARN)) 11643 return; 11644 if (!port_is_stopped(port_id)) { 11645 printf("Please stop port %d first\n", port_id); 11646 return; 11647 } 11648 11649 ret = eth_dev_info_get_print_err(port_id, &dev_info); 11650 if (ret != 0) 11651 return; 11652 11653 if (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_MACSEC_INSERT) { 11654 #ifdef RTE_NET_IXGBE 11655 ret = rte_pmd_ixgbe_macsec_disable(port_id); 11656 #endif 11657 } 11658 switch (ret) { 11659 case 0: 11660 ports[port_id].dev_conf.txmode.offloads &= 11661 ~DEV_TX_OFFLOAD_MACSEC_INSERT; 11662 cmd_reconfig_device_queue(port_id, 1, 1); 11663 break; 11664 case -ENODEV: 11665 printf("invalid port_id %d\n", port_id); 11666 break; 11667 case -ENOTSUP: 11668 printf("not supported on port %d\n", port_id); 11669 break; 11670 default: 11671 printf("programming error: (%s)\n", strerror(-ret)); 11672 } 11673 } 11674 11675 cmdline_parse_inst_t cmd_set_macsec_offload_off = { 11676 .f = cmd_set_macsec_offload_off_parsed, 11677 .data = NULL, 11678 .help_str = "set macsec offload <port_id> off", 11679 .tokens = { 11680 (void *)&cmd_macsec_offload_off_set, 11681 (void *)&cmd_macsec_offload_off_macsec, 11682 (void *)&cmd_macsec_offload_off_offload, 11683 (void *)&cmd_macsec_offload_off_port_id, 11684 (void *)&cmd_macsec_offload_off_off, 11685 NULL, 11686 }, 11687 }; 11688 11689 /* Common result structure for MACsec secure connection configure */ 11690 struct cmd_macsec_sc_result { 11691 cmdline_fixed_string_t set; 11692 cmdline_fixed_string_t macsec; 11693 cmdline_fixed_string_t sc; 11694 cmdline_fixed_string_t tx_rx; 11695 portid_t port_id; 11696 struct rte_ether_addr mac; 11697 uint16_t pi; 11698 }; 11699 11700 /* Common CLI fields for MACsec secure connection configure */ 11701 cmdline_parse_token_string_t cmd_macsec_sc_set = 11702 TOKEN_STRING_INITIALIZER 11703 (struct cmd_macsec_sc_result, 11704 set, "set"); 11705 cmdline_parse_token_string_t cmd_macsec_sc_macsec = 11706 TOKEN_STRING_INITIALIZER 11707 (struct cmd_macsec_sc_result, 11708 macsec, "macsec"); 11709 cmdline_parse_token_string_t cmd_macsec_sc_sc = 11710 TOKEN_STRING_INITIALIZER 11711 (struct cmd_macsec_sc_result, 11712 sc, "sc"); 11713 cmdline_parse_token_string_t cmd_macsec_sc_tx_rx = 11714 TOKEN_STRING_INITIALIZER 11715 (struct cmd_macsec_sc_result, 11716 tx_rx, "tx#rx"); 11717 cmdline_parse_token_num_t cmd_macsec_sc_port_id = 11718 TOKEN_NUM_INITIALIZER 11719 (struct cmd_macsec_sc_result, 11720 port_id, RTE_UINT16); 11721 cmdline_parse_token_etheraddr_t cmd_macsec_sc_mac = 11722 TOKEN_ETHERADDR_INITIALIZER 11723 (struct cmd_macsec_sc_result, 11724 mac); 11725 cmdline_parse_token_num_t cmd_macsec_sc_pi = 11726 TOKEN_NUM_INITIALIZER 11727 (struct cmd_macsec_sc_result, 11728 pi, RTE_UINT16); 11729 11730 static void 11731 cmd_set_macsec_sc_parsed( 11732 void *parsed_result, 11733 __rte_unused struct cmdline *cl, 11734 __rte_unused void *data) 11735 { 11736 struct cmd_macsec_sc_result *res = parsed_result; 11737 int ret = -ENOTSUP; 11738 int is_tx = (strcmp(res->tx_rx, "tx") == 0) ? 1 : 0; 11739 11740 #ifdef RTE_NET_IXGBE 11741 ret = is_tx ? 11742 rte_pmd_ixgbe_macsec_config_txsc(res->port_id, 11743 res->mac.addr_bytes) : 11744 rte_pmd_ixgbe_macsec_config_rxsc(res->port_id, 11745 res->mac.addr_bytes, res->pi); 11746 #endif 11747 RTE_SET_USED(is_tx); 11748 11749 switch (ret) { 11750 case 0: 11751 break; 11752 case -ENODEV: 11753 printf("invalid port_id %d\n", res->port_id); 11754 break; 11755 case -ENOTSUP: 11756 printf("not supported on port %d\n", res->port_id); 11757 break; 11758 default: 11759 printf("programming error: (%s)\n", strerror(-ret)); 11760 } 11761 } 11762 11763 cmdline_parse_inst_t cmd_set_macsec_sc = { 11764 .f = cmd_set_macsec_sc_parsed, 11765 .data = NULL, 11766 .help_str = "set macsec sc tx|rx <port_id> <mac> <pi>", 11767 .tokens = { 11768 (void *)&cmd_macsec_sc_set, 11769 (void *)&cmd_macsec_sc_macsec, 11770 (void *)&cmd_macsec_sc_sc, 11771 (void *)&cmd_macsec_sc_tx_rx, 11772 (void *)&cmd_macsec_sc_port_id, 11773 (void *)&cmd_macsec_sc_mac, 11774 (void *)&cmd_macsec_sc_pi, 11775 NULL, 11776 }, 11777 }; 11778 11779 /* Common result structure for MACsec secure connection configure */ 11780 struct cmd_macsec_sa_result { 11781 cmdline_fixed_string_t set; 11782 cmdline_fixed_string_t macsec; 11783 cmdline_fixed_string_t sa; 11784 cmdline_fixed_string_t tx_rx; 11785 portid_t port_id; 11786 uint8_t idx; 11787 uint8_t an; 11788 uint32_t pn; 11789 cmdline_fixed_string_t key; 11790 }; 11791 11792 /* Common CLI fields for MACsec secure connection configure */ 11793 cmdline_parse_token_string_t cmd_macsec_sa_set = 11794 TOKEN_STRING_INITIALIZER 11795 (struct cmd_macsec_sa_result, 11796 set, "set"); 11797 cmdline_parse_token_string_t cmd_macsec_sa_macsec = 11798 TOKEN_STRING_INITIALIZER 11799 (struct cmd_macsec_sa_result, 11800 macsec, "macsec"); 11801 cmdline_parse_token_string_t cmd_macsec_sa_sa = 11802 TOKEN_STRING_INITIALIZER 11803 (struct cmd_macsec_sa_result, 11804 sa, "sa"); 11805 cmdline_parse_token_string_t cmd_macsec_sa_tx_rx = 11806 TOKEN_STRING_INITIALIZER 11807 (struct cmd_macsec_sa_result, 11808 tx_rx, "tx#rx"); 11809 cmdline_parse_token_num_t cmd_macsec_sa_port_id = 11810 TOKEN_NUM_INITIALIZER 11811 (struct cmd_macsec_sa_result, 11812 port_id, RTE_UINT16); 11813 cmdline_parse_token_num_t cmd_macsec_sa_idx = 11814 TOKEN_NUM_INITIALIZER 11815 (struct cmd_macsec_sa_result, 11816 idx, RTE_UINT8); 11817 cmdline_parse_token_num_t cmd_macsec_sa_an = 11818 TOKEN_NUM_INITIALIZER 11819 (struct cmd_macsec_sa_result, 11820 an, RTE_UINT8); 11821 cmdline_parse_token_num_t cmd_macsec_sa_pn = 11822 TOKEN_NUM_INITIALIZER 11823 (struct cmd_macsec_sa_result, 11824 pn, RTE_UINT32); 11825 cmdline_parse_token_string_t cmd_macsec_sa_key = 11826 TOKEN_STRING_INITIALIZER 11827 (struct cmd_macsec_sa_result, 11828 key, NULL); 11829 11830 static void 11831 cmd_set_macsec_sa_parsed( 11832 void *parsed_result, 11833 __rte_unused struct cmdline *cl, 11834 __rte_unused void *data) 11835 { 11836 struct cmd_macsec_sa_result *res = parsed_result; 11837 int ret = -ENOTSUP; 11838 int is_tx = (strcmp(res->tx_rx, "tx") == 0) ? 1 : 0; 11839 uint8_t key[16] = { 0 }; 11840 uint8_t xdgt0; 11841 uint8_t xdgt1; 11842 int key_len; 11843 int i; 11844 11845 key_len = strlen(res->key) / 2; 11846 if (key_len > 16) 11847 key_len = 16; 11848 11849 for (i = 0; i < key_len; i++) { 11850 xdgt0 = parse_and_check_key_hexa_digit(res->key, (i * 2)); 11851 if (xdgt0 == 0xFF) 11852 return; 11853 xdgt1 = parse_and_check_key_hexa_digit(res->key, (i * 2) + 1); 11854 if (xdgt1 == 0xFF) 11855 return; 11856 key[i] = (uint8_t) ((xdgt0 * 16) + xdgt1); 11857 } 11858 11859 #ifdef RTE_NET_IXGBE 11860 ret = is_tx ? 11861 rte_pmd_ixgbe_macsec_select_txsa(res->port_id, 11862 res->idx, res->an, res->pn, key) : 11863 rte_pmd_ixgbe_macsec_select_rxsa(res->port_id, 11864 res->idx, res->an, res->pn, key); 11865 #endif 11866 RTE_SET_USED(is_tx); 11867 RTE_SET_USED(key); 11868 11869 switch (ret) { 11870 case 0: 11871 break; 11872 case -EINVAL: 11873 printf("invalid idx %d or an %d\n", res->idx, res->an); 11874 break; 11875 case -ENODEV: 11876 printf("invalid port_id %d\n", res->port_id); 11877 break; 11878 case -ENOTSUP: 11879 printf("not supported on port %d\n", res->port_id); 11880 break; 11881 default: 11882 printf("programming error: (%s)\n", strerror(-ret)); 11883 } 11884 } 11885 11886 cmdline_parse_inst_t cmd_set_macsec_sa = { 11887 .f = cmd_set_macsec_sa_parsed, 11888 .data = NULL, 11889 .help_str = "set macsec sa tx|rx <port_id> <idx> <an> <pn> <key>", 11890 .tokens = { 11891 (void *)&cmd_macsec_sa_set, 11892 (void *)&cmd_macsec_sa_macsec, 11893 (void *)&cmd_macsec_sa_sa, 11894 (void *)&cmd_macsec_sa_tx_rx, 11895 (void *)&cmd_macsec_sa_port_id, 11896 (void *)&cmd_macsec_sa_idx, 11897 (void *)&cmd_macsec_sa_an, 11898 (void *)&cmd_macsec_sa_pn, 11899 (void *)&cmd_macsec_sa_key, 11900 NULL, 11901 }, 11902 }; 11903 11904 /* VF unicast promiscuous mode configuration */ 11905 11906 /* Common result structure for VF unicast promiscuous mode */ 11907 struct cmd_vf_promisc_result { 11908 cmdline_fixed_string_t set; 11909 cmdline_fixed_string_t vf; 11910 cmdline_fixed_string_t promisc; 11911 portid_t port_id; 11912 uint32_t vf_id; 11913 cmdline_fixed_string_t on_off; 11914 }; 11915 11916 /* Common CLI fields for VF unicast promiscuous mode enable disable */ 11917 cmdline_parse_token_string_t cmd_vf_promisc_set = 11918 TOKEN_STRING_INITIALIZER 11919 (struct cmd_vf_promisc_result, 11920 set, "set"); 11921 cmdline_parse_token_string_t cmd_vf_promisc_vf = 11922 TOKEN_STRING_INITIALIZER 11923 (struct cmd_vf_promisc_result, 11924 vf, "vf"); 11925 cmdline_parse_token_string_t cmd_vf_promisc_promisc = 11926 TOKEN_STRING_INITIALIZER 11927 (struct cmd_vf_promisc_result, 11928 promisc, "promisc"); 11929 cmdline_parse_token_num_t cmd_vf_promisc_port_id = 11930 TOKEN_NUM_INITIALIZER 11931 (struct cmd_vf_promisc_result, 11932 port_id, RTE_UINT16); 11933 cmdline_parse_token_num_t cmd_vf_promisc_vf_id = 11934 TOKEN_NUM_INITIALIZER 11935 (struct cmd_vf_promisc_result, 11936 vf_id, RTE_UINT32); 11937 cmdline_parse_token_string_t cmd_vf_promisc_on_off = 11938 TOKEN_STRING_INITIALIZER 11939 (struct cmd_vf_promisc_result, 11940 on_off, "on#off"); 11941 11942 static void 11943 cmd_set_vf_promisc_parsed( 11944 void *parsed_result, 11945 __rte_unused struct cmdline *cl, 11946 __rte_unused void *data) 11947 { 11948 struct cmd_vf_promisc_result *res = parsed_result; 11949 int ret = -ENOTSUP; 11950 11951 __rte_unused int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0; 11952 11953 if (port_id_is_invalid(res->port_id, ENABLED_WARN)) 11954 return; 11955 11956 #ifdef RTE_NET_I40E 11957 ret = rte_pmd_i40e_set_vf_unicast_promisc(res->port_id, 11958 res->vf_id, is_on); 11959 #endif 11960 11961 switch (ret) { 11962 case 0: 11963 break; 11964 case -EINVAL: 11965 printf("invalid vf_id %d\n", res->vf_id); 11966 break; 11967 case -ENODEV: 11968 printf("invalid port_id %d\n", res->port_id); 11969 break; 11970 case -ENOTSUP: 11971 printf("function not implemented\n"); 11972 break; 11973 default: 11974 printf("programming error: (%s)\n", strerror(-ret)); 11975 } 11976 } 11977 11978 cmdline_parse_inst_t cmd_set_vf_promisc = { 11979 .f = cmd_set_vf_promisc_parsed, 11980 .data = NULL, 11981 .help_str = "set vf promisc <port_id> <vf_id> on|off: " 11982 "Set unicast promiscuous mode for a VF from the PF", 11983 .tokens = { 11984 (void *)&cmd_vf_promisc_set, 11985 (void *)&cmd_vf_promisc_vf, 11986 (void *)&cmd_vf_promisc_promisc, 11987 (void *)&cmd_vf_promisc_port_id, 11988 (void *)&cmd_vf_promisc_vf_id, 11989 (void *)&cmd_vf_promisc_on_off, 11990 NULL, 11991 }, 11992 }; 11993 11994 /* VF multicast promiscuous mode configuration */ 11995 11996 /* Common result structure for VF multicast promiscuous mode */ 11997 struct cmd_vf_allmulti_result { 11998 cmdline_fixed_string_t set; 11999 cmdline_fixed_string_t vf; 12000 cmdline_fixed_string_t allmulti; 12001 portid_t port_id; 12002 uint32_t vf_id; 12003 cmdline_fixed_string_t on_off; 12004 }; 12005 12006 /* Common CLI fields for VF multicast promiscuous mode enable disable */ 12007 cmdline_parse_token_string_t cmd_vf_allmulti_set = 12008 TOKEN_STRING_INITIALIZER 12009 (struct cmd_vf_allmulti_result, 12010 set, "set"); 12011 cmdline_parse_token_string_t cmd_vf_allmulti_vf = 12012 TOKEN_STRING_INITIALIZER 12013 (struct cmd_vf_allmulti_result, 12014 vf, "vf"); 12015 cmdline_parse_token_string_t cmd_vf_allmulti_allmulti = 12016 TOKEN_STRING_INITIALIZER 12017 (struct cmd_vf_allmulti_result, 12018 allmulti, "allmulti"); 12019 cmdline_parse_token_num_t cmd_vf_allmulti_port_id = 12020 TOKEN_NUM_INITIALIZER 12021 (struct cmd_vf_allmulti_result, 12022 port_id, RTE_UINT16); 12023 cmdline_parse_token_num_t cmd_vf_allmulti_vf_id = 12024 TOKEN_NUM_INITIALIZER 12025 (struct cmd_vf_allmulti_result, 12026 vf_id, RTE_UINT32); 12027 cmdline_parse_token_string_t cmd_vf_allmulti_on_off = 12028 TOKEN_STRING_INITIALIZER 12029 (struct cmd_vf_allmulti_result, 12030 on_off, "on#off"); 12031 12032 static void 12033 cmd_set_vf_allmulti_parsed( 12034 void *parsed_result, 12035 __rte_unused struct cmdline *cl, 12036 __rte_unused void *data) 12037 { 12038 struct cmd_vf_allmulti_result *res = parsed_result; 12039 int ret = -ENOTSUP; 12040 12041 __rte_unused int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0; 12042 12043 if (port_id_is_invalid(res->port_id, ENABLED_WARN)) 12044 return; 12045 12046 #ifdef RTE_NET_I40E 12047 ret = rte_pmd_i40e_set_vf_multicast_promisc(res->port_id, 12048 res->vf_id, is_on); 12049 #endif 12050 12051 switch (ret) { 12052 case 0: 12053 break; 12054 case -EINVAL: 12055 printf("invalid vf_id %d\n", res->vf_id); 12056 break; 12057 case -ENODEV: 12058 printf("invalid port_id %d\n", res->port_id); 12059 break; 12060 case -ENOTSUP: 12061 printf("function not implemented\n"); 12062 break; 12063 default: 12064 printf("programming error: (%s)\n", strerror(-ret)); 12065 } 12066 } 12067 12068 cmdline_parse_inst_t cmd_set_vf_allmulti = { 12069 .f = cmd_set_vf_allmulti_parsed, 12070 .data = NULL, 12071 .help_str = "set vf allmulti <port_id> <vf_id> on|off: " 12072 "Set multicast promiscuous mode for a VF from the PF", 12073 .tokens = { 12074 (void *)&cmd_vf_allmulti_set, 12075 (void *)&cmd_vf_allmulti_vf, 12076 (void *)&cmd_vf_allmulti_allmulti, 12077 (void *)&cmd_vf_allmulti_port_id, 12078 (void *)&cmd_vf_allmulti_vf_id, 12079 (void *)&cmd_vf_allmulti_on_off, 12080 NULL, 12081 }, 12082 }; 12083 12084 /* vf broadcast mode configuration */ 12085 12086 /* Common result structure for vf broadcast */ 12087 struct cmd_set_vf_broadcast_result { 12088 cmdline_fixed_string_t set; 12089 cmdline_fixed_string_t vf; 12090 cmdline_fixed_string_t broadcast; 12091 portid_t port_id; 12092 uint16_t vf_id; 12093 cmdline_fixed_string_t on_off; 12094 }; 12095 12096 /* Common CLI fields for vf broadcast enable disable */ 12097 cmdline_parse_token_string_t cmd_set_vf_broadcast_set = 12098 TOKEN_STRING_INITIALIZER 12099 (struct cmd_set_vf_broadcast_result, 12100 set, "set"); 12101 cmdline_parse_token_string_t cmd_set_vf_broadcast_vf = 12102 TOKEN_STRING_INITIALIZER 12103 (struct cmd_set_vf_broadcast_result, 12104 vf, "vf"); 12105 cmdline_parse_token_string_t cmd_set_vf_broadcast_broadcast = 12106 TOKEN_STRING_INITIALIZER 12107 (struct cmd_set_vf_broadcast_result, 12108 broadcast, "broadcast"); 12109 cmdline_parse_token_num_t cmd_set_vf_broadcast_port_id = 12110 TOKEN_NUM_INITIALIZER 12111 (struct cmd_set_vf_broadcast_result, 12112 port_id, RTE_UINT16); 12113 cmdline_parse_token_num_t cmd_set_vf_broadcast_vf_id = 12114 TOKEN_NUM_INITIALIZER 12115 (struct cmd_set_vf_broadcast_result, 12116 vf_id, RTE_UINT16); 12117 cmdline_parse_token_string_t cmd_set_vf_broadcast_on_off = 12118 TOKEN_STRING_INITIALIZER 12119 (struct cmd_set_vf_broadcast_result, 12120 on_off, "on#off"); 12121 12122 static void 12123 cmd_set_vf_broadcast_parsed( 12124 void *parsed_result, 12125 __rte_unused struct cmdline *cl, 12126 __rte_unused void *data) 12127 { 12128 struct cmd_set_vf_broadcast_result *res = parsed_result; 12129 int ret = -ENOTSUP; 12130 12131 __rte_unused int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0; 12132 12133 if (port_id_is_invalid(res->port_id, ENABLED_WARN)) 12134 return; 12135 12136 #ifdef RTE_NET_I40E 12137 ret = rte_pmd_i40e_set_vf_broadcast(res->port_id, 12138 res->vf_id, is_on); 12139 #endif 12140 12141 switch (ret) { 12142 case 0: 12143 break; 12144 case -EINVAL: 12145 printf("invalid vf_id %d or is_on %d\n", res->vf_id, is_on); 12146 break; 12147 case -ENODEV: 12148 printf("invalid port_id %d\n", res->port_id); 12149 break; 12150 case -ENOTSUP: 12151 printf("function not implemented\n"); 12152 break; 12153 default: 12154 printf("programming error: (%s)\n", strerror(-ret)); 12155 } 12156 } 12157 12158 cmdline_parse_inst_t cmd_set_vf_broadcast = { 12159 .f = cmd_set_vf_broadcast_parsed, 12160 .data = NULL, 12161 .help_str = "set vf broadcast <port_id> <vf_id> on|off", 12162 .tokens = { 12163 (void *)&cmd_set_vf_broadcast_set, 12164 (void *)&cmd_set_vf_broadcast_vf, 12165 (void *)&cmd_set_vf_broadcast_broadcast, 12166 (void *)&cmd_set_vf_broadcast_port_id, 12167 (void *)&cmd_set_vf_broadcast_vf_id, 12168 (void *)&cmd_set_vf_broadcast_on_off, 12169 NULL, 12170 }, 12171 }; 12172 12173 /* vf vlan tag configuration */ 12174 12175 /* Common result structure for vf vlan tag */ 12176 struct cmd_set_vf_vlan_tag_result { 12177 cmdline_fixed_string_t set; 12178 cmdline_fixed_string_t vf; 12179 cmdline_fixed_string_t vlan; 12180 cmdline_fixed_string_t tag; 12181 portid_t port_id; 12182 uint16_t vf_id; 12183 cmdline_fixed_string_t on_off; 12184 }; 12185 12186 /* Common CLI fields for vf vlan tag enable disable */ 12187 cmdline_parse_token_string_t cmd_set_vf_vlan_tag_set = 12188 TOKEN_STRING_INITIALIZER 12189 (struct cmd_set_vf_vlan_tag_result, 12190 set, "set"); 12191 cmdline_parse_token_string_t cmd_set_vf_vlan_tag_vf = 12192 TOKEN_STRING_INITIALIZER 12193 (struct cmd_set_vf_vlan_tag_result, 12194 vf, "vf"); 12195 cmdline_parse_token_string_t cmd_set_vf_vlan_tag_vlan = 12196 TOKEN_STRING_INITIALIZER 12197 (struct cmd_set_vf_vlan_tag_result, 12198 vlan, "vlan"); 12199 cmdline_parse_token_string_t cmd_set_vf_vlan_tag_tag = 12200 TOKEN_STRING_INITIALIZER 12201 (struct cmd_set_vf_vlan_tag_result, 12202 tag, "tag"); 12203 cmdline_parse_token_num_t cmd_set_vf_vlan_tag_port_id = 12204 TOKEN_NUM_INITIALIZER 12205 (struct cmd_set_vf_vlan_tag_result, 12206 port_id, RTE_UINT16); 12207 cmdline_parse_token_num_t cmd_set_vf_vlan_tag_vf_id = 12208 TOKEN_NUM_INITIALIZER 12209 (struct cmd_set_vf_vlan_tag_result, 12210 vf_id, RTE_UINT16); 12211 cmdline_parse_token_string_t cmd_set_vf_vlan_tag_on_off = 12212 TOKEN_STRING_INITIALIZER 12213 (struct cmd_set_vf_vlan_tag_result, 12214 on_off, "on#off"); 12215 12216 static void 12217 cmd_set_vf_vlan_tag_parsed( 12218 void *parsed_result, 12219 __rte_unused struct cmdline *cl, 12220 __rte_unused void *data) 12221 { 12222 struct cmd_set_vf_vlan_tag_result *res = parsed_result; 12223 int ret = -ENOTSUP; 12224 12225 __rte_unused int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0; 12226 12227 if (port_id_is_invalid(res->port_id, ENABLED_WARN)) 12228 return; 12229 12230 #ifdef RTE_NET_I40E 12231 ret = rte_pmd_i40e_set_vf_vlan_tag(res->port_id, 12232 res->vf_id, is_on); 12233 #endif 12234 12235 switch (ret) { 12236 case 0: 12237 break; 12238 case -EINVAL: 12239 printf("invalid vf_id %d or is_on %d\n", res->vf_id, is_on); 12240 break; 12241 case -ENODEV: 12242 printf("invalid port_id %d\n", res->port_id); 12243 break; 12244 case -ENOTSUP: 12245 printf("function not implemented\n"); 12246 break; 12247 default: 12248 printf("programming error: (%s)\n", strerror(-ret)); 12249 } 12250 } 12251 12252 cmdline_parse_inst_t cmd_set_vf_vlan_tag = { 12253 .f = cmd_set_vf_vlan_tag_parsed, 12254 .data = NULL, 12255 .help_str = "set vf vlan tag <port_id> <vf_id> on|off", 12256 .tokens = { 12257 (void *)&cmd_set_vf_vlan_tag_set, 12258 (void *)&cmd_set_vf_vlan_tag_vf, 12259 (void *)&cmd_set_vf_vlan_tag_vlan, 12260 (void *)&cmd_set_vf_vlan_tag_tag, 12261 (void *)&cmd_set_vf_vlan_tag_port_id, 12262 (void *)&cmd_set_vf_vlan_tag_vf_id, 12263 (void *)&cmd_set_vf_vlan_tag_on_off, 12264 NULL, 12265 }, 12266 }; 12267 12268 /* Common definition of VF and TC TX bandwidth configuration */ 12269 struct cmd_vf_tc_bw_result { 12270 cmdline_fixed_string_t set; 12271 cmdline_fixed_string_t vf; 12272 cmdline_fixed_string_t tc; 12273 cmdline_fixed_string_t tx; 12274 cmdline_fixed_string_t min_bw; 12275 cmdline_fixed_string_t max_bw; 12276 cmdline_fixed_string_t strict_link_prio; 12277 portid_t port_id; 12278 uint16_t vf_id; 12279 uint8_t tc_no; 12280 uint32_t bw; 12281 cmdline_fixed_string_t bw_list; 12282 uint8_t tc_map; 12283 }; 12284 12285 cmdline_parse_token_string_t cmd_vf_tc_bw_set = 12286 TOKEN_STRING_INITIALIZER 12287 (struct cmd_vf_tc_bw_result, 12288 set, "set"); 12289 cmdline_parse_token_string_t cmd_vf_tc_bw_vf = 12290 TOKEN_STRING_INITIALIZER 12291 (struct cmd_vf_tc_bw_result, 12292 vf, "vf"); 12293 cmdline_parse_token_string_t cmd_vf_tc_bw_tc = 12294 TOKEN_STRING_INITIALIZER 12295 (struct cmd_vf_tc_bw_result, 12296 tc, "tc"); 12297 cmdline_parse_token_string_t cmd_vf_tc_bw_tx = 12298 TOKEN_STRING_INITIALIZER 12299 (struct cmd_vf_tc_bw_result, 12300 tx, "tx"); 12301 cmdline_parse_token_string_t cmd_vf_tc_bw_strict_link_prio = 12302 TOKEN_STRING_INITIALIZER 12303 (struct cmd_vf_tc_bw_result, 12304 strict_link_prio, "strict-link-priority"); 12305 cmdline_parse_token_string_t cmd_vf_tc_bw_min_bw = 12306 TOKEN_STRING_INITIALIZER 12307 (struct cmd_vf_tc_bw_result, 12308 min_bw, "min-bandwidth"); 12309 cmdline_parse_token_string_t cmd_vf_tc_bw_max_bw = 12310 TOKEN_STRING_INITIALIZER 12311 (struct cmd_vf_tc_bw_result, 12312 max_bw, "max-bandwidth"); 12313 cmdline_parse_token_num_t cmd_vf_tc_bw_port_id = 12314 TOKEN_NUM_INITIALIZER 12315 (struct cmd_vf_tc_bw_result, 12316 port_id, RTE_UINT16); 12317 cmdline_parse_token_num_t cmd_vf_tc_bw_vf_id = 12318 TOKEN_NUM_INITIALIZER 12319 (struct cmd_vf_tc_bw_result, 12320 vf_id, RTE_UINT16); 12321 cmdline_parse_token_num_t cmd_vf_tc_bw_tc_no = 12322 TOKEN_NUM_INITIALIZER 12323 (struct cmd_vf_tc_bw_result, 12324 tc_no, RTE_UINT8); 12325 cmdline_parse_token_num_t cmd_vf_tc_bw_bw = 12326 TOKEN_NUM_INITIALIZER 12327 (struct cmd_vf_tc_bw_result, 12328 bw, RTE_UINT32); 12329 cmdline_parse_token_string_t cmd_vf_tc_bw_bw_list = 12330 TOKEN_STRING_INITIALIZER 12331 (struct cmd_vf_tc_bw_result, 12332 bw_list, NULL); 12333 cmdline_parse_token_num_t cmd_vf_tc_bw_tc_map = 12334 TOKEN_NUM_INITIALIZER 12335 (struct cmd_vf_tc_bw_result, 12336 tc_map, RTE_UINT8); 12337 12338 /* VF max bandwidth setting */ 12339 static void 12340 cmd_vf_max_bw_parsed( 12341 void *parsed_result, 12342 __rte_unused struct cmdline *cl, 12343 __rte_unused void *data) 12344 { 12345 struct cmd_vf_tc_bw_result *res = parsed_result; 12346 int ret = -ENOTSUP; 12347 12348 if (port_id_is_invalid(res->port_id, ENABLED_WARN)) 12349 return; 12350 12351 #ifdef RTE_NET_I40E 12352 ret = rte_pmd_i40e_set_vf_max_bw(res->port_id, 12353 res->vf_id, res->bw); 12354 #endif 12355 12356 switch (ret) { 12357 case 0: 12358 break; 12359 case -EINVAL: 12360 printf("invalid vf_id %d or bandwidth %d\n", 12361 res->vf_id, res->bw); 12362 break; 12363 case -ENODEV: 12364 printf("invalid port_id %d\n", res->port_id); 12365 break; 12366 case -ENOTSUP: 12367 printf("function not implemented\n"); 12368 break; 12369 default: 12370 printf("programming error: (%s)\n", strerror(-ret)); 12371 } 12372 } 12373 12374 cmdline_parse_inst_t cmd_vf_max_bw = { 12375 .f = cmd_vf_max_bw_parsed, 12376 .data = NULL, 12377 .help_str = "set vf tx max-bandwidth <port_id> <vf_id> <bandwidth>", 12378 .tokens = { 12379 (void *)&cmd_vf_tc_bw_set, 12380 (void *)&cmd_vf_tc_bw_vf, 12381 (void *)&cmd_vf_tc_bw_tx, 12382 (void *)&cmd_vf_tc_bw_max_bw, 12383 (void *)&cmd_vf_tc_bw_port_id, 12384 (void *)&cmd_vf_tc_bw_vf_id, 12385 (void *)&cmd_vf_tc_bw_bw, 12386 NULL, 12387 }, 12388 }; 12389 12390 static int 12391 vf_tc_min_bw_parse_bw_list(uint8_t *bw_list, 12392 uint8_t *tc_num, 12393 char *str) 12394 { 12395 uint32_t size; 12396 const char *p, *p0 = str; 12397 char s[256]; 12398 char *end; 12399 char *str_fld[16]; 12400 uint16_t i; 12401 int ret; 12402 12403 p = strchr(p0, '('); 12404 if (p == NULL) { 12405 printf("The bandwidth-list should be '(bw1, bw2, ...)'\n"); 12406 return -1; 12407 } 12408 p++; 12409 p0 = strchr(p, ')'); 12410 if (p0 == NULL) { 12411 printf("The bandwidth-list should be '(bw1, bw2, ...)'\n"); 12412 return -1; 12413 } 12414 size = p0 - p; 12415 if (size >= sizeof(s)) { 12416 printf("The string size exceeds the internal buffer size\n"); 12417 return -1; 12418 } 12419 snprintf(s, sizeof(s), "%.*s", size, p); 12420 ret = rte_strsplit(s, sizeof(s), str_fld, 16, ','); 12421 if (ret <= 0) { 12422 printf("Failed to get the bandwidth list. "); 12423 return -1; 12424 } 12425 *tc_num = ret; 12426 for (i = 0; i < ret; i++) 12427 bw_list[i] = (uint8_t)strtoul(str_fld[i], &end, 0); 12428 12429 return 0; 12430 } 12431 12432 /* TC min bandwidth setting */ 12433 static void 12434 cmd_vf_tc_min_bw_parsed( 12435 void *parsed_result, 12436 __rte_unused struct cmdline *cl, 12437 __rte_unused void *data) 12438 { 12439 struct cmd_vf_tc_bw_result *res = parsed_result; 12440 uint8_t tc_num; 12441 uint8_t bw[16]; 12442 int ret = -ENOTSUP; 12443 12444 if (port_id_is_invalid(res->port_id, ENABLED_WARN)) 12445 return; 12446 12447 ret = vf_tc_min_bw_parse_bw_list(bw, &tc_num, res->bw_list); 12448 if (ret) 12449 return; 12450 12451 #ifdef RTE_NET_I40E 12452 ret = rte_pmd_i40e_set_vf_tc_bw_alloc(res->port_id, res->vf_id, 12453 tc_num, bw); 12454 #endif 12455 12456 switch (ret) { 12457 case 0: 12458 break; 12459 case -EINVAL: 12460 printf("invalid vf_id %d or bandwidth\n", res->vf_id); 12461 break; 12462 case -ENODEV: 12463 printf("invalid port_id %d\n", res->port_id); 12464 break; 12465 case -ENOTSUP: 12466 printf("function not implemented\n"); 12467 break; 12468 default: 12469 printf("programming error: (%s)\n", strerror(-ret)); 12470 } 12471 } 12472 12473 cmdline_parse_inst_t cmd_vf_tc_min_bw = { 12474 .f = cmd_vf_tc_min_bw_parsed, 12475 .data = NULL, 12476 .help_str = "set vf tc tx min-bandwidth <port_id> <vf_id>" 12477 " <bw1, bw2, ...>", 12478 .tokens = { 12479 (void *)&cmd_vf_tc_bw_set, 12480 (void *)&cmd_vf_tc_bw_vf, 12481 (void *)&cmd_vf_tc_bw_tc, 12482 (void *)&cmd_vf_tc_bw_tx, 12483 (void *)&cmd_vf_tc_bw_min_bw, 12484 (void *)&cmd_vf_tc_bw_port_id, 12485 (void *)&cmd_vf_tc_bw_vf_id, 12486 (void *)&cmd_vf_tc_bw_bw_list, 12487 NULL, 12488 }, 12489 }; 12490 12491 static void 12492 cmd_tc_min_bw_parsed( 12493 void *parsed_result, 12494 __rte_unused struct cmdline *cl, 12495 __rte_unused void *data) 12496 { 12497 struct cmd_vf_tc_bw_result *res = parsed_result; 12498 struct rte_port *port; 12499 uint8_t tc_num; 12500 uint8_t bw[16]; 12501 int ret = -ENOTSUP; 12502 12503 if (port_id_is_invalid(res->port_id, ENABLED_WARN)) 12504 return; 12505 12506 port = &ports[res->port_id]; 12507 /** Check if the port is not started **/ 12508 if (port->port_status != RTE_PORT_STOPPED) { 12509 printf("Please stop port %d first\n", res->port_id); 12510 return; 12511 } 12512 12513 ret = vf_tc_min_bw_parse_bw_list(bw, &tc_num, res->bw_list); 12514 if (ret) 12515 return; 12516 12517 #ifdef RTE_NET_IXGBE 12518 ret = rte_pmd_ixgbe_set_tc_bw_alloc(res->port_id, tc_num, bw); 12519 #endif 12520 12521 switch (ret) { 12522 case 0: 12523 break; 12524 case -EINVAL: 12525 printf("invalid bandwidth\n"); 12526 break; 12527 case -ENODEV: 12528 printf("invalid port_id %d\n", res->port_id); 12529 break; 12530 case -ENOTSUP: 12531 printf("function not implemented\n"); 12532 break; 12533 default: 12534 printf("programming error: (%s)\n", strerror(-ret)); 12535 } 12536 } 12537 12538 cmdline_parse_inst_t cmd_tc_min_bw = { 12539 .f = cmd_tc_min_bw_parsed, 12540 .data = NULL, 12541 .help_str = "set tc tx min-bandwidth <port_id> <bw1, bw2, ...>", 12542 .tokens = { 12543 (void *)&cmd_vf_tc_bw_set, 12544 (void *)&cmd_vf_tc_bw_tc, 12545 (void *)&cmd_vf_tc_bw_tx, 12546 (void *)&cmd_vf_tc_bw_min_bw, 12547 (void *)&cmd_vf_tc_bw_port_id, 12548 (void *)&cmd_vf_tc_bw_bw_list, 12549 NULL, 12550 }, 12551 }; 12552 12553 /* TC max bandwidth setting */ 12554 static void 12555 cmd_vf_tc_max_bw_parsed( 12556 void *parsed_result, 12557 __rte_unused struct cmdline *cl, 12558 __rte_unused void *data) 12559 { 12560 struct cmd_vf_tc_bw_result *res = parsed_result; 12561 int ret = -ENOTSUP; 12562 12563 if (port_id_is_invalid(res->port_id, ENABLED_WARN)) 12564 return; 12565 12566 #ifdef RTE_NET_I40E 12567 ret = rte_pmd_i40e_set_vf_tc_max_bw(res->port_id, res->vf_id, 12568 res->tc_no, res->bw); 12569 #endif 12570 12571 switch (ret) { 12572 case 0: 12573 break; 12574 case -EINVAL: 12575 printf("invalid vf_id %d, tc_no %d or bandwidth %d\n", 12576 res->vf_id, res->tc_no, res->bw); 12577 break; 12578 case -ENODEV: 12579 printf("invalid port_id %d\n", res->port_id); 12580 break; 12581 case -ENOTSUP: 12582 printf("function not implemented\n"); 12583 break; 12584 default: 12585 printf("programming error: (%s)\n", strerror(-ret)); 12586 } 12587 } 12588 12589 cmdline_parse_inst_t cmd_vf_tc_max_bw = { 12590 .f = cmd_vf_tc_max_bw_parsed, 12591 .data = NULL, 12592 .help_str = "set vf tc tx max-bandwidth <port_id> <vf_id> <tc_no>" 12593 " <bandwidth>", 12594 .tokens = { 12595 (void *)&cmd_vf_tc_bw_set, 12596 (void *)&cmd_vf_tc_bw_vf, 12597 (void *)&cmd_vf_tc_bw_tc, 12598 (void *)&cmd_vf_tc_bw_tx, 12599 (void *)&cmd_vf_tc_bw_max_bw, 12600 (void *)&cmd_vf_tc_bw_port_id, 12601 (void *)&cmd_vf_tc_bw_vf_id, 12602 (void *)&cmd_vf_tc_bw_tc_no, 12603 (void *)&cmd_vf_tc_bw_bw, 12604 NULL, 12605 }, 12606 }; 12607 12608 /** Set VXLAN encapsulation details */ 12609 struct cmd_set_vxlan_result { 12610 cmdline_fixed_string_t set; 12611 cmdline_fixed_string_t vxlan; 12612 cmdline_fixed_string_t pos_token; 12613 cmdline_fixed_string_t ip_version; 12614 uint32_t vlan_present:1; 12615 uint32_t vni; 12616 uint16_t udp_src; 12617 uint16_t udp_dst; 12618 cmdline_ipaddr_t ip_src; 12619 cmdline_ipaddr_t ip_dst; 12620 uint16_t tci; 12621 uint8_t tos; 12622 uint8_t ttl; 12623 struct rte_ether_addr eth_src; 12624 struct rte_ether_addr eth_dst; 12625 }; 12626 12627 cmdline_parse_token_string_t cmd_set_vxlan_set = 12628 TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, set, "set"); 12629 cmdline_parse_token_string_t cmd_set_vxlan_vxlan = 12630 TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, vxlan, "vxlan"); 12631 cmdline_parse_token_string_t cmd_set_vxlan_vxlan_tos_ttl = 12632 TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, vxlan, 12633 "vxlan-tos-ttl"); 12634 cmdline_parse_token_string_t cmd_set_vxlan_vxlan_with_vlan = 12635 TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, vxlan, 12636 "vxlan-with-vlan"); 12637 cmdline_parse_token_string_t cmd_set_vxlan_ip_version = 12638 TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, pos_token, 12639 "ip-version"); 12640 cmdline_parse_token_string_t cmd_set_vxlan_ip_version_value = 12641 TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, ip_version, 12642 "ipv4#ipv6"); 12643 cmdline_parse_token_string_t cmd_set_vxlan_vni = 12644 TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, pos_token, 12645 "vni"); 12646 cmdline_parse_token_num_t cmd_set_vxlan_vni_value = 12647 TOKEN_NUM_INITIALIZER(struct cmd_set_vxlan_result, vni, RTE_UINT32); 12648 cmdline_parse_token_string_t cmd_set_vxlan_udp_src = 12649 TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, pos_token, 12650 "udp-src"); 12651 cmdline_parse_token_num_t cmd_set_vxlan_udp_src_value = 12652 TOKEN_NUM_INITIALIZER(struct cmd_set_vxlan_result, udp_src, RTE_UINT16); 12653 cmdline_parse_token_string_t cmd_set_vxlan_udp_dst = 12654 TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, pos_token, 12655 "udp-dst"); 12656 cmdline_parse_token_num_t cmd_set_vxlan_udp_dst_value = 12657 TOKEN_NUM_INITIALIZER(struct cmd_set_vxlan_result, udp_dst, RTE_UINT16); 12658 cmdline_parse_token_string_t cmd_set_vxlan_ip_tos = 12659 TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, pos_token, 12660 "ip-tos"); 12661 cmdline_parse_token_num_t cmd_set_vxlan_ip_tos_value = 12662 TOKEN_NUM_INITIALIZER(struct cmd_set_vxlan_result, tos, RTE_UINT8); 12663 cmdline_parse_token_string_t cmd_set_vxlan_ip_ttl = 12664 TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, pos_token, 12665 "ip-ttl"); 12666 cmdline_parse_token_num_t cmd_set_vxlan_ip_ttl_value = 12667 TOKEN_NUM_INITIALIZER(struct cmd_set_vxlan_result, ttl, RTE_UINT8); 12668 cmdline_parse_token_string_t cmd_set_vxlan_ip_src = 12669 TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, pos_token, 12670 "ip-src"); 12671 cmdline_parse_token_ipaddr_t cmd_set_vxlan_ip_src_value = 12672 TOKEN_IPADDR_INITIALIZER(struct cmd_set_vxlan_result, ip_src); 12673 cmdline_parse_token_string_t cmd_set_vxlan_ip_dst = 12674 TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, pos_token, 12675 "ip-dst"); 12676 cmdline_parse_token_ipaddr_t cmd_set_vxlan_ip_dst_value = 12677 TOKEN_IPADDR_INITIALIZER(struct cmd_set_vxlan_result, ip_dst); 12678 cmdline_parse_token_string_t cmd_set_vxlan_vlan = 12679 TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, pos_token, 12680 "vlan-tci"); 12681 cmdline_parse_token_num_t cmd_set_vxlan_vlan_value = 12682 TOKEN_NUM_INITIALIZER(struct cmd_set_vxlan_result, tci, RTE_UINT16); 12683 cmdline_parse_token_string_t cmd_set_vxlan_eth_src = 12684 TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, pos_token, 12685 "eth-src"); 12686 cmdline_parse_token_etheraddr_t cmd_set_vxlan_eth_src_value = 12687 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_vxlan_result, eth_src); 12688 cmdline_parse_token_string_t cmd_set_vxlan_eth_dst = 12689 TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, pos_token, 12690 "eth-dst"); 12691 cmdline_parse_token_etheraddr_t cmd_set_vxlan_eth_dst_value = 12692 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_vxlan_result, eth_dst); 12693 12694 static void cmd_set_vxlan_parsed(void *parsed_result, 12695 __rte_unused struct cmdline *cl, 12696 __rte_unused void *data) 12697 { 12698 struct cmd_set_vxlan_result *res = parsed_result; 12699 union { 12700 uint32_t vxlan_id; 12701 uint8_t vni[4]; 12702 } id = { 12703 .vxlan_id = rte_cpu_to_be_32(res->vni) & RTE_BE32(0x00ffffff), 12704 }; 12705 12706 vxlan_encap_conf.select_tos_ttl = 0; 12707 if (strcmp(res->vxlan, "vxlan") == 0) 12708 vxlan_encap_conf.select_vlan = 0; 12709 else if (strcmp(res->vxlan, "vxlan-with-vlan") == 0) 12710 vxlan_encap_conf.select_vlan = 1; 12711 else if (strcmp(res->vxlan, "vxlan-tos-ttl") == 0) { 12712 vxlan_encap_conf.select_vlan = 0; 12713 vxlan_encap_conf.select_tos_ttl = 1; 12714 } 12715 if (strcmp(res->ip_version, "ipv4") == 0) 12716 vxlan_encap_conf.select_ipv4 = 1; 12717 else if (strcmp(res->ip_version, "ipv6") == 0) 12718 vxlan_encap_conf.select_ipv4 = 0; 12719 else 12720 return; 12721 rte_memcpy(vxlan_encap_conf.vni, &id.vni[1], 3); 12722 vxlan_encap_conf.udp_src = rte_cpu_to_be_16(res->udp_src); 12723 vxlan_encap_conf.udp_dst = rte_cpu_to_be_16(res->udp_dst); 12724 vxlan_encap_conf.ip_tos = res->tos; 12725 vxlan_encap_conf.ip_ttl = res->ttl; 12726 if (vxlan_encap_conf.select_ipv4) { 12727 IPV4_ADDR_TO_UINT(res->ip_src, vxlan_encap_conf.ipv4_src); 12728 IPV4_ADDR_TO_UINT(res->ip_dst, vxlan_encap_conf.ipv4_dst); 12729 } else { 12730 IPV6_ADDR_TO_ARRAY(res->ip_src, vxlan_encap_conf.ipv6_src); 12731 IPV6_ADDR_TO_ARRAY(res->ip_dst, vxlan_encap_conf.ipv6_dst); 12732 } 12733 if (vxlan_encap_conf.select_vlan) 12734 vxlan_encap_conf.vlan_tci = rte_cpu_to_be_16(res->tci); 12735 rte_memcpy(vxlan_encap_conf.eth_src, res->eth_src.addr_bytes, 12736 RTE_ETHER_ADDR_LEN); 12737 rte_memcpy(vxlan_encap_conf.eth_dst, res->eth_dst.addr_bytes, 12738 RTE_ETHER_ADDR_LEN); 12739 } 12740 12741 cmdline_parse_inst_t cmd_set_vxlan = { 12742 .f = cmd_set_vxlan_parsed, 12743 .data = NULL, 12744 .help_str = "set vxlan ip-version ipv4|ipv6 vni <vni> udp-src" 12745 " <udp-src> udp-dst <udp-dst> ip-src <ip-src> ip-dst <ip-dst>" 12746 " eth-src <eth-src> eth-dst <eth-dst>", 12747 .tokens = { 12748 (void *)&cmd_set_vxlan_set, 12749 (void *)&cmd_set_vxlan_vxlan, 12750 (void *)&cmd_set_vxlan_ip_version, 12751 (void *)&cmd_set_vxlan_ip_version_value, 12752 (void *)&cmd_set_vxlan_vni, 12753 (void *)&cmd_set_vxlan_vni_value, 12754 (void *)&cmd_set_vxlan_udp_src, 12755 (void *)&cmd_set_vxlan_udp_src_value, 12756 (void *)&cmd_set_vxlan_udp_dst, 12757 (void *)&cmd_set_vxlan_udp_dst_value, 12758 (void *)&cmd_set_vxlan_ip_src, 12759 (void *)&cmd_set_vxlan_ip_src_value, 12760 (void *)&cmd_set_vxlan_ip_dst, 12761 (void *)&cmd_set_vxlan_ip_dst_value, 12762 (void *)&cmd_set_vxlan_eth_src, 12763 (void *)&cmd_set_vxlan_eth_src_value, 12764 (void *)&cmd_set_vxlan_eth_dst, 12765 (void *)&cmd_set_vxlan_eth_dst_value, 12766 NULL, 12767 }, 12768 }; 12769 12770 cmdline_parse_inst_t cmd_set_vxlan_tos_ttl = { 12771 .f = cmd_set_vxlan_parsed, 12772 .data = NULL, 12773 .help_str = "set vxlan-tos-ttl ip-version ipv4|ipv6 vni <vni> udp-src" 12774 " <udp-src> udp-dst <udp-dst> ip-tos <ip-tos> ip-ttl <ip-ttl>" 12775 " ip-src <ip-src> ip-dst <ip-dst> eth-src <eth-src>" 12776 " eth-dst <eth-dst>", 12777 .tokens = { 12778 (void *)&cmd_set_vxlan_set, 12779 (void *)&cmd_set_vxlan_vxlan_tos_ttl, 12780 (void *)&cmd_set_vxlan_ip_version, 12781 (void *)&cmd_set_vxlan_ip_version_value, 12782 (void *)&cmd_set_vxlan_vni, 12783 (void *)&cmd_set_vxlan_vni_value, 12784 (void *)&cmd_set_vxlan_udp_src, 12785 (void *)&cmd_set_vxlan_udp_src_value, 12786 (void *)&cmd_set_vxlan_udp_dst, 12787 (void *)&cmd_set_vxlan_udp_dst_value, 12788 (void *)&cmd_set_vxlan_ip_tos, 12789 (void *)&cmd_set_vxlan_ip_tos_value, 12790 (void *)&cmd_set_vxlan_ip_ttl, 12791 (void *)&cmd_set_vxlan_ip_ttl_value, 12792 (void *)&cmd_set_vxlan_ip_src, 12793 (void *)&cmd_set_vxlan_ip_src_value, 12794 (void *)&cmd_set_vxlan_ip_dst, 12795 (void *)&cmd_set_vxlan_ip_dst_value, 12796 (void *)&cmd_set_vxlan_eth_src, 12797 (void *)&cmd_set_vxlan_eth_src_value, 12798 (void *)&cmd_set_vxlan_eth_dst, 12799 (void *)&cmd_set_vxlan_eth_dst_value, 12800 NULL, 12801 }, 12802 }; 12803 12804 cmdline_parse_inst_t cmd_set_vxlan_with_vlan = { 12805 .f = cmd_set_vxlan_parsed, 12806 .data = NULL, 12807 .help_str = "set vxlan-with-vlan ip-version ipv4|ipv6 vni <vni>" 12808 " udp-src <udp-src> udp-dst <udp-dst> ip-src <ip-src> ip-dst" 12809 " <ip-dst> vlan-tci <vlan-tci> eth-src <eth-src> eth-dst" 12810 " <eth-dst>", 12811 .tokens = { 12812 (void *)&cmd_set_vxlan_set, 12813 (void *)&cmd_set_vxlan_vxlan_with_vlan, 12814 (void *)&cmd_set_vxlan_ip_version, 12815 (void *)&cmd_set_vxlan_ip_version_value, 12816 (void *)&cmd_set_vxlan_vni, 12817 (void *)&cmd_set_vxlan_vni_value, 12818 (void *)&cmd_set_vxlan_udp_src, 12819 (void *)&cmd_set_vxlan_udp_src_value, 12820 (void *)&cmd_set_vxlan_udp_dst, 12821 (void *)&cmd_set_vxlan_udp_dst_value, 12822 (void *)&cmd_set_vxlan_ip_src, 12823 (void *)&cmd_set_vxlan_ip_src_value, 12824 (void *)&cmd_set_vxlan_ip_dst, 12825 (void *)&cmd_set_vxlan_ip_dst_value, 12826 (void *)&cmd_set_vxlan_vlan, 12827 (void *)&cmd_set_vxlan_vlan_value, 12828 (void *)&cmd_set_vxlan_eth_src, 12829 (void *)&cmd_set_vxlan_eth_src_value, 12830 (void *)&cmd_set_vxlan_eth_dst, 12831 (void *)&cmd_set_vxlan_eth_dst_value, 12832 NULL, 12833 }, 12834 }; 12835 12836 /** Set NVGRE encapsulation details */ 12837 struct cmd_set_nvgre_result { 12838 cmdline_fixed_string_t set; 12839 cmdline_fixed_string_t nvgre; 12840 cmdline_fixed_string_t pos_token; 12841 cmdline_fixed_string_t ip_version; 12842 uint32_t tni; 12843 cmdline_ipaddr_t ip_src; 12844 cmdline_ipaddr_t ip_dst; 12845 uint16_t tci; 12846 struct rte_ether_addr eth_src; 12847 struct rte_ether_addr eth_dst; 12848 }; 12849 12850 cmdline_parse_token_string_t cmd_set_nvgre_set = 12851 TOKEN_STRING_INITIALIZER(struct cmd_set_nvgre_result, set, "set"); 12852 cmdline_parse_token_string_t cmd_set_nvgre_nvgre = 12853 TOKEN_STRING_INITIALIZER(struct cmd_set_nvgre_result, nvgre, "nvgre"); 12854 cmdline_parse_token_string_t cmd_set_nvgre_nvgre_with_vlan = 12855 TOKEN_STRING_INITIALIZER(struct cmd_set_nvgre_result, nvgre, 12856 "nvgre-with-vlan"); 12857 cmdline_parse_token_string_t cmd_set_nvgre_ip_version = 12858 TOKEN_STRING_INITIALIZER(struct cmd_set_nvgre_result, pos_token, 12859 "ip-version"); 12860 cmdline_parse_token_string_t cmd_set_nvgre_ip_version_value = 12861 TOKEN_STRING_INITIALIZER(struct cmd_set_nvgre_result, ip_version, 12862 "ipv4#ipv6"); 12863 cmdline_parse_token_string_t cmd_set_nvgre_tni = 12864 TOKEN_STRING_INITIALIZER(struct cmd_set_nvgre_result, pos_token, 12865 "tni"); 12866 cmdline_parse_token_num_t cmd_set_nvgre_tni_value = 12867 TOKEN_NUM_INITIALIZER(struct cmd_set_nvgre_result, tni, RTE_UINT32); 12868 cmdline_parse_token_string_t cmd_set_nvgre_ip_src = 12869 TOKEN_STRING_INITIALIZER(struct cmd_set_nvgre_result, pos_token, 12870 "ip-src"); 12871 cmdline_parse_token_num_t cmd_set_nvgre_ip_src_value = 12872 TOKEN_IPADDR_INITIALIZER(struct cmd_set_nvgre_result, ip_src); 12873 cmdline_parse_token_string_t cmd_set_nvgre_ip_dst = 12874 TOKEN_STRING_INITIALIZER(struct cmd_set_nvgre_result, pos_token, 12875 "ip-dst"); 12876 cmdline_parse_token_ipaddr_t cmd_set_nvgre_ip_dst_value = 12877 TOKEN_IPADDR_INITIALIZER(struct cmd_set_nvgre_result, ip_dst); 12878 cmdline_parse_token_string_t cmd_set_nvgre_vlan = 12879 TOKEN_STRING_INITIALIZER(struct cmd_set_nvgre_result, pos_token, 12880 "vlan-tci"); 12881 cmdline_parse_token_num_t cmd_set_nvgre_vlan_value = 12882 TOKEN_NUM_INITIALIZER(struct cmd_set_nvgre_result, tci, RTE_UINT16); 12883 cmdline_parse_token_string_t cmd_set_nvgre_eth_src = 12884 TOKEN_STRING_INITIALIZER(struct cmd_set_nvgre_result, pos_token, 12885 "eth-src"); 12886 cmdline_parse_token_etheraddr_t cmd_set_nvgre_eth_src_value = 12887 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_nvgre_result, eth_src); 12888 cmdline_parse_token_string_t cmd_set_nvgre_eth_dst = 12889 TOKEN_STRING_INITIALIZER(struct cmd_set_nvgre_result, pos_token, 12890 "eth-dst"); 12891 cmdline_parse_token_etheraddr_t cmd_set_nvgre_eth_dst_value = 12892 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_nvgre_result, eth_dst); 12893 12894 static void cmd_set_nvgre_parsed(void *parsed_result, 12895 __rte_unused struct cmdline *cl, 12896 __rte_unused void *data) 12897 { 12898 struct cmd_set_nvgre_result *res = parsed_result; 12899 union { 12900 uint32_t nvgre_tni; 12901 uint8_t tni[4]; 12902 } id = { 12903 .nvgre_tni = rte_cpu_to_be_32(res->tni) & RTE_BE32(0x00ffffff), 12904 }; 12905 12906 if (strcmp(res->nvgre, "nvgre") == 0) 12907 nvgre_encap_conf.select_vlan = 0; 12908 else if (strcmp(res->nvgre, "nvgre-with-vlan") == 0) 12909 nvgre_encap_conf.select_vlan = 1; 12910 if (strcmp(res->ip_version, "ipv4") == 0) 12911 nvgre_encap_conf.select_ipv4 = 1; 12912 else if (strcmp(res->ip_version, "ipv6") == 0) 12913 nvgre_encap_conf.select_ipv4 = 0; 12914 else 12915 return; 12916 rte_memcpy(nvgre_encap_conf.tni, &id.tni[1], 3); 12917 if (nvgre_encap_conf.select_ipv4) { 12918 IPV4_ADDR_TO_UINT(res->ip_src, nvgre_encap_conf.ipv4_src); 12919 IPV4_ADDR_TO_UINT(res->ip_dst, nvgre_encap_conf.ipv4_dst); 12920 } else { 12921 IPV6_ADDR_TO_ARRAY(res->ip_src, nvgre_encap_conf.ipv6_src); 12922 IPV6_ADDR_TO_ARRAY(res->ip_dst, nvgre_encap_conf.ipv6_dst); 12923 } 12924 if (nvgre_encap_conf.select_vlan) 12925 nvgre_encap_conf.vlan_tci = rte_cpu_to_be_16(res->tci); 12926 rte_memcpy(nvgre_encap_conf.eth_src, res->eth_src.addr_bytes, 12927 RTE_ETHER_ADDR_LEN); 12928 rte_memcpy(nvgre_encap_conf.eth_dst, res->eth_dst.addr_bytes, 12929 RTE_ETHER_ADDR_LEN); 12930 } 12931 12932 cmdline_parse_inst_t cmd_set_nvgre = { 12933 .f = cmd_set_nvgre_parsed, 12934 .data = NULL, 12935 .help_str = "set nvgre ip-version <ipv4|ipv6> tni <tni> ip-src" 12936 " <ip-src> ip-dst <ip-dst> eth-src <eth-src>" 12937 " eth-dst <eth-dst>", 12938 .tokens = { 12939 (void *)&cmd_set_nvgre_set, 12940 (void *)&cmd_set_nvgre_nvgre, 12941 (void *)&cmd_set_nvgre_ip_version, 12942 (void *)&cmd_set_nvgre_ip_version_value, 12943 (void *)&cmd_set_nvgre_tni, 12944 (void *)&cmd_set_nvgre_tni_value, 12945 (void *)&cmd_set_nvgre_ip_src, 12946 (void *)&cmd_set_nvgre_ip_src_value, 12947 (void *)&cmd_set_nvgre_ip_dst, 12948 (void *)&cmd_set_nvgre_ip_dst_value, 12949 (void *)&cmd_set_nvgre_eth_src, 12950 (void *)&cmd_set_nvgre_eth_src_value, 12951 (void *)&cmd_set_nvgre_eth_dst, 12952 (void *)&cmd_set_nvgre_eth_dst_value, 12953 NULL, 12954 }, 12955 }; 12956 12957 cmdline_parse_inst_t cmd_set_nvgre_with_vlan = { 12958 .f = cmd_set_nvgre_parsed, 12959 .data = NULL, 12960 .help_str = "set nvgre-with-vlan ip-version <ipv4|ipv6> tni <tni>" 12961 " ip-src <ip-src> ip-dst <ip-dst> vlan-tci <vlan-tci>" 12962 " eth-src <eth-src> eth-dst <eth-dst>", 12963 .tokens = { 12964 (void *)&cmd_set_nvgre_set, 12965 (void *)&cmd_set_nvgre_nvgre_with_vlan, 12966 (void *)&cmd_set_nvgre_ip_version, 12967 (void *)&cmd_set_nvgre_ip_version_value, 12968 (void *)&cmd_set_nvgre_tni, 12969 (void *)&cmd_set_nvgre_tni_value, 12970 (void *)&cmd_set_nvgre_ip_src, 12971 (void *)&cmd_set_nvgre_ip_src_value, 12972 (void *)&cmd_set_nvgre_ip_dst, 12973 (void *)&cmd_set_nvgre_ip_dst_value, 12974 (void *)&cmd_set_nvgre_vlan, 12975 (void *)&cmd_set_nvgre_vlan_value, 12976 (void *)&cmd_set_nvgre_eth_src, 12977 (void *)&cmd_set_nvgre_eth_src_value, 12978 (void *)&cmd_set_nvgre_eth_dst, 12979 (void *)&cmd_set_nvgre_eth_dst_value, 12980 NULL, 12981 }, 12982 }; 12983 12984 /** Set L2 encapsulation details */ 12985 struct cmd_set_l2_encap_result { 12986 cmdline_fixed_string_t set; 12987 cmdline_fixed_string_t l2_encap; 12988 cmdline_fixed_string_t pos_token; 12989 cmdline_fixed_string_t ip_version; 12990 uint32_t vlan_present:1; 12991 uint16_t tci; 12992 struct rte_ether_addr eth_src; 12993 struct rte_ether_addr eth_dst; 12994 }; 12995 12996 cmdline_parse_token_string_t cmd_set_l2_encap_set = 12997 TOKEN_STRING_INITIALIZER(struct cmd_set_l2_encap_result, set, "set"); 12998 cmdline_parse_token_string_t cmd_set_l2_encap_l2_encap = 12999 TOKEN_STRING_INITIALIZER(struct cmd_set_l2_encap_result, l2_encap, "l2_encap"); 13000 cmdline_parse_token_string_t cmd_set_l2_encap_l2_encap_with_vlan = 13001 TOKEN_STRING_INITIALIZER(struct cmd_set_l2_encap_result, l2_encap, 13002 "l2_encap-with-vlan"); 13003 cmdline_parse_token_string_t cmd_set_l2_encap_ip_version = 13004 TOKEN_STRING_INITIALIZER(struct cmd_set_l2_encap_result, pos_token, 13005 "ip-version"); 13006 cmdline_parse_token_string_t cmd_set_l2_encap_ip_version_value = 13007 TOKEN_STRING_INITIALIZER(struct cmd_set_l2_encap_result, ip_version, 13008 "ipv4#ipv6"); 13009 cmdline_parse_token_string_t cmd_set_l2_encap_vlan = 13010 TOKEN_STRING_INITIALIZER(struct cmd_set_l2_encap_result, pos_token, 13011 "vlan-tci"); 13012 cmdline_parse_token_num_t cmd_set_l2_encap_vlan_value = 13013 TOKEN_NUM_INITIALIZER(struct cmd_set_l2_encap_result, tci, RTE_UINT16); 13014 cmdline_parse_token_string_t cmd_set_l2_encap_eth_src = 13015 TOKEN_STRING_INITIALIZER(struct cmd_set_l2_encap_result, pos_token, 13016 "eth-src"); 13017 cmdline_parse_token_etheraddr_t cmd_set_l2_encap_eth_src_value = 13018 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_l2_encap_result, eth_src); 13019 cmdline_parse_token_string_t cmd_set_l2_encap_eth_dst = 13020 TOKEN_STRING_INITIALIZER(struct cmd_set_l2_encap_result, pos_token, 13021 "eth-dst"); 13022 cmdline_parse_token_etheraddr_t cmd_set_l2_encap_eth_dst_value = 13023 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_l2_encap_result, eth_dst); 13024 13025 static void cmd_set_l2_encap_parsed(void *parsed_result, 13026 __rte_unused struct cmdline *cl, 13027 __rte_unused void *data) 13028 { 13029 struct cmd_set_l2_encap_result *res = parsed_result; 13030 13031 if (strcmp(res->l2_encap, "l2_encap") == 0) 13032 l2_encap_conf.select_vlan = 0; 13033 else if (strcmp(res->l2_encap, "l2_encap-with-vlan") == 0) 13034 l2_encap_conf.select_vlan = 1; 13035 if (strcmp(res->ip_version, "ipv4") == 0) 13036 l2_encap_conf.select_ipv4 = 1; 13037 else if (strcmp(res->ip_version, "ipv6") == 0) 13038 l2_encap_conf.select_ipv4 = 0; 13039 else 13040 return; 13041 if (l2_encap_conf.select_vlan) 13042 l2_encap_conf.vlan_tci = rte_cpu_to_be_16(res->tci); 13043 rte_memcpy(l2_encap_conf.eth_src, res->eth_src.addr_bytes, 13044 RTE_ETHER_ADDR_LEN); 13045 rte_memcpy(l2_encap_conf.eth_dst, res->eth_dst.addr_bytes, 13046 RTE_ETHER_ADDR_LEN); 13047 } 13048 13049 cmdline_parse_inst_t cmd_set_l2_encap = { 13050 .f = cmd_set_l2_encap_parsed, 13051 .data = NULL, 13052 .help_str = "set l2_encap ip-version ipv4|ipv6" 13053 " eth-src <eth-src> eth-dst <eth-dst>", 13054 .tokens = { 13055 (void *)&cmd_set_l2_encap_set, 13056 (void *)&cmd_set_l2_encap_l2_encap, 13057 (void *)&cmd_set_l2_encap_ip_version, 13058 (void *)&cmd_set_l2_encap_ip_version_value, 13059 (void *)&cmd_set_l2_encap_eth_src, 13060 (void *)&cmd_set_l2_encap_eth_src_value, 13061 (void *)&cmd_set_l2_encap_eth_dst, 13062 (void *)&cmd_set_l2_encap_eth_dst_value, 13063 NULL, 13064 }, 13065 }; 13066 13067 cmdline_parse_inst_t cmd_set_l2_encap_with_vlan = { 13068 .f = cmd_set_l2_encap_parsed, 13069 .data = NULL, 13070 .help_str = "set l2_encap-with-vlan ip-version ipv4|ipv6" 13071 " vlan-tci <vlan-tci> eth-src <eth-src> eth-dst <eth-dst>", 13072 .tokens = { 13073 (void *)&cmd_set_l2_encap_set, 13074 (void *)&cmd_set_l2_encap_l2_encap_with_vlan, 13075 (void *)&cmd_set_l2_encap_ip_version, 13076 (void *)&cmd_set_l2_encap_ip_version_value, 13077 (void *)&cmd_set_l2_encap_vlan, 13078 (void *)&cmd_set_l2_encap_vlan_value, 13079 (void *)&cmd_set_l2_encap_eth_src, 13080 (void *)&cmd_set_l2_encap_eth_src_value, 13081 (void *)&cmd_set_l2_encap_eth_dst, 13082 (void *)&cmd_set_l2_encap_eth_dst_value, 13083 NULL, 13084 }, 13085 }; 13086 13087 /** Set L2 decapsulation details */ 13088 struct cmd_set_l2_decap_result { 13089 cmdline_fixed_string_t set; 13090 cmdline_fixed_string_t l2_decap; 13091 cmdline_fixed_string_t pos_token; 13092 uint32_t vlan_present:1; 13093 }; 13094 13095 cmdline_parse_token_string_t cmd_set_l2_decap_set = 13096 TOKEN_STRING_INITIALIZER(struct cmd_set_l2_decap_result, set, "set"); 13097 cmdline_parse_token_string_t cmd_set_l2_decap_l2_decap = 13098 TOKEN_STRING_INITIALIZER(struct cmd_set_l2_decap_result, l2_decap, 13099 "l2_decap"); 13100 cmdline_parse_token_string_t cmd_set_l2_decap_l2_decap_with_vlan = 13101 TOKEN_STRING_INITIALIZER(struct cmd_set_l2_decap_result, l2_decap, 13102 "l2_decap-with-vlan"); 13103 13104 static void cmd_set_l2_decap_parsed(void *parsed_result, 13105 __rte_unused struct cmdline *cl, 13106 __rte_unused void *data) 13107 { 13108 struct cmd_set_l2_decap_result *res = parsed_result; 13109 13110 if (strcmp(res->l2_decap, "l2_decap") == 0) 13111 l2_decap_conf.select_vlan = 0; 13112 else if (strcmp(res->l2_decap, "l2_decap-with-vlan") == 0) 13113 l2_decap_conf.select_vlan = 1; 13114 } 13115 13116 cmdline_parse_inst_t cmd_set_l2_decap = { 13117 .f = cmd_set_l2_decap_parsed, 13118 .data = NULL, 13119 .help_str = "set l2_decap", 13120 .tokens = { 13121 (void *)&cmd_set_l2_decap_set, 13122 (void *)&cmd_set_l2_decap_l2_decap, 13123 NULL, 13124 }, 13125 }; 13126 13127 cmdline_parse_inst_t cmd_set_l2_decap_with_vlan = { 13128 .f = cmd_set_l2_decap_parsed, 13129 .data = NULL, 13130 .help_str = "set l2_decap-with-vlan", 13131 .tokens = { 13132 (void *)&cmd_set_l2_decap_set, 13133 (void *)&cmd_set_l2_decap_l2_decap_with_vlan, 13134 NULL, 13135 }, 13136 }; 13137 13138 /** Set MPLSoGRE encapsulation details */ 13139 struct cmd_set_mplsogre_encap_result { 13140 cmdline_fixed_string_t set; 13141 cmdline_fixed_string_t mplsogre; 13142 cmdline_fixed_string_t pos_token; 13143 cmdline_fixed_string_t ip_version; 13144 uint32_t vlan_present:1; 13145 uint32_t label; 13146 cmdline_ipaddr_t ip_src; 13147 cmdline_ipaddr_t ip_dst; 13148 uint16_t tci; 13149 struct rte_ether_addr eth_src; 13150 struct rte_ether_addr eth_dst; 13151 }; 13152 13153 cmdline_parse_token_string_t cmd_set_mplsogre_encap_set = 13154 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_encap_result, set, 13155 "set"); 13156 cmdline_parse_token_string_t cmd_set_mplsogre_encap_mplsogre_encap = 13157 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_encap_result, mplsogre, 13158 "mplsogre_encap"); 13159 cmdline_parse_token_string_t cmd_set_mplsogre_encap_mplsogre_encap_with_vlan = 13160 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_encap_result, 13161 mplsogre, "mplsogre_encap-with-vlan"); 13162 cmdline_parse_token_string_t cmd_set_mplsogre_encap_ip_version = 13163 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_encap_result, 13164 pos_token, "ip-version"); 13165 cmdline_parse_token_string_t cmd_set_mplsogre_encap_ip_version_value = 13166 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_encap_result, 13167 ip_version, "ipv4#ipv6"); 13168 cmdline_parse_token_string_t cmd_set_mplsogre_encap_label = 13169 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_encap_result, 13170 pos_token, "label"); 13171 cmdline_parse_token_num_t cmd_set_mplsogre_encap_label_value = 13172 TOKEN_NUM_INITIALIZER(struct cmd_set_mplsogre_encap_result, label, 13173 RTE_UINT32); 13174 cmdline_parse_token_string_t cmd_set_mplsogre_encap_ip_src = 13175 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_encap_result, 13176 pos_token, "ip-src"); 13177 cmdline_parse_token_ipaddr_t cmd_set_mplsogre_encap_ip_src_value = 13178 TOKEN_IPADDR_INITIALIZER(struct cmd_set_mplsogre_encap_result, ip_src); 13179 cmdline_parse_token_string_t cmd_set_mplsogre_encap_ip_dst = 13180 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_encap_result, 13181 pos_token, "ip-dst"); 13182 cmdline_parse_token_ipaddr_t cmd_set_mplsogre_encap_ip_dst_value = 13183 TOKEN_IPADDR_INITIALIZER(struct cmd_set_mplsogre_encap_result, ip_dst); 13184 cmdline_parse_token_string_t cmd_set_mplsogre_encap_vlan = 13185 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_encap_result, 13186 pos_token, "vlan-tci"); 13187 cmdline_parse_token_num_t cmd_set_mplsogre_encap_vlan_value = 13188 TOKEN_NUM_INITIALIZER(struct cmd_set_mplsogre_encap_result, tci, 13189 RTE_UINT16); 13190 cmdline_parse_token_string_t cmd_set_mplsogre_encap_eth_src = 13191 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_encap_result, 13192 pos_token, "eth-src"); 13193 cmdline_parse_token_etheraddr_t cmd_set_mplsogre_encap_eth_src_value = 13194 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_mplsogre_encap_result, 13195 eth_src); 13196 cmdline_parse_token_string_t cmd_set_mplsogre_encap_eth_dst = 13197 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_encap_result, 13198 pos_token, "eth-dst"); 13199 cmdline_parse_token_etheraddr_t cmd_set_mplsogre_encap_eth_dst_value = 13200 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_mplsogre_encap_result, 13201 eth_dst); 13202 13203 static void cmd_set_mplsogre_encap_parsed(void *parsed_result, 13204 __rte_unused struct cmdline *cl, 13205 __rte_unused void *data) 13206 { 13207 struct cmd_set_mplsogre_encap_result *res = parsed_result; 13208 union { 13209 uint32_t mplsogre_label; 13210 uint8_t label[4]; 13211 } id = { 13212 .mplsogre_label = rte_cpu_to_be_32(res->label<<12), 13213 }; 13214 13215 if (strcmp(res->mplsogre, "mplsogre_encap") == 0) 13216 mplsogre_encap_conf.select_vlan = 0; 13217 else if (strcmp(res->mplsogre, "mplsogre_encap-with-vlan") == 0) 13218 mplsogre_encap_conf.select_vlan = 1; 13219 if (strcmp(res->ip_version, "ipv4") == 0) 13220 mplsogre_encap_conf.select_ipv4 = 1; 13221 else if (strcmp(res->ip_version, "ipv6") == 0) 13222 mplsogre_encap_conf.select_ipv4 = 0; 13223 else 13224 return; 13225 rte_memcpy(mplsogre_encap_conf.label, &id.label, 3); 13226 if (mplsogre_encap_conf.select_ipv4) { 13227 IPV4_ADDR_TO_UINT(res->ip_src, mplsogre_encap_conf.ipv4_src); 13228 IPV4_ADDR_TO_UINT(res->ip_dst, mplsogre_encap_conf.ipv4_dst); 13229 } else { 13230 IPV6_ADDR_TO_ARRAY(res->ip_src, mplsogre_encap_conf.ipv6_src); 13231 IPV6_ADDR_TO_ARRAY(res->ip_dst, mplsogre_encap_conf.ipv6_dst); 13232 } 13233 if (mplsogre_encap_conf.select_vlan) 13234 mplsogre_encap_conf.vlan_tci = rte_cpu_to_be_16(res->tci); 13235 rte_memcpy(mplsogre_encap_conf.eth_src, res->eth_src.addr_bytes, 13236 RTE_ETHER_ADDR_LEN); 13237 rte_memcpy(mplsogre_encap_conf.eth_dst, res->eth_dst.addr_bytes, 13238 RTE_ETHER_ADDR_LEN); 13239 } 13240 13241 cmdline_parse_inst_t cmd_set_mplsogre_encap = { 13242 .f = cmd_set_mplsogre_encap_parsed, 13243 .data = NULL, 13244 .help_str = "set mplsogre_encap ip-version ipv4|ipv6 label <label>" 13245 " ip-src <ip-src> ip-dst <ip-dst> eth-src <eth-src>" 13246 " eth-dst <eth-dst>", 13247 .tokens = { 13248 (void *)&cmd_set_mplsogre_encap_set, 13249 (void *)&cmd_set_mplsogre_encap_mplsogre_encap, 13250 (void *)&cmd_set_mplsogre_encap_ip_version, 13251 (void *)&cmd_set_mplsogre_encap_ip_version_value, 13252 (void *)&cmd_set_mplsogre_encap_label, 13253 (void *)&cmd_set_mplsogre_encap_label_value, 13254 (void *)&cmd_set_mplsogre_encap_ip_src, 13255 (void *)&cmd_set_mplsogre_encap_ip_src_value, 13256 (void *)&cmd_set_mplsogre_encap_ip_dst, 13257 (void *)&cmd_set_mplsogre_encap_ip_dst_value, 13258 (void *)&cmd_set_mplsogre_encap_eth_src, 13259 (void *)&cmd_set_mplsogre_encap_eth_src_value, 13260 (void *)&cmd_set_mplsogre_encap_eth_dst, 13261 (void *)&cmd_set_mplsogre_encap_eth_dst_value, 13262 NULL, 13263 }, 13264 }; 13265 13266 cmdline_parse_inst_t cmd_set_mplsogre_encap_with_vlan = { 13267 .f = cmd_set_mplsogre_encap_parsed, 13268 .data = NULL, 13269 .help_str = "set mplsogre_encap-with-vlan ip-version ipv4|ipv6" 13270 " label <label> ip-src <ip-src> ip-dst <ip-dst>" 13271 " vlan-tci <vlan-tci> eth-src <eth-src> eth-dst <eth-dst>", 13272 .tokens = { 13273 (void *)&cmd_set_mplsogre_encap_set, 13274 (void *)&cmd_set_mplsogre_encap_mplsogre_encap_with_vlan, 13275 (void *)&cmd_set_mplsogre_encap_ip_version, 13276 (void *)&cmd_set_mplsogre_encap_ip_version_value, 13277 (void *)&cmd_set_mplsogre_encap_label, 13278 (void *)&cmd_set_mplsogre_encap_label_value, 13279 (void *)&cmd_set_mplsogre_encap_ip_src, 13280 (void *)&cmd_set_mplsogre_encap_ip_src_value, 13281 (void *)&cmd_set_mplsogre_encap_ip_dst, 13282 (void *)&cmd_set_mplsogre_encap_ip_dst_value, 13283 (void *)&cmd_set_mplsogre_encap_vlan, 13284 (void *)&cmd_set_mplsogre_encap_vlan_value, 13285 (void *)&cmd_set_mplsogre_encap_eth_src, 13286 (void *)&cmd_set_mplsogre_encap_eth_src_value, 13287 (void *)&cmd_set_mplsogre_encap_eth_dst, 13288 (void *)&cmd_set_mplsogre_encap_eth_dst_value, 13289 NULL, 13290 }, 13291 }; 13292 13293 /** Set MPLSoGRE decapsulation details */ 13294 struct cmd_set_mplsogre_decap_result { 13295 cmdline_fixed_string_t set; 13296 cmdline_fixed_string_t mplsogre; 13297 cmdline_fixed_string_t pos_token; 13298 cmdline_fixed_string_t ip_version; 13299 uint32_t vlan_present:1; 13300 }; 13301 13302 cmdline_parse_token_string_t cmd_set_mplsogre_decap_set = 13303 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_decap_result, set, 13304 "set"); 13305 cmdline_parse_token_string_t cmd_set_mplsogre_decap_mplsogre_decap = 13306 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_decap_result, mplsogre, 13307 "mplsogre_decap"); 13308 cmdline_parse_token_string_t cmd_set_mplsogre_decap_mplsogre_decap_with_vlan = 13309 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_decap_result, 13310 mplsogre, "mplsogre_decap-with-vlan"); 13311 cmdline_parse_token_string_t cmd_set_mplsogre_decap_ip_version = 13312 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_decap_result, 13313 pos_token, "ip-version"); 13314 cmdline_parse_token_string_t cmd_set_mplsogre_decap_ip_version_value = 13315 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_decap_result, 13316 ip_version, "ipv4#ipv6"); 13317 13318 static void cmd_set_mplsogre_decap_parsed(void *parsed_result, 13319 __rte_unused struct cmdline *cl, 13320 __rte_unused void *data) 13321 { 13322 struct cmd_set_mplsogre_decap_result *res = parsed_result; 13323 13324 if (strcmp(res->mplsogre, "mplsogre_decap") == 0) 13325 mplsogre_decap_conf.select_vlan = 0; 13326 else if (strcmp(res->mplsogre, "mplsogre_decap-with-vlan") == 0) 13327 mplsogre_decap_conf.select_vlan = 1; 13328 if (strcmp(res->ip_version, "ipv4") == 0) 13329 mplsogre_decap_conf.select_ipv4 = 1; 13330 else if (strcmp(res->ip_version, "ipv6") == 0) 13331 mplsogre_decap_conf.select_ipv4 = 0; 13332 } 13333 13334 cmdline_parse_inst_t cmd_set_mplsogre_decap = { 13335 .f = cmd_set_mplsogre_decap_parsed, 13336 .data = NULL, 13337 .help_str = "set mplsogre_decap ip-version ipv4|ipv6", 13338 .tokens = { 13339 (void *)&cmd_set_mplsogre_decap_set, 13340 (void *)&cmd_set_mplsogre_decap_mplsogre_decap, 13341 (void *)&cmd_set_mplsogre_decap_ip_version, 13342 (void *)&cmd_set_mplsogre_decap_ip_version_value, 13343 NULL, 13344 }, 13345 }; 13346 13347 cmdline_parse_inst_t cmd_set_mplsogre_decap_with_vlan = { 13348 .f = cmd_set_mplsogre_decap_parsed, 13349 .data = NULL, 13350 .help_str = "set mplsogre_decap-with-vlan ip-version ipv4|ipv6", 13351 .tokens = { 13352 (void *)&cmd_set_mplsogre_decap_set, 13353 (void *)&cmd_set_mplsogre_decap_mplsogre_decap_with_vlan, 13354 (void *)&cmd_set_mplsogre_decap_ip_version, 13355 (void *)&cmd_set_mplsogre_decap_ip_version_value, 13356 NULL, 13357 }, 13358 }; 13359 13360 /** Set MPLSoUDP encapsulation details */ 13361 struct cmd_set_mplsoudp_encap_result { 13362 cmdline_fixed_string_t set; 13363 cmdline_fixed_string_t mplsoudp; 13364 cmdline_fixed_string_t pos_token; 13365 cmdline_fixed_string_t ip_version; 13366 uint32_t vlan_present:1; 13367 uint32_t label; 13368 uint16_t udp_src; 13369 uint16_t udp_dst; 13370 cmdline_ipaddr_t ip_src; 13371 cmdline_ipaddr_t ip_dst; 13372 uint16_t tci; 13373 struct rte_ether_addr eth_src; 13374 struct rte_ether_addr eth_dst; 13375 }; 13376 13377 cmdline_parse_token_string_t cmd_set_mplsoudp_encap_set = 13378 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_encap_result, set, 13379 "set"); 13380 cmdline_parse_token_string_t cmd_set_mplsoudp_encap_mplsoudp_encap = 13381 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_encap_result, mplsoudp, 13382 "mplsoudp_encap"); 13383 cmdline_parse_token_string_t cmd_set_mplsoudp_encap_mplsoudp_encap_with_vlan = 13384 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_encap_result, 13385 mplsoudp, "mplsoudp_encap-with-vlan"); 13386 cmdline_parse_token_string_t cmd_set_mplsoudp_encap_ip_version = 13387 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_encap_result, 13388 pos_token, "ip-version"); 13389 cmdline_parse_token_string_t cmd_set_mplsoudp_encap_ip_version_value = 13390 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_encap_result, 13391 ip_version, "ipv4#ipv6"); 13392 cmdline_parse_token_string_t cmd_set_mplsoudp_encap_label = 13393 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_encap_result, 13394 pos_token, "label"); 13395 cmdline_parse_token_num_t cmd_set_mplsoudp_encap_label_value = 13396 TOKEN_NUM_INITIALIZER(struct cmd_set_mplsoudp_encap_result, label, 13397 RTE_UINT32); 13398 cmdline_parse_token_string_t cmd_set_mplsoudp_encap_udp_src = 13399 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_encap_result, 13400 pos_token, "udp-src"); 13401 cmdline_parse_token_num_t cmd_set_mplsoudp_encap_udp_src_value = 13402 TOKEN_NUM_INITIALIZER(struct cmd_set_mplsoudp_encap_result, udp_src, 13403 RTE_UINT16); 13404 cmdline_parse_token_string_t cmd_set_mplsoudp_encap_udp_dst = 13405 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_encap_result, 13406 pos_token, "udp-dst"); 13407 cmdline_parse_token_num_t cmd_set_mplsoudp_encap_udp_dst_value = 13408 TOKEN_NUM_INITIALIZER(struct cmd_set_mplsoudp_encap_result, udp_dst, 13409 RTE_UINT16); 13410 cmdline_parse_token_string_t cmd_set_mplsoudp_encap_ip_src = 13411 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_encap_result, 13412 pos_token, "ip-src"); 13413 cmdline_parse_token_ipaddr_t cmd_set_mplsoudp_encap_ip_src_value = 13414 TOKEN_IPADDR_INITIALIZER(struct cmd_set_mplsoudp_encap_result, ip_src); 13415 cmdline_parse_token_string_t cmd_set_mplsoudp_encap_ip_dst = 13416 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_encap_result, 13417 pos_token, "ip-dst"); 13418 cmdline_parse_token_ipaddr_t cmd_set_mplsoudp_encap_ip_dst_value = 13419 TOKEN_IPADDR_INITIALIZER(struct cmd_set_mplsoudp_encap_result, ip_dst); 13420 cmdline_parse_token_string_t cmd_set_mplsoudp_encap_vlan = 13421 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_encap_result, 13422 pos_token, "vlan-tci"); 13423 cmdline_parse_token_num_t cmd_set_mplsoudp_encap_vlan_value = 13424 TOKEN_NUM_INITIALIZER(struct cmd_set_mplsoudp_encap_result, tci, 13425 RTE_UINT16); 13426 cmdline_parse_token_string_t cmd_set_mplsoudp_encap_eth_src = 13427 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_encap_result, 13428 pos_token, "eth-src"); 13429 cmdline_parse_token_etheraddr_t cmd_set_mplsoudp_encap_eth_src_value = 13430 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_mplsoudp_encap_result, 13431 eth_src); 13432 cmdline_parse_token_string_t cmd_set_mplsoudp_encap_eth_dst = 13433 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_encap_result, 13434 pos_token, "eth-dst"); 13435 cmdline_parse_token_etheraddr_t cmd_set_mplsoudp_encap_eth_dst_value = 13436 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_mplsoudp_encap_result, 13437 eth_dst); 13438 13439 static void cmd_set_mplsoudp_encap_parsed(void *parsed_result, 13440 __rte_unused struct cmdline *cl, 13441 __rte_unused void *data) 13442 { 13443 struct cmd_set_mplsoudp_encap_result *res = parsed_result; 13444 union { 13445 uint32_t mplsoudp_label; 13446 uint8_t label[4]; 13447 } id = { 13448 .mplsoudp_label = rte_cpu_to_be_32(res->label<<12), 13449 }; 13450 13451 if (strcmp(res->mplsoudp, "mplsoudp_encap") == 0) 13452 mplsoudp_encap_conf.select_vlan = 0; 13453 else if (strcmp(res->mplsoudp, "mplsoudp_encap-with-vlan") == 0) 13454 mplsoudp_encap_conf.select_vlan = 1; 13455 if (strcmp(res->ip_version, "ipv4") == 0) 13456 mplsoudp_encap_conf.select_ipv4 = 1; 13457 else if (strcmp(res->ip_version, "ipv6") == 0) 13458 mplsoudp_encap_conf.select_ipv4 = 0; 13459 else 13460 return; 13461 rte_memcpy(mplsoudp_encap_conf.label, &id.label, 3); 13462 mplsoudp_encap_conf.udp_src = rte_cpu_to_be_16(res->udp_src); 13463 mplsoudp_encap_conf.udp_dst = rte_cpu_to_be_16(res->udp_dst); 13464 if (mplsoudp_encap_conf.select_ipv4) { 13465 IPV4_ADDR_TO_UINT(res->ip_src, mplsoudp_encap_conf.ipv4_src); 13466 IPV4_ADDR_TO_UINT(res->ip_dst, mplsoudp_encap_conf.ipv4_dst); 13467 } else { 13468 IPV6_ADDR_TO_ARRAY(res->ip_src, mplsoudp_encap_conf.ipv6_src); 13469 IPV6_ADDR_TO_ARRAY(res->ip_dst, mplsoudp_encap_conf.ipv6_dst); 13470 } 13471 if (mplsoudp_encap_conf.select_vlan) 13472 mplsoudp_encap_conf.vlan_tci = rte_cpu_to_be_16(res->tci); 13473 rte_memcpy(mplsoudp_encap_conf.eth_src, res->eth_src.addr_bytes, 13474 RTE_ETHER_ADDR_LEN); 13475 rte_memcpy(mplsoudp_encap_conf.eth_dst, res->eth_dst.addr_bytes, 13476 RTE_ETHER_ADDR_LEN); 13477 } 13478 13479 cmdline_parse_inst_t cmd_set_mplsoudp_encap = { 13480 .f = cmd_set_mplsoudp_encap_parsed, 13481 .data = NULL, 13482 .help_str = "set mplsoudp_encap ip-version ipv4|ipv6 label <label>" 13483 " udp-src <udp-src> udp-dst <udp-dst> ip-src <ip-src>" 13484 " ip-dst <ip-dst> eth-src <eth-src> eth-dst <eth-dst>", 13485 .tokens = { 13486 (void *)&cmd_set_mplsoudp_encap_set, 13487 (void *)&cmd_set_mplsoudp_encap_mplsoudp_encap, 13488 (void *)&cmd_set_mplsoudp_encap_ip_version, 13489 (void *)&cmd_set_mplsoudp_encap_ip_version_value, 13490 (void *)&cmd_set_mplsoudp_encap_label, 13491 (void *)&cmd_set_mplsoudp_encap_label_value, 13492 (void *)&cmd_set_mplsoudp_encap_udp_src, 13493 (void *)&cmd_set_mplsoudp_encap_udp_src_value, 13494 (void *)&cmd_set_mplsoudp_encap_udp_dst, 13495 (void *)&cmd_set_mplsoudp_encap_udp_dst_value, 13496 (void *)&cmd_set_mplsoudp_encap_ip_src, 13497 (void *)&cmd_set_mplsoudp_encap_ip_src_value, 13498 (void *)&cmd_set_mplsoudp_encap_ip_dst, 13499 (void *)&cmd_set_mplsoudp_encap_ip_dst_value, 13500 (void *)&cmd_set_mplsoudp_encap_eth_src, 13501 (void *)&cmd_set_mplsoudp_encap_eth_src_value, 13502 (void *)&cmd_set_mplsoudp_encap_eth_dst, 13503 (void *)&cmd_set_mplsoudp_encap_eth_dst_value, 13504 NULL, 13505 }, 13506 }; 13507 13508 cmdline_parse_inst_t cmd_set_mplsoudp_encap_with_vlan = { 13509 .f = cmd_set_mplsoudp_encap_parsed, 13510 .data = NULL, 13511 .help_str = "set mplsoudp_encap-with-vlan ip-version ipv4|ipv6" 13512 " label <label> udp-src <udp-src> udp-dst <udp-dst>" 13513 " ip-src <ip-src> ip-dst <ip-dst> vlan-tci <vlan-tci>" 13514 " eth-src <eth-src> eth-dst <eth-dst>", 13515 .tokens = { 13516 (void *)&cmd_set_mplsoudp_encap_set, 13517 (void *)&cmd_set_mplsoudp_encap_mplsoudp_encap_with_vlan, 13518 (void *)&cmd_set_mplsoudp_encap_ip_version, 13519 (void *)&cmd_set_mplsoudp_encap_ip_version_value, 13520 (void *)&cmd_set_mplsoudp_encap_label, 13521 (void *)&cmd_set_mplsoudp_encap_label_value, 13522 (void *)&cmd_set_mplsoudp_encap_udp_src, 13523 (void *)&cmd_set_mplsoudp_encap_udp_src_value, 13524 (void *)&cmd_set_mplsoudp_encap_udp_dst, 13525 (void *)&cmd_set_mplsoudp_encap_udp_dst_value, 13526 (void *)&cmd_set_mplsoudp_encap_ip_src, 13527 (void *)&cmd_set_mplsoudp_encap_ip_src_value, 13528 (void *)&cmd_set_mplsoudp_encap_ip_dst, 13529 (void *)&cmd_set_mplsoudp_encap_ip_dst_value, 13530 (void *)&cmd_set_mplsoudp_encap_vlan, 13531 (void *)&cmd_set_mplsoudp_encap_vlan_value, 13532 (void *)&cmd_set_mplsoudp_encap_eth_src, 13533 (void *)&cmd_set_mplsoudp_encap_eth_src_value, 13534 (void *)&cmd_set_mplsoudp_encap_eth_dst, 13535 (void *)&cmd_set_mplsoudp_encap_eth_dst_value, 13536 NULL, 13537 }, 13538 }; 13539 13540 /** Set MPLSoUDP decapsulation details */ 13541 struct cmd_set_mplsoudp_decap_result { 13542 cmdline_fixed_string_t set; 13543 cmdline_fixed_string_t mplsoudp; 13544 cmdline_fixed_string_t pos_token; 13545 cmdline_fixed_string_t ip_version; 13546 uint32_t vlan_present:1; 13547 }; 13548 13549 cmdline_parse_token_string_t cmd_set_mplsoudp_decap_set = 13550 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_decap_result, set, 13551 "set"); 13552 cmdline_parse_token_string_t cmd_set_mplsoudp_decap_mplsoudp_decap = 13553 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_decap_result, mplsoudp, 13554 "mplsoudp_decap"); 13555 cmdline_parse_token_string_t cmd_set_mplsoudp_decap_mplsoudp_decap_with_vlan = 13556 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_decap_result, 13557 mplsoudp, "mplsoudp_decap-with-vlan"); 13558 cmdline_parse_token_string_t cmd_set_mplsoudp_decap_ip_version = 13559 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_decap_result, 13560 pos_token, "ip-version"); 13561 cmdline_parse_token_string_t cmd_set_mplsoudp_decap_ip_version_value = 13562 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_decap_result, 13563 ip_version, "ipv4#ipv6"); 13564 13565 static void cmd_set_mplsoudp_decap_parsed(void *parsed_result, 13566 __rte_unused struct cmdline *cl, 13567 __rte_unused void *data) 13568 { 13569 struct cmd_set_mplsoudp_decap_result *res = parsed_result; 13570 13571 if (strcmp(res->mplsoudp, "mplsoudp_decap") == 0) 13572 mplsoudp_decap_conf.select_vlan = 0; 13573 else if (strcmp(res->mplsoudp, "mplsoudp_decap-with-vlan") == 0) 13574 mplsoudp_decap_conf.select_vlan = 1; 13575 if (strcmp(res->ip_version, "ipv4") == 0) 13576 mplsoudp_decap_conf.select_ipv4 = 1; 13577 else if (strcmp(res->ip_version, "ipv6") == 0) 13578 mplsoudp_decap_conf.select_ipv4 = 0; 13579 } 13580 13581 cmdline_parse_inst_t cmd_set_mplsoudp_decap = { 13582 .f = cmd_set_mplsoudp_decap_parsed, 13583 .data = NULL, 13584 .help_str = "set mplsoudp_decap ip-version ipv4|ipv6", 13585 .tokens = { 13586 (void *)&cmd_set_mplsoudp_decap_set, 13587 (void *)&cmd_set_mplsoudp_decap_mplsoudp_decap, 13588 (void *)&cmd_set_mplsoudp_decap_ip_version, 13589 (void *)&cmd_set_mplsoudp_decap_ip_version_value, 13590 NULL, 13591 }, 13592 }; 13593 13594 cmdline_parse_inst_t cmd_set_mplsoudp_decap_with_vlan = { 13595 .f = cmd_set_mplsoudp_decap_parsed, 13596 .data = NULL, 13597 .help_str = "set mplsoudp_decap-with-vlan ip-version ipv4|ipv6", 13598 .tokens = { 13599 (void *)&cmd_set_mplsoudp_decap_set, 13600 (void *)&cmd_set_mplsoudp_decap_mplsoudp_decap_with_vlan, 13601 (void *)&cmd_set_mplsoudp_decap_ip_version, 13602 (void *)&cmd_set_mplsoudp_decap_ip_version_value, 13603 NULL, 13604 }, 13605 }; 13606 13607 /* Strict link priority scheduling mode setting */ 13608 static void 13609 cmd_strict_link_prio_parsed( 13610 void *parsed_result, 13611 __rte_unused struct cmdline *cl, 13612 __rte_unused void *data) 13613 { 13614 struct cmd_vf_tc_bw_result *res = parsed_result; 13615 int ret = -ENOTSUP; 13616 13617 if (port_id_is_invalid(res->port_id, ENABLED_WARN)) 13618 return; 13619 13620 #ifdef RTE_NET_I40E 13621 ret = rte_pmd_i40e_set_tc_strict_prio(res->port_id, res->tc_map); 13622 #endif 13623 13624 switch (ret) { 13625 case 0: 13626 break; 13627 case -EINVAL: 13628 printf("invalid tc_bitmap 0x%x\n", res->tc_map); 13629 break; 13630 case -ENODEV: 13631 printf("invalid port_id %d\n", res->port_id); 13632 break; 13633 case -ENOTSUP: 13634 printf("function not implemented\n"); 13635 break; 13636 default: 13637 printf("programming error: (%s)\n", strerror(-ret)); 13638 } 13639 } 13640 13641 cmdline_parse_inst_t cmd_strict_link_prio = { 13642 .f = cmd_strict_link_prio_parsed, 13643 .data = NULL, 13644 .help_str = "set tx strict-link-priority <port_id> <tc_bitmap>", 13645 .tokens = { 13646 (void *)&cmd_vf_tc_bw_set, 13647 (void *)&cmd_vf_tc_bw_tx, 13648 (void *)&cmd_vf_tc_bw_strict_link_prio, 13649 (void *)&cmd_vf_tc_bw_port_id, 13650 (void *)&cmd_vf_tc_bw_tc_map, 13651 NULL, 13652 }, 13653 }; 13654 13655 /* Load dynamic device personalization*/ 13656 struct cmd_ddp_add_result { 13657 cmdline_fixed_string_t ddp; 13658 cmdline_fixed_string_t add; 13659 portid_t port_id; 13660 char filepath[]; 13661 }; 13662 13663 cmdline_parse_token_string_t cmd_ddp_add_ddp = 13664 TOKEN_STRING_INITIALIZER(struct cmd_ddp_add_result, ddp, "ddp"); 13665 cmdline_parse_token_string_t cmd_ddp_add_add = 13666 TOKEN_STRING_INITIALIZER(struct cmd_ddp_add_result, add, "add"); 13667 cmdline_parse_token_num_t cmd_ddp_add_port_id = 13668 TOKEN_NUM_INITIALIZER(struct cmd_ddp_add_result, port_id, 13669 RTE_UINT16); 13670 cmdline_parse_token_string_t cmd_ddp_add_filepath = 13671 TOKEN_STRING_INITIALIZER(struct cmd_ddp_add_result, filepath, NULL); 13672 13673 static void 13674 cmd_ddp_add_parsed( 13675 void *parsed_result, 13676 __rte_unused struct cmdline *cl, 13677 __rte_unused void *data) 13678 { 13679 struct cmd_ddp_add_result *res = parsed_result; 13680 uint8_t *buff; 13681 uint32_t size; 13682 char *filepath; 13683 char *file_fld[2]; 13684 int file_num; 13685 int ret = -ENOTSUP; 13686 13687 if (!all_ports_stopped()) { 13688 printf("Please stop all ports first\n"); 13689 return; 13690 } 13691 13692 filepath = strdup(res->filepath); 13693 if (filepath == NULL) { 13694 printf("Failed to allocate memory\n"); 13695 return; 13696 } 13697 file_num = rte_strsplit(filepath, strlen(filepath), file_fld, 2, ','); 13698 13699 buff = open_file(file_fld[0], &size); 13700 if (!buff) { 13701 free((void *)filepath); 13702 return; 13703 } 13704 13705 #ifdef RTE_NET_I40E 13706 if (ret == -ENOTSUP) 13707 ret = rte_pmd_i40e_process_ddp_package(res->port_id, 13708 buff, size, 13709 RTE_PMD_I40E_PKG_OP_WR_ADD); 13710 #endif 13711 13712 if (ret == -EEXIST) 13713 printf("Profile has already existed.\n"); 13714 else if (ret < 0) 13715 printf("Failed to load profile.\n"); 13716 else if (file_num == 2) 13717 save_file(file_fld[1], buff, size); 13718 13719 close_file(buff); 13720 free((void *)filepath); 13721 } 13722 13723 cmdline_parse_inst_t cmd_ddp_add = { 13724 .f = cmd_ddp_add_parsed, 13725 .data = NULL, 13726 .help_str = "ddp add <port_id> <profile_path[,backup_profile_path]>", 13727 .tokens = { 13728 (void *)&cmd_ddp_add_ddp, 13729 (void *)&cmd_ddp_add_add, 13730 (void *)&cmd_ddp_add_port_id, 13731 (void *)&cmd_ddp_add_filepath, 13732 NULL, 13733 }, 13734 }; 13735 13736 /* Delete dynamic device personalization*/ 13737 struct cmd_ddp_del_result { 13738 cmdline_fixed_string_t ddp; 13739 cmdline_fixed_string_t del; 13740 portid_t port_id; 13741 char filepath[]; 13742 }; 13743 13744 cmdline_parse_token_string_t cmd_ddp_del_ddp = 13745 TOKEN_STRING_INITIALIZER(struct cmd_ddp_del_result, ddp, "ddp"); 13746 cmdline_parse_token_string_t cmd_ddp_del_del = 13747 TOKEN_STRING_INITIALIZER(struct cmd_ddp_del_result, del, "del"); 13748 cmdline_parse_token_num_t cmd_ddp_del_port_id = 13749 TOKEN_NUM_INITIALIZER(struct cmd_ddp_del_result, port_id, RTE_UINT16); 13750 cmdline_parse_token_string_t cmd_ddp_del_filepath = 13751 TOKEN_STRING_INITIALIZER(struct cmd_ddp_del_result, filepath, NULL); 13752 13753 static void 13754 cmd_ddp_del_parsed( 13755 void *parsed_result, 13756 __rte_unused struct cmdline *cl, 13757 __rte_unused void *data) 13758 { 13759 struct cmd_ddp_del_result *res = parsed_result; 13760 uint8_t *buff; 13761 uint32_t size; 13762 int ret = -ENOTSUP; 13763 13764 if (!all_ports_stopped()) { 13765 printf("Please stop all ports first\n"); 13766 return; 13767 } 13768 13769 buff = open_file(res->filepath, &size); 13770 if (!buff) 13771 return; 13772 13773 #ifdef RTE_NET_I40E 13774 if (ret == -ENOTSUP) 13775 ret = rte_pmd_i40e_process_ddp_package(res->port_id, 13776 buff, size, 13777 RTE_PMD_I40E_PKG_OP_WR_DEL); 13778 #endif 13779 13780 if (ret == -EACCES) 13781 printf("Profile does not exist.\n"); 13782 else if (ret < 0) 13783 printf("Failed to delete profile.\n"); 13784 13785 close_file(buff); 13786 } 13787 13788 cmdline_parse_inst_t cmd_ddp_del = { 13789 .f = cmd_ddp_del_parsed, 13790 .data = NULL, 13791 .help_str = "ddp del <port_id> <backup_profile_path>", 13792 .tokens = { 13793 (void *)&cmd_ddp_del_ddp, 13794 (void *)&cmd_ddp_del_del, 13795 (void *)&cmd_ddp_del_port_id, 13796 (void *)&cmd_ddp_del_filepath, 13797 NULL, 13798 }, 13799 }; 13800 13801 /* Get dynamic device personalization profile info */ 13802 struct cmd_ddp_info_result { 13803 cmdline_fixed_string_t ddp; 13804 cmdline_fixed_string_t get; 13805 cmdline_fixed_string_t info; 13806 char filepath[]; 13807 }; 13808 13809 cmdline_parse_token_string_t cmd_ddp_info_ddp = 13810 TOKEN_STRING_INITIALIZER(struct cmd_ddp_info_result, ddp, "ddp"); 13811 cmdline_parse_token_string_t cmd_ddp_info_get = 13812 TOKEN_STRING_INITIALIZER(struct cmd_ddp_info_result, get, "get"); 13813 cmdline_parse_token_string_t cmd_ddp_info_info = 13814 TOKEN_STRING_INITIALIZER(struct cmd_ddp_info_result, info, "info"); 13815 cmdline_parse_token_string_t cmd_ddp_info_filepath = 13816 TOKEN_STRING_INITIALIZER(struct cmd_ddp_info_result, filepath, NULL); 13817 13818 static void 13819 cmd_ddp_info_parsed( 13820 void *parsed_result, 13821 __rte_unused struct cmdline *cl, 13822 __rte_unused void *data) 13823 { 13824 struct cmd_ddp_info_result *res = parsed_result; 13825 uint8_t *pkg; 13826 uint32_t pkg_size; 13827 int ret = -ENOTSUP; 13828 #ifdef RTE_NET_I40E 13829 uint32_t i, j, n; 13830 uint8_t *buff; 13831 uint32_t buff_size = 0; 13832 struct rte_pmd_i40e_profile_info info; 13833 uint32_t dev_num = 0; 13834 struct rte_pmd_i40e_ddp_device_id *devs; 13835 uint32_t proto_num = 0; 13836 struct rte_pmd_i40e_proto_info *proto = NULL; 13837 uint32_t pctype_num = 0; 13838 struct rte_pmd_i40e_ptype_info *pctype; 13839 uint32_t ptype_num = 0; 13840 struct rte_pmd_i40e_ptype_info *ptype; 13841 uint8_t proto_id; 13842 13843 #endif 13844 13845 pkg = open_file(res->filepath, &pkg_size); 13846 if (!pkg) 13847 return; 13848 13849 #ifdef RTE_NET_I40E 13850 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size, 13851 (uint8_t *)&info, sizeof(info), 13852 RTE_PMD_I40E_PKG_INFO_GLOBAL_HEADER); 13853 if (!ret) { 13854 printf("Global Track id: 0x%x\n", info.track_id); 13855 printf("Global Version: %d.%d.%d.%d\n", 13856 info.version.major, 13857 info.version.minor, 13858 info.version.update, 13859 info.version.draft); 13860 printf("Global Package name: %s\n\n", info.name); 13861 } 13862 13863 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size, 13864 (uint8_t *)&info, sizeof(info), 13865 RTE_PMD_I40E_PKG_INFO_HEADER); 13866 if (!ret) { 13867 printf("i40e Profile Track id: 0x%x\n", info.track_id); 13868 printf("i40e Profile Version: %d.%d.%d.%d\n", 13869 info.version.major, 13870 info.version.minor, 13871 info.version.update, 13872 info.version.draft); 13873 printf("i40e Profile name: %s\n\n", info.name); 13874 } 13875 13876 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size, 13877 (uint8_t *)&buff_size, sizeof(buff_size), 13878 RTE_PMD_I40E_PKG_INFO_GLOBAL_NOTES_SIZE); 13879 if (!ret && buff_size) { 13880 buff = (uint8_t *)malloc(buff_size); 13881 if (buff) { 13882 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size, 13883 buff, buff_size, 13884 RTE_PMD_I40E_PKG_INFO_GLOBAL_NOTES); 13885 if (!ret) 13886 printf("Package Notes:\n%s\n\n", buff); 13887 free(buff); 13888 } 13889 } 13890 13891 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size, 13892 (uint8_t *)&dev_num, sizeof(dev_num), 13893 RTE_PMD_I40E_PKG_INFO_DEVID_NUM); 13894 if (!ret && dev_num) { 13895 buff_size = dev_num * sizeof(struct rte_pmd_i40e_ddp_device_id); 13896 devs = (struct rte_pmd_i40e_ddp_device_id *)malloc(buff_size); 13897 if (devs) { 13898 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size, 13899 (uint8_t *)devs, buff_size, 13900 RTE_PMD_I40E_PKG_INFO_DEVID_LIST); 13901 if (!ret) { 13902 printf("List of supported devices:\n"); 13903 for (i = 0; i < dev_num; i++) { 13904 printf(" %04X:%04X %04X:%04X\n", 13905 devs[i].vendor_dev_id >> 16, 13906 devs[i].vendor_dev_id & 0xFFFF, 13907 devs[i].sub_vendor_dev_id >> 16, 13908 devs[i].sub_vendor_dev_id & 0xFFFF); 13909 } 13910 printf("\n"); 13911 } 13912 free(devs); 13913 } 13914 } 13915 13916 /* get information about protocols and packet types */ 13917 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size, 13918 (uint8_t *)&proto_num, sizeof(proto_num), 13919 RTE_PMD_I40E_PKG_INFO_PROTOCOL_NUM); 13920 if (ret || !proto_num) 13921 goto no_print_return; 13922 13923 buff_size = proto_num * sizeof(struct rte_pmd_i40e_proto_info); 13924 proto = (struct rte_pmd_i40e_proto_info *)malloc(buff_size); 13925 if (!proto) 13926 goto no_print_return; 13927 13928 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size, (uint8_t *)proto, 13929 buff_size, 13930 RTE_PMD_I40E_PKG_INFO_PROTOCOL_LIST); 13931 if (!ret) { 13932 printf("List of used protocols:\n"); 13933 for (i = 0; i < proto_num; i++) 13934 printf(" %2u: %s\n", proto[i].proto_id, 13935 proto[i].name); 13936 printf("\n"); 13937 } 13938 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size, 13939 (uint8_t *)&pctype_num, sizeof(pctype_num), 13940 RTE_PMD_I40E_PKG_INFO_PCTYPE_NUM); 13941 if (ret || !pctype_num) 13942 goto no_print_pctypes; 13943 13944 buff_size = pctype_num * sizeof(struct rte_pmd_i40e_ptype_info); 13945 pctype = (struct rte_pmd_i40e_ptype_info *)malloc(buff_size); 13946 if (!pctype) 13947 goto no_print_pctypes; 13948 13949 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size, (uint8_t *)pctype, 13950 buff_size, 13951 RTE_PMD_I40E_PKG_INFO_PCTYPE_LIST); 13952 if (ret) { 13953 free(pctype); 13954 goto no_print_pctypes; 13955 } 13956 13957 printf("List of defined packet classification types:\n"); 13958 for (i = 0; i < pctype_num; i++) { 13959 printf(" %2u:", pctype[i].ptype_id); 13960 for (j = 0; j < RTE_PMD_I40E_PROTO_NUM; j++) { 13961 proto_id = pctype[i].protocols[j]; 13962 if (proto_id != RTE_PMD_I40E_PROTO_UNUSED) { 13963 for (n = 0; n < proto_num; n++) { 13964 if (proto[n].proto_id == proto_id) { 13965 printf(" %s", proto[n].name); 13966 break; 13967 } 13968 } 13969 } 13970 } 13971 printf("\n"); 13972 } 13973 printf("\n"); 13974 free(pctype); 13975 13976 no_print_pctypes: 13977 13978 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size, (uint8_t *)&ptype_num, 13979 sizeof(ptype_num), 13980 RTE_PMD_I40E_PKG_INFO_PTYPE_NUM); 13981 if (ret || !ptype_num) 13982 goto no_print_return; 13983 13984 buff_size = ptype_num * sizeof(struct rte_pmd_i40e_ptype_info); 13985 ptype = (struct rte_pmd_i40e_ptype_info *)malloc(buff_size); 13986 if (!ptype) 13987 goto no_print_return; 13988 13989 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size, (uint8_t *)ptype, 13990 buff_size, 13991 RTE_PMD_I40E_PKG_INFO_PTYPE_LIST); 13992 if (ret) { 13993 free(ptype); 13994 goto no_print_return; 13995 } 13996 printf("List of defined packet types:\n"); 13997 for (i = 0; i < ptype_num; i++) { 13998 printf(" %2u:", ptype[i].ptype_id); 13999 for (j = 0; j < RTE_PMD_I40E_PROTO_NUM; j++) { 14000 proto_id = ptype[i].protocols[j]; 14001 if (proto_id != RTE_PMD_I40E_PROTO_UNUSED) { 14002 for (n = 0; n < proto_num; n++) { 14003 if (proto[n].proto_id == proto_id) { 14004 printf(" %s", proto[n].name); 14005 break; 14006 } 14007 } 14008 } 14009 } 14010 printf("\n"); 14011 } 14012 free(ptype); 14013 printf("\n"); 14014 14015 ret = 0; 14016 no_print_return: 14017 if (proto) 14018 free(proto); 14019 #endif 14020 if (ret == -ENOTSUP) 14021 printf("Function not supported in PMD driver\n"); 14022 close_file(pkg); 14023 } 14024 14025 cmdline_parse_inst_t cmd_ddp_get_info = { 14026 .f = cmd_ddp_info_parsed, 14027 .data = NULL, 14028 .help_str = "ddp get info <profile_path>", 14029 .tokens = { 14030 (void *)&cmd_ddp_info_ddp, 14031 (void *)&cmd_ddp_info_get, 14032 (void *)&cmd_ddp_info_info, 14033 (void *)&cmd_ddp_info_filepath, 14034 NULL, 14035 }, 14036 }; 14037 14038 /* Get dynamic device personalization profile info list*/ 14039 #define PROFILE_INFO_SIZE 48 14040 #define MAX_PROFILE_NUM 16 14041 14042 struct cmd_ddp_get_list_result { 14043 cmdline_fixed_string_t ddp; 14044 cmdline_fixed_string_t get; 14045 cmdline_fixed_string_t list; 14046 portid_t port_id; 14047 }; 14048 14049 cmdline_parse_token_string_t cmd_ddp_get_list_ddp = 14050 TOKEN_STRING_INITIALIZER(struct cmd_ddp_get_list_result, ddp, "ddp"); 14051 cmdline_parse_token_string_t cmd_ddp_get_list_get = 14052 TOKEN_STRING_INITIALIZER(struct cmd_ddp_get_list_result, get, "get"); 14053 cmdline_parse_token_string_t cmd_ddp_get_list_list = 14054 TOKEN_STRING_INITIALIZER(struct cmd_ddp_get_list_result, list, "list"); 14055 cmdline_parse_token_num_t cmd_ddp_get_list_port_id = 14056 TOKEN_NUM_INITIALIZER(struct cmd_ddp_get_list_result, port_id, 14057 RTE_UINT16); 14058 14059 static void 14060 cmd_ddp_get_list_parsed( 14061 __rte_unused void *parsed_result, 14062 __rte_unused struct cmdline *cl, 14063 __rte_unused void *data) 14064 { 14065 #ifdef RTE_NET_I40E 14066 struct cmd_ddp_get_list_result *res = parsed_result; 14067 struct rte_pmd_i40e_profile_list *p_list; 14068 struct rte_pmd_i40e_profile_info *p_info; 14069 uint32_t p_num; 14070 uint32_t size; 14071 uint32_t i; 14072 #endif 14073 int ret = -ENOTSUP; 14074 14075 #ifdef RTE_NET_I40E 14076 size = PROFILE_INFO_SIZE * MAX_PROFILE_NUM + 4; 14077 p_list = (struct rte_pmd_i40e_profile_list *)malloc(size); 14078 if (!p_list) { 14079 printf("%s: Failed to malloc buffer\n", __func__); 14080 return; 14081 } 14082 14083 if (ret == -ENOTSUP) 14084 ret = rte_pmd_i40e_get_ddp_list(res->port_id, 14085 (uint8_t *)p_list, size); 14086 14087 if (!ret) { 14088 p_num = p_list->p_count; 14089 printf("Profile number is: %d\n\n", p_num); 14090 14091 for (i = 0; i < p_num; i++) { 14092 p_info = &p_list->p_info[i]; 14093 printf("Profile %d:\n", i); 14094 printf("Track id: 0x%x\n", p_info->track_id); 14095 printf("Version: %d.%d.%d.%d\n", 14096 p_info->version.major, 14097 p_info->version.minor, 14098 p_info->version.update, 14099 p_info->version.draft); 14100 printf("Profile name: %s\n\n", p_info->name); 14101 } 14102 } 14103 14104 free(p_list); 14105 #endif 14106 14107 if (ret < 0) 14108 printf("Failed to get ddp list\n"); 14109 } 14110 14111 cmdline_parse_inst_t cmd_ddp_get_list = { 14112 .f = cmd_ddp_get_list_parsed, 14113 .data = NULL, 14114 .help_str = "ddp get list <port_id>", 14115 .tokens = { 14116 (void *)&cmd_ddp_get_list_ddp, 14117 (void *)&cmd_ddp_get_list_get, 14118 (void *)&cmd_ddp_get_list_list, 14119 (void *)&cmd_ddp_get_list_port_id, 14120 NULL, 14121 }, 14122 }; 14123 14124 /* Configure input set */ 14125 struct cmd_cfg_input_set_result { 14126 cmdline_fixed_string_t port; 14127 cmdline_fixed_string_t cfg; 14128 portid_t port_id; 14129 cmdline_fixed_string_t pctype; 14130 uint8_t pctype_id; 14131 cmdline_fixed_string_t inset_type; 14132 cmdline_fixed_string_t opt; 14133 cmdline_fixed_string_t field; 14134 uint8_t field_idx; 14135 }; 14136 14137 static void 14138 cmd_cfg_input_set_parsed( 14139 __rte_unused void *parsed_result, 14140 __rte_unused struct cmdline *cl, 14141 __rte_unused void *data) 14142 { 14143 #ifdef RTE_NET_I40E 14144 struct cmd_cfg_input_set_result *res = parsed_result; 14145 enum rte_pmd_i40e_inset_type inset_type = INSET_NONE; 14146 struct rte_pmd_i40e_inset inset; 14147 #endif 14148 int ret = -ENOTSUP; 14149 14150 if (!all_ports_stopped()) { 14151 printf("Please stop all ports first\n"); 14152 return; 14153 } 14154 14155 #ifdef RTE_NET_I40E 14156 if (!strcmp(res->inset_type, "hash_inset")) 14157 inset_type = INSET_HASH; 14158 else if (!strcmp(res->inset_type, "fdir_inset")) 14159 inset_type = INSET_FDIR; 14160 else if (!strcmp(res->inset_type, "fdir_flx_inset")) 14161 inset_type = INSET_FDIR_FLX; 14162 ret = rte_pmd_i40e_inset_get(res->port_id, res->pctype_id, 14163 &inset, inset_type); 14164 if (ret) { 14165 printf("Failed to get input set.\n"); 14166 return; 14167 } 14168 14169 if (!strcmp(res->opt, "get")) { 14170 ret = rte_pmd_i40e_inset_field_get(inset.inset, 14171 res->field_idx); 14172 if (ret) 14173 printf("Field index %d is enabled.\n", res->field_idx); 14174 else 14175 printf("Field index %d is disabled.\n", res->field_idx); 14176 return; 14177 } else if (!strcmp(res->opt, "set")) 14178 ret = rte_pmd_i40e_inset_field_set(&inset.inset, 14179 res->field_idx); 14180 else if (!strcmp(res->opt, "clear")) 14181 ret = rte_pmd_i40e_inset_field_clear(&inset.inset, 14182 res->field_idx); 14183 if (ret) { 14184 printf("Failed to configure input set field.\n"); 14185 return; 14186 } 14187 14188 ret = rte_pmd_i40e_inset_set(res->port_id, res->pctype_id, 14189 &inset, inset_type); 14190 if (ret) { 14191 printf("Failed to set input set.\n"); 14192 return; 14193 } 14194 #endif 14195 14196 if (ret == -ENOTSUP) 14197 printf("Function not supported\n"); 14198 } 14199 14200 cmdline_parse_token_string_t cmd_cfg_input_set_port = 14201 TOKEN_STRING_INITIALIZER(struct cmd_cfg_input_set_result, 14202 port, "port"); 14203 cmdline_parse_token_string_t cmd_cfg_input_set_cfg = 14204 TOKEN_STRING_INITIALIZER(struct cmd_cfg_input_set_result, 14205 cfg, "config"); 14206 cmdline_parse_token_num_t cmd_cfg_input_set_port_id = 14207 TOKEN_NUM_INITIALIZER(struct cmd_cfg_input_set_result, 14208 port_id, RTE_UINT16); 14209 cmdline_parse_token_string_t cmd_cfg_input_set_pctype = 14210 TOKEN_STRING_INITIALIZER(struct cmd_cfg_input_set_result, 14211 pctype, "pctype"); 14212 cmdline_parse_token_num_t cmd_cfg_input_set_pctype_id = 14213 TOKEN_NUM_INITIALIZER(struct cmd_cfg_input_set_result, 14214 pctype_id, RTE_UINT8); 14215 cmdline_parse_token_string_t cmd_cfg_input_set_inset_type = 14216 TOKEN_STRING_INITIALIZER(struct cmd_cfg_input_set_result, 14217 inset_type, 14218 "hash_inset#fdir_inset#fdir_flx_inset"); 14219 cmdline_parse_token_string_t cmd_cfg_input_set_opt = 14220 TOKEN_STRING_INITIALIZER(struct cmd_cfg_input_set_result, 14221 opt, "get#set#clear"); 14222 cmdline_parse_token_string_t cmd_cfg_input_set_field = 14223 TOKEN_STRING_INITIALIZER(struct cmd_cfg_input_set_result, 14224 field, "field"); 14225 cmdline_parse_token_num_t cmd_cfg_input_set_field_idx = 14226 TOKEN_NUM_INITIALIZER(struct cmd_cfg_input_set_result, 14227 field_idx, RTE_UINT8); 14228 14229 cmdline_parse_inst_t cmd_cfg_input_set = { 14230 .f = cmd_cfg_input_set_parsed, 14231 .data = NULL, 14232 .help_str = "port config <port_id> pctype <pctype_id> hash_inset|" 14233 "fdir_inset|fdir_flx_inset get|set|clear field <field_idx>", 14234 .tokens = { 14235 (void *)&cmd_cfg_input_set_port, 14236 (void *)&cmd_cfg_input_set_cfg, 14237 (void *)&cmd_cfg_input_set_port_id, 14238 (void *)&cmd_cfg_input_set_pctype, 14239 (void *)&cmd_cfg_input_set_pctype_id, 14240 (void *)&cmd_cfg_input_set_inset_type, 14241 (void *)&cmd_cfg_input_set_opt, 14242 (void *)&cmd_cfg_input_set_field, 14243 (void *)&cmd_cfg_input_set_field_idx, 14244 NULL, 14245 }, 14246 }; 14247 14248 /* Clear input set */ 14249 struct cmd_clear_input_set_result { 14250 cmdline_fixed_string_t port; 14251 cmdline_fixed_string_t cfg; 14252 portid_t port_id; 14253 cmdline_fixed_string_t pctype; 14254 uint8_t pctype_id; 14255 cmdline_fixed_string_t inset_type; 14256 cmdline_fixed_string_t clear; 14257 cmdline_fixed_string_t all; 14258 }; 14259 14260 static void 14261 cmd_clear_input_set_parsed( 14262 __rte_unused void *parsed_result, 14263 __rte_unused struct cmdline *cl, 14264 __rte_unused void *data) 14265 { 14266 #ifdef RTE_NET_I40E 14267 struct cmd_clear_input_set_result *res = parsed_result; 14268 enum rte_pmd_i40e_inset_type inset_type = INSET_NONE; 14269 struct rte_pmd_i40e_inset inset; 14270 #endif 14271 int ret = -ENOTSUP; 14272 14273 if (!all_ports_stopped()) { 14274 printf("Please stop all ports first\n"); 14275 return; 14276 } 14277 14278 #ifdef RTE_NET_I40E 14279 if (!strcmp(res->inset_type, "hash_inset")) 14280 inset_type = INSET_HASH; 14281 else if (!strcmp(res->inset_type, "fdir_inset")) 14282 inset_type = INSET_FDIR; 14283 else if (!strcmp(res->inset_type, "fdir_flx_inset")) 14284 inset_type = INSET_FDIR_FLX; 14285 14286 memset(&inset, 0, sizeof(inset)); 14287 14288 ret = rte_pmd_i40e_inset_set(res->port_id, res->pctype_id, 14289 &inset, inset_type); 14290 if (ret) { 14291 printf("Failed to clear input set.\n"); 14292 return; 14293 } 14294 14295 #endif 14296 14297 if (ret == -ENOTSUP) 14298 printf("Function not supported\n"); 14299 } 14300 14301 cmdline_parse_token_string_t cmd_clear_input_set_port = 14302 TOKEN_STRING_INITIALIZER(struct cmd_clear_input_set_result, 14303 port, "port"); 14304 cmdline_parse_token_string_t cmd_clear_input_set_cfg = 14305 TOKEN_STRING_INITIALIZER(struct cmd_clear_input_set_result, 14306 cfg, "config"); 14307 cmdline_parse_token_num_t cmd_clear_input_set_port_id = 14308 TOKEN_NUM_INITIALIZER(struct cmd_clear_input_set_result, 14309 port_id, RTE_UINT16); 14310 cmdline_parse_token_string_t cmd_clear_input_set_pctype = 14311 TOKEN_STRING_INITIALIZER(struct cmd_clear_input_set_result, 14312 pctype, "pctype"); 14313 cmdline_parse_token_num_t cmd_clear_input_set_pctype_id = 14314 TOKEN_NUM_INITIALIZER(struct cmd_clear_input_set_result, 14315 pctype_id, RTE_UINT8); 14316 cmdline_parse_token_string_t cmd_clear_input_set_inset_type = 14317 TOKEN_STRING_INITIALIZER(struct cmd_clear_input_set_result, 14318 inset_type, 14319 "hash_inset#fdir_inset#fdir_flx_inset"); 14320 cmdline_parse_token_string_t cmd_clear_input_set_clear = 14321 TOKEN_STRING_INITIALIZER(struct cmd_clear_input_set_result, 14322 clear, "clear"); 14323 cmdline_parse_token_string_t cmd_clear_input_set_all = 14324 TOKEN_STRING_INITIALIZER(struct cmd_clear_input_set_result, 14325 all, "all"); 14326 14327 cmdline_parse_inst_t cmd_clear_input_set = { 14328 .f = cmd_clear_input_set_parsed, 14329 .data = NULL, 14330 .help_str = "port config <port_id> pctype <pctype_id> hash_inset|" 14331 "fdir_inset|fdir_flx_inset clear all", 14332 .tokens = { 14333 (void *)&cmd_clear_input_set_port, 14334 (void *)&cmd_clear_input_set_cfg, 14335 (void *)&cmd_clear_input_set_port_id, 14336 (void *)&cmd_clear_input_set_pctype, 14337 (void *)&cmd_clear_input_set_pctype_id, 14338 (void *)&cmd_clear_input_set_inset_type, 14339 (void *)&cmd_clear_input_set_clear, 14340 (void *)&cmd_clear_input_set_all, 14341 NULL, 14342 }, 14343 }; 14344 14345 /* show vf stats */ 14346 14347 /* Common result structure for show vf stats */ 14348 struct cmd_show_vf_stats_result { 14349 cmdline_fixed_string_t show; 14350 cmdline_fixed_string_t vf; 14351 cmdline_fixed_string_t stats; 14352 portid_t port_id; 14353 uint16_t vf_id; 14354 }; 14355 14356 /* Common CLI fields show vf stats*/ 14357 cmdline_parse_token_string_t cmd_show_vf_stats_show = 14358 TOKEN_STRING_INITIALIZER 14359 (struct cmd_show_vf_stats_result, 14360 show, "show"); 14361 cmdline_parse_token_string_t cmd_show_vf_stats_vf = 14362 TOKEN_STRING_INITIALIZER 14363 (struct cmd_show_vf_stats_result, 14364 vf, "vf"); 14365 cmdline_parse_token_string_t cmd_show_vf_stats_stats = 14366 TOKEN_STRING_INITIALIZER 14367 (struct cmd_show_vf_stats_result, 14368 stats, "stats"); 14369 cmdline_parse_token_num_t cmd_show_vf_stats_port_id = 14370 TOKEN_NUM_INITIALIZER 14371 (struct cmd_show_vf_stats_result, 14372 port_id, RTE_UINT16); 14373 cmdline_parse_token_num_t cmd_show_vf_stats_vf_id = 14374 TOKEN_NUM_INITIALIZER 14375 (struct cmd_show_vf_stats_result, 14376 vf_id, RTE_UINT16); 14377 14378 static void 14379 cmd_show_vf_stats_parsed( 14380 void *parsed_result, 14381 __rte_unused struct cmdline *cl, 14382 __rte_unused void *data) 14383 { 14384 struct cmd_show_vf_stats_result *res = parsed_result; 14385 struct rte_eth_stats stats; 14386 int ret = -ENOTSUP; 14387 static const char *nic_stats_border = "########################"; 14388 14389 if (port_id_is_invalid(res->port_id, ENABLED_WARN)) 14390 return; 14391 14392 memset(&stats, 0, sizeof(stats)); 14393 14394 #ifdef RTE_NET_I40E 14395 if (ret == -ENOTSUP) 14396 ret = rte_pmd_i40e_get_vf_stats(res->port_id, 14397 res->vf_id, 14398 &stats); 14399 #endif 14400 #ifdef RTE_NET_BNXT 14401 if (ret == -ENOTSUP) 14402 ret = rte_pmd_bnxt_get_vf_stats(res->port_id, 14403 res->vf_id, 14404 &stats); 14405 #endif 14406 14407 switch (ret) { 14408 case 0: 14409 break; 14410 case -EINVAL: 14411 printf("invalid vf_id %d\n", res->vf_id); 14412 break; 14413 case -ENODEV: 14414 printf("invalid port_id %d\n", res->port_id); 14415 break; 14416 case -ENOTSUP: 14417 printf("function not implemented\n"); 14418 break; 14419 default: 14420 printf("programming error: (%s)\n", strerror(-ret)); 14421 } 14422 14423 printf("\n %s NIC statistics for port %-2d vf %-2d %s\n", 14424 nic_stats_border, res->port_id, res->vf_id, nic_stats_border); 14425 14426 printf(" RX-packets: %-10"PRIu64" RX-missed: %-10"PRIu64" RX-bytes: " 14427 "%-"PRIu64"\n", 14428 stats.ipackets, stats.imissed, stats.ibytes); 14429 printf(" RX-errors: %-"PRIu64"\n", stats.ierrors); 14430 printf(" RX-nombuf: %-10"PRIu64"\n", 14431 stats.rx_nombuf); 14432 printf(" TX-packets: %-10"PRIu64" TX-errors: %-10"PRIu64" TX-bytes: " 14433 "%-"PRIu64"\n", 14434 stats.opackets, stats.oerrors, stats.obytes); 14435 14436 printf(" %s############################%s\n", 14437 nic_stats_border, nic_stats_border); 14438 } 14439 14440 cmdline_parse_inst_t cmd_show_vf_stats = { 14441 .f = cmd_show_vf_stats_parsed, 14442 .data = NULL, 14443 .help_str = "show vf stats <port_id> <vf_id>", 14444 .tokens = { 14445 (void *)&cmd_show_vf_stats_show, 14446 (void *)&cmd_show_vf_stats_vf, 14447 (void *)&cmd_show_vf_stats_stats, 14448 (void *)&cmd_show_vf_stats_port_id, 14449 (void *)&cmd_show_vf_stats_vf_id, 14450 NULL, 14451 }, 14452 }; 14453 14454 /* clear vf stats */ 14455 14456 /* Common result structure for clear vf stats */ 14457 struct cmd_clear_vf_stats_result { 14458 cmdline_fixed_string_t clear; 14459 cmdline_fixed_string_t vf; 14460 cmdline_fixed_string_t stats; 14461 portid_t port_id; 14462 uint16_t vf_id; 14463 }; 14464 14465 /* Common CLI fields clear vf stats*/ 14466 cmdline_parse_token_string_t cmd_clear_vf_stats_clear = 14467 TOKEN_STRING_INITIALIZER 14468 (struct cmd_clear_vf_stats_result, 14469 clear, "clear"); 14470 cmdline_parse_token_string_t cmd_clear_vf_stats_vf = 14471 TOKEN_STRING_INITIALIZER 14472 (struct cmd_clear_vf_stats_result, 14473 vf, "vf"); 14474 cmdline_parse_token_string_t cmd_clear_vf_stats_stats = 14475 TOKEN_STRING_INITIALIZER 14476 (struct cmd_clear_vf_stats_result, 14477 stats, "stats"); 14478 cmdline_parse_token_num_t cmd_clear_vf_stats_port_id = 14479 TOKEN_NUM_INITIALIZER 14480 (struct cmd_clear_vf_stats_result, 14481 port_id, RTE_UINT16); 14482 cmdline_parse_token_num_t cmd_clear_vf_stats_vf_id = 14483 TOKEN_NUM_INITIALIZER 14484 (struct cmd_clear_vf_stats_result, 14485 vf_id, RTE_UINT16); 14486 14487 static void 14488 cmd_clear_vf_stats_parsed( 14489 void *parsed_result, 14490 __rte_unused struct cmdline *cl, 14491 __rte_unused void *data) 14492 { 14493 struct cmd_clear_vf_stats_result *res = parsed_result; 14494 int ret = -ENOTSUP; 14495 14496 if (port_id_is_invalid(res->port_id, ENABLED_WARN)) 14497 return; 14498 14499 #ifdef RTE_NET_I40E 14500 if (ret == -ENOTSUP) 14501 ret = rte_pmd_i40e_reset_vf_stats(res->port_id, 14502 res->vf_id); 14503 #endif 14504 #ifdef RTE_NET_BNXT 14505 if (ret == -ENOTSUP) 14506 ret = rte_pmd_bnxt_reset_vf_stats(res->port_id, 14507 res->vf_id); 14508 #endif 14509 14510 switch (ret) { 14511 case 0: 14512 break; 14513 case -EINVAL: 14514 printf("invalid vf_id %d\n", res->vf_id); 14515 break; 14516 case -ENODEV: 14517 printf("invalid port_id %d\n", res->port_id); 14518 break; 14519 case -ENOTSUP: 14520 printf("function not implemented\n"); 14521 break; 14522 default: 14523 printf("programming error: (%s)\n", strerror(-ret)); 14524 } 14525 } 14526 14527 cmdline_parse_inst_t cmd_clear_vf_stats = { 14528 .f = cmd_clear_vf_stats_parsed, 14529 .data = NULL, 14530 .help_str = "clear vf stats <port_id> <vf_id>", 14531 .tokens = { 14532 (void *)&cmd_clear_vf_stats_clear, 14533 (void *)&cmd_clear_vf_stats_vf, 14534 (void *)&cmd_clear_vf_stats_stats, 14535 (void *)&cmd_clear_vf_stats_port_id, 14536 (void *)&cmd_clear_vf_stats_vf_id, 14537 NULL, 14538 }, 14539 }; 14540 14541 /* port config pctype mapping reset */ 14542 14543 /* Common result structure for port config pctype mapping reset */ 14544 struct cmd_pctype_mapping_reset_result { 14545 cmdline_fixed_string_t port; 14546 cmdline_fixed_string_t config; 14547 portid_t port_id; 14548 cmdline_fixed_string_t pctype; 14549 cmdline_fixed_string_t mapping; 14550 cmdline_fixed_string_t reset; 14551 }; 14552 14553 /* Common CLI fields for port config pctype mapping reset*/ 14554 cmdline_parse_token_string_t cmd_pctype_mapping_reset_port = 14555 TOKEN_STRING_INITIALIZER 14556 (struct cmd_pctype_mapping_reset_result, 14557 port, "port"); 14558 cmdline_parse_token_string_t cmd_pctype_mapping_reset_config = 14559 TOKEN_STRING_INITIALIZER 14560 (struct cmd_pctype_mapping_reset_result, 14561 config, "config"); 14562 cmdline_parse_token_num_t cmd_pctype_mapping_reset_port_id = 14563 TOKEN_NUM_INITIALIZER 14564 (struct cmd_pctype_mapping_reset_result, 14565 port_id, RTE_UINT16); 14566 cmdline_parse_token_string_t cmd_pctype_mapping_reset_pctype = 14567 TOKEN_STRING_INITIALIZER 14568 (struct cmd_pctype_mapping_reset_result, 14569 pctype, "pctype"); 14570 cmdline_parse_token_string_t cmd_pctype_mapping_reset_mapping = 14571 TOKEN_STRING_INITIALIZER 14572 (struct cmd_pctype_mapping_reset_result, 14573 mapping, "mapping"); 14574 cmdline_parse_token_string_t cmd_pctype_mapping_reset_reset = 14575 TOKEN_STRING_INITIALIZER 14576 (struct cmd_pctype_mapping_reset_result, 14577 reset, "reset"); 14578 14579 static void 14580 cmd_pctype_mapping_reset_parsed( 14581 void *parsed_result, 14582 __rte_unused struct cmdline *cl, 14583 __rte_unused void *data) 14584 { 14585 struct cmd_pctype_mapping_reset_result *res = parsed_result; 14586 int ret = -ENOTSUP; 14587 14588 if (port_id_is_invalid(res->port_id, ENABLED_WARN)) 14589 return; 14590 14591 #ifdef RTE_NET_I40E 14592 ret = rte_pmd_i40e_flow_type_mapping_reset(res->port_id); 14593 #endif 14594 14595 switch (ret) { 14596 case 0: 14597 break; 14598 case -ENODEV: 14599 printf("invalid port_id %d\n", res->port_id); 14600 break; 14601 case -ENOTSUP: 14602 printf("function not implemented\n"); 14603 break; 14604 default: 14605 printf("programming error: (%s)\n", strerror(-ret)); 14606 } 14607 } 14608 14609 cmdline_parse_inst_t cmd_pctype_mapping_reset = { 14610 .f = cmd_pctype_mapping_reset_parsed, 14611 .data = NULL, 14612 .help_str = "port config <port_id> pctype mapping reset", 14613 .tokens = { 14614 (void *)&cmd_pctype_mapping_reset_port, 14615 (void *)&cmd_pctype_mapping_reset_config, 14616 (void *)&cmd_pctype_mapping_reset_port_id, 14617 (void *)&cmd_pctype_mapping_reset_pctype, 14618 (void *)&cmd_pctype_mapping_reset_mapping, 14619 (void *)&cmd_pctype_mapping_reset_reset, 14620 NULL, 14621 }, 14622 }; 14623 14624 /* show port pctype mapping */ 14625 14626 /* Common result structure for show port pctype mapping */ 14627 struct cmd_pctype_mapping_get_result { 14628 cmdline_fixed_string_t show; 14629 cmdline_fixed_string_t port; 14630 portid_t port_id; 14631 cmdline_fixed_string_t pctype; 14632 cmdline_fixed_string_t mapping; 14633 }; 14634 14635 /* Common CLI fields for pctype mapping get */ 14636 cmdline_parse_token_string_t cmd_pctype_mapping_get_show = 14637 TOKEN_STRING_INITIALIZER 14638 (struct cmd_pctype_mapping_get_result, 14639 show, "show"); 14640 cmdline_parse_token_string_t cmd_pctype_mapping_get_port = 14641 TOKEN_STRING_INITIALIZER 14642 (struct cmd_pctype_mapping_get_result, 14643 port, "port"); 14644 cmdline_parse_token_num_t cmd_pctype_mapping_get_port_id = 14645 TOKEN_NUM_INITIALIZER 14646 (struct cmd_pctype_mapping_get_result, 14647 port_id, RTE_UINT16); 14648 cmdline_parse_token_string_t cmd_pctype_mapping_get_pctype = 14649 TOKEN_STRING_INITIALIZER 14650 (struct cmd_pctype_mapping_get_result, 14651 pctype, "pctype"); 14652 cmdline_parse_token_string_t cmd_pctype_mapping_get_mapping = 14653 TOKEN_STRING_INITIALIZER 14654 (struct cmd_pctype_mapping_get_result, 14655 mapping, "mapping"); 14656 14657 static void 14658 cmd_pctype_mapping_get_parsed( 14659 void *parsed_result, 14660 __rte_unused struct cmdline *cl, 14661 __rte_unused void *data) 14662 { 14663 struct cmd_pctype_mapping_get_result *res = parsed_result; 14664 int ret = -ENOTSUP; 14665 #ifdef RTE_NET_I40E 14666 struct rte_pmd_i40e_flow_type_mapping 14667 mapping[RTE_PMD_I40E_FLOW_TYPE_MAX]; 14668 int i, j, first_pctype; 14669 #endif 14670 14671 if (port_id_is_invalid(res->port_id, ENABLED_WARN)) 14672 return; 14673 14674 #ifdef RTE_NET_I40E 14675 ret = rte_pmd_i40e_flow_type_mapping_get(res->port_id, mapping); 14676 #endif 14677 14678 switch (ret) { 14679 case 0: 14680 break; 14681 case -ENODEV: 14682 printf("invalid port_id %d\n", res->port_id); 14683 return; 14684 case -ENOTSUP: 14685 printf("function not implemented\n"); 14686 return; 14687 default: 14688 printf("programming error: (%s)\n", strerror(-ret)); 14689 return; 14690 } 14691 14692 #ifdef RTE_NET_I40E 14693 for (i = 0; i < RTE_PMD_I40E_FLOW_TYPE_MAX; i++) { 14694 if (mapping[i].pctype != 0ULL) { 14695 first_pctype = 1; 14696 14697 printf("pctype: "); 14698 for (j = 0; j < RTE_PMD_I40E_PCTYPE_MAX; j++) { 14699 if (mapping[i].pctype & (1ULL << j)) { 14700 printf(first_pctype ? 14701 "%02d" : ",%02d", j); 14702 first_pctype = 0; 14703 } 14704 } 14705 printf(" -> flowtype: %02d\n", mapping[i].flow_type); 14706 } 14707 } 14708 #endif 14709 } 14710 14711 cmdline_parse_inst_t cmd_pctype_mapping_get = { 14712 .f = cmd_pctype_mapping_get_parsed, 14713 .data = NULL, 14714 .help_str = "show port <port_id> pctype mapping", 14715 .tokens = { 14716 (void *)&cmd_pctype_mapping_get_show, 14717 (void *)&cmd_pctype_mapping_get_port, 14718 (void *)&cmd_pctype_mapping_get_port_id, 14719 (void *)&cmd_pctype_mapping_get_pctype, 14720 (void *)&cmd_pctype_mapping_get_mapping, 14721 NULL, 14722 }, 14723 }; 14724 14725 /* port config pctype mapping update */ 14726 14727 /* Common result structure for port config pctype mapping update */ 14728 struct cmd_pctype_mapping_update_result { 14729 cmdline_fixed_string_t port; 14730 cmdline_fixed_string_t config; 14731 portid_t port_id; 14732 cmdline_fixed_string_t pctype; 14733 cmdline_fixed_string_t mapping; 14734 cmdline_fixed_string_t update; 14735 cmdline_fixed_string_t pctype_list; 14736 uint16_t flow_type; 14737 }; 14738 14739 /* Common CLI fields for pctype mapping update*/ 14740 cmdline_parse_token_string_t cmd_pctype_mapping_update_port = 14741 TOKEN_STRING_INITIALIZER 14742 (struct cmd_pctype_mapping_update_result, 14743 port, "port"); 14744 cmdline_parse_token_string_t cmd_pctype_mapping_update_config = 14745 TOKEN_STRING_INITIALIZER 14746 (struct cmd_pctype_mapping_update_result, 14747 config, "config"); 14748 cmdline_parse_token_num_t cmd_pctype_mapping_update_port_id = 14749 TOKEN_NUM_INITIALIZER 14750 (struct cmd_pctype_mapping_update_result, 14751 port_id, RTE_UINT16); 14752 cmdline_parse_token_string_t cmd_pctype_mapping_update_pctype = 14753 TOKEN_STRING_INITIALIZER 14754 (struct cmd_pctype_mapping_update_result, 14755 pctype, "pctype"); 14756 cmdline_parse_token_string_t cmd_pctype_mapping_update_mapping = 14757 TOKEN_STRING_INITIALIZER 14758 (struct cmd_pctype_mapping_update_result, 14759 mapping, "mapping"); 14760 cmdline_parse_token_string_t cmd_pctype_mapping_update_update = 14761 TOKEN_STRING_INITIALIZER 14762 (struct cmd_pctype_mapping_update_result, 14763 update, "update"); 14764 cmdline_parse_token_string_t cmd_pctype_mapping_update_pc_type = 14765 TOKEN_STRING_INITIALIZER 14766 (struct cmd_pctype_mapping_update_result, 14767 pctype_list, NULL); 14768 cmdline_parse_token_num_t cmd_pctype_mapping_update_flow_type = 14769 TOKEN_NUM_INITIALIZER 14770 (struct cmd_pctype_mapping_update_result, 14771 flow_type, RTE_UINT16); 14772 14773 static void 14774 cmd_pctype_mapping_update_parsed( 14775 void *parsed_result, 14776 __rte_unused struct cmdline *cl, 14777 __rte_unused void *data) 14778 { 14779 struct cmd_pctype_mapping_update_result *res = parsed_result; 14780 int ret = -ENOTSUP; 14781 #ifdef RTE_NET_I40E 14782 struct rte_pmd_i40e_flow_type_mapping mapping; 14783 unsigned int i; 14784 unsigned int nb_item; 14785 unsigned int pctype_list[RTE_PMD_I40E_PCTYPE_MAX]; 14786 #endif 14787 14788 if (port_id_is_invalid(res->port_id, ENABLED_WARN)) 14789 return; 14790 14791 #ifdef RTE_NET_I40E 14792 nb_item = parse_item_list(res->pctype_list, "pctypes", 14793 RTE_PMD_I40E_PCTYPE_MAX, pctype_list, 1); 14794 mapping.flow_type = res->flow_type; 14795 for (i = 0, mapping.pctype = 0ULL; i < nb_item; i++) 14796 mapping.pctype |= (1ULL << pctype_list[i]); 14797 ret = rte_pmd_i40e_flow_type_mapping_update(res->port_id, 14798 &mapping, 14799 1, 14800 0); 14801 #endif 14802 14803 switch (ret) { 14804 case 0: 14805 break; 14806 case -EINVAL: 14807 printf("invalid pctype or flow type\n"); 14808 break; 14809 case -ENODEV: 14810 printf("invalid port_id %d\n", res->port_id); 14811 break; 14812 case -ENOTSUP: 14813 printf("function not implemented\n"); 14814 break; 14815 default: 14816 printf("programming error: (%s)\n", strerror(-ret)); 14817 } 14818 } 14819 14820 cmdline_parse_inst_t cmd_pctype_mapping_update = { 14821 .f = cmd_pctype_mapping_update_parsed, 14822 .data = NULL, 14823 .help_str = "port config <port_id> pctype mapping update" 14824 " <pctype_id_0,[pctype_id_1]*> <flowtype_id>", 14825 .tokens = { 14826 (void *)&cmd_pctype_mapping_update_port, 14827 (void *)&cmd_pctype_mapping_update_config, 14828 (void *)&cmd_pctype_mapping_update_port_id, 14829 (void *)&cmd_pctype_mapping_update_pctype, 14830 (void *)&cmd_pctype_mapping_update_mapping, 14831 (void *)&cmd_pctype_mapping_update_update, 14832 (void *)&cmd_pctype_mapping_update_pc_type, 14833 (void *)&cmd_pctype_mapping_update_flow_type, 14834 NULL, 14835 }, 14836 }; 14837 14838 /* ptype mapping get */ 14839 14840 /* Common result structure for ptype mapping get */ 14841 struct cmd_ptype_mapping_get_result { 14842 cmdline_fixed_string_t ptype; 14843 cmdline_fixed_string_t mapping; 14844 cmdline_fixed_string_t get; 14845 portid_t port_id; 14846 uint8_t valid_only; 14847 }; 14848 14849 /* Common CLI fields for ptype mapping get */ 14850 cmdline_parse_token_string_t cmd_ptype_mapping_get_ptype = 14851 TOKEN_STRING_INITIALIZER 14852 (struct cmd_ptype_mapping_get_result, 14853 ptype, "ptype"); 14854 cmdline_parse_token_string_t cmd_ptype_mapping_get_mapping = 14855 TOKEN_STRING_INITIALIZER 14856 (struct cmd_ptype_mapping_get_result, 14857 mapping, "mapping"); 14858 cmdline_parse_token_string_t cmd_ptype_mapping_get_get = 14859 TOKEN_STRING_INITIALIZER 14860 (struct cmd_ptype_mapping_get_result, 14861 get, "get"); 14862 cmdline_parse_token_num_t cmd_ptype_mapping_get_port_id = 14863 TOKEN_NUM_INITIALIZER 14864 (struct cmd_ptype_mapping_get_result, 14865 port_id, RTE_UINT16); 14866 cmdline_parse_token_num_t cmd_ptype_mapping_get_valid_only = 14867 TOKEN_NUM_INITIALIZER 14868 (struct cmd_ptype_mapping_get_result, 14869 valid_only, RTE_UINT8); 14870 14871 static void 14872 cmd_ptype_mapping_get_parsed( 14873 void *parsed_result, 14874 __rte_unused struct cmdline *cl, 14875 __rte_unused void *data) 14876 { 14877 struct cmd_ptype_mapping_get_result *res = parsed_result; 14878 int ret = -ENOTSUP; 14879 #ifdef RTE_NET_I40E 14880 int max_ptype_num = 256; 14881 struct rte_pmd_i40e_ptype_mapping mapping[max_ptype_num]; 14882 uint16_t count; 14883 int i; 14884 #endif 14885 14886 if (port_id_is_invalid(res->port_id, ENABLED_WARN)) 14887 return; 14888 14889 #ifdef RTE_NET_I40E 14890 ret = rte_pmd_i40e_ptype_mapping_get(res->port_id, 14891 mapping, 14892 max_ptype_num, 14893 &count, 14894 res->valid_only); 14895 #endif 14896 14897 switch (ret) { 14898 case 0: 14899 break; 14900 case -ENODEV: 14901 printf("invalid port_id %d\n", res->port_id); 14902 break; 14903 case -ENOTSUP: 14904 printf("function not implemented\n"); 14905 break; 14906 default: 14907 printf("programming error: (%s)\n", strerror(-ret)); 14908 } 14909 14910 #ifdef RTE_NET_I40E 14911 if (!ret) { 14912 for (i = 0; i < count; i++) 14913 printf("%3d\t0x%08x\n", 14914 mapping[i].hw_ptype, mapping[i].sw_ptype); 14915 } 14916 #endif 14917 } 14918 14919 cmdline_parse_inst_t cmd_ptype_mapping_get = { 14920 .f = cmd_ptype_mapping_get_parsed, 14921 .data = NULL, 14922 .help_str = "ptype mapping get <port_id> <valid_only>", 14923 .tokens = { 14924 (void *)&cmd_ptype_mapping_get_ptype, 14925 (void *)&cmd_ptype_mapping_get_mapping, 14926 (void *)&cmd_ptype_mapping_get_get, 14927 (void *)&cmd_ptype_mapping_get_port_id, 14928 (void *)&cmd_ptype_mapping_get_valid_only, 14929 NULL, 14930 }, 14931 }; 14932 14933 /* ptype mapping replace */ 14934 14935 /* Common result structure for ptype mapping replace */ 14936 struct cmd_ptype_mapping_replace_result { 14937 cmdline_fixed_string_t ptype; 14938 cmdline_fixed_string_t mapping; 14939 cmdline_fixed_string_t replace; 14940 portid_t port_id; 14941 uint32_t target; 14942 uint8_t mask; 14943 uint32_t pkt_type; 14944 }; 14945 14946 /* Common CLI fields for ptype mapping replace */ 14947 cmdline_parse_token_string_t cmd_ptype_mapping_replace_ptype = 14948 TOKEN_STRING_INITIALIZER 14949 (struct cmd_ptype_mapping_replace_result, 14950 ptype, "ptype"); 14951 cmdline_parse_token_string_t cmd_ptype_mapping_replace_mapping = 14952 TOKEN_STRING_INITIALIZER 14953 (struct cmd_ptype_mapping_replace_result, 14954 mapping, "mapping"); 14955 cmdline_parse_token_string_t cmd_ptype_mapping_replace_replace = 14956 TOKEN_STRING_INITIALIZER 14957 (struct cmd_ptype_mapping_replace_result, 14958 replace, "replace"); 14959 cmdline_parse_token_num_t cmd_ptype_mapping_replace_port_id = 14960 TOKEN_NUM_INITIALIZER 14961 (struct cmd_ptype_mapping_replace_result, 14962 port_id, RTE_UINT16); 14963 cmdline_parse_token_num_t cmd_ptype_mapping_replace_target = 14964 TOKEN_NUM_INITIALIZER 14965 (struct cmd_ptype_mapping_replace_result, 14966 target, RTE_UINT32); 14967 cmdline_parse_token_num_t cmd_ptype_mapping_replace_mask = 14968 TOKEN_NUM_INITIALIZER 14969 (struct cmd_ptype_mapping_replace_result, 14970 mask, RTE_UINT8); 14971 cmdline_parse_token_num_t cmd_ptype_mapping_replace_pkt_type = 14972 TOKEN_NUM_INITIALIZER 14973 (struct cmd_ptype_mapping_replace_result, 14974 pkt_type, RTE_UINT32); 14975 14976 static void 14977 cmd_ptype_mapping_replace_parsed( 14978 void *parsed_result, 14979 __rte_unused struct cmdline *cl, 14980 __rte_unused void *data) 14981 { 14982 struct cmd_ptype_mapping_replace_result *res = parsed_result; 14983 int ret = -ENOTSUP; 14984 14985 if (port_id_is_invalid(res->port_id, ENABLED_WARN)) 14986 return; 14987 14988 #ifdef RTE_NET_I40E 14989 ret = rte_pmd_i40e_ptype_mapping_replace(res->port_id, 14990 res->target, 14991 res->mask, 14992 res->pkt_type); 14993 #endif 14994 14995 switch (ret) { 14996 case 0: 14997 break; 14998 case -EINVAL: 14999 printf("invalid ptype 0x%8x or 0x%8x\n", 15000 res->target, res->pkt_type); 15001 break; 15002 case -ENODEV: 15003 printf("invalid port_id %d\n", res->port_id); 15004 break; 15005 case -ENOTSUP: 15006 printf("function not implemented\n"); 15007 break; 15008 default: 15009 printf("programming error: (%s)\n", strerror(-ret)); 15010 } 15011 } 15012 15013 cmdline_parse_inst_t cmd_ptype_mapping_replace = { 15014 .f = cmd_ptype_mapping_replace_parsed, 15015 .data = NULL, 15016 .help_str = 15017 "ptype mapping replace <port_id> <target> <mask> <pkt_type>", 15018 .tokens = { 15019 (void *)&cmd_ptype_mapping_replace_ptype, 15020 (void *)&cmd_ptype_mapping_replace_mapping, 15021 (void *)&cmd_ptype_mapping_replace_replace, 15022 (void *)&cmd_ptype_mapping_replace_port_id, 15023 (void *)&cmd_ptype_mapping_replace_target, 15024 (void *)&cmd_ptype_mapping_replace_mask, 15025 (void *)&cmd_ptype_mapping_replace_pkt_type, 15026 NULL, 15027 }, 15028 }; 15029 15030 /* ptype mapping reset */ 15031 15032 /* Common result structure for ptype mapping reset */ 15033 struct cmd_ptype_mapping_reset_result { 15034 cmdline_fixed_string_t ptype; 15035 cmdline_fixed_string_t mapping; 15036 cmdline_fixed_string_t reset; 15037 portid_t port_id; 15038 }; 15039 15040 /* Common CLI fields for ptype mapping reset*/ 15041 cmdline_parse_token_string_t cmd_ptype_mapping_reset_ptype = 15042 TOKEN_STRING_INITIALIZER 15043 (struct cmd_ptype_mapping_reset_result, 15044 ptype, "ptype"); 15045 cmdline_parse_token_string_t cmd_ptype_mapping_reset_mapping = 15046 TOKEN_STRING_INITIALIZER 15047 (struct cmd_ptype_mapping_reset_result, 15048 mapping, "mapping"); 15049 cmdline_parse_token_string_t cmd_ptype_mapping_reset_reset = 15050 TOKEN_STRING_INITIALIZER 15051 (struct cmd_ptype_mapping_reset_result, 15052 reset, "reset"); 15053 cmdline_parse_token_num_t cmd_ptype_mapping_reset_port_id = 15054 TOKEN_NUM_INITIALIZER 15055 (struct cmd_ptype_mapping_reset_result, 15056 port_id, RTE_UINT16); 15057 15058 static void 15059 cmd_ptype_mapping_reset_parsed( 15060 void *parsed_result, 15061 __rte_unused struct cmdline *cl, 15062 __rte_unused void *data) 15063 { 15064 struct cmd_ptype_mapping_reset_result *res = parsed_result; 15065 int ret = -ENOTSUP; 15066 15067 if (port_id_is_invalid(res->port_id, ENABLED_WARN)) 15068 return; 15069 15070 #ifdef RTE_NET_I40E 15071 ret = rte_pmd_i40e_ptype_mapping_reset(res->port_id); 15072 #endif 15073 15074 switch (ret) { 15075 case 0: 15076 break; 15077 case -ENODEV: 15078 printf("invalid port_id %d\n", res->port_id); 15079 break; 15080 case -ENOTSUP: 15081 printf("function not implemented\n"); 15082 break; 15083 default: 15084 printf("programming error: (%s)\n", strerror(-ret)); 15085 } 15086 } 15087 15088 cmdline_parse_inst_t cmd_ptype_mapping_reset = { 15089 .f = cmd_ptype_mapping_reset_parsed, 15090 .data = NULL, 15091 .help_str = "ptype mapping reset <port_id>", 15092 .tokens = { 15093 (void *)&cmd_ptype_mapping_reset_ptype, 15094 (void *)&cmd_ptype_mapping_reset_mapping, 15095 (void *)&cmd_ptype_mapping_reset_reset, 15096 (void *)&cmd_ptype_mapping_reset_port_id, 15097 NULL, 15098 }, 15099 }; 15100 15101 /* ptype mapping update */ 15102 15103 /* Common result structure for ptype mapping update */ 15104 struct cmd_ptype_mapping_update_result { 15105 cmdline_fixed_string_t ptype; 15106 cmdline_fixed_string_t mapping; 15107 cmdline_fixed_string_t reset; 15108 portid_t port_id; 15109 uint8_t hw_ptype; 15110 uint32_t sw_ptype; 15111 }; 15112 15113 /* Common CLI fields for ptype mapping update*/ 15114 cmdline_parse_token_string_t cmd_ptype_mapping_update_ptype = 15115 TOKEN_STRING_INITIALIZER 15116 (struct cmd_ptype_mapping_update_result, 15117 ptype, "ptype"); 15118 cmdline_parse_token_string_t cmd_ptype_mapping_update_mapping = 15119 TOKEN_STRING_INITIALIZER 15120 (struct cmd_ptype_mapping_update_result, 15121 mapping, "mapping"); 15122 cmdline_parse_token_string_t cmd_ptype_mapping_update_update = 15123 TOKEN_STRING_INITIALIZER 15124 (struct cmd_ptype_mapping_update_result, 15125 reset, "update"); 15126 cmdline_parse_token_num_t cmd_ptype_mapping_update_port_id = 15127 TOKEN_NUM_INITIALIZER 15128 (struct cmd_ptype_mapping_update_result, 15129 port_id, RTE_UINT16); 15130 cmdline_parse_token_num_t cmd_ptype_mapping_update_hw_ptype = 15131 TOKEN_NUM_INITIALIZER 15132 (struct cmd_ptype_mapping_update_result, 15133 hw_ptype, RTE_UINT8); 15134 cmdline_parse_token_num_t cmd_ptype_mapping_update_sw_ptype = 15135 TOKEN_NUM_INITIALIZER 15136 (struct cmd_ptype_mapping_update_result, 15137 sw_ptype, RTE_UINT32); 15138 15139 static void 15140 cmd_ptype_mapping_update_parsed( 15141 void *parsed_result, 15142 __rte_unused struct cmdline *cl, 15143 __rte_unused void *data) 15144 { 15145 struct cmd_ptype_mapping_update_result *res = parsed_result; 15146 int ret = -ENOTSUP; 15147 #ifdef RTE_NET_I40E 15148 struct rte_pmd_i40e_ptype_mapping mapping; 15149 #endif 15150 if (port_id_is_invalid(res->port_id, ENABLED_WARN)) 15151 return; 15152 15153 #ifdef RTE_NET_I40E 15154 mapping.hw_ptype = res->hw_ptype; 15155 mapping.sw_ptype = res->sw_ptype; 15156 ret = rte_pmd_i40e_ptype_mapping_update(res->port_id, 15157 &mapping, 15158 1, 15159 0); 15160 #endif 15161 15162 switch (ret) { 15163 case 0: 15164 break; 15165 case -EINVAL: 15166 printf("invalid ptype 0x%8x\n", res->sw_ptype); 15167 break; 15168 case -ENODEV: 15169 printf("invalid port_id %d\n", res->port_id); 15170 break; 15171 case -ENOTSUP: 15172 printf("function not implemented\n"); 15173 break; 15174 default: 15175 printf("programming error: (%s)\n", strerror(-ret)); 15176 } 15177 } 15178 15179 cmdline_parse_inst_t cmd_ptype_mapping_update = { 15180 .f = cmd_ptype_mapping_update_parsed, 15181 .data = NULL, 15182 .help_str = "ptype mapping update <port_id> <hw_ptype> <sw_ptype>", 15183 .tokens = { 15184 (void *)&cmd_ptype_mapping_update_ptype, 15185 (void *)&cmd_ptype_mapping_update_mapping, 15186 (void *)&cmd_ptype_mapping_update_update, 15187 (void *)&cmd_ptype_mapping_update_port_id, 15188 (void *)&cmd_ptype_mapping_update_hw_ptype, 15189 (void *)&cmd_ptype_mapping_update_sw_ptype, 15190 NULL, 15191 }, 15192 }; 15193 15194 /* Common result structure for file commands */ 15195 struct cmd_cmdfile_result { 15196 cmdline_fixed_string_t load; 15197 cmdline_fixed_string_t filename; 15198 }; 15199 15200 /* Common CLI fields for file commands */ 15201 cmdline_parse_token_string_t cmd_load_cmdfile = 15202 TOKEN_STRING_INITIALIZER(struct cmd_cmdfile_result, load, "load"); 15203 cmdline_parse_token_string_t cmd_load_cmdfile_filename = 15204 TOKEN_STRING_INITIALIZER(struct cmd_cmdfile_result, filename, NULL); 15205 15206 static void 15207 cmd_load_from_file_parsed( 15208 void *parsed_result, 15209 __rte_unused struct cmdline *cl, 15210 __rte_unused void *data) 15211 { 15212 struct cmd_cmdfile_result *res = parsed_result; 15213 15214 cmdline_read_from_file(res->filename); 15215 } 15216 15217 cmdline_parse_inst_t cmd_load_from_file = { 15218 .f = cmd_load_from_file_parsed, 15219 .data = NULL, 15220 .help_str = "load <filename>", 15221 .tokens = { 15222 (void *)&cmd_load_cmdfile, 15223 (void *)&cmd_load_cmdfile_filename, 15224 NULL, 15225 }, 15226 }; 15227 15228 /* Get Rx offloads capabilities */ 15229 struct cmd_rx_offload_get_capa_result { 15230 cmdline_fixed_string_t show; 15231 cmdline_fixed_string_t port; 15232 portid_t port_id; 15233 cmdline_fixed_string_t rx_offload; 15234 cmdline_fixed_string_t capabilities; 15235 }; 15236 15237 cmdline_parse_token_string_t cmd_rx_offload_get_capa_show = 15238 TOKEN_STRING_INITIALIZER 15239 (struct cmd_rx_offload_get_capa_result, 15240 show, "show"); 15241 cmdline_parse_token_string_t cmd_rx_offload_get_capa_port = 15242 TOKEN_STRING_INITIALIZER 15243 (struct cmd_rx_offload_get_capa_result, 15244 port, "port"); 15245 cmdline_parse_token_num_t cmd_rx_offload_get_capa_port_id = 15246 TOKEN_NUM_INITIALIZER 15247 (struct cmd_rx_offload_get_capa_result, 15248 port_id, RTE_UINT16); 15249 cmdline_parse_token_string_t cmd_rx_offload_get_capa_rx_offload = 15250 TOKEN_STRING_INITIALIZER 15251 (struct cmd_rx_offload_get_capa_result, 15252 rx_offload, "rx_offload"); 15253 cmdline_parse_token_string_t cmd_rx_offload_get_capa_capabilities = 15254 TOKEN_STRING_INITIALIZER 15255 (struct cmd_rx_offload_get_capa_result, 15256 capabilities, "capabilities"); 15257 15258 static void 15259 print_rx_offloads(uint64_t offloads) 15260 { 15261 uint64_t single_offload; 15262 int begin; 15263 int end; 15264 int bit; 15265 15266 if (offloads == 0) 15267 return; 15268 15269 begin = __builtin_ctzll(offloads); 15270 end = sizeof(offloads) * CHAR_BIT - __builtin_clzll(offloads); 15271 15272 single_offload = 1ULL << begin; 15273 for (bit = begin; bit < end; bit++) { 15274 if (offloads & single_offload) 15275 printf(" %s", 15276 rte_eth_dev_rx_offload_name(single_offload)); 15277 single_offload <<= 1; 15278 } 15279 } 15280 15281 static void 15282 cmd_rx_offload_get_capa_parsed( 15283 void *parsed_result, 15284 __rte_unused struct cmdline *cl, 15285 __rte_unused void *data) 15286 { 15287 struct cmd_rx_offload_get_capa_result *res = parsed_result; 15288 struct rte_eth_dev_info dev_info; 15289 portid_t port_id = res->port_id; 15290 uint64_t queue_offloads; 15291 uint64_t port_offloads; 15292 int ret; 15293 15294 ret = eth_dev_info_get_print_err(port_id, &dev_info); 15295 if (ret != 0) 15296 return; 15297 15298 queue_offloads = dev_info.rx_queue_offload_capa; 15299 port_offloads = dev_info.rx_offload_capa ^ queue_offloads; 15300 15301 printf("Rx Offloading Capabilities of port %d :\n", port_id); 15302 printf(" Per Queue :"); 15303 print_rx_offloads(queue_offloads); 15304 15305 printf("\n"); 15306 printf(" Per Port :"); 15307 print_rx_offloads(port_offloads); 15308 printf("\n\n"); 15309 } 15310 15311 cmdline_parse_inst_t cmd_rx_offload_get_capa = { 15312 .f = cmd_rx_offload_get_capa_parsed, 15313 .data = NULL, 15314 .help_str = "show port <port_id> rx_offload capabilities", 15315 .tokens = { 15316 (void *)&cmd_rx_offload_get_capa_show, 15317 (void *)&cmd_rx_offload_get_capa_port, 15318 (void *)&cmd_rx_offload_get_capa_port_id, 15319 (void *)&cmd_rx_offload_get_capa_rx_offload, 15320 (void *)&cmd_rx_offload_get_capa_capabilities, 15321 NULL, 15322 } 15323 }; 15324 15325 /* Get Rx offloads configuration */ 15326 struct cmd_rx_offload_get_configuration_result { 15327 cmdline_fixed_string_t show; 15328 cmdline_fixed_string_t port; 15329 portid_t port_id; 15330 cmdline_fixed_string_t rx_offload; 15331 cmdline_fixed_string_t configuration; 15332 }; 15333 15334 cmdline_parse_token_string_t cmd_rx_offload_get_configuration_show = 15335 TOKEN_STRING_INITIALIZER 15336 (struct cmd_rx_offload_get_configuration_result, 15337 show, "show"); 15338 cmdline_parse_token_string_t cmd_rx_offload_get_configuration_port = 15339 TOKEN_STRING_INITIALIZER 15340 (struct cmd_rx_offload_get_configuration_result, 15341 port, "port"); 15342 cmdline_parse_token_num_t cmd_rx_offload_get_configuration_port_id = 15343 TOKEN_NUM_INITIALIZER 15344 (struct cmd_rx_offload_get_configuration_result, 15345 port_id, RTE_UINT16); 15346 cmdline_parse_token_string_t cmd_rx_offload_get_configuration_rx_offload = 15347 TOKEN_STRING_INITIALIZER 15348 (struct cmd_rx_offload_get_configuration_result, 15349 rx_offload, "rx_offload"); 15350 cmdline_parse_token_string_t cmd_rx_offload_get_configuration_configuration = 15351 TOKEN_STRING_INITIALIZER 15352 (struct cmd_rx_offload_get_configuration_result, 15353 configuration, "configuration"); 15354 15355 static void 15356 cmd_rx_offload_get_configuration_parsed( 15357 void *parsed_result, 15358 __rte_unused struct cmdline *cl, 15359 __rte_unused void *data) 15360 { 15361 struct cmd_rx_offload_get_configuration_result *res = parsed_result; 15362 struct rte_eth_dev_info dev_info; 15363 portid_t port_id = res->port_id; 15364 struct rte_port *port = &ports[port_id]; 15365 uint64_t port_offloads; 15366 uint64_t queue_offloads; 15367 uint16_t nb_rx_queues; 15368 int q; 15369 int ret; 15370 15371 printf("Rx Offloading Configuration of port %d :\n", port_id); 15372 15373 port_offloads = port->dev_conf.rxmode.offloads; 15374 printf(" Port :"); 15375 print_rx_offloads(port_offloads); 15376 printf("\n"); 15377 15378 ret = eth_dev_info_get_print_err(port_id, &dev_info); 15379 if (ret != 0) 15380 return; 15381 15382 nb_rx_queues = dev_info.nb_rx_queues; 15383 for (q = 0; q < nb_rx_queues; q++) { 15384 queue_offloads = port->rx_conf[q].offloads; 15385 printf(" Queue[%2d] :", q); 15386 print_rx_offloads(queue_offloads); 15387 printf("\n"); 15388 } 15389 printf("\n"); 15390 } 15391 15392 cmdline_parse_inst_t cmd_rx_offload_get_configuration = { 15393 .f = cmd_rx_offload_get_configuration_parsed, 15394 .data = NULL, 15395 .help_str = "show port <port_id> rx_offload configuration", 15396 .tokens = { 15397 (void *)&cmd_rx_offload_get_configuration_show, 15398 (void *)&cmd_rx_offload_get_configuration_port, 15399 (void *)&cmd_rx_offload_get_configuration_port_id, 15400 (void *)&cmd_rx_offload_get_configuration_rx_offload, 15401 (void *)&cmd_rx_offload_get_configuration_configuration, 15402 NULL, 15403 } 15404 }; 15405 15406 /* Enable/Disable a per port offloading */ 15407 struct cmd_config_per_port_rx_offload_result { 15408 cmdline_fixed_string_t port; 15409 cmdline_fixed_string_t config; 15410 portid_t port_id; 15411 cmdline_fixed_string_t rx_offload; 15412 cmdline_fixed_string_t offload; 15413 cmdline_fixed_string_t on_off; 15414 }; 15415 15416 cmdline_parse_token_string_t cmd_config_per_port_rx_offload_result_port = 15417 TOKEN_STRING_INITIALIZER 15418 (struct cmd_config_per_port_rx_offload_result, 15419 port, "port"); 15420 cmdline_parse_token_string_t cmd_config_per_port_rx_offload_result_config = 15421 TOKEN_STRING_INITIALIZER 15422 (struct cmd_config_per_port_rx_offload_result, 15423 config, "config"); 15424 cmdline_parse_token_num_t cmd_config_per_port_rx_offload_result_port_id = 15425 TOKEN_NUM_INITIALIZER 15426 (struct cmd_config_per_port_rx_offload_result, 15427 port_id, RTE_UINT16); 15428 cmdline_parse_token_string_t cmd_config_per_port_rx_offload_result_rx_offload = 15429 TOKEN_STRING_INITIALIZER 15430 (struct cmd_config_per_port_rx_offload_result, 15431 rx_offload, "rx_offload"); 15432 cmdline_parse_token_string_t cmd_config_per_port_rx_offload_result_offload = 15433 TOKEN_STRING_INITIALIZER 15434 (struct cmd_config_per_port_rx_offload_result, 15435 offload, "vlan_strip#ipv4_cksum#udp_cksum#tcp_cksum#tcp_lro#" 15436 "qinq_strip#outer_ipv4_cksum#macsec_strip#" 15437 "header_split#vlan_filter#vlan_extend#jumbo_frame#" 15438 "scatter#buffer_split#timestamp#security#" 15439 "keep_crc#rss_hash"); 15440 cmdline_parse_token_string_t cmd_config_per_port_rx_offload_result_on_off = 15441 TOKEN_STRING_INITIALIZER 15442 (struct cmd_config_per_port_rx_offload_result, 15443 on_off, "on#off"); 15444 15445 static uint64_t 15446 search_rx_offload(const char *name) 15447 { 15448 uint64_t single_offload; 15449 const char *single_name; 15450 int found = 0; 15451 unsigned int bit; 15452 15453 single_offload = 1; 15454 for (bit = 0; bit < sizeof(single_offload) * CHAR_BIT; bit++) { 15455 single_name = rte_eth_dev_rx_offload_name(single_offload); 15456 if (!strcasecmp(single_name, name)) { 15457 found = 1; 15458 break; 15459 } 15460 single_offload <<= 1; 15461 } 15462 15463 if (found) 15464 return single_offload; 15465 15466 return 0; 15467 } 15468 15469 static void 15470 cmd_config_per_port_rx_offload_parsed(void *parsed_result, 15471 __rte_unused struct cmdline *cl, 15472 __rte_unused void *data) 15473 { 15474 struct cmd_config_per_port_rx_offload_result *res = parsed_result; 15475 portid_t port_id = res->port_id; 15476 struct rte_eth_dev_info dev_info; 15477 struct rte_port *port = &ports[port_id]; 15478 uint64_t single_offload; 15479 uint16_t nb_rx_queues; 15480 int q; 15481 int ret; 15482 15483 if (port->port_status != RTE_PORT_STOPPED) { 15484 printf("Error: Can't config offload when Port %d " 15485 "is not stopped\n", port_id); 15486 return; 15487 } 15488 15489 single_offload = search_rx_offload(res->offload); 15490 if (single_offload == 0) { 15491 printf("Unknown offload name: %s\n", res->offload); 15492 return; 15493 } 15494 15495 ret = eth_dev_info_get_print_err(port_id, &dev_info); 15496 if (ret != 0) 15497 return; 15498 15499 nb_rx_queues = dev_info.nb_rx_queues; 15500 if (!strcmp(res->on_off, "on")) { 15501 port->dev_conf.rxmode.offloads |= single_offload; 15502 for (q = 0; q < nb_rx_queues; q++) 15503 port->rx_conf[q].offloads |= single_offload; 15504 } else { 15505 port->dev_conf.rxmode.offloads &= ~single_offload; 15506 for (q = 0; q < nb_rx_queues; q++) 15507 port->rx_conf[q].offloads &= ~single_offload; 15508 } 15509 15510 cmd_reconfig_device_queue(port_id, 1, 1); 15511 } 15512 15513 cmdline_parse_inst_t cmd_config_per_port_rx_offload = { 15514 .f = cmd_config_per_port_rx_offload_parsed, 15515 .data = NULL, 15516 .help_str = "port config <port_id> rx_offload vlan_strip|ipv4_cksum|" 15517 "udp_cksum|tcp_cksum|tcp_lro|qinq_strip|outer_ipv4_cksum|" 15518 "macsec_strip|header_split|vlan_filter|vlan_extend|" 15519 "jumbo_frame|scatter|buffer_split|timestamp|security|" 15520 "keep_crc|rss_hash on|off", 15521 .tokens = { 15522 (void *)&cmd_config_per_port_rx_offload_result_port, 15523 (void *)&cmd_config_per_port_rx_offload_result_config, 15524 (void *)&cmd_config_per_port_rx_offload_result_port_id, 15525 (void *)&cmd_config_per_port_rx_offload_result_rx_offload, 15526 (void *)&cmd_config_per_port_rx_offload_result_offload, 15527 (void *)&cmd_config_per_port_rx_offload_result_on_off, 15528 NULL, 15529 } 15530 }; 15531 15532 /* Enable/Disable a per queue offloading */ 15533 struct cmd_config_per_queue_rx_offload_result { 15534 cmdline_fixed_string_t port; 15535 portid_t port_id; 15536 cmdline_fixed_string_t rxq; 15537 uint16_t queue_id; 15538 cmdline_fixed_string_t rx_offload; 15539 cmdline_fixed_string_t offload; 15540 cmdline_fixed_string_t on_off; 15541 }; 15542 15543 cmdline_parse_token_string_t cmd_config_per_queue_rx_offload_result_port = 15544 TOKEN_STRING_INITIALIZER 15545 (struct cmd_config_per_queue_rx_offload_result, 15546 port, "port"); 15547 cmdline_parse_token_num_t cmd_config_per_queue_rx_offload_result_port_id = 15548 TOKEN_NUM_INITIALIZER 15549 (struct cmd_config_per_queue_rx_offload_result, 15550 port_id, RTE_UINT16); 15551 cmdline_parse_token_string_t cmd_config_per_queue_rx_offload_result_rxq = 15552 TOKEN_STRING_INITIALIZER 15553 (struct cmd_config_per_queue_rx_offload_result, 15554 rxq, "rxq"); 15555 cmdline_parse_token_num_t cmd_config_per_queue_rx_offload_result_queue_id = 15556 TOKEN_NUM_INITIALIZER 15557 (struct cmd_config_per_queue_rx_offload_result, 15558 queue_id, RTE_UINT16); 15559 cmdline_parse_token_string_t cmd_config_per_queue_rx_offload_result_rxoffload = 15560 TOKEN_STRING_INITIALIZER 15561 (struct cmd_config_per_queue_rx_offload_result, 15562 rx_offload, "rx_offload"); 15563 cmdline_parse_token_string_t cmd_config_per_queue_rx_offload_result_offload = 15564 TOKEN_STRING_INITIALIZER 15565 (struct cmd_config_per_queue_rx_offload_result, 15566 offload, "vlan_strip#ipv4_cksum#udp_cksum#tcp_cksum#tcp_lro#" 15567 "qinq_strip#outer_ipv4_cksum#macsec_strip#" 15568 "header_split#vlan_filter#vlan_extend#jumbo_frame#" 15569 "scatter#buffer_split#timestamp#security#keep_crc"); 15570 cmdline_parse_token_string_t cmd_config_per_queue_rx_offload_result_on_off = 15571 TOKEN_STRING_INITIALIZER 15572 (struct cmd_config_per_queue_rx_offload_result, 15573 on_off, "on#off"); 15574 15575 static void 15576 cmd_config_per_queue_rx_offload_parsed(void *parsed_result, 15577 __rte_unused struct cmdline *cl, 15578 __rte_unused void *data) 15579 { 15580 struct cmd_config_per_queue_rx_offload_result *res = parsed_result; 15581 struct rte_eth_dev_info dev_info; 15582 portid_t port_id = res->port_id; 15583 uint16_t queue_id = res->queue_id; 15584 struct rte_port *port = &ports[port_id]; 15585 uint64_t single_offload; 15586 int ret; 15587 15588 if (port->port_status != RTE_PORT_STOPPED) { 15589 printf("Error: Can't config offload when Port %d " 15590 "is not stopped\n", port_id); 15591 return; 15592 } 15593 15594 ret = eth_dev_info_get_print_err(port_id, &dev_info); 15595 if (ret != 0) 15596 return; 15597 15598 if (queue_id >= dev_info.nb_rx_queues) { 15599 printf("Error: input queue_id should be 0 ... " 15600 "%d\n", dev_info.nb_rx_queues - 1); 15601 return; 15602 } 15603 15604 single_offload = search_rx_offload(res->offload); 15605 if (single_offload == 0) { 15606 printf("Unknown offload name: %s\n", res->offload); 15607 return; 15608 } 15609 15610 if (!strcmp(res->on_off, "on")) 15611 port->rx_conf[queue_id].offloads |= single_offload; 15612 else 15613 port->rx_conf[queue_id].offloads &= ~single_offload; 15614 15615 cmd_reconfig_device_queue(port_id, 1, 1); 15616 } 15617 15618 cmdline_parse_inst_t cmd_config_per_queue_rx_offload = { 15619 .f = cmd_config_per_queue_rx_offload_parsed, 15620 .data = NULL, 15621 .help_str = "port <port_id> rxq <queue_id> rx_offload " 15622 "vlan_strip|ipv4_cksum|" 15623 "udp_cksum|tcp_cksum|tcp_lro|qinq_strip|outer_ipv4_cksum|" 15624 "macsec_strip|header_split|vlan_filter|vlan_extend|" 15625 "jumbo_frame|scatter|buffer_split|timestamp|security|" 15626 "keep_crc on|off", 15627 .tokens = { 15628 (void *)&cmd_config_per_queue_rx_offload_result_port, 15629 (void *)&cmd_config_per_queue_rx_offload_result_port_id, 15630 (void *)&cmd_config_per_queue_rx_offload_result_rxq, 15631 (void *)&cmd_config_per_queue_rx_offload_result_queue_id, 15632 (void *)&cmd_config_per_queue_rx_offload_result_rxoffload, 15633 (void *)&cmd_config_per_queue_rx_offload_result_offload, 15634 (void *)&cmd_config_per_queue_rx_offload_result_on_off, 15635 NULL, 15636 } 15637 }; 15638 15639 /* Get Tx offloads capabilities */ 15640 struct cmd_tx_offload_get_capa_result { 15641 cmdline_fixed_string_t show; 15642 cmdline_fixed_string_t port; 15643 portid_t port_id; 15644 cmdline_fixed_string_t tx_offload; 15645 cmdline_fixed_string_t capabilities; 15646 }; 15647 15648 cmdline_parse_token_string_t cmd_tx_offload_get_capa_show = 15649 TOKEN_STRING_INITIALIZER 15650 (struct cmd_tx_offload_get_capa_result, 15651 show, "show"); 15652 cmdline_parse_token_string_t cmd_tx_offload_get_capa_port = 15653 TOKEN_STRING_INITIALIZER 15654 (struct cmd_tx_offload_get_capa_result, 15655 port, "port"); 15656 cmdline_parse_token_num_t cmd_tx_offload_get_capa_port_id = 15657 TOKEN_NUM_INITIALIZER 15658 (struct cmd_tx_offload_get_capa_result, 15659 port_id, RTE_UINT16); 15660 cmdline_parse_token_string_t cmd_tx_offload_get_capa_tx_offload = 15661 TOKEN_STRING_INITIALIZER 15662 (struct cmd_tx_offload_get_capa_result, 15663 tx_offload, "tx_offload"); 15664 cmdline_parse_token_string_t cmd_tx_offload_get_capa_capabilities = 15665 TOKEN_STRING_INITIALIZER 15666 (struct cmd_tx_offload_get_capa_result, 15667 capabilities, "capabilities"); 15668 15669 static void 15670 print_tx_offloads(uint64_t offloads) 15671 { 15672 uint64_t single_offload; 15673 int begin; 15674 int end; 15675 int bit; 15676 15677 if (offloads == 0) 15678 return; 15679 15680 begin = __builtin_ctzll(offloads); 15681 end = sizeof(offloads) * CHAR_BIT - __builtin_clzll(offloads); 15682 15683 single_offload = 1ULL << begin; 15684 for (bit = begin; bit < end; bit++) { 15685 if (offloads & single_offload) 15686 printf(" %s", 15687 rte_eth_dev_tx_offload_name(single_offload)); 15688 single_offload <<= 1; 15689 } 15690 } 15691 15692 static void 15693 cmd_tx_offload_get_capa_parsed( 15694 void *parsed_result, 15695 __rte_unused struct cmdline *cl, 15696 __rte_unused void *data) 15697 { 15698 struct cmd_tx_offload_get_capa_result *res = parsed_result; 15699 struct rte_eth_dev_info dev_info; 15700 portid_t port_id = res->port_id; 15701 uint64_t queue_offloads; 15702 uint64_t port_offloads; 15703 int ret; 15704 15705 ret = eth_dev_info_get_print_err(port_id, &dev_info); 15706 if (ret != 0) 15707 return; 15708 15709 queue_offloads = dev_info.tx_queue_offload_capa; 15710 port_offloads = dev_info.tx_offload_capa ^ queue_offloads; 15711 15712 printf("Tx Offloading Capabilities of port %d :\n", port_id); 15713 printf(" Per Queue :"); 15714 print_tx_offloads(queue_offloads); 15715 15716 printf("\n"); 15717 printf(" Per Port :"); 15718 print_tx_offloads(port_offloads); 15719 printf("\n\n"); 15720 } 15721 15722 cmdline_parse_inst_t cmd_tx_offload_get_capa = { 15723 .f = cmd_tx_offload_get_capa_parsed, 15724 .data = NULL, 15725 .help_str = "show port <port_id> tx_offload capabilities", 15726 .tokens = { 15727 (void *)&cmd_tx_offload_get_capa_show, 15728 (void *)&cmd_tx_offload_get_capa_port, 15729 (void *)&cmd_tx_offload_get_capa_port_id, 15730 (void *)&cmd_tx_offload_get_capa_tx_offload, 15731 (void *)&cmd_tx_offload_get_capa_capabilities, 15732 NULL, 15733 } 15734 }; 15735 15736 /* Get Tx offloads configuration */ 15737 struct cmd_tx_offload_get_configuration_result { 15738 cmdline_fixed_string_t show; 15739 cmdline_fixed_string_t port; 15740 portid_t port_id; 15741 cmdline_fixed_string_t tx_offload; 15742 cmdline_fixed_string_t configuration; 15743 }; 15744 15745 cmdline_parse_token_string_t cmd_tx_offload_get_configuration_show = 15746 TOKEN_STRING_INITIALIZER 15747 (struct cmd_tx_offload_get_configuration_result, 15748 show, "show"); 15749 cmdline_parse_token_string_t cmd_tx_offload_get_configuration_port = 15750 TOKEN_STRING_INITIALIZER 15751 (struct cmd_tx_offload_get_configuration_result, 15752 port, "port"); 15753 cmdline_parse_token_num_t cmd_tx_offload_get_configuration_port_id = 15754 TOKEN_NUM_INITIALIZER 15755 (struct cmd_tx_offload_get_configuration_result, 15756 port_id, RTE_UINT16); 15757 cmdline_parse_token_string_t cmd_tx_offload_get_configuration_tx_offload = 15758 TOKEN_STRING_INITIALIZER 15759 (struct cmd_tx_offload_get_configuration_result, 15760 tx_offload, "tx_offload"); 15761 cmdline_parse_token_string_t cmd_tx_offload_get_configuration_configuration = 15762 TOKEN_STRING_INITIALIZER 15763 (struct cmd_tx_offload_get_configuration_result, 15764 configuration, "configuration"); 15765 15766 static void 15767 cmd_tx_offload_get_configuration_parsed( 15768 void *parsed_result, 15769 __rte_unused struct cmdline *cl, 15770 __rte_unused void *data) 15771 { 15772 struct cmd_tx_offload_get_configuration_result *res = parsed_result; 15773 struct rte_eth_dev_info dev_info; 15774 portid_t port_id = res->port_id; 15775 struct rte_port *port = &ports[port_id]; 15776 uint64_t port_offloads; 15777 uint64_t queue_offloads; 15778 uint16_t nb_tx_queues; 15779 int q; 15780 int ret; 15781 15782 printf("Tx Offloading Configuration of port %d :\n", port_id); 15783 15784 port_offloads = port->dev_conf.txmode.offloads; 15785 printf(" Port :"); 15786 print_tx_offloads(port_offloads); 15787 printf("\n"); 15788 15789 ret = eth_dev_info_get_print_err(port_id, &dev_info); 15790 if (ret != 0) 15791 return; 15792 15793 nb_tx_queues = dev_info.nb_tx_queues; 15794 for (q = 0; q < nb_tx_queues; q++) { 15795 queue_offloads = port->tx_conf[q].offloads; 15796 printf(" Queue[%2d] :", q); 15797 print_tx_offloads(queue_offloads); 15798 printf("\n"); 15799 } 15800 printf("\n"); 15801 } 15802 15803 cmdline_parse_inst_t cmd_tx_offload_get_configuration = { 15804 .f = cmd_tx_offload_get_configuration_parsed, 15805 .data = NULL, 15806 .help_str = "show port <port_id> tx_offload configuration", 15807 .tokens = { 15808 (void *)&cmd_tx_offload_get_configuration_show, 15809 (void *)&cmd_tx_offload_get_configuration_port, 15810 (void *)&cmd_tx_offload_get_configuration_port_id, 15811 (void *)&cmd_tx_offload_get_configuration_tx_offload, 15812 (void *)&cmd_tx_offload_get_configuration_configuration, 15813 NULL, 15814 } 15815 }; 15816 15817 /* Enable/Disable a per port offloading */ 15818 struct cmd_config_per_port_tx_offload_result { 15819 cmdline_fixed_string_t port; 15820 cmdline_fixed_string_t config; 15821 portid_t port_id; 15822 cmdline_fixed_string_t tx_offload; 15823 cmdline_fixed_string_t offload; 15824 cmdline_fixed_string_t on_off; 15825 }; 15826 15827 cmdline_parse_token_string_t cmd_config_per_port_tx_offload_result_port = 15828 TOKEN_STRING_INITIALIZER 15829 (struct cmd_config_per_port_tx_offload_result, 15830 port, "port"); 15831 cmdline_parse_token_string_t cmd_config_per_port_tx_offload_result_config = 15832 TOKEN_STRING_INITIALIZER 15833 (struct cmd_config_per_port_tx_offload_result, 15834 config, "config"); 15835 cmdline_parse_token_num_t cmd_config_per_port_tx_offload_result_port_id = 15836 TOKEN_NUM_INITIALIZER 15837 (struct cmd_config_per_port_tx_offload_result, 15838 port_id, RTE_UINT16); 15839 cmdline_parse_token_string_t cmd_config_per_port_tx_offload_result_tx_offload = 15840 TOKEN_STRING_INITIALIZER 15841 (struct cmd_config_per_port_tx_offload_result, 15842 tx_offload, "tx_offload"); 15843 cmdline_parse_token_string_t cmd_config_per_port_tx_offload_result_offload = 15844 TOKEN_STRING_INITIALIZER 15845 (struct cmd_config_per_port_tx_offload_result, 15846 offload, "vlan_insert#ipv4_cksum#udp_cksum#tcp_cksum#" 15847 "sctp_cksum#tcp_tso#udp_tso#outer_ipv4_cksum#" 15848 "qinq_insert#vxlan_tnl_tso#gre_tnl_tso#" 15849 "ipip_tnl_tso#geneve_tnl_tso#macsec_insert#" 15850 "mt_lockfree#multi_segs#mbuf_fast_free#security#" 15851 "send_on_timestamp"); 15852 cmdline_parse_token_string_t cmd_config_per_port_tx_offload_result_on_off = 15853 TOKEN_STRING_INITIALIZER 15854 (struct cmd_config_per_port_tx_offload_result, 15855 on_off, "on#off"); 15856 15857 static uint64_t 15858 search_tx_offload(const char *name) 15859 { 15860 uint64_t single_offload; 15861 const char *single_name; 15862 int found = 0; 15863 unsigned int bit; 15864 15865 single_offload = 1; 15866 for (bit = 0; bit < sizeof(single_offload) * CHAR_BIT; bit++) { 15867 single_name = rte_eth_dev_tx_offload_name(single_offload); 15868 if (single_name == NULL) 15869 break; 15870 if (!strcasecmp(single_name, name)) { 15871 found = 1; 15872 break; 15873 } else if (!strcasecmp(single_name, "UNKNOWN")) 15874 break; 15875 single_offload <<= 1; 15876 } 15877 15878 if (found) 15879 return single_offload; 15880 15881 return 0; 15882 } 15883 15884 static void 15885 cmd_config_per_port_tx_offload_parsed(void *parsed_result, 15886 __rte_unused struct cmdline *cl, 15887 __rte_unused void *data) 15888 { 15889 struct cmd_config_per_port_tx_offload_result *res = parsed_result; 15890 portid_t port_id = res->port_id; 15891 struct rte_eth_dev_info dev_info; 15892 struct rte_port *port = &ports[port_id]; 15893 uint64_t single_offload; 15894 uint16_t nb_tx_queues; 15895 int q; 15896 int ret; 15897 15898 if (port->port_status != RTE_PORT_STOPPED) { 15899 printf("Error: Can't config offload when Port %d " 15900 "is not stopped\n", port_id); 15901 return; 15902 } 15903 15904 single_offload = search_tx_offload(res->offload); 15905 if (single_offload == 0) { 15906 printf("Unknown offload name: %s\n", res->offload); 15907 return; 15908 } 15909 15910 ret = eth_dev_info_get_print_err(port_id, &dev_info); 15911 if (ret != 0) 15912 return; 15913 15914 nb_tx_queues = dev_info.nb_tx_queues; 15915 if (!strcmp(res->on_off, "on")) { 15916 port->dev_conf.txmode.offloads |= single_offload; 15917 for (q = 0; q < nb_tx_queues; q++) 15918 port->tx_conf[q].offloads |= single_offload; 15919 } else { 15920 port->dev_conf.txmode.offloads &= ~single_offload; 15921 for (q = 0; q < nb_tx_queues; q++) 15922 port->tx_conf[q].offloads &= ~single_offload; 15923 } 15924 15925 cmd_reconfig_device_queue(port_id, 1, 1); 15926 } 15927 15928 cmdline_parse_inst_t cmd_config_per_port_tx_offload = { 15929 .f = cmd_config_per_port_tx_offload_parsed, 15930 .data = NULL, 15931 .help_str = "port config <port_id> tx_offload " 15932 "vlan_insert|ipv4_cksum|udp_cksum|tcp_cksum|" 15933 "sctp_cksum|tcp_tso|udp_tso|outer_ipv4_cksum|" 15934 "qinq_insert|vxlan_tnl_tso|gre_tnl_tso|" 15935 "ipip_tnl_tso|geneve_tnl_tso|macsec_insert|" 15936 "mt_lockfree|multi_segs|mbuf_fast_free|security|" 15937 "send_on_timestamp on|off", 15938 .tokens = { 15939 (void *)&cmd_config_per_port_tx_offload_result_port, 15940 (void *)&cmd_config_per_port_tx_offload_result_config, 15941 (void *)&cmd_config_per_port_tx_offload_result_port_id, 15942 (void *)&cmd_config_per_port_tx_offload_result_tx_offload, 15943 (void *)&cmd_config_per_port_tx_offload_result_offload, 15944 (void *)&cmd_config_per_port_tx_offload_result_on_off, 15945 NULL, 15946 } 15947 }; 15948 15949 /* Enable/Disable a per queue offloading */ 15950 struct cmd_config_per_queue_tx_offload_result { 15951 cmdline_fixed_string_t port; 15952 portid_t port_id; 15953 cmdline_fixed_string_t txq; 15954 uint16_t queue_id; 15955 cmdline_fixed_string_t tx_offload; 15956 cmdline_fixed_string_t offload; 15957 cmdline_fixed_string_t on_off; 15958 }; 15959 15960 cmdline_parse_token_string_t cmd_config_per_queue_tx_offload_result_port = 15961 TOKEN_STRING_INITIALIZER 15962 (struct cmd_config_per_queue_tx_offload_result, 15963 port, "port"); 15964 cmdline_parse_token_num_t cmd_config_per_queue_tx_offload_result_port_id = 15965 TOKEN_NUM_INITIALIZER 15966 (struct cmd_config_per_queue_tx_offload_result, 15967 port_id, RTE_UINT16); 15968 cmdline_parse_token_string_t cmd_config_per_queue_tx_offload_result_txq = 15969 TOKEN_STRING_INITIALIZER 15970 (struct cmd_config_per_queue_tx_offload_result, 15971 txq, "txq"); 15972 cmdline_parse_token_num_t cmd_config_per_queue_tx_offload_result_queue_id = 15973 TOKEN_NUM_INITIALIZER 15974 (struct cmd_config_per_queue_tx_offload_result, 15975 queue_id, RTE_UINT16); 15976 cmdline_parse_token_string_t cmd_config_per_queue_tx_offload_result_txoffload = 15977 TOKEN_STRING_INITIALIZER 15978 (struct cmd_config_per_queue_tx_offload_result, 15979 tx_offload, "tx_offload"); 15980 cmdline_parse_token_string_t cmd_config_per_queue_tx_offload_result_offload = 15981 TOKEN_STRING_INITIALIZER 15982 (struct cmd_config_per_queue_tx_offload_result, 15983 offload, "vlan_insert#ipv4_cksum#udp_cksum#tcp_cksum#" 15984 "sctp_cksum#tcp_tso#udp_tso#outer_ipv4_cksum#" 15985 "qinq_insert#vxlan_tnl_tso#gre_tnl_tso#" 15986 "ipip_tnl_tso#geneve_tnl_tso#macsec_insert#" 15987 "mt_lockfree#multi_segs#mbuf_fast_free#security"); 15988 cmdline_parse_token_string_t cmd_config_per_queue_tx_offload_result_on_off = 15989 TOKEN_STRING_INITIALIZER 15990 (struct cmd_config_per_queue_tx_offload_result, 15991 on_off, "on#off"); 15992 15993 static void 15994 cmd_config_per_queue_tx_offload_parsed(void *parsed_result, 15995 __rte_unused struct cmdline *cl, 15996 __rte_unused void *data) 15997 { 15998 struct cmd_config_per_queue_tx_offload_result *res = parsed_result; 15999 struct rte_eth_dev_info dev_info; 16000 portid_t port_id = res->port_id; 16001 uint16_t queue_id = res->queue_id; 16002 struct rte_port *port = &ports[port_id]; 16003 uint64_t single_offload; 16004 int ret; 16005 16006 if (port->port_status != RTE_PORT_STOPPED) { 16007 printf("Error: Can't config offload when Port %d " 16008 "is not stopped\n", port_id); 16009 return; 16010 } 16011 16012 ret = eth_dev_info_get_print_err(port_id, &dev_info); 16013 if (ret != 0) 16014 return; 16015 16016 if (queue_id >= dev_info.nb_tx_queues) { 16017 printf("Error: input queue_id should be 0 ... " 16018 "%d\n", dev_info.nb_tx_queues - 1); 16019 return; 16020 } 16021 16022 single_offload = search_tx_offload(res->offload); 16023 if (single_offload == 0) { 16024 printf("Unknown offload name: %s\n", res->offload); 16025 return; 16026 } 16027 16028 if (!strcmp(res->on_off, "on")) 16029 port->tx_conf[queue_id].offloads |= single_offload; 16030 else 16031 port->tx_conf[queue_id].offloads &= ~single_offload; 16032 16033 cmd_reconfig_device_queue(port_id, 1, 1); 16034 } 16035 16036 cmdline_parse_inst_t cmd_config_per_queue_tx_offload = { 16037 .f = cmd_config_per_queue_tx_offload_parsed, 16038 .data = NULL, 16039 .help_str = "port <port_id> txq <queue_id> tx_offload " 16040 "vlan_insert|ipv4_cksum|udp_cksum|tcp_cksum|" 16041 "sctp_cksum|tcp_tso|udp_tso|outer_ipv4_cksum|" 16042 "qinq_insert|vxlan_tnl_tso|gre_tnl_tso|" 16043 "ipip_tnl_tso|geneve_tnl_tso|macsec_insert|" 16044 "mt_lockfree|multi_segs|mbuf_fast_free|security " 16045 "on|off", 16046 .tokens = { 16047 (void *)&cmd_config_per_queue_tx_offload_result_port, 16048 (void *)&cmd_config_per_queue_tx_offload_result_port_id, 16049 (void *)&cmd_config_per_queue_tx_offload_result_txq, 16050 (void *)&cmd_config_per_queue_tx_offload_result_queue_id, 16051 (void *)&cmd_config_per_queue_tx_offload_result_txoffload, 16052 (void *)&cmd_config_per_queue_tx_offload_result_offload, 16053 (void *)&cmd_config_per_queue_tx_offload_result_on_off, 16054 NULL, 16055 } 16056 }; 16057 16058 /* *** configure tx_metadata for specific port *** */ 16059 struct cmd_config_tx_metadata_specific_result { 16060 cmdline_fixed_string_t port; 16061 cmdline_fixed_string_t keyword; 16062 uint16_t port_id; 16063 cmdline_fixed_string_t item; 16064 uint32_t value; 16065 }; 16066 16067 static void 16068 cmd_config_tx_metadata_specific_parsed(void *parsed_result, 16069 __rte_unused struct cmdline *cl, 16070 __rte_unused void *data) 16071 { 16072 struct cmd_config_tx_metadata_specific_result *res = parsed_result; 16073 16074 if (port_id_is_invalid(res->port_id, ENABLED_WARN)) 16075 return; 16076 ports[res->port_id].tx_metadata = res->value; 16077 /* Add/remove callback to insert valid metadata in every Tx packet. */ 16078 if (ports[res->port_id].tx_metadata) 16079 add_tx_md_callback(res->port_id); 16080 else 16081 remove_tx_md_callback(res->port_id); 16082 rte_flow_dynf_metadata_register(); 16083 } 16084 16085 cmdline_parse_token_string_t cmd_config_tx_metadata_specific_port = 16086 TOKEN_STRING_INITIALIZER(struct cmd_config_tx_metadata_specific_result, 16087 port, "port"); 16088 cmdline_parse_token_string_t cmd_config_tx_metadata_specific_keyword = 16089 TOKEN_STRING_INITIALIZER(struct cmd_config_tx_metadata_specific_result, 16090 keyword, "config"); 16091 cmdline_parse_token_num_t cmd_config_tx_metadata_specific_id = 16092 TOKEN_NUM_INITIALIZER(struct cmd_config_tx_metadata_specific_result, 16093 port_id, RTE_UINT16); 16094 cmdline_parse_token_string_t cmd_config_tx_metadata_specific_item = 16095 TOKEN_STRING_INITIALIZER(struct cmd_config_tx_metadata_specific_result, 16096 item, "tx_metadata"); 16097 cmdline_parse_token_num_t cmd_config_tx_metadata_specific_value = 16098 TOKEN_NUM_INITIALIZER(struct cmd_config_tx_metadata_specific_result, 16099 value, RTE_UINT32); 16100 16101 cmdline_parse_inst_t cmd_config_tx_metadata_specific = { 16102 .f = cmd_config_tx_metadata_specific_parsed, 16103 .data = NULL, 16104 .help_str = "port config <port_id> tx_metadata <value>", 16105 .tokens = { 16106 (void *)&cmd_config_tx_metadata_specific_port, 16107 (void *)&cmd_config_tx_metadata_specific_keyword, 16108 (void *)&cmd_config_tx_metadata_specific_id, 16109 (void *)&cmd_config_tx_metadata_specific_item, 16110 (void *)&cmd_config_tx_metadata_specific_value, 16111 NULL, 16112 }, 16113 }; 16114 16115 /* *** set dynf *** */ 16116 struct cmd_config_tx_dynf_specific_result { 16117 cmdline_fixed_string_t port; 16118 cmdline_fixed_string_t keyword; 16119 uint16_t port_id; 16120 cmdline_fixed_string_t item; 16121 cmdline_fixed_string_t name; 16122 cmdline_fixed_string_t value; 16123 }; 16124 16125 static void 16126 cmd_config_dynf_specific_parsed(void *parsed_result, 16127 __rte_unused struct cmdline *cl, 16128 __rte_unused void *data) 16129 { 16130 struct cmd_config_tx_dynf_specific_result *res = parsed_result; 16131 struct rte_mbuf_dynflag desc_flag; 16132 int flag; 16133 uint64_t old_port_flags; 16134 16135 if (port_id_is_invalid(res->port_id, ENABLED_WARN)) 16136 return; 16137 flag = rte_mbuf_dynflag_lookup(res->name, NULL); 16138 if (flag <= 0) { 16139 if (strlcpy(desc_flag.name, res->name, 16140 RTE_MBUF_DYN_NAMESIZE) >= RTE_MBUF_DYN_NAMESIZE) { 16141 printf("Flag name too long\n"); 16142 return; 16143 } 16144 desc_flag.flags = 0; 16145 flag = rte_mbuf_dynflag_register(&desc_flag); 16146 if (flag < 0) { 16147 printf("Can't register flag\n"); 16148 return; 16149 } 16150 strcpy(dynf_names[flag], desc_flag.name); 16151 } 16152 old_port_flags = ports[res->port_id].mbuf_dynf; 16153 if (!strcmp(res->value, "set")) { 16154 ports[res->port_id].mbuf_dynf |= 1UL << flag; 16155 if (old_port_flags == 0) 16156 add_tx_dynf_callback(res->port_id); 16157 } else { 16158 ports[res->port_id].mbuf_dynf &= ~(1UL << flag); 16159 if (ports[res->port_id].mbuf_dynf == 0) 16160 remove_tx_dynf_callback(res->port_id); 16161 } 16162 } 16163 16164 cmdline_parse_token_string_t cmd_config_tx_dynf_specific_port = 16165 TOKEN_STRING_INITIALIZER(struct cmd_config_tx_dynf_specific_result, 16166 keyword, "port"); 16167 cmdline_parse_token_string_t cmd_config_tx_dynf_specific_keyword = 16168 TOKEN_STRING_INITIALIZER(struct cmd_config_tx_dynf_specific_result, 16169 keyword, "config"); 16170 cmdline_parse_token_num_t cmd_config_tx_dynf_specific_port_id = 16171 TOKEN_NUM_INITIALIZER(struct cmd_config_tx_dynf_specific_result, 16172 port_id, RTE_UINT16); 16173 cmdline_parse_token_string_t cmd_config_tx_dynf_specific_item = 16174 TOKEN_STRING_INITIALIZER(struct cmd_config_tx_dynf_specific_result, 16175 item, "dynf"); 16176 cmdline_parse_token_string_t cmd_config_tx_dynf_specific_name = 16177 TOKEN_STRING_INITIALIZER(struct cmd_config_tx_dynf_specific_result, 16178 name, NULL); 16179 cmdline_parse_token_string_t cmd_config_tx_dynf_specific_value = 16180 TOKEN_STRING_INITIALIZER(struct cmd_config_tx_dynf_specific_result, 16181 value, "set#clear"); 16182 16183 cmdline_parse_inst_t cmd_config_tx_dynf_specific = { 16184 .f = cmd_config_dynf_specific_parsed, 16185 .data = NULL, 16186 .help_str = "port config <port id> dynf <name> set|clear", 16187 .tokens = { 16188 (void *)&cmd_config_tx_dynf_specific_port, 16189 (void *)&cmd_config_tx_dynf_specific_keyword, 16190 (void *)&cmd_config_tx_dynf_specific_port_id, 16191 (void *)&cmd_config_tx_dynf_specific_item, 16192 (void *)&cmd_config_tx_dynf_specific_name, 16193 (void *)&cmd_config_tx_dynf_specific_value, 16194 NULL, 16195 }, 16196 }; 16197 16198 /* *** display tx_metadata per port configuration *** */ 16199 struct cmd_show_tx_metadata_result { 16200 cmdline_fixed_string_t cmd_show; 16201 cmdline_fixed_string_t cmd_port; 16202 cmdline_fixed_string_t cmd_keyword; 16203 portid_t cmd_pid; 16204 }; 16205 16206 static void 16207 cmd_show_tx_metadata_parsed(void *parsed_result, 16208 __rte_unused struct cmdline *cl, 16209 __rte_unused void *data) 16210 { 16211 struct cmd_show_tx_metadata_result *res = parsed_result; 16212 16213 if (!rte_eth_dev_is_valid_port(res->cmd_pid)) { 16214 printf("invalid port id %u\n", res->cmd_pid); 16215 return; 16216 } 16217 if (!strcmp(res->cmd_keyword, "tx_metadata")) { 16218 printf("Port %u tx_metadata: %u\n", res->cmd_pid, 16219 ports[res->cmd_pid].tx_metadata); 16220 } 16221 } 16222 16223 cmdline_parse_token_string_t cmd_show_tx_metadata_show = 16224 TOKEN_STRING_INITIALIZER(struct cmd_show_tx_metadata_result, 16225 cmd_show, "show"); 16226 cmdline_parse_token_string_t cmd_show_tx_metadata_port = 16227 TOKEN_STRING_INITIALIZER(struct cmd_show_tx_metadata_result, 16228 cmd_port, "port"); 16229 cmdline_parse_token_num_t cmd_show_tx_metadata_pid = 16230 TOKEN_NUM_INITIALIZER(struct cmd_show_tx_metadata_result, 16231 cmd_pid, RTE_UINT16); 16232 cmdline_parse_token_string_t cmd_show_tx_metadata_keyword = 16233 TOKEN_STRING_INITIALIZER(struct cmd_show_tx_metadata_result, 16234 cmd_keyword, "tx_metadata"); 16235 16236 cmdline_parse_inst_t cmd_show_tx_metadata = { 16237 .f = cmd_show_tx_metadata_parsed, 16238 .data = NULL, 16239 .help_str = "show port <port_id> tx_metadata", 16240 .tokens = { 16241 (void *)&cmd_show_tx_metadata_show, 16242 (void *)&cmd_show_tx_metadata_port, 16243 (void *)&cmd_show_tx_metadata_pid, 16244 (void *)&cmd_show_tx_metadata_keyword, 16245 NULL, 16246 }, 16247 }; 16248 16249 /* *** show fec capability per port configuration *** */ 16250 struct cmd_show_fec_capability_result { 16251 cmdline_fixed_string_t cmd_show; 16252 cmdline_fixed_string_t cmd_port; 16253 cmdline_fixed_string_t cmd_fec; 16254 cmdline_fixed_string_t cmd_keyword; 16255 portid_t cmd_pid; 16256 }; 16257 16258 static void 16259 cmd_show_fec_capability_parsed(void *parsed_result, 16260 __rte_unused struct cmdline *cl, 16261 __rte_unused void *data) 16262 { 16263 struct cmd_show_fec_capability_result *res = parsed_result; 16264 struct rte_eth_fec_capa *speed_fec_capa; 16265 unsigned int num; 16266 int ret; 16267 16268 if (!rte_eth_dev_is_valid_port(res->cmd_pid)) { 16269 printf("Invalid port id %u\n", res->cmd_pid); 16270 return; 16271 } 16272 16273 ret = rte_eth_fec_get_capability(res->cmd_pid, NULL, 0); 16274 if (ret == -ENOTSUP) { 16275 printf("Function not implemented\n"); 16276 return; 16277 } else if (ret < 0) { 16278 printf("Get FEC capability failed: %d\n", ret); 16279 return; 16280 } 16281 16282 num = (unsigned int)ret; 16283 speed_fec_capa = calloc(num, sizeof(*speed_fec_capa)); 16284 if (speed_fec_capa == NULL) { 16285 printf("Failed to alloc FEC capability buffer\n"); 16286 return; 16287 } 16288 16289 ret = rte_eth_fec_get_capability(res->cmd_pid, speed_fec_capa, num); 16290 if (ret < 0) { 16291 printf("Error getting FEC capability: %d\n", ret); 16292 goto out; 16293 } 16294 16295 show_fec_capability(num, speed_fec_capa); 16296 out: 16297 free(speed_fec_capa); 16298 } 16299 16300 cmdline_parse_token_string_t cmd_show_fec_capability_show = 16301 TOKEN_STRING_INITIALIZER(struct cmd_show_fec_capability_result, 16302 cmd_show, "show"); 16303 cmdline_parse_token_string_t cmd_show_fec_capability_port = 16304 TOKEN_STRING_INITIALIZER(struct cmd_show_fec_capability_result, 16305 cmd_port, "port"); 16306 cmdline_parse_token_num_t cmd_show_fec_capability_pid = 16307 TOKEN_NUM_INITIALIZER(struct cmd_show_fec_capability_result, 16308 cmd_pid, RTE_UINT16); 16309 cmdline_parse_token_string_t cmd_show_fec_capability_fec = 16310 TOKEN_STRING_INITIALIZER(struct cmd_show_fec_capability_result, 16311 cmd_fec, "fec"); 16312 cmdline_parse_token_string_t cmd_show_fec_capability_keyword = 16313 TOKEN_STRING_INITIALIZER(struct cmd_show_fec_capability_result, 16314 cmd_keyword, "capabilities"); 16315 16316 cmdline_parse_inst_t cmd_show_capability = { 16317 .f = cmd_show_fec_capability_parsed, 16318 .data = NULL, 16319 .help_str = "show port <port_id> fec capabilities", 16320 .tokens = { 16321 (void *)&cmd_show_fec_capability_show, 16322 (void *)&cmd_show_fec_capability_port, 16323 (void *)&cmd_show_fec_capability_pid, 16324 (void *)&cmd_show_fec_capability_fec, 16325 (void *)&cmd_show_fec_capability_keyword, 16326 NULL, 16327 }, 16328 }; 16329 16330 /* *** show fec mode per port configuration *** */ 16331 struct cmd_show_fec_metadata_result { 16332 cmdline_fixed_string_t cmd_show; 16333 cmdline_fixed_string_t cmd_port; 16334 cmdline_fixed_string_t cmd_keyword; 16335 portid_t cmd_pid; 16336 }; 16337 16338 static void 16339 cmd_show_fec_mode_parsed(void *parsed_result, 16340 __rte_unused struct cmdline *cl, 16341 __rte_unused void *data) 16342 { 16343 #define FEC_NAME_SIZE 16 16344 struct cmd_show_fec_metadata_result *res = parsed_result; 16345 uint32_t mode; 16346 char buf[FEC_NAME_SIZE]; 16347 int ret; 16348 16349 if (!rte_eth_dev_is_valid_port(res->cmd_pid)) { 16350 printf("Invalid port id %u\n", res->cmd_pid); 16351 return; 16352 } 16353 ret = rte_eth_fec_get(res->cmd_pid, &mode); 16354 if (ret == -ENOTSUP) { 16355 printf("Function not implemented\n"); 16356 return; 16357 } else if (ret < 0) { 16358 printf("Get FEC mode failed\n"); 16359 return; 16360 } 16361 16362 switch (mode) { 16363 case RTE_ETH_FEC_MODE_CAPA_MASK(NOFEC): 16364 strlcpy(buf, "off", sizeof(buf)); 16365 break; 16366 case RTE_ETH_FEC_MODE_CAPA_MASK(AUTO): 16367 strlcpy(buf, "auto", sizeof(buf)); 16368 break; 16369 case RTE_ETH_FEC_MODE_CAPA_MASK(BASER): 16370 strlcpy(buf, "baser", sizeof(buf)); 16371 break; 16372 case RTE_ETH_FEC_MODE_CAPA_MASK(RS): 16373 strlcpy(buf, "rs", sizeof(buf)); 16374 break; 16375 default: 16376 return; 16377 } 16378 16379 printf("%s\n", buf); 16380 } 16381 16382 cmdline_parse_token_string_t cmd_show_fec_mode_show = 16383 TOKEN_STRING_INITIALIZER(struct cmd_show_fec_metadata_result, 16384 cmd_show, "show"); 16385 cmdline_parse_token_string_t cmd_show_fec_mode_port = 16386 TOKEN_STRING_INITIALIZER(struct cmd_show_fec_metadata_result, 16387 cmd_port, "port"); 16388 cmdline_parse_token_num_t cmd_show_fec_mode_pid = 16389 TOKEN_NUM_INITIALIZER(struct cmd_show_fec_metadata_result, 16390 cmd_pid, RTE_UINT16); 16391 cmdline_parse_token_string_t cmd_show_fec_mode_keyword = 16392 TOKEN_STRING_INITIALIZER(struct cmd_show_fec_metadata_result, 16393 cmd_keyword, "fec_mode"); 16394 16395 cmdline_parse_inst_t cmd_show_fec_mode = { 16396 .f = cmd_show_fec_mode_parsed, 16397 .data = NULL, 16398 .help_str = "show port <port_id> fec_mode", 16399 .tokens = { 16400 (void *)&cmd_show_fec_mode_show, 16401 (void *)&cmd_show_fec_mode_port, 16402 (void *)&cmd_show_fec_mode_pid, 16403 (void *)&cmd_show_fec_mode_keyword, 16404 NULL, 16405 }, 16406 }; 16407 16408 /* *** set fec mode per port configuration *** */ 16409 struct cmd_set_port_fec_mode { 16410 cmdline_fixed_string_t set; 16411 cmdline_fixed_string_t port; 16412 portid_t port_id; 16413 cmdline_fixed_string_t fec_mode; 16414 cmdline_fixed_string_t fec_value; 16415 }; 16416 16417 /* Common CLI fields for set fec mode */ 16418 cmdline_parse_token_string_t cmd_set_port_fec_mode_set = 16419 TOKEN_STRING_INITIALIZER 16420 (struct cmd_set_port_fec_mode, 16421 set, "set"); 16422 cmdline_parse_token_string_t cmd_set_port_fec_mode_port = 16423 TOKEN_STRING_INITIALIZER 16424 (struct cmd_set_port_fec_mode, 16425 port, "port"); 16426 cmdline_parse_token_num_t cmd_set_port_fec_mode_port_id = 16427 TOKEN_NUM_INITIALIZER 16428 (struct cmd_set_port_fec_mode, 16429 port_id, RTE_UINT16); 16430 cmdline_parse_token_string_t cmd_set_port_fec_mode_str = 16431 TOKEN_STRING_INITIALIZER 16432 (struct cmd_set_port_fec_mode, 16433 fec_mode, "fec_mode"); 16434 cmdline_parse_token_string_t cmd_set_port_fec_mode_value = 16435 TOKEN_STRING_INITIALIZER 16436 (struct cmd_set_port_fec_mode, 16437 fec_value, NULL); 16438 16439 static void 16440 cmd_set_port_fec_mode_parsed( 16441 void *parsed_result, 16442 __rte_unused struct cmdline *cl, 16443 __rte_unused void *data) 16444 { 16445 struct cmd_set_port_fec_mode *res = parsed_result; 16446 uint16_t port_id = res->port_id; 16447 uint32_t mode; 16448 int ret; 16449 16450 ret = parse_fec_mode(res->fec_value, &mode); 16451 if (ret < 0) { 16452 printf("Unknown fec mode: %s for Port %d\n", res->fec_value, 16453 port_id); 16454 return; 16455 } 16456 16457 ret = rte_eth_fec_set(port_id, mode); 16458 if (ret == -ENOTSUP) { 16459 printf("Function not implemented\n"); 16460 return; 16461 } else if (ret < 0) { 16462 printf("Set FEC mode failed\n"); 16463 return; 16464 } 16465 } 16466 16467 cmdline_parse_inst_t cmd_set_fec_mode = { 16468 .f = cmd_set_port_fec_mode_parsed, 16469 .data = NULL, 16470 .help_str = "set port <port_id> fec_mode auto|off|rs|baser", 16471 .tokens = { 16472 (void *)&cmd_set_port_fec_mode_set, 16473 (void *)&cmd_set_port_fec_mode_port, 16474 (void *)&cmd_set_port_fec_mode_port_id, 16475 (void *)&cmd_set_port_fec_mode_str, 16476 (void *)&cmd_set_port_fec_mode_value, 16477 NULL, 16478 }, 16479 }; 16480 16481 /* show port supported ptypes */ 16482 16483 /* Common result structure for show port ptypes */ 16484 struct cmd_show_port_supported_ptypes_result { 16485 cmdline_fixed_string_t show; 16486 cmdline_fixed_string_t port; 16487 portid_t port_id; 16488 cmdline_fixed_string_t ptypes; 16489 }; 16490 16491 /* Common CLI fields for show port ptypes */ 16492 cmdline_parse_token_string_t cmd_show_port_supported_ptypes_show = 16493 TOKEN_STRING_INITIALIZER 16494 (struct cmd_show_port_supported_ptypes_result, 16495 show, "show"); 16496 cmdline_parse_token_string_t cmd_show_port_supported_ptypes_port = 16497 TOKEN_STRING_INITIALIZER 16498 (struct cmd_show_port_supported_ptypes_result, 16499 port, "port"); 16500 cmdline_parse_token_num_t cmd_show_port_supported_ptypes_port_id = 16501 TOKEN_NUM_INITIALIZER 16502 (struct cmd_show_port_supported_ptypes_result, 16503 port_id, RTE_UINT16); 16504 cmdline_parse_token_string_t cmd_show_port_supported_ptypes_ptypes = 16505 TOKEN_STRING_INITIALIZER 16506 (struct cmd_show_port_supported_ptypes_result, 16507 ptypes, "ptypes"); 16508 16509 static void 16510 cmd_show_port_supported_ptypes_parsed( 16511 void *parsed_result, 16512 __rte_unused struct cmdline *cl, 16513 __rte_unused void *data) 16514 { 16515 #define RSVD_PTYPE_MASK 0xf0000000 16516 #define MAX_PTYPES_PER_LAYER 16 16517 #define LTYPE_NAMESIZE 32 16518 #define PTYPE_NAMESIZE 256 16519 struct cmd_show_port_supported_ptypes_result *res = parsed_result; 16520 char buf[PTYPE_NAMESIZE], ltype[LTYPE_NAMESIZE]; 16521 uint32_t ptype_mask = RTE_PTYPE_L2_MASK; 16522 uint32_t ptypes[MAX_PTYPES_PER_LAYER]; 16523 uint16_t port_id = res->port_id; 16524 int ret, i; 16525 16526 ret = rte_eth_dev_get_supported_ptypes(port_id, ptype_mask, NULL, 0); 16527 if (ret < 0) 16528 return; 16529 16530 while (ptype_mask != RSVD_PTYPE_MASK) { 16531 16532 switch (ptype_mask) { 16533 case RTE_PTYPE_L2_MASK: 16534 strlcpy(ltype, "L2", sizeof(ltype)); 16535 break; 16536 case RTE_PTYPE_L3_MASK: 16537 strlcpy(ltype, "L3", sizeof(ltype)); 16538 break; 16539 case RTE_PTYPE_L4_MASK: 16540 strlcpy(ltype, "L4", sizeof(ltype)); 16541 break; 16542 case RTE_PTYPE_TUNNEL_MASK: 16543 strlcpy(ltype, "Tunnel", sizeof(ltype)); 16544 break; 16545 case RTE_PTYPE_INNER_L2_MASK: 16546 strlcpy(ltype, "Inner L2", sizeof(ltype)); 16547 break; 16548 case RTE_PTYPE_INNER_L3_MASK: 16549 strlcpy(ltype, "Inner L3", sizeof(ltype)); 16550 break; 16551 case RTE_PTYPE_INNER_L4_MASK: 16552 strlcpy(ltype, "Inner L4", sizeof(ltype)); 16553 break; 16554 default: 16555 return; 16556 } 16557 16558 ret = rte_eth_dev_get_supported_ptypes(res->port_id, 16559 ptype_mask, ptypes, 16560 MAX_PTYPES_PER_LAYER); 16561 16562 if (ret > 0) 16563 printf("Supported %s ptypes:\n", ltype); 16564 else 16565 printf("%s ptypes unsupported\n", ltype); 16566 16567 for (i = 0; i < ret; ++i) { 16568 rte_get_ptype_name(ptypes[i], buf, sizeof(buf)); 16569 printf("%s\n", buf); 16570 } 16571 16572 ptype_mask <<= 4; 16573 } 16574 } 16575 16576 cmdline_parse_inst_t cmd_show_port_supported_ptypes = { 16577 .f = cmd_show_port_supported_ptypes_parsed, 16578 .data = NULL, 16579 .help_str = "show port <port_id> ptypes", 16580 .tokens = { 16581 (void *)&cmd_show_port_supported_ptypes_show, 16582 (void *)&cmd_show_port_supported_ptypes_port, 16583 (void *)&cmd_show_port_supported_ptypes_port_id, 16584 (void *)&cmd_show_port_supported_ptypes_ptypes, 16585 NULL, 16586 }, 16587 }; 16588 16589 /* *** display rx/tx descriptor status *** */ 16590 struct cmd_show_rx_tx_desc_status_result { 16591 cmdline_fixed_string_t cmd_show; 16592 cmdline_fixed_string_t cmd_port; 16593 cmdline_fixed_string_t cmd_keyword; 16594 cmdline_fixed_string_t cmd_desc; 16595 cmdline_fixed_string_t cmd_status; 16596 portid_t cmd_pid; 16597 portid_t cmd_qid; 16598 portid_t cmd_did; 16599 }; 16600 16601 static void 16602 cmd_show_rx_tx_desc_status_parsed(void *parsed_result, 16603 __rte_unused struct cmdline *cl, 16604 __rte_unused void *data) 16605 { 16606 struct cmd_show_rx_tx_desc_status_result *res = parsed_result; 16607 int rc; 16608 16609 if (!rte_eth_dev_is_valid_port(res->cmd_pid)) { 16610 printf("invalid port id %u\n", res->cmd_pid); 16611 return; 16612 } 16613 16614 if (!strcmp(res->cmd_keyword, "rxq")) { 16615 rc = rte_eth_rx_descriptor_status(res->cmd_pid, res->cmd_qid, 16616 res->cmd_did); 16617 if (rc < 0) { 16618 printf("Invalid queueid = %d\n", res->cmd_qid); 16619 return; 16620 } 16621 if (rc == RTE_ETH_RX_DESC_AVAIL) 16622 printf("Desc status = AVAILABLE\n"); 16623 else if (rc == RTE_ETH_RX_DESC_DONE) 16624 printf("Desc status = DONE\n"); 16625 else 16626 printf("Desc status = UNAVAILABLE\n"); 16627 } else if (!strcmp(res->cmd_keyword, "txq")) { 16628 rc = rte_eth_tx_descriptor_status(res->cmd_pid, res->cmd_qid, 16629 res->cmd_did); 16630 if (rc < 0) { 16631 printf("Invalid queueid = %d\n", res->cmd_qid); 16632 return; 16633 } 16634 if (rc == RTE_ETH_TX_DESC_FULL) 16635 printf("Desc status = FULL\n"); 16636 else if (rc == RTE_ETH_TX_DESC_DONE) 16637 printf("Desc status = DONE\n"); 16638 else 16639 printf("Desc status = UNAVAILABLE\n"); 16640 } 16641 } 16642 16643 cmdline_parse_token_string_t cmd_show_rx_tx_desc_status_show = 16644 TOKEN_STRING_INITIALIZER(struct cmd_show_rx_tx_desc_status_result, 16645 cmd_show, "show"); 16646 cmdline_parse_token_string_t cmd_show_rx_tx_desc_status_port = 16647 TOKEN_STRING_INITIALIZER(struct cmd_show_rx_tx_desc_status_result, 16648 cmd_port, "port"); 16649 cmdline_parse_token_num_t cmd_show_rx_tx_desc_status_pid = 16650 TOKEN_NUM_INITIALIZER(struct cmd_show_rx_tx_desc_status_result, 16651 cmd_pid, RTE_UINT16); 16652 cmdline_parse_token_string_t cmd_show_rx_tx_desc_status_keyword = 16653 TOKEN_STRING_INITIALIZER(struct cmd_show_rx_tx_desc_status_result, 16654 cmd_keyword, "rxq#txq"); 16655 cmdline_parse_token_num_t cmd_show_rx_tx_desc_status_qid = 16656 TOKEN_NUM_INITIALIZER(struct cmd_show_rx_tx_desc_status_result, 16657 cmd_qid, RTE_UINT16); 16658 cmdline_parse_token_string_t cmd_show_rx_tx_desc_status_desc = 16659 TOKEN_STRING_INITIALIZER(struct cmd_show_rx_tx_desc_status_result, 16660 cmd_desc, "desc"); 16661 cmdline_parse_token_num_t cmd_show_rx_tx_desc_status_did = 16662 TOKEN_NUM_INITIALIZER(struct cmd_show_rx_tx_desc_status_result, 16663 cmd_did, RTE_UINT16); 16664 cmdline_parse_token_string_t cmd_show_rx_tx_desc_status_status = 16665 TOKEN_STRING_INITIALIZER(struct cmd_show_rx_tx_desc_status_result, 16666 cmd_status, "status"); 16667 cmdline_parse_inst_t cmd_show_rx_tx_desc_status = { 16668 .f = cmd_show_rx_tx_desc_status_parsed, 16669 .data = NULL, 16670 .help_str = "show port <port_id> rxq|txq <queue_id> desc <desc_id> " 16671 "status", 16672 .tokens = { 16673 (void *)&cmd_show_rx_tx_desc_status_show, 16674 (void *)&cmd_show_rx_tx_desc_status_port, 16675 (void *)&cmd_show_rx_tx_desc_status_pid, 16676 (void *)&cmd_show_rx_tx_desc_status_keyword, 16677 (void *)&cmd_show_rx_tx_desc_status_qid, 16678 (void *)&cmd_show_rx_tx_desc_status_desc, 16679 (void *)&cmd_show_rx_tx_desc_status_did, 16680 (void *)&cmd_show_rx_tx_desc_status_status, 16681 NULL, 16682 }, 16683 }; 16684 16685 /* Common result structure for set port ptypes */ 16686 struct cmd_set_port_ptypes_result { 16687 cmdline_fixed_string_t set; 16688 cmdline_fixed_string_t port; 16689 portid_t port_id; 16690 cmdline_fixed_string_t ptype_mask; 16691 uint32_t mask; 16692 }; 16693 16694 /* Common CLI fields for set port ptypes */ 16695 cmdline_parse_token_string_t cmd_set_port_ptypes_set = 16696 TOKEN_STRING_INITIALIZER 16697 (struct cmd_set_port_ptypes_result, 16698 set, "set"); 16699 cmdline_parse_token_string_t cmd_set_port_ptypes_port = 16700 TOKEN_STRING_INITIALIZER 16701 (struct cmd_set_port_ptypes_result, 16702 port, "port"); 16703 cmdline_parse_token_num_t cmd_set_port_ptypes_port_id = 16704 TOKEN_NUM_INITIALIZER 16705 (struct cmd_set_port_ptypes_result, 16706 port_id, RTE_UINT16); 16707 cmdline_parse_token_string_t cmd_set_port_ptypes_mask_str = 16708 TOKEN_STRING_INITIALIZER 16709 (struct cmd_set_port_ptypes_result, 16710 ptype_mask, "ptype_mask"); 16711 cmdline_parse_token_num_t cmd_set_port_ptypes_mask_u32 = 16712 TOKEN_NUM_INITIALIZER 16713 (struct cmd_set_port_ptypes_result, 16714 mask, RTE_UINT32); 16715 16716 static void 16717 cmd_set_port_ptypes_parsed( 16718 void *parsed_result, 16719 __rte_unused struct cmdline *cl, 16720 __rte_unused void *data) 16721 { 16722 struct cmd_set_port_ptypes_result *res = parsed_result; 16723 #define PTYPE_NAMESIZE 256 16724 char ptype_name[PTYPE_NAMESIZE]; 16725 uint16_t port_id = res->port_id; 16726 uint32_t ptype_mask = res->mask; 16727 int ret, i; 16728 16729 ret = rte_eth_dev_get_supported_ptypes(port_id, RTE_PTYPE_ALL_MASK, 16730 NULL, 0); 16731 if (ret <= 0) { 16732 printf("Port %d doesn't support any ptypes.\n", port_id); 16733 return; 16734 } 16735 16736 uint32_t ptypes[ret]; 16737 16738 ret = rte_eth_dev_set_ptypes(port_id, ptype_mask, ptypes, ret); 16739 if (ret < 0) { 16740 printf("Unable to set requested ptypes for Port %d\n", port_id); 16741 return; 16742 } 16743 16744 printf("Successfully set following ptypes for Port %d\n", port_id); 16745 for (i = 0; i < ret && ptypes[i] != RTE_PTYPE_UNKNOWN; i++) { 16746 rte_get_ptype_name(ptypes[i], ptype_name, sizeof(ptype_name)); 16747 printf("%s\n", ptype_name); 16748 } 16749 16750 clear_ptypes = false; 16751 } 16752 16753 cmdline_parse_inst_t cmd_set_port_ptypes = { 16754 .f = cmd_set_port_ptypes_parsed, 16755 .data = NULL, 16756 .help_str = "set port <port_id> ptype_mask <mask>", 16757 .tokens = { 16758 (void *)&cmd_set_port_ptypes_set, 16759 (void *)&cmd_set_port_ptypes_port, 16760 (void *)&cmd_set_port_ptypes_port_id, 16761 (void *)&cmd_set_port_ptypes_mask_str, 16762 (void *)&cmd_set_port_ptypes_mask_u32, 16763 NULL, 16764 }, 16765 }; 16766 16767 /* *** display mac addresses added to a port *** */ 16768 struct cmd_showport_macs_result { 16769 cmdline_fixed_string_t cmd_show; 16770 cmdline_fixed_string_t cmd_port; 16771 cmdline_fixed_string_t cmd_keyword; 16772 portid_t cmd_pid; 16773 }; 16774 16775 static void 16776 cmd_showport_macs_parsed(void *parsed_result, 16777 __rte_unused struct cmdline *cl, 16778 __rte_unused void *data) 16779 { 16780 struct cmd_showport_macs_result *res = parsed_result; 16781 16782 if (port_id_is_invalid(res->cmd_pid, ENABLED_WARN)) 16783 return; 16784 16785 if (!strcmp(res->cmd_keyword, "macs")) 16786 show_macs(res->cmd_pid); 16787 else if (!strcmp(res->cmd_keyword, "mcast_macs")) 16788 show_mcast_macs(res->cmd_pid); 16789 } 16790 16791 cmdline_parse_token_string_t cmd_showport_macs_show = 16792 TOKEN_STRING_INITIALIZER(struct cmd_showport_macs_result, 16793 cmd_show, "show"); 16794 cmdline_parse_token_string_t cmd_showport_macs_port = 16795 TOKEN_STRING_INITIALIZER(struct cmd_showport_macs_result, 16796 cmd_port, "port"); 16797 cmdline_parse_token_num_t cmd_showport_macs_pid = 16798 TOKEN_NUM_INITIALIZER(struct cmd_showport_macs_result, 16799 cmd_pid, RTE_UINT16); 16800 cmdline_parse_token_string_t cmd_showport_macs_keyword = 16801 TOKEN_STRING_INITIALIZER(struct cmd_showport_macs_result, 16802 cmd_keyword, "macs#mcast_macs"); 16803 16804 cmdline_parse_inst_t cmd_showport_macs = { 16805 .f = cmd_showport_macs_parsed, 16806 .data = NULL, 16807 .help_str = "show port <port_id> macs|mcast_macs", 16808 .tokens = { 16809 (void *)&cmd_showport_macs_show, 16810 (void *)&cmd_showport_macs_port, 16811 (void *)&cmd_showport_macs_pid, 16812 (void *)&cmd_showport_macs_keyword, 16813 NULL, 16814 }, 16815 }; 16816 16817 /* ******************************************************************************** */ 16818 16819 /* list of instructions */ 16820 cmdline_parse_ctx_t main_ctx[] = { 16821 (cmdline_parse_inst_t *)&cmd_help_brief, 16822 (cmdline_parse_inst_t *)&cmd_help_long, 16823 (cmdline_parse_inst_t *)&cmd_quit, 16824 (cmdline_parse_inst_t *)&cmd_load_from_file, 16825 (cmdline_parse_inst_t *)&cmd_showport, 16826 (cmdline_parse_inst_t *)&cmd_showqueue, 16827 (cmdline_parse_inst_t *)&cmd_showeeprom, 16828 (cmdline_parse_inst_t *)&cmd_showportall, 16829 (cmdline_parse_inst_t *)&cmd_showdevice, 16830 (cmdline_parse_inst_t *)&cmd_showcfg, 16831 (cmdline_parse_inst_t *)&cmd_showfwdall, 16832 (cmdline_parse_inst_t *)&cmd_start, 16833 (cmdline_parse_inst_t *)&cmd_start_tx_first, 16834 (cmdline_parse_inst_t *)&cmd_start_tx_first_n, 16835 (cmdline_parse_inst_t *)&cmd_set_link_up, 16836 (cmdline_parse_inst_t *)&cmd_set_link_down, 16837 (cmdline_parse_inst_t *)&cmd_reset, 16838 (cmdline_parse_inst_t *)&cmd_set_numbers, 16839 (cmdline_parse_inst_t *)&cmd_set_log, 16840 (cmdline_parse_inst_t *)&cmd_set_rxoffs, 16841 (cmdline_parse_inst_t *)&cmd_set_rxpkts, 16842 (cmdline_parse_inst_t *)&cmd_set_txpkts, 16843 (cmdline_parse_inst_t *)&cmd_set_txsplit, 16844 (cmdline_parse_inst_t *)&cmd_set_txtimes, 16845 (cmdline_parse_inst_t *)&cmd_set_fwd_list, 16846 (cmdline_parse_inst_t *)&cmd_set_fwd_mask, 16847 (cmdline_parse_inst_t *)&cmd_set_fwd_mode, 16848 (cmdline_parse_inst_t *)&cmd_set_fwd_retry_mode, 16849 (cmdline_parse_inst_t *)&cmd_set_burst_tx_retry, 16850 (cmdline_parse_inst_t *)&cmd_set_promisc_mode_one, 16851 (cmdline_parse_inst_t *)&cmd_set_promisc_mode_all, 16852 (cmdline_parse_inst_t *)&cmd_set_allmulti_mode_one, 16853 (cmdline_parse_inst_t *)&cmd_set_allmulti_mode_all, 16854 (cmdline_parse_inst_t *)&cmd_set_flush_rx, 16855 (cmdline_parse_inst_t *)&cmd_set_link_check, 16856 (cmdline_parse_inst_t *)&cmd_set_bypass_mode, 16857 (cmdline_parse_inst_t *)&cmd_set_bypass_event, 16858 (cmdline_parse_inst_t *)&cmd_set_bypass_timeout, 16859 (cmdline_parse_inst_t *)&cmd_show_bypass_config, 16860 #ifdef RTE_NET_BOND 16861 (cmdline_parse_inst_t *) &cmd_set_bonding_mode, 16862 (cmdline_parse_inst_t *) &cmd_show_bonding_config, 16863 (cmdline_parse_inst_t *) &cmd_set_bonding_primary, 16864 (cmdline_parse_inst_t *) &cmd_add_bonding_slave, 16865 (cmdline_parse_inst_t *) &cmd_remove_bonding_slave, 16866 (cmdline_parse_inst_t *) &cmd_create_bonded_device, 16867 (cmdline_parse_inst_t *) &cmd_set_bond_mac_addr, 16868 (cmdline_parse_inst_t *) &cmd_set_balance_xmit_policy, 16869 (cmdline_parse_inst_t *) &cmd_set_bond_mon_period, 16870 (cmdline_parse_inst_t *) &cmd_set_lacp_dedicated_queues, 16871 (cmdline_parse_inst_t *) &cmd_set_bonding_agg_mode_policy, 16872 #endif 16873 (cmdline_parse_inst_t *)&cmd_vlan_offload, 16874 (cmdline_parse_inst_t *)&cmd_vlan_tpid, 16875 (cmdline_parse_inst_t *)&cmd_rx_vlan_filter_all, 16876 (cmdline_parse_inst_t *)&cmd_rx_vlan_filter, 16877 (cmdline_parse_inst_t *)&cmd_tx_vlan_set, 16878 (cmdline_parse_inst_t *)&cmd_tx_vlan_set_qinq, 16879 (cmdline_parse_inst_t *)&cmd_tx_vlan_reset, 16880 (cmdline_parse_inst_t *)&cmd_tx_vlan_set_pvid, 16881 (cmdline_parse_inst_t *)&cmd_csum_set, 16882 (cmdline_parse_inst_t *)&cmd_csum_show, 16883 (cmdline_parse_inst_t *)&cmd_csum_tunnel, 16884 (cmdline_parse_inst_t *)&cmd_tso_set, 16885 (cmdline_parse_inst_t *)&cmd_tso_show, 16886 (cmdline_parse_inst_t *)&cmd_tunnel_tso_set, 16887 (cmdline_parse_inst_t *)&cmd_tunnel_tso_show, 16888 (cmdline_parse_inst_t *)&cmd_gro_enable, 16889 (cmdline_parse_inst_t *)&cmd_gro_flush, 16890 (cmdline_parse_inst_t *)&cmd_gro_show, 16891 (cmdline_parse_inst_t *)&cmd_gso_enable, 16892 (cmdline_parse_inst_t *)&cmd_gso_size, 16893 (cmdline_parse_inst_t *)&cmd_gso_show, 16894 (cmdline_parse_inst_t *)&cmd_link_flow_control_set, 16895 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_rx, 16896 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_tx, 16897 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_hw, 16898 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_lw, 16899 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_pt, 16900 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_xon, 16901 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_macfwd, 16902 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_autoneg, 16903 (cmdline_parse_inst_t *)&cmd_priority_flow_control_set, 16904 (cmdline_parse_inst_t *)&cmd_config_dcb, 16905 (cmdline_parse_inst_t *)&cmd_read_reg, 16906 (cmdline_parse_inst_t *)&cmd_read_reg_bit_field, 16907 (cmdline_parse_inst_t *)&cmd_read_reg_bit, 16908 (cmdline_parse_inst_t *)&cmd_write_reg, 16909 (cmdline_parse_inst_t *)&cmd_write_reg_bit_field, 16910 (cmdline_parse_inst_t *)&cmd_write_reg_bit, 16911 (cmdline_parse_inst_t *)&cmd_read_rxd_txd, 16912 (cmdline_parse_inst_t *)&cmd_stop, 16913 (cmdline_parse_inst_t *)&cmd_mac_addr, 16914 (cmdline_parse_inst_t *)&cmd_set_fwd_eth_peer, 16915 (cmdline_parse_inst_t *)&cmd_set_qmap, 16916 (cmdline_parse_inst_t *)&cmd_set_xstats_hide_zero, 16917 (cmdline_parse_inst_t *)&cmd_set_record_core_cycles, 16918 (cmdline_parse_inst_t *)&cmd_set_record_burst_stats, 16919 (cmdline_parse_inst_t *)&cmd_operate_port, 16920 (cmdline_parse_inst_t *)&cmd_operate_specific_port, 16921 (cmdline_parse_inst_t *)&cmd_operate_attach_port, 16922 (cmdline_parse_inst_t *)&cmd_operate_detach_port, 16923 (cmdline_parse_inst_t *)&cmd_operate_detach_device, 16924 (cmdline_parse_inst_t *)&cmd_set_port_setup_on, 16925 (cmdline_parse_inst_t *)&cmd_config_speed_all, 16926 (cmdline_parse_inst_t *)&cmd_config_speed_specific, 16927 (cmdline_parse_inst_t *)&cmd_config_loopback_all, 16928 (cmdline_parse_inst_t *)&cmd_config_loopback_specific, 16929 (cmdline_parse_inst_t *)&cmd_config_rx_tx, 16930 (cmdline_parse_inst_t *)&cmd_config_mtu, 16931 (cmdline_parse_inst_t *)&cmd_config_max_pkt_len, 16932 (cmdline_parse_inst_t *)&cmd_config_max_lro_pkt_size, 16933 (cmdline_parse_inst_t *)&cmd_config_rx_mode_flag, 16934 (cmdline_parse_inst_t *)&cmd_config_rss, 16935 (cmdline_parse_inst_t *)&cmd_config_rxtx_ring_size, 16936 (cmdline_parse_inst_t *)&cmd_config_rxtx_queue, 16937 (cmdline_parse_inst_t *)&cmd_config_deferred_start_rxtx_queue, 16938 (cmdline_parse_inst_t *)&cmd_setup_rxtx_queue, 16939 (cmdline_parse_inst_t *)&cmd_config_rss_reta, 16940 (cmdline_parse_inst_t *)&cmd_showport_reta, 16941 (cmdline_parse_inst_t *)&cmd_showport_macs, 16942 (cmdline_parse_inst_t *)&cmd_config_burst, 16943 (cmdline_parse_inst_t *)&cmd_config_thresh, 16944 (cmdline_parse_inst_t *)&cmd_config_threshold, 16945 (cmdline_parse_inst_t *)&cmd_set_uc_hash_filter, 16946 (cmdline_parse_inst_t *)&cmd_set_uc_all_hash_filter, 16947 (cmdline_parse_inst_t *)&cmd_vf_mac_addr_filter, 16948 (cmdline_parse_inst_t *)&cmd_queue_rate_limit, 16949 (cmdline_parse_inst_t *)&cmd_tunnel_udp_config, 16950 (cmdline_parse_inst_t *)&cmd_set_mirror_mask, 16951 (cmdline_parse_inst_t *)&cmd_set_mirror_link, 16952 (cmdline_parse_inst_t *)&cmd_reset_mirror_rule, 16953 (cmdline_parse_inst_t *)&cmd_showport_rss_hash, 16954 (cmdline_parse_inst_t *)&cmd_showport_rss_hash_key, 16955 (cmdline_parse_inst_t *)&cmd_config_rss_hash_key, 16956 (cmdline_parse_inst_t *)&cmd_dump, 16957 (cmdline_parse_inst_t *)&cmd_dump_one, 16958 #ifdef RTE_NET_I40E 16959 (cmdline_parse_inst_t *)&cmd_add_del_raw_flow_director, 16960 #endif 16961 (cmdline_parse_inst_t *)&cmd_set_flow_director_ip_mask, 16962 (cmdline_parse_inst_t *)&cmd_set_flow_director_mac_vlan_mask, 16963 (cmdline_parse_inst_t *)&cmd_set_flow_director_tunnel_mask, 16964 (cmdline_parse_inst_t *)&cmd_set_flow_director_flex_payload, 16965 (cmdline_parse_inst_t *)&cmd_flow, 16966 (cmdline_parse_inst_t *)&cmd_show_port_meter_cap, 16967 (cmdline_parse_inst_t *)&cmd_add_port_meter_profile_srtcm, 16968 (cmdline_parse_inst_t *)&cmd_add_port_meter_profile_trtcm, 16969 (cmdline_parse_inst_t *)&cmd_del_port_meter_profile, 16970 (cmdline_parse_inst_t *)&cmd_create_port_meter, 16971 (cmdline_parse_inst_t *)&cmd_enable_port_meter, 16972 (cmdline_parse_inst_t *)&cmd_disable_port_meter, 16973 (cmdline_parse_inst_t *)&cmd_del_port_meter, 16974 (cmdline_parse_inst_t *)&cmd_set_port_meter_profile, 16975 (cmdline_parse_inst_t *)&cmd_set_port_meter_dscp_table, 16976 (cmdline_parse_inst_t *)&cmd_set_port_meter_policer_action, 16977 (cmdline_parse_inst_t *)&cmd_set_port_meter_stats_mask, 16978 (cmdline_parse_inst_t *)&cmd_show_port_meter_stats, 16979 (cmdline_parse_inst_t *)&cmd_mcast_addr, 16980 (cmdline_parse_inst_t *)&cmd_set_vf_vlan_anti_spoof, 16981 (cmdline_parse_inst_t *)&cmd_set_vf_mac_anti_spoof, 16982 (cmdline_parse_inst_t *)&cmd_set_vf_vlan_stripq, 16983 (cmdline_parse_inst_t *)&cmd_set_vf_vlan_insert, 16984 (cmdline_parse_inst_t *)&cmd_set_tx_loopback, 16985 (cmdline_parse_inst_t *)&cmd_set_all_queues_drop_en, 16986 (cmdline_parse_inst_t *)&cmd_set_vf_split_drop_en, 16987 (cmdline_parse_inst_t *)&cmd_set_macsec_offload_on, 16988 (cmdline_parse_inst_t *)&cmd_set_macsec_offload_off, 16989 (cmdline_parse_inst_t *)&cmd_set_macsec_sc, 16990 (cmdline_parse_inst_t *)&cmd_set_macsec_sa, 16991 (cmdline_parse_inst_t *)&cmd_set_vf_traffic, 16992 (cmdline_parse_inst_t *)&cmd_set_vf_rxmode, 16993 (cmdline_parse_inst_t *)&cmd_vf_rate_limit, 16994 (cmdline_parse_inst_t *)&cmd_vf_rxvlan_filter, 16995 (cmdline_parse_inst_t *)&cmd_set_vf_mac_addr, 16996 (cmdline_parse_inst_t *)&cmd_set_vf_promisc, 16997 (cmdline_parse_inst_t *)&cmd_set_vf_allmulti, 16998 (cmdline_parse_inst_t *)&cmd_set_vf_broadcast, 16999 (cmdline_parse_inst_t *)&cmd_set_vf_vlan_tag, 17000 (cmdline_parse_inst_t *)&cmd_vf_max_bw, 17001 (cmdline_parse_inst_t *)&cmd_vf_tc_min_bw, 17002 (cmdline_parse_inst_t *)&cmd_vf_tc_max_bw, 17003 (cmdline_parse_inst_t *)&cmd_strict_link_prio, 17004 (cmdline_parse_inst_t *)&cmd_tc_min_bw, 17005 (cmdline_parse_inst_t *)&cmd_set_vxlan, 17006 (cmdline_parse_inst_t *)&cmd_set_vxlan_tos_ttl, 17007 (cmdline_parse_inst_t *)&cmd_set_vxlan_with_vlan, 17008 (cmdline_parse_inst_t *)&cmd_set_nvgre, 17009 (cmdline_parse_inst_t *)&cmd_set_nvgre_with_vlan, 17010 (cmdline_parse_inst_t *)&cmd_set_l2_encap, 17011 (cmdline_parse_inst_t *)&cmd_set_l2_encap_with_vlan, 17012 (cmdline_parse_inst_t *)&cmd_set_l2_decap, 17013 (cmdline_parse_inst_t *)&cmd_set_l2_decap_with_vlan, 17014 (cmdline_parse_inst_t *)&cmd_set_mplsogre_encap, 17015 (cmdline_parse_inst_t *)&cmd_set_mplsogre_encap_with_vlan, 17016 (cmdline_parse_inst_t *)&cmd_set_mplsogre_decap, 17017 (cmdline_parse_inst_t *)&cmd_set_mplsogre_decap_with_vlan, 17018 (cmdline_parse_inst_t *)&cmd_set_mplsoudp_encap, 17019 (cmdline_parse_inst_t *)&cmd_set_mplsoudp_encap_with_vlan, 17020 (cmdline_parse_inst_t *)&cmd_set_mplsoudp_decap, 17021 (cmdline_parse_inst_t *)&cmd_set_mplsoudp_decap_with_vlan, 17022 (cmdline_parse_inst_t *)&cmd_ddp_add, 17023 (cmdline_parse_inst_t *)&cmd_ddp_del, 17024 (cmdline_parse_inst_t *)&cmd_ddp_get_list, 17025 (cmdline_parse_inst_t *)&cmd_ddp_get_info, 17026 (cmdline_parse_inst_t *)&cmd_cfg_input_set, 17027 (cmdline_parse_inst_t *)&cmd_clear_input_set, 17028 (cmdline_parse_inst_t *)&cmd_show_vf_stats, 17029 (cmdline_parse_inst_t *)&cmd_clear_vf_stats, 17030 (cmdline_parse_inst_t *)&cmd_show_port_supported_ptypes, 17031 (cmdline_parse_inst_t *)&cmd_set_port_ptypes, 17032 (cmdline_parse_inst_t *)&cmd_ptype_mapping_get, 17033 (cmdline_parse_inst_t *)&cmd_ptype_mapping_replace, 17034 (cmdline_parse_inst_t *)&cmd_ptype_mapping_reset, 17035 (cmdline_parse_inst_t *)&cmd_ptype_mapping_update, 17036 17037 (cmdline_parse_inst_t *)&cmd_pctype_mapping_get, 17038 (cmdline_parse_inst_t *)&cmd_pctype_mapping_reset, 17039 (cmdline_parse_inst_t *)&cmd_pctype_mapping_update, 17040 (cmdline_parse_inst_t *)&cmd_queue_region, 17041 (cmdline_parse_inst_t *)&cmd_region_flowtype, 17042 (cmdline_parse_inst_t *)&cmd_user_priority_region, 17043 (cmdline_parse_inst_t *)&cmd_flush_queue_region, 17044 (cmdline_parse_inst_t *)&cmd_show_queue_region_info_all, 17045 (cmdline_parse_inst_t *)&cmd_show_port_tm_cap, 17046 (cmdline_parse_inst_t *)&cmd_show_port_tm_level_cap, 17047 (cmdline_parse_inst_t *)&cmd_show_port_tm_node_cap, 17048 (cmdline_parse_inst_t *)&cmd_show_port_tm_node_type, 17049 (cmdline_parse_inst_t *)&cmd_show_port_tm_node_stats, 17050 (cmdline_parse_inst_t *)&cmd_add_port_tm_node_shaper_profile, 17051 (cmdline_parse_inst_t *)&cmd_del_port_tm_node_shaper_profile, 17052 (cmdline_parse_inst_t *)&cmd_add_port_tm_node_shared_shaper, 17053 (cmdline_parse_inst_t *)&cmd_del_port_tm_node_shared_shaper, 17054 (cmdline_parse_inst_t *)&cmd_add_port_tm_node_wred_profile, 17055 (cmdline_parse_inst_t *)&cmd_del_port_tm_node_wred_profile, 17056 (cmdline_parse_inst_t *)&cmd_set_port_tm_node_shaper_profile, 17057 (cmdline_parse_inst_t *)&cmd_add_port_tm_nonleaf_node, 17058 (cmdline_parse_inst_t *)&cmd_add_port_tm_nonleaf_node_pmode, 17059 (cmdline_parse_inst_t *)&cmd_add_port_tm_leaf_node, 17060 (cmdline_parse_inst_t *)&cmd_del_port_tm_node, 17061 (cmdline_parse_inst_t *)&cmd_set_port_tm_node_parent, 17062 (cmdline_parse_inst_t *)&cmd_suspend_port_tm_node, 17063 (cmdline_parse_inst_t *)&cmd_resume_port_tm_node, 17064 (cmdline_parse_inst_t *)&cmd_port_tm_hierarchy_commit, 17065 (cmdline_parse_inst_t *)&cmd_port_tm_mark_ip_ecn, 17066 (cmdline_parse_inst_t *)&cmd_port_tm_mark_ip_dscp, 17067 (cmdline_parse_inst_t *)&cmd_port_tm_mark_vlan_dei, 17068 (cmdline_parse_inst_t *)&cmd_cfg_tunnel_udp_port, 17069 (cmdline_parse_inst_t *)&cmd_rx_offload_get_capa, 17070 (cmdline_parse_inst_t *)&cmd_rx_offload_get_configuration, 17071 (cmdline_parse_inst_t *)&cmd_config_per_port_rx_offload, 17072 (cmdline_parse_inst_t *)&cmd_config_per_queue_rx_offload, 17073 (cmdline_parse_inst_t *)&cmd_tx_offload_get_capa, 17074 (cmdline_parse_inst_t *)&cmd_tx_offload_get_configuration, 17075 (cmdline_parse_inst_t *)&cmd_config_per_port_tx_offload, 17076 (cmdline_parse_inst_t *)&cmd_config_per_queue_tx_offload, 17077 #ifdef RTE_LIB_BPF 17078 (cmdline_parse_inst_t *)&cmd_operate_bpf_ld_parse, 17079 (cmdline_parse_inst_t *)&cmd_operate_bpf_unld_parse, 17080 #endif 17081 (cmdline_parse_inst_t *)&cmd_config_tx_metadata_specific, 17082 (cmdline_parse_inst_t *)&cmd_show_tx_metadata, 17083 (cmdline_parse_inst_t *)&cmd_show_rx_tx_desc_status, 17084 (cmdline_parse_inst_t *)&cmd_set_raw, 17085 (cmdline_parse_inst_t *)&cmd_show_set_raw, 17086 (cmdline_parse_inst_t *)&cmd_show_set_raw_all, 17087 (cmdline_parse_inst_t *)&cmd_config_tx_dynf_specific, 17088 (cmdline_parse_inst_t *)&cmd_show_fec_mode, 17089 (cmdline_parse_inst_t *)&cmd_set_fec_mode, 17090 (cmdline_parse_inst_t *)&cmd_show_capability, 17091 NULL, 17092 }; 17093 17094 /* read cmdline commands from file */ 17095 void 17096 cmdline_read_from_file(const char *filename) 17097 { 17098 struct cmdline *cl; 17099 17100 cl = cmdline_file_new(main_ctx, "testpmd> ", filename); 17101 if (cl == NULL) { 17102 printf("Failed to create file based cmdline context: %s\n", 17103 filename); 17104 return; 17105 } 17106 17107 cmdline_interact(cl); 17108 cmdline_quit(cl); 17109 17110 cmdline_free(cl); 17111 17112 printf("Read CLI commands from %s\n", filename); 17113 } 17114 17115 /* prompt function, called from main on MAIN lcore */ 17116 void 17117 prompt(void) 17118 { 17119 /* initialize non-constant commands */ 17120 cmd_set_fwd_mode_init(); 17121 cmd_set_fwd_retry_mode_init(); 17122 17123 testpmd_cl = cmdline_stdin_new(main_ctx, "testpmd> "); 17124 if (testpmd_cl == NULL) 17125 return; 17126 cmdline_interact(testpmd_cl); 17127 cmdline_stdin_exit(testpmd_cl); 17128 } 17129 17130 void 17131 prompt_exit(void) 17132 { 17133 if (testpmd_cl != NULL) 17134 cmdline_quit(testpmd_cl); 17135 } 17136 17137 static void 17138 cmd_reconfig_device_queue(portid_t id, uint8_t dev, uint8_t queue) 17139 { 17140 if (id == (portid_t)RTE_PORT_ALL) { 17141 portid_t pid; 17142 17143 RTE_ETH_FOREACH_DEV(pid) { 17144 /* check if need_reconfig has been set to 1 */ 17145 if (ports[pid].need_reconfig == 0) 17146 ports[pid].need_reconfig = dev; 17147 /* check if need_reconfig_queues has been set to 1 */ 17148 if (ports[pid].need_reconfig_queues == 0) 17149 ports[pid].need_reconfig_queues = queue; 17150 } 17151 } else if (!port_id_is_invalid(id, DISABLED_WARN)) { 17152 /* check if need_reconfig has been set to 1 */ 17153 if (ports[id].need_reconfig == 0) 17154 ports[id].need_reconfig = dev; 17155 /* check if need_reconfig_queues has been set to 1 */ 17156 if (ports[id].need_reconfig_queues == 0) 17157 ports[id].need_reconfig_queues = queue; 17158 } 17159 } 17160