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