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 <ctype.h> 7 #include <stdarg.h> 8 #include <errno.h> 9 #include <stdio.h> 10 #include <stdint.h> 11 #include <stdlib.h> 12 #include <string.h> 13 #include <unistd.h> 14 #include <inttypes.h> 15 #include <sys/queue.h> 16 17 #include <rte_common.h> 18 #include <rte_byteorder.h> 19 #include <rte_log.h> 20 #include <rte_debug.h> 21 #include <rte_cycles.h> 22 #include <rte_memory.h> 23 #include <rte_memzone.h> 24 #include <rte_malloc.h> 25 #include <rte_launch.h> 26 #include <rte_eal.h> 27 #include <rte_per_lcore.h> 28 #include <rte_lcore.h> 29 #include <rte_branch_prediction.h> 30 #include <rte_ring.h> 31 #include <rte_mempool.h> 32 #include <rte_interrupts.h> 33 #include <rte_ether.h> 34 #include <rte_ethdev.h> 35 #include <rte_string_fns.h> 36 #include <rte_devargs.h> 37 #include <rte_flow.h> 38 #ifdef RTE_LIB_GRO 39 #include <rte_gro.h> 40 #endif 41 #include <rte_mbuf_dyn.h> 42 #include <rte_trace.h> 43 44 #include <cmdline_rdline.h> 45 #include <cmdline_parse.h> 46 #include <cmdline_parse_num.h> 47 #include <cmdline_parse_string.h> 48 #include <cmdline_parse_ipaddr.h> 49 #include <cmdline_parse_etheraddr.h> 50 #include <cmdline_socket.h> 51 #include <cmdline.h> 52 #if defined RTE_BUS_DPAA && defined RTE_NET_DPAA 53 #include <rte_pmd_dpaa.h> 54 #endif 55 #ifdef RTE_NET_IXGBE 56 #include <rte_pmd_ixgbe.h> 57 #endif 58 #ifdef RTE_NET_I40E 59 #include <rte_pmd_i40e.h> 60 #endif 61 #ifdef RTE_NET_BNXT 62 #include <rte_pmd_bnxt.h> 63 #endif 64 #include "testpmd.h" 65 #include "cmdline_cman.h" 66 #include "cmdline_mtr.h" 67 #include "cmdline_tm.h" 68 #include "bpf_cmd.h" 69 70 static struct cmdline *testpmd_cl; 71 static cmdline_parse_ctx_t *main_ctx; 72 static TAILQ_HEAD(, testpmd_driver_commands) driver_commands_head = 73 TAILQ_HEAD_INITIALIZER(driver_commands_head); 74 75 /* *** Help command with introduction. *** */ 76 struct cmd_help_brief_result { 77 cmdline_fixed_string_t help; 78 }; 79 80 static void cmd_help_brief_parsed(__rte_unused void *parsed_result, 81 struct cmdline *cl, 82 __rte_unused void *data) 83 { 84 cmdline_printf( 85 cl, 86 "\n" 87 "Help is available for the following sections:\n\n" 88 " help control : Start and stop forwarding.\n" 89 " help display : Displaying port, stats and config " 90 "information.\n" 91 " help config : Configuration information.\n" 92 " help ports : Configuring ports.\n" 93 " help filters : Filters configuration help.\n" 94 " help traffic_management : Traffic Management commands.\n" 95 " help devices : Device related commands.\n" 96 " help drivers : Driver specific commands.\n" 97 " help all : All of the above sections.\n\n" 98 ); 99 100 } 101 102 static cmdline_parse_token_string_t cmd_help_brief_help = 103 TOKEN_STRING_INITIALIZER(struct cmd_help_brief_result, help, "help"); 104 105 static cmdline_parse_inst_t cmd_help_brief = { 106 .f = cmd_help_brief_parsed, 107 .data = NULL, 108 .help_str = "help: Show help", 109 .tokens = { 110 (void *)&cmd_help_brief_help, 111 NULL, 112 }, 113 }; 114 115 /* *** Help command with help sections. *** */ 116 struct cmd_help_long_result { 117 cmdline_fixed_string_t help; 118 cmdline_fixed_string_t section; 119 }; 120 121 static void cmd_help_long_parsed(void *parsed_result, 122 struct cmdline *cl, 123 __rte_unused void *data) 124 { 125 int show_all = 0; 126 struct cmd_help_long_result *res = parsed_result; 127 128 if (!strcmp(res->section, "all")) 129 show_all = 1; 130 131 if (show_all || !strcmp(res->section, "control")) { 132 133 cmdline_printf( 134 cl, 135 "\n" 136 "Control forwarding:\n" 137 "-------------------\n\n" 138 139 "start\n" 140 " Start packet forwarding with current configuration.\n\n" 141 142 "start tx_first\n" 143 " Start packet forwarding with current config" 144 " after sending one burst of packets.\n\n" 145 146 "stop\n" 147 " Stop packet forwarding, and display accumulated" 148 " statistics.\n\n" 149 150 "quit\n" 151 " Quit to prompt.\n\n" 152 ); 153 } 154 155 if (show_all || !strcmp(res->section, "display")) { 156 157 cmdline_printf( 158 cl, 159 "\n" 160 "Display:\n" 161 "--------\n\n" 162 163 "show port (info|stats|summary|xstats|fdir|dcb_tc) (port_id|all)\n" 164 " Display information for port_id, or all.\n\n" 165 166 "show port info (port_id) representor\n" 167 " Show supported representors for a specific port\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|rxhdrs|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 "show vf stats (port_id) (vf_id)\n" 196 " Display a VF's statistics.\n\n" 197 198 "clear vf stats (port_id) (vf_id)\n" 199 " Reset a VF's statistics.\n\n" 200 201 "show port meter stats (port_id) (meter_id) (clear)\n" 202 " Get meter stats on a port\n\n" 203 204 "show fwd stats all\n" 205 " Display statistics for all fwd engines.\n\n" 206 207 "clear fwd stats all\n" 208 " Clear statistics for all fwd engines.\n\n" 209 210 "show port (port_id) rx_offload capabilities\n" 211 " List all per queue and per port Rx offloading" 212 " capabilities of a port\n\n" 213 214 "show port (port_id) rx_offload configuration\n" 215 " List port level and all queue level" 216 " Rx offloading configuration\n\n" 217 218 "show port (port_id) tx_offload capabilities\n" 219 " List all per queue and per port" 220 " Tx offloading capabilities of a port\n\n" 221 222 "show port (port_id) tx_offload configuration\n" 223 " List port level and all queue level" 224 " Tx offloading configuration\n\n" 225 226 "show port (port_id) tx_metadata\n" 227 " Show Tx metadata value set" 228 " for a specific port\n\n" 229 230 "show port (port_id) ptypes\n" 231 " Show port supported ptypes" 232 " for a specific port\n\n" 233 234 "show device info (<identifier>|all)" 235 " Show general information about devices probed.\n\n" 236 237 "show port (port_id) rxq|txq (queue_id) desc (desc_id) status" 238 " Show status of rx|tx descriptor.\n\n" 239 240 "show port (port_id) rxq (queue_id) desc used count\n" 241 " Show current number of filled receive" 242 " packet descriptors.\n\n" 243 244 "show port (port_id) macs|mcast_macs" 245 " Display list of mac addresses added to port.\n\n" 246 247 "show port (port_id) flow transfer proxy\n" 248 " Display proxy port to manage transfer flows\n\n" 249 250 "show port (port_id) fec capabilities" 251 " Show fec capabilities of a port.\n\n" 252 253 "show port (port_id) fec_mode" 254 " Show fec mode of a port.\n\n" 255 256 "show port (port_id) flow_ctrl" 257 " Show flow control info of a port.\n\n" 258 259 "dump_physmem\n" 260 " Dumps all physical memory segment layouts\n\n" 261 262 "dump_socket_mem\n" 263 " Dumps the memory usage of all sockets\n\n" 264 265 "dump_memzone\n" 266 " Dumps the layout of all memory zones\n\n" 267 268 "dump_struct_sizes\n" 269 " Dumps the size of all memory structures\n\n" 270 271 "dump_ring\n" 272 " Dumps the status of all or specific element in DPDK rings\n\n" 273 274 "dump_mempool\n" 275 " Dumps the statistics of all or specific memory pool\n\n" 276 277 "dump_devargs\n" 278 " Dumps the user device list\n\n" 279 280 "dump_lcores\n" 281 " Dumps the logical cores list\n\n" 282 283 "dump_trace\n" 284 " Dumps the tracing data to the folder according to the current EAL settings\n\n" 285 286 "dump_log_types\n" 287 " Dumps the log level for all the dpdk modules\n\n" 288 ); 289 } 290 291 if (show_all || !strcmp(res->section, "config")) { 292 cmdline_printf( 293 cl, 294 "\n" 295 "Configuration:\n" 296 "--------------\n" 297 "Configuration changes only become active when" 298 " forwarding is started/restarted.\n\n" 299 300 "set default\n" 301 " Reset forwarding to the default configuration.\n\n" 302 303 "set verbose (level)\n" 304 " Set the debug verbosity level X.\n\n" 305 306 "set log global|(type) (level)\n" 307 " Set the log level.\n\n" 308 309 "set nbport (num)\n" 310 " Set number of ports.\n\n" 311 312 "set nbcore (num)\n" 313 " Set number of cores.\n\n" 314 315 "set coremask (mask)\n" 316 " Set the forwarding cores hexadecimal mask.\n\n" 317 318 "set portmask (mask)\n" 319 " Set the forwarding ports hexadecimal mask.\n\n" 320 321 "set burst (num)\n" 322 " Set number of packets per burst.\n\n" 323 324 "set burst tx delay (microseconds) retry (num)\n" 325 " Set the transmit delay time and number of retries," 326 " effective when retry is enabled.\n\n" 327 328 "set rxoffs (x[,y]*)\n" 329 " Set the offset of each packet segment on" 330 " receiving if split feature is engaged." 331 " Affects only the queues configured with split" 332 " offloads.\n\n" 333 334 "set rxpkts (x[,y]*)\n" 335 " Set the length of each segment to scatter" 336 " packets on receiving if split feature is engaged." 337 " Affects only the queues configured with split" 338 " offloads.\n\n" 339 340 "set rxhdrs (eth[,ipv4])*\n" 341 " Set the protocol hdr of each segment to scatter" 342 " packets on receiving if split feature is engaged." 343 " Affects only the queues configured with split" 344 " offloads.\n" 345 " Supported values: eth|ipv4|ipv6|ipv4-tcp|ipv6-tcp|" 346 "ipv4-udp|ipv6-udp|ipv4-sctp|ipv6-sctp|" 347 "grenat|inner-eth|inner-ipv4|inner-ipv6|inner-ipv4-tcp|" 348 "inner-ipv6-tcp|inner-ipv4-udp|inner-ipv6-udp|" 349 "inner-ipv4-sctp|inner-ipv6-sctp\n\n" 350 351 "set txpkts (x[,y]*)\n" 352 " Set the length of each segment of TXONLY" 353 " and optionally CSUM packets.\n\n" 354 355 "set txsplit (off|on|rand)\n" 356 " Set the split policy for the TX packets." 357 " Right now only applicable for CSUM and TXONLY" 358 " modes\n\n" 359 360 "set txtimes (x, y)\n" 361 " Set the scheduling on timestamps" 362 " timings for the TXONLY mode\n\n" 363 364 "set corelist (x[,y]*)\n" 365 " Set the list of forwarding cores.\n\n" 366 367 "set portlist (x[,y]*)\n" 368 " Set the list of forwarding ports.\n\n" 369 370 "set port setup on (iterator|event)\n" 371 " Select how attached port is retrieved for setup.\n\n" 372 373 "set tx loopback (port_id) (on|off)\n" 374 " Enable or disable tx loopback.\n\n" 375 376 "set all queues drop (port_id) (on|off)\n" 377 " Set drop enable bit for all queues.\n\n" 378 379 "set vf mac antispoof (port_id) (vf_id) (on|off).\n" 380 " Set MAC antispoof for a VF from the PF.\n\n" 381 382 "vlan set stripq (on|off) (port_id,queue_id)\n" 383 " Set the VLAN strip for a queue on a port.\n\n" 384 385 "set vf vlan stripq (port_id) (vf_id) (on|off)\n" 386 " Set the VLAN strip for all queues in a pool for a VF from the PF.\n\n" 387 388 "set vf vlan insert (port_id) (vf_id) (vlan_id)\n" 389 " Set VLAN insert for a VF from the PF.\n\n" 390 391 "set vf vlan antispoof (port_id) (vf_id) (on|off)\n" 392 " Set VLAN antispoof for a VF from the PF.\n\n" 393 394 "vlan set (strip|filter|qinq_strip|extend) (on|off) (port_id)\n" 395 " Set the VLAN strip or filter or qinq strip or extend\n\n" 396 397 "vlan set (inner|outer) tpid (value) (port_id)\n" 398 " Set the VLAN TPID for Packet Filtering on" 399 " a port\n\n" 400 401 "rx_vlan add (vlan_id|all) (port_id)\n" 402 " Add a vlan_id, or all identifiers, to the set" 403 " of VLAN identifiers filtered by port_id.\n\n" 404 405 "rx_vlan rm (vlan_id|all) (port_id)\n" 406 " Remove a vlan_id, or all identifiers, from the set" 407 " of VLAN identifiers filtered by port_id.\n\n" 408 409 "rx_vlan add (vlan_id) port (port_id) vf (vf_mask)\n" 410 " Add a vlan_id, to the set of VLAN identifiers" 411 "filtered for VF(s) from port_id.\n\n" 412 413 "rx_vlan rm (vlan_id) port (port_id) vf (vf_mask)\n" 414 " Remove a vlan_id, to the set of VLAN identifiers" 415 "filtered for VF(s) from port_id.\n\n" 416 417 "rx_vxlan_port add (udp_port) (port_id)\n" 418 " Add an UDP port for VXLAN packet filter on a port\n\n" 419 420 "rx_vxlan_port rm (udp_port) (port_id)\n" 421 " Remove an UDP port for VXLAN packet filter on a port\n\n" 422 423 "tx_vlan set (port_id) vlan_id[, vlan_id_outer]\n" 424 " Set hardware insertion of VLAN IDs (single or double VLAN " 425 "depends on the number of VLAN IDs) in packets sent on a port.\n\n" 426 427 "tx_vlan set pvid port_id vlan_id (on|off)\n" 428 " Set port based TX VLAN insertion.\n\n" 429 430 "tx_vlan reset (port_id)\n" 431 " Disable hardware insertion of a VLAN header in" 432 " packets sent on a port.\n\n" 433 434 "csum set (ip|udp|tcp|sctp|outer-ip|outer-udp) (hw|sw) (port_id)\n" 435 " Select hardware or software calculation of the" 436 " checksum when transmitting a packet using the" 437 " csum forward engine.\n" 438 " ip|udp|tcp|sctp always concern the inner layer.\n" 439 " outer-ip concerns the outer IP layer in" 440 " outer-udp concerns the outer UDP layer in" 441 " case the packet is recognized as a tunnel packet by" 442 " the forward engine (vxlan, gre and ipip are supported)\n" 443 " Please check the NIC datasheet for HW limits.\n\n" 444 445 "csum parse-tunnel (on|off) (tx_port_id)\n" 446 " If disabled, treat tunnel packets as non-tunneled" 447 " packets (treat inner headers as payload). The port\n" 448 " argument is the port used for TX in csum forward" 449 " engine.\n\n" 450 451 "csum show (port_id)\n" 452 " Display tx checksum offload configuration\n\n" 453 454 "tso set (segsize) (portid)\n" 455 " Enable TCP Segmentation Offload in csum forward" 456 " engine.\n" 457 " Please check the NIC datasheet for HW limits.\n\n" 458 459 "tso show (portid)" 460 " Display the status of TCP Segmentation Offload.\n\n" 461 462 #ifdef RTE_LIB_GRO 463 "set port (port_id) gro on|off\n" 464 " Enable or disable Generic Receive Offload in" 465 " csum forwarding engine.\n\n" 466 467 "show port (port_id) gro\n" 468 " Display GRO configuration.\n\n" 469 470 "set gro flush (cycles)\n" 471 " Set the cycle to flush GROed packets from" 472 " reassembly tables.\n\n" 473 #endif 474 475 #ifdef RTE_LIB_GSO 476 "set port (port_id) gso (on|off)" 477 " Enable or disable Generic Segmentation Offload in" 478 " csum forwarding engine.\n\n" 479 480 "set gso segsz (length)\n" 481 " Set max packet length for output GSO segments," 482 " including packet header and payload.\n\n" 483 484 "show port (port_id) gso\n" 485 " Show GSO configuration.\n\n" 486 #endif 487 488 "set fwd (%s)\n" 489 " Set packet forwarding mode.\n\n" 490 491 "mac_addr add (port_id) (XX:XX:XX:XX:XX:XX)\n" 492 " Add a MAC address on port_id.\n\n" 493 494 "mac_addr remove (port_id) (XX:XX:XX:XX:XX:XX)\n" 495 " Remove a MAC address from port_id.\n\n" 496 497 "mac_addr set (port_id) (XX:XX:XX:XX:XX:XX)\n" 498 " Set the default MAC address for port_id.\n\n" 499 500 "mac_addr add port (port_id) vf (vf_id) (mac_address)\n" 501 " Add a MAC address for a VF on the port.\n\n" 502 503 "mcast_addr add (port_id) (mcast_addr)\n" 504 " Add a multicast MAC addresses on port_id.\n\n" 505 506 "mcast_addr remove (port_id) (mcast_addr)\n" 507 " Remove a multicast MAC address from port_id.\n\n" 508 509 "set vf mac addr (port_id) (vf_id) (XX:XX:XX:XX:XX:XX)\n" 510 " Set the MAC address for a VF from the PF.\n\n" 511 512 "set eth-peer (port_id) (peer_addr)\n" 513 " set the peer address for certain port.\n\n" 514 515 "set port (port_id) uta (mac_address|all) (on|off)\n" 516 " Add/Remove a or all unicast hash filter(s)" 517 "from port X.\n\n" 518 519 "set promisc (port_id|all) (on|off)\n" 520 " Set the promiscuous mode on port_id, or all.\n\n" 521 522 "set allmulti (port_id|all) (on|off)\n" 523 " Set the allmulti mode on port_id, or all.\n\n" 524 525 "set flow_ctrl rx (on|off) tx (on|off) (high_water)" 526 " (low_water) (pause_time) (send_xon) mac_ctrl_frame_fwd" 527 " (on|off) autoneg (on|off) (port_id)\n" 528 "set flow_ctrl rx (on|off) (portid)\n" 529 "set flow_ctrl tx (on|off) (portid)\n" 530 "set flow_ctrl high_water (high_water) (portid)\n" 531 "set flow_ctrl low_water (low_water) (portid)\n" 532 "set flow_ctrl pause_time (pause_time) (portid)\n" 533 "set flow_ctrl send_xon (send_xon) (portid)\n" 534 "set flow_ctrl mac_ctrl_frame_fwd (on|off) (portid)\n" 535 "set flow_ctrl autoneg (on|off) (port_id)\n" 536 " Set the link flow control parameter on a port.\n\n" 537 538 "set pfc_ctrl rx (on|off) tx (on|off) (high_water)" 539 " (low_water) (pause_time) (priority) (port_id)\n" 540 " Set the priority flow control parameter on a" 541 " port.\n\n" 542 543 "set pfc_queue_ctrl (port_id) rx (on|off) (tx_qid)" 544 " (tx_tc) tx (on|off) (rx_qid) (rx_tc) (pause_time)\n" 545 " Set the queue priority flow control parameter on a" 546 " given Rx and Tx queues of a port.\n\n" 547 548 "set port (port_id) rxq (queue_id) avail_thresh (0..99)>\n " 549 " set available descriptors threshold for Rx queue\n\n" 550 551 "set stat_qmap (tx|rx) (port_id) (queue_id) (qmapping)\n" 552 " Set statistics mapping (qmapping 0..15) for RX/TX" 553 " queue on port.\n" 554 " e.g., 'set stat_qmap rx 0 2 5' sets rx queue 2" 555 " on port 0 to mapping 5.\n\n" 556 557 "set xstats-hide-zero on|off\n" 558 " Set the option to hide the zero values" 559 " for xstats display.\n" 560 561 "set record-core-cycles on|off\n" 562 " Set the option to enable measurement of CPU cycles.\n" 563 564 "set record-burst-stats on|off\n" 565 " Set the option to enable display of RX and TX bursts.\n" 566 567 "set port (port_id) vf (vf_id) rx|tx on|off\n" 568 " Enable/Disable a VF receive/transmit from a port\n\n" 569 570 "set port (port_id) vf (vf_id) rxmode (AUPE|ROPE|BAM" 571 "|MPE) (on|off)\n" 572 " AUPE:accepts untagged VLAN;" 573 "ROPE:accept unicast hash\n\n" 574 " BAM:accepts broadcast packets;" 575 "MPE:accepts all multicast packets\n\n" 576 " Enable/Disable a VF receive mode of a port\n\n" 577 578 "set port (port_id) queue (queue_id) rate (rate_num)\n" 579 " Set rate limit for a queue of a port\n\n" 580 581 "set port (port_id) vf (vf_id) rate (rate_num) " 582 "queue_mask (queue_mask_value)\n" 583 " Set rate limit for queues in VF of a port\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 link-up port (port_id)\n" 590 " Set link up for a port.\n\n" 591 592 "set link-down port (port_id)\n" 593 " Set link down for a port.\n\n" 594 595 "set port (port_id) ptype_mask (ptype_mask)\n" 596 " set packet types classification for a specific port\n\n" 597 598 "show port meter cap (port_id)\n" 599 " Show port meter capability information\n\n" 600 601 "add port meter profile srtcm_rfc2697 (port_id) (profile_id) (cir) (cbs) (ebs) (packet_mode)\n" 602 " meter profile add - srtcm rfc 2697\n\n" 603 604 "add port meter profile trtcm_rfc2698 (port_id) (profile_id) (cir) (pir) (cbs) (pbs) (packet_mode)\n" 605 " meter profile add - trtcm rfc 2698\n\n" 606 607 "add port meter profile trtcm_rfc4115 (port_id) (profile_id) (cir) (eir) (cbs) (ebs) (packet_mode)\n" 608 " meter profile add - trtcm rfc 4115\n\n" 609 610 "del port meter profile (port_id) (profile_id)\n" 611 " meter profile delete\n\n" 612 613 "create port meter (port_id) (mtr_id) (profile_id) (policy_id) (meter_enable)\n" 614 "(stats_mask) (shared) (use_pre_meter_color) [(dscp_tbl_entry0) (dscp_tbl_entry1)...\n" 615 "(dscp_tbl_entry63)]\n" 616 " meter create\n\n" 617 618 "enable port meter (port_id) (mtr_id)\n" 619 " meter enable\n\n" 620 621 "disable port meter (port_id) (mtr_id)\n" 622 " meter disable\n\n" 623 624 "del port meter (port_id) (mtr_id)\n" 625 " meter delete\n\n" 626 627 "add port meter policy (port_id) (policy_id) g_actions (actions)\n" 628 "y_actions (actions) r_actions (actions)\n" 629 " meter policy add\n\n" 630 631 "del port meter policy (port_id) (policy_id)\n" 632 " meter policy delete\n\n" 633 634 "set port meter profile (port_id) (mtr_id) (profile_id)\n" 635 " meter update meter profile\n\n" 636 637 "set port meter dscp table (port_id) (mtr_id) [(dscp_tbl_entry0)\n" 638 "(dscp_tbl_entry1)...(dscp_tbl_entry63)]\n" 639 " update meter dscp table entries\n\n" 640 641 "set port meter policer action (port_id) (mtr_id) (action_mask)\n" 642 "(action0) [(action1) (action2)]\n" 643 " meter update policer action\n\n" 644 645 "set port meter stats mask (port_id) (mtr_id) (stats_mask)\n" 646 " meter update stats\n\n" 647 648 "set port (port_id) fec_mode auto|off|rs|baser\n" 649 " set fec mode for a specific port\n\n" 650 651 "show port cman capa (port_id)\n" 652 " Show congestion management capabilities\n\n" 653 654 "show port cman config (port_id)\n" 655 " Show congestion management configuration\n\n" 656 657 "set port cman config (port_id) (queue_id) default | " 658 "[obj (queue|queue_mempool) mode red (min_thresh) " 659 "(max_thresh) (prob_inv)]\n" 660 " Set congestion management configuration\n\n" 661 662 , list_pkt_forwarding_modes() 663 ); 664 } 665 666 if (show_all || !strcmp(res->section, "ports")) { 667 668 cmdline_printf( 669 cl, 670 "\n" 671 "Port Operations:\n" 672 "----------------\n\n" 673 674 "port start (port_id|all)\n" 675 " Start all ports or port_id.\n\n" 676 677 "port stop (port_id|all)\n" 678 " Stop all ports or port_id.\n\n" 679 680 "port close (port_id|all)\n" 681 " Close all ports or port_id.\n\n" 682 683 "port reset (port_id|all)\n" 684 " Reset all ports or port_id.\n\n" 685 686 "port attach (ident)\n" 687 " Attach physical or virtual dev by pci address or virtual device name\n\n" 688 689 "port detach (port_id)\n" 690 " Detach physical or virtual dev by port_id\n\n" 691 692 "port config (port_id|all)" 693 " speed (10|100|1000|2500|5000|10000|25000|40000|50000|100000|200000|400000|auto)" 694 " duplex (half|full|auto)\n" 695 " Set speed and duplex for all ports or port_id\n\n" 696 697 "port config (port_id|all) loopback (mode)\n" 698 " Set loopback mode for all ports or port_id\n\n" 699 700 "port config all (rxq|txq|rxd|txd) (value)\n" 701 " Set number for rxq/txq/rxd/txd.\n\n" 702 703 "port config all max-pkt-len (value)\n" 704 " Set the max packet length.\n\n" 705 706 "port config all max-lro-pkt-size (value)\n" 707 " Set the max LRO aggregated packet size.\n\n" 708 709 "port config all drop-en (on|off)\n" 710 " Enable or disable packet drop on all RX queues of all ports when no " 711 "receive buffers available.\n\n" 712 713 "port config all rss (all|default|level-default|level-outer|level-inner|" 714 "ip|tcp|udp|sctp|tunnel|vlan|none|" 715 "ipv4|ipv4-frag|ipv4-tcp|ipv4-udp|ipv4-sctp|ipv4-other|" 716 "ipv6|ipv6-frag|ipv6-tcp|ipv6-udp|ipv6-sctp|ipv6-other|ipv6-ex|ipv6-tcp-ex|ipv6-udp-ex|" 717 "l2-payload|port|vxlan|geneve|nvgre|gtpu|eth|s-vlan|c-vlan|" 718 "esp|ah|l2tpv3|pfcp|pppoe|ecpri|mpls|ipv4-chksum|l4-chksum|" 719 "l2tpv2|l3-pre96|l3-pre64|l3-pre56|l3-pre48|l3-pre40|l3-pre32|" 720 "l2-dst-only|l2-src-only|l4-dst-only|l4-src-only|l3-dst-only|l3-src-only|<rsstype_id>)\n" 721 " Set the RSS mode.\n\n" 722 723 "port config port-id rss reta (hash,queue)[,(hash,queue)]\n" 724 " Set the RSS redirection table.\n\n" 725 726 "port config (port_id) dcb vt (on|off) (traffic_class)" 727 " pfc (on|off)\n" 728 " Set the DCB mode.\n\n" 729 730 "port config all burst (value)\n" 731 " Set the number of packets per burst.\n\n" 732 733 "port config all (txpt|txht|txwt|rxpt|rxht|rxwt)" 734 " (value)\n" 735 " Set the ring prefetch/host/writeback threshold" 736 " for tx/rx queue.\n\n" 737 738 "port config all (txfreet|txrst|rxfreet) (value)\n" 739 " Set free threshold for rx/tx, or set" 740 " tx rs bit threshold.\n\n" 741 "port config mtu X value\n" 742 " Set the MTU of port X to a given value\n\n" 743 744 "port config (port_id) (rxq|txq) (queue_id) ring_size (value)\n" 745 " Set a rx/tx queue's ring size configuration, the new" 746 " value will take effect after command that (re-)start the port" 747 " or command that setup the specific queue\n\n" 748 749 "port (port_id) (rxq|txq) (queue_id) (start|stop)\n" 750 " Start/stop a rx/tx queue of port X. Only take effect" 751 " when port X is started\n\n" 752 753 "port (port_id) (rxq|txq) (queue_id) deferred_start (on|off)\n" 754 " Switch on/off a deferred start of port X rx/tx queue. Only" 755 " take effect when port X is stopped.\n\n" 756 757 "port (port_id) (rxq|txq) (queue_id) setup\n" 758 " Setup a rx/tx queue of port X.\n\n" 759 760 "port config (port_id) udp_tunnel_port add|rm vxlan|geneve|ecpri (udp_port)\n\n" 761 " Add/remove UDP tunnel port for tunneling offload\n\n" 762 763 "port config <port_id> rx_offload vlan_strip|" 764 "ipv4_cksum|udp_cksum|tcp_cksum|tcp_lro|qinq_strip|" 765 "outer_ipv4_cksum|macsec_strip|" 766 "vlan_filter|vlan_extend|scatter|" 767 "buffer_split|timestamp|security|keep_crc on|off\n" 768 " Enable or disable a per port Rx offloading" 769 " on all Rx queues of a port\n\n" 770 771 "port (port_id) rxq (queue_id) rx_offload vlan_strip|" 772 "ipv4_cksum|udp_cksum|tcp_cksum|tcp_lro|qinq_strip|" 773 "outer_ipv4_cksum|macsec_strip|" 774 "vlan_filter|vlan_extend|scatter|" 775 "buffer_split|timestamp|security|keep_crc on|off\n" 776 " Enable or disable a per queue Rx offloading" 777 " only on a specific Rx queue\n\n" 778 779 "port config (port_id) tx_offload vlan_insert|" 780 "ipv4_cksum|udp_cksum|tcp_cksum|sctp_cksum|tcp_tso|" 781 "udp_tso|outer_ipv4_cksum|qinq_insert|vxlan_tnl_tso|" 782 "gre_tnl_tso|ipip_tnl_tso|geneve_tnl_tso|" 783 "macsec_insert|mt_lockfree|multi_segs|mbuf_fast_free|" 784 "security on|off\n" 785 " Enable or disable a per port Tx offloading" 786 " on all Tx queues of a port\n\n" 787 788 "port (port_id) txq (queue_id) tx_offload vlan_insert|" 789 "ipv4_cksum|udp_cksum|tcp_cksum|sctp_cksum|tcp_tso|" 790 "udp_tso|outer_ipv4_cksum|qinq_insert|vxlan_tnl_tso|" 791 "gre_tnl_tso|ipip_tnl_tso|geneve_tnl_tso|macsec_insert" 792 "|mt_lockfree|multi_segs|mbuf_fast_free|security" 793 " on|off\n" 794 " Enable or disable a per queue Tx offloading" 795 " only on a specific Tx queue\n\n" 796 797 "bpf-load rx|tx (port) (queue) (J|M|B) (file_name)\n" 798 " Load an eBPF program as a callback" 799 " for particular RX/TX queue\n\n" 800 801 "bpf-unload rx|tx (port) (queue)\n" 802 " Unload previously loaded eBPF program" 803 " for particular RX/TX queue\n\n" 804 805 "port config (port_id) tx_metadata (value)\n" 806 " Set Tx metadata value per port. Testpmd will add this value" 807 " to any Tx packet sent from this port\n\n" 808 809 "port config (port_id) dynf (name) set|clear\n" 810 " Register a dynf and Set/clear this flag on Tx. " 811 "Testpmd will set this value to any Tx packet " 812 "sent from this port\n\n" 813 814 "port cleanup (port_id) txq (queue_id) (free_cnt)\n" 815 " Cleanup txq mbufs for a specific Tx queue\n\n" 816 817 "port config (port_id) txq (queue_id) affinity (value)\n" 818 " Map a Tx queue with an aggregated port " 819 "of the DPDK port\n\n" 820 ); 821 } 822 823 if (show_all || !strcmp(res->section, "filters")) { 824 825 cmdline_printf( 826 cl, 827 "\n" 828 "filters:\n" 829 "--------\n\n" 830 831 "flow validate {port_id}" 832 " [group {group_id}] [priority {level}]" 833 " [ingress] [egress]" 834 " pattern {item} [/ {item} [...]] / end" 835 " actions {action} [/ {action} [...]] / end\n" 836 " Check whether a flow rule can be created.\n\n" 837 838 "flow create {port_id}" 839 " [group {group_id}] [priority {level}]" 840 " [ingress] [egress]" 841 " pattern {item} [/ {item} [...]] / end" 842 " actions {action} [/ {action} [...]] / end\n" 843 " Create a flow rule.\n\n" 844 845 "flow destroy {port_id} rule {rule_id} [...]\n" 846 " Destroy specific flow rules.\n\n" 847 848 "flow flush {port_id}\n" 849 " Destroy all flow rules.\n\n" 850 851 "flow query {port_id} {rule_id} {action}\n" 852 " Query an existing flow rule.\n\n" 853 854 "flow list {port_id} [group {group_id}] [...]\n" 855 " List existing flow rules sorted by priority," 856 " filtered by group identifiers.\n\n" 857 858 "flow isolate {port_id} {boolean}\n" 859 " Restrict ingress traffic to the defined" 860 " flow rules\n\n" 861 862 "flow aged {port_id} [destroy]\n" 863 " List and destroy aged flows" 864 " flow rules\n\n" 865 866 "flow indirect_action {port_id} create" 867 " [action_id {indirect_action_id}]" 868 " [ingress] [egress]" 869 " action {action} / end\n" 870 " Create indirect action.\n\n" 871 872 "flow indirect_action {port_id} update" 873 " {indirect_action_id} action {action} / end\n" 874 " Update indirect action.\n\n" 875 876 "flow indirect_action {port_id} destroy" 877 " action_id {indirect_action_id} [...]\n" 878 " Destroy specific indirect actions.\n\n" 879 880 "flow indirect_action {port_id} query" 881 " {indirect_action_id}\n" 882 " Query an existing indirect action.\n\n" 883 884 "set vxlan ip-version (ipv4|ipv6) vni (vni) udp-src" 885 " (udp-src) udp-dst (udp-dst) ip-src (ip-src) ip-dst" 886 " (ip-dst) eth-src (eth-src) eth-dst (eth-dst)\n" 887 " Configure the VXLAN encapsulation for flows.\n\n" 888 889 "set vxlan-with-vlan ip-version (ipv4|ipv6) vni (vni)" 890 " udp-src (udp-src) udp-dst (udp-dst) ip-src (ip-src)" 891 " ip-dst (ip-dst) vlan-tci (vlan-tci) eth-src (eth-src)" 892 " eth-dst (eth-dst)\n" 893 " Configure the VXLAN encapsulation for flows.\n\n" 894 895 "set vxlan-tos-ttl ip-version (ipv4|ipv6) vni (vni) udp-src" 896 " (udp-src) udp-dst (udp-dst) ip-tos (ip-tos) ip-ttl (ip-ttl)" 897 " ip-src (ip-src) ip-dst (ip-dst) eth-src (eth-src)" 898 " eth-dst (eth-dst)\n" 899 " Configure the VXLAN encapsulation for flows.\n\n" 900 901 "set nvgre ip-version (ipv4|ipv6) tni (tni) ip-src" 902 " (ip-src) ip-dst (ip-dst) eth-src (eth-src) eth-dst" 903 " (eth-dst)\n" 904 " Configure the NVGRE encapsulation for flows.\n\n" 905 906 "set nvgre-with-vlan ip-version (ipv4|ipv6) tni (tni)" 907 " ip-src (ip-src) ip-dst (ip-dst) vlan-tci (vlan-tci)" 908 " eth-src (eth-src) eth-dst (eth-dst)\n" 909 " Configure the NVGRE encapsulation for flows.\n\n" 910 911 "set raw_encap {flow items}\n" 912 " Configure the encapsulation with raw data.\n\n" 913 914 "set raw_decap {flow items}\n" 915 " Configure the decapsulation with raw data.\n\n" 916 917 ); 918 } 919 920 if (show_all || !strcmp(res->section, "traffic_management")) { 921 cmdline_printf( 922 cl, 923 "\n" 924 "Traffic Management:\n" 925 "--------------\n" 926 "show port tm cap (port_id)\n" 927 " Display the port TM capability.\n\n" 928 929 "show port tm level cap (port_id) (level_id)\n" 930 " Display the port TM hierarchical level capability.\n\n" 931 932 "show port tm node cap (port_id) (node_id)\n" 933 " Display the port TM node capability.\n\n" 934 935 "show port tm node type (port_id) (node_id)\n" 936 " Display the port TM node type.\n\n" 937 938 "show port tm node stats (port_id) (node_id) (clear)\n" 939 " Display the port TM node stats.\n\n" 940 941 "add port tm node shaper profile (port_id) (shaper_profile_id)" 942 " (cmit_tb_rate) (cmit_tb_size) (peak_tb_rate) (peak_tb_size)" 943 " (packet_length_adjust) (packet_mode)\n" 944 " Add port tm node private shaper profile.\n\n" 945 946 "del port tm node shaper profile (port_id) (shaper_profile_id)\n" 947 " Delete port tm node private shaper profile.\n\n" 948 949 "add port tm node shared shaper (port_id) (shared_shaper_id)" 950 " (shaper_profile_id)\n" 951 " Add/update port tm node shared shaper.\n\n" 952 953 "del port tm node shared shaper (port_id) (shared_shaper_id)\n" 954 " Delete port tm node shared shaper.\n\n" 955 956 "set port tm node shaper profile (port_id) (node_id)" 957 " (shaper_profile_id)\n" 958 " Set port tm node shaper profile.\n\n" 959 960 "add port tm node wred profile (port_id) (wred_profile_id)" 961 " (color_g) (min_th_g) (max_th_g) (maxp_inv_g) (wq_log2_g)" 962 " (color_y) (min_th_y) (max_th_y) (maxp_inv_y) (wq_log2_y)" 963 " (color_r) (min_th_r) (max_th_r) (maxp_inv_r) (wq_log2_r)\n" 964 " Add port tm node wred profile.\n\n" 965 966 "del port tm node wred profile (port_id) (wred_profile_id)\n" 967 " Delete port tm node wred profile.\n\n" 968 969 "add port tm nonleaf node (port_id) (node_id) (parent_node_id)" 970 " (priority) (weight) (level_id) (shaper_profile_id)" 971 " (n_sp_priorities) (stats_mask) (n_shared_shapers)" 972 " [(shared_shaper_id_0) (shared_shaper_id_1)...]\n" 973 " Add port tm nonleaf node.\n\n" 974 975 "add port tm nonleaf node pktmode (port_id) (node_id) (parent_node_id)" 976 " (priority) (weight) (level_id) (shaper_profile_id)" 977 " (n_sp_priorities) (stats_mask) (n_shared_shapers)" 978 " [(shared_shaper_id_0) (shared_shaper_id_1)...]\n" 979 " Add port tm nonleaf node with pkt mode enabled.\n\n" 980 981 "add port tm leaf node (port_id) (node_id) (parent_node_id)" 982 " (priority) (weight) (level_id) (shaper_profile_id)" 983 " (cman_mode) (wred_profile_id) (stats_mask) (n_shared_shapers)" 984 " [(shared_shaper_id_0) (shared_shaper_id_1)...]\n" 985 " Add port tm leaf node.\n\n" 986 987 "del port tm node (port_id) (node_id)\n" 988 " Delete port tm node.\n\n" 989 990 "set port tm node parent (port_id) (node_id) (parent_node_id)" 991 " (priority) (weight)\n" 992 " Set port tm node parent.\n\n" 993 994 "suspend port tm node (port_id) (node_id)" 995 " Suspend tm node.\n\n" 996 997 "resume port tm node (port_id) (node_id)" 998 " Resume tm node.\n\n" 999 1000 "port tm hierarchy commit (port_id) (clean_on_fail)\n" 1001 " Commit tm hierarchy.\n\n" 1002 1003 "set port tm mark ip_ecn (port) (green) (yellow)" 1004 " (red)\n" 1005 " Enables/Disables the traffic management marking" 1006 " for IP ECN (Explicit Congestion Notification)" 1007 " packets on a given port\n\n" 1008 1009 "set port tm mark ip_dscp (port) (green) (yellow)" 1010 " (red)\n" 1011 " Enables/Disables the traffic management marking" 1012 " on the port for IP dscp packets\n\n" 1013 1014 "set port tm mark vlan_dei (port) (green) (yellow)" 1015 " (red)\n" 1016 " Enables/Disables the traffic management marking" 1017 " on the port for VLAN packets with DEI enabled\n\n" 1018 ); 1019 } 1020 1021 if (show_all || !strcmp(res->section, "devices")) { 1022 cmdline_printf( 1023 cl, 1024 "\n" 1025 "Device Operations:\n" 1026 "--------------\n" 1027 "device detach (identifier)\n" 1028 " Detach device by identifier.\n\n" 1029 ); 1030 } 1031 1032 if (show_all || !strcmp(res->section, "drivers")) { 1033 struct testpmd_driver_commands *c; 1034 unsigned int i; 1035 1036 cmdline_printf( 1037 cl, 1038 "\n" 1039 "Driver specific:\n" 1040 "----------------\n" 1041 ); 1042 TAILQ_FOREACH(c, &driver_commands_head, next) { 1043 for (i = 0; c->commands[i].ctx != NULL; i++) 1044 cmdline_printf(cl, "%s\n", c->commands[i].help); 1045 } 1046 } 1047 } 1048 1049 static cmdline_parse_token_string_t cmd_help_long_help = 1050 TOKEN_STRING_INITIALIZER(struct cmd_help_long_result, help, "help"); 1051 1052 static cmdline_parse_token_string_t cmd_help_long_section = 1053 TOKEN_STRING_INITIALIZER(struct cmd_help_long_result, section, 1054 "all#control#display#config#ports#" 1055 "filters#traffic_management#devices#drivers"); 1056 1057 static cmdline_parse_inst_t cmd_help_long = { 1058 .f = cmd_help_long_parsed, 1059 .data = NULL, 1060 .help_str = "help all|control|display|config|ports|" 1061 "filters|traffic_management|devices|drivers: " 1062 "Show help", 1063 .tokens = { 1064 (void *)&cmd_help_long_help, 1065 (void *)&cmd_help_long_section, 1066 NULL, 1067 }, 1068 }; 1069 1070 1071 /* *** start/stop/close all ports *** */ 1072 struct cmd_operate_port_result { 1073 cmdline_fixed_string_t keyword; 1074 cmdline_fixed_string_t name; 1075 cmdline_fixed_string_t value; 1076 }; 1077 1078 static void cmd_operate_port_parsed(void *parsed_result, 1079 __rte_unused struct cmdline *cl, 1080 __rte_unused void *data) 1081 { 1082 struct cmd_operate_port_result *res = parsed_result; 1083 1084 if (!strcmp(res->name, "start")) 1085 start_port(RTE_PORT_ALL); 1086 else if (!strcmp(res->name, "stop")) 1087 stop_port(RTE_PORT_ALL); 1088 else if (!strcmp(res->name, "close")) 1089 close_port(RTE_PORT_ALL); 1090 else if (!strcmp(res->name, "reset")) 1091 reset_port(RTE_PORT_ALL); 1092 else 1093 fprintf(stderr, "Unknown parameter\n"); 1094 } 1095 1096 static cmdline_parse_token_string_t cmd_operate_port_all_cmd = 1097 TOKEN_STRING_INITIALIZER(struct cmd_operate_port_result, keyword, 1098 "port"); 1099 static cmdline_parse_token_string_t cmd_operate_port_all_port = 1100 TOKEN_STRING_INITIALIZER(struct cmd_operate_port_result, name, 1101 "start#stop#close#reset"); 1102 static cmdline_parse_token_string_t cmd_operate_port_all_all = 1103 TOKEN_STRING_INITIALIZER(struct cmd_operate_port_result, value, "all"); 1104 1105 static cmdline_parse_inst_t cmd_operate_port = { 1106 .f = cmd_operate_port_parsed, 1107 .data = NULL, 1108 .help_str = "port start|stop|close|reset all: Start/Stop/Close/Reset all ports", 1109 .tokens = { 1110 (void *)&cmd_operate_port_all_cmd, 1111 (void *)&cmd_operate_port_all_port, 1112 (void *)&cmd_operate_port_all_all, 1113 NULL, 1114 }, 1115 }; 1116 1117 /* *** start/stop/close specific port *** */ 1118 struct cmd_operate_specific_port_result { 1119 cmdline_fixed_string_t keyword; 1120 cmdline_fixed_string_t name; 1121 uint8_t value; 1122 }; 1123 1124 static void cmd_operate_specific_port_parsed(void *parsed_result, 1125 __rte_unused struct cmdline *cl, 1126 __rte_unused void *data) 1127 { 1128 struct cmd_operate_specific_port_result *res = parsed_result; 1129 1130 if (!strcmp(res->name, "start")) 1131 start_port(res->value); 1132 else if (!strcmp(res->name, "stop")) 1133 stop_port(res->value); 1134 else if (!strcmp(res->name, "close")) 1135 close_port(res->value); 1136 else if (!strcmp(res->name, "reset")) 1137 reset_port(res->value); 1138 else 1139 fprintf(stderr, "Unknown parameter\n"); 1140 } 1141 1142 static cmdline_parse_token_string_t cmd_operate_specific_port_cmd = 1143 TOKEN_STRING_INITIALIZER(struct cmd_operate_specific_port_result, 1144 keyword, "port"); 1145 static cmdline_parse_token_string_t cmd_operate_specific_port_port = 1146 TOKEN_STRING_INITIALIZER(struct cmd_operate_specific_port_result, 1147 name, "start#stop#close#reset"); 1148 static cmdline_parse_token_num_t cmd_operate_specific_port_id = 1149 TOKEN_NUM_INITIALIZER(struct cmd_operate_specific_port_result, 1150 value, RTE_UINT8); 1151 1152 static cmdline_parse_inst_t cmd_operate_specific_port = { 1153 .f = cmd_operate_specific_port_parsed, 1154 .data = NULL, 1155 .help_str = "port start|stop|close|reset <port_id>: Start/Stop/Close/Reset port_id", 1156 .tokens = { 1157 (void *)&cmd_operate_specific_port_cmd, 1158 (void *)&cmd_operate_specific_port_port, 1159 (void *)&cmd_operate_specific_port_id, 1160 NULL, 1161 }, 1162 }; 1163 1164 /* *** enable port setup (after attach) via iterator or event *** */ 1165 struct cmd_set_port_setup_on_result { 1166 cmdline_fixed_string_t set; 1167 cmdline_fixed_string_t port; 1168 cmdline_fixed_string_t setup; 1169 cmdline_fixed_string_t on; 1170 cmdline_fixed_string_t mode; 1171 }; 1172 1173 static void cmd_set_port_setup_on_parsed(void *parsed_result, 1174 __rte_unused struct cmdline *cl, 1175 __rte_unused void *data) 1176 { 1177 struct cmd_set_port_setup_on_result *res = parsed_result; 1178 1179 if (strcmp(res->mode, "event") == 0) 1180 setup_on_probe_event = true; 1181 else if (strcmp(res->mode, "iterator") == 0) 1182 setup_on_probe_event = false; 1183 else 1184 fprintf(stderr, "Unknown mode\n"); 1185 } 1186 1187 static cmdline_parse_token_string_t cmd_set_port_setup_on_set = 1188 TOKEN_STRING_INITIALIZER(struct cmd_set_port_setup_on_result, 1189 set, "set"); 1190 static cmdline_parse_token_string_t cmd_set_port_setup_on_port = 1191 TOKEN_STRING_INITIALIZER(struct cmd_set_port_setup_on_result, 1192 port, "port"); 1193 static cmdline_parse_token_string_t cmd_set_port_setup_on_setup = 1194 TOKEN_STRING_INITIALIZER(struct cmd_set_port_setup_on_result, 1195 setup, "setup"); 1196 static cmdline_parse_token_string_t cmd_set_port_setup_on_on = 1197 TOKEN_STRING_INITIALIZER(struct cmd_set_port_setup_on_result, 1198 on, "on"); 1199 static cmdline_parse_token_string_t cmd_set_port_setup_on_mode = 1200 TOKEN_STRING_INITIALIZER(struct cmd_set_port_setup_on_result, 1201 mode, "iterator#event"); 1202 1203 static cmdline_parse_inst_t cmd_set_port_setup_on = { 1204 .f = cmd_set_port_setup_on_parsed, 1205 .data = NULL, 1206 .help_str = "set port setup on iterator|event", 1207 .tokens = { 1208 (void *)&cmd_set_port_setup_on_set, 1209 (void *)&cmd_set_port_setup_on_port, 1210 (void *)&cmd_set_port_setup_on_setup, 1211 (void *)&cmd_set_port_setup_on_on, 1212 (void *)&cmd_set_port_setup_on_mode, 1213 NULL, 1214 }, 1215 }; 1216 1217 /* *** attach a specified port *** */ 1218 struct cmd_operate_attach_port_result { 1219 cmdline_fixed_string_t port; 1220 cmdline_fixed_string_t keyword; 1221 cmdline_multi_string_t identifier; 1222 }; 1223 1224 static void cmd_operate_attach_port_parsed(void *parsed_result, 1225 __rte_unused struct cmdline *cl, 1226 __rte_unused void *data) 1227 { 1228 struct cmd_operate_attach_port_result *res = parsed_result; 1229 1230 if (!strcmp(res->keyword, "attach")) 1231 attach_port(res->identifier); 1232 else 1233 fprintf(stderr, "Unknown parameter\n"); 1234 } 1235 1236 static cmdline_parse_token_string_t cmd_operate_attach_port_port = 1237 TOKEN_STRING_INITIALIZER(struct cmd_operate_attach_port_result, 1238 port, "port"); 1239 static cmdline_parse_token_string_t cmd_operate_attach_port_keyword = 1240 TOKEN_STRING_INITIALIZER(struct cmd_operate_attach_port_result, 1241 keyword, "attach"); 1242 static cmdline_parse_token_string_t cmd_operate_attach_port_identifier = 1243 TOKEN_STRING_INITIALIZER(struct cmd_operate_attach_port_result, 1244 identifier, TOKEN_STRING_MULTI); 1245 1246 static cmdline_parse_inst_t cmd_operate_attach_port = { 1247 .f = cmd_operate_attach_port_parsed, 1248 .data = NULL, 1249 .help_str = "port attach <identifier>: " 1250 "(identifier: pci address or virtual dev name)", 1251 .tokens = { 1252 (void *)&cmd_operate_attach_port_port, 1253 (void *)&cmd_operate_attach_port_keyword, 1254 (void *)&cmd_operate_attach_port_identifier, 1255 NULL, 1256 }, 1257 }; 1258 1259 /* *** detach a specified port *** */ 1260 struct cmd_operate_detach_port_result { 1261 cmdline_fixed_string_t port; 1262 cmdline_fixed_string_t keyword; 1263 portid_t port_id; 1264 }; 1265 1266 static void cmd_operate_detach_port_parsed(void *parsed_result, 1267 __rte_unused struct cmdline *cl, 1268 __rte_unused void *data) 1269 { 1270 struct cmd_operate_detach_port_result *res = parsed_result; 1271 1272 if (!strcmp(res->keyword, "detach")) { 1273 RTE_ETH_VALID_PORTID_OR_RET(res->port_id); 1274 detach_port_device(res->port_id); 1275 } else { 1276 fprintf(stderr, "Unknown parameter\n"); 1277 } 1278 } 1279 1280 static cmdline_parse_token_string_t cmd_operate_detach_port_port = 1281 TOKEN_STRING_INITIALIZER(struct cmd_operate_detach_port_result, 1282 port, "port"); 1283 static cmdline_parse_token_string_t cmd_operate_detach_port_keyword = 1284 TOKEN_STRING_INITIALIZER(struct cmd_operate_detach_port_result, 1285 keyword, "detach"); 1286 static cmdline_parse_token_num_t cmd_operate_detach_port_port_id = 1287 TOKEN_NUM_INITIALIZER(struct cmd_operate_detach_port_result, 1288 port_id, RTE_UINT16); 1289 1290 static cmdline_parse_inst_t cmd_operate_detach_port = { 1291 .f = cmd_operate_detach_port_parsed, 1292 .data = NULL, 1293 .help_str = "port detach <port_id>", 1294 .tokens = { 1295 (void *)&cmd_operate_detach_port_port, 1296 (void *)&cmd_operate_detach_port_keyword, 1297 (void *)&cmd_operate_detach_port_port_id, 1298 NULL, 1299 }, 1300 }; 1301 1302 /* *** detach device by identifier *** */ 1303 struct cmd_operate_detach_device_result { 1304 cmdline_fixed_string_t device; 1305 cmdline_fixed_string_t keyword; 1306 cmdline_fixed_string_t identifier; 1307 }; 1308 1309 static void cmd_operate_detach_device_parsed(void *parsed_result, 1310 __rte_unused struct cmdline *cl, 1311 __rte_unused void *data) 1312 { 1313 struct cmd_operate_detach_device_result *res = parsed_result; 1314 1315 if (!strcmp(res->keyword, "detach")) 1316 detach_devargs(res->identifier); 1317 else 1318 fprintf(stderr, "Unknown parameter\n"); 1319 } 1320 1321 static cmdline_parse_token_string_t cmd_operate_detach_device_device = 1322 TOKEN_STRING_INITIALIZER(struct cmd_operate_detach_device_result, 1323 device, "device"); 1324 static cmdline_parse_token_string_t cmd_operate_detach_device_keyword = 1325 TOKEN_STRING_INITIALIZER(struct cmd_operate_detach_device_result, 1326 keyword, "detach"); 1327 static cmdline_parse_token_string_t cmd_operate_detach_device_identifier = 1328 TOKEN_STRING_INITIALIZER(struct cmd_operate_detach_device_result, 1329 identifier, NULL); 1330 1331 static cmdline_parse_inst_t cmd_operate_detach_device = { 1332 .f = cmd_operate_detach_device_parsed, 1333 .data = NULL, 1334 .help_str = "device detach <identifier>:" 1335 "(identifier: pci address or virtual dev name)", 1336 .tokens = { 1337 (void *)&cmd_operate_detach_device_device, 1338 (void *)&cmd_operate_detach_device_keyword, 1339 (void *)&cmd_operate_detach_device_identifier, 1340 NULL, 1341 }, 1342 }; 1343 /* *** configure speed for all ports *** */ 1344 struct cmd_config_speed_all { 1345 cmdline_fixed_string_t port; 1346 cmdline_fixed_string_t keyword; 1347 cmdline_fixed_string_t all; 1348 cmdline_fixed_string_t item1; 1349 cmdline_fixed_string_t item2; 1350 cmdline_fixed_string_t value1; 1351 cmdline_fixed_string_t value2; 1352 }; 1353 1354 static int 1355 parse_and_check_speed_duplex(char *speedstr, char *duplexstr, uint32_t *speed) 1356 { 1357 1358 int duplex; 1359 1360 if (!strcmp(duplexstr, "half")) { 1361 duplex = RTE_ETH_LINK_HALF_DUPLEX; 1362 } else if (!strcmp(duplexstr, "full")) { 1363 duplex = RTE_ETH_LINK_FULL_DUPLEX; 1364 } else if (!strcmp(duplexstr, "auto")) { 1365 duplex = RTE_ETH_LINK_FULL_DUPLEX; 1366 } else { 1367 fprintf(stderr, "Unknown duplex parameter\n"); 1368 return -1; 1369 } 1370 1371 if (!strcmp(speedstr, "10")) { 1372 *speed = (duplex == RTE_ETH_LINK_HALF_DUPLEX) ? 1373 RTE_ETH_LINK_SPEED_10M_HD : RTE_ETH_LINK_SPEED_10M; 1374 } else if (!strcmp(speedstr, "100")) { 1375 *speed = (duplex == RTE_ETH_LINK_HALF_DUPLEX) ? 1376 RTE_ETH_LINK_SPEED_100M_HD : RTE_ETH_LINK_SPEED_100M; 1377 } else { 1378 if (duplex != RTE_ETH_LINK_FULL_DUPLEX) { 1379 fprintf(stderr, "Invalid speed/duplex parameters\n"); 1380 return -1; 1381 } 1382 if (!strcmp(speedstr, "1000")) { 1383 *speed = RTE_ETH_LINK_SPEED_1G; 1384 } else if (!strcmp(speedstr, "2500")) { 1385 *speed = RTE_ETH_LINK_SPEED_2_5G; 1386 } else if (!strcmp(speedstr, "5000")) { 1387 *speed = RTE_ETH_LINK_SPEED_5G; 1388 } else if (!strcmp(speedstr, "10000")) { 1389 *speed = RTE_ETH_LINK_SPEED_10G; 1390 } else if (!strcmp(speedstr, "25000")) { 1391 *speed = RTE_ETH_LINK_SPEED_25G; 1392 } else if (!strcmp(speedstr, "40000")) { 1393 *speed = RTE_ETH_LINK_SPEED_40G; 1394 } else if (!strcmp(speedstr, "50000")) { 1395 *speed = RTE_ETH_LINK_SPEED_50G; 1396 } else if (!strcmp(speedstr, "100000")) { 1397 *speed = RTE_ETH_LINK_SPEED_100G; 1398 } else if (!strcmp(speedstr, "200000")) { 1399 *speed = RTE_ETH_LINK_SPEED_200G; 1400 } else if (!strcmp(speedstr, "400000")) { 1401 *speed = RTE_ETH_LINK_SPEED_400G; 1402 } else if (!strcmp(speedstr, "auto")) { 1403 *speed = RTE_ETH_LINK_SPEED_AUTONEG; 1404 } else { 1405 fprintf(stderr, "Unknown speed parameter\n"); 1406 return -1; 1407 } 1408 } 1409 1410 if (*speed != RTE_ETH_LINK_SPEED_AUTONEG) 1411 *speed |= RTE_ETH_LINK_SPEED_FIXED; 1412 1413 return 0; 1414 } 1415 1416 static void 1417 cmd_config_speed_all_parsed(void *parsed_result, 1418 __rte_unused struct cmdline *cl, 1419 __rte_unused void *data) 1420 { 1421 struct cmd_config_speed_all *res = parsed_result; 1422 uint32_t link_speed; 1423 portid_t pid; 1424 1425 if (!all_ports_stopped()) { 1426 fprintf(stderr, "Please stop all ports first\n"); 1427 return; 1428 } 1429 1430 if (parse_and_check_speed_duplex(res->value1, res->value2, 1431 &link_speed) < 0) 1432 return; 1433 1434 RTE_ETH_FOREACH_DEV(pid) { 1435 ports[pid].dev_conf.link_speeds = link_speed; 1436 } 1437 1438 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1); 1439 } 1440 1441 static cmdline_parse_token_string_t cmd_config_speed_all_port = 1442 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_all, port, "port"); 1443 static cmdline_parse_token_string_t cmd_config_speed_all_keyword = 1444 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_all, keyword, 1445 "config"); 1446 static cmdline_parse_token_string_t cmd_config_speed_all_all = 1447 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_all, all, "all"); 1448 static cmdline_parse_token_string_t cmd_config_speed_all_item1 = 1449 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_all, item1, "speed"); 1450 static cmdline_parse_token_string_t cmd_config_speed_all_value1 = 1451 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_all, value1, 1452 "10#100#1000#2500#5000#10000#25000#40000#50000#100000#200000#400000#auto"); 1453 static cmdline_parse_token_string_t cmd_config_speed_all_item2 = 1454 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_all, item2, "duplex"); 1455 static cmdline_parse_token_string_t cmd_config_speed_all_value2 = 1456 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_all, value2, 1457 "half#full#auto"); 1458 1459 static cmdline_parse_inst_t cmd_config_speed_all = { 1460 .f = cmd_config_speed_all_parsed, 1461 .data = NULL, 1462 .help_str = "port config all speed " 1463 "10|100|1000|2500|5000|10000|25000|40000|50000|100000|200000|400000|auto duplex " 1464 "half|full|auto", 1465 .tokens = { 1466 (void *)&cmd_config_speed_all_port, 1467 (void *)&cmd_config_speed_all_keyword, 1468 (void *)&cmd_config_speed_all_all, 1469 (void *)&cmd_config_speed_all_item1, 1470 (void *)&cmd_config_speed_all_value1, 1471 (void *)&cmd_config_speed_all_item2, 1472 (void *)&cmd_config_speed_all_value2, 1473 NULL, 1474 }, 1475 }; 1476 1477 /* *** configure speed for specific port *** */ 1478 struct cmd_config_speed_specific { 1479 cmdline_fixed_string_t port; 1480 cmdline_fixed_string_t keyword; 1481 portid_t id; 1482 cmdline_fixed_string_t item1; 1483 cmdline_fixed_string_t item2; 1484 cmdline_fixed_string_t value1; 1485 cmdline_fixed_string_t value2; 1486 }; 1487 1488 static void 1489 cmd_config_speed_specific_parsed(void *parsed_result, 1490 __rte_unused struct cmdline *cl, 1491 __rte_unused void *data) 1492 { 1493 struct cmd_config_speed_specific *res = parsed_result; 1494 uint32_t link_speed; 1495 1496 if (port_id_is_invalid(res->id, ENABLED_WARN)) 1497 return; 1498 1499 if (!port_is_stopped(res->id)) { 1500 fprintf(stderr, "Please stop port %d first\n", res->id); 1501 return; 1502 } 1503 1504 if (parse_and_check_speed_duplex(res->value1, res->value2, 1505 &link_speed) < 0) 1506 return; 1507 1508 ports[res->id].dev_conf.link_speeds = link_speed; 1509 1510 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1); 1511 } 1512 1513 1514 static cmdline_parse_token_string_t cmd_config_speed_specific_port = 1515 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_specific, port, 1516 "port"); 1517 static cmdline_parse_token_string_t cmd_config_speed_specific_keyword = 1518 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_specific, keyword, 1519 "config"); 1520 static cmdline_parse_token_num_t cmd_config_speed_specific_id = 1521 TOKEN_NUM_INITIALIZER(struct cmd_config_speed_specific, id, RTE_UINT16); 1522 static cmdline_parse_token_string_t cmd_config_speed_specific_item1 = 1523 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_specific, item1, 1524 "speed"); 1525 static cmdline_parse_token_string_t cmd_config_speed_specific_value1 = 1526 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_specific, value1, 1527 "10#100#1000#2500#5000#10000#25000#40000#50000#100000#200000#400000#auto"); 1528 static cmdline_parse_token_string_t cmd_config_speed_specific_item2 = 1529 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_specific, item2, 1530 "duplex"); 1531 static cmdline_parse_token_string_t cmd_config_speed_specific_value2 = 1532 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_specific, value2, 1533 "half#full#auto"); 1534 1535 static cmdline_parse_inst_t cmd_config_speed_specific = { 1536 .f = cmd_config_speed_specific_parsed, 1537 .data = NULL, 1538 .help_str = "port config <port_id> speed " 1539 "10|100|1000|2500|5000|10000|25000|40000|50000|100000|200000|400000|auto duplex " 1540 "half|full|auto", 1541 .tokens = { 1542 (void *)&cmd_config_speed_specific_port, 1543 (void *)&cmd_config_speed_specific_keyword, 1544 (void *)&cmd_config_speed_specific_id, 1545 (void *)&cmd_config_speed_specific_item1, 1546 (void *)&cmd_config_speed_specific_value1, 1547 (void *)&cmd_config_speed_specific_item2, 1548 (void *)&cmd_config_speed_specific_value2, 1549 NULL, 1550 }, 1551 }; 1552 1553 /* *** configure loopback for all ports *** */ 1554 struct cmd_config_loopback_all { 1555 cmdline_fixed_string_t port; 1556 cmdline_fixed_string_t keyword; 1557 cmdline_fixed_string_t all; 1558 cmdline_fixed_string_t item; 1559 uint32_t mode; 1560 }; 1561 1562 static void 1563 cmd_config_loopback_all_parsed(void *parsed_result, 1564 __rte_unused struct cmdline *cl, 1565 __rte_unused void *data) 1566 { 1567 struct cmd_config_loopback_all *res = parsed_result; 1568 portid_t pid; 1569 1570 if (!all_ports_stopped()) { 1571 fprintf(stderr, "Please stop all ports first\n"); 1572 return; 1573 } 1574 1575 RTE_ETH_FOREACH_DEV(pid) { 1576 ports[pid].dev_conf.lpbk_mode = res->mode; 1577 } 1578 1579 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1); 1580 } 1581 1582 static cmdline_parse_token_string_t cmd_config_loopback_all_port = 1583 TOKEN_STRING_INITIALIZER(struct cmd_config_loopback_all, port, "port"); 1584 static cmdline_parse_token_string_t cmd_config_loopback_all_keyword = 1585 TOKEN_STRING_INITIALIZER(struct cmd_config_loopback_all, keyword, 1586 "config"); 1587 static cmdline_parse_token_string_t cmd_config_loopback_all_all = 1588 TOKEN_STRING_INITIALIZER(struct cmd_config_loopback_all, all, "all"); 1589 static cmdline_parse_token_string_t cmd_config_loopback_all_item = 1590 TOKEN_STRING_INITIALIZER(struct cmd_config_loopback_all, item, 1591 "loopback"); 1592 static cmdline_parse_token_num_t cmd_config_loopback_all_mode = 1593 TOKEN_NUM_INITIALIZER(struct cmd_config_loopback_all, mode, RTE_UINT32); 1594 1595 static cmdline_parse_inst_t cmd_config_loopback_all = { 1596 .f = cmd_config_loopback_all_parsed, 1597 .data = NULL, 1598 .help_str = "port config all loopback <mode>", 1599 .tokens = { 1600 (void *)&cmd_config_loopback_all_port, 1601 (void *)&cmd_config_loopback_all_keyword, 1602 (void *)&cmd_config_loopback_all_all, 1603 (void *)&cmd_config_loopback_all_item, 1604 (void *)&cmd_config_loopback_all_mode, 1605 NULL, 1606 }, 1607 }; 1608 1609 /* *** configure loopback for specific port *** */ 1610 struct cmd_config_loopback_specific { 1611 cmdline_fixed_string_t port; 1612 cmdline_fixed_string_t keyword; 1613 uint16_t port_id; 1614 cmdline_fixed_string_t item; 1615 uint32_t mode; 1616 }; 1617 1618 static void 1619 cmd_config_loopback_specific_parsed(void *parsed_result, 1620 __rte_unused struct cmdline *cl, 1621 __rte_unused void *data) 1622 { 1623 struct cmd_config_loopback_specific *res = parsed_result; 1624 1625 if (port_id_is_invalid(res->port_id, ENABLED_WARN)) 1626 return; 1627 1628 if (!port_is_stopped(res->port_id)) { 1629 fprintf(stderr, "Please stop port %u first\n", res->port_id); 1630 return; 1631 } 1632 1633 ports[res->port_id].dev_conf.lpbk_mode = res->mode; 1634 1635 cmd_reconfig_device_queue(res->port_id, 1, 1); 1636 } 1637 1638 1639 static cmdline_parse_token_string_t cmd_config_loopback_specific_port = 1640 TOKEN_STRING_INITIALIZER(struct cmd_config_loopback_specific, port, 1641 "port"); 1642 static cmdline_parse_token_string_t cmd_config_loopback_specific_keyword = 1643 TOKEN_STRING_INITIALIZER(struct cmd_config_loopback_specific, keyword, 1644 "config"); 1645 static cmdline_parse_token_num_t cmd_config_loopback_specific_id = 1646 TOKEN_NUM_INITIALIZER(struct cmd_config_loopback_specific, port_id, 1647 RTE_UINT16); 1648 static cmdline_parse_token_string_t cmd_config_loopback_specific_item = 1649 TOKEN_STRING_INITIALIZER(struct cmd_config_loopback_specific, item, 1650 "loopback"); 1651 static cmdline_parse_token_num_t cmd_config_loopback_specific_mode = 1652 TOKEN_NUM_INITIALIZER(struct cmd_config_loopback_specific, mode, 1653 RTE_UINT32); 1654 1655 static cmdline_parse_inst_t cmd_config_loopback_specific = { 1656 .f = cmd_config_loopback_specific_parsed, 1657 .data = NULL, 1658 .help_str = "port config <port_id> loopback <mode>", 1659 .tokens = { 1660 (void *)&cmd_config_loopback_specific_port, 1661 (void *)&cmd_config_loopback_specific_keyword, 1662 (void *)&cmd_config_loopback_specific_id, 1663 (void *)&cmd_config_loopback_specific_item, 1664 (void *)&cmd_config_loopback_specific_mode, 1665 NULL, 1666 }, 1667 }; 1668 1669 /* *** configure txq/rxq, txd/rxd *** */ 1670 struct cmd_config_rx_tx { 1671 cmdline_fixed_string_t port; 1672 cmdline_fixed_string_t keyword; 1673 cmdline_fixed_string_t all; 1674 cmdline_fixed_string_t name; 1675 uint16_t value; 1676 }; 1677 1678 static void 1679 cmd_config_rx_tx_parsed(void *parsed_result, 1680 __rte_unused struct cmdline *cl, 1681 __rte_unused void *data) 1682 { 1683 struct cmd_config_rx_tx *res = parsed_result; 1684 1685 if (!all_ports_stopped()) { 1686 fprintf(stderr, "Please stop all ports first\n"); 1687 return; 1688 } 1689 if (!strcmp(res->name, "rxq")) { 1690 if (!res->value && !nb_txq) { 1691 fprintf(stderr, "Warning: Either rx or tx queues should be non zero\n"); 1692 return; 1693 } 1694 if (check_nb_rxq(res->value) != 0) 1695 return; 1696 nb_rxq = res->value; 1697 } 1698 else if (!strcmp(res->name, "txq")) { 1699 if (!res->value && !nb_rxq) { 1700 fprintf(stderr, "Warning: Either rx or tx queues should be non zero\n"); 1701 return; 1702 } 1703 if (check_nb_txq(res->value) != 0) 1704 return; 1705 nb_txq = res->value; 1706 } 1707 else if (!strcmp(res->name, "rxd")) { 1708 if (check_nb_rxd(res->value) != 0) 1709 return; 1710 nb_rxd = res->value; 1711 } else if (!strcmp(res->name, "txd")) { 1712 if (check_nb_txd(res->value) != 0) 1713 return; 1714 1715 nb_txd = res->value; 1716 } else { 1717 fprintf(stderr, "Unknown parameter\n"); 1718 return; 1719 } 1720 1721 fwd_config_setup(); 1722 1723 init_port_config(); 1724 1725 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1); 1726 } 1727 1728 static cmdline_parse_token_string_t cmd_config_rx_tx_port = 1729 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_tx, port, "port"); 1730 static cmdline_parse_token_string_t cmd_config_rx_tx_keyword = 1731 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_tx, keyword, "config"); 1732 static cmdline_parse_token_string_t cmd_config_rx_tx_all = 1733 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_tx, all, "all"); 1734 static cmdline_parse_token_string_t cmd_config_rx_tx_name = 1735 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_tx, name, 1736 "rxq#txq#rxd#txd"); 1737 static cmdline_parse_token_num_t cmd_config_rx_tx_value = 1738 TOKEN_NUM_INITIALIZER(struct cmd_config_rx_tx, value, RTE_UINT16); 1739 1740 static cmdline_parse_inst_t cmd_config_rx_tx = { 1741 .f = cmd_config_rx_tx_parsed, 1742 .data = NULL, 1743 .help_str = "port config all rxq|txq|rxd|txd <value>", 1744 .tokens = { 1745 (void *)&cmd_config_rx_tx_port, 1746 (void *)&cmd_config_rx_tx_keyword, 1747 (void *)&cmd_config_rx_tx_all, 1748 (void *)&cmd_config_rx_tx_name, 1749 (void *)&cmd_config_rx_tx_value, 1750 NULL, 1751 }, 1752 }; 1753 1754 /* *** config max packet length *** */ 1755 struct cmd_config_max_pkt_len_result { 1756 cmdline_fixed_string_t port; 1757 cmdline_fixed_string_t keyword; 1758 cmdline_fixed_string_t all; 1759 cmdline_fixed_string_t name; 1760 uint32_t value; 1761 }; 1762 1763 static void 1764 cmd_config_max_pkt_len_parsed(void *parsed_result, 1765 __rte_unused struct cmdline *cl, 1766 __rte_unused void *data) 1767 { 1768 struct cmd_config_max_pkt_len_result *res = parsed_result; 1769 portid_t port_id; 1770 int ret; 1771 1772 if (strcmp(res->name, "max-pkt-len") != 0) { 1773 printf("Unknown parameter\n"); 1774 return; 1775 } 1776 1777 if (!all_ports_stopped()) { 1778 fprintf(stderr, "Please stop all ports first\n"); 1779 return; 1780 } 1781 1782 RTE_ETH_FOREACH_DEV(port_id) { 1783 struct rte_port *port = &ports[port_id]; 1784 1785 if (res->value < RTE_ETHER_MIN_LEN) { 1786 fprintf(stderr, 1787 "max-pkt-len can not be less than %d\n", 1788 RTE_ETHER_MIN_LEN); 1789 return; 1790 } 1791 1792 ret = eth_dev_info_get_print_err(port_id, &port->dev_info); 1793 if (ret != 0) { 1794 fprintf(stderr, 1795 "rte_eth_dev_info_get() failed for port %u\n", 1796 port_id); 1797 return; 1798 } 1799 1800 update_mtu_from_frame_size(port_id, res->value); 1801 } 1802 1803 init_port_config(); 1804 1805 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1); 1806 } 1807 1808 static cmdline_parse_token_string_t cmd_config_max_pkt_len_port = 1809 TOKEN_STRING_INITIALIZER(struct cmd_config_max_pkt_len_result, port, 1810 "port"); 1811 static cmdline_parse_token_string_t cmd_config_max_pkt_len_keyword = 1812 TOKEN_STRING_INITIALIZER(struct cmd_config_max_pkt_len_result, keyword, 1813 "config"); 1814 static cmdline_parse_token_string_t cmd_config_max_pkt_len_all = 1815 TOKEN_STRING_INITIALIZER(struct cmd_config_max_pkt_len_result, all, 1816 "all"); 1817 static cmdline_parse_token_string_t cmd_config_max_pkt_len_name = 1818 TOKEN_STRING_INITIALIZER(struct cmd_config_max_pkt_len_result, name, 1819 "max-pkt-len"); 1820 static cmdline_parse_token_num_t cmd_config_max_pkt_len_value = 1821 TOKEN_NUM_INITIALIZER(struct cmd_config_max_pkt_len_result, value, 1822 RTE_UINT32); 1823 1824 static cmdline_parse_inst_t cmd_config_max_pkt_len = { 1825 .f = cmd_config_max_pkt_len_parsed, 1826 .data = NULL, 1827 .help_str = "port config all max-pkt-len <value>", 1828 .tokens = { 1829 (void *)&cmd_config_max_pkt_len_port, 1830 (void *)&cmd_config_max_pkt_len_keyword, 1831 (void *)&cmd_config_max_pkt_len_all, 1832 (void *)&cmd_config_max_pkt_len_name, 1833 (void *)&cmd_config_max_pkt_len_value, 1834 NULL, 1835 }, 1836 }; 1837 1838 /* *** config max LRO aggregated packet size *** */ 1839 struct cmd_config_max_lro_pkt_size_result { 1840 cmdline_fixed_string_t port; 1841 cmdline_fixed_string_t keyword; 1842 cmdline_fixed_string_t all; 1843 cmdline_fixed_string_t name; 1844 uint32_t value; 1845 }; 1846 1847 static void 1848 cmd_config_max_lro_pkt_size_parsed(void *parsed_result, 1849 __rte_unused struct cmdline *cl, 1850 __rte_unused void *data) 1851 { 1852 struct cmd_config_max_lro_pkt_size_result *res = parsed_result; 1853 portid_t pid; 1854 1855 if (!all_ports_stopped()) { 1856 fprintf(stderr, "Please stop all ports first\n"); 1857 return; 1858 } 1859 1860 RTE_ETH_FOREACH_DEV(pid) { 1861 struct rte_port *port = &ports[pid]; 1862 1863 if (!strcmp(res->name, "max-lro-pkt-size")) { 1864 if (res->value == 1865 port->dev_conf.rxmode.max_lro_pkt_size) 1866 return; 1867 1868 port->dev_conf.rxmode.max_lro_pkt_size = res->value; 1869 } else { 1870 fprintf(stderr, "Unknown parameter\n"); 1871 return; 1872 } 1873 } 1874 1875 init_port_config(); 1876 1877 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1); 1878 } 1879 1880 static cmdline_parse_token_string_t cmd_config_max_lro_pkt_size_port = 1881 TOKEN_STRING_INITIALIZER(struct cmd_config_max_lro_pkt_size_result, 1882 port, "port"); 1883 static cmdline_parse_token_string_t cmd_config_max_lro_pkt_size_keyword = 1884 TOKEN_STRING_INITIALIZER(struct cmd_config_max_lro_pkt_size_result, 1885 keyword, "config"); 1886 static cmdline_parse_token_string_t cmd_config_max_lro_pkt_size_all = 1887 TOKEN_STRING_INITIALIZER(struct cmd_config_max_lro_pkt_size_result, 1888 all, "all"); 1889 static cmdline_parse_token_string_t cmd_config_max_lro_pkt_size_name = 1890 TOKEN_STRING_INITIALIZER(struct cmd_config_max_lro_pkt_size_result, 1891 name, "max-lro-pkt-size"); 1892 static cmdline_parse_token_num_t cmd_config_max_lro_pkt_size_value = 1893 TOKEN_NUM_INITIALIZER(struct cmd_config_max_lro_pkt_size_result, 1894 value, RTE_UINT32); 1895 1896 static cmdline_parse_inst_t cmd_config_max_lro_pkt_size = { 1897 .f = cmd_config_max_lro_pkt_size_parsed, 1898 .data = NULL, 1899 .help_str = "port config all max-lro-pkt-size <value>", 1900 .tokens = { 1901 (void *)&cmd_config_max_lro_pkt_size_port, 1902 (void *)&cmd_config_max_lro_pkt_size_keyword, 1903 (void *)&cmd_config_max_lro_pkt_size_all, 1904 (void *)&cmd_config_max_lro_pkt_size_name, 1905 (void *)&cmd_config_max_lro_pkt_size_value, 1906 NULL, 1907 }, 1908 }; 1909 1910 /* *** configure port MTU *** */ 1911 struct cmd_config_mtu_result { 1912 cmdline_fixed_string_t port; 1913 cmdline_fixed_string_t keyword; 1914 cmdline_fixed_string_t mtu; 1915 portid_t port_id; 1916 uint16_t value; 1917 }; 1918 1919 static void 1920 cmd_config_mtu_parsed(void *parsed_result, 1921 __rte_unused struct cmdline *cl, 1922 __rte_unused void *data) 1923 { 1924 struct cmd_config_mtu_result *res = parsed_result; 1925 1926 port_mtu_set(res->port_id, res->value); 1927 } 1928 1929 static cmdline_parse_token_string_t cmd_config_mtu_port = 1930 TOKEN_STRING_INITIALIZER(struct cmd_config_mtu_result, port, 1931 "port"); 1932 static cmdline_parse_token_string_t cmd_config_mtu_keyword = 1933 TOKEN_STRING_INITIALIZER(struct cmd_config_mtu_result, keyword, 1934 "config"); 1935 static cmdline_parse_token_string_t cmd_config_mtu_mtu = 1936 TOKEN_STRING_INITIALIZER(struct cmd_config_mtu_result, keyword, 1937 "mtu"); 1938 static cmdline_parse_token_num_t cmd_config_mtu_port_id = 1939 TOKEN_NUM_INITIALIZER(struct cmd_config_mtu_result, port_id, 1940 RTE_UINT16); 1941 static cmdline_parse_token_num_t cmd_config_mtu_value = 1942 TOKEN_NUM_INITIALIZER(struct cmd_config_mtu_result, value, 1943 RTE_UINT16); 1944 1945 static cmdline_parse_inst_t cmd_config_mtu = { 1946 .f = cmd_config_mtu_parsed, 1947 .data = NULL, 1948 .help_str = "port config mtu <port_id> <value>", 1949 .tokens = { 1950 (void *)&cmd_config_mtu_port, 1951 (void *)&cmd_config_mtu_keyword, 1952 (void *)&cmd_config_mtu_mtu, 1953 (void *)&cmd_config_mtu_port_id, 1954 (void *)&cmd_config_mtu_value, 1955 NULL, 1956 }, 1957 }; 1958 1959 /* *** configure rx mode *** */ 1960 struct cmd_config_rx_mode_flag { 1961 cmdline_fixed_string_t port; 1962 cmdline_fixed_string_t keyword; 1963 cmdline_fixed_string_t all; 1964 cmdline_fixed_string_t name; 1965 cmdline_fixed_string_t value; 1966 }; 1967 1968 static void 1969 cmd_config_rx_mode_flag_parsed(void *parsed_result, 1970 __rte_unused struct cmdline *cl, 1971 __rte_unused void *data) 1972 { 1973 struct cmd_config_rx_mode_flag *res = parsed_result; 1974 1975 if (!all_ports_stopped()) { 1976 fprintf(stderr, "Please stop all ports first\n"); 1977 return; 1978 } 1979 1980 if (!strcmp(res->name, "drop-en")) { 1981 if (!strcmp(res->value, "on")) 1982 rx_drop_en = 1; 1983 else if (!strcmp(res->value, "off")) 1984 rx_drop_en = 0; 1985 else { 1986 fprintf(stderr, "Unknown parameter\n"); 1987 return; 1988 } 1989 } else { 1990 fprintf(stderr, "Unknown parameter\n"); 1991 return; 1992 } 1993 1994 init_port_config(); 1995 1996 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1); 1997 } 1998 1999 static cmdline_parse_token_string_t cmd_config_rx_mode_flag_port = 2000 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_mode_flag, port, "port"); 2001 static cmdline_parse_token_string_t cmd_config_rx_mode_flag_keyword = 2002 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_mode_flag, keyword, 2003 "config"); 2004 static cmdline_parse_token_string_t cmd_config_rx_mode_flag_all = 2005 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_mode_flag, all, "all"); 2006 static cmdline_parse_token_string_t cmd_config_rx_mode_flag_name = 2007 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_mode_flag, name, 2008 "drop-en"); 2009 static cmdline_parse_token_string_t cmd_config_rx_mode_flag_value = 2010 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_mode_flag, value, 2011 "on#off"); 2012 2013 static cmdline_parse_inst_t cmd_config_rx_mode_flag = { 2014 .f = cmd_config_rx_mode_flag_parsed, 2015 .data = NULL, 2016 .help_str = "port config all drop-en on|off", 2017 .tokens = { 2018 (void *)&cmd_config_rx_mode_flag_port, 2019 (void *)&cmd_config_rx_mode_flag_keyword, 2020 (void *)&cmd_config_rx_mode_flag_all, 2021 (void *)&cmd_config_rx_mode_flag_name, 2022 (void *)&cmd_config_rx_mode_flag_value, 2023 NULL, 2024 }, 2025 }; 2026 2027 /* *** configure rss *** */ 2028 struct cmd_config_rss { 2029 cmdline_fixed_string_t port; 2030 cmdline_fixed_string_t keyword; 2031 cmdline_fixed_string_t all; 2032 cmdline_fixed_string_t name; 2033 cmdline_fixed_string_t value; 2034 }; 2035 2036 static void 2037 cmd_config_rss_parsed(void *parsed_result, 2038 __rte_unused struct cmdline *cl, 2039 __rte_unused void *data) 2040 { 2041 struct cmd_config_rss *res = parsed_result; 2042 struct rte_eth_rss_conf rss_conf = { .rss_key_len = 0, }; 2043 struct rte_eth_dev_info dev_info = { .flow_type_rss_offloads = 0, }; 2044 int use_default = 0; 2045 int all_updated = 1; 2046 int diag; 2047 uint16_t i; 2048 int ret; 2049 2050 if (!strcmp(res->value, "level-default")) { 2051 rss_hf &= (~RTE_ETH_RSS_LEVEL_MASK); 2052 rss_conf.rss_hf = (rss_hf | RTE_ETH_RSS_LEVEL_PMD_DEFAULT); 2053 } else if (!strcmp(res->value, "level-outer")) { 2054 rss_hf &= (~RTE_ETH_RSS_LEVEL_MASK); 2055 rss_conf.rss_hf = (rss_hf | RTE_ETH_RSS_LEVEL_OUTERMOST); 2056 } else if (!strcmp(res->value, "level-inner")) { 2057 rss_hf &= (~RTE_ETH_RSS_LEVEL_MASK); 2058 rss_conf.rss_hf = (rss_hf | RTE_ETH_RSS_LEVEL_INNERMOST); 2059 } else if (!strcmp(res->value, "default")) { 2060 use_default = 1; 2061 } else if (isdigit(res->value[0])) { 2062 int value = atoi(res->value); 2063 if (value > 0 && value < 64) 2064 rss_conf.rss_hf = 1ULL << (uint8_t)value; 2065 else { 2066 fprintf(stderr, "flowtype_id should be greater than 0 and less than 64.\n"); 2067 return; 2068 } 2069 } else if (!strcmp(res->value, "none")) { 2070 rss_conf.rss_hf = 0; 2071 } else { 2072 rss_conf.rss_hf = str_to_rsstypes(res->value); 2073 if (rss_conf.rss_hf == 0) { 2074 fprintf(stderr, "Unknown parameter\n"); 2075 return; 2076 } 2077 } 2078 rss_conf.rss_key = NULL; 2079 /* Update global configuration for RSS types. */ 2080 RTE_ETH_FOREACH_DEV(i) { 2081 struct rte_eth_rss_conf local_rss_conf; 2082 2083 ret = eth_dev_info_get_print_err(i, &dev_info); 2084 if (ret != 0) 2085 return; 2086 2087 if (use_default) 2088 rss_conf.rss_hf = dev_info.flow_type_rss_offloads; 2089 2090 local_rss_conf = rss_conf; 2091 local_rss_conf.rss_hf = rss_conf.rss_hf & 2092 dev_info.flow_type_rss_offloads; 2093 if (local_rss_conf.rss_hf != rss_conf.rss_hf) { 2094 printf("Port %u modified RSS hash function based on hardware support," 2095 "requested:%#"PRIx64" configured:%#"PRIx64"\n", 2096 i, rss_conf.rss_hf, local_rss_conf.rss_hf); 2097 } 2098 diag = rte_eth_dev_rss_hash_update(i, &local_rss_conf); 2099 if (diag < 0) { 2100 all_updated = 0; 2101 fprintf(stderr, 2102 "Configuration of RSS hash at ethernet port %d failed with error (%d): %s.\n", 2103 i, -diag, strerror(-diag)); 2104 } 2105 } 2106 if (all_updated && !use_default) { 2107 rss_hf = rss_conf.rss_hf; 2108 printf("rss_hf %#"PRIx64"\n", rss_hf); 2109 } 2110 } 2111 2112 static cmdline_parse_token_string_t cmd_config_rss_port = 2113 TOKEN_STRING_INITIALIZER(struct cmd_config_rss, port, "port"); 2114 static cmdline_parse_token_string_t cmd_config_rss_keyword = 2115 TOKEN_STRING_INITIALIZER(struct cmd_config_rss, keyword, "config"); 2116 static cmdline_parse_token_string_t cmd_config_rss_all = 2117 TOKEN_STRING_INITIALIZER(struct cmd_config_rss, all, "all"); 2118 static cmdline_parse_token_string_t cmd_config_rss_name = 2119 TOKEN_STRING_INITIALIZER(struct cmd_config_rss, name, "rss"); 2120 static cmdline_parse_token_string_t cmd_config_rss_value = 2121 TOKEN_STRING_INITIALIZER(struct cmd_config_rss, value, NULL); 2122 2123 static cmdline_parse_inst_t cmd_config_rss = { 2124 .f = cmd_config_rss_parsed, 2125 .data = NULL, 2126 .help_str = "port config all rss " 2127 "all|default|level-default|level-outer|level-inner|" 2128 "ip|tcp|udp|sctp|tunnel|vlan|none|" 2129 "ipv4|ipv4-frag|ipv4-tcp|ipv4-udp|ipv4-sctp|ipv4-other|" 2130 "ipv6|ipv6-frag|ipv6-tcp|ipv6-udp|ipv6-sctp|ipv6-other|ipv6-ex|ipv6-tcp-ex|ipv6-udp-ex|" 2131 "l2-payload|port|vxlan|geneve|nvgre|gtpu|eth|s-vlan|c-vlan|" 2132 "esp|ah|l2tpv3|pfcp|pppoe|ecpri|mpls|ipv4-chksum|l4-chksum|" 2133 "l2tpv2|l3-pre96|l3-pre64|l3-pre56|l3-pre48|l3-pre40|l3-pre32|" 2134 "l2-dst-only|l2-src-only|l4-dst-only|l4-src-only|l3-dst-only|l3-src-only|<rsstype_id>", 2135 .tokens = { 2136 (void *)&cmd_config_rss_port, 2137 (void *)&cmd_config_rss_keyword, 2138 (void *)&cmd_config_rss_all, 2139 (void *)&cmd_config_rss_name, 2140 (void *)&cmd_config_rss_value, 2141 NULL, 2142 }, 2143 }; 2144 2145 /* *** configure rss hash key *** */ 2146 struct cmd_config_rss_hash_key { 2147 cmdline_fixed_string_t port; 2148 cmdline_fixed_string_t config; 2149 portid_t port_id; 2150 cmdline_fixed_string_t rss_hash_key; 2151 cmdline_fixed_string_t rss_type; 2152 cmdline_fixed_string_t key; 2153 }; 2154 2155 static uint8_t 2156 hexa_digit_to_value(char hexa_digit) 2157 { 2158 if ((hexa_digit >= '0') && (hexa_digit <= '9')) 2159 return (uint8_t) (hexa_digit - '0'); 2160 if ((hexa_digit >= 'a') && (hexa_digit <= 'f')) 2161 return (uint8_t) ((hexa_digit - 'a') + 10); 2162 if ((hexa_digit >= 'A') && (hexa_digit <= 'F')) 2163 return (uint8_t) ((hexa_digit - 'A') + 10); 2164 /* Invalid hexa digit */ 2165 return 0xFF; 2166 } 2167 2168 static uint8_t 2169 parse_and_check_key_hexa_digit(char *key, int idx) 2170 { 2171 uint8_t hexa_v; 2172 2173 hexa_v = hexa_digit_to_value(key[idx]); 2174 if (hexa_v == 0xFF) 2175 fprintf(stderr, 2176 "invalid key: character %c at position %d is not a valid hexa digit\n", 2177 key[idx], idx); 2178 return hexa_v; 2179 } 2180 2181 static void 2182 cmd_config_rss_hash_key_parsed(void *parsed_result, 2183 __rte_unused struct cmdline *cl, 2184 __rte_unused void *data) 2185 { 2186 struct cmd_config_rss_hash_key *res = parsed_result; 2187 uint8_t hash_key[RSS_HASH_KEY_LENGTH]; 2188 uint8_t xdgt0; 2189 uint8_t xdgt1; 2190 int i; 2191 struct rte_eth_dev_info dev_info; 2192 uint8_t hash_key_size; 2193 uint32_t key_len; 2194 int ret; 2195 2196 ret = eth_dev_info_get_print_err(res->port_id, &dev_info); 2197 if (ret != 0) 2198 return; 2199 2200 if (dev_info.hash_key_size > 0 && 2201 dev_info.hash_key_size <= sizeof(hash_key)) 2202 hash_key_size = dev_info.hash_key_size; 2203 else { 2204 fprintf(stderr, 2205 "dev_info did not provide a valid hash key size\n"); 2206 return; 2207 } 2208 /* Check the length of the RSS hash key */ 2209 key_len = strlen(res->key); 2210 if (key_len != (hash_key_size * 2)) { 2211 fprintf(stderr, 2212 "key length: %d invalid - key must be a string of %d hexa-decimal numbers\n", 2213 (int)key_len, hash_key_size * 2); 2214 return; 2215 } 2216 /* Translate RSS hash key into binary representation */ 2217 for (i = 0; i < hash_key_size; i++) { 2218 xdgt0 = parse_and_check_key_hexa_digit(res->key, (i * 2)); 2219 if (xdgt0 == 0xFF) 2220 return; 2221 xdgt1 = parse_and_check_key_hexa_digit(res->key, (i * 2) + 1); 2222 if (xdgt1 == 0xFF) 2223 return; 2224 hash_key[i] = (uint8_t) ((xdgt0 * 16) + xdgt1); 2225 } 2226 port_rss_hash_key_update(res->port_id, res->rss_type, hash_key, 2227 hash_key_size); 2228 } 2229 2230 static cmdline_parse_token_string_t cmd_config_rss_hash_key_port = 2231 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_hash_key, port, "port"); 2232 static cmdline_parse_token_string_t cmd_config_rss_hash_key_config = 2233 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_hash_key, config, 2234 "config"); 2235 static cmdline_parse_token_num_t cmd_config_rss_hash_key_port_id = 2236 TOKEN_NUM_INITIALIZER(struct cmd_config_rss_hash_key, port_id, 2237 RTE_UINT16); 2238 static cmdline_parse_token_string_t cmd_config_rss_hash_key_rss_hash_key = 2239 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_hash_key, 2240 rss_hash_key, "rss-hash-key"); 2241 static cmdline_parse_token_string_t cmd_config_rss_hash_key_rss_type = 2242 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_hash_key, rss_type, 2243 "ipv4#ipv4-frag#ipv4-tcp#ipv4-udp#ipv4-sctp#" 2244 "ipv4-other#ipv6#ipv6-frag#ipv6-tcp#ipv6-udp#" 2245 "ipv6-sctp#ipv6-other#l2-payload#ipv6-ex#" 2246 "ipv6-tcp-ex#ipv6-udp-ex#" 2247 "l3-src-only#l3-dst-only#l4-src-only#l4-dst-only#" 2248 "l2-src-only#l2-dst-only#s-vlan#c-vlan#" 2249 "l2tpv3#esp#ah#pfcp#pppoe#gtpu#ecpri#mpls#l2tpv2"); 2250 static cmdline_parse_token_string_t cmd_config_rss_hash_key_value = 2251 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_hash_key, key, NULL); 2252 2253 static cmdline_parse_inst_t cmd_config_rss_hash_key = { 2254 .f = cmd_config_rss_hash_key_parsed, 2255 .data = NULL, 2256 .help_str = "port config <port_id> rss-hash-key " 2257 "ipv4|ipv4-frag|ipv4-tcp|ipv4-udp|ipv4-sctp|ipv4-other|" 2258 "ipv6|ipv6-frag|ipv6-tcp|ipv6-udp|ipv6-sctp|ipv6-other|" 2259 "l2-payload|ipv6-ex|ipv6-tcp-ex|ipv6-udp-ex|" 2260 "l3-src-only|l3-dst-only|l4-src-only|l4-dst-only|" 2261 "l2-src-only|l2-dst-only|s-vlan|c-vlan|" 2262 "l2tpv3|esp|ah|pfcp|pppoe|gtpu|ecpri|mpls|l2tpv2 " 2263 "<string of hex digits (variable length, NIC dependent)>", 2264 .tokens = { 2265 (void *)&cmd_config_rss_hash_key_port, 2266 (void *)&cmd_config_rss_hash_key_config, 2267 (void *)&cmd_config_rss_hash_key_port_id, 2268 (void *)&cmd_config_rss_hash_key_rss_hash_key, 2269 (void *)&cmd_config_rss_hash_key_rss_type, 2270 (void *)&cmd_config_rss_hash_key_value, 2271 NULL, 2272 }, 2273 }; 2274 2275 /* *** cleanup txq mbufs *** */ 2276 struct cmd_cleanup_txq_mbufs_result { 2277 cmdline_fixed_string_t port; 2278 cmdline_fixed_string_t keyword; 2279 cmdline_fixed_string_t name; 2280 uint16_t port_id; 2281 uint16_t queue_id; 2282 uint32_t free_cnt; 2283 }; 2284 2285 static void 2286 cmd_cleanup_txq_mbufs_parsed(void *parsed_result, 2287 __rte_unused struct cmdline *cl, 2288 __rte_unused void *data) 2289 { 2290 struct cmd_cleanup_txq_mbufs_result *res = parsed_result; 2291 uint16_t port_id = res->port_id; 2292 uint16_t queue_id = res->queue_id; 2293 uint32_t free_cnt = res->free_cnt; 2294 struct rte_eth_txq_info qinfo; 2295 int ret; 2296 2297 if (test_done == 0) { 2298 fprintf(stderr, "Please stop forwarding first\n"); 2299 return; 2300 } 2301 2302 if (rte_eth_tx_queue_info_get(port_id, queue_id, &qinfo)) { 2303 fprintf(stderr, "Failed to get port %u Tx queue %u info\n", 2304 port_id, queue_id); 2305 return; 2306 } 2307 2308 if (qinfo.queue_state != RTE_ETH_QUEUE_STATE_STARTED) { 2309 fprintf(stderr, "Tx queue %u not started\n", queue_id); 2310 return; 2311 } 2312 2313 ret = rte_eth_tx_done_cleanup(port_id, queue_id, free_cnt); 2314 if (ret < 0) { 2315 fprintf(stderr, 2316 "Failed to cleanup mbuf for port %u Tx queue %u error desc: %s(%d)\n", 2317 port_id, queue_id, strerror(-ret), ret); 2318 return; 2319 } 2320 2321 printf("Cleanup port %u Tx queue %u mbuf nums: %u\n", 2322 port_id, queue_id, ret); 2323 } 2324 2325 static cmdline_parse_token_string_t cmd_cleanup_txq_mbufs_port = 2326 TOKEN_STRING_INITIALIZER(struct cmd_cleanup_txq_mbufs_result, port, 2327 "port"); 2328 static cmdline_parse_token_string_t cmd_cleanup_txq_mbufs_cleanup = 2329 TOKEN_STRING_INITIALIZER(struct cmd_cleanup_txq_mbufs_result, keyword, 2330 "cleanup"); 2331 static cmdline_parse_token_num_t cmd_cleanup_txq_mbufs_port_id = 2332 TOKEN_NUM_INITIALIZER(struct cmd_cleanup_txq_mbufs_result, port_id, 2333 RTE_UINT16); 2334 static cmdline_parse_token_string_t cmd_cleanup_txq_mbufs_txq = 2335 TOKEN_STRING_INITIALIZER(struct cmd_cleanup_txq_mbufs_result, name, 2336 "txq"); 2337 static cmdline_parse_token_num_t cmd_cleanup_txq_mbufs_queue_id = 2338 TOKEN_NUM_INITIALIZER(struct cmd_cleanup_txq_mbufs_result, queue_id, 2339 RTE_UINT16); 2340 static cmdline_parse_token_num_t cmd_cleanup_txq_mbufs_free_cnt = 2341 TOKEN_NUM_INITIALIZER(struct cmd_cleanup_txq_mbufs_result, free_cnt, 2342 RTE_UINT32); 2343 2344 static cmdline_parse_inst_t cmd_cleanup_txq_mbufs = { 2345 .f = cmd_cleanup_txq_mbufs_parsed, 2346 .data = NULL, 2347 .help_str = "port cleanup <port_id> txq <queue_id> <free_cnt>", 2348 .tokens = { 2349 (void *)&cmd_cleanup_txq_mbufs_port, 2350 (void *)&cmd_cleanup_txq_mbufs_cleanup, 2351 (void *)&cmd_cleanup_txq_mbufs_port_id, 2352 (void *)&cmd_cleanup_txq_mbufs_txq, 2353 (void *)&cmd_cleanup_txq_mbufs_queue_id, 2354 (void *)&cmd_cleanup_txq_mbufs_free_cnt, 2355 NULL, 2356 }, 2357 }; 2358 2359 /* *** configure port rxq/txq ring size *** */ 2360 struct cmd_config_rxtx_ring_size { 2361 cmdline_fixed_string_t port; 2362 cmdline_fixed_string_t config; 2363 portid_t portid; 2364 cmdline_fixed_string_t rxtxq; 2365 uint16_t qid; 2366 cmdline_fixed_string_t rsize; 2367 uint16_t size; 2368 }; 2369 2370 static void 2371 cmd_config_rxtx_ring_size_parsed(void *parsed_result, 2372 __rte_unused struct cmdline *cl, 2373 __rte_unused void *data) 2374 { 2375 struct cmd_config_rxtx_ring_size *res = parsed_result; 2376 struct rte_port *port; 2377 uint8_t isrx; 2378 2379 if (port_id_is_invalid(res->portid, ENABLED_WARN)) 2380 return; 2381 2382 if (res->portid == (portid_t)RTE_PORT_ALL) { 2383 fprintf(stderr, "Invalid port id\n"); 2384 return; 2385 } 2386 2387 port = &ports[res->portid]; 2388 2389 if (!strcmp(res->rxtxq, "rxq")) 2390 isrx = 1; 2391 else if (!strcmp(res->rxtxq, "txq")) 2392 isrx = 0; 2393 else { 2394 fprintf(stderr, "Unknown parameter\n"); 2395 return; 2396 } 2397 2398 if (isrx && rx_queue_id_is_invalid(res->qid)) 2399 return; 2400 else if (!isrx && tx_queue_id_is_invalid(res->qid)) 2401 return; 2402 2403 if (isrx && res->size != 0 && res->size <= rx_free_thresh) { 2404 fprintf(stderr, 2405 "Invalid rx ring_size, must > rx_free_thresh: %d\n", 2406 rx_free_thresh); 2407 return; 2408 } 2409 2410 if (isrx) 2411 port->nb_rx_desc[res->qid] = res->size; 2412 else 2413 port->nb_tx_desc[res->qid] = res->size; 2414 2415 cmd_reconfig_device_queue(res->portid, 0, 1); 2416 } 2417 2418 static cmdline_parse_token_string_t cmd_config_rxtx_ring_size_port = 2419 TOKEN_STRING_INITIALIZER(struct cmd_config_rxtx_ring_size, 2420 port, "port"); 2421 static cmdline_parse_token_string_t cmd_config_rxtx_ring_size_config = 2422 TOKEN_STRING_INITIALIZER(struct cmd_config_rxtx_ring_size, 2423 config, "config"); 2424 static cmdline_parse_token_num_t cmd_config_rxtx_ring_size_portid = 2425 TOKEN_NUM_INITIALIZER(struct cmd_config_rxtx_ring_size, 2426 portid, RTE_UINT16); 2427 static cmdline_parse_token_string_t cmd_config_rxtx_ring_size_rxtxq = 2428 TOKEN_STRING_INITIALIZER(struct cmd_config_rxtx_ring_size, 2429 rxtxq, "rxq#txq"); 2430 static cmdline_parse_token_num_t cmd_config_rxtx_ring_size_qid = 2431 TOKEN_NUM_INITIALIZER(struct cmd_config_rxtx_ring_size, 2432 qid, RTE_UINT16); 2433 static cmdline_parse_token_string_t cmd_config_rxtx_ring_size_rsize = 2434 TOKEN_STRING_INITIALIZER(struct cmd_config_rxtx_ring_size, 2435 rsize, "ring_size"); 2436 static cmdline_parse_token_num_t cmd_config_rxtx_ring_size_size = 2437 TOKEN_NUM_INITIALIZER(struct cmd_config_rxtx_ring_size, 2438 size, RTE_UINT16); 2439 2440 static cmdline_parse_inst_t cmd_config_rxtx_ring_size = { 2441 .f = cmd_config_rxtx_ring_size_parsed, 2442 .data = NULL, 2443 .help_str = "port config <port_id> rxq|txq <queue_id> ring_size <value>", 2444 .tokens = { 2445 (void *)&cmd_config_rxtx_ring_size_port, 2446 (void *)&cmd_config_rxtx_ring_size_config, 2447 (void *)&cmd_config_rxtx_ring_size_portid, 2448 (void *)&cmd_config_rxtx_ring_size_rxtxq, 2449 (void *)&cmd_config_rxtx_ring_size_qid, 2450 (void *)&cmd_config_rxtx_ring_size_rsize, 2451 (void *)&cmd_config_rxtx_ring_size_size, 2452 NULL, 2453 }, 2454 }; 2455 2456 /* *** configure port rxq/txq start/stop *** */ 2457 struct cmd_config_rxtx_queue { 2458 cmdline_fixed_string_t port; 2459 portid_t portid; 2460 cmdline_fixed_string_t rxtxq; 2461 uint16_t qid; 2462 cmdline_fixed_string_t opname; 2463 }; 2464 2465 static void 2466 cmd_config_rxtx_queue_parsed(void *parsed_result, 2467 __rte_unused struct cmdline *cl, 2468 __rte_unused void *data) 2469 { 2470 struct cmd_config_rxtx_queue *res = parsed_result; 2471 struct rte_port *port; 2472 uint8_t isrx; 2473 uint8_t isstart; 2474 uint8_t *state; 2475 int ret = 0; 2476 2477 if (test_done == 0) { 2478 fprintf(stderr, "Please stop forwarding first\n"); 2479 return; 2480 } 2481 2482 if (port_id_is_invalid(res->portid, ENABLED_WARN)) 2483 return; 2484 2485 if (port_is_started(res->portid) != 1) { 2486 fprintf(stderr, "Please start port %u first\n", res->portid); 2487 return; 2488 } 2489 2490 if (!strcmp(res->rxtxq, "rxq")) 2491 isrx = 1; 2492 else if (!strcmp(res->rxtxq, "txq")) 2493 isrx = 0; 2494 else { 2495 fprintf(stderr, "Unknown parameter\n"); 2496 return; 2497 } 2498 2499 if (isrx && rx_queue_id_is_invalid(res->qid)) 2500 return; 2501 else if (!isrx && tx_queue_id_is_invalid(res->qid)) 2502 return; 2503 2504 if (!strcmp(res->opname, "start")) 2505 isstart = 1; 2506 else if (!strcmp(res->opname, "stop")) 2507 isstart = 0; 2508 else { 2509 fprintf(stderr, "Unknown parameter\n"); 2510 return; 2511 } 2512 2513 if (isstart && isrx) 2514 ret = rte_eth_dev_rx_queue_start(res->portid, res->qid); 2515 else if (!isstart && isrx) 2516 ret = rte_eth_dev_rx_queue_stop(res->portid, res->qid); 2517 else if (isstart && !isrx) 2518 ret = rte_eth_dev_tx_queue_start(res->portid, res->qid); 2519 else 2520 ret = rte_eth_dev_tx_queue_stop(res->portid, res->qid); 2521 2522 if (ret == -ENOTSUP) { 2523 fprintf(stderr, "Function not supported in PMD\n"); 2524 return; 2525 } 2526 2527 port = &ports[res->portid]; 2528 state = isrx ? &port->rxq[res->qid].state : &port->txq[res->qid].state; 2529 *state = isstart ? RTE_ETH_QUEUE_STATE_STARTED : 2530 RTE_ETH_QUEUE_STATE_STOPPED; 2531 } 2532 2533 static cmdline_parse_token_string_t cmd_config_rxtx_queue_port = 2534 TOKEN_STRING_INITIALIZER(struct cmd_config_rxtx_queue, port, "port"); 2535 static cmdline_parse_token_num_t cmd_config_rxtx_queue_portid = 2536 TOKEN_NUM_INITIALIZER(struct cmd_config_rxtx_queue, portid, RTE_UINT16); 2537 static cmdline_parse_token_string_t cmd_config_rxtx_queue_rxtxq = 2538 TOKEN_STRING_INITIALIZER(struct cmd_config_rxtx_queue, rxtxq, "rxq#txq"); 2539 static cmdline_parse_token_num_t cmd_config_rxtx_queue_qid = 2540 TOKEN_NUM_INITIALIZER(struct cmd_config_rxtx_queue, qid, RTE_UINT16); 2541 static cmdline_parse_token_string_t cmd_config_rxtx_queue_opname = 2542 TOKEN_STRING_INITIALIZER(struct cmd_config_rxtx_queue, opname, 2543 "start#stop"); 2544 2545 static cmdline_parse_inst_t cmd_config_rxtx_queue = { 2546 .f = cmd_config_rxtx_queue_parsed, 2547 .data = NULL, 2548 .help_str = "port <port_id> rxq|txq <queue_id> start|stop", 2549 .tokens = { 2550 (void *)&cmd_config_rxtx_queue_port, 2551 (void *)&cmd_config_rxtx_queue_portid, 2552 (void *)&cmd_config_rxtx_queue_rxtxq, 2553 (void *)&cmd_config_rxtx_queue_qid, 2554 (void *)&cmd_config_rxtx_queue_opname, 2555 NULL, 2556 }, 2557 }; 2558 2559 /* *** configure port rxq/txq deferred start on/off *** */ 2560 struct cmd_config_deferred_start_rxtx_queue { 2561 cmdline_fixed_string_t port; 2562 portid_t port_id; 2563 cmdline_fixed_string_t rxtxq; 2564 uint16_t qid; 2565 cmdline_fixed_string_t opname; 2566 cmdline_fixed_string_t state; 2567 }; 2568 2569 static void 2570 cmd_config_deferred_start_rxtx_queue_parsed(void *parsed_result, 2571 __rte_unused struct cmdline *cl, 2572 __rte_unused void *data) 2573 { 2574 struct cmd_config_deferred_start_rxtx_queue *res = parsed_result; 2575 struct rte_port *port; 2576 uint8_t isrx; 2577 uint8_t ison; 2578 uint8_t needreconfig = 0; 2579 2580 if (port_id_is_invalid(res->port_id, ENABLED_WARN)) 2581 return; 2582 2583 if (port_is_started(res->port_id) != 0) { 2584 fprintf(stderr, "Please stop port %u first\n", res->port_id); 2585 return; 2586 } 2587 2588 port = &ports[res->port_id]; 2589 2590 isrx = !strcmp(res->rxtxq, "rxq"); 2591 2592 if (isrx && rx_queue_id_is_invalid(res->qid)) 2593 return; 2594 else if (!isrx && tx_queue_id_is_invalid(res->qid)) 2595 return; 2596 2597 ison = !strcmp(res->state, "on"); 2598 2599 if (isrx && port->rxq[res->qid].conf.rx_deferred_start != ison) { 2600 port->rxq[res->qid].conf.rx_deferred_start = ison; 2601 needreconfig = 1; 2602 } else if (!isrx && port->txq[res->qid].conf.tx_deferred_start != ison) { 2603 port->txq[res->qid].conf.tx_deferred_start = ison; 2604 needreconfig = 1; 2605 } 2606 2607 if (needreconfig) 2608 cmd_reconfig_device_queue(res->port_id, 0, 1); 2609 } 2610 2611 static cmdline_parse_token_string_t cmd_config_deferred_start_rxtx_queue_port = 2612 TOKEN_STRING_INITIALIZER(struct cmd_config_deferred_start_rxtx_queue, 2613 port, "port"); 2614 static cmdline_parse_token_num_t cmd_config_deferred_start_rxtx_queue_port_id = 2615 TOKEN_NUM_INITIALIZER(struct cmd_config_deferred_start_rxtx_queue, 2616 port_id, RTE_UINT16); 2617 static cmdline_parse_token_string_t cmd_config_deferred_start_rxtx_queue_rxtxq = 2618 TOKEN_STRING_INITIALIZER(struct cmd_config_deferred_start_rxtx_queue, 2619 rxtxq, "rxq#txq"); 2620 static cmdline_parse_token_num_t cmd_config_deferred_start_rxtx_queue_qid = 2621 TOKEN_NUM_INITIALIZER(struct cmd_config_deferred_start_rxtx_queue, 2622 qid, RTE_UINT16); 2623 static cmdline_parse_token_string_t cmd_config_deferred_start_rxtx_queue_opname = 2624 TOKEN_STRING_INITIALIZER(struct cmd_config_deferred_start_rxtx_queue, 2625 opname, "deferred_start"); 2626 static cmdline_parse_token_string_t cmd_config_deferred_start_rxtx_queue_state = 2627 TOKEN_STRING_INITIALIZER(struct cmd_config_deferred_start_rxtx_queue, 2628 state, "on#off"); 2629 2630 static cmdline_parse_inst_t cmd_config_deferred_start_rxtx_queue = { 2631 .f = cmd_config_deferred_start_rxtx_queue_parsed, 2632 .data = NULL, 2633 .help_str = "port <port_id> rxq|txq <queue_id> deferred_start on|off", 2634 .tokens = { 2635 (void *)&cmd_config_deferred_start_rxtx_queue_port, 2636 (void *)&cmd_config_deferred_start_rxtx_queue_port_id, 2637 (void *)&cmd_config_deferred_start_rxtx_queue_rxtxq, 2638 (void *)&cmd_config_deferred_start_rxtx_queue_qid, 2639 (void *)&cmd_config_deferred_start_rxtx_queue_opname, 2640 (void *)&cmd_config_deferred_start_rxtx_queue_state, 2641 NULL, 2642 }, 2643 }; 2644 2645 /* *** configure port rxq/txq setup *** */ 2646 struct cmd_setup_rxtx_queue { 2647 cmdline_fixed_string_t port; 2648 portid_t portid; 2649 cmdline_fixed_string_t rxtxq; 2650 uint16_t qid; 2651 cmdline_fixed_string_t setup; 2652 }; 2653 2654 /* Common CLI fields for queue setup */ 2655 static cmdline_parse_token_string_t cmd_setup_rxtx_queue_port = 2656 TOKEN_STRING_INITIALIZER(struct cmd_setup_rxtx_queue, port, "port"); 2657 static cmdline_parse_token_num_t cmd_setup_rxtx_queue_portid = 2658 TOKEN_NUM_INITIALIZER(struct cmd_setup_rxtx_queue, portid, RTE_UINT16); 2659 static cmdline_parse_token_string_t cmd_setup_rxtx_queue_rxtxq = 2660 TOKEN_STRING_INITIALIZER(struct cmd_setup_rxtx_queue, rxtxq, "rxq#txq"); 2661 static cmdline_parse_token_num_t cmd_setup_rxtx_queue_qid = 2662 TOKEN_NUM_INITIALIZER(struct cmd_setup_rxtx_queue, qid, RTE_UINT16); 2663 static cmdline_parse_token_string_t cmd_setup_rxtx_queue_setup = 2664 TOKEN_STRING_INITIALIZER(struct cmd_setup_rxtx_queue, setup, "setup"); 2665 2666 static void 2667 cmd_setup_rxtx_queue_parsed( 2668 void *parsed_result, 2669 __rte_unused struct cmdline *cl, 2670 __rte_unused void *data) 2671 { 2672 struct cmd_setup_rxtx_queue *res = parsed_result; 2673 struct rte_port *port; 2674 struct rte_mempool *mp; 2675 unsigned int socket_id; 2676 uint8_t isrx = 0; 2677 int ret; 2678 2679 if (port_id_is_invalid(res->portid, ENABLED_WARN)) 2680 return; 2681 2682 if (res->portid == (portid_t)RTE_PORT_ALL) { 2683 fprintf(stderr, "Invalid port id\n"); 2684 return; 2685 } 2686 2687 if (!strcmp(res->rxtxq, "rxq")) 2688 isrx = 1; 2689 else if (!strcmp(res->rxtxq, "txq")) 2690 isrx = 0; 2691 else { 2692 fprintf(stderr, "Unknown parameter\n"); 2693 return; 2694 } 2695 2696 if (isrx && rx_queue_id_is_invalid(res->qid)) { 2697 fprintf(stderr, "Invalid rx queue\n"); 2698 return; 2699 } else if (!isrx && tx_queue_id_is_invalid(res->qid)) { 2700 fprintf(stderr, "Invalid tx queue\n"); 2701 return; 2702 } 2703 2704 port = &ports[res->portid]; 2705 if (isrx) { 2706 socket_id = rxring_numa[res->portid]; 2707 if (!numa_support || socket_id == NUMA_NO_CONFIG) 2708 socket_id = port->socket_id; 2709 2710 mp = mbuf_pool_find(socket_id, 0); 2711 if (mp == NULL) { 2712 fprintf(stderr, 2713 "Failed to setup RX queue: No mempool allocation on the socket %d\n", 2714 rxring_numa[res->portid]); 2715 return; 2716 } 2717 ret = rx_queue_setup(res->portid, 2718 res->qid, 2719 port->nb_rx_desc[res->qid], 2720 socket_id, 2721 &port->rxq[res->qid].conf, 2722 mp); 2723 if (ret) 2724 fprintf(stderr, "Failed to setup RX queue\n"); 2725 } else { 2726 socket_id = txring_numa[res->portid]; 2727 if (!numa_support || socket_id == NUMA_NO_CONFIG) 2728 socket_id = port->socket_id; 2729 2730 if (port->nb_tx_desc[res->qid] < tx_pkt_nb_segs) { 2731 fprintf(stderr, 2732 "Failed to setup TX queue: not enough descriptors\n"); 2733 return; 2734 } 2735 ret = rte_eth_tx_queue_setup(res->portid, 2736 res->qid, 2737 port->nb_tx_desc[res->qid], 2738 socket_id, 2739 &port->txq[res->qid].conf); 2740 if (ret) 2741 fprintf(stderr, "Failed to setup TX queue\n"); 2742 } 2743 } 2744 2745 static cmdline_parse_inst_t cmd_setup_rxtx_queue = { 2746 .f = cmd_setup_rxtx_queue_parsed, 2747 .data = NULL, 2748 .help_str = "port <port_id> rxq|txq <queue_idx> setup", 2749 .tokens = { 2750 (void *)&cmd_setup_rxtx_queue_port, 2751 (void *)&cmd_setup_rxtx_queue_portid, 2752 (void *)&cmd_setup_rxtx_queue_rxtxq, 2753 (void *)&cmd_setup_rxtx_queue_qid, 2754 (void *)&cmd_setup_rxtx_queue_setup, 2755 NULL, 2756 }, 2757 }; 2758 2759 2760 /* *** Configure RSS RETA *** */ 2761 struct cmd_config_rss_reta { 2762 cmdline_fixed_string_t port; 2763 cmdline_fixed_string_t keyword; 2764 portid_t port_id; 2765 cmdline_fixed_string_t name; 2766 cmdline_fixed_string_t list_name; 2767 cmdline_fixed_string_t list_of_items; 2768 }; 2769 2770 static int 2771 parse_reta_config(const char *str, 2772 struct rte_eth_rss_reta_entry64 *reta_conf, 2773 uint16_t nb_entries) 2774 { 2775 int i; 2776 unsigned size; 2777 uint16_t hash_index, idx, shift; 2778 uint16_t nb_queue; 2779 char s[256]; 2780 const char *p, *p0 = str; 2781 char *end; 2782 enum fieldnames { 2783 FLD_HASH_INDEX = 0, 2784 FLD_QUEUE, 2785 _NUM_FLD 2786 }; 2787 unsigned long int_fld[_NUM_FLD]; 2788 char *str_fld[_NUM_FLD]; 2789 2790 while ((p = strchr(p0,'(')) != NULL) { 2791 ++p; 2792 if((p0 = strchr(p,')')) == NULL) 2793 return -1; 2794 2795 size = p0 - p; 2796 if(size >= sizeof(s)) 2797 return -1; 2798 2799 snprintf(s, sizeof(s), "%.*s", size, p); 2800 if (rte_strsplit(s, sizeof(s), str_fld, _NUM_FLD, ',') != _NUM_FLD) 2801 return -1; 2802 for (i = 0; i < _NUM_FLD; i++) { 2803 errno = 0; 2804 int_fld[i] = strtoul(str_fld[i], &end, 0); 2805 if (errno != 0 || end == str_fld[i] || 2806 int_fld[i] > 65535) 2807 return -1; 2808 } 2809 2810 hash_index = (uint16_t)int_fld[FLD_HASH_INDEX]; 2811 nb_queue = (uint16_t)int_fld[FLD_QUEUE]; 2812 2813 if (hash_index >= nb_entries) { 2814 fprintf(stderr, "Invalid RETA hash index=%d\n", 2815 hash_index); 2816 return -1; 2817 } 2818 2819 idx = hash_index / RTE_ETH_RETA_GROUP_SIZE; 2820 shift = hash_index % RTE_ETH_RETA_GROUP_SIZE; 2821 reta_conf[idx].mask |= (1ULL << shift); 2822 reta_conf[idx].reta[shift] = nb_queue; 2823 } 2824 2825 return 0; 2826 } 2827 2828 static void 2829 cmd_set_rss_reta_parsed(void *parsed_result, 2830 __rte_unused struct cmdline *cl, 2831 __rte_unused void *data) 2832 { 2833 int ret; 2834 struct rte_eth_dev_info dev_info; 2835 struct rte_eth_rss_reta_entry64 reta_conf[8]; 2836 struct cmd_config_rss_reta *res = parsed_result; 2837 2838 ret = eth_dev_info_get_print_err(res->port_id, &dev_info); 2839 if (ret != 0) 2840 return; 2841 2842 if (dev_info.reta_size == 0) { 2843 fprintf(stderr, 2844 "Redirection table size is 0 which is invalid for RSS\n"); 2845 return; 2846 } else 2847 printf("The reta size of port %d is %u\n", 2848 res->port_id, dev_info.reta_size); 2849 if (dev_info.reta_size > RTE_ETH_RSS_RETA_SIZE_512) { 2850 fprintf(stderr, 2851 "Currently do not support more than %u entries of redirection table\n", 2852 RTE_ETH_RSS_RETA_SIZE_512); 2853 return; 2854 } 2855 2856 memset(reta_conf, 0, sizeof(reta_conf)); 2857 if (!strcmp(res->list_name, "reta")) { 2858 if (parse_reta_config(res->list_of_items, reta_conf, 2859 dev_info.reta_size)) { 2860 fprintf(stderr, 2861 "Invalid RSS Redirection Table config entered\n"); 2862 return; 2863 } 2864 ret = rte_eth_dev_rss_reta_update(res->port_id, 2865 reta_conf, dev_info.reta_size); 2866 if (ret != 0) 2867 fprintf(stderr, 2868 "Bad redirection table parameter, return code = %d\n", 2869 ret); 2870 } 2871 } 2872 2873 static cmdline_parse_token_string_t cmd_config_rss_reta_port = 2874 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_reta, port, "port"); 2875 static cmdline_parse_token_string_t cmd_config_rss_reta_keyword = 2876 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_reta, keyword, "config"); 2877 static cmdline_parse_token_num_t cmd_config_rss_reta_port_id = 2878 TOKEN_NUM_INITIALIZER(struct cmd_config_rss_reta, port_id, RTE_UINT16); 2879 static cmdline_parse_token_string_t cmd_config_rss_reta_name = 2880 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_reta, name, "rss"); 2881 static cmdline_parse_token_string_t cmd_config_rss_reta_list_name = 2882 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_reta, list_name, "reta"); 2883 static cmdline_parse_token_string_t cmd_config_rss_reta_list_of_items = 2884 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_reta, list_of_items, 2885 NULL); 2886 static cmdline_parse_inst_t cmd_config_rss_reta = { 2887 .f = cmd_set_rss_reta_parsed, 2888 .data = NULL, 2889 .help_str = "port config <port_id> rss reta <hash,queue[,hash,queue]*>", 2890 .tokens = { 2891 (void *)&cmd_config_rss_reta_port, 2892 (void *)&cmd_config_rss_reta_keyword, 2893 (void *)&cmd_config_rss_reta_port_id, 2894 (void *)&cmd_config_rss_reta_name, 2895 (void *)&cmd_config_rss_reta_list_name, 2896 (void *)&cmd_config_rss_reta_list_of_items, 2897 NULL, 2898 }, 2899 }; 2900 2901 /* *** SHOW PORT RETA INFO *** */ 2902 struct cmd_showport_reta { 2903 cmdline_fixed_string_t show; 2904 cmdline_fixed_string_t port; 2905 portid_t port_id; 2906 cmdline_fixed_string_t rss; 2907 cmdline_fixed_string_t reta; 2908 uint16_t size; 2909 cmdline_fixed_string_t list_of_items; 2910 }; 2911 2912 static int 2913 showport_parse_reta_config(struct rte_eth_rss_reta_entry64 *conf, 2914 uint16_t nb_entries, 2915 char *str) 2916 { 2917 uint32_t size; 2918 const char *p, *p0 = str; 2919 char s[256]; 2920 char *end; 2921 char *str_fld[8]; 2922 uint16_t i; 2923 uint16_t num = (nb_entries + RTE_ETH_RETA_GROUP_SIZE - 1) / 2924 RTE_ETH_RETA_GROUP_SIZE; 2925 int ret; 2926 2927 p = strchr(p0, '('); 2928 if (p == NULL) 2929 return -1; 2930 p++; 2931 p0 = strchr(p, ')'); 2932 if (p0 == NULL) 2933 return -1; 2934 size = p0 - p; 2935 if (size >= sizeof(s)) { 2936 fprintf(stderr, 2937 "The string size exceeds the internal buffer size\n"); 2938 return -1; 2939 } 2940 snprintf(s, sizeof(s), "%.*s", size, p); 2941 ret = rte_strsplit(s, sizeof(s), str_fld, num, ','); 2942 if (ret <= 0 || ret != num) { 2943 fprintf(stderr, 2944 "The bits of masks do not match the number of reta entries: %u\n", 2945 num); 2946 return -1; 2947 } 2948 for (i = 0; i < ret; i++) 2949 conf[i].mask = (uint64_t)strtoull(str_fld[i], &end, 0); 2950 2951 return 0; 2952 } 2953 2954 static void 2955 cmd_showport_reta_parsed(void *parsed_result, 2956 __rte_unused struct cmdline *cl, 2957 __rte_unused void *data) 2958 { 2959 struct cmd_showport_reta *res = parsed_result; 2960 struct rte_eth_rss_reta_entry64 reta_conf[8]; 2961 struct rte_eth_dev_info dev_info; 2962 uint16_t max_reta_size; 2963 int ret; 2964 2965 ret = eth_dev_info_get_print_err(res->port_id, &dev_info); 2966 if (ret != 0) 2967 return; 2968 2969 max_reta_size = RTE_MIN(dev_info.reta_size, RTE_ETH_RSS_RETA_SIZE_512); 2970 if (res->size == 0 || res->size > max_reta_size) { 2971 fprintf(stderr, "Invalid redirection table size: %u (1-%u)\n", 2972 res->size, max_reta_size); 2973 return; 2974 } 2975 2976 memset(reta_conf, 0, sizeof(reta_conf)); 2977 if (showport_parse_reta_config(reta_conf, res->size, 2978 res->list_of_items) < 0) { 2979 fprintf(stderr, "Invalid string: %s for reta masks\n", 2980 res->list_of_items); 2981 return; 2982 } 2983 port_rss_reta_info(res->port_id, reta_conf, res->size); 2984 } 2985 2986 static cmdline_parse_token_string_t cmd_showport_reta_show = 2987 TOKEN_STRING_INITIALIZER(struct cmd_showport_reta, show, "show"); 2988 static cmdline_parse_token_string_t cmd_showport_reta_port = 2989 TOKEN_STRING_INITIALIZER(struct cmd_showport_reta, port, "port"); 2990 static cmdline_parse_token_num_t cmd_showport_reta_port_id = 2991 TOKEN_NUM_INITIALIZER(struct cmd_showport_reta, port_id, RTE_UINT16); 2992 static cmdline_parse_token_string_t cmd_showport_reta_rss = 2993 TOKEN_STRING_INITIALIZER(struct cmd_showport_reta, rss, "rss"); 2994 static cmdline_parse_token_string_t cmd_showport_reta_reta = 2995 TOKEN_STRING_INITIALIZER(struct cmd_showport_reta, reta, "reta"); 2996 static cmdline_parse_token_num_t cmd_showport_reta_size = 2997 TOKEN_NUM_INITIALIZER(struct cmd_showport_reta, size, RTE_UINT16); 2998 static cmdline_parse_token_string_t cmd_showport_reta_list_of_items = 2999 TOKEN_STRING_INITIALIZER(struct cmd_showport_reta, 3000 list_of_items, NULL); 3001 3002 static cmdline_parse_inst_t cmd_showport_reta = { 3003 .f = cmd_showport_reta_parsed, 3004 .data = NULL, 3005 .help_str = "show port <port_id> rss reta <size> <mask0[,mask1]*>", 3006 .tokens = { 3007 (void *)&cmd_showport_reta_show, 3008 (void *)&cmd_showport_reta_port, 3009 (void *)&cmd_showport_reta_port_id, 3010 (void *)&cmd_showport_reta_rss, 3011 (void *)&cmd_showport_reta_reta, 3012 (void *)&cmd_showport_reta_size, 3013 (void *)&cmd_showport_reta_list_of_items, 3014 NULL, 3015 }, 3016 }; 3017 3018 /* *** Show RSS hash configuration *** */ 3019 struct cmd_showport_rss_hash { 3020 cmdline_fixed_string_t show; 3021 cmdline_fixed_string_t port; 3022 portid_t port_id; 3023 cmdline_fixed_string_t rss_hash; 3024 cmdline_fixed_string_t rss_type; 3025 cmdline_fixed_string_t key; /* optional argument */ 3026 }; 3027 3028 static void cmd_showport_rss_hash_parsed(void *parsed_result, 3029 __rte_unused struct cmdline *cl, 3030 void *show_rss_key) 3031 { 3032 struct cmd_showport_rss_hash *res = parsed_result; 3033 3034 port_rss_hash_conf_show(res->port_id, show_rss_key != NULL); 3035 } 3036 3037 static cmdline_parse_token_string_t cmd_showport_rss_hash_show = 3038 TOKEN_STRING_INITIALIZER(struct cmd_showport_rss_hash, show, "show"); 3039 static cmdline_parse_token_string_t cmd_showport_rss_hash_port = 3040 TOKEN_STRING_INITIALIZER(struct cmd_showport_rss_hash, port, "port"); 3041 static cmdline_parse_token_num_t cmd_showport_rss_hash_port_id = 3042 TOKEN_NUM_INITIALIZER(struct cmd_showport_rss_hash, port_id, 3043 RTE_UINT16); 3044 static cmdline_parse_token_string_t cmd_showport_rss_hash_rss_hash = 3045 TOKEN_STRING_INITIALIZER(struct cmd_showport_rss_hash, rss_hash, 3046 "rss-hash"); 3047 static cmdline_parse_token_string_t cmd_showport_rss_hash_rss_key = 3048 TOKEN_STRING_INITIALIZER(struct cmd_showport_rss_hash, key, "key"); 3049 3050 static cmdline_parse_inst_t cmd_showport_rss_hash = { 3051 .f = cmd_showport_rss_hash_parsed, 3052 .data = NULL, 3053 .help_str = "show port <port_id> rss-hash", 3054 .tokens = { 3055 (void *)&cmd_showport_rss_hash_show, 3056 (void *)&cmd_showport_rss_hash_port, 3057 (void *)&cmd_showport_rss_hash_port_id, 3058 (void *)&cmd_showport_rss_hash_rss_hash, 3059 NULL, 3060 }, 3061 }; 3062 3063 static cmdline_parse_inst_t cmd_showport_rss_hash_key = { 3064 .f = cmd_showport_rss_hash_parsed, 3065 .data = (void *)1, 3066 .help_str = "show port <port_id> rss-hash key", 3067 .tokens = { 3068 (void *)&cmd_showport_rss_hash_show, 3069 (void *)&cmd_showport_rss_hash_port, 3070 (void *)&cmd_showport_rss_hash_port_id, 3071 (void *)&cmd_showport_rss_hash_rss_hash, 3072 (void *)&cmd_showport_rss_hash_rss_key, 3073 NULL, 3074 }, 3075 }; 3076 3077 /* *** Configure DCB *** */ 3078 struct cmd_config_dcb { 3079 cmdline_fixed_string_t port; 3080 cmdline_fixed_string_t config; 3081 portid_t port_id; 3082 cmdline_fixed_string_t dcb; 3083 cmdline_fixed_string_t vt; 3084 cmdline_fixed_string_t vt_en; 3085 uint8_t num_tcs; 3086 cmdline_fixed_string_t pfc; 3087 cmdline_fixed_string_t pfc_en; 3088 }; 3089 3090 static void 3091 cmd_config_dcb_parsed(void *parsed_result, 3092 __rte_unused struct cmdline *cl, 3093 __rte_unused void *data) 3094 { 3095 struct cmd_config_dcb *res = parsed_result; 3096 struct rte_eth_dcb_info dcb_info; 3097 portid_t port_id = res->port_id; 3098 struct rte_port *port; 3099 uint8_t pfc_en; 3100 int ret; 3101 3102 port = &ports[port_id]; 3103 /** Check if the port is not started **/ 3104 if (port->port_status != RTE_PORT_STOPPED) { 3105 fprintf(stderr, "Please stop port %d first\n", port_id); 3106 return; 3107 } 3108 3109 if ((res->num_tcs != RTE_ETH_4_TCS) && (res->num_tcs != RTE_ETH_8_TCS)) { 3110 fprintf(stderr, 3111 "The invalid number of traffic class, only 4 or 8 allowed.\n"); 3112 return; 3113 } 3114 3115 if (nb_fwd_lcores < res->num_tcs) { 3116 fprintf(stderr, 3117 "nb_cores shouldn't be less than number of TCs.\n"); 3118 return; 3119 } 3120 3121 /* Check whether the port supports the report of DCB info. */ 3122 ret = rte_eth_dev_get_dcb_info(port_id, &dcb_info); 3123 if (ret == -ENOTSUP) { 3124 fprintf(stderr, "rte_eth_dev_get_dcb_info not supported.\n"); 3125 return; 3126 } 3127 3128 if (!strncmp(res->pfc_en, "on", 2)) 3129 pfc_en = 1; 3130 else 3131 pfc_en = 0; 3132 3133 /* DCB in VT mode */ 3134 if (!strncmp(res->vt_en, "on", 2)) 3135 ret = init_port_dcb_config(port_id, DCB_VT_ENABLED, 3136 (enum rte_eth_nb_tcs)res->num_tcs, 3137 pfc_en); 3138 else 3139 ret = init_port_dcb_config(port_id, DCB_ENABLED, 3140 (enum rte_eth_nb_tcs)res->num_tcs, 3141 pfc_en); 3142 if (ret != 0) { 3143 fprintf(stderr, "Cannot initialize network ports.\n"); 3144 return; 3145 } 3146 3147 fwd_config_setup(); 3148 3149 cmd_reconfig_device_queue(port_id, 1, 1); 3150 } 3151 3152 static cmdline_parse_token_string_t cmd_config_dcb_port = 3153 TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, port, "port"); 3154 static cmdline_parse_token_string_t cmd_config_dcb_config = 3155 TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, config, "config"); 3156 static cmdline_parse_token_num_t cmd_config_dcb_port_id = 3157 TOKEN_NUM_INITIALIZER(struct cmd_config_dcb, port_id, RTE_UINT16); 3158 static cmdline_parse_token_string_t cmd_config_dcb_dcb = 3159 TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, dcb, "dcb"); 3160 static cmdline_parse_token_string_t cmd_config_dcb_vt = 3161 TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, vt, "vt"); 3162 static cmdline_parse_token_string_t cmd_config_dcb_vt_en = 3163 TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, vt_en, "on#off"); 3164 static cmdline_parse_token_num_t cmd_config_dcb_num_tcs = 3165 TOKEN_NUM_INITIALIZER(struct cmd_config_dcb, num_tcs, RTE_UINT8); 3166 static cmdline_parse_token_string_t cmd_config_dcb_pfc = 3167 TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, pfc, "pfc"); 3168 static cmdline_parse_token_string_t cmd_config_dcb_pfc_en = 3169 TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, pfc_en, "on#off"); 3170 3171 static cmdline_parse_inst_t cmd_config_dcb = { 3172 .f = cmd_config_dcb_parsed, 3173 .data = NULL, 3174 .help_str = "port config <port-id> dcb vt on|off <num_tcs> pfc on|off", 3175 .tokens = { 3176 (void *)&cmd_config_dcb_port, 3177 (void *)&cmd_config_dcb_config, 3178 (void *)&cmd_config_dcb_port_id, 3179 (void *)&cmd_config_dcb_dcb, 3180 (void *)&cmd_config_dcb_vt, 3181 (void *)&cmd_config_dcb_vt_en, 3182 (void *)&cmd_config_dcb_num_tcs, 3183 (void *)&cmd_config_dcb_pfc, 3184 (void *)&cmd_config_dcb_pfc_en, 3185 NULL, 3186 }, 3187 }; 3188 3189 /* *** configure number of packets per burst *** */ 3190 struct cmd_config_burst { 3191 cmdline_fixed_string_t port; 3192 cmdline_fixed_string_t keyword; 3193 cmdline_fixed_string_t all; 3194 cmdline_fixed_string_t name; 3195 uint16_t value; 3196 }; 3197 3198 static void 3199 cmd_config_burst_parsed(void *parsed_result, 3200 __rte_unused struct cmdline *cl, 3201 __rte_unused void *data) 3202 { 3203 struct cmd_config_burst *res = parsed_result; 3204 struct rte_eth_dev_info dev_info; 3205 uint16_t rec_nb_pkts; 3206 int ret; 3207 3208 if (!all_ports_stopped()) { 3209 fprintf(stderr, "Please stop all ports first\n"); 3210 return; 3211 } 3212 3213 if (!strcmp(res->name, "burst")) { 3214 if (res->value == 0) { 3215 /* If user gives a value of zero, query the PMD for 3216 * its recommended Rx burst size. Testpmd uses a single 3217 * size for all ports, so assume all ports are the same 3218 * NIC model and use the values from Port 0. 3219 */ 3220 ret = eth_dev_info_get_print_err(0, &dev_info); 3221 if (ret != 0) 3222 return; 3223 3224 rec_nb_pkts = dev_info.default_rxportconf.burst_size; 3225 3226 if (rec_nb_pkts == 0) { 3227 printf("PMD does not recommend a burst size.\n" 3228 "User provided value must be between" 3229 " 1 and %d\n", MAX_PKT_BURST); 3230 return; 3231 } else if (rec_nb_pkts > MAX_PKT_BURST) { 3232 printf("PMD recommended burst size of %d" 3233 " exceeds maximum value of %d\n", 3234 rec_nb_pkts, MAX_PKT_BURST); 3235 return; 3236 } 3237 printf("Using PMD-provided burst value of %d\n", 3238 rec_nb_pkts); 3239 nb_pkt_per_burst = rec_nb_pkts; 3240 } else if (res->value > MAX_PKT_BURST) { 3241 fprintf(stderr, "burst must be >= 1 && <= %d\n", 3242 MAX_PKT_BURST); 3243 return; 3244 } else 3245 nb_pkt_per_burst = res->value; 3246 } else { 3247 fprintf(stderr, "Unknown parameter\n"); 3248 return; 3249 } 3250 3251 init_port_config(); 3252 3253 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1); 3254 } 3255 3256 static cmdline_parse_token_string_t cmd_config_burst_port = 3257 TOKEN_STRING_INITIALIZER(struct cmd_config_burst, port, "port"); 3258 static cmdline_parse_token_string_t cmd_config_burst_keyword = 3259 TOKEN_STRING_INITIALIZER(struct cmd_config_burst, keyword, "config"); 3260 static cmdline_parse_token_string_t cmd_config_burst_all = 3261 TOKEN_STRING_INITIALIZER(struct cmd_config_burst, all, "all"); 3262 static cmdline_parse_token_string_t cmd_config_burst_name = 3263 TOKEN_STRING_INITIALIZER(struct cmd_config_burst, name, "burst"); 3264 static cmdline_parse_token_num_t cmd_config_burst_value = 3265 TOKEN_NUM_INITIALIZER(struct cmd_config_burst, value, RTE_UINT16); 3266 3267 static cmdline_parse_inst_t cmd_config_burst = { 3268 .f = cmd_config_burst_parsed, 3269 .data = NULL, 3270 .help_str = "port config all burst <value>", 3271 .tokens = { 3272 (void *)&cmd_config_burst_port, 3273 (void *)&cmd_config_burst_keyword, 3274 (void *)&cmd_config_burst_all, 3275 (void *)&cmd_config_burst_name, 3276 (void *)&cmd_config_burst_value, 3277 NULL, 3278 }, 3279 }; 3280 3281 /* *** configure rx/tx queues *** */ 3282 struct cmd_config_thresh { 3283 cmdline_fixed_string_t port; 3284 cmdline_fixed_string_t keyword; 3285 cmdline_fixed_string_t all; 3286 cmdline_fixed_string_t name; 3287 uint8_t value; 3288 }; 3289 3290 static void 3291 cmd_config_thresh_parsed(void *parsed_result, 3292 __rte_unused struct cmdline *cl, 3293 __rte_unused void *data) 3294 { 3295 struct cmd_config_thresh *res = parsed_result; 3296 3297 if (!all_ports_stopped()) { 3298 fprintf(stderr, "Please stop all ports first\n"); 3299 return; 3300 } 3301 3302 if (!strcmp(res->name, "txpt")) 3303 tx_pthresh = res->value; 3304 else if(!strcmp(res->name, "txht")) 3305 tx_hthresh = res->value; 3306 else if(!strcmp(res->name, "txwt")) 3307 tx_wthresh = res->value; 3308 else if(!strcmp(res->name, "rxpt")) 3309 rx_pthresh = res->value; 3310 else if(!strcmp(res->name, "rxht")) 3311 rx_hthresh = res->value; 3312 else if(!strcmp(res->name, "rxwt")) 3313 rx_wthresh = res->value; 3314 else { 3315 fprintf(stderr, "Unknown parameter\n"); 3316 return; 3317 } 3318 3319 init_port_config(); 3320 3321 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1); 3322 } 3323 3324 static cmdline_parse_token_string_t cmd_config_thresh_port = 3325 TOKEN_STRING_INITIALIZER(struct cmd_config_thresh, port, "port"); 3326 static cmdline_parse_token_string_t cmd_config_thresh_keyword = 3327 TOKEN_STRING_INITIALIZER(struct cmd_config_thresh, keyword, "config"); 3328 static cmdline_parse_token_string_t cmd_config_thresh_all = 3329 TOKEN_STRING_INITIALIZER(struct cmd_config_thresh, all, "all"); 3330 static cmdline_parse_token_string_t cmd_config_thresh_name = 3331 TOKEN_STRING_INITIALIZER(struct cmd_config_thresh, name, 3332 "txpt#txht#txwt#rxpt#rxht#rxwt"); 3333 static cmdline_parse_token_num_t cmd_config_thresh_value = 3334 TOKEN_NUM_INITIALIZER(struct cmd_config_thresh, value, RTE_UINT8); 3335 3336 static cmdline_parse_inst_t cmd_config_thresh = { 3337 .f = cmd_config_thresh_parsed, 3338 .data = NULL, 3339 .help_str = "port config all txpt|txht|txwt|rxpt|rxht|rxwt <value>", 3340 .tokens = { 3341 (void *)&cmd_config_thresh_port, 3342 (void *)&cmd_config_thresh_keyword, 3343 (void *)&cmd_config_thresh_all, 3344 (void *)&cmd_config_thresh_name, 3345 (void *)&cmd_config_thresh_value, 3346 NULL, 3347 }, 3348 }; 3349 3350 /* *** configure free/rs threshold *** */ 3351 struct cmd_config_threshold { 3352 cmdline_fixed_string_t port; 3353 cmdline_fixed_string_t keyword; 3354 cmdline_fixed_string_t all; 3355 cmdline_fixed_string_t name; 3356 uint16_t value; 3357 }; 3358 3359 static void 3360 cmd_config_threshold_parsed(void *parsed_result, 3361 __rte_unused struct cmdline *cl, 3362 __rte_unused void *data) 3363 { 3364 struct cmd_config_threshold *res = parsed_result; 3365 3366 if (!all_ports_stopped()) { 3367 fprintf(stderr, "Please stop all ports first\n"); 3368 return; 3369 } 3370 3371 if (!strcmp(res->name, "txfreet")) 3372 tx_free_thresh = res->value; 3373 else if (!strcmp(res->name, "txrst")) 3374 tx_rs_thresh = res->value; 3375 else if (!strcmp(res->name, "rxfreet")) 3376 rx_free_thresh = res->value; 3377 else { 3378 fprintf(stderr, "Unknown parameter\n"); 3379 return; 3380 } 3381 3382 init_port_config(); 3383 3384 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1); 3385 } 3386 3387 static cmdline_parse_token_string_t cmd_config_threshold_port = 3388 TOKEN_STRING_INITIALIZER(struct cmd_config_threshold, port, "port"); 3389 static cmdline_parse_token_string_t cmd_config_threshold_keyword = 3390 TOKEN_STRING_INITIALIZER(struct cmd_config_threshold, keyword, 3391 "config"); 3392 static cmdline_parse_token_string_t cmd_config_threshold_all = 3393 TOKEN_STRING_INITIALIZER(struct cmd_config_threshold, all, "all"); 3394 static cmdline_parse_token_string_t cmd_config_threshold_name = 3395 TOKEN_STRING_INITIALIZER(struct cmd_config_threshold, name, 3396 "txfreet#txrst#rxfreet"); 3397 static cmdline_parse_token_num_t cmd_config_threshold_value = 3398 TOKEN_NUM_INITIALIZER(struct cmd_config_threshold, value, RTE_UINT16); 3399 3400 static cmdline_parse_inst_t cmd_config_threshold = { 3401 .f = cmd_config_threshold_parsed, 3402 .data = NULL, 3403 .help_str = "port config all txfreet|txrst|rxfreet <value>", 3404 .tokens = { 3405 (void *)&cmd_config_threshold_port, 3406 (void *)&cmd_config_threshold_keyword, 3407 (void *)&cmd_config_threshold_all, 3408 (void *)&cmd_config_threshold_name, 3409 (void *)&cmd_config_threshold_value, 3410 NULL, 3411 }, 3412 }; 3413 3414 /* *** stop *** */ 3415 struct cmd_stop_result { 3416 cmdline_fixed_string_t stop; 3417 }; 3418 3419 static void cmd_stop_parsed(__rte_unused void *parsed_result, 3420 __rte_unused struct cmdline *cl, 3421 __rte_unused void *data) 3422 { 3423 stop_packet_forwarding(); 3424 } 3425 3426 static cmdline_parse_token_string_t cmd_stop_stop = 3427 TOKEN_STRING_INITIALIZER(struct cmd_stop_result, stop, "stop"); 3428 3429 static cmdline_parse_inst_t cmd_stop = { 3430 .f = cmd_stop_parsed, 3431 .data = NULL, 3432 .help_str = "stop: Stop packet forwarding", 3433 .tokens = { 3434 (void *)&cmd_stop_stop, 3435 NULL, 3436 }, 3437 }; 3438 3439 static unsigned int 3440 get_ptype(char *value) 3441 { 3442 uint32_t protocol; 3443 3444 if (!strcmp(value, "eth")) 3445 protocol = RTE_PTYPE_L2_ETHER; 3446 else if (!strcmp(value, "ipv4")) 3447 protocol = RTE_PTYPE_L2_ETHER | RTE_PTYPE_L3_IPV4_EXT_UNKNOWN; 3448 else if (!strcmp(value, "ipv6")) 3449 protocol = RTE_PTYPE_L2_ETHER | RTE_PTYPE_L3_IPV6_EXT_UNKNOWN; 3450 else if (!strcmp(value, "ipv4-tcp")) 3451 protocol = RTE_PTYPE_L2_ETHER | RTE_PTYPE_L3_IPV4_EXT_UNKNOWN | RTE_PTYPE_L4_TCP; 3452 else if (!strcmp(value, "ipv4-udp")) 3453 protocol = RTE_PTYPE_L2_ETHER | RTE_PTYPE_L3_IPV4_EXT_UNKNOWN | RTE_PTYPE_L4_UDP; 3454 else if (!strcmp(value, "ipv4-sctp")) 3455 protocol = RTE_PTYPE_L2_ETHER | RTE_PTYPE_L3_IPV4_EXT_UNKNOWN | RTE_PTYPE_L4_SCTP; 3456 else if (!strcmp(value, "ipv6-tcp")) 3457 protocol = RTE_PTYPE_L2_ETHER | RTE_PTYPE_L3_IPV6_EXT_UNKNOWN | RTE_PTYPE_L4_TCP; 3458 else if (!strcmp(value, "ipv6-udp")) 3459 protocol = RTE_PTYPE_L2_ETHER | RTE_PTYPE_L3_IPV6_EXT_UNKNOWN | RTE_PTYPE_L4_UDP; 3460 else if (!strcmp(value, "ipv6-sctp")) 3461 protocol = RTE_PTYPE_L2_ETHER | RTE_PTYPE_L3_IPV6_EXT_UNKNOWN | RTE_PTYPE_L4_SCTP; 3462 else if (!strcmp(value, "grenat")) 3463 protocol = RTE_PTYPE_TUNNEL_GRENAT; 3464 else if (!strcmp(value, "inner-eth")) 3465 protocol = RTE_PTYPE_TUNNEL_GRENAT | RTE_PTYPE_INNER_L2_ETHER; 3466 else if (!strcmp(value, "inner-ipv4")) 3467 protocol = RTE_PTYPE_TUNNEL_GRENAT | RTE_PTYPE_INNER_L2_ETHER | 3468 RTE_PTYPE_INNER_L3_IPV4_EXT_UNKNOWN; 3469 else if (!strcmp(value, "inner-ipv6")) 3470 protocol = RTE_PTYPE_TUNNEL_GRENAT | RTE_PTYPE_INNER_L2_ETHER | 3471 RTE_PTYPE_INNER_L3_IPV6_EXT_UNKNOWN; 3472 else if (!strcmp(value, "inner-ipv4-tcp")) 3473 protocol = RTE_PTYPE_TUNNEL_GRENAT | RTE_PTYPE_INNER_L2_ETHER | 3474 RTE_PTYPE_INNER_L3_IPV4_EXT_UNKNOWN | RTE_PTYPE_INNER_L4_TCP; 3475 else if (!strcmp(value, "inner-ipv4-udp")) 3476 protocol = RTE_PTYPE_TUNNEL_GRENAT | RTE_PTYPE_INNER_L2_ETHER | 3477 RTE_PTYPE_INNER_L3_IPV4_EXT_UNKNOWN | RTE_PTYPE_INNER_L4_UDP; 3478 else if (!strcmp(value, "inner-ipv4-sctp")) 3479 protocol = RTE_PTYPE_TUNNEL_GRENAT | RTE_PTYPE_INNER_L2_ETHER | 3480 RTE_PTYPE_INNER_L3_IPV4_EXT_UNKNOWN | RTE_PTYPE_INNER_L4_SCTP; 3481 else if (!strcmp(value, "inner-ipv6-tcp")) 3482 protocol = RTE_PTYPE_TUNNEL_GRENAT | RTE_PTYPE_INNER_L2_ETHER | 3483 RTE_PTYPE_INNER_L3_IPV6_EXT_UNKNOWN | RTE_PTYPE_INNER_L4_TCP; 3484 else if (!strcmp(value, "inner-ipv6-udp")) 3485 protocol = RTE_PTYPE_TUNNEL_GRENAT | RTE_PTYPE_INNER_L2_ETHER | 3486 RTE_PTYPE_INNER_L3_IPV6_EXT_UNKNOWN | RTE_PTYPE_INNER_L4_UDP; 3487 else if (!strcmp(value, "inner-ipv6-sctp")) 3488 protocol = RTE_PTYPE_TUNNEL_GRENAT | RTE_PTYPE_INNER_L2_ETHER | 3489 RTE_PTYPE_INNER_L3_IPV6_EXT_UNKNOWN | RTE_PTYPE_INNER_L4_SCTP; 3490 else { 3491 fprintf(stderr, "Unsupported protocol: %s\n", value); 3492 protocol = RTE_PTYPE_UNKNOWN; 3493 } 3494 3495 return protocol; 3496 } 3497 3498 /* *** SET RXHDRSLIST *** */ 3499 3500 unsigned int 3501 parse_hdrs_list(const char *str, const char *item_name, unsigned int max_items, 3502 unsigned int *parsed_items) 3503 { 3504 unsigned int nb_item; 3505 char *cur; 3506 char *tmp; 3507 3508 nb_item = 0; 3509 char *str2 = strdup(str); 3510 cur = strtok_r(str2, ",", &tmp); 3511 while (cur != NULL) { 3512 parsed_items[nb_item] = get_ptype(cur); 3513 cur = strtok_r(NULL, ",", &tmp); 3514 nb_item++; 3515 } 3516 if (nb_item > max_items) 3517 fprintf(stderr, "Number of %s = %u > %u (maximum items)\n", 3518 item_name, nb_item + 1, max_items); 3519 free(str2); 3520 return nb_item; 3521 } 3522 3523 /* *** SET CORELIST and PORTLIST CONFIGURATION *** */ 3524 3525 unsigned int 3526 parse_item_list(const char *str, const char *item_name, unsigned int max_items, 3527 unsigned int *parsed_items, int check_unique_values) 3528 { 3529 unsigned int nb_item; 3530 unsigned int value; 3531 unsigned int i; 3532 unsigned int j; 3533 int value_ok; 3534 char c; 3535 3536 /* 3537 * First parse all items in the list and store their value. 3538 */ 3539 value = 0; 3540 nb_item = 0; 3541 value_ok = 0; 3542 for (i = 0; i < strnlen(str, STR_TOKEN_SIZE); i++) { 3543 c = str[i]; 3544 if ((c >= '0') && (c <= '9')) { 3545 value = (unsigned int) (value * 10 + (c - '0')); 3546 value_ok = 1; 3547 continue; 3548 } 3549 if (c != ',') { 3550 fprintf(stderr, "character %c is not a decimal digit\n", c); 3551 return 0; 3552 } 3553 if (! value_ok) { 3554 fprintf(stderr, "No valid value before comma\n"); 3555 return 0; 3556 } 3557 if (nb_item < max_items) { 3558 parsed_items[nb_item] = value; 3559 value_ok = 0; 3560 value = 0; 3561 } 3562 nb_item++; 3563 } 3564 if (nb_item >= max_items) { 3565 fprintf(stderr, "Number of %s = %u > %u (maximum items)\n", 3566 item_name, nb_item + 1, max_items); 3567 return 0; 3568 } 3569 parsed_items[nb_item++] = value; 3570 if (! check_unique_values) 3571 return nb_item; 3572 3573 /* 3574 * Then, check that all values in the list are different. 3575 * No optimization here... 3576 */ 3577 for (i = 0; i < nb_item; i++) { 3578 for (j = i + 1; j < nb_item; j++) { 3579 if (parsed_items[j] == parsed_items[i]) { 3580 fprintf(stderr, 3581 "duplicated %s %u at index %u and %u\n", 3582 item_name, parsed_items[i], i, j); 3583 return 0; 3584 } 3585 } 3586 } 3587 return nb_item; 3588 } 3589 3590 struct cmd_set_list_result { 3591 cmdline_fixed_string_t cmd_keyword; 3592 cmdline_fixed_string_t list_name; 3593 cmdline_fixed_string_t list_of_items; 3594 }; 3595 3596 static void cmd_set_list_parsed(void *parsed_result, 3597 __rte_unused struct cmdline *cl, 3598 __rte_unused void *data) 3599 { 3600 struct cmd_set_list_result *res; 3601 union { 3602 unsigned int lcorelist[RTE_MAX_LCORE]; 3603 unsigned int portlist[RTE_MAX_ETHPORTS]; 3604 } parsed_items; 3605 unsigned int nb_item; 3606 3607 if (test_done == 0) { 3608 fprintf(stderr, "Please stop forwarding first\n"); 3609 return; 3610 } 3611 3612 res = parsed_result; 3613 if (!strcmp(res->list_name, "corelist")) { 3614 nb_item = parse_item_list(res->list_of_items, "core", 3615 RTE_MAX_LCORE, 3616 parsed_items.lcorelist, 1); 3617 if (nb_item > 0) { 3618 set_fwd_lcores_list(parsed_items.lcorelist, nb_item); 3619 fwd_config_setup(); 3620 } 3621 return; 3622 } 3623 if (!strcmp(res->list_name, "portlist")) { 3624 nb_item = parse_item_list(res->list_of_items, "port", 3625 RTE_MAX_ETHPORTS, 3626 parsed_items.portlist, 1); 3627 if (nb_item > 0) { 3628 set_fwd_ports_list(parsed_items.portlist, nb_item); 3629 fwd_config_setup(); 3630 } 3631 } 3632 } 3633 3634 static cmdline_parse_token_string_t cmd_set_list_keyword = 3635 TOKEN_STRING_INITIALIZER(struct cmd_set_list_result, cmd_keyword, 3636 "set"); 3637 static cmdline_parse_token_string_t cmd_set_list_name = 3638 TOKEN_STRING_INITIALIZER(struct cmd_set_list_result, list_name, 3639 "corelist#portlist"); 3640 static cmdline_parse_token_string_t cmd_set_list_of_items = 3641 TOKEN_STRING_INITIALIZER(struct cmd_set_list_result, list_of_items, 3642 NULL); 3643 3644 static cmdline_parse_inst_t cmd_set_fwd_list = { 3645 .f = cmd_set_list_parsed, 3646 .data = NULL, 3647 .help_str = "set corelist|portlist <list0[,list1]*>", 3648 .tokens = { 3649 (void *)&cmd_set_list_keyword, 3650 (void *)&cmd_set_list_name, 3651 (void *)&cmd_set_list_of_items, 3652 NULL, 3653 }, 3654 }; 3655 3656 /* *** SET COREMASK and PORTMASK CONFIGURATION *** */ 3657 3658 struct cmd_setmask_result { 3659 cmdline_fixed_string_t set; 3660 cmdline_fixed_string_t mask; 3661 uint64_t hexavalue; 3662 }; 3663 3664 static void cmd_set_mask_parsed(void *parsed_result, 3665 __rte_unused struct cmdline *cl, 3666 __rte_unused void *data) 3667 { 3668 struct cmd_setmask_result *res = parsed_result; 3669 3670 if (test_done == 0) { 3671 fprintf(stderr, "Please stop forwarding first\n"); 3672 return; 3673 } 3674 if (!strcmp(res->mask, "coremask")) { 3675 set_fwd_lcores_mask(res->hexavalue); 3676 fwd_config_setup(); 3677 } else if (!strcmp(res->mask, "portmask")) { 3678 set_fwd_ports_mask(res->hexavalue); 3679 fwd_config_setup(); 3680 } 3681 } 3682 3683 static cmdline_parse_token_string_t cmd_setmask_set = 3684 TOKEN_STRING_INITIALIZER(struct cmd_setmask_result, set, "set"); 3685 static cmdline_parse_token_string_t cmd_setmask_mask = 3686 TOKEN_STRING_INITIALIZER(struct cmd_setmask_result, mask, 3687 "coremask#portmask"); 3688 static cmdline_parse_token_num_t cmd_setmask_value = 3689 TOKEN_NUM_INITIALIZER(struct cmd_setmask_result, hexavalue, RTE_UINT64); 3690 3691 static cmdline_parse_inst_t cmd_set_fwd_mask = { 3692 .f = cmd_set_mask_parsed, 3693 .data = NULL, 3694 .help_str = "set coremask|portmask <hexadecimal value>", 3695 .tokens = { 3696 (void *)&cmd_setmask_set, 3697 (void *)&cmd_setmask_mask, 3698 (void *)&cmd_setmask_value, 3699 NULL, 3700 }, 3701 }; 3702 3703 /* 3704 * SET NBPORT, NBCORE, PACKET BURST, and VERBOSE LEVEL CONFIGURATION 3705 */ 3706 struct cmd_set_result { 3707 cmdline_fixed_string_t set; 3708 cmdline_fixed_string_t what; 3709 uint16_t value; 3710 }; 3711 3712 static void cmd_set_parsed(void *parsed_result, 3713 __rte_unused struct cmdline *cl, 3714 __rte_unused void *data) 3715 { 3716 struct cmd_set_result *res = parsed_result; 3717 if (!strcmp(res->what, "nbport")) { 3718 set_fwd_ports_number(res->value); 3719 fwd_config_setup(); 3720 } else if (!strcmp(res->what, "nbcore")) { 3721 set_fwd_lcores_number(res->value); 3722 fwd_config_setup(); 3723 } else if (!strcmp(res->what, "burst")) 3724 set_nb_pkt_per_burst(res->value); 3725 else if (!strcmp(res->what, "verbose")) 3726 set_verbose_level(res->value); 3727 } 3728 3729 static cmdline_parse_token_string_t cmd_set_set = 3730 TOKEN_STRING_INITIALIZER(struct cmd_set_result, set, "set"); 3731 static cmdline_parse_token_string_t cmd_set_what = 3732 TOKEN_STRING_INITIALIZER(struct cmd_set_result, what, 3733 "nbport#nbcore#burst#verbose"); 3734 static cmdline_parse_token_num_t cmd_set_value = 3735 TOKEN_NUM_INITIALIZER(struct cmd_set_result, value, RTE_UINT16); 3736 3737 static cmdline_parse_inst_t cmd_set_numbers = { 3738 .f = cmd_set_parsed, 3739 .data = NULL, 3740 .help_str = "set nbport|nbcore|burst|verbose <value>", 3741 .tokens = { 3742 (void *)&cmd_set_set, 3743 (void *)&cmd_set_what, 3744 (void *)&cmd_set_value, 3745 NULL, 3746 }, 3747 }; 3748 3749 /* *** SET LOG LEVEL CONFIGURATION *** */ 3750 3751 struct cmd_set_log_result { 3752 cmdline_fixed_string_t set; 3753 cmdline_fixed_string_t log; 3754 cmdline_fixed_string_t type; 3755 uint32_t level; 3756 }; 3757 3758 static void 3759 cmd_set_log_parsed(void *parsed_result, 3760 __rte_unused struct cmdline *cl, 3761 __rte_unused void *data) 3762 { 3763 struct cmd_set_log_result *res; 3764 int ret; 3765 3766 res = parsed_result; 3767 if (!strcmp(res->type, "global")) 3768 rte_log_set_global_level(res->level); 3769 else { 3770 ret = rte_log_set_level_regexp(res->type, res->level); 3771 if (ret < 0) 3772 fprintf(stderr, "Unable to set log level\n"); 3773 } 3774 } 3775 3776 static cmdline_parse_token_string_t cmd_set_log_set = 3777 TOKEN_STRING_INITIALIZER(struct cmd_set_log_result, set, "set"); 3778 static cmdline_parse_token_string_t cmd_set_log_log = 3779 TOKEN_STRING_INITIALIZER(struct cmd_set_log_result, log, "log"); 3780 static cmdline_parse_token_string_t cmd_set_log_type = 3781 TOKEN_STRING_INITIALIZER(struct cmd_set_log_result, type, NULL); 3782 static cmdline_parse_token_num_t cmd_set_log_level = 3783 TOKEN_NUM_INITIALIZER(struct cmd_set_log_result, level, RTE_UINT32); 3784 3785 static cmdline_parse_inst_t cmd_set_log = { 3786 .f = cmd_set_log_parsed, 3787 .data = NULL, 3788 .help_str = "set log global|<type> <level>", 3789 .tokens = { 3790 (void *)&cmd_set_log_set, 3791 (void *)&cmd_set_log_log, 3792 (void *)&cmd_set_log_type, 3793 (void *)&cmd_set_log_level, 3794 NULL, 3795 }, 3796 }; 3797 3798 /* *** SET SEGMENT OFFSETS OF RX PACKETS SPLIT *** */ 3799 3800 struct cmd_set_rxoffs_result { 3801 cmdline_fixed_string_t cmd_keyword; 3802 cmdline_fixed_string_t rxoffs; 3803 cmdline_fixed_string_t seg_offsets; 3804 }; 3805 3806 static void 3807 cmd_set_rxoffs_parsed(void *parsed_result, 3808 __rte_unused struct cmdline *cl, 3809 __rte_unused void *data) 3810 { 3811 struct cmd_set_rxoffs_result *res; 3812 unsigned int seg_offsets[MAX_SEGS_BUFFER_SPLIT]; 3813 unsigned int nb_segs; 3814 3815 res = parsed_result; 3816 nb_segs = parse_item_list(res->seg_offsets, "segment offsets", 3817 MAX_SEGS_BUFFER_SPLIT, seg_offsets, 0); 3818 if (nb_segs > 0) 3819 set_rx_pkt_offsets(seg_offsets, nb_segs); 3820 cmd_reconfig_device_queue(RTE_PORT_ALL, 0, 1); 3821 } 3822 3823 static cmdline_parse_token_string_t cmd_set_rxoffs_keyword = 3824 TOKEN_STRING_INITIALIZER(struct cmd_set_rxoffs_result, 3825 cmd_keyword, "set"); 3826 static cmdline_parse_token_string_t cmd_set_rxoffs_name = 3827 TOKEN_STRING_INITIALIZER(struct cmd_set_rxoffs_result, 3828 rxoffs, "rxoffs"); 3829 static cmdline_parse_token_string_t cmd_set_rxoffs_offsets = 3830 TOKEN_STRING_INITIALIZER(struct cmd_set_rxoffs_result, 3831 seg_offsets, NULL); 3832 3833 static cmdline_parse_inst_t cmd_set_rxoffs = { 3834 .f = cmd_set_rxoffs_parsed, 3835 .data = NULL, 3836 .help_str = "set rxoffs <len0[,len1]*>", 3837 .tokens = { 3838 (void *)&cmd_set_rxoffs_keyword, 3839 (void *)&cmd_set_rxoffs_name, 3840 (void *)&cmd_set_rxoffs_offsets, 3841 NULL, 3842 }, 3843 }; 3844 3845 /* *** SET SEGMENT LENGTHS OF RX PACKETS SPLIT *** */ 3846 3847 struct cmd_set_rxpkts_result { 3848 cmdline_fixed_string_t cmd_keyword; 3849 cmdline_fixed_string_t rxpkts; 3850 cmdline_fixed_string_t seg_lengths; 3851 }; 3852 3853 static void 3854 cmd_set_rxpkts_parsed(void *parsed_result, 3855 __rte_unused struct cmdline *cl, 3856 __rte_unused void *data) 3857 { 3858 struct cmd_set_rxpkts_result *res; 3859 unsigned int seg_lengths[MAX_SEGS_BUFFER_SPLIT]; 3860 unsigned int nb_segs; 3861 3862 res = parsed_result; 3863 nb_segs = parse_item_list(res->seg_lengths, "segment lengths", 3864 MAX_SEGS_BUFFER_SPLIT, seg_lengths, 0); 3865 if (nb_segs > 0) 3866 set_rx_pkt_segments(seg_lengths, nb_segs); 3867 cmd_reconfig_device_queue(RTE_PORT_ALL, 0, 1); 3868 } 3869 3870 static cmdline_parse_token_string_t cmd_set_rxpkts_keyword = 3871 TOKEN_STRING_INITIALIZER(struct cmd_set_rxpkts_result, 3872 cmd_keyword, "set"); 3873 static cmdline_parse_token_string_t cmd_set_rxpkts_name = 3874 TOKEN_STRING_INITIALIZER(struct cmd_set_rxpkts_result, 3875 rxpkts, "rxpkts"); 3876 static cmdline_parse_token_string_t cmd_set_rxpkts_lengths = 3877 TOKEN_STRING_INITIALIZER(struct cmd_set_rxpkts_result, 3878 seg_lengths, NULL); 3879 3880 static cmdline_parse_inst_t cmd_set_rxpkts = { 3881 .f = cmd_set_rxpkts_parsed, 3882 .data = NULL, 3883 .help_str = "set rxpkts <len0[,len1]*>", 3884 .tokens = { 3885 (void *)&cmd_set_rxpkts_keyword, 3886 (void *)&cmd_set_rxpkts_name, 3887 (void *)&cmd_set_rxpkts_lengths, 3888 NULL, 3889 }, 3890 }; 3891 3892 /* *** SET SEGMENT HEADERS OF RX PACKETS SPLIT *** */ 3893 struct cmd_set_rxhdrs_result { 3894 cmdline_fixed_string_t set; 3895 cmdline_fixed_string_t rxhdrs; 3896 cmdline_fixed_string_t values; 3897 }; 3898 3899 static void 3900 cmd_set_rxhdrs_parsed(void *parsed_result, 3901 __rte_unused struct cmdline *cl, 3902 __rte_unused void *data) 3903 { 3904 struct cmd_set_rxhdrs_result *res; 3905 unsigned int seg_hdrs[MAX_SEGS_BUFFER_SPLIT]; 3906 unsigned int nb_segs; 3907 3908 res = parsed_result; 3909 nb_segs = parse_hdrs_list(res->values, "segment hdrs", 3910 MAX_SEGS_BUFFER_SPLIT, seg_hdrs); 3911 if (nb_segs > 0) 3912 set_rx_pkt_hdrs(seg_hdrs, nb_segs); 3913 cmd_reconfig_device_queue(RTE_PORT_ALL, 0, 1); 3914 } 3915 3916 static cmdline_parse_token_string_t cmd_set_rxhdrs_set = 3917 TOKEN_STRING_INITIALIZER(struct cmd_set_rxhdrs_result, 3918 set, "set"); 3919 static cmdline_parse_token_string_t cmd_set_rxhdrs_rxhdrs = 3920 TOKEN_STRING_INITIALIZER(struct cmd_set_rxhdrs_result, 3921 rxhdrs, "rxhdrs"); 3922 static cmdline_parse_token_string_t cmd_set_rxhdrs_values = 3923 TOKEN_STRING_INITIALIZER(struct cmd_set_rxhdrs_result, 3924 values, NULL); 3925 3926 static cmdline_parse_inst_t cmd_set_rxhdrs = { 3927 .f = cmd_set_rxhdrs_parsed, 3928 .data = NULL, 3929 .help_str = "set rxhdrs <eth[,ipv4]*>", 3930 .tokens = { 3931 (void *)&cmd_set_rxhdrs_set, 3932 (void *)&cmd_set_rxhdrs_rxhdrs, 3933 (void *)&cmd_set_rxhdrs_values, 3934 NULL, 3935 }, 3936 }; 3937 3938 /* *** SET SEGMENT LENGTHS OF TXONLY PACKETS *** */ 3939 3940 struct cmd_set_txpkts_result { 3941 cmdline_fixed_string_t cmd_keyword; 3942 cmdline_fixed_string_t txpkts; 3943 cmdline_fixed_string_t seg_lengths; 3944 }; 3945 3946 static void 3947 cmd_set_txpkts_parsed(void *parsed_result, 3948 __rte_unused struct cmdline *cl, 3949 __rte_unused void *data) 3950 { 3951 struct cmd_set_txpkts_result *res; 3952 unsigned seg_lengths[RTE_MAX_SEGS_PER_PKT]; 3953 unsigned int nb_segs; 3954 3955 res = parsed_result; 3956 nb_segs = parse_item_list(res->seg_lengths, "segment lengths", 3957 RTE_MAX_SEGS_PER_PKT, seg_lengths, 0); 3958 if (nb_segs > 0) 3959 set_tx_pkt_segments(seg_lengths, nb_segs); 3960 } 3961 3962 static cmdline_parse_token_string_t cmd_set_txpkts_keyword = 3963 TOKEN_STRING_INITIALIZER(struct cmd_set_txpkts_result, 3964 cmd_keyword, "set"); 3965 static cmdline_parse_token_string_t cmd_set_txpkts_name = 3966 TOKEN_STRING_INITIALIZER(struct cmd_set_txpkts_result, 3967 txpkts, "txpkts"); 3968 static cmdline_parse_token_string_t cmd_set_txpkts_lengths = 3969 TOKEN_STRING_INITIALIZER(struct cmd_set_txpkts_result, 3970 seg_lengths, NULL); 3971 3972 static cmdline_parse_inst_t cmd_set_txpkts = { 3973 .f = cmd_set_txpkts_parsed, 3974 .data = NULL, 3975 .help_str = "set txpkts <len0[,len1]*>", 3976 .tokens = { 3977 (void *)&cmd_set_txpkts_keyword, 3978 (void *)&cmd_set_txpkts_name, 3979 (void *)&cmd_set_txpkts_lengths, 3980 NULL, 3981 }, 3982 }; 3983 3984 /* *** SET COPY AND SPLIT POLICY ON TX PACKETS *** */ 3985 3986 struct cmd_set_txsplit_result { 3987 cmdline_fixed_string_t cmd_keyword; 3988 cmdline_fixed_string_t txsplit; 3989 cmdline_fixed_string_t mode; 3990 }; 3991 3992 static void 3993 cmd_set_txsplit_parsed(void *parsed_result, 3994 __rte_unused struct cmdline *cl, 3995 __rte_unused void *data) 3996 { 3997 struct cmd_set_txsplit_result *res; 3998 3999 res = parsed_result; 4000 set_tx_pkt_split(res->mode); 4001 } 4002 4003 static cmdline_parse_token_string_t cmd_set_txsplit_keyword = 4004 TOKEN_STRING_INITIALIZER(struct cmd_set_txsplit_result, 4005 cmd_keyword, "set"); 4006 static cmdline_parse_token_string_t cmd_set_txsplit_name = 4007 TOKEN_STRING_INITIALIZER(struct cmd_set_txsplit_result, 4008 txsplit, "txsplit"); 4009 static cmdline_parse_token_string_t cmd_set_txsplit_mode = 4010 TOKEN_STRING_INITIALIZER(struct cmd_set_txsplit_result, 4011 mode, NULL); 4012 4013 static cmdline_parse_inst_t cmd_set_txsplit = { 4014 .f = cmd_set_txsplit_parsed, 4015 .data = NULL, 4016 .help_str = "set txsplit on|off|rand", 4017 .tokens = { 4018 (void *)&cmd_set_txsplit_keyword, 4019 (void *)&cmd_set_txsplit_name, 4020 (void *)&cmd_set_txsplit_mode, 4021 NULL, 4022 }, 4023 }; 4024 4025 /* *** SET TIMES FOR TXONLY PACKETS SCHEDULING ON TIMESTAMPS *** */ 4026 4027 struct cmd_set_txtimes_result { 4028 cmdline_fixed_string_t cmd_keyword; 4029 cmdline_fixed_string_t txtimes; 4030 cmdline_fixed_string_t tx_times; 4031 }; 4032 4033 static void 4034 cmd_set_txtimes_parsed(void *parsed_result, 4035 __rte_unused struct cmdline *cl, 4036 __rte_unused void *data) 4037 { 4038 struct cmd_set_txtimes_result *res; 4039 unsigned int tx_times[2] = {0, 0}; 4040 unsigned int n_times; 4041 4042 res = parsed_result; 4043 n_times = parse_item_list(res->tx_times, "tx times", 4044 2, tx_times, 0); 4045 if (n_times == 2) 4046 set_tx_pkt_times(tx_times); 4047 } 4048 4049 static cmdline_parse_token_string_t cmd_set_txtimes_keyword = 4050 TOKEN_STRING_INITIALIZER(struct cmd_set_txtimes_result, 4051 cmd_keyword, "set"); 4052 static cmdline_parse_token_string_t cmd_set_txtimes_name = 4053 TOKEN_STRING_INITIALIZER(struct cmd_set_txtimes_result, 4054 txtimes, "txtimes"); 4055 static cmdline_parse_token_string_t cmd_set_txtimes_value = 4056 TOKEN_STRING_INITIALIZER(struct cmd_set_txtimes_result, 4057 tx_times, NULL); 4058 4059 static cmdline_parse_inst_t cmd_set_txtimes = { 4060 .f = cmd_set_txtimes_parsed, 4061 .data = NULL, 4062 .help_str = "set txtimes <inter_burst>,<intra_burst>", 4063 .tokens = { 4064 (void *)&cmd_set_txtimes_keyword, 4065 (void *)&cmd_set_txtimes_name, 4066 (void *)&cmd_set_txtimes_value, 4067 NULL, 4068 }, 4069 }; 4070 4071 /* *** ADD/REMOVE ALL VLAN IDENTIFIERS TO/FROM A PORT VLAN RX FILTER *** */ 4072 struct cmd_rx_vlan_filter_all_result { 4073 cmdline_fixed_string_t rx_vlan; 4074 cmdline_fixed_string_t what; 4075 cmdline_fixed_string_t all; 4076 portid_t port_id; 4077 }; 4078 4079 static void 4080 cmd_rx_vlan_filter_all_parsed(void *parsed_result, 4081 __rte_unused struct cmdline *cl, 4082 __rte_unused void *data) 4083 { 4084 struct cmd_rx_vlan_filter_all_result *res = parsed_result; 4085 4086 if (!strcmp(res->what, "add")) 4087 rx_vlan_all_filter_set(res->port_id, 1); 4088 else 4089 rx_vlan_all_filter_set(res->port_id, 0); 4090 } 4091 4092 static cmdline_parse_token_string_t cmd_rx_vlan_filter_all_rx_vlan = 4093 TOKEN_STRING_INITIALIZER(struct cmd_rx_vlan_filter_all_result, 4094 rx_vlan, "rx_vlan"); 4095 static cmdline_parse_token_string_t cmd_rx_vlan_filter_all_what = 4096 TOKEN_STRING_INITIALIZER(struct cmd_rx_vlan_filter_all_result, 4097 what, "add#rm"); 4098 static cmdline_parse_token_string_t cmd_rx_vlan_filter_all_all = 4099 TOKEN_STRING_INITIALIZER(struct cmd_rx_vlan_filter_all_result, 4100 all, "all"); 4101 static cmdline_parse_token_num_t cmd_rx_vlan_filter_all_portid = 4102 TOKEN_NUM_INITIALIZER(struct cmd_rx_vlan_filter_all_result, 4103 port_id, RTE_UINT16); 4104 4105 static cmdline_parse_inst_t cmd_rx_vlan_filter_all = { 4106 .f = cmd_rx_vlan_filter_all_parsed, 4107 .data = NULL, 4108 .help_str = "rx_vlan add|rm all <port_id>: " 4109 "Add/Remove all identifiers to/from the set of VLAN " 4110 "identifiers filtered by a port", 4111 .tokens = { 4112 (void *)&cmd_rx_vlan_filter_all_rx_vlan, 4113 (void *)&cmd_rx_vlan_filter_all_what, 4114 (void *)&cmd_rx_vlan_filter_all_all, 4115 (void *)&cmd_rx_vlan_filter_all_portid, 4116 NULL, 4117 }, 4118 }; 4119 4120 /* *** VLAN OFFLOAD SET ON A PORT *** */ 4121 struct cmd_vlan_offload_result { 4122 cmdline_fixed_string_t vlan; 4123 cmdline_fixed_string_t set; 4124 cmdline_fixed_string_t vlan_type; 4125 cmdline_fixed_string_t what; 4126 cmdline_fixed_string_t on; 4127 cmdline_fixed_string_t port_id; 4128 }; 4129 4130 static void 4131 cmd_vlan_offload_parsed(void *parsed_result, 4132 __rte_unused struct cmdline *cl, 4133 __rte_unused void *data) 4134 { 4135 int on; 4136 struct cmd_vlan_offload_result *res = parsed_result; 4137 char *str; 4138 int i, len = 0; 4139 portid_t port_id = 0; 4140 unsigned int tmp; 4141 4142 str = res->port_id; 4143 len = strnlen(str, STR_TOKEN_SIZE); 4144 i = 0; 4145 /* Get port_id first */ 4146 while(i < len){ 4147 if(str[i] == ',') 4148 break; 4149 4150 i++; 4151 } 4152 str[i]='\0'; 4153 tmp = strtoul(str, NULL, 0); 4154 /* If port_id greater that what portid_t can represent, return */ 4155 if(tmp >= RTE_MAX_ETHPORTS) 4156 return; 4157 port_id = (portid_t)tmp; 4158 4159 if (!strcmp(res->on, "on")) 4160 on = 1; 4161 else 4162 on = 0; 4163 4164 if (!strcmp(res->what, "strip")) 4165 rx_vlan_strip_set(port_id, on); 4166 else if(!strcmp(res->what, "stripq")){ 4167 uint16_t queue_id = 0; 4168 4169 /* No queue_id, return */ 4170 if(i + 1 >= len) { 4171 fprintf(stderr, "must specify (port,queue_id)\n"); 4172 return; 4173 } 4174 tmp = strtoul(str + i + 1, NULL, 0); 4175 /* If queue_id greater that what 16-bits can represent, return */ 4176 if(tmp > 0xffff) 4177 return; 4178 4179 queue_id = (uint16_t)tmp; 4180 rx_vlan_strip_set_on_queue(port_id, queue_id, on); 4181 } 4182 else if (!strcmp(res->what, "filter")) 4183 rx_vlan_filter_set(port_id, on); 4184 else if (!strcmp(res->what, "qinq_strip")) 4185 rx_vlan_qinq_strip_set(port_id, on); 4186 else 4187 vlan_extend_set(port_id, on); 4188 4189 return; 4190 } 4191 4192 static cmdline_parse_token_string_t cmd_vlan_offload_vlan = 4193 TOKEN_STRING_INITIALIZER(struct cmd_vlan_offload_result, 4194 vlan, "vlan"); 4195 static cmdline_parse_token_string_t cmd_vlan_offload_set = 4196 TOKEN_STRING_INITIALIZER(struct cmd_vlan_offload_result, 4197 set, "set"); 4198 static cmdline_parse_token_string_t cmd_vlan_offload_what = 4199 TOKEN_STRING_INITIALIZER(struct cmd_vlan_offload_result, 4200 what, "strip#filter#qinq_strip#extend#stripq"); 4201 static cmdline_parse_token_string_t cmd_vlan_offload_on = 4202 TOKEN_STRING_INITIALIZER(struct cmd_vlan_offload_result, 4203 on, "on#off"); 4204 static cmdline_parse_token_string_t cmd_vlan_offload_portid = 4205 TOKEN_STRING_INITIALIZER(struct cmd_vlan_offload_result, 4206 port_id, NULL); 4207 4208 static cmdline_parse_inst_t cmd_vlan_offload = { 4209 .f = cmd_vlan_offload_parsed, 4210 .data = NULL, 4211 .help_str = "vlan set strip|filter|qinq_strip|extend|stripq on|off " 4212 "<port_id[,queue_id]>: " 4213 "Strip/Filter/QinQ for rx side Extend for both rx/tx sides", 4214 .tokens = { 4215 (void *)&cmd_vlan_offload_vlan, 4216 (void *)&cmd_vlan_offload_set, 4217 (void *)&cmd_vlan_offload_what, 4218 (void *)&cmd_vlan_offload_on, 4219 (void *)&cmd_vlan_offload_portid, 4220 NULL, 4221 }, 4222 }; 4223 4224 /* *** VLAN TPID SET ON A PORT *** */ 4225 struct cmd_vlan_tpid_result { 4226 cmdline_fixed_string_t vlan; 4227 cmdline_fixed_string_t set; 4228 cmdline_fixed_string_t vlan_type; 4229 cmdline_fixed_string_t what; 4230 uint16_t tp_id; 4231 portid_t port_id; 4232 }; 4233 4234 static void 4235 cmd_vlan_tpid_parsed(void *parsed_result, 4236 __rte_unused struct cmdline *cl, 4237 __rte_unused void *data) 4238 { 4239 struct cmd_vlan_tpid_result *res = parsed_result; 4240 enum rte_vlan_type vlan_type; 4241 4242 if (!strcmp(res->vlan_type, "inner")) 4243 vlan_type = RTE_ETH_VLAN_TYPE_INNER; 4244 else if (!strcmp(res->vlan_type, "outer")) 4245 vlan_type = RTE_ETH_VLAN_TYPE_OUTER; 4246 else { 4247 fprintf(stderr, "Unknown vlan type\n"); 4248 return; 4249 } 4250 vlan_tpid_set(res->port_id, vlan_type, res->tp_id); 4251 } 4252 4253 static cmdline_parse_token_string_t cmd_vlan_tpid_vlan = 4254 TOKEN_STRING_INITIALIZER(struct cmd_vlan_tpid_result, 4255 vlan, "vlan"); 4256 static cmdline_parse_token_string_t cmd_vlan_tpid_set = 4257 TOKEN_STRING_INITIALIZER(struct cmd_vlan_tpid_result, 4258 set, "set"); 4259 static cmdline_parse_token_string_t cmd_vlan_type = 4260 TOKEN_STRING_INITIALIZER(struct cmd_vlan_tpid_result, 4261 vlan_type, "inner#outer"); 4262 static cmdline_parse_token_string_t cmd_vlan_tpid_what = 4263 TOKEN_STRING_INITIALIZER(struct cmd_vlan_tpid_result, 4264 what, "tpid"); 4265 static cmdline_parse_token_num_t cmd_vlan_tpid_tpid = 4266 TOKEN_NUM_INITIALIZER(struct cmd_vlan_tpid_result, 4267 tp_id, RTE_UINT16); 4268 static cmdline_parse_token_num_t cmd_vlan_tpid_portid = 4269 TOKEN_NUM_INITIALIZER(struct cmd_vlan_tpid_result, 4270 port_id, RTE_UINT16); 4271 4272 static cmdline_parse_inst_t cmd_vlan_tpid = { 4273 .f = cmd_vlan_tpid_parsed, 4274 .data = NULL, 4275 .help_str = "vlan set inner|outer tpid <tp_id> <port_id>: " 4276 "Set the VLAN Ether type", 4277 .tokens = { 4278 (void *)&cmd_vlan_tpid_vlan, 4279 (void *)&cmd_vlan_tpid_set, 4280 (void *)&cmd_vlan_type, 4281 (void *)&cmd_vlan_tpid_what, 4282 (void *)&cmd_vlan_tpid_tpid, 4283 (void *)&cmd_vlan_tpid_portid, 4284 NULL, 4285 }, 4286 }; 4287 4288 /* *** ADD/REMOVE A VLAN IDENTIFIER TO/FROM A PORT VLAN RX FILTER *** */ 4289 struct cmd_rx_vlan_filter_result { 4290 cmdline_fixed_string_t rx_vlan; 4291 cmdline_fixed_string_t what; 4292 uint16_t vlan_id; 4293 portid_t port_id; 4294 }; 4295 4296 static void 4297 cmd_rx_vlan_filter_parsed(void *parsed_result, 4298 __rte_unused struct cmdline *cl, 4299 __rte_unused void *data) 4300 { 4301 struct cmd_rx_vlan_filter_result *res = parsed_result; 4302 4303 if (!strcmp(res->what, "add")) 4304 rx_vft_set(res->port_id, res->vlan_id, 1); 4305 else 4306 rx_vft_set(res->port_id, res->vlan_id, 0); 4307 } 4308 4309 static cmdline_parse_token_string_t cmd_rx_vlan_filter_rx_vlan = 4310 TOKEN_STRING_INITIALIZER(struct cmd_rx_vlan_filter_result, 4311 rx_vlan, "rx_vlan"); 4312 static cmdline_parse_token_string_t cmd_rx_vlan_filter_what = 4313 TOKEN_STRING_INITIALIZER(struct cmd_rx_vlan_filter_result, 4314 what, "add#rm"); 4315 static cmdline_parse_token_num_t cmd_rx_vlan_filter_vlanid = 4316 TOKEN_NUM_INITIALIZER(struct cmd_rx_vlan_filter_result, 4317 vlan_id, RTE_UINT16); 4318 static cmdline_parse_token_num_t cmd_rx_vlan_filter_portid = 4319 TOKEN_NUM_INITIALIZER(struct cmd_rx_vlan_filter_result, 4320 port_id, RTE_UINT16); 4321 4322 static cmdline_parse_inst_t cmd_rx_vlan_filter = { 4323 .f = cmd_rx_vlan_filter_parsed, 4324 .data = NULL, 4325 .help_str = "rx_vlan add|rm <vlan_id> <port_id>: " 4326 "Add/Remove a VLAN identifier to/from the set of VLAN " 4327 "identifiers filtered by a port", 4328 .tokens = { 4329 (void *)&cmd_rx_vlan_filter_rx_vlan, 4330 (void *)&cmd_rx_vlan_filter_what, 4331 (void *)&cmd_rx_vlan_filter_vlanid, 4332 (void *)&cmd_rx_vlan_filter_portid, 4333 NULL, 4334 }, 4335 }; 4336 4337 /* *** ENABLE HARDWARE INSERTION OF VLAN HEADER IN TX PACKETS *** */ 4338 struct cmd_tx_vlan_set_result { 4339 cmdline_fixed_string_t tx_vlan; 4340 cmdline_fixed_string_t set; 4341 portid_t port_id; 4342 uint16_t vlan_id; 4343 }; 4344 4345 static void 4346 cmd_tx_vlan_set_parsed(void *parsed_result, 4347 __rte_unused struct cmdline *cl, 4348 __rte_unused void *data) 4349 { 4350 struct cmd_tx_vlan_set_result *res = parsed_result; 4351 4352 if (port_id_is_invalid(res->port_id, ENABLED_WARN)) 4353 return; 4354 4355 if (!port_is_stopped(res->port_id)) { 4356 fprintf(stderr, "Please stop port %d first\n", res->port_id); 4357 return; 4358 } 4359 4360 tx_vlan_set(res->port_id, res->vlan_id); 4361 4362 cmd_reconfig_device_queue(res->port_id, 1, 1); 4363 } 4364 4365 static cmdline_parse_token_string_t cmd_tx_vlan_set_tx_vlan = 4366 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_result, 4367 tx_vlan, "tx_vlan"); 4368 static cmdline_parse_token_string_t cmd_tx_vlan_set_set = 4369 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_result, 4370 set, "set"); 4371 static cmdline_parse_token_num_t cmd_tx_vlan_set_portid = 4372 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_result, 4373 port_id, RTE_UINT16); 4374 static cmdline_parse_token_num_t cmd_tx_vlan_set_vlanid = 4375 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_result, 4376 vlan_id, RTE_UINT16); 4377 4378 static cmdline_parse_inst_t cmd_tx_vlan_set = { 4379 .f = cmd_tx_vlan_set_parsed, 4380 .data = NULL, 4381 .help_str = "tx_vlan set <port_id> <vlan_id>: " 4382 "Enable hardware insertion of a single VLAN header " 4383 "with a given TAG Identifier in packets sent on a port", 4384 .tokens = { 4385 (void *)&cmd_tx_vlan_set_tx_vlan, 4386 (void *)&cmd_tx_vlan_set_set, 4387 (void *)&cmd_tx_vlan_set_portid, 4388 (void *)&cmd_tx_vlan_set_vlanid, 4389 NULL, 4390 }, 4391 }; 4392 4393 /* *** ENABLE HARDWARE INSERTION OF Double VLAN HEADER IN TX PACKETS *** */ 4394 struct cmd_tx_vlan_set_qinq_result { 4395 cmdline_fixed_string_t tx_vlan; 4396 cmdline_fixed_string_t set; 4397 portid_t port_id; 4398 uint16_t vlan_id; 4399 uint16_t vlan_id_outer; 4400 }; 4401 4402 static void 4403 cmd_tx_vlan_set_qinq_parsed(void *parsed_result, 4404 __rte_unused struct cmdline *cl, 4405 __rte_unused void *data) 4406 { 4407 struct cmd_tx_vlan_set_qinq_result *res = parsed_result; 4408 4409 if (port_id_is_invalid(res->port_id, ENABLED_WARN)) 4410 return; 4411 4412 if (!port_is_stopped(res->port_id)) { 4413 fprintf(stderr, "Please stop port %d first\n", res->port_id); 4414 return; 4415 } 4416 4417 tx_qinq_set(res->port_id, res->vlan_id, res->vlan_id_outer); 4418 4419 cmd_reconfig_device_queue(res->port_id, 1, 1); 4420 } 4421 4422 static cmdline_parse_token_string_t cmd_tx_vlan_set_qinq_tx_vlan = 4423 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_qinq_result, 4424 tx_vlan, "tx_vlan"); 4425 static cmdline_parse_token_string_t cmd_tx_vlan_set_qinq_set = 4426 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_qinq_result, 4427 set, "set"); 4428 static cmdline_parse_token_num_t cmd_tx_vlan_set_qinq_portid = 4429 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_qinq_result, 4430 port_id, RTE_UINT16); 4431 static cmdline_parse_token_num_t cmd_tx_vlan_set_qinq_vlanid = 4432 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_qinq_result, 4433 vlan_id, RTE_UINT16); 4434 static cmdline_parse_token_num_t cmd_tx_vlan_set_qinq_vlanid_outer = 4435 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_qinq_result, 4436 vlan_id_outer, RTE_UINT16); 4437 4438 static cmdline_parse_inst_t cmd_tx_vlan_set_qinq = { 4439 .f = cmd_tx_vlan_set_qinq_parsed, 4440 .data = NULL, 4441 .help_str = "tx_vlan set <port_id> <vlan_id> <outer_vlan_id>: " 4442 "Enable hardware insertion of double VLAN header " 4443 "with given TAG Identifiers in packets sent on a port", 4444 .tokens = { 4445 (void *)&cmd_tx_vlan_set_qinq_tx_vlan, 4446 (void *)&cmd_tx_vlan_set_qinq_set, 4447 (void *)&cmd_tx_vlan_set_qinq_portid, 4448 (void *)&cmd_tx_vlan_set_qinq_vlanid, 4449 (void *)&cmd_tx_vlan_set_qinq_vlanid_outer, 4450 NULL, 4451 }, 4452 }; 4453 4454 /* *** ENABLE/DISABLE PORT BASED TX VLAN INSERTION *** */ 4455 struct cmd_tx_vlan_set_pvid_result { 4456 cmdline_fixed_string_t tx_vlan; 4457 cmdline_fixed_string_t set; 4458 cmdline_fixed_string_t pvid; 4459 portid_t port_id; 4460 uint16_t vlan_id; 4461 cmdline_fixed_string_t mode; 4462 }; 4463 4464 static void 4465 cmd_tx_vlan_set_pvid_parsed(void *parsed_result, 4466 __rte_unused struct cmdline *cl, 4467 __rte_unused void *data) 4468 { 4469 struct cmd_tx_vlan_set_pvid_result *res = parsed_result; 4470 4471 if (strcmp(res->mode, "on") == 0) 4472 tx_vlan_pvid_set(res->port_id, res->vlan_id, 1); 4473 else 4474 tx_vlan_pvid_set(res->port_id, res->vlan_id, 0); 4475 } 4476 4477 static cmdline_parse_token_string_t cmd_tx_vlan_set_pvid_tx_vlan = 4478 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_pvid_result, 4479 tx_vlan, "tx_vlan"); 4480 static cmdline_parse_token_string_t cmd_tx_vlan_set_pvid_set = 4481 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_pvid_result, 4482 set, "set"); 4483 static cmdline_parse_token_string_t cmd_tx_vlan_set_pvid_pvid = 4484 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_pvid_result, 4485 pvid, "pvid"); 4486 static cmdline_parse_token_num_t cmd_tx_vlan_set_pvid_port_id = 4487 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_pvid_result, 4488 port_id, RTE_UINT16); 4489 static cmdline_parse_token_num_t cmd_tx_vlan_set_pvid_vlan_id = 4490 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_pvid_result, 4491 vlan_id, RTE_UINT16); 4492 static cmdline_parse_token_string_t cmd_tx_vlan_set_pvid_mode = 4493 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_pvid_result, 4494 mode, "on#off"); 4495 4496 static cmdline_parse_inst_t cmd_tx_vlan_set_pvid = { 4497 .f = cmd_tx_vlan_set_pvid_parsed, 4498 .data = NULL, 4499 .help_str = "tx_vlan set pvid <port_id> <vlan_id> on|off", 4500 .tokens = { 4501 (void *)&cmd_tx_vlan_set_pvid_tx_vlan, 4502 (void *)&cmd_tx_vlan_set_pvid_set, 4503 (void *)&cmd_tx_vlan_set_pvid_pvid, 4504 (void *)&cmd_tx_vlan_set_pvid_port_id, 4505 (void *)&cmd_tx_vlan_set_pvid_vlan_id, 4506 (void *)&cmd_tx_vlan_set_pvid_mode, 4507 NULL, 4508 }, 4509 }; 4510 4511 /* *** DISABLE HARDWARE INSERTION OF VLAN HEADER IN TX PACKETS *** */ 4512 struct cmd_tx_vlan_reset_result { 4513 cmdline_fixed_string_t tx_vlan; 4514 cmdline_fixed_string_t reset; 4515 portid_t port_id; 4516 }; 4517 4518 static void 4519 cmd_tx_vlan_reset_parsed(void *parsed_result, 4520 __rte_unused struct cmdline *cl, 4521 __rte_unused void *data) 4522 { 4523 struct cmd_tx_vlan_reset_result *res = parsed_result; 4524 4525 if (port_id_is_invalid(res->port_id, ENABLED_WARN)) 4526 return; 4527 4528 if (!port_is_stopped(res->port_id)) { 4529 fprintf(stderr, "Please stop port %d first\n", res->port_id); 4530 return; 4531 } 4532 4533 tx_vlan_reset(res->port_id); 4534 4535 cmd_reconfig_device_queue(res->port_id, 1, 1); 4536 } 4537 4538 static cmdline_parse_token_string_t cmd_tx_vlan_reset_tx_vlan = 4539 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_reset_result, 4540 tx_vlan, "tx_vlan"); 4541 static cmdline_parse_token_string_t cmd_tx_vlan_reset_reset = 4542 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_reset_result, 4543 reset, "reset"); 4544 static cmdline_parse_token_num_t cmd_tx_vlan_reset_portid = 4545 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_reset_result, 4546 port_id, RTE_UINT16); 4547 4548 static cmdline_parse_inst_t cmd_tx_vlan_reset = { 4549 .f = cmd_tx_vlan_reset_parsed, 4550 .data = NULL, 4551 .help_str = "tx_vlan reset <port_id>: Disable hardware insertion of a " 4552 "VLAN header in packets sent on a port", 4553 .tokens = { 4554 (void *)&cmd_tx_vlan_reset_tx_vlan, 4555 (void *)&cmd_tx_vlan_reset_reset, 4556 (void *)&cmd_tx_vlan_reset_portid, 4557 NULL, 4558 }, 4559 }; 4560 4561 4562 /* *** ENABLE HARDWARE INSERTION OF CHECKSUM IN TX PACKETS *** */ 4563 struct cmd_csum_result { 4564 cmdline_fixed_string_t csum; 4565 cmdline_fixed_string_t mode; 4566 cmdline_fixed_string_t proto; 4567 cmdline_fixed_string_t hwsw; 4568 portid_t port_id; 4569 }; 4570 4571 static void 4572 csum_show(int port_id) 4573 { 4574 struct rte_eth_dev_info dev_info; 4575 uint64_t tx_offloads; 4576 int ret; 4577 4578 tx_offloads = ports[port_id].dev_conf.txmode.offloads; 4579 printf("Parse tunnel is %s\n", 4580 (ports[port_id].parse_tunnel) ? "on" : "off"); 4581 printf("IP checksum offload is %s\n", 4582 (tx_offloads & RTE_ETH_TX_OFFLOAD_IPV4_CKSUM) ? "hw" : "sw"); 4583 printf("UDP checksum offload is %s\n", 4584 (tx_offloads & RTE_ETH_TX_OFFLOAD_UDP_CKSUM) ? "hw" : "sw"); 4585 printf("TCP checksum offload is %s\n", 4586 (tx_offloads & RTE_ETH_TX_OFFLOAD_TCP_CKSUM) ? "hw" : "sw"); 4587 printf("SCTP checksum offload is %s\n", 4588 (tx_offloads & RTE_ETH_TX_OFFLOAD_SCTP_CKSUM) ? "hw" : "sw"); 4589 printf("Outer-Ip checksum offload is %s\n", 4590 (tx_offloads & RTE_ETH_TX_OFFLOAD_OUTER_IPV4_CKSUM) ? "hw" : "sw"); 4591 printf("Outer-Udp checksum offload is %s\n", 4592 (tx_offloads & RTE_ETH_TX_OFFLOAD_OUTER_UDP_CKSUM) ? "hw" : "sw"); 4593 4594 /* display warnings if configuration is not supported by the NIC */ 4595 ret = eth_dev_info_get_print_err(port_id, &dev_info); 4596 if (ret != 0) 4597 return; 4598 4599 if ((tx_offloads & RTE_ETH_TX_OFFLOAD_IPV4_CKSUM) && 4600 (dev_info.tx_offload_capa & RTE_ETH_TX_OFFLOAD_IPV4_CKSUM) == 0) { 4601 fprintf(stderr, 4602 "Warning: hardware IP checksum enabled but not supported by port %d\n", 4603 port_id); 4604 } 4605 if ((tx_offloads & RTE_ETH_TX_OFFLOAD_UDP_CKSUM) && 4606 (dev_info.tx_offload_capa & RTE_ETH_TX_OFFLOAD_UDP_CKSUM) == 0) { 4607 fprintf(stderr, 4608 "Warning: hardware UDP checksum enabled but not supported by port %d\n", 4609 port_id); 4610 } 4611 if ((tx_offloads & RTE_ETH_TX_OFFLOAD_TCP_CKSUM) && 4612 (dev_info.tx_offload_capa & RTE_ETH_TX_OFFLOAD_TCP_CKSUM) == 0) { 4613 fprintf(stderr, 4614 "Warning: hardware TCP checksum enabled but not supported by port %d\n", 4615 port_id); 4616 } 4617 if ((tx_offloads & RTE_ETH_TX_OFFLOAD_SCTP_CKSUM) && 4618 (dev_info.tx_offload_capa & RTE_ETH_TX_OFFLOAD_SCTP_CKSUM) == 0) { 4619 fprintf(stderr, 4620 "Warning: hardware SCTP checksum enabled but not supported by port %d\n", 4621 port_id); 4622 } 4623 if ((tx_offloads & RTE_ETH_TX_OFFLOAD_OUTER_IPV4_CKSUM) && 4624 (dev_info.tx_offload_capa & RTE_ETH_TX_OFFLOAD_OUTER_IPV4_CKSUM) == 0) { 4625 fprintf(stderr, 4626 "Warning: hardware outer IP checksum enabled but not supported by port %d\n", 4627 port_id); 4628 } 4629 if ((tx_offloads & RTE_ETH_TX_OFFLOAD_OUTER_UDP_CKSUM) && 4630 (dev_info.tx_offload_capa & RTE_ETH_TX_OFFLOAD_OUTER_UDP_CKSUM) 4631 == 0) { 4632 fprintf(stderr, 4633 "Warning: hardware outer UDP checksum enabled but not supported by port %d\n", 4634 port_id); 4635 } 4636 } 4637 4638 static void 4639 cmd_config_queue_tx_offloads(struct rte_port *port) 4640 { 4641 int k; 4642 4643 /* Apply queue tx offloads configuration */ 4644 for (k = 0; k < port->dev_info.max_tx_queues; k++) 4645 port->txq[k].conf.offloads = 4646 port->dev_conf.txmode.offloads; 4647 } 4648 4649 static void 4650 cmd_csum_parsed(void *parsed_result, 4651 __rte_unused struct cmdline *cl, 4652 __rte_unused void *data) 4653 { 4654 struct cmd_csum_result *res = parsed_result; 4655 int hw = 0; 4656 uint64_t csum_offloads = 0; 4657 struct rte_eth_dev_info dev_info; 4658 int ret; 4659 4660 if (port_id_is_invalid(res->port_id, ENABLED_WARN)) { 4661 fprintf(stderr, "invalid port %d\n", res->port_id); 4662 return; 4663 } 4664 if (!port_is_stopped(res->port_id)) { 4665 fprintf(stderr, "Please stop port %d first\n", res->port_id); 4666 return; 4667 } 4668 4669 ret = eth_dev_info_get_print_err(res->port_id, &dev_info); 4670 if (ret != 0) 4671 return; 4672 4673 if (!strcmp(res->mode, "set")) { 4674 4675 if (!strcmp(res->hwsw, "hw")) 4676 hw = 1; 4677 4678 if (!strcmp(res->proto, "ip")) { 4679 if (hw == 0 || (dev_info.tx_offload_capa & 4680 RTE_ETH_TX_OFFLOAD_IPV4_CKSUM)) { 4681 csum_offloads |= RTE_ETH_TX_OFFLOAD_IPV4_CKSUM; 4682 } else { 4683 fprintf(stderr, 4684 "IP checksum offload is not supported by port %u\n", 4685 res->port_id); 4686 } 4687 } else if (!strcmp(res->proto, "udp")) { 4688 if (hw == 0 || (dev_info.tx_offload_capa & 4689 RTE_ETH_TX_OFFLOAD_UDP_CKSUM)) { 4690 csum_offloads |= RTE_ETH_TX_OFFLOAD_UDP_CKSUM; 4691 } else { 4692 fprintf(stderr, 4693 "UDP checksum offload is not supported by port %u\n", 4694 res->port_id); 4695 } 4696 } else if (!strcmp(res->proto, "tcp")) { 4697 if (hw == 0 || (dev_info.tx_offload_capa & 4698 RTE_ETH_TX_OFFLOAD_TCP_CKSUM)) { 4699 csum_offloads |= RTE_ETH_TX_OFFLOAD_TCP_CKSUM; 4700 } else { 4701 fprintf(stderr, 4702 "TCP checksum offload is not supported by port %u\n", 4703 res->port_id); 4704 } 4705 } else if (!strcmp(res->proto, "sctp")) { 4706 if (hw == 0 || (dev_info.tx_offload_capa & 4707 RTE_ETH_TX_OFFLOAD_SCTP_CKSUM)) { 4708 csum_offloads |= RTE_ETH_TX_OFFLOAD_SCTP_CKSUM; 4709 } else { 4710 fprintf(stderr, 4711 "SCTP checksum offload is not supported by port %u\n", 4712 res->port_id); 4713 } 4714 } else if (!strcmp(res->proto, "outer-ip")) { 4715 if (hw == 0 || (dev_info.tx_offload_capa & 4716 RTE_ETH_TX_OFFLOAD_OUTER_IPV4_CKSUM)) { 4717 csum_offloads |= 4718 RTE_ETH_TX_OFFLOAD_OUTER_IPV4_CKSUM; 4719 } else { 4720 fprintf(stderr, 4721 "Outer IP checksum offload is not supported by port %u\n", 4722 res->port_id); 4723 } 4724 } else if (!strcmp(res->proto, "outer-udp")) { 4725 if (hw == 0 || (dev_info.tx_offload_capa & 4726 RTE_ETH_TX_OFFLOAD_OUTER_UDP_CKSUM)) { 4727 csum_offloads |= 4728 RTE_ETH_TX_OFFLOAD_OUTER_UDP_CKSUM; 4729 } else { 4730 fprintf(stderr, 4731 "Outer UDP checksum offload is not supported by port %u\n", 4732 res->port_id); 4733 } 4734 } 4735 4736 if (hw) { 4737 ports[res->port_id].dev_conf.txmode.offloads |= 4738 csum_offloads; 4739 } else { 4740 ports[res->port_id].dev_conf.txmode.offloads &= 4741 (~csum_offloads); 4742 } 4743 cmd_config_queue_tx_offloads(&ports[res->port_id]); 4744 } 4745 csum_show(res->port_id); 4746 4747 cmd_reconfig_device_queue(res->port_id, 1, 1); 4748 } 4749 4750 static cmdline_parse_token_string_t cmd_csum_csum = 4751 TOKEN_STRING_INITIALIZER(struct cmd_csum_result, 4752 csum, "csum"); 4753 static cmdline_parse_token_string_t cmd_csum_mode = 4754 TOKEN_STRING_INITIALIZER(struct cmd_csum_result, 4755 mode, "set"); 4756 static cmdline_parse_token_string_t cmd_csum_proto = 4757 TOKEN_STRING_INITIALIZER(struct cmd_csum_result, 4758 proto, "ip#tcp#udp#sctp#outer-ip#outer-udp"); 4759 static cmdline_parse_token_string_t cmd_csum_hwsw = 4760 TOKEN_STRING_INITIALIZER(struct cmd_csum_result, 4761 hwsw, "hw#sw"); 4762 static cmdline_parse_token_num_t cmd_csum_portid = 4763 TOKEN_NUM_INITIALIZER(struct cmd_csum_result, 4764 port_id, RTE_UINT16); 4765 4766 static cmdline_parse_inst_t cmd_csum_set = { 4767 .f = cmd_csum_parsed, 4768 .data = NULL, 4769 .help_str = "csum set ip|tcp|udp|sctp|outer-ip|outer-udp hw|sw <port_id>: " 4770 "Enable/Disable hardware calculation of L3/L4 checksum when " 4771 "using csum forward engine", 4772 .tokens = { 4773 (void *)&cmd_csum_csum, 4774 (void *)&cmd_csum_mode, 4775 (void *)&cmd_csum_proto, 4776 (void *)&cmd_csum_hwsw, 4777 (void *)&cmd_csum_portid, 4778 NULL, 4779 }, 4780 }; 4781 4782 static cmdline_parse_token_string_t cmd_csum_mode_show = 4783 TOKEN_STRING_INITIALIZER(struct cmd_csum_result, 4784 mode, "show"); 4785 4786 static cmdline_parse_inst_t cmd_csum_show = { 4787 .f = cmd_csum_parsed, 4788 .data = NULL, 4789 .help_str = "csum show <port_id>: Show checksum offload configuration", 4790 .tokens = { 4791 (void *)&cmd_csum_csum, 4792 (void *)&cmd_csum_mode_show, 4793 (void *)&cmd_csum_portid, 4794 NULL, 4795 }, 4796 }; 4797 4798 /* Enable/disable tunnel parsing */ 4799 struct cmd_csum_tunnel_result { 4800 cmdline_fixed_string_t csum; 4801 cmdline_fixed_string_t parse; 4802 cmdline_fixed_string_t onoff; 4803 portid_t port_id; 4804 }; 4805 4806 static void 4807 cmd_csum_tunnel_parsed(void *parsed_result, 4808 __rte_unused struct cmdline *cl, 4809 __rte_unused void *data) 4810 { 4811 struct cmd_csum_tunnel_result *res = parsed_result; 4812 4813 if (port_id_is_invalid(res->port_id, ENABLED_WARN)) 4814 return; 4815 4816 if (!strcmp(res->onoff, "on")) 4817 ports[res->port_id].parse_tunnel = 1; 4818 else 4819 ports[res->port_id].parse_tunnel = 0; 4820 4821 csum_show(res->port_id); 4822 } 4823 4824 static cmdline_parse_token_string_t cmd_csum_tunnel_csum = 4825 TOKEN_STRING_INITIALIZER(struct cmd_csum_tunnel_result, 4826 csum, "csum"); 4827 static cmdline_parse_token_string_t cmd_csum_tunnel_parse = 4828 TOKEN_STRING_INITIALIZER(struct cmd_csum_tunnel_result, 4829 parse, "parse-tunnel"); 4830 static cmdline_parse_token_string_t cmd_csum_tunnel_onoff = 4831 TOKEN_STRING_INITIALIZER(struct cmd_csum_tunnel_result, 4832 onoff, "on#off"); 4833 static cmdline_parse_token_num_t cmd_csum_tunnel_portid = 4834 TOKEN_NUM_INITIALIZER(struct cmd_csum_tunnel_result, 4835 port_id, RTE_UINT16); 4836 4837 static cmdline_parse_inst_t cmd_csum_tunnel = { 4838 .f = cmd_csum_tunnel_parsed, 4839 .data = NULL, 4840 .help_str = "csum parse-tunnel on|off <port_id>: " 4841 "Enable/Disable parsing of tunnels for csum engine", 4842 .tokens = { 4843 (void *)&cmd_csum_tunnel_csum, 4844 (void *)&cmd_csum_tunnel_parse, 4845 (void *)&cmd_csum_tunnel_onoff, 4846 (void *)&cmd_csum_tunnel_portid, 4847 NULL, 4848 }, 4849 }; 4850 4851 struct cmd_csum_mac_swap_result { 4852 cmdline_fixed_string_t csum; 4853 cmdline_fixed_string_t parse; 4854 cmdline_fixed_string_t onoff; 4855 portid_t port_id; 4856 }; 4857 4858 static void 4859 cmd_csum_mac_swap_parsed(void *parsed_result, 4860 __rte_unused struct cmdline *cl, 4861 __rte_unused void *data) 4862 { 4863 struct cmd_csum_mac_swap_result *res = parsed_result; 4864 4865 if (port_id_is_invalid(res->port_id, ENABLED_WARN)) 4866 return; 4867 if (strcmp(res->onoff, "on") == 0) 4868 ports[res->port_id].fwd_mac_swap = 1; 4869 else 4870 ports[res->port_id].fwd_mac_swap = 0; 4871 } 4872 4873 static cmdline_parse_token_string_t cmd_csum_mac_swap_csum = 4874 TOKEN_STRING_INITIALIZER(struct cmd_csum_mac_swap_result, 4875 csum, "csum"); 4876 static cmdline_parse_token_string_t cmd_csum_mac_swap_parse = 4877 TOKEN_STRING_INITIALIZER(struct cmd_csum_mac_swap_result, 4878 parse, "mac-swap"); 4879 static cmdline_parse_token_string_t cmd_csum_mac_swap_onoff = 4880 TOKEN_STRING_INITIALIZER(struct cmd_csum_mac_swap_result, 4881 onoff, "on#off"); 4882 static cmdline_parse_token_num_t cmd_csum_mac_swap_portid = 4883 TOKEN_NUM_INITIALIZER(struct cmd_csum_mac_swap_result, 4884 port_id, RTE_UINT16); 4885 4886 static cmdline_parse_inst_t cmd_csum_mac_swap = { 4887 .f = cmd_csum_mac_swap_parsed, 4888 .data = NULL, 4889 .help_str = "csum mac-swap on|off <port_id>: " 4890 "Enable/Disable forward mac address swap", 4891 .tokens = { 4892 (void *)&cmd_csum_mac_swap_csum, 4893 (void *)&cmd_csum_mac_swap_parse, 4894 (void *)&cmd_csum_mac_swap_onoff, 4895 (void *)&cmd_csum_mac_swap_portid, 4896 NULL, 4897 }, 4898 }; 4899 4900 /* *** ENABLE HARDWARE SEGMENTATION IN TX NON-TUNNELED PACKETS *** */ 4901 struct cmd_tso_set_result { 4902 cmdline_fixed_string_t tso; 4903 cmdline_fixed_string_t mode; 4904 uint16_t tso_segsz; 4905 portid_t port_id; 4906 }; 4907 4908 static void 4909 cmd_tso_set_parsed(void *parsed_result, 4910 __rte_unused struct cmdline *cl, 4911 __rte_unused void *data) 4912 { 4913 struct cmd_tso_set_result *res = parsed_result; 4914 struct rte_eth_dev_info dev_info; 4915 int ret; 4916 4917 if (port_id_is_invalid(res->port_id, ENABLED_WARN)) 4918 return; 4919 if (!port_is_stopped(res->port_id)) { 4920 fprintf(stderr, "Please stop port %d first\n", res->port_id); 4921 return; 4922 } 4923 4924 if (!strcmp(res->mode, "set")) 4925 ports[res->port_id].tso_segsz = res->tso_segsz; 4926 4927 ret = eth_dev_info_get_print_err(res->port_id, &dev_info); 4928 if (ret != 0) 4929 return; 4930 4931 if ((ports[res->port_id].tso_segsz != 0) && 4932 (dev_info.tx_offload_capa & RTE_ETH_TX_OFFLOAD_TCP_TSO) == 0) { 4933 fprintf(stderr, "Error: TSO is not supported by port %d\n", 4934 res->port_id); 4935 return; 4936 } 4937 4938 if (ports[res->port_id].tso_segsz == 0) { 4939 ports[res->port_id].dev_conf.txmode.offloads &= 4940 ~RTE_ETH_TX_OFFLOAD_TCP_TSO; 4941 printf("TSO for non-tunneled packets is disabled\n"); 4942 } else { 4943 ports[res->port_id].dev_conf.txmode.offloads |= 4944 RTE_ETH_TX_OFFLOAD_TCP_TSO; 4945 printf("TSO segment size for non-tunneled packets is %d\n", 4946 ports[res->port_id].tso_segsz); 4947 } 4948 cmd_config_queue_tx_offloads(&ports[res->port_id]); 4949 4950 /* display warnings if configuration is not supported by the NIC */ 4951 ret = eth_dev_info_get_print_err(res->port_id, &dev_info); 4952 if (ret != 0) 4953 return; 4954 4955 if ((ports[res->port_id].tso_segsz != 0) && 4956 (dev_info.tx_offload_capa & RTE_ETH_TX_OFFLOAD_TCP_TSO) == 0) { 4957 fprintf(stderr, 4958 "Warning: TSO enabled but not supported by port %d\n", 4959 res->port_id); 4960 } 4961 4962 cmd_reconfig_device_queue(res->port_id, 1, 1); 4963 } 4964 4965 static cmdline_parse_token_string_t cmd_tso_set_tso = 4966 TOKEN_STRING_INITIALIZER(struct cmd_tso_set_result, 4967 tso, "tso"); 4968 static cmdline_parse_token_string_t cmd_tso_set_mode = 4969 TOKEN_STRING_INITIALIZER(struct cmd_tso_set_result, 4970 mode, "set"); 4971 static cmdline_parse_token_num_t cmd_tso_set_tso_segsz = 4972 TOKEN_NUM_INITIALIZER(struct cmd_tso_set_result, 4973 tso_segsz, RTE_UINT16); 4974 static cmdline_parse_token_num_t cmd_tso_set_portid = 4975 TOKEN_NUM_INITIALIZER(struct cmd_tso_set_result, 4976 port_id, RTE_UINT16); 4977 4978 static cmdline_parse_inst_t cmd_tso_set = { 4979 .f = cmd_tso_set_parsed, 4980 .data = NULL, 4981 .help_str = "tso set <tso_segsz> <port_id>: " 4982 "Set TSO segment size of non-tunneled packets for csum engine " 4983 "(0 to disable)", 4984 .tokens = { 4985 (void *)&cmd_tso_set_tso, 4986 (void *)&cmd_tso_set_mode, 4987 (void *)&cmd_tso_set_tso_segsz, 4988 (void *)&cmd_tso_set_portid, 4989 NULL, 4990 }, 4991 }; 4992 4993 static cmdline_parse_token_string_t cmd_tso_show_mode = 4994 TOKEN_STRING_INITIALIZER(struct cmd_tso_set_result, 4995 mode, "show"); 4996 4997 4998 static cmdline_parse_inst_t cmd_tso_show = { 4999 .f = cmd_tso_set_parsed, 5000 .data = NULL, 5001 .help_str = "tso show <port_id>: " 5002 "Show TSO segment size of non-tunneled packets for csum engine", 5003 .tokens = { 5004 (void *)&cmd_tso_set_tso, 5005 (void *)&cmd_tso_show_mode, 5006 (void *)&cmd_tso_set_portid, 5007 NULL, 5008 }, 5009 }; 5010 5011 /* *** ENABLE HARDWARE SEGMENTATION IN TX TUNNELED PACKETS *** */ 5012 struct cmd_tunnel_tso_set_result { 5013 cmdline_fixed_string_t tso; 5014 cmdline_fixed_string_t mode; 5015 uint16_t tso_segsz; 5016 portid_t port_id; 5017 }; 5018 5019 static struct rte_eth_dev_info 5020 check_tunnel_tso_nic_support(portid_t port_id) 5021 { 5022 struct rte_eth_dev_info dev_info; 5023 5024 if (eth_dev_info_get_print_err(port_id, &dev_info) != 0) 5025 return dev_info; 5026 5027 if (!(dev_info.tx_offload_capa & RTE_ETH_TX_OFFLOAD_VXLAN_TNL_TSO)) 5028 fprintf(stderr, 5029 "Warning: VXLAN TUNNEL TSO not supported therefore not enabled for port %d\n", 5030 port_id); 5031 if (!(dev_info.tx_offload_capa & RTE_ETH_TX_OFFLOAD_GRE_TNL_TSO)) 5032 fprintf(stderr, 5033 "Warning: GRE TUNNEL TSO not supported therefore not enabled for port %d\n", 5034 port_id); 5035 if (!(dev_info.tx_offload_capa & RTE_ETH_TX_OFFLOAD_IPIP_TNL_TSO)) 5036 fprintf(stderr, 5037 "Warning: IPIP TUNNEL TSO not supported therefore not enabled for port %d\n", 5038 port_id); 5039 if (!(dev_info.tx_offload_capa & RTE_ETH_TX_OFFLOAD_GENEVE_TNL_TSO)) 5040 fprintf(stderr, 5041 "Warning: GENEVE TUNNEL TSO not supported therefore not enabled for port %d\n", 5042 port_id); 5043 if (!(dev_info.tx_offload_capa & RTE_ETH_TX_OFFLOAD_IP_TNL_TSO)) 5044 fprintf(stderr, 5045 "Warning: IP TUNNEL TSO not supported therefore not enabled for port %d\n", 5046 port_id); 5047 if (!(dev_info.tx_offload_capa & RTE_ETH_TX_OFFLOAD_UDP_TNL_TSO)) 5048 fprintf(stderr, 5049 "Warning: UDP TUNNEL TSO not supported therefore not enabled for port %d\n", 5050 port_id); 5051 return dev_info; 5052 } 5053 5054 static void 5055 cmd_tunnel_tso_set_parsed(void *parsed_result, 5056 __rte_unused struct cmdline *cl, 5057 __rte_unused void *data) 5058 { 5059 struct cmd_tunnel_tso_set_result *res = parsed_result; 5060 struct rte_eth_dev_info dev_info; 5061 5062 if (port_id_is_invalid(res->port_id, ENABLED_WARN)) 5063 return; 5064 if (!port_is_stopped(res->port_id)) { 5065 fprintf(stderr, "Please stop port %d first\n", res->port_id); 5066 return; 5067 } 5068 5069 if (!strcmp(res->mode, "set")) 5070 ports[res->port_id].tunnel_tso_segsz = res->tso_segsz; 5071 5072 dev_info = check_tunnel_tso_nic_support(res->port_id); 5073 if (ports[res->port_id].tunnel_tso_segsz == 0) { 5074 ports[res->port_id].dev_conf.txmode.offloads &= 5075 ~(RTE_ETH_TX_OFFLOAD_VXLAN_TNL_TSO | 5076 RTE_ETH_TX_OFFLOAD_GRE_TNL_TSO | 5077 RTE_ETH_TX_OFFLOAD_IPIP_TNL_TSO | 5078 RTE_ETH_TX_OFFLOAD_GENEVE_TNL_TSO | 5079 RTE_ETH_TX_OFFLOAD_IP_TNL_TSO | 5080 RTE_ETH_TX_OFFLOAD_UDP_TNL_TSO); 5081 printf("TSO for tunneled packets is disabled\n"); 5082 } else { 5083 uint64_t tso_offloads = (RTE_ETH_TX_OFFLOAD_VXLAN_TNL_TSO | 5084 RTE_ETH_TX_OFFLOAD_GRE_TNL_TSO | 5085 RTE_ETH_TX_OFFLOAD_IPIP_TNL_TSO | 5086 RTE_ETH_TX_OFFLOAD_GENEVE_TNL_TSO | 5087 RTE_ETH_TX_OFFLOAD_IP_TNL_TSO | 5088 RTE_ETH_TX_OFFLOAD_UDP_TNL_TSO); 5089 5090 ports[res->port_id].dev_conf.txmode.offloads |= 5091 (tso_offloads & dev_info.tx_offload_capa); 5092 printf("TSO segment size for tunneled packets is %d\n", 5093 ports[res->port_id].tunnel_tso_segsz); 5094 5095 /* Below conditions are needed to make it work: 5096 * (1) tunnel TSO is supported by the NIC; 5097 * (2) "csum parse_tunnel" must be set so that tunneled pkts 5098 * are recognized; 5099 * (3) for tunneled pkts with outer L3 of IPv4, 5100 * "csum set outer-ip" must be set to hw, because after tso, 5101 * total_len of outer IP header is changed, and the checksum 5102 * of outer IP header calculated by sw should be wrong; that 5103 * is not necessary for IPv6 tunneled pkts because there's no 5104 * checksum in IP header anymore. 5105 */ 5106 5107 if (!ports[res->port_id].parse_tunnel) 5108 fprintf(stderr, 5109 "Warning: csum parse_tunnel must be set so that tunneled packets are recognized\n"); 5110 if (!(ports[res->port_id].dev_conf.txmode.offloads & 5111 RTE_ETH_TX_OFFLOAD_OUTER_IPV4_CKSUM)) 5112 fprintf(stderr, 5113 "Warning: csum set outer-ip must be set to hw if outer L3 is IPv4; not necessary for IPv6\n"); 5114 } 5115 5116 cmd_config_queue_tx_offloads(&ports[res->port_id]); 5117 cmd_reconfig_device_queue(res->port_id, 1, 1); 5118 } 5119 5120 static cmdline_parse_token_string_t cmd_tunnel_tso_set_tso = 5121 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_tso_set_result, 5122 tso, "tunnel_tso"); 5123 static cmdline_parse_token_string_t cmd_tunnel_tso_set_mode = 5124 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_tso_set_result, 5125 mode, "set"); 5126 static cmdline_parse_token_num_t cmd_tunnel_tso_set_tso_segsz = 5127 TOKEN_NUM_INITIALIZER(struct cmd_tunnel_tso_set_result, 5128 tso_segsz, RTE_UINT16); 5129 static cmdline_parse_token_num_t cmd_tunnel_tso_set_portid = 5130 TOKEN_NUM_INITIALIZER(struct cmd_tunnel_tso_set_result, 5131 port_id, RTE_UINT16); 5132 5133 static cmdline_parse_inst_t cmd_tunnel_tso_set = { 5134 .f = cmd_tunnel_tso_set_parsed, 5135 .data = NULL, 5136 .help_str = "tunnel_tso set <tso_segsz> <port_id>: " 5137 "Set TSO segment size of tunneled packets for csum engine " 5138 "(0 to disable)", 5139 .tokens = { 5140 (void *)&cmd_tunnel_tso_set_tso, 5141 (void *)&cmd_tunnel_tso_set_mode, 5142 (void *)&cmd_tunnel_tso_set_tso_segsz, 5143 (void *)&cmd_tunnel_tso_set_portid, 5144 NULL, 5145 }, 5146 }; 5147 5148 static cmdline_parse_token_string_t cmd_tunnel_tso_show_mode = 5149 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_tso_set_result, 5150 mode, "show"); 5151 5152 5153 static cmdline_parse_inst_t cmd_tunnel_tso_show = { 5154 .f = cmd_tunnel_tso_set_parsed, 5155 .data = NULL, 5156 .help_str = "tunnel_tso show <port_id> " 5157 "Show TSO segment size of tunneled packets for csum engine", 5158 .tokens = { 5159 (void *)&cmd_tunnel_tso_set_tso, 5160 (void *)&cmd_tunnel_tso_show_mode, 5161 (void *)&cmd_tunnel_tso_set_portid, 5162 NULL, 5163 }, 5164 }; 5165 5166 #ifdef RTE_LIB_GRO 5167 /* *** SET GRO FOR A PORT *** */ 5168 struct cmd_gro_enable_result { 5169 cmdline_fixed_string_t cmd_set; 5170 cmdline_fixed_string_t cmd_port; 5171 cmdline_fixed_string_t cmd_keyword; 5172 cmdline_fixed_string_t cmd_onoff; 5173 portid_t cmd_pid; 5174 }; 5175 5176 static void 5177 cmd_gro_enable_parsed(void *parsed_result, 5178 __rte_unused struct cmdline *cl, 5179 __rte_unused void *data) 5180 { 5181 struct cmd_gro_enable_result *res; 5182 5183 res = parsed_result; 5184 if (!strcmp(res->cmd_keyword, "gro")) 5185 setup_gro(res->cmd_onoff, res->cmd_pid); 5186 } 5187 5188 static cmdline_parse_token_string_t cmd_gro_enable_set = 5189 TOKEN_STRING_INITIALIZER(struct cmd_gro_enable_result, 5190 cmd_set, "set"); 5191 static cmdline_parse_token_string_t cmd_gro_enable_port = 5192 TOKEN_STRING_INITIALIZER(struct cmd_gro_enable_result, 5193 cmd_keyword, "port"); 5194 static cmdline_parse_token_num_t cmd_gro_enable_pid = 5195 TOKEN_NUM_INITIALIZER(struct cmd_gro_enable_result, 5196 cmd_pid, RTE_UINT16); 5197 static cmdline_parse_token_string_t cmd_gro_enable_keyword = 5198 TOKEN_STRING_INITIALIZER(struct cmd_gro_enable_result, 5199 cmd_keyword, "gro"); 5200 static cmdline_parse_token_string_t cmd_gro_enable_onoff = 5201 TOKEN_STRING_INITIALIZER(struct cmd_gro_enable_result, 5202 cmd_onoff, "on#off"); 5203 5204 static cmdline_parse_inst_t cmd_gro_enable = { 5205 .f = cmd_gro_enable_parsed, 5206 .data = NULL, 5207 .help_str = "set port <port_id> gro on|off", 5208 .tokens = { 5209 (void *)&cmd_gro_enable_set, 5210 (void *)&cmd_gro_enable_port, 5211 (void *)&cmd_gro_enable_pid, 5212 (void *)&cmd_gro_enable_keyword, 5213 (void *)&cmd_gro_enable_onoff, 5214 NULL, 5215 }, 5216 }; 5217 5218 /* *** DISPLAY GRO CONFIGURATION *** */ 5219 struct cmd_gro_show_result { 5220 cmdline_fixed_string_t cmd_show; 5221 cmdline_fixed_string_t cmd_port; 5222 cmdline_fixed_string_t cmd_keyword; 5223 portid_t cmd_pid; 5224 }; 5225 5226 static void 5227 cmd_gro_show_parsed(void *parsed_result, 5228 __rte_unused struct cmdline *cl, 5229 __rte_unused void *data) 5230 { 5231 struct cmd_gro_show_result *res; 5232 5233 res = parsed_result; 5234 if (!strcmp(res->cmd_keyword, "gro")) 5235 show_gro(res->cmd_pid); 5236 } 5237 5238 static cmdline_parse_token_string_t cmd_gro_show_show = 5239 TOKEN_STRING_INITIALIZER(struct cmd_gro_show_result, 5240 cmd_show, "show"); 5241 static cmdline_parse_token_string_t cmd_gro_show_port = 5242 TOKEN_STRING_INITIALIZER(struct cmd_gro_show_result, 5243 cmd_port, "port"); 5244 static cmdline_parse_token_num_t cmd_gro_show_pid = 5245 TOKEN_NUM_INITIALIZER(struct cmd_gro_show_result, 5246 cmd_pid, RTE_UINT16); 5247 static cmdline_parse_token_string_t cmd_gro_show_keyword = 5248 TOKEN_STRING_INITIALIZER(struct cmd_gro_show_result, 5249 cmd_keyword, "gro"); 5250 5251 static cmdline_parse_inst_t cmd_gro_show = { 5252 .f = cmd_gro_show_parsed, 5253 .data = NULL, 5254 .help_str = "show port <port_id> gro", 5255 .tokens = { 5256 (void *)&cmd_gro_show_show, 5257 (void *)&cmd_gro_show_port, 5258 (void *)&cmd_gro_show_pid, 5259 (void *)&cmd_gro_show_keyword, 5260 NULL, 5261 }, 5262 }; 5263 5264 /* *** SET FLUSH CYCLES FOR GRO *** */ 5265 struct cmd_gro_flush_result { 5266 cmdline_fixed_string_t cmd_set; 5267 cmdline_fixed_string_t cmd_keyword; 5268 cmdline_fixed_string_t cmd_flush; 5269 uint8_t cmd_cycles; 5270 }; 5271 5272 static void 5273 cmd_gro_flush_parsed(void *parsed_result, 5274 __rte_unused struct cmdline *cl, 5275 __rte_unused void *data) 5276 { 5277 struct cmd_gro_flush_result *res; 5278 5279 res = parsed_result; 5280 if ((!strcmp(res->cmd_keyword, "gro")) && 5281 (!strcmp(res->cmd_flush, "flush"))) 5282 setup_gro_flush_cycles(res->cmd_cycles); 5283 } 5284 5285 static cmdline_parse_token_string_t cmd_gro_flush_set = 5286 TOKEN_STRING_INITIALIZER(struct cmd_gro_flush_result, 5287 cmd_set, "set"); 5288 static cmdline_parse_token_string_t cmd_gro_flush_keyword = 5289 TOKEN_STRING_INITIALIZER(struct cmd_gro_flush_result, 5290 cmd_keyword, "gro"); 5291 static cmdline_parse_token_string_t cmd_gro_flush_flush = 5292 TOKEN_STRING_INITIALIZER(struct cmd_gro_flush_result, 5293 cmd_flush, "flush"); 5294 static cmdline_parse_token_num_t cmd_gro_flush_cycles = 5295 TOKEN_NUM_INITIALIZER(struct cmd_gro_flush_result, 5296 cmd_cycles, RTE_UINT8); 5297 5298 static cmdline_parse_inst_t cmd_gro_flush = { 5299 .f = cmd_gro_flush_parsed, 5300 .data = NULL, 5301 .help_str = "set gro flush <cycles>", 5302 .tokens = { 5303 (void *)&cmd_gro_flush_set, 5304 (void *)&cmd_gro_flush_keyword, 5305 (void *)&cmd_gro_flush_flush, 5306 (void *)&cmd_gro_flush_cycles, 5307 NULL, 5308 }, 5309 }; 5310 #endif /* RTE_LIB_GRO */ 5311 5312 #ifdef RTE_LIB_GSO 5313 /* *** ENABLE/DISABLE GSO *** */ 5314 struct cmd_gso_enable_result { 5315 cmdline_fixed_string_t cmd_set; 5316 cmdline_fixed_string_t cmd_port; 5317 cmdline_fixed_string_t cmd_keyword; 5318 cmdline_fixed_string_t cmd_mode; 5319 portid_t cmd_pid; 5320 }; 5321 5322 static void 5323 cmd_gso_enable_parsed(void *parsed_result, 5324 __rte_unused struct cmdline *cl, 5325 __rte_unused void *data) 5326 { 5327 struct cmd_gso_enable_result *res; 5328 5329 res = parsed_result; 5330 if (!strcmp(res->cmd_keyword, "gso")) 5331 setup_gso(res->cmd_mode, res->cmd_pid); 5332 } 5333 5334 static cmdline_parse_token_string_t cmd_gso_enable_set = 5335 TOKEN_STRING_INITIALIZER(struct cmd_gso_enable_result, 5336 cmd_set, "set"); 5337 static cmdline_parse_token_string_t cmd_gso_enable_port = 5338 TOKEN_STRING_INITIALIZER(struct cmd_gso_enable_result, 5339 cmd_port, "port"); 5340 static cmdline_parse_token_string_t cmd_gso_enable_keyword = 5341 TOKEN_STRING_INITIALIZER(struct cmd_gso_enable_result, 5342 cmd_keyword, "gso"); 5343 static cmdline_parse_token_string_t cmd_gso_enable_mode = 5344 TOKEN_STRING_INITIALIZER(struct cmd_gso_enable_result, 5345 cmd_mode, "on#off"); 5346 static cmdline_parse_token_num_t cmd_gso_enable_pid = 5347 TOKEN_NUM_INITIALIZER(struct cmd_gso_enable_result, 5348 cmd_pid, RTE_UINT16); 5349 5350 static cmdline_parse_inst_t cmd_gso_enable = { 5351 .f = cmd_gso_enable_parsed, 5352 .data = NULL, 5353 .help_str = "set port <port_id> gso on|off", 5354 .tokens = { 5355 (void *)&cmd_gso_enable_set, 5356 (void *)&cmd_gso_enable_port, 5357 (void *)&cmd_gso_enable_pid, 5358 (void *)&cmd_gso_enable_keyword, 5359 (void *)&cmd_gso_enable_mode, 5360 NULL, 5361 }, 5362 }; 5363 5364 /* *** SET MAX PACKET LENGTH FOR GSO SEGMENTS *** */ 5365 struct cmd_gso_size_result { 5366 cmdline_fixed_string_t cmd_set; 5367 cmdline_fixed_string_t cmd_keyword; 5368 cmdline_fixed_string_t cmd_segsz; 5369 uint16_t cmd_size; 5370 }; 5371 5372 static void 5373 cmd_gso_size_parsed(void *parsed_result, 5374 __rte_unused struct cmdline *cl, 5375 __rte_unused void *data) 5376 { 5377 struct cmd_gso_size_result *res = parsed_result; 5378 5379 if (test_done == 0) { 5380 fprintf(stderr, 5381 "Before setting GSO segsz, please first stop forwarding\n"); 5382 return; 5383 } 5384 5385 if (!strcmp(res->cmd_keyword, "gso") && 5386 !strcmp(res->cmd_segsz, "segsz")) { 5387 if (res->cmd_size < RTE_GSO_SEG_SIZE_MIN) 5388 fprintf(stderr, 5389 "gso_size should be larger than %zu. Please input a legal value\n", 5390 RTE_GSO_SEG_SIZE_MIN); 5391 else 5392 gso_max_segment_size = res->cmd_size; 5393 } 5394 } 5395 5396 static cmdline_parse_token_string_t cmd_gso_size_set = 5397 TOKEN_STRING_INITIALIZER(struct cmd_gso_size_result, 5398 cmd_set, "set"); 5399 static cmdline_parse_token_string_t cmd_gso_size_keyword = 5400 TOKEN_STRING_INITIALIZER(struct cmd_gso_size_result, 5401 cmd_keyword, "gso"); 5402 static cmdline_parse_token_string_t cmd_gso_size_segsz = 5403 TOKEN_STRING_INITIALIZER(struct cmd_gso_size_result, 5404 cmd_segsz, "segsz"); 5405 static cmdline_parse_token_num_t cmd_gso_size_size = 5406 TOKEN_NUM_INITIALIZER(struct cmd_gso_size_result, 5407 cmd_size, RTE_UINT16); 5408 5409 static cmdline_parse_inst_t cmd_gso_size = { 5410 .f = cmd_gso_size_parsed, 5411 .data = NULL, 5412 .help_str = "set gso segsz <length>", 5413 .tokens = { 5414 (void *)&cmd_gso_size_set, 5415 (void *)&cmd_gso_size_keyword, 5416 (void *)&cmd_gso_size_segsz, 5417 (void *)&cmd_gso_size_size, 5418 NULL, 5419 }, 5420 }; 5421 5422 /* *** SHOW GSO CONFIGURATION *** */ 5423 struct cmd_gso_show_result { 5424 cmdline_fixed_string_t cmd_show; 5425 cmdline_fixed_string_t cmd_port; 5426 cmdline_fixed_string_t cmd_keyword; 5427 portid_t cmd_pid; 5428 }; 5429 5430 static void 5431 cmd_gso_show_parsed(void *parsed_result, 5432 __rte_unused struct cmdline *cl, 5433 __rte_unused void *data) 5434 { 5435 struct cmd_gso_show_result *res = parsed_result; 5436 5437 if (!rte_eth_dev_is_valid_port(res->cmd_pid)) { 5438 fprintf(stderr, "invalid port id %u\n", res->cmd_pid); 5439 return; 5440 } 5441 if (!strcmp(res->cmd_keyword, "gso")) { 5442 if (gso_ports[res->cmd_pid].enable) { 5443 printf("Max GSO'd packet size: %uB\n" 5444 "Supported GSO types: TCP/IPv4, " 5445 "UDP/IPv4, VxLAN with inner " 5446 "TCP/IPv4 packet, GRE with inner " 5447 "TCP/IPv4 packet\n", 5448 gso_max_segment_size); 5449 } else 5450 printf("GSO is not enabled on Port %u\n", res->cmd_pid); 5451 } 5452 } 5453 5454 static cmdline_parse_token_string_t cmd_gso_show_show = 5455 TOKEN_STRING_INITIALIZER(struct cmd_gso_show_result, 5456 cmd_show, "show"); 5457 static cmdline_parse_token_string_t cmd_gso_show_port = 5458 TOKEN_STRING_INITIALIZER(struct cmd_gso_show_result, 5459 cmd_port, "port"); 5460 static cmdline_parse_token_string_t cmd_gso_show_keyword = 5461 TOKEN_STRING_INITIALIZER(struct cmd_gso_show_result, 5462 cmd_keyword, "gso"); 5463 static cmdline_parse_token_num_t cmd_gso_show_pid = 5464 TOKEN_NUM_INITIALIZER(struct cmd_gso_show_result, 5465 cmd_pid, RTE_UINT16); 5466 5467 static cmdline_parse_inst_t cmd_gso_show = { 5468 .f = cmd_gso_show_parsed, 5469 .data = NULL, 5470 .help_str = "show port <port_id> gso", 5471 .tokens = { 5472 (void *)&cmd_gso_show_show, 5473 (void *)&cmd_gso_show_port, 5474 (void *)&cmd_gso_show_pid, 5475 (void *)&cmd_gso_show_keyword, 5476 NULL, 5477 }, 5478 }; 5479 #endif /* RTE_LIB_GSO */ 5480 5481 /* *** ENABLE/DISABLE FLUSH ON RX STREAMS *** */ 5482 struct cmd_set_flush_rx { 5483 cmdline_fixed_string_t set; 5484 cmdline_fixed_string_t flush_rx; 5485 cmdline_fixed_string_t mode; 5486 }; 5487 5488 static void 5489 cmd_set_flush_rx_parsed(void *parsed_result, 5490 __rte_unused struct cmdline *cl, 5491 __rte_unused void *data) 5492 { 5493 struct cmd_set_flush_rx *res = parsed_result; 5494 5495 if (num_procs > 1 && (strcmp(res->mode, "on") == 0)) { 5496 printf("multi-process doesn't support to flush Rx queues.\n"); 5497 return; 5498 } 5499 5500 no_flush_rx = (uint8_t)((strcmp(res->mode, "on") == 0) ? 0 : 1); 5501 } 5502 5503 static cmdline_parse_token_string_t cmd_setflushrx_set = 5504 TOKEN_STRING_INITIALIZER(struct cmd_set_flush_rx, 5505 set, "set"); 5506 static cmdline_parse_token_string_t cmd_setflushrx_flush_rx = 5507 TOKEN_STRING_INITIALIZER(struct cmd_set_flush_rx, 5508 flush_rx, "flush_rx"); 5509 static cmdline_parse_token_string_t cmd_setflushrx_mode = 5510 TOKEN_STRING_INITIALIZER(struct cmd_set_flush_rx, 5511 mode, "on#off"); 5512 5513 5514 static cmdline_parse_inst_t cmd_set_flush_rx = { 5515 .f = cmd_set_flush_rx_parsed, 5516 .help_str = "set flush_rx on|off: Enable/Disable flush on rx streams", 5517 .data = NULL, 5518 .tokens = { 5519 (void *)&cmd_setflushrx_set, 5520 (void *)&cmd_setflushrx_flush_rx, 5521 (void *)&cmd_setflushrx_mode, 5522 NULL, 5523 }, 5524 }; 5525 5526 /* *** ENABLE/DISABLE LINK STATUS CHECK *** */ 5527 struct cmd_set_link_check { 5528 cmdline_fixed_string_t set; 5529 cmdline_fixed_string_t link_check; 5530 cmdline_fixed_string_t mode; 5531 }; 5532 5533 static void 5534 cmd_set_link_check_parsed(void *parsed_result, 5535 __rte_unused struct cmdline *cl, 5536 __rte_unused void *data) 5537 { 5538 struct cmd_set_link_check *res = parsed_result; 5539 no_link_check = (uint8_t)((strcmp(res->mode, "on") == 0) ? 0 : 1); 5540 } 5541 5542 static cmdline_parse_token_string_t cmd_setlinkcheck_set = 5543 TOKEN_STRING_INITIALIZER(struct cmd_set_link_check, 5544 set, "set"); 5545 static cmdline_parse_token_string_t cmd_setlinkcheck_link_check = 5546 TOKEN_STRING_INITIALIZER(struct cmd_set_link_check, 5547 link_check, "link_check"); 5548 static cmdline_parse_token_string_t cmd_setlinkcheck_mode = 5549 TOKEN_STRING_INITIALIZER(struct cmd_set_link_check, 5550 mode, "on#off"); 5551 5552 5553 static cmdline_parse_inst_t cmd_set_link_check = { 5554 .f = cmd_set_link_check_parsed, 5555 .help_str = "set link_check on|off: Enable/Disable link status check " 5556 "when starting/stopping a port", 5557 .data = NULL, 5558 .tokens = { 5559 (void *)&cmd_setlinkcheck_set, 5560 (void *)&cmd_setlinkcheck_link_check, 5561 (void *)&cmd_setlinkcheck_mode, 5562 NULL, 5563 }, 5564 }; 5565 5566 /* *** SET FORWARDING MODE *** */ 5567 struct cmd_set_fwd_mode_result { 5568 cmdline_fixed_string_t set; 5569 cmdline_fixed_string_t fwd; 5570 cmdline_fixed_string_t mode; 5571 }; 5572 5573 static void cmd_set_fwd_mode_parsed(void *parsed_result, 5574 __rte_unused struct cmdline *cl, 5575 __rte_unused void *data) 5576 { 5577 struct cmd_set_fwd_mode_result *res = parsed_result; 5578 5579 retry_enabled = 0; 5580 set_pkt_forwarding_mode(res->mode); 5581 } 5582 5583 static cmdline_parse_token_string_t cmd_setfwd_set = 5584 TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_mode_result, set, "set"); 5585 static cmdline_parse_token_string_t cmd_setfwd_fwd = 5586 TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_mode_result, fwd, "fwd"); 5587 static cmdline_parse_token_string_t cmd_setfwd_mode = 5588 TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_mode_result, mode, 5589 "" /* defined at init */); 5590 5591 static cmdline_parse_inst_t cmd_set_fwd_mode = { 5592 .f = cmd_set_fwd_mode_parsed, 5593 .data = NULL, 5594 .help_str = NULL, /* defined at init */ 5595 .tokens = { 5596 (void *)&cmd_setfwd_set, 5597 (void *)&cmd_setfwd_fwd, 5598 (void *)&cmd_setfwd_mode, 5599 NULL, 5600 }, 5601 }; 5602 5603 static void cmd_set_fwd_mode_init(void) 5604 { 5605 char *modes, *c; 5606 static char token[128]; 5607 static char help[256]; 5608 cmdline_parse_token_string_t *token_struct; 5609 5610 modes = list_pkt_forwarding_modes(); 5611 snprintf(help, sizeof(help), "set fwd %s: " 5612 "Set packet forwarding mode", modes); 5613 cmd_set_fwd_mode.help_str = help; 5614 5615 /* string token separator is # */ 5616 for (c = token; *modes != '\0'; modes++) 5617 if (*modes == '|') 5618 *c++ = '#'; 5619 else 5620 *c++ = *modes; 5621 token_struct = (cmdline_parse_token_string_t*)cmd_set_fwd_mode.tokens[2]; 5622 token_struct->string_data.str = token; 5623 } 5624 5625 /* *** SET RETRY FORWARDING MODE *** */ 5626 struct cmd_set_fwd_retry_mode_result { 5627 cmdline_fixed_string_t set; 5628 cmdline_fixed_string_t fwd; 5629 cmdline_fixed_string_t mode; 5630 cmdline_fixed_string_t retry; 5631 }; 5632 5633 static void cmd_set_fwd_retry_mode_parsed(void *parsed_result, 5634 __rte_unused struct cmdline *cl, 5635 __rte_unused void *data) 5636 { 5637 struct cmd_set_fwd_retry_mode_result *res = parsed_result; 5638 5639 retry_enabled = 1; 5640 set_pkt_forwarding_mode(res->mode); 5641 } 5642 5643 static cmdline_parse_token_string_t cmd_setfwd_retry_set = 5644 TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_retry_mode_result, 5645 set, "set"); 5646 static cmdline_parse_token_string_t cmd_setfwd_retry_fwd = 5647 TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_retry_mode_result, 5648 fwd, "fwd"); 5649 static cmdline_parse_token_string_t cmd_setfwd_retry_mode = 5650 TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_retry_mode_result, 5651 mode, 5652 "" /* defined at init */); 5653 static cmdline_parse_token_string_t cmd_setfwd_retry_retry = 5654 TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_retry_mode_result, 5655 retry, "retry"); 5656 5657 static cmdline_parse_inst_t cmd_set_fwd_retry_mode = { 5658 .f = cmd_set_fwd_retry_mode_parsed, 5659 .data = NULL, 5660 .help_str = NULL, /* defined at init */ 5661 .tokens = { 5662 (void *)&cmd_setfwd_retry_set, 5663 (void *)&cmd_setfwd_retry_fwd, 5664 (void *)&cmd_setfwd_retry_mode, 5665 (void *)&cmd_setfwd_retry_retry, 5666 NULL, 5667 }, 5668 }; 5669 5670 static void cmd_set_fwd_retry_mode_init(void) 5671 { 5672 char *modes, *c; 5673 static char token[128]; 5674 static char help[256]; 5675 cmdline_parse_token_string_t *token_struct; 5676 5677 modes = list_pkt_forwarding_retry_modes(); 5678 snprintf(help, sizeof(help), "set fwd %s retry: " 5679 "Set packet forwarding mode with retry", modes); 5680 cmd_set_fwd_retry_mode.help_str = help; 5681 5682 /* string token separator is # */ 5683 for (c = token; *modes != '\0'; modes++) 5684 if (*modes == '|') 5685 *c++ = '#'; 5686 else 5687 *c++ = *modes; 5688 token_struct = (cmdline_parse_token_string_t *) 5689 cmd_set_fwd_retry_mode.tokens[2]; 5690 token_struct->string_data.str = token; 5691 } 5692 5693 /* *** SET BURST TX DELAY TIME RETRY NUMBER *** */ 5694 struct cmd_set_burst_tx_retry_result { 5695 cmdline_fixed_string_t set; 5696 cmdline_fixed_string_t burst; 5697 cmdline_fixed_string_t tx; 5698 cmdline_fixed_string_t delay; 5699 uint32_t time; 5700 cmdline_fixed_string_t retry; 5701 uint32_t retry_num; 5702 }; 5703 5704 static void cmd_set_burst_tx_retry_parsed(void *parsed_result, 5705 __rte_unused struct cmdline *cl, 5706 __rte_unused void *data) 5707 { 5708 struct cmd_set_burst_tx_retry_result *res = parsed_result; 5709 5710 if (!strcmp(res->set, "set") && !strcmp(res->burst, "burst") 5711 && !strcmp(res->tx, "tx")) { 5712 if (!strcmp(res->delay, "delay")) 5713 burst_tx_delay_time = res->time; 5714 if (!strcmp(res->retry, "retry")) 5715 burst_tx_retry_num = res->retry_num; 5716 } 5717 5718 } 5719 5720 static cmdline_parse_token_string_t cmd_set_burst_tx_retry_set = 5721 TOKEN_STRING_INITIALIZER(struct cmd_set_burst_tx_retry_result, set, "set"); 5722 static cmdline_parse_token_string_t cmd_set_burst_tx_retry_burst = 5723 TOKEN_STRING_INITIALIZER(struct cmd_set_burst_tx_retry_result, burst, 5724 "burst"); 5725 static cmdline_parse_token_string_t cmd_set_burst_tx_retry_tx = 5726 TOKEN_STRING_INITIALIZER(struct cmd_set_burst_tx_retry_result, tx, "tx"); 5727 static cmdline_parse_token_string_t cmd_set_burst_tx_retry_delay = 5728 TOKEN_STRING_INITIALIZER(struct cmd_set_burst_tx_retry_result, delay, "delay"); 5729 static cmdline_parse_token_num_t cmd_set_burst_tx_retry_time = 5730 TOKEN_NUM_INITIALIZER(struct cmd_set_burst_tx_retry_result, time, 5731 RTE_UINT32); 5732 static cmdline_parse_token_string_t cmd_set_burst_tx_retry_retry = 5733 TOKEN_STRING_INITIALIZER(struct cmd_set_burst_tx_retry_result, retry, "retry"); 5734 static cmdline_parse_token_num_t cmd_set_burst_tx_retry_retry_num = 5735 TOKEN_NUM_INITIALIZER(struct cmd_set_burst_tx_retry_result, retry_num, 5736 RTE_UINT32); 5737 5738 static cmdline_parse_inst_t cmd_set_burst_tx_retry = { 5739 .f = cmd_set_burst_tx_retry_parsed, 5740 .help_str = "set burst tx delay <delay_usec> retry <num_retry>", 5741 .tokens = { 5742 (void *)&cmd_set_burst_tx_retry_set, 5743 (void *)&cmd_set_burst_tx_retry_burst, 5744 (void *)&cmd_set_burst_tx_retry_tx, 5745 (void *)&cmd_set_burst_tx_retry_delay, 5746 (void *)&cmd_set_burst_tx_retry_time, 5747 (void *)&cmd_set_burst_tx_retry_retry, 5748 (void *)&cmd_set_burst_tx_retry_retry_num, 5749 NULL, 5750 }, 5751 }; 5752 5753 /* *** SET PROMISC MODE *** */ 5754 struct cmd_set_promisc_mode_result { 5755 cmdline_fixed_string_t set; 5756 cmdline_fixed_string_t promisc; 5757 cmdline_fixed_string_t port_all; /* valid if "allports" argument == 1 */ 5758 uint16_t port_num; /* valid if "allports" argument == 0 */ 5759 cmdline_fixed_string_t mode; 5760 }; 5761 5762 static void cmd_set_promisc_mode_parsed(void *parsed_result, 5763 __rte_unused struct cmdline *cl, 5764 void *allports) 5765 { 5766 struct cmd_set_promisc_mode_result *res = parsed_result; 5767 int enable; 5768 portid_t i; 5769 5770 if (!strcmp(res->mode, "on")) 5771 enable = 1; 5772 else 5773 enable = 0; 5774 5775 /* all ports */ 5776 if (allports) { 5777 RTE_ETH_FOREACH_DEV(i) 5778 eth_set_promisc_mode(i, enable); 5779 } else { 5780 eth_set_promisc_mode(res->port_num, enable); 5781 } 5782 } 5783 5784 static cmdline_parse_token_string_t cmd_setpromisc_set = 5785 TOKEN_STRING_INITIALIZER(struct cmd_set_promisc_mode_result, set, "set"); 5786 static cmdline_parse_token_string_t cmd_setpromisc_promisc = 5787 TOKEN_STRING_INITIALIZER(struct cmd_set_promisc_mode_result, promisc, 5788 "promisc"); 5789 static cmdline_parse_token_string_t cmd_setpromisc_portall = 5790 TOKEN_STRING_INITIALIZER(struct cmd_set_promisc_mode_result, port_all, 5791 "all"); 5792 static cmdline_parse_token_num_t cmd_setpromisc_portnum = 5793 TOKEN_NUM_INITIALIZER(struct cmd_set_promisc_mode_result, port_num, 5794 RTE_UINT16); 5795 static cmdline_parse_token_string_t cmd_setpromisc_mode = 5796 TOKEN_STRING_INITIALIZER(struct cmd_set_promisc_mode_result, mode, 5797 "on#off"); 5798 5799 static cmdline_parse_inst_t cmd_set_promisc_mode_all = { 5800 .f = cmd_set_promisc_mode_parsed, 5801 .data = (void *)1, 5802 .help_str = "set promisc all on|off: Set promisc mode for all ports", 5803 .tokens = { 5804 (void *)&cmd_setpromisc_set, 5805 (void *)&cmd_setpromisc_promisc, 5806 (void *)&cmd_setpromisc_portall, 5807 (void *)&cmd_setpromisc_mode, 5808 NULL, 5809 }, 5810 }; 5811 5812 static cmdline_parse_inst_t cmd_set_promisc_mode_one = { 5813 .f = cmd_set_promisc_mode_parsed, 5814 .data = (void *)0, 5815 .help_str = "set promisc <port_id> on|off: Set promisc mode on port_id", 5816 .tokens = { 5817 (void *)&cmd_setpromisc_set, 5818 (void *)&cmd_setpromisc_promisc, 5819 (void *)&cmd_setpromisc_portnum, 5820 (void *)&cmd_setpromisc_mode, 5821 NULL, 5822 }, 5823 }; 5824 5825 /* *** SET ALLMULTI MODE *** */ 5826 struct cmd_set_allmulti_mode_result { 5827 cmdline_fixed_string_t set; 5828 cmdline_fixed_string_t allmulti; 5829 cmdline_fixed_string_t port_all; /* valid if "allports" argument == 1 */ 5830 uint16_t port_num; /* valid if "allports" argument == 0 */ 5831 cmdline_fixed_string_t mode; 5832 }; 5833 5834 static void cmd_set_allmulti_mode_parsed(void *parsed_result, 5835 __rte_unused struct cmdline *cl, 5836 void *allports) 5837 { 5838 struct cmd_set_allmulti_mode_result *res = parsed_result; 5839 int enable; 5840 portid_t i; 5841 5842 if (!strcmp(res->mode, "on")) 5843 enable = 1; 5844 else 5845 enable = 0; 5846 5847 /* all ports */ 5848 if (allports) { 5849 RTE_ETH_FOREACH_DEV(i) { 5850 eth_set_allmulticast_mode(i, enable); 5851 } 5852 } 5853 else { 5854 eth_set_allmulticast_mode(res->port_num, enable); 5855 } 5856 } 5857 5858 static cmdline_parse_token_string_t cmd_setallmulti_set = 5859 TOKEN_STRING_INITIALIZER(struct cmd_set_allmulti_mode_result, set, "set"); 5860 static cmdline_parse_token_string_t cmd_setallmulti_allmulti = 5861 TOKEN_STRING_INITIALIZER(struct cmd_set_allmulti_mode_result, allmulti, 5862 "allmulti"); 5863 static cmdline_parse_token_string_t cmd_setallmulti_portall = 5864 TOKEN_STRING_INITIALIZER(struct cmd_set_allmulti_mode_result, port_all, 5865 "all"); 5866 static cmdline_parse_token_num_t cmd_setallmulti_portnum = 5867 TOKEN_NUM_INITIALIZER(struct cmd_set_allmulti_mode_result, port_num, 5868 RTE_UINT16); 5869 static cmdline_parse_token_string_t cmd_setallmulti_mode = 5870 TOKEN_STRING_INITIALIZER(struct cmd_set_allmulti_mode_result, mode, 5871 "on#off"); 5872 5873 static cmdline_parse_inst_t cmd_set_allmulti_mode_all = { 5874 .f = cmd_set_allmulti_mode_parsed, 5875 .data = (void *)1, 5876 .help_str = "set allmulti all on|off: Set allmulti mode for all ports", 5877 .tokens = { 5878 (void *)&cmd_setallmulti_set, 5879 (void *)&cmd_setallmulti_allmulti, 5880 (void *)&cmd_setallmulti_portall, 5881 (void *)&cmd_setallmulti_mode, 5882 NULL, 5883 }, 5884 }; 5885 5886 static cmdline_parse_inst_t cmd_set_allmulti_mode_one = { 5887 .f = cmd_set_allmulti_mode_parsed, 5888 .data = (void *)0, 5889 .help_str = "set allmulti <port_id> on|off: " 5890 "Set allmulti mode on port_id", 5891 .tokens = { 5892 (void *)&cmd_setallmulti_set, 5893 (void *)&cmd_setallmulti_allmulti, 5894 (void *)&cmd_setallmulti_portnum, 5895 (void *)&cmd_setallmulti_mode, 5896 NULL, 5897 }, 5898 }; 5899 5900 /* *** GET CURRENT ETHERNET LINK FLOW CONTROL *** */ 5901 struct cmd_link_flow_ctrl_show { 5902 cmdline_fixed_string_t show; 5903 cmdline_fixed_string_t port; 5904 portid_t port_id; 5905 cmdline_fixed_string_t flow_ctrl; 5906 }; 5907 5908 static cmdline_parse_token_string_t cmd_lfc_show_show = 5909 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_show, 5910 show, "show"); 5911 static cmdline_parse_token_string_t cmd_lfc_show_port = 5912 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_show, 5913 port, "port"); 5914 static cmdline_parse_token_num_t cmd_lfc_show_portid = 5915 TOKEN_NUM_INITIALIZER(struct cmd_link_flow_ctrl_show, 5916 port_id, RTE_UINT16); 5917 static cmdline_parse_token_string_t cmd_lfc_show_flow_ctrl = 5918 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_show, 5919 flow_ctrl, "flow_ctrl"); 5920 5921 static void 5922 cmd_link_flow_ctrl_show_parsed(void *parsed_result, 5923 __rte_unused struct cmdline *cl, 5924 __rte_unused void *data) 5925 { 5926 struct cmd_link_flow_ctrl_show *res = parsed_result; 5927 static const char *info_border = "*********************"; 5928 struct rte_eth_fc_conf fc_conf; 5929 bool rx_fc_en = false; 5930 bool tx_fc_en = false; 5931 int ret; 5932 5933 ret = rte_eth_dev_flow_ctrl_get(res->port_id, &fc_conf); 5934 if (ret != 0) { 5935 fprintf(stderr, 5936 "Failed to get current flow ctrl information: err = %d\n", 5937 ret); 5938 return; 5939 } 5940 5941 if (fc_conf.mode == RTE_ETH_FC_RX_PAUSE || fc_conf.mode == RTE_ETH_FC_FULL) 5942 rx_fc_en = true; 5943 if (fc_conf.mode == RTE_ETH_FC_TX_PAUSE || fc_conf.mode == RTE_ETH_FC_FULL) 5944 tx_fc_en = true; 5945 5946 printf("\n%s Flow control infos for port %-2d %s\n", 5947 info_border, res->port_id, info_border); 5948 printf("FC mode:\n"); 5949 printf(" Rx pause: %s\n", rx_fc_en ? "on" : "off"); 5950 printf(" Tx pause: %s\n", tx_fc_en ? "on" : "off"); 5951 printf("Autoneg: %s\n", fc_conf.autoneg ? "on" : "off"); 5952 printf("Pause time: 0x%x\n", fc_conf.pause_time); 5953 printf("High waterline: 0x%x\n", fc_conf.high_water); 5954 printf("Low waterline: 0x%x\n", fc_conf.low_water); 5955 printf("Send XON: %s\n", fc_conf.send_xon ? "on" : "off"); 5956 printf("Forward MAC control frames: %s\n", 5957 fc_conf.mac_ctrl_frame_fwd ? "on" : "off"); 5958 printf("\n%s************** End ***********%s\n", 5959 info_border, info_border); 5960 } 5961 5962 static cmdline_parse_inst_t cmd_link_flow_control_show = { 5963 .f = cmd_link_flow_ctrl_show_parsed, 5964 .data = NULL, 5965 .help_str = "show port <port_id> flow_ctrl", 5966 .tokens = { 5967 (void *)&cmd_lfc_show_show, 5968 (void *)&cmd_lfc_show_port, 5969 (void *)&cmd_lfc_show_portid, 5970 (void *)&cmd_lfc_show_flow_ctrl, 5971 NULL, 5972 }, 5973 }; 5974 5975 /* *** SETUP ETHERNET LINK FLOW CONTROL *** */ 5976 struct cmd_link_flow_ctrl_set_result { 5977 cmdline_fixed_string_t set; 5978 cmdline_fixed_string_t flow_ctrl; 5979 cmdline_fixed_string_t rx; 5980 cmdline_fixed_string_t rx_lfc_mode; 5981 cmdline_fixed_string_t tx; 5982 cmdline_fixed_string_t tx_lfc_mode; 5983 cmdline_fixed_string_t mac_ctrl_frame_fwd; 5984 cmdline_fixed_string_t mac_ctrl_frame_fwd_mode; 5985 cmdline_fixed_string_t autoneg_str; 5986 cmdline_fixed_string_t autoneg; 5987 cmdline_fixed_string_t hw_str; 5988 uint32_t high_water; 5989 cmdline_fixed_string_t lw_str; 5990 uint32_t low_water; 5991 cmdline_fixed_string_t pt_str; 5992 uint16_t pause_time; 5993 cmdline_fixed_string_t xon_str; 5994 uint16_t send_xon; 5995 portid_t port_id; 5996 }; 5997 5998 static cmdline_parse_token_string_t cmd_lfc_set_set = 5999 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result, 6000 set, "set"); 6001 static cmdline_parse_token_string_t cmd_lfc_set_flow_ctrl = 6002 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result, 6003 flow_ctrl, "flow_ctrl"); 6004 static cmdline_parse_token_string_t cmd_lfc_set_rx = 6005 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result, 6006 rx, "rx"); 6007 static cmdline_parse_token_string_t cmd_lfc_set_rx_mode = 6008 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result, 6009 rx_lfc_mode, "on#off"); 6010 static cmdline_parse_token_string_t cmd_lfc_set_tx = 6011 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result, 6012 tx, "tx"); 6013 static cmdline_parse_token_string_t cmd_lfc_set_tx_mode = 6014 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result, 6015 tx_lfc_mode, "on#off"); 6016 static cmdline_parse_token_string_t cmd_lfc_set_high_water_str = 6017 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result, 6018 hw_str, "high_water"); 6019 static cmdline_parse_token_num_t cmd_lfc_set_high_water = 6020 TOKEN_NUM_INITIALIZER(struct cmd_link_flow_ctrl_set_result, 6021 high_water, RTE_UINT32); 6022 static cmdline_parse_token_string_t cmd_lfc_set_low_water_str = 6023 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result, 6024 lw_str, "low_water"); 6025 static cmdline_parse_token_num_t cmd_lfc_set_low_water = 6026 TOKEN_NUM_INITIALIZER(struct cmd_link_flow_ctrl_set_result, 6027 low_water, RTE_UINT32); 6028 static cmdline_parse_token_string_t cmd_lfc_set_pause_time_str = 6029 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result, 6030 pt_str, "pause_time"); 6031 static cmdline_parse_token_num_t cmd_lfc_set_pause_time = 6032 TOKEN_NUM_INITIALIZER(struct cmd_link_flow_ctrl_set_result, 6033 pause_time, RTE_UINT16); 6034 static cmdline_parse_token_string_t cmd_lfc_set_send_xon_str = 6035 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result, 6036 xon_str, "send_xon"); 6037 static cmdline_parse_token_num_t cmd_lfc_set_send_xon = 6038 TOKEN_NUM_INITIALIZER(struct cmd_link_flow_ctrl_set_result, 6039 send_xon, RTE_UINT16); 6040 static cmdline_parse_token_string_t cmd_lfc_set_mac_ctrl_frame_fwd_mode = 6041 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result, 6042 mac_ctrl_frame_fwd, "mac_ctrl_frame_fwd"); 6043 static cmdline_parse_token_string_t cmd_lfc_set_mac_ctrl_frame_fwd = 6044 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result, 6045 mac_ctrl_frame_fwd_mode, "on#off"); 6046 static cmdline_parse_token_string_t cmd_lfc_set_autoneg_str = 6047 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result, 6048 autoneg_str, "autoneg"); 6049 static cmdline_parse_token_string_t cmd_lfc_set_autoneg = 6050 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result, 6051 autoneg, "on#off"); 6052 static cmdline_parse_token_num_t cmd_lfc_set_portid = 6053 TOKEN_NUM_INITIALIZER(struct cmd_link_flow_ctrl_set_result, 6054 port_id, RTE_UINT16); 6055 6056 /* forward declaration */ 6057 static void 6058 cmd_link_flow_ctrl_set_parsed(void *parsed_result, struct cmdline *cl, 6059 void *data); 6060 6061 static cmdline_parse_inst_t cmd_link_flow_control_set = { 6062 .f = cmd_link_flow_ctrl_set_parsed, 6063 .data = NULL, 6064 .help_str = "set flow_ctrl rx on|off tx on|off <high_water> " 6065 "<low_water> <pause_time> <send_xon> mac_ctrl_frame_fwd on|off " 6066 "autoneg on|off <port_id>: Configure the Ethernet flow control", 6067 .tokens = { 6068 (void *)&cmd_lfc_set_set, 6069 (void *)&cmd_lfc_set_flow_ctrl, 6070 (void *)&cmd_lfc_set_rx, 6071 (void *)&cmd_lfc_set_rx_mode, 6072 (void *)&cmd_lfc_set_tx, 6073 (void *)&cmd_lfc_set_tx_mode, 6074 (void *)&cmd_lfc_set_high_water, 6075 (void *)&cmd_lfc_set_low_water, 6076 (void *)&cmd_lfc_set_pause_time, 6077 (void *)&cmd_lfc_set_send_xon, 6078 (void *)&cmd_lfc_set_mac_ctrl_frame_fwd_mode, 6079 (void *)&cmd_lfc_set_mac_ctrl_frame_fwd, 6080 (void *)&cmd_lfc_set_autoneg_str, 6081 (void *)&cmd_lfc_set_autoneg, 6082 (void *)&cmd_lfc_set_portid, 6083 NULL, 6084 }, 6085 }; 6086 6087 static cmdline_parse_inst_t cmd_link_flow_control_set_rx = { 6088 .f = cmd_link_flow_ctrl_set_parsed, 6089 .data = (void *)&cmd_link_flow_control_set_rx, 6090 .help_str = "set flow_ctrl rx on|off <port_id>: " 6091 "Change rx flow control parameter", 6092 .tokens = { 6093 (void *)&cmd_lfc_set_set, 6094 (void *)&cmd_lfc_set_flow_ctrl, 6095 (void *)&cmd_lfc_set_rx, 6096 (void *)&cmd_lfc_set_rx_mode, 6097 (void *)&cmd_lfc_set_portid, 6098 NULL, 6099 }, 6100 }; 6101 6102 static cmdline_parse_inst_t cmd_link_flow_control_set_tx = { 6103 .f = cmd_link_flow_ctrl_set_parsed, 6104 .data = (void *)&cmd_link_flow_control_set_tx, 6105 .help_str = "set flow_ctrl tx on|off <port_id>: " 6106 "Change tx flow control parameter", 6107 .tokens = { 6108 (void *)&cmd_lfc_set_set, 6109 (void *)&cmd_lfc_set_flow_ctrl, 6110 (void *)&cmd_lfc_set_tx, 6111 (void *)&cmd_lfc_set_tx_mode, 6112 (void *)&cmd_lfc_set_portid, 6113 NULL, 6114 }, 6115 }; 6116 6117 static cmdline_parse_inst_t cmd_link_flow_control_set_hw = { 6118 .f = cmd_link_flow_ctrl_set_parsed, 6119 .data = (void *)&cmd_link_flow_control_set_hw, 6120 .help_str = "set flow_ctrl high_water <value> <port_id>: " 6121 "Change high water flow control parameter", 6122 .tokens = { 6123 (void *)&cmd_lfc_set_set, 6124 (void *)&cmd_lfc_set_flow_ctrl, 6125 (void *)&cmd_lfc_set_high_water_str, 6126 (void *)&cmd_lfc_set_high_water, 6127 (void *)&cmd_lfc_set_portid, 6128 NULL, 6129 }, 6130 }; 6131 6132 static cmdline_parse_inst_t cmd_link_flow_control_set_lw = { 6133 .f = cmd_link_flow_ctrl_set_parsed, 6134 .data = (void *)&cmd_link_flow_control_set_lw, 6135 .help_str = "set flow_ctrl low_water <value> <port_id>: " 6136 "Change low water flow control parameter", 6137 .tokens = { 6138 (void *)&cmd_lfc_set_set, 6139 (void *)&cmd_lfc_set_flow_ctrl, 6140 (void *)&cmd_lfc_set_low_water_str, 6141 (void *)&cmd_lfc_set_low_water, 6142 (void *)&cmd_lfc_set_portid, 6143 NULL, 6144 }, 6145 }; 6146 6147 static cmdline_parse_inst_t cmd_link_flow_control_set_pt = { 6148 .f = cmd_link_flow_ctrl_set_parsed, 6149 .data = (void *)&cmd_link_flow_control_set_pt, 6150 .help_str = "set flow_ctrl pause_time <value> <port_id>: " 6151 "Change pause time flow control parameter", 6152 .tokens = { 6153 (void *)&cmd_lfc_set_set, 6154 (void *)&cmd_lfc_set_flow_ctrl, 6155 (void *)&cmd_lfc_set_pause_time_str, 6156 (void *)&cmd_lfc_set_pause_time, 6157 (void *)&cmd_lfc_set_portid, 6158 NULL, 6159 }, 6160 }; 6161 6162 static cmdline_parse_inst_t cmd_link_flow_control_set_xon = { 6163 .f = cmd_link_flow_ctrl_set_parsed, 6164 .data = (void *)&cmd_link_flow_control_set_xon, 6165 .help_str = "set flow_ctrl send_xon <value> <port_id>: " 6166 "Change send_xon flow control parameter", 6167 .tokens = { 6168 (void *)&cmd_lfc_set_set, 6169 (void *)&cmd_lfc_set_flow_ctrl, 6170 (void *)&cmd_lfc_set_send_xon_str, 6171 (void *)&cmd_lfc_set_send_xon, 6172 (void *)&cmd_lfc_set_portid, 6173 NULL, 6174 }, 6175 }; 6176 6177 static cmdline_parse_inst_t cmd_link_flow_control_set_macfwd = { 6178 .f = cmd_link_flow_ctrl_set_parsed, 6179 .data = (void *)&cmd_link_flow_control_set_macfwd, 6180 .help_str = "set flow_ctrl mac_ctrl_frame_fwd on|off <port_id>: " 6181 "Change mac ctrl fwd flow control parameter", 6182 .tokens = { 6183 (void *)&cmd_lfc_set_set, 6184 (void *)&cmd_lfc_set_flow_ctrl, 6185 (void *)&cmd_lfc_set_mac_ctrl_frame_fwd_mode, 6186 (void *)&cmd_lfc_set_mac_ctrl_frame_fwd, 6187 (void *)&cmd_lfc_set_portid, 6188 NULL, 6189 }, 6190 }; 6191 6192 static cmdline_parse_inst_t cmd_link_flow_control_set_autoneg = { 6193 .f = cmd_link_flow_ctrl_set_parsed, 6194 .data = (void *)&cmd_link_flow_control_set_autoneg, 6195 .help_str = "set flow_ctrl autoneg on|off <port_id>: " 6196 "Change autoneg flow control parameter", 6197 .tokens = { 6198 (void *)&cmd_lfc_set_set, 6199 (void *)&cmd_lfc_set_flow_ctrl, 6200 (void *)&cmd_lfc_set_autoneg_str, 6201 (void *)&cmd_lfc_set_autoneg, 6202 (void *)&cmd_lfc_set_portid, 6203 NULL, 6204 }, 6205 }; 6206 6207 static void 6208 cmd_link_flow_ctrl_set_parsed(void *parsed_result, 6209 __rte_unused struct cmdline *cl, 6210 void *data) 6211 { 6212 struct cmd_link_flow_ctrl_set_result *res = parsed_result; 6213 cmdline_parse_inst_t *cmd = data; 6214 struct rte_eth_fc_conf fc_conf; 6215 int rx_fc_en = 0; 6216 int tx_fc_en = 0; 6217 int ret; 6218 6219 /* 6220 * Rx on/off, flow control is enabled/disabled on RX side. This can indicate 6221 * the RTE_ETH_FC_TX_PAUSE, Transmit pause frame at the Rx side. 6222 * Tx on/off, flow control is enabled/disabled on TX side. This can indicate 6223 * the RTE_ETH_FC_RX_PAUSE, Respond to the pause frame at the Tx side. 6224 */ 6225 static enum rte_eth_fc_mode rx_tx_onoff_2_lfc_mode[2][2] = { 6226 {RTE_ETH_FC_NONE, RTE_ETH_FC_TX_PAUSE}, {RTE_ETH_FC_RX_PAUSE, RTE_ETH_FC_FULL} 6227 }; 6228 6229 /* Partial command line, retrieve current configuration */ 6230 if (cmd) { 6231 ret = rte_eth_dev_flow_ctrl_get(res->port_id, &fc_conf); 6232 if (ret != 0) { 6233 fprintf(stderr, 6234 "cannot get current flow ctrl parameters, return code = %d\n", 6235 ret); 6236 return; 6237 } 6238 6239 if ((fc_conf.mode == RTE_ETH_FC_RX_PAUSE) || 6240 (fc_conf.mode == RTE_ETH_FC_FULL)) 6241 rx_fc_en = 1; 6242 if ((fc_conf.mode == RTE_ETH_FC_TX_PAUSE) || 6243 (fc_conf.mode == RTE_ETH_FC_FULL)) 6244 tx_fc_en = 1; 6245 } 6246 6247 if (!cmd || cmd == &cmd_link_flow_control_set_rx) 6248 rx_fc_en = (!strcmp(res->rx_lfc_mode, "on")) ? 1 : 0; 6249 6250 if (!cmd || cmd == &cmd_link_flow_control_set_tx) 6251 tx_fc_en = (!strcmp(res->tx_lfc_mode, "on")) ? 1 : 0; 6252 6253 fc_conf.mode = rx_tx_onoff_2_lfc_mode[rx_fc_en][tx_fc_en]; 6254 6255 if (!cmd || cmd == &cmd_link_flow_control_set_hw) 6256 fc_conf.high_water = res->high_water; 6257 6258 if (!cmd || cmd == &cmd_link_flow_control_set_lw) 6259 fc_conf.low_water = res->low_water; 6260 6261 if (!cmd || cmd == &cmd_link_flow_control_set_pt) 6262 fc_conf.pause_time = res->pause_time; 6263 6264 if (!cmd || cmd == &cmd_link_flow_control_set_xon) 6265 fc_conf.send_xon = res->send_xon; 6266 6267 if (!cmd || cmd == &cmd_link_flow_control_set_macfwd) { 6268 if (!strcmp(res->mac_ctrl_frame_fwd_mode, "on")) 6269 fc_conf.mac_ctrl_frame_fwd = 1; 6270 else 6271 fc_conf.mac_ctrl_frame_fwd = 0; 6272 } 6273 6274 if (!cmd || cmd == &cmd_link_flow_control_set_autoneg) 6275 fc_conf.autoneg = (!strcmp(res->autoneg, "on")) ? 1 : 0; 6276 6277 ret = rte_eth_dev_flow_ctrl_set(res->port_id, &fc_conf); 6278 if (ret != 0) 6279 fprintf(stderr, 6280 "bad flow control parameter, return code = %d\n", 6281 ret); 6282 } 6283 6284 /* *** SETUP ETHERNET PRIORITY FLOW CONTROL *** */ 6285 struct cmd_priority_flow_ctrl_set_result { 6286 cmdline_fixed_string_t set; 6287 cmdline_fixed_string_t pfc_ctrl; 6288 cmdline_fixed_string_t rx; 6289 cmdline_fixed_string_t rx_pfc_mode; 6290 cmdline_fixed_string_t tx; 6291 cmdline_fixed_string_t tx_pfc_mode; 6292 uint32_t high_water; 6293 uint32_t low_water; 6294 uint16_t pause_time; 6295 uint8_t priority; 6296 portid_t port_id; 6297 }; 6298 6299 static void 6300 cmd_priority_flow_ctrl_set_parsed(void *parsed_result, 6301 __rte_unused struct cmdline *cl, 6302 __rte_unused void *data) 6303 { 6304 struct cmd_priority_flow_ctrl_set_result *res = parsed_result; 6305 struct rte_eth_pfc_conf pfc_conf; 6306 int rx_fc_enable, tx_fc_enable; 6307 int ret; 6308 6309 /* 6310 * Rx on/off, flow control is enabled/disabled on RX side. This can indicate 6311 * the RTE_ETH_FC_TX_PAUSE, Transmit pause frame at the Rx side. 6312 * Tx on/off, flow control is enabled/disabled on TX side. This can indicate 6313 * the RTE_ETH_FC_RX_PAUSE, Respond to the pause frame at the Tx side. 6314 */ 6315 static enum rte_eth_fc_mode rx_tx_onoff_2_pfc_mode[2][2] = { 6316 {RTE_ETH_FC_NONE, RTE_ETH_FC_TX_PAUSE}, {RTE_ETH_FC_RX_PAUSE, RTE_ETH_FC_FULL} 6317 }; 6318 6319 memset(&pfc_conf, 0, sizeof(struct rte_eth_pfc_conf)); 6320 rx_fc_enable = (!strncmp(res->rx_pfc_mode, "on",2)) ? 1 : 0; 6321 tx_fc_enable = (!strncmp(res->tx_pfc_mode, "on",2)) ? 1 : 0; 6322 pfc_conf.fc.mode = rx_tx_onoff_2_pfc_mode[rx_fc_enable][tx_fc_enable]; 6323 pfc_conf.fc.high_water = res->high_water; 6324 pfc_conf.fc.low_water = res->low_water; 6325 pfc_conf.fc.pause_time = res->pause_time; 6326 pfc_conf.priority = res->priority; 6327 6328 ret = rte_eth_dev_priority_flow_ctrl_set(res->port_id, &pfc_conf); 6329 if (ret != 0) 6330 fprintf(stderr, 6331 "bad priority flow control parameter, return code = %d\n", 6332 ret); 6333 } 6334 6335 static cmdline_parse_token_string_t cmd_pfc_set_set = 6336 TOKEN_STRING_INITIALIZER(struct cmd_priority_flow_ctrl_set_result, 6337 set, "set"); 6338 static cmdline_parse_token_string_t cmd_pfc_set_flow_ctrl = 6339 TOKEN_STRING_INITIALIZER(struct cmd_priority_flow_ctrl_set_result, 6340 pfc_ctrl, "pfc_ctrl"); 6341 static cmdline_parse_token_string_t cmd_pfc_set_rx = 6342 TOKEN_STRING_INITIALIZER(struct cmd_priority_flow_ctrl_set_result, 6343 rx, "rx"); 6344 static cmdline_parse_token_string_t cmd_pfc_set_rx_mode = 6345 TOKEN_STRING_INITIALIZER(struct cmd_priority_flow_ctrl_set_result, 6346 rx_pfc_mode, "on#off"); 6347 static cmdline_parse_token_string_t cmd_pfc_set_tx = 6348 TOKEN_STRING_INITIALIZER(struct cmd_priority_flow_ctrl_set_result, 6349 tx, "tx"); 6350 static cmdline_parse_token_string_t cmd_pfc_set_tx_mode = 6351 TOKEN_STRING_INITIALIZER(struct cmd_priority_flow_ctrl_set_result, 6352 tx_pfc_mode, "on#off"); 6353 static cmdline_parse_token_num_t cmd_pfc_set_high_water = 6354 TOKEN_NUM_INITIALIZER(struct cmd_priority_flow_ctrl_set_result, 6355 high_water, RTE_UINT32); 6356 static cmdline_parse_token_num_t cmd_pfc_set_low_water = 6357 TOKEN_NUM_INITIALIZER(struct cmd_priority_flow_ctrl_set_result, 6358 low_water, RTE_UINT32); 6359 static cmdline_parse_token_num_t cmd_pfc_set_pause_time = 6360 TOKEN_NUM_INITIALIZER(struct cmd_priority_flow_ctrl_set_result, 6361 pause_time, RTE_UINT16); 6362 static cmdline_parse_token_num_t cmd_pfc_set_priority = 6363 TOKEN_NUM_INITIALIZER(struct cmd_priority_flow_ctrl_set_result, 6364 priority, RTE_UINT8); 6365 static cmdline_parse_token_num_t cmd_pfc_set_portid = 6366 TOKEN_NUM_INITIALIZER(struct cmd_priority_flow_ctrl_set_result, 6367 port_id, RTE_UINT16); 6368 6369 static cmdline_parse_inst_t cmd_priority_flow_control_set = { 6370 .f = cmd_priority_flow_ctrl_set_parsed, 6371 .data = NULL, 6372 .help_str = "set pfc_ctrl rx on|off tx on|off <high_water> <low_water> " 6373 "<pause_time> <priority> <port_id>: " 6374 "Configure the Ethernet priority flow control", 6375 .tokens = { 6376 (void *)&cmd_pfc_set_set, 6377 (void *)&cmd_pfc_set_flow_ctrl, 6378 (void *)&cmd_pfc_set_rx, 6379 (void *)&cmd_pfc_set_rx_mode, 6380 (void *)&cmd_pfc_set_tx, 6381 (void *)&cmd_pfc_set_tx_mode, 6382 (void *)&cmd_pfc_set_high_water, 6383 (void *)&cmd_pfc_set_low_water, 6384 (void *)&cmd_pfc_set_pause_time, 6385 (void *)&cmd_pfc_set_priority, 6386 (void *)&cmd_pfc_set_portid, 6387 NULL, 6388 }, 6389 }; 6390 6391 struct cmd_queue_priority_flow_ctrl_set_result { 6392 cmdline_fixed_string_t set; 6393 cmdline_fixed_string_t pfc_queue_ctrl; 6394 portid_t port_id; 6395 cmdline_fixed_string_t rx; 6396 cmdline_fixed_string_t rx_pfc_mode; 6397 uint16_t tx_qid; 6398 uint8_t tx_tc; 6399 cmdline_fixed_string_t tx; 6400 cmdline_fixed_string_t tx_pfc_mode; 6401 uint16_t rx_qid; 6402 uint8_t rx_tc; 6403 uint16_t pause_time; 6404 }; 6405 6406 static void 6407 cmd_queue_priority_flow_ctrl_set_parsed(void *parsed_result, 6408 __rte_unused struct cmdline *cl, 6409 __rte_unused void *data) 6410 { 6411 struct cmd_queue_priority_flow_ctrl_set_result *res = parsed_result; 6412 struct rte_eth_pfc_queue_conf pfc_queue_conf; 6413 int rx_fc_enable, tx_fc_enable; 6414 int ret; 6415 6416 /* 6417 * Rx on/off, flow control is enabled/disabled on RX side. This can 6418 * indicate the RTE_ETH_FC_TX_PAUSE, Transmit pause frame at the Rx 6419 * side. Tx on/off, flow control is enabled/disabled on TX side. This 6420 * can indicate the RTE_ETH_FC_RX_PAUSE, Respond to the pause frame at 6421 * the Tx side. 6422 */ 6423 static enum rte_eth_fc_mode rx_tx_onoff_2_mode[2][2] = { 6424 {RTE_ETH_FC_NONE, RTE_ETH_FC_TX_PAUSE}, 6425 {RTE_ETH_FC_RX_PAUSE, RTE_ETH_FC_FULL} 6426 }; 6427 6428 memset(&pfc_queue_conf, 0, sizeof(struct rte_eth_pfc_queue_conf)); 6429 rx_fc_enable = (!strncmp(res->rx_pfc_mode, "on", 2)) ? 1 : 0; 6430 tx_fc_enable = (!strncmp(res->tx_pfc_mode, "on", 2)) ? 1 : 0; 6431 pfc_queue_conf.mode = rx_tx_onoff_2_mode[rx_fc_enable][tx_fc_enable]; 6432 pfc_queue_conf.rx_pause.tc = res->tx_tc; 6433 pfc_queue_conf.rx_pause.tx_qid = res->tx_qid; 6434 pfc_queue_conf.tx_pause.tc = res->rx_tc; 6435 pfc_queue_conf.tx_pause.rx_qid = res->rx_qid; 6436 pfc_queue_conf.tx_pause.pause_time = res->pause_time; 6437 6438 ret = rte_eth_dev_priority_flow_ctrl_queue_configure(res->port_id, 6439 &pfc_queue_conf); 6440 if (ret != 0) { 6441 fprintf(stderr, 6442 "bad queue priority flow control parameter, rc = %d\n", 6443 ret); 6444 } 6445 } 6446 6447 static cmdline_parse_token_string_t cmd_q_pfc_set_set = 6448 TOKEN_STRING_INITIALIZER(struct cmd_queue_priority_flow_ctrl_set_result, 6449 set, "set"); 6450 static cmdline_parse_token_string_t cmd_q_pfc_set_flow_ctrl = 6451 TOKEN_STRING_INITIALIZER(struct cmd_queue_priority_flow_ctrl_set_result, 6452 pfc_queue_ctrl, "pfc_queue_ctrl"); 6453 static cmdline_parse_token_num_t cmd_q_pfc_set_portid = 6454 TOKEN_NUM_INITIALIZER(struct cmd_queue_priority_flow_ctrl_set_result, 6455 port_id, RTE_UINT16); 6456 static cmdline_parse_token_string_t cmd_q_pfc_set_rx = 6457 TOKEN_STRING_INITIALIZER(struct cmd_queue_priority_flow_ctrl_set_result, 6458 rx, "rx"); 6459 static cmdline_parse_token_string_t cmd_q_pfc_set_rx_mode = 6460 TOKEN_STRING_INITIALIZER(struct cmd_queue_priority_flow_ctrl_set_result, 6461 rx_pfc_mode, "on#off"); 6462 static cmdline_parse_token_num_t cmd_q_pfc_set_tx_qid = 6463 TOKEN_NUM_INITIALIZER(struct cmd_queue_priority_flow_ctrl_set_result, 6464 tx_qid, RTE_UINT16); 6465 static cmdline_parse_token_num_t cmd_q_pfc_set_tx_tc = 6466 TOKEN_NUM_INITIALIZER(struct cmd_queue_priority_flow_ctrl_set_result, 6467 tx_tc, RTE_UINT8); 6468 static cmdline_parse_token_string_t cmd_q_pfc_set_tx = 6469 TOKEN_STRING_INITIALIZER(struct cmd_queue_priority_flow_ctrl_set_result, 6470 tx, "tx"); 6471 static cmdline_parse_token_string_t cmd_q_pfc_set_tx_mode = 6472 TOKEN_STRING_INITIALIZER(struct cmd_queue_priority_flow_ctrl_set_result, 6473 tx_pfc_mode, "on#off"); 6474 static cmdline_parse_token_num_t cmd_q_pfc_set_rx_qid = 6475 TOKEN_NUM_INITIALIZER(struct cmd_queue_priority_flow_ctrl_set_result, 6476 rx_qid, RTE_UINT16); 6477 static cmdline_parse_token_num_t cmd_q_pfc_set_rx_tc = 6478 TOKEN_NUM_INITIALIZER(struct cmd_queue_priority_flow_ctrl_set_result, 6479 rx_tc, RTE_UINT8); 6480 static cmdline_parse_token_num_t cmd_q_pfc_set_pause_time = 6481 TOKEN_NUM_INITIALIZER(struct cmd_queue_priority_flow_ctrl_set_result, 6482 pause_time, RTE_UINT16); 6483 6484 static cmdline_parse_inst_t cmd_queue_priority_flow_control_set = { 6485 .f = cmd_queue_priority_flow_ctrl_set_parsed, 6486 .data = NULL, 6487 .help_str = "set pfc_queue_ctrl <port_id> rx <on|off> <tx_qid> <tx_tc> " 6488 "tx <on|off> <rx_qid> <rx_tc> <pause_time>: " 6489 "Configure the Ethernet queue priority flow control", 6490 .tokens = { 6491 (void *)&cmd_q_pfc_set_set, 6492 (void *)&cmd_q_pfc_set_flow_ctrl, 6493 (void *)&cmd_q_pfc_set_portid, 6494 (void *)&cmd_q_pfc_set_rx, 6495 (void *)&cmd_q_pfc_set_rx_mode, 6496 (void *)&cmd_q_pfc_set_tx_qid, 6497 (void *)&cmd_q_pfc_set_tx_tc, 6498 (void *)&cmd_q_pfc_set_tx, 6499 (void *)&cmd_q_pfc_set_tx_mode, 6500 (void *)&cmd_q_pfc_set_rx_qid, 6501 (void *)&cmd_q_pfc_set_rx_tc, 6502 (void *)&cmd_q_pfc_set_pause_time, 6503 NULL, 6504 }, 6505 }; 6506 6507 /* *** RESET CONFIGURATION *** */ 6508 struct cmd_reset_result { 6509 cmdline_fixed_string_t reset; 6510 cmdline_fixed_string_t def; 6511 }; 6512 6513 static void cmd_reset_parsed(__rte_unused void *parsed_result, 6514 struct cmdline *cl, 6515 __rte_unused void *data) 6516 { 6517 cmdline_printf(cl, "Reset to default forwarding configuration...\n"); 6518 set_def_fwd_config(); 6519 } 6520 6521 static cmdline_parse_token_string_t cmd_reset_set = 6522 TOKEN_STRING_INITIALIZER(struct cmd_reset_result, reset, "set"); 6523 static cmdline_parse_token_string_t cmd_reset_def = 6524 TOKEN_STRING_INITIALIZER(struct cmd_reset_result, def, 6525 "default"); 6526 6527 static cmdline_parse_inst_t cmd_reset = { 6528 .f = cmd_reset_parsed, 6529 .data = NULL, 6530 .help_str = "set default: Reset default forwarding configuration", 6531 .tokens = { 6532 (void *)&cmd_reset_set, 6533 (void *)&cmd_reset_def, 6534 NULL, 6535 }, 6536 }; 6537 6538 /* *** START FORWARDING *** */ 6539 struct cmd_start_result { 6540 cmdline_fixed_string_t start; 6541 }; 6542 6543 static cmdline_parse_token_string_t cmd_start_start = 6544 TOKEN_STRING_INITIALIZER(struct cmd_start_result, start, "start"); 6545 6546 static void cmd_start_parsed(__rte_unused void *parsed_result, 6547 __rte_unused struct cmdline *cl, 6548 __rte_unused void *data) 6549 { 6550 start_packet_forwarding(0); 6551 } 6552 6553 static cmdline_parse_inst_t cmd_start = { 6554 .f = cmd_start_parsed, 6555 .data = NULL, 6556 .help_str = "start: Start packet forwarding", 6557 .tokens = { 6558 (void *)&cmd_start_start, 6559 NULL, 6560 }, 6561 }; 6562 6563 /* *** START FORWARDING WITH ONE TX BURST FIRST *** */ 6564 struct cmd_start_tx_first_result { 6565 cmdline_fixed_string_t start; 6566 cmdline_fixed_string_t tx_first; 6567 }; 6568 6569 static void 6570 cmd_start_tx_first_parsed(__rte_unused void *parsed_result, 6571 __rte_unused struct cmdline *cl, 6572 __rte_unused void *data) 6573 { 6574 start_packet_forwarding(1); 6575 } 6576 6577 static cmdline_parse_token_string_t cmd_start_tx_first_start = 6578 TOKEN_STRING_INITIALIZER(struct cmd_start_tx_first_result, start, 6579 "start"); 6580 static cmdline_parse_token_string_t cmd_start_tx_first_tx_first = 6581 TOKEN_STRING_INITIALIZER(struct cmd_start_tx_first_result, 6582 tx_first, "tx_first"); 6583 6584 static cmdline_parse_inst_t cmd_start_tx_first = { 6585 .f = cmd_start_tx_first_parsed, 6586 .data = NULL, 6587 .help_str = "start tx_first: Start packet forwarding, " 6588 "after sending 1 burst of packets", 6589 .tokens = { 6590 (void *)&cmd_start_tx_first_start, 6591 (void *)&cmd_start_tx_first_tx_first, 6592 NULL, 6593 }, 6594 }; 6595 6596 /* *** START FORWARDING WITH N TX BURST FIRST *** */ 6597 struct cmd_start_tx_first_n_result { 6598 cmdline_fixed_string_t start; 6599 cmdline_fixed_string_t tx_first; 6600 uint32_t tx_num; 6601 }; 6602 6603 static void 6604 cmd_start_tx_first_n_parsed(void *parsed_result, 6605 __rte_unused struct cmdline *cl, 6606 __rte_unused void *data) 6607 { 6608 struct cmd_start_tx_first_n_result *res = parsed_result; 6609 6610 start_packet_forwarding(res->tx_num); 6611 } 6612 6613 static cmdline_parse_token_string_t cmd_start_tx_first_n_start = 6614 TOKEN_STRING_INITIALIZER(struct cmd_start_tx_first_n_result, 6615 start, "start"); 6616 static cmdline_parse_token_string_t cmd_start_tx_first_n_tx_first = 6617 TOKEN_STRING_INITIALIZER(struct cmd_start_tx_first_n_result, 6618 tx_first, "tx_first"); 6619 static cmdline_parse_token_num_t cmd_start_tx_first_n_tx_num = 6620 TOKEN_NUM_INITIALIZER(struct cmd_start_tx_first_n_result, 6621 tx_num, RTE_UINT32); 6622 6623 static cmdline_parse_inst_t cmd_start_tx_first_n = { 6624 .f = cmd_start_tx_first_n_parsed, 6625 .data = NULL, 6626 .help_str = "start tx_first <num>: " 6627 "packet forwarding, after sending <num> bursts of packets", 6628 .tokens = { 6629 (void *)&cmd_start_tx_first_n_start, 6630 (void *)&cmd_start_tx_first_n_tx_first, 6631 (void *)&cmd_start_tx_first_n_tx_num, 6632 NULL, 6633 }, 6634 }; 6635 6636 /* *** SET LINK UP *** */ 6637 struct cmd_set_link_up_result { 6638 cmdline_fixed_string_t set; 6639 cmdline_fixed_string_t link_up; 6640 cmdline_fixed_string_t port; 6641 portid_t port_id; 6642 }; 6643 6644 static cmdline_parse_token_string_t cmd_set_link_up_set = 6645 TOKEN_STRING_INITIALIZER(struct cmd_set_link_up_result, set, "set"); 6646 static cmdline_parse_token_string_t cmd_set_link_up_link_up = 6647 TOKEN_STRING_INITIALIZER(struct cmd_set_link_up_result, link_up, 6648 "link-up"); 6649 static cmdline_parse_token_string_t cmd_set_link_up_port = 6650 TOKEN_STRING_INITIALIZER(struct cmd_set_link_up_result, port, "port"); 6651 static cmdline_parse_token_num_t cmd_set_link_up_port_id = 6652 TOKEN_NUM_INITIALIZER(struct cmd_set_link_up_result, port_id, 6653 RTE_UINT16); 6654 6655 static void cmd_set_link_up_parsed(__rte_unused void *parsed_result, 6656 __rte_unused struct cmdline *cl, 6657 __rte_unused void *data) 6658 { 6659 struct cmd_set_link_up_result *res = parsed_result; 6660 dev_set_link_up(res->port_id); 6661 } 6662 6663 static cmdline_parse_inst_t cmd_set_link_up = { 6664 .f = cmd_set_link_up_parsed, 6665 .data = NULL, 6666 .help_str = "set link-up port <port id>", 6667 .tokens = { 6668 (void *)&cmd_set_link_up_set, 6669 (void *)&cmd_set_link_up_link_up, 6670 (void *)&cmd_set_link_up_port, 6671 (void *)&cmd_set_link_up_port_id, 6672 NULL, 6673 }, 6674 }; 6675 6676 /* *** SET LINK DOWN *** */ 6677 struct cmd_set_link_down_result { 6678 cmdline_fixed_string_t set; 6679 cmdline_fixed_string_t link_down; 6680 cmdline_fixed_string_t port; 6681 portid_t port_id; 6682 }; 6683 6684 static cmdline_parse_token_string_t cmd_set_link_down_set = 6685 TOKEN_STRING_INITIALIZER(struct cmd_set_link_down_result, set, "set"); 6686 static cmdline_parse_token_string_t cmd_set_link_down_link_down = 6687 TOKEN_STRING_INITIALIZER(struct cmd_set_link_down_result, link_down, 6688 "link-down"); 6689 static cmdline_parse_token_string_t cmd_set_link_down_port = 6690 TOKEN_STRING_INITIALIZER(struct cmd_set_link_down_result, port, "port"); 6691 static cmdline_parse_token_num_t cmd_set_link_down_port_id = 6692 TOKEN_NUM_INITIALIZER(struct cmd_set_link_down_result, port_id, 6693 RTE_UINT16); 6694 6695 static void cmd_set_link_down_parsed( 6696 __rte_unused void *parsed_result, 6697 __rte_unused struct cmdline *cl, 6698 __rte_unused void *data) 6699 { 6700 struct cmd_set_link_down_result *res = parsed_result; 6701 dev_set_link_down(res->port_id); 6702 } 6703 6704 static cmdline_parse_inst_t cmd_set_link_down = { 6705 .f = cmd_set_link_down_parsed, 6706 .data = NULL, 6707 .help_str = "set link-down port <port id>", 6708 .tokens = { 6709 (void *)&cmd_set_link_down_set, 6710 (void *)&cmd_set_link_down_link_down, 6711 (void *)&cmd_set_link_down_port, 6712 (void *)&cmd_set_link_down_port_id, 6713 NULL, 6714 }, 6715 }; 6716 6717 /* *** SHOW CFG *** */ 6718 struct cmd_showcfg_result { 6719 cmdline_fixed_string_t show; 6720 cmdline_fixed_string_t cfg; 6721 cmdline_fixed_string_t what; 6722 }; 6723 6724 static void cmd_showcfg_parsed(void *parsed_result, 6725 __rte_unused struct cmdline *cl, 6726 __rte_unused void *data) 6727 { 6728 struct cmd_showcfg_result *res = parsed_result; 6729 if (!strcmp(res->what, "rxtx")) 6730 rxtx_config_display(); 6731 else if (!strcmp(res->what, "cores")) 6732 fwd_lcores_config_display(); 6733 else if (!strcmp(res->what, "fwd")) 6734 pkt_fwd_config_display(&cur_fwd_config); 6735 else if (!strcmp(res->what, "rxoffs")) 6736 show_rx_pkt_offsets(); 6737 else if (!strcmp(res->what, "rxpkts")) 6738 show_rx_pkt_segments(); 6739 else if (!strcmp(res->what, "rxhdrs")) 6740 show_rx_pkt_hdrs(); 6741 else if (!strcmp(res->what, "txpkts")) 6742 show_tx_pkt_segments(); 6743 else if (!strcmp(res->what, "txtimes")) 6744 show_tx_pkt_times(); 6745 } 6746 6747 static cmdline_parse_token_string_t cmd_showcfg_show = 6748 TOKEN_STRING_INITIALIZER(struct cmd_showcfg_result, show, "show"); 6749 static cmdline_parse_token_string_t cmd_showcfg_port = 6750 TOKEN_STRING_INITIALIZER(struct cmd_showcfg_result, cfg, "config"); 6751 static cmdline_parse_token_string_t cmd_showcfg_what = 6752 TOKEN_STRING_INITIALIZER(struct cmd_showcfg_result, what, 6753 "rxtx#cores#fwd#rxoffs#rxpkts#rxhdrs#txpkts#txtimes"); 6754 6755 static cmdline_parse_inst_t cmd_showcfg = { 6756 .f = cmd_showcfg_parsed, 6757 .data = NULL, 6758 .help_str = "show config rxtx|cores|fwd|rxoffs|rxpkts|rxhdrs|txpkts|txtimes", 6759 .tokens = { 6760 (void *)&cmd_showcfg_show, 6761 (void *)&cmd_showcfg_port, 6762 (void *)&cmd_showcfg_what, 6763 NULL, 6764 }, 6765 }; 6766 6767 /* *** SHOW ALL PORT INFO *** */ 6768 struct cmd_showportall_result { 6769 cmdline_fixed_string_t show; 6770 cmdline_fixed_string_t port; 6771 cmdline_fixed_string_t what; 6772 cmdline_fixed_string_t all; 6773 }; 6774 6775 static void cmd_showportall_parsed(void *parsed_result, 6776 __rte_unused struct cmdline *cl, 6777 __rte_unused void *data) 6778 { 6779 portid_t i; 6780 6781 struct cmd_showportall_result *res = parsed_result; 6782 if (!strcmp(res->show, "clear")) { 6783 if (!strcmp(res->what, "stats")) 6784 RTE_ETH_FOREACH_DEV(i) 6785 nic_stats_clear(i); 6786 else if (!strcmp(res->what, "xstats")) 6787 RTE_ETH_FOREACH_DEV(i) 6788 nic_xstats_clear(i); 6789 } else if (!strcmp(res->what, "info")) 6790 RTE_ETH_FOREACH_DEV(i) 6791 port_infos_display(i); 6792 else if (!strcmp(res->what, "summary")) { 6793 port_summary_header_display(); 6794 RTE_ETH_FOREACH_DEV(i) 6795 port_summary_display(i); 6796 } 6797 else if (!strcmp(res->what, "stats")) 6798 RTE_ETH_FOREACH_DEV(i) 6799 nic_stats_display(i); 6800 else if (!strcmp(res->what, "xstats")) 6801 RTE_ETH_FOREACH_DEV(i) 6802 nic_xstats_display(i); 6803 #if defined(RTE_NET_I40E) || defined(RTE_NET_IXGBE) 6804 else if (!strcmp(res->what, "fdir")) 6805 RTE_ETH_FOREACH_DEV(i) 6806 fdir_get_infos(i); 6807 #endif 6808 else if (!strcmp(res->what, "dcb_tc")) 6809 RTE_ETH_FOREACH_DEV(i) 6810 port_dcb_info_display(i); 6811 } 6812 6813 static cmdline_parse_token_string_t cmd_showportall_show = 6814 TOKEN_STRING_INITIALIZER(struct cmd_showportall_result, show, 6815 "show#clear"); 6816 static cmdline_parse_token_string_t cmd_showportall_port = 6817 TOKEN_STRING_INITIALIZER(struct cmd_showportall_result, port, "port"); 6818 static cmdline_parse_token_string_t cmd_showportall_what = 6819 TOKEN_STRING_INITIALIZER(struct cmd_showportall_result, what, 6820 "info#summary#stats#xstats#fdir#dcb_tc"); 6821 static cmdline_parse_token_string_t cmd_showportall_all = 6822 TOKEN_STRING_INITIALIZER(struct cmd_showportall_result, all, "all"); 6823 static cmdline_parse_inst_t cmd_showportall = { 6824 .f = cmd_showportall_parsed, 6825 .data = NULL, 6826 .help_str = "show|clear port " 6827 "info|summary|stats|xstats|fdir|dcb_tc all", 6828 .tokens = { 6829 (void *)&cmd_showportall_show, 6830 (void *)&cmd_showportall_port, 6831 (void *)&cmd_showportall_what, 6832 (void *)&cmd_showportall_all, 6833 NULL, 6834 }, 6835 }; 6836 6837 /* *** SHOW PORT INFO *** */ 6838 struct cmd_showport_result { 6839 cmdline_fixed_string_t show; 6840 cmdline_fixed_string_t port; 6841 cmdline_fixed_string_t what; 6842 uint16_t portnum; 6843 }; 6844 6845 static void cmd_showport_parsed(void *parsed_result, 6846 __rte_unused struct cmdline *cl, 6847 __rte_unused void *data) 6848 { 6849 struct cmd_showport_result *res = parsed_result; 6850 if (!strcmp(res->show, "clear")) { 6851 if (!strcmp(res->what, "stats")) 6852 nic_stats_clear(res->portnum); 6853 else if (!strcmp(res->what, "xstats")) 6854 nic_xstats_clear(res->portnum); 6855 } else if (!strcmp(res->what, "info")) 6856 port_infos_display(res->portnum); 6857 else if (!strcmp(res->what, "summary")) { 6858 port_summary_header_display(); 6859 port_summary_display(res->portnum); 6860 } 6861 else if (!strcmp(res->what, "stats")) 6862 nic_stats_display(res->portnum); 6863 else if (!strcmp(res->what, "xstats")) 6864 nic_xstats_display(res->portnum); 6865 #if defined(RTE_NET_I40E) || defined(RTE_NET_IXGBE) 6866 else if (!strcmp(res->what, "fdir")) 6867 fdir_get_infos(res->portnum); 6868 #endif 6869 else if (!strcmp(res->what, "dcb_tc")) 6870 port_dcb_info_display(res->portnum); 6871 } 6872 6873 static cmdline_parse_token_string_t cmd_showport_show = 6874 TOKEN_STRING_INITIALIZER(struct cmd_showport_result, show, 6875 "show#clear"); 6876 static cmdline_parse_token_string_t cmd_showport_port = 6877 TOKEN_STRING_INITIALIZER(struct cmd_showport_result, port, "port"); 6878 static cmdline_parse_token_string_t cmd_showport_what = 6879 TOKEN_STRING_INITIALIZER(struct cmd_showport_result, what, 6880 "info#summary#stats#xstats#fdir#dcb_tc"); 6881 static cmdline_parse_token_num_t cmd_showport_portnum = 6882 TOKEN_NUM_INITIALIZER(struct cmd_showport_result, portnum, RTE_UINT16); 6883 6884 static cmdline_parse_inst_t cmd_showport = { 6885 .f = cmd_showport_parsed, 6886 .data = NULL, 6887 .help_str = "show|clear port " 6888 "info|summary|stats|xstats|fdir|dcb_tc " 6889 "<port_id>", 6890 .tokens = { 6891 (void *)&cmd_showport_show, 6892 (void *)&cmd_showport_port, 6893 (void *)&cmd_showport_what, 6894 (void *)&cmd_showport_portnum, 6895 NULL, 6896 }, 6897 }; 6898 6899 /* *** show port representors information *** */ 6900 struct cmd_representor_info_result { 6901 cmdline_fixed_string_t cmd_show; 6902 cmdline_fixed_string_t cmd_port; 6903 cmdline_fixed_string_t cmd_info; 6904 cmdline_fixed_string_t cmd_keyword; 6905 portid_t cmd_pid; 6906 }; 6907 6908 static void 6909 cmd_representor_info_parsed(void *parsed_result, 6910 __rte_unused struct cmdline *cl, 6911 __rte_unused void *data) 6912 { 6913 struct cmd_representor_info_result *res = parsed_result; 6914 struct rte_eth_representor_info *info; 6915 struct rte_eth_representor_range *range; 6916 uint32_t range_diff; 6917 uint32_t i; 6918 int ret; 6919 int num; 6920 6921 if (!rte_eth_dev_is_valid_port(res->cmd_pid)) { 6922 fprintf(stderr, "Invalid port id %u\n", res->cmd_pid); 6923 return; 6924 } 6925 6926 ret = rte_eth_representor_info_get(res->cmd_pid, NULL); 6927 if (ret < 0) { 6928 fprintf(stderr, 6929 "Failed to get the number of representor info ranges for port %hu: %s\n", 6930 res->cmd_pid, rte_strerror(-ret)); 6931 return; 6932 } 6933 num = ret; 6934 6935 info = calloc(1, sizeof(*info) + num * sizeof(info->ranges[0])); 6936 if (info == NULL) { 6937 fprintf(stderr, 6938 "Failed to allocate memory for representor info for port %hu\n", 6939 res->cmd_pid); 6940 return; 6941 } 6942 info->nb_ranges_alloc = num; 6943 6944 ret = rte_eth_representor_info_get(res->cmd_pid, info); 6945 if (ret < 0) { 6946 fprintf(stderr, 6947 "Failed to get the representor info for port %hu: %s\n", 6948 res->cmd_pid, rte_strerror(-ret)); 6949 free(info); 6950 return; 6951 } 6952 6953 printf("Port controller: %hu\n", info->controller); 6954 printf("Port PF: %hu\n", info->pf); 6955 6956 printf("Ranges: %u\n", info->nb_ranges); 6957 for (i = 0; i < info->nb_ranges; i++) { 6958 range = &info->ranges[i]; 6959 range_diff = range->id_end - range->id_base; 6960 6961 printf("%u. ", i + 1); 6962 printf("'%s' ", range->name); 6963 if (range_diff > 0) 6964 printf("[%u-%u]: ", range->id_base, range->id_end); 6965 else 6966 printf("[%u]: ", range->id_base); 6967 6968 printf("Controller %d, PF %d", range->controller, range->pf); 6969 6970 switch (range->type) { 6971 case RTE_ETH_REPRESENTOR_NONE: 6972 printf(", NONE\n"); 6973 break; 6974 case RTE_ETH_REPRESENTOR_VF: 6975 if (range_diff > 0) 6976 printf(", VF %d..%d\n", range->vf, 6977 range->vf + range_diff); 6978 else 6979 printf(", VF %d\n", range->vf); 6980 break; 6981 case RTE_ETH_REPRESENTOR_SF: 6982 printf(", SF %d\n", range->sf); 6983 break; 6984 case RTE_ETH_REPRESENTOR_PF: 6985 if (range_diff > 0) 6986 printf("..%d\n", range->pf + range_diff); 6987 else 6988 printf("\n"); 6989 break; 6990 default: 6991 printf(", UNKNOWN TYPE %d\n", range->type); 6992 break; 6993 } 6994 } 6995 6996 free(info); 6997 } 6998 6999 static cmdline_parse_token_string_t cmd_representor_info_show = 7000 TOKEN_STRING_INITIALIZER(struct cmd_representor_info_result, 7001 cmd_show, "show"); 7002 static cmdline_parse_token_string_t cmd_representor_info_port = 7003 TOKEN_STRING_INITIALIZER(struct cmd_representor_info_result, 7004 cmd_port, "port"); 7005 static cmdline_parse_token_string_t cmd_representor_info_info = 7006 TOKEN_STRING_INITIALIZER(struct cmd_representor_info_result, 7007 cmd_info, "info"); 7008 static cmdline_parse_token_num_t cmd_representor_info_pid = 7009 TOKEN_NUM_INITIALIZER(struct cmd_representor_info_result, 7010 cmd_pid, RTE_UINT16); 7011 static cmdline_parse_token_string_t cmd_representor_info_keyword = 7012 TOKEN_STRING_INITIALIZER(struct cmd_representor_info_result, 7013 cmd_keyword, "representor"); 7014 7015 static cmdline_parse_inst_t cmd_representor_info = { 7016 .f = cmd_representor_info_parsed, 7017 .data = NULL, 7018 .help_str = "show port info <port_id> representor", 7019 .tokens = { 7020 (void *)&cmd_representor_info_show, 7021 (void *)&cmd_representor_info_port, 7022 (void *)&cmd_representor_info_info, 7023 (void *)&cmd_representor_info_pid, 7024 (void *)&cmd_representor_info_keyword, 7025 NULL, 7026 }, 7027 }; 7028 7029 7030 /* *** SHOW DEVICE INFO *** */ 7031 struct cmd_showdevice_result { 7032 cmdline_fixed_string_t show; 7033 cmdline_fixed_string_t device; 7034 cmdline_fixed_string_t what; 7035 cmdline_fixed_string_t identifier; 7036 }; 7037 7038 static void cmd_showdevice_parsed(void *parsed_result, 7039 __rte_unused struct cmdline *cl, 7040 __rte_unused void *data) 7041 { 7042 struct cmd_showdevice_result *res = parsed_result; 7043 if (!strcmp(res->what, "info")) { 7044 if (!strcmp(res->identifier, "all")) 7045 device_infos_display(NULL); 7046 else 7047 device_infos_display(res->identifier); 7048 } 7049 } 7050 7051 static cmdline_parse_token_string_t cmd_showdevice_show = 7052 TOKEN_STRING_INITIALIZER(struct cmd_showdevice_result, show, 7053 "show"); 7054 static cmdline_parse_token_string_t cmd_showdevice_device = 7055 TOKEN_STRING_INITIALIZER(struct cmd_showdevice_result, device, "device"); 7056 static cmdline_parse_token_string_t cmd_showdevice_what = 7057 TOKEN_STRING_INITIALIZER(struct cmd_showdevice_result, what, 7058 "info"); 7059 static cmdline_parse_token_string_t cmd_showdevice_identifier = 7060 TOKEN_STRING_INITIALIZER(struct cmd_showdevice_result, 7061 identifier, NULL); 7062 7063 static cmdline_parse_inst_t cmd_showdevice = { 7064 .f = cmd_showdevice_parsed, 7065 .data = NULL, 7066 .help_str = "show device info <identifier>|all", 7067 .tokens = { 7068 (void *)&cmd_showdevice_show, 7069 (void *)&cmd_showdevice_device, 7070 (void *)&cmd_showdevice_what, 7071 (void *)&cmd_showdevice_identifier, 7072 NULL, 7073 }, 7074 }; 7075 7076 /* *** SHOW MODULE EEPROM/EEPROM port INFO *** */ 7077 struct cmd_showeeprom_result { 7078 cmdline_fixed_string_t show; 7079 cmdline_fixed_string_t port; 7080 uint16_t portnum; 7081 cmdline_fixed_string_t type; 7082 }; 7083 7084 static void cmd_showeeprom_parsed(void *parsed_result, 7085 __rte_unused struct cmdline *cl, 7086 __rte_unused void *data) 7087 { 7088 struct cmd_showeeprom_result *res = parsed_result; 7089 7090 if (!strcmp(res->type, "eeprom")) 7091 port_eeprom_display(res->portnum); 7092 else if (!strcmp(res->type, "module_eeprom")) 7093 port_module_eeprom_display(res->portnum); 7094 else 7095 fprintf(stderr, "Unknown argument\n"); 7096 } 7097 7098 static cmdline_parse_token_string_t cmd_showeeprom_show = 7099 TOKEN_STRING_INITIALIZER(struct cmd_showeeprom_result, show, "show"); 7100 static cmdline_parse_token_string_t cmd_showeeprom_port = 7101 TOKEN_STRING_INITIALIZER(struct cmd_showeeprom_result, port, "port"); 7102 static cmdline_parse_token_num_t cmd_showeeprom_portnum = 7103 TOKEN_NUM_INITIALIZER(struct cmd_showeeprom_result, portnum, 7104 RTE_UINT16); 7105 static cmdline_parse_token_string_t cmd_showeeprom_type = 7106 TOKEN_STRING_INITIALIZER(struct cmd_showeeprom_result, type, "module_eeprom#eeprom"); 7107 7108 static cmdline_parse_inst_t cmd_showeeprom = { 7109 .f = cmd_showeeprom_parsed, 7110 .data = NULL, 7111 .help_str = "show port <port_id> module_eeprom|eeprom", 7112 .tokens = { 7113 (void *)&cmd_showeeprom_show, 7114 (void *)&cmd_showeeprom_port, 7115 (void *)&cmd_showeeprom_portnum, 7116 (void *)&cmd_showeeprom_type, 7117 NULL, 7118 }, 7119 }; 7120 7121 /* *** SHOW QUEUE INFO *** */ 7122 struct cmd_showqueue_result { 7123 cmdline_fixed_string_t show; 7124 cmdline_fixed_string_t type; 7125 cmdline_fixed_string_t what; 7126 uint16_t portnum; 7127 uint16_t queuenum; 7128 }; 7129 7130 static void 7131 cmd_showqueue_parsed(void *parsed_result, 7132 __rte_unused struct cmdline *cl, 7133 __rte_unused void *data) 7134 { 7135 struct cmd_showqueue_result *res = parsed_result; 7136 7137 if (!strcmp(res->type, "rxq")) 7138 rx_queue_infos_display(res->portnum, res->queuenum); 7139 else if (!strcmp(res->type, "txq")) 7140 tx_queue_infos_display(res->portnum, res->queuenum); 7141 } 7142 7143 static cmdline_parse_token_string_t cmd_showqueue_show = 7144 TOKEN_STRING_INITIALIZER(struct cmd_showqueue_result, show, "show"); 7145 static cmdline_parse_token_string_t cmd_showqueue_type = 7146 TOKEN_STRING_INITIALIZER(struct cmd_showqueue_result, type, "rxq#txq"); 7147 static cmdline_parse_token_string_t cmd_showqueue_what = 7148 TOKEN_STRING_INITIALIZER(struct cmd_showqueue_result, what, "info"); 7149 static cmdline_parse_token_num_t cmd_showqueue_portnum = 7150 TOKEN_NUM_INITIALIZER(struct cmd_showqueue_result, portnum, 7151 RTE_UINT16); 7152 static cmdline_parse_token_num_t cmd_showqueue_queuenum = 7153 TOKEN_NUM_INITIALIZER(struct cmd_showqueue_result, queuenum, 7154 RTE_UINT16); 7155 7156 static cmdline_parse_inst_t cmd_showqueue = { 7157 .f = cmd_showqueue_parsed, 7158 .data = NULL, 7159 .help_str = "show rxq|txq info <port_id> <queue_id>", 7160 .tokens = { 7161 (void *)&cmd_showqueue_show, 7162 (void *)&cmd_showqueue_type, 7163 (void *)&cmd_showqueue_what, 7164 (void *)&cmd_showqueue_portnum, 7165 (void *)&cmd_showqueue_queuenum, 7166 NULL, 7167 }, 7168 }; 7169 7170 /* show/clear fwd engine statistics */ 7171 struct fwd_result { 7172 cmdline_fixed_string_t action; 7173 cmdline_fixed_string_t fwd; 7174 cmdline_fixed_string_t stats; 7175 cmdline_fixed_string_t all; 7176 }; 7177 7178 static cmdline_parse_token_string_t cmd_fwd_action = 7179 TOKEN_STRING_INITIALIZER(struct fwd_result, action, "show#clear"); 7180 static cmdline_parse_token_string_t cmd_fwd_fwd = 7181 TOKEN_STRING_INITIALIZER(struct fwd_result, fwd, "fwd"); 7182 static cmdline_parse_token_string_t cmd_fwd_stats = 7183 TOKEN_STRING_INITIALIZER(struct fwd_result, stats, "stats"); 7184 static cmdline_parse_token_string_t cmd_fwd_all = 7185 TOKEN_STRING_INITIALIZER(struct fwd_result, all, "all"); 7186 7187 static void 7188 cmd_showfwdall_parsed(void *parsed_result, 7189 __rte_unused struct cmdline *cl, 7190 __rte_unused void *data) 7191 { 7192 struct fwd_result *res = parsed_result; 7193 7194 if (!strcmp(res->action, "show")) 7195 fwd_stats_display(); 7196 else 7197 fwd_stats_reset(); 7198 } 7199 7200 static cmdline_parse_inst_t cmd_showfwdall = { 7201 .f = cmd_showfwdall_parsed, 7202 .data = NULL, 7203 .help_str = "show|clear fwd stats all", 7204 .tokens = { 7205 (void *)&cmd_fwd_action, 7206 (void *)&cmd_fwd_fwd, 7207 (void *)&cmd_fwd_stats, 7208 (void *)&cmd_fwd_all, 7209 NULL, 7210 }, 7211 }; 7212 7213 /* *** READ A RING DESCRIPTOR OF A PORT RX/TX QUEUE *** */ 7214 struct cmd_read_rxd_txd_result { 7215 cmdline_fixed_string_t read; 7216 cmdline_fixed_string_t rxd_txd; 7217 portid_t port_id; 7218 uint16_t queue_id; 7219 uint16_t desc_id; 7220 }; 7221 7222 static void 7223 cmd_read_rxd_txd_parsed(void *parsed_result, 7224 __rte_unused struct cmdline *cl, 7225 __rte_unused void *data) 7226 { 7227 struct cmd_read_rxd_txd_result *res = parsed_result; 7228 7229 if (!strcmp(res->rxd_txd, "rxd")) 7230 rx_ring_desc_display(res->port_id, res->queue_id, res->desc_id); 7231 else if (!strcmp(res->rxd_txd, "txd")) 7232 tx_ring_desc_display(res->port_id, res->queue_id, res->desc_id); 7233 } 7234 7235 static cmdline_parse_token_string_t cmd_read_rxd_txd_read = 7236 TOKEN_STRING_INITIALIZER(struct cmd_read_rxd_txd_result, read, "read"); 7237 static cmdline_parse_token_string_t cmd_read_rxd_txd_rxd_txd = 7238 TOKEN_STRING_INITIALIZER(struct cmd_read_rxd_txd_result, rxd_txd, 7239 "rxd#txd"); 7240 static cmdline_parse_token_num_t cmd_read_rxd_txd_port_id = 7241 TOKEN_NUM_INITIALIZER(struct cmd_read_rxd_txd_result, port_id, 7242 RTE_UINT16); 7243 static cmdline_parse_token_num_t cmd_read_rxd_txd_queue_id = 7244 TOKEN_NUM_INITIALIZER(struct cmd_read_rxd_txd_result, queue_id, 7245 RTE_UINT16); 7246 static cmdline_parse_token_num_t cmd_read_rxd_txd_desc_id = 7247 TOKEN_NUM_INITIALIZER(struct cmd_read_rxd_txd_result, desc_id, 7248 RTE_UINT16); 7249 7250 static cmdline_parse_inst_t cmd_read_rxd_txd = { 7251 .f = cmd_read_rxd_txd_parsed, 7252 .data = NULL, 7253 .help_str = "read rxd|txd <port_id> <queue_id> <desc_id>", 7254 .tokens = { 7255 (void *)&cmd_read_rxd_txd_read, 7256 (void *)&cmd_read_rxd_txd_rxd_txd, 7257 (void *)&cmd_read_rxd_txd_port_id, 7258 (void *)&cmd_read_rxd_txd_queue_id, 7259 (void *)&cmd_read_rxd_txd_desc_id, 7260 NULL, 7261 }, 7262 }; 7263 7264 /* *** QUIT *** */ 7265 struct cmd_quit_result { 7266 cmdline_fixed_string_t quit; 7267 }; 7268 7269 static void cmd_quit_parsed(__rte_unused void *parsed_result, 7270 struct cmdline *cl, 7271 __rte_unused void *data) 7272 { 7273 cmdline_quit(cl); 7274 cl_quit = 1; 7275 } 7276 7277 static cmdline_parse_token_string_t cmd_quit_quit = 7278 TOKEN_STRING_INITIALIZER(struct cmd_quit_result, quit, "quit"); 7279 7280 static cmdline_parse_inst_t cmd_quit = { 7281 .f = cmd_quit_parsed, 7282 .data = NULL, 7283 .help_str = "quit: Exit application", 7284 .tokens = { 7285 (void *)&cmd_quit_quit, 7286 NULL, 7287 }, 7288 }; 7289 7290 /* *** ADD/REMOVE MAC ADDRESS FROM A PORT *** */ 7291 struct cmd_mac_addr_result { 7292 cmdline_fixed_string_t mac_addr_cmd; 7293 cmdline_fixed_string_t what; 7294 uint16_t port_num; 7295 struct rte_ether_addr address; 7296 }; 7297 7298 static void cmd_mac_addr_parsed(void *parsed_result, 7299 __rte_unused struct cmdline *cl, 7300 __rte_unused void *data) 7301 { 7302 struct cmd_mac_addr_result *res = parsed_result; 7303 int ret; 7304 7305 if (strcmp(res->what, "add") == 0) 7306 ret = rte_eth_dev_mac_addr_add(res->port_num, &res->address, 0); 7307 else if (strcmp(res->what, "set") == 0) 7308 ret = rte_eth_dev_default_mac_addr_set(res->port_num, 7309 &res->address); 7310 else 7311 ret = rte_eth_dev_mac_addr_remove(res->port_num, &res->address); 7312 7313 /* check the return value and print it if is < 0 */ 7314 if(ret < 0) 7315 fprintf(stderr, "mac_addr_cmd error: (%s)\n", strerror(-ret)); 7316 7317 } 7318 7319 static cmdline_parse_token_string_t cmd_mac_addr_cmd = 7320 TOKEN_STRING_INITIALIZER(struct cmd_mac_addr_result, mac_addr_cmd, 7321 "mac_addr"); 7322 static cmdline_parse_token_string_t cmd_mac_addr_what = 7323 TOKEN_STRING_INITIALIZER(struct cmd_mac_addr_result, what, 7324 "add#remove#set"); 7325 static cmdline_parse_token_num_t cmd_mac_addr_portnum = 7326 TOKEN_NUM_INITIALIZER(struct cmd_mac_addr_result, port_num, 7327 RTE_UINT16); 7328 static cmdline_parse_token_etheraddr_t cmd_mac_addr_addr = 7329 TOKEN_ETHERADDR_INITIALIZER(struct cmd_mac_addr_result, address); 7330 7331 static cmdline_parse_inst_t cmd_mac_addr = { 7332 .f = cmd_mac_addr_parsed, 7333 .data = (void *)0, 7334 .help_str = "mac_addr add|remove|set <port_id> <mac_addr>: " 7335 "Add/Remove/Set MAC address on port_id", 7336 .tokens = { 7337 (void *)&cmd_mac_addr_cmd, 7338 (void *)&cmd_mac_addr_what, 7339 (void *)&cmd_mac_addr_portnum, 7340 (void *)&cmd_mac_addr_addr, 7341 NULL, 7342 }, 7343 }; 7344 7345 /* *** SET THE PEER ADDRESS FOR CERTAIN PORT *** */ 7346 struct cmd_eth_peer_result { 7347 cmdline_fixed_string_t set; 7348 cmdline_fixed_string_t eth_peer; 7349 portid_t port_id; 7350 cmdline_fixed_string_t peer_addr; 7351 }; 7352 7353 static void cmd_set_eth_peer_parsed(void *parsed_result, 7354 __rte_unused struct cmdline *cl, 7355 __rte_unused void *data) 7356 { 7357 struct cmd_eth_peer_result *res = parsed_result; 7358 7359 if (test_done == 0) { 7360 fprintf(stderr, "Please stop forwarding first\n"); 7361 return; 7362 } 7363 if (!strcmp(res->eth_peer, "eth-peer")) { 7364 set_fwd_eth_peer(res->port_id, res->peer_addr); 7365 fwd_config_setup(); 7366 } 7367 } 7368 static cmdline_parse_token_string_t cmd_eth_peer_set = 7369 TOKEN_STRING_INITIALIZER(struct cmd_eth_peer_result, set, "set"); 7370 static cmdline_parse_token_string_t cmd_eth_peer = 7371 TOKEN_STRING_INITIALIZER(struct cmd_eth_peer_result, eth_peer, "eth-peer"); 7372 static cmdline_parse_token_num_t cmd_eth_peer_port_id = 7373 TOKEN_NUM_INITIALIZER(struct cmd_eth_peer_result, port_id, 7374 RTE_UINT16); 7375 static cmdline_parse_token_string_t cmd_eth_peer_addr = 7376 TOKEN_STRING_INITIALIZER(struct cmd_eth_peer_result, peer_addr, NULL); 7377 7378 static cmdline_parse_inst_t cmd_set_fwd_eth_peer = { 7379 .f = cmd_set_eth_peer_parsed, 7380 .data = NULL, 7381 .help_str = "set eth-peer <port_id> <peer_mac>", 7382 .tokens = { 7383 (void *)&cmd_eth_peer_set, 7384 (void *)&cmd_eth_peer, 7385 (void *)&cmd_eth_peer_port_id, 7386 (void *)&cmd_eth_peer_addr, 7387 NULL, 7388 }, 7389 }; 7390 7391 /* *** CONFIGURE QUEUE STATS COUNTER MAPPINGS *** */ 7392 struct cmd_set_qmap_result { 7393 cmdline_fixed_string_t set; 7394 cmdline_fixed_string_t qmap; 7395 cmdline_fixed_string_t what; 7396 portid_t port_id; 7397 uint16_t queue_id; 7398 uint8_t map_value; 7399 }; 7400 7401 static void 7402 cmd_set_qmap_parsed(void *parsed_result, 7403 __rte_unused struct cmdline *cl, 7404 __rte_unused void *data) 7405 { 7406 struct cmd_set_qmap_result *res = parsed_result; 7407 int is_rx = (strcmp(res->what, "tx") == 0) ? 0 : 1; 7408 7409 set_qmap(res->port_id, (uint8_t)is_rx, res->queue_id, res->map_value); 7410 } 7411 7412 static cmdline_parse_token_string_t cmd_setqmap_set = 7413 TOKEN_STRING_INITIALIZER(struct cmd_set_qmap_result, 7414 set, "set"); 7415 static cmdline_parse_token_string_t cmd_setqmap_qmap = 7416 TOKEN_STRING_INITIALIZER(struct cmd_set_qmap_result, 7417 qmap, "stat_qmap"); 7418 static cmdline_parse_token_string_t cmd_setqmap_what = 7419 TOKEN_STRING_INITIALIZER(struct cmd_set_qmap_result, 7420 what, "tx#rx"); 7421 static cmdline_parse_token_num_t cmd_setqmap_portid = 7422 TOKEN_NUM_INITIALIZER(struct cmd_set_qmap_result, 7423 port_id, RTE_UINT16); 7424 static cmdline_parse_token_num_t cmd_setqmap_queueid = 7425 TOKEN_NUM_INITIALIZER(struct cmd_set_qmap_result, 7426 queue_id, RTE_UINT16); 7427 static cmdline_parse_token_num_t cmd_setqmap_mapvalue = 7428 TOKEN_NUM_INITIALIZER(struct cmd_set_qmap_result, 7429 map_value, RTE_UINT8); 7430 7431 static cmdline_parse_inst_t cmd_set_qmap = { 7432 .f = cmd_set_qmap_parsed, 7433 .data = NULL, 7434 .help_str = "set stat_qmap rx|tx <port_id> <queue_id> <map_value>: " 7435 "Set statistics mapping value on tx|rx queue_id of port_id", 7436 .tokens = { 7437 (void *)&cmd_setqmap_set, 7438 (void *)&cmd_setqmap_qmap, 7439 (void *)&cmd_setqmap_what, 7440 (void *)&cmd_setqmap_portid, 7441 (void *)&cmd_setqmap_queueid, 7442 (void *)&cmd_setqmap_mapvalue, 7443 NULL, 7444 }, 7445 }; 7446 7447 /* *** SET OPTION TO HIDE ZERO VALUES FOR XSTATS DISPLAY *** */ 7448 struct cmd_set_xstats_hide_zero_result { 7449 cmdline_fixed_string_t keyword; 7450 cmdline_fixed_string_t name; 7451 cmdline_fixed_string_t on_off; 7452 }; 7453 7454 static void 7455 cmd_set_xstats_hide_zero_parsed(void *parsed_result, 7456 __rte_unused struct cmdline *cl, 7457 __rte_unused void *data) 7458 { 7459 struct cmd_set_xstats_hide_zero_result *res; 7460 uint16_t on_off = 0; 7461 7462 res = parsed_result; 7463 on_off = !strcmp(res->on_off, "on") ? 1 : 0; 7464 set_xstats_hide_zero(on_off); 7465 } 7466 7467 static cmdline_parse_token_string_t cmd_set_xstats_hide_zero_keyword = 7468 TOKEN_STRING_INITIALIZER(struct cmd_set_xstats_hide_zero_result, 7469 keyword, "set"); 7470 static cmdline_parse_token_string_t cmd_set_xstats_hide_zero_name = 7471 TOKEN_STRING_INITIALIZER(struct cmd_set_xstats_hide_zero_result, 7472 name, "xstats-hide-zero"); 7473 static cmdline_parse_token_string_t cmd_set_xstats_hide_zero_on_off = 7474 TOKEN_STRING_INITIALIZER(struct cmd_set_xstats_hide_zero_result, 7475 on_off, "on#off"); 7476 7477 static cmdline_parse_inst_t cmd_set_xstats_hide_zero = { 7478 .f = cmd_set_xstats_hide_zero_parsed, 7479 .data = NULL, 7480 .help_str = "set xstats-hide-zero on|off", 7481 .tokens = { 7482 (void *)&cmd_set_xstats_hide_zero_keyword, 7483 (void *)&cmd_set_xstats_hide_zero_name, 7484 (void *)&cmd_set_xstats_hide_zero_on_off, 7485 NULL, 7486 }, 7487 }; 7488 7489 /* *** SET OPTION TO ENABLE MEASUREMENT OF CPU CYCLES *** */ 7490 struct cmd_set_record_core_cycles_result { 7491 cmdline_fixed_string_t keyword; 7492 cmdline_fixed_string_t name; 7493 cmdline_fixed_string_t on_off; 7494 }; 7495 7496 static void 7497 cmd_set_record_core_cycles_parsed(void *parsed_result, 7498 __rte_unused struct cmdline *cl, 7499 __rte_unused void *data) 7500 { 7501 struct cmd_set_record_core_cycles_result *res; 7502 uint16_t on_off = 0; 7503 7504 res = parsed_result; 7505 on_off = !strcmp(res->on_off, "on") ? 1 : 0; 7506 set_record_core_cycles(on_off); 7507 } 7508 7509 static cmdline_parse_token_string_t cmd_set_record_core_cycles_keyword = 7510 TOKEN_STRING_INITIALIZER(struct cmd_set_record_core_cycles_result, 7511 keyword, "set"); 7512 static cmdline_parse_token_string_t cmd_set_record_core_cycles_name = 7513 TOKEN_STRING_INITIALIZER(struct cmd_set_record_core_cycles_result, 7514 name, "record-core-cycles"); 7515 static cmdline_parse_token_string_t cmd_set_record_core_cycles_on_off = 7516 TOKEN_STRING_INITIALIZER(struct cmd_set_record_core_cycles_result, 7517 on_off, "on#off"); 7518 7519 static cmdline_parse_inst_t cmd_set_record_core_cycles = { 7520 .f = cmd_set_record_core_cycles_parsed, 7521 .data = NULL, 7522 .help_str = "set record-core-cycles on|off", 7523 .tokens = { 7524 (void *)&cmd_set_record_core_cycles_keyword, 7525 (void *)&cmd_set_record_core_cycles_name, 7526 (void *)&cmd_set_record_core_cycles_on_off, 7527 NULL, 7528 }, 7529 }; 7530 7531 /* *** SET OPTION TO ENABLE DISPLAY OF RX AND TX BURSTS *** */ 7532 struct cmd_set_record_burst_stats_result { 7533 cmdline_fixed_string_t keyword; 7534 cmdline_fixed_string_t name; 7535 cmdline_fixed_string_t on_off; 7536 }; 7537 7538 static void 7539 cmd_set_record_burst_stats_parsed(void *parsed_result, 7540 __rte_unused struct cmdline *cl, 7541 __rte_unused void *data) 7542 { 7543 struct cmd_set_record_burst_stats_result *res; 7544 uint16_t on_off = 0; 7545 7546 res = parsed_result; 7547 on_off = !strcmp(res->on_off, "on") ? 1 : 0; 7548 set_record_burst_stats(on_off); 7549 } 7550 7551 static cmdline_parse_token_string_t cmd_set_record_burst_stats_keyword = 7552 TOKEN_STRING_INITIALIZER(struct cmd_set_record_burst_stats_result, 7553 keyword, "set"); 7554 static cmdline_parse_token_string_t cmd_set_record_burst_stats_name = 7555 TOKEN_STRING_INITIALIZER(struct cmd_set_record_burst_stats_result, 7556 name, "record-burst-stats"); 7557 static cmdline_parse_token_string_t cmd_set_record_burst_stats_on_off = 7558 TOKEN_STRING_INITIALIZER(struct cmd_set_record_burst_stats_result, 7559 on_off, "on#off"); 7560 7561 static cmdline_parse_inst_t cmd_set_record_burst_stats = { 7562 .f = cmd_set_record_burst_stats_parsed, 7563 .data = NULL, 7564 .help_str = "set record-burst-stats on|off", 7565 .tokens = { 7566 (void *)&cmd_set_record_burst_stats_keyword, 7567 (void *)&cmd_set_record_burst_stats_name, 7568 (void *)&cmd_set_record_burst_stats_on_off, 7569 NULL, 7570 }, 7571 }; 7572 7573 /* *** CONFIGURE UNICAST HASH TABLE *** */ 7574 struct cmd_set_uc_hash_table { 7575 cmdline_fixed_string_t set; 7576 cmdline_fixed_string_t port; 7577 portid_t port_id; 7578 cmdline_fixed_string_t what; 7579 struct rte_ether_addr address; 7580 cmdline_fixed_string_t mode; 7581 }; 7582 7583 static void 7584 cmd_set_uc_hash_parsed(void *parsed_result, 7585 __rte_unused struct cmdline *cl, 7586 __rte_unused void *data) 7587 { 7588 int ret=0; 7589 struct cmd_set_uc_hash_table *res = parsed_result; 7590 7591 int is_on = (strcmp(res->mode, "on") == 0) ? 1 : 0; 7592 7593 if (strcmp(res->what, "uta") == 0) 7594 ret = rte_eth_dev_uc_hash_table_set(res->port_id, 7595 &res->address,(uint8_t)is_on); 7596 if (ret < 0) 7597 fprintf(stderr, 7598 "bad unicast hash table parameter, return code = %d\n", 7599 ret); 7600 7601 } 7602 7603 static cmdline_parse_token_string_t cmd_set_uc_hash_set = 7604 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_hash_table, 7605 set, "set"); 7606 static cmdline_parse_token_string_t cmd_set_uc_hash_port = 7607 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_hash_table, 7608 port, "port"); 7609 static cmdline_parse_token_num_t cmd_set_uc_hash_portid = 7610 TOKEN_NUM_INITIALIZER(struct cmd_set_uc_hash_table, 7611 port_id, RTE_UINT16); 7612 static cmdline_parse_token_string_t cmd_set_uc_hash_what = 7613 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_hash_table, 7614 what, "uta"); 7615 static cmdline_parse_token_etheraddr_t cmd_set_uc_hash_mac = 7616 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_uc_hash_table, 7617 address); 7618 static cmdline_parse_token_string_t cmd_set_uc_hash_mode = 7619 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_hash_table, 7620 mode, "on#off"); 7621 7622 static cmdline_parse_inst_t cmd_set_uc_hash_filter = { 7623 .f = cmd_set_uc_hash_parsed, 7624 .data = NULL, 7625 .help_str = "set port <port_id> uta <mac_addr> on|off)", 7626 .tokens = { 7627 (void *)&cmd_set_uc_hash_set, 7628 (void *)&cmd_set_uc_hash_port, 7629 (void *)&cmd_set_uc_hash_portid, 7630 (void *)&cmd_set_uc_hash_what, 7631 (void *)&cmd_set_uc_hash_mac, 7632 (void *)&cmd_set_uc_hash_mode, 7633 NULL, 7634 }, 7635 }; 7636 7637 struct cmd_set_uc_all_hash_table { 7638 cmdline_fixed_string_t set; 7639 cmdline_fixed_string_t port; 7640 portid_t port_id; 7641 cmdline_fixed_string_t what; 7642 cmdline_fixed_string_t value; 7643 cmdline_fixed_string_t mode; 7644 }; 7645 7646 static void 7647 cmd_set_uc_all_hash_parsed(void *parsed_result, 7648 __rte_unused struct cmdline *cl, 7649 __rte_unused void *data) 7650 { 7651 int ret=0; 7652 struct cmd_set_uc_all_hash_table *res = parsed_result; 7653 7654 int is_on = (strcmp(res->mode, "on") == 0) ? 1 : 0; 7655 7656 if ((strcmp(res->what, "uta") == 0) && 7657 (strcmp(res->value, "all") == 0)) 7658 ret = rte_eth_dev_uc_all_hash_table_set(res->port_id,(uint8_t) is_on); 7659 if (ret < 0) 7660 fprintf(stderr, 7661 "bad unicast hash table parameter, return code = %d\n", 7662 ret); 7663 } 7664 7665 static cmdline_parse_token_string_t cmd_set_uc_all_hash_set = 7666 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_all_hash_table, 7667 set, "set"); 7668 static cmdline_parse_token_string_t cmd_set_uc_all_hash_port = 7669 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_all_hash_table, 7670 port, "port"); 7671 static cmdline_parse_token_num_t cmd_set_uc_all_hash_portid = 7672 TOKEN_NUM_INITIALIZER(struct cmd_set_uc_all_hash_table, 7673 port_id, RTE_UINT16); 7674 static cmdline_parse_token_string_t cmd_set_uc_all_hash_what = 7675 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_all_hash_table, 7676 what, "uta"); 7677 static cmdline_parse_token_string_t cmd_set_uc_all_hash_value = 7678 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_all_hash_table, 7679 value,"all"); 7680 static cmdline_parse_token_string_t cmd_set_uc_all_hash_mode = 7681 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_all_hash_table, 7682 mode, "on#off"); 7683 7684 static cmdline_parse_inst_t cmd_set_uc_all_hash_filter = { 7685 .f = cmd_set_uc_all_hash_parsed, 7686 .data = NULL, 7687 .help_str = "set port <port_id> uta all on|off", 7688 .tokens = { 7689 (void *)&cmd_set_uc_all_hash_set, 7690 (void *)&cmd_set_uc_all_hash_port, 7691 (void *)&cmd_set_uc_all_hash_portid, 7692 (void *)&cmd_set_uc_all_hash_what, 7693 (void *)&cmd_set_uc_all_hash_value, 7694 (void *)&cmd_set_uc_all_hash_mode, 7695 NULL, 7696 }, 7697 }; 7698 7699 /* *** CONFIGURE VF TRAFFIC CONTROL *** */ 7700 struct cmd_set_vf_traffic { 7701 cmdline_fixed_string_t set; 7702 cmdline_fixed_string_t port; 7703 portid_t port_id; 7704 cmdline_fixed_string_t vf; 7705 uint8_t vf_id; 7706 cmdline_fixed_string_t what; 7707 cmdline_fixed_string_t mode; 7708 }; 7709 7710 static void 7711 cmd_set_vf_traffic_parsed(void *parsed_result, 7712 __rte_unused struct cmdline *cl, 7713 __rte_unused void *data) 7714 { 7715 struct cmd_set_vf_traffic *res = parsed_result; 7716 int is_rx = (strcmp(res->what, "rx") == 0) ? 1 : 0; 7717 int is_on = (strcmp(res->mode, "on") == 0) ? 1 : 0; 7718 7719 set_vf_traffic(res->port_id, (uint8_t)is_rx, res->vf_id,(uint8_t) is_on); 7720 } 7721 7722 static cmdline_parse_token_string_t cmd_setvf_traffic_set = 7723 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_traffic, 7724 set, "set"); 7725 static cmdline_parse_token_string_t cmd_setvf_traffic_port = 7726 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_traffic, 7727 port, "port"); 7728 static cmdline_parse_token_num_t cmd_setvf_traffic_portid = 7729 TOKEN_NUM_INITIALIZER(struct cmd_set_vf_traffic, 7730 port_id, RTE_UINT16); 7731 static cmdline_parse_token_string_t cmd_setvf_traffic_vf = 7732 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_traffic, 7733 vf, "vf"); 7734 static cmdline_parse_token_num_t cmd_setvf_traffic_vfid = 7735 TOKEN_NUM_INITIALIZER(struct cmd_set_vf_traffic, 7736 vf_id, RTE_UINT8); 7737 static cmdline_parse_token_string_t cmd_setvf_traffic_what = 7738 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_traffic, 7739 what, "tx#rx"); 7740 static cmdline_parse_token_string_t cmd_setvf_traffic_mode = 7741 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_traffic, 7742 mode, "on#off"); 7743 7744 static cmdline_parse_inst_t cmd_set_vf_traffic = { 7745 .f = cmd_set_vf_traffic_parsed, 7746 .data = NULL, 7747 .help_str = "set port <port_id> vf <vf_id> rx|tx on|off", 7748 .tokens = { 7749 (void *)&cmd_setvf_traffic_set, 7750 (void *)&cmd_setvf_traffic_port, 7751 (void *)&cmd_setvf_traffic_portid, 7752 (void *)&cmd_setvf_traffic_vf, 7753 (void *)&cmd_setvf_traffic_vfid, 7754 (void *)&cmd_setvf_traffic_what, 7755 (void *)&cmd_setvf_traffic_mode, 7756 NULL, 7757 }, 7758 }; 7759 7760 /* *** CONFIGURE VF RECEIVE MODE *** */ 7761 struct cmd_set_vf_rxmode { 7762 cmdline_fixed_string_t set; 7763 cmdline_fixed_string_t port; 7764 portid_t port_id; 7765 cmdline_fixed_string_t vf; 7766 uint8_t vf_id; 7767 cmdline_fixed_string_t what; 7768 cmdline_fixed_string_t mode; 7769 cmdline_fixed_string_t on; 7770 }; 7771 7772 static void 7773 cmd_set_vf_rxmode_parsed(void *parsed_result, 7774 __rte_unused struct cmdline *cl, 7775 __rte_unused void *data) 7776 { 7777 int ret = -ENOTSUP; 7778 uint16_t vf_rxmode = 0; 7779 struct cmd_set_vf_rxmode *res = parsed_result; 7780 7781 int is_on = (strcmp(res->on, "on") == 0) ? 1 : 0; 7782 if (!strcmp(res->what,"rxmode")) { 7783 if (!strcmp(res->mode, "AUPE")) 7784 vf_rxmode |= RTE_ETH_VMDQ_ACCEPT_UNTAG; 7785 else if (!strcmp(res->mode, "ROPE")) 7786 vf_rxmode |= RTE_ETH_VMDQ_ACCEPT_HASH_UC; 7787 else if (!strcmp(res->mode, "BAM")) 7788 vf_rxmode |= RTE_ETH_VMDQ_ACCEPT_BROADCAST; 7789 else if (!strncmp(res->mode, "MPE",3)) 7790 vf_rxmode |= RTE_ETH_VMDQ_ACCEPT_MULTICAST; 7791 } 7792 7793 RTE_SET_USED(is_on); 7794 RTE_SET_USED(vf_rxmode); 7795 7796 #ifdef RTE_NET_IXGBE 7797 if (ret == -ENOTSUP) 7798 ret = rte_pmd_ixgbe_set_vf_rxmode(res->port_id, res->vf_id, 7799 vf_rxmode, (uint8_t)is_on); 7800 #endif 7801 #ifdef RTE_NET_BNXT 7802 if (ret == -ENOTSUP) 7803 ret = rte_pmd_bnxt_set_vf_rxmode(res->port_id, res->vf_id, 7804 vf_rxmode, (uint8_t)is_on); 7805 #endif 7806 if (ret < 0) 7807 fprintf(stderr, 7808 "bad VF receive mode parameter, return code = %d\n", 7809 ret); 7810 } 7811 7812 static cmdline_parse_token_string_t cmd_set_vf_rxmode_set = 7813 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_rxmode, 7814 set, "set"); 7815 static cmdline_parse_token_string_t cmd_set_vf_rxmode_port = 7816 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_rxmode, 7817 port, "port"); 7818 static cmdline_parse_token_num_t cmd_set_vf_rxmode_portid = 7819 TOKEN_NUM_INITIALIZER(struct cmd_set_vf_rxmode, 7820 port_id, RTE_UINT16); 7821 static cmdline_parse_token_string_t cmd_set_vf_rxmode_vf = 7822 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_rxmode, 7823 vf, "vf"); 7824 static cmdline_parse_token_num_t cmd_set_vf_rxmode_vfid = 7825 TOKEN_NUM_INITIALIZER(struct cmd_set_vf_rxmode, 7826 vf_id, RTE_UINT8); 7827 static cmdline_parse_token_string_t cmd_set_vf_rxmode_what = 7828 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_rxmode, 7829 what, "rxmode"); 7830 static cmdline_parse_token_string_t cmd_set_vf_rxmode_mode = 7831 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_rxmode, 7832 mode, "AUPE#ROPE#BAM#MPE"); 7833 static cmdline_parse_token_string_t cmd_set_vf_rxmode_on = 7834 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_rxmode, 7835 on, "on#off"); 7836 7837 static cmdline_parse_inst_t cmd_set_vf_rxmode = { 7838 .f = cmd_set_vf_rxmode_parsed, 7839 .data = NULL, 7840 .help_str = "set port <port_id> vf <vf_id> rxmode " 7841 "AUPE|ROPE|BAM|MPE on|off", 7842 .tokens = { 7843 (void *)&cmd_set_vf_rxmode_set, 7844 (void *)&cmd_set_vf_rxmode_port, 7845 (void *)&cmd_set_vf_rxmode_portid, 7846 (void *)&cmd_set_vf_rxmode_vf, 7847 (void *)&cmd_set_vf_rxmode_vfid, 7848 (void *)&cmd_set_vf_rxmode_what, 7849 (void *)&cmd_set_vf_rxmode_mode, 7850 (void *)&cmd_set_vf_rxmode_on, 7851 NULL, 7852 }, 7853 }; 7854 7855 /* *** ADD MAC ADDRESS FILTER FOR A VF OF A PORT *** */ 7856 struct cmd_vf_mac_addr_result { 7857 cmdline_fixed_string_t mac_addr_cmd; 7858 cmdline_fixed_string_t what; 7859 cmdline_fixed_string_t port; 7860 uint16_t port_num; 7861 cmdline_fixed_string_t vf; 7862 uint8_t vf_num; 7863 struct rte_ether_addr address; 7864 }; 7865 7866 static void cmd_vf_mac_addr_parsed(void *parsed_result, 7867 __rte_unused struct cmdline *cl, 7868 __rte_unused void *data) 7869 { 7870 struct cmd_vf_mac_addr_result *res = parsed_result; 7871 int ret = -ENOTSUP; 7872 7873 if (strcmp(res->what, "add") != 0) 7874 return; 7875 7876 #ifdef RTE_NET_I40E 7877 if (ret == -ENOTSUP) 7878 ret = rte_pmd_i40e_add_vf_mac_addr(res->port_num, res->vf_num, 7879 &res->address); 7880 #endif 7881 #ifdef RTE_NET_BNXT 7882 if (ret == -ENOTSUP) 7883 ret = rte_pmd_bnxt_mac_addr_add(res->port_num, &res->address, 7884 res->vf_num); 7885 #endif 7886 7887 if(ret < 0) 7888 fprintf(stderr, "vf_mac_addr_cmd error: (%s)\n", strerror(-ret)); 7889 7890 } 7891 7892 static cmdline_parse_token_string_t cmd_vf_mac_addr_cmd = 7893 TOKEN_STRING_INITIALIZER(struct cmd_vf_mac_addr_result, 7894 mac_addr_cmd,"mac_addr"); 7895 static cmdline_parse_token_string_t cmd_vf_mac_addr_what = 7896 TOKEN_STRING_INITIALIZER(struct cmd_vf_mac_addr_result, 7897 what,"add"); 7898 static cmdline_parse_token_string_t cmd_vf_mac_addr_port = 7899 TOKEN_STRING_INITIALIZER(struct cmd_vf_mac_addr_result, 7900 port,"port"); 7901 static cmdline_parse_token_num_t cmd_vf_mac_addr_portnum = 7902 TOKEN_NUM_INITIALIZER(struct cmd_vf_mac_addr_result, 7903 port_num, RTE_UINT16); 7904 static cmdline_parse_token_string_t cmd_vf_mac_addr_vf = 7905 TOKEN_STRING_INITIALIZER(struct cmd_vf_mac_addr_result, 7906 vf,"vf"); 7907 static cmdline_parse_token_num_t cmd_vf_mac_addr_vfnum = 7908 TOKEN_NUM_INITIALIZER(struct cmd_vf_mac_addr_result, 7909 vf_num, RTE_UINT8); 7910 static cmdline_parse_token_etheraddr_t cmd_vf_mac_addr_addr = 7911 TOKEN_ETHERADDR_INITIALIZER(struct cmd_vf_mac_addr_result, 7912 address); 7913 7914 static cmdline_parse_inst_t cmd_vf_mac_addr_filter = { 7915 .f = cmd_vf_mac_addr_parsed, 7916 .data = (void *)0, 7917 .help_str = "mac_addr add port <port_id> vf <vf_id> <mac_addr>: " 7918 "Add MAC address filtering for a VF on port_id", 7919 .tokens = { 7920 (void *)&cmd_vf_mac_addr_cmd, 7921 (void *)&cmd_vf_mac_addr_what, 7922 (void *)&cmd_vf_mac_addr_port, 7923 (void *)&cmd_vf_mac_addr_portnum, 7924 (void *)&cmd_vf_mac_addr_vf, 7925 (void *)&cmd_vf_mac_addr_vfnum, 7926 (void *)&cmd_vf_mac_addr_addr, 7927 NULL, 7928 }, 7929 }; 7930 7931 /* *** ADD/REMOVE A VLAN IDENTIFIER TO/FROM A PORT VLAN RX FILTER *** */ 7932 struct cmd_vf_rx_vlan_filter { 7933 cmdline_fixed_string_t rx_vlan; 7934 cmdline_fixed_string_t what; 7935 uint16_t vlan_id; 7936 cmdline_fixed_string_t port; 7937 portid_t port_id; 7938 cmdline_fixed_string_t vf; 7939 uint64_t vf_mask; 7940 }; 7941 7942 static void 7943 cmd_vf_rx_vlan_filter_parsed(void *parsed_result, 7944 __rte_unused struct cmdline *cl, 7945 __rte_unused void *data) 7946 { 7947 struct cmd_vf_rx_vlan_filter *res = parsed_result; 7948 int ret = -ENOTSUP; 7949 7950 __rte_unused int is_add = (strcmp(res->what, "add") == 0) ? 1 : 0; 7951 7952 #ifdef RTE_NET_IXGBE 7953 if (ret == -ENOTSUP) 7954 ret = rte_pmd_ixgbe_set_vf_vlan_filter(res->port_id, 7955 res->vlan_id, res->vf_mask, is_add); 7956 #endif 7957 #ifdef RTE_NET_I40E 7958 if (ret == -ENOTSUP) 7959 ret = rte_pmd_i40e_set_vf_vlan_filter(res->port_id, 7960 res->vlan_id, res->vf_mask, is_add); 7961 #endif 7962 #ifdef RTE_NET_BNXT 7963 if (ret == -ENOTSUP) 7964 ret = rte_pmd_bnxt_set_vf_vlan_filter(res->port_id, 7965 res->vlan_id, res->vf_mask, is_add); 7966 #endif 7967 7968 switch (ret) { 7969 case 0: 7970 break; 7971 case -EINVAL: 7972 fprintf(stderr, "invalid vlan_id %d or vf_mask %"PRIu64"\n", 7973 res->vlan_id, res->vf_mask); 7974 break; 7975 case -ENODEV: 7976 fprintf(stderr, "invalid port_id %d\n", res->port_id); 7977 break; 7978 case -ENOTSUP: 7979 fprintf(stderr, "function not implemented or supported\n"); 7980 break; 7981 default: 7982 fprintf(stderr, "programming error: (%s)\n", strerror(-ret)); 7983 } 7984 } 7985 7986 static cmdline_parse_token_string_t cmd_vf_rx_vlan_filter_rx_vlan = 7987 TOKEN_STRING_INITIALIZER(struct cmd_vf_rx_vlan_filter, 7988 rx_vlan, "rx_vlan"); 7989 static cmdline_parse_token_string_t cmd_vf_rx_vlan_filter_what = 7990 TOKEN_STRING_INITIALIZER(struct cmd_vf_rx_vlan_filter, 7991 what, "add#rm"); 7992 static cmdline_parse_token_num_t cmd_vf_rx_vlan_filter_vlanid = 7993 TOKEN_NUM_INITIALIZER(struct cmd_vf_rx_vlan_filter, 7994 vlan_id, RTE_UINT16); 7995 static cmdline_parse_token_string_t cmd_vf_rx_vlan_filter_port = 7996 TOKEN_STRING_INITIALIZER(struct cmd_vf_rx_vlan_filter, 7997 port, "port"); 7998 static cmdline_parse_token_num_t cmd_vf_rx_vlan_filter_portid = 7999 TOKEN_NUM_INITIALIZER(struct cmd_vf_rx_vlan_filter, 8000 port_id, RTE_UINT16); 8001 static cmdline_parse_token_string_t cmd_vf_rx_vlan_filter_vf = 8002 TOKEN_STRING_INITIALIZER(struct cmd_vf_rx_vlan_filter, 8003 vf, "vf"); 8004 static cmdline_parse_token_num_t cmd_vf_rx_vlan_filter_vf_mask = 8005 TOKEN_NUM_INITIALIZER(struct cmd_vf_rx_vlan_filter, 8006 vf_mask, RTE_UINT64); 8007 8008 static cmdline_parse_inst_t cmd_vf_rxvlan_filter = { 8009 .f = cmd_vf_rx_vlan_filter_parsed, 8010 .data = NULL, 8011 .help_str = "rx_vlan add|rm <vlan_id> port <port_id> vf <vf_mask>: " 8012 "(vf_mask = hexadecimal VF mask)", 8013 .tokens = { 8014 (void *)&cmd_vf_rx_vlan_filter_rx_vlan, 8015 (void *)&cmd_vf_rx_vlan_filter_what, 8016 (void *)&cmd_vf_rx_vlan_filter_vlanid, 8017 (void *)&cmd_vf_rx_vlan_filter_port, 8018 (void *)&cmd_vf_rx_vlan_filter_portid, 8019 (void *)&cmd_vf_rx_vlan_filter_vf, 8020 (void *)&cmd_vf_rx_vlan_filter_vf_mask, 8021 NULL, 8022 }, 8023 }; 8024 8025 /* *** SET RATE LIMIT FOR A QUEUE OF A PORT *** */ 8026 struct cmd_queue_rate_limit_result { 8027 cmdline_fixed_string_t set; 8028 cmdline_fixed_string_t port; 8029 uint16_t port_num; 8030 cmdline_fixed_string_t queue; 8031 uint8_t queue_num; 8032 cmdline_fixed_string_t rate; 8033 uint32_t rate_num; 8034 }; 8035 8036 static void cmd_queue_rate_limit_parsed(void *parsed_result, 8037 __rte_unused struct cmdline *cl, 8038 __rte_unused void *data) 8039 { 8040 struct cmd_queue_rate_limit_result *res = parsed_result; 8041 int ret = 0; 8042 8043 if ((strcmp(res->set, "set") == 0) && (strcmp(res->port, "port") == 0) 8044 && (strcmp(res->queue, "queue") == 0) 8045 && (strcmp(res->rate, "rate") == 0)) 8046 ret = set_queue_rate_limit(res->port_num, res->queue_num, 8047 res->rate_num); 8048 if (ret < 0) 8049 fprintf(stderr, "queue_rate_limit_cmd error: (%s)\n", 8050 strerror(-ret)); 8051 8052 } 8053 8054 static cmdline_parse_token_string_t cmd_queue_rate_limit_set = 8055 TOKEN_STRING_INITIALIZER(struct cmd_queue_rate_limit_result, 8056 set, "set"); 8057 static cmdline_parse_token_string_t cmd_queue_rate_limit_port = 8058 TOKEN_STRING_INITIALIZER(struct cmd_queue_rate_limit_result, 8059 port, "port"); 8060 static cmdline_parse_token_num_t cmd_queue_rate_limit_portnum = 8061 TOKEN_NUM_INITIALIZER(struct cmd_queue_rate_limit_result, 8062 port_num, RTE_UINT16); 8063 static cmdline_parse_token_string_t cmd_queue_rate_limit_queue = 8064 TOKEN_STRING_INITIALIZER(struct cmd_queue_rate_limit_result, 8065 queue, "queue"); 8066 static cmdline_parse_token_num_t cmd_queue_rate_limit_queuenum = 8067 TOKEN_NUM_INITIALIZER(struct cmd_queue_rate_limit_result, 8068 queue_num, RTE_UINT8); 8069 static cmdline_parse_token_string_t cmd_queue_rate_limit_rate = 8070 TOKEN_STRING_INITIALIZER(struct cmd_queue_rate_limit_result, 8071 rate, "rate"); 8072 static cmdline_parse_token_num_t cmd_queue_rate_limit_ratenum = 8073 TOKEN_NUM_INITIALIZER(struct cmd_queue_rate_limit_result, 8074 rate_num, RTE_UINT32); 8075 8076 static cmdline_parse_inst_t cmd_queue_rate_limit = { 8077 .f = cmd_queue_rate_limit_parsed, 8078 .data = (void *)0, 8079 .help_str = "set port <port_id> queue <queue_id> rate <rate_value>: " 8080 "Set rate limit for a queue on port_id", 8081 .tokens = { 8082 (void *)&cmd_queue_rate_limit_set, 8083 (void *)&cmd_queue_rate_limit_port, 8084 (void *)&cmd_queue_rate_limit_portnum, 8085 (void *)&cmd_queue_rate_limit_queue, 8086 (void *)&cmd_queue_rate_limit_queuenum, 8087 (void *)&cmd_queue_rate_limit_rate, 8088 (void *)&cmd_queue_rate_limit_ratenum, 8089 NULL, 8090 }, 8091 }; 8092 8093 /* *** SET RATE LIMIT FOR A VF OF A PORT *** */ 8094 struct cmd_vf_rate_limit_result { 8095 cmdline_fixed_string_t set; 8096 cmdline_fixed_string_t port; 8097 uint16_t port_num; 8098 cmdline_fixed_string_t vf; 8099 uint8_t vf_num; 8100 cmdline_fixed_string_t rate; 8101 uint32_t rate_num; 8102 cmdline_fixed_string_t q_msk; 8103 uint64_t q_msk_val; 8104 }; 8105 8106 static void cmd_vf_rate_limit_parsed(void *parsed_result, 8107 __rte_unused struct cmdline *cl, 8108 __rte_unused void *data) 8109 { 8110 struct cmd_vf_rate_limit_result *res = parsed_result; 8111 int ret = 0; 8112 8113 if ((strcmp(res->set, "set") == 0) && (strcmp(res->port, "port") == 0) 8114 && (strcmp(res->vf, "vf") == 0) 8115 && (strcmp(res->rate, "rate") == 0) 8116 && (strcmp(res->q_msk, "queue_mask") == 0)) 8117 ret = set_vf_rate_limit(res->port_num, res->vf_num, 8118 res->rate_num, res->q_msk_val); 8119 if (ret < 0) 8120 fprintf(stderr, "vf_rate_limit_cmd error: (%s)\n", 8121 strerror(-ret)); 8122 8123 } 8124 8125 static cmdline_parse_token_string_t cmd_vf_rate_limit_set = 8126 TOKEN_STRING_INITIALIZER(struct cmd_vf_rate_limit_result, 8127 set, "set"); 8128 static cmdline_parse_token_string_t cmd_vf_rate_limit_port = 8129 TOKEN_STRING_INITIALIZER(struct cmd_vf_rate_limit_result, 8130 port, "port"); 8131 static cmdline_parse_token_num_t cmd_vf_rate_limit_portnum = 8132 TOKEN_NUM_INITIALIZER(struct cmd_vf_rate_limit_result, 8133 port_num, RTE_UINT16); 8134 static cmdline_parse_token_string_t cmd_vf_rate_limit_vf = 8135 TOKEN_STRING_INITIALIZER(struct cmd_vf_rate_limit_result, 8136 vf, "vf"); 8137 static cmdline_parse_token_num_t cmd_vf_rate_limit_vfnum = 8138 TOKEN_NUM_INITIALIZER(struct cmd_vf_rate_limit_result, 8139 vf_num, RTE_UINT8); 8140 static cmdline_parse_token_string_t cmd_vf_rate_limit_rate = 8141 TOKEN_STRING_INITIALIZER(struct cmd_vf_rate_limit_result, 8142 rate, "rate"); 8143 static cmdline_parse_token_num_t cmd_vf_rate_limit_ratenum = 8144 TOKEN_NUM_INITIALIZER(struct cmd_vf_rate_limit_result, 8145 rate_num, RTE_UINT32); 8146 static cmdline_parse_token_string_t cmd_vf_rate_limit_q_msk = 8147 TOKEN_STRING_INITIALIZER(struct cmd_vf_rate_limit_result, 8148 q_msk, "queue_mask"); 8149 static cmdline_parse_token_num_t cmd_vf_rate_limit_q_msk_val = 8150 TOKEN_NUM_INITIALIZER(struct cmd_vf_rate_limit_result, 8151 q_msk_val, RTE_UINT64); 8152 8153 static cmdline_parse_inst_t cmd_vf_rate_limit = { 8154 .f = cmd_vf_rate_limit_parsed, 8155 .data = (void *)0, 8156 .help_str = "set port <port_id> vf <vf_id> rate <rate_value> " 8157 "queue_mask <queue_mask_value>: " 8158 "Set rate limit for queues of VF on port_id", 8159 .tokens = { 8160 (void *)&cmd_vf_rate_limit_set, 8161 (void *)&cmd_vf_rate_limit_port, 8162 (void *)&cmd_vf_rate_limit_portnum, 8163 (void *)&cmd_vf_rate_limit_vf, 8164 (void *)&cmd_vf_rate_limit_vfnum, 8165 (void *)&cmd_vf_rate_limit_rate, 8166 (void *)&cmd_vf_rate_limit_ratenum, 8167 (void *)&cmd_vf_rate_limit_q_msk, 8168 (void *)&cmd_vf_rate_limit_q_msk_val, 8169 NULL, 8170 }, 8171 }; 8172 8173 /* *** CONFIGURE TUNNEL UDP PORT *** */ 8174 struct cmd_tunnel_udp_config { 8175 cmdline_fixed_string_t rx_vxlan_port; 8176 cmdline_fixed_string_t what; 8177 uint16_t udp_port; 8178 portid_t port_id; 8179 }; 8180 8181 static void 8182 cmd_tunnel_udp_config_parsed(void *parsed_result, 8183 __rte_unused struct cmdline *cl, 8184 __rte_unused void *data) 8185 { 8186 struct cmd_tunnel_udp_config *res = parsed_result; 8187 struct rte_eth_udp_tunnel tunnel_udp; 8188 int ret; 8189 8190 tunnel_udp.udp_port = res->udp_port; 8191 tunnel_udp.prot_type = RTE_ETH_TUNNEL_TYPE_VXLAN; 8192 8193 if (!strcmp(res->what, "add")) 8194 ret = rte_eth_dev_udp_tunnel_port_add(res->port_id, 8195 &tunnel_udp); 8196 else 8197 ret = rte_eth_dev_udp_tunnel_port_delete(res->port_id, 8198 &tunnel_udp); 8199 8200 if (ret < 0) 8201 fprintf(stderr, "udp tunneling add error: (%s)\n", 8202 strerror(-ret)); 8203 } 8204 8205 static cmdline_parse_token_string_t cmd_tunnel_udp_config_rx_vxlan_port = 8206 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_udp_config, 8207 rx_vxlan_port, "rx_vxlan_port"); 8208 static cmdline_parse_token_string_t cmd_tunnel_udp_config_what = 8209 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_udp_config, 8210 what, "add#rm"); 8211 static cmdline_parse_token_num_t cmd_tunnel_udp_config_udp_port = 8212 TOKEN_NUM_INITIALIZER(struct cmd_tunnel_udp_config, 8213 udp_port, RTE_UINT16); 8214 static cmdline_parse_token_num_t cmd_tunnel_udp_config_port_id = 8215 TOKEN_NUM_INITIALIZER(struct cmd_tunnel_udp_config, 8216 port_id, RTE_UINT16); 8217 8218 static cmdline_parse_inst_t cmd_tunnel_udp_config = { 8219 .f = cmd_tunnel_udp_config_parsed, 8220 .data = (void *)0, 8221 .help_str = "rx_vxlan_port add|rm <udp_port> <port_id>: " 8222 "Add/Remove a tunneling UDP port filter", 8223 .tokens = { 8224 (void *)&cmd_tunnel_udp_config_rx_vxlan_port, 8225 (void *)&cmd_tunnel_udp_config_what, 8226 (void *)&cmd_tunnel_udp_config_udp_port, 8227 (void *)&cmd_tunnel_udp_config_port_id, 8228 NULL, 8229 }, 8230 }; 8231 8232 struct cmd_config_tunnel_udp_port { 8233 cmdline_fixed_string_t port; 8234 cmdline_fixed_string_t config; 8235 portid_t port_id; 8236 cmdline_fixed_string_t udp_tunnel_port; 8237 cmdline_fixed_string_t action; 8238 cmdline_fixed_string_t tunnel_type; 8239 uint16_t udp_port; 8240 }; 8241 8242 static void 8243 cmd_cfg_tunnel_udp_port_parsed(void *parsed_result, 8244 __rte_unused struct cmdline *cl, 8245 __rte_unused void *data) 8246 { 8247 struct cmd_config_tunnel_udp_port *res = parsed_result; 8248 struct rte_eth_udp_tunnel tunnel_udp; 8249 int ret = 0; 8250 8251 if (port_id_is_invalid(res->port_id, ENABLED_WARN)) 8252 return; 8253 8254 tunnel_udp.udp_port = res->udp_port; 8255 8256 if (!strcmp(res->tunnel_type, "vxlan")) { 8257 tunnel_udp.prot_type = RTE_ETH_TUNNEL_TYPE_VXLAN; 8258 } else if (!strcmp(res->tunnel_type, "geneve")) { 8259 tunnel_udp.prot_type = RTE_ETH_TUNNEL_TYPE_GENEVE; 8260 } else if (!strcmp(res->tunnel_type, "vxlan-gpe")) { 8261 tunnel_udp.prot_type = RTE_ETH_TUNNEL_TYPE_VXLAN_GPE; 8262 } else if (!strcmp(res->tunnel_type, "ecpri")) { 8263 tunnel_udp.prot_type = RTE_ETH_TUNNEL_TYPE_ECPRI; 8264 } else { 8265 fprintf(stderr, "Invalid tunnel type\n"); 8266 return; 8267 } 8268 8269 if (!strcmp(res->action, "add")) 8270 ret = rte_eth_dev_udp_tunnel_port_add(res->port_id, 8271 &tunnel_udp); 8272 else 8273 ret = rte_eth_dev_udp_tunnel_port_delete(res->port_id, 8274 &tunnel_udp); 8275 8276 if (ret < 0) 8277 fprintf(stderr, "udp tunneling port add error: (%s)\n", 8278 strerror(-ret)); 8279 } 8280 8281 static cmdline_parse_token_string_t cmd_config_tunnel_udp_port_port = 8282 TOKEN_STRING_INITIALIZER(struct cmd_config_tunnel_udp_port, port, 8283 "port"); 8284 static cmdline_parse_token_string_t cmd_config_tunnel_udp_port_config = 8285 TOKEN_STRING_INITIALIZER(struct cmd_config_tunnel_udp_port, config, 8286 "config"); 8287 static cmdline_parse_token_num_t cmd_config_tunnel_udp_port_port_id = 8288 TOKEN_NUM_INITIALIZER(struct cmd_config_tunnel_udp_port, port_id, 8289 RTE_UINT16); 8290 static cmdline_parse_token_string_t cmd_config_tunnel_udp_port_tunnel_port = 8291 TOKEN_STRING_INITIALIZER(struct cmd_config_tunnel_udp_port, 8292 udp_tunnel_port, 8293 "udp_tunnel_port"); 8294 static cmdline_parse_token_string_t cmd_config_tunnel_udp_port_action = 8295 TOKEN_STRING_INITIALIZER(struct cmd_config_tunnel_udp_port, action, 8296 "add#rm"); 8297 static cmdline_parse_token_string_t cmd_config_tunnel_udp_port_tunnel_type = 8298 TOKEN_STRING_INITIALIZER(struct cmd_config_tunnel_udp_port, tunnel_type, 8299 "vxlan#geneve#vxlan-gpe#ecpri"); 8300 static cmdline_parse_token_num_t cmd_config_tunnel_udp_port_value = 8301 TOKEN_NUM_INITIALIZER(struct cmd_config_tunnel_udp_port, udp_port, 8302 RTE_UINT16); 8303 8304 static cmdline_parse_inst_t cmd_cfg_tunnel_udp_port = { 8305 .f = cmd_cfg_tunnel_udp_port_parsed, 8306 .data = NULL, 8307 .help_str = "port config <port_id> udp_tunnel_port add|rm vxlan|" 8308 "geneve|vxlan-gpe|ecpri <udp_port>", 8309 .tokens = { 8310 (void *)&cmd_config_tunnel_udp_port_port, 8311 (void *)&cmd_config_tunnel_udp_port_config, 8312 (void *)&cmd_config_tunnel_udp_port_port_id, 8313 (void *)&cmd_config_tunnel_udp_port_tunnel_port, 8314 (void *)&cmd_config_tunnel_udp_port_action, 8315 (void *)&cmd_config_tunnel_udp_port_tunnel_type, 8316 (void *)&cmd_config_tunnel_udp_port_value, 8317 NULL, 8318 }, 8319 }; 8320 8321 /* ******************************************************************************** */ 8322 8323 struct cmd_dump_result { 8324 cmdline_fixed_string_t dump; 8325 }; 8326 8327 static void 8328 dump_struct_sizes(void) 8329 { 8330 #define DUMP_SIZE(t) printf("sizeof(" #t ") = %u\n", (unsigned)sizeof(t)); 8331 DUMP_SIZE(struct rte_mbuf); 8332 DUMP_SIZE(struct rte_mempool); 8333 DUMP_SIZE(struct rte_ring); 8334 #undef DUMP_SIZE 8335 } 8336 8337 8338 /* Dump the socket memory statistics on console */ 8339 static void 8340 dump_socket_mem(FILE *f) 8341 { 8342 struct rte_malloc_socket_stats socket_stats; 8343 unsigned int i; 8344 size_t total = 0; 8345 size_t alloc = 0; 8346 size_t free = 0; 8347 unsigned int n_alloc = 0; 8348 unsigned int n_free = 0; 8349 static size_t last_allocs; 8350 static size_t last_total; 8351 8352 8353 for (i = 0; i < RTE_MAX_NUMA_NODES; i++) { 8354 if (rte_malloc_get_socket_stats(i, &socket_stats) || 8355 !socket_stats.heap_totalsz_bytes) 8356 continue; 8357 total += socket_stats.heap_totalsz_bytes; 8358 alloc += socket_stats.heap_allocsz_bytes; 8359 free += socket_stats.heap_freesz_bytes; 8360 n_alloc += socket_stats.alloc_count; 8361 n_free += socket_stats.free_count; 8362 fprintf(f, 8363 "Socket %u: size(M) total: %.6lf alloc: %.6lf(%.3lf%%) free: %.6lf \tcount alloc: %-4u free: %u\n", 8364 i, 8365 (double)socket_stats.heap_totalsz_bytes / (1024 * 1024), 8366 (double)socket_stats.heap_allocsz_bytes / (1024 * 1024), 8367 (double)socket_stats.heap_allocsz_bytes * 100 / 8368 (double)socket_stats.heap_totalsz_bytes, 8369 (double)socket_stats.heap_freesz_bytes / (1024 * 1024), 8370 socket_stats.alloc_count, 8371 socket_stats.free_count); 8372 } 8373 fprintf(f, 8374 "Total : size(M) total: %.6lf alloc: %.6lf(%.3lf%%) free: %.6lf \tcount alloc: %-4u free: %u\n", 8375 (double)total / (1024 * 1024), (double)alloc / (1024 * 1024), 8376 total ? ((double)alloc * 100 / (double)total) : 0, 8377 (double)free / (1024 * 1024), 8378 n_alloc, n_free); 8379 if (last_allocs) 8380 fprintf(stdout, "Memory total change: %.6lf(M), allocation change: %.6lf(M)\n", 8381 ((double)total - (double)last_total) / (1024 * 1024), 8382 (double)(alloc - (double)last_allocs) / 1024 / 1024); 8383 last_allocs = alloc; 8384 last_total = total; 8385 } 8386 8387 static void cmd_dump_parsed(void *parsed_result, 8388 __rte_unused struct cmdline *cl, 8389 __rte_unused void *data) 8390 { 8391 struct cmd_dump_result *res = parsed_result; 8392 8393 if (!strcmp(res->dump, "dump_physmem")) 8394 rte_dump_physmem_layout(stdout); 8395 else if (!strcmp(res->dump, "dump_socket_mem")) 8396 dump_socket_mem(stdout); 8397 else if (!strcmp(res->dump, "dump_memzone")) 8398 rte_memzone_dump(stdout); 8399 else if (!strcmp(res->dump, "dump_struct_sizes")) 8400 dump_struct_sizes(); 8401 else if (!strcmp(res->dump, "dump_ring")) 8402 rte_ring_list_dump(stdout); 8403 else if (!strcmp(res->dump, "dump_mempool")) 8404 rte_mempool_list_dump(stdout); 8405 else if (!strcmp(res->dump, "dump_devargs")) 8406 rte_devargs_dump(stdout); 8407 else if (!strcmp(res->dump, "dump_lcores")) 8408 rte_lcore_dump(stdout); 8409 #ifndef RTE_EXEC_ENV_WINDOWS 8410 else if (!strcmp(res->dump, "dump_trace")) 8411 rte_trace_save(); 8412 #endif 8413 else if (!strcmp(res->dump, "dump_log_types")) 8414 rte_log_dump(stdout); 8415 } 8416 8417 static cmdline_parse_token_string_t cmd_dump_dump = 8418 TOKEN_STRING_INITIALIZER(struct cmd_dump_result, dump, 8419 "dump_physmem#" 8420 "dump_memzone#" 8421 "dump_socket_mem#" 8422 "dump_struct_sizes#" 8423 "dump_ring#" 8424 "dump_mempool#" 8425 "dump_devargs#" 8426 "dump_lcores#" 8427 #ifndef RTE_EXEC_ENV_WINDOWS 8428 "dump_trace#" 8429 #endif 8430 "dump_log_types"); 8431 8432 static cmdline_parse_inst_t cmd_dump = { 8433 .f = cmd_dump_parsed, /* function to call */ 8434 .data = NULL, /* 2nd arg of func */ 8435 .help_str = "Dump status", 8436 .tokens = { /* token list, NULL terminated */ 8437 (void *)&cmd_dump_dump, 8438 NULL, 8439 }, 8440 }; 8441 8442 /* ******************************************************************************** */ 8443 8444 struct cmd_dump_one_result { 8445 cmdline_fixed_string_t dump; 8446 cmdline_fixed_string_t name; 8447 }; 8448 8449 static void cmd_dump_one_parsed(void *parsed_result, struct cmdline *cl, 8450 __rte_unused void *data) 8451 { 8452 struct cmd_dump_one_result *res = parsed_result; 8453 8454 if (!strcmp(res->dump, "dump_ring")) { 8455 struct rte_ring *r; 8456 r = rte_ring_lookup(res->name); 8457 if (r == NULL) { 8458 cmdline_printf(cl, "Cannot find ring\n"); 8459 return; 8460 } 8461 rte_ring_dump(stdout, r); 8462 } else if (!strcmp(res->dump, "dump_mempool")) { 8463 struct rte_mempool *mp; 8464 mp = rte_mempool_lookup(res->name); 8465 if (mp == NULL) { 8466 cmdline_printf(cl, "Cannot find mempool\n"); 8467 return; 8468 } 8469 rte_mempool_dump(stdout, mp); 8470 } 8471 } 8472 8473 static cmdline_parse_token_string_t cmd_dump_one_dump = 8474 TOKEN_STRING_INITIALIZER(struct cmd_dump_one_result, dump, 8475 "dump_ring#dump_mempool"); 8476 8477 static cmdline_parse_token_string_t cmd_dump_one_name = 8478 TOKEN_STRING_INITIALIZER(struct cmd_dump_one_result, name, NULL); 8479 8480 static cmdline_parse_inst_t cmd_dump_one = { 8481 .f = cmd_dump_one_parsed, /* function to call */ 8482 .data = NULL, /* 2nd arg of func */ 8483 .help_str = "dump_ring|dump_mempool <name>: Dump one ring/mempool", 8484 .tokens = { /* token list, NULL terminated */ 8485 (void *)&cmd_dump_one_dump, 8486 (void *)&cmd_dump_one_name, 8487 NULL, 8488 }, 8489 }; 8490 8491 /* *** Filters Control *** */ 8492 8493 #define IPV4_ADDR_TO_UINT(ip_addr, ip) \ 8494 do { \ 8495 if ((ip_addr).family == AF_INET) \ 8496 (ip) = (ip_addr).addr.ipv4.s_addr; \ 8497 else { \ 8498 fprintf(stderr, "invalid parameter.\n"); \ 8499 return; \ 8500 } \ 8501 } while (0) 8502 8503 #define IPV6_ADDR_TO_ARRAY(ip_addr, ip) \ 8504 do { \ 8505 if ((ip_addr).family == AF_INET6) \ 8506 rte_memcpy(&(ip), \ 8507 &((ip_addr).addr.ipv6), \ 8508 sizeof(struct in6_addr)); \ 8509 else { \ 8510 fprintf(stderr, "invalid parameter.\n"); \ 8511 return; \ 8512 } \ 8513 } while (0) 8514 8515 /* Generic flow interface command. */ 8516 extern cmdline_parse_inst_t cmd_flow; 8517 8518 /* *** ADD/REMOVE A MULTICAST MAC ADDRESS TO/FROM A PORT *** */ 8519 struct cmd_mcast_addr_result { 8520 cmdline_fixed_string_t mcast_addr_cmd; 8521 cmdline_fixed_string_t what; 8522 uint16_t port_num; 8523 struct rte_ether_addr mc_addr; 8524 }; 8525 8526 static void cmd_mcast_addr_parsed(void *parsed_result, 8527 __rte_unused struct cmdline *cl, 8528 __rte_unused void *data) 8529 { 8530 struct cmd_mcast_addr_result *res = parsed_result; 8531 8532 if (!rte_is_multicast_ether_addr(&res->mc_addr)) { 8533 fprintf(stderr, 8534 "Invalid multicast addr " RTE_ETHER_ADDR_PRT_FMT "\n", 8535 RTE_ETHER_ADDR_BYTES(&res->mc_addr)); 8536 return; 8537 } 8538 if (strcmp(res->what, "add") == 0) 8539 mcast_addr_add(res->port_num, &res->mc_addr); 8540 else 8541 mcast_addr_remove(res->port_num, &res->mc_addr); 8542 } 8543 8544 static cmdline_parse_token_string_t cmd_mcast_addr_cmd = 8545 TOKEN_STRING_INITIALIZER(struct cmd_mcast_addr_result, 8546 mcast_addr_cmd, "mcast_addr"); 8547 static cmdline_parse_token_string_t cmd_mcast_addr_what = 8548 TOKEN_STRING_INITIALIZER(struct cmd_mcast_addr_result, what, 8549 "add#remove"); 8550 static cmdline_parse_token_num_t cmd_mcast_addr_portnum = 8551 TOKEN_NUM_INITIALIZER(struct cmd_mcast_addr_result, port_num, 8552 RTE_UINT16); 8553 static cmdline_parse_token_etheraddr_t cmd_mcast_addr_addr = 8554 TOKEN_ETHERADDR_INITIALIZER(struct cmd_mac_addr_result, address); 8555 8556 static cmdline_parse_inst_t cmd_mcast_addr = { 8557 .f = cmd_mcast_addr_parsed, 8558 .data = (void *)0, 8559 .help_str = "mcast_addr add|remove <port_id> <mcast_addr>: " 8560 "Add/Remove multicast MAC address on port_id", 8561 .tokens = { 8562 (void *)&cmd_mcast_addr_cmd, 8563 (void *)&cmd_mcast_addr_what, 8564 (void *)&cmd_mcast_addr_portnum, 8565 (void *)&cmd_mcast_addr_addr, 8566 NULL, 8567 }, 8568 }; 8569 8570 /* vf vlan anti spoof configuration */ 8571 8572 /* Common result structure for vf vlan anti spoof */ 8573 struct cmd_vf_vlan_anti_spoof_result { 8574 cmdline_fixed_string_t set; 8575 cmdline_fixed_string_t vf; 8576 cmdline_fixed_string_t vlan; 8577 cmdline_fixed_string_t antispoof; 8578 portid_t port_id; 8579 uint32_t vf_id; 8580 cmdline_fixed_string_t on_off; 8581 }; 8582 8583 /* Common CLI fields for vf vlan anti spoof enable disable */ 8584 static cmdline_parse_token_string_t cmd_vf_vlan_anti_spoof_set = 8585 TOKEN_STRING_INITIALIZER 8586 (struct cmd_vf_vlan_anti_spoof_result, 8587 set, "set"); 8588 static cmdline_parse_token_string_t cmd_vf_vlan_anti_spoof_vf = 8589 TOKEN_STRING_INITIALIZER 8590 (struct cmd_vf_vlan_anti_spoof_result, 8591 vf, "vf"); 8592 static cmdline_parse_token_string_t cmd_vf_vlan_anti_spoof_vlan = 8593 TOKEN_STRING_INITIALIZER 8594 (struct cmd_vf_vlan_anti_spoof_result, 8595 vlan, "vlan"); 8596 static cmdline_parse_token_string_t cmd_vf_vlan_anti_spoof_antispoof = 8597 TOKEN_STRING_INITIALIZER 8598 (struct cmd_vf_vlan_anti_spoof_result, 8599 antispoof, "antispoof"); 8600 static cmdline_parse_token_num_t cmd_vf_vlan_anti_spoof_port_id = 8601 TOKEN_NUM_INITIALIZER 8602 (struct cmd_vf_vlan_anti_spoof_result, 8603 port_id, RTE_UINT16); 8604 static cmdline_parse_token_num_t cmd_vf_vlan_anti_spoof_vf_id = 8605 TOKEN_NUM_INITIALIZER 8606 (struct cmd_vf_vlan_anti_spoof_result, 8607 vf_id, RTE_UINT32); 8608 static cmdline_parse_token_string_t cmd_vf_vlan_anti_spoof_on_off = 8609 TOKEN_STRING_INITIALIZER 8610 (struct cmd_vf_vlan_anti_spoof_result, 8611 on_off, "on#off"); 8612 8613 static void 8614 cmd_set_vf_vlan_anti_spoof_parsed( 8615 void *parsed_result, 8616 __rte_unused struct cmdline *cl, 8617 __rte_unused void *data) 8618 { 8619 struct cmd_vf_vlan_anti_spoof_result *res = parsed_result; 8620 int ret = -ENOTSUP; 8621 8622 __rte_unused int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0; 8623 8624 if (port_id_is_invalid(res->port_id, ENABLED_WARN)) 8625 return; 8626 8627 #ifdef RTE_NET_IXGBE 8628 if (ret == -ENOTSUP) 8629 ret = rte_pmd_ixgbe_set_vf_vlan_anti_spoof(res->port_id, 8630 res->vf_id, is_on); 8631 #endif 8632 #ifdef RTE_NET_I40E 8633 if (ret == -ENOTSUP) 8634 ret = rte_pmd_i40e_set_vf_vlan_anti_spoof(res->port_id, 8635 res->vf_id, is_on); 8636 #endif 8637 #ifdef RTE_NET_BNXT 8638 if (ret == -ENOTSUP) 8639 ret = rte_pmd_bnxt_set_vf_vlan_anti_spoof(res->port_id, 8640 res->vf_id, is_on); 8641 #endif 8642 8643 switch (ret) { 8644 case 0: 8645 break; 8646 case -EINVAL: 8647 fprintf(stderr, "invalid vf_id %d\n", res->vf_id); 8648 break; 8649 case -ENODEV: 8650 fprintf(stderr, "invalid port_id %d\n", res->port_id); 8651 break; 8652 case -ENOTSUP: 8653 fprintf(stderr, "function not implemented\n"); 8654 break; 8655 default: 8656 fprintf(stderr, "programming error: (%s)\n", strerror(-ret)); 8657 } 8658 } 8659 8660 static cmdline_parse_inst_t cmd_set_vf_vlan_anti_spoof = { 8661 .f = cmd_set_vf_vlan_anti_spoof_parsed, 8662 .data = NULL, 8663 .help_str = "set vf vlan antispoof <port_id> <vf_id> on|off", 8664 .tokens = { 8665 (void *)&cmd_vf_vlan_anti_spoof_set, 8666 (void *)&cmd_vf_vlan_anti_spoof_vf, 8667 (void *)&cmd_vf_vlan_anti_spoof_vlan, 8668 (void *)&cmd_vf_vlan_anti_spoof_antispoof, 8669 (void *)&cmd_vf_vlan_anti_spoof_port_id, 8670 (void *)&cmd_vf_vlan_anti_spoof_vf_id, 8671 (void *)&cmd_vf_vlan_anti_spoof_on_off, 8672 NULL, 8673 }, 8674 }; 8675 8676 /* vf mac anti spoof configuration */ 8677 8678 /* Common result structure for vf mac anti spoof */ 8679 struct cmd_vf_mac_anti_spoof_result { 8680 cmdline_fixed_string_t set; 8681 cmdline_fixed_string_t vf; 8682 cmdline_fixed_string_t mac; 8683 cmdline_fixed_string_t antispoof; 8684 portid_t port_id; 8685 uint32_t vf_id; 8686 cmdline_fixed_string_t on_off; 8687 }; 8688 8689 /* Common CLI fields for vf mac anti spoof enable disable */ 8690 static cmdline_parse_token_string_t cmd_vf_mac_anti_spoof_set = 8691 TOKEN_STRING_INITIALIZER 8692 (struct cmd_vf_mac_anti_spoof_result, 8693 set, "set"); 8694 static cmdline_parse_token_string_t cmd_vf_mac_anti_spoof_vf = 8695 TOKEN_STRING_INITIALIZER 8696 (struct cmd_vf_mac_anti_spoof_result, 8697 vf, "vf"); 8698 static cmdline_parse_token_string_t cmd_vf_mac_anti_spoof_mac = 8699 TOKEN_STRING_INITIALIZER 8700 (struct cmd_vf_mac_anti_spoof_result, 8701 mac, "mac"); 8702 static cmdline_parse_token_string_t cmd_vf_mac_anti_spoof_antispoof = 8703 TOKEN_STRING_INITIALIZER 8704 (struct cmd_vf_mac_anti_spoof_result, 8705 antispoof, "antispoof"); 8706 static cmdline_parse_token_num_t cmd_vf_mac_anti_spoof_port_id = 8707 TOKEN_NUM_INITIALIZER 8708 (struct cmd_vf_mac_anti_spoof_result, 8709 port_id, RTE_UINT16); 8710 static cmdline_parse_token_num_t cmd_vf_mac_anti_spoof_vf_id = 8711 TOKEN_NUM_INITIALIZER 8712 (struct cmd_vf_mac_anti_spoof_result, 8713 vf_id, RTE_UINT32); 8714 static cmdline_parse_token_string_t cmd_vf_mac_anti_spoof_on_off = 8715 TOKEN_STRING_INITIALIZER 8716 (struct cmd_vf_mac_anti_spoof_result, 8717 on_off, "on#off"); 8718 8719 static void 8720 cmd_set_vf_mac_anti_spoof_parsed( 8721 void *parsed_result, 8722 __rte_unused struct cmdline *cl, 8723 __rte_unused void *data) 8724 { 8725 struct cmd_vf_mac_anti_spoof_result *res = parsed_result; 8726 int ret = -ENOTSUP; 8727 8728 __rte_unused int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0; 8729 8730 if (port_id_is_invalid(res->port_id, ENABLED_WARN)) 8731 return; 8732 8733 #ifdef RTE_NET_IXGBE 8734 if (ret == -ENOTSUP) 8735 ret = rte_pmd_ixgbe_set_vf_mac_anti_spoof(res->port_id, 8736 res->vf_id, is_on); 8737 #endif 8738 #ifdef RTE_NET_I40E 8739 if (ret == -ENOTSUP) 8740 ret = rte_pmd_i40e_set_vf_mac_anti_spoof(res->port_id, 8741 res->vf_id, is_on); 8742 #endif 8743 #ifdef RTE_NET_BNXT 8744 if (ret == -ENOTSUP) 8745 ret = rte_pmd_bnxt_set_vf_mac_anti_spoof(res->port_id, 8746 res->vf_id, is_on); 8747 #endif 8748 8749 switch (ret) { 8750 case 0: 8751 break; 8752 case -EINVAL: 8753 fprintf(stderr, "invalid vf_id %d or is_on %d\n", 8754 res->vf_id, is_on); 8755 break; 8756 case -ENODEV: 8757 fprintf(stderr, "invalid port_id %d\n", res->port_id); 8758 break; 8759 case -ENOTSUP: 8760 fprintf(stderr, "function not implemented\n"); 8761 break; 8762 default: 8763 fprintf(stderr, "programming error: (%s)\n", strerror(-ret)); 8764 } 8765 } 8766 8767 static cmdline_parse_inst_t cmd_set_vf_mac_anti_spoof = { 8768 .f = cmd_set_vf_mac_anti_spoof_parsed, 8769 .data = NULL, 8770 .help_str = "set vf mac antispoof <port_id> <vf_id> on|off", 8771 .tokens = { 8772 (void *)&cmd_vf_mac_anti_spoof_set, 8773 (void *)&cmd_vf_mac_anti_spoof_vf, 8774 (void *)&cmd_vf_mac_anti_spoof_mac, 8775 (void *)&cmd_vf_mac_anti_spoof_antispoof, 8776 (void *)&cmd_vf_mac_anti_spoof_port_id, 8777 (void *)&cmd_vf_mac_anti_spoof_vf_id, 8778 (void *)&cmd_vf_mac_anti_spoof_on_off, 8779 NULL, 8780 }, 8781 }; 8782 8783 /* vf vlan strip queue configuration */ 8784 8785 /* Common result structure for vf mac anti spoof */ 8786 struct cmd_vf_vlan_stripq_result { 8787 cmdline_fixed_string_t set; 8788 cmdline_fixed_string_t vf; 8789 cmdline_fixed_string_t vlan; 8790 cmdline_fixed_string_t stripq; 8791 portid_t port_id; 8792 uint16_t vf_id; 8793 cmdline_fixed_string_t on_off; 8794 }; 8795 8796 /* Common CLI fields for vf vlan strip enable disable */ 8797 static cmdline_parse_token_string_t cmd_vf_vlan_stripq_set = 8798 TOKEN_STRING_INITIALIZER 8799 (struct cmd_vf_vlan_stripq_result, 8800 set, "set"); 8801 static cmdline_parse_token_string_t cmd_vf_vlan_stripq_vf = 8802 TOKEN_STRING_INITIALIZER 8803 (struct cmd_vf_vlan_stripq_result, 8804 vf, "vf"); 8805 static cmdline_parse_token_string_t cmd_vf_vlan_stripq_vlan = 8806 TOKEN_STRING_INITIALIZER 8807 (struct cmd_vf_vlan_stripq_result, 8808 vlan, "vlan"); 8809 static cmdline_parse_token_string_t cmd_vf_vlan_stripq_stripq = 8810 TOKEN_STRING_INITIALIZER 8811 (struct cmd_vf_vlan_stripq_result, 8812 stripq, "stripq"); 8813 static cmdline_parse_token_num_t cmd_vf_vlan_stripq_port_id = 8814 TOKEN_NUM_INITIALIZER 8815 (struct cmd_vf_vlan_stripq_result, 8816 port_id, RTE_UINT16); 8817 static cmdline_parse_token_num_t cmd_vf_vlan_stripq_vf_id = 8818 TOKEN_NUM_INITIALIZER 8819 (struct cmd_vf_vlan_stripq_result, 8820 vf_id, RTE_UINT16); 8821 static cmdline_parse_token_string_t cmd_vf_vlan_stripq_on_off = 8822 TOKEN_STRING_INITIALIZER 8823 (struct cmd_vf_vlan_stripq_result, 8824 on_off, "on#off"); 8825 8826 static void 8827 cmd_set_vf_vlan_stripq_parsed( 8828 void *parsed_result, 8829 __rte_unused struct cmdline *cl, 8830 __rte_unused void *data) 8831 { 8832 struct cmd_vf_vlan_stripq_result *res = parsed_result; 8833 int ret = -ENOTSUP; 8834 8835 __rte_unused int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0; 8836 8837 if (port_id_is_invalid(res->port_id, ENABLED_WARN)) 8838 return; 8839 8840 #ifdef RTE_NET_IXGBE 8841 if (ret == -ENOTSUP) 8842 ret = rte_pmd_ixgbe_set_vf_vlan_stripq(res->port_id, 8843 res->vf_id, is_on); 8844 #endif 8845 #ifdef RTE_NET_I40E 8846 if (ret == -ENOTSUP) 8847 ret = rte_pmd_i40e_set_vf_vlan_stripq(res->port_id, 8848 res->vf_id, is_on); 8849 #endif 8850 #ifdef RTE_NET_BNXT 8851 if (ret == -ENOTSUP) 8852 ret = rte_pmd_bnxt_set_vf_vlan_stripq(res->port_id, 8853 res->vf_id, is_on); 8854 #endif 8855 8856 switch (ret) { 8857 case 0: 8858 break; 8859 case -EINVAL: 8860 fprintf(stderr, "invalid vf_id %d or is_on %d\n", 8861 res->vf_id, is_on); 8862 break; 8863 case -ENODEV: 8864 fprintf(stderr, "invalid port_id %d\n", res->port_id); 8865 break; 8866 case -ENOTSUP: 8867 fprintf(stderr, "function not implemented\n"); 8868 break; 8869 default: 8870 fprintf(stderr, "programming error: (%s)\n", strerror(-ret)); 8871 } 8872 } 8873 8874 static cmdline_parse_inst_t cmd_set_vf_vlan_stripq = { 8875 .f = cmd_set_vf_vlan_stripq_parsed, 8876 .data = NULL, 8877 .help_str = "set vf vlan stripq <port_id> <vf_id> on|off", 8878 .tokens = { 8879 (void *)&cmd_vf_vlan_stripq_set, 8880 (void *)&cmd_vf_vlan_stripq_vf, 8881 (void *)&cmd_vf_vlan_stripq_vlan, 8882 (void *)&cmd_vf_vlan_stripq_stripq, 8883 (void *)&cmd_vf_vlan_stripq_port_id, 8884 (void *)&cmd_vf_vlan_stripq_vf_id, 8885 (void *)&cmd_vf_vlan_stripq_on_off, 8886 NULL, 8887 }, 8888 }; 8889 8890 /* vf vlan insert configuration */ 8891 8892 /* Common result structure for vf vlan insert */ 8893 struct cmd_vf_vlan_insert_result { 8894 cmdline_fixed_string_t set; 8895 cmdline_fixed_string_t vf; 8896 cmdline_fixed_string_t vlan; 8897 cmdline_fixed_string_t insert; 8898 portid_t port_id; 8899 uint16_t vf_id; 8900 uint16_t vlan_id; 8901 }; 8902 8903 /* Common CLI fields for vf vlan insert enable disable */ 8904 static cmdline_parse_token_string_t cmd_vf_vlan_insert_set = 8905 TOKEN_STRING_INITIALIZER 8906 (struct cmd_vf_vlan_insert_result, 8907 set, "set"); 8908 static cmdline_parse_token_string_t cmd_vf_vlan_insert_vf = 8909 TOKEN_STRING_INITIALIZER 8910 (struct cmd_vf_vlan_insert_result, 8911 vf, "vf"); 8912 static cmdline_parse_token_string_t cmd_vf_vlan_insert_vlan = 8913 TOKEN_STRING_INITIALIZER 8914 (struct cmd_vf_vlan_insert_result, 8915 vlan, "vlan"); 8916 static cmdline_parse_token_string_t cmd_vf_vlan_insert_insert = 8917 TOKEN_STRING_INITIALIZER 8918 (struct cmd_vf_vlan_insert_result, 8919 insert, "insert"); 8920 static cmdline_parse_token_num_t cmd_vf_vlan_insert_port_id = 8921 TOKEN_NUM_INITIALIZER 8922 (struct cmd_vf_vlan_insert_result, 8923 port_id, RTE_UINT16); 8924 static cmdline_parse_token_num_t cmd_vf_vlan_insert_vf_id = 8925 TOKEN_NUM_INITIALIZER 8926 (struct cmd_vf_vlan_insert_result, 8927 vf_id, RTE_UINT16); 8928 static cmdline_parse_token_num_t cmd_vf_vlan_insert_vlan_id = 8929 TOKEN_NUM_INITIALIZER 8930 (struct cmd_vf_vlan_insert_result, 8931 vlan_id, RTE_UINT16); 8932 8933 static void 8934 cmd_set_vf_vlan_insert_parsed( 8935 void *parsed_result, 8936 __rte_unused struct cmdline *cl, 8937 __rte_unused void *data) 8938 { 8939 struct cmd_vf_vlan_insert_result *res = parsed_result; 8940 int ret = -ENOTSUP; 8941 8942 if (port_id_is_invalid(res->port_id, ENABLED_WARN)) 8943 return; 8944 8945 #ifdef RTE_NET_IXGBE 8946 if (ret == -ENOTSUP) 8947 ret = rte_pmd_ixgbe_set_vf_vlan_insert(res->port_id, res->vf_id, 8948 res->vlan_id); 8949 #endif 8950 #ifdef RTE_NET_I40E 8951 if (ret == -ENOTSUP) 8952 ret = rte_pmd_i40e_set_vf_vlan_insert(res->port_id, res->vf_id, 8953 res->vlan_id); 8954 #endif 8955 #ifdef RTE_NET_BNXT 8956 if (ret == -ENOTSUP) 8957 ret = rte_pmd_bnxt_set_vf_vlan_insert(res->port_id, res->vf_id, 8958 res->vlan_id); 8959 #endif 8960 8961 switch (ret) { 8962 case 0: 8963 break; 8964 case -EINVAL: 8965 fprintf(stderr, "invalid vf_id %d or vlan_id %d\n", 8966 res->vf_id, res->vlan_id); 8967 break; 8968 case -ENODEV: 8969 fprintf(stderr, "invalid port_id %d\n", res->port_id); 8970 break; 8971 case -ENOTSUP: 8972 fprintf(stderr, "function not implemented\n"); 8973 break; 8974 default: 8975 fprintf(stderr, "programming error: (%s)\n", strerror(-ret)); 8976 } 8977 } 8978 8979 static cmdline_parse_inst_t cmd_set_vf_vlan_insert = { 8980 .f = cmd_set_vf_vlan_insert_parsed, 8981 .data = NULL, 8982 .help_str = "set vf vlan insert <port_id> <vf_id> <vlan_id>", 8983 .tokens = { 8984 (void *)&cmd_vf_vlan_insert_set, 8985 (void *)&cmd_vf_vlan_insert_vf, 8986 (void *)&cmd_vf_vlan_insert_vlan, 8987 (void *)&cmd_vf_vlan_insert_insert, 8988 (void *)&cmd_vf_vlan_insert_port_id, 8989 (void *)&cmd_vf_vlan_insert_vf_id, 8990 (void *)&cmd_vf_vlan_insert_vlan_id, 8991 NULL, 8992 }, 8993 }; 8994 8995 /* tx loopback configuration */ 8996 8997 /* Common result structure for tx loopback */ 8998 struct cmd_tx_loopback_result { 8999 cmdline_fixed_string_t set; 9000 cmdline_fixed_string_t tx; 9001 cmdline_fixed_string_t loopback; 9002 portid_t port_id; 9003 cmdline_fixed_string_t on_off; 9004 }; 9005 9006 /* Common CLI fields for tx loopback enable disable */ 9007 static cmdline_parse_token_string_t cmd_tx_loopback_set = 9008 TOKEN_STRING_INITIALIZER 9009 (struct cmd_tx_loopback_result, 9010 set, "set"); 9011 static cmdline_parse_token_string_t cmd_tx_loopback_tx = 9012 TOKEN_STRING_INITIALIZER 9013 (struct cmd_tx_loopback_result, 9014 tx, "tx"); 9015 static cmdline_parse_token_string_t cmd_tx_loopback_loopback = 9016 TOKEN_STRING_INITIALIZER 9017 (struct cmd_tx_loopback_result, 9018 loopback, "loopback"); 9019 static cmdline_parse_token_num_t cmd_tx_loopback_port_id = 9020 TOKEN_NUM_INITIALIZER 9021 (struct cmd_tx_loopback_result, 9022 port_id, RTE_UINT16); 9023 static cmdline_parse_token_string_t cmd_tx_loopback_on_off = 9024 TOKEN_STRING_INITIALIZER 9025 (struct cmd_tx_loopback_result, 9026 on_off, "on#off"); 9027 9028 static void 9029 cmd_set_tx_loopback_parsed( 9030 void *parsed_result, 9031 __rte_unused struct cmdline *cl, 9032 __rte_unused void *data) 9033 { 9034 struct cmd_tx_loopback_result *res = parsed_result; 9035 int ret = -ENOTSUP; 9036 9037 __rte_unused int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0; 9038 9039 if (port_id_is_invalid(res->port_id, ENABLED_WARN)) 9040 return; 9041 9042 #ifdef RTE_NET_IXGBE 9043 if (ret == -ENOTSUP) 9044 ret = rte_pmd_ixgbe_set_tx_loopback(res->port_id, is_on); 9045 #endif 9046 #ifdef RTE_NET_I40E 9047 if (ret == -ENOTSUP) 9048 ret = rte_pmd_i40e_set_tx_loopback(res->port_id, is_on); 9049 #endif 9050 #ifdef RTE_NET_BNXT 9051 if (ret == -ENOTSUP) 9052 ret = rte_pmd_bnxt_set_tx_loopback(res->port_id, is_on); 9053 #endif 9054 #if defined RTE_BUS_DPAA && defined RTE_NET_DPAA 9055 if (ret == -ENOTSUP) 9056 ret = rte_pmd_dpaa_set_tx_loopback(res->port_id, is_on); 9057 #endif 9058 9059 switch (ret) { 9060 case 0: 9061 break; 9062 case -EINVAL: 9063 fprintf(stderr, "invalid is_on %d\n", is_on); 9064 break; 9065 case -ENODEV: 9066 fprintf(stderr, "invalid port_id %d\n", res->port_id); 9067 break; 9068 case -ENOTSUP: 9069 fprintf(stderr, "function not implemented\n"); 9070 break; 9071 default: 9072 fprintf(stderr, "programming error: (%s)\n", strerror(-ret)); 9073 } 9074 } 9075 9076 static cmdline_parse_inst_t cmd_set_tx_loopback = { 9077 .f = cmd_set_tx_loopback_parsed, 9078 .data = NULL, 9079 .help_str = "set tx loopback <port_id> on|off", 9080 .tokens = { 9081 (void *)&cmd_tx_loopback_set, 9082 (void *)&cmd_tx_loopback_tx, 9083 (void *)&cmd_tx_loopback_loopback, 9084 (void *)&cmd_tx_loopback_port_id, 9085 (void *)&cmd_tx_loopback_on_off, 9086 NULL, 9087 }, 9088 }; 9089 9090 /* all queues drop enable configuration */ 9091 9092 /* Common result structure for all queues drop enable */ 9093 struct cmd_all_queues_drop_en_result { 9094 cmdline_fixed_string_t set; 9095 cmdline_fixed_string_t all; 9096 cmdline_fixed_string_t queues; 9097 cmdline_fixed_string_t drop; 9098 portid_t port_id; 9099 cmdline_fixed_string_t on_off; 9100 }; 9101 9102 /* Common CLI fields for tx loopback enable disable */ 9103 static cmdline_parse_token_string_t cmd_all_queues_drop_en_set = 9104 TOKEN_STRING_INITIALIZER 9105 (struct cmd_all_queues_drop_en_result, 9106 set, "set"); 9107 static cmdline_parse_token_string_t cmd_all_queues_drop_en_all = 9108 TOKEN_STRING_INITIALIZER 9109 (struct cmd_all_queues_drop_en_result, 9110 all, "all"); 9111 static cmdline_parse_token_string_t cmd_all_queues_drop_en_queues = 9112 TOKEN_STRING_INITIALIZER 9113 (struct cmd_all_queues_drop_en_result, 9114 queues, "queues"); 9115 static cmdline_parse_token_string_t cmd_all_queues_drop_en_drop = 9116 TOKEN_STRING_INITIALIZER 9117 (struct cmd_all_queues_drop_en_result, 9118 drop, "drop"); 9119 static cmdline_parse_token_num_t cmd_all_queues_drop_en_port_id = 9120 TOKEN_NUM_INITIALIZER 9121 (struct cmd_all_queues_drop_en_result, 9122 port_id, RTE_UINT16); 9123 static cmdline_parse_token_string_t cmd_all_queues_drop_en_on_off = 9124 TOKEN_STRING_INITIALIZER 9125 (struct cmd_all_queues_drop_en_result, 9126 on_off, "on#off"); 9127 9128 static void 9129 cmd_set_all_queues_drop_en_parsed( 9130 void *parsed_result, 9131 __rte_unused struct cmdline *cl, 9132 __rte_unused void *data) 9133 { 9134 struct cmd_all_queues_drop_en_result *res = parsed_result; 9135 int ret = -ENOTSUP; 9136 int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0; 9137 9138 if (port_id_is_invalid(res->port_id, ENABLED_WARN)) 9139 return; 9140 9141 #ifdef RTE_NET_IXGBE 9142 if (ret == -ENOTSUP) 9143 ret = rte_pmd_ixgbe_set_all_queues_drop_en(res->port_id, is_on); 9144 #endif 9145 #ifdef RTE_NET_BNXT 9146 if (ret == -ENOTSUP) 9147 ret = rte_pmd_bnxt_set_all_queues_drop_en(res->port_id, is_on); 9148 #endif 9149 switch (ret) { 9150 case 0: 9151 break; 9152 case -EINVAL: 9153 fprintf(stderr, "invalid is_on %d\n", is_on); 9154 break; 9155 case -ENODEV: 9156 fprintf(stderr, "invalid port_id %d\n", res->port_id); 9157 break; 9158 case -ENOTSUP: 9159 fprintf(stderr, "function not implemented\n"); 9160 break; 9161 default: 9162 fprintf(stderr, "programming error: (%s)\n", strerror(-ret)); 9163 } 9164 } 9165 9166 static cmdline_parse_inst_t cmd_set_all_queues_drop_en = { 9167 .f = cmd_set_all_queues_drop_en_parsed, 9168 .data = NULL, 9169 .help_str = "set all queues drop <port_id> on|off", 9170 .tokens = { 9171 (void *)&cmd_all_queues_drop_en_set, 9172 (void *)&cmd_all_queues_drop_en_all, 9173 (void *)&cmd_all_queues_drop_en_queues, 9174 (void *)&cmd_all_queues_drop_en_drop, 9175 (void *)&cmd_all_queues_drop_en_port_id, 9176 (void *)&cmd_all_queues_drop_en_on_off, 9177 NULL, 9178 }, 9179 }; 9180 9181 /* vf mac address configuration */ 9182 9183 /* Common result structure for vf mac address */ 9184 struct cmd_set_vf_mac_addr_result { 9185 cmdline_fixed_string_t set; 9186 cmdline_fixed_string_t vf; 9187 cmdline_fixed_string_t mac; 9188 cmdline_fixed_string_t addr; 9189 portid_t port_id; 9190 uint16_t vf_id; 9191 struct rte_ether_addr mac_addr; 9192 9193 }; 9194 9195 /* Common CLI fields for vf split drop enable disable */ 9196 static cmdline_parse_token_string_t cmd_set_vf_mac_addr_set = 9197 TOKEN_STRING_INITIALIZER 9198 (struct cmd_set_vf_mac_addr_result, 9199 set, "set"); 9200 static cmdline_parse_token_string_t cmd_set_vf_mac_addr_vf = 9201 TOKEN_STRING_INITIALIZER 9202 (struct cmd_set_vf_mac_addr_result, 9203 vf, "vf"); 9204 static cmdline_parse_token_string_t cmd_set_vf_mac_addr_mac = 9205 TOKEN_STRING_INITIALIZER 9206 (struct cmd_set_vf_mac_addr_result, 9207 mac, "mac"); 9208 static cmdline_parse_token_string_t cmd_set_vf_mac_addr_addr = 9209 TOKEN_STRING_INITIALIZER 9210 (struct cmd_set_vf_mac_addr_result, 9211 addr, "addr"); 9212 static cmdline_parse_token_num_t cmd_set_vf_mac_addr_port_id = 9213 TOKEN_NUM_INITIALIZER 9214 (struct cmd_set_vf_mac_addr_result, 9215 port_id, RTE_UINT16); 9216 static cmdline_parse_token_num_t cmd_set_vf_mac_addr_vf_id = 9217 TOKEN_NUM_INITIALIZER 9218 (struct cmd_set_vf_mac_addr_result, 9219 vf_id, RTE_UINT16); 9220 static cmdline_parse_token_etheraddr_t cmd_set_vf_mac_addr_mac_addr = 9221 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_vf_mac_addr_result, 9222 mac_addr); 9223 9224 static void 9225 cmd_set_vf_mac_addr_parsed( 9226 void *parsed_result, 9227 __rte_unused struct cmdline *cl, 9228 __rte_unused void *data) 9229 { 9230 struct cmd_set_vf_mac_addr_result *res = parsed_result; 9231 int ret = -ENOTSUP; 9232 9233 if (port_id_is_invalid(res->port_id, ENABLED_WARN)) 9234 return; 9235 9236 #ifdef RTE_NET_IXGBE 9237 if (ret == -ENOTSUP) 9238 ret = rte_pmd_ixgbe_set_vf_mac_addr(res->port_id, res->vf_id, 9239 &res->mac_addr); 9240 #endif 9241 #ifdef RTE_NET_I40E 9242 if (ret == -ENOTSUP) 9243 ret = rte_pmd_i40e_set_vf_mac_addr(res->port_id, res->vf_id, 9244 &res->mac_addr); 9245 #endif 9246 #ifdef RTE_NET_BNXT 9247 if (ret == -ENOTSUP) 9248 ret = rte_pmd_bnxt_set_vf_mac_addr(res->port_id, res->vf_id, 9249 &res->mac_addr); 9250 #endif 9251 9252 switch (ret) { 9253 case 0: 9254 break; 9255 case -EINVAL: 9256 fprintf(stderr, "invalid vf_id %d or mac_addr\n", res->vf_id); 9257 break; 9258 case -ENODEV: 9259 fprintf(stderr, "invalid port_id %d\n", res->port_id); 9260 break; 9261 case -ENOTSUP: 9262 fprintf(stderr, "function not implemented\n"); 9263 break; 9264 default: 9265 fprintf(stderr, "programming error: (%s)\n", strerror(-ret)); 9266 } 9267 } 9268 9269 static cmdline_parse_inst_t cmd_set_vf_mac_addr = { 9270 .f = cmd_set_vf_mac_addr_parsed, 9271 .data = NULL, 9272 .help_str = "set vf mac addr <port_id> <vf_id> <mac_addr>", 9273 .tokens = { 9274 (void *)&cmd_set_vf_mac_addr_set, 9275 (void *)&cmd_set_vf_mac_addr_vf, 9276 (void *)&cmd_set_vf_mac_addr_mac, 9277 (void *)&cmd_set_vf_mac_addr_addr, 9278 (void *)&cmd_set_vf_mac_addr_port_id, 9279 (void *)&cmd_set_vf_mac_addr_vf_id, 9280 (void *)&cmd_set_vf_mac_addr_mac_addr, 9281 NULL, 9282 }, 9283 }; 9284 9285 /** Set VXLAN encapsulation details */ 9286 struct cmd_set_vxlan_result { 9287 cmdline_fixed_string_t set; 9288 cmdline_fixed_string_t vxlan; 9289 cmdline_fixed_string_t pos_token; 9290 cmdline_fixed_string_t ip_version; 9291 uint32_t vlan_present:1; 9292 uint32_t vni; 9293 uint16_t udp_src; 9294 uint16_t udp_dst; 9295 cmdline_ipaddr_t ip_src; 9296 cmdline_ipaddr_t ip_dst; 9297 uint16_t tci; 9298 uint8_t tos; 9299 uint8_t ttl; 9300 struct rte_ether_addr eth_src; 9301 struct rte_ether_addr eth_dst; 9302 }; 9303 9304 static cmdline_parse_token_string_t cmd_set_vxlan_set = 9305 TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, set, "set"); 9306 static cmdline_parse_token_string_t cmd_set_vxlan_vxlan = 9307 TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, vxlan, "vxlan"); 9308 static cmdline_parse_token_string_t cmd_set_vxlan_vxlan_tos_ttl = 9309 TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, vxlan, 9310 "vxlan-tos-ttl"); 9311 static cmdline_parse_token_string_t cmd_set_vxlan_vxlan_with_vlan = 9312 TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, vxlan, 9313 "vxlan-with-vlan"); 9314 static cmdline_parse_token_string_t cmd_set_vxlan_ip_version = 9315 TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, pos_token, 9316 "ip-version"); 9317 static cmdline_parse_token_string_t cmd_set_vxlan_ip_version_value = 9318 TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, ip_version, 9319 "ipv4#ipv6"); 9320 static cmdline_parse_token_string_t cmd_set_vxlan_vni = 9321 TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, pos_token, 9322 "vni"); 9323 static cmdline_parse_token_num_t cmd_set_vxlan_vni_value = 9324 TOKEN_NUM_INITIALIZER(struct cmd_set_vxlan_result, vni, RTE_UINT32); 9325 static cmdline_parse_token_string_t cmd_set_vxlan_udp_src = 9326 TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, pos_token, 9327 "udp-src"); 9328 static cmdline_parse_token_num_t cmd_set_vxlan_udp_src_value = 9329 TOKEN_NUM_INITIALIZER(struct cmd_set_vxlan_result, udp_src, RTE_UINT16); 9330 static cmdline_parse_token_string_t cmd_set_vxlan_udp_dst = 9331 TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, pos_token, 9332 "udp-dst"); 9333 static cmdline_parse_token_num_t cmd_set_vxlan_udp_dst_value = 9334 TOKEN_NUM_INITIALIZER(struct cmd_set_vxlan_result, udp_dst, RTE_UINT16); 9335 static cmdline_parse_token_string_t cmd_set_vxlan_ip_tos = 9336 TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, pos_token, 9337 "ip-tos"); 9338 static cmdline_parse_token_num_t cmd_set_vxlan_ip_tos_value = 9339 TOKEN_NUM_INITIALIZER(struct cmd_set_vxlan_result, tos, RTE_UINT8); 9340 static cmdline_parse_token_string_t cmd_set_vxlan_ip_ttl = 9341 TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, pos_token, 9342 "ip-ttl"); 9343 static cmdline_parse_token_num_t cmd_set_vxlan_ip_ttl_value = 9344 TOKEN_NUM_INITIALIZER(struct cmd_set_vxlan_result, ttl, RTE_UINT8); 9345 static cmdline_parse_token_string_t cmd_set_vxlan_ip_src = 9346 TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, pos_token, 9347 "ip-src"); 9348 static cmdline_parse_token_ipaddr_t cmd_set_vxlan_ip_src_value = 9349 TOKEN_IPADDR_INITIALIZER(struct cmd_set_vxlan_result, ip_src); 9350 static cmdline_parse_token_string_t cmd_set_vxlan_ip_dst = 9351 TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, pos_token, 9352 "ip-dst"); 9353 static cmdline_parse_token_ipaddr_t cmd_set_vxlan_ip_dst_value = 9354 TOKEN_IPADDR_INITIALIZER(struct cmd_set_vxlan_result, ip_dst); 9355 static cmdline_parse_token_string_t cmd_set_vxlan_vlan = 9356 TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, pos_token, 9357 "vlan-tci"); 9358 static cmdline_parse_token_num_t cmd_set_vxlan_vlan_value = 9359 TOKEN_NUM_INITIALIZER(struct cmd_set_vxlan_result, tci, RTE_UINT16); 9360 static cmdline_parse_token_string_t cmd_set_vxlan_eth_src = 9361 TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, pos_token, 9362 "eth-src"); 9363 static cmdline_parse_token_etheraddr_t cmd_set_vxlan_eth_src_value = 9364 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_vxlan_result, eth_src); 9365 static cmdline_parse_token_string_t cmd_set_vxlan_eth_dst = 9366 TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, pos_token, 9367 "eth-dst"); 9368 static cmdline_parse_token_etheraddr_t cmd_set_vxlan_eth_dst_value = 9369 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_vxlan_result, eth_dst); 9370 9371 static void cmd_set_vxlan_parsed(void *parsed_result, 9372 __rte_unused struct cmdline *cl, 9373 __rte_unused void *data) 9374 { 9375 struct cmd_set_vxlan_result *res = parsed_result; 9376 union { 9377 uint32_t vxlan_id; 9378 uint8_t vni[4]; 9379 } id = { 9380 .vxlan_id = rte_cpu_to_be_32(res->vni) & RTE_BE32(0x00ffffff), 9381 }; 9382 9383 vxlan_encap_conf.select_tos_ttl = 0; 9384 if (strcmp(res->vxlan, "vxlan") == 0) 9385 vxlan_encap_conf.select_vlan = 0; 9386 else if (strcmp(res->vxlan, "vxlan-with-vlan") == 0) 9387 vxlan_encap_conf.select_vlan = 1; 9388 else if (strcmp(res->vxlan, "vxlan-tos-ttl") == 0) { 9389 vxlan_encap_conf.select_vlan = 0; 9390 vxlan_encap_conf.select_tos_ttl = 1; 9391 } 9392 if (strcmp(res->ip_version, "ipv4") == 0) 9393 vxlan_encap_conf.select_ipv4 = 1; 9394 else if (strcmp(res->ip_version, "ipv6") == 0) 9395 vxlan_encap_conf.select_ipv4 = 0; 9396 else 9397 return; 9398 rte_memcpy(vxlan_encap_conf.vni, &id.vni[1], 3); 9399 vxlan_encap_conf.udp_src = rte_cpu_to_be_16(res->udp_src); 9400 vxlan_encap_conf.udp_dst = rte_cpu_to_be_16(res->udp_dst); 9401 vxlan_encap_conf.ip_tos = res->tos; 9402 vxlan_encap_conf.ip_ttl = res->ttl; 9403 if (vxlan_encap_conf.select_ipv4) { 9404 IPV4_ADDR_TO_UINT(res->ip_src, vxlan_encap_conf.ipv4_src); 9405 IPV4_ADDR_TO_UINT(res->ip_dst, vxlan_encap_conf.ipv4_dst); 9406 } else { 9407 IPV6_ADDR_TO_ARRAY(res->ip_src, vxlan_encap_conf.ipv6_src); 9408 IPV6_ADDR_TO_ARRAY(res->ip_dst, vxlan_encap_conf.ipv6_dst); 9409 } 9410 if (vxlan_encap_conf.select_vlan) 9411 vxlan_encap_conf.vlan_tci = rte_cpu_to_be_16(res->tci); 9412 rte_memcpy(vxlan_encap_conf.eth_src, res->eth_src.addr_bytes, 9413 RTE_ETHER_ADDR_LEN); 9414 rte_memcpy(vxlan_encap_conf.eth_dst, res->eth_dst.addr_bytes, 9415 RTE_ETHER_ADDR_LEN); 9416 } 9417 9418 static cmdline_parse_inst_t cmd_set_vxlan = { 9419 .f = cmd_set_vxlan_parsed, 9420 .data = NULL, 9421 .help_str = "set vxlan ip-version ipv4|ipv6 vni <vni> udp-src" 9422 " <udp-src> udp-dst <udp-dst> ip-src <ip-src> ip-dst <ip-dst>" 9423 " eth-src <eth-src> eth-dst <eth-dst>", 9424 .tokens = { 9425 (void *)&cmd_set_vxlan_set, 9426 (void *)&cmd_set_vxlan_vxlan, 9427 (void *)&cmd_set_vxlan_ip_version, 9428 (void *)&cmd_set_vxlan_ip_version_value, 9429 (void *)&cmd_set_vxlan_vni, 9430 (void *)&cmd_set_vxlan_vni_value, 9431 (void *)&cmd_set_vxlan_udp_src, 9432 (void *)&cmd_set_vxlan_udp_src_value, 9433 (void *)&cmd_set_vxlan_udp_dst, 9434 (void *)&cmd_set_vxlan_udp_dst_value, 9435 (void *)&cmd_set_vxlan_ip_src, 9436 (void *)&cmd_set_vxlan_ip_src_value, 9437 (void *)&cmd_set_vxlan_ip_dst, 9438 (void *)&cmd_set_vxlan_ip_dst_value, 9439 (void *)&cmd_set_vxlan_eth_src, 9440 (void *)&cmd_set_vxlan_eth_src_value, 9441 (void *)&cmd_set_vxlan_eth_dst, 9442 (void *)&cmd_set_vxlan_eth_dst_value, 9443 NULL, 9444 }, 9445 }; 9446 9447 static cmdline_parse_inst_t cmd_set_vxlan_tos_ttl = { 9448 .f = cmd_set_vxlan_parsed, 9449 .data = NULL, 9450 .help_str = "set vxlan-tos-ttl ip-version ipv4|ipv6 vni <vni> udp-src" 9451 " <udp-src> udp-dst <udp-dst> ip-tos <ip-tos> ip-ttl <ip-ttl>" 9452 " ip-src <ip-src> ip-dst <ip-dst> eth-src <eth-src>" 9453 " eth-dst <eth-dst>", 9454 .tokens = { 9455 (void *)&cmd_set_vxlan_set, 9456 (void *)&cmd_set_vxlan_vxlan_tos_ttl, 9457 (void *)&cmd_set_vxlan_ip_version, 9458 (void *)&cmd_set_vxlan_ip_version_value, 9459 (void *)&cmd_set_vxlan_vni, 9460 (void *)&cmd_set_vxlan_vni_value, 9461 (void *)&cmd_set_vxlan_udp_src, 9462 (void *)&cmd_set_vxlan_udp_src_value, 9463 (void *)&cmd_set_vxlan_udp_dst, 9464 (void *)&cmd_set_vxlan_udp_dst_value, 9465 (void *)&cmd_set_vxlan_ip_tos, 9466 (void *)&cmd_set_vxlan_ip_tos_value, 9467 (void *)&cmd_set_vxlan_ip_ttl, 9468 (void *)&cmd_set_vxlan_ip_ttl_value, 9469 (void *)&cmd_set_vxlan_ip_src, 9470 (void *)&cmd_set_vxlan_ip_src_value, 9471 (void *)&cmd_set_vxlan_ip_dst, 9472 (void *)&cmd_set_vxlan_ip_dst_value, 9473 (void *)&cmd_set_vxlan_eth_src, 9474 (void *)&cmd_set_vxlan_eth_src_value, 9475 (void *)&cmd_set_vxlan_eth_dst, 9476 (void *)&cmd_set_vxlan_eth_dst_value, 9477 NULL, 9478 }, 9479 }; 9480 9481 static cmdline_parse_inst_t cmd_set_vxlan_with_vlan = { 9482 .f = cmd_set_vxlan_parsed, 9483 .data = NULL, 9484 .help_str = "set vxlan-with-vlan ip-version ipv4|ipv6 vni <vni>" 9485 " udp-src <udp-src> udp-dst <udp-dst> ip-src <ip-src> ip-dst" 9486 " <ip-dst> vlan-tci <vlan-tci> eth-src <eth-src> eth-dst" 9487 " <eth-dst>", 9488 .tokens = { 9489 (void *)&cmd_set_vxlan_set, 9490 (void *)&cmd_set_vxlan_vxlan_with_vlan, 9491 (void *)&cmd_set_vxlan_ip_version, 9492 (void *)&cmd_set_vxlan_ip_version_value, 9493 (void *)&cmd_set_vxlan_vni, 9494 (void *)&cmd_set_vxlan_vni_value, 9495 (void *)&cmd_set_vxlan_udp_src, 9496 (void *)&cmd_set_vxlan_udp_src_value, 9497 (void *)&cmd_set_vxlan_udp_dst, 9498 (void *)&cmd_set_vxlan_udp_dst_value, 9499 (void *)&cmd_set_vxlan_ip_src, 9500 (void *)&cmd_set_vxlan_ip_src_value, 9501 (void *)&cmd_set_vxlan_ip_dst, 9502 (void *)&cmd_set_vxlan_ip_dst_value, 9503 (void *)&cmd_set_vxlan_vlan, 9504 (void *)&cmd_set_vxlan_vlan_value, 9505 (void *)&cmd_set_vxlan_eth_src, 9506 (void *)&cmd_set_vxlan_eth_src_value, 9507 (void *)&cmd_set_vxlan_eth_dst, 9508 (void *)&cmd_set_vxlan_eth_dst_value, 9509 NULL, 9510 }, 9511 }; 9512 9513 /** Set NVGRE encapsulation details */ 9514 struct cmd_set_nvgre_result { 9515 cmdline_fixed_string_t set; 9516 cmdline_fixed_string_t nvgre; 9517 cmdline_fixed_string_t pos_token; 9518 cmdline_fixed_string_t ip_version; 9519 uint32_t tni; 9520 cmdline_ipaddr_t ip_src; 9521 cmdline_ipaddr_t ip_dst; 9522 uint16_t tci; 9523 struct rte_ether_addr eth_src; 9524 struct rte_ether_addr eth_dst; 9525 }; 9526 9527 static cmdline_parse_token_string_t cmd_set_nvgre_set = 9528 TOKEN_STRING_INITIALIZER(struct cmd_set_nvgre_result, set, "set"); 9529 static cmdline_parse_token_string_t cmd_set_nvgre_nvgre = 9530 TOKEN_STRING_INITIALIZER(struct cmd_set_nvgre_result, nvgre, "nvgre"); 9531 static cmdline_parse_token_string_t cmd_set_nvgre_nvgre_with_vlan = 9532 TOKEN_STRING_INITIALIZER(struct cmd_set_nvgre_result, nvgre, 9533 "nvgre-with-vlan"); 9534 static cmdline_parse_token_string_t cmd_set_nvgre_ip_version = 9535 TOKEN_STRING_INITIALIZER(struct cmd_set_nvgre_result, pos_token, 9536 "ip-version"); 9537 static cmdline_parse_token_string_t cmd_set_nvgre_ip_version_value = 9538 TOKEN_STRING_INITIALIZER(struct cmd_set_nvgre_result, ip_version, 9539 "ipv4#ipv6"); 9540 static cmdline_parse_token_string_t cmd_set_nvgre_tni = 9541 TOKEN_STRING_INITIALIZER(struct cmd_set_nvgre_result, pos_token, 9542 "tni"); 9543 static cmdline_parse_token_num_t cmd_set_nvgre_tni_value = 9544 TOKEN_NUM_INITIALIZER(struct cmd_set_nvgre_result, tni, RTE_UINT32); 9545 static cmdline_parse_token_string_t cmd_set_nvgre_ip_src = 9546 TOKEN_STRING_INITIALIZER(struct cmd_set_nvgre_result, pos_token, 9547 "ip-src"); 9548 static cmdline_parse_token_num_t cmd_set_nvgre_ip_src_value = 9549 TOKEN_IPADDR_INITIALIZER(struct cmd_set_nvgre_result, ip_src); 9550 static cmdline_parse_token_string_t cmd_set_nvgre_ip_dst = 9551 TOKEN_STRING_INITIALIZER(struct cmd_set_nvgre_result, pos_token, 9552 "ip-dst"); 9553 static cmdline_parse_token_ipaddr_t cmd_set_nvgre_ip_dst_value = 9554 TOKEN_IPADDR_INITIALIZER(struct cmd_set_nvgre_result, ip_dst); 9555 static cmdline_parse_token_string_t cmd_set_nvgre_vlan = 9556 TOKEN_STRING_INITIALIZER(struct cmd_set_nvgre_result, pos_token, 9557 "vlan-tci"); 9558 static cmdline_parse_token_num_t cmd_set_nvgre_vlan_value = 9559 TOKEN_NUM_INITIALIZER(struct cmd_set_nvgre_result, tci, RTE_UINT16); 9560 static cmdline_parse_token_string_t cmd_set_nvgre_eth_src = 9561 TOKEN_STRING_INITIALIZER(struct cmd_set_nvgre_result, pos_token, 9562 "eth-src"); 9563 static cmdline_parse_token_etheraddr_t cmd_set_nvgre_eth_src_value = 9564 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_nvgre_result, eth_src); 9565 static cmdline_parse_token_string_t cmd_set_nvgre_eth_dst = 9566 TOKEN_STRING_INITIALIZER(struct cmd_set_nvgre_result, pos_token, 9567 "eth-dst"); 9568 static cmdline_parse_token_etheraddr_t cmd_set_nvgre_eth_dst_value = 9569 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_nvgre_result, eth_dst); 9570 9571 static void cmd_set_nvgre_parsed(void *parsed_result, 9572 __rte_unused struct cmdline *cl, 9573 __rte_unused void *data) 9574 { 9575 struct cmd_set_nvgre_result *res = parsed_result; 9576 union { 9577 uint32_t nvgre_tni; 9578 uint8_t tni[4]; 9579 } id = { 9580 .nvgre_tni = rte_cpu_to_be_32(res->tni) & RTE_BE32(0x00ffffff), 9581 }; 9582 9583 if (strcmp(res->nvgre, "nvgre") == 0) 9584 nvgre_encap_conf.select_vlan = 0; 9585 else if (strcmp(res->nvgre, "nvgre-with-vlan") == 0) 9586 nvgre_encap_conf.select_vlan = 1; 9587 if (strcmp(res->ip_version, "ipv4") == 0) 9588 nvgre_encap_conf.select_ipv4 = 1; 9589 else if (strcmp(res->ip_version, "ipv6") == 0) 9590 nvgre_encap_conf.select_ipv4 = 0; 9591 else 9592 return; 9593 rte_memcpy(nvgre_encap_conf.tni, &id.tni[1], 3); 9594 if (nvgre_encap_conf.select_ipv4) { 9595 IPV4_ADDR_TO_UINT(res->ip_src, nvgre_encap_conf.ipv4_src); 9596 IPV4_ADDR_TO_UINT(res->ip_dst, nvgre_encap_conf.ipv4_dst); 9597 } else { 9598 IPV6_ADDR_TO_ARRAY(res->ip_src, nvgre_encap_conf.ipv6_src); 9599 IPV6_ADDR_TO_ARRAY(res->ip_dst, nvgre_encap_conf.ipv6_dst); 9600 } 9601 if (nvgre_encap_conf.select_vlan) 9602 nvgre_encap_conf.vlan_tci = rte_cpu_to_be_16(res->tci); 9603 rte_memcpy(nvgre_encap_conf.eth_src, res->eth_src.addr_bytes, 9604 RTE_ETHER_ADDR_LEN); 9605 rte_memcpy(nvgre_encap_conf.eth_dst, res->eth_dst.addr_bytes, 9606 RTE_ETHER_ADDR_LEN); 9607 } 9608 9609 static cmdline_parse_inst_t cmd_set_nvgre = { 9610 .f = cmd_set_nvgre_parsed, 9611 .data = NULL, 9612 .help_str = "set nvgre ip-version <ipv4|ipv6> tni <tni> ip-src" 9613 " <ip-src> ip-dst <ip-dst> eth-src <eth-src>" 9614 " eth-dst <eth-dst>", 9615 .tokens = { 9616 (void *)&cmd_set_nvgre_set, 9617 (void *)&cmd_set_nvgre_nvgre, 9618 (void *)&cmd_set_nvgre_ip_version, 9619 (void *)&cmd_set_nvgre_ip_version_value, 9620 (void *)&cmd_set_nvgre_tni, 9621 (void *)&cmd_set_nvgre_tni_value, 9622 (void *)&cmd_set_nvgre_ip_src, 9623 (void *)&cmd_set_nvgre_ip_src_value, 9624 (void *)&cmd_set_nvgre_ip_dst, 9625 (void *)&cmd_set_nvgre_ip_dst_value, 9626 (void *)&cmd_set_nvgre_eth_src, 9627 (void *)&cmd_set_nvgre_eth_src_value, 9628 (void *)&cmd_set_nvgre_eth_dst, 9629 (void *)&cmd_set_nvgre_eth_dst_value, 9630 NULL, 9631 }, 9632 }; 9633 9634 static cmdline_parse_inst_t cmd_set_nvgre_with_vlan = { 9635 .f = cmd_set_nvgre_parsed, 9636 .data = NULL, 9637 .help_str = "set nvgre-with-vlan ip-version <ipv4|ipv6> tni <tni>" 9638 " ip-src <ip-src> ip-dst <ip-dst> vlan-tci <vlan-tci>" 9639 " eth-src <eth-src> eth-dst <eth-dst>", 9640 .tokens = { 9641 (void *)&cmd_set_nvgre_set, 9642 (void *)&cmd_set_nvgre_nvgre_with_vlan, 9643 (void *)&cmd_set_nvgre_ip_version, 9644 (void *)&cmd_set_nvgre_ip_version_value, 9645 (void *)&cmd_set_nvgre_tni, 9646 (void *)&cmd_set_nvgre_tni_value, 9647 (void *)&cmd_set_nvgre_ip_src, 9648 (void *)&cmd_set_nvgre_ip_src_value, 9649 (void *)&cmd_set_nvgre_ip_dst, 9650 (void *)&cmd_set_nvgre_ip_dst_value, 9651 (void *)&cmd_set_nvgre_vlan, 9652 (void *)&cmd_set_nvgre_vlan_value, 9653 (void *)&cmd_set_nvgre_eth_src, 9654 (void *)&cmd_set_nvgre_eth_src_value, 9655 (void *)&cmd_set_nvgre_eth_dst, 9656 (void *)&cmd_set_nvgre_eth_dst_value, 9657 NULL, 9658 }, 9659 }; 9660 9661 /** Set L2 encapsulation details */ 9662 struct cmd_set_l2_encap_result { 9663 cmdline_fixed_string_t set; 9664 cmdline_fixed_string_t l2_encap; 9665 cmdline_fixed_string_t pos_token; 9666 cmdline_fixed_string_t ip_version; 9667 uint32_t vlan_present:1; 9668 uint16_t tci; 9669 struct rte_ether_addr eth_src; 9670 struct rte_ether_addr eth_dst; 9671 }; 9672 9673 static cmdline_parse_token_string_t cmd_set_l2_encap_set = 9674 TOKEN_STRING_INITIALIZER(struct cmd_set_l2_encap_result, set, "set"); 9675 static cmdline_parse_token_string_t cmd_set_l2_encap_l2_encap = 9676 TOKEN_STRING_INITIALIZER(struct cmd_set_l2_encap_result, l2_encap, "l2_encap"); 9677 static cmdline_parse_token_string_t cmd_set_l2_encap_l2_encap_with_vlan = 9678 TOKEN_STRING_INITIALIZER(struct cmd_set_l2_encap_result, l2_encap, 9679 "l2_encap-with-vlan"); 9680 static cmdline_parse_token_string_t cmd_set_l2_encap_ip_version = 9681 TOKEN_STRING_INITIALIZER(struct cmd_set_l2_encap_result, pos_token, 9682 "ip-version"); 9683 static cmdline_parse_token_string_t cmd_set_l2_encap_ip_version_value = 9684 TOKEN_STRING_INITIALIZER(struct cmd_set_l2_encap_result, ip_version, 9685 "ipv4#ipv6"); 9686 static cmdline_parse_token_string_t cmd_set_l2_encap_vlan = 9687 TOKEN_STRING_INITIALIZER(struct cmd_set_l2_encap_result, pos_token, 9688 "vlan-tci"); 9689 static cmdline_parse_token_num_t cmd_set_l2_encap_vlan_value = 9690 TOKEN_NUM_INITIALIZER(struct cmd_set_l2_encap_result, tci, RTE_UINT16); 9691 static cmdline_parse_token_string_t cmd_set_l2_encap_eth_src = 9692 TOKEN_STRING_INITIALIZER(struct cmd_set_l2_encap_result, pos_token, 9693 "eth-src"); 9694 static cmdline_parse_token_etheraddr_t cmd_set_l2_encap_eth_src_value = 9695 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_l2_encap_result, eth_src); 9696 static cmdline_parse_token_string_t cmd_set_l2_encap_eth_dst = 9697 TOKEN_STRING_INITIALIZER(struct cmd_set_l2_encap_result, pos_token, 9698 "eth-dst"); 9699 static cmdline_parse_token_etheraddr_t cmd_set_l2_encap_eth_dst_value = 9700 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_l2_encap_result, eth_dst); 9701 9702 static void cmd_set_l2_encap_parsed(void *parsed_result, 9703 __rte_unused struct cmdline *cl, 9704 __rte_unused void *data) 9705 { 9706 struct cmd_set_l2_encap_result *res = parsed_result; 9707 9708 if (strcmp(res->l2_encap, "l2_encap") == 0) 9709 l2_encap_conf.select_vlan = 0; 9710 else if (strcmp(res->l2_encap, "l2_encap-with-vlan") == 0) 9711 l2_encap_conf.select_vlan = 1; 9712 if (strcmp(res->ip_version, "ipv4") == 0) 9713 l2_encap_conf.select_ipv4 = 1; 9714 else if (strcmp(res->ip_version, "ipv6") == 0) 9715 l2_encap_conf.select_ipv4 = 0; 9716 else 9717 return; 9718 if (l2_encap_conf.select_vlan) 9719 l2_encap_conf.vlan_tci = rte_cpu_to_be_16(res->tci); 9720 rte_memcpy(l2_encap_conf.eth_src, res->eth_src.addr_bytes, 9721 RTE_ETHER_ADDR_LEN); 9722 rte_memcpy(l2_encap_conf.eth_dst, res->eth_dst.addr_bytes, 9723 RTE_ETHER_ADDR_LEN); 9724 } 9725 9726 static cmdline_parse_inst_t cmd_set_l2_encap = { 9727 .f = cmd_set_l2_encap_parsed, 9728 .data = NULL, 9729 .help_str = "set l2_encap ip-version ipv4|ipv6" 9730 " eth-src <eth-src> eth-dst <eth-dst>", 9731 .tokens = { 9732 (void *)&cmd_set_l2_encap_set, 9733 (void *)&cmd_set_l2_encap_l2_encap, 9734 (void *)&cmd_set_l2_encap_ip_version, 9735 (void *)&cmd_set_l2_encap_ip_version_value, 9736 (void *)&cmd_set_l2_encap_eth_src, 9737 (void *)&cmd_set_l2_encap_eth_src_value, 9738 (void *)&cmd_set_l2_encap_eth_dst, 9739 (void *)&cmd_set_l2_encap_eth_dst_value, 9740 NULL, 9741 }, 9742 }; 9743 9744 static cmdline_parse_inst_t cmd_set_l2_encap_with_vlan = { 9745 .f = cmd_set_l2_encap_parsed, 9746 .data = NULL, 9747 .help_str = "set l2_encap-with-vlan ip-version ipv4|ipv6" 9748 " vlan-tci <vlan-tci> eth-src <eth-src> eth-dst <eth-dst>", 9749 .tokens = { 9750 (void *)&cmd_set_l2_encap_set, 9751 (void *)&cmd_set_l2_encap_l2_encap_with_vlan, 9752 (void *)&cmd_set_l2_encap_ip_version, 9753 (void *)&cmd_set_l2_encap_ip_version_value, 9754 (void *)&cmd_set_l2_encap_vlan, 9755 (void *)&cmd_set_l2_encap_vlan_value, 9756 (void *)&cmd_set_l2_encap_eth_src, 9757 (void *)&cmd_set_l2_encap_eth_src_value, 9758 (void *)&cmd_set_l2_encap_eth_dst, 9759 (void *)&cmd_set_l2_encap_eth_dst_value, 9760 NULL, 9761 }, 9762 }; 9763 9764 /** Set L2 decapsulation details */ 9765 struct cmd_set_l2_decap_result { 9766 cmdline_fixed_string_t set; 9767 cmdline_fixed_string_t l2_decap; 9768 cmdline_fixed_string_t pos_token; 9769 uint32_t vlan_present:1; 9770 }; 9771 9772 static cmdline_parse_token_string_t cmd_set_l2_decap_set = 9773 TOKEN_STRING_INITIALIZER(struct cmd_set_l2_decap_result, set, "set"); 9774 static cmdline_parse_token_string_t cmd_set_l2_decap_l2_decap = 9775 TOKEN_STRING_INITIALIZER(struct cmd_set_l2_decap_result, l2_decap, 9776 "l2_decap"); 9777 static cmdline_parse_token_string_t cmd_set_l2_decap_l2_decap_with_vlan = 9778 TOKEN_STRING_INITIALIZER(struct cmd_set_l2_decap_result, l2_decap, 9779 "l2_decap-with-vlan"); 9780 9781 static void cmd_set_l2_decap_parsed(void *parsed_result, 9782 __rte_unused struct cmdline *cl, 9783 __rte_unused void *data) 9784 { 9785 struct cmd_set_l2_decap_result *res = parsed_result; 9786 9787 if (strcmp(res->l2_decap, "l2_decap") == 0) 9788 l2_decap_conf.select_vlan = 0; 9789 else if (strcmp(res->l2_decap, "l2_decap-with-vlan") == 0) 9790 l2_decap_conf.select_vlan = 1; 9791 } 9792 9793 static cmdline_parse_inst_t cmd_set_l2_decap = { 9794 .f = cmd_set_l2_decap_parsed, 9795 .data = NULL, 9796 .help_str = "set l2_decap", 9797 .tokens = { 9798 (void *)&cmd_set_l2_decap_set, 9799 (void *)&cmd_set_l2_decap_l2_decap, 9800 NULL, 9801 }, 9802 }; 9803 9804 static cmdline_parse_inst_t cmd_set_l2_decap_with_vlan = { 9805 .f = cmd_set_l2_decap_parsed, 9806 .data = NULL, 9807 .help_str = "set l2_decap-with-vlan", 9808 .tokens = { 9809 (void *)&cmd_set_l2_decap_set, 9810 (void *)&cmd_set_l2_decap_l2_decap_with_vlan, 9811 NULL, 9812 }, 9813 }; 9814 9815 /** Set MPLSoGRE encapsulation details */ 9816 struct cmd_set_mplsogre_encap_result { 9817 cmdline_fixed_string_t set; 9818 cmdline_fixed_string_t mplsogre; 9819 cmdline_fixed_string_t pos_token; 9820 cmdline_fixed_string_t ip_version; 9821 uint32_t vlan_present:1; 9822 uint32_t label; 9823 cmdline_ipaddr_t ip_src; 9824 cmdline_ipaddr_t ip_dst; 9825 uint16_t tci; 9826 struct rte_ether_addr eth_src; 9827 struct rte_ether_addr eth_dst; 9828 }; 9829 9830 static cmdline_parse_token_string_t cmd_set_mplsogre_encap_set = 9831 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_encap_result, set, 9832 "set"); 9833 static cmdline_parse_token_string_t cmd_set_mplsogre_encap_mplsogre_encap = 9834 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_encap_result, mplsogre, 9835 "mplsogre_encap"); 9836 static cmdline_parse_token_string_t cmd_set_mplsogre_encap_mplsogre_encap_with_vlan = 9837 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_encap_result, 9838 mplsogre, "mplsogre_encap-with-vlan"); 9839 static cmdline_parse_token_string_t cmd_set_mplsogre_encap_ip_version = 9840 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_encap_result, 9841 pos_token, "ip-version"); 9842 static cmdline_parse_token_string_t cmd_set_mplsogre_encap_ip_version_value = 9843 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_encap_result, 9844 ip_version, "ipv4#ipv6"); 9845 static cmdline_parse_token_string_t cmd_set_mplsogre_encap_label = 9846 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_encap_result, 9847 pos_token, "label"); 9848 static cmdline_parse_token_num_t cmd_set_mplsogre_encap_label_value = 9849 TOKEN_NUM_INITIALIZER(struct cmd_set_mplsogre_encap_result, label, 9850 RTE_UINT32); 9851 static cmdline_parse_token_string_t cmd_set_mplsogre_encap_ip_src = 9852 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_encap_result, 9853 pos_token, "ip-src"); 9854 static cmdline_parse_token_ipaddr_t cmd_set_mplsogre_encap_ip_src_value = 9855 TOKEN_IPADDR_INITIALIZER(struct cmd_set_mplsogre_encap_result, ip_src); 9856 static cmdline_parse_token_string_t cmd_set_mplsogre_encap_ip_dst = 9857 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_encap_result, 9858 pos_token, "ip-dst"); 9859 static cmdline_parse_token_ipaddr_t cmd_set_mplsogre_encap_ip_dst_value = 9860 TOKEN_IPADDR_INITIALIZER(struct cmd_set_mplsogre_encap_result, ip_dst); 9861 static cmdline_parse_token_string_t cmd_set_mplsogre_encap_vlan = 9862 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_encap_result, 9863 pos_token, "vlan-tci"); 9864 static cmdline_parse_token_num_t cmd_set_mplsogre_encap_vlan_value = 9865 TOKEN_NUM_INITIALIZER(struct cmd_set_mplsogre_encap_result, tci, 9866 RTE_UINT16); 9867 static cmdline_parse_token_string_t cmd_set_mplsogre_encap_eth_src = 9868 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_encap_result, 9869 pos_token, "eth-src"); 9870 static cmdline_parse_token_etheraddr_t cmd_set_mplsogre_encap_eth_src_value = 9871 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_mplsogre_encap_result, 9872 eth_src); 9873 static cmdline_parse_token_string_t cmd_set_mplsogre_encap_eth_dst = 9874 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_encap_result, 9875 pos_token, "eth-dst"); 9876 static cmdline_parse_token_etheraddr_t cmd_set_mplsogre_encap_eth_dst_value = 9877 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_mplsogre_encap_result, 9878 eth_dst); 9879 9880 static void cmd_set_mplsogre_encap_parsed(void *parsed_result, 9881 __rte_unused struct cmdline *cl, 9882 __rte_unused void *data) 9883 { 9884 struct cmd_set_mplsogre_encap_result *res = parsed_result; 9885 union { 9886 uint32_t mplsogre_label; 9887 uint8_t label[4]; 9888 } id = { 9889 .mplsogre_label = rte_cpu_to_be_32(res->label<<12), 9890 }; 9891 9892 if (strcmp(res->mplsogre, "mplsogre_encap") == 0) 9893 mplsogre_encap_conf.select_vlan = 0; 9894 else if (strcmp(res->mplsogre, "mplsogre_encap-with-vlan") == 0) 9895 mplsogre_encap_conf.select_vlan = 1; 9896 if (strcmp(res->ip_version, "ipv4") == 0) 9897 mplsogre_encap_conf.select_ipv4 = 1; 9898 else if (strcmp(res->ip_version, "ipv6") == 0) 9899 mplsogre_encap_conf.select_ipv4 = 0; 9900 else 9901 return; 9902 rte_memcpy(mplsogre_encap_conf.label, &id.label, 3); 9903 if (mplsogre_encap_conf.select_ipv4) { 9904 IPV4_ADDR_TO_UINT(res->ip_src, mplsogre_encap_conf.ipv4_src); 9905 IPV4_ADDR_TO_UINT(res->ip_dst, mplsogre_encap_conf.ipv4_dst); 9906 } else { 9907 IPV6_ADDR_TO_ARRAY(res->ip_src, mplsogre_encap_conf.ipv6_src); 9908 IPV6_ADDR_TO_ARRAY(res->ip_dst, mplsogre_encap_conf.ipv6_dst); 9909 } 9910 if (mplsogre_encap_conf.select_vlan) 9911 mplsogre_encap_conf.vlan_tci = rte_cpu_to_be_16(res->tci); 9912 rte_memcpy(mplsogre_encap_conf.eth_src, res->eth_src.addr_bytes, 9913 RTE_ETHER_ADDR_LEN); 9914 rte_memcpy(mplsogre_encap_conf.eth_dst, res->eth_dst.addr_bytes, 9915 RTE_ETHER_ADDR_LEN); 9916 } 9917 9918 static cmdline_parse_inst_t cmd_set_mplsogre_encap = { 9919 .f = cmd_set_mplsogre_encap_parsed, 9920 .data = NULL, 9921 .help_str = "set mplsogre_encap ip-version ipv4|ipv6 label <label>" 9922 " ip-src <ip-src> ip-dst <ip-dst> eth-src <eth-src>" 9923 " eth-dst <eth-dst>", 9924 .tokens = { 9925 (void *)&cmd_set_mplsogre_encap_set, 9926 (void *)&cmd_set_mplsogre_encap_mplsogre_encap, 9927 (void *)&cmd_set_mplsogre_encap_ip_version, 9928 (void *)&cmd_set_mplsogre_encap_ip_version_value, 9929 (void *)&cmd_set_mplsogre_encap_label, 9930 (void *)&cmd_set_mplsogre_encap_label_value, 9931 (void *)&cmd_set_mplsogre_encap_ip_src, 9932 (void *)&cmd_set_mplsogre_encap_ip_src_value, 9933 (void *)&cmd_set_mplsogre_encap_ip_dst, 9934 (void *)&cmd_set_mplsogre_encap_ip_dst_value, 9935 (void *)&cmd_set_mplsogre_encap_eth_src, 9936 (void *)&cmd_set_mplsogre_encap_eth_src_value, 9937 (void *)&cmd_set_mplsogre_encap_eth_dst, 9938 (void *)&cmd_set_mplsogre_encap_eth_dst_value, 9939 NULL, 9940 }, 9941 }; 9942 9943 static cmdline_parse_inst_t cmd_set_mplsogre_encap_with_vlan = { 9944 .f = cmd_set_mplsogre_encap_parsed, 9945 .data = NULL, 9946 .help_str = "set mplsogre_encap-with-vlan ip-version ipv4|ipv6" 9947 " label <label> ip-src <ip-src> ip-dst <ip-dst>" 9948 " vlan-tci <vlan-tci> eth-src <eth-src> eth-dst <eth-dst>", 9949 .tokens = { 9950 (void *)&cmd_set_mplsogre_encap_set, 9951 (void *)&cmd_set_mplsogre_encap_mplsogre_encap_with_vlan, 9952 (void *)&cmd_set_mplsogre_encap_ip_version, 9953 (void *)&cmd_set_mplsogre_encap_ip_version_value, 9954 (void *)&cmd_set_mplsogre_encap_label, 9955 (void *)&cmd_set_mplsogre_encap_label_value, 9956 (void *)&cmd_set_mplsogre_encap_ip_src, 9957 (void *)&cmd_set_mplsogre_encap_ip_src_value, 9958 (void *)&cmd_set_mplsogre_encap_ip_dst, 9959 (void *)&cmd_set_mplsogre_encap_ip_dst_value, 9960 (void *)&cmd_set_mplsogre_encap_vlan, 9961 (void *)&cmd_set_mplsogre_encap_vlan_value, 9962 (void *)&cmd_set_mplsogre_encap_eth_src, 9963 (void *)&cmd_set_mplsogre_encap_eth_src_value, 9964 (void *)&cmd_set_mplsogre_encap_eth_dst, 9965 (void *)&cmd_set_mplsogre_encap_eth_dst_value, 9966 NULL, 9967 }, 9968 }; 9969 9970 /** Set MPLSoGRE decapsulation details */ 9971 struct cmd_set_mplsogre_decap_result { 9972 cmdline_fixed_string_t set; 9973 cmdline_fixed_string_t mplsogre; 9974 cmdline_fixed_string_t pos_token; 9975 cmdline_fixed_string_t ip_version; 9976 uint32_t vlan_present:1; 9977 }; 9978 9979 static cmdline_parse_token_string_t cmd_set_mplsogre_decap_set = 9980 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_decap_result, set, 9981 "set"); 9982 static cmdline_parse_token_string_t cmd_set_mplsogre_decap_mplsogre_decap = 9983 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_decap_result, mplsogre, 9984 "mplsogre_decap"); 9985 static cmdline_parse_token_string_t cmd_set_mplsogre_decap_mplsogre_decap_with_vlan = 9986 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_decap_result, 9987 mplsogre, "mplsogre_decap-with-vlan"); 9988 static cmdline_parse_token_string_t cmd_set_mplsogre_decap_ip_version = 9989 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_decap_result, 9990 pos_token, "ip-version"); 9991 static cmdline_parse_token_string_t cmd_set_mplsogre_decap_ip_version_value = 9992 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_decap_result, 9993 ip_version, "ipv4#ipv6"); 9994 9995 static void cmd_set_mplsogre_decap_parsed(void *parsed_result, 9996 __rte_unused struct cmdline *cl, 9997 __rte_unused void *data) 9998 { 9999 struct cmd_set_mplsogre_decap_result *res = parsed_result; 10000 10001 if (strcmp(res->mplsogre, "mplsogre_decap") == 0) 10002 mplsogre_decap_conf.select_vlan = 0; 10003 else if (strcmp(res->mplsogre, "mplsogre_decap-with-vlan") == 0) 10004 mplsogre_decap_conf.select_vlan = 1; 10005 if (strcmp(res->ip_version, "ipv4") == 0) 10006 mplsogre_decap_conf.select_ipv4 = 1; 10007 else if (strcmp(res->ip_version, "ipv6") == 0) 10008 mplsogre_decap_conf.select_ipv4 = 0; 10009 } 10010 10011 static cmdline_parse_inst_t cmd_set_mplsogre_decap = { 10012 .f = cmd_set_mplsogre_decap_parsed, 10013 .data = NULL, 10014 .help_str = "set mplsogre_decap ip-version ipv4|ipv6", 10015 .tokens = { 10016 (void *)&cmd_set_mplsogre_decap_set, 10017 (void *)&cmd_set_mplsogre_decap_mplsogre_decap, 10018 (void *)&cmd_set_mplsogre_decap_ip_version, 10019 (void *)&cmd_set_mplsogre_decap_ip_version_value, 10020 NULL, 10021 }, 10022 }; 10023 10024 static cmdline_parse_inst_t cmd_set_mplsogre_decap_with_vlan = { 10025 .f = cmd_set_mplsogre_decap_parsed, 10026 .data = NULL, 10027 .help_str = "set mplsogre_decap-with-vlan ip-version ipv4|ipv6", 10028 .tokens = { 10029 (void *)&cmd_set_mplsogre_decap_set, 10030 (void *)&cmd_set_mplsogre_decap_mplsogre_decap_with_vlan, 10031 (void *)&cmd_set_mplsogre_decap_ip_version, 10032 (void *)&cmd_set_mplsogre_decap_ip_version_value, 10033 NULL, 10034 }, 10035 }; 10036 10037 /** Set MPLSoUDP encapsulation details */ 10038 struct cmd_set_mplsoudp_encap_result { 10039 cmdline_fixed_string_t set; 10040 cmdline_fixed_string_t mplsoudp; 10041 cmdline_fixed_string_t pos_token; 10042 cmdline_fixed_string_t ip_version; 10043 uint32_t vlan_present:1; 10044 uint32_t label; 10045 uint16_t udp_src; 10046 uint16_t udp_dst; 10047 cmdline_ipaddr_t ip_src; 10048 cmdline_ipaddr_t ip_dst; 10049 uint16_t tci; 10050 struct rte_ether_addr eth_src; 10051 struct rte_ether_addr eth_dst; 10052 }; 10053 10054 static cmdline_parse_token_string_t cmd_set_mplsoudp_encap_set = 10055 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_encap_result, set, 10056 "set"); 10057 static cmdline_parse_token_string_t cmd_set_mplsoudp_encap_mplsoudp_encap = 10058 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_encap_result, mplsoudp, 10059 "mplsoudp_encap"); 10060 static cmdline_parse_token_string_t cmd_set_mplsoudp_encap_mplsoudp_encap_with_vlan = 10061 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_encap_result, 10062 mplsoudp, "mplsoudp_encap-with-vlan"); 10063 static cmdline_parse_token_string_t cmd_set_mplsoudp_encap_ip_version = 10064 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_encap_result, 10065 pos_token, "ip-version"); 10066 static cmdline_parse_token_string_t cmd_set_mplsoudp_encap_ip_version_value = 10067 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_encap_result, 10068 ip_version, "ipv4#ipv6"); 10069 static cmdline_parse_token_string_t cmd_set_mplsoudp_encap_label = 10070 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_encap_result, 10071 pos_token, "label"); 10072 static cmdline_parse_token_num_t cmd_set_mplsoudp_encap_label_value = 10073 TOKEN_NUM_INITIALIZER(struct cmd_set_mplsoudp_encap_result, label, 10074 RTE_UINT32); 10075 static cmdline_parse_token_string_t cmd_set_mplsoudp_encap_udp_src = 10076 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_encap_result, 10077 pos_token, "udp-src"); 10078 static cmdline_parse_token_num_t cmd_set_mplsoudp_encap_udp_src_value = 10079 TOKEN_NUM_INITIALIZER(struct cmd_set_mplsoudp_encap_result, udp_src, 10080 RTE_UINT16); 10081 static cmdline_parse_token_string_t cmd_set_mplsoudp_encap_udp_dst = 10082 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_encap_result, 10083 pos_token, "udp-dst"); 10084 static cmdline_parse_token_num_t cmd_set_mplsoudp_encap_udp_dst_value = 10085 TOKEN_NUM_INITIALIZER(struct cmd_set_mplsoudp_encap_result, udp_dst, 10086 RTE_UINT16); 10087 static cmdline_parse_token_string_t cmd_set_mplsoudp_encap_ip_src = 10088 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_encap_result, 10089 pos_token, "ip-src"); 10090 static cmdline_parse_token_ipaddr_t cmd_set_mplsoudp_encap_ip_src_value = 10091 TOKEN_IPADDR_INITIALIZER(struct cmd_set_mplsoudp_encap_result, ip_src); 10092 static cmdline_parse_token_string_t cmd_set_mplsoudp_encap_ip_dst = 10093 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_encap_result, 10094 pos_token, "ip-dst"); 10095 static cmdline_parse_token_ipaddr_t cmd_set_mplsoudp_encap_ip_dst_value = 10096 TOKEN_IPADDR_INITIALIZER(struct cmd_set_mplsoudp_encap_result, ip_dst); 10097 static cmdline_parse_token_string_t cmd_set_mplsoudp_encap_vlan = 10098 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_encap_result, 10099 pos_token, "vlan-tci"); 10100 static cmdline_parse_token_num_t cmd_set_mplsoudp_encap_vlan_value = 10101 TOKEN_NUM_INITIALIZER(struct cmd_set_mplsoudp_encap_result, tci, 10102 RTE_UINT16); 10103 static cmdline_parse_token_string_t cmd_set_mplsoudp_encap_eth_src = 10104 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_encap_result, 10105 pos_token, "eth-src"); 10106 static cmdline_parse_token_etheraddr_t cmd_set_mplsoudp_encap_eth_src_value = 10107 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_mplsoudp_encap_result, 10108 eth_src); 10109 static cmdline_parse_token_string_t cmd_set_mplsoudp_encap_eth_dst = 10110 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_encap_result, 10111 pos_token, "eth-dst"); 10112 static cmdline_parse_token_etheraddr_t cmd_set_mplsoudp_encap_eth_dst_value = 10113 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_mplsoudp_encap_result, 10114 eth_dst); 10115 10116 static void cmd_set_mplsoudp_encap_parsed(void *parsed_result, 10117 __rte_unused struct cmdline *cl, 10118 __rte_unused void *data) 10119 { 10120 struct cmd_set_mplsoudp_encap_result *res = parsed_result; 10121 union { 10122 uint32_t mplsoudp_label; 10123 uint8_t label[4]; 10124 } id = { 10125 .mplsoudp_label = rte_cpu_to_be_32(res->label<<12), 10126 }; 10127 10128 if (strcmp(res->mplsoudp, "mplsoudp_encap") == 0) 10129 mplsoudp_encap_conf.select_vlan = 0; 10130 else if (strcmp(res->mplsoudp, "mplsoudp_encap-with-vlan") == 0) 10131 mplsoudp_encap_conf.select_vlan = 1; 10132 if (strcmp(res->ip_version, "ipv4") == 0) 10133 mplsoudp_encap_conf.select_ipv4 = 1; 10134 else if (strcmp(res->ip_version, "ipv6") == 0) 10135 mplsoudp_encap_conf.select_ipv4 = 0; 10136 else 10137 return; 10138 rte_memcpy(mplsoudp_encap_conf.label, &id.label, 3); 10139 mplsoudp_encap_conf.udp_src = rte_cpu_to_be_16(res->udp_src); 10140 mplsoudp_encap_conf.udp_dst = rte_cpu_to_be_16(res->udp_dst); 10141 if (mplsoudp_encap_conf.select_ipv4) { 10142 IPV4_ADDR_TO_UINT(res->ip_src, mplsoudp_encap_conf.ipv4_src); 10143 IPV4_ADDR_TO_UINT(res->ip_dst, mplsoudp_encap_conf.ipv4_dst); 10144 } else { 10145 IPV6_ADDR_TO_ARRAY(res->ip_src, mplsoudp_encap_conf.ipv6_src); 10146 IPV6_ADDR_TO_ARRAY(res->ip_dst, mplsoudp_encap_conf.ipv6_dst); 10147 } 10148 if (mplsoudp_encap_conf.select_vlan) 10149 mplsoudp_encap_conf.vlan_tci = rte_cpu_to_be_16(res->tci); 10150 rte_memcpy(mplsoudp_encap_conf.eth_src, res->eth_src.addr_bytes, 10151 RTE_ETHER_ADDR_LEN); 10152 rte_memcpy(mplsoudp_encap_conf.eth_dst, res->eth_dst.addr_bytes, 10153 RTE_ETHER_ADDR_LEN); 10154 } 10155 10156 static cmdline_parse_inst_t cmd_set_mplsoudp_encap = { 10157 .f = cmd_set_mplsoudp_encap_parsed, 10158 .data = NULL, 10159 .help_str = "set mplsoudp_encap ip-version ipv4|ipv6 label <label>" 10160 " udp-src <udp-src> udp-dst <udp-dst> ip-src <ip-src>" 10161 " ip-dst <ip-dst> eth-src <eth-src> eth-dst <eth-dst>", 10162 .tokens = { 10163 (void *)&cmd_set_mplsoudp_encap_set, 10164 (void *)&cmd_set_mplsoudp_encap_mplsoudp_encap, 10165 (void *)&cmd_set_mplsoudp_encap_ip_version, 10166 (void *)&cmd_set_mplsoudp_encap_ip_version_value, 10167 (void *)&cmd_set_mplsoudp_encap_label, 10168 (void *)&cmd_set_mplsoudp_encap_label_value, 10169 (void *)&cmd_set_mplsoudp_encap_udp_src, 10170 (void *)&cmd_set_mplsoudp_encap_udp_src_value, 10171 (void *)&cmd_set_mplsoudp_encap_udp_dst, 10172 (void *)&cmd_set_mplsoudp_encap_udp_dst_value, 10173 (void *)&cmd_set_mplsoudp_encap_ip_src, 10174 (void *)&cmd_set_mplsoudp_encap_ip_src_value, 10175 (void *)&cmd_set_mplsoudp_encap_ip_dst, 10176 (void *)&cmd_set_mplsoudp_encap_ip_dst_value, 10177 (void *)&cmd_set_mplsoudp_encap_eth_src, 10178 (void *)&cmd_set_mplsoudp_encap_eth_src_value, 10179 (void *)&cmd_set_mplsoudp_encap_eth_dst, 10180 (void *)&cmd_set_mplsoudp_encap_eth_dst_value, 10181 NULL, 10182 }, 10183 }; 10184 10185 static cmdline_parse_inst_t cmd_set_mplsoudp_encap_with_vlan = { 10186 .f = cmd_set_mplsoudp_encap_parsed, 10187 .data = NULL, 10188 .help_str = "set mplsoudp_encap-with-vlan ip-version ipv4|ipv6" 10189 " label <label> udp-src <udp-src> udp-dst <udp-dst>" 10190 " ip-src <ip-src> ip-dst <ip-dst> vlan-tci <vlan-tci>" 10191 " eth-src <eth-src> eth-dst <eth-dst>", 10192 .tokens = { 10193 (void *)&cmd_set_mplsoudp_encap_set, 10194 (void *)&cmd_set_mplsoudp_encap_mplsoudp_encap_with_vlan, 10195 (void *)&cmd_set_mplsoudp_encap_ip_version, 10196 (void *)&cmd_set_mplsoudp_encap_ip_version_value, 10197 (void *)&cmd_set_mplsoudp_encap_label, 10198 (void *)&cmd_set_mplsoudp_encap_label_value, 10199 (void *)&cmd_set_mplsoudp_encap_udp_src, 10200 (void *)&cmd_set_mplsoudp_encap_udp_src_value, 10201 (void *)&cmd_set_mplsoudp_encap_udp_dst, 10202 (void *)&cmd_set_mplsoudp_encap_udp_dst_value, 10203 (void *)&cmd_set_mplsoudp_encap_ip_src, 10204 (void *)&cmd_set_mplsoudp_encap_ip_src_value, 10205 (void *)&cmd_set_mplsoudp_encap_ip_dst, 10206 (void *)&cmd_set_mplsoudp_encap_ip_dst_value, 10207 (void *)&cmd_set_mplsoudp_encap_vlan, 10208 (void *)&cmd_set_mplsoudp_encap_vlan_value, 10209 (void *)&cmd_set_mplsoudp_encap_eth_src, 10210 (void *)&cmd_set_mplsoudp_encap_eth_src_value, 10211 (void *)&cmd_set_mplsoudp_encap_eth_dst, 10212 (void *)&cmd_set_mplsoudp_encap_eth_dst_value, 10213 NULL, 10214 }, 10215 }; 10216 10217 /** Set MPLSoUDP decapsulation details */ 10218 struct cmd_set_mplsoudp_decap_result { 10219 cmdline_fixed_string_t set; 10220 cmdline_fixed_string_t mplsoudp; 10221 cmdline_fixed_string_t pos_token; 10222 cmdline_fixed_string_t ip_version; 10223 uint32_t vlan_present:1; 10224 }; 10225 10226 static cmdline_parse_token_string_t cmd_set_mplsoudp_decap_set = 10227 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_decap_result, set, 10228 "set"); 10229 static cmdline_parse_token_string_t cmd_set_mplsoudp_decap_mplsoudp_decap = 10230 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_decap_result, mplsoudp, 10231 "mplsoudp_decap"); 10232 static cmdline_parse_token_string_t cmd_set_mplsoudp_decap_mplsoudp_decap_with_vlan = 10233 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_decap_result, 10234 mplsoudp, "mplsoudp_decap-with-vlan"); 10235 static cmdline_parse_token_string_t cmd_set_mplsoudp_decap_ip_version = 10236 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_decap_result, 10237 pos_token, "ip-version"); 10238 static cmdline_parse_token_string_t cmd_set_mplsoudp_decap_ip_version_value = 10239 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_decap_result, 10240 ip_version, "ipv4#ipv6"); 10241 10242 static void cmd_set_mplsoudp_decap_parsed(void *parsed_result, 10243 __rte_unused struct cmdline *cl, 10244 __rte_unused void *data) 10245 { 10246 struct cmd_set_mplsoudp_decap_result *res = parsed_result; 10247 10248 if (strcmp(res->mplsoudp, "mplsoudp_decap") == 0) 10249 mplsoudp_decap_conf.select_vlan = 0; 10250 else if (strcmp(res->mplsoudp, "mplsoudp_decap-with-vlan") == 0) 10251 mplsoudp_decap_conf.select_vlan = 1; 10252 if (strcmp(res->ip_version, "ipv4") == 0) 10253 mplsoudp_decap_conf.select_ipv4 = 1; 10254 else if (strcmp(res->ip_version, "ipv6") == 0) 10255 mplsoudp_decap_conf.select_ipv4 = 0; 10256 } 10257 10258 static cmdline_parse_inst_t cmd_set_mplsoudp_decap = { 10259 .f = cmd_set_mplsoudp_decap_parsed, 10260 .data = NULL, 10261 .help_str = "set mplsoudp_decap ip-version ipv4|ipv6", 10262 .tokens = { 10263 (void *)&cmd_set_mplsoudp_decap_set, 10264 (void *)&cmd_set_mplsoudp_decap_mplsoudp_decap, 10265 (void *)&cmd_set_mplsoudp_decap_ip_version, 10266 (void *)&cmd_set_mplsoudp_decap_ip_version_value, 10267 NULL, 10268 }, 10269 }; 10270 10271 static cmdline_parse_inst_t cmd_set_mplsoudp_decap_with_vlan = { 10272 .f = cmd_set_mplsoudp_decap_parsed, 10273 .data = NULL, 10274 .help_str = "set mplsoudp_decap-with-vlan ip-version ipv4|ipv6", 10275 .tokens = { 10276 (void *)&cmd_set_mplsoudp_decap_set, 10277 (void *)&cmd_set_mplsoudp_decap_mplsoudp_decap_with_vlan, 10278 (void *)&cmd_set_mplsoudp_decap_ip_version, 10279 (void *)&cmd_set_mplsoudp_decap_ip_version_value, 10280 NULL, 10281 }, 10282 }; 10283 10284 /** Set connection tracking object common details */ 10285 struct cmd_set_conntrack_common_result { 10286 cmdline_fixed_string_t set; 10287 cmdline_fixed_string_t conntrack; 10288 cmdline_fixed_string_t common; 10289 cmdline_fixed_string_t peer; 10290 cmdline_fixed_string_t is_orig; 10291 cmdline_fixed_string_t enable; 10292 cmdline_fixed_string_t live; 10293 cmdline_fixed_string_t sack; 10294 cmdline_fixed_string_t cack; 10295 cmdline_fixed_string_t last_dir; 10296 cmdline_fixed_string_t liberal; 10297 cmdline_fixed_string_t state; 10298 cmdline_fixed_string_t max_ack_win; 10299 cmdline_fixed_string_t retrans; 10300 cmdline_fixed_string_t last_win; 10301 cmdline_fixed_string_t last_seq; 10302 cmdline_fixed_string_t last_ack; 10303 cmdline_fixed_string_t last_end; 10304 cmdline_fixed_string_t last_index; 10305 uint8_t stat; 10306 uint8_t factor; 10307 uint16_t peer_port; 10308 uint32_t is_original; 10309 uint32_t en; 10310 uint32_t is_live; 10311 uint32_t s_ack; 10312 uint32_t c_ack; 10313 uint32_t ld; 10314 uint32_t lb; 10315 uint8_t re_num; 10316 uint8_t li; 10317 uint16_t lw; 10318 uint32_t ls; 10319 uint32_t la; 10320 uint32_t le; 10321 }; 10322 10323 static cmdline_parse_token_string_t cmd_set_conntrack_set = 10324 TOKEN_STRING_INITIALIZER(struct cmd_set_conntrack_common_result, 10325 set, "set"); 10326 static cmdline_parse_token_string_t cmd_set_conntrack_conntrack = 10327 TOKEN_STRING_INITIALIZER(struct cmd_set_conntrack_common_result, 10328 conntrack, "conntrack"); 10329 static cmdline_parse_token_string_t cmd_set_conntrack_common_com = 10330 TOKEN_STRING_INITIALIZER(struct cmd_set_conntrack_common_result, 10331 common, "com"); 10332 static cmdline_parse_token_string_t cmd_set_conntrack_common_peer = 10333 TOKEN_STRING_INITIALIZER(struct cmd_set_conntrack_common_result, 10334 peer, "peer"); 10335 static cmdline_parse_token_num_t cmd_set_conntrack_common_peer_value = 10336 TOKEN_NUM_INITIALIZER(struct cmd_set_conntrack_common_result, 10337 peer_port, RTE_UINT16); 10338 static cmdline_parse_token_string_t cmd_set_conntrack_common_is_orig = 10339 TOKEN_STRING_INITIALIZER(struct cmd_set_conntrack_common_result, 10340 is_orig, "is_orig"); 10341 static cmdline_parse_token_num_t cmd_set_conntrack_common_is_orig_value = 10342 TOKEN_NUM_INITIALIZER(struct cmd_set_conntrack_common_result, 10343 is_original, RTE_UINT32); 10344 static cmdline_parse_token_string_t cmd_set_conntrack_common_enable = 10345 TOKEN_STRING_INITIALIZER(struct cmd_set_conntrack_common_result, 10346 enable, "enable"); 10347 static cmdline_parse_token_num_t cmd_set_conntrack_common_enable_value = 10348 TOKEN_NUM_INITIALIZER(struct cmd_set_conntrack_common_result, 10349 en, RTE_UINT32); 10350 static cmdline_parse_token_string_t cmd_set_conntrack_common_live = 10351 TOKEN_STRING_INITIALIZER(struct cmd_set_conntrack_common_result, 10352 live, "live"); 10353 static cmdline_parse_token_num_t cmd_set_conntrack_common_live_value = 10354 TOKEN_NUM_INITIALIZER(struct cmd_set_conntrack_common_result, 10355 is_live, RTE_UINT32); 10356 static cmdline_parse_token_string_t cmd_set_conntrack_common_sack = 10357 TOKEN_STRING_INITIALIZER(struct cmd_set_conntrack_common_result, 10358 sack, "sack"); 10359 static cmdline_parse_token_num_t cmd_set_conntrack_common_sack_value = 10360 TOKEN_NUM_INITIALIZER(struct cmd_set_conntrack_common_result, 10361 s_ack, RTE_UINT32); 10362 static cmdline_parse_token_string_t cmd_set_conntrack_common_cack = 10363 TOKEN_STRING_INITIALIZER(struct cmd_set_conntrack_common_result, 10364 cack, "cack"); 10365 static cmdline_parse_token_num_t cmd_set_conntrack_common_cack_value = 10366 TOKEN_NUM_INITIALIZER(struct cmd_set_conntrack_common_result, 10367 c_ack, RTE_UINT32); 10368 static cmdline_parse_token_string_t cmd_set_conntrack_common_last_dir = 10369 TOKEN_STRING_INITIALIZER(struct cmd_set_conntrack_common_result, 10370 last_dir, "last_dir"); 10371 static cmdline_parse_token_num_t cmd_set_conntrack_common_last_dir_value = 10372 TOKEN_NUM_INITIALIZER(struct cmd_set_conntrack_common_result, 10373 ld, RTE_UINT32); 10374 static cmdline_parse_token_string_t cmd_set_conntrack_common_liberal = 10375 TOKEN_STRING_INITIALIZER(struct cmd_set_conntrack_common_result, 10376 liberal, "liberal"); 10377 static cmdline_parse_token_num_t cmd_set_conntrack_common_liberal_value = 10378 TOKEN_NUM_INITIALIZER(struct cmd_set_conntrack_common_result, 10379 lb, RTE_UINT32); 10380 static cmdline_parse_token_string_t cmd_set_conntrack_common_state = 10381 TOKEN_STRING_INITIALIZER(struct cmd_set_conntrack_common_result, 10382 state, "state"); 10383 static cmdline_parse_token_num_t cmd_set_conntrack_common_state_value = 10384 TOKEN_NUM_INITIALIZER(struct cmd_set_conntrack_common_result, 10385 stat, RTE_UINT8); 10386 static cmdline_parse_token_string_t cmd_set_conntrack_common_max_ackwin = 10387 TOKEN_STRING_INITIALIZER(struct cmd_set_conntrack_common_result, 10388 max_ack_win, "max_ack_win"); 10389 static cmdline_parse_token_num_t cmd_set_conntrack_common_max_ackwin_value = 10390 TOKEN_NUM_INITIALIZER(struct cmd_set_conntrack_common_result, 10391 factor, RTE_UINT8); 10392 static cmdline_parse_token_string_t cmd_set_conntrack_common_retrans = 10393 TOKEN_STRING_INITIALIZER(struct cmd_set_conntrack_common_result, 10394 retrans, "r_lim"); 10395 static cmdline_parse_token_num_t cmd_set_conntrack_common_retrans_value = 10396 TOKEN_NUM_INITIALIZER(struct cmd_set_conntrack_common_result, 10397 re_num, RTE_UINT8); 10398 static cmdline_parse_token_string_t cmd_set_conntrack_common_last_win = 10399 TOKEN_STRING_INITIALIZER(struct cmd_set_conntrack_common_result, 10400 last_win, "last_win"); 10401 static cmdline_parse_token_num_t cmd_set_conntrack_common_last_win_value = 10402 TOKEN_NUM_INITIALIZER(struct cmd_set_conntrack_common_result, 10403 lw, RTE_UINT16); 10404 static cmdline_parse_token_string_t cmd_set_conntrack_common_last_seq = 10405 TOKEN_STRING_INITIALIZER(struct cmd_set_conntrack_common_result, 10406 last_seq, "last_seq"); 10407 static cmdline_parse_token_num_t cmd_set_conntrack_common_last_seq_value = 10408 TOKEN_NUM_INITIALIZER(struct cmd_set_conntrack_common_result, 10409 ls, RTE_UINT32); 10410 static cmdline_parse_token_string_t cmd_set_conntrack_common_last_ack = 10411 TOKEN_STRING_INITIALIZER(struct cmd_set_conntrack_common_result, 10412 last_ack, "last_ack"); 10413 static cmdline_parse_token_num_t cmd_set_conntrack_common_last_ack_value = 10414 TOKEN_NUM_INITIALIZER(struct cmd_set_conntrack_common_result, 10415 la, RTE_UINT32); 10416 static cmdline_parse_token_string_t cmd_set_conntrack_common_last_end = 10417 TOKEN_STRING_INITIALIZER(struct cmd_set_conntrack_common_result, 10418 last_end, "last_end"); 10419 static cmdline_parse_token_num_t cmd_set_conntrack_common_last_end_value = 10420 TOKEN_NUM_INITIALIZER(struct cmd_set_conntrack_common_result, 10421 le, RTE_UINT32); 10422 static cmdline_parse_token_string_t cmd_set_conntrack_common_last_index = 10423 TOKEN_STRING_INITIALIZER(struct cmd_set_conntrack_common_result, 10424 last_index, "last_index"); 10425 static cmdline_parse_token_num_t cmd_set_conntrack_common_last_index_value = 10426 TOKEN_NUM_INITIALIZER(struct cmd_set_conntrack_common_result, 10427 li, RTE_UINT8); 10428 10429 static void cmd_set_conntrack_common_parsed(void *parsed_result, 10430 __rte_unused struct cmdline *cl, 10431 __rte_unused void *data) 10432 { 10433 struct cmd_set_conntrack_common_result *res = parsed_result; 10434 10435 /* No need to swap to big endian. */ 10436 conntrack_context.peer_port = res->peer_port; 10437 conntrack_context.is_original_dir = res->is_original; 10438 conntrack_context.enable = res->en; 10439 conntrack_context.live_connection = res->is_live; 10440 conntrack_context.selective_ack = res->s_ack; 10441 conntrack_context.challenge_ack_passed = res->c_ack; 10442 conntrack_context.last_direction = res->ld; 10443 conntrack_context.liberal_mode = res->lb; 10444 conntrack_context.state = (enum rte_flow_conntrack_state)res->stat; 10445 conntrack_context.max_ack_window = res->factor; 10446 conntrack_context.retransmission_limit = res->re_num; 10447 conntrack_context.last_window = res->lw; 10448 conntrack_context.last_index = 10449 (enum rte_flow_conntrack_tcp_last_index)res->li; 10450 conntrack_context.last_seq = res->ls; 10451 conntrack_context.last_ack = res->la; 10452 conntrack_context.last_end = res->le; 10453 } 10454 10455 static cmdline_parse_inst_t cmd_set_conntrack_common = { 10456 .f = cmd_set_conntrack_common_parsed, 10457 .data = NULL, 10458 .help_str = "set conntrack com peer <port_id> is_orig <dir> enable <en>" 10459 " live <ack_seen> sack <en> cack <passed> last_dir <dir>" 10460 " liberal <en> state <s> max_ack_win <factor> r_lim <num>" 10461 " last_win <win> last_seq <seq> last_ack <ack> last_end <end>" 10462 " last_index <flag>", 10463 .tokens = { 10464 (void *)&cmd_set_conntrack_set, 10465 (void *)&cmd_set_conntrack_conntrack, 10466 (void *)&cmd_set_conntrack_common_com, 10467 (void *)&cmd_set_conntrack_common_peer, 10468 (void *)&cmd_set_conntrack_common_peer_value, 10469 (void *)&cmd_set_conntrack_common_is_orig, 10470 (void *)&cmd_set_conntrack_common_is_orig_value, 10471 (void *)&cmd_set_conntrack_common_enable, 10472 (void *)&cmd_set_conntrack_common_enable_value, 10473 (void *)&cmd_set_conntrack_common_live, 10474 (void *)&cmd_set_conntrack_common_live_value, 10475 (void *)&cmd_set_conntrack_common_sack, 10476 (void *)&cmd_set_conntrack_common_sack_value, 10477 (void *)&cmd_set_conntrack_common_cack, 10478 (void *)&cmd_set_conntrack_common_cack_value, 10479 (void *)&cmd_set_conntrack_common_last_dir, 10480 (void *)&cmd_set_conntrack_common_last_dir_value, 10481 (void *)&cmd_set_conntrack_common_liberal, 10482 (void *)&cmd_set_conntrack_common_liberal_value, 10483 (void *)&cmd_set_conntrack_common_state, 10484 (void *)&cmd_set_conntrack_common_state_value, 10485 (void *)&cmd_set_conntrack_common_max_ackwin, 10486 (void *)&cmd_set_conntrack_common_max_ackwin_value, 10487 (void *)&cmd_set_conntrack_common_retrans, 10488 (void *)&cmd_set_conntrack_common_retrans_value, 10489 (void *)&cmd_set_conntrack_common_last_win, 10490 (void *)&cmd_set_conntrack_common_last_win_value, 10491 (void *)&cmd_set_conntrack_common_last_seq, 10492 (void *)&cmd_set_conntrack_common_last_seq_value, 10493 (void *)&cmd_set_conntrack_common_last_ack, 10494 (void *)&cmd_set_conntrack_common_last_ack_value, 10495 (void *)&cmd_set_conntrack_common_last_end, 10496 (void *)&cmd_set_conntrack_common_last_end_value, 10497 (void *)&cmd_set_conntrack_common_last_index, 10498 (void *)&cmd_set_conntrack_common_last_index_value, 10499 NULL, 10500 }, 10501 }; 10502 10503 /** Set connection tracking object both directions' details */ 10504 struct cmd_set_conntrack_dir_result { 10505 cmdline_fixed_string_t set; 10506 cmdline_fixed_string_t conntrack; 10507 cmdline_fixed_string_t dir; 10508 cmdline_fixed_string_t scale; 10509 cmdline_fixed_string_t fin; 10510 cmdline_fixed_string_t ack_seen; 10511 cmdline_fixed_string_t unack; 10512 cmdline_fixed_string_t sent_end; 10513 cmdline_fixed_string_t reply_end; 10514 cmdline_fixed_string_t max_win; 10515 cmdline_fixed_string_t max_ack; 10516 uint32_t factor; 10517 uint32_t f; 10518 uint32_t as; 10519 uint32_t un; 10520 uint32_t se; 10521 uint32_t re; 10522 uint32_t mw; 10523 uint32_t ma; 10524 }; 10525 10526 static cmdline_parse_token_string_t cmd_set_conntrack_dir_dir = 10527 TOKEN_STRING_INITIALIZER(struct cmd_set_conntrack_dir_result, 10528 dir, "orig#rply"); 10529 static cmdline_parse_token_string_t cmd_set_conntrack_dir_scale = 10530 TOKEN_STRING_INITIALIZER(struct cmd_set_conntrack_dir_result, 10531 scale, "scale"); 10532 static cmdline_parse_token_num_t cmd_set_conntrack_dir_scale_value = 10533 TOKEN_NUM_INITIALIZER(struct cmd_set_conntrack_dir_result, 10534 factor, RTE_UINT32); 10535 static cmdline_parse_token_string_t cmd_set_conntrack_dir_fin = 10536 TOKEN_STRING_INITIALIZER(struct cmd_set_conntrack_dir_result, 10537 fin, "fin"); 10538 static cmdline_parse_token_num_t cmd_set_conntrack_dir_fin_value = 10539 TOKEN_NUM_INITIALIZER(struct cmd_set_conntrack_dir_result, 10540 f, RTE_UINT32); 10541 static cmdline_parse_token_string_t cmd_set_conntrack_dir_ack = 10542 TOKEN_STRING_INITIALIZER(struct cmd_set_conntrack_dir_result, 10543 ack_seen, "acked"); 10544 static cmdline_parse_token_num_t cmd_set_conntrack_dir_ack_value = 10545 TOKEN_NUM_INITIALIZER(struct cmd_set_conntrack_dir_result, 10546 as, RTE_UINT32); 10547 static cmdline_parse_token_string_t cmd_set_conntrack_dir_unack_data = 10548 TOKEN_STRING_INITIALIZER(struct cmd_set_conntrack_dir_result, 10549 unack, "unack_data"); 10550 static cmdline_parse_token_num_t cmd_set_conntrack_dir_unack_data_value = 10551 TOKEN_NUM_INITIALIZER(struct cmd_set_conntrack_dir_result, 10552 un, RTE_UINT32); 10553 static cmdline_parse_token_string_t cmd_set_conntrack_dir_sent_end = 10554 TOKEN_STRING_INITIALIZER(struct cmd_set_conntrack_dir_result, 10555 sent_end, "sent_end"); 10556 static cmdline_parse_token_num_t cmd_set_conntrack_dir_sent_end_value = 10557 TOKEN_NUM_INITIALIZER(struct cmd_set_conntrack_dir_result, 10558 se, RTE_UINT32); 10559 static cmdline_parse_token_string_t cmd_set_conntrack_dir_reply_end = 10560 TOKEN_STRING_INITIALIZER(struct cmd_set_conntrack_dir_result, 10561 reply_end, "reply_end"); 10562 static cmdline_parse_token_num_t cmd_set_conntrack_dir_reply_end_value = 10563 TOKEN_NUM_INITIALIZER(struct cmd_set_conntrack_dir_result, 10564 re, RTE_UINT32); 10565 static cmdline_parse_token_string_t cmd_set_conntrack_dir_max_win = 10566 TOKEN_STRING_INITIALIZER(struct cmd_set_conntrack_dir_result, 10567 max_win, "max_win"); 10568 static cmdline_parse_token_num_t cmd_set_conntrack_dir_max_win_value = 10569 TOKEN_NUM_INITIALIZER(struct cmd_set_conntrack_dir_result, 10570 mw, RTE_UINT32); 10571 static cmdline_parse_token_string_t cmd_set_conntrack_dir_max_ack = 10572 TOKEN_STRING_INITIALIZER(struct cmd_set_conntrack_dir_result, 10573 max_ack, "max_ack"); 10574 static cmdline_parse_token_num_t cmd_set_conntrack_dir_max_ack_value = 10575 TOKEN_NUM_INITIALIZER(struct cmd_set_conntrack_dir_result, 10576 ma, RTE_UINT32); 10577 10578 static void cmd_set_conntrack_dir_parsed(void *parsed_result, 10579 __rte_unused struct cmdline *cl, 10580 __rte_unused void *data) 10581 { 10582 struct cmd_set_conntrack_dir_result *res = parsed_result; 10583 struct rte_flow_tcp_dir_param *dir = NULL; 10584 10585 if (strcmp(res->dir, "orig") == 0) 10586 dir = &conntrack_context.original_dir; 10587 else if (strcmp(res->dir, "rply") == 0) 10588 dir = &conntrack_context.reply_dir; 10589 else 10590 return; 10591 dir->scale = res->factor; 10592 dir->close_initiated = res->f; 10593 dir->last_ack_seen = res->as; 10594 dir->data_unacked = res->un; 10595 dir->sent_end = res->se; 10596 dir->reply_end = res->re; 10597 dir->max_ack = res->ma; 10598 dir->max_win = res->mw; 10599 } 10600 10601 static cmdline_parse_inst_t cmd_set_conntrack_dir = { 10602 .f = cmd_set_conntrack_dir_parsed, 10603 .data = NULL, 10604 .help_str = "set conntrack orig|rply scale <factor> fin <sent>" 10605 " acked <seen> unack_data <unack> sent_end <sent>" 10606 " reply_end <reply> max_win <win> max_ack <ack>", 10607 .tokens = { 10608 (void *)&cmd_set_conntrack_set, 10609 (void *)&cmd_set_conntrack_conntrack, 10610 (void *)&cmd_set_conntrack_dir_dir, 10611 (void *)&cmd_set_conntrack_dir_scale, 10612 (void *)&cmd_set_conntrack_dir_scale_value, 10613 (void *)&cmd_set_conntrack_dir_fin, 10614 (void *)&cmd_set_conntrack_dir_fin_value, 10615 (void *)&cmd_set_conntrack_dir_ack, 10616 (void *)&cmd_set_conntrack_dir_ack_value, 10617 (void *)&cmd_set_conntrack_dir_unack_data, 10618 (void *)&cmd_set_conntrack_dir_unack_data_value, 10619 (void *)&cmd_set_conntrack_dir_sent_end, 10620 (void *)&cmd_set_conntrack_dir_sent_end_value, 10621 (void *)&cmd_set_conntrack_dir_reply_end, 10622 (void *)&cmd_set_conntrack_dir_reply_end_value, 10623 (void *)&cmd_set_conntrack_dir_max_win, 10624 (void *)&cmd_set_conntrack_dir_max_win_value, 10625 (void *)&cmd_set_conntrack_dir_max_ack, 10626 (void *)&cmd_set_conntrack_dir_max_ack_value, 10627 NULL, 10628 }, 10629 }; 10630 10631 /* show vf stats */ 10632 10633 /* Common result structure for show vf stats */ 10634 struct cmd_show_vf_stats_result { 10635 cmdline_fixed_string_t show; 10636 cmdline_fixed_string_t vf; 10637 cmdline_fixed_string_t stats; 10638 portid_t port_id; 10639 uint16_t vf_id; 10640 }; 10641 10642 /* Common CLI fields show vf stats*/ 10643 static cmdline_parse_token_string_t cmd_show_vf_stats_show = 10644 TOKEN_STRING_INITIALIZER 10645 (struct cmd_show_vf_stats_result, 10646 show, "show"); 10647 static cmdline_parse_token_string_t cmd_show_vf_stats_vf = 10648 TOKEN_STRING_INITIALIZER 10649 (struct cmd_show_vf_stats_result, 10650 vf, "vf"); 10651 static cmdline_parse_token_string_t cmd_show_vf_stats_stats = 10652 TOKEN_STRING_INITIALIZER 10653 (struct cmd_show_vf_stats_result, 10654 stats, "stats"); 10655 static cmdline_parse_token_num_t cmd_show_vf_stats_port_id = 10656 TOKEN_NUM_INITIALIZER 10657 (struct cmd_show_vf_stats_result, 10658 port_id, RTE_UINT16); 10659 static cmdline_parse_token_num_t cmd_show_vf_stats_vf_id = 10660 TOKEN_NUM_INITIALIZER 10661 (struct cmd_show_vf_stats_result, 10662 vf_id, RTE_UINT16); 10663 10664 static void 10665 cmd_show_vf_stats_parsed( 10666 void *parsed_result, 10667 __rte_unused struct cmdline *cl, 10668 __rte_unused void *data) 10669 { 10670 struct cmd_show_vf_stats_result *res = parsed_result; 10671 struct rte_eth_stats stats; 10672 int ret = -ENOTSUP; 10673 static const char *nic_stats_border = "########################"; 10674 10675 if (port_id_is_invalid(res->port_id, ENABLED_WARN)) 10676 return; 10677 10678 memset(&stats, 0, sizeof(stats)); 10679 10680 #ifdef RTE_NET_I40E 10681 if (ret == -ENOTSUP) 10682 ret = rte_pmd_i40e_get_vf_stats(res->port_id, 10683 res->vf_id, 10684 &stats); 10685 #endif 10686 #ifdef RTE_NET_BNXT 10687 if (ret == -ENOTSUP) 10688 ret = rte_pmd_bnxt_get_vf_stats(res->port_id, 10689 res->vf_id, 10690 &stats); 10691 #endif 10692 10693 switch (ret) { 10694 case 0: 10695 break; 10696 case -EINVAL: 10697 fprintf(stderr, "invalid vf_id %d\n", res->vf_id); 10698 break; 10699 case -ENODEV: 10700 fprintf(stderr, "invalid port_id %d\n", res->port_id); 10701 break; 10702 case -ENOTSUP: 10703 fprintf(stderr, "function not implemented\n"); 10704 break; 10705 default: 10706 fprintf(stderr, "programming error: (%s)\n", strerror(-ret)); 10707 } 10708 10709 printf("\n %s NIC statistics for port %-2d vf %-2d %s\n", 10710 nic_stats_border, res->port_id, res->vf_id, nic_stats_border); 10711 10712 printf(" RX-packets: %-10"PRIu64" RX-missed: %-10"PRIu64" RX-bytes: " 10713 "%-"PRIu64"\n", 10714 stats.ipackets, stats.imissed, stats.ibytes); 10715 printf(" RX-errors: %-"PRIu64"\n", stats.ierrors); 10716 printf(" RX-nombuf: %-10"PRIu64"\n", 10717 stats.rx_nombuf); 10718 printf(" TX-packets: %-10"PRIu64" TX-errors: %-10"PRIu64" TX-bytes: " 10719 "%-"PRIu64"\n", 10720 stats.opackets, stats.oerrors, stats.obytes); 10721 10722 printf(" %s############################%s\n", 10723 nic_stats_border, nic_stats_border); 10724 } 10725 10726 static cmdline_parse_inst_t cmd_show_vf_stats = { 10727 .f = cmd_show_vf_stats_parsed, 10728 .data = NULL, 10729 .help_str = "show vf stats <port_id> <vf_id>", 10730 .tokens = { 10731 (void *)&cmd_show_vf_stats_show, 10732 (void *)&cmd_show_vf_stats_vf, 10733 (void *)&cmd_show_vf_stats_stats, 10734 (void *)&cmd_show_vf_stats_port_id, 10735 (void *)&cmd_show_vf_stats_vf_id, 10736 NULL, 10737 }, 10738 }; 10739 10740 /* clear vf stats */ 10741 10742 /* Common result structure for clear vf stats */ 10743 struct cmd_clear_vf_stats_result { 10744 cmdline_fixed_string_t clear; 10745 cmdline_fixed_string_t vf; 10746 cmdline_fixed_string_t stats; 10747 portid_t port_id; 10748 uint16_t vf_id; 10749 }; 10750 10751 /* Common CLI fields clear vf stats*/ 10752 static cmdline_parse_token_string_t cmd_clear_vf_stats_clear = 10753 TOKEN_STRING_INITIALIZER 10754 (struct cmd_clear_vf_stats_result, 10755 clear, "clear"); 10756 static cmdline_parse_token_string_t cmd_clear_vf_stats_vf = 10757 TOKEN_STRING_INITIALIZER 10758 (struct cmd_clear_vf_stats_result, 10759 vf, "vf"); 10760 static cmdline_parse_token_string_t cmd_clear_vf_stats_stats = 10761 TOKEN_STRING_INITIALIZER 10762 (struct cmd_clear_vf_stats_result, 10763 stats, "stats"); 10764 static cmdline_parse_token_num_t cmd_clear_vf_stats_port_id = 10765 TOKEN_NUM_INITIALIZER 10766 (struct cmd_clear_vf_stats_result, 10767 port_id, RTE_UINT16); 10768 static cmdline_parse_token_num_t cmd_clear_vf_stats_vf_id = 10769 TOKEN_NUM_INITIALIZER 10770 (struct cmd_clear_vf_stats_result, 10771 vf_id, RTE_UINT16); 10772 10773 static void 10774 cmd_clear_vf_stats_parsed( 10775 void *parsed_result, 10776 __rte_unused struct cmdline *cl, 10777 __rte_unused void *data) 10778 { 10779 struct cmd_clear_vf_stats_result *res = parsed_result; 10780 int ret = -ENOTSUP; 10781 10782 if (port_id_is_invalid(res->port_id, ENABLED_WARN)) 10783 return; 10784 10785 #ifdef RTE_NET_I40E 10786 if (ret == -ENOTSUP) 10787 ret = rte_pmd_i40e_reset_vf_stats(res->port_id, 10788 res->vf_id); 10789 #endif 10790 #ifdef RTE_NET_BNXT 10791 if (ret == -ENOTSUP) 10792 ret = rte_pmd_bnxt_reset_vf_stats(res->port_id, 10793 res->vf_id); 10794 #endif 10795 10796 switch (ret) { 10797 case 0: 10798 break; 10799 case -EINVAL: 10800 fprintf(stderr, "invalid vf_id %d\n", res->vf_id); 10801 break; 10802 case -ENODEV: 10803 fprintf(stderr, "invalid port_id %d\n", res->port_id); 10804 break; 10805 case -ENOTSUP: 10806 fprintf(stderr, "function not implemented\n"); 10807 break; 10808 default: 10809 fprintf(stderr, "programming error: (%s)\n", strerror(-ret)); 10810 } 10811 } 10812 10813 static cmdline_parse_inst_t cmd_clear_vf_stats = { 10814 .f = cmd_clear_vf_stats_parsed, 10815 .data = NULL, 10816 .help_str = "clear vf stats <port_id> <vf_id>", 10817 .tokens = { 10818 (void *)&cmd_clear_vf_stats_clear, 10819 (void *)&cmd_clear_vf_stats_vf, 10820 (void *)&cmd_clear_vf_stats_stats, 10821 (void *)&cmd_clear_vf_stats_port_id, 10822 (void *)&cmd_clear_vf_stats_vf_id, 10823 NULL, 10824 }, 10825 }; 10826 10827 /* Common result structure for file commands */ 10828 struct cmd_cmdfile_result { 10829 cmdline_fixed_string_t load; 10830 cmdline_fixed_string_t filename; 10831 }; 10832 10833 /* Common CLI fields for file commands */ 10834 static cmdline_parse_token_string_t cmd_load_cmdfile = 10835 TOKEN_STRING_INITIALIZER(struct cmd_cmdfile_result, load, "load"); 10836 static cmdline_parse_token_string_t cmd_load_cmdfile_filename = 10837 TOKEN_STRING_INITIALIZER(struct cmd_cmdfile_result, filename, NULL); 10838 10839 static void 10840 cmd_load_from_file_parsed( 10841 void *parsed_result, 10842 __rte_unused struct cmdline *cl, 10843 __rte_unused void *data) 10844 { 10845 struct cmd_cmdfile_result *res = parsed_result; 10846 10847 cmdline_read_from_file(res->filename); 10848 } 10849 10850 static cmdline_parse_inst_t cmd_load_from_file = { 10851 .f = cmd_load_from_file_parsed, 10852 .data = NULL, 10853 .help_str = "load <filename>", 10854 .tokens = { 10855 (void *)&cmd_load_cmdfile, 10856 (void *)&cmd_load_cmdfile_filename, 10857 NULL, 10858 }, 10859 }; 10860 10861 /* Get Rx offloads capabilities */ 10862 struct cmd_rx_offload_get_capa_result { 10863 cmdline_fixed_string_t show; 10864 cmdline_fixed_string_t port; 10865 portid_t port_id; 10866 cmdline_fixed_string_t rx_offload; 10867 cmdline_fixed_string_t capabilities; 10868 }; 10869 10870 static cmdline_parse_token_string_t cmd_rx_offload_get_capa_show = 10871 TOKEN_STRING_INITIALIZER 10872 (struct cmd_rx_offload_get_capa_result, 10873 show, "show"); 10874 static cmdline_parse_token_string_t cmd_rx_offload_get_capa_port = 10875 TOKEN_STRING_INITIALIZER 10876 (struct cmd_rx_offload_get_capa_result, 10877 port, "port"); 10878 static cmdline_parse_token_num_t cmd_rx_offload_get_capa_port_id = 10879 TOKEN_NUM_INITIALIZER 10880 (struct cmd_rx_offload_get_capa_result, 10881 port_id, RTE_UINT16); 10882 static cmdline_parse_token_string_t cmd_rx_offload_get_capa_rx_offload = 10883 TOKEN_STRING_INITIALIZER 10884 (struct cmd_rx_offload_get_capa_result, 10885 rx_offload, "rx_offload"); 10886 static cmdline_parse_token_string_t cmd_rx_offload_get_capa_capabilities = 10887 TOKEN_STRING_INITIALIZER 10888 (struct cmd_rx_offload_get_capa_result, 10889 capabilities, "capabilities"); 10890 10891 static void 10892 print_rx_offloads(uint64_t offloads) 10893 { 10894 uint64_t single_offload; 10895 int begin; 10896 int end; 10897 int bit; 10898 10899 if (offloads == 0) 10900 return; 10901 10902 begin = rte_ctz64(offloads); 10903 end = sizeof(offloads) * CHAR_BIT - rte_clz64(offloads); 10904 10905 single_offload = 1ULL << begin; 10906 for (bit = begin; bit < end; bit++) { 10907 if (offloads & single_offload) 10908 printf(" %s", 10909 rte_eth_dev_rx_offload_name(single_offload)); 10910 single_offload <<= 1; 10911 } 10912 } 10913 10914 static void 10915 cmd_rx_offload_get_capa_parsed( 10916 void *parsed_result, 10917 __rte_unused struct cmdline *cl, 10918 __rte_unused void *data) 10919 { 10920 struct cmd_rx_offload_get_capa_result *res = parsed_result; 10921 struct rte_eth_dev_info dev_info; 10922 portid_t port_id = res->port_id; 10923 uint64_t queue_offloads; 10924 uint64_t port_offloads; 10925 int ret; 10926 10927 ret = eth_dev_info_get_print_err(port_id, &dev_info); 10928 if (ret != 0) 10929 return; 10930 10931 queue_offloads = dev_info.rx_queue_offload_capa; 10932 port_offloads = dev_info.rx_offload_capa ^ queue_offloads; 10933 10934 printf("Rx Offloading Capabilities of port %d :\n", port_id); 10935 printf(" Per Queue :"); 10936 print_rx_offloads(queue_offloads); 10937 10938 printf("\n"); 10939 printf(" Per Port :"); 10940 print_rx_offloads(port_offloads); 10941 printf("\n\n"); 10942 } 10943 10944 static cmdline_parse_inst_t cmd_rx_offload_get_capa = { 10945 .f = cmd_rx_offload_get_capa_parsed, 10946 .data = NULL, 10947 .help_str = "show port <port_id> rx_offload capabilities", 10948 .tokens = { 10949 (void *)&cmd_rx_offload_get_capa_show, 10950 (void *)&cmd_rx_offload_get_capa_port, 10951 (void *)&cmd_rx_offload_get_capa_port_id, 10952 (void *)&cmd_rx_offload_get_capa_rx_offload, 10953 (void *)&cmd_rx_offload_get_capa_capabilities, 10954 NULL, 10955 } 10956 }; 10957 10958 /* Get Rx offloads configuration */ 10959 struct cmd_rx_offload_get_configuration_result { 10960 cmdline_fixed_string_t show; 10961 cmdline_fixed_string_t port; 10962 portid_t port_id; 10963 cmdline_fixed_string_t rx_offload; 10964 cmdline_fixed_string_t configuration; 10965 }; 10966 10967 static cmdline_parse_token_string_t cmd_rx_offload_get_configuration_show = 10968 TOKEN_STRING_INITIALIZER 10969 (struct cmd_rx_offload_get_configuration_result, 10970 show, "show"); 10971 static cmdline_parse_token_string_t cmd_rx_offload_get_configuration_port = 10972 TOKEN_STRING_INITIALIZER 10973 (struct cmd_rx_offload_get_configuration_result, 10974 port, "port"); 10975 static cmdline_parse_token_num_t cmd_rx_offload_get_configuration_port_id = 10976 TOKEN_NUM_INITIALIZER 10977 (struct cmd_rx_offload_get_configuration_result, 10978 port_id, RTE_UINT16); 10979 static cmdline_parse_token_string_t cmd_rx_offload_get_configuration_rx_offload = 10980 TOKEN_STRING_INITIALIZER 10981 (struct cmd_rx_offload_get_configuration_result, 10982 rx_offload, "rx_offload"); 10983 static cmdline_parse_token_string_t cmd_rx_offload_get_configuration_configuration = 10984 TOKEN_STRING_INITIALIZER 10985 (struct cmd_rx_offload_get_configuration_result, 10986 configuration, "configuration"); 10987 10988 static void 10989 cmd_rx_offload_get_configuration_parsed( 10990 void *parsed_result, 10991 __rte_unused struct cmdline *cl, 10992 __rte_unused void *data) 10993 { 10994 struct cmd_rx_offload_get_configuration_result *res = parsed_result; 10995 struct rte_eth_dev_info dev_info; 10996 portid_t port_id = res->port_id; 10997 struct rte_port *port = &ports[port_id]; 10998 struct rte_eth_conf dev_conf; 10999 uint64_t port_offloads; 11000 uint64_t queue_offloads; 11001 uint16_t nb_rx_queues; 11002 int q; 11003 int ret; 11004 11005 printf("Rx Offloading Configuration of port %d :\n", port_id); 11006 11007 ret = eth_dev_conf_get_print_err(port_id, &dev_conf); 11008 if (ret != 0) 11009 return; 11010 11011 port_offloads = dev_conf.rxmode.offloads; 11012 printf(" Port :"); 11013 print_rx_offloads(port_offloads); 11014 printf("\n"); 11015 11016 ret = eth_dev_info_get_print_err(port_id, &dev_info); 11017 if (ret != 0) 11018 return; 11019 11020 nb_rx_queues = dev_info.nb_rx_queues; 11021 for (q = 0; q < nb_rx_queues; q++) { 11022 queue_offloads = port->rxq[q].conf.offloads; 11023 printf(" Queue[%2d] :", q); 11024 print_rx_offloads(queue_offloads); 11025 printf("\n"); 11026 } 11027 printf("\n"); 11028 } 11029 11030 static cmdline_parse_inst_t cmd_rx_offload_get_configuration = { 11031 .f = cmd_rx_offload_get_configuration_parsed, 11032 .data = NULL, 11033 .help_str = "show port <port_id> rx_offload configuration", 11034 .tokens = { 11035 (void *)&cmd_rx_offload_get_configuration_show, 11036 (void *)&cmd_rx_offload_get_configuration_port, 11037 (void *)&cmd_rx_offload_get_configuration_port_id, 11038 (void *)&cmd_rx_offload_get_configuration_rx_offload, 11039 (void *)&cmd_rx_offload_get_configuration_configuration, 11040 NULL, 11041 } 11042 }; 11043 11044 /* Enable/Disable a per port offloading */ 11045 struct cmd_config_per_port_rx_offload_result { 11046 cmdline_fixed_string_t port; 11047 cmdline_fixed_string_t config; 11048 portid_t port_id; 11049 cmdline_fixed_string_t rx_offload; 11050 cmdline_fixed_string_t offload; 11051 cmdline_fixed_string_t on_off; 11052 }; 11053 11054 static cmdline_parse_token_string_t cmd_config_per_port_rx_offload_result_port = 11055 TOKEN_STRING_INITIALIZER 11056 (struct cmd_config_per_port_rx_offload_result, 11057 port, "port"); 11058 static cmdline_parse_token_string_t cmd_config_per_port_rx_offload_result_config = 11059 TOKEN_STRING_INITIALIZER 11060 (struct cmd_config_per_port_rx_offload_result, 11061 config, "config"); 11062 static cmdline_parse_token_num_t cmd_config_per_port_rx_offload_result_port_id = 11063 TOKEN_NUM_INITIALIZER 11064 (struct cmd_config_per_port_rx_offload_result, 11065 port_id, RTE_UINT16); 11066 static cmdline_parse_token_string_t cmd_config_per_port_rx_offload_result_rx_offload = 11067 TOKEN_STRING_INITIALIZER 11068 (struct cmd_config_per_port_rx_offload_result, 11069 rx_offload, "rx_offload"); 11070 static cmdline_parse_token_string_t cmd_config_per_port_rx_offload_result_offload = 11071 TOKEN_STRING_INITIALIZER 11072 (struct cmd_config_per_port_rx_offload_result, 11073 offload, "vlan_strip#ipv4_cksum#udp_cksum#tcp_cksum#tcp_lro#" 11074 "qinq_strip#outer_ipv4_cksum#macsec_strip#" 11075 "vlan_filter#vlan_extend#" 11076 "scatter#buffer_split#timestamp#security#" 11077 "keep_crc#rss_hash"); 11078 static cmdline_parse_token_string_t cmd_config_per_port_rx_offload_result_on_off = 11079 TOKEN_STRING_INITIALIZER 11080 (struct cmd_config_per_port_rx_offload_result, 11081 on_off, "on#off"); 11082 11083 static uint64_t 11084 search_rx_offload(const char *name) 11085 { 11086 uint64_t single_offload; 11087 const char *single_name; 11088 int found = 0; 11089 unsigned int bit; 11090 11091 single_offload = 1; 11092 for (bit = 0; bit < sizeof(single_offload) * CHAR_BIT; bit++) { 11093 single_name = rte_eth_dev_rx_offload_name(single_offload); 11094 if (!strcasecmp(single_name, name)) { 11095 found = 1; 11096 break; 11097 } 11098 single_offload <<= 1; 11099 } 11100 11101 if (found) 11102 return single_offload; 11103 11104 return 0; 11105 } 11106 11107 static void 11108 cmd_config_per_port_rx_offload_parsed(void *parsed_result, 11109 __rte_unused struct cmdline *cl, 11110 __rte_unused void *data) 11111 { 11112 struct cmd_config_per_port_rx_offload_result *res = parsed_result; 11113 portid_t port_id = res->port_id; 11114 struct rte_eth_dev_info dev_info; 11115 struct rte_port *port = &ports[port_id]; 11116 uint64_t single_offload; 11117 uint16_t nb_rx_queues; 11118 int q; 11119 int ret; 11120 11121 if (port->port_status != RTE_PORT_STOPPED) { 11122 fprintf(stderr, 11123 "Error: Can't config offload when Port %d is not stopped\n", 11124 port_id); 11125 return; 11126 } 11127 11128 single_offload = search_rx_offload(res->offload); 11129 if (single_offload == 0) { 11130 fprintf(stderr, "Unknown offload name: %s\n", res->offload); 11131 return; 11132 } 11133 11134 ret = eth_dev_info_get_print_err(port_id, &dev_info); 11135 if (ret != 0) 11136 return; 11137 11138 nb_rx_queues = dev_info.nb_rx_queues; 11139 if (!strcmp(res->on_off, "on")) { 11140 port->dev_conf.rxmode.offloads |= single_offload; 11141 for (q = 0; q < nb_rx_queues; q++) 11142 port->rxq[q].conf.offloads |= single_offload; 11143 } else { 11144 port->dev_conf.rxmode.offloads &= ~single_offload; 11145 for (q = 0; q < nb_rx_queues; q++) 11146 port->rxq[q].conf.offloads &= ~single_offload; 11147 } 11148 11149 cmd_reconfig_device_queue(port_id, 1, 1); 11150 } 11151 11152 static cmdline_parse_inst_t cmd_config_per_port_rx_offload = { 11153 .f = cmd_config_per_port_rx_offload_parsed, 11154 .data = NULL, 11155 .help_str = "port config <port_id> rx_offload vlan_strip|ipv4_cksum|" 11156 "udp_cksum|tcp_cksum|tcp_lro|qinq_strip|outer_ipv4_cksum|" 11157 "macsec_strip|vlan_filter|vlan_extend|" 11158 "scatter|buffer_split|timestamp|security|" 11159 "keep_crc|rss_hash on|off", 11160 .tokens = { 11161 (void *)&cmd_config_per_port_rx_offload_result_port, 11162 (void *)&cmd_config_per_port_rx_offload_result_config, 11163 (void *)&cmd_config_per_port_rx_offload_result_port_id, 11164 (void *)&cmd_config_per_port_rx_offload_result_rx_offload, 11165 (void *)&cmd_config_per_port_rx_offload_result_offload, 11166 (void *)&cmd_config_per_port_rx_offload_result_on_off, 11167 NULL, 11168 } 11169 }; 11170 11171 /* Enable/Disable a per queue offloading */ 11172 struct cmd_config_per_queue_rx_offload_result { 11173 cmdline_fixed_string_t port; 11174 portid_t port_id; 11175 cmdline_fixed_string_t rxq; 11176 uint16_t queue_id; 11177 cmdline_fixed_string_t rx_offload; 11178 cmdline_fixed_string_t offload; 11179 cmdline_fixed_string_t on_off; 11180 }; 11181 11182 static cmdline_parse_token_string_t cmd_config_per_queue_rx_offload_result_port = 11183 TOKEN_STRING_INITIALIZER 11184 (struct cmd_config_per_queue_rx_offload_result, 11185 port, "port"); 11186 static cmdline_parse_token_num_t cmd_config_per_queue_rx_offload_result_port_id = 11187 TOKEN_NUM_INITIALIZER 11188 (struct cmd_config_per_queue_rx_offload_result, 11189 port_id, RTE_UINT16); 11190 static cmdline_parse_token_string_t cmd_config_per_queue_rx_offload_result_rxq = 11191 TOKEN_STRING_INITIALIZER 11192 (struct cmd_config_per_queue_rx_offload_result, 11193 rxq, "rxq"); 11194 static cmdline_parse_token_num_t cmd_config_per_queue_rx_offload_result_queue_id = 11195 TOKEN_NUM_INITIALIZER 11196 (struct cmd_config_per_queue_rx_offload_result, 11197 queue_id, RTE_UINT16); 11198 static cmdline_parse_token_string_t cmd_config_per_queue_rx_offload_result_rxoffload = 11199 TOKEN_STRING_INITIALIZER 11200 (struct cmd_config_per_queue_rx_offload_result, 11201 rx_offload, "rx_offload"); 11202 static cmdline_parse_token_string_t cmd_config_per_queue_rx_offload_result_offload = 11203 TOKEN_STRING_INITIALIZER 11204 (struct cmd_config_per_queue_rx_offload_result, 11205 offload, "vlan_strip#ipv4_cksum#udp_cksum#tcp_cksum#tcp_lro#" 11206 "qinq_strip#outer_ipv4_cksum#macsec_strip#" 11207 "vlan_filter#vlan_extend#" 11208 "scatter#buffer_split#timestamp#security#keep_crc"); 11209 static cmdline_parse_token_string_t cmd_config_per_queue_rx_offload_result_on_off = 11210 TOKEN_STRING_INITIALIZER 11211 (struct cmd_config_per_queue_rx_offload_result, 11212 on_off, "on#off"); 11213 11214 static void 11215 cmd_config_per_queue_rx_offload_parsed(void *parsed_result, 11216 __rte_unused struct cmdline *cl, 11217 __rte_unused void *data) 11218 { 11219 struct cmd_config_per_queue_rx_offload_result *res = parsed_result; 11220 struct rte_eth_dev_info dev_info; 11221 portid_t port_id = res->port_id; 11222 uint16_t queue_id = res->queue_id; 11223 struct rte_port *port = &ports[port_id]; 11224 uint64_t single_offload; 11225 int ret; 11226 11227 if (port->port_status != RTE_PORT_STOPPED) { 11228 fprintf(stderr, 11229 "Error: Can't config offload when Port %d is not stopped\n", 11230 port_id); 11231 return; 11232 } 11233 11234 ret = eth_dev_info_get_print_err(port_id, &dev_info); 11235 if (ret != 0) 11236 return; 11237 11238 if (queue_id >= dev_info.nb_rx_queues) { 11239 fprintf(stderr, 11240 "Error: input queue_id should be 0 ... %d\n", 11241 dev_info.nb_rx_queues - 1); 11242 return; 11243 } 11244 11245 single_offload = search_rx_offload(res->offload); 11246 if (single_offload == 0) { 11247 fprintf(stderr, "Unknown offload name: %s\n", res->offload); 11248 return; 11249 } 11250 11251 if (!strcmp(res->on_off, "on")) 11252 port->rxq[queue_id].conf.offloads |= single_offload; 11253 else 11254 port->rxq[queue_id].conf.offloads &= ~single_offload; 11255 11256 cmd_reconfig_device_queue(port_id, 1, 1); 11257 } 11258 11259 static cmdline_parse_inst_t cmd_config_per_queue_rx_offload = { 11260 .f = cmd_config_per_queue_rx_offload_parsed, 11261 .data = NULL, 11262 .help_str = "port <port_id> rxq <queue_id> rx_offload " 11263 "vlan_strip|ipv4_cksum|" 11264 "udp_cksum|tcp_cksum|tcp_lro|qinq_strip|outer_ipv4_cksum|" 11265 "macsec_strip|vlan_filter|vlan_extend|" 11266 "scatter|buffer_split|timestamp|security|" 11267 "keep_crc on|off", 11268 .tokens = { 11269 (void *)&cmd_config_per_queue_rx_offload_result_port, 11270 (void *)&cmd_config_per_queue_rx_offload_result_port_id, 11271 (void *)&cmd_config_per_queue_rx_offload_result_rxq, 11272 (void *)&cmd_config_per_queue_rx_offload_result_queue_id, 11273 (void *)&cmd_config_per_queue_rx_offload_result_rxoffload, 11274 (void *)&cmd_config_per_queue_rx_offload_result_offload, 11275 (void *)&cmd_config_per_queue_rx_offload_result_on_off, 11276 NULL, 11277 } 11278 }; 11279 11280 /* Get Tx offloads capabilities */ 11281 struct cmd_tx_offload_get_capa_result { 11282 cmdline_fixed_string_t show; 11283 cmdline_fixed_string_t port; 11284 portid_t port_id; 11285 cmdline_fixed_string_t tx_offload; 11286 cmdline_fixed_string_t capabilities; 11287 }; 11288 11289 static cmdline_parse_token_string_t cmd_tx_offload_get_capa_show = 11290 TOKEN_STRING_INITIALIZER 11291 (struct cmd_tx_offload_get_capa_result, 11292 show, "show"); 11293 static cmdline_parse_token_string_t cmd_tx_offload_get_capa_port = 11294 TOKEN_STRING_INITIALIZER 11295 (struct cmd_tx_offload_get_capa_result, 11296 port, "port"); 11297 static cmdline_parse_token_num_t cmd_tx_offload_get_capa_port_id = 11298 TOKEN_NUM_INITIALIZER 11299 (struct cmd_tx_offload_get_capa_result, 11300 port_id, RTE_UINT16); 11301 static cmdline_parse_token_string_t cmd_tx_offload_get_capa_tx_offload = 11302 TOKEN_STRING_INITIALIZER 11303 (struct cmd_tx_offload_get_capa_result, 11304 tx_offload, "tx_offload"); 11305 static cmdline_parse_token_string_t cmd_tx_offload_get_capa_capabilities = 11306 TOKEN_STRING_INITIALIZER 11307 (struct cmd_tx_offload_get_capa_result, 11308 capabilities, "capabilities"); 11309 11310 static void 11311 print_tx_offloads(uint64_t offloads) 11312 { 11313 uint64_t single_offload; 11314 int begin; 11315 int end; 11316 int bit; 11317 11318 if (offloads == 0) 11319 return; 11320 11321 begin = rte_ctz64(offloads); 11322 end = sizeof(offloads) * CHAR_BIT - rte_clz64(offloads); 11323 11324 single_offload = 1ULL << begin; 11325 for (bit = begin; bit < end; bit++) { 11326 if (offloads & single_offload) 11327 printf(" %s", 11328 rte_eth_dev_tx_offload_name(single_offload)); 11329 single_offload <<= 1; 11330 } 11331 } 11332 11333 static void 11334 cmd_tx_offload_get_capa_parsed( 11335 void *parsed_result, 11336 __rte_unused struct cmdline *cl, 11337 __rte_unused void *data) 11338 { 11339 struct cmd_tx_offload_get_capa_result *res = parsed_result; 11340 struct rte_eth_dev_info dev_info; 11341 portid_t port_id = res->port_id; 11342 uint64_t queue_offloads; 11343 uint64_t port_offloads; 11344 int ret; 11345 11346 ret = eth_dev_info_get_print_err(port_id, &dev_info); 11347 if (ret != 0) 11348 return; 11349 11350 queue_offloads = dev_info.tx_queue_offload_capa; 11351 port_offloads = dev_info.tx_offload_capa ^ queue_offloads; 11352 11353 printf("Tx Offloading Capabilities of port %d :\n", port_id); 11354 printf(" Per Queue :"); 11355 print_tx_offloads(queue_offloads); 11356 11357 printf("\n"); 11358 printf(" Per Port :"); 11359 print_tx_offloads(port_offloads); 11360 printf("\n\n"); 11361 } 11362 11363 static cmdline_parse_inst_t cmd_tx_offload_get_capa = { 11364 .f = cmd_tx_offload_get_capa_parsed, 11365 .data = NULL, 11366 .help_str = "show port <port_id> tx_offload capabilities", 11367 .tokens = { 11368 (void *)&cmd_tx_offload_get_capa_show, 11369 (void *)&cmd_tx_offload_get_capa_port, 11370 (void *)&cmd_tx_offload_get_capa_port_id, 11371 (void *)&cmd_tx_offload_get_capa_tx_offload, 11372 (void *)&cmd_tx_offload_get_capa_capabilities, 11373 NULL, 11374 } 11375 }; 11376 11377 /* Get Tx offloads configuration */ 11378 struct cmd_tx_offload_get_configuration_result { 11379 cmdline_fixed_string_t show; 11380 cmdline_fixed_string_t port; 11381 portid_t port_id; 11382 cmdline_fixed_string_t tx_offload; 11383 cmdline_fixed_string_t configuration; 11384 }; 11385 11386 static cmdline_parse_token_string_t cmd_tx_offload_get_configuration_show = 11387 TOKEN_STRING_INITIALIZER 11388 (struct cmd_tx_offload_get_configuration_result, 11389 show, "show"); 11390 static cmdline_parse_token_string_t cmd_tx_offload_get_configuration_port = 11391 TOKEN_STRING_INITIALIZER 11392 (struct cmd_tx_offload_get_configuration_result, 11393 port, "port"); 11394 static cmdline_parse_token_num_t cmd_tx_offload_get_configuration_port_id = 11395 TOKEN_NUM_INITIALIZER 11396 (struct cmd_tx_offload_get_configuration_result, 11397 port_id, RTE_UINT16); 11398 static cmdline_parse_token_string_t cmd_tx_offload_get_configuration_tx_offload = 11399 TOKEN_STRING_INITIALIZER 11400 (struct cmd_tx_offload_get_configuration_result, 11401 tx_offload, "tx_offload"); 11402 static cmdline_parse_token_string_t cmd_tx_offload_get_configuration_configuration = 11403 TOKEN_STRING_INITIALIZER 11404 (struct cmd_tx_offload_get_configuration_result, 11405 configuration, "configuration"); 11406 11407 static void 11408 cmd_tx_offload_get_configuration_parsed( 11409 void *parsed_result, 11410 __rte_unused struct cmdline *cl, 11411 __rte_unused void *data) 11412 { 11413 struct cmd_tx_offload_get_configuration_result *res = parsed_result; 11414 struct rte_eth_dev_info dev_info; 11415 portid_t port_id = res->port_id; 11416 struct rte_port *port = &ports[port_id]; 11417 struct rte_eth_conf dev_conf; 11418 uint64_t port_offloads; 11419 uint64_t queue_offloads; 11420 uint16_t nb_tx_queues; 11421 int q; 11422 int ret; 11423 11424 printf("Tx Offloading Configuration of port %d :\n", port_id); 11425 11426 ret = eth_dev_conf_get_print_err(port_id, &dev_conf); 11427 if (ret != 0) 11428 return; 11429 11430 port_offloads = dev_conf.txmode.offloads; 11431 printf(" Port :"); 11432 print_tx_offloads(port_offloads); 11433 printf("\n"); 11434 11435 ret = eth_dev_info_get_print_err(port_id, &dev_info); 11436 if (ret != 0) 11437 return; 11438 11439 nb_tx_queues = dev_info.nb_tx_queues; 11440 for (q = 0; q < nb_tx_queues; q++) { 11441 queue_offloads = port->txq[q].conf.offloads; 11442 printf(" Queue[%2d] :", q); 11443 print_tx_offloads(queue_offloads); 11444 printf("\n"); 11445 } 11446 printf("\n"); 11447 } 11448 11449 static cmdline_parse_inst_t cmd_tx_offload_get_configuration = { 11450 .f = cmd_tx_offload_get_configuration_parsed, 11451 .data = NULL, 11452 .help_str = "show port <port_id> tx_offload configuration", 11453 .tokens = { 11454 (void *)&cmd_tx_offload_get_configuration_show, 11455 (void *)&cmd_tx_offload_get_configuration_port, 11456 (void *)&cmd_tx_offload_get_configuration_port_id, 11457 (void *)&cmd_tx_offload_get_configuration_tx_offload, 11458 (void *)&cmd_tx_offload_get_configuration_configuration, 11459 NULL, 11460 } 11461 }; 11462 11463 /* Enable/Disable a per port offloading */ 11464 struct cmd_config_per_port_tx_offload_result { 11465 cmdline_fixed_string_t port; 11466 cmdline_fixed_string_t config; 11467 portid_t port_id; 11468 cmdline_fixed_string_t tx_offload; 11469 cmdline_fixed_string_t offload; 11470 cmdline_fixed_string_t on_off; 11471 }; 11472 11473 static cmdline_parse_token_string_t cmd_config_per_port_tx_offload_result_port = 11474 TOKEN_STRING_INITIALIZER 11475 (struct cmd_config_per_port_tx_offload_result, 11476 port, "port"); 11477 static cmdline_parse_token_string_t cmd_config_per_port_tx_offload_result_config = 11478 TOKEN_STRING_INITIALIZER 11479 (struct cmd_config_per_port_tx_offload_result, 11480 config, "config"); 11481 static cmdline_parse_token_num_t cmd_config_per_port_tx_offload_result_port_id = 11482 TOKEN_NUM_INITIALIZER 11483 (struct cmd_config_per_port_tx_offload_result, 11484 port_id, RTE_UINT16); 11485 static cmdline_parse_token_string_t cmd_config_per_port_tx_offload_result_tx_offload = 11486 TOKEN_STRING_INITIALIZER 11487 (struct cmd_config_per_port_tx_offload_result, 11488 tx_offload, "tx_offload"); 11489 static cmdline_parse_token_string_t cmd_config_per_port_tx_offload_result_offload = 11490 TOKEN_STRING_INITIALIZER 11491 (struct cmd_config_per_port_tx_offload_result, 11492 offload, "vlan_insert#ipv4_cksum#udp_cksum#tcp_cksum#" 11493 "sctp_cksum#tcp_tso#udp_tso#outer_ipv4_cksum#" 11494 "qinq_insert#vxlan_tnl_tso#gre_tnl_tso#" 11495 "ipip_tnl_tso#geneve_tnl_tso#macsec_insert#" 11496 "mt_lockfree#multi_segs#mbuf_fast_free#security#" 11497 "send_on_timestamp"); 11498 static cmdline_parse_token_string_t cmd_config_per_port_tx_offload_result_on_off = 11499 TOKEN_STRING_INITIALIZER 11500 (struct cmd_config_per_port_tx_offload_result, 11501 on_off, "on#off"); 11502 11503 static uint64_t 11504 search_tx_offload(const char *name) 11505 { 11506 uint64_t single_offload; 11507 const char *single_name; 11508 int found = 0; 11509 unsigned int bit; 11510 11511 single_offload = 1; 11512 for (bit = 0; bit < sizeof(single_offload) * CHAR_BIT; bit++) { 11513 single_name = rte_eth_dev_tx_offload_name(single_offload); 11514 if (single_name == NULL) 11515 break; 11516 if (!strcasecmp(single_name, name)) { 11517 found = 1; 11518 break; 11519 } else if (!strcasecmp(single_name, "UNKNOWN")) 11520 break; 11521 single_offload <<= 1; 11522 } 11523 11524 if (found) 11525 return single_offload; 11526 11527 return 0; 11528 } 11529 11530 static void 11531 cmd_config_per_port_tx_offload_parsed(void *parsed_result, 11532 __rte_unused struct cmdline *cl, 11533 __rte_unused void *data) 11534 { 11535 struct cmd_config_per_port_tx_offload_result *res = parsed_result; 11536 portid_t port_id = res->port_id; 11537 struct rte_eth_dev_info dev_info; 11538 struct rte_port *port = &ports[port_id]; 11539 uint64_t single_offload; 11540 uint16_t nb_tx_queues; 11541 int q; 11542 int ret; 11543 11544 if (port->port_status != RTE_PORT_STOPPED) { 11545 fprintf(stderr, 11546 "Error: Can't config offload when Port %d is not stopped\n", 11547 port_id); 11548 return; 11549 } 11550 11551 single_offload = search_tx_offload(res->offload); 11552 if (single_offload == 0) { 11553 fprintf(stderr, "Unknown offload name: %s\n", res->offload); 11554 return; 11555 } 11556 11557 ret = eth_dev_info_get_print_err(port_id, &dev_info); 11558 if (ret != 0) 11559 return; 11560 11561 nb_tx_queues = dev_info.nb_tx_queues; 11562 if (!strcmp(res->on_off, "on")) { 11563 port->dev_conf.txmode.offloads |= single_offload; 11564 for (q = 0; q < nb_tx_queues; q++) 11565 port->txq[q].conf.offloads |= single_offload; 11566 } else { 11567 port->dev_conf.txmode.offloads &= ~single_offload; 11568 for (q = 0; q < nb_tx_queues; q++) 11569 port->txq[q].conf.offloads &= ~single_offload; 11570 } 11571 11572 cmd_reconfig_device_queue(port_id, 1, 1); 11573 } 11574 11575 static cmdline_parse_inst_t cmd_config_per_port_tx_offload = { 11576 .f = cmd_config_per_port_tx_offload_parsed, 11577 .data = NULL, 11578 .help_str = "port config <port_id> tx_offload " 11579 "vlan_insert|ipv4_cksum|udp_cksum|tcp_cksum|" 11580 "sctp_cksum|tcp_tso|udp_tso|outer_ipv4_cksum|" 11581 "qinq_insert|vxlan_tnl_tso|gre_tnl_tso|" 11582 "ipip_tnl_tso|geneve_tnl_tso|macsec_insert|" 11583 "mt_lockfree|multi_segs|mbuf_fast_free|security|" 11584 "send_on_timestamp on|off", 11585 .tokens = { 11586 (void *)&cmd_config_per_port_tx_offload_result_port, 11587 (void *)&cmd_config_per_port_tx_offload_result_config, 11588 (void *)&cmd_config_per_port_tx_offload_result_port_id, 11589 (void *)&cmd_config_per_port_tx_offload_result_tx_offload, 11590 (void *)&cmd_config_per_port_tx_offload_result_offload, 11591 (void *)&cmd_config_per_port_tx_offload_result_on_off, 11592 NULL, 11593 } 11594 }; 11595 11596 /* Enable/Disable a per queue offloading */ 11597 struct cmd_config_per_queue_tx_offload_result { 11598 cmdline_fixed_string_t port; 11599 portid_t port_id; 11600 cmdline_fixed_string_t txq; 11601 uint16_t queue_id; 11602 cmdline_fixed_string_t tx_offload; 11603 cmdline_fixed_string_t offload; 11604 cmdline_fixed_string_t on_off; 11605 }; 11606 11607 static cmdline_parse_token_string_t cmd_config_per_queue_tx_offload_result_port = 11608 TOKEN_STRING_INITIALIZER 11609 (struct cmd_config_per_queue_tx_offload_result, 11610 port, "port"); 11611 static cmdline_parse_token_num_t cmd_config_per_queue_tx_offload_result_port_id = 11612 TOKEN_NUM_INITIALIZER 11613 (struct cmd_config_per_queue_tx_offload_result, 11614 port_id, RTE_UINT16); 11615 static cmdline_parse_token_string_t cmd_config_per_queue_tx_offload_result_txq = 11616 TOKEN_STRING_INITIALIZER 11617 (struct cmd_config_per_queue_tx_offload_result, 11618 txq, "txq"); 11619 static cmdline_parse_token_num_t cmd_config_per_queue_tx_offload_result_queue_id = 11620 TOKEN_NUM_INITIALIZER 11621 (struct cmd_config_per_queue_tx_offload_result, 11622 queue_id, RTE_UINT16); 11623 static cmdline_parse_token_string_t cmd_config_per_queue_tx_offload_result_txoffload = 11624 TOKEN_STRING_INITIALIZER 11625 (struct cmd_config_per_queue_tx_offload_result, 11626 tx_offload, "tx_offload"); 11627 static cmdline_parse_token_string_t cmd_config_per_queue_tx_offload_result_offload = 11628 TOKEN_STRING_INITIALIZER 11629 (struct cmd_config_per_queue_tx_offload_result, 11630 offload, "vlan_insert#ipv4_cksum#udp_cksum#tcp_cksum#" 11631 "sctp_cksum#tcp_tso#udp_tso#outer_ipv4_cksum#" 11632 "qinq_insert#vxlan_tnl_tso#gre_tnl_tso#" 11633 "ipip_tnl_tso#geneve_tnl_tso#macsec_insert#" 11634 "mt_lockfree#multi_segs#mbuf_fast_free#security"); 11635 static cmdline_parse_token_string_t cmd_config_per_queue_tx_offload_result_on_off = 11636 TOKEN_STRING_INITIALIZER 11637 (struct cmd_config_per_queue_tx_offload_result, 11638 on_off, "on#off"); 11639 11640 static void 11641 cmd_config_per_queue_tx_offload_parsed(void *parsed_result, 11642 __rte_unused struct cmdline *cl, 11643 __rte_unused void *data) 11644 { 11645 struct cmd_config_per_queue_tx_offload_result *res = parsed_result; 11646 struct rte_eth_dev_info dev_info; 11647 portid_t port_id = res->port_id; 11648 uint16_t queue_id = res->queue_id; 11649 struct rte_port *port = &ports[port_id]; 11650 uint64_t single_offload; 11651 int ret; 11652 11653 if (port->port_status != RTE_PORT_STOPPED) { 11654 fprintf(stderr, 11655 "Error: Can't config offload when Port %d is not stopped\n", 11656 port_id); 11657 return; 11658 } 11659 11660 ret = eth_dev_info_get_print_err(port_id, &dev_info); 11661 if (ret != 0) 11662 return; 11663 11664 if (queue_id >= dev_info.nb_tx_queues) { 11665 fprintf(stderr, 11666 "Error: input queue_id should be 0 ... %d\n", 11667 dev_info.nb_tx_queues - 1); 11668 return; 11669 } 11670 11671 single_offload = search_tx_offload(res->offload); 11672 if (single_offload == 0) { 11673 fprintf(stderr, "Unknown offload name: %s\n", res->offload); 11674 return; 11675 } 11676 11677 if (!strcmp(res->on_off, "on")) 11678 port->txq[queue_id].conf.offloads |= single_offload; 11679 else 11680 port->txq[queue_id].conf.offloads &= ~single_offload; 11681 11682 cmd_reconfig_device_queue(port_id, 1, 1); 11683 } 11684 11685 static cmdline_parse_inst_t cmd_config_per_queue_tx_offload = { 11686 .f = cmd_config_per_queue_tx_offload_parsed, 11687 .data = NULL, 11688 .help_str = "port <port_id> txq <queue_id> tx_offload " 11689 "vlan_insert|ipv4_cksum|udp_cksum|tcp_cksum|" 11690 "sctp_cksum|tcp_tso|udp_tso|outer_ipv4_cksum|" 11691 "qinq_insert|vxlan_tnl_tso|gre_tnl_tso|" 11692 "ipip_tnl_tso|geneve_tnl_tso|macsec_insert|" 11693 "mt_lockfree|multi_segs|mbuf_fast_free|security " 11694 "on|off", 11695 .tokens = { 11696 (void *)&cmd_config_per_queue_tx_offload_result_port, 11697 (void *)&cmd_config_per_queue_tx_offload_result_port_id, 11698 (void *)&cmd_config_per_queue_tx_offload_result_txq, 11699 (void *)&cmd_config_per_queue_tx_offload_result_queue_id, 11700 (void *)&cmd_config_per_queue_tx_offload_result_txoffload, 11701 (void *)&cmd_config_per_queue_tx_offload_result_offload, 11702 (void *)&cmd_config_per_queue_tx_offload_result_on_off, 11703 NULL, 11704 } 11705 }; 11706 11707 /* *** configure tx_metadata for specific port *** */ 11708 struct cmd_config_tx_metadata_specific_result { 11709 cmdline_fixed_string_t port; 11710 cmdline_fixed_string_t keyword; 11711 uint16_t port_id; 11712 cmdline_fixed_string_t item; 11713 uint32_t value; 11714 }; 11715 11716 static void 11717 cmd_config_tx_metadata_specific_parsed(void *parsed_result, 11718 __rte_unused struct cmdline *cl, 11719 __rte_unused void *data) 11720 { 11721 struct cmd_config_tx_metadata_specific_result *res = parsed_result; 11722 11723 if (port_id_is_invalid(res->port_id, ENABLED_WARN)) 11724 return; 11725 ports[res->port_id].tx_metadata = res->value; 11726 /* Add/remove callback to insert valid metadata in every Tx packet. */ 11727 if (ports[res->port_id].tx_metadata) 11728 add_tx_md_callback(res->port_id); 11729 else 11730 remove_tx_md_callback(res->port_id); 11731 rte_flow_dynf_metadata_register(); 11732 } 11733 11734 static cmdline_parse_token_string_t cmd_config_tx_metadata_specific_port = 11735 TOKEN_STRING_INITIALIZER(struct cmd_config_tx_metadata_specific_result, 11736 port, "port"); 11737 static cmdline_parse_token_string_t cmd_config_tx_metadata_specific_keyword = 11738 TOKEN_STRING_INITIALIZER(struct cmd_config_tx_metadata_specific_result, 11739 keyword, "config"); 11740 static cmdline_parse_token_num_t cmd_config_tx_metadata_specific_id = 11741 TOKEN_NUM_INITIALIZER(struct cmd_config_tx_metadata_specific_result, 11742 port_id, RTE_UINT16); 11743 static cmdline_parse_token_string_t cmd_config_tx_metadata_specific_item = 11744 TOKEN_STRING_INITIALIZER(struct cmd_config_tx_metadata_specific_result, 11745 item, "tx_metadata"); 11746 static cmdline_parse_token_num_t cmd_config_tx_metadata_specific_value = 11747 TOKEN_NUM_INITIALIZER(struct cmd_config_tx_metadata_specific_result, 11748 value, RTE_UINT32); 11749 11750 static cmdline_parse_inst_t cmd_config_tx_metadata_specific = { 11751 .f = cmd_config_tx_metadata_specific_parsed, 11752 .data = NULL, 11753 .help_str = "port config <port_id> tx_metadata <value>", 11754 .tokens = { 11755 (void *)&cmd_config_tx_metadata_specific_port, 11756 (void *)&cmd_config_tx_metadata_specific_keyword, 11757 (void *)&cmd_config_tx_metadata_specific_id, 11758 (void *)&cmd_config_tx_metadata_specific_item, 11759 (void *)&cmd_config_tx_metadata_specific_value, 11760 NULL, 11761 }, 11762 }; 11763 11764 /* *** set dynf *** */ 11765 struct cmd_config_tx_dynf_specific_result { 11766 cmdline_fixed_string_t port; 11767 cmdline_fixed_string_t keyword; 11768 uint16_t port_id; 11769 cmdline_fixed_string_t item; 11770 cmdline_fixed_string_t name; 11771 cmdline_fixed_string_t value; 11772 }; 11773 11774 static void 11775 cmd_config_dynf_specific_parsed(void *parsed_result, 11776 __rte_unused struct cmdline *cl, 11777 __rte_unused void *data) 11778 { 11779 struct cmd_config_tx_dynf_specific_result *res = parsed_result; 11780 struct rte_mbuf_dynflag desc_flag; 11781 int flag; 11782 uint64_t old_port_flags; 11783 11784 if (port_id_is_invalid(res->port_id, ENABLED_WARN)) 11785 return; 11786 flag = rte_mbuf_dynflag_lookup(res->name, NULL); 11787 if (flag <= 0) { 11788 if (strlcpy(desc_flag.name, res->name, 11789 RTE_MBUF_DYN_NAMESIZE) >= RTE_MBUF_DYN_NAMESIZE) { 11790 fprintf(stderr, "Flag name too long\n"); 11791 return; 11792 } 11793 desc_flag.flags = 0; 11794 flag = rte_mbuf_dynflag_register(&desc_flag); 11795 if (flag < 0) { 11796 fprintf(stderr, "Can't register flag\n"); 11797 return; 11798 } 11799 strcpy(dynf_names[flag], desc_flag.name); 11800 } 11801 old_port_flags = ports[res->port_id].mbuf_dynf; 11802 if (!strcmp(res->value, "set")) { 11803 ports[res->port_id].mbuf_dynf |= 1UL << flag; 11804 if (old_port_flags == 0) 11805 add_tx_dynf_callback(res->port_id); 11806 } else { 11807 ports[res->port_id].mbuf_dynf &= ~(1UL << flag); 11808 if (ports[res->port_id].mbuf_dynf == 0) 11809 remove_tx_dynf_callback(res->port_id); 11810 } 11811 } 11812 11813 static cmdline_parse_token_string_t cmd_config_tx_dynf_specific_port = 11814 TOKEN_STRING_INITIALIZER(struct cmd_config_tx_dynf_specific_result, 11815 keyword, "port"); 11816 static cmdline_parse_token_string_t cmd_config_tx_dynf_specific_keyword = 11817 TOKEN_STRING_INITIALIZER(struct cmd_config_tx_dynf_specific_result, 11818 keyword, "config"); 11819 static cmdline_parse_token_num_t cmd_config_tx_dynf_specific_port_id = 11820 TOKEN_NUM_INITIALIZER(struct cmd_config_tx_dynf_specific_result, 11821 port_id, RTE_UINT16); 11822 static cmdline_parse_token_string_t cmd_config_tx_dynf_specific_item = 11823 TOKEN_STRING_INITIALIZER(struct cmd_config_tx_dynf_specific_result, 11824 item, "dynf"); 11825 static cmdline_parse_token_string_t cmd_config_tx_dynf_specific_name = 11826 TOKEN_STRING_INITIALIZER(struct cmd_config_tx_dynf_specific_result, 11827 name, NULL); 11828 static cmdline_parse_token_string_t cmd_config_tx_dynf_specific_value = 11829 TOKEN_STRING_INITIALIZER(struct cmd_config_tx_dynf_specific_result, 11830 value, "set#clear"); 11831 11832 static cmdline_parse_inst_t cmd_config_tx_dynf_specific = { 11833 .f = cmd_config_dynf_specific_parsed, 11834 .data = NULL, 11835 .help_str = "port config <port id> dynf <name> set|clear", 11836 .tokens = { 11837 (void *)&cmd_config_tx_dynf_specific_port, 11838 (void *)&cmd_config_tx_dynf_specific_keyword, 11839 (void *)&cmd_config_tx_dynf_specific_port_id, 11840 (void *)&cmd_config_tx_dynf_specific_item, 11841 (void *)&cmd_config_tx_dynf_specific_name, 11842 (void *)&cmd_config_tx_dynf_specific_value, 11843 NULL, 11844 }, 11845 }; 11846 11847 /* *** display tx_metadata per port configuration *** */ 11848 struct cmd_show_tx_metadata_result { 11849 cmdline_fixed_string_t cmd_show; 11850 cmdline_fixed_string_t cmd_port; 11851 cmdline_fixed_string_t cmd_keyword; 11852 portid_t cmd_pid; 11853 }; 11854 11855 static void 11856 cmd_show_tx_metadata_parsed(void *parsed_result, 11857 __rte_unused struct cmdline *cl, 11858 __rte_unused void *data) 11859 { 11860 struct cmd_show_tx_metadata_result *res = parsed_result; 11861 11862 if (!rte_eth_dev_is_valid_port(res->cmd_pid)) { 11863 fprintf(stderr, "invalid port id %u\n", res->cmd_pid); 11864 return; 11865 } 11866 if (!strcmp(res->cmd_keyword, "tx_metadata")) { 11867 printf("Port %u tx_metadata: %u\n", res->cmd_pid, 11868 ports[res->cmd_pid].tx_metadata); 11869 } 11870 } 11871 11872 static cmdline_parse_token_string_t cmd_show_tx_metadata_show = 11873 TOKEN_STRING_INITIALIZER(struct cmd_show_tx_metadata_result, 11874 cmd_show, "show"); 11875 static cmdline_parse_token_string_t cmd_show_tx_metadata_port = 11876 TOKEN_STRING_INITIALIZER(struct cmd_show_tx_metadata_result, 11877 cmd_port, "port"); 11878 static cmdline_parse_token_num_t cmd_show_tx_metadata_pid = 11879 TOKEN_NUM_INITIALIZER(struct cmd_show_tx_metadata_result, 11880 cmd_pid, RTE_UINT16); 11881 static cmdline_parse_token_string_t cmd_show_tx_metadata_keyword = 11882 TOKEN_STRING_INITIALIZER(struct cmd_show_tx_metadata_result, 11883 cmd_keyword, "tx_metadata"); 11884 11885 static cmdline_parse_inst_t cmd_show_tx_metadata = { 11886 .f = cmd_show_tx_metadata_parsed, 11887 .data = NULL, 11888 .help_str = "show port <port_id> tx_metadata", 11889 .tokens = { 11890 (void *)&cmd_show_tx_metadata_show, 11891 (void *)&cmd_show_tx_metadata_port, 11892 (void *)&cmd_show_tx_metadata_pid, 11893 (void *)&cmd_show_tx_metadata_keyword, 11894 NULL, 11895 }, 11896 }; 11897 11898 /* *** show fec capability per port configuration *** */ 11899 struct cmd_show_fec_capability_result { 11900 cmdline_fixed_string_t cmd_show; 11901 cmdline_fixed_string_t cmd_port; 11902 cmdline_fixed_string_t cmd_fec; 11903 cmdline_fixed_string_t cmd_keyword; 11904 portid_t cmd_pid; 11905 }; 11906 11907 static void 11908 cmd_show_fec_capability_parsed(void *parsed_result, 11909 __rte_unused struct cmdline *cl, 11910 __rte_unused void *data) 11911 { 11912 struct cmd_show_fec_capability_result *res = parsed_result; 11913 struct rte_eth_fec_capa *speed_fec_capa; 11914 unsigned int num; 11915 int ret; 11916 11917 if (!rte_eth_dev_is_valid_port(res->cmd_pid)) { 11918 fprintf(stderr, "Invalid port id %u\n", res->cmd_pid); 11919 return; 11920 } 11921 11922 ret = rte_eth_fec_get_capability(res->cmd_pid, NULL, 0); 11923 if (ret == -ENOTSUP) { 11924 fprintf(stderr, "Function not implemented\n"); 11925 return; 11926 } else if (ret < 0) { 11927 fprintf(stderr, "Get FEC capability failed: %d\n", ret); 11928 return; 11929 } 11930 11931 num = (unsigned int)ret; 11932 speed_fec_capa = calloc(num, sizeof(*speed_fec_capa)); 11933 if (speed_fec_capa == NULL) { 11934 fprintf(stderr, "Failed to alloc FEC capability buffer\n"); 11935 return; 11936 } 11937 11938 ret = rte_eth_fec_get_capability(res->cmd_pid, speed_fec_capa, num); 11939 if (ret < 0) { 11940 fprintf(stderr, "Error getting FEC capability: %d\n", ret); 11941 goto out; 11942 } 11943 11944 show_fec_capability(num, speed_fec_capa); 11945 out: 11946 free(speed_fec_capa); 11947 } 11948 11949 static cmdline_parse_token_string_t cmd_show_fec_capability_show = 11950 TOKEN_STRING_INITIALIZER(struct cmd_show_fec_capability_result, 11951 cmd_show, "show"); 11952 static cmdline_parse_token_string_t cmd_show_fec_capability_port = 11953 TOKEN_STRING_INITIALIZER(struct cmd_show_fec_capability_result, 11954 cmd_port, "port"); 11955 static cmdline_parse_token_num_t cmd_show_fec_capability_pid = 11956 TOKEN_NUM_INITIALIZER(struct cmd_show_fec_capability_result, 11957 cmd_pid, RTE_UINT16); 11958 static cmdline_parse_token_string_t cmd_show_fec_capability_fec = 11959 TOKEN_STRING_INITIALIZER(struct cmd_show_fec_capability_result, 11960 cmd_fec, "fec"); 11961 static cmdline_parse_token_string_t cmd_show_fec_capability_keyword = 11962 TOKEN_STRING_INITIALIZER(struct cmd_show_fec_capability_result, 11963 cmd_keyword, "capabilities"); 11964 11965 static cmdline_parse_inst_t cmd_show_capability = { 11966 .f = cmd_show_fec_capability_parsed, 11967 .data = NULL, 11968 .help_str = "show port <port_id> fec capabilities", 11969 .tokens = { 11970 (void *)&cmd_show_fec_capability_show, 11971 (void *)&cmd_show_fec_capability_port, 11972 (void *)&cmd_show_fec_capability_pid, 11973 (void *)&cmd_show_fec_capability_fec, 11974 (void *)&cmd_show_fec_capability_keyword, 11975 NULL, 11976 }, 11977 }; 11978 11979 /* *** show fec mode per port configuration *** */ 11980 struct cmd_show_fec_metadata_result { 11981 cmdline_fixed_string_t cmd_show; 11982 cmdline_fixed_string_t cmd_port; 11983 cmdline_fixed_string_t cmd_keyword; 11984 portid_t cmd_pid; 11985 }; 11986 11987 static void 11988 cmd_show_fec_mode_parsed(void *parsed_result, 11989 __rte_unused struct cmdline *cl, 11990 __rte_unused void *data) 11991 { 11992 #define FEC_NAME_SIZE 16 11993 struct cmd_show_fec_metadata_result *res = parsed_result; 11994 uint32_t mode; 11995 char buf[FEC_NAME_SIZE]; 11996 int ret; 11997 11998 if (!rte_eth_dev_is_valid_port(res->cmd_pid)) { 11999 fprintf(stderr, "Invalid port id %u\n", res->cmd_pid); 12000 return; 12001 } 12002 ret = rte_eth_fec_get(res->cmd_pid, &mode); 12003 if (ret == -ENOTSUP) { 12004 fprintf(stderr, "Function not implemented\n"); 12005 return; 12006 } else if (ret < 0) { 12007 fprintf(stderr, "Get FEC mode failed\n"); 12008 return; 12009 } 12010 12011 switch (mode) { 12012 case RTE_ETH_FEC_MODE_CAPA_MASK(NOFEC): 12013 strlcpy(buf, "off", sizeof(buf)); 12014 break; 12015 case RTE_ETH_FEC_MODE_CAPA_MASK(AUTO): 12016 strlcpy(buf, "auto", sizeof(buf)); 12017 break; 12018 case RTE_ETH_FEC_MODE_CAPA_MASK(BASER): 12019 strlcpy(buf, "baser", sizeof(buf)); 12020 break; 12021 case RTE_ETH_FEC_MODE_CAPA_MASK(RS): 12022 strlcpy(buf, "rs", sizeof(buf)); 12023 break; 12024 case RTE_ETH_FEC_MODE_CAPA_MASK(LLRS): 12025 strlcpy(buf, "llrs", sizeof(buf)); 12026 break; 12027 default: 12028 return; 12029 } 12030 12031 printf("%s\n", buf); 12032 } 12033 12034 static cmdline_parse_token_string_t cmd_show_fec_mode_show = 12035 TOKEN_STRING_INITIALIZER(struct cmd_show_fec_metadata_result, 12036 cmd_show, "show"); 12037 static cmdline_parse_token_string_t cmd_show_fec_mode_port = 12038 TOKEN_STRING_INITIALIZER(struct cmd_show_fec_metadata_result, 12039 cmd_port, "port"); 12040 static cmdline_parse_token_num_t cmd_show_fec_mode_pid = 12041 TOKEN_NUM_INITIALIZER(struct cmd_show_fec_metadata_result, 12042 cmd_pid, RTE_UINT16); 12043 static cmdline_parse_token_string_t cmd_show_fec_mode_keyword = 12044 TOKEN_STRING_INITIALIZER(struct cmd_show_fec_metadata_result, 12045 cmd_keyword, "fec_mode"); 12046 12047 static cmdline_parse_inst_t cmd_show_fec_mode = { 12048 .f = cmd_show_fec_mode_parsed, 12049 .data = NULL, 12050 .help_str = "show port <port_id> fec_mode", 12051 .tokens = { 12052 (void *)&cmd_show_fec_mode_show, 12053 (void *)&cmd_show_fec_mode_port, 12054 (void *)&cmd_show_fec_mode_pid, 12055 (void *)&cmd_show_fec_mode_keyword, 12056 NULL, 12057 }, 12058 }; 12059 12060 /* *** set fec mode per port configuration *** */ 12061 struct cmd_set_port_fec_mode { 12062 cmdline_fixed_string_t set; 12063 cmdline_fixed_string_t port; 12064 portid_t port_id; 12065 cmdline_fixed_string_t fec_mode; 12066 cmdline_fixed_string_t fec_value; 12067 }; 12068 12069 /* Common CLI fields for set fec mode */ 12070 static cmdline_parse_token_string_t cmd_set_port_fec_mode_set = 12071 TOKEN_STRING_INITIALIZER 12072 (struct cmd_set_port_fec_mode, 12073 set, "set"); 12074 static cmdline_parse_token_string_t cmd_set_port_fec_mode_port = 12075 TOKEN_STRING_INITIALIZER 12076 (struct cmd_set_port_fec_mode, 12077 port, "port"); 12078 static cmdline_parse_token_num_t cmd_set_port_fec_mode_port_id = 12079 TOKEN_NUM_INITIALIZER 12080 (struct cmd_set_port_fec_mode, 12081 port_id, RTE_UINT16); 12082 static cmdline_parse_token_string_t cmd_set_port_fec_mode_str = 12083 TOKEN_STRING_INITIALIZER 12084 (struct cmd_set_port_fec_mode, 12085 fec_mode, "fec_mode"); 12086 static cmdline_parse_token_string_t cmd_set_port_fec_mode_value = 12087 TOKEN_STRING_INITIALIZER 12088 (struct cmd_set_port_fec_mode, 12089 fec_value, NULL); 12090 12091 static void 12092 cmd_set_port_fec_mode_parsed( 12093 void *parsed_result, 12094 __rte_unused struct cmdline *cl, 12095 __rte_unused void *data) 12096 { 12097 struct cmd_set_port_fec_mode *res = parsed_result; 12098 uint16_t port_id = res->port_id; 12099 uint32_t fec_capa; 12100 int ret; 12101 12102 ret = parse_fec_mode(res->fec_value, &fec_capa); 12103 if (ret < 0) { 12104 fprintf(stderr, "Unknown fec mode: %s for port %d\n", 12105 res->fec_value, port_id); 12106 return; 12107 } 12108 12109 ret = rte_eth_fec_set(port_id, fec_capa); 12110 if (ret == -ENOTSUP) { 12111 fprintf(stderr, "Function not implemented\n"); 12112 return; 12113 } else if (ret < 0) { 12114 fprintf(stderr, "Set FEC mode failed\n"); 12115 return; 12116 } 12117 } 12118 12119 static cmdline_parse_inst_t cmd_set_fec_mode = { 12120 .f = cmd_set_port_fec_mode_parsed, 12121 .data = NULL, 12122 .help_str = "set port <port_id> fec_mode auto|off|rs|baser|llrs", 12123 .tokens = { 12124 (void *)&cmd_set_port_fec_mode_set, 12125 (void *)&cmd_set_port_fec_mode_port, 12126 (void *)&cmd_set_port_fec_mode_port_id, 12127 (void *)&cmd_set_port_fec_mode_str, 12128 (void *)&cmd_set_port_fec_mode_value, 12129 NULL, 12130 }, 12131 }; 12132 12133 /* *** set available descriptors threshold for an RxQ of a port *** */ 12134 struct cmd_set_rxq_avail_thresh_result { 12135 cmdline_fixed_string_t set; 12136 cmdline_fixed_string_t port; 12137 uint16_t port_num; 12138 cmdline_fixed_string_t rxq; 12139 uint16_t rxq_num; 12140 cmdline_fixed_string_t avail_thresh; 12141 uint8_t avail_thresh_num; 12142 }; 12143 12144 static void cmd_set_rxq_avail_thresh_parsed(void *parsed_result, 12145 __rte_unused struct cmdline *cl, 12146 __rte_unused void *data) 12147 { 12148 struct cmd_set_rxq_avail_thresh_result *res = parsed_result; 12149 int ret = 0; 12150 12151 if ((strcmp(res->set, "set") == 0) && (strcmp(res->port, "port") == 0) 12152 && (strcmp(res->rxq, "rxq") == 0) 12153 && (strcmp(res->avail_thresh, "avail_thresh") == 0)) 12154 ret = set_rxq_avail_thresh(res->port_num, res->rxq_num, 12155 res->avail_thresh_num); 12156 if (ret < 0) 12157 printf("rxq_avail_thresh_cmd error: (%s)\n", strerror(-ret)); 12158 12159 } 12160 12161 static cmdline_parse_token_string_t cmd_set_rxq_avail_thresh_set = 12162 TOKEN_STRING_INITIALIZER(struct cmd_set_rxq_avail_thresh_result, 12163 set, "set"); 12164 static cmdline_parse_token_string_t cmd_set_rxq_avail_thresh_port = 12165 TOKEN_STRING_INITIALIZER(struct cmd_set_rxq_avail_thresh_result, 12166 port, "port"); 12167 static cmdline_parse_token_num_t cmd_set_rxq_avail_thresh_portnum = 12168 TOKEN_NUM_INITIALIZER(struct cmd_set_rxq_avail_thresh_result, 12169 port_num, RTE_UINT16); 12170 static cmdline_parse_token_string_t cmd_set_rxq_avail_thresh_rxq = 12171 TOKEN_STRING_INITIALIZER(struct cmd_set_rxq_avail_thresh_result, 12172 rxq, "rxq"); 12173 static cmdline_parse_token_num_t cmd_set_rxq_avail_thresh_rxqnum = 12174 TOKEN_NUM_INITIALIZER(struct cmd_set_rxq_avail_thresh_result, 12175 rxq_num, RTE_UINT16); 12176 static cmdline_parse_token_string_t cmd_set_rxq_avail_thresh_avail_thresh = 12177 TOKEN_STRING_INITIALIZER(struct cmd_set_rxq_avail_thresh_result, 12178 avail_thresh, "avail_thresh"); 12179 static cmdline_parse_token_num_t cmd_set_rxq_avail_thresh_avail_threshnum = 12180 TOKEN_NUM_INITIALIZER(struct cmd_set_rxq_avail_thresh_result, 12181 avail_thresh_num, RTE_UINT8); 12182 12183 static cmdline_parse_inst_t cmd_set_rxq_avail_thresh = { 12184 .f = cmd_set_rxq_avail_thresh_parsed, 12185 .data = (void *)0, 12186 .help_str = 12187 "set port <port_id> rxq <queue_id> avail_thresh <0..99>: " 12188 "Set available descriptors threshold for Rx queue", 12189 .tokens = { 12190 (void *)&cmd_set_rxq_avail_thresh_set, 12191 (void *)&cmd_set_rxq_avail_thresh_port, 12192 (void *)&cmd_set_rxq_avail_thresh_portnum, 12193 (void *)&cmd_set_rxq_avail_thresh_rxq, 12194 (void *)&cmd_set_rxq_avail_thresh_rxqnum, 12195 (void *)&cmd_set_rxq_avail_thresh_avail_thresh, 12196 (void *)&cmd_set_rxq_avail_thresh_avail_threshnum, 12197 NULL, 12198 }, 12199 }; 12200 12201 /* show port supported ptypes */ 12202 12203 /* Common result structure for show port ptypes */ 12204 struct cmd_show_port_supported_ptypes_result { 12205 cmdline_fixed_string_t show; 12206 cmdline_fixed_string_t port; 12207 portid_t port_id; 12208 cmdline_fixed_string_t ptypes; 12209 }; 12210 12211 /* Common CLI fields for show port ptypes */ 12212 static cmdline_parse_token_string_t cmd_show_port_supported_ptypes_show = 12213 TOKEN_STRING_INITIALIZER 12214 (struct cmd_show_port_supported_ptypes_result, 12215 show, "show"); 12216 static cmdline_parse_token_string_t cmd_show_port_supported_ptypes_port = 12217 TOKEN_STRING_INITIALIZER 12218 (struct cmd_show_port_supported_ptypes_result, 12219 port, "port"); 12220 static cmdline_parse_token_num_t cmd_show_port_supported_ptypes_port_id = 12221 TOKEN_NUM_INITIALIZER 12222 (struct cmd_show_port_supported_ptypes_result, 12223 port_id, RTE_UINT16); 12224 static cmdline_parse_token_string_t cmd_show_port_supported_ptypes_ptypes = 12225 TOKEN_STRING_INITIALIZER 12226 (struct cmd_show_port_supported_ptypes_result, 12227 ptypes, "ptypes"); 12228 12229 static void 12230 cmd_show_port_supported_ptypes_parsed( 12231 void *parsed_result, 12232 __rte_unused struct cmdline *cl, 12233 __rte_unused void *data) 12234 { 12235 #define RSVD_PTYPE_MASK 0xf0000000 12236 #define MAX_PTYPES_PER_LAYER 16 12237 #define LTYPE_NAMESIZE 32 12238 #define PTYPE_NAMESIZE 256 12239 struct cmd_show_port_supported_ptypes_result *res = parsed_result; 12240 char buf[PTYPE_NAMESIZE], ltype[LTYPE_NAMESIZE]; 12241 uint32_t ptype_mask = RTE_PTYPE_L2_MASK; 12242 uint32_t ptypes[MAX_PTYPES_PER_LAYER]; 12243 uint16_t port_id = res->port_id; 12244 int ret, i; 12245 12246 ret = rte_eth_dev_get_supported_ptypes(port_id, ptype_mask, NULL, 0); 12247 if (ret < 0) 12248 return; 12249 12250 while (ptype_mask != RSVD_PTYPE_MASK) { 12251 12252 switch (ptype_mask) { 12253 case RTE_PTYPE_L2_MASK: 12254 strlcpy(ltype, "L2", sizeof(ltype)); 12255 break; 12256 case RTE_PTYPE_L3_MASK: 12257 strlcpy(ltype, "L3", sizeof(ltype)); 12258 break; 12259 case RTE_PTYPE_L4_MASK: 12260 strlcpy(ltype, "L4", sizeof(ltype)); 12261 break; 12262 case RTE_PTYPE_TUNNEL_MASK: 12263 strlcpy(ltype, "Tunnel", sizeof(ltype)); 12264 break; 12265 case RTE_PTYPE_INNER_L2_MASK: 12266 strlcpy(ltype, "Inner L2", sizeof(ltype)); 12267 break; 12268 case RTE_PTYPE_INNER_L3_MASK: 12269 strlcpy(ltype, "Inner L3", sizeof(ltype)); 12270 break; 12271 case RTE_PTYPE_INNER_L4_MASK: 12272 strlcpy(ltype, "Inner L4", sizeof(ltype)); 12273 break; 12274 default: 12275 return; 12276 } 12277 12278 ret = rte_eth_dev_get_supported_ptypes(res->port_id, 12279 ptype_mask, ptypes, 12280 MAX_PTYPES_PER_LAYER); 12281 12282 if (ret > 0) 12283 printf("Supported %s ptypes:\n", ltype); 12284 else 12285 printf("%s ptypes unsupported\n", ltype); 12286 12287 for (i = 0; i < ret; ++i) { 12288 rte_get_ptype_name(ptypes[i], buf, sizeof(buf)); 12289 printf("%s\n", buf); 12290 } 12291 12292 ptype_mask <<= 4; 12293 } 12294 } 12295 12296 static cmdline_parse_inst_t cmd_show_port_supported_ptypes = { 12297 .f = cmd_show_port_supported_ptypes_parsed, 12298 .data = NULL, 12299 .help_str = "show port <port_id> ptypes", 12300 .tokens = { 12301 (void *)&cmd_show_port_supported_ptypes_show, 12302 (void *)&cmd_show_port_supported_ptypes_port, 12303 (void *)&cmd_show_port_supported_ptypes_port_id, 12304 (void *)&cmd_show_port_supported_ptypes_ptypes, 12305 NULL, 12306 }, 12307 }; 12308 12309 /* *** display rx/tx descriptor status *** */ 12310 struct cmd_show_rx_tx_desc_status_result { 12311 cmdline_fixed_string_t cmd_show; 12312 cmdline_fixed_string_t cmd_port; 12313 cmdline_fixed_string_t cmd_keyword; 12314 cmdline_fixed_string_t cmd_desc; 12315 cmdline_fixed_string_t cmd_status; 12316 portid_t cmd_pid; 12317 portid_t cmd_qid; 12318 portid_t cmd_did; 12319 }; 12320 12321 static void 12322 cmd_show_rx_tx_desc_status_parsed(void *parsed_result, 12323 __rte_unused struct cmdline *cl, 12324 __rte_unused void *data) 12325 { 12326 struct cmd_show_rx_tx_desc_status_result *res = parsed_result; 12327 int rc; 12328 12329 if (!strcmp(res->cmd_keyword, "rxq")) { 12330 if (rte_eth_rx_queue_is_valid(res->cmd_pid, res->cmd_qid) != 0) { 12331 fprintf(stderr, 12332 "Invalid input: port id = %d, queue id = %d\n", 12333 res->cmd_pid, res->cmd_qid); 12334 return; 12335 } 12336 rc = rte_eth_rx_descriptor_status(res->cmd_pid, res->cmd_qid, 12337 res->cmd_did); 12338 if (rc < 0) { 12339 fprintf(stderr, 12340 "Invalid input: queue id = %d, desc id = %d\n", 12341 res->cmd_qid, res->cmd_did); 12342 return; 12343 } 12344 if (rc == RTE_ETH_RX_DESC_AVAIL) 12345 printf("Desc status = AVAILABLE\n"); 12346 else if (rc == RTE_ETH_RX_DESC_DONE) 12347 printf("Desc status = DONE\n"); 12348 else 12349 printf("Desc status = UNAVAILABLE\n"); 12350 } else if (!strcmp(res->cmd_keyword, "txq")) { 12351 if (rte_eth_tx_queue_is_valid(res->cmd_pid, res->cmd_qid) != 0) { 12352 fprintf(stderr, 12353 "Invalid input: port id = %d, queue id = %d\n", 12354 res->cmd_pid, res->cmd_qid); 12355 return; 12356 } 12357 rc = rte_eth_tx_descriptor_status(res->cmd_pid, res->cmd_qid, 12358 res->cmd_did); 12359 if (rc < 0) { 12360 fprintf(stderr, 12361 "Invalid input: queue id = %d, desc id = %d\n", 12362 res->cmd_qid, res->cmd_did); 12363 return; 12364 } 12365 if (rc == RTE_ETH_TX_DESC_FULL) 12366 printf("Desc status = FULL\n"); 12367 else if (rc == RTE_ETH_TX_DESC_DONE) 12368 printf("Desc status = DONE\n"); 12369 else 12370 printf("Desc status = UNAVAILABLE\n"); 12371 } 12372 } 12373 12374 static cmdline_parse_token_string_t cmd_show_rx_tx_desc_status_show = 12375 TOKEN_STRING_INITIALIZER(struct cmd_show_rx_tx_desc_status_result, 12376 cmd_show, "show"); 12377 static cmdline_parse_token_string_t cmd_show_rx_tx_desc_status_port = 12378 TOKEN_STRING_INITIALIZER(struct cmd_show_rx_tx_desc_status_result, 12379 cmd_port, "port"); 12380 static cmdline_parse_token_num_t cmd_show_rx_tx_desc_status_pid = 12381 TOKEN_NUM_INITIALIZER(struct cmd_show_rx_tx_desc_status_result, 12382 cmd_pid, RTE_UINT16); 12383 static cmdline_parse_token_string_t cmd_show_rx_tx_desc_status_keyword = 12384 TOKEN_STRING_INITIALIZER(struct cmd_show_rx_tx_desc_status_result, 12385 cmd_keyword, "rxq#txq"); 12386 static cmdline_parse_token_num_t cmd_show_rx_tx_desc_status_qid = 12387 TOKEN_NUM_INITIALIZER(struct cmd_show_rx_tx_desc_status_result, 12388 cmd_qid, RTE_UINT16); 12389 static cmdline_parse_token_string_t cmd_show_rx_tx_desc_status_desc = 12390 TOKEN_STRING_INITIALIZER(struct cmd_show_rx_tx_desc_status_result, 12391 cmd_desc, "desc"); 12392 static cmdline_parse_token_num_t cmd_show_rx_tx_desc_status_did = 12393 TOKEN_NUM_INITIALIZER(struct cmd_show_rx_tx_desc_status_result, 12394 cmd_did, RTE_UINT16); 12395 static cmdline_parse_token_string_t cmd_show_rx_tx_desc_status_status = 12396 TOKEN_STRING_INITIALIZER(struct cmd_show_rx_tx_desc_status_result, 12397 cmd_status, "status"); 12398 static cmdline_parse_inst_t cmd_show_rx_tx_desc_status = { 12399 .f = cmd_show_rx_tx_desc_status_parsed, 12400 .data = NULL, 12401 .help_str = "show port <port_id> rxq|txq <queue_id> desc <desc_id> " 12402 "status", 12403 .tokens = { 12404 (void *)&cmd_show_rx_tx_desc_status_show, 12405 (void *)&cmd_show_rx_tx_desc_status_port, 12406 (void *)&cmd_show_rx_tx_desc_status_pid, 12407 (void *)&cmd_show_rx_tx_desc_status_keyword, 12408 (void *)&cmd_show_rx_tx_desc_status_qid, 12409 (void *)&cmd_show_rx_tx_desc_status_desc, 12410 (void *)&cmd_show_rx_tx_desc_status_did, 12411 (void *)&cmd_show_rx_tx_desc_status_status, 12412 NULL, 12413 }, 12414 }; 12415 12416 /* *** display rx queue desc used count *** */ 12417 struct cmd_show_rx_queue_desc_used_count_result { 12418 cmdline_fixed_string_t cmd_show; 12419 cmdline_fixed_string_t cmd_port; 12420 cmdline_fixed_string_t cmd_rxq; 12421 cmdline_fixed_string_t cmd_desc; 12422 cmdline_fixed_string_t cmd_used; 12423 cmdline_fixed_string_t cmd_count; 12424 portid_t cmd_pid; 12425 portid_t cmd_qid; 12426 }; 12427 12428 static void 12429 cmd_show_rx_queue_desc_used_count_parsed(void *parsed_result, 12430 __rte_unused struct cmdline *cl, 12431 __rte_unused void *data) 12432 { 12433 struct cmd_show_rx_queue_desc_used_count_result *res = parsed_result; 12434 int rc; 12435 12436 if (rte_eth_rx_queue_is_valid(res->cmd_pid, res->cmd_qid) != 0) { 12437 fprintf(stderr, 12438 "Invalid input: port id = %d, queue id = %d\n", 12439 res->cmd_pid, res->cmd_qid); 12440 return; 12441 } 12442 12443 rc = rte_eth_rx_queue_count(res->cmd_pid, res->cmd_qid); 12444 if (rc < 0) { 12445 fprintf(stderr, "Invalid queueid = %d\n", res->cmd_qid); 12446 return; 12447 } 12448 printf("Used desc count = %d\n", rc); 12449 } 12450 12451 static cmdline_parse_token_string_t cmd_show_rx_queue_desc_used_count_show = 12452 TOKEN_STRING_INITIALIZER 12453 (struct cmd_show_rx_queue_desc_used_count_result, 12454 cmd_show, "show"); 12455 static cmdline_parse_token_string_t cmd_show_rx_queue_desc_used_count_port = 12456 TOKEN_STRING_INITIALIZER 12457 (struct cmd_show_rx_queue_desc_used_count_result, 12458 cmd_port, "port"); 12459 static cmdline_parse_token_num_t cmd_show_rx_queue_desc_used_count_pid = 12460 TOKEN_NUM_INITIALIZER 12461 (struct cmd_show_rx_queue_desc_used_count_result, 12462 cmd_pid, RTE_UINT16); 12463 static cmdline_parse_token_string_t cmd_show_rx_queue_desc_used_count_rxq = 12464 TOKEN_STRING_INITIALIZER 12465 (struct cmd_show_rx_queue_desc_used_count_result, 12466 cmd_rxq, "rxq"); 12467 static cmdline_parse_token_num_t cmd_show_rx_queue_desc_used_count_qid = 12468 TOKEN_NUM_INITIALIZER 12469 (struct cmd_show_rx_queue_desc_used_count_result, 12470 cmd_qid, RTE_UINT16); 12471 static cmdline_parse_token_string_t cmd_show_rx_queue_desc_used_count_desc = 12472 TOKEN_STRING_INITIALIZER 12473 (struct cmd_show_rx_queue_desc_used_count_result, 12474 cmd_count, "desc"); 12475 static cmdline_parse_token_string_t cmd_show_rx_queue_desc_used_count_used = 12476 TOKEN_STRING_INITIALIZER 12477 (struct cmd_show_rx_queue_desc_used_count_result, 12478 cmd_count, "used"); 12479 static cmdline_parse_token_string_t cmd_show_rx_queue_desc_used_count_count = 12480 TOKEN_STRING_INITIALIZER 12481 (struct cmd_show_rx_queue_desc_used_count_result, 12482 cmd_count, "count"); 12483 static cmdline_parse_inst_t cmd_show_rx_queue_desc_used_count = { 12484 .f = cmd_show_rx_queue_desc_used_count_parsed, 12485 .data = NULL, 12486 .help_str = "show port <port_id> rxq <queue_id> desc used count", 12487 .tokens = { 12488 (void *)&cmd_show_rx_queue_desc_used_count_show, 12489 (void *)&cmd_show_rx_queue_desc_used_count_port, 12490 (void *)&cmd_show_rx_queue_desc_used_count_pid, 12491 (void *)&cmd_show_rx_queue_desc_used_count_rxq, 12492 (void *)&cmd_show_rx_queue_desc_used_count_qid, 12493 (void *)&cmd_show_rx_queue_desc_used_count_desc, 12494 (void *)&cmd_show_rx_queue_desc_used_count_used, 12495 (void *)&cmd_show_rx_queue_desc_used_count_count, 12496 NULL, 12497 }, 12498 }; 12499 12500 /* Common result structure for set port ptypes */ 12501 struct cmd_set_port_ptypes_result { 12502 cmdline_fixed_string_t set; 12503 cmdline_fixed_string_t port; 12504 portid_t port_id; 12505 cmdline_fixed_string_t ptype_mask; 12506 uint32_t mask; 12507 }; 12508 12509 /* Common CLI fields for set port ptypes */ 12510 static cmdline_parse_token_string_t cmd_set_port_ptypes_set = 12511 TOKEN_STRING_INITIALIZER 12512 (struct cmd_set_port_ptypes_result, 12513 set, "set"); 12514 static cmdline_parse_token_string_t cmd_set_port_ptypes_port = 12515 TOKEN_STRING_INITIALIZER 12516 (struct cmd_set_port_ptypes_result, 12517 port, "port"); 12518 static cmdline_parse_token_num_t cmd_set_port_ptypes_port_id = 12519 TOKEN_NUM_INITIALIZER 12520 (struct cmd_set_port_ptypes_result, 12521 port_id, RTE_UINT16); 12522 static cmdline_parse_token_string_t cmd_set_port_ptypes_mask_str = 12523 TOKEN_STRING_INITIALIZER 12524 (struct cmd_set_port_ptypes_result, 12525 ptype_mask, "ptype_mask"); 12526 static cmdline_parse_token_num_t cmd_set_port_ptypes_mask_u32 = 12527 TOKEN_NUM_INITIALIZER 12528 (struct cmd_set_port_ptypes_result, 12529 mask, RTE_UINT32); 12530 12531 static void 12532 cmd_set_port_ptypes_parsed( 12533 void *parsed_result, 12534 __rte_unused struct cmdline *cl, 12535 __rte_unused void *data) 12536 { 12537 struct cmd_set_port_ptypes_result *res = parsed_result; 12538 #define PTYPE_NAMESIZE 256 12539 char ptype_name[PTYPE_NAMESIZE]; 12540 uint16_t port_id = res->port_id; 12541 uint32_t ptype_mask = res->mask; 12542 int ret, i; 12543 12544 ret = rte_eth_dev_get_supported_ptypes(port_id, RTE_PTYPE_ALL_MASK, 12545 NULL, 0); 12546 if (ret <= 0) { 12547 fprintf(stderr, "Port %d doesn't support any ptypes.\n", 12548 port_id); 12549 return; 12550 } 12551 12552 uint32_t ptypes[ret]; 12553 12554 ret = rte_eth_dev_set_ptypes(port_id, ptype_mask, ptypes, ret); 12555 if (ret < 0) { 12556 fprintf(stderr, "Unable to set requested ptypes for Port %d\n", 12557 port_id); 12558 return; 12559 } 12560 12561 printf("Successfully set following ptypes for Port %d\n", port_id); 12562 for (i = 0; i < ret && ptypes[i] != RTE_PTYPE_UNKNOWN; i++) { 12563 rte_get_ptype_name(ptypes[i], ptype_name, sizeof(ptype_name)); 12564 printf("%s\n", ptype_name); 12565 } 12566 12567 clear_ptypes = false; 12568 } 12569 12570 static cmdline_parse_inst_t cmd_set_port_ptypes = { 12571 .f = cmd_set_port_ptypes_parsed, 12572 .data = NULL, 12573 .help_str = "set port <port_id> ptype_mask <mask>", 12574 .tokens = { 12575 (void *)&cmd_set_port_ptypes_set, 12576 (void *)&cmd_set_port_ptypes_port, 12577 (void *)&cmd_set_port_ptypes_port_id, 12578 (void *)&cmd_set_port_ptypes_mask_str, 12579 (void *)&cmd_set_port_ptypes_mask_u32, 12580 NULL, 12581 }, 12582 }; 12583 12584 /* *** display mac addresses added to a port *** */ 12585 struct cmd_showport_macs_result { 12586 cmdline_fixed_string_t cmd_show; 12587 cmdline_fixed_string_t cmd_port; 12588 cmdline_fixed_string_t cmd_keyword; 12589 portid_t cmd_pid; 12590 }; 12591 12592 static void 12593 cmd_showport_macs_parsed(void *parsed_result, 12594 __rte_unused struct cmdline *cl, 12595 __rte_unused void *data) 12596 { 12597 struct cmd_showport_macs_result *res = parsed_result; 12598 12599 if (port_id_is_invalid(res->cmd_pid, ENABLED_WARN)) 12600 return; 12601 12602 if (!strcmp(res->cmd_keyword, "macs")) 12603 show_macs(res->cmd_pid); 12604 else if (!strcmp(res->cmd_keyword, "mcast_macs")) 12605 show_mcast_macs(res->cmd_pid); 12606 } 12607 12608 static cmdline_parse_token_string_t cmd_showport_macs_show = 12609 TOKEN_STRING_INITIALIZER(struct cmd_showport_macs_result, 12610 cmd_show, "show"); 12611 static cmdline_parse_token_string_t cmd_showport_macs_port = 12612 TOKEN_STRING_INITIALIZER(struct cmd_showport_macs_result, 12613 cmd_port, "port"); 12614 static cmdline_parse_token_num_t cmd_showport_macs_pid = 12615 TOKEN_NUM_INITIALIZER(struct cmd_showport_macs_result, 12616 cmd_pid, RTE_UINT16); 12617 static cmdline_parse_token_string_t cmd_showport_macs_keyword = 12618 TOKEN_STRING_INITIALIZER(struct cmd_showport_macs_result, 12619 cmd_keyword, "macs#mcast_macs"); 12620 12621 static cmdline_parse_inst_t cmd_showport_macs = { 12622 .f = cmd_showport_macs_parsed, 12623 .data = NULL, 12624 .help_str = "show port <port_id> macs|mcast_macs", 12625 .tokens = { 12626 (void *)&cmd_showport_macs_show, 12627 (void *)&cmd_showport_macs_port, 12628 (void *)&cmd_showport_macs_pid, 12629 (void *)&cmd_showport_macs_keyword, 12630 NULL, 12631 }, 12632 }; 12633 12634 /* *** show flow transfer proxy port ID for the given port *** */ 12635 struct cmd_show_port_flow_transfer_proxy_result { 12636 cmdline_fixed_string_t show; 12637 cmdline_fixed_string_t port; 12638 portid_t port_id; 12639 cmdline_fixed_string_t flow; 12640 cmdline_fixed_string_t transfer; 12641 cmdline_fixed_string_t proxy; 12642 }; 12643 12644 static cmdline_parse_token_string_t cmd_show_port_flow_transfer_proxy_show = 12645 TOKEN_STRING_INITIALIZER 12646 (struct cmd_show_port_flow_transfer_proxy_result, 12647 show, "show"); 12648 static cmdline_parse_token_string_t cmd_show_port_flow_transfer_proxy_port = 12649 TOKEN_STRING_INITIALIZER 12650 (struct cmd_show_port_flow_transfer_proxy_result, 12651 port, "port"); 12652 static cmdline_parse_token_num_t cmd_show_port_flow_transfer_proxy_port_id = 12653 TOKEN_NUM_INITIALIZER 12654 (struct cmd_show_port_flow_transfer_proxy_result, 12655 port_id, RTE_UINT16); 12656 static cmdline_parse_token_string_t cmd_show_port_flow_transfer_proxy_flow = 12657 TOKEN_STRING_INITIALIZER 12658 (struct cmd_show_port_flow_transfer_proxy_result, 12659 flow, "flow"); 12660 static cmdline_parse_token_string_t cmd_show_port_flow_transfer_proxy_transfer = 12661 TOKEN_STRING_INITIALIZER 12662 (struct cmd_show_port_flow_transfer_proxy_result, 12663 transfer, "transfer"); 12664 static cmdline_parse_token_string_t cmd_show_port_flow_transfer_proxy_proxy = 12665 TOKEN_STRING_INITIALIZER 12666 (struct cmd_show_port_flow_transfer_proxy_result, 12667 proxy, "proxy"); 12668 12669 static void 12670 cmd_show_port_flow_transfer_proxy_parsed(void *parsed_result, 12671 __rte_unused struct cmdline *cl, 12672 __rte_unused void *data) 12673 { 12674 struct cmd_show_port_flow_transfer_proxy_result *res = parsed_result; 12675 portid_t proxy_port_id; 12676 int ret; 12677 12678 printf("\n"); 12679 12680 ret = rte_flow_pick_transfer_proxy(res->port_id, &proxy_port_id, NULL); 12681 if (ret != 0) { 12682 fprintf(stderr, "Failed to pick transfer proxy: %s\n", 12683 rte_strerror(-ret)); 12684 return; 12685 } 12686 12687 printf("Transfer proxy port ID: %u\n\n", proxy_port_id); 12688 } 12689 12690 static cmdline_parse_inst_t cmd_show_port_flow_transfer_proxy = { 12691 .f = cmd_show_port_flow_transfer_proxy_parsed, 12692 .data = NULL, 12693 .help_str = "show port <port_id> flow transfer proxy", 12694 .tokens = { 12695 (void *)&cmd_show_port_flow_transfer_proxy_show, 12696 (void *)&cmd_show_port_flow_transfer_proxy_port, 12697 (void *)&cmd_show_port_flow_transfer_proxy_port_id, 12698 (void *)&cmd_show_port_flow_transfer_proxy_flow, 12699 (void *)&cmd_show_port_flow_transfer_proxy_transfer, 12700 (void *)&cmd_show_port_flow_transfer_proxy_proxy, 12701 NULL, 12702 } 12703 }; 12704 12705 /* *** configure port txq affinity value *** */ 12706 struct cmd_config_tx_affinity_map { 12707 cmdline_fixed_string_t port; 12708 cmdline_fixed_string_t config; 12709 portid_t portid; 12710 cmdline_fixed_string_t txq; 12711 uint16_t qid; 12712 cmdline_fixed_string_t affinity; 12713 uint8_t value; 12714 }; 12715 12716 static void 12717 cmd_config_tx_affinity_map_parsed(void *parsed_result, 12718 __rte_unused struct cmdline *cl, 12719 __rte_unused void *data) 12720 { 12721 struct cmd_config_tx_affinity_map *res = parsed_result; 12722 int ret; 12723 12724 if (port_id_is_invalid(res->portid, ENABLED_WARN)) 12725 return; 12726 12727 if (res->portid == (portid_t)RTE_PORT_ALL) { 12728 printf("Invalid port id\n"); 12729 return; 12730 } 12731 12732 if (strcmp(res->txq, "txq")) { 12733 printf("Unknown parameter\n"); 12734 return; 12735 } 12736 if (tx_queue_id_is_invalid(res->qid)) 12737 return; 12738 12739 ret = rte_eth_dev_count_aggr_ports(res->portid); 12740 if (ret < 0) { 12741 printf("Failed to count the aggregated ports: (%s)\n", 12742 strerror(-ret)); 12743 return; 12744 } 12745 12746 ret = rte_eth_dev_map_aggr_tx_affinity(res->portid, res->qid, res->value); 12747 if (ret != 0) { 12748 printf("Failed to map tx queue with an aggregated port: %s\n", 12749 rte_strerror(-ret)); 12750 return; 12751 } 12752 } 12753 12754 cmdline_parse_token_string_t cmd_config_tx_affinity_map_port = 12755 TOKEN_STRING_INITIALIZER(struct cmd_config_tx_affinity_map, 12756 port, "port"); 12757 cmdline_parse_token_string_t cmd_config_tx_affinity_map_config = 12758 TOKEN_STRING_INITIALIZER(struct cmd_config_tx_affinity_map, 12759 config, "config"); 12760 cmdline_parse_token_num_t cmd_config_tx_affinity_map_portid = 12761 TOKEN_NUM_INITIALIZER(struct cmd_config_tx_affinity_map, 12762 portid, RTE_UINT16); 12763 cmdline_parse_token_string_t cmd_config_tx_affinity_map_txq = 12764 TOKEN_STRING_INITIALIZER(struct cmd_config_tx_affinity_map, 12765 txq, "txq"); 12766 cmdline_parse_token_num_t cmd_config_tx_affinity_map_qid = 12767 TOKEN_NUM_INITIALIZER(struct cmd_config_tx_affinity_map, 12768 qid, RTE_UINT16); 12769 cmdline_parse_token_string_t cmd_config_tx_affinity_map_affinity = 12770 TOKEN_STRING_INITIALIZER(struct cmd_config_tx_affinity_map, 12771 affinity, "affinity"); 12772 cmdline_parse_token_num_t cmd_config_tx_affinity_map_value = 12773 TOKEN_NUM_INITIALIZER(struct cmd_config_tx_affinity_map, 12774 value, RTE_UINT8); 12775 12776 static cmdline_parse_inst_t cmd_config_tx_affinity_map = { 12777 .f = cmd_config_tx_affinity_map_parsed, 12778 .data = (void *)0, 12779 .help_str = "port config <port_id> txq <queue_id> affinity <value>", 12780 .tokens = { 12781 (void *)&cmd_config_tx_affinity_map_port, 12782 (void *)&cmd_config_tx_affinity_map_config, 12783 (void *)&cmd_config_tx_affinity_map_portid, 12784 (void *)&cmd_config_tx_affinity_map_txq, 12785 (void *)&cmd_config_tx_affinity_map_qid, 12786 (void *)&cmd_config_tx_affinity_map_affinity, 12787 (void *)&cmd_config_tx_affinity_map_value, 12788 NULL, 12789 }, 12790 }; 12791 12792 /* ******************************************************************************** */ 12793 12794 /* list of instructions */ 12795 static cmdline_parse_ctx_t builtin_ctx[] = { 12796 (cmdline_parse_inst_t *)&cmd_help_brief, 12797 (cmdline_parse_inst_t *)&cmd_help_long, 12798 (cmdline_parse_inst_t *)&cmd_quit, 12799 (cmdline_parse_inst_t *)&cmd_load_from_file, 12800 (cmdline_parse_inst_t *)&cmd_showport, 12801 (cmdline_parse_inst_t *)&cmd_showqueue, 12802 (cmdline_parse_inst_t *)&cmd_showeeprom, 12803 (cmdline_parse_inst_t *)&cmd_showportall, 12804 (cmdline_parse_inst_t *)&cmd_representor_info, 12805 (cmdline_parse_inst_t *)&cmd_showdevice, 12806 (cmdline_parse_inst_t *)&cmd_showcfg, 12807 (cmdline_parse_inst_t *)&cmd_showfwdall, 12808 (cmdline_parse_inst_t *)&cmd_start, 12809 (cmdline_parse_inst_t *)&cmd_start_tx_first, 12810 (cmdline_parse_inst_t *)&cmd_start_tx_first_n, 12811 (cmdline_parse_inst_t *)&cmd_set_link_up, 12812 (cmdline_parse_inst_t *)&cmd_set_link_down, 12813 (cmdline_parse_inst_t *)&cmd_reset, 12814 (cmdline_parse_inst_t *)&cmd_set_numbers, 12815 (cmdline_parse_inst_t *)&cmd_set_log, 12816 (cmdline_parse_inst_t *)&cmd_set_rxoffs, 12817 (cmdline_parse_inst_t *)&cmd_set_rxpkts, 12818 (cmdline_parse_inst_t *)&cmd_set_rxhdrs, 12819 (cmdline_parse_inst_t *)&cmd_set_txpkts, 12820 (cmdline_parse_inst_t *)&cmd_set_txsplit, 12821 (cmdline_parse_inst_t *)&cmd_set_txtimes, 12822 (cmdline_parse_inst_t *)&cmd_set_fwd_list, 12823 (cmdline_parse_inst_t *)&cmd_set_fwd_mask, 12824 (cmdline_parse_inst_t *)&cmd_set_fwd_mode, 12825 (cmdline_parse_inst_t *)&cmd_set_fwd_retry_mode, 12826 (cmdline_parse_inst_t *)&cmd_set_burst_tx_retry, 12827 (cmdline_parse_inst_t *)&cmd_set_promisc_mode_one, 12828 (cmdline_parse_inst_t *)&cmd_set_promisc_mode_all, 12829 (cmdline_parse_inst_t *)&cmd_set_allmulti_mode_one, 12830 (cmdline_parse_inst_t *)&cmd_set_allmulti_mode_all, 12831 (cmdline_parse_inst_t *)&cmd_set_flush_rx, 12832 (cmdline_parse_inst_t *)&cmd_set_link_check, 12833 (cmdline_parse_inst_t *)&cmd_vlan_offload, 12834 (cmdline_parse_inst_t *)&cmd_vlan_tpid, 12835 (cmdline_parse_inst_t *)&cmd_rx_vlan_filter_all, 12836 (cmdline_parse_inst_t *)&cmd_rx_vlan_filter, 12837 (cmdline_parse_inst_t *)&cmd_tx_vlan_set, 12838 (cmdline_parse_inst_t *)&cmd_tx_vlan_set_qinq, 12839 (cmdline_parse_inst_t *)&cmd_tx_vlan_reset, 12840 (cmdline_parse_inst_t *)&cmd_tx_vlan_set_pvid, 12841 (cmdline_parse_inst_t *)&cmd_csum_set, 12842 (cmdline_parse_inst_t *)&cmd_csum_show, 12843 (cmdline_parse_inst_t *)&cmd_csum_tunnel, 12844 (cmdline_parse_inst_t *)&cmd_csum_mac_swap, 12845 (cmdline_parse_inst_t *)&cmd_tso_set, 12846 (cmdline_parse_inst_t *)&cmd_tso_show, 12847 (cmdline_parse_inst_t *)&cmd_tunnel_tso_set, 12848 (cmdline_parse_inst_t *)&cmd_tunnel_tso_show, 12849 #ifdef RTE_LIB_GRO 12850 (cmdline_parse_inst_t *)&cmd_gro_enable, 12851 (cmdline_parse_inst_t *)&cmd_gro_flush, 12852 (cmdline_parse_inst_t *)&cmd_gro_show, 12853 #endif 12854 #ifdef RTE_LIB_GSO 12855 (cmdline_parse_inst_t *)&cmd_gso_enable, 12856 (cmdline_parse_inst_t *)&cmd_gso_size, 12857 (cmdline_parse_inst_t *)&cmd_gso_show, 12858 #endif 12859 (cmdline_parse_inst_t *)&cmd_link_flow_control_set, 12860 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_rx, 12861 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_tx, 12862 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_hw, 12863 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_lw, 12864 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_pt, 12865 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_xon, 12866 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_macfwd, 12867 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_autoneg, 12868 (cmdline_parse_inst_t *)&cmd_link_flow_control_show, 12869 (cmdline_parse_inst_t *)&cmd_priority_flow_control_set, 12870 (cmdline_parse_inst_t *)&cmd_queue_priority_flow_control_set, 12871 (cmdline_parse_inst_t *)&cmd_config_dcb, 12872 (cmdline_parse_inst_t *)&cmd_read_rxd_txd, 12873 (cmdline_parse_inst_t *)&cmd_stop, 12874 (cmdline_parse_inst_t *)&cmd_mac_addr, 12875 (cmdline_parse_inst_t *)&cmd_set_fwd_eth_peer, 12876 (cmdline_parse_inst_t *)&cmd_set_qmap, 12877 (cmdline_parse_inst_t *)&cmd_set_xstats_hide_zero, 12878 (cmdline_parse_inst_t *)&cmd_set_record_core_cycles, 12879 (cmdline_parse_inst_t *)&cmd_set_record_burst_stats, 12880 (cmdline_parse_inst_t *)&cmd_operate_port, 12881 (cmdline_parse_inst_t *)&cmd_operate_specific_port, 12882 (cmdline_parse_inst_t *)&cmd_operate_attach_port, 12883 (cmdline_parse_inst_t *)&cmd_operate_detach_port, 12884 (cmdline_parse_inst_t *)&cmd_operate_detach_device, 12885 (cmdline_parse_inst_t *)&cmd_set_port_setup_on, 12886 (cmdline_parse_inst_t *)&cmd_config_speed_all, 12887 (cmdline_parse_inst_t *)&cmd_config_speed_specific, 12888 (cmdline_parse_inst_t *)&cmd_config_loopback_all, 12889 (cmdline_parse_inst_t *)&cmd_config_loopback_specific, 12890 (cmdline_parse_inst_t *)&cmd_config_rx_tx, 12891 (cmdline_parse_inst_t *)&cmd_config_mtu, 12892 (cmdline_parse_inst_t *)&cmd_config_max_pkt_len, 12893 (cmdline_parse_inst_t *)&cmd_config_max_lro_pkt_size, 12894 (cmdline_parse_inst_t *)&cmd_config_rx_mode_flag, 12895 (cmdline_parse_inst_t *)&cmd_config_rss, 12896 (cmdline_parse_inst_t *)&cmd_config_rxtx_ring_size, 12897 (cmdline_parse_inst_t *)&cmd_config_rxtx_queue, 12898 (cmdline_parse_inst_t *)&cmd_config_deferred_start_rxtx_queue, 12899 (cmdline_parse_inst_t *)&cmd_setup_rxtx_queue, 12900 (cmdline_parse_inst_t *)&cmd_config_rss_reta, 12901 (cmdline_parse_inst_t *)&cmd_showport_reta, 12902 (cmdline_parse_inst_t *)&cmd_showport_macs, 12903 (cmdline_parse_inst_t *)&cmd_show_port_flow_transfer_proxy, 12904 (cmdline_parse_inst_t *)&cmd_config_burst, 12905 (cmdline_parse_inst_t *)&cmd_config_thresh, 12906 (cmdline_parse_inst_t *)&cmd_config_threshold, 12907 (cmdline_parse_inst_t *)&cmd_set_uc_hash_filter, 12908 (cmdline_parse_inst_t *)&cmd_set_uc_all_hash_filter, 12909 (cmdline_parse_inst_t *)&cmd_vf_mac_addr_filter, 12910 (cmdline_parse_inst_t *)&cmd_queue_rate_limit, 12911 (cmdline_parse_inst_t *)&cmd_tunnel_udp_config, 12912 (cmdline_parse_inst_t *)&cmd_showport_rss_hash, 12913 (cmdline_parse_inst_t *)&cmd_showport_rss_hash_key, 12914 (cmdline_parse_inst_t *)&cmd_config_rss_hash_key, 12915 (cmdline_parse_inst_t *)&cmd_cleanup_txq_mbufs, 12916 (cmdline_parse_inst_t *)&cmd_dump, 12917 (cmdline_parse_inst_t *)&cmd_dump_one, 12918 (cmdline_parse_inst_t *)&cmd_flow, 12919 (cmdline_parse_inst_t *)&cmd_show_port_meter_cap, 12920 (cmdline_parse_inst_t *)&cmd_add_port_meter_profile_srtcm, 12921 (cmdline_parse_inst_t *)&cmd_add_port_meter_profile_trtcm, 12922 (cmdline_parse_inst_t *)&cmd_add_port_meter_profile_trtcm_rfc4115, 12923 (cmdline_parse_inst_t *)&cmd_del_port_meter_profile, 12924 (cmdline_parse_inst_t *)&cmd_create_port_meter, 12925 (cmdline_parse_inst_t *)&cmd_enable_port_meter, 12926 (cmdline_parse_inst_t *)&cmd_disable_port_meter, 12927 (cmdline_parse_inst_t *)&cmd_del_port_meter, 12928 (cmdline_parse_inst_t *)&cmd_del_port_meter_policy, 12929 (cmdline_parse_inst_t *)&cmd_set_port_meter_profile, 12930 (cmdline_parse_inst_t *)&cmd_set_port_meter_dscp_table, 12931 (cmdline_parse_inst_t *)&cmd_set_port_meter_vlan_table, 12932 (cmdline_parse_inst_t *)&cmd_set_port_meter_in_proto, 12933 (cmdline_parse_inst_t *)&cmd_get_port_meter_in_proto, 12934 (cmdline_parse_inst_t *)&cmd_get_port_meter_in_proto_prio, 12935 (cmdline_parse_inst_t *)&cmd_set_port_meter_stats_mask, 12936 (cmdline_parse_inst_t *)&cmd_show_port_meter_stats, 12937 (cmdline_parse_inst_t *)&cmd_mcast_addr, 12938 (cmdline_parse_inst_t *)&cmd_set_vf_vlan_anti_spoof, 12939 (cmdline_parse_inst_t *)&cmd_set_vf_mac_anti_spoof, 12940 (cmdline_parse_inst_t *)&cmd_set_vf_vlan_stripq, 12941 (cmdline_parse_inst_t *)&cmd_set_vf_vlan_insert, 12942 (cmdline_parse_inst_t *)&cmd_set_tx_loopback, 12943 (cmdline_parse_inst_t *)&cmd_set_all_queues_drop_en, 12944 (cmdline_parse_inst_t *)&cmd_set_vf_traffic, 12945 (cmdline_parse_inst_t *)&cmd_set_vf_rxmode, 12946 (cmdline_parse_inst_t *)&cmd_vf_rate_limit, 12947 (cmdline_parse_inst_t *)&cmd_vf_rxvlan_filter, 12948 (cmdline_parse_inst_t *)&cmd_set_vf_mac_addr, 12949 (cmdline_parse_inst_t *)&cmd_set_vxlan, 12950 (cmdline_parse_inst_t *)&cmd_set_vxlan_tos_ttl, 12951 (cmdline_parse_inst_t *)&cmd_set_vxlan_with_vlan, 12952 (cmdline_parse_inst_t *)&cmd_set_nvgre, 12953 (cmdline_parse_inst_t *)&cmd_set_nvgre_with_vlan, 12954 (cmdline_parse_inst_t *)&cmd_set_l2_encap, 12955 (cmdline_parse_inst_t *)&cmd_set_l2_encap_with_vlan, 12956 (cmdline_parse_inst_t *)&cmd_set_l2_decap, 12957 (cmdline_parse_inst_t *)&cmd_set_l2_decap_with_vlan, 12958 (cmdline_parse_inst_t *)&cmd_set_mplsogre_encap, 12959 (cmdline_parse_inst_t *)&cmd_set_mplsogre_encap_with_vlan, 12960 (cmdline_parse_inst_t *)&cmd_set_mplsogre_decap, 12961 (cmdline_parse_inst_t *)&cmd_set_mplsogre_decap_with_vlan, 12962 (cmdline_parse_inst_t *)&cmd_set_mplsoudp_encap, 12963 (cmdline_parse_inst_t *)&cmd_set_mplsoudp_encap_with_vlan, 12964 (cmdline_parse_inst_t *)&cmd_set_mplsoudp_decap, 12965 (cmdline_parse_inst_t *)&cmd_set_mplsoudp_decap_with_vlan, 12966 (cmdline_parse_inst_t *)&cmd_set_conntrack_common, 12967 (cmdline_parse_inst_t *)&cmd_set_conntrack_dir, 12968 (cmdline_parse_inst_t *)&cmd_show_vf_stats, 12969 (cmdline_parse_inst_t *)&cmd_clear_vf_stats, 12970 (cmdline_parse_inst_t *)&cmd_show_port_supported_ptypes, 12971 (cmdline_parse_inst_t *)&cmd_set_port_ptypes, 12972 (cmdline_parse_inst_t *)&cmd_show_port_tm_cap, 12973 (cmdline_parse_inst_t *)&cmd_show_port_tm_level_cap, 12974 (cmdline_parse_inst_t *)&cmd_show_port_tm_node_cap, 12975 (cmdline_parse_inst_t *)&cmd_show_port_tm_node_type, 12976 (cmdline_parse_inst_t *)&cmd_show_port_tm_node_stats, 12977 (cmdline_parse_inst_t *)&cmd_add_port_tm_node_shaper_profile, 12978 (cmdline_parse_inst_t *)&cmd_del_port_tm_node_shaper_profile, 12979 (cmdline_parse_inst_t *)&cmd_add_port_tm_node_shared_shaper, 12980 (cmdline_parse_inst_t *)&cmd_del_port_tm_node_shared_shaper, 12981 (cmdline_parse_inst_t *)&cmd_add_port_tm_node_wred_profile, 12982 (cmdline_parse_inst_t *)&cmd_del_port_tm_node_wred_profile, 12983 (cmdline_parse_inst_t *)&cmd_set_port_tm_node_shaper_profile, 12984 (cmdline_parse_inst_t *)&cmd_add_port_tm_nonleaf_node, 12985 (cmdline_parse_inst_t *)&cmd_add_port_tm_nonleaf_node_pmode, 12986 (cmdline_parse_inst_t *)&cmd_add_port_tm_leaf_node, 12987 (cmdline_parse_inst_t *)&cmd_del_port_tm_node, 12988 (cmdline_parse_inst_t *)&cmd_set_port_tm_node_parent, 12989 (cmdline_parse_inst_t *)&cmd_suspend_port_tm_node, 12990 (cmdline_parse_inst_t *)&cmd_resume_port_tm_node, 12991 (cmdline_parse_inst_t *)&cmd_port_tm_hierarchy_commit, 12992 (cmdline_parse_inst_t *)&cmd_port_tm_mark_ip_ecn, 12993 (cmdline_parse_inst_t *)&cmd_port_tm_mark_ip_dscp, 12994 (cmdline_parse_inst_t *)&cmd_port_tm_mark_vlan_dei, 12995 (cmdline_parse_inst_t *)&cmd_cfg_tunnel_udp_port, 12996 (cmdline_parse_inst_t *)&cmd_rx_offload_get_capa, 12997 (cmdline_parse_inst_t *)&cmd_rx_offload_get_configuration, 12998 (cmdline_parse_inst_t *)&cmd_config_per_port_rx_offload, 12999 (cmdline_parse_inst_t *)&cmd_config_per_queue_rx_offload, 13000 (cmdline_parse_inst_t *)&cmd_tx_offload_get_capa, 13001 (cmdline_parse_inst_t *)&cmd_tx_offload_get_configuration, 13002 (cmdline_parse_inst_t *)&cmd_config_per_port_tx_offload, 13003 (cmdline_parse_inst_t *)&cmd_config_per_queue_tx_offload, 13004 #ifdef RTE_LIB_BPF 13005 (cmdline_parse_inst_t *)&cmd_operate_bpf_ld_parse, 13006 (cmdline_parse_inst_t *)&cmd_operate_bpf_unld_parse, 13007 #endif 13008 (cmdline_parse_inst_t *)&cmd_config_tx_metadata_specific, 13009 (cmdline_parse_inst_t *)&cmd_show_tx_metadata, 13010 (cmdline_parse_inst_t *)&cmd_show_rx_tx_desc_status, 13011 (cmdline_parse_inst_t *)&cmd_show_rx_queue_desc_used_count, 13012 (cmdline_parse_inst_t *)&cmd_set_raw, 13013 (cmdline_parse_inst_t *)&cmd_show_set_raw, 13014 (cmdline_parse_inst_t *)&cmd_show_set_raw_all, 13015 (cmdline_parse_inst_t *)&cmd_config_tx_dynf_specific, 13016 (cmdline_parse_inst_t *)&cmd_show_fec_mode, 13017 (cmdline_parse_inst_t *)&cmd_set_fec_mode, 13018 (cmdline_parse_inst_t *)&cmd_set_rxq_avail_thresh, 13019 (cmdline_parse_inst_t *)&cmd_show_capability, 13020 (cmdline_parse_inst_t *)&cmd_set_flex_is_pattern, 13021 (cmdline_parse_inst_t *)&cmd_set_flex_spec_pattern, 13022 (cmdline_parse_inst_t *)&cmd_show_port_cman_capa, 13023 (cmdline_parse_inst_t *)&cmd_show_port_cman_config, 13024 (cmdline_parse_inst_t *)&cmd_set_port_cman_config, 13025 (cmdline_parse_inst_t *)&cmd_config_tx_affinity_map, 13026 NULL, 13027 }; 13028 13029 void 13030 testpmd_add_driver_commands(struct testpmd_driver_commands *c) 13031 { 13032 TAILQ_INSERT_TAIL(&driver_commands_head, c, next); 13033 } 13034 13035 int 13036 init_cmdline(void) 13037 { 13038 struct testpmd_driver_commands *c; 13039 unsigned int count; 13040 unsigned int i; 13041 13042 /* initialize non-constant commands */ 13043 cmd_set_fwd_mode_init(); 13044 cmd_set_fwd_retry_mode_init(); 13045 13046 count = 0; 13047 for (i = 0; builtin_ctx[i] != NULL; i++) 13048 count++; 13049 TAILQ_FOREACH(c, &driver_commands_head, next) { 13050 for (i = 0; c->commands[i].ctx != NULL; i++) 13051 count++; 13052 } 13053 13054 /* cmdline expects a NULL terminated array */ 13055 main_ctx = calloc(count + 1, sizeof(main_ctx[0])); 13056 if (main_ctx == NULL) 13057 return -1; 13058 13059 count = 0; 13060 for (i = 0; builtin_ctx[i] != NULL; i++, count++) 13061 main_ctx[count] = builtin_ctx[i]; 13062 TAILQ_FOREACH(c, &driver_commands_head, next) { 13063 for (i = 0; c->commands[i].ctx != NULL; i++, count++) 13064 main_ctx[count] = c->commands[i].ctx; 13065 } 13066 13067 return 0; 13068 } 13069 13070 /* read cmdline commands from file */ 13071 void 13072 cmdline_read_from_file(const char *filename) 13073 { 13074 struct cmdline *cl; 13075 13076 cl = cmdline_file_new(main_ctx, "testpmd> ", filename); 13077 if (cl == NULL) { 13078 fprintf(stderr, 13079 "Failed to create file based cmdline context: %s\n", 13080 filename); 13081 return; 13082 } 13083 13084 cmdline_interact(cl); 13085 cmdline_quit(cl); 13086 13087 cmdline_free(cl); 13088 13089 printf("Read CLI commands from %s\n", filename); 13090 } 13091 13092 void 13093 prompt_exit(void) 13094 { 13095 cmdline_quit(testpmd_cl); 13096 } 13097 13098 /* prompt function, called from main on MAIN lcore */ 13099 void 13100 prompt(void) 13101 { 13102 testpmd_cl = cmdline_stdin_new(main_ctx, "testpmd> "); 13103 if (testpmd_cl == NULL) { 13104 fprintf(stderr, 13105 "Failed to create stdin based cmdline context\n"); 13106 return; 13107 } 13108 13109 cmdline_interact(testpmd_cl); 13110 cmdline_stdin_exit(testpmd_cl); 13111 } 13112 13113 void 13114 cmd_reconfig_device_queue(portid_t id, uint8_t dev, uint8_t queue) 13115 { 13116 if (id == (portid_t)RTE_PORT_ALL) { 13117 portid_t pid; 13118 13119 RTE_ETH_FOREACH_DEV(pid) { 13120 /* check if need_reconfig has been set to 1 */ 13121 if (ports[pid].need_reconfig == 0) 13122 ports[pid].need_reconfig = dev; 13123 /* check if need_reconfig_queues has been set to 1 */ 13124 if (ports[pid].need_reconfig_queues == 0) 13125 ports[pid].need_reconfig_queues = queue; 13126 } 13127 } else if (!port_id_is_invalid(id, DISABLED_WARN)) { 13128 /* check if need_reconfig has been set to 1 */ 13129 if (ports[id].need_reconfig == 0) 13130 ports[id].need_reconfig = dev; 13131 /* check if need_reconfig_queues has been set to 1 */ 13132 if (ports[id].need_reconfig_queues == 0) 13133 ports[id].need_reconfig_queues = queue; 13134 } 13135 } 13136