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