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