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