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