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 <termios.h> 12 #include <unistd.h> 13 #include <inttypes.h> 14 #include <sys/socket.h> 15 #include <netinet/in.h> 16 17 #include <sys/queue.h> 18 19 #include <rte_common.h> 20 #include <rte_byteorder.h> 21 #include <rte_log.h> 22 #include <rte_debug.h> 23 #include <rte_cycles.h> 24 #include <rte_memory.h> 25 #include <rte_memzone.h> 26 #include <rte_malloc.h> 27 #include <rte_launch.h> 28 #include <rte_eal.h> 29 #include <rte_per_lcore.h> 30 #include <rte_lcore.h> 31 #include <rte_atomic.h> 32 #include <rte_branch_prediction.h> 33 #include <rte_ring.h> 34 #include <rte_mempool.h> 35 #include <rte_interrupts.h> 36 #include <rte_pci.h> 37 #include <rte_ether.h> 38 #include <rte_ethdev.h> 39 #include <rte_string_fns.h> 40 #include <rte_devargs.h> 41 #include <rte_flow.h> 42 #include <rte_gro.h> 43 #include <rte_mbuf_dyn.h> 44 45 #include <cmdline_rdline.h> 46 #include <cmdline_parse.h> 47 #include <cmdline_parse_num.h> 48 #include <cmdline_parse_string.h> 49 #include <cmdline_parse_ipaddr.h> 50 #include <cmdline_parse_etheraddr.h> 51 #include <cmdline_socket.h> 52 #include <cmdline.h> 53 #ifdef RTE_LIBRTE_PMD_BOND 54 #include <rte_eth_bond.h> 55 #include <rte_eth_bond_8023ad.h> 56 #endif 57 #if defined RTE_LIBRTE_DPAA_BUS && defined RTE_LIBRTE_DPAA_PMD 58 #include <rte_pmd_dpaa.h> 59 #endif 60 #ifdef RTE_LIBRTE_IXGBE_PMD 61 #include <rte_pmd_ixgbe.h> 62 #endif 63 #ifdef RTE_LIBRTE_I40E_PMD 64 #include <rte_pmd_i40e.h> 65 #endif 66 #ifdef RTE_LIBRTE_BNXT_PMD 67 #include <rte_pmd_bnxt.h> 68 #endif 69 #include "testpmd.h" 70 #include "cmdline_mtr.h" 71 #include "cmdline_tm.h" 72 #include "bpf_cmd.h" 73 74 static struct cmdline *testpmd_cl; 75 76 static void cmd_reconfig_device_queue(portid_t id, uint8_t dev, uint8_t queue); 77 78 /* *** Help command with introduction. *** */ 79 struct cmd_help_brief_result { 80 cmdline_fixed_string_t help; 81 }; 82 83 static void cmd_help_brief_parsed(__rte_unused void *parsed_result, 84 struct cmdline *cl, 85 __rte_unused void *data) 86 { 87 cmdline_printf( 88 cl, 89 "\n" 90 "Help is available for the following sections:\n\n" 91 " help control : Start and stop forwarding.\n" 92 " help display : Displaying port, stats and config " 93 "information.\n" 94 " help config : Configuration information.\n" 95 " help ports : Configuring ports.\n" 96 " help registers : Reading and setting port registers.\n" 97 " help filters : Filters configuration help.\n" 98 " help traffic_management : Traffic Management commands.\n" 99 " help devices : Device related cmds.\n" 100 " help all : All of the above sections.\n\n" 101 ); 102 103 } 104 105 cmdline_parse_token_string_t cmd_help_brief_help = 106 TOKEN_STRING_INITIALIZER(struct cmd_help_brief_result, help, "help"); 107 108 cmdline_parse_inst_t cmd_help_brief = { 109 .f = cmd_help_brief_parsed, 110 .data = NULL, 111 .help_str = "help: Show help", 112 .tokens = { 113 (void *)&cmd_help_brief_help, 114 NULL, 115 }, 116 }; 117 118 /* *** Help command with help sections. *** */ 119 struct cmd_help_long_result { 120 cmdline_fixed_string_t help; 121 cmdline_fixed_string_t section; 122 }; 123 124 static void cmd_help_long_parsed(void *parsed_result, 125 struct cmdline *cl, 126 __rte_unused void *data) 127 { 128 int show_all = 0; 129 struct cmd_help_long_result *res = parsed_result; 130 131 if (!strcmp(res->section, "all")) 132 show_all = 1; 133 134 if (show_all || !strcmp(res->section, "control")) { 135 136 cmdline_printf( 137 cl, 138 "\n" 139 "Control forwarding:\n" 140 "-------------------\n\n" 141 142 "start\n" 143 " Start packet forwarding with current configuration.\n\n" 144 145 "start tx_first\n" 146 " Start packet forwarding with current config" 147 " after sending one burst of packets.\n\n" 148 149 "stop\n" 150 " Stop packet forwarding, and display accumulated" 151 " statistics.\n\n" 152 153 "quit\n" 154 " Quit to prompt.\n\n" 155 ); 156 } 157 158 if (show_all || !strcmp(res->section, "display")) { 159 160 cmdline_printf( 161 cl, 162 "\n" 163 "Display:\n" 164 "--------\n\n" 165 166 "show port (info|stats|summary|xstats|fdir|stat_qmap|dcb_tc|cap) (port_id|all)\n" 167 " Display information for port_id, or all.\n\n" 168 169 "show port X rss reta (size) (mask0,mask1,...)\n" 170 " Display the rss redirection table entry indicated" 171 " by masks on port X. size is used to indicate the" 172 " hardware supported reta size\n\n" 173 174 "show port (port_id) rss-hash [key]\n" 175 " Display the RSS hash functions and RSS hash key of port\n\n" 176 177 "clear port (info|stats|xstats|fdir|stat_qmap) (port_id|all)\n" 178 " Clear information for port_id, or all.\n\n" 179 180 "show (rxq|txq) info (port_id) (queue_id)\n" 181 " Display information for configured RX/TX queue.\n\n" 182 183 "show config (rxtx|cores|fwd|txpkts)\n" 184 " Display the given configuration.\n\n" 185 186 "read rxd (port_id) (queue_id) (rxd_id)\n" 187 " Display an RX descriptor of a port RX queue.\n\n" 188 189 "read txd (port_id) (queue_id) (txd_id)\n" 190 " Display a TX descriptor of a port TX queue.\n\n" 191 192 "ddp get list (port_id)\n" 193 " Get ddp profile info list\n\n" 194 195 "ddp get info (profile_path)\n" 196 " Get ddp profile information.\n\n" 197 198 "show vf stats (port_id) (vf_id)\n" 199 " Display a VF's statistics.\n\n" 200 201 "clear vf stats (port_id) (vf_id)\n" 202 " Reset a VF's statistics.\n\n" 203 204 "show port (port_id) pctype mapping\n" 205 " Get flow ptype to pctype mapping on a port\n\n" 206 207 "show port meter stats (port_id) (meter_id) (clear)\n" 208 " Get meter stats on a port\n\n" 209 210 "show fwd stats all\n" 211 " Display statistics for all fwd engines.\n\n" 212 213 "clear fwd stats all\n" 214 " Clear statistics for all fwd engines.\n\n" 215 216 "show port (port_id) rx_offload capabilities\n" 217 " List all per queue and per port Rx offloading" 218 " capabilities of a port\n\n" 219 220 "show port (port_id) rx_offload configuration\n" 221 " List port level and all queue level" 222 " Rx offloading configuration\n\n" 223 224 "show port (port_id) tx_offload capabilities\n" 225 " List all per queue and per port" 226 " Tx offloading capabilities of a port\n\n" 227 228 "show port (port_id) tx_offload configuration\n" 229 " List port level and all queue level" 230 " Tx offloading configuration\n\n" 231 232 "show port (port_id) tx_metadata\n" 233 " Show Tx metadata value set" 234 " for a specific port\n\n" 235 236 "show port (port_id) ptypes\n" 237 " Show port supported ptypes" 238 " for a specific port\n\n" 239 240 "show device info (<identifier>|all)" 241 " Show general information about devices probed.\n\n" 242 243 "show port (port_id) rxq|txq (queue_id) desc (desc_id) status" 244 " Show status of rx|tx descriptor.\n\n" 245 246 "show port (port_id) macs|mcast_macs" 247 " Display list of mac addresses added to port.\n\n" 248 ); 249 } 250 251 if (show_all || !strcmp(res->section, "config")) { 252 cmdline_printf( 253 cl, 254 "\n" 255 "Configuration:\n" 256 "--------------\n" 257 "Configuration changes only become active when" 258 " forwarding is started/restarted.\n\n" 259 260 "set default\n" 261 " Reset forwarding to the default configuration.\n\n" 262 263 "set verbose (level)\n" 264 " Set the debug verbosity level X.\n\n" 265 266 "set log global|(type) (level)\n" 267 " Set the log level.\n\n" 268 269 "set nbport (num)\n" 270 " Set number of ports.\n\n" 271 272 "set nbcore (num)\n" 273 " Set number of cores.\n\n" 274 275 "set coremask (mask)\n" 276 " Set the forwarding cores hexadecimal mask.\n\n" 277 278 "set portmask (mask)\n" 279 " Set the forwarding ports hexadecimal mask.\n\n" 280 281 "set burst (num)\n" 282 " Set number of packets per burst.\n\n" 283 284 "set burst tx delay (microseconds) retry (num)\n" 285 " Set the transmit delay time and number of retries," 286 " effective when retry is enabled.\n\n" 287 288 "set txpkts (x[,y]*)\n" 289 " Set the length of each segment of TXONLY" 290 " and optionally CSUM packets.\n\n" 291 292 "set txsplit (off|on|rand)\n" 293 " Set the split policy for the TX packets." 294 " Right now only applicable for CSUM and TXONLY" 295 " modes\n\n" 296 297 "set txtimes (x, y)\n" 298 " Set the scheduling on timestamps" 299 " timings for the TXONLY mode\n\n" 300 301 "set corelist (x[,y]*)\n" 302 " Set the list of forwarding cores.\n\n" 303 304 "set portlist (x[,y]*)\n" 305 " Set the list of forwarding ports.\n\n" 306 307 "set port setup on (iterator|event)\n" 308 " Select how attached port is retrieved for setup.\n\n" 309 310 "set tx loopback (port_id) (on|off)\n" 311 " Enable or disable tx loopback.\n\n" 312 313 "set all queues drop (port_id) (on|off)\n" 314 " Set drop enable bit for all queues.\n\n" 315 316 "set vf split drop (port_id) (vf_id) (on|off)\n" 317 " Set split drop enable bit for a VF from the PF.\n\n" 318 319 "set vf mac antispoof (port_id) (vf_id) (on|off).\n" 320 " Set MAC antispoof for a VF from the PF.\n\n" 321 322 "set macsec offload (port_id) on encrypt (on|off) replay-protect (on|off)\n" 323 " Enable MACsec offload.\n\n" 324 325 "set macsec offload (port_id) off\n" 326 " Disable MACsec offload.\n\n" 327 328 "set macsec sc (tx|rx) (port_id) (mac) (pi)\n" 329 " Configure MACsec secure connection (SC).\n\n" 330 331 "set macsec sa (tx|rx) (port_id) (idx) (an) (pn) (key)\n" 332 " Configure MACsec secure association (SA).\n\n" 333 334 "set vf broadcast (port_id) (vf_id) (on|off)\n" 335 " Set VF broadcast for a VF from the PF.\n\n" 336 337 "vlan set stripq (on|off) (port_id,queue_id)\n" 338 " Set the VLAN strip for a queue on a port.\n\n" 339 340 "set vf vlan stripq (port_id) (vf_id) (on|off)\n" 341 " Set the VLAN strip for all queues in a pool for a VF from the PF.\n\n" 342 343 "set vf vlan insert (port_id) (vf_id) (vlan_id)\n" 344 " Set VLAN insert for a VF from the PF.\n\n" 345 346 "set vf vlan antispoof (port_id) (vf_id) (on|off)\n" 347 " Set VLAN antispoof for a VF from the PF.\n\n" 348 349 "set vf vlan tag (port_id) (vf_id) (on|off)\n" 350 " Set VLAN tag for a VF from the PF.\n\n" 351 352 "set vf tx max-bandwidth (port_id) (vf_id) (bandwidth)\n" 353 " Set a VF's max bandwidth(Mbps).\n\n" 354 355 "set vf tc tx min-bandwidth (port_id) (vf_id) (bw1, bw2, ...)\n" 356 " Set all TCs' min bandwidth(%%) on a VF.\n\n" 357 358 "set vf tc tx max-bandwidth (port_id) (vf_id) (tc_no) (bandwidth)\n" 359 " Set a TC's max bandwidth(Mbps) on a VF.\n\n" 360 361 "set tx strict-link-priority (port_id) (tc_bitmap)\n" 362 " Set some TCs' strict link priority mode on a physical port.\n\n" 363 364 "set tc tx min-bandwidth (port_id) (bw1, bw2, ...)\n" 365 " Set all TCs' min bandwidth(%%) for all PF and VFs.\n\n" 366 367 "vlan set (strip|filter|qinq_strip|extend) (on|off) (port_id)\n" 368 " Set the VLAN strip or filter or qinq strip or extend\n\n" 369 370 "vlan set (inner|outer) tpid (value) (port_id)\n" 371 " Set the VLAN TPID for Packet Filtering on" 372 " a port\n\n" 373 374 "rx_vlan add (vlan_id|all) (port_id)\n" 375 " Add a vlan_id, or all identifiers, to the set" 376 " of VLAN identifiers filtered by port_id.\n\n" 377 378 "rx_vlan rm (vlan_id|all) (port_id)\n" 379 " Remove a vlan_id, or all identifiers, from the set" 380 " of VLAN identifiers filtered by port_id.\n\n" 381 382 "rx_vlan add (vlan_id) port (port_id) vf (vf_mask)\n" 383 " Add a vlan_id, to the set of VLAN identifiers" 384 "filtered for VF(s) from port_id.\n\n" 385 386 "rx_vlan rm (vlan_id) port (port_id) vf (vf_mask)\n" 387 " Remove a vlan_id, to the set of VLAN identifiers" 388 "filtered for VF(s) from port_id.\n\n" 389 390 "tunnel_filter add (port_id) (outer_mac) (inner_mac) (ip_addr) " 391 "(inner_vlan) (vxlan|nvgre|ipingre|vxlan-gpe) (imac-ivlan|imac-ivlan-tenid|" 392 "imac-tenid|imac|omac-imac-tenid|oip|iip) (tenant_id) (queue_id)\n" 393 " add a tunnel filter of a port.\n\n" 394 395 "tunnel_filter rm (port_id) (outer_mac) (inner_mac) (ip_addr) " 396 "(inner_vlan) (vxlan|nvgre|ipingre|vxlan-gpe) (imac-ivlan|imac-ivlan-tenid|" 397 "imac-tenid|imac|omac-imac-tenid|oip|iip) (tenant_id) (queue_id)\n" 398 " remove a tunnel filter of a port.\n\n" 399 400 "rx_vxlan_port add (udp_port) (port_id)\n" 401 " Add an UDP port for VXLAN packet filter on a port\n\n" 402 403 "rx_vxlan_port rm (udp_port) (port_id)\n" 404 " Remove an UDP port for VXLAN packet filter on a port\n\n" 405 406 "tx_vlan set (port_id) vlan_id[, vlan_id_outer]\n" 407 " Set hardware insertion of VLAN IDs (single or double VLAN " 408 "depends on the number of VLAN IDs) in packets sent on a port.\n\n" 409 410 "tx_vlan set pvid port_id vlan_id (on|off)\n" 411 " Set port based TX VLAN insertion.\n\n" 412 413 "tx_vlan reset (port_id)\n" 414 " Disable hardware insertion of a VLAN header in" 415 " packets sent on a port.\n\n" 416 417 "csum set (ip|udp|tcp|sctp|outer-ip|outer-udp) (hw|sw) (port_id)\n" 418 " Select hardware or software calculation of the" 419 " checksum when transmitting a packet using the" 420 " csum forward engine.\n" 421 " ip|udp|tcp|sctp always concern the inner layer.\n" 422 " outer-ip concerns the outer IP layer in" 423 " outer-udp concerns the outer UDP layer in" 424 " case the packet is recognized as a tunnel packet by" 425 " the forward engine (vxlan, gre and ipip are supported)\n" 426 " Please check the NIC datasheet for HW limits.\n\n" 427 428 "csum parse-tunnel (on|off) (tx_port_id)\n" 429 " If disabled, treat tunnel packets as non-tunneled" 430 " packets (treat inner headers as payload). The port\n" 431 " argument is the port used for TX in csum forward" 432 " engine.\n\n" 433 434 "csum show (port_id)\n" 435 " Display tx checksum offload configuration\n\n" 436 437 "tso set (segsize) (portid)\n" 438 " Enable TCP Segmentation Offload in csum forward" 439 " engine.\n" 440 " Please check the NIC datasheet for HW limits.\n\n" 441 442 "tso show (portid)" 443 " Display the status of TCP Segmentation Offload.\n\n" 444 445 "set port (port_id) gro on|off\n" 446 " Enable or disable Generic Receive Offload in" 447 " csum forwarding engine.\n\n" 448 449 "show port (port_id) gro\n" 450 " Display GRO configuration.\n\n" 451 452 "set gro flush (cycles)\n" 453 " Set the cycle to flush GROed packets from" 454 " reassembly tables.\n\n" 455 456 "set port (port_id) gso (on|off)" 457 " Enable or disable Generic Segmentation Offload in" 458 " csum forwarding engine.\n\n" 459 460 "set gso segsz (length)\n" 461 " Set max packet length for output GSO segments," 462 " including packet header and payload.\n\n" 463 464 "show port (port_id) gso\n" 465 " Show GSO configuration.\n\n" 466 467 "set fwd (%s)\n" 468 " Set packet forwarding mode.\n\n" 469 470 "mac_addr add (port_id) (XX:XX:XX:XX:XX:XX)\n" 471 " Add a MAC address on port_id.\n\n" 472 473 "mac_addr remove (port_id) (XX:XX:XX:XX:XX:XX)\n" 474 " Remove a MAC address from port_id.\n\n" 475 476 "mac_addr set (port_id) (XX:XX:XX:XX:XX:XX)\n" 477 " Set the default MAC address for port_id.\n\n" 478 479 "mac_addr add port (port_id) vf (vf_id) (mac_address)\n" 480 " Add a MAC address for a VF on the port.\n\n" 481 482 "set vf mac addr (port_id) (vf_id) (XX:XX:XX:XX:XX:XX)\n" 483 " Set the MAC address for a VF from the PF.\n\n" 484 485 "set eth-peer (port_id) (peer_addr)\n" 486 " set the peer address for certain port.\n\n" 487 488 "set port (port_id) uta (mac_address|all) (on|off)\n" 489 " Add/Remove a or all unicast hash filter(s)" 490 "from port X.\n\n" 491 492 "set promisc (port_id|all) (on|off)\n" 493 " Set the promiscuous mode on port_id, or all.\n\n" 494 495 "set allmulti (port_id|all) (on|off)\n" 496 " Set the allmulti mode on port_id, or all.\n\n" 497 498 "set vf promisc (port_id) (vf_id) (on|off)\n" 499 " Set unicast promiscuous mode for a VF from the PF.\n\n" 500 501 "set vf allmulti (port_id) (vf_id) (on|off)\n" 502 " Set multicast promiscuous mode for a VF from the PF.\n\n" 503 504 "set flow_ctrl rx (on|off) tx (on|off) (high_water)" 505 " (low_water) (pause_time) (send_xon) mac_ctrl_frame_fwd" 506 " (on|off) autoneg (on|off) (port_id)\n" 507 "set flow_ctrl rx (on|off) (portid)\n" 508 "set flow_ctrl tx (on|off) (portid)\n" 509 "set flow_ctrl high_water (high_water) (portid)\n" 510 "set flow_ctrl low_water (low_water) (portid)\n" 511 "set flow_ctrl pause_time (pause_time) (portid)\n" 512 "set flow_ctrl send_xon (send_xon) (portid)\n" 513 "set flow_ctrl mac_ctrl_frame_fwd (on|off) (portid)\n" 514 "set flow_ctrl autoneg (on|off) (port_id)\n" 515 " Set the link flow control parameter on a port.\n\n" 516 517 "set pfc_ctrl rx (on|off) tx (on|off) (high_water)" 518 " (low_water) (pause_time) (priority) (port_id)\n" 519 " Set the priority flow control parameter on a" 520 " port.\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/tranmit from a port\n\n" 540 541 "set port (port_id) vf (vf_id) (mac_addr)" 542 " (exact-mac#exact-mac-vlan#hashmac|hashmac-vlan) on|off\n" 543 " Add/Remove unicast or multicast MAC addr filter" 544 " for a VF.\n\n" 545 546 "set port (port_id) vf (vf_id) rxmode (AUPE|ROPE|BAM" 547 "|MPE) (on|off)\n" 548 " AUPE:accepts untagged VLAN;" 549 "ROPE:accept unicast hash\n\n" 550 " BAM:accepts broadcast packets;" 551 "MPE:accepts all multicast packets\n\n" 552 " Enable/Disable a VF receive mode of a port\n\n" 553 554 "set port (port_id) queue (queue_id) rate (rate_num)\n" 555 " Set rate limit for a queue of a port\n\n" 556 557 "set port (port_id) vf (vf_id) rate (rate_num) " 558 "queue_mask (queue_mask_value)\n" 559 " Set rate limit for queues in VF of a port\n\n" 560 561 "set port (port_id) mirror-rule (rule_id)" 562 " (pool-mirror-up|pool-mirror-down|vlan-mirror)" 563 " (poolmask|vlanid[,vlanid]*) dst-pool (pool_id) (on|off)\n" 564 " Set pool or vlan type mirror rule on a port.\n" 565 " e.g., 'set port 0 mirror-rule 0 vlan-mirror 0,1" 566 " dst-pool 0 on' enable mirror traffic with vlan 0,1" 567 " to pool 0.\n\n" 568 569 "set port (port_id) mirror-rule (rule_id)" 570 " (uplink-mirror|downlink-mirror) dst-pool" 571 " (pool_id) (on|off)\n" 572 " Set uplink or downlink type mirror rule on a port.\n" 573 " e.g., 'set port 0 mirror-rule 0 uplink-mirror dst-pool" 574 " 0 on' enable mirror income traffic to pool 0.\n\n" 575 576 "reset port (port_id) mirror-rule (rule_id)\n" 577 " Reset a mirror rule.\n\n" 578 579 "set flush_rx (on|off)\n" 580 " Flush (default) or don't flush RX streams before" 581 " forwarding. Mainly used with PCAP drivers.\n\n" 582 583 "set bypass mode (normal|bypass|isolate) (port_id)\n" 584 " Set the bypass mode for the lowest port on bypass enabled" 585 " NIC.\n\n" 586 587 "set bypass event (timeout|os_on|os_off|power_on|power_off) " 588 "mode (normal|bypass|isolate) (port_id)\n" 589 " Set the event required to initiate specified bypass mode for" 590 " the lowest port on a bypass enabled NIC where:\n" 591 " timeout = enable bypass after watchdog timeout.\n" 592 " os_on = enable bypass when OS/board is powered on.\n" 593 " os_off = enable bypass when OS/board is powered off.\n" 594 " power_on = enable bypass when power supply is turned on.\n" 595 " power_off = enable bypass when power supply is turned off." 596 "\n\n" 597 598 "set bypass timeout (0|1.5|2|3|4|8|16|32)\n" 599 " Set the bypass watchdog timeout to 'n' seconds" 600 " where 0 = instant.\n\n" 601 602 "show bypass config (port_id)\n" 603 " Show the bypass configuration for a bypass enabled NIC" 604 " using the lowest port on the NIC.\n\n" 605 606 #ifdef RTE_LIBRTE_PMD_BOND 607 "create bonded device (mode) (socket)\n" 608 " Create a new bonded device with specific bonding mode and socket.\n\n" 609 610 "add bonding slave (slave_id) (port_id)\n" 611 " Add a slave device to a bonded device.\n\n" 612 613 "remove bonding slave (slave_id) (port_id)\n" 614 " Remove a slave device from a bonded device.\n\n" 615 616 "set bonding mode (value) (port_id)\n" 617 " Set the bonding mode on a bonded device.\n\n" 618 619 "set bonding primary (slave_id) (port_id)\n" 620 " Set the primary slave for a bonded device.\n\n" 621 622 "show bonding config (port_id)\n" 623 " Show the bonding config for port_id.\n\n" 624 625 "set bonding mac_addr (port_id) (address)\n" 626 " Set the MAC address of a bonded device.\n\n" 627 628 "set bonding mode IEEE802.3AD aggregator policy (port_id) (agg_name)" 629 " Set Aggregation mode for IEEE802.3AD (mode 4)" 630 631 "set bonding xmit_balance_policy (port_id) (l2|l23|l34)\n" 632 " Set the transmit balance policy for bonded device running in balance mode.\n\n" 633 634 "set bonding mon_period (port_id) (value)\n" 635 " Set the bonding link status monitoring polling period in ms.\n\n" 636 637 "set bonding lacp dedicated_queues <port_id> (enable|disable)\n" 638 " Enable/disable dedicated queues for LACP control traffic.\n\n" 639 640 #endif 641 "set link-up port (port_id)\n" 642 " Set link up for a port.\n\n" 643 644 "set link-down port (port_id)\n" 645 " Set link down for a port.\n\n" 646 647 "E-tag set insertion on port-tag-id (value)" 648 " port (port_id) vf (vf_id)\n" 649 " Enable E-tag insertion for a VF on a port\n\n" 650 651 "E-tag set insertion off port (port_id) vf (vf_id)\n" 652 " Disable E-tag insertion for a VF on a port\n\n" 653 654 "E-tag set stripping (on|off) port (port_id)\n" 655 " Enable/disable E-tag stripping on a port\n\n" 656 657 "E-tag set forwarding (on|off) port (port_id)\n" 658 " Enable/disable E-tag based forwarding" 659 " on a port\n\n" 660 661 "E-tag set filter add e-tag-id (value) dst-pool" 662 " (pool_id) port (port_id)\n" 663 " Add an E-tag forwarding filter on a port\n\n" 664 665 "E-tag set filter del e-tag-id (value) port (port_id)\n" 666 " Delete an E-tag forwarding filter on a port\n\n" 667 668 "ddp add (port_id) (profile_path[,backup_profile_path])\n" 669 " Load a profile package on a port\n\n" 670 671 "ddp del (port_id) (backup_profile_path)\n" 672 " Delete a profile package from a port\n\n" 673 674 "ptype mapping get (port_id) (valid_only)\n" 675 " Get ptype mapping on a port\n\n" 676 677 "ptype mapping replace (port_id) (target) (mask) (pky_type)\n" 678 " Replace target with the pkt_type in ptype mapping\n\n" 679 680 "ptype mapping reset (port_id)\n" 681 " Reset ptype mapping on a port\n\n" 682 683 "ptype mapping update (port_id) (hw_ptype) (sw_ptype)\n" 684 " Update a ptype mapping item on a port\n\n" 685 686 "set port (port_id) ptype_mask (ptype_mask)\n" 687 " set packet types classification for a specific port\n\n" 688 689 "set port (port_id) queue-region region_id (value) " 690 "queue_start_index (value) queue_num (value)\n" 691 " Set a queue region on a port\n\n" 692 693 "set port (port_id) queue-region region_id (value) " 694 "flowtype (value)\n" 695 " Set a flowtype region index on a port\n\n" 696 697 "set port (port_id) queue-region UP (value) region_id (value)\n" 698 " Set the mapping of User Priority to " 699 "queue region on a port\n\n" 700 701 "set port (port_id) queue-region flush (on|off)\n" 702 " flush all queue region related configuration\n\n" 703 704 "show port meter cap (port_id)\n" 705 " Show port meter capability information\n\n" 706 707 "add port meter profile srtcm_rfc2697 (port_id) (profile_id) (cir) (cbs) (ebs)\n" 708 " meter profile add - srtcm rfc 2697\n\n" 709 710 "add port meter profile trtcm_rfc2698 (port_id) (profile_id) (cir) (pir) (cbs) (pbs)\n" 711 " meter profile add - trtcm rfc 2698\n\n" 712 713 "add port meter profile trtcm_rfc4115 (port_id) (profile_id) (cir) (eir) (cbs) (ebs)\n" 714 " meter profile add - trtcm rfc 4115\n\n" 715 716 "del port meter profile (port_id) (profile_id)\n" 717 " meter profile delete\n\n" 718 719 "create port meter (port_id) (mtr_id) (profile_id) (meter_enable)\n" 720 "(g_action) (y_action) (r_action) (stats_mask) (shared)\n" 721 "(use_pre_meter_color) [(dscp_tbl_entry0) (dscp_tbl_entry1)...\n" 722 "(dscp_tbl_entry63)]\n" 723 " meter create\n\n" 724 725 "enable port meter (port_id) (mtr_id)\n" 726 " meter enable\n\n" 727 728 "disable port meter (port_id) (mtr_id)\n" 729 " meter disable\n\n" 730 731 "del port meter (port_id) (mtr_id)\n" 732 " meter delete\n\n" 733 734 "set port meter profile (port_id) (mtr_id) (profile_id)\n" 735 " meter update meter profile\n\n" 736 737 "set port meter dscp table (port_id) (mtr_id) [(dscp_tbl_entry0)\n" 738 "(dscp_tbl_entry1)...(dscp_tbl_entry63)]\n" 739 " update meter dscp table entries\n\n" 740 741 "set port meter policer action (port_id) (mtr_id) (action_mask)\n" 742 "(action0) [(action1) (action2)]\n" 743 " meter update policer action\n\n" 744 745 "set port meter stats mask (port_id) (mtr_id) (stats_mask)\n" 746 " meter update stats\n\n" 747 748 "show port (port_id) queue-region\n" 749 " show all queue region related configuration info\n\n" 750 751 , list_pkt_forwarding_modes() 752 ); 753 } 754 755 if (show_all || !strcmp(res->section, "ports")) { 756 757 cmdline_printf( 758 cl, 759 "\n" 760 "Port Operations:\n" 761 "----------------\n\n" 762 763 "port start (port_id|all)\n" 764 " Start all ports or port_id.\n\n" 765 766 "port stop (port_id|all)\n" 767 " Stop all ports or port_id.\n\n" 768 769 "port close (port_id|all)\n" 770 " Close all ports or port_id.\n\n" 771 772 "port reset (port_id|all)\n" 773 " Reset all ports or port_id.\n\n" 774 775 "port attach (ident)\n" 776 " Attach physical or virtual dev by pci address or virtual device name\n\n" 777 778 "port detach (port_id)\n" 779 " Detach physical or virtual dev by port_id\n\n" 780 781 "port config (port_id|all)" 782 " speed (10|100|1000|10000|25000|40000|50000|100000|200000|auto)" 783 " duplex (half|full|auto)\n" 784 " Set speed and duplex for all ports or port_id\n\n" 785 786 "port config (port_id|all) loopback (mode)\n" 787 " Set loopback mode for all ports or port_id\n\n" 788 789 "port config all (rxq|txq|rxd|txd) (value)\n" 790 " Set number for rxq/txq/rxd/txd.\n\n" 791 792 "port config all max-pkt-len (value)\n" 793 " Set the max packet length.\n\n" 794 795 "port config all max-lro-pkt-size (value)\n" 796 " Set the max LRO aggregated packet size.\n\n" 797 798 "port config all drop-en (on|off)\n" 799 " Enable or disable packet drop on all RX queues of all ports when no " 800 "receive buffers available.\n\n" 801 802 "port config all rss (all|default|ip|tcp|udp|sctp|" 803 "ether|port|vxlan|geneve|nvgre|vxlan-gpe|none|level-default|" 804 "level-outer|level-inner|<flowtype_id>)\n" 805 " Set the RSS mode.\n\n" 806 807 "port config port-id rss reta (hash,queue)[,(hash,queue)]\n" 808 " Set the RSS redirection table.\n\n" 809 810 "port config (port_id) dcb vt (on|off) (traffic_class)" 811 " pfc (on|off)\n" 812 " Set the DCB mode.\n\n" 813 814 "port config all burst (value)\n" 815 " Set the number of packets per burst.\n\n" 816 817 "port config all (txpt|txht|txwt|rxpt|rxht|rxwt)" 818 " (value)\n" 819 " Set the ring prefetch/host/writeback threshold" 820 " for tx/rx queue.\n\n" 821 822 "port config all (txfreet|txrst|rxfreet) (value)\n" 823 " Set free threshold for rx/tx, or set" 824 " tx rs bit threshold.\n\n" 825 "port config mtu X value\n" 826 " Set the MTU of port X to a given value\n\n" 827 828 "port config (port_id) (rxq|txq) (queue_id) ring_size (value)\n" 829 " Set a rx/tx queue's ring size configuration, the new" 830 " value will take effect after command that (re-)start the port" 831 " or command that setup the specific queue\n\n" 832 833 "port (port_id) (rxq|txq) (queue_id) (start|stop)\n" 834 " Start/stop a rx/tx queue of port X. Only take effect" 835 " when port X is started\n\n" 836 837 "port (port_id) (rxq|txq) (queue_id) deferred_start (on|off)\n" 838 " Switch on/off a deferred start of port X rx/tx queue. Only" 839 " take effect when port X is stopped.\n\n" 840 841 "port (port_id) (rxq|txq) (queue_id) setup\n" 842 " Setup a rx/tx queue of port X.\n\n" 843 844 "port config (port_id|all) l2-tunnel E-tag ether-type" 845 " (value)\n" 846 " Set the value of E-tag ether-type.\n\n" 847 848 "port config (port_id|all) l2-tunnel E-tag" 849 " (enable|disable)\n" 850 " Enable/disable the E-tag support.\n\n" 851 852 "port config (port_id) pctype mapping reset\n" 853 " Reset flow type to pctype mapping on a port\n\n" 854 855 "port config (port_id) pctype mapping update" 856 " (pctype_id_0[,pctype_id_1]*) (flow_type_id)\n" 857 " Update a flow type to pctype mapping item on a port\n\n" 858 859 "port config (port_id) pctype (pctype_id) hash_inset|" 860 "fdir_inset|fdir_flx_inset get|set|clear field\n" 861 " (field_idx)\n" 862 " Configure RSS|FDIR|FDIR_FLX input set for some pctype\n\n" 863 864 "port config (port_id) pctype (pctype_id) hash_inset|" 865 "fdir_inset|fdir_flx_inset clear all" 866 " Clear RSS|FDIR|FDIR_FLX input set completely for some pctype\n\n" 867 868 "port config (port_id) udp_tunnel_port add|rm vxlan|geneve (udp_port)\n\n" 869 " Add/remove UDP tunnel port for tunneling offload\n\n" 870 871 "port config <port_id> rx_offload vlan_strip|" 872 "ipv4_cksum|udp_cksum|tcp_cksum|tcp_lro|qinq_strip|" 873 "outer_ipv4_cksum|macsec_strip|header_split|" 874 "vlan_filter|vlan_extend|jumbo_frame|" 875 "scatter|timestamp|security|keep_crc on|off\n" 876 " Enable or disable a per port Rx offloading" 877 " on all Rx queues of a port\n\n" 878 879 "port (port_id) rxq (queue_id) rx_offload vlan_strip|" 880 "ipv4_cksum|udp_cksum|tcp_cksum|tcp_lro|qinq_strip|" 881 "outer_ipv4_cksum|macsec_strip|header_split|" 882 "vlan_filter|vlan_extend|jumbo_frame|" 883 "scatter|timestamp|security|keep_crc on|off\n" 884 " Enable or disable a per queue Rx offloading" 885 " only on a specific Rx queue\n\n" 886 887 "port config (port_id) tx_offload vlan_insert|" 888 "ipv4_cksum|udp_cksum|tcp_cksum|sctp_cksum|tcp_tso|" 889 "udp_tso|outer_ipv4_cksum|qinq_insert|vxlan_tnl_tso|" 890 "gre_tnl_tso|ipip_tnl_tso|geneve_tnl_tso|" 891 "macsec_insert|mt_lockfree|multi_segs|mbuf_fast_free|" 892 "security on|off\n" 893 " Enable or disable a per port Tx offloading" 894 " on all Tx queues of a port\n\n" 895 896 "port (port_id) txq (queue_id) tx_offload vlan_insert|" 897 "ipv4_cksum|udp_cksum|tcp_cksum|sctp_cksum|tcp_tso|" 898 "udp_tso|outer_ipv4_cksum|qinq_insert|vxlan_tnl_tso|" 899 "gre_tnl_tso|ipip_tnl_tso|geneve_tnl_tso|macsec_insert" 900 "|mt_lockfree|multi_segs|mbuf_fast_free|security" 901 " on|off\n" 902 " Enable or disable a per queue Tx offloading" 903 " only on a specific Tx queue\n\n" 904 905 "bpf-load rx|tx (port) (queue) (J|M|B) (file_name)\n" 906 " Load an eBPF program as a callback" 907 " for particular RX/TX queue\n\n" 908 909 "bpf-unload rx|tx (port) (queue)\n" 910 " Unload previously loaded eBPF program" 911 " for particular RX/TX queue\n\n" 912 913 "port config (port_id) tx_metadata (value)\n" 914 " Set Tx metadata value per port. Testpmd will add this value" 915 " to any Tx packet sent from this port\n\n" 916 917 "port config (port_id) dynf (name) set|clear\n" 918 " Register a dynf and Set/clear this flag on Tx. " 919 "Testpmd will set this value to any Tx packet " 920 "sent from this port\n\n" 921 ); 922 } 923 924 if (show_all || !strcmp(res->section, "registers")) { 925 926 cmdline_printf( 927 cl, 928 "\n" 929 "Registers:\n" 930 "----------\n\n" 931 932 "read reg (port_id) (address)\n" 933 " Display value of a port register.\n\n" 934 935 "read regfield (port_id) (address) (bit_x) (bit_y)\n" 936 " Display a port register bit field.\n\n" 937 938 "read regbit (port_id) (address) (bit_x)\n" 939 " Display a single port register bit.\n\n" 940 941 "write reg (port_id) (address) (value)\n" 942 " Set value of a port register.\n\n" 943 944 "write regfield (port_id) (address) (bit_x) (bit_y)" 945 " (value)\n" 946 " Set bit field of a port register.\n\n" 947 948 "write regbit (port_id) (address) (bit_x) (value)\n" 949 " Set single bit value of a port register.\n\n" 950 ); 951 } 952 if (show_all || !strcmp(res->section, "filters")) { 953 954 cmdline_printf( 955 cl, 956 "\n" 957 "filters:\n" 958 "--------\n\n" 959 960 "ethertype_filter (port_id) (add|del)" 961 " (mac_addr|mac_ignr) (mac_address) ethertype" 962 " (ether_type) (drop|fwd) queue (queue_id)\n" 963 " Add/Del an ethertype filter.\n\n" 964 965 "2tuple_filter (port_id) (add|del)" 966 " dst_port (dst_port_value) protocol (protocol_value)" 967 " mask (mask_value) tcp_flags (tcp_flags_value)" 968 " priority (prio_value) queue (queue_id)\n" 969 " Add/Del a 2tuple filter.\n\n" 970 971 "5tuple_filter (port_id) (add|del)" 972 " dst_ip (dst_address) src_ip (src_address)" 973 " dst_port (dst_port_value) src_port (src_port_value)" 974 " protocol (protocol_value)" 975 " mask (mask_value) tcp_flags (tcp_flags_value)" 976 " priority (prio_value) queue (queue_id)\n" 977 " Add/Del a 5tuple filter.\n\n" 978 979 "syn_filter (port_id) (add|del) priority (high|low) queue (queue_id)" 980 " Add/Del syn filter.\n\n" 981 982 "flex_filter (port_id) (add|del) len (len_value)" 983 " bytes (bytes_value) mask (mask_value)" 984 " priority (prio_value) queue (queue_id)\n" 985 " Add/Del a flex filter.\n\n" 986 987 "flow_director_filter (port_id) mode IP (add|del|update)" 988 " flow (ipv4-other|ipv4-frag|ipv6-other|ipv6-frag)" 989 " src (src_ip_address) dst (dst_ip_address)" 990 " tos (tos_value) proto (proto_value) ttl (ttl_value)" 991 " vlan (vlan_value) flexbytes (flexbytes_value)" 992 " (drop|fwd) pf|vf(vf_id) queue (queue_id)" 993 " fd_id (fd_id_value)\n" 994 " Add/Del an IP type flow director filter.\n\n" 995 996 "flow_director_filter (port_id) mode IP (add|del|update)" 997 " flow (ipv4-tcp|ipv4-udp|ipv6-tcp|ipv6-udp)" 998 " src (src_ip_address) (src_port)" 999 " dst (dst_ip_address) (dst_port)" 1000 " tos (tos_value) ttl (ttl_value)" 1001 " vlan (vlan_value) flexbytes (flexbytes_value)" 1002 " (drop|fwd) pf|vf(vf_id) queue (queue_id)" 1003 " fd_id (fd_id_value)\n" 1004 " Add/Del an UDP/TCP type flow director filter.\n\n" 1005 1006 "flow_director_filter (port_id) mode IP (add|del|update)" 1007 " flow (ipv4-sctp|ipv6-sctp)" 1008 " src (src_ip_address) (src_port)" 1009 " dst (dst_ip_address) (dst_port)" 1010 " tag (verification_tag) " 1011 " tos (tos_value) ttl (ttl_value)" 1012 " vlan (vlan_value)" 1013 " flexbytes (flexbytes_value) (drop|fwd)" 1014 " pf|vf(vf_id) queue (queue_id) fd_id (fd_id_value)\n" 1015 " Add/Del a SCTP type flow director filter.\n\n" 1016 1017 "flow_director_filter (port_id) mode IP (add|del|update)" 1018 " flow l2_payload ether (ethertype)" 1019 " flexbytes (flexbytes_value) (drop|fwd)" 1020 " pf|vf(vf_id) queue (queue_id) fd_id (fd_id_value)\n" 1021 " Add/Del a l2 payload type flow director filter.\n\n" 1022 1023 "flow_director_filter (port_id) mode MAC-VLAN (add|del|update)" 1024 " mac (mac_address) vlan (vlan_value)" 1025 " flexbytes (flexbytes_value) (drop|fwd)" 1026 " queue (queue_id) fd_id (fd_id_value)\n" 1027 " Add/Del a MAC-VLAN flow director filter.\n\n" 1028 1029 "flow_director_filter (port_id) mode Tunnel (add|del|update)" 1030 " mac (mac_address) vlan (vlan_value)" 1031 " tunnel (NVGRE|VxLAN) tunnel-id (tunnel_id_value)" 1032 " flexbytes (flexbytes_value) (drop|fwd)" 1033 " queue (queue_id) fd_id (fd_id_value)\n" 1034 " Add/Del a Tunnel flow director filter.\n\n" 1035 1036 "flow_director_filter (port_id) mode raw (add|del|update)" 1037 " flow (flow_id) (drop|fwd) queue (queue_id)" 1038 " fd_id (fd_id_value) packet (packet file name)\n" 1039 " Add/Del a raw type flow director filter.\n\n" 1040 1041 "flush_flow_director (port_id)\n" 1042 " Flush all flow director entries of a device.\n\n" 1043 1044 "flow_director_mask (port_id) mode IP vlan (vlan_value)" 1045 " src_mask (ipv4_src) (ipv6_src) (src_port)" 1046 " dst_mask (ipv4_dst) (ipv6_dst) (dst_port)\n" 1047 " Set flow director IP mask.\n\n" 1048 1049 "flow_director_mask (port_id) mode MAC-VLAN" 1050 " vlan (vlan_value)\n" 1051 " Set flow director MAC-VLAN mask.\n\n" 1052 1053 "flow_director_mask (port_id) mode Tunnel" 1054 " vlan (vlan_value) mac (mac_value)" 1055 " tunnel-type (tunnel_type_value)" 1056 " tunnel-id (tunnel_id_value)\n" 1057 " Set flow director Tunnel mask.\n\n" 1058 1059 "flow_director_flex_mask (port_id)" 1060 " flow (none|ipv4-other|ipv4-frag|ipv4-tcp|ipv4-udp|ipv4-sctp|" 1061 "ipv6-other|ipv6-frag|ipv6-tcp|ipv6-udp|ipv6-sctp|l2_payload|all)" 1062 " (mask)\n" 1063 " Configure mask of flex payload.\n\n" 1064 1065 "flow_director_flex_payload (port_id)" 1066 " (raw|l2|l3|l4) (config)\n" 1067 " Configure flex payload selection.\n\n" 1068 1069 "get_sym_hash_ena_per_port (port_id)\n" 1070 " get symmetric hash enable configuration per port.\n\n" 1071 1072 "set_sym_hash_ena_per_port (port_id) (enable|disable)\n" 1073 " set symmetric hash enable configuration per port" 1074 " to enable or disable.\n\n" 1075 1076 "get_hash_global_config (port_id)\n" 1077 " Get the global configurations of hash filters.\n\n" 1078 1079 "set_hash_global_config (port_id) (toeplitz|simple_xor|symmetric_toeplitz|default)" 1080 " (ipv4|ipv4-frag|ipv4-tcp|ipv4-udp|ipv4-sctp|ipv4-other|ipv6|" 1081 "ipv6-frag|ipv6-tcp|ipv6-udp|ipv6-sctp|ipv6-other|l2_payload)" 1082 " (enable|disable)\n" 1083 " Set the global configurations of hash filters.\n\n" 1084 1085 "set_hash_input_set (port_id) (ipv4|ipv4-frag|" 1086 "ipv4-tcp|ipv4-udp|ipv4-sctp|ipv4-other|ipv6|" 1087 "ipv6-frag|ipv6-tcp|ipv6-udp|ipv6-sctp|ipv6-other|" 1088 "l2_payload|<flowtype_id>) (ovlan|ivlan|src-ipv4|dst-ipv4|" 1089 "src-ipv6|dst-ipv6|ipv4-tos|ipv4-proto|ipv6-tc|" 1090 "ipv6-next-header|udp-src-port|udp-dst-port|" 1091 "tcp-src-port|tcp-dst-port|sctp-src-port|" 1092 "sctp-dst-port|sctp-veri-tag|udp-key|gre-key|fld-1st|" 1093 "fld-2nd|fld-3rd|fld-4th|fld-5th|fld-6th|fld-7th|" 1094 "fld-8th|none) (select|add)\n" 1095 " Set the input set for hash.\n\n" 1096 1097 "set_fdir_input_set (port_id) " 1098 "(ipv4-frag|ipv4-tcp|ipv4-udp|ipv4-sctp|ipv4-other|" 1099 "ipv6-frag|ipv6-tcp|ipv6-udp|ipv6-sctp|ipv6-other|" 1100 "l2_payload) (ivlan|ethertype|src-ipv4|dst-ipv4|src-ipv6|" 1101 "dst-ipv6|ipv4-tos|ipv4-proto|ipv4-ttl|ipv6-tc|" 1102 "ipv6-next-header|ipv6-hop-limits|udp-src-port|" 1103 "udp-dst-port|tcp-src-port|tcp-dst-port|" 1104 "sctp-src-port|sctp-dst-port|sctp-veri-tag|none)" 1105 " (select|add)\n" 1106 " Set the input set for FDir.\n\n" 1107 1108 "flow validate {port_id}" 1109 " [group {group_id}] [priority {level}]" 1110 " [ingress] [egress]" 1111 " pattern {item} [/ {item} [...]] / end" 1112 " actions {action} [/ {action} [...]] / end\n" 1113 " Check whether a flow rule can be created.\n\n" 1114 1115 "flow create {port_id}" 1116 " [group {group_id}] [priority {level}]" 1117 " [ingress] [egress]" 1118 " pattern {item} [/ {item} [...]] / end" 1119 " actions {action} [/ {action} [...]] / end\n" 1120 " Create a flow rule.\n\n" 1121 1122 "flow destroy {port_id} rule {rule_id} [...]\n" 1123 " Destroy specific flow rules.\n\n" 1124 1125 "flow flush {port_id}\n" 1126 " Destroy all flow rules.\n\n" 1127 1128 "flow query {port_id} {rule_id} {action}\n" 1129 " Query an existing flow rule.\n\n" 1130 1131 "flow list {port_id} [group {group_id}] [...]\n" 1132 " List existing flow rules sorted by priority," 1133 " filtered by group identifiers.\n\n" 1134 1135 "flow isolate {port_id} {boolean}\n" 1136 " Restrict ingress traffic to the defined" 1137 " flow rules\n\n" 1138 1139 "flow aged {port_id} [destroy]\n" 1140 " List and destroy aged flows" 1141 " flow rules\n\n" 1142 1143 "set vxlan ip-version (ipv4|ipv6) vni (vni) udp-src" 1144 " (udp-src) udp-dst (udp-dst) ip-src (ip-src) ip-dst" 1145 " (ip-dst) eth-src (eth-src) eth-dst (eth-dst)\n" 1146 " Configure the VXLAN encapsulation for flows.\n\n" 1147 1148 "set vxlan-with-vlan ip-version (ipv4|ipv6) vni (vni)" 1149 " udp-src (udp-src) udp-dst (udp-dst) ip-src (ip-src)" 1150 " ip-dst (ip-dst) vlan-tci (vlan-tci) eth-src (eth-src)" 1151 " eth-dst (eth-dst)\n" 1152 " Configure the VXLAN encapsulation for flows.\n\n" 1153 1154 "set vxlan-tos-ttl ip-version (ipv4|ipv6) vni (vni) udp-src" 1155 " (udp-src) udp-dst (udp-dst) ip-tos (ip-tos) ip-ttl (ip-ttl)" 1156 " ip-src (ip-src) ip-dst (ip-dst) eth-src (eth-src)" 1157 " eth-dst (eth-dst)\n" 1158 " Configure the VXLAN encapsulation for flows.\n\n" 1159 1160 "set nvgre ip-version (ipv4|ipv6) tni (tni) ip-src" 1161 " (ip-src) ip-dst (ip-dst) eth-src (eth-src) eth-dst" 1162 " (eth-dst)\n" 1163 " Configure the NVGRE encapsulation for flows.\n\n" 1164 1165 "set nvgre-with-vlan ip-version (ipv4|ipv6) tni (tni)" 1166 " ip-src (ip-src) ip-dst (ip-dst) vlan-tci (vlan-tci)" 1167 " eth-src (eth-src) eth-dst (eth-dst)\n" 1168 " Configure the NVGRE encapsulation for flows.\n\n" 1169 1170 "set raw_encap {flow items}\n" 1171 " Configure the encapsulation with raw data.\n\n" 1172 1173 "set raw_decap {flow items}\n" 1174 " Configure the decapsulation with raw data.\n\n" 1175 1176 ); 1177 } 1178 1179 if (show_all || !strcmp(res->section, "traffic_management")) { 1180 cmdline_printf( 1181 cl, 1182 "\n" 1183 "Traffic Management:\n" 1184 "--------------\n" 1185 "show port tm cap (port_id)\n" 1186 " Display the port TM capability.\n\n" 1187 1188 "show port tm level cap (port_id) (level_id)\n" 1189 " Display the port TM hierarchical level capability.\n\n" 1190 1191 "show port tm node cap (port_id) (node_id)\n" 1192 " Display the port TM node capability.\n\n" 1193 1194 "show port tm node type (port_id) (node_id)\n" 1195 " Display the port TM node type.\n\n" 1196 1197 "show port tm node stats (port_id) (node_id) (clear)\n" 1198 " Display the port TM node stats.\n\n" 1199 1200 "add port tm node shaper profile (port_id) (shaper_profile_id)" 1201 " (cmit_tb_rate) (cmit_tb_size) (peak_tb_rate) (peak_tb_size)" 1202 " (packet_length_adjust) (packet_mode)\n" 1203 " Add port tm node private shaper profile.\n\n" 1204 1205 "del port tm node shaper profile (port_id) (shaper_profile_id)\n" 1206 " Delete port tm node private shaper profile.\n\n" 1207 1208 "add port tm node shared shaper (port_id) (shared_shaper_id)" 1209 " (shaper_profile_id)\n" 1210 " Add/update port tm node shared shaper.\n\n" 1211 1212 "del port tm node shared shaper (port_id) (shared_shaper_id)\n" 1213 " Delete port tm node shared shaper.\n\n" 1214 1215 "set port tm node shaper profile (port_id) (node_id)" 1216 " (shaper_profile_id)\n" 1217 " Set port tm node shaper profile.\n\n" 1218 1219 "add port tm node wred profile (port_id) (wred_profile_id)" 1220 " (color_g) (min_th_g) (max_th_g) (maxp_inv_g) (wq_log2_g)" 1221 " (color_y) (min_th_y) (max_th_y) (maxp_inv_y) (wq_log2_y)" 1222 " (color_r) (min_th_r) (max_th_r) (maxp_inv_r) (wq_log2_r)\n" 1223 " Add port tm node wred profile.\n\n" 1224 1225 "del port tm node wred profile (port_id) (wred_profile_id)\n" 1226 " Delete port tm node wred profile.\n\n" 1227 1228 "add port tm nonleaf node (port_id) (node_id) (parent_node_id)" 1229 " (priority) (weight) (level_id) (shaper_profile_id)" 1230 " (n_sp_priorities) (stats_mask) (n_shared_shapers)" 1231 " [(shared_shaper_id_0) (shared_shaper_id_1)...]\n" 1232 " Add port tm nonleaf node.\n\n" 1233 1234 "add port tm nonleaf node pktmode (port_id) (node_id) (parent_node_id)" 1235 " (priority) (weight) (level_id) (shaper_profile_id)" 1236 " (n_sp_priorities) (stats_mask) (n_shared_shapers)" 1237 " [(shared_shaper_id_0) (shared_shaper_id_1)...]\n" 1238 " Add port tm nonleaf node with pkt mode enabled.\n\n" 1239 1240 "add port tm leaf node (port_id) (node_id) (parent_node_id)" 1241 " (priority) (weight) (level_id) (shaper_profile_id)" 1242 " (cman_mode) (wred_profile_id) (stats_mask) (n_shared_shapers)" 1243 " [(shared_shaper_id_0) (shared_shaper_id_1)...]\n" 1244 " Add port tm leaf node.\n\n" 1245 1246 "del port tm node (port_id) (node_id)\n" 1247 " Delete port tm node.\n\n" 1248 1249 "set port tm node parent (port_id) (node_id) (parent_node_id)" 1250 " (priority) (weight)\n" 1251 " Set port tm node parent.\n\n" 1252 1253 "suspend port tm node (port_id) (node_id)" 1254 " Suspend tm node.\n\n" 1255 1256 "resume port tm node (port_id) (node_id)" 1257 " Resume tm node.\n\n" 1258 1259 "port tm hierarchy commit (port_id) (clean_on_fail)\n" 1260 " Commit tm hierarchy.\n\n" 1261 1262 "set port tm mark ip_ecn (port) (green) (yellow)" 1263 " (red)\n" 1264 " Enables/Disables the traffic management marking" 1265 " for IP ECN (Explicit Congestion Notification)" 1266 " packets on a given port\n\n" 1267 1268 "set port tm mark ip_dscp (port) (green) (yellow)" 1269 " (red)\n" 1270 " Enables/Disables the traffic management marking" 1271 " on the port for IP dscp packets\n\n" 1272 1273 "set port tm mark vlan_dei (port) (green) (yellow)" 1274 " (red)\n" 1275 " Enables/Disables the traffic management marking" 1276 " on the port for VLAN packets with DEI enabled\n\n" 1277 ); 1278 } 1279 1280 if (show_all || !strcmp(res->section, "devices")) { 1281 cmdline_printf( 1282 cl, 1283 "\n" 1284 "Device Operations:\n" 1285 "--------------\n" 1286 "device detach (identifier)\n" 1287 " Detach device by identifier.\n\n" 1288 ); 1289 } 1290 1291 } 1292 1293 cmdline_parse_token_string_t cmd_help_long_help = 1294 TOKEN_STRING_INITIALIZER(struct cmd_help_long_result, help, "help"); 1295 1296 cmdline_parse_token_string_t cmd_help_long_section = 1297 TOKEN_STRING_INITIALIZER(struct cmd_help_long_result, section, 1298 "all#control#display#config#" 1299 "ports#registers#filters#traffic_management#devices"); 1300 1301 cmdline_parse_inst_t cmd_help_long = { 1302 .f = cmd_help_long_parsed, 1303 .data = NULL, 1304 .help_str = "help all|control|display|config|ports|register|" 1305 "filters|traffic_management|devices: " 1306 "Show help", 1307 .tokens = { 1308 (void *)&cmd_help_long_help, 1309 (void *)&cmd_help_long_section, 1310 NULL, 1311 }, 1312 }; 1313 1314 1315 /* *** start/stop/close all ports *** */ 1316 struct cmd_operate_port_result { 1317 cmdline_fixed_string_t keyword; 1318 cmdline_fixed_string_t name; 1319 cmdline_fixed_string_t value; 1320 }; 1321 1322 static void cmd_operate_port_parsed(void *parsed_result, 1323 __rte_unused struct cmdline *cl, 1324 __rte_unused void *data) 1325 { 1326 struct cmd_operate_port_result *res = parsed_result; 1327 1328 if (!strcmp(res->name, "start")) 1329 start_port(RTE_PORT_ALL); 1330 else if (!strcmp(res->name, "stop")) 1331 stop_port(RTE_PORT_ALL); 1332 else if (!strcmp(res->name, "close")) 1333 close_port(RTE_PORT_ALL); 1334 else if (!strcmp(res->name, "reset")) 1335 reset_port(RTE_PORT_ALL); 1336 else 1337 printf("Unknown parameter\n"); 1338 } 1339 1340 cmdline_parse_token_string_t cmd_operate_port_all_cmd = 1341 TOKEN_STRING_INITIALIZER(struct cmd_operate_port_result, keyword, 1342 "port"); 1343 cmdline_parse_token_string_t cmd_operate_port_all_port = 1344 TOKEN_STRING_INITIALIZER(struct cmd_operate_port_result, name, 1345 "start#stop#close#reset"); 1346 cmdline_parse_token_string_t cmd_operate_port_all_all = 1347 TOKEN_STRING_INITIALIZER(struct cmd_operate_port_result, value, "all"); 1348 1349 cmdline_parse_inst_t cmd_operate_port = { 1350 .f = cmd_operate_port_parsed, 1351 .data = NULL, 1352 .help_str = "port start|stop|close all: Start/Stop/Close/Reset all ports", 1353 .tokens = { 1354 (void *)&cmd_operate_port_all_cmd, 1355 (void *)&cmd_operate_port_all_port, 1356 (void *)&cmd_operate_port_all_all, 1357 NULL, 1358 }, 1359 }; 1360 1361 /* *** start/stop/close specific port *** */ 1362 struct cmd_operate_specific_port_result { 1363 cmdline_fixed_string_t keyword; 1364 cmdline_fixed_string_t name; 1365 uint8_t value; 1366 }; 1367 1368 static void cmd_operate_specific_port_parsed(void *parsed_result, 1369 __rte_unused struct cmdline *cl, 1370 __rte_unused void *data) 1371 { 1372 struct cmd_operate_specific_port_result *res = parsed_result; 1373 1374 if (!strcmp(res->name, "start")) 1375 start_port(res->value); 1376 else if (!strcmp(res->name, "stop")) 1377 stop_port(res->value); 1378 else if (!strcmp(res->name, "close")) 1379 close_port(res->value); 1380 else if (!strcmp(res->name, "reset")) 1381 reset_port(res->value); 1382 else 1383 printf("Unknown parameter\n"); 1384 } 1385 1386 cmdline_parse_token_string_t cmd_operate_specific_port_cmd = 1387 TOKEN_STRING_INITIALIZER(struct cmd_operate_specific_port_result, 1388 keyword, "port"); 1389 cmdline_parse_token_string_t cmd_operate_specific_port_port = 1390 TOKEN_STRING_INITIALIZER(struct cmd_operate_specific_port_result, 1391 name, "start#stop#close#reset"); 1392 cmdline_parse_token_num_t cmd_operate_specific_port_id = 1393 TOKEN_NUM_INITIALIZER(struct cmd_operate_specific_port_result, 1394 value, UINT8); 1395 1396 cmdline_parse_inst_t cmd_operate_specific_port = { 1397 .f = cmd_operate_specific_port_parsed, 1398 .data = NULL, 1399 .help_str = "port start|stop|close <port_id>: Start/Stop/Close/Reset port_id", 1400 .tokens = { 1401 (void *)&cmd_operate_specific_port_cmd, 1402 (void *)&cmd_operate_specific_port_port, 1403 (void *)&cmd_operate_specific_port_id, 1404 NULL, 1405 }, 1406 }; 1407 1408 /* *** enable port setup (after attach) via iterator or event *** */ 1409 struct cmd_set_port_setup_on_result { 1410 cmdline_fixed_string_t set; 1411 cmdline_fixed_string_t port; 1412 cmdline_fixed_string_t setup; 1413 cmdline_fixed_string_t on; 1414 cmdline_fixed_string_t mode; 1415 }; 1416 1417 static void cmd_set_port_setup_on_parsed(void *parsed_result, 1418 __rte_unused struct cmdline *cl, 1419 __rte_unused void *data) 1420 { 1421 struct cmd_set_port_setup_on_result *res = parsed_result; 1422 1423 if (strcmp(res->mode, "event") == 0) 1424 setup_on_probe_event = true; 1425 else if (strcmp(res->mode, "iterator") == 0) 1426 setup_on_probe_event = false; 1427 else 1428 printf("Unknown mode\n"); 1429 } 1430 1431 cmdline_parse_token_string_t cmd_set_port_setup_on_set = 1432 TOKEN_STRING_INITIALIZER(struct cmd_set_port_setup_on_result, 1433 set, "set"); 1434 cmdline_parse_token_string_t cmd_set_port_setup_on_port = 1435 TOKEN_STRING_INITIALIZER(struct cmd_set_port_setup_on_result, 1436 port, "port"); 1437 cmdline_parse_token_string_t cmd_set_port_setup_on_setup = 1438 TOKEN_STRING_INITIALIZER(struct cmd_set_port_setup_on_result, 1439 setup, "setup"); 1440 cmdline_parse_token_string_t cmd_set_port_setup_on_on = 1441 TOKEN_STRING_INITIALIZER(struct cmd_set_port_setup_on_result, 1442 on, "on"); 1443 cmdline_parse_token_string_t cmd_set_port_setup_on_mode = 1444 TOKEN_STRING_INITIALIZER(struct cmd_set_port_setup_on_result, 1445 mode, "iterator#event"); 1446 1447 cmdline_parse_inst_t cmd_set_port_setup_on = { 1448 .f = cmd_set_port_setup_on_parsed, 1449 .data = NULL, 1450 .help_str = "set port setup on iterator|event", 1451 .tokens = { 1452 (void *)&cmd_set_port_setup_on_set, 1453 (void *)&cmd_set_port_setup_on_port, 1454 (void *)&cmd_set_port_setup_on_setup, 1455 (void *)&cmd_set_port_setup_on_on, 1456 (void *)&cmd_set_port_setup_on_mode, 1457 NULL, 1458 }, 1459 }; 1460 1461 /* *** attach a specified port *** */ 1462 struct cmd_operate_attach_port_result { 1463 cmdline_fixed_string_t port; 1464 cmdline_fixed_string_t keyword; 1465 cmdline_multi_string_t identifier; 1466 }; 1467 1468 static void cmd_operate_attach_port_parsed(void *parsed_result, 1469 __rte_unused struct cmdline *cl, 1470 __rte_unused void *data) 1471 { 1472 struct cmd_operate_attach_port_result *res = parsed_result; 1473 1474 if (!strcmp(res->keyword, "attach")) 1475 attach_port(res->identifier); 1476 else 1477 printf("Unknown parameter\n"); 1478 } 1479 1480 cmdline_parse_token_string_t cmd_operate_attach_port_port = 1481 TOKEN_STRING_INITIALIZER(struct cmd_operate_attach_port_result, 1482 port, "port"); 1483 cmdline_parse_token_string_t cmd_operate_attach_port_keyword = 1484 TOKEN_STRING_INITIALIZER(struct cmd_operate_attach_port_result, 1485 keyword, "attach"); 1486 cmdline_parse_token_string_t cmd_operate_attach_port_identifier = 1487 TOKEN_STRING_INITIALIZER(struct cmd_operate_attach_port_result, 1488 identifier, TOKEN_STRING_MULTI); 1489 1490 cmdline_parse_inst_t cmd_operate_attach_port = { 1491 .f = cmd_operate_attach_port_parsed, 1492 .data = NULL, 1493 .help_str = "port attach <identifier>: " 1494 "(identifier: pci address or virtual dev name)", 1495 .tokens = { 1496 (void *)&cmd_operate_attach_port_port, 1497 (void *)&cmd_operate_attach_port_keyword, 1498 (void *)&cmd_operate_attach_port_identifier, 1499 NULL, 1500 }, 1501 }; 1502 1503 /* *** detach a specified port *** */ 1504 struct cmd_operate_detach_port_result { 1505 cmdline_fixed_string_t port; 1506 cmdline_fixed_string_t keyword; 1507 portid_t port_id; 1508 }; 1509 1510 static void cmd_operate_detach_port_parsed(void *parsed_result, 1511 __rte_unused struct cmdline *cl, 1512 __rte_unused void *data) 1513 { 1514 struct cmd_operate_detach_port_result *res = parsed_result; 1515 1516 if (!strcmp(res->keyword, "detach")) { 1517 RTE_ETH_VALID_PORTID_OR_RET(res->port_id); 1518 detach_port_device(res->port_id); 1519 } else { 1520 printf("Unknown parameter\n"); 1521 } 1522 } 1523 1524 cmdline_parse_token_string_t cmd_operate_detach_port_port = 1525 TOKEN_STRING_INITIALIZER(struct cmd_operate_detach_port_result, 1526 port, "port"); 1527 cmdline_parse_token_string_t cmd_operate_detach_port_keyword = 1528 TOKEN_STRING_INITIALIZER(struct cmd_operate_detach_port_result, 1529 keyword, "detach"); 1530 cmdline_parse_token_num_t cmd_operate_detach_port_port_id = 1531 TOKEN_NUM_INITIALIZER(struct cmd_operate_detach_port_result, 1532 port_id, UINT16); 1533 1534 cmdline_parse_inst_t cmd_operate_detach_port = { 1535 .f = cmd_operate_detach_port_parsed, 1536 .data = NULL, 1537 .help_str = "port detach <port_id>", 1538 .tokens = { 1539 (void *)&cmd_operate_detach_port_port, 1540 (void *)&cmd_operate_detach_port_keyword, 1541 (void *)&cmd_operate_detach_port_port_id, 1542 NULL, 1543 }, 1544 }; 1545 1546 /* *** detach device by identifier *** */ 1547 struct cmd_operate_detach_device_result { 1548 cmdline_fixed_string_t device; 1549 cmdline_fixed_string_t keyword; 1550 cmdline_fixed_string_t identifier; 1551 }; 1552 1553 static void cmd_operate_detach_device_parsed(void *parsed_result, 1554 __rte_unused struct cmdline *cl, 1555 __rte_unused void *data) 1556 { 1557 struct cmd_operate_detach_device_result *res = parsed_result; 1558 1559 if (!strcmp(res->keyword, "detach")) 1560 detach_devargs(res->identifier); 1561 else 1562 printf("Unknown parameter\n"); 1563 } 1564 1565 cmdline_parse_token_string_t cmd_operate_detach_device_device = 1566 TOKEN_STRING_INITIALIZER(struct cmd_operate_detach_device_result, 1567 device, "device"); 1568 cmdline_parse_token_string_t cmd_operate_detach_device_keyword = 1569 TOKEN_STRING_INITIALIZER(struct cmd_operate_detach_device_result, 1570 keyword, "detach"); 1571 cmdline_parse_token_string_t cmd_operate_detach_device_identifier = 1572 TOKEN_STRING_INITIALIZER(struct cmd_operate_detach_device_result, 1573 identifier, NULL); 1574 1575 cmdline_parse_inst_t cmd_operate_detach_device = { 1576 .f = cmd_operate_detach_device_parsed, 1577 .data = NULL, 1578 .help_str = "device detach <identifier>:" 1579 "(identifier: pci address or virtual dev name)", 1580 .tokens = { 1581 (void *)&cmd_operate_detach_device_device, 1582 (void *)&cmd_operate_detach_device_keyword, 1583 (void *)&cmd_operate_detach_device_identifier, 1584 NULL, 1585 }, 1586 }; 1587 /* *** configure speed for all ports *** */ 1588 struct cmd_config_speed_all { 1589 cmdline_fixed_string_t port; 1590 cmdline_fixed_string_t keyword; 1591 cmdline_fixed_string_t all; 1592 cmdline_fixed_string_t item1; 1593 cmdline_fixed_string_t item2; 1594 cmdline_fixed_string_t value1; 1595 cmdline_fixed_string_t value2; 1596 }; 1597 1598 static int 1599 parse_and_check_speed_duplex(char *speedstr, char *duplexstr, uint32_t *speed) 1600 { 1601 1602 int duplex; 1603 1604 if (!strcmp(duplexstr, "half")) { 1605 duplex = ETH_LINK_HALF_DUPLEX; 1606 } else if (!strcmp(duplexstr, "full")) { 1607 duplex = ETH_LINK_FULL_DUPLEX; 1608 } else if (!strcmp(duplexstr, "auto")) { 1609 duplex = ETH_LINK_FULL_DUPLEX; 1610 } else { 1611 printf("Unknown duplex parameter\n"); 1612 return -1; 1613 } 1614 1615 if (!strcmp(speedstr, "10")) { 1616 *speed = (duplex == ETH_LINK_HALF_DUPLEX) ? 1617 ETH_LINK_SPEED_10M_HD : ETH_LINK_SPEED_10M; 1618 } else if (!strcmp(speedstr, "100")) { 1619 *speed = (duplex == ETH_LINK_HALF_DUPLEX) ? 1620 ETH_LINK_SPEED_100M_HD : ETH_LINK_SPEED_100M; 1621 } else { 1622 if (duplex != ETH_LINK_FULL_DUPLEX) { 1623 printf("Invalid speed/duplex parameters\n"); 1624 return -1; 1625 } 1626 if (!strcmp(speedstr, "1000")) { 1627 *speed = ETH_LINK_SPEED_1G; 1628 } else if (!strcmp(speedstr, "10000")) { 1629 *speed = ETH_LINK_SPEED_10G; 1630 } else if (!strcmp(speedstr, "25000")) { 1631 *speed = ETH_LINK_SPEED_25G; 1632 } else if (!strcmp(speedstr, "40000")) { 1633 *speed = ETH_LINK_SPEED_40G; 1634 } else if (!strcmp(speedstr, "50000")) { 1635 *speed = ETH_LINK_SPEED_50G; 1636 } else if (!strcmp(speedstr, "100000")) { 1637 *speed = ETH_LINK_SPEED_100G; 1638 } else if (!strcmp(speedstr, "200000")) { 1639 *speed = ETH_LINK_SPEED_200G; 1640 } else if (!strcmp(speedstr, "auto")) { 1641 *speed = ETH_LINK_SPEED_AUTONEG; 1642 } else { 1643 printf("Unknown speed parameter\n"); 1644 return -1; 1645 } 1646 } 1647 1648 return 0; 1649 } 1650 1651 static void 1652 cmd_config_speed_all_parsed(void *parsed_result, 1653 __rte_unused struct cmdline *cl, 1654 __rte_unused void *data) 1655 { 1656 struct cmd_config_speed_all *res = parsed_result; 1657 uint32_t link_speed; 1658 portid_t pid; 1659 1660 if (!all_ports_stopped()) { 1661 printf("Please stop all ports first\n"); 1662 return; 1663 } 1664 1665 if (parse_and_check_speed_duplex(res->value1, res->value2, 1666 &link_speed) < 0) 1667 return; 1668 1669 RTE_ETH_FOREACH_DEV(pid) { 1670 ports[pid].dev_conf.link_speeds = link_speed; 1671 } 1672 1673 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1); 1674 } 1675 1676 cmdline_parse_token_string_t cmd_config_speed_all_port = 1677 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_all, port, "port"); 1678 cmdline_parse_token_string_t cmd_config_speed_all_keyword = 1679 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_all, keyword, 1680 "config"); 1681 cmdline_parse_token_string_t cmd_config_speed_all_all = 1682 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_all, all, "all"); 1683 cmdline_parse_token_string_t cmd_config_speed_all_item1 = 1684 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_all, item1, "speed"); 1685 cmdline_parse_token_string_t cmd_config_speed_all_value1 = 1686 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_all, value1, 1687 "10#100#1000#10000#25000#40000#50000#100000#200000#auto"); 1688 cmdline_parse_token_string_t cmd_config_speed_all_item2 = 1689 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_all, item2, "duplex"); 1690 cmdline_parse_token_string_t cmd_config_speed_all_value2 = 1691 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_all, value2, 1692 "half#full#auto"); 1693 1694 cmdline_parse_inst_t cmd_config_speed_all = { 1695 .f = cmd_config_speed_all_parsed, 1696 .data = NULL, 1697 .help_str = "port config all speed " 1698 "10|100|1000|10000|25000|40000|50000|100000|200000|auto duplex " 1699 "half|full|auto", 1700 .tokens = { 1701 (void *)&cmd_config_speed_all_port, 1702 (void *)&cmd_config_speed_all_keyword, 1703 (void *)&cmd_config_speed_all_all, 1704 (void *)&cmd_config_speed_all_item1, 1705 (void *)&cmd_config_speed_all_value1, 1706 (void *)&cmd_config_speed_all_item2, 1707 (void *)&cmd_config_speed_all_value2, 1708 NULL, 1709 }, 1710 }; 1711 1712 /* *** configure speed for specific port *** */ 1713 struct cmd_config_speed_specific { 1714 cmdline_fixed_string_t port; 1715 cmdline_fixed_string_t keyword; 1716 portid_t id; 1717 cmdline_fixed_string_t item1; 1718 cmdline_fixed_string_t item2; 1719 cmdline_fixed_string_t value1; 1720 cmdline_fixed_string_t value2; 1721 }; 1722 1723 static void 1724 cmd_config_speed_specific_parsed(void *parsed_result, 1725 __rte_unused struct cmdline *cl, 1726 __rte_unused void *data) 1727 { 1728 struct cmd_config_speed_specific *res = parsed_result; 1729 uint32_t link_speed; 1730 1731 if (!all_ports_stopped()) { 1732 printf("Please stop all ports first\n"); 1733 return; 1734 } 1735 1736 if (port_id_is_invalid(res->id, ENABLED_WARN)) 1737 return; 1738 1739 if (parse_and_check_speed_duplex(res->value1, res->value2, 1740 &link_speed) < 0) 1741 return; 1742 1743 ports[res->id].dev_conf.link_speeds = link_speed; 1744 1745 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1); 1746 } 1747 1748 1749 cmdline_parse_token_string_t cmd_config_speed_specific_port = 1750 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_specific, port, 1751 "port"); 1752 cmdline_parse_token_string_t cmd_config_speed_specific_keyword = 1753 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_specific, keyword, 1754 "config"); 1755 cmdline_parse_token_num_t cmd_config_speed_specific_id = 1756 TOKEN_NUM_INITIALIZER(struct cmd_config_speed_specific, id, UINT16); 1757 cmdline_parse_token_string_t cmd_config_speed_specific_item1 = 1758 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_specific, item1, 1759 "speed"); 1760 cmdline_parse_token_string_t cmd_config_speed_specific_value1 = 1761 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_specific, value1, 1762 "10#100#1000#10000#25000#40000#50000#100000#200000#auto"); 1763 cmdline_parse_token_string_t cmd_config_speed_specific_item2 = 1764 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_specific, item2, 1765 "duplex"); 1766 cmdline_parse_token_string_t cmd_config_speed_specific_value2 = 1767 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_specific, value2, 1768 "half#full#auto"); 1769 1770 cmdline_parse_inst_t cmd_config_speed_specific = { 1771 .f = cmd_config_speed_specific_parsed, 1772 .data = NULL, 1773 .help_str = "port config <port_id> speed " 1774 "10|100|1000|10000|25000|40000|50000|100000|200000|auto duplex " 1775 "half|full|auto", 1776 .tokens = { 1777 (void *)&cmd_config_speed_specific_port, 1778 (void *)&cmd_config_speed_specific_keyword, 1779 (void *)&cmd_config_speed_specific_id, 1780 (void *)&cmd_config_speed_specific_item1, 1781 (void *)&cmd_config_speed_specific_value1, 1782 (void *)&cmd_config_speed_specific_item2, 1783 (void *)&cmd_config_speed_specific_value2, 1784 NULL, 1785 }, 1786 }; 1787 1788 /* *** configure loopback for all ports *** */ 1789 struct cmd_config_loopback_all { 1790 cmdline_fixed_string_t port; 1791 cmdline_fixed_string_t keyword; 1792 cmdline_fixed_string_t all; 1793 cmdline_fixed_string_t item; 1794 uint32_t mode; 1795 }; 1796 1797 static void 1798 cmd_config_loopback_all_parsed(void *parsed_result, 1799 __rte_unused struct cmdline *cl, 1800 __rte_unused void *data) 1801 { 1802 struct cmd_config_loopback_all *res = parsed_result; 1803 portid_t pid; 1804 1805 if (!all_ports_stopped()) { 1806 printf("Please stop all ports first\n"); 1807 return; 1808 } 1809 1810 RTE_ETH_FOREACH_DEV(pid) { 1811 ports[pid].dev_conf.lpbk_mode = res->mode; 1812 } 1813 1814 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1); 1815 } 1816 1817 cmdline_parse_token_string_t cmd_config_loopback_all_port = 1818 TOKEN_STRING_INITIALIZER(struct cmd_config_loopback_all, port, "port"); 1819 cmdline_parse_token_string_t cmd_config_loopback_all_keyword = 1820 TOKEN_STRING_INITIALIZER(struct cmd_config_loopback_all, keyword, 1821 "config"); 1822 cmdline_parse_token_string_t cmd_config_loopback_all_all = 1823 TOKEN_STRING_INITIALIZER(struct cmd_config_loopback_all, all, "all"); 1824 cmdline_parse_token_string_t cmd_config_loopback_all_item = 1825 TOKEN_STRING_INITIALIZER(struct cmd_config_loopback_all, item, 1826 "loopback"); 1827 cmdline_parse_token_num_t cmd_config_loopback_all_mode = 1828 TOKEN_NUM_INITIALIZER(struct cmd_config_loopback_all, mode, UINT32); 1829 1830 cmdline_parse_inst_t cmd_config_loopback_all = { 1831 .f = cmd_config_loopback_all_parsed, 1832 .data = NULL, 1833 .help_str = "port config all loopback <mode>", 1834 .tokens = { 1835 (void *)&cmd_config_loopback_all_port, 1836 (void *)&cmd_config_loopback_all_keyword, 1837 (void *)&cmd_config_loopback_all_all, 1838 (void *)&cmd_config_loopback_all_item, 1839 (void *)&cmd_config_loopback_all_mode, 1840 NULL, 1841 }, 1842 }; 1843 1844 /* *** configure loopback for specific port *** */ 1845 struct cmd_config_loopback_specific { 1846 cmdline_fixed_string_t port; 1847 cmdline_fixed_string_t keyword; 1848 uint16_t port_id; 1849 cmdline_fixed_string_t item; 1850 uint32_t mode; 1851 }; 1852 1853 static void 1854 cmd_config_loopback_specific_parsed(void *parsed_result, 1855 __rte_unused struct cmdline *cl, 1856 __rte_unused void *data) 1857 { 1858 struct cmd_config_loopback_specific *res = parsed_result; 1859 1860 if (port_id_is_invalid(res->port_id, ENABLED_WARN)) 1861 return; 1862 1863 if (!port_is_stopped(res->port_id)) { 1864 printf("Please stop port %u first\n", res->port_id); 1865 return; 1866 } 1867 1868 ports[res->port_id].dev_conf.lpbk_mode = res->mode; 1869 1870 cmd_reconfig_device_queue(res->port_id, 1, 1); 1871 } 1872 1873 1874 cmdline_parse_token_string_t cmd_config_loopback_specific_port = 1875 TOKEN_STRING_INITIALIZER(struct cmd_config_loopback_specific, port, 1876 "port"); 1877 cmdline_parse_token_string_t cmd_config_loopback_specific_keyword = 1878 TOKEN_STRING_INITIALIZER(struct cmd_config_loopback_specific, keyword, 1879 "config"); 1880 cmdline_parse_token_num_t cmd_config_loopback_specific_id = 1881 TOKEN_NUM_INITIALIZER(struct cmd_config_loopback_specific, port_id, 1882 UINT16); 1883 cmdline_parse_token_string_t cmd_config_loopback_specific_item = 1884 TOKEN_STRING_INITIALIZER(struct cmd_config_loopback_specific, item, 1885 "loopback"); 1886 cmdline_parse_token_num_t cmd_config_loopback_specific_mode = 1887 TOKEN_NUM_INITIALIZER(struct cmd_config_loopback_specific, mode, 1888 UINT32); 1889 1890 cmdline_parse_inst_t cmd_config_loopback_specific = { 1891 .f = cmd_config_loopback_specific_parsed, 1892 .data = NULL, 1893 .help_str = "port config <port_id> loopback <mode>", 1894 .tokens = { 1895 (void *)&cmd_config_loopback_specific_port, 1896 (void *)&cmd_config_loopback_specific_keyword, 1897 (void *)&cmd_config_loopback_specific_id, 1898 (void *)&cmd_config_loopback_specific_item, 1899 (void *)&cmd_config_loopback_specific_mode, 1900 NULL, 1901 }, 1902 }; 1903 1904 /* *** configure txq/rxq, txd/rxd *** */ 1905 struct cmd_config_rx_tx { 1906 cmdline_fixed_string_t port; 1907 cmdline_fixed_string_t keyword; 1908 cmdline_fixed_string_t all; 1909 cmdline_fixed_string_t name; 1910 uint16_t value; 1911 }; 1912 1913 static void 1914 cmd_config_rx_tx_parsed(void *parsed_result, 1915 __rte_unused struct cmdline *cl, 1916 __rte_unused void *data) 1917 { 1918 struct cmd_config_rx_tx *res = parsed_result; 1919 1920 if (!all_ports_stopped()) { 1921 printf("Please stop all ports first\n"); 1922 return; 1923 } 1924 if (!strcmp(res->name, "rxq")) { 1925 if (!res->value && !nb_txq) { 1926 printf("Warning: Either rx or tx queues should be non zero\n"); 1927 return; 1928 } 1929 if (check_nb_rxq(res->value) != 0) 1930 return; 1931 nb_rxq = res->value; 1932 } 1933 else if (!strcmp(res->name, "txq")) { 1934 if (!res->value && !nb_rxq) { 1935 printf("Warning: Either rx or tx queues should be non zero\n"); 1936 return; 1937 } 1938 if (check_nb_txq(res->value) != 0) 1939 return; 1940 nb_txq = res->value; 1941 } 1942 else if (!strcmp(res->name, "rxd")) { 1943 if (check_nb_rxd(res->value) != 0) 1944 return; 1945 nb_rxd = res->value; 1946 } else if (!strcmp(res->name, "txd")) { 1947 if (check_nb_txd(res->value) != 0) 1948 return; 1949 1950 nb_txd = res->value; 1951 } else { 1952 printf("Unknown parameter\n"); 1953 return; 1954 } 1955 1956 fwd_config_setup(); 1957 1958 init_port_config(); 1959 1960 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1); 1961 } 1962 1963 cmdline_parse_token_string_t cmd_config_rx_tx_port = 1964 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_tx, port, "port"); 1965 cmdline_parse_token_string_t cmd_config_rx_tx_keyword = 1966 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_tx, keyword, "config"); 1967 cmdline_parse_token_string_t cmd_config_rx_tx_all = 1968 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_tx, all, "all"); 1969 cmdline_parse_token_string_t cmd_config_rx_tx_name = 1970 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_tx, name, 1971 "rxq#txq#rxd#txd"); 1972 cmdline_parse_token_num_t cmd_config_rx_tx_value = 1973 TOKEN_NUM_INITIALIZER(struct cmd_config_rx_tx, value, UINT16); 1974 1975 cmdline_parse_inst_t cmd_config_rx_tx = { 1976 .f = cmd_config_rx_tx_parsed, 1977 .data = NULL, 1978 .help_str = "port config all rxq|txq|rxd|txd <value>", 1979 .tokens = { 1980 (void *)&cmd_config_rx_tx_port, 1981 (void *)&cmd_config_rx_tx_keyword, 1982 (void *)&cmd_config_rx_tx_all, 1983 (void *)&cmd_config_rx_tx_name, 1984 (void *)&cmd_config_rx_tx_value, 1985 NULL, 1986 }, 1987 }; 1988 1989 /* *** config max packet length *** */ 1990 struct cmd_config_max_pkt_len_result { 1991 cmdline_fixed_string_t port; 1992 cmdline_fixed_string_t keyword; 1993 cmdline_fixed_string_t all; 1994 cmdline_fixed_string_t name; 1995 uint32_t value; 1996 }; 1997 1998 static void 1999 cmd_config_max_pkt_len_parsed(void *parsed_result, 2000 __rte_unused struct cmdline *cl, 2001 __rte_unused void *data) 2002 { 2003 struct cmd_config_max_pkt_len_result *res = parsed_result; 2004 portid_t pid; 2005 2006 if (!all_ports_stopped()) { 2007 printf("Please stop all ports first\n"); 2008 return; 2009 } 2010 2011 RTE_ETH_FOREACH_DEV(pid) { 2012 struct rte_port *port = &ports[pid]; 2013 uint64_t rx_offloads = port->dev_conf.rxmode.offloads; 2014 2015 if (!strcmp(res->name, "max-pkt-len")) { 2016 if (res->value < RTE_ETHER_MIN_LEN) { 2017 printf("max-pkt-len can not be less than %d\n", 2018 RTE_ETHER_MIN_LEN); 2019 return; 2020 } 2021 if (res->value == port->dev_conf.rxmode.max_rx_pkt_len) 2022 return; 2023 2024 port->dev_conf.rxmode.max_rx_pkt_len = res->value; 2025 if (res->value > RTE_ETHER_MAX_LEN) 2026 rx_offloads |= DEV_RX_OFFLOAD_JUMBO_FRAME; 2027 else 2028 rx_offloads &= ~DEV_RX_OFFLOAD_JUMBO_FRAME; 2029 port->dev_conf.rxmode.offloads = rx_offloads; 2030 } else { 2031 printf("Unknown parameter\n"); 2032 return; 2033 } 2034 } 2035 2036 init_port_config(); 2037 2038 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1); 2039 } 2040 2041 cmdline_parse_token_string_t cmd_config_max_pkt_len_port = 2042 TOKEN_STRING_INITIALIZER(struct cmd_config_max_pkt_len_result, port, 2043 "port"); 2044 cmdline_parse_token_string_t cmd_config_max_pkt_len_keyword = 2045 TOKEN_STRING_INITIALIZER(struct cmd_config_max_pkt_len_result, keyword, 2046 "config"); 2047 cmdline_parse_token_string_t cmd_config_max_pkt_len_all = 2048 TOKEN_STRING_INITIALIZER(struct cmd_config_max_pkt_len_result, all, 2049 "all"); 2050 cmdline_parse_token_string_t cmd_config_max_pkt_len_name = 2051 TOKEN_STRING_INITIALIZER(struct cmd_config_max_pkt_len_result, name, 2052 "max-pkt-len"); 2053 cmdline_parse_token_num_t cmd_config_max_pkt_len_value = 2054 TOKEN_NUM_INITIALIZER(struct cmd_config_max_pkt_len_result, value, 2055 UINT32); 2056 2057 cmdline_parse_inst_t cmd_config_max_pkt_len = { 2058 .f = cmd_config_max_pkt_len_parsed, 2059 .data = NULL, 2060 .help_str = "port config all max-pkt-len <value>", 2061 .tokens = { 2062 (void *)&cmd_config_max_pkt_len_port, 2063 (void *)&cmd_config_max_pkt_len_keyword, 2064 (void *)&cmd_config_max_pkt_len_all, 2065 (void *)&cmd_config_max_pkt_len_name, 2066 (void *)&cmd_config_max_pkt_len_value, 2067 NULL, 2068 }, 2069 }; 2070 2071 /* *** config max LRO aggregated packet size *** */ 2072 struct cmd_config_max_lro_pkt_size_result { 2073 cmdline_fixed_string_t port; 2074 cmdline_fixed_string_t keyword; 2075 cmdline_fixed_string_t all; 2076 cmdline_fixed_string_t name; 2077 uint32_t value; 2078 }; 2079 2080 static void 2081 cmd_config_max_lro_pkt_size_parsed(void *parsed_result, 2082 __rte_unused struct cmdline *cl, 2083 __rte_unused void *data) 2084 { 2085 struct cmd_config_max_lro_pkt_size_result *res = parsed_result; 2086 portid_t pid; 2087 2088 if (!all_ports_stopped()) { 2089 printf("Please stop all ports first\n"); 2090 return; 2091 } 2092 2093 RTE_ETH_FOREACH_DEV(pid) { 2094 struct rte_port *port = &ports[pid]; 2095 2096 if (!strcmp(res->name, "max-lro-pkt-size")) { 2097 if (res->value == 2098 port->dev_conf.rxmode.max_lro_pkt_size) 2099 return; 2100 2101 port->dev_conf.rxmode.max_lro_pkt_size = res->value; 2102 } else { 2103 printf("Unknown parameter\n"); 2104 return; 2105 } 2106 } 2107 2108 init_port_config(); 2109 2110 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1); 2111 } 2112 2113 cmdline_parse_token_string_t cmd_config_max_lro_pkt_size_port = 2114 TOKEN_STRING_INITIALIZER(struct cmd_config_max_lro_pkt_size_result, 2115 port, "port"); 2116 cmdline_parse_token_string_t cmd_config_max_lro_pkt_size_keyword = 2117 TOKEN_STRING_INITIALIZER(struct cmd_config_max_lro_pkt_size_result, 2118 keyword, "config"); 2119 cmdline_parse_token_string_t cmd_config_max_lro_pkt_size_all = 2120 TOKEN_STRING_INITIALIZER(struct cmd_config_max_lro_pkt_size_result, 2121 all, "all"); 2122 cmdline_parse_token_string_t cmd_config_max_lro_pkt_size_name = 2123 TOKEN_STRING_INITIALIZER(struct cmd_config_max_lro_pkt_size_result, 2124 name, "max-lro-pkt-size"); 2125 cmdline_parse_token_num_t cmd_config_max_lro_pkt_size_value = 2126 TOKEN_NUM_INITIALIZER(struct cmd_config_max_lro_pkt_size_result, 2127 value, UINT32); 2128 2129 cmdline_parse_inst_t cmd_config_max_lro_pkt_size = { 2130 .f = cmd_config_max_lro_pkt_size_parsed, 2131 .data = NULL, 2132 .help_str = "port config all max-lro-pkt-size <value>", 2133 .tokens = { 2134 (void *)&cmd_config_max_lro_pkt_size_port, 2135 (void *)&cmd_config_max_lro_pkt_size_keyword, 2136 (void *)&cmd_config_max_lro_pkt_size_all, 2137 (void *)&cmd_config_max_lro_pkt_size_name, 2138 (void *)&cmd_config_max_lro_pkt_size_value, 2139 NULL, 2140 }, 2141 }; 2142 2143 /* *** configure port MTU *** */ 2144 struct cmd_config_mtu_result { 2145 cmdline_fixed_string_t port; 2146 cmdline_fixed_string_t keyword; 2147 cmdline_fixed_string_t mtu; 2148 portid_t port_id; 2149 uint16_t value; 2150 }; 2151 2152 static void 2153 cmd_config_mtu_parsed(void *parsed_result, 2154 __rte_unused struct cmdline *cl, 2155 __rte_unused void *data) 2156 { 2157 struct cmd_config_mtu_result *res = parsed_result; 2158 2159 if (res->value < RTE_ETHER_MIN_LEN) { 2160 printf("mtu cannot be less than %d\n", RTE_ETHER_MIN_LEN); 2161 return; 2162 } 2163 port_mtu_set(res->port_id, res->value); 2164 } 2165 2166 cmdline_parse_token_string_t cmd_config_mtu_port = 2167 TOKEN_STRING_INITIALIZER(struct cmd_config_mtu_result, port, 2168 "port"); 2169 cmdline_parse_token_string_t cmd_config_mtu_keyword = 2170 TOKEN_STRING_INITIALIZER(struct cmd_config_mtu_result, keyword, 2171 "config"); 2172 cmdline_parse_token_string_t cmd_config_mtu_mtu = 2173 TOKEN_STRING_INITIALIZER(struct cmd_config_mtu_result, keyword, 2174 "mtu"); 2175 cmdline_parse_token_num_t cmd_config_mtu_port_id = 2176 TOKEN_NUM_INITIALIZER(struct cmd_config_mtu_result, port_id, UINT16); 2177 cmdline_parse_token_num_t cmd_config_mtu_value = 2178 TOKEN_NUM_INITIALIZER(struct cmd_config_mtu_result, value, UINT16); 2179 2180 cmdline_parse_inst_t cmd_config_mtu = { 2181 .f = cmd_config_mtu_parsed, 2182 .data = NULL, 2183 .help_str = "port config mtu <port_id> <value>", 2184 .tokens = { 2185 (void *)&cmd_config_mtu_port, 2186 (void *)&cmd_config_mtu_keyword, 2187 (void *)&cmd_config_mtu_mtu, 2188 (void *)&cmd_config_mtu_port_id, 2189 (void *)&cmd_config_mtu_value, 2190 NULL, 2191 }, 2192 }; 2193 2194 /* *** configure rx mode *** */ 2195 struct cmd_config_rx_mode_flag { 2196 cmdline_fixed_string_t port; 2197 cmdline_fixed_string_t keyword; 2198 cmdline_fixed_string_t all; 2199 cmdline_fixed_string_t name; 2200 cmdline_fixed_string_t value; 2201 }; 2202 2203 static void 2204 cmd_config_rx_mode_flag_parsed(void *parsed_result, 2205 __rte_unused struct cmdline *cl, 2206 __rte_unused void *data) 2207 { 2208 struct cmd_config_rx_mode_flag *res = parsed_result; 2209 2210 if (!all_ports_stopped()) { 2211 printf("Please stop all ports first\n"); 2212 return; 2213 } 2214 2215 if (!strcmp(res->name, "drop-en")) { 2216 if (!strcmp(res->value, "on")) 2217 rx_drop_en = 1; 2218 else if (!strcmp(res->value, "off")) 2219 rx_drop_en = 0; 2220 else { 2221 printf("Unknown parameter\n"); 2222 return; 2223 } 2224 } else { 2225 printf("Unknown parameter\n"); 2226 return; 2227 } 2228 2229 init_port_config(); 2230 2231 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1); 2232 } 2233 2234 cmdline_parse_token_string_t cmd_config_rx_mode_flag_port = 2235 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_mode_flag, port, "port"); 2236 cmdline_parse_token_string_t cmd_config_rx_mode_flag_keyword = 2237 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_mode_flag, keyword, 2238 "config"); 2239 cmdline_parse_token_string_t cmd_config_rx_mode_flag_all = 2240 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_mode_flag, all, "all"); 2241 cmdline_parse_token_string_t cmd_config_rx_mode_flag_name = 2242 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_mode_flag, name, 2243 "drop-en"); 2244 cmdline_parse_token_string_t cmd_config_rx_mode_flag_value = 2245 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_mode_flag, value, 2246 "on#off"); 2247 2248 cmdline_parse_inst_t cmd_config_rx_mode_flag = { 2249 .f = cmd_config_rx_mode_flag_parsed, 2250 .data = NULL, 2251 .help_str = "port config all drop-en on|off", 2252 .tokens = { 2253 (void *)&cmd_config_rx_mode_flag_port, 2254 (void *)&cmd_config_rx_mode_flag_keyword, 2255 (void *)&cmd_config_rx_mode_flag_all, 2256 (void *)&cmd_config_rx_mode_flag_name, 2257 (void *)&cmd_config_rx_mode_flag_value, 2258 NULL, 2259 }, 2260 }; 2261 2262 /* *** configure rss *** */ 2263 struct cmd_config_rss { 2264 cmdline_fixed_string_t port; 2265 cmdline_fixed_string_t keyword; 2266 cmdline_fixed_string_t all; 2267 cmdline_fixed_string_t name; 2268 cmdline_fixed_string_t value; 2269 }; 2270 2271 static void 2272 cmd_config_rss_parsed(void *parsed_result, 2273 __rte_unused struct cmdline *cl, 2274 __rte_unused void *data) 2275 { 2276 struct cmd_config_rss *res = parsed_result; 2277 struct rte_eth_rss_conf rss_conf = { .rss_key_len = 0, }; 2278 struct rte_eth_dev_info dev_info = { .flow_type_rss_offloads = 0, }; 2279 int use_default = 0; 2280 int all_updated = 1; 2281 int diag; 2282 uint16_t i; 2283 int ret; 2284 2285 if (!strcmp(res->value, "all")) 2286 rss_conf.rss_hf = ETH_RSS_ETH | ETH_RSS_VLAN | ETH_RSS_IP | 2287 ETH_RSS_TCP | ETH_RSS_UDP | ETH_RSS_SCTP | 2288 ETH_RSS_L2_PAYLOAD | ETH_RSS_L2TPV3 | ETH_RSS_ESP | 2289 ETH_RSS_AH | ETH_RSS_PFCP | ETH_RSS_GTPU; 2290 else if (!strcmp(res->value, "eth")) 2291 rss_conf.rss_hf = ETH_RSS_ETH; 2292 else if (!strcmp(res->value, "vlan")) 2293 rss_conf.rss_hf = ETH_RSS_VLAN; 2294 else if (!strcmp(res->value, "ip")) 2295 rss_conf.rss_hf = ETH_RSS_IP; 2296 else if (!strcmp(res->value, "udp")) 2297 rss_conf.rss_hf = ETH_RSS_UDP; 2298 else if (!strcmp(res->value, "tcp")) 2299 rss_conf.rss_hf = ETH_RSS_TCP; 2300 else if (!strcmp(res->value, "sctp")) 2301 rss_conf.rss_hf = ETH_RSS_SCTP; 2302 else if (!strcmp(res->value, "ether")) 2303 rss_conf.rss_hf = ETH_RSS_L2_PAYLOAD; 2304 else if (!strcmp(res->value, "port")) 2305 rss_conf.rss_hf = ETH_RSS_PORT; 2306 else if (!strcmp(res->value, "vxlan")) 2307 rss_conf.rss_hf = ETH_RSS_VXLAN; 2308 else if (!strcmp(res->value, "geneve")) 2309 rss_conf.rss_hf = ETH_RSS_GENEVE; 2310 else if (!strcmp(res->value, "nvgre")) 2311 rss_conf.rss_hf = ETH_RSS_NVGRE; 2312 else if (!strcmp(res->value, "l3-pre32")) 2313 rss_conf.rss_hf = RTE_ETH_RSS_L3_PRE32; 2314 else if (!strcmp(res->value, "l3-pre40")) 2315 rss_conf.rss_hf = RTE_ETH_RSS_L3_PRE40; 2316 else if (!strcmp(res->value, "l3-pre48")) 2317 rss_conf.rss_hf = RTE_ETH_RSS_L3_PRE48; 2318 else if (!strcmp(res->value, "l3-pre56")) 2319 rss_conf.rss_hf = RTE_ETH_RSS_L3_PRE56; 2320 else if (!strcmp(res->value, "l3-pre64")) 2321 rss_conf.rss_hf = RTE_ETH_RSS_L3_PRE64; 2322 else if (!strcmp(res->value, "l3-pre96")) 2323 rss_conf.rss_hf = RTE_ETH_RSS_L3_PRE96; 2324 else if (!strcmp(res->value, "l3-src-only")) 2325 rss_conf.rss_hf = ETH_RSS_L3_SRC_ONLY; 2326 else if (!strcmp(res->value, "l3-dst-only")) 2327 rss_conf.rss_hf = ETH_RSS_L3_DST_ONLY; 2328 else if (!strcmp(res->value, "l4-src-only")) 2329 rss_conf.rss_hf = ETH_RSS_L4_SRC_ONLY; 2330 else if (!strcmp(res->value, "l4-dst-only")) 2331 rss_conf.rss_hf = ETH_RSS_L4_DST_ONLY; 2332 else if (!strcmp(res->value, "l2-src-only")) 2333 rss_conf.rss_hf = ETH_RSS_L2_SRC_ONLY; 2334 else if (!strcmp(res->value, "l2-dst-only")) 2335 rss_conf.rss_hf = ETH_RSS_L2_DST_ONLY; 2336 else if (!strcmp(res->value, "l2tpv3")) 2337 rss_conf.rss_hf = ETH_RSS_L2TPV3; 2338 else if (!strcmp(res->value, "esp")) 2339 rss_conf.rss_hf = ETH_RSS_ESP; 2340 else if (!strcmp(res->value, "ah")) 2341 rss_conf.rss_hf = ETH_RSS_AH; 2342 else if (!strcmp(res->value, "pfcp")) 2343 rss_conf.rss_hf = ETH_RSS_PFCP; 2344 else if (!strcmp(res->value, "pppoe")) 2345 rss_conf.rss_hf = ETH_RSS_PPPOE; 2346 else if (!strcmp(res->value, "gtpu")) 2347 rss_conf.rss_hf = ETH_RSS_GTPU; 2348 else if (!strcmp(res->value, "none")) 2349 rss_conf.rss_hf = 0; 2350 else if (!strcmp(res->value, "level-default")) { 2351 rss_hf &= (~ETH_RSS_LEVEL_MASK); 2352 rss_conf.rss_hf = (rss_hf | ETH_RSS_LEVEL_PMD_DEFAULT); 2353 } else if (!strcmp(res->value, "level-outer")) { 2354 rss_hf &= (~ETH_RSS_LEVEL_MASK); 2355 rss_conf.rss_hf = (rss_hf | ETH_RSS_LEVEL_OUTERMOST); 2356 } else if (!strcmp(res->value, "level-inner")) { 2357 rss_hf &= (~ETH_RSS_LEVEL_MASK); 2358 rss_conf.rss_hf = (rss_hf | ETH_RSS_LEVEL_INNERMOST); 2359 } else if (!strcmp(res->value, "default")) 2360 use_default = 1; 2361 else if (isdigit(res->value[0]) && atoi(res->value) > 0 && 2362 atoi(res->value) < 64) 2363 rss_conf.rss_hf = 1ULL << atoi(res->value); 2364 else { 2365 printf("Unknown parameter\n"); 2366 return; 2367 } 2368 rss_conf.rss_key = NULL; 2369 /* Update global configuration for RSS types. */ 2370 RTE_ETH_FOREACH_DEV(i) { 2371 struct rte_eth_rss_conf local_rss_conf; 2372 2373 ret = eth_dev_info_get_print_err(i, &dev_info); 2374 if (ret != 0) 2375 return; 2376 2377 if (use_default) 2378 rss_conf.rss_hf = dev_info.flow_type_rss_offloads; 2379 2380 local_rss_conf = rss_conf; 2381 local_rss_conf.rss_hf = rss_conf.rss_hf & 2382 dev_info.flow_type_rss_offloads; 2383 if (local_rss_conf.rss_hf != rss_conf.rss_hf) { 2384 printf("Port %u modified RSS hash function based on hardware support," 2385 "requested:%#"PRIx64" configured:%#"PRIx64"\n", 2386 i, rss_conf.rss_hf, local_rss_conf.rss_hf); 2387 } 2388 diag = rte_eth_dev_rss_hash_update(i, &local_rss_conf); 2389 if (diag < 0) { 2390 all_updated = 0; 2391 printf("Configuration of RSS hash at ethernet port %d " 2392 "failed with error (%d): %s.\n", 2393 i, -diag, strerror(-diag)); 2394 } 2395 } 2396 if (all_updated && !use_default) { 2397 rss_hf = rss_conf.rss_hf; 2398 printf("rss_hf %#"PRIx64"\n", rss_hf); 2399 } 2400 } 2401 2402 cmdline_parse_token_string_t cmd_config_rss_port = 2403 TOKEN_STRING_INITIALIZER(struct cmd_config_rss, port, "port"); 2404 cmdline_parse_token_string_t cmd_config_rss_keyword = 2405 TOKEN_STRING_INITIALIZER(struct cmd_config_rss, keyword, "config"); 2406 cmdline_parse_token_string_t cmd_config_rss_all = 2407 TOKEN_STRING_INITIALIZER(struct cmd_config_rss, all, "all"); 2408 cmdline_parse_token_string_t cmd_config_rss_name = 2409 TOKEN_STRING_INITIALIZER(struct cmd_config_rss, name, "rss"); 2410 cmdline_parse_token_string_t cmd_config_rss_value = 2411 TOKEN_STRING_INITIALIZER(struct cmd_config_rss, value, NULL); 2412 2413 cmdline_parse_inst_t cmd_config_rss = { 2414 .f = cmd_config_rss_parsed, 2415 .data = NULL, 2416 .help_str = "port config all rss " 2417 "all|default|eth|vlan|ip|tcp|udp|sctp|ether|port|vxlan|geneve|" 2418 "nvgre|vxlan-gpe|l2tpv3|esp|ah|pfcp|none|level-default|" 2419 "level-outer|level-inner|<flowtype_id>", 2420 .tokens = { 2421 (void *)&cmd_config_rss_port, 2422 (void *)&cmd_config_rss_keyword, 2423 (void *)&cmd_config_rss_all, 2424 (void *)&cmd_config_rss_name, 2425 (void *)&cmd_config_rss_value, 2426 NULL, 2427 }, 2428 }; 2429 2430 /* *** configure rss hash key *** */ 2431 struct cmd_config_rss_hash_key { 2432 cmdline_fixed_string_t port; 2433 cmdline_fixed_string_t config; 2434 portid_t port_id; 2435 cmdline_fixed_string_t rss_hash_key; 2436 cmdline_fixed_string_t rss_type; 2437 cmdline_fixed_string_t key; 2438 }; 2439 2440 static uint8_t 2441 hexa_digit_to_value(char hexa_digit) 2442 { 2443 if ((hexa_digit >= '0') && (hexa_digit <= '9')) 2444 return (uint8_t) (hexa_digit - '0'); 2445 if ((hexa_digit >= 'a') && (hexa_digit <= 'f')) 2446 return (uint8_t) ((hexa_digit - 'a') + 10); 2447 if ((hexa_digit >= 'A') && (hexa_digit <= 'F')) 2448 return (uint8_t) ((hexa_digit - 'A') + 10); 2449 /* Invalid hexa digit */ 2450 return 0xFF; 2451 } 2452 2453 static uint8_t 2454 parse_and_check_key_hexa_digit(char *key, int idx) 2455 { 2456 uint8_t hexa_v; 2457 2458 hexa_v = hexa_digit_to_value(key[idx]); 2459 if (hexa_v == 0xFF) 2460 printf("invalid key: character %c at position %d is not a " 2461 "valid hexa digit\n", key[idx], idx); 2462 return hexa_v; 2463 } 2464 2465 static void 2466 cmd_config_rss_hash_key_parsed(void *parsed_result, 2467 __rte_unused struct cmdline *cl, 2468 __rte_unused void *data) 2469 { 2470 struct cmd_config_rss_hash_key *res = parsed_result; 2471 uint8_t hash_key[RSS_HASH_KEY_LENGTH]; 2472 uint8_t xdgt0; 2473 uint8_t xdgt1; 2474 int i; 2475 struct rte_eth_dev_info dev_info; 2476 uint8_t hash_key_size; 2477 uint32_t key_len; 2478 int ret; 2479 2480 ret = eth_dev_info_get_print_err(res->port_id, &dev_info); 2481 if (ret != 0) 2482 return; 2483 2484 if (dev_info.hash_key_size > 0 && 2485 dev_info.hash_key_size <= sizeof(hash_key)) 2486 hash_key_size = dev_info.hash_key_size; 2487 else { 2488 printf("dev_info did not provide a valid hash key size\n"); 2489 return; 2490 } 2491 /* Check the length of the RSS hash key */ 2492 key_len = strlen(res->key); 2493 if (key_len != (hash_key_size * 2)) { 2494 printf("key length: %d invalid - key must be a string of %d" 2495 " hexa-decimal numbers\n", 2496 (int) key_len, hash_key_size * 2); 2497 return; 2498 } 2499 /* Translate RSS hash key into binary representation */ 2500 for (i = 0; i < hash_key_size; i++) { 2501 xdgt0 = parse_and_check_key_hexa_digit(res->key, (i * 2)); 2502 if (xdgt0 == 0xFF) 2503 return; 2504 xdgt1 = parse_and_check_key_hexa_digit(res->key, (i * 2) + 1); 2505 if (xdgt1 == 0xFF) 2506 return; 2507 hash_key[i] = (uint8_t) ((xdgt0 * 16) + xdgt1); 2508 } 2509 port_rss_hash_key_update(res->port_id, res->rss_type, hash_key, 2510 hash_key_size); 2511 } 2512 2513 cmdline_parse_token_string_t cmd_config_rss_hash_key_port = 2514 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_hash_key, port, "port"); 2515 cmdline_parse_token_string_t cmd_config_rss_hash_key_config = 2516 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_hash_key, config, 2517 "config"); 2518 cmdline_parse_token_num_t cmd_config_rss_hash_key_port_id = 2519 TOKEN_NUM_INITIALIZER(struct cmd_config_rss_hash_key, port_id, UINT16); 2520 cmdline_parse_token_string_t cmd_config_rss_hash_key_rss_hash_key = 2521 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_hash_key, 2522 rss_hash_key, "rss-hash-key"); 2523 cmdline_parse_token_string_t cmd_config_rss_hash_key_rss_type = 2524 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_hash_key, rss_type, 2525 "ipv4#ipv4-frag#ipv4-tcp#ipv4-udp#ipv4-sctp#" 2526 "ipv4-other#ipv6#ipv6-frag#ipv6-tcp#ipv6-udp#" 2527 "ipv6-sctp#ipv6-other#l2-payload#ipv6-ex#" 2528 "ipv6-tcp-ex#ipv6-udp-ex#" 2529 "l3-src-only#l3-dst-only#l4-src-only#l4-dst-only#" 2530 "l2-src-only#l2-dst-only#s-vlan#c-vlan#" 2531 "l2tpv3#esp#ah#pfcp#pppoe#gtpu"); 2532 cmdline_parse_token_string_t cmd_config_rss_hash_key_value = 2533 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_hash_key, key, NULL); 2534 2535 cmdline_parse_inst_t cmd_config_rss_hash_key = { 2536 .f = cmd_config_rss_hash_key_parsed, 2537 .data = NULL, 2538 .help_str = "port config <port_id> rss-hash-key " 2539 "ipv4|ipv4-frag|ipv4-tcp|ipv4-udp|ipv4-sctp|ipv4-other|" 2540 "ipv6|ipv6-frag|ipv6-tcp|ipv6-udp|ipv6-sctp|ipv6-other|" 2541 "l2-payload|ipv6-ex|ipv6-tcp-ex|ipv6-udp-ex|" 2542 "l3-src-only|l3-dst-only|l4-src-only|l4-dst-only|" 2543 "l2-src-only|l2-dst-only|s-vlan|c-vlan|" 2544 "l2tpv3|esp|ah|pfcp|pppoe|gtpu " 2545 "<string of hex digits (variable length, NIC dependent)>", 2546 .tokens = { 2547 (void *)&cmd_config_rss_hash_key_port, 2548 (void *)&cmd_config_rss_hash_key_config, 2549 (void *)&cmd_config_rss_hash_key_port_id, 2550 (void *)&cmd_config_rss_hash_key_rss_hash_key, 2551 (void *)&cmd_config_rss_hash_key_rss_type, 2552 (void *)&cmd_config_rss_hash_key_value, 2553 NULL, 2554 }, 2555 }; 2556 2557 /* *** configure port rxq/txq ring size *** */ 2558 struct cmd_config_rxtx_ring_size { 2559 cmdline_fixed_string_t port; 2560 cmdline_fixed_string_t config; 2561 portid_t portid; 2562 cmdline_fixed_string_t rxtxq; 2563 uint16_t qid; 2564 cmdline_fixed_string_t rsize; 2565 uint16_t size; 2566 }; 2567 2568 static void 2569 cmd_config_rxtx_ring_size_parsed(void *parsed_result, 2570 __rte_unused struct cmdline *cl, 2571 __rte_unused void *data) 2572 { 2573 struct cmd_config_rxtx_ring_size *res = parsed_result; 2574 struct rte_port *port; 2575 uint8_t isrx; 2576 2577 if (port_id_is_invalid(res->portid, ENABLED_WARN)) 2578 return; 2579 2580 if (res->portid == (portid_t)RTE_PORT_ALL) { 2581 printf("Invalid port id\n"); 2582 return; 2583 } 2584 2585 port = &ports[res->portid]; 2586 2587 if (!strcmp(res->rxtxq, "rxq")) 2588 isrx = 1; 2589 else if (!strcmp(res->rxtxq, "txq")) 2590 isrx = 0; 2591 else { 2592 printf("Unknown parameter\n"); 2593 return; 2594 } 2595 2596 if (isrx && rx_queue_id_is_invalid(res->qid)) 2597 return; 2598 else if (!isrx && tx_queue_id_is_invalid(res->qid)) 2599 return; 2600 2601 if (isrx && res->size != 0 && res->size <= rx_free_thresh) { 2602 printf("Invalid rx ring_size, must > rx_free_thresh: %d\n", 2603 rx_free_thresh); 2604 return; 2605 } 2606 2607 if (isrx) 2608 port->nb_rx_desc[res->qid] = res->size; 2609 else 2610 port->nb_tx_desc[res->qid] = res->size; 2611 2612 cmd_reconfig_device_queue(res->portid, 0, 1); 2613 } 2614 2615 cmdline_parse_token_string_t cmd_config_rxtx_ring_size_port = 2616 TOKEN_STRING_INITIALIZER(struct cmd_config_rxtx_ring_size, 2617 port, "port"); 2618 cmdline_parse_token_string_t cmd_config_rxtx_ring_size_config = 2619 TOKEN_STRING_INITIALIZER(struct cmd_config_rxtx_ring_size, 2620 config, "config"); 2621 cmdline_parse_token_num_t cmd_config_rxtx_ring_size_portid = 2622 TOKEN_NUM_INITIALIZER(struct cmd_config_rxtx_ring_size, 2623 portid, UINT16); 2624 cmdline_parse_token_string_t cmd_config_rxtx_ring_size_rxtxq = 2625 TOKEN_STRING_INITIALIZER(struct cmd_config_rxtx_ring_size, 2626 rxtxq, "rxq#txq"); 2627 cmdline_parse_token_num_t cmd_config_rxtx_ring_size_qid = 2628 TOKEN_NUM_INITIALIZER(struct cmd_config_rxtx_ring_size, 2629 qid, UINT16); 2630 cmdline_parse_token_string_t cmd_config_rxtx_ring_size_rsize = 2631 TOKEN_STRING_INITIALIZER(struct cmd_config_rxtx_ring_size, 2632 rsize, "ring_size"); 2633 cmdline_parse_token_num_t cmd_config_rxtx_ring_size_size = 2634 TOKEN_NUM_INITIALIZER(struct cmd_config_rxtx_ring_size, 2635 size, UINT16); 2636 2637 cmdline_parse_inst_t cmd_config_rxtx_ring_size = { 2638 .f = cmd_config_rxtx_ring_size_parsed, 2639 .data = NULL, 2640 .help_str = "port config <port_id> rxq|txq <queue_id> ring_size <value>", 2641 .tokens = { 2642 (void *)&cmd_config_rxtx_ring_size_port, 2643 (void *)&cmd_config_rxtx_ring_size_config, 2644 (void *)&cmd_config_rxtx_ring_size_portid, 2645 (void *)&cmd_config_rxtx_ring_size_rxtxq, 2646 (void *)&cmd_config_rxtx_ring_size_qid, 2647 (void *)&cmd_config_rxtx_ring_size_rsize, 2648 (void *)&cmd_config_rxtx_ring_size_size, 2649 NULL, 2650 }, 2651 }; 2652 2653 /* *** configure port rxq/txq start/stop *** */ 2654 struct cmd_config_rxtx_queue { 2655 cmdline_fixed_string_t port; 2656 portid_t portid; 2657 cmdline_fixed_string_t rxtxq; 2658 uint16_t qid; 2659 cmdline_fixed_string_t opname; 2660 }; 2661 2662 static void 2663 cmd_config_rxtx_queue_parsed(void *parsed_result, 2664 __rte_unused struct cmdline *cl, 2665 __rte_unused void *data) 2666 { 2667 struct cmd_config_rxtx_queue *res = parsed_result; 2668 uint8_t isrx; 2669 uint8_t isstart; 2670 int ret = 0; 2671 2672 if (test_done == 0) { 2673 printf("Please stop forwarding first\n"); 2674 return; 2675 } 2676 2677 if (port_id_is_invalid(res->portid, ENABLED_WARN)) 2678 return; 2679 2680 if (port_is_started(res->portid) != 1) { 2681 printf("Please start port %u first\n", res->portid); 2682 return; 2683 } 2684 2685 if (!strcmp(res->rxtxq, "rxq")) 2686 isrx = 1; 2687 else if (!strcmp(res->rxtxq, "txq")) 2688 isrx = 0; 2689 else { 2690 printf("Unknown parameter\n"); 2691 return; 2692 } 2693 2694 if (isrx && rx_queue_id_is_invalid(res->qid)) 2695 return; 2696 else if (!isrx && tx_queue_id_is_invalid(res->qid)) 2697 return; 2698 2699 if (!strcmp(res->opname, "start")) 2700 isstart = 1; 2701 else if (!strcmp(res->opname, "stop")) 2702 isstart = 0; 2703 else { 2704 printf("Unknown parameter\n"); 2705 return; 2706 } 2707 2708 if (isstart && isrx) 2709 ret = rte_eth_dev_rx_queue_start(res->portid, res->qid); 2710 else if (!isstart && isrx) 2711 ret = rte_eth_dev_rx_queue_stop(res->portid, res->qid); 2712 else if (isstart && !isrx) 2713 ret = rte_eth_dev_tx_queue_start(res->portid, res->qid); 2714 else 2715 ret = rte_eth_dev_tx_queue_stop(res->portid, res->qid); 2716 2717 if (ret == -ENOTSUP) 2718 printf("Function not supported in PMD driver\n"); 2719 } 2720 2721 cmdline_parse_token_string_t cmd_config_rxtx_queue_port = 2722 TOKEN_STRING_INITIALIZER(struct cmd_config_rxtx_queue, port, "port"); 2723 cmdline_parse_token_num_t cmd_config_rxtx_queue_portid = 2724 TOKEN_NUM_INITIALIZER(struct cmd_config_rxtx_queue, portid, UINT16); 2725 cmdline_parse_token_string_t cmd_config_rxtx_queue_rxtxq = 2726 TOKEN_STRING_INITIALIZER(struct cmd_config_rxtx_queue, rxtxq, "rxq#txq"); 2727 cmdline_parse_token_num_t cmd_config_rxtx_queue_qid = 2728 TOKEN_NUM_INITIALIZER(struct cmd_config_rxtx_queue, qid, UINT16); 2729 cmdline_parse_token_string_t cmd_config_rxtx_queue_opname = 2730 TOKEN_STRING_INITIALIZER(struct cmd_config_rxtx_queue, opname, 2731 "start#stop"); 2732 2733 cmdline_parse_inst_t cmd_config_rxtx_queue = { 2734 .f = cmd_config_rxtx_queue_parsed, 2735 .data = NULL, 2736 .help_str = "port <port_id> rxq|txq <queue_id> start|stop", 2737 .tokens = { 2738 (void *)&cmd_config_rxtx_queue_port, 2739 (void *)&cmd_config_rxtx_queue_portid, 2740 (void *)&cmd_config_rxtx_queue_rxtxq, 2741 (void *)&cmd_config_rxtx_queue_qid, 2742 (void *)&cmd_config_rxtx_queue_opname, 2743 NULL, 2744 }, 2745 }; 2746 2747 /* *** configure port rxq/txq deferred start on/off *** */ 2748 struct cmd_config_deferred_start_rxtx_queue { 2749 cmdline_fixed_string_t port; 2750 portid_t port_id; 2751 cmdline_fixed_string_t rxtxq; 2752 uint16_t qid; 2753 cmdline_fixed_string_t opname; 2754 cmdline_fixed_string_t state; 2755 }; 2756 2757 static void 2758 cmd_config_deferred_start_rxtx_queue_parsed(void *parsed_result, 2759 __rte_unused struct cmdline *cl, 2760 __rte_unused void *data) 2761 { 2762 struct cmd_config_deferred_start_rxtx_queue *res = parsed_result; 2763 struct rte_port *port; 2764 uint8_t isrx; 2765 uint8_t ison; 2766 uint8_t needreconfig = 0; 2767 2768 if (port_id_is_invalid(res->port_id, ENABLED_WARN)) 2769 return; 2770 2771 if (port_is_started(res->port_id) != 0) { 2772 printf("Please stop port %u first\n", res->port_id); 2773 return; 2774 } 2775 2776 port = &ports[res->port_id]; 2777 2778 isrx = !strcmp(res->rxtxq, "rxq"); 2779 2780 if (isrx && rx_queue_id_is_invalid(res->qid)) 2781 return; 2782 else if (!isrx && tx_queue_id_is_invalid(res->qid)) 2783 return; 2784 2785 ison = !strcmp(res->state, "on"); 2786 2787 if (isrx && port->rx_conf[res->qid].rx_deferred_start != ison) { 2788 port->rx_conf[res->qid].rx_deferred_start = ison; 2789 needreconfig = 1; 2790 } else if (!isrx && port->tx_conf[res->qid].tx_deferred_start != ison) { 2791 port->tx_conf[res->qid].tx_deferred_start = ison; 2792 needreconfig = 1; 2793 } 2794 2795 if (needreconfig) 2796 cmd_reconfig_device_queue(res->port_id, 0, 1); 2797 } 2798 2799 cmdline_parse_token_string_t cmd_config_deferred_start_rxtx_queue_port = 2800 TOKEN_STRING_INITIALIZER(struct cmd_config_deferred_start_rxtx_queue, 2801 port, "port"); 2802 cmdline_parse_token_num_t cmd_config_deferred_start_rxtx_queue_port_id = 2803 TOKEN_NUM_INITIALIZER(struct cmd_config_deferred_start_rxtx_queue, 2804 port_id, UINT16); 2805 cmdline_parse_token_string_t cmd_config_deferred_start_rxtx_queue_rxtxq = 2806 TOKEN_STRING_INITIALIZER(struct cmd_config_deferred_start_rxtx_queue, 2807 rxtxq, "rxq#txq"); 2808 cmdline_parse_token_num_t cmd_config_deferred_start_rxtx_queue_qid = 2809 TOKEN_NUM_INITIALIZER(struct cmd_config_deferred_start_rxtx_queue, 2810 qid, UINT16); 2811 cmdline_parse_token_string_t cmd_config_deferred_start_rxtx_queue_opname = 2812 TOKEN_STRING_INITIALIZER(struct cmd_config_deferred_start_rxtx_queue, 2813 opname, "deferred_start"); 2814 cmdline_parse_token_string_t cmd_config_deferred_start_rxtx_queue_state = 2815 TOKEN_STRING_INITIALIZER(struct cmd_config_deferred_start_rxtx_queue, 2816 state, "on#off"); 2817 2818 cmdline_parse_inst_t cmd_config_deferred_start_rxtx_queue = { 2819 .f = cmd_config_deferred_start_rxtx_queue_parsed, 2820 .data = NULL, 2821 .help_str = "port <port_id> rxq|txq <queue_id> deferred_start on|off", 2822 .tokens = { 2823 (void *)&cmd_config_deferred_start_rxtx_queue_port, 2824 (void *)&cmd_config_deferred_start_rxtx_queue_port_id, 2825 (void *)&cmd_config_deferred_start_rxtx_queue_rxtxq, 2826 (void *)&cmd_config_deferred_start_rxtx_queue_qid, 2827 (void *)&cmd_config_deferred_start_rxtx_queue_opname, 2828 (void *)&cmd_config_deferred_start_rxtx_queue_state, 2829 NULL, 2830 }, 2831 }; 2832 2833 /* *** configure port rxq/txq setup *** */ 2834 struct cmd_setup_rxtx_queue { 2835 cmdline_fixed_string_t port; 2836 portid_t portid; 2837 cmdline_fixed_string_t rxtxq; 2838 uint16_t qid; 2839 cmdline_fixed_string_t setup; 2840 }; 2841 2842 /* Common CLI fields for queue setup */ 2843 cmdline_parse_token_string_t cmd_setup_rxtx_queue_port = 2844 TOKEN_STRING_INITIALIZER(struct cmd_setup_rxtx_queue, port, "port"); 2845 cmdline_parse_token_num_t cmd_setup_rxtx_queue_portid = 2846 TOKEN_NUM_INITIALIZER(struct cmd_setup_rxtx_queue, portid, UINT16); 2847 cmdline_parse_token_string_t cmd_setup_rxtx_queue_rxtxq = 2848 TOKEN_STRING_INITIALIZER(struct cmd_setup_rxtx_queue, rxtxq, "rxq#txq"); 2849 cmdline_parse_token_num_t cmd_setup_rxtx_queue_qid = 2850 TOKEN_NUM_INITIALIZER(struct cmd_setup_rxtx_queue, qid, UINT16); 2851 cmdline_parse_token_string_t cmd_setup_rxtx_queue_setup = 2852 TOKEN_STRING_INITIALIZER(struct cmd_setup_rxtx_queue, setup, "setup"); 2853 2854 static void 2855 cmd_setup_rxtx_queue_parsed( 2856 void *parsed_result, 2857 __rte_unused struct cmdline *cl, 2858 __rte_unused void *data) 2859 { 2860 struct cmd_setup_rxtx_queue *res = parsed_result; 2861 struct rte_port *port; 2862 struct rte_mempool *mp; 2863 unsigned int socket_id; 2864 uint8_t isrx = 0; 2865 int ret; 2866 2867 if (port_id_is_invalid(res->portid, ENABLED_WARN)) 2868 return; 2869 2870 if (res->portid == (portid_t)RTE_PORT_ALL) { 2871 printf("Invalid port id\n"); 2872 return; 2873 } 2874 2875 if (!strcmp(res->rxtxq, "rxq")) 2876 isrx = 1; 2877 else if (!strcmp(res->rxtxq, "txq")) 2878 isrx = 0; 2879 else { 2880 printf("Unknown parameter\n"); 2881 return; 2882 } 2883 2884 if (isrx && rx_queue_id_is_invalid(res->qid)) { 2885 printf("Invalid rx queue\n"); 2886 return; 2887 } else if (!isrx && tx_queue_id_is_invalid(res->qid)) { 2888 printf("Invalid tx queue\n"); 2889 return; 2890 } 2891 2892 port = &ports[res->portid]; 2893 if (isrx) { 2894 socket_id = rxring_numa[res->portid]; 2895 if (!numa_support || socket_id == NUMA_NO_CONFIG) 2896 socket_id = port->socket_id; 2897 2898 mp = mbuf_pool_find(socket_id); 2899 if (mp == NULL) { 2900 printf("Failed to setup RX queue: " 2901 "No mempool allocation" 2902 " on the socket %d\n", 2903 rxring_numa[res->portid]); 2904 return; 2905 } 2906 ret = rte_eth_rx_queue_setup(res->portid, 2907 res->qid, 2908 port->nb_rx_desc[res->qid], 2909 socket_id, 2910 &port->rx_conf[res->qid], 2911 mp); 2912 if (ret) 2913 printf("Failed to setup RX queue\n"); 2914 } else { 2915 socket_id = txring_numa[res->portid]; 2916 if (!numa_support || socket_id == NUMA_NO_CONFIG) 2917 socket_id = port->socket_id; 2918 2919 ret = rte_eth_tx_queue_setup(res->portid, 2920 res->qid, 2921 port->nb_tx_desc[res->qid], 2922 socket_id, 2923 &port->tx_conf[res->qid]); 2924 if (ret) 2925 printf("Failed to setup TX queue\n"); 2926 } 2927 } 2928 2929 cmdline_parse_inst_t cmd_setup_rxtx_queue = { 2930 .f = cmd_setup_rxtx_queue_parsed, 2931 .data = NULL, 2932 .help_str = "port <port_id> rxq|txq <queue_idx> setup", 2933 .tokens = { 2934 (void *)&cmd_setup_rxtx_queue_port, 2935 (void *)&cmd_setup_rxtx_queue_portid, 2936 (void *)&cmd_setup_rxtx_queue_rxtxq, 2937 (void *)&cmd_setup_rxtx_queue_qid, 2938 (void *)&cmd_setup_rxtx_queue_setup, 2939 NULL, 2940 }, 2941 }; 2942 2943 2944 /* *** Configure RSS RETA *** */ 2945 struct cmd_config_rss_reta { 2946 cmdline_fixed_string_t port; 2947 cmdline_fixed_string_t keyword; 2948 portid_t port_id; 2949 cmdline_fixed_string_t name; 2950 cmdline_fixed_string_t list_name; 2951 cmdline_fixed_string_t list_of_items; 2952 }; 2953 2954 static int 2955 parse_reta_config(const char *str, 2956 struct rte_eth_rss_reta_entry64 *reta_conf, 2957 uint16_t nb_entries) 2958 { 2959 int i; 2960 unsigned size; 2961 uint16_t hash_index, idx, shift; 2962 uint16_t nb_queue; 2963 char s[256]; 2964 const char *p, *p0 = str; 2965 char *end; 2966 enum fieldnames { 2967 FLD_HASH_INDEX = 0, 2968 FLD_QUEUE, 2969 _NUM_FLD 2970 }; 2971 unsigned long int_fld[_NUM_FLD]; 2972 char *str_fld[_NUM_FLD]; 2973 2974 while ((p = strchr(p0,'(')) != NULL) { 2975 ++p; 2976 if((p0 = strchr(p,')')) == NULL) 2977 return -1; 2978 2979 size = p0 - p; 2980 if(size >= sizeof(s)) 2981 return -1; 2982 2983 snprintf(s, sizeof(s), "%.*s", size, p); 2984 if (rte_strsplit(s, sizeof(s), str_fld, _NUM_FLD, ',') != _NUM_FLD) 2985 return -1; 2986 for (i = 0; i < _NUM_FLD; i++) { 2987 errno = 0; 2988 int_fld[i] = strtoul(str_fld[i], &end, 0); 2989 if (errno != 0 || end == str_fld[i] || 2990 int_fld[i] > 65535) 2991 return -1; 2992 } 2993 2994 hash_index = (uint16_t)int_fld[FLD_HASH_INDEX]; 2995 nb_queue = (uint16_t)int_fld[FLD_QUEUE]; 2996 2997 if (hash_index >= nb_entries) { 2998 printf("Invalid RETA hash index=%d\n", hash_index); 2999 return -1; 3000 } 3001 3002 idx = hash_index / RTE_RETA_GROUP_SIZE; 3003 shift = hash_index % RTE_RETA_GROUP_SIZE; 3004 reta_conf[idx].mask |= (1ULL << shift); 3005 reta_conf[idx].reta[shift] = nb_queue; 3006 } 3007 3008 return 0; 3009 } 3010 3011 static void 3012 cmd_set_rss_reta_parsed(void *parsed_result, 3013 __rte_unused struct cmdline *cl, 3014 __rte_unused void *data) 3015 { 3016 int ret; 3017 struct rte_eth_dev_info dev_info; 3018 struct rte_eth_rss_reta_entry64 reta_conf[8]; 3019 struct cmd_config_rss_reta *res = parsed_result; 3020 3021 ret = eth_dev_info_get_print_err(res->port_id, &dev_info); 3022 if (ret != 0) 3023 return; 3024 3025 if (dev_info.reta_size == 0) { 3026 printf("Redirection table size is 0 which is " 3027 "invalid for RSS\n"); 3028 return; 3029 } else 3030 printf("The reta size of port %d is %u\n", 3031 res->port_id, dev_info.reta_size); 3032 if (dev_info.reta_size > ETH_RSS_RETA_SIZE_512) { 3033 printf("Currently do not support more than %u entries of " 3034 "redirection table\n", ETH_RSS_RETA_SIZE_512); 3035 return; 3036 } 3037 3038 memset(reta_conf, 0, sizeof(reta_conf)); 3039 if (!strcmp(res->list_name, "reta")) { 3040 if (parse_reta_config(res->list_of_items, reta_conf, 3041 dev_info.reta_size)) { 3042 printf("Invalid RSS Redirection Table " 3043 "config entered\n"); 3044 return; 3045 } 3046 ret = rte_eth_dev_rss_reta_update(res->port_id, 3047 reta_conf, dev_info.reta_size); 3048 if (ret != 0) 3049 printf("Bad redirection table parameter, " 3050 "return code = %d \n", ret); 3051 } 3052 } 3053 3054 cmdline_parse_token_string_t cmd_config_rss_reta_port = 3055 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_reta, port, "port"); 3056 cmdline_parse_token_string_t cmd_config_rss_reta_keyword = 3057 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_reta, keyword, "config"); 3058 cmdline_parse_token_num_t cmd_config_rss_reta_port_id = 3059 TOKEN_NUM_INITIALIZER(struct cmd_config_rss_reta, port_id, UINT16); 3060 cmdline_parse_token_string_t cmd_config_rss_reta_name = 3061 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_reta, name, "rss"); 3062 cmdline_parse_token_string_t cmd_config_rss_reta_list_name = 3063 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_reta, list_name, "reta"); 3064 cmdline_parse_token_string_t cmd_config_rss_reta_list_of_items = 3065 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_reta, list_of_items, 3066 NULL); 3067 cmdline_parse_inst_t cmd_config_rss_reta = { 3068 .f = cmd_set_rss_reta_parsed, 3069 .data = NULL, 3070 .help_str = "port config <port_id> rss reta <hash,queue[,hash,queue]*>", 3071 .tokens = { 3072 (void *)&cmd_config_rss_reta_port, 3073 (void *)&cmd_config_rss_reta_keyword, 3074 (void *)&cmd_config_rss_reta_port_id, 3075 (void *)&cmd_config_rss_reta_name, 3076 (void *)&cmd_config_rss_reta_list_name, 3077 (void *)&cmd_config_rss_reta_list_of_items, 3078 NULL, 3079 }, 3080 }; 3081 3082 /* *** SHOW PORT RETA INFO *** */ 3083 struct cmd_showport_reta { 3084 cmdline_fixed_string_t show; 3085 cmdline_fixed_string_t port; 3086 portid_t port_id; 3087 cmdline_fixed_string_t rss; 3088 cmdline_fixed_string_t reta; 3089 uint16_t size; 3090 cmdline_fixed_string_t list_of_items; 3091 }; 3092 3093 static int 3094 showport_parse_reta_config(struct rte_eth_rss_reta_entry64 *conf, 3095 uint16_t nb_entries, 3096 char *str) 3097 { 3098 uint32_t size; 3099 const char *p, *p0 = str; 3100 char s[256]; 3101 char *end; 3102 char *str_fld[8]; 3103 uint16_t i; 3104 uint16_t num = (nb_entries + RTE_RETA_GROUP_SIZE - 1) / 3105 RTE_RETA_GROUP_SIZE; 3106 int ret; 3107 3108 p = strchr(p0, '('); 3109 if (p == NULL) 3110 return -1; 3111 p++; 3112 p0 = strchr(p, ')'); 3113 if (p0 == NULL) 3114 return -1; 3115 size = p0 - p; 3116 if (size >= sizeof(s)) { 3117 printf("The string size exceeds the internal buffer size\n"); 3118 return -1; 3119 } 3120 snprintf(s, sizeof(s), "%.*s", size, p); 3121 ret = rte_strsplit(s, sizeof(s), str_fld, num, ','); 3122 if (ret <= 0 || ret != num) { 3123 printf("The bits of masks do not match the number of " 3124 "reta entries: %u\n", num); 3125 return -1; 3126 } 3127 for (i = 0; i < ret; i++) 3128 conf[i].mask = (uint64_t)strtoul(str_fld[i], &end, 0); 3129 3130 return 0; 3131 } 3132 3133 static void 3134 cmd_showport_reta_parsed(void *parsed_result, 3135 __rte_unused struct cmdline *cl, 3136 __rte_unused void *data) 3137 { 3138 struct cmd_showport_reta *res = parsed_result; 3139 struct rte_eth_rss_reta_entry64 reta_conf[8]; 3140 struct rte_eth_dev_info dev_info; 3141 uint16_t max_reta_size; 3142 int ret; 3143 3144 ret = eth_dev_info_get_print_err(res->port_id, &dev_info); 3145 if (ret != 0) 3146 return; 3147 3148 max_reta_size = RTE_MIN(dev_info.reta_size, ETH_RSS_RETA_SIZE_512); 3149 if (res->size == 0 || res->size > max_reta_size) { 3150 printf("Invalid redirection table size: %u (1-%u)\n", 3151 res->size, max_reta_size); 3152 return; 3153 } 3154 3155 memset(reta_conf, 0, sizeof(reta_conf)); 3156 if (showport_parse_reta_config(reta_conf, res->size, 3157 res->list_of_items) < 0) { 3158 printf("Invalid string: %s for reta masks\n", 3159 res->list_of_items); 3160 return; 3161 } 3162 port_rss_reta_info(res->port_id, reta_conf, res->size); 3163 } 3164 3165 cmdline_parse_token_string_t cmd_showport_reta_show = 3166 TOKEN_STRING_INITIALIZER(struct cmd_showport_reta, show, "show"); 3167 cmdline_parse_token_string_t cmd_showport_reta_port = 3168 TOKEN_STRING_INITIALIZER(struct cmd_showport_reta, port, "port"); 3169 cmdline_parse_token_num_t cmd_showport_reta_port_id = 3170 TOKEN_NUM_INITIALIZER(struct cmd_showport_reta, port_id, UINT16); 3171 cmdline_parse_token_string_t cmd_showport_reta_rss = 3172 TOKEN_STRING_INITIALIZER(struct cmd_showport_reta, rss, "rss"); 3173 cmdline_parse_token_string_t cmd_showport_reta_reta = 3174 TOKEN_STRING_INITIALIZER(struct cmd_showport_reta, reta, "reta"); 3175 cmdline_parse_token_num_t cmd_showport_reta_size = 3176 TOKEN_NUM_INITIALIZER(struct cmd_showport_reta, size, UINT16); 3177 cmdline_parse_token_string_t cmd_showport_reta_list_of_items = 3178 TOKEN_STRING_INITIALIZER(struct cmd_showport_reta, 3179 list_of_items, NULL); 3180 3181 cmdline_parse_inst_t cmd_showport_reta = { 3182 .f = cmd_showport_reta_parsed, 3183 .data = NULL, 3184 .help_str = "show port <port_id> rss reta <size> <mask0[,mask1]*>", 3185 .tokens = { 3186 (void *)&cmd_showport_reta_show, 3187 (void *)&cmd_showport_reta_port, 3188 (void *)&cmd_showport_reta_port_id, 3189 (void *)&cmd_showport_reta_rss, 3190 (void *)&cmd_showport_reta_reta, 3191 (void *)&cmd_showport_reta_size, 3192 (void *)&cmd_showport_reta_list_of_items, 3193 NULL, 3194 }, 3195 }; 3196 3197 /* *** Show RSS hash configuration *** */ 3198 struct cmd_showport_rss_hash { 3199 cmdline_fixed_string_t show; 3200 cmdline_fixed_string_t port; 3201 portid_t port_id; 3202 cmdline_fixed_string_t rss_hash; 3203 cmdline_fixed_string_t rss_type; 3204 cmdline_fixed_string_t key; /* optional argument */ 3205 }; 3206 3207 static void cmd_showport_rss_hash_parsed(void *parsed_result, 3208 __rte_unused struct cmdline *cl, 3209 void *show_rss_key) 3210 { 3211 struct cmd_showport_rss_hash *res = parsed_result; 3212 3213 port_rss_hash_conf_show(res->port_id, show_rss_key != NULL); 3214 } 3215 3216 cmdline_parse_token_string_t cmd_showport_rss_hash_show = 3217 TOKEN_STRING_INITIALIZER(struct cmd_showport_rss_hash, show, "show"); 3218 cmdline_parse_token_string_t cmd_showport_rss_hash_port = 3219 TOKEN_STRING_INITIALIZER(struct cmd_showport_rss_hash, port, "port"); 3220 cmdline_parse_token_num_t cmd_showport_rss_hash_port_id = 3221 TOKEN_NUM_INITIALIZER(struct cmd_showport_rss_hash, port_id, UINT16); 3222 cmdline_parse_token_string_t cmd_showport_rss_hash_rss_hash = 3223 TOKEN_STRING_INITIALIZER(struct cmd_showport_rss_hash, rss_hash, 3224 "rss-hash"); 3225 cmdline_parse_token_string_t cmd_showport_rss_hash_rss_key = 3226 TOKEN_STRING_INITIALIZER(struct cmd_showport_rss_hash, key, "key"); 3227 3228 cmdline_parse_inst_t cmd_showport_rss_hash = { 3229 .f = cmd_showport_rss_hash_parsed, 3230 .data = NULL, 3231 .help_str = "show port <port_id> rss-hash", 3232 .tokens = { 3233 (void *)&cmd_showport_rss_hash_show, 3234 (void *)&cmd_showport_rss_hash_port, 3235 (void *)&cmd_showport_rss_hash_port_id, 3236 (void *)&cmd_showport_rss_hash_rss_hash, 3237 NULL, 3238 }, 3239 }; 3240 3241 cmdline_parse_inst_t cmd_showport_rss_hash_key = { 3242 .f = cmd_showport_rss_hash_parsed, 3243 .data = (void *)1, 3244 .help_str = "show port <port_id> rss-hash key", 3245 .tokens = { 3246 (void *)&cmd_showport_rss_hash_show, 3247 (void *)&cmd_showport_rss_hash_port, 3248 (void *)&cmd_showport_rss_hash_port_id, 3249 (void *)&cmd_showport_rss_hash_rss_hash, 3250 (void *)&cmd_showport_rss_hash_rss_key, 3251 NULL, 3252 }, 3253 }; 3254 3255 /* *** Configure DCB *** */ 3256 struct cmd_config_dcb { 3257 cmdline_fixed_string_t port; 3258 cmdline_fixed_string_t config; 3259 portid_t port_id; 3260 cmdline_fixed_string_t dcb; 3261 cmdline_fixed_string_t vt; 3262 cmdline_fixed_string_t vt_en; 3263 uint8_t num_tcs; 3264 cmdline_fixed_string_t pfc; 3265 cmdline_fixed_string_t pfc_en; 3266 }; 3267 3268 static void 3269 cmd_config_dcb_parsed(void *parsed_result, 3270 __rte_unused struct cmdline *cl, 3271 __rte_unused void *data) 3272 { 3273 struct cmd_config_dcb *res = parsed_result; 3274 portid_t port_id = res->port_id; 3275 struct rte_port *port; 3276 uint8_t pfc_en; 3277 int ret; 3278 3279 port = &ports[port_id]; 3280 /** Check if the port is not started **/ 3281 if (port->port_status != RTE_PORT_STOPPED) { 3282 printf("Please stop port %d first\n", port_id); 3283 return; 3284 } 3285 3286 if ((res->num_tcs != ETH_4_TCS) && (res->num_tcs != ETH_8_TCS)) { 3287 printf("The invalid number of traffic class," 3288 " only 4 or 8 allowed.\n"); 3289 return; 3290 } 3291 3292 if (nb_fwd_lcores < res->num_tcs) { 3293 printf("nb_cores shouldn't be less than number of TCs.\n"); 3294 return; 3295 } 3296 if (!strncmp(res->pfc_en, "on", 2)) 3297 pfc_en = 1; 3298 else 3299 pfc_en = 0; 3300 3301 /* DCB in VT mode */ 3302 if (!strncmp(res->vt_en, "on", 2)) 3303 ret = init_port_dcb_config(port_id, DCB_VT_ENABLED, 3304 (enum rte_eth_nb_tcs)res->num_tcs, 3305 pfc_en); 3306 else 3307 ret = init_port_dcb_config(port_id, DCB_ENABLED, 3308 (enum rte_eth_nb_tcs)res->num_tcs, 3309 pfc_en); 3310 3311 3312 if (ret != 0) { 3313 printf("Cannot initialize network ports.\n"); 3314 return; 3315 } 3316 3317 cmd_reconfig_device_queue(port_id, 1, 1); 3318 } 3319 3320 cmdline_parse_token_string_t cmd_config_dcb_port = 3321 TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, port, "port"); 3322 cmdline_parse_token_string_t cmd_config_dcb_config = 3323 TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, config, "config"); 3324 cmdline_parse_token_num_t cmd_config_dcb_port_id = 3325 TOKEN_NUM_INITIALIZER(struct cmd_config_dcb, port_id, UINT16); 3326 cmdline_parse_token_string_t cmd_config_dcb_dcb = 3327 TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, dcb, "dcb"); 3328 cmdline_parse_token_string_t cmd_config_dcb_vt = 3329 TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, vt, "vt"); 3330 cmdline_parse_token_string_t cmd_config_dcb_vt_en = 3331 TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, vt_en, "on#off"); 3332 cmdline_parse_token_num_t cmd_config_dcb_num_tcs = 3333 TOKEN_NUM_INITIALIZER(struct cmd_config_dcb, num_tcs, UINT8); 3334 cmdline_parse_token_string_t cmd_config_dcb_pfc= 3335 TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, pfc, "pfc"); 3336 cmdline_parse_token_string_t cmd_config_dcb_pfc_en = 3337 TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, pfc_en, "on#off"); 3338 3339 cmdline_parse_inst_t cmd_config_dcb = { 3340 .f = cmd_config_dcb_parsed, 3341 .data = NULL, 3342 .help_str = "port config <port-id> dcb vt on|off <num_tcs> pfc on|off", 3343 .tokens = { 3344 (void *)&cmd_config_dcb_port, 3345 (void *)&cmd_config_dcb_config, 3346 (void *)&cmd_config_dcb_port_id, 3347 (void *)&cmd_config_dcb_dcb, 3348 (void *)&cmd_config_dcb_vt, 3349 (void *)&cmd_config_dcb_vt_en, 3350 (void *)&cmd_config_dcb_num_tcs, 3351 (void *)&cmd_config_dcb_pfc, 3352 (void *)&cmd_config_dcb_pfc_en, 3353 NULL, 3354 }, 3355 }; 3356 3357 /* *** configure number of packets per burst *** */ 3358 struct cmd_config_burst { 3359 cmdline_fixed_string_t port; 3360 cmdline_fixed_string_t keyword; 3361 cmdline_fixed_string_t all; 3362 cmdline_fixed_string_t name; 3363 uint16_t value; 3364 }; 3365 3366 static void 3367 cmd_config_burst_parsed(void *parsed_result, 3368 __rte_unused struct cmdline *cl, 3369 __rte_unused void *data) 3370 { 3371 struct cmd_config_burst *res = parsed_result; 3372 struct rte_eth_dev_info dev_info; 3373 uint16_t rec_nb_pkts; 3374 int ret; 3375 3376 if (!all_ports_stopped()) { 3377 printf("Please stop all ports first\n"); 3378 return; 3379 } 3380 3381 if (!strcmp(res->name, "burst")) { 3382 if (res->value == 0) { 3383 /* If user gives a value of zero, query the PMD for 3384 * its recommended Rx burst size. Testpmd uses a single 3385 * size for all ports, so assume all ports are the same 3386 * NIC model and use the values from Port 0. 3387 */ 3388 ret = eth_dev_info_get_print_err(0, &dev_info); 3389 if (ret != 0) 3390 return; 3391 3392 rec_nb_pkts = dev_info.default_rxportconf.burst_size; 3393 3394 if (rec_nb_pkts == 0) { 3395 printf("PMD does not recommend a burst size.\n" 3396 "User provided value must be between" 3397 " 1 and %d\n", MAX_PKT_BURST); 3398 return; 3399 } else if (rec_nb_pkts > MAX_PKT_BURST) { 3400 printf("PMD recommended burst size of %d" 3401 " exceeds maximum value of %d\n", 3402 rec_nb_pkts, MAX_PKT_BURST); 3403 return; 3404 } 3405 printf("Using PMD-provided burst value of %d\n", 3406 rec_nb_pkts); 3407 nb_pkt_per_burst = rec_nb_pkts; 3408 } else if (res->value > MAX_PKT_BURST) { 3409 printf("burst must be >= 1 && <= %d\n", MAX_PKT_BURST); 3410 return; 3411 } else 3412 nb_pkt_per_burst = res->value; 3413 } else { 3414 printf("Unknown parameter\n"); 3415 return; 3416 } 3417 3418 init_port_config(); 3419 3420 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1); 3421 } 3422 3423 cmdline_parse_token_string_t cmd_config_burst_port = 3424 TOKEN_STRING_INITIALIZER(struct cmd_config_burst, port, "port"); 3425 cmdline_parse_token_string_t cmd_config_burst_keyword = 3426 TOKEN_STRING_INITIALIZER(struct cmd_config_burst, keyword, "config"); 3427 cmdline_parse_token_string_t cmd_config_burst_all = 3428 TOKEN_STRING_INITIALIZER(struct cmd_config_burst, all, "all"); 3429 cmdline_parse_token_string_t cmd_config_burst_name = 3430 TOKEN_STRING_INITIALIZER(struct cmd_config_burst, name, "burst"); 3431 cmdline_parse_token_num_t cmd_config_burst_value = 3432 TOKEN_NUM_INITIALIZER(struct cmd_config_burst, value, UINT16); 3433 3434 cmdline_parse_inst_t cmd_config_burst = { 3435 .f = cmd_config_burst_parsed, 3436 .data = NULL, 3437 .help_str = "port config all burst <value>", 3438 .tokens = { 3439 (void *)&cmd_config_burst_port, 3440 (void *)&cmd_config_burst_keyword, 3441 (void *)&cmd_config_burst_all, 3442 (void *)&cmd_config_burst_name, 3443 (void *)&cmd_config_burst_value, 3444 NULL, 3445 }, 3446 }; 3447 3448 /* *** configure rx/tx queues *** */ 3449 struct cmd_config_thresh { 3450 cmdline_fixed_string_t port; 3451 cmdline_fixed_string_t keyword; 3452 cmdline_fixed_string_t all; 3453 cmdline_fixed_string_t name; 3454 uint8_t value; 3455 }; 3456 3457 static void 3458 cmd_config_thresh_parsed(void *parsed_result, 3459 __rte_unused struct cmdline *cl, 3460 __rte_unused void *data) 3461 { 3462 struct cmd_config_thresh *res = parsed_result; 3463 3464 if (!all_ports_stopped()) { 3465 printf("Please stop all ports first\n"); 3466 return; 3467 } 3468 3469 if (!strcmp(res->name, "txpt")) 3470 tx_pthresh = res->value; 3471 else if(!strcmp(res->name, "txht")) 3472 tx_hthresh = res->value; 3473 else if(!strcmp(res->name, "txwt")) 3474 tx_wthresh = res->value; 3475 else if(!strcmp(res->name, "rxpt")) 3476 rx_pthresh = res->value; 3477 else if(!strcmp(res->name, "rxht")) 3478 rx_hthresh = res->value; 3479 else if(!strcmp(res->name, "rxwt")) 3480 rx_wthresh = res->value; 3481 else { 3482 printf("Unknown parameter\n"); 3483 return; 3484 } 3485 3486 init_port_config(); 3487 3488 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1); 3489 } 3490 3491 cmdline_parse_token_string_t cmd_config_thresh_port = 3492 TOKEN_STRING_INITIALIZER(struct cmd_config_thresh, port, "port"); 3493 cmdline_parse_token_string_t cmd_config_thresh_keyword = 3494 TOKEN_STRING_INITIALIZER(struct cmd_config_thresh, keyword, "config"); 3495 cmdline_parse_token_string_t cmd_config_thresh_all = 3496 TOKEN_STRING_INITIALIZER(struct cmd_config_thresh, all, "all"); 3497 cmdline_parse_token_string_t cmd_config_thresh_name = 3498 TOKEN_STRING_INITIALIZER(struct cmd_config_thresh, name, 3499 "txpt#txht#txwt#rxpt#rxht#rxwt"); 3500 cmdline_parse_token_num_t cmd_config_thresh_value = 3501 TOKEN_NUM_INITIALIZER(struct cmd_config_thresh, value, UINT8); 3502 3503 cmdline_parse_inst_t cmd_config_thresh = { 3504 .f = cmd_config_thresh_parsed, 3505 .data = NULL, 3506 .help_str = "port config all txpt|txht|txwt|rxpt|rxht|rxwt <value>", 3507 .tokens = { 3508 (void *)&cmd_config_thresh_port, 3509 (void *)&cmd_config_thresh_keyword, 3510 (void *)&cmd_config_thresh_all, 3511 (void *)&cmd_config_thresh_name, 3512 (void *)&cmd_config_thresh_value, 3513 NULL, 3514 }, 3515 }; 3516 3517 /* *** configure free/rs threshold *** */ 3518 struct cmd_config_threshold { 3519 cmdline_fixed_string_t port; 3520 cmdline_fixed_string_t keyword; 3521 cmdline_fixed_string_t all; 3522 cmdline_fixed_string_t name; 3523 uint16_t value; 3524 }; 3525 3526 static void 3527 cmd_config_threshold_parsed(void *parsed_result, 3528 __rte_unused struct cmdline *cl, 3529 __rte_unused void *data) 3530 { 3531 struct cmd_config_threshold *res = parsed_result; 3532 3533 if (!all_ports_stopped()) { 3534 printf("Please stop all ports first\n"); 3535 return; 3536 } 3537 3538 if (!strcmp(res->name, "txfreet")) 3539 tx_free_thresh = res->value; 3540 else if (!strcmp(res->name, "txrst")) 3541 tx_rs_thresh = res->value; 3542 else if (!strcmp(res->name, "rxfreet")) 3543 rx_free_thresh = res->value; 3544 else { 3545 printf("Unknown parameter\n"); 3546 return; 3547 } 3548 3549 init_port_config(); 3550 3551 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1); 3552 } 3553 3554 cmdline_parse_token_string_t cmd_config_threshold_port = 3555 TOKEN_STRING_INITIALIZER(struct cmd_config_threshold, port, "port"); 3556 cmdline_parse_token_string_t cmd_config_threshold_keyword = 3557 TOKEN_STRING_INITIALIZER(struct cmd_config_threshold, keyword, 3558 "config"); 3559 cmdline_parse_token_string_t cmd_config_threshold_all = 3560 TOKEN_STRING_INITIALIZER(struct cmd_config_threshold, all, "all"); 3561 cmdline_parse_token_string_t cmd_config_threshold_name = 3562 TOKEN_STRING_INITIALIZER(struct cmd_config_threshold, name, 3563 "txfreet#txrst#rxfreet"); 3564 cmdline_parse_token_num_t cmd_config_threshold_value = 3565 TOKEN_NUM_INITIALIZER(struct cmd_config_threshold, value, UINT16); 3566 3567 cmdline_parse_inst_t cmd_config_threshold = { 3568 .f = cmd_config_threshold_parsed, 3569 .data = NULL, 3570 .help_str = "port config all txfreet|txrst|rxfreet <value>", 3571 .tokens = { 3572 (void *)&cmd_config_threshold_port, 3573 (void *)&cmd_config_threshold_keyword, 3574 (void *)&cmd_config_threshold_all, 3575 (void *)&cmd_config_threshold_name, 3576 (void *)&cmd_config_threshold_value, 3577 NULL, 3578 }, 3579 }; 3580 3581 /* *** stop *** */ 3582 struct cmd_stop_result { 3583 cmdline_fixed_string_t stop; 3584 }; 3585 3586 static void cmd_stop_parsed(__rte_unused void *parsed_result, 3587 __rte_unused struct cmdline *cl, 3588 __rte_unused void *data) 3589 { 3590 stop_packet_forwarding(); 3591 } 3592 3593 cmdline_parse_token_string_t cmd_stop_stop = 3594 TOKEN_STRING_INITIALIZER(struct cmd_stop_result, stop, "stop"); 3595 3596 cmdline_parse_inst_t cmd_stop = { 3597 .f = cmd_stop_parsed, 3598 .data = NULL, 3599 .help_str = "stop: Stop packet forwarding", 3600 .tokens = { 3601 (void *)&cmd_stop_stop, 3602 NULL, 3603 }, 3604 }; 3605 3606 /* *** SET CORELIST and PORTLIST CONFIGURATION *** */ 3607 3608 unsigned int 3609 parse_item_list(char* str, const char* item_name, unsigned int max_items, 3610 unsigned int *parsed_items, int check_unique_values) 3611 { 3612 unsigned int nb_item; 3613 unsigned int value; 3614 unsigned int i; 3615 unsigned int j; 3616 int value_ok; 3617 char c; 3618 3619 /* 3620 * First parse all items in the list and store their value. 3621 */ 3622 value = 0; 3623 nb_item = 0; 3624 value_ok = 0; 3625 for (i = 0; i < strnlen(str, STR_TOKEN_SIZE); i++) { 3626 c = str[i]; 3627 if ((c >= '0') && (c <= '9')) { 3628 value = (unsigned int) (value * 10 + (c - '0')); 3629 value_ok = 1; 3630 continue; 3631 } 3632 if (c != ',') { 3633 printf("character %c is not a decimal digit\n", c); 3634 return 0; 3635 } 3636 if (! value_ok) { 3637 printf("No valid value before comma\n"); 3638 return 0; 3639 } 3640 if (nb_item < max_items) { 3641 parsed_items[nb_item] = value; 3642 value_ok = 0; 3643 value = 0; 3644 } 3645 nb_item++; 3646 } 3647 if (nb_item >= max_items) { 3648 printf("Number of %s = %u > %u (maximum items)\n", 3649 item_name, nb_item + 1, max_items); 3650 return 0; 3651 } 3652 parsed_items[nb_item++] = value; 3653 if (! check_unique_values) 3654 return nb_item; 3655 3656 /* 3657 * Then, check that all values in the list are differents. 3658 * No optimization here... 3659 */ 3660 for (i = 0; i < nb_item; i++) { 3661 for (j = i + 1; j < nb_item; j++) { 3662 if (parsed_items[j] == parsed_items[i]) { 3663 printf("duplicated %s %u at index %u and %u\n", 3664 item_name, parsed_items[i], i, j); 3665 return 0; 3666 } 3667 } 3668 } 3669 return nb_item; 3670 } 3671 3672 struct cmd_set_list_result { 3673 cmdline_fixed_string_t cmd_keyword; 3674 cmdline_fixed_string_t list_name; 3675 cmdline_fixed_string_t list_of_items; 3676 }; 3677 3678 static void cmd_set_list_parsed(void *parsed_result, 3679 __rte_unused struct cmdline *cl, 3680 __rte_unused void *data) 3681 { 3682 struct cmd_set_list_result *res; 3683 union { 3684 unsigned int lcorelist[RTE_MAX_LCORE]; 3685 unsigned int portlist[RTE_MAX_ETHPORTS]; 3686 } parsed_items; 3687 unsigned int nb_item; 3688 3689 if (test_done == 0) { 3690 printf("Please stop forwarding first\n"); 3691 return; 3692 } 3693 3694 res = parsed_result; 3695 if (!strcmp(res->list_name, "corelist")) { 3696 nb_item = parse_item_list(res->list_of_items, "core", 3697 RTE_MAX_LCORE, 3698 parsed_items.lcorelist, 1); 3699 if (nb_item > 0) { 3700 set_fwd_lcores_list(parsed_items.lcorelist, nb_item); 3701 fwd_config_setup(); 3702 } 3703 return; 3704 } 3705 if (!strcmp(res->list_name, "portlist")) { 3706 nb_item = parse_item_list(res->list_of_items, "port", 3707 RTE_MAX_ETHPORTS, 3708 parsed_items.portlist, 1); 3709 if (nb_item > 0) { 3710 set_fwd_ports_list(parsed_items.portlist, nb_item); 3711 fwd_config_setup(); 3712 } 3713 } 3714 } 3715 3716 cmdline_parse_token_string_t cmd_set_list_keyword = 3717 TOKEN_STRING_INITIALIZER(struct cmd_set_list_result, cmd_keyword, 3718 "set"); 3719 cmdline_parse_token_string_t cmd_set_list_name = 3720 TOKEN_STRING_INITIALIZER(struct cmd_set_list_result, list_name, 3721 "corelist#portlist"); 3722 cmdline_parse_token_string_t cmd_set_list_of_items = 3723 TOKEN_STRING_INITIALIZER(struct cmd_set_list_result, list_of_items, 3724 NULL); 3725 3726 cmdline_parse_inst_t cmd_set_fwd_list = { 3727 .f = cmd_set_list_parsed, 3728 .data = NULL, 3729 .help_str = "set corelist|portlist <list0[,list1]*>", 3730 .tokens = { 3731 (void *)&cmd_set_list_keyword, 3732 (void *)&cmd_set_list_name, 3733 (void *)&cmd_set_list_of_items, 3734 NULL, 3735 }, 3736 }; 3737 3738 /* *** SET COREMASK and PORTMASK CONFIGURATION *** */ 3739 3740 struct cmd_setmask_result { 3741 cmdline_fixed_string_t set; 3742 cmdline_fixed_string_t mask; 3743 uint64_t hexavalue; 3744 }; 3745 3746 static void cmd_set_mask_parsed(void *parsed_result, 3747 __rte_unused struct cmdline *cl, 3748 __rte_unused void *data) 3749 { 3750 struct cmd_setmask_result *res = parsed_result; 3751 3752 if (test_done == 0) { 3753 printf("Please stop forwarding first\n"); 3754 return; 3755 } 3756 if (!strcmp(res->mask, "coremask")) { 3757 set_fwd_lcores_mask(res->hexavalue); 3758 fwd_config_setup(); 3759 } else if (!strcmp(res->mask, "portmask")) { 3760 set_fwd_ports_mask(res->hexavalue); 3761 fwd_config_setup(); 3762 } 3763 } 3764 3765 cmdline_parse_token_string_t cmd_setmask_set = 3766 TOKEN_STRING_INITIALIZER(struct cmd_setmask_result, set, "set"); 3767 cmdline_parse_token_string_t cmd_setmask_mask = 3768 TOKEN_STRING_INITIALIZER(struct cmd_setmask_result, mask, 3769 "coremask#portmask"); 3770 cmdline_parse_token_num_t cmd_setmask_value = 3771 TOKEN_NUM_INITIALIZER(struct cmd_setmask_result, hexavalue, UINT64); 3772 3773 cmdline_parse_inst_t cmd_set_fwd_mask = { 3774 .f = cmd_set_mask_parsed, 3775 .data = NULL, 3776 .help_str = "set coremask|portmask <hexadecimal value>", 3777 .tokens = { 3778 (void *)&cmd_setmask_set, 3779 (void *)&cmd_setmask_mask, 3780 (void *)&cmd_setmask_value, 3781 NULL, 3782 }, 3783 }; 3784 3785 /* 3786 * SET NBPORT, NBCORE, PACKET BURST, and VERBOSE LEVEL CONFIGURATION 3787 */ 3788 struct cmd_set_result { 3789 cmdline_fixed_string_t set; 3790 cmdline_fixed_string_t what; 3791 uint16_t value; 3792 }; 3793 3794 static void cmd_set_parsed(void *parsed_result, 3795 __rte_unused struct cmdline *cl, 3796 __rte_unused void *data) 3797 { 3798 struct cmd_set_result *res = parsed_result; 3799 if (!strcmp(res->what, "nbport")) { 3800 set_fwd_ports_number(res->value); 3801 fwd_config_setup(); 3802 } else if (!strcmp(res->what, "nbcore")) { 3803 set_fwd_lcores_number(res->value); 3804 fwd_config_setup(); 3805 } else if (!strcmp(res->what, "burst")) 3806 set_nb_pkt_per_burst(res->value); 3807 else if (!strcmp(res->what, "verbose")) 3808 set_verbose_level(res->value); 3809 } 3810 3811 cmdline_parse_token_string_t cmd_set_set = 3812 TOKEN_STRING_INITIALIZER(struct cmd_set_result, set, "set"); 3813 cmdline_parse_token_string_t cmd_set_what = 3814 TOKEN_STRING_INITIALIZER(struct cmd_set_result, what, 3815 "nbport#nbcore#burst#verbose"); 3816 cmdline_parse_token_num_t cmd_set_value = 3817 TOKEN_NUM_INITIALIZER(struct cmd_set_result, value, UINT16); 3818 3819 cmdline_parse_inst_t cmd_set_numbers = { 3820 .f = cmd_set_parsed, 3821 .data = NULL, 3822 .help_str = "set nbport|nbcore|burst|verbose <value>", 3823 .tokens = { 3824 (void *)&cmd_set_set, 3825 (void *)&cmd_set_what, 3826 (void *)&cmd_set_value, 3827 NULL, 3828 }, 3829 }; 3830 3831 /* *** SET LOG LEVEL CONFIGURATION *** */ 3832 3833 struct cmd_set_log_result { 3834 cmdline_fixed_string_t set; 3835 cmdline_fixed_string_t log; 3836 cmdline_fixed_string_t type; 3837 uint32_t level; 3838 }; 3839 3840 static void 3841 cmd_set_log_parsed(void *parsed_result, 3842 __rte_unused struct cmdline *cl, 3843 __rte_unused void *data) 3844 { 3845 struct cmd_set_log_result *res; 3846 int ret; 3847 3848 res = parsed_result; 3849 if (!strcmp(res->type, "global")) 3850 rte_log_set_global_level(res->level); 3851 else { 3852 ret = rte_log_set_level_regexp(res->type, res->level); 3853 if (ret < 0) 3854 printf("Unable to set log level\n"); 3855 } 3856 } 3857 3858 cmdline_parse_token_string_t cmd_set_log_set = 3859 TOKEN_STRING_INITIALIZER(struct cmd_set_log_result, set, "set"); 3860 cmdline_parse_token_string_t cmd_set_log_log = 3861 TOKEN_STRING_INITIALIZER(struct cmd_set_log_result, log, "log"); 3862 cmdline_parse_token_string_t cmd_set_log_type = 3863 TOKEN_STRING_INITIALIZER(struct cmd_set_log_result, type, NULL); 3864 cmdline_parse_token_num_t cmd_set_log_level = 3865 TOKEN_NUM_INITIALIZER(struct cmd_set_log_result, level, UINT32); 3866 3867 cmdline_parse_inst_t cmd_set_log = { 3868 .f = cmd_set_log_parsed, 3869 .data = NULL, 3870 .help_str = "set log global|<type> <level>", 3871 .tokens = { 3872 (void *)&cmd_set_log_set, 3873 (void *)&cmd_set_log_log, 3874 (void *)&cmd_set_log_type, 3875 (void *)&cmd_set_log_level, 3876 NULL, 3877 }, 3878 }; 3879 3880 /* *** SET SEGMENT LENGTHS OF TXONLY PACKETS *** */ 3881 3882 struct cmd_set_txpkts_result { 3883 cmdline_fixed_string_t cmd_keyword; 3884 cmdline_fixed_string_t txpkts; 3885 cmdline_fixed_string_t seg_lengths; 3886 }; 3887 3888 static void 3889 cmd_set_txpkts_parsed(void *parsed_result, 3890 __rte_unused struct cmdline *cl, 3891 __rte_unused void *data) 3892 { 3893 struct cmd_set_txpkts_result *res; 3894 unsigned seg_lengths[RTE_MAX_SEGS_PER_PKT]; 3895 unsigned int nb_segs; 3896 3897 res = parsed_result; 3898 nb_segs = parse_item_list(res->seg_lengths, "segment lengths", 3899 RTE_MAX_SEGS_PER_PKT, seg_lengths, 0); 3900 if (nb_segs > 0) 3901 set_tx_pkt_segments(seg_lengths, nb_segs); 3902 } 3903 3904 cmdline_parse_token_string_t cmd_set_txpkts_keyword = 3905 TOKEN_STRING_INITIALIZER(struct cmd_set_txpkts_result, 3906 cmd_keyword, "set"); 3907 cmdline_parse_token_string_t cmd_set_txpkts_name = 3908 TOKEN_STRING_INITIALIZER(struct cmd_set_txpkts_result, 3909 txpkts, "txpkts"); 3910 cmdline_parse_token_string_t cmd_set_txpkts_lengths = 3911 TOKEN_STRING_INITIALIZER(struct cmd_set_txpkts_result, 3912 seg_lengths, NULL); 3913 3914 cmdline_parse_inst_t cmd_set_txpkts = { 3915 .f = cmd_set_txpkts_parsed, 3916 .data = NULL, 3917 .help_str = "set txpkts <len0[,len1]*>", 3918 .tokens = { 3919 (void *)&cmd_set_txpkts_keyword, 3920 (void *)&cmd_set_txpkts_name, 3921 (void *)&cmd_set_txpkts_lengths, 3922 NULL, 3923 }, 3924 }; 3925 3926 /* *** SET COPY AND SPLIT POLICY ON TX PACKETS *** */ 3927 3928 struct cmd_set_txsplit_result { 3929 cmdline_fixed_string_t cmd_keyword; 3930 cmdline_fixed_string_t txsplit; 3931 cmdline_fixed_string_t mode; 3932 }; 3933 3934 static void 3935 cmd_set_txsplit_parsed(void *parsed_result, 3936 __rte_unused struct cmdline *cl, 3937 __rte_unused void *data) 3938 { 3939 struct cmd_set_txsplit_result *res; 3940 3941 res = parsed_result; 3942 set_tx_pkt_split(res->mode); 3943 } 3944 3945 cmdline_parse_token_string_t cmd_set_txsplit_keyword = 3946 TOKEN_STRING_INITIALIZER(struct cmd_set_txsplit_result, 3947 cmd_keyword, "set"); 3948 cmdline_parse_token_string_t cmd_set_txsplit_name = 3949 TOKEN_STRING_INITIALIZER(struct cmd_set_txsplit_result, 3950 txsplit, "txsplit"); 3951 cmdline_parse_token_string_t cmd_set_txsplit_mode = 3952 TOKEN_STRING_INITIALIZER(struct cmd_set_txsplit_result, 3953 mode, NULL); 3954 3955 cmdline_parse_inst_t cmd_set_txsplit = { 3956 .f = cmd_set_txsplit_parsed, 3957 .data = NULL, 3958 .help_str = "set txsplit on|off|rand", 3959 .tokens = { 3960 (void *)&cmd_set_txsplit_keyword, 3961 (void *)&cmd_set_txsplit_name, 3962 (void *)&cmd_set_txsplit_mode, 3963 NULL, 3964 }, 3965 }; 3966 3967 /* *** SET TIMES FOR TXONLY PACKETS SCHEDULING ON TIMESTAMPS *** */ 3968 3969 struct cmd_set_txtimes_result { 3970 cmdline_fixed_string_t cmd_keyword; 3971 cmdline_fixed_string_t txtimes; 3972 cmdline_fixed_string_t tx_times; 3973 }; 3974 3975 static void 3976 cmd_set_txtimes_parsed(void *parsed_result, 3977 __rte_unused struct cmdline *cl, 3978 __rte_unused void *data) 3979 { 3980 struct cmd_set_txtimes_result *res; 3981 unsigned int tx_times[2] = {0, 0}; 3982 unsigned int n_times; 3983 3984 res = parsed_result; 3985 n_times = parse_item_list(res->tx_times, "tx times", 3986 2, tx_times, 0); 3987 if (n_times == 2) 3988 set_tx_pkt_times(tx_times); 3989 } 3990 3991 cmdline_parse_token_string_t cmd_set_txtimes_keyword = 3992 TOKEN_STRING_INITIALIZER(struct cmd_set_txtimes_result, 3993 cmd_keyword, "set"); 3994 cmdline_parse_token_string_t cmd_set_txtimes_name = 3995 TOKEN_STRING_INITIALIZER(struct cmd_set_txtimes_result, 3996 txtimes, "txtimes"); 3997 cmdline_parse_token_string_t cmd_set_txtimes_value = 3998 TOKEN_STRING_INITIALIZER(struct cmd_set_txtimes_result, 3999 tx_times, NULL); 4000 4001 cmdline_parse_inst_t cmd_set_txtimes = { 4002 .f = cmd_set_txtimes_parsed, 4003 .data = NULL, 4004 .help_str = "set txtimes <inter_burst>,<intra_burst>", 4005 .tokens = { 4006 (void *)&cmd_set_txtimes_keyword, 4007 (void *)&cmd_set_txtimes_name, 4008 (void *)&cmd_set_txtimes_value, 4009 NULL, 4010 }, 4011 }; 4012 4013 /* *** ADD/REMOVE ALL VLAN IDENTIFIERS TO/FROM A PORT VLAN RX FILTER *** */ 4014 struct cmd_rx_vlan_filter_all_result { 4015 cmdline_fixed_string_t rx_vlan; 4016 cmdline_fixed_string_t what; 4017 cmdline_fixed_string_t all; 4018 portid_t port_id; 4019 }; 4020 4021 static void 4022 cmd_rx_vlan_filter_all_parsed(void *parsed_result, 4023 __rte_unused struct cmdline *cl, 4024 __rte_unused void *data) 4025 { 4026 struct cmd_rx_vlan_filter_all_result *res = parsed_result; 4027 4028 if (!strcmp(res->what, "add")) 4029 rx_vlan_all_filter_set(res->port_id, 1); 4030 else 4031 rx_vlan_all_filter_set(res->port_id, 0); 4032 } 4033 4034 cmdline_parse_token_string_t cmd_rx_vlan_filter_all_rx_vlan = 4035 TOKEN_STRING_INITIALIZER(struct cmd_rx_vlan_filter_all_result, 4036 rx_vlan, "rx_vlan"); 4037 cmdline_parse_token_string_t cmd_rx_vlan_filter_all_what = 4038 TOKEN_STRING_INITIALIZER(struct cmd_rx_vlan_filter_all_result, 4039 what, "add#rm"); 4040 cmdline_parse_token_string_t cmd_rx_vlan_filter_all_all = 4041 TOKEN_STRING_INITIALIZER(struct cmd_rx_vlan_filter_all_result, 4042 all, "all"); 4043 cmdline_parse_token_num_t cmd_rx_vlan_filter_all_portid = 4044 TOKEN_NUM_INITIALIZER(struct cmd_rx_vlan_filter_all_result, 4045 port_id, UINT16); 4046 4047 cmdline_parse_inst_t cmd_rx_vlan_filter_all = { 4048 .f = cmd_rx_vlan_filter_all_parsed, 4049 .data = NULL, 4050 .help_str = "rx_vlan add|rm all <port_id>: " 4051 "Add/Remove all identifiers to/from the set of VLAN " 4052 "identifiers filtered by a port", 4053 .tokens = { 4054 (void *)&cmd_rx_vlan_filter_all_rx_vlan, 4055 (void *)&cmd_rx_vlan_filter_all_what, 4056 (void *)&cmd_rx_vlan_filter_all_all, 4057 (void *)&cmd_rx_vlan_filter_all_portid, 4058 NULL, 4059 }, 4060 }; 4061 4062 /* *** VLAN OFFLOAD SET ON A PORT *** */ 4063 struct cmd_vlan_offload_result { 4064 cmdline_fixed_string_t vlan; 4065 cmdline_fixed_string_t set; 4066 cmdline_fixed_string_t vlan_type; 4067 cmdline_fixed_string_t what; 4068 cmdline_fixed_string_t on; 4069 cmdline_fixed_string_t port_id; 4070 }; 4071 4072 static void 4073 cmd_vlan_offload_parsed(void *parsed_result, 4074 __rte_unused struct cmdline *cl, 4075 __rte_unused void *data) 4076 { 4077 int on; 4078 struct cmd_vlan_offload_result *res = parsed_result; 4079 char *str; 4080 int i, len = 0; 4081 portid_t port_id = 0; 4082 unsigned int tmp; 4083 4084 str = res->port_id; 4085 len = strnlen(str, STR_TOKEN_SIZE); 4086 i = 0; 4087 /* Get port_id first */ 4088 while(i < len){ 4089 if(str[i] == ',') 4090 break; 4091 4092 i++; 4093 } 4094 str[i]='\0'; 4095 tmp = strtoul(str, NULL, 0); 4096 /* If port_id greater that what portid_t can represent, return */ 4097 if(tmp >= RTE_MAX_ETHPORTS) 4098 return; 4099 port_id = (portid_t)tmp; 4100 4101 if (!strcmp(res->on, "on")) 4102 on = 1; 4103 else 4104 on = 0; 4105 4106 if (!strcmp(res->what, "strip")) 4107 rx_vlan_strip_set(port_id, on); 4108 else if(!strcmp(res->what, "stripq")){ 4109 uint16_t queue_id = 0; 4110 4111 /* No queue_id, return */ 4112 if(i + 1 >= len) { 4113 printf("must specify (port,queue_id)\n"); 4114 return; 4115 } 4116 tmp = strtoul(str + i + 1, NULL, 0); 4117 /* If queue_id greater that what 16-bits can represent, return */ 4118 if(tmp > 0xffff) 4119 return; 4120 4121 queue_id = (uint16_t)tmp; 4122 rx_vlan_strip_set_on_queue(port_id, queue_id, on); 4123 } 4124 else if (!strcmp(res->what, "filter")) 4125 rx_vlan_filter_set(port_id, on); 4126 else if (!strcmp(res->what, "qinq_strip")) 4127 rx_vlan_qinq_strip_set(port_id, on); 4128 else 4129 vlan_extend_set(port_id, on); 4130 4131 return; 4132 } 4133 4134 cmdline_parse_token_string_t cmd_vlan_offload_vlan = 4135 TOKEN_STRING_INITIALIZER(struct cmd_vlan_offload_result, 4136 vlan, "vlan"); 4137 cmdline_parse_token_string_t cmd_vlan_offload_set = 4138 TOKEN_STRING_INITIALIZER(struct cmd_vlan_offload_result, 4139 set, "set"); 4140 cmdline_parse_token_string_t cmd_vlan_offload_what = 4141 TOKEN_STRING_INITIALIZER(struct cmd_vlan_offload_result, 4142 what, "strip#filter#qinq_strip#extend#stripq"); 4143 cmdline_parse_token_string_t cmd_vlan_offload_on = 4144 TOKEN_STRING_INITIALIZER(struct cmd_vlan_offload_result, 4145 on, "on#off"); 4146 cmdline_parse_token_string_t cmd_vlan_offload_portid = 4147 TOKEN_STRING_INITIALIZER(struct cmd_vlan_offload_result, 4148 port_id, NULL); 4149 4150 cmdline_parse_inst_t cmd_vlan_offload = { 4151 .f = cmd_vlan_offload_parsed, 4152 .data = NULL, 4153 .help_str = "vlan set strip|filter|qinq_strip|extend|stripq on|off " 4154 "<port_id[,queue_id]>: " 4155 "Strip/Filter/QinQ for rx side Extend for both rx/tx sides", 4156 .tokens = { 4157 (void *)&cmd_vlan_offload_vlan, 4158 (void *)&cmd_vlan_offload_set, 4159 (void *)&cmd_vlan_offload_what, 4160 (void *)&cmd_vlan_offload_on, 4161 (void *)&cmd_vlan_offload_portid, 4162 NULL, 4163 }, 4164 }; 4165 4166 /* *** VLAN TPID SET ON A PORT *** */ 4167 struct cmd_vlan_tpid_result { 4168 cmdline_fixed_string_t vlan; 4169 cmdline_fixed_string_t set; 4170 cmdline_fixed_string_t vlan_type; 4171 cmdline_fixed_string_t what; 4172 uint16_t tp_id; 4173 portid_t port_id; 4174 }; 4175 4176 static void 4177 cmd_vlan_tpid_parsed(void *parsed_result, 4178 __rte_unused struct cmdline *cl, 4179 __rte_unused void *data) 4180 { 4181 struct cmd_vlan_tpid_result *res = parsed_result; 4182 enum rte_vlan_type vlan_type; 4183 4184 if (!strcmp(res->vlan_type, "inner")) 4185 vlan_type = ETH_VLAN_TYPE_INNER; 4186 else if (!strcmp(res->vlan_type, "outer")) 4187 vlan_type = ETH_VLAN_TYPE_OUTER; 4188 else { 4189 printf("Unknown vlan type\n"); 4190 return; 4191 } 4192 vlan_tpid_set(res->port_id, vlan_type, res->tp_id); 4193 } 4194 4195 cmdline_parse_token_string_t cmd_vlan_tpid_vlan = 4196 TOKEN_STRING_INITIALIZER(struct cmd_vlan_tpid_result, 4197 vlan, "vlan"); 4198 cmdline_parse_token_string_t cmd_vlan_tpid_set = 4199 TOKEN_STRING_INITIALIZER(struct cmd_vlan_tpid_result, 4200 set, "set"); 4201 cmdline_parse_token_string_t cmd_vlan_type = 4202 TOKEN_STRING_INITIALIZER(struct cmd_vlan_tpid_result, 4203 vlan_type, "inner#outer"); 4204 cmdline_parse_token_string_t cmd_vlan_tpid_what = 4205 TOKEN_STRING_INITIALIZER(struct cmd_vlan_tpid_result, 4206 what, "tpid"); 4207 cmdline_parse_token_num_t cmd_vlan_tpid_tpid = 4208 TOKEN_NUM_INITIALIZER(struct cmd_vlan_tpid_result, 4209 tp_id, UINT16); 4210 cmdline_parse_token_num_t cmd_vlan_tpid_portid = 4211 TOKEN_NUM_INITIALIZER(struct cmd_vlan_tpid_result, 4212 port_id, UINT16); 4213 4214 cmdline_parse_inst_t cmd_vlan_tpid = { 4215 .f = cmd_vlan_tpid_parsed, 4216 .data = NULL, 4217 .help_str = "vlan set inner|outer tpid <tp_id> <port_id>: " 4218 "Set the VLAN Ether type", 4219 .tokens = { 4220 (void *)&cmd_vlan_tpid_vlan, 4221 (void *)&cmd_vlan_tpid_set, 4222 (void *)&cmd_vlan_type, 4223 (void *)&cmd_vlan_tpid_what, 4224 (void *)&cmd_vlan_tpid_tpid, 4225 (void *)&cmd_vlan_tpid_portid, 4226 NULL, 4227 }, 4228 }; 4229 4230 /* *** ADD/REMOVE A VLAN IDENTIFIER TO/FROM A PORT VLAN RX FILTER *** */ 4231 struct cmd_rx_vlan_filter_result { 4232 cmdline_fixed_string_t rx_vlan; 4233 cmdline_fixed_string_t what; 4234 uint16_t vlan_id; 4235 portid_t port_id; 4236 }; 4237 4238 static void 4239 cmd_rx_vlan_filter_parsed(void *parsed_result, 4240 __rte_unused struct cmdline *cl, 4241 __rte_unused void *data) 4242 { 4243 struct cmd_rx_vlan_filter_result *res = parsed_result; 4244 4245 if (!strcmp(res->what, "add")) 4246 rx_vft_set(res->port_id, res->vlan_id, 1); 4247 else 4248 rx_vft_set(res->port_id, res->vlan_id, 0); 4249 } 4250 4251 cmdline_parse_token_string_t cmd_rx_vlan_filter_rx_vlan = 4252 TOKEN_STRING_INITIALIZER(struct cmd_rx_vlan_filter_result, 4253 rx_vlan, "rx_vlan"); 4254 cmdline_parse_token_string_t cmd_rx_vlan_filter_what = 4255 TOKEN_STRING_INITIALIZER(struct cmd_rx_vlan_filter_result, 4256 what, "add#rm"); 4257 cmdline_parse_token_num_t cmd_rx_vlan_filter_vlanid = 4258 TOKEN_NUM_INITIALIZER(struct cmd_rx_vlan_filter_result, 4259 vlan_id, UINT16); 4260 cmdline_parse_token_num_t cmd_rx_vlan_filter_portid = 4261 TOKEN_NUM_INITIALIZER(struct cmd_rx_vlan_filter_result, 4262 port_id, UINT16); 4263 4264 cmdline_parse_inst_t cmd_rx_vlan_filter = { 4265 .f = cmd_rx_vlan_filter_parsed, 4266 .data = NULL, 4267 .help_str = "rx_vlan add|rm <vlan_id> <port_id>: " 4268 "Add/Remove a VLAN identifier to/from the set of VLAN " 4269 "identifiers filtered by a port", 4270 .tokens = { 4271 (void *)&cmd_rx_vlan_filter_rx_vlan, 4272 (void *)&cmd_rx_vlan_filter_what, 4273 (void *)&cmd_rx_vlan_filter_vlanid, 4274 (void *)&cmd_rx_vlan_filter_portid, 4275 NULL, 4276 }, 4277 }; 4278 4279 /* *** ENABLE HARDWARE INSERTION OF VLAN HEADER IN TX PACKETS *** */ 4280 struct cmd_tx_vlan_set_result { 4281 cmdline_fixed_string_t tx_vlan; 4282 cmdline_fixed_string_t set; 4283 portid_t port_id; 4284 uint16_t vlan_id; 4285 }; 4286 4287 static void 4288 cmd_tx_vlan_set_parsed(void *parsed_result, 4289 __rte_unused struct cmdline *cl, 4290 __rte_unused void *data) 4291 { 4292 struct cmd_tx_vlan_set_result *res = parsed_result; 4293 4294 if (!port_is_stopped(res->port_id)) { 4295 printf("Please stop port %d first\n", res->port_id); 4296 return; 4297 } 4298 4299 tx_vlan_set(res->port_id, res->vlan_id); 4300 4301 cmd_reconfig_device_queue(res->port_id, 1, 1); 4302 } 4303 4304 cmdline_parse_token_string_t cmd_tx_vlan_set_tx_vlan = 4305 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_result, 4306 tx_vlan, "tx_vlan"); 4307 cmdline_parse_token_string_t cmd_tx_vlan_set_set = 4308 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_result, 4309 set, "set"); 4310 cmdline_parse_token_num_t cmd_tx_vlan_set_portid = 4311 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_result, 4312 port_id, UINT16); 4313 cmdline_parse_token_num_t cmd_tx_vlan_set_vlanid = 4314 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_result, 4315 vlan_id, UINT16); 4316 4317 cmdline_parse_inst_t cmd_tx_vlan_set = { 4318 .f = cmd_tx_vlan_set_parsed, 4319 .data = NULL, 4320 .help_str = "tx_vlan set <port_id> <vlan_id>: " 4321 "Enable hardware insertion of a single VLAN header " 4322 "with a given TAG Identifier in packets sent on a port", 4323 .tokens = { 4324 (void *)&cmd_tx_vlan_set_tx_vlan, 4325 (void *)&cmd_tx_vlan_set_set, 4326 (void *)&cmd_tx_vlan_set_portid, 4327 (void *)&cmd_tx_vlan_set_vlanid, 4328 NULL, 4329 }, 4330 }; 4331 4332 /* *** ENABLE HARDWARE INSERTION OF Double VLAN HEADER IN TX PACKETS *** */ 4333 struct cmd_tx_vlan_set_qinq_result { 4334 cmdline_fixed_string_t tx_vlan; 4335 cmdline_fixed_string_t set; 4336 portid_t port_id; 4337 uint16_t vlan_id; 4338 uint16_t vlan_id_outer; 4339 }; 4340 4341 static void 4342 cmd_tx_vlan_set_qinq_parsed(void *parsed_result, 4343 __rte_unused struct cmdline *cl, 4344 __rte_unused void *data) 4345 { 4346 struct cmd_tx_vlan_set_qinq_result *res = parsed_result; 4347 4348 if (!port_is_stopped(res->port_id)) { 4349 printf("Please stop port %d first\n", res->port_id); 4350 return; 4351 } 4352 4353 tx_qinq_set(res->port_id, res->vlan_id, res->vlan_id_outer); 4354 4355 cmd_reconfig_device_queue(res->port_id, 1, 1); 4356 } 4357 4358 cmdline_parse_token_string_t cmd_tx_vlan_set_qinq_tx_vlan = 4359 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_qinq_result, 4360 tx_vlan, "tx_vlan"); 4361 cmdline_parse_token_string_t cmd_tx_vlan_set_qinq_set = 4362 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_qinq_result, 4363 set, "set"); 4364 cmdline_parse_token_num_t cmd_tx_vlan_set_qinq_portid = 4365 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_qinq_result, 4366 port_id, UINT16); 4367 cmdline_parse_token_num_t cmd_tx_vlan_set_qinq_vlanid = 4368 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_qinq_result, 4369 vlan_id, UINT16); 4370 cmdline_parse_token_num_t cmd_tx_vlan_set_qinq_vlanid_outer = 4371 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_qinq_result, 4372 vlan_id_outer, UINT16); 4373 4374 cmdline_parse_inst_t cmd_tx_vlan_set_qinq = { 4375 .f = cmd_tx_vlan_set_qinq_parsed, 4376 .data = NULL, 4377 .help_str = "tx_vlan set <port_id> <vlan_id> <outer_vlan_id>: " 4378 "Enable hardware insertion of double VLAN header " 4379 "with given TAG Identifiers in packets sent on a port", 4380 .tokens = { 4381 (void *)&cmd_tx_vlan_set_qinq_tx_vlan, 4382 (void *)&cmd_tx_vlan_set_qinq_set, 4383 (void *)&cmd_tx_vlan_set_qinq_portid, 4384 (void *)&cmd_tx_vlan_set_qinq_vlanid, 4385 (void *)&cmd_tx_vlan_set_qinq_vlanid_outer, 4386 NULL, 4387 }, 4388 }; 4389 4390 /* *** ENABLE/DISABLE PORT BASED TX VLAN INSERTION *** */ 4391 struct cmd_tx_vlan_set_pvid_result { 4392 cmdline_fixed_string_t tx_vlan; 4393 cmdline_fixed_string_t set; 4394 cmdline_fixed_string_t pvid; 4395 portid_t port_id; 4396 uint16_t vlan_id; 4397 cmdline_fixed_string_t mode; 4398 }; 4399 4400 static void 4401 cmd_tx_vlan_set_pvid_parsed(void *parsed_result, 4402 __rte_unused struct cmdline *cl, 4403 __rte_unused void *data) 4404 { 4405 struct cmd_tx_vlan_set_pvid_result *res = parsed_result; 4406 4407 if (strcmp(res->mode, "on") == 0) 4408 tx_vlan_pvid_set(res->port_id, res->vlan_id, 1); 4409 else 4410 tx_vlan_pvid_set(res->port_id, res->vlan_id, 0); 4411 } 4412 4413 cmdline_parse_token_string_t cmd_tx_vlan_set_pvid_tx_vlan = 4414 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_pvid_result, 4415 tx_vlan, "tx_vlan"); 4416 cmdline_parse_token_string_t cmd_tx_vlan_set_pvid_set = 4417 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_pvid_result, 4418 set, "set"); 4419 cmdline_parse_token_string_t cmd_tx_vlan_set_pvid_pvid = 4420 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_pvid_result, 4421 pvid, "pvid"); 4422 cmdline_parse_token_num_t cmd_tx_vlan_set_pvid_port_id = 4423 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_pvid_result, 4424 port_id, UINT16); 4425 cmdline_parse_token_num_t cmd_tx_vlan_set_pvid_vlan_id = 4426 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_pvid_result, 4427 vlan_id, UINT16); 4428 cmdline_parse_token_string_t cmd_tx_vlan_set_pvid_mode = 4429 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_pvid_result, 4430 mode, "on#off"); 4431 4432 cmdline_parse_inst_t cmd_tx_vlan_set_pvid = { 4433 .f = cmd_tx_vlan_set_pvid_parsed, 4434 .data = NULL, 4435 .help_str = "tx_vlan set pvid <port_id> <vlan_id> on|off", 4436 .tokens = { 4437 (void *)&cmd_tx_vlan_set_pvid_tx_vlan, 4438 (void *)&cmd_tx_vlan_set_pvid_set, 4439 (void *)&cmd_tx_vlan_set_pvid_pvid, 4440 (void *)&cmd_tx_vlan_set_pvid_port_id, 4441 (void *)&cmd_tx_vlan_set_pvid_vlan_id, 4442 (void *)&cmd_tx_vlan_set_pvid_mode, 4443 NULL, 4444 }, 4445 }; 4446 4447 /* *** DISABLE HARDWARE INSERTION OF VLAN HEADER IN TX PACKETS *** */ 4448 struct cmd_tx_vlan_reset_result { 4449 cmdline_fixed_string_t tx_vlan; 4450 cmdline_fixed_string_t reset; 4451 portid_t port_id; 4452 }; 4453 4454 static void 4455 cmd_tx_vlan_reset_parsed(void *parsed_result, 4456 __rte_unused struct cmdline *cl, 4457 __rte_unused void *data) 4458 { 4459 struct cmd_tx_vlan_reset_result *res = parsed_result; 4460 4461 if (!port_is_stopped(res->port_id)) { 4462 printf("Please stop port %d first\n", res->port_id); 4463 return; 4464 } 4465 4466 tx_vlan_reset(res->port_id); 4467 4468 cmd_reconfig_device_queue(res->port_id, 1, 1); 4469 } 4470 4471 cmdline_parse_token_string_t cmd_tx_vlan_reset_tx_vlan = 4472 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_reset_result, 4473 tx_vlan, "tx_vlan"); 4474 cmdline_parse_token_string_t cmd_tx_vlan_reset_reset = 4475 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_reset_result, 4476 reset, "reset"); 4477 cmdline_parse_token_num_t cmd_tx_vlan_reset_portid = 4478 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_reset_result, 4479 port_id, UINT16); 4480 4481 cmdline_parse_inst_t cmd_tx_vlan_reset = { 4482 .f = cmd_tx_vlan_reset_parsed, 4483 .data = NULL, 4484 .help_str = "tx_vlan reset <port_id>: Disable hardware insertion of a " 4485 "VLAN header in packets sent on a port", 4486 .tokens = { 4487 (void *)&cmd_tx_vlan_reset_tx_vlan, 4488 (void *)&cmd_tx_vlan_reset_reset, 4489 (void *)&cmd_tx_vlan_reset_portid, 4490 NULL, 4491 }, 4492 }; 4493 4494 4495 /* *** ENABLE HARDWARE INSERTION OF CHECKSUM IN TX PACKETS *** */ 4496 struct cmd_csum_result { 4497 cmdline_fixed_string_t csum; 4498 cmdline_fixed_string_t mode; 4499 cmdline_fixed_string_t proto; 4500 cmdline_fixed_string_t hwsw; 4501 portid_t port_id; 4502 }; 4503 4504 static void 4505 csum_show(int port_id) 4506 { 4507 struct rte_eth_dev_info dev_info; 4508 uint64_t tx_offloads; 4509 int ret; 4510 4511 tx_offloads = ports[port_id].dev_conf.txmode.offloads; 4512 printf("Parse tunnel is %s\n", 4513 (ports[port_id].parse_tunnel) ? "on" : "off"); 4514 printf("IP checksum offload is %s\n", 4515 (tx_offloads & DEV_TX_OFFLOAD_IPV4_CKSUM) ? "hw" : "sw"); 4516 printf("UDP checksum offload is %s\n", 4517 (tx_offloads & DEV_TX_OFFLOAD_UDP_CKSUM) ? "hw" : "sw"); 4518 printf("TCP checksum offload is %s\n", 4519 (tx_offloads & DEV_TX_OFFLOAD_TCP_CKSUM) ? "hw" : "sw"); 4520 printf("SCTP checksum offload is %s\n", 4521 (tx_offloads & DEV_TX_OFFLOAD_SCTP_CKSUM) ? "hw" : "sw"); 4522 printf("Outer-Ip checksum offload is %s\n", 4523 (tx_offloads & DEV_TX_OFFLOAD_OUTER_IPV4_CKSUM) ? "hw" : "sw"); 4524 printf("Outer-Udp checksum offload is %s\n", 4525 (tx_offloads & DEV_TX_OFFLOAD_OUTER_UDP_CKSUM) ? "hw" : "sw"); 4526 4527 /* display warnings if configuration is not supported by the NIC */ 4528 ret = eth_dev_info_get_print_err(port_id, &dev_info); 4529 if (ret != 0) 4530 return; 4531 4532 if ((tx_offloads & DEV_TX_OFFLOAD_IPV4_CKSUM) && 4533 (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_IPV4_CKSUM) == 0) { 4534 printf("Warning: hardware IP checksum enabled but not " 4535 "supported by port %d\n", port_id); 4536 } 4537 if ((tx_offloads & DEV_TX_OFFLOAD_UDP_CKSUM) && 4538 (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_UDP_CKSUM) == 0) { 4539 printf("Warning: hardware UDP checksum enabled but not " 4540 "supported by port %d\n", port_id); 4541 } 4542 if ((tx_offloads & DEV_TX_OFFLOAD_TCP_CKSUM) && 4543 (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_TCP_CKSUM) == 0) { 4544 printf("Warning: hardware TCP checksum enabled but not " 4545 "supported by port %d\n", port_id); 4546 } 4547 if ((tx_offloads & DEV_TX_OFFLOAD_SCTP_CKSUM) && 4548 (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_SCTP_CKSUM) == 0) { 4549 printf("Warning: hardware SCTP checksum enabled but not " 4550 "supported by port %d\n", port_id); 4551 } 4552 if ((tx_offloads & DEV_TX_OFFLOAD_OUTER_IPV4_CKSUM) && 4553 (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_OUTER_IPV4_CKSUM) == 0) { 4554 printf("Warning: hardware outer IP checksum enabled but not " 4555 "supported by port %d\n", port_id); 4556 } 4557 if ((tx_offloads & DEV_TX_OFFLOAD_OUTER_UDP_CKSUM) && 4558 (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_OUTER_UDP_CKSUM) 4559 == 0) { 4560 printf("Warning: hardware outer UDP checksum enabled but not " 4561 "supported by port %d\n", port_id); 4562 } 4563 } 4564 4565 static void 4566 cmd_config_queue_tx_offloads(struct rte_port *port) 4567 { 4568 int k; 4569 4570 /* Apply queue tx offloads configuration */ 4571 for (k = 0; k < port->dev_info.max_rx_queues; k++) 4572 port->tx_conf[k].offloads = 4573 port->dev_conf.txmode.offloads; 4574 } 4575 4576 static void 4577 cmd_csum_parsed(void *parsed_result, 4578 __rte_unused struct cmdline *cl, 4579 __rte_unused void *data) 4580 { 4581 struct cmd_csum_result *res = parsed_result; 4582 int hw = 0; 4583 uint64_t csum_offloads = 0; 4584 struct rte_eth_dev_info dev_info; 4585 int ret; 4586 4587 if (port_id_is_invalid(res->port_id, ENABLED_WARN)) { 4588 printf("invalid port %d\n", res->port_id); 4589 return; 4590 } 4591 if (!port_is_stopped(res->port_id)) { 4592 printf("Please stop port %d first\n", res->port_id); 4593 return; 4594 } 4595 4596 ret = eth_dev_info_get_print_err(res->port_id, &dev_info); 4597 if (ret != 0) 4598 return; 4599 4600 if (!strcmp(res->mode, "set")) { 4601 4602 if (!strcmp(res->hwsw, "hw")) 4603 hw = 1; 4604 4605 if (!strcmp(res->proto, "ip")) { 4606 if (hw == 0 || (dev_info.tx_offload_capa & 4607 DEV_TX_OFFLOAD_IPV4_CKSUM)) { 4608 csum_offloads |= DEV_TX_OFFLOAD_IPV4_CKSUM; 4609 } else { 4610 printf("IP checksum offload is not supported " 4611 "by port %u\n", res->port_id); 4612 } 4613 } else if (!strcmp(res->proto, "udp")) { 4614 if (hw == 0 || (dev_info.tx_offload_capa & 4615 DEV_TX_OFFLOAD_UDP_CKSUM)) { 4616 csum_offloads |= DEV_TX_OFFLOAD_UDP_CKSUM; 4617 } else { 4618 printf("UDP checksum offload is not supported " 4619 "by port %u\n", res->port_id); 4620 } 4621 } else if (!strcmp(res->proto, "tcp")) { 4622 if (hw == 0 || (dev_info.tx_offload_capa & 4623 DEV_TX_OFFLOAD_TCP_CKSUM)) { 4624 csum_offloads |= DEV_TX_OFFLOAD_TCP_CKSUM; 4625 } else { 4626 printf("TCP checksum offload is not supported " 4627 "by port %u\n", res->port_id); 4628 } 4629 } else if (!strcmp(res->proto, "sctp")) { 4630 if (hw == 0 || (dev_info.tx_offload_capa & 4631 DEV_TX_OFFLOAD_SCTP_CKSUM)) { 4632 csum_offloads |= DEV_TX_OFFLOAD_SCTP_CKSUM; 4633 } else { 4634 printf("SCTP checksum offload is not supported " 4635 "by port %u\n", res->port_id); 4636 } 4637 } else if (!strcmp(res->proto, "outer-ip")) { 4638 if (hw == 0 || (dev_info.tx_offload_capa & 4639 DEV_TX_OFFLOAD_OUTER_IPV4_CKSUM)) { 4640 csum_offloads |= 4641 DEV_TX_OFFLOAD_OUTER_IPV4_CKSUM; 4642 } else { 4643 printf("Outer IP checksum offload is not " 4644 "supported by port %u\n", res->port_id); 4645 } 4646 } else if (!strcmp(res->proto, "outer-udp")) { 4647 if (hw == 0 || (dev_info.tx_offload_capa & 4648 DEV_TX_OFFLOAD_OUTER_UDP_CKSUM)) { 4649 csum_offloads |= 4650 DEV_TX_OFFLOAD_OUTER_UDP_CKSUM; 4651 } else { 4652 printf("Outer UDP checksum offload is not " 4653 "supported by port %u\n", res->port_id); 4654 } 4655 } 4656 4657 if (hw) { 4658 ports[res->port_id].dev_conf.txmode.offloads |= 4659 csum_offloads; 4660 } else { 4661 ports[res->port_id].dev_conf.txmode.offloads &= 4662 (~csum_offloads); 4663 } 4664 cmd_config_queue_tx_offloads(&ports[res->port_id]); 4665 } 4666 csum_show(res->port_id); 4667 4668 cmd_reconfig_device_queue(res->port_id, 1, 1); 4669 } 4670 4671 cmdline_parse_token_string_t cmd_csum_csum = 4672 TOKEN_STRING_INITIALIZER(struct cmd_csum_result, 4673 csum, "csum"); 4674 cmdline_parse_token_string_t cmd_csum_mode = 4675 TOKEN_STRING_INITIALIZER(struct cmd_csum_result, 4676 mode, "set"); 4677 cmdline_parse_token_string_t cmd_csum_proto = 4678 TOKEN_STRING_INITIALIZER(struct cmd_csum_result, 4679 proto, "ip#tcp#udp#sctp#outer-ip#outer-udp"); 4680 cmdline_parse_token_string_t cmd_csum_hwsw = 4681 TOKEN_STRING_INITIALIZER(struct cmd_csum_result, 4682 hwsw, "hw#sw"); 4683 cmdline_parse_token_num_t cmd_csum_portid = 4684 TOKEN_NUM_INITIALIZER(struct cmd_csum_result, 4685 port_id, UINT16); 4686 4687 cmdline_parse_inst_t cmd_csum_set = { 4688 .f = cmd_csum_parsed, 4689 .data = NULL, 4690 .help_str = "csum set ip|tcp|udp|sctp|outer-ip|outer-udp hw|sw <port_id>: " 4691 "Enable/Disable hardware calculation of L3/L4 checksum when " 4692 "using csum forward engine", 4693 .tokens = { 4694 (void *)&cmd_csum_csum, 4695 (void *)&cmd_csum_mode, 4696 (void *)&cmd_csum_proto, 4697 (void *)&cmd_csum_hwsw, 4698 (void *)&cmd_csum_portid, 4699 NULL, 4700 }, 4701 }; 4702 4703 cmdline_parse_token_string_t cmd_csum_mode_show = 4704 TOKEN_STRING_INITIALIZER(struct cmd_csum_result, 4705 mode, "show"); 4706 4707 cmdline_parse_inst_t cmd_csum_show = { 4708 .f = cmd_csum_parsed, 4709 .data = NULL, 4710 .help_str = "csum show <port_id>: Show checksum offload configuration", 4711 .tokens = { 4712 (void *)&cmd_csum_csum, 4713 (void *)&cmd_csum_mode_show, 4714 (void *)&cmd_csum_portid, 4715 NULL, 4716 }, 4717 }; 4718 4719 /* Enable/disable tunnel parsing */ 4720 struct cmd_csum_tunnel_result { 4721 cmdline_fixed_string_t csum; 4722 cmdline_fixed_string_t parse; 4723 cmdline_fixed_string_t onoff; 4724 portid_t port_id; 4725 }; 4726 4727 static void 4728 cmd_csum_tunnel_parsed(void *parsed_result, 4729 __rte_unused struct cmdline *cl, 4730 __rte_unused void *data) 4731 { 4732 struct cmd_csum_tunnel_result *res = parsed_result; 4733 4734 if (port_id_is_invalid(res->port_id, ENABLED_WARN)) 4735 return; 4736 4737 if (!strcmp(res->onoff, "on")) 4738 ports[res->port_id].parse_tunnel = 1; 4739 else 4740 ports[res->port_id].parse_tunnel = 0; 4741 4742 csum_show(res->port_id); 4743 } 4744 4745 cmdline_parse_token_string_t cmd_csum_tunnel_csum = 4746 TOKEN_STRING_INITIALIZER(struct cmd_csum_tunnel_result, 4747 csum, "csum"); 4748 cmdline_parse_token_string_t cmd_csum_tunnel_parse = 4749 TOKEN_STRING_INITIALIZER(struct cmd_csum_tunnel_result, 4750 parse, "parse-tunnel"); 4751 cmdline_parse_token_string_t cmd_csum_tunnel_onoff = 4752 TOKEN_STRING_INITIALIZER(struct cmd_csum_tunnel_result, 4753 onoff, "on#off"); 4754 cmdline_parse_token_num_t cmd_csum_tunnel_portid = 4755 TOKEN_NUM_INITIALIZER(struct cmd_csum_tunnel_result, 4756 port_id, UINT16); 4757 4758 cmdline_parse_inst_t cmd_csum_tunnel = { 4759 .f = cmd_csum_tunnel_parsed, 4760 .data = NULL, 4761 .help_str = "csum parse-tunnel on|off <port_id>: " 4762 "Enable/Disable parsing of tunnels for csum engine", 4763 .tokens = { 4764 (void *)&cmd_csum_tunnel_csum, 4765 (void *)&cmd_csum_tunnel_parse, 4766 (void *)&cmd_csum_tunnel_onoff, 4767 (void *)&cmd_csum_tunnel_portid, 4768 NULL, 4769 }, 4770 }; 4771 4772 /* *** ENABLE HARDWARE SEGMENTATION IN TX NON-TUNNELED PACKETS *** */ 4773 struct cmd_tso_set_result { 4774 cmdline_fixed_string_t tso; 4775 cmdline_fixed_string_t mode; 4776 uint16_t tso_segsz; 4777 portid_t port_id; 4778 }; 4779 4780 static void 4781 cmd_tso_set_parsed(void *parsed_result, 4782 __rte_unused struct cmdline *cl, 4783 __rte_unused void *data) 4784 { 4785 struct cmd_tso_set_result *res = parsed_result; 4786 struct rte_eth_dev_info dev_info; 4787 int ret; 4788 4789 if (port_id_is_invalid(res->port_id, ENABLED_WARN)) 4790 return; 4791 if (!port_is_stopped(res->port_id)) { 4792 printf("Please stop port %d first\n", res->port_id); 4793 return; 4794 } 4795 4796 if (!strcmp(res->mode, "set")) 4797 ports[res->port_id].tso_segsz = res->tso_segsz; 4798 4799 ret = eth_dev_info_get_print_err(res->port_id, &dev_info); 4800 if (ret != 0) 4801 return; 4802 4803 if ((ports[res->port_id].tso_segsz != 0) && 4804 (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_TCP_TSO) == 0) { 4805 printf("Error: TSO is not supported by port %d\n", 4806 res->port_id); 4807 return; 4808 } 4809 4810 if (ports[res->port_id].tso_segsz == 0) { 4811 ports[res->port_id].dev_conf.txmode.offloads &= 4812 ~DEV_TX_OFFLOAD_TCP_TSO; 4813 printf("TSO for non-tunneled packets is disabled\n"); 4814 } else { 4815 ports[res->port_id].dev_conf.txmode.offloads |= 4816 DEV_TX_OFFLOAD_TCP_TSO; 4817 printf("TSO segment size for non-tunneled packets is %d\n", 4818 ports[res->port_id].tso_segsz); 4819 } 4820 cmd_config_queue_tx_offloads(&ports[res->port_id]); 4821 4822 /* display warnings if configuration is not supported by the NIC */ 4823 ret = eth_dev_info_get_print_err(res->port_id, &dev_info); 4824 if (ret != 0) 4825 return; 4826 4827 if ((ports[res->port_id].tso_segsz != 0) && 4828 (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_TCP_TSO) == 0) { 4829 printf("Warning: TSO enabled but not " 4830 "supported by port %d\n", res->port_id); 4831 } 4832 4833 cmd_reconfig_device_queue(res->port_id, 1, 1); 4834 } 4835 4836 cmdline_parse_token_string_t cmd_tso_set_tso = 4837 TOKEN_STRING_INITIALIZER(struct cmd_tso_set_result, 4838 tso, "tso"); 4839 cmdline_parse_token_string_t cmd_tso_set_mode = 4840 TOKEN_STRING_INITIALIZER(struct cmd_tso_set_result, 4841 mode, "set"); 4842 cmdline_parse_token_num_t cmd_tso_set_tso_segsz = 4843 TOKEN_NUM_INITIALIZER(struct cmd_tso_set_result, 4844 tso_segsz, UINT16); 4845 cmdline_parse_token_num_t cmd_tso_set_portid = 4846 TOKEN_NUM_INITIALIZER(struct cmd_tso_set_result, 4847 port_id, UINT16); 4848 4849 cmdline_parse_inst_t cmd_tso_set = { 4850 .f = cmd_tso_set_parsed, 4851 .data = NULL, 4852 .help_str = "tso set <tso_segsz> <port_id>: " 4853 "Set TSO segment size of non-tunneled packets for csum engine " 4854 "(0 to disable)", 4855 .tokens = { 4856 (void *)&cmd_tso_set_tso, 4857 (void *)&cmd_tso_set_mode, 4858 (void *)&cmd_tso_set_tso_segsz, 4859 (void *)&cmd_tso_set_portid, 4860 NULL, 4861 }, 4862 }; 4863 4864 cmdline_parse_token_string_t cmd_tso_show_mode = 4865 TOKEN_STRING_INITIALIZER(struct cmd_tso_set_result, 4866 mode, "show"); 4867 4868 4869 cmdline_parse_inst_t cmd_tso_show = { 4870 .f = cmd_tso_set_parsed, 4871 .data = NULL, 4872 .help_str = "tso show <port_id>: " 4873 "Show TSO segment size of non-tunneled packets for csum engine", 4874 .tokens = { 4875 (void *)&cmd_tso_set_tso, 4876 (void *)&cmd_tso_show_mode, 4877 (void *)&cmd_tso_set_portid, 4878 NULL, 4879 }, 4880 }; 4881 4882 /* *** ENABLE HARDWARE SEGMENTATION IN TX TUNNELED PACKETS *** */ 4883 struct cmd_tunnel_tso_set_result { 4884 cmdline_fixed_string_t tso; 4885 cmdline_fixed_string_t mode; 4886 uint16_t tso_segsz; 4887 portid_t port_id; 4888 }; 4889 4890 static struct rte_eth_dev_info 4891 check_tunnel_tso_nic_support(portid_t port_id) 4892 { 4893 struct rte_eth_dev_info dev_info; 4894 4895 if (eth_dev_info_get_print_err(port_id, &dev_info) != 0) 4896 return dev_info; 4897 4898 if (!(dev_info.tx_offload_capa & DEV_TX_OFFLOAD_VXLAN_TNL_TSO)) 4899 printf("Warning: VXLAN TUNNEL TSO not supported therefore " 4900 "not enabled for port %d\n", port_id); 4901 if (!(dev_info.tx_offload_capa & DEV_TX_OFFLOAD_GRE_TNL_TSO)) 4902 printf("Warning: GRE TUNNEL TSO not supported therefore " 4903 "not enabled for port %d\n", port_id); 4904 if (!(dev_info.tx_offload_capa & DEV_TX_OFFLOAD_IPIP_TNL_TSO)) 4905 printf("Warning: IPIP TUNNEL TSO not supported therefore " 4906 "not enabled for port %d\n", port_id); 4907 if (!(dev_info.tx_offload_capa & DEV_TX_OFFLOAD_GENEVE_TNL_TSO)) 4908 printf("Warning: GENEVE TUNNEL TSO not supported therefore " 4909 "not enabled for port %d\n", port_id); 4910 if (!(dev_info.tx_offload_capa & DEV_TX_OFFLOAD_IP_TNL_TSO)) 4911 printf("Warning: IP TUNNEL TSO not supported therefore " 4912 "not enabled for port %d\n", port_id); 4913 if (!(dev_info.tx_offload_capa & DEV_TX_OFFLOAD_UDP_TNL_TSO)) 4914 printf("Warning: UDP TUNNEL TSO not supported therefore " 4915 "not enabled for port %d\n", port_id); 4916 return dev_info; 4917 } 4918 4919 static void 4920 cmd_tunnel_tso_set_parsed(void *parsed_result, 4921 __rte_unused struct cmdline *cl, 4922 __rte_unused void *data) 4923 { 4924 struct cmd_tunnel_tso_set_result *res = parsed_result; 4925 struct rte_eth_dev_info dev_info; 4926 4927 if (port_id_is_invalid(res->port_id, ENABLED_WARN)) 4928 return; 4929 if (!port_is_stopped(res->port_id)) { 4930 printf("Please stop port %d first\n", res->port_id); 4931 return; 4932 } 4933 4934 if (!strcmp(res->mode, "set")) 4935 ports[res->port_id].tunnel_tso_segsz = res->tso_segsz; 4936 4937 dev_info = check_tunnel_tso_nic_support(res->port_id); 4938 if (ports[res->port_id].tunnel_tso_segsz == 0) { 4939 ports[res->port_id].dev_conf.txmode.offloads &= 4940 ~(DEV_TX_OFFLOAD_VXLAN_TNL_TSO | 4941 DEV_TX_OFFLOAD_GRE_TNL_TSO | 4942 DEV_TX_OFFLOAD_IPIP_TNL_TSO | 4943 DEV_TX_OFFLOAD_GENEVE_TNL_TSO | 4944 DEV_TX_OFFLOAD_IP_TNL_TSO | 4945 DEV_TX_OFFLOAD_UDP_TNL_TSO); 4946 printf("TSO for tunneled packets is disabled\n"); 4947 } else { 4948 uint64_t tso_offloads = (DEV_TX_OFFLOAD_VXLAN_TNL_TSO | 4949 DEV_TX_OFFLOAD_GRE_TNL_TSO | 4950 DEV_TX_OFFLOAD_IPIP_TNL_TSO | 4951 DEV_TX_OFFLOAD_GENEVE_TNL_TSO | 4952 DEV_TX_OFFLOAD_IP_TNL_TSO | 4953 DEV_TX_OFFLOAD_UDP_TNL_TSO); 4954 4955 ports[res->port_id].dev_conf.txmode.offloads |= 4956 (tso_offloads & dev_info.tx_offload_capa); 4957 printf("TSO segment size for tunneled packets is %d\n", 4958 ports[res->port_id].tunnel_tso_segsz); 4959 4960 /* Below conditions are needed to make it work: 4961 * (1) tunnel TSO is supported by the NIC; 4962 * (2) "csum parse_tunnel" must be set so that tunneled pkts 4963 * are recognized; 4964 * (3) for tunneled pkts with outer L3 of IPv4, 4965 * "csum set outer-ip" must be set to hw, because after tso, 4966 * total_len of outer IP header is changed, and the checksum 4967 * of outer IP header calculated by sw should be wrong; that 4968 * is not necessary for IPv6 tunneled pkts because there's no 4969 * checksum in IP header anymore. 4970 */ 4971 4972 if (!ports[res->port_id].parse_tunnel) 4973 printf("Warning: csum parse_tunnel must be set " 4974 "so that tunneled packets are recognized\n"); 4975 if (!(ports[res->port_id].dev_conf.txmode.offloads & 4976 DEV_TX_OFFLOAD_OUTER_IPV4_CKSUM)) 4977 printf("Warning: csum set outer-ip must be set to hw " 4978 "if outer L3 is IPv4; not necessary for IPv6\n"); 4979 } 4980 4981 cmd_config_queue_tx_offloads(&ports[res->port_id]); 4982 cmd_reconfig_device_queue(res->port_id, 1, 1); 4983 } 4984 4985 cmdline_parse_token_string_t cmd_tunnel_tso_set_tso = 4986 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_tso_set_result, 4987 tso, "tunnel_tso"); 4988 cmdline_parse_token_string_t cmd_tunnel_tso_set_mode = 4989 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_tso_set_result, 4990 mode, "set"); 4991 cmdline_parse_token_num_t cmd_tunnel_tso_set_tso_segsz = 4992 TOKEN_NUM_INITIALIZER(struct cmd_tunnel_tso_set_result, 4993 tso_segsz, UINT16); 4994 cmdline_parse_token_num_t cmd_tunnel_tso_set_portid = 4995 TOKEN_NUM_INITIALIZER(struct cmd_tunnel_tso_set_result, 4996 port_id, UINT16); 4997 4998 cmdline_parse_inst_t cmd_tunnel_tso_set = { 4999 .f = cmd_tunnel_tso_set_parsed, 5000 .data = NULL, 5001 .help_str = "tunnel_tso set <tso_segsz> <port_id>: " 5002 "Set TSO segment size of tunneled packets for csum engine " 5003 "(0 to disable)", 5004 .tokens = { 5005 (void *)&cmd_tunnel_tso_set_tso, 5006 (void *)&cmd_tunnel_tso_set_mode, 5007 (void *)&cmd_tunnel_tso_set_tso_segsz, 5008 (void *)&cmd_tunnel_tso_set_portid, 5009 NULL, 5010 }, 5011 }; 5012 5013 cmdline_parse_token_string_t cmd_tunnel_tso_show_mode = 5014 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_tso_set_result, 5015 mode, "show"); 5016 5017 5018 cmdline_parse_inst_t cmd_tunnel_tso_show = { 5019 .f = cmd_tunnel_tso_set_parsed, 5020 .data = NULL, 5021 .help_str = "tunnel_tso show <port_id> " 5022 "Show TSO segment size of tunneled packets for csum engine", 5023 .tokens = { 5024 (void *)&cmd_tunnel_tso_set_tso, 5025 (void *)&cmd_tunnel_tso_show_mode, 5026 (void *)&cmd_tunnel_tso_set_portid, 5027 NULL, 5028 }, 5029 }; 5030 5031 /* *** SET GRO FOR A PORT *** */ 5032 struct cmd_gro_enable_result { 5033 cmdline_fixed_string_t cmd_set; 5034 cmdline_fixed_string_t cmd_port; 5035 cmdline_fixed_string_t cmd_keyword; 5036 cmdline_fixed_string_t cmd_onoff; 5037 portid_t cmd_pid; 5038 }; 5039 5040 static void 5041 cmd_gro_enable_parsed(void *parsed_result, 5042 __rte_unused struct cmdline *cl, 5043 __rte_unused void *data) 5044 { 5045 struct cmd_gro_enable_result *res; 5046 5047 res = parsed_result; 5048 if (!strcmp(res->cmd_keyword, "gro")) 5049 setup_gro(res->cmd_onoff, res->cmd_pid); 5050 } 5051 5052 cmdline_parse_token_string_t cmd_gro_enable_set = 5053 TOKEN_STRING_INITIALIZER(struct cmd_gro_enable_result, 5054 cmd_set, "set"); 5055 cmdline_parse_token_string_t cmd_gro_enable_port = 5056 TOKEN_STRING_INITIALIZER(struct cmd_gro_enable_result, 5057 cmd_keyword, "port"); 5058 cmdline_parse_token_num_t cmd_gro_enable_pid = 5059 TOKEN_NUM_INITIALIZER(struct cmd_gro_enable_result, 5060 cmd_pid, UINT16); 5061 cmdline_parse_token_string_t cmd_gro_enable_keyword = 5062 TOKEN_STRING_INITIALIZER(struct cmd_gro_enable_result, 5063 cmd_keyword, "gro"); 5064 cmdline_parse_token_string_t cmd_gro_enable_onoff = 5065 TOKEN_STRING_INITIALIZER(struct cmd_gro_enable_result, 5066 cmd_onoff, "on#off"); 5067 5068 cmdline_parse_inst_t cmd_gro_enable = { 5069 .f = cmd_gro_enable_parsed, 5070 .data = NULL, 5071 .help_str = "set port <port_id> gro on|off", 5072 .tokens = { 5073 (void *)&cmd_gro_enable_set, 5074 (void *)&cmd_gro_enable_port, 5075 (void *)&cmd_gro_enable_pid, 5076 (void *)&cmd_gro_enable_keyword, 5077 (void *)&cmd_gro_enable_onoff, 5078 NULL, 5079 }, 5080 }; 5081 5082 /* *** DISPLAY GRO CONFIGURATION *** */ 5083 struct cmd_gro_show_result { 5084 cmdline_fixed_string_t cmd_show; 5085 cmdline_fixed_string_t cmd_port; 5086 cmdline_fixed_string_t cmd_keyword; 5087 portid_t cmd_pid; 5088 }; 5089 5090 static void 5091 cmd_gro_show_parsed(void *parsed_result, 5092 __rte_unused struct cmdline *cl, 5093 __rte_unused void *data) 5094 { 5095 struct cmd_gro_show_result *res; 5096 5097 res = parsed_result; 5098 if (!strcmp(res->cmd_keyword, "gro")) 5099 show_gro(res->cmd_pid); 5100 } 5101 5102 cmdline_parse_token_string_t cmd_gro_show_show = 5103 TOKEN_STRING_INITIALIZER(struct cmd_gro_show_result, 5104 cmd_show, "show"); 5105 cmdline_parse_token_string_t cmd_gro_show_port = 5106 TOKEN_STRING_INITIALIZER(struct cmd_gro_show_result, 5107 cmd_port, "port"); 5108 cmdline_parse_token_num_t cmd_gro_show_pid = 5109 TOKEN_NUM_INITIALIZER(struct cmd_gro_show_result, 5110 cmd_pid, UINT16); 5111 cmdline_parse_token_string_t cmd_gro_show_keyword = 5112 TOKEN_STRING_INITIALIZER(struct cmd_gro_show_result, 5113 cmd_keyword, "gro"); 5114 5115 cmdline_parse_inst_t cmd_gro_show = { 5116 .f = cmd_gro_show_parsed, 5117 .data = NULL, 5118 .help_str = "show port <port_id> gro", 5119 .tokens = { 5120 (void *)&cmd_gro_show_show, 5121 (void *)&cmd_gro_show_port, 5122 (void *)&cmd_gro_show_pid, 5123 (void *)&cmd_gro_show_keyword, 5124 NULL, 5125 }, 5126 }; 5127 5128 /* *** SET FLUSH CYCLES FOR GRO *** */ 5129 struct cmd_gro_flush_result { 5130 cmdline_fixed_string_t cmd_set; 5131 cmdline_fixed_string_t cmd_keyword; 5132 cmdline_fixed_string_t cmd_flush; 5133 uint8_t cmd_cycles; 5134 }; 5135 5136 static void 5137 cmd_gro_flush_parsed(void *parsed_result, 5138 __rte_unused struct cmdline *cl, 5139 __rte_unused void *data) 5140 { 5141 struct cmd_gro_flush_result *res; 5142 5143 res = parsed_result; 5144 if ((!strcmp(res->cmd_keyword, "gro")) && 5145 (!strcmp(res->cmd_flush, "flush"))) 5146 setup_gro_flush_cycles(res->cmd_cycles); 5147 } 5148 5149 cmdline_parse_token_string_t cmd_gro_flush_set = 5150 TOKEN_STRING_INITIALIZER(struct cmd_gro_flush_result, 5151 cmd_set, "set"); 5152 cmdline_parse_token_string_t cmd_gro_flush_keyword = 5153 TOKEN_STRING_INITIALIZER(struct cmd_gro_flush_result, 5154 cmd_keyword, "gro"); 5155 cmdline_parse_token_string_t cmd_gro_flush_flush = 5156 TOKEN_STRING_INITIALIZER(struct cmd_gro_flush_result, 5157 cmd_flush, "flush"); 5158 cmdline_parse_token_num_t cmd_gro_flush_cycles = 5159 TOKEN_NUM_INITIALIZER(struct cmd_gro_flush_result, 5160 cmd_cycles, UINT8); 5161 5162 cmdline_parse_inst_t cmd_gro_flush = { 5163 .f = cmd_gro_flush_parsed, 5164 .data = NULL, 5165 .help_str = "set gro flush <cycles>", 5166 .tokens = { 5167 (void *)&cmd_gro_flush_set, 5168 (void *)&cmd_gro_flush_keyword, 5169 (void *)&cmd_gro_flush_flush, 5170 (void *)&cmd_gro_flush_cycles, 5171 NULL, 5172 }, 5173 }; 5174 5175 /* *** ENABLE/DISABLE GSO *** */ 5176 struct cmd_gso_enable_result { 5177 cmdline_fixed_string_t cmd_set; 5178 cmdline_fixed_string_t cmd_port; 5179 cmdline_fixed_string_t cmd_keyword; 5180 cmdline_fixed_string_t cmd_mode; 5181 portid_t cmd_pid; 5182 }; 5183 5184 static void 5185 cmd_gso_enable_parsed(void *parsed_result, 5186 __rte_unused struct cmdline *cl, 5187 __rte_unused void *data) 5188 { 5189 struct cmd_gso_enable_result *res; 5190 5191 res = parsed_result; 5192 if (!strcmp(res->cmd_keyword, "gso")) 5193 setup_gso(res->cmd_mode, res->cmd_pid); 5194 } 5195 5196 cmdline_parse_token_string_t cmd_gso_enable_set = 5197 TOKEN_STRING_INITIALIZER(struct cmd_gso_enable_result, 5198 cmd_set, "set"); 5199 cmdline_parse_token_string_t cmd_gso_enable_port = 5200 TOKEN_STRING_INITIALIZER(struct cmd_gso_enable_result, 5201 cmd_port, "port"); 5202 cmdline_parse_token_string_t cmd_gso_enable_keyword = 5203 TOKEN_STRING_INITIALIZER(struct cmd_gso_enable_result, 5204 cmd_keyword, "gso"); 5205 cmdline_parse_token_string_t cmd_gso_enable_mode = 5206 TOKEN_STRING_INITIALIZER(struct cmd_gso_enable_result, 5207 cmd_mode, "on#off"); 5208 cmdline_parse_token_num_t cmd_gso_enable_pid = 5209 TOKEN_NUM_INITIALIZER(struct cmd_gso_enable_result, 5210 cmd_pid, UINT16); 5211 5212 cmdline_parse_inst_t cmd_gso_enable = { 5213 .f = cmd_gso_enable_parsed, 5214 .data = NULL, 5215 .help_str = "set port <port_id> gso on|off", 5216 .tokens = { 5217 (void *)&cmd_gso_enable_set, 5218 (void *)&cmd_gso_enable_port, 5219 (void *)&cmd_gso_enable_pid, 5220 (void *)&cmd_gso_enable_keyword, 5221 (void *)&cmd_gso_enable_mode, 5222 NULL, 5223 }, 5224 }; 5225 5226 /* *** SET MAX PACKET LENGTH FOR GSO SEGMENTS *** */ 5227 struct cmd_gso_size_result { 5228 cmdline_fixed_string_t cmd_set; 5229 cmdline_fixed_string_t cmd_keyword; 5230 cmdline_fixed_string_t cmd_segsz; 5231 uint16_t cmd_size; 5232 }; 5233 5234 static void 5235 cmd_gso_size_parsed(void *parsed_result, 5236 __rte_unused struct cmdline *cl, 5237 __rte_unused void *data) 5238 { 5239 struct cmd_gso_size_result *res = parsed_result; 5240 5241 if (test_done == 0) { 5242 printf("Before setting GSO segsz, please first" 5243 " stop forwarding\n"); 5244 return; 5245 } 5246 5247 if (!strcmp(res->cmd_keyword, "gso") && 5248 !strcmp(res->cmd_segsz, "segsz")) { 5249 if (res->cmd_size < RTE_GSO_SEG_SIZE_MIN) 5250 printf("gso_size should be larger than %zu." 5251 " Please input a legal value\n", 5252 RTE_GSO_SEG_SIZE_MIN); 5253 else 5254 gso_max_segment_size = res->cmd_size; 5255 } 5256 } 5257 5258 cmdline_parse_token_string_t cmd_gso_size_set = 5259 TOKEN_STRING_INITIALIZER(struct cmd_gso_size_result, 5260 cmd_set, "set"); 5261 cmdline_parse_token_string_t cmd_gso_size_keyword = 5262 TOKEN_STRING_INITIALIZER(struct cmd_gso_size_result, 5263 cmd_keyword, "gso"); 5264 cmdline_parse_token_string_t cmd_gso_size_segsz = 5265 TOKEN_STRING_INITIALIZER(struct cmd_gso_size_result, 5266 cmd_segsz, "segsz"); 5267 cmdline_parse_token_num_t cmd_gso_size_size = 5268 TOKEN_NUM_INITIALIZER(struct cmd_gso_size_result, 5269 cmd_size, UINT16); 5270 5271 cmdline_parse_inst_t cmd_gso_size = { 5272 .f = cmd_gso_size_parsed, 5273 .data = NULL, 5274 .help_str = "set gso segsz <length>", 5275 .tokens = { 5276 (void *)&cmd_gso_size_set, 5277 (void *)&cmd_gso_size_keyword, 5278 (void *)&cmd_gso_size_segsz, 5279 (void *)&cmd_gso_size_size, 5280 NULL, 5281 }, 5282 }; 5283 5284 /* *** SHOW GSO CONFIGURATION *** */ 5285 struct cmd_gso_show_result { 5286 cmdline_fixed_string_t cmd_show; 5287 cmdline_fixed_string_t cmd_port; 5288 cmdline_fixed_string_t cmd_keyword; 5289 portid_t cmd_pid; 5290 }; 5291 5292 static void 5293 cmd_gso_show_parsed(void *parsed_result, 5294 __rte_unused struct cmdline *cl, 5295 __rte_unused void *data) 5296 { 5297 struct cmd_gso_show_result *res = parsed_result; 5298 5299 if (!rte_eth_dev_is_valid_port(res->cmd_pid)) { 5300 printf("invalid port id %u\n", res->cmd_pid); 5301 return; 5302 } 5303 if (!strcmp(res->cmd_keyword, "gso")) { 5304 if (gso_ports[res->cmd_pid].enable) { 5305 printf("Max GSO'd packet size: %uB\n" 5306 "Supported GSO types: TCP/IPv4, " 5307 "UDP/IPv4, VxLAN with inner " 5308 "TCP/IPv4 packet, GRE with inner " 5309 "TCP/IPv4 packet\n", 5310 gso_max_segment_size); 5311 } else 5312 printf("GSO is not enabled on Port %u\n", res->cmd_pid); 5313 } 5314 } 5315 5316 cmdline_parse_token_string_t cmd_gso_show_show = 5317 TOKEN_STRING_INITIALIZER(struct cmd_gso_show_result, 5318 cmd_show, "show"); 5319 cmdline_parse_token_string_t cmd_gso_show_port = 5320 TOKEN_STRING_INITIALIZER(struct cmd_gso_show_result, 5321 cmd_port, "port"); 5322 cmdline_parse_token_string_t cmd_gso_show_keyword = 5323 TOKEN_STRING_INITIALIZER(struct cmd_gso_show_result, 5324 cmd_keyword, "gso"); 5325 cmdline_parse_token_num_t cmd_gso_show_pid = 5326 TOKEN_NUM_INITIALIZER(struct cmd_gso_show_result, 5327 cmd_pid, UINT16); 5328 5329 cmdline_parse_inst_t cmd_gso_show = { 5330 .f = cmd_gso_show_parsed, 5331 .data = NULL, 5332 .help_str = "show port <port_id> gso", 5333 .tokens = { 5334 (void *)&cmd_gso_show_show, 5335 (void *)&cmd_gso_show_port, 5336 (void *)&cmd_gso_show_pid, 5337 (void *)&cmd_gso_show_keyword, 5338 NULL, 5339 }, 5340 }; 5341 5342 /* *** ENABLE/DISABLE FLUSH ON RX STREAMS *** */ 5343 struct cmd_set_flush_rx { 5344 cmdline_fixed_string_t set; 5345 cmdline_fixed_string_t flush_rx; 5346 cmdline_fixed_string_t mode; 5347 }; 5348 5349 static void 5350 cmd_set_flush_rx_parsed(void *parsed_result, 5351 __rte_unused struct cmdline *cl, 5352 __rte_unused void *data) 5353 { 5354 struct cmd_set_flush_rx *res = parsed_result; 5355 no_flush_rx = (uint8_t)((strcmp(res->mode, "on") == 0) ? 0 : 1); 5356 } 5357 5358 cmdline_parse_token_string_t cmd_setflushrx_set = 5359 TOKEN_STRING_INITIALIZER(struct cmd_set_flush_rx, 5360 set, "set"); 5361 cmdline_parse_token_string_t cmd_setflushrx_flush_rx = 5362 TOKEN_STRING_INITIALIZER(struct cmd_set_flush_rx, 5363 flush_rx, "flush_rx"); 5364 cmdline_parse_token_string_t cmd_setflushrx_mode = 5365 TOKEN_STRING_INITIALIZER(struct cmd_set_flush_rx, 5366 mode, "on#off"); 5367 5368 5369 cmdline_parse_inst_t cmd_set_flush_rx = { 5370 .f = cmd_set_flush_rx_parsed, 5371 .help_str = "set flush_rx on|off: Enable/Disable flush on rx streams", 5372 .data = NULL, 5373 .tokens = { 5374 (void *)&cmd_setflushrx_set, 5375 (void *)&cmd_setflushrx_flush_rx, 5376 (void *)&cmd_setflushrx_mode, 5377 NULL, 5378 }, 5379 }; 5380 5381 /* *** ENABLE/DISABLE LINK STATUS CHECK *** */ 5382 struct cmd_set_link_check { 5383 cmdline_fixed_string_t set; 5384 cmdline_fixed_string_t link_check; 5385 cmdline_fixed_string_t mode; 5386 }; 5387 5388 static void 5389 cmd_set_link_check_parsed(void *parsed_result, 5390 __rte_unused struct cmdline *cl, 5391 __rte_unused void *data) 5392 { 5393 struct cmd_set_link_check *res = parsed_result; 5394 no_link_check = (uint8_t)((strcmp(res->mode, "on") == 0) ? 0 : 1); 5395 } 5396 5397 cmdline_parse_token_string_t cmd_setlinkcheck_set = 5398 TOKEN_STRING_INITIALIZER(struct cmd_set_link_check, 5399 set, "set"); 5400 cmdline_parse_token_string_t cmd_setlinkcheck_link_check = 5401 TOKEN_STRING_INITIALIZER(struct cmd_set_link_check, 5402 link_check, "link_check"); 5403 cmdline_parse_token_string_t cmd_setlinkcheck_mode = 5404 TOKEN_STRING_INITIALIZER(struct cmd_set_link_check, 5405 mode, "on#off"); 5406 5407 5408 cmdline_parse_inst_t cmd_set_link_check = { 5409 .f = cmd_set_link_check_parsed, 5410 .help_str = "set link_check on|off: Enable/Disable link status check " 5411 "when starting/stopping a port", 5412 .data = NULL, 5413 .tokens = { 5414 (void *)&cmd_setlinkcheck_set, 5415 (void *)&cmd_setlinkcheck_link_check, 5416 (void *)&cmd_setlinkcheck_mode, 5417 NULL, 5418 }, 5419 }; 5420 5421 /* *** SET NIC BYPASS MODE *** */ 5422 struct cmd_set_bypass_mode_result { 5423 cmdline_fixed_string_t set; 5424 cmdline_fixed_string_t bypass; 5425 cmdline_fixed_string_t mode; 5426 cmdline_fixed_string_t value; 5427 portid_t port_id; 5428 }; 5429 5430 static void 5431 cmd_set_bypass_mode_parsed(void *parsed_result, 5432 __rte_unused struct cmdline *cl, 5433 __rte_unused void *data) 5434 { 5435 struct cmd_set_bypass_mode_result *res = parsed_result; 5436 portid_t port_id = res->port_id; 5437 int32_t rc = -EINVAL; 5438 5439 #if defined RTE_LIBRTE_IXGBE_PMD && defined RTE_LIBRTE_IXGBE_BYPASS 5440 uint32_t bypass_mode = RTE_PMD_IXGBE_BYPASS_MODE_NORMAL; 5441 5442 if (!strcmp(res->value, "bypass")) 5443 bypass_mode = RTE_PMD_IXGBE_BYPASS_MODE_BYPASS; 5444 else if (!strcmp(res->value, "isolate")) 5445 bypass_mode = RTE_PMD_IXGBE_BYPASS_MODE_ISOLATE; 5446 else 5447 bypass_mode = RTE_PMD_IXGBE_BYPASS_MODE_NORMAL; 5448 5449 /* Set the bypass mode for the relevant port. */ 5450 rc = rte_pmd_ixgbe_bypass_state_set(port_id, &bypass_mode); 5451 #endif 5452 if (rc != 0) 5453 printf("\t Failed to set bypass mode for port = %d.\n", port_id); 5454 } 5455 5456 cmdline_parse_token_string_t cmd_setbypass_mode_set = 5457 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_mode_result, 5458 set, "set"); 5459 cmdline_parse_token_string_t cmd_setbypass_mode_bypass = 5460 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_mode_result, 5461 bypass, "bypass"); 5462 cmdline_parse_token_string_t cmd_setbypass_mode_mode = 5463 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_mode_result, 5464 mode, "mode"); 5465 cmdline_parse_token_string_t cmd_setbypass_mode_value = 5466 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_mode_result, 5467 value, "normal#bypass#isolate"); 5468 cmdline_parse_token_num_t cmd_setbypass_mode_port = 5469 TOKEN_NUM_INITIALIZER(struct cmd_set_bypass_mode_result, 5470 port_id, UINT16); 5471 5472 cmdline_parse_inst_t cmd_set_bypass_mode = { 5473 .f = cmd_set_bypass_mode_parsed, 5474 .help_str = "set bypass mode normal|bypass|isolate <port_id>: " 5475 "Set the NIC bypass mode for port_id", 5476 .data = NULL, 5477 .tokens = { 5478 (void *)&cmd_setbypass_mode_set, 5479 (void *)&cmd_setbypass_mode_bypass, 5480 (void *)&cmd_setbypass_mode_mode, 5481 (void *)&cmd_setbypass_mode_value, 5482 (void *)&cmd_setbypass_mode_port, 5483 NULL, 5484 }, 5485 }; 5486 5487 /* *** SET NIC BYPASS EVENT *** */ 5488 struct cmd_set_bypass_event_result { 5489 cmdline_fixed_string_t set; 5490 cmdline_fixed_string_t bypass; 5491 cmdline_fixed_string_t event; 5492 cmdline_fixed_string_t event_value; 5493 cmdline_fixed_string_t mode; 5494 cmdline_fixed_string_t mode_value; 5495 portid_t port_id; 5496 }; 5497 5498 static void 5499 cmd_set_bypass_event_parsed(void *parsed_result, 5500 __rte_unused struct cmdline *cl, 5501 __rte_unused void *data) 5502 { 5503 int32_t rc = -EINVAL; 5504 struct cmd_set_bypass_event_result *res = parsed_result; 5505 portid_t port_id = res->port_id; 5506 5507 #if defined RTE_LIBRTE_IXGBE_PMD && defined RTE_LIBRTE_IXGBE_BYPASS 5508 uint32_t bypass_event = RTE_PMD_IXGBE_BYPASS_EVENT_NONE; 5509 uint32_t bypass_mode = RTE_PMD_IXGBE_BYPASS_MODE_NORMAL; 5510 5511 if (!strcmp(res->event_value, "timeout")) 5512 bypass_event = RTE_PMD_IXGBE_BYPASS_EVENT_TIMEOUT; 5513 else if (!strcmp(res->event_value, "os_on")) 5514 bypass_event = RTE_PMD_IXGBE_BYPASS_EVENT_OS_ON; 5515 else if (!strcmp(res->event_value, "os_off")) 5516 bypass_event = RTE_PMD_IXGBE_BYPASS_EVENT_OS_OFF; 5517 else if (!strcmp(res->event_value, "power_on")) 5518 bypass_event = RTE_PMD_IXGBE_BYPASS_EVENT_POWER_ON; 5519 else if (!strcmp(res->event_value, "power_off")) 5520 bypass_event = RTE_PMD_IXGBE_BYPASS_EVENT_POWER_OFF; 5521 else 5522 bypass_event = RTE_PMD_IXGBE_BYPASS_EVENT_NONE; 5523 5524 if (!strcmp(res->mode_value, "bypass")) 5525 bypass_mode = RTE_PMD_IXGBE_BYPASS_MODE_BYPASS; 5526 else if (!strcmp(res->mode_value, "isolate")) 5527 bypass_mode = RTE_PMD_IXGBE_BYPASS_MODE_ISOLATE; 5528 else 5529 bypass_mode = RTE_PMD_IXGBE_BYPASS_MODE_NORMAL; 5530 5531 /* Set the watchdog timeout. */ 5532 if (bypass_event == RTE_PMD_IXGBE_BYPASS_EVENT_TIMEOUT) { 5533 5534 rc = -EINVAL; 5535 if (RTE_PMD_IXGBE_BYPASS_TMT_VALID(bypass_timeout)) { 5536 rc = rte_pmd_ixgbe_bypass_wd_timeout_store(port_id, 5537 bypass_timeout); 5538 } 5539 if (rc != 0) { 5540 printf("Failed to set timeout value %u " 5541 "for port %d, errto code: %d.\n", 5542 bypass_timeout, port_id, rc); 5543 } 5544 } 5545 5546 /* Set the bypass event to transition to bypass mode. */ 5547 rc = rte_pmd_ixgbe_bypass_event_store(port_id, bypass_event, 5548 bypass_mode); 5549 #endif 5550 5551 if (rc != 0) 5552 printf("\t Failed to set bypass event for port = %d.\n", 5553 port_id); 5554 } 5555 5556 cmdline_parse_token_string_t cmd_setbypass_event_set = 5557 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_event_result, 5558 set, "set"); 5559 cmdline_parse_token_string_t cmd_setbypass_event_bypass = 5560 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_event_result, 5561 bypass, "bypass"); 5562 cmdline_parse_token_string_t cmd_setbypass_event_event = 5563 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_event_result, 5564 event, "event"); 5565 cmdline_parse_token_string_t cmd_setbypass_event_event_value = 5566 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_event_result, 5567 event_value, "none#timeout#os_off#os_on#power_on#power_off"); 5568 cmdline_parse_token_string_t cmd_setbypass_event_mode = 5569 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_event_result, 5570 mode, "mode"); 5571 cmdline_parse_token_string_t cmd_setbypass_event_mode_value = 5572 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_event_result, 5573 mode_value, "normal#bypass#isolate"); 5574 cmdline_parse_token_num_t cmd_setbypass_event_port = 5575 TOKEN_NUM_INITIALIZER(struct cmd_set_bypass_event_result, 5576 port_id, UINT16); 5577 5578 cmdline_parse_inst_t cmd_set_bypass_event = { 5579 .f = cmd_set_bypass_event_parsed, 5580 .help_str = "set bypass event none|timeout|os_on|os_off|power_on|" 5581 "power_off mode normal|bypass|isolate <port_id>: " 5582 "Set the NIC bypass event mode for port_id", 5583 .data = NULL, 5584 .tokens = { 5585 (void *)&cmd_setbypass_event_set, 5586 (void *)&cmd_setbypass_event_bypass, 5587 (void *)&cmd_setbypass_event_event, 5588 (void *)&cmd_setbypass_event_event_value, 5589 (void *)&cmd_setbypass_event_mode, 5590 (void *)&cmd_setbypass_event_mode_value, 5591 (void *)&cmd_setbypass_event_port, 5592 NULL, 5593 }, 5594 }; 5595 5596 5597 /* *** SET NIC BYPASS TIMEOUT *** */ 5598 struct cmd_set_bypass_timeout_result { 5599 cmdline_fixed_string_t set; 5600 cmdline_fixed_string_t bypass; 5601 cmdline_fixed_string_t timeout; 5602 cmdline_fixed_string_t value; 5603 }; 5604 5605 static void 5606 cmd_set_bypass_timeout_parsed(void *parsed_result, 5607 __rte_unused struct cmdline *cl, 5608 __rte_unused void *data) 5609 { 5610 __rte_unused struct cmd_set_bypass_timeout_result *res = parsed_result; 5611 5612 #if defined RTE_LIBRTE_IXGBE_PMD && defined RTE_LIBRTE_IXGBE_BYPASS 5613 if (!strcmp(res->value, "1.5")) 5614 bypass_timeout = RTE_PMD_IXGBE_BYPASS_TMT_1_5_SEC; 5615 else if (!strcmp(res->value, "2")) 5616 bypass_timeout = RTE_PMD_IXGBE_BYPASS_TMT_2_SEC; 5617 else if (!strcmp(res->value, "3")) 5618 bypass_timeout = RTE_PMD_IXGBE_BYPASS_TMT_3_SEC; 5619 else if (!strcmp(res->value, "4")) 5620 bypass_timeout = RTE_PMD_IXGBE_BYPASS_TMT_4_SEC; 5621 else if (!strcmp(res->value, "8")) 5622 bypass_timeout = RTE_PMD_IXGBE_BYPASS_TMT_8_SEC; 5623 else if (!strcmp(res->value, "16")) 5624 bypass_timeout = RTE_PMD_IXGBE_BYPASS_TMT_16_SEC; 5625 else if (!strcmp(res->value, "32")) 5626 bypass_timeout = RTE_PMD_IXGBE_BYPASS_TMT_32_SEC; 5627 else 5628 bypass_timeout = RTE_PMD_IXGBE_BYPASS_TMT_OFF; 5629 #endif 5630 } 5631 5632 cmdline_parse_token_string_t cmd_setbypass_timeout_set = 5633 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_timeout_result, 5634 set, "set"); 5635 cmdline_parse_token_string_t cmd_setbypass_timeout_bypass = 5636 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_timeout_result, 5637 bypass, "bypass"); 5638 cmdline_parse_token_string_t cmd_setbypass_timeout_timeout = 5639 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_timeout_result, 5640 timeout, "timeout"); 5641 cmdline_parse_token_string_t cmd_setbypass_timeout_value = 5642 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_timeout_result, 5643 value, "0#1.5#2#3#4#8#16#32"); 5644 5645 cmdline_parse_inst_t cmd_set_bypass_timeout = { 5646 .f = cmd_set_bypass_timeout_parsed, 5647 .help_str = "set bypass timeout 0|1.5|2|3|4|8|16|32: " 5648 "Set the NIC bypass watchdog timeout in seconds", 5649 .data = NULL, 5650 .tokens = { 5651 (void *)&cmd_setbypass_timeout_set, 5652 (void *)&cmd_setbypass_timeout_bypass, 5653 (void *)&cmd_setbypass_timeout_timeout, 5654 (void *)&cmd_setbypass_timeout_value, 5655 NULL, 5656 }, 5657 }; 5658 5659 /* *** SHOW NIC BYPASS MODE *** */ 5660 struct cmd_show_bypass_config_result { 5661 cmdline_fixed_string_t show; 5662 cmdline_fixed_string_t bypass; 5663 cmdline_fixed_string_t config; 5664 portid_t port_id; 5665 }; 5666 5667 static void 5668 cmd_show_bypass_config_parsed(void *parsed_result, 5669 __rte_unused struct cmdline *cl, 5670 __rte_unused void *data) 5671 { 5672 struct cmd_show_bypass_config_result *res = parsed_result; 5673 portid_t port_id = res->port_id; 5674 int rc = -EINVAL; 5675 #if defined RTE_LIBRTE_IXGBE_PMD && defined RTE_LIBRTE_IXGBE_BYPASS 5676 uint32_t event_mode; 5677 uint32_t bypass_mode; 5678 uint32_t timeout = bypass_timeout; 5679 unsigned int i; 5680 5681 static const char * const timeouts[RTE_PMD_IXGBE_BYPASS_TMT_NUM] = 5682 {"off", "1.5", "2", "3", "4", "8", "16", "32"}; 5683 static const char * const modes[RTE_PMD_IXGBE_BYPASS_MODE_NUM] = 5684 {"UNKNOWN", "normal", "bypass", "isolate"}; 5685 static const char * const events[RTE_PMD_IXGBE_BYPASS_EVENT_NUM] = { 5686 "NONE", 5687 "OS/board on", 5688 "power supply on", 5689 "OS/board off", 5690 "power supply off", 5691 "timeout"}; 5692 5693 /* Display the bypass mode.*/ 5694 if (rte_pmd_ixgbe_bypass_state_show(port_id, &bypass_mode) != 0) { 5695 printf("\tFailed to get bypass mode for port = %d\n", port_id); 5696 return; 5697 } 5698 else { 5699 if (!RTE_PMD_IXGBE_BYPASS_MODE_VALID(bypass_mode)) 5700 bypass_mode = RTE_PMD_IXGBE_BYPASS_MODE_NONE; 5701 5702 printf("\tbypass mode = %s\n", modes[bypass_mode]); 5703 } 5704 5705 /* Display the bypass timeout.*/ 5706 if (!RTE_PMD_IXGBE_BYPASS_TMT_VALID(timeout)) 5707 timeout = RTE_PMD_IXGBE_BYPASS_TMT_OFF; 5708 5709 printf("\tbypass timeout = %s\n", timeouts[timeout]); 5710 5711 /* Display the bypass events and associated modes. */ 5712 for (i = RTE_PMD_IXGBE_BYPASS_EVENT_START; i < RTE_DIM(events); i++) { 5713 5714 if (rte_pmd_ixgbe_bypass_event_show(port_id, i, &event_mode)) { 5715 printf("\tFailed to get bypass mode for event = %s\n", 5716 events[i]); 5717 } else { 5718 if (!RTE_PMD_IXGBE_BYPASS_MODE_VALID(event_mode)) 5719 event_mode = RTE_PMD_IXGBE_BYPASS_MODE_NONE; 5720 5721 printf("\tbypass event: %-16s = %s\n", events[i], 5722 modes[event_mode]); 5723 } 5724 } 5725 #endif 5726 if (rc != 0) 5727 printf("\tFailed to get bypass configuration for port = %d\n", 5728 port_id); 5729 } 5730 5731 cmdline_parse_token_string_t cmd_showbypass_config_show = 5732 TOKEN_STRING_INITIALIZER(struct cmd_show_bypass_config_result, 5733 show, "show"); 5734 cmdline_parse_token_string_t cmd_showbypass_config_bypass = 5735 TOKEN_STRING_INITIALIZER(struct cmd_show_bypass_config_result, 5736 bypass, "bypass"); 5737 cmdline_parse_token_string_t cmd_showbypass_config_config = 5738 TOKEN_STRING_INITIALIZER(struct cmd_show_bypass_config_result, 5739 config, "config"); 5740 cmdline_parse_token_num_t cmd_showbypass_config_port = 5741 TOKEN_NUM_INITIALIZER(struct cmd_show_bypass_config_result, 5742 port_id, UINT16); 5743 5744 cmdline_parse_inst_t cmd_show_bypass_config = { 5745 .f = cmd_show_bypass_config_parsed, 5746 .help_str = "show bypass config <port_id>: " 5747 "Show the NIC bypass config for port_id", 5748 .data = NULL, 5749 .tokens = { 5750 (void *)&cmd_showbypass_config_show, 5751 (void *)&cmd_showbypass_config_bypass, 5752 (void *)&cmd_showbypass_config_config, 5753 (void *)&cmd_showbypass_config_port, 5754 NULL, 5755 }, 5756 }; 5757 5758 #ifdef RTE_LIBRTE_PMD_BOND 5759 /* *** SET BONDING MODE *** */ 5760 struct cmd_set_bonding_mode_result { 5761 cmdline_fixed_string_t set; 5762 cmdline_fixed_string_t bonding; 5763 cmdline_fixed_string_t mode; 5764 uint8_t value; 5765 portid_t port_id; 5766 }; 5767 5768 static void cmd_set_bonding_mode_parsed(void *parsed_result, 5769 __rte_unused struct cmdline *cl, 5770 __rte_unused void *data) 5771 { 5772 struct cmd_set_bonding_mode_result *res = parsed_result; 5773 portid_t port_id = res->port_id; 5774 5775 /* Set the bonding mode for the relevant port. */ 5776 if (0 != rte_eth_bond_mode_set(port_id, res->value)) 5777 printf("\t Failed to set bonding mode for port = %d.\n", port_id); 5778 } 5779 5780 cmdline_parse_token_string_t cmd_setbonding_mode_set = 5781 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_mode_result, 5782 set, "set"); 5783 cmdline_parse_token_string_t cmd_setbonding_mode_bonding = 5784 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_mode_result, 5785 bonding, "bonding"); 5786 cmdline_parse_token_string_t cmd_setbonding_mode_mode = 5787 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_mode_result, 5788 mode, "mode"); 5789 cmdline_parse_token_num_t cmd_setbonding_mode_value = 5790 TOKEN_NUM_INITIALIZER(struct cmd_set_bonding_mode_result, 5791 value, UINT8); 5792 cmdline_parse_token_num_t cmd_setbonding_mode_port = 5793 TOKEN_NUM_INITIALIZER(struct cmd_set_bonding_mode_result, 5794 port_id, UINT16); 5795 5796 cmdline_parse_inst_t cmd_set_bonding_mode = { 5797 .f = cmd_set_bonding_mode_parsed, 5798 .help_str = "set bonding mode <mode_value> <port_id>: " 5799 "Set the bonding mode for port_id", 5800 .data = NULL, 5801 .tokens = { 5802 (void *) &cmd_setbonding_mode_set, 5803 (void *) &cmd_setbonding_mode_bonding, 5804 (void *) &cmd_setbonding_mode_mode, 5805 (void *) &cmd_setbonding_mode_value, 5806 (void *) &cmd_setbonding_mode_port, 5807 NULL 5808 } 5809 }; 5810 5811 /* *** SET BONDING SLOW_QUEUE SW/HW *** */ 5812 struct cmd_set_bonding_lacp_dedicated_queues_result { 5813 cmdline_fixed_string_t set; 5814 cmdline_fixed_string_t bonding; 5815 cmdline_fixed_string_t lacp; 5816 cmdline_fixed_string_t dedicated_queues; 5817 portid_t port_id; 5818 cmdline_fixed_string_t mode; 5819 }; 5820 5821 static void cmd_set_bonding_lacp_dedicated_queues_parsed(void *parsed_result, 5822 __rte_unused struct cmdline *cl, 5823 __rte_unused void *data) 5824 { 5825 struct cmd_set_bonding_lacp_dedicated_queues_result *res = parsed_result; 5826 portid_t port_id = res->port_id; 5827 struct rte_port *port; 5828 5829 port = &ports[port_id]; 5830 5831 /** Check if the port is not started **/ 5832 if (port->port_status != RTE_PORT_STOPPED) { 5833 printf("Please stop port %d first\n", port_id); 5834 return; 5835 } 5836 5837 if (!strcmp(res->mode, "enable")) { 5838 if (rte_eth_bond_8023ad_dedicated_queues_enable(port_id) == 0) 5839 printf("Dedicate queues for LACP control packets" 5840 " enabled\n"); 5841 else 5842 printf("Enabling dedicate queues for LACP control " 5843 "packets on port %d failed\n", port_id); 5844 } else if (!strcmp(res->mode, "disable")) { 5845 if (rte_eth_bond_8023ad_dedicated_queues_disable(port_id) == 0) 5846 printf("Dedicated queues for LACP control packets " 5847 "disabled\n"); 5848 else 5849 printf("Disabling dedicated queues for LACP control " 5850 "traffic on port %d failed\n", port_id); 5851 } 5852 } 5853 5854 cmdline_parse_token_string_t cmd_setbonding_lacp_dedicated_queues_set = 5855 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_lacp_dedicated_queues_result, 5856 set, "set"); 5857 cmdline_parse_token_string_t cmd_setbonding_lacp_dedicated_queues_bonding = 5858 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_lacp_dedicated_queues_result, 5859 bonding, "bonding"); 5860 cmdline_parse_token_string_t cmd_setbonding_lacp_dedicated_queues_lacp = 5861 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_lacp_dedicated_queues_result, 5862 lacp, "lacp"); 5863 cmdline_parse_token_string_t cmd_setbonding_lacp_dedicated_queues_dedicated_queues = 5864 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_lacp_dedicated_queues_result, 5865 dedicated_queues, "dedicated_queues"); 5866 cmdline_parse_token_num_t cmd_setbonding_lacp_dedicated_queues_port_id = 5867 TOKEN_NUM_INITIALIZER(struct cmd_set_bonding_lacp_dedicated_queues_result, 5868 port_id, UINT16); 5869 cmdline_parse_token_string_t cmd_setbonding_lacp_dedicated_queues_mode = 5870 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_lacp_dedicated_queues_result, 5871 mode, "enable#disable"); 5872 5873 cmdline_parse_inst_t cmd_set_lacp_dedicated_queues = { 5874 .f = cmd_set_bonding_lacp_dedicated_queues_parsed, 5875 .help_str = "set bonding lacp dedicated_queues <port_id> " 5876 "enable|disable: " 5877 "Enable/disable dedicated queues for LACP control traffic for port_id", 5878 .data = NULL, 5879 .tokens = { 5880 (void *)&cmd_setbonding_lacp_dedicated_queues_set, 5881 (void *)&cmd_setbonding_lacp_dedicated_queues_bonding, 5882 (void *)&cmd_setbonding_lacp_dedicated_queues_lacp, 5883 (void *)&cmd_setbonding_lacp_dedicated_queues_dedicated_queues, 5884 (void *)&cmd_setbonding_lacp_dedicated_queues_port_id, 5885 (void *)&cmd_setbonding_lacp_dedicated_queues_mode, 5886 NULL 5887 } 5888 }; 5889 5890 /* *** SET BALANCE XMIT POLICY *** */ 5891 struct cmd_set_bonding_balance_xmit_policy_result { 5892 cmdline_fixed_string_t set; 5893 cmdline_fixed_string_t bonding; 5894 cmdline_fixed_string_t balance_xmit_policy; 5895 portid_t port_id; 5896 cmdline_fixed_string_t policy; 5897 }; 5898 5899 static void cmd_set_bonding_balance_xmit_policy_parsed(void *parsed_result, 5900 __rte_unused struct cmdline *cl, 5901 __rte_unused void *data) 5902 { 5903 struct cmd_set_bonding_balance_xmit_policy_result *res = parsed_result; 5904 portid_t port_id = res->port_id; 5905 uint8_t policy; 5906 5907 if (!strcmp(res->policy, "l2")) { 5908 policy = BALANCE_XMIT_POLICY_LAYER2; 5909 } else if (!strcmp(res->policy, "l23")) { 5910 policy = BALANCE_XMIT_POLICY_LAYER23; 5911 } else if (!strcmp(res->policy, "l34")) { 5912 policy = BALANCE_XMIT_POLICY_LAYER34; 5913 } else { 5914 printf("\t Invalid xmit policy selection"); 5915 return; 5916 } 5917 5918 /* Set the bonding mode for the relevant port. */ 5919 if (0 != rte_eth_bond_xmit_policy_set(port_id, policy)) { 5920 printf("\t Failed to set bonding balance xmit policy for port = %d.\n", 5921 port_id); 5922 } 5923 } 5924 5925 cmdline_parse_token_string_t cmd_setbonding_balance_xmit_policy_set = 5926 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_balance_xmit_policy_result, 5927 set, "set"); 5928 cmdline_parse_token_string_t cmd_setbonding_balance_xmit_policy_bonding = 5929 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_balance_xmit_policy_result, 5930 bonding, "bonding"); 5931 cmdline_parse_token_string_t cmd_setbonding_balance_xmit_policy_balance_xmit_policy = 5932 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_balance_xmit_policy_result, 5933 balance_xmit_policy, "balance_xmit_policy"); 5934 cmdline_parse_token_num_t cmd_setbonding_balance_xmit_policy_port = 5935 TOKEN_NUM_INITIALIZER(struct cmd_set_bonding_balance_xmit_policy_result, 5936 port_id, UINT16); 5937 cmdline_parse_token_string_t cmd_setbonding_balance_xmit_policy_policy = 5938 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_balance_xmit_policy_result, 5939 policy, "l2#l23#l34"); 5940 5941 cmdline_parse_inst_t cmd_set_balance_xmit_policy = { 5942 .f = cmd_set_bonding_balance_xmit_policy_parsed, 5943 .help_str = "set bonding balance_xmit_policy <port_id> " 5944 "l2|l23|l34: " 5945 "Set the bonding balance_xmit_policy for port_id", 5946 .data = NULL, 5947 .tokens = { 5948 (void *)&cmd_setbonding_balance_xmit_policy_set, 5949 (void *)&cmd_setbonding_balance_xmit_policy_bonding, 5950 (void *)&cmd_setbonding_balance_xmit_policy_balance_xmit_policy, 5951 (void *)&cmd_setbonding_balance_xmit_policy_port, 5952 (void *)&cmd_setbonding_balance_xmit_policy_policy, 5953 NULL 5954 } 5955 }; 5956 5957 /* *** SHOW NIC BONDING CONFIGURATION *** */ 5958 struct cmd_show_bonding_config_result { 5959 cmdline_fixed_string_t show; 5960 cmdline_fixed_string_t bonding; 5961 cmdline_fixed_string_t config; 5962 portid_t port_id; 5963 }; 5964 5965 static void cmd_show_bonding_config_parsed(void *parsed_result, 5966 __rte_unused struct cmdline *cl, 5967 __rte_unused void *data) 5968 { 5969 struct cmd_show_bonding_config_result *res = parsed_result; 5970 int bonding_mode, agg_mode; 5971 portid_t slaves[RTE_MAX_ETHPORTS]; 5972 int num_slaves, num_active_slaves; 5973 int primary_id; 5974 int i; 5975 portid_t port_id = res->port_id; 5976 5977 /* Display the bonding mode.*/ 5978 bonding_mode = rte_eth_bond_mode_get(port_id); 5979 if (bonding_mode < 0) { 5980 printf("\tFailed to get bonding mode for port = %d\n", port_id); 5981 return; 5982 } else 5983 printf("\tBonding mode: %d\n", bonding_mode); 5984 5985 if (bonding_mode == BONDING_MODE_BALANCE) { 5986 int balance_xmit_policy; 5987 5988 balance_xmit_policy = rte_eth_bond_xmit_policy_get(port_id); 5989 if (balance_xmit_policy < 0) { 5990 printf("\tFailed to get balance xmit policy for port = %d\n", 5991 port_id); 5992 return; 5993 } else { 5994 printf("\tBalance Xmit Policy: "); 5995 5996 switch (balance_xmit_policy) { 5997 case BALANCE_XMIT_POLICY_LAYER2: 5998 printf("BALANCE_XMIT_POLICY_LAYER2"); 5999 break; 6000 case BALANCE_XMIT_POLICY_LAYER23: 6001 printf("BALANCE_XMIT_POLICY_LAYER23"); 6002 break; 6003 case BALANCE_XMIT_POLICY_LAYER34: 6004 printf("BALANCE_XMIT_POLICY_LAYER34"); 6005 break; 6006 } 6007 printf("\n"); 6008 } 6009 } 6010 6011 if (bonding_mode == BONDING_MODE_8023AD) { 6012 agg_mode = rte_eth_bond_8023ad_agg_selection_get(port_id); 6013 printf("\tIEEE802.3AD Aggregator Mode: "); 6014 switch (agg_mode) { 6015 case AGG_BANDWIDTH: 6016 printf("bandwidth"); 6017 break; 6018 case AGG_STABLE: 6019 printf("stable"); 6020 break; 6021 case AGG_COUNT: 6022 printf("count"); 6023 break; 6024 } 6025 printf("\n"); 6026 } 6027 6028 num_slaves = rte_eth_bond_slaves_get(port_id, slaves, RTE_MAX_ETHPORTS); 6029 6030 if (num_slaves < 0) { 6031 printf("\tFailed to get slave list for port = %d\n", port_id); 6032 return; 6033 } 6034 if (num_slaves > 0) { 6035 printf("\tSlaves (%d): [", num_slaves); 6036 for (i = 0; i < num_slaves - 1; i++) 6037 printf("%d ", slaves[i]); 6038 6039 printf("%d]\n", slaves[num_slaves - 1]); 6040 } else { 6041 printf("\tSlaves: []\n"); 6042 6043 } 6044 6045 num_active_slaves = rte_eth_bond_active_slaves_get(port_id, slaves, 6046 RTE_MAX_ETHPORTS); 6047 6048 if (num_active_slaves < 0) { 6049 printf("\tFailed to get active slave list for port = %d\n", port_id); 6050 return; 6051 } 6052 if (num_active_slaves > 0) { 6053 printf("\tActive Slaves (%d): [", num_active_slaves); 6054 for (i = 0; i < num_active_slaves - 1; i++) 6055 printf("%d ", slaves[i]); 6056 6057 printf("%d]\n", slaves[num_active_slaves - 1]); 6058 6059 } else { 6060 printf("\tActive Slaves: []\n"); 6061 6062 } 6063 6064 primary_id = rte_eth_bond_primary_get(port_id); 6065 if (primary_id < 0) { 6066 printf("\tFailed to get primary slave for port = %d\n", port_id); 6067 return; 6068 } else 6069 printf("\tPrimary: [%d]\n", primary_id); 6070 6071 } 6072 6073 cmdline_parse_token_string_t cmd_showbonding_config_show = 6074 TOKEN_STRING_INITIALIZER(struct cmd_show_bonding_config_result, 6075 show, "show"); 6076 cmdline_parse_token_string_t cmd_showbonding_config_bonding = 6077 TOKEN_STRING_INITIALIZER(struct cmd_show_bonding_config_result, 6078 bonding, "bonding"); 6079 cmdline_parse_token_string_t cmd_showbonding_config_config = 6080 TOKEN_STRING_INITIALIZER(struct cmd_show_bonding_config_result, 6081 config, "config"); 6082 cmdline_parse_token_num_t cmd_showbonding_config_port = 6083 TOKEN_NUM_INITIALIZER(struct cmd_show_bonding_config_result, 6084 port_id, UINT16); 6085 6086 cmdline_parse_inst_t cmd_show_bonding_config = { 6087 .f = cmd_show_bonding_config_parsed, 6088 .help_str = "show bonding config <port_id>: " 6089 "Show the bonding config for port_id", 6090 .data = NULL, 6091 .tokens = { 6092 (void *)&cmd_showbonding_config_show, 6093 (void *)&cmd_showbonding_config_bonding, 6094 (void *)&cmd_showbonding_config_config, 6095 (void *)&cmd_showbonding_config_port, 6096 NULL 6097 } 6098 }; 6099 6100 /* *** SET BONDING PRIMARY *** */ 6101 struct cmd_set_bonding_primary_result { 6102 cmdline_fixed_string_t set; 6103 cmdline_fixed_string_t bonding; 6104 cmdline_fixed_string_t primary; 6105 portid_t slave_id; 6106 portid_t port_id; 6107 }; 6108 6109 static void cmd_set_bonding_primary_parsed(void *parsed_result, 6110 __rte_unused struct cmdline *cl, 6111 __rte_unused void *data) 6112 { 6113 struct cmd_set_bonding_primary_result *res = parsed_result; 6114 portid_t master_port_id = res->port_id; 6115 portid_t slave_port_id = res->slave_id; 6116 6117 /* Set the primary slave for a bonded device. */ 6118 if (0 != rte_eth_bond_primary_set(master_port_id, slave_port_id)) { 6119 printf("\t Failed to set primary slave for port = %d.\n", 6120 master_port_id); 6121 return; 6122 } 6123 init_port_config(); 6124 } 6125 6126 cmdline_parse_token_string_t cmd_setbonding_primary_set = 6127 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_primary_result, 6128 set, "set"); 6129 cmdline_parse_token_string_t cmd_setbonding_primary_bonding = 6130 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_primary_result, 6131 bonding, "bonding"); 6132 cmdline_parse_token_string_t cmd_setbonding_primary_primary = 6133 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_primary_result, 6134 primary, "primary"); 6135 cmdline_parse_token_num_t cmd_setbonding_primary_slave = 6136 TOKEN_NUM_INITIALIZER(struct cmd_set_bonding_primary_result, 6137 slave_id, UINT16); 6138 cmdline_parse_token_num_t cmd_setbonding_primary_port = 6139 TOKEN_NUM_INITIALIZER(struct cmd_set_bonding_primary_result, 6140 port_id, UINT16); 6141 6142 cmdline_parse_inst_t cmd_set_bonding_primary = { 6143 .f = cmd_set_bonding_primary_parsed, 6144 .help_str = "set bonding primary <slave_id> <port_id>: " 6145 "Set the primary slave for port_id", 6146 .data = NULL, 6147 .tokens = { 6148 (void *)&cmd_setbonding_primary_set, 6149 (void *)&cmd_setbonding_primary_bonding, 6150 (void *)&cmd_setbonding_primary_primary, 6151 (void *)&cmd_setbonding_primary_slave, 6152 (void *)&cmd_setbonding_primary_port, 6153 NULL 6154 } 6155 }; 6156 6157 /* *** ADD SLAVE *** */ 6158 struct cmd_add_bonding_slave_result { 6159 cmdline_fixed_string_t add; 6160 cmdline_fixed_string_t bonding; 6161 cmdline_fixed_string_t slave; 6162 portid_t slave_id; 6163 portid_t port_id; 6164 }; 6165 6166 static void cmd_add_bonding_slave_parsed(void *parsed_result, 6167 __rte_unused struct cmdline *cl, 6168 __rte_unused void *data) 6169 { 6170 struct cmd_add_bonding_slave_result *res = parsed_result; 6171 portid_t master_port_id = res->port_id; 6172 portid_t slave_port_id = res->slave_id; 6173 6174 /* add the slave for a bonded device. */ 6175 if (0 != rte_eth_bond_slave_add(master_port_id, slave_port_id)) { 6176 printf("\t Failed to add slave %d to master port = %d.\n", 6177 slave_port_id, master_port_id); 6178 return; 6179 } 6180 init_port_config(); 6181 set_port_slave_flag(slave_port_id); 6182 } 6183 6184 cmdline_parse_token_string_t cmd_addbonding_slave_add = 6185 TOKEN_STRING_INITIALIZER(struct cmd_add_bonding_slave_result, 6186 add, "add"); 6187 cmdline_parse_token_string_t cmd_addbonding_slave_bonding = 6188 TOKEN_STRING_INITIALIZER(struct cmd_add_bonding_slave_result, 6189 bonding, "bonding"); 6190 cmdline_parse_token_string_t cmd_addbonding_slave_slave = 6191 TOKEN_STRING_INITIALIZER(struct cmd_add_bonding_slave_result, 6192 slave, "slave"); 6193 cmdline_parse_token_num_t cmd_addbonding_slave_slaveid = 6194 TOKEN_NUM_INITIALIZER(struct cmd_add_bonding_slave_result, 6195 slave_id, UINT16); 6196 cmdline_parse_token_num_t cmd_addbonding_slave_port = 6197 TOKEN_NUM_INITIALIZER(struct cmd_add_bonding_slave_result, 6198 port_id, UINT16); 6199 6200 cmdline_parse_inst_t cmd_add_bonding_slave = { 6201 .f = cmd_add_bonding_slave_parsed, 6202 .help_str = "add bonding slave <slave_id> <port_id>: " 6203 "Add a slave device to a bonded device", 6204 .data = NULL, 6205 .tokens = { 6206 (void *)&cmd_addbonding_slave_add, 6207 (void *)&cmd_addbonding_slave_bonding, 6208 (void *)&cmd_addbonding_slave_slave, 6209 (void *)&cmd_addbonding_slave_slaveid, 6210 (void *)&cmd_addbonding_slave_port, 6211 NULL 6212 } 6213 }; 6214 6215 /* *** REMOVE SLAVE *** */ 6216 struct cmd_remove_bonding_slave_result { 6217 cmdline_fixed_string_t remove; 6218 cmdline_fixed_string_t bonding; 6219 cmdline_fixed_string_t slave; 6220 portid_t slave_id; 6221 portid_t port_id; 6222 }; 6223 6224 static void cmd_remove_bonding_slave_parsed(void *parsed_result, 6225 __rte_unused struct cmdline *cl, 6226 __rte_unused void *data) 6227 { 6228 struct cmd_remove_bonding_slave_result *res = parsed_result; 6229 portid_t master_port_id = res->port_id; 6230 portid_t slave_port_id = res->slave_id; 6231 6232 /* remove the slave from a bonded device. */ 6233 if (0 != rte_eth_bond_slave_remove(master_port_id, slave_port_id)) { 6234 printf("\t Failed to remove slave %d from master port = %d.\n", 6235 slave_port_id, master_port_id); 6236 return; 6237 } 6238 init_port_config(); 6239 clear_port_slave_flag(slave_port_id); 6240 } 6241 6242 cmdline_parse_token_string_t cmd_removebonding_slave_remove = 6243 TOKEN_STRING_INITIALIZER(struct cmd_remove_bonding_slave_result, 6244 remove, "remove"); 6245 cmdline_parse_token_string_t cmd_removebonding_slave_bonding = 6246 TOKEN_STRING_INITIALIZER(struct cmd_remove_bonding_slave_result, 6247 bonding, "bonding"); 6248 cmdline_parse_token_string_t cmd_removebonding_slave_slave = 6249 TOKEN_STRING_INITIALIZER(struct cmd_remove_bonding_slave_result, 6250 slave, "slave"); 6251 cmdline_parse_token_num_t cmd_removebonding_slave_slaveid = 6252 TOKEN_NUM_INITIALIZER(struct cmd_remove_bonding_slave_result, 6253 slave_id, UINT16); 6254 cmdline_parse_token_num_t cmd_removebonding_slave_port = 6255 TOKEN_NUM_INITIALIZER(struct cmd_remove_bonding_slave_result, 6256 port_id, UINT16); 6257 6258 cmdline_parse_inst_t cmd_remove_bonding_slave = { 6259 .f = cmd_remove_bonding_slave_parsed, 6260 .help_str = "remove bonding slave <slave_id> <port_id>: " 6261 "Remove a slave device from a bonded device", 6262 .data = NULL, 6263 .tokens = { 6264 (void *)&cmd_removebonding_slave_remove, 6265 (void *)&cmd_removebonding_slave_bonding, 6266 (void *)&cmd_removebonding_slave_slave, 6267 (void *)&cmd_removebonding_slave_slaveid, 6268 (void *)&cmd_removebonding_slave_port, 6269 NULL 6270 } 6271 }; 6272 6273 /* *** CREATE BONDED DEVICE *** */ 6274 struct cmd_create_bonded_device_result { 6275 cmdline_fixed_string_t create; 6276 cmdline_fixed_string_t bonded; 6277 cmdline_fixed_string_t device; 6278 uint8_t mode; 6279 uint8_t socket; 6280 }; 6281 6282 static int bond_dev_num = 0; 6283 6284 static void cmd_create_bonded_device_parsed(void *parsed_result, 6285 __rte_unused struct cmdline *cl, 6286 __rte_unused void *data) 6287 { 6288 struct cmd_create_bonded_device_result *res = parsed_result; 6289 char ethdev_name[RTE_ETH_NAME_MAX_LEN]; 6290 int port_id; 6291 int ret; 6292 6293 if (test_done == 0) { 6294 printf("Please stop forwarding first\n"); 6295 return; 6296 } 6297 6298 snprintf(ethdev_name, RTE_ETH_NAME_MAX_LEN, "net_bonding_testpmd_%d", 6299 bond_dev_num++); 6300 6301 /* Create a new bonded device. */ 6302 port_id = rte_eth_bond_create(ethdev_name, res->mode, res->socket); 6303 if (port_id < 0) { 6304 printf("\t Failed to create bonded device.\n"); 6305 return; 6306 } else { 6307 printf("Created new bonded device %s on (port %d).\n", ethdev_name, 6308 port_id); 6309 6310 /* Update number of ports */ 6311 nb_ports = rte_eth_dev_count_avail(); 6312 reconfig(port_id, res->socket); 6313 ret = rte_eth_promiscuous_enable(port_id); 6314 if (ret != 0) 6315 printf("Failed to enable promiscuous mode for port %u: %s - ignore\n", 6316 port_id, rte_strerror(-ret)); 6317 6318 ports[port_id].need_setup = 0; 6319 ports[port_id].port_status = RTE_PORT_STOPPED; 6320 } 6321 6322 } 6323 6324 cmdline_parse_token_string_t cmd_createbonded_device_create = 6325 TOKEN_STRING_INITIALIZER(struct cmd_create_bonded_device_result, 6326 create, "create"); 6327 cmdline_parse_token_string_t cmd_createbonded_device_bonded = 6328 TOKEN_STRING_INITIALIZER(struct cmd_create_bonded_device_result, 6329 bonded, "bonded"); 6330 cmdline_parse_token_string_t cmd_createbonded_device_device = 6331 TOKEN_STRING_INITIALIZER(struct cmd_create_bonded_device_result, 6332 device, "device"); 6333 cmdline_parse_token_num_t cmd_createbonded_device_mode = 6334 TOKEN_NUM_INITIALIZER(struct cmd_create_bonded_device_result, 6335 mode, UINT8); 6336 cmdline_parse_token_num_t cmd_createbonded_device_socket = 6337 TOKEN_NUM_INITIALIZER(struct cmd_create_bonded_device_result, 6338 socket, UINT8); 6339 6340 cmdline_parse_inst_t cmd_create_bonded_device = { 6341 .f = cmd_create_bonded_device_parsed, 6342 .help_str = "create bonded device <mode> <socket>: " 6343 "Create a new bonded device with specific bonding mode and socket", 6344 .data = NULL, 6345 .tokens = { 6346 (void *)&cmd_createbonded_device_create, 6347 (void *)&cmd_createbonded_device_bonded, 6348 (void *)&cmd_createbonded_device_device, 6349 (void *)&cmd_createbonded_device_mode, 6350 (void *)&cmd_createbonded_device_socket, 6351 NULL 6352 } 6353 }; 6354 6355 /* *** SET MAC ADDRESS IN BONDED DEVICE *** */ 6356 struct cmd_set_bond_mac_addr_result { 6357 cmdline_fixed_string_t set; 6358 cmdline_fixed_string_t bonding; 6359 cmdline_fixed_string_t mac_addr; 6360 uint16_t port_num; 6361 struct rte_ether_addr address; 6362 }; 6363 6364 static void cmd_set_bond_mac_addr_parsed(void *parsed_result, 6365 __rte_unused struct cmdline *cl, 6366 __rte_unused void *data) 6367 { 6368 struct cmd_set_bond_mac_addr_result *res = parsed_result; 6369 int ret; 6370 6371 if (port_id_is_invalid(res->port_num, ENABLED_WARN)) 6372 return; 6373 6374 ret = rte_eth_bond_mac_address_set(res->port_num, &res->address); 6375 6376 /* check the return value and print it if is < 0 */ 6377 if (ret < 0) 6378 printf("set_bond_mac_addr error: (%s)\n", strerror(-ret)); 6379 } 6380 6381 cmdline_parse_token_string_t cmd_set_bond_mac_addr_set = 6382 TOKEN_STRING_INITIALIZER(struct cmd_set_bond_mac_addr_result, set, "set"); 6383 cmdline_parse_token_string_t cmd_set_bond_mac_addr_bonding = 6384 TOKEN_STRING_INITIALIZER(struct cmd_set_bond_mac_addr_result, bonding, 6385 "bonding"); 6386 cmdline_parse_token_string_t cmd_set_bond_mac_addr_mac = 6387 TOKEN_STRING_INITIALIZER(struct cmd_set_bond_mac_addr_result, mac_addr, 6388 "mac_addr"); 6389 cmdline_parse_token_num_t cmd_set_bond_mac_addr_portnum = 6390 TOKEN_NUM_INITIALIZER(struct cmd_set_bond_mac_addr_result, 6391 port_num, UINT16); 6392 cmdline_parse_token_etheraddr_t cmd_set_bond_mac_addr_addr = 6393 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_bond_mac_addr_result, address); 6394 6395 cmdline_parse_inst_t cmd_set_bond_mac_addr = { 6396 .f = cmd_set_bond_mac_addr_parsed, 6397 .data = (void *) 0, 6398 .help_str = "set bonding mac_addr <port_id> <mac_addr>", 6399 .tokens = { 6400 (void *)&cmd_set_bond_mac_addr_set, 6401 (void *)&cmd_set_bond_mac_addr_bonding, 6402 (void *)&cmd_set_bond_mac_addr_mac, 6403 (void *)&cmd_set_bond_mac_addr_portnum, 6404 (void *)&cmd_set_bond_mac_addr_addr, 6405 NULL 6406 } 6407 }; 6408 6409 6410 /* *** SET LINK STATUS MONITORING POLLING PERIOD ON BONDED DEVICE *** */ 6411 struct cmd_set_bond_mon_period_result { 6412 cmdline_fixed_string_t set; 6413 cmdline_fixed_string_t bonding; 6414 cmdline_fixed_string_t mon_period; 6415 uint16_t port_num; 6416 uint32_t period_ms; 6417 }; 6418 6419 static void cmd_set_bond_mon_period_parsed(void *parsed_result, 6420 __rte_unused struct cmdline *cl, 6421 __rte_unused void *data) 6422 { 6423 struct cmd_set_bond_mon_period_result *res = parsed_result; 6424 int ret; 6425 6426 ret = rte_eth_bond_link_monitoring_set(res->port_num, res->period_ms); 6427 6428 /* check the return value and print it if is < 0 */ 6429 if (ret < 0) 6430 printf("set_bond_mac_addr error: (%s)\n", strerror(-ret)); 6431 } 6432 6433 cmdline_parse_token_string_t cmd_set_bond_mon_period_set = 6434 TOKEN_STRING_INITIALIZER(struct cmd_set_bond_mon_period_result, 6435 set, "set"); 6436 cmdline_parse_token_string_t cmd_set_bond_mon_period_bonding = 6437 TOKEN_STRING_INITIALIZER(struct cmd_set_bond_mon_period_result, 6438 bonding, "bonding"); 6439 cmdline_parse_token_string_t cmd_set_bond_mon_period_mon_period = 6440 TOKEN_STRING_INITIALIZER(struct cmd_set_bond_mon_period_result, 6441 mon_period, "mon_period"); 6442 cmdline_parse_token_num_t cmd_set_bond_mon_period_portnum = 6443 TOKEN_NUM_INITIALIZER(struct cmd_set_bond_mon_period_result, 6444 port_num, UINT16); 6445 cmdline_parse_token_num_t cmd_set_bond_mon_period_period_ms = 6446 TOKEN_NUM_INITIALIZER(struct cmd_set_bond_mon_period_result, 6447 period_ms, UINT32); 6448 6449 cmdline_parse_inst_t cmd_set_bond_mon_period = { 6450 .f = cmd_set_bond_mon_period_parsed, 6451 .data = (void *) 0, 6452 .help_str = "set bonding mon_period <port_id> <period_ms>", 6453 .tokens = { 6454 (void *)&cmd_set_bond_mon_period_set, 6455 (void *)&cmd_set_bond_mon_period_bonding, 6456 (void *)&cmd_set_bond_mon_period_mon_period, 6457 (void *)&cmd_set_bond_mon_period_portnum, 6458 (void *)&cmd_set_bond_mon_period_period_ms, 6459 NULL 6460 } 6461 }; 6462 6463 6464 6465 struct cmd_set_bonding_agg_mode_policy_result { 6466 cmdline_fixed_string_t set; 6467 cmdline_fixed_string_t bonding; 6468 cmdline_fixed_string_t agg_mode; 6469 uint16_t port_num; 6470 cmdline_fixed_string_t policy; 6471 }; 6472 6473 6474 static void 6475 cmd_set_bonding_agg_mode(void *parsed_result, 6476 __rte_unused struct cmdline *cl, 6477 __rte_unused void *data) 6478 { 6479 struct cmd_set_bonding_agg_mode_policy_result *res = parsed_result; 6480 uint8_t policy = AGG_BANDWIDTH; 6481 6482 if (!strcmp(res->policy, "bandwidth")) 6483 policy = AGG_BANDWIDTH; 6484 else if (!strcmp(res->policy, "stable")) 6485 policy = AGG_STABLE; 6486 else if (!strcmp(res->policy, "count")) 6487 policy = AGG_COUNT; 6488 6489 rte_eth_bond_8023ad_agg_selection_set(res->port_num, policy); 6490 } 6491 6492 6493 cmdline_parse_token_string_t cmd_set_bonding_agg_mode_set = 6494 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_agg_mode_policy_result, 6495 set, "set"); 6496 cmdline_parse_token_string_t cmd_set_bonding_agg_mode_bonding = 6497 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_agg_mode_policy_result, 6498 bonding, "bonding"); 6499 6500 cmdline_parse_token_string_t cmd_set_bonding_agg_mode_agg_mode = 6501 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_agg_mode_policy_result, 6502 agg_mode, "agg_mode"); 6503 6504 cmdline_parse_token_num_t cmd_set_bonding_agg_mode_portnum = 6505 TOKEN_NUM_INITIALIZER(struct cmd_set_bonding_agg_mode_policy_result, 6506 port_num, UINT16); 6507 6508 cmdline_parse_token_string_t cmd_set_bonding_agg_mode_policy_string = 6509 TOKEN_STRING_INITIALIZER( 6510 struct cmd_set_bonding_balance_xmit_policy_result, 6511 policy, "stable#bandwidth#count"); 6512 6513 cmdline_parse_inst_t cmd_set_bonding_agg_mode_policy = { 6514 .f = cmd_set_bonding_agg_mode, 6515 .data = (void *) 0, 6516 .help_str = "set bonding mode IEEE802.3AD aggregator policy <port_id> <agg_name>", 6517 .tokens = { 6518 (void *)&cmd_set_bonding_agg_mode_set, 6519 (void *)&cmd_set_bonding_agg_mode_bonding, 6520 (void *)&cmd_set_bonding_agg_mode_agg_mode, 6521 (void *)&cmd_set_bonding_agg_mode_portnum, 6522 (void *)&cmd_set_bonding_agg_mode_policy_string, 6523 NULL 6524 } 6525 }; 6526 6527 6528 #endif /* RTE_LIBRTE_PMD_BOND */ 6529 6530 /* *** SET FORWARDING MODE *** */ 6531 struct cmd_set_fwd_mode_result { 6532 cmdline_fixed_string_t set; 6533 cmdline_fixed_string_t fwd; 6534 cmdline_fixed_string_t mode; 6535 }; 6536 6537 static void cmd_set_fwd_mode_parsed(void *parsed_result, 6538 __rte_unused struct cmdline *cl, 6539 __rte_unused void *data) 6540 { 6541 struct cmd_set_fwd_mode_result *res = parsed_result; 6542 6543 retry_enabled = 0; 6544 set_pkt_forwarding_mode(res->mode); 6545 } 6546 6547 cmdline_parse_token_string_t cmd_setfwd_set = 6548 TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_mode_result, set, "set"); 6549 cmdline_parse_token_string_t cmd_setfwd_fwd = 6550 TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_mode_result, fwd, "fwd"); 6551 cmdline_parse_token_string_t cmd_setfwd_mode = 6552 TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_mode_result, mode, 6553 "" /* defined at init */); 6554 6555 cmdline_parse_inst_t cmd_set_fwd_mode = { 6556 .f = cmd_set_fwd_mode_parsed, 6557 .data = NULL, 6558 .help_str = NULL, /* defined at init */ 6559 .tokens = { 6560 (void *)&cmd_setfwd_set, 6561 (void *)&cmd_setfwd_fwd, 6562 (void *)&cmd_setfwd_mode, 6563 NULL, 6564 }, 6565 }; 6566 6567 static void cmd_set_fwd_mode_init(void) 6568 { 6569 char *modes, *c; 6570 static char token[128]; 6571 static char help[256]; 6572 cmdline_parse_token_string_t *token_struct; 6573 6574 modes = list_pkt_forwarding_modes(); 6575 snprintf(help, sizeof(help), "set fwd %s: " 6576 "Set packet forwarding mode", modes); 6577 cmd_set_fwd_mode.help_str = help; 6578 6579 /* string token separator is # */ 6580 for (c = token; *modes != '\0'; modes++) 6581 if (*modes == '|') 6582 *c++ = '#'; 6583 else 6584 *c++ = *modes; 6585 token_struct = (cmdline_parse_token_string_t*)cmd_set_fwd_mode.tokens[2]; 6586 token_struct->string_data.str = token; 6587 } 6588 6589 /* *** SET RETRY FORWARDING MODE *** */ 6590 struct cmd_set_fwd_retry_mode_result { 6591 cmdline_fixed_string_t set; 6592 cmdline_fixed_string_t fwd; 6593 cmdline_fixed_string_t mode; 6594 cmdline_fixed_string_t retry; 6595 }; 6596 6597 static void cmd_set_fwd_retry_mode_parsed(void *parsed_result, 6598 __rte_unused struct cmdline *cl, 6599 __rte_unused void *data) 6600 { 6601 struct cmd_set_fwd_retry_mode_result *res = parsed_result; 6602 6603 retry_enabled = 1; 6604 set_pkt_forwarding_mode(res->mode); 6605 } 6606 6607 cmdline_parse_token_string_t cmd_setfwd_retry_set = 6608 TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_retry_mode_result, 6609 set, "set"); 6610 cmdline_parse_token_string_t cmd_setfwd_retry_fwd = 6611 TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_retry_mode_result, 6612 fwd, "fwd"); 6613 cmdline_parse_token_string_t cmd_setfwd_retry_mode = 6614 TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_retry_mode_result, 6615 mode, 6616 "" /* defined at init */); 6617 cmdline_parse_token_string_t cmd_setfwd_retry_retry = 6618 TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_retry_mode_result, 6619 retry, "retry"); 6620 6621 cmdline_parse_inst_t cmd_set_fwd_retry_mode = { 6622 .f = cmd_set_fwd_retry_mode_parsed, 6623 .data = NULL, 6624 .help_str = NULL, /* defined at init */ 6625 .tokens = { 6626 (void *)&cmd_setfwd_retry_set, 6627 (void *)&cmd_setfwd_retry_fwd, 6628 (void *)&cmd_setfwd_retry_mode, 6629 (void *)&cmd_setfwd_retry_retry, 6630 NULL, 6631 }, 6632 }; 6633 6634 static void cmd_set_fwd_retry_mode_init(void) 6635 { 6636 char *modes, *c; 6637 static char token[128]; 6638 static char help[256]; 6639 cmdline_parse_token_string_t *token_struct; 6640 6641 modes = list_pkt_forwarding_retry_modes(); 6642 snprintf(help, sizeof(help), "set fwd %s retry: " 6643 "Set packet forwarding mode with retry", modes); 6644 cmd_set_fwd_retry_mode.help_str = help; 6645 6646 /* string token separator is # */ 6647 for (c = token; *modes != '\0'; modes++) 6648 if (*modes == '|') 6649 *c++ = '#'; 6650 else 6651 *c++ = *modes; 6652 token_struct = (cmdline_parse_token_string_t *) 6653 cmd_set_fwd_retry_mode.tokens[2]; 6654 token_struct->string_data.str = token; 6655 } 6656 6657 /* *** SET BURST TX DELAY TIME RETRY NUMBER *** */ 6658 struct cmd_set_burst_tx_retry_result { 6659 cmdline_fixed_string_t set; 6660 cmdline_fixed_string_t burst; 6661 cmdline_fixed_string_t tx; 6662 cmdline_fixed_string_t delay; 6663 uint32_t time; 6664 cmdline_fixed_string_t retry; 6665 uint32_t retry_num; 6666 }; 6667 6668 static void cmd_set_burst_tx_retry_parsed(void *parsed_result, 6669 __rte_unused struct cmdline *cl, 6670 __rte_unused void *data) 6671 { 6672 struct cmd_set_burst_tx_retry_result *res = parsed_result; 6673 6674 if (!strcmp(res->set, "set") && !strcmp(res->burst, "burst") 6675 && !strcmp(res->tx, "tx")) { 6676 if (!strcmp(res->delay, "delay")) 6677 burst_tx_delay_time = res->time; 6678 if (!strcmp(res->retry, "retry")) 6679 burst_tx_retry_num = res->retry_num; 6680 } 6681 6682 } 6683 6684 cmdline_parse_token_string_t cmd_set_burst_tx_retry_set = 6685 TOKEN_STRING_INITIALIZER(struct cmd_set_burst_tx_retry_result, set, "set"); 6686 cmdline_parse_token_string_t cmd_set_burst_tx_retry_burst = 6687 TOKEN_STRING_INITIALIZER(struct cmd_set_burst_tx_retry_result, burst, 6688 "burst"); 6689 cmdline_parse_token_string_t cmd_set_burst_tx_retry_tx = 6690 TOKEN_STRING_INITIALIZER(struct cmd_set_burst_tx_retry_result, tx, "tx"); 6691 cmdline_parse_token_string_t cmd_set_burst_tx_retry_delay = 6692 TOKEN_STRING_INITIALIZER(struct cmd_set_burst_tx_retry_result, delay, "delay"); 6693 cmdline_parse_token_num_t cmd_set_burst_tx_retry_time = 6694 TOKEN_NUM_INITIALIZER(struct cmd_set_burst_tx_retry_result, time, UINT32); 6695 cmdline_parse_token_string_t cmd_set_burst_tx_retry_retry = 6696 TOKEN_STRING_INITIALIZER(struct cmd_set_burst_tx_retry_result, retry, "retry"); 6697 cmdline_parse_token_num_t cmd_set_burst_tx_retry_retry_num = 6698 TOKEN_NUM_INITIALIZER(struct cmd_set_burst_tx_retry_result, retry_num, UINT32); 6699 6700 cmdline_parse_inst_t cmd_set_burst_tx_retry = { 6701 .f = cmd_set_burst_tx_retry_parsed, 6702 .help_str = "set burst tx delay <delay_usec> retry <num_retry>", 6703 .tokens = { 6704 (void *)&cmd_set_burst_tx_retry_set, 6705 (void *)&cmd_set_burst_tx_retry_burst, 6706 (void *)&cmd_set_burst_tx_retry_tx, 6707 (void *)&cmd_set_burst_tx_retry_delay, 6708 (void *)&cmd_set_burst_tx_retry_time, 6709 (void *)&cmd_set_burst_tx_retry_retry, 6710 (void *)&cmd_set_burst_tx_retry_retry_num, 6711 NULL, 6712 }, 6713 }; 6714 6715 /* *** SET PROMISC MODE *** */ 6716 struct cmd_set_promisc_mode_result { 6717 cmdline_fixed_string_t set; 6718 cmdline_fixed_string_t promisc; 6719 cmdline_fixed_string_t port_all; /* valid if "allports" argument == 1 */ 6720 uint16_t port_num; /* valid if "allports" argument == 0 */ 6721 cmdline_fixed_string_t mode; 6722 }; 6723 6724 static void cmd_set_promisc_mode_parsed(void *parsed_result, 6725 __rte_unused struct cmdline *cl, 6726 void *allports) 6727 { 6728 struct cmd_set_promisc_mode_result *res = parsed_result; 6729 int enable; 6730 portid_t i; 6731 6732 if (!strcmp(res->mode, "on")) 6733 enable = 1; 6734 else 6735 enable = 0; 6736 6737 /* all ports */ 6738 if (allports) { 6739 RTE_ETH_FOREACH_DEV(i) 6740 eth_set_promisc_mode(i, enable); 6741 } else { 6742 eth_set_promisc_mode(res->port_num, enable); 6743 } 6744 } 6745 6746 cmdline_parse_token_string_t cmd_setpromisc_set = 6747 TOKEN_STRING_INITIALIZER(struct cmd_set_promisc_mode_result, set, "set"); 6748 cmdline_parse_token_string_t cmd_setpromisc_promisc = 6749 TOKEN_STRING_INITIALIZER(struct cmd_set_promisc_mode_result, promisc, 6750 "promisc"); 6751 cmdline_parse_token_string_t cmd_setpromisc_portall = 6752 TOKEN_STRING_INITIALIZER(struct cmd_set_promisc_mode_result, port_all, 6753 "all"); 6754 cmdline_parse_token_num_t cmd_setpromisc_portnum = 6755 TOKEN_NUM_INITIALIZER(struct cmd_set_promisc_mode_result, port_num, 6756 UINT16); 6757 cmdline_parse_token_string_t cmd_setpromisc_mode = 6758 TOKEN_STRING_INITIALIZER(struct cmd_set_promisc_mode_result, mode, 6759 "on#off"); 6760 6761 cmdline_parse_inst_t cmd_set_promisc_mode_all = { 6762 .f = cmd_set_promisc_mode_parsed, 6763 .data = (void *)1, 6764 .help_str = "set promisc all on|off: Set promisc mode for all ports", 6765 .tokens = { 6766 (void *)&cmd_setpromisc_set, 6767 (void *)&cmd_setpromisc_promisc, 6768 (void *)&cmd_setpromisc_portall, 6769 (void *)&cmd_setpromisc_mode, 6770 NULL, 6771 }, 6772 }; 6773 6774 cmdline_parse_inst_t cmd_set_promisc_mode_one = { 6775 .f = cmd_set_promisc_mode_parsed, 6776 .data = (void *)0, 6777 .help_str = "set promisc <port_id> on|off: Set promisc mode on port_id", 6778 .tokens = { 6779 (void *)&cmd_setpromisc_set, 6780 (void *)&cmd_setpromisc_promisc, 6781 (void *)&cmd_setpromisc_portnum, 6782 (void *)&cmd_setpromisc_mode, 6783 NULL, 6784 }, 6785 }; 6786 6787 /* *** SET ALLMULTI MODE *** */ 6788 struct cmd_set_allmulti_mode_result { 6789 cmdline_fixed_string_t set; 6790 cmdline_fixed_string_t allmulti; 6791 cmdline_fixed_string_t port_all; /* valid if "allports" argument == 1 */ 6792 uint16_t port_num; /* valid if "allports" argument == 0 */ 6793 cmdline_fixed_string_t mode; 6794 }; 6795 6796 static void cmd_set_allmulti_mode_parsed(void *parsed_result, 6797 __rte_unused struct cmdline *cl, 6798 void *allports) 6799 { 6800 struct cmd_set_allmulti_mode_result *res = parsed_result; 6801 int enable; 6802 portid_t i; 6803 6804 if (!strcmp(res->mode, "on")) 6805 enable = 1; 6806 else 6807 enable = 0; 6808 6809 /* all ports */ 6810 if (allports) { 6811 RTE_ETH_FOREACH_DEV(i) { 6812 eth_set_allmulticast_mode(i, enable); 6813 } 6814 } 6815 else { 6816 eth_set_allmulticast_mode(res->port_num, enable); 6817 } 6818 } 6819 6820 cmdline_parse_token_string_t cmd_setallmulti_set = 6821 TOKEN_STRING_INITIALIZER(struct cmd_set_allmulti_mode_result, set, "set"); 6822 cmdline_parse_token_string_t cmd_setallmulti_allmulti = 6823 TOKEN_STRING_INITIALIZER(struct cmd_set_allmulti_mode_result, allmulti, 6824 "allmulti"); 6825 cmdline_parse_token_string_t cmd_setallmulti_portall = 6826 TOKEN_STRING_INITIALIZER(struct cmd_set_allmulti_mode_result, port_all, 6827 "all"); 6828 cmdline_parse_token_num_t cmd_setallmulti_portnum = 6829 TOKEN_NUM_INITIALIZER(struct cmd_set_allmulti_mode_result, port_num, 6830 UINT16); 6831 cmdline_parse_token_string_t cmd_setallmulti_mode = 6832 TOKEN_STRING_INITIALIZER(struct cmd_set_allmulti_mode_result, mode, 6833 "on#off"); 6834 6835 cmdline_parse_inst_t cmd_set_allmulti_mode_all = { 6836 .f = cmd_set_allmulti_mode_parsed, 6837 .data = (void *)1, 6838 .help_str = "set allmulti all on|off: Set allmulti mode for all ports", 6839 .tokens = { 6840 (void *)&cmd_setallmulti_set, 6841 (void *)&cmd_setallmulti_allmulti, 6842 (void *)&cmd_setallmulti_portall, 6843 (void *)&cmd_setallmulti_mode, 6844 NULL, 6845 }, 6846 }; 6847 6848 cmdline_parse_inst_t cmd_set_allmulti_mode_one = { 6849 .f = cmd_set_allmulti_mode_parsed, 6850 .data = (void *)0, 6851 .help_str = "set allmulti <port_id> on|off: " 6852 "Set allmulti mode on port_id", 6853 .tokens = { 6854 (void *)&cmd_setallmulti_set, 6855 (void *)&cmd_setallmulti_allmulti, 6856 (void *)&cmd_setallmulti_portnum, 6857 (void *)&cmd_setallmulti_mode, 6858 NULL, 6859 }, 6860 }; 6861 6862 /* *** SETUP ETHERNET LINK FLOW CONTROL *** */ 6863 struct cmd_link_flow_ctrl_set_result { 6864 cmdline_fixed_string_t set; 6865 cmdline_fixed_string_t flow_ctrl; 6866 cmdline_fixed_string_t rx; 6867 cmdline_fixed_string_t rx_lfc_mode; 6868 cmdline_fixed_string_t tx; 6869 cmdline_fixed_string_t tx_lfc_mode; 6870 cmdline_fixed_string_t mac_ctrl_frame_fwd; 6871 cmdline_fixed_string_t mac_ctrl_frame_fwd_mode; 6872 cmdline_fixed_string_t autoneg_str; 6873 cmdline_fixed_string_t autoneg; 6874 cmdline_fixed_string_t hw_str; 6875 uint32_t high_water; 6876 cmdline_fixed_string_t lw_str; 6877 uint32_t low_water; 6878 cmdline_fixed_string_t pt_str; 6879 uint16_t pause_time; 6880 cmdline_fixed_string_t xon_str; 6881 uint16_t send_xon; 6882 portid_t port_id; 6883 }; 6884 6885 cmdline_parse_token_string_t cmd_lfc_set_set = 6886 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result, 6887 set, "set"); 6888 cmdline_parse_token_string_t cmd_lfc_set_flow_ctrl = 6889 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result, 6890 flow_ctrl, "flow_ctrl"); 6891 cmdline_parse_token_string_t cmd_lfc_set_rx = 6892 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result, 6893 rx, "rx"); 6894 cmdline_parse_token_string_t cmd_lfc_set_rx_mode = 6895 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result, 6896 rx_lfc_mode, "on#off"); 6897 cmdline_parse_token_string_t cmd_lfc_set_tx = 6898 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result, 6899 tx, "tx"); 6900 cmdline_parse_token_string_t cmd_lfc_set_tx_mode = 6901 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result, 6902 tx_lfc_mode, "on#off"); 6903 cmdline_parse_token_string_t cmd_lfc_set_high_water_str = 6904 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result, 6905 hw_str, "high_water"); 6906 cmdline_parse_token_num_t cmd_lfc_set_high_water = 6907 TOKEN_NUM_INITIALIZER(struct cmd_link_flow_ctrl_set_result, 6908 high_water, UINT32); 6909 cmdline_parse_token_string_t cmd_lfc_set_low_water_str = 6910 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result, 6911 lw_str, "low_water"); 6912 cmdline_parse_token_num_t cmd_lfc_set_low_water = 6913 TOKEN_NUM_INITIALIZER(struct cmd_link_flow_ctrl_set_result, 6914 low_water, UINT32); 6915 cmdline_parse_token_string_t cmd_lfc_set_pause_time_str = 6916 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result, 6917 pt_str, "pause_time"); 6918 cmdline_parse_token_num_t cmd_lfc_set_pause_time = 6919 TOKEN_NUM_INITIALIZER(struct cmd_link_flow_ctrl_set_result, 6920 pause_time, UINT16); 6921 cmdline_parse_token_string_t cmd_lfc_set_send_xon_str = 6922 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result, 6923 xon_str, "send_xon"); 6924 cmdline_parse_token_num_t cmd_lfc_set_send_xon = 6925 TOKEN_NUM_INITIALIZER(struct cmd_link_flow_ctrl_set_result, 6926 send_xon, UINT16); 6927 cmdline_parse_token_string_t cmd_lfc_set_mac_ctrl_frame_fwd_mode = 6928 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result, 6929 mac_ctrl_frame_fwd, "mac_ctrl_frame_fwd"); 6930 cmdline_parse_token_string_t cmd_lfc_set_mac_ctrl_frame_fwd = 6931 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result, 6932 mac_ctrl_frame_fwd_mode, "on#off"); 6933 cmdline_parse_token_string_t cmd_lfc_set_autoneg_str = 6934 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result, 6935 autoneg_str, "autoneg"); 6936 cmdline_parse_token_string_t cmd_lfc_set_autoneg = 6937 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result, 6938 autoneg, "on#off"); 6939 cmdline_parse_token_num_t cmd_lfc_set_portid = 6940 TOKEN_NUM_INITIALIZER(struct cmd_link_flow_ctrl_set_result, 6941 port_id, UINT16); 6942 6943 /* forward declaration */ 6944 static void 6945 cmd_link_flow_ctrl_set_parsed(void *parsed_result, struct cmdline *cl, 6946 void *data); 6947 6948 cmdline_parse_inst_t cmd_link_flow_control_set = { 6949 .f = cmd_link_flow_ctrl_set_parsed, 6950 .data = NULL, 6951 .help_str = "set flow_ctrl rx on|off tx on|off <high_water> " 6952 "<low_water> <pause_time> <send_xon> mac_ctrl_frame_fwd on|off " 6953 "autoneg on|off <port_id>: Configure the Ethernet flow control", 6954 .tokens = { 6955 (void *)&cmd_lfc_set_set, 6956 (void *)&cmd_lfc_set_flow_ctrl, 6957 (void *)&cmd_lfc_set_rx, 6958 (void *)&cmd_lfc_set_rx_mode, 6959 (void *)&cmd_lfc_set_tx, 6960 (void *)&cmd_lfc_set_tx_mode, 6961 (void *)&cmd_lfc_set_high_water, 6962 (void *)&cmd_lfc_set_low_water, 6963 (void *)&cmd_lfc_set_pause_time, 6964 (void *)&cmd_lfc_set_send_xon, 6965 (void *)&cmd_lfc_set_mac_ctrl_frame_fwd_mode, 6966 (void *)&cmd_lfc_set_mac_ctrl_frame_fwd, 6967 (void *)&cmd_lfc_set_autoneg_str, 6968 (void *)&cmd_lfc_set_autoneg, 6969 (void *)&cmd_lfc_set_portid, 6970 NULL, 6971 }, 6972 }; 6973 6974 cmdline_parse_inst_t cmd_link_flow_control_set_rx = { 6975 .f = cmd_link_flow_ctrl_set_parsed, 6976 .data = (void *)&cmd_link_flow_control_set_rx, 6977 .help_str = "set flow_ctrl rx on|off <port_id>: " 6978 "Change rx flow control parameter", 6979 .tokens = { 6980 (void *)&cmd_lfc_set_set, 6981 (void *)&cmd_lfc_set_flow_ctrl, 6982 (void *)&cmd_lfc_set_rx, 6983 (void *)&cmd_lfc_set_rx_mode, 6984 (void *)&cmd_lfc_set_portid, 6985 NULL, 6986 }, 6987 }; 6988 6989 cmdline_parse_inst_t cmd_link_flow_control_set_tx = { 6990 .f = cmd_link_flow_ctrl_set_parsed, 6991 .data = (void *)&cmd_link_flow_control_set_tx, 6992 .help_str = "set flow_ctrl tx on|off <port_id>: " 6993 "Change tx flow control parameter", 6994 .tokens = { 6995 (void *)&cmd_lfc_set_set, 6996 (void *)&cmd_lfc_set_flow_ctrl, 6997 (void *)&cmd_lfc_set_tx, 6998 (void *)&cmd_lfc_set_tx_mode, 6999 (void *)&cmd_lfc_set_portid, 7000 NULL, 7001 }, 7002 }; 7003 7004 cmdline_parse_inst_t cmd_link_flow_control_set_hw = { 7005 .f = cmd_link_flow_ctrl_set_parsed, 7006 .data = (void *)&cmd_link_flow_control_set_hw, 7007 .help_str = "set flow_ctrl high_water <value> <port_id>: " 7008 "Change high water flow control parameter", 7009 .tokens = { 7010 (void *)&cmd_lfc_set_set, 7011 (void *)&cmd_lfc_set_flow_ctrl, 7012 (void *)&cmd_lfc_set_high_water_str, 7013 (void *)&cmd_lfc_set_high_water, 7014 (void *)&cmd_lfc_set_portid, 7015 NULL, 7016 }, 7017 }; 7018 7019 cmdline_parse_inst_t cmd_link_flow_control_set_lw = { 7020 .f = cmd_link_flow_ctrl_set_parsed, 7021 .data = (void *)&cmd_link_flow_control_set_lw, 7022 .help_str = "set flow_ctrl low_water <value> <port_id>: " 7023 "Change low water flow control parameter", 7024 .tokens = { 7025 (void *)&cmd_lfc_set_set, 7026 (void *)&cmd_lfc_set_flow_ctrl, 7027 (void *)&cmd_lfc_set_low_water_str, 7028 (void *)&cmd_lfc_set_low_water, 7029 (void *)&cmd_lfc_set_portid, 7030 NULL, 7031 }, 7032 }; 7033 7034 cmdline_parse_inst_t cmd_link_flow_control_set_pt = { 7035 .f = cmd_link_flow_ctrl_set_parsed, 7036 .data = (void *)&cmd_link_flow_control_set_pt, 7037 .help_str = "set flow_ctrl pause_time <value> <port_id>: " 7038 "Change pause time flow control parameter", 7039 .tokens = { 7040 (void *)&cmd_lfc_set_set, 7041 (void *)&cmd_lfc_set_flow_ctrl, 7042 (void *)&cmd_lfc_set_pause_time_str, 7043 (void *)&cmd_lfc_set_pause_time, 7044 (void *)&cmd_lfc_set_portid, 7045 NULL, 7046 }, 7047 }; 7048 7049 cmdline_parse_inst_t cmd_link_flow_control_set_xon = { 7050 .f = cmd_link_flow_ctrl_set_parsed, 7051 .data = (void *)&cmd_link_flow_control_set_xon, 7052 .help_str = "set flow_ctrl send_xon <value> <port_id>: " 7053 "Change send_xon flow control parameter", 7054 .tokens = { 7055 (void *)&cmd_lfc_set_set, 7056 (void *)&cmd_lfc_set_flow_ctrl, 7057 (void *)&cmd_lfc_set_send_xon_str, 7058 (void *)&cmd_lfc_set_send_xon, 7059 (void *)&cmd_lfc_set_portid, 7060 NULL, 7061 }, 7062 }; 7063 7064 cmdline_parse_inst_t cmd_link_flow_control_set_macfwd = { 7065 .f = cmd_link_flow_ctrl_set_parsed, 7066 .data = (void *)&cmd_link_flow_control_set_macfwd, 7067 .help_str = "set flow_ctrl mac_ctrl_frame_fwd on|off <port_id>: " 7068 "Change mac ctrl fwd flow control parameter", 7069 .tokens = { 7070 (void *)&cmd_lfc_set_set, 7071 (void *)&cmd_lfc_set_flow_ctrl, 7072 (void *)&cmd_lfc_set_mac_ctrl_frame_fwd_mode, 7073 (void *)&cmd_lfc_set_mac_ctrl_frame_fwd, 7074 (void *)&cmd_lfc_set_portid, 7075 NULL, 7076 }, 7077 }; 7078 7079 cmdline_parse_inst_t cmd_link_flow_control_set_autoneg = { 7080 .f = cmd_link_flow_ctrl_set_parsed, 7081 .data = (void *)&cmd_link_flow_control_set_autoneg, 7082 .help_str = "set flow_ctrl autoneg on|off <port_id>: " 7083 "Change autoneg flow control parameter", 7084 .tokens = { 7085 (void *)&cmd_lfc_set_set, 7086 (void *)&cmd_lfc_set_flow_ctrl, 7087 (void *)&cmd_lfc_set_autoneg_str, 7088 (void *)&cmd_lfc_set_autoneg, 7089 (void *)&cmd_lfc_set_portid, 7090 NULL, 7091 }, 7092 }; 7093 7094 static void 7095 cmd_link_flow_ctrl_set_parsed(void *parsed_result, 7096 __rte_unused struct cmdline *cl, 7097 void *data) 7098 { 7099 struct cmd_link_flow_ctrl_set_result *res = parsed_result; 7100 cmdline_parse_inst_t *cmd = data; 7101 struct rte_eth_fc_conf fc_conf; 7102 int rx_fc_en = 0; 7103 int tx_fc_en = 0; 7104 int ret; 7105 7106 /* 7107 * Rx on/off, flow control is enabled/disabled on RX side. This can indicate 7108 * the RTE_FC_TX_PAUSE, Transmit pause frame at the Rx side. 7109 * Tx on/off, flow control is enabled/disabled on TX side. This can indicate 7110 * the RTE_FC_RX_PAUSE, Respond to the pause frame at the Tx side. 7111 */ 7112 static enum rte_eth_fc_mode rx_tx_onoff_2_lfc_mode[2][2] = { 7113 {RTE_FC_NONE, RTE_FC_TX_PAUSE}, {RTE_FC_RX_PAUSE, RTE_FC_FULL} 7114 }; 7115 7116 /* Partial command line, retrieve current configuration */ 7117 if (cmd) { 7118 ret = rte_eth_dev_flow_ctrl_get(res->port_id, &fc_conf); 7119 if (ret != 0) { 7120 printf("cannot get current flow ctrl parameters, return" 7121 "code = %d\n", ret); 7122 return; 7123 } 7124 7125 if ((fc_conf.mode == RTE_FC_RX_PAUSE) || 7126 (fc_conf.mode == RTE_FC_FULL)) 7127 rx_fc_en = 1; 7128 if ((fc_conf.mode == RTE_FC_TX_PAUSE) || 7129 (fc_conf.mode == RTE_FC_FULL)) 7130 tx_fc_en = 1; 7131 } 7132 7133 if (!cmd || cmd == &cmd_link_flow_control_set_rx) 7134 rx_fc_en = (!strcmp(res->rx_lfc_mode, "on")) ? 1 : 0; 7135 7136 if (!cmd || cmd == &cmd_link_flow_control_set_tx) 7137 tx_fc_en = (!strcmp(res->tx_lfc_mode, "on")) ? 1 : 0; 7138 7139 fc_conf.mode = rx_tx_onoff_2_lfc_mode[rx_fc_en][tx_fc_en]; 7140 7141 if (!cmd || cmd == &cmd_link_flow_control_set_hw) 7142 fc_conf.high_water = res->high_water; 7143 7144 if (!cmd || cmd == &cmd_link_flow_control_set_lw) 7145 fc_conf.low_water = res->low_water; 7146 7147 if (!cmd || cmd == &cmd_link_flow_control_set_pt) 7148 fc_conf.pause_time = res->pause_time; 7149 7150 if (!cmd || cmd == &cmd_link_flow_control_set_xon) 7151 fc_conf.send_xon = res->send_xon; 7152 7153 if (!cmd || cmd == &cmd_link_flow_control_set_macfwd) { 7154 if (!strcmp(res->mac_ctrl_frame_fwd_mode, "on")) 7155 fc_conf.mac_ctrl_frame_fwd = 1; 7156 else 7157 fc_conf.mac_ctrl_frame_fwd = 0; 7158 } 7159 7160 if (!cmd || cmd == &cmd_link_flow_control_set_autoneg) 7161 fc_conf.autoneg = (!strcmp(res->autoneg, "on")) ? 1 : 0; 7162 7163 ret = rte_eth_dev_flow_ctrl_set(res->port_id, &fc_conf); 7164 if (ret != 0) 7165 printf("bad flow contrl parameter, return code = %d \n", ret); 7166 } 7167 7168 /* *** SETUP ETHERNET PRIORITY FLOW CONTROL *** */ 7169 struct cmd_priority_flow_ctrl_set_result { 7170 cmdline_fixed_string_t set; 7171 cmdline_fixed_string_t pfc_ctrl; 7172 cmdline_fixed_string_t rx; 7173 cmdline_fixed_string_t rx_pfc_mode; 7174 cmdline_fixed_string_t tx; 7175 cmdline_fixed_string_t tx_pfc_mode; 7176 uint32_t high_water; 7177 uint32_t low_water; 7178 uint16_t pause_time; 7179 uint8_t priority; 7180 portid_t port_id; 7181 }; 7182 7183 static void 7184 cmd_priority_flow_ctrl_set_parsed(void *parsed_result, 7185 __rte_unused struct cmdline *cl, 7186 __rte_unused void *data) 7187 { 7188 struct cmd_priority_flow_ctrl_set_result *res = parsed_result; 7189 struct rte_eth_pfc_conf pfc_conf; 7190 int rx_fc_enable, tx_fc_enable; 7191 int ret; 7192 7193 /* 7194 * Rx on/off, flow control is enabled/disabled on RX side. This can indicate 7195 * the RTE_FC_TX_PAUSE, Transmit pause frame at the Rx side. 7196 * Tx on/off, flow control is enabled/disabled on TX side. This can indicate 7197 * the RTE_FC_RX_PAUSE, Respond to the pause frame at the Tx side. 7198 */ 7199 static enum rte_eth_fc_mode rx_tx_onoff_2_pfc_mode[2][2] = { 7200 {RTE_FC_NONE, RTE_FC_TX_PAUSE}, {RTE_FC_RX_PAUSE, RTE_FC_FULL} 7201 }; 7202 7203 memset(&pfc_conf, 0, sizeof(struct rte_eth_pfc_conf)); 7204 rx_fc_enable = (!strncmp(res->rx_pfc_mode, "on",2)) ? 1 : 0; 7205 tx_fc_enable = (!strncmp(res->tx_pfc_mode, "on",2)) ? 1 : 0; 7206 pfc_conf.fc.mode = rx_tx_onoff_2_pfc_mode[rx_fc_enable][tx_fc_enable]; 7207 pfc_conf.fc.high_water = res->high_water; 7208 pfc_conf.fc.low_water = res->low_water; 7209 pfc_conf.fc.pause_time = res->pause_time; 7210 pfc_conf.priority = res->priority; 7211 7212 ret = rte_eth_dev_priority_flow_ctrl_set(res->port_id, &pfc_conf); 7213 if (ret != 0) 7214 printf("bad priority flow contrl parameter, return code = %d \n", ret); 7215 } 7216 7217 cmdline_parse_token_string_t cmd_pfc_set_set = 7218 TOKEN_STRING_INITIALIZER(struct cmd_priority_flow_ctrl_set_result, 7219 set, "set"); 7220 cmdline_parse_token_string_t cmd_pfc_set_flow_ctrl = 7221 TOKEN_STRING_INITIALIZER(struct cmd_priority_flow_ctrl_set_result, 7222 pfc_ctrl, "pfc_ctrl"); 7223 cmdline_parse_token_string_t cmd_pfc_set_rx = 7224 TOKEN_STRING_INITIALIZER(struct cmd_priority_flow_ctrl_set_result, 7225 rx, "rx"); 7226 cmdline_parse_token_string_t cmd_pfc_set_rx_mode = 7227 TOKEN_STRING_INITIALIZER(struct cmd_priority_flow_ctrl_set_result, 7228 rx_pfc_mode, "on#off"); 7229 cmdline_parse_token_string_t cmd_pfc_set_tx = 7230 TOKEN_STRING_INITIALIZER(struct cmd_priority_flow_ctrl_set_result, 7231 tx, "tx"); 7232 cmdline_parse_token_string_t cmd_pfc_set_tx_mode = 7233 TOKEN_STRING_INITIALIZER(struct cmd_priority_flow_ctrl_set_result, 7234 tx_pfc_mode, "on#off"); 7235 cmdline_parse_token_num_t cmd_pfc_set_high_water = 7236 TOKEN_NUM_INITIALIZER(struct cmd_priority_flow_ctrl_set_result, 7237 high_water, UINT32); 7238 cmdline_parse_token_num_t cmd_pfc_set_low_water = 7239 TOKEN_NUM_INITIALIZER(struct cmd_priority_flow_ctrl_set_result, 7240 low_water, UINT32); 7241 cmdline_parse_token_num_t cmd_pfc_set_pause_time = 7242 TOKEN_NUM_INITIALIZER(struct cmd_priority_flow_ctrl_set_result, 7243 pause_time, UINT16); 7244 cmdline_parse_token_num_t cmd_pfc_set_priority = 7245 TOKEN_NUM_INITIALIZER(struct cmd_priority_flow_ctrl_set_result, 7246 priority, UINT8); 7247 cmdline_parse_token_num_t cmd_pfc_set_portid = 7248 TOKEN_NUM_INITIALIZER(struct cmd_priority_flow_ctrl_set_result, 7249 port_id, UINT16); 7250 7251 cmdline_parse_inst_t cmd_priority_flow_control_set = { 7252 .f = cmd_priority_flow_ctrl_set_parsed, 7253 .data = NULL, 7254 .help_str = "set pfc_ctrl rx on|off tx on|off <high_water> <low_water> " 7255 "<pause_time> <priority> <port_id>: " 7256 "Configure the Ethernet priority flow control", 7257 .tokens = { 7258 (void *)&cmd_pfc_set_set, 7259 (void *)&cmd_pfc_set_flow_ctrl, 7260 (void *)&cmd_pfc_set_rx, 7261 (void *)&cmd_pfc_set_rx_mode, 7262 (void *)&cmd_pfc_set_tx, 7263 (void *)&cmd_pfc_set_tx_mode, 7264 (void *)&cmd_pfc_set_high_water, 7265 (void *)&cmd_pfc_set_low_water, 7266 (void *)&cmd_pfc_set_pause_time, 7267 (void *)&cmd_pfc_set_priority, 7268 (void *)&cmd_pfc_set_portid, 7269 NULL, 7270 }, 7271 }; 7272 7273 /* *** RESET CONFIGURATION *** */ 7274 struct cmd_reset_result { 7275 cmdline_fixed_string_t reset; 7276 cmdline_fixed_string_t def; 7277 }; 7278 7279 static void cmd_reset_parsed(__rte_unused void *parsed_result, 7280 struct cmdline *cl, 7281 __rte_unused void *data) 7282 { 7283 cmdline_printf(cl, "Reset to default forwarding configuration...\n"); 7284 set_def_fwd_config(); 7285 } 7286 7287 cmdline_parse_token_string_t cmd_reset_set = 7288 TOKEN_STRING_INITIALIZER(struct cmd_reset_result, reset, "set"); 7289 cmdline_parse_token_string_t cmd_reset_def = 7290 TOKEN_STRING_INITIALIZER(struct cmd_reset_result, def, 7291 "default"); 7292 7293 cmdline_parse_inst_t cmd_reset = { 7294 .f = cmd_reset_parsed, 7295 .data = NULL, 7296 .help_str = "set default: Reset default forwarding configuration", 7297 .tokens = { 7298 (void *)&cmd_reset_set, 7299 (void *)&cmd_reset_def, 7300 NULL, 7301 }, 7302 }; 7303 7304 /* *** START FORWARDING *** */ 7305 struct cmd_start_result { 7306 cmdline_fixed_string_t start; 7307 }; 7308 7309 cmdline_parse_token_string_t cmd_start_start = 7310 TOKEN_STRING_INITIALIZER(struct cmd_start_result, start, "start"); 7311 7312 static void cmd_start_parsed(__rte_unused void *parsed_result, 7313 __rte_unused struct cmdline *cl, 7314 __rte_unused void *data) 7315 { 7316 start_packet_forwarding(0); 7317 } 7318 7319 cmdline_parse_inst_t cmd_start = { 7320 .f = cmd_start_parsed, 7321 .data = NULL, 7322 .help_str = "start: Start packet forwarding", 7323 .tokens = { 7324 (void *)&cmd_start_start, 7325 NULL, 7326 }, 7327 }; 7328 7329 /* *** START FORWARDING WITH ONE TX BURST FIRST *** */ 7330 struct cmd_start_tx_first_result { 7331 cmdline_fixed_string_t start; 7332 cmdline_fixed_string_t tx_first; 7333 }; 7334 7335 static void 7336 cmd_start_tx_first_parsed(__rte_unused void *parsed_result, 7337 __rte_unused struct cmdline *cl, 7338 __rte_unused void *data) 7339 { 7340 start_packet_forwarding(1); 7341 } 7342 7343 cmdline_parse_token_string_t cmd_start_tx_first_start = 7344 TOKEN_STRING_INITIALIZER(struct cmd_start_tx_first_result, start, 7345 "start"); 7346 cmdline_parse_token_string_t cmd_start_tx_first_tx_first = 7347 TOKEN_STRING_INITIALIZER(struct cmd_start_tx_first_result, 7348 tx_first, "tx_first"); 7349 7350 cmdline_parse_inst_t cmd_start_tx_first = { 7351 .f = cmd_start_tx_first_parsed, 7352 .data = NULL, 7353 .help_str = "start tx_first: Start packet forwarding, " 7354 "after sending 1 burst of packets", 7355 .tokens = { 7356 (void *)&cmd_start_tx_first_start, 7357 (void *)&cmd_start_tx_first_tx_first, 7358 NULL, 7359 }, 7360 }; 7361 7362 /* *** START FORWARDING WITH N TX BURST FIRST *** */ 7363 struct cmd_start_tx_first_n_result { 7364 cmdline_fixed_string_t start; 7365 cmdline_fixed_string_t tx_first; 7366 uint32_t tx_num; 7367 }; 7368 7369 static void 7370 cmd_start_tx_first_n_parsed(void *parsed_result, 7371 __rte_unused struct cmdline *cl, 7372 __rte_unused void *data) 7373 { 7374 struct cmd_start_tx_first_n_result *res = parsed_result; 7375 7376 start_packet_forwarding(res->tx_num); 7377 } 7378 7379 cmdline_parse_token_string_t cmd_start_tx_first_n_start = 7380 TOKEN_STRING_INITIALIZER(struct cmd_start_tx_first_n_result, 7381 start, "start"); 7382 cmdline_parse_token_string_t cmd_start_tx_first_n_tx_first = 7383 TOKEN_STRING_INITIALIZER(struct cmd_start_tx_first_n_result, 7384 tx_first, "tx_first"); 7385 cmdline_parse_token_num_t cmd_start_tx_first_n_tx_num = 7386 TOKEN_NUM_INITIALIZER(struct cmd_start_tx_first_n_result, 7387 tx_num, UINT32); 7388 7389 cmdline_parse_inst_t cmd_start_tx_first_n = { 7390 .f = cmd_start_tx_first_n_parsed, 7391 .data = NULL, 7392 .help_str = "start tx_first <num>: " 7393 "packet forwarding, after sending <num> bursts of packets", 7394 .tokens = { 7395 (void *)&cmd_start_tx_first_n_start, 7396 (void *)&cmd_start_tx_first_n_tx_first, 7397 (void *)&cmd_start_tx_first_n_tx_num, 7398 NULL, 7399 }, 7400 }; 7401 7402 /* *** SET LINK UP *** */ 7403 struct cmd_set_link_up_result { 7404 cmdline_fixed_string_t set; 7405 cmdline_fixed_string_t link_up; 7406 cmdline_fixed_string_t port; 7407 portid_t port_id; 7408 }; 7409 7410 cmdline_parse_token_string_t cmd_set_link_up_set = 7411 TOKEN_STRING_INITIALIZER(struct cmd_set_link_up_result, set, "set"); 7412 cmdline_parse_token_string_t cmd_set_link_up_link_up = 7413 TOKEN_STRING_INITIALIZER(struct cmd_set_link_up_result, link_up, 7414 "link-up"); 7415 cmdline_parse_token_string_t cmd_set_link_up_port = 7416 TOKEN_STRING_INITIALIZER(struct cmd_set_link_up_result, port, "port"); 7417 cmdline_parse_token_num_t cmd_set_link_up_port_id = 7418 TOKEN_NUM_INITIALIZER(struct cmd_set_link_up_result, port_id, UINT16); 7419 7420 static void cmd_set_link_up_parsed(__rte_unused void *parsed_result, 7421 __rte_unused struct cmdline *cl, 7422 __rte_unused void *data) 7423 { 7424 struct cmd_set_link_up_result *res = parsed_result; 7425 dev_set_link_up(res->port_id); 7426 } 7427 7428 cmdline_parse_inst_t cmd_set_link_up = { 7429 .f = cmd_set_link_up_parsed, 7430 .data = NULL, 7431 .help_str = "set link-up port <port id>", 7432 .tokens = { 7433 (void *)&cmd_set_link_up_set, 7434 (void *)&cmd_set_link_up_link_up, 7435 (void *)&cmd_set_link_up_port, 7436 (void *)&cmd_set_link_up_port_id, 7437 NULL, 7438 }, 7439 }; 7440 7441 /* *** SET LINK DOWN *** */ 7442 struct cmd_set_link_down_result { 7443 cmdline_fixed_string_t set; 7444 cmdline_fixed_string_t link_down; 7445 cmdline_fixed_string_t port; 7446 portid_t port_id; 7447 }; 7448 7449 cmdline_parse_token_string_t cmd_set_link_down_set = 7450 TOKEN_STRING_INITIALIZER(struct cmd_set_link_down_result, set, "set"); 7451 cmdline_parse_token_string_t cmd_set_link_down_link_down = 7452 TOKEN_STRING_INITIALIZER(struct cmd_set_link_down_result, link_down, 7453 "link-down"); 7454 cmdline_parse_token_string_t cmd_set_link_down_port = 7455 TOKEN_STRING_INITIALIZER(struct cmd_set_link_down_result, port, "port"); 7456 cmdline_parse_token_num_t cmd_set_link_down_port_id = 7457 TOKEN_NUM_INITIALIZER(struct cmd_set_link_down_result, port_id, UINT16); 7458 7459 static void cmd_set_link_down_parsed( 7460 __rte_unused void *parsed_result, 7461 __rte_unused struct cmdline *cl, 7462 __rte_unused void *data) 7463 { 7464 struct cmd_set_link_down_result *res = parsed_result; 7465 dev_set_link_down(res->port_id); 7466 } 7467 7468 cmdline_parse_inst_t cmd_set_link_down = { 7469 .f = cmd_set_link_down_parsed, 7470 .data = NULL, 7471 .help_str = "set link-down port <port id>", 7472 .tokens = { 7473 (void *)&cmd_set_link_down_set, 7474 (void *)&cmd_set_link_down_link_down, 7475 (void *)&cmd_set_link_down_port, 7476 (void *)&cmd_set_link_down_port_id, 7477 NULL, 7478 }, 7479 }; 7480 7481 /* *** SHOW CFG *** */ 7482 struct cmd_showcfg_result { 7483 cmdline_fixed_string_t show; 7484 cmdline_fixed_string_t cfg; 7485 cmdline_fixed_string_t what; 7486 }; 7487 7488 static void cmd_showcfg_parsed(void *parsed_result, 7489 __rte_unused struct cmdline *cl, 7490 __rte_unused void *data) 7491 { 7492 struct cmd_showcfg_result *res = parsed_result; 7493 if (!strcmp(res->what, "rxtx")) 7494 rxtx_config_display(); 7495 else if (!strcmp(res->what, "cores")) 7496 fwd_lcores_config_display(); 7497 else if (!strcmp(res->what, "fwd")) 7498 pkt_fwd_config_display(&cur_fwd_config); 7499 else if (!strcmp(res->what, "txpkts")) 7500 show_tx_pkt_segments(); 7501 else if (!strcmp(res->what, "txtimes")) 7502 show_tx_pkt_times(); 7503 } 7504 7505 cmdline_parse_token_string_t cmd_showcfg_show = 7506 TOKEN_STRING_INITIALIZER(struct cmd_showcfg_result, show, "show"); 7507 cmdline_parse_token_string_t cmd_showcfg_port = 7508 TOKEN_STRING_INITIALIZER(struct cmd_showcfg_result, cfg, "config"); 7509 cmdline_parse_token_string_t cmd_showcfg_what = 7510 TOKEN_STRING_INITIALIZER(struct cmd_showcfg_result, what, 7511 "rxtx#cores#fwd#txpkts#txtimes"); 7512 7513 cmdline_parse_inst_t cmd_showcfg = { 7514 .f = cmd_showcfg_parsed, 7515 .data = NULL, 7516 .help_str = "show config rxtx|cores|fwd|txpkts|txtimes", 7517 .tokens = { 7518 (void *)&cmd_showcfg_show, 7519 (void *)&cmd_showcfg_port, 7520 (void *)&cmd_showcfg_what, 7521 NULL, 7522 }, 7523 }; 7524 7525 /* *** SHOW ALL PORT INFO *** */ 7526 struct cmd_showportall_result { 7527 cmdline_fixed_string_t show; 7528 cmdline_fixed_string_t port; 7529 cmdline_fixed_string_t what; 7530 cmdline_fixed_string_t all; 7531 }; 7532 7533 static void cmd_showportall_parsed(void *parsed_result, 7534 __rte_unused struct cmdline *cl, 7535 __rte_unused void *data) 7536 { 7537 portid_t i; 7538 7539 struct cmd_showportall_result *res = parsed_result; 7540 if (!strcmp(res->show, "clear")) { 7541 if (!strcmp(res->what, "stats")) 7542 RTE_ETH_FOREACH_DEV(i) 7543 nic_stats_clear(i); 7544 else if (!strcmp(res->what, "xstats")) 7545 RTE_ETH_FOREACH_DEV(i) 7546 nic_xstats_clear(i); 7547 } else if (!strcmp(res->what, "info")) 7548 RTE_ETH_FOREACH_DEV(i) 7549 port_infos_display(i); 7550 else if (!strcmp(res->what, "summary")) { 7551 port_summary_header_display(); 7552 RTE_ETH_FOREACH_DEV(i) 7553 port_summary_display(i); 7554 } 7555 else if (!strcmp(res->what, "stats")) 7556 RTE_ETH_FOREACH_DEV(i) 7557 nic_stats_display(i); 7558 else if (!strcmp(res->what, "xstats")) 7559 RTE_ETH_FOREACH_DEV(i) 7560 nic_xstats_display(i); 7561 else if (!strcmp(res->what, "fdir")) 7562 RTE_ETH_FOREACH_DEV(i) 7563 fdir_get_infos(i); 7564 else if (!strcmp(res->what, "stat_qmap")) 7565 RTE_ETH_FOREACH_DEV(i) 7566 nic_stats_mapping_display(i); 7567 else if (!strcmp(res->what, "dcb_tc")) 7568 RTE_ETH_FOREACH_DEV(i) 7569 port_dcb_info_display(i); 7570 else if (!strcmp(res->what, "cap")) 7571 RTE_ETH_FOREACH_DEV(i) 7572 port_offload_cap_display(i); 7573 } 7574 7575 cmdline_parse_token_string_t cmd_showportall_show = 7576 TOKEN_STRING_INITIALIZER(struct cmd_showportall_result, show, 7577 "show#clear"); 7578 cmdline_parse_token_string_t cmd_showportall_port = 7579 TOKEN_STRING_INITIALIZER(struct cmd_showportall_result, port, "port"); 7580 cmdline_parse_token_string_t cmd_showportall_what = 7581 TOKEN_STRING_INITIALIZER(struct cmd_showportall_result, what, 7582 "info#summary#stats#xstats#fdir#stat_qmap#dcb_tc#cap"); 7583 cmdline_parse_token_string_t cmd_showportall_all = 7584 TOKEN_STRING_INITIALIZER(struct cmd_showportall_result, all, "all"); 7585 cmdline_parse_inst_t cmd_showportall = { 7586 .f = cmd_showportall_parsed, 7587 .data = NULL, 7588 .help_str = "show|clear port " 7589 "info|summary|stats|xstats|fdir|stat_qmap|dcb_tc|cap all", 7590 .tokens = { 7591 (void *)&cmd_showportall_show, 7592 (void *)&cmd_showportall_port, 7593 (void *)&cmd_showportall_what, 7594 (void *)&cmd_showportall_all, 7595 NULL, 7596 }, 7597 }; 7598 7599 /* *** SHOW PORT INFO *** */ 7600 struct cmd_showport_result { 7601 cmdline_fixed_string_t show; 7602 cmdline_fixed_string_t port; 7603 cmdline_fixed_string_t what; 7604 uint16_t portnum; 7605 }; 7606 7607 static void cmd_showport_parsed(void *parsed_result, 7608 __rte_unused struct cmdline *cl, 7609 __rte_unused void *data) 7610 { 7611 struct cmd_showport_result *res = parsed_result; 7612 if (!strcmp(res->show, "clear")) { 7613 if (!strcmp(res->what, "stats")) 7614 nic_stats_clear(res->portnum); 7615 else if (!strcmp(res->what, "xstats")) 7616 nic_xstats_clear(res->portnum); 7617 } else if (!strcmp(res->what, "info")) 7618 port_infos_display(res->portnum); 7619 else if (!strcmp(res->what, "summary")) { 7620 port_summary_header_display(); 7621 port_summary_display(res->portnum); 7622 } 7623 else if (!strcmp(res->what, "stats")) 7624 nic_stats_display(res->portnum); 7625 else if (!strcmp(res->what, "xstats")) 7626 nic_xstats_display(res->portnum); 7627 else if (!strcmp(res->what, "fdir")) 7628 fdir_get_infos(res->portnum); 7629 else if (!strcmp(res->what, "stat_qmap")) 7630 nic_stats_mapping_display(res->portnum); 7631 else if (!strcmp(res->what, "dcb_tc")) 7632 port_dcb_info_display(res->portnum); 7633 else if (!strcmp(res->what, "cap")) 7634 port_offload_cap_display(res->portnum); 7635 } 7636 7637 cmdline_parse_token_string_t cmd_showport_show = 7638 TOKEN_STRING_INITIALIZER(struct cmd_showport_result, show, 7639 "show#clear"); 7640 cmdline_parse_token_string_t cmd_showport_port = 7641 TOKEN_STRING_INITIALIZER(struct cmd_showport_result, port, "port"); 7642 cmdline_parse_token_string_t cmd_showport_what = 7643 TOKEN_STRING_INITIALIZER(struct cmd_showport_result, what, 7644 "info#summary#stats#xstats#fdir#stat_qmap#dcb_tc#cap"); 7645 cmdline_parse_token_num_t cmd_showport_portnum = 7646 TOKEN_NUM_INITIALIZER(struct cmd_showport_result, portnum, UINT16); 7647 7648 cmdline_parse_inst_t cmd_showport = { 7649 .f = cmd_showport_parsed, 7650 .data = NULL, 7651 .help_str = "show|clear port " 7652 "info|summary|stats|xstats|fdir|stat_qmap|dcb_tc|cap " 7653 "<port_id>", 7654 .tokens = { 7655 (void *)&cmd_showport_show, 7656 (void *)&cmd_showport_port, 7657 (void *)&cmd_showport_what, 7658 (void *)&cmd_showport_portnum, 7659 NULL, 7660 }, 7661 }; 7662 7663 /* *** SHOW DEVICE INFO *** */ 7664 struct cmd_showdevice_result { 7665 cmdline_fixed_string_t show; 7666 cmdline_fixed_string_t device; 7667 cmdline_fixed_string_t what; 7668 cmdline_fixed_string_t identifier; 7669 }; 7670 7671 static void cmd_showdevice_parsed(void *parsed_result, 7672 __rte_unused struct cmdline *cl, 7673 __rte_unused void *data) 7674 { 7675 struct cmd_showdevice_result *res = parsed_result; 7676 if (!strcmp(res->what, "info")) { 7677 if (!strcmp(res->identifier, "all")) 7678 device_infos_display(NULL); 7679 else 7680 device_infos_display(res->identifier); 7681 } 7682 } 7683 7684 cmdline_parse_token_string_t cmd_showdevice_show = 7685 TOKEN_STRING_INITIALIZER(struct cmd_showdevice_result, show, 7686 "show"); 7687 cmdline_parse_token_string_t cmd_showdevice_device = 7688 TOKEN_STRING_INITIALIZER(struct cmd_showdevice_result, device, "device"); 7689 cmdline_parse_token_string_t cmd_showdevice_what = 7690 TOKEN_STRING_INITIALIZER(struct cmd_showdevice_result, what, 7691 "info"); 7692 cmdline_parse_token_string_t cmd_showdevice_identifier = 7693 TOKEN_STRING_INITIALIZER(struct cmd_showdevice_result, 7694 identifier, NULL); 7695 7696 cmdline_parse_inst_t cmd_showdevice = { 7697 .f = cmd_showdevice_parsed, 7698 .data = NULL, 7699 .help_str = "show device info <identifier>|all", 7700 .tokens = { 7701 (void *)&cmd_showdevice_show, 7702 (void *)&cmd_showdevice_device, 7703 (void *)&cmd_showdevice_what, 7704 (void *)&cmd_showdevice_identifier, 7705 NULL, 7706 }, 7707 }; 7708 /* *** SHOW QUEUE INFO *** */ 7709 struct cmd_showqueue_result { 7710 cmdline_fixed_string_t show; 7711 cmdline_fixed_string_t type; 7712 cmdline_fixed_string_t what; 7713 uint16_t portnum; 7714 uint16_t queuenum; 7715 }; 7716 7717 static void 7718 cmd_showqueue_parsed(void *parsed_result, 7719 __rte_unused struct cmdline *cl, 7720 __rte_unused void *data) 7721 { 7722 struct cmd_showqueue_result *res = parsed_result; 7723 7724 if (!strcmp(res->type, "rxq")) 7725 rx_queue_infos_display(res->portnum, res->queuenum); 7726 else if (!strcmp(res->type, "txq")) 7727 tx_queue_infos_display(res->portnum, res->queuenum); 7728 } 7729 7730 cmdline_parse_token_string_t cmd_showqueue_show = 7731 TOKEN_STRING_INITIALIZER(struct cmd_showqueue_result, show, "show"); 7732 cmdline_parse_token_string_t cmd_showqueue_type = 7733 TOKEN_STRING_INITIALIZER(struct cmd_showqueue_result, type, "rxq#txq"); 7734 cmdline_parse_token_string_t cmd_showqueue_what = 7735 TOKEN_STRING_INITIALIZER(struct cmd_showqueue_result, what, "info"); 7736 cmdline_parse_token_num_t cmd_showqueue_portnum = 7737 TOKEN_NUM_INITIALIZER(struct cmd_showqueue_result, portnum, UINT16); 7738 cmdline_parse_token_num_t cmd_showqueue_queuenum = 7739 TOKEN_NUM_INITIALIZER(struct cmd_showqueue_result, queuenum, UINT16); 7740 7741 cmdline_parse_inst_t cmd_showqueue = { 7742 .f = cmd_showqueue_parsed, 7743 .data = NULL, 7744 .help_str = "show rxq|txq info <port_id> <queue_id>", 7745 .tokens = { 7746 (void *)&cmd_showqueue_show, 7747 (void *)&cmd_showqueue_type, 7748 (void *)&cmd_showqueue_what, 7749 (void *)&cmd_showqueue_portnum, 7750 (void *)&cmd_showqueue_queuenum, 7751 NULL, 7752 }, 7753 }; 7754 7755 /* show/clear fwd engine statistics */ 7756 struct fwd_result { 7757 cmdline_fixed_string_t action; 7758 cmdline_fixed_string_t fwd; 7759 cmdline_fixed_string_t stats; 7760 cmdline_fixed_string_t all; 7761 }; 7762 7763 cmdline_parse_token_string_t cmd_fwd_action = 7764 TOKEN_STRING_INITIALIZER(struct fwd_result, action, "show#clear"); 7765 cmdline_parse_token_string_t cmd_fwd_fwd = 7766 TOKEN_STRING_INITIALIZER(struct fwd_result, fwd, "fwd"); 7767 cmdline_parse_token_string_t cmd_fwd_stats = 7768 TOKEN_STRING_INITIALIZER(struct fwd_result, stats, "stats"); 7769 cmdline_parse_token_string_t cmd_fwd_all = 7770 TOKEN_STRING_INITIALIZER(struct fwd_result, all, "all"); 7771 7772 static void 7773 cmd_showfwdall_parsed(void *parsed_result, 7774 __rte_unused struct cmdline *cl, 7775 __rte_unused void *data) 7776 { 7777 struct fwd_result *res = parsed_result; 7778 7779 if (!strcmp(res->action, "show")) 7780 fwd_stats_display(); 7781 else 7782 fwd_stats_reset(); 7783 } 7784 7785 static cmdline_parse_inst_t cmd_showfwdall = { 7786 .f = cmd_showfwdall_parsed, 7787 .data = NULL, 7788 .help_str = "show|clear fwd stats all", 7789 .tokens = { 7790 (void *)&cmd_fwd_action, 7791 (void *)&cmd_fwd_fwd, 7792 (void *)&cmd_fwd_stats, 7793 (void *)&cmd_fwd_all, 7794 NULL, 7795 }, 7796 }; 7797 7798 /* *** READ PORT REGISTER *** */ 7799 struct cmd_read_reg_result { 7800 cmdline_fixed_string_t read; 7801 cmdline_fixed_string_t reg; 7802 portid_t port_id; 7803 uint32_t reg_off; 7804 }; 7805 7806 static void 7807 cmd_read_reg_parsed(void *parsed_result, 7808 __rte_unused struct cmdline *cl, 7809 __rte_unused void *data) 7810 { 7811 struct cmd_read_reg_result *res = parsed_result; 7812 port_reg_display(res->port_id, res->reg_off); 7813 } 7814 7815 cmdline_parse_token_string_t cmd_read_reg_read = 7816 TOKEN_STRING_INITIALIZER(struct cmd_read_reg_result, read, "read"); 7817 cmdline_parse_token_string_t cmd_read_reg_reg = 7818 TOKEN_STRING_INITIALIZER(struct cmd_read_reg_result, reg, "reg"); 7819 cmdline_parse_token_num_t cmd_read_reg_port_id = 7820 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_result, port_id, UINT16); 7821 cmdline_parse_token_num_t cmd_read_reg_reg_off = 7822 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_result, reg_off, UINT32); 7823 7824 cmdline_parse_inst_t cmd_read_reg = { 7825 .f = cmd_read_reg_parsed, 7826 .data = NULL, 7827 .help_str = "read reg <port_id> <reg_off>", 7828 .tokens = { 7829 (void *)&cmd_read_reg_read, 7830 (void *)&cmd_read_reg_reg, 7831 (void *)&cmd_read_reg_port_id, 7832 (void *)&cmd_read_reg_reg_off, 7833 NULL, 7834 }, 7835 }; 7836 7837 /* *** READ PORT REGISTER BIT FIELD *** */ 7838 struct cmd_read_reg_bit_field_result { 7839 cmdline_fixed_string_t read; 7840 cmdline_fixed_string_t regfield; 7841 portid_t port_id; 7842 uint32_t reg_off; 7843 uint8_t bit1_pos; 7844 uint8_t bit2_pos; 7845 }; 7846 7847 static void 7848 cmd_read_reg_bit_field_parsed(void *parsed_result, 7849 __rte_unused struct cmdline *cl, 7850 __rte_unused void *data) 7851 { 7852 struct cmd_read_reg_bit_field_result *res = parsed_result; 7853 port_reg_bit_field_display(res->port_id, res->reg_off, 7854 res->bit1_pos, res->bit2_pos); 7855 } 7856 7857 cmdline_parse_token_string_t cmd_read_reg_bit_field_read = 7858 TOKEN_STRING_INITIALIZER(struct cmd_read_reg_bit_field_result, read, 7859 "read"); 7860 cmdline_parse_token_string_t cmd_read_reg_bit_field_regfield = 7861 TOKEN_STRING_INITIALIZER(struct cmd_read_reg_bit_field_result, 7862 regfield, "regfield"); 7863 cmdline_parse_token_num_t cmd_read_reg_bit_field_port_id = 7864 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_field_result, port_id, 7865 UINT16); 7866 cmdline_parse_token_num_t cmd_read_reg_bit_field_reg_off = 7867 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_field_result, reg_off, 7868 UINT32); 7869 cmdline_parse_token_num_t cmd_read_reg_bit_field_bit1_pos = 7870 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_field_result, bit1_pos, 7871 UINT8); 7872 cmdline_parse_token_num_t cmd_read_reg_bit_field_bit2_pos = 7873 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_field_result, bit2_pos, 7874 UINT8); 7875 7876 cmdline_parse_inst_t cmd_read_reg_bit_field = { 7877 .f = cmd_read_reg_bit_field_parsed, 7878 .data = NULL, 7879 .help_str = "read regfield <port_id> <reg_off> <bit_x> <bit_y>: " 7880 "Read register bit field between bit_x and bit_y included", 7881 .tokens = { 7882 (void *)&cmd_read_reg_bit_field_read, 7883 (void *)&cmd_read_reg_bit_field_regfield, 7884 (void *)&cmd_read_reg_bit_field_port_id, 7885 (void *)&cmd_read_reg_bit_field_reg_off, 7886 (void *)&cmd_read_reg_bit_field_bit1_pos, 7887 (void *)&cmd_read_reg_bit_field_bit2_pos, 7888 NULL, 7889 }, 7890 }; 7891 7892 /* *** READ PORT REGISTER BIT *** */ 7893 struct cmd_read_reg_bit_result { 7894 cmdline_fixed_string_t read; 7895 cmdline_fixed_string_t regbit; 7896 portid_t port_id; 7897 uint32_t reg_off; 7898 uint8_t bit_pos; 7899 }; 7900 7901 static void 7902 cmd_read_reg_bit_parsed(void *parsed_result, 7903 __rte_unused struct cmdline *cl, 7904 __rte_unused void *data) 7905 { 7906 struct cmd_read_reg_bit_result *res = parsed_result; 7907 port_reg_bit_display(res->port_id, res->reg_off, res->bit_pos); 7908 } 7909 7910 cmdline_parse_token_string_t cmd_read_reg_bit_read = 7911 TOKEN_STRING_INITIALIZER(struct cmd_read_reg_bit_result, read, "read"); 7912 cmdline_parse_token_string_t cmd_read_reg_bit_regbit = 7913 TOKEN_STRING_INITIALIZER(struct cmd_read_reg_bit_result, 7914 regbit, "regbit"); 7915 cmdline_parse_token_num_t cmd_read_reg_bit_port_id = 7916 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_result, port_id, UINT16); 7917 cmdline_parse_token_num_t cmd_read_reg_bit_reg_off = 7918 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_result, reg_off, UINT32); 7919 cmdline_parse_token_num_t cmd_read_reg_bit_bit_pos = 7920 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_result, bit_pos, UINT8); 7921 7922 cmdline_parse_inst_t cmd_read_reg_bit = { 7923 .f = cmd_read_reg_bit_parsed, 7924 .data = NULL, 7925 .help_str = "read regbit <port_id> <reg_off> <bit_x>: 0 <= bit_x <= 31", 7926 .tokens = { 7927 (void *)&cmd_read_reg_bit_read, 7928 (void *)&cmd_read_reg_bit_regbit, 7929 (void *)&cmd_read_reg_bit_port_id, 7930 (void *)&cmd_read_reg_bit_reg_off, 7931 (void *)&cmd_read_reg_bit_bit_pos, 7932 NULL, 7933 }, 7934 }; 7935 7936 /* *** WRITE PORT REGISTER *** */ 7937 struct cmd_write_reg_result { 7938 cmdline_fixed_string_t write; 7939 cmdline_fixed_string_t reg; 7940 portid_t port_id; 7941 uint32_t reg_off; 7942 uint32_t value; 7943 }; 7944 7945 static void 7946 cmd_write_reg_parsed(void *parsed_result, 7947 __rte_unused struct cmdline *cl, 7948 __rte_unused void *data) 7949 { 7950 struct cmd_write_reg_result *res = parsed_result; 7951 port_reg_set(res->port_id, res->reg_off, res->value); 7952 } 7953 7954 cmdline_parse_token_string_t cmd_write_reg_write = 7955 TOKEN_STRING_INITIALIZER(struct cmd_write_reg_result, write, "write"); 7956 cmdline_parse_token_string_t cmd_write_reg_reg = 7957 TOKEN_STRING_INITIALIZER(struct cmd_write_reg_result, reg, "reg"); 7958 cmdline_parse_token_num_t cmd_write_reg_port_id = 7959 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_result, port_id, UINT16); 7960 cmdline_parse_token_num_t cmd_write_reg_reg_off = 7961 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_result, reg_off, UINT32); 7962 cmdline_parse_token_num_t cmd_write_reg_value = 7963 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_result, value, UINT32); 7964 7965 cmdline_parse_inst_t cmd_write_reg = { 7966 .f = cmd_write_reg_parsed, 7967 .data = NULL, 7968 .help_str = "write reg <port_id> <reg_off> <reg_value>", 7969 .tokens = { 7970 (void *)&cmd_write_reg_write, 7971 (void *)&cmd_write_reg_reg, 7972 (void *)&cmd_write_reg_port_id, 7973 (void *)&cmd_write_reg_reg_off, 7974 (void *)&cmd_write_reg_value, 7975 NULL, 7976 }, 7977 }; 7978 7979 /* *** WRITE PORT REGISTER BIT FIELD *** */ 7980 struct cmd_write_reg_bit_field_result { 7981 cmdline_fixed_string_t write; 7982 cmdline_fixed_string_t regfield; 7983 portid_t port_id; 7984 uint32_t reg_off; 7985 uint8_t bit1_pos; 7986 uint8_t bit2_pos; 7987 uint32_t value; 7988 }; 7989 7990 static void 7991 cmd_write_reg_bit_field_parsed(void *parsed_result, 7992 __rte_unused struct cmdline *cl, 7993 __rte_unused void *data) 7994 { 7995 struct cmd_write_reg_bit_field_result *res = parsed_result; 7996 port_reg_bit_field_set(res->port_id, res->reg_off, 7997 res->bit1_pos, res->bit2_pos, res->value); 7998 } 7999 8000 cmdline_parse_token_string_t cmd_write_reg_bit_field_write = 8001 TOKEN_STRING_INITIALIZER(struct cmd_write_reg_bit_field_result, write, 8002 "write"); 8003 cmdline_parse_token_string_t cmd_write_reg_bit_field_regfield = 8004 TOKEN_STRING_INITIALIZER(struct cmd_write_reg_bit_field_result, 8005 regfield, "regfield"); 8006 cmdline_parse_token_num_t cmd_write_reg_bit_field_port_id = 8007 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_field_result, port_id, 8008 UINT16); 8009 cmdline_parse_token_num_t cmd_write_reg_bit_field_reg_off = 8010 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_field_result, reg_off, 8011 UINT32); 8012 cmdline_parse_token_num_t cmd_write_reg_bit_field_bit1_pos = 8013 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_field_result, bit1_pos, 8014 UINT8); 8015 cmdline_parse_token_num_t cmd_write_reg_bit_field_bit2_pos = 8016 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_field_result, bit2_pos, 8017 UINT8); 8018 cmdline_parse_token_num_t cmd_write_reg_bit_field_value = 8019 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_field_result, value, 8020 UINT32); 8021 8022 cmdline_parse_inst_t cmd_write_reg_bit_field = { 8023 .f = cmd_write_reg_bit_field_parsed, 8024 .data = NULL, 8025 .help_str = "write regfield <port_id> <reg_off> <bit_x> <bit_y> " 8026 "<reg_value>: " 8027 "Set register bit field between bit_x and bit_y included", 8028 .tokens = { 8029 (void *)&cmd_write_reg_bit_field_write, 8030 (void *)&cmd_write_reg_bit_field_regfield, 8031 (void *)&cmd_write_reg_bit_field_port_id, 8032 (void *)&cmd_write_reg_bit_field_reg_off, 8033 (void *)&cmd_write_reg_bit_field_bit1_pos, 8034 (void *)&cmd_write_reg_bit_field_bit2_pos, 8035 (void *)&cmd_write_reg_bit_field_value, 8036 NULL, 8037 }, 8038 }; 8039 8040 /* *** WRITE PORT REGISTER BIT *** */ 8041 struct cmd_write_reg_bit_result { 8042 cmdline_fixed_string_t write; 8043 cmdline_fixed_string_t regbit; 8044 portid_t port_id; 8045 uint32_t reg_off; 8046 uint8_t bit_pos; 8047 uint8_t value; 8048 }; 8049 8050 static void 8051 cmd_write_reg_bit_parsed(void *parsed_result, 8052 __rte_unused struct cmdline *cl, 8053 __rte_unused void *data) 8054 { 8055 struct cmd_write_reg_bit_result *res = parsed_result; 8056 port_reg_bit_set(res->port_id, res->reg_off, res->bit_pos, res->value); 8057 } 8058 8059 cmdline_parse_token_string_t cmd_write_reg_bit_write = 8060 TOKEN_STRING_INITIALIZER(struct cmd_write_reg_bit_result, write, 8061 "write"); 8062 cmdline_parse_token_string_t cmd_write_reg_bit_regbit = 8063 TOKEN_STRING_INITIALIZER(struct cmd_write_reg_bit_result, 8064 regbit, "regbit"); 8065 cmdline_parse_token_num_t cmd_write_reg_bit_port_id = 8066 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_result, port_id, UINT16); 8067 cmdline_parse_token_num_t cmd_write_reg_bit_reg_off = 8068 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_result, reg_off, UINT32); 8069 cmdline_parse_token_num_t cmd_write_reg_bit_bit_pos = 8070 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_result, bit_pos, UINT8); 8071 cmdline_parse_token_num_t cmd_write_reg_bit_value = 8072 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_result, value, UINT8); 8073 8074 cmdline_parse_inst_t cmd_write_reg_bit = { 8075 .f = cmd_write_reg_bit_parsed, 8076 .data = NULL, 8077 .help_str = "write regbit <port_id> <reg_off> <bit_x> 0|1: " 8078 "0 <= bit_x <= 31", 8079 .tokens = { 8080 (void *)&cmd_write_reg_bit_write, 8081 (void *)&cmd_write_reg_bit_regbit, 8082 (void *)&cmd_write_reg_bit_port_id, 8083 (void *)&cmd_write_reg_bit_reg_off, 8084 (void *)&cmd_write_reg_bit_bit_pos, 8085 (void *)&cmd_write_reg_bit_value, 8086 NULL, 8087 }, 8088 }; 8089 8090 /* *** READ A RING DESCRIPTOR OF A PORT RX/TX QUEUE *** */ 8091 struct cmd_read_rxd_txd_result { 8092 cmdline_fixed_string_t read; 8093 cmdline_fixed_string_t rxd_txd; 8094 portid_t port_id; 8095 uint16_t queue_id; 8096 uint16_t desc_id; 8097 }; 8098 8099 static void 8100 cmd_read_rxd_txd_parsed(void *parsed_result, 8101 __rte_unused struct cmdline *cl, 8102 __rte_unused void *data) 8103 { 8104 struct cmd_read_rxd_txd_result *res = parsed_result; 8105 8106 if (!strcmp(res->rxd_txd, "rxd")) 8107 rx_ring_desc_display(res->port_id, res->queue_id, res->desc_id); 8108 else if (!strcmp(res->rxd_txd, "txd")) 8109 tx_ring_desc_display(res->port_id, res->queue_id, res->desc_id); 8110 } 8111 8112 cmdline_parse_token_string_t cmd_read_rxd_txd_read = 8113 TOKEN_STRING_INITIALIZER(struct cmd_read_rxd_txd_result, read, "read"); 8114 cmdline_parse_token_string_t cmd_read_rxd_txd_rxd_txd = 8115 TOKEN_STRING_INITIALIZER(struct cmd_read_rxd_txd_result, rxd_txd, 8116 "rxd#txd"); 8117 cmdline_parse_token_num_t cmd_read_rxd_txd_port_id = 8118 TOKEN_NUM_INITIALIZER(struct cmd_read_rxd_txd_result, port_id, UINT16); 8119 cmdline_parse_token_num_t cmd_read_rxd_txd_queue_id = 8120 TOKEN_NUM_INITIALIZER(struct cmd_read_rxd_txd_result, queue_id, UINT16); 8121 cmdline_parse_token_num_t cmd_read_rxd_txd_desc_id = 8122 TOKEN_NUM_INITIALIZER(struct cmd_read_rxd_txd_result, desc_id, UINT16); 8123 8124 cmdline_parse_inst_t cmd_read_rxd_txd = { 8125 .f = cmd_read_rxd_txd_parsed, 8126 .data = NULL, 8127 .help_str = "read rxd|txd <port_id> <queue_id> <desc_id>", 8128 .tokens = { 8129 (void *)&cmd_read_rxd_txd_read, 8130 (void *)&cmd_read_rxd_txd_rxd_txd, 8131 (void *)&cmd_read_rxd_txd_port_id, 8132 (void *)&cmd_read_rxd_txd_queue_id, 8133 (void *)&cmd_read_rxd_txd_desc_id, 8134 NULL, 8135 }, 8136 }; 8137 8138 /* *** QUIT *** */ 8139 struct cmd_quit_result { 8140 cmdline_fixed_string_t quit; 8141 }; 8142 8143 static void cmd_quit_parsed(__rte_unused void *parsed_result, 8144 struct cmdline *cl, 8145 __rte_unused void *data) 8146 { 8147 cmdline_quit(cl); 8148 } 8149 8150 cmdline_parse_token_string_t cmd_quit_quit = 8151 TOKEN_STRING_INITIALIZER(struct cmd_quit_result, quit, "quit"); 8152 8153 cmdline_parse_inst_t cmd_quit = { 8154 .f = cmd_quit_parsed, 8155 .data = NULL, 8156 .help_str = "quit: Exit application", 8157 .tokens = { 8158 (void *)&cmd_quit_quit, 8159 NULL, 8160 }, 8161 }; 8162 8163 /* *** ADD/REMOVE MAC ADDRESS FROM A PORT *** */ 8164 struct cmd_mac_addr_result { 8165 cmdline_fixed_string_t mac_addr_cmd; 8166 cmdline_fixed_string_t what; 8167 uint16_t port_num; 8168 struct rte_ether_addr address; 8169 }; 8170 8171 static void cmd_mac_addr_parsed(void *parsed_result, 8172 __rte_unused struct cmdline *cl, 8173 __rte_unused void *data) 8174 { 8175 struct cmd_mac_addr_result *res = parsed_result; 8176 int ret; 8177 8178 if (strcmp(res->what, "add") == 0) 8179 ret = rte_eth_dev_mac_addr_add(res->port_num, &res->address, 0); 8180 else if (strcmp(res->what, "set") == 0) 8181 ret = rte_eth_dev_default_mac_addr_set(res->port_num, 8182 &res->address); 8183 else 8184 ret = rte_eth_dev_mac_addr_remove(res->port_num, &res->address); 8185 8186 /* check the return value and print it if is < 0 */ 8187 if(ret < 0) 8188 printf("mac_addr_cmd error: (%s)\n", strerror(-ret)); 8189 8190 } 8191 8192 cmdline_parse_token_string_t cmd_mac_addr_cmd = 8193 TOKEN_STRING_INITIALIZER(struct cmd_mac_addr_result, mac_addr_cmd, 8194 "mac_addr"); 8195 cmdline_parse_token_string_t cmd_mac_addr_what = 8196 TOKEN_STRING_INITIALIZER(struct cmd_mac_addr_result, what, 8197 "add#remove#set"); 8198 cmdline_parse_token_num_t cmd_mac_addr_portnum = 8199 TOKEN_NUM_INITIALIZER(struct cmd_mac_addr_result, port_num, 8200 UINT16); 8201 cmdline_parse_token_etheraddr_t cmd_mac_addr_addr = 8202 TOKEN_ETHERADDR_INITIALIZER(struct cmd_mac_addr_result, address); 8203 8204 cmdline_parse_inst_t cmd_mac_addr = { 8205 .f = cmd_mac_addr_parsed, 8206 .data = (void *)0, 8207 .help_str = "mac_addr add|remove|set <port_id> <mac_addr>: " 8208 "Add/Remove/Set MAC address on port_id", 8209 .tokens = { 8210 (void *)&cmd_mac_addr_cmd, 8211 (void *)&cmd_mac_addr_what, 8212 (void *)&cmd_mac_addr_portnum, 8213 (void *)&cmd_mac_addr_addr, 8214 NULL, 8215 }, 8216 }; 8217 8218 /* *** SET THE PEER ADDRESS FOR CERTAIN PORT *** */ 8219 struct cmd_eth_peer_result { 8220 cmdline_fixed_string_t set; 8221 cmdline_fixed_string_t eth_peer; 8222 portid_t port_id; 8223 cmdline_fixed_string_t peer_addr; 8224 }; 8225 8226 static void cmd_set_eth_peer_parsed(void *parsed_result, 8227 __rte_unused struct cmdline *cl, 8228 __rte_unused void *data) 8229 { 8230 struct cmd_eth_peer_result *res = parsed_result; 8231 8232 if (test_done == 0) { 8233 printf("Please stop forwarding first\n"); 8234 return; 8235 } 8236 if (!strcmp(res->eth_peer, "eth-peer")) { 8237 set_fwd_eth_peer(res->port_id, res->peer_addr); 8238 fwd_config_setup(); 8239 } 8240 } 8241 cmdline_parse_token_string_t cmd_eth_peer_set = 8242 TOKEN_STRING_INITIALIZER(struct cmd_eth_peer_result, set, "set"); 8243 cmdline_parse_token_string_t cmd_eth_peer = 8244 TOKEN_STRING_INITIALIZER(struct cmd_eth_peer_result, eth_peer, "eth-peer"); 8245 cmdline_parse_token_num_t cmd_eth_peer_port_id = 8246 TOKEN_NUM_INITIALIZER(struct cmd_eth_peer_result, port_id, UINT16); 8247 cmdline_parse_token_string_t cmd_eth_peer_addr = 8248 TOKEN_STRING_INITIALIZER(struct cmd_eth_peer_result, peer_addr, NULL); 8249 8250 cmdline_parse_inst_t cmd_set_fwd_eth_peer = { 8251 .f = cmd_set_eth_peer_parsed, 8252 .data = NULL, 8253 .help_str = "set eth-peer <port_id> <peer_mac>", 8254 .tokens = { 8255 (void *)&cmd_eth_peer_set, 8256 (void *)&cmd_eth_peer, 8257 (void *)&cmd_eth_peer_port_id, 8258 (void *)&cmd_eth_peer_addr, 8259 NULL, 8260 }, 8261 }; 8262 8263 /* *** CONFIGURE QUEUE STATS COUNTER MAPPINGS *** */ 8264 struct cmd_set_qmap_result { 8265 cmdline_fixed_string_t set; 8266 cmdline_fixed_string_t qmap; 8267 cmdline_fixed_string_t what; 8268 portid_t port_id; 8269 uint16_t queue_id; 8270 uint8_t map_value; 8271 }; 8272 8273 static void 8274 cmd_set_qmap_parsed(void *parsed_result, 8275 __rte_unused struct cmdline *cl, 8276 __rte_unused void *data) 8277 { 8278 struct cmd_set_qmap_result *res = parsed_result; 8279 int is_rx = (strcmp(res->what, "tx") == 0) ? 0 : 1; 8280 8281 set_qmap(res->port_id, (uint8_t)is_rx, res->queue_id, res->map_value); 8282 } 8283 8284 cmdline_parse_token_string_t cmd_setqmap_set = 8285 TOKEN_STRING_INITIALIZER(struct cmd_set_qmap_result, 8286 set, "set"); 8287 cmdline_parse_token_string_t cmd_setqmap_qmap = 8288 TOKEN_STRING_INITIALIZER(struct cmd_set_qmap_result, 8289 qmap, "stat_qmap"); 8290 cmdline_parse_token_string_t cmd_setqmap_what = 8291 TOKEN_STRING_INITIALIZER(struct cmd_set_qmap_result, 8292 what, "tx#rx"); 8293 cmdline_parse_token_num_t cmd_setqmap_portid = 8294 TOKEN_NUM_INITIALIZER(struct cmd_set_qmap_result, 8295 port_id, UINT16); 8296 cmdline_parse_token_num_t cmd_setqmap_queueid = 8297 TOKEN_NUM_INITIALIZER(struct cmd_set_qmap_result, 8298 queue_id, UINT16); 8299 cmdline_parse_token_num_t cmd_setqmap_mapvalue = 8300 TOKEN_NUM_INITIALIZER(struct cmd_set_qmap_result, 8301 map_value, UINT8); 8302 8303 cmdline_parse_inst_t cmd_set_qmap = { 8304 .f = cmd_set_qmap_parsed, 8305 .data = NULL, 8306 .help_str = "set stat_qmap rx|tx <port_id> <queue_id> <map_value>: " 8307 "Set statistics mapping value on tx|rx queue_id of port_id", 8308 .tokens = { 8309 (void *)&cmd_setqmap_set, 8310 (void *)&cmd_setqmap_qmap, 8311 (void *)&cmd_setqmap_what, 8312 (void *)&cmd_setqmap_portid, 8313 (void *)&cmd_setqmap_queueid, 8314 (void *)&cmd_setqmap_mapvalue, 8315 NULL, 8316 }, 8317 }; 8318 8319 /* *** SET OPTION TO HIDE ZERO VALUES FOR XSTATS DISPLAY *** */ 8320 struct cmd_set_xstats_hide_zero_result { 8321 cmdline_fixed_string_t keyword; 8322 cmdline_fixed_string_t name; 8323 cmdline_fixed_string_t on_off; 8324 }; 8325 8326 static void 8327 cmd_set_xstats_hide_zero_parsed(void *parsed_result, 8328 __rte_unused struct cmdline *cl, 8329 __rte_unused void *data) 8330 { 8331 struct cmd_set_xstats_hide_zero_result *res; 8332 uint16_t on_off = 0; 8333 8334 res = parsed_result; 8335 on_off = !strcmp(res->on_off, "on") ? 1 : 0; 8336 set_xstats_hide_zero(on_off); 8337 } 8338 8339 cmdline_parse_token_string_t cmd_set_xstats_hide_zero_keyword = 8340 TOKEN_STRING_INITIALIZER(struct cmd_set_xstats_hide_zero_result, 8341 keyword, "set"); 8342 cmdline_parse_token_string_t cmd_set_xstats_hide_zero_name = 8343 TOKEN_STRING_INITIALIZER(struct cmd_set_xstats_hide_zero_result, 8344 name, "xstats-hide-zero"); 8345 cmdline_parse_token_string_t cmd_set_xstats_hide_zero_on_off = 8346 TOKEN_STRING_INITIALIZER(struct cmd_set_xstats_hide_zero_result, 8347 on_off, "on#off"); 8348 8349 cmdline_parse_inst_t cmd_set_xstats_hide_zero = { 8350 .f = cmd_set_xstats_hide_zero_parsed, 8351 .data = NULL, 8352 .help_str = "set xstats-hide-zero on|off", 8353 .tokens = { 8354 (void *)&cmd_set_xstats_hide_zero_keyword, 8355 (void *)&cmd_set_xstats_hide_zero_name, 8356 (void *)&cmd_set_xstats_hide_zero_on_off, 8357 NULL, 8358 }, 8359 }; 8360 8361 /* *** SET OPTION TO ENABLE MEASUREMENT OF CPU CYCLES *** */ 8362 struct cmd_set_record_core_cycles_result { 8363 cmdline_fixed_string_t keyword; 8364 cmdline_fixed_string_t name; 8365 cmdline_fixed_string_t on_off; 8366 }; 8367 8368 static void 8369 cmd_set_record_core_cycles_parsed(void *parsed_result, 8370 __rte_unused struct cmdline *cl, 8371 __rte_unused void *data) 8372 { 8373 struct cmd_set_record_core_cycles_result *res; 8374 uint16_t on_off = 0; 8375 8376 res = parsed_result; 8377 on_off = !strcmp(res->on_off, "on") ? 1 : 0; 8378 set_record_core_cycles(on_off); 8379 } 8380 8381 cmdline_parse_token_string_t cmd_set_record_core_cycles_keyword = 8382 TOKEN_STRING_INITIALIZER(struct cmd_set_record_core_cycles_result, 8383 keyword, "set"); 8384 cmdline_parse_token_string_t cmd_set_record_core_cycles_name = 8385 TOKEN_STRING_INITIALIZER(struct cmd_set_record_core_cycles_result, 8386 name, "record-core-cycles"); 8387 cmdline_parse_token_string_t cmd_set_record_core_cycles_on_off = 8388 TOKEN_STRING_INITIALIZER(struct cmd_set_record_core_cycles_result, 8389 on_off, "on#off"); 8390 8391 cmdline_parse_inst_t cmd_set_record_core_cycles = { 8392 .f = cmd_set_record_core_cycles_parsed, 8393 .data = NULL, 8394 .help_str = "set record-core-cycles on|off", 8395 .tokens = { 8396 (void *)&cmd_set_record_core_cycles_keyword, 8397 (void *)&cmd_set_record_core_cycles_name, 8398 (void *)&cmd_set_record_core_cycles_on_off, 8399 NULL, 8400 }, 8401 }; 8402 8403 /* *** SET OPTION TO ENABLE DISPLAY OF RX AND TX BURSTS *** */ 8404 struct cmd_set_record_burst_stats_result { 8405 cmdline_fixed_string_t keyword; 8406 cmdline_fixed_string_t name; 8407 cmdline_fixed_string_t on_off; 8408 }; 8409 8410 static void 8411 cmd_set_record_burst_stats_parsed(void *parsed_result, 8412 __rte_unused struct cmdline *cl, 8413 __rte_unused void *data) 8414 { 8415 struct cmd_set_record_burst_stats_result *res; 8416 uint16_t on_off = 0; 8417 8418 res = parsed_result; 8419 on_off = !strcmp(res->on_off, "on") ? 1 : 0; 8420 set_record_burst_stats(on_off); 8421 } 8422 8423 cmdline_parse_token_string_t cmd_set_record_burst_stats_keyword = 8424 TOKEN_STRING_INITIALIZER(struct cmd_set_record_burst_stats_result, 8425 keyword, "set"); 8426 cmdline_parse_token_string_t cmd_set_record_burst_stats_name = 8427 TOKEN_STRING_INITIALIZER(struct cmd_set_record_burst_stats_result, 8428 name, "record-burst-stats"); 8429 cmdline_parse_token_string_t cmd_set_record_burst_stats_on_off = 8430 TOKEN_STRING_INITIALIZER(struct cmd_set_record_burst_stats_result, 8431 on_off, "on#off"); 8432 8433 cmdline_parse_inst_t cmd_set_record_burst_stats = { 8434 .f = cmd_set_record_burst_stats_parsed, 8435 .data = NULL, 8436 .help_str = "set record-burst-stats on|off", 8437 .tokens = { 8438 (void *)&cmd_set_record_burst_stats_keyword, 8439 (void *)&cmd_set_record_burst_stats_name, 8440 (void *)&cmd_set_record_burst_stats_on_off, 8441 NULL, 8442 }, 8443 }; 8444 8445 /* *** CONFIGURE UNICAST HASH TABLE *** */ 8446 struct cmd_set_uc_hash_table { 8447 cmdline_fixed_string_t set; 8448 cmdline_fixed_string_t port; 8449 portid_t port_id; 8450 cmdline_fixed_string_t what; 8451 struct rte_ether_addr address; 8452 cmdline_fixed_string_t mode; 8453 }; 8454 8455 static void 8456 cmd_set_uc_hash_parsed(void *parsed_result, 8457 __rte_unused struct cmdline *cl, 8458 __rte_unused void *data) 8459 { 8460 int ret=0; 8461 struct cmd_set_uc_hash_table *res = parsed_result; 8462 8463 int is_on = (strcmp(res->mode, "on") == 0) ? 1 : 0; 8464 8465 if (strcmp(res->what, "uta") == 0) 8466 ret = rte_eth_dev_uc_hash_table_set(res->port_id, 8467 &res->address,(uint8_t)is_on); 8468 if (ret < 0) 8469 printf("bad unicast hash table parameter, return code = %d \n", ret); 8470 8471 } 8472 8473 cmdline_parse_token_string_t cmd_set_uc_hash_set = 8474 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_hash_table, 8475 set, "set"); 8476 cmdline_parse_token_string_t cmd_set_uc_hash_port = 8477 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_hash_table, 8478 port, "port"); 8479 cmdline_parse_token_num_t cmd_set_uc_hash_portid = 8480 TOKEN_NUM_INITIALIZER(struct cmd_set_uc_hash_table, 8481 port_id, UINT16); 8482 cmdline_parse_token_string_t cmd_set_uc_hash_what = 8483 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_hash_table, 8484 what, "uta"); 8485 cmdline_parse_token_etheraddr_t cmd_set_uc_hash_mac = 8486 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_uc_hash_table, 8487 address); 8488 cmdline_parse_token_string_t cmd_set_uc_hash_mode = 8489 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_hash_table, 8490 mode, "on#off"); 8491 8492 cmdline_parse_inst_t cmd_set_uc_hash_filter = { 8493 .f = cmd_set_uc_hash_parsed, 8494 .data = NULL, 8495 .help_str = "set port <port_id> uta <mac_addr> on|off)", 8496 .tokens = { 8497 (void *)&cmd_set_uc_hash_set, 8498 (void *)&cmd_set_uc_hash_port, 8499 (void *)&cmd_set_uc_hash_portid, 8500 (void *)&cmd_set_uc_hash_what, 8501 (void *)&cmd_set_uc_hash_mac, 8502 (void *)&cmd_set_uc_hash_mode, 8503 NULL, 8504 }, 8505 }; 8506 8507 struct cmd_set_uc_all_hash_table { 8508 cmdline_fixed_string_t set; 8509 cmdline_fixed_string_t port; 8510 portid_t port_id; 8511 cmdline_fixed_string_t what; 8512 cmdline_fixed_string_t value; 8513 cmdline_fixed_string_t mode; 8514 }; 8515 8516 static void 8517 cmd_set_uc_all_hash_parsed(void *parsed_result, 8518 __rte_unused struct cmdline *cl, 8519 __rte_unused void *data) 8520 { 8521 int ret=0; 8522 struct cmd_set_uc_all_hash_table *res = parsed_result; 8523 8524 int is_on = (strcmp(res->mode, "on") == 0) ? 1 : 0; 8525 8526 if ((strcmp(res->what, "uta") == 0) && 8527 (strcmp(res->value, "all") == 0)) 8528 ret = rte_eth_dev_uc_all_hash_table_set(res->port_id,(uint8_t) is_on); 8529 if (ret < 0) 8530 printf("bad unicast hash table parameter," 8531 "return code = %d \n", ret); 8532 } 8533 8534 cmdline_parse_token_string_t cmd_set_uc_all_hash_set = 8535 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_all_hash_table, 8536 set, "set"); 8537 cmdline_parse_token_string_t cmd_set_uc_all_hash_port = 8538 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_all_hash_table, 8539 port, "port"); 8540 cmdline_parse_token_num_t cmd_set_uc_all_hash_portid = 8541 TOKEN_NUM_INITIALIZER(struct cmd_set_uc_all_hash_table, 8542 port_id, UINT16); 8543 cmdline_parse_token_string_t cmd_set_uc_all_hash_what = 8544 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_all_hash_table, 8545 what, "uta"); 8546 cmdline_parse_token_string_t cmd_set_uc_all_hash_value = 8547 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_all_hash_table, 8548 value,"all"); 8549 cmdline_parse_token_string_t cmd_set_uc_all_hash_mode = 8550 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_all_hash_table, 8551 mode, "on#off"); 8552 8553 cmdline_parse_inst_t cmd_set_uc_all_hash_filter = { 8554 .f = cmd_set_uc_all_hash_parsed, 8555 .data = NULL, 8556 .help_str = "set port <port_id> uta all on|off", 8557 .tokens = { 8558 (void *)&cmd_set_uc_all_hash_set, 8559 (void *)&cmd_set_uc_all_hash_port, 8560 (void *)&cmd_set_uc_all_hash_portid, 8561 (void *)&cmd_set_uc_all_hash_what, 8562 (void *)&cmd_set_uc_all_hash_value, 8563 (void *)&cmd_set_uc_all_hash_mode, 8564 NULL, 8565 }, 8566 }; 8567 8568 /* *** CONFIGURE MACVLAN FILTER FOR VF(s) *** */ 8569 struct cmd_set_vf_macvlan_filter { 8570 cmdline_fixed_string_t set; 8571 cmdline_fixed_string_t port; 8572 portid_t port_id; 8573 cmdline_fixed_string_t vf; 8574 uint8_t vf_id; 8575 struct rte_ether_addr address; 8576 cmdline_fixed_string_t filter_type; 8577 cmdline_fixed_string_t mode; 8578 }; 8579 8580 static void 8581 cmd_set_vf_macvlan_parsed(void *parsed_result, 8582 __rte_unused struct cmdline *cl, 8583 __rte_unused void *data) 8584 { 8585 int is_on, ret = 0; 8586 struct cmd_set_vf_macvlan_filter *res = parsed_result; 8587 struct rte_eth_mac_filter filter; 8588 8589 memset(&filter, 0, sizeof(struct rte_eth_mac_filter)); 8590 8591 rte_memcpy(&filter.mac_addr, &res->address, RTE_ETHER_ADDR_LEN); 8592 8593 /* set VF MAC filter */ 8594 filter.is_vf = 1; 8595 8596 /* set VF ID */ 8597 filter.dst_id = res->vf_id; 8598 8599 if (!strcmp(res->filter_type, "exact-mac")) 8600 filter.filter_type = RTE_MAC_PERFECT_MATCH; 8601 else if (!strcmp(res->filter_type, "exact-mac-vlan")) 8602 filter.filter_type = RTE_MACVLAN_PERFECT_MATCH; 8603 else if (!strcmp(res->filter_type, "hashmac")) 8604 filter.filter_type = RTE_MAC_HASH_MATCH; 8605 else if (!strcmp(res->filter_type, "hashmac-vlan")) 8606 filter.filter_type = RTE_MACVLAN_HASH_MATCH; 8607 8608 is_on = (strcmp(res->mode, "on") == 0) ? 1 : 0; 8609 8610 if (is_on) 8611 ret = rte_eth_dev_filter_ctrl(res->port_id, 8612 RTE_ETH_FILTER_MACVLAN, 8613 RTE_ETH_FILTER_ADD, 8614 &filter); 8615 else 8616 ret = rte_eth_dev_filter_ctrl(res->port_id, 8617 RTE_ETH_FILTER_MACVLAN, 8618 RTE_ETH_FILTER_DELETE, 8619 &filter); 8620 8621 if (ret < 0) 8622 printf("bad set MAC hash parameter, return code = %d\n", ret); 8623 8624 } 8625 8626 cmdline_parse_token_string_t cmd_set_vf_macvlan_set = 8627 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_macvlan_filter, 8628 set, "set"); 8629 cmdline_parse_token_string_t cmd_set_vf_macvlan_port = 8630 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_macvlan_filter, 8631 port, "port"); 8632 cmdline_parse_token_num_t cmd_set_vf_macvlan_portid = 8633 TOKEN_NUM_INITIALIZER(struct cmd_set_vf_macvlan_filter, 8634 port_id, UINT16); 8635 cmdline_parse_token_string_t cmd_set_vf_macvlan_vf = 8636 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_macvlan_filter, 8637 vf, "vf"); 8638 cmdline_parse_token_num_t cmd_set_vf_macvlan_vf_id = 8639 TOKEN_NUM_INITIALIZER(struct cmd_set_vf_macvlan_filter, 8640 vf_id, UINT8); 8641 cmdline_parse_token_etheraddr_t cmd_set_vf_macvlan_mac = 8642 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_vf_macvlan_filter, 8643 address); 8644 cmdline_parse_token_string_t cmd_set_vf_macvlan_filter_type = 8645 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_macvlan_filter, 8646 filter_type, "exact-mac#exact-mac-vlan" 8647 "#hashmac#hashmac-vlan"); 8648 cmdline_parse_token_string_t cmd_set_vf_macvlan_mode = 8649 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_macvlan_filter, 8650 mode, "on#off"); 8651 8652 cmdline_parse_inst_t cmd_set_vf_macvlan_filter = { 8653 .f = cmd_set_vf_macvlan_parsed, 8654 .data = NULL, 8655 .help_str = "set port <port_id> vf <vf_id> <mac_addr> " 8656 "exact-mac|exact-mac-vlan|hashmac|hashmac-vlan on|off: " 8657 "Exact match rule: exact match of MAC or MAC and VLAN; " 8658 "hash match rule: hash match of MAC and exact match of VLAN", 8659 .tokens = { 8660 (void *)&cmd_set_vf_macvlan_set, 8661 (void *)&cmd_set_vf_macvlan_port, 8662 (void *)&cmd_set_vf_macvlan_portid, 8663 (void *)&cmd_set_vf_macvlan_vf, 8664 (void *)&cmd_set_vf_macvlan_vf_id, 8665 (void *)&cmd_set_vf_macvlan_mac, 8666 (void *)&cmd_set_vf_macvlan_filter_type, 8667 (void *)&cmd_set_vf_macvlan_mode, 8668 NULL, 8669 }, 8670 }; 8671 8672 /* *** CONFIGURE VF TRAFFIC CONTROL *** */ 8673 struct cmd_set_vf_traffic { 8674 cmdline_fixed_string_t set; 8675 cmdline_fixed_string_t port; 8676 portid_t port_id; 8677 cmdline_fixed_string_t vf; 8678 uint8_t vf_id; 8679 cmdline_fixed_string_t what; 8680 cmdline_fixed_string_t mode; 8681 }; 8682 8683 static void 8684 cmd_set_vf_traffic_parsed(void *parsed_result, 8685 __rte_unused struct cmdline *cl, 8686 __rte_unused void *data) 8687 { 8688 struct cmd_set_vf_traffic *res = parsed_result; 8689 int is_rx = (strcmp(res->what, "rx") == 0) ? 1 : 0; 8690 int is_on = (strcmp(res->mode, "on") == 0) ? 1 : 0; 8691 8692 set_vf_traffic(res->port_id, (uint8_t)is_rx, res->vf_id,(uint8_t) is_on); 8693 } 8694 8695 cmdline_parse_token_string_t cmd_setvf_traffic_set = 8696 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_traffic, 8697 set, "set"); 8698 cmdline_parse_token_string_t cmd_setvf_traffic_port = 8699 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_traffic, 8700 port, "port"); 8701 cmdline_parse_token_num_t cmd_setvf_traffic_portid = 8702 TOKEN_NUM_INITIALIZER(struct cmd_set_vf_traffic, 8703 port_id, UINT16); 8704 cmdline_parse_token_string_t cmd_setvf_traffic_vf = 8705 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_traffic, 8706 vf, "vf"); 8707 cmdline_parse_token_num_t cmd_setvf_traffic_vfid = 8708 TOKEN_NUM_INITIALIZER(struct cmd_set_vf_traffic, 8709 vf_id, UINT8); 8710 cmdline_parse_token_string_t cmd_setvf_traffic_what = 8711 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_traffic, 8712 what, "tx#rx"); 8713 cmdline_parse_token_string_t cmd_setvf_traffic_mode = 8714 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_traffic, 8715 mode, "on#off"); 8716 8717 cmdline_parse_inst_t cmd_set_vf_traffic = { 8718 .f = cmd_set_vf_traffic_parsed, 8719 .data = NULL, 8720 .help_str = "set port <port_id> vf <vf_id> rx|tx on|off", 8721 .tokens = { 8722 (void *)&cmd_setvf_traffic_set, 8723 (void *)&cmd_setvf_traffic_port, 8724 (void *)&cmd_setvf_traffic_portid, 8725 (void *)&cmd_setvf_traffic_vf, 8726 (void *)&cmd_setvf_traffic_vfid, 8727 (void *)&cmd_setvf_traffic_what, 8728 (void *)&cmd_setvf_traffic_mode, 8729 NULL, 8730 }, 8731 }; 8732 8733 /* *** CONFIGURE VF RECEIVE MODE *** */ 8734 struct cmd_set_vf_rxmode { 8735 cmdline_fixed_string_t set; 8736 cmdline_fixed_string_t port; 8737 portid_t port_id; 8738 cmdline_fixed_string_t vf; 8739 uint8_t vf_id; 8740 cmdline_fixed_string_t what; 8741 cmdline_fixed_string_t mode; 8742 cmdline_fixed_string_t on; 8743 }; 8744 8745 static void 8746 cmd_set_vf_rxmode_parsed(void *parsed_result, 8747 __rte_unused struct cmdline *cl, 8748 __rte_unused void *data) 8749 { 8750 int ret = -ENOTSUP; 8751 uint16_t vf_rxmode = 0; 8752 struct cmd_set_vf_rxmode *res = parsed_result; 8753 8754 int is_on = (strcmp(res->on, "on") == 0) ? 1 : 0; 8755 if (!strcmp(res->what,"rxmode")) { 8756 if (!strcmp(res->mode, "AUPE")) 8757 vf_rxmode |= ETH_VMDQ_ACCEPT_UNTAG; 8758 else if (!strcmp(res->mode, "ROPE")) 8759 vf_rxmode |= ETH_VMDQ_ACCEPT_HASH_UC; 8760 else if (!strcmp(res->mode, "BAM")) 8761 vf_rxmode |= ETH_VMDQ_ACCEPT_BROADCAST; 8762 else if (!strncmp(res->mode, "MPE",3)) 8763 vf_rxmode |= ETH_VMDQ_ACCEPT_MULTICAST; 8764 } 8765 8766 RTE_SET_USED(is_on); 8767 8768 #ifdef RTE_LIBRTE_IXGBE_PMD 8769 if (ret == -ENOTSUP) 8770 ret = rte_pmd_ixgbe_set_vf_rxmode(res->port_id, res->vf_id, 8771 vf_rxmode, (uint8_t)is_on); 8772 #endif 8773 #ifdef RTE_LIBRTE_BNXT_PMD 8774 if (ret == -ENOTSUP) 8775 ret = rte_pmd_bnxt_set_vf_rxmode(res->port_id, res->vf_id, 8776 vf_rxmode, (uint8_t)is_on); 8777 #endif 8778 if (ret < 0) 8779 printf("bad VF receive mode parameter, return code = %d \n", 8780 ret); 8781 } 8782 8783 cmdline_parse_token_string_t cmd_set_vf_rxmode_set = 8784 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_rxmode, 8785 set, "set"); 8786 cmdline_parse_token_string_t cmd_set_vf_rxmode_port = 8787 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_rxmode, 8788 port, "port"); 8789 cmdline_parse_token_num_t cmd_set_vf_rxmode_portid = 8790 TOKEN_NUM_INITIALIZER(struct cmd_set_vf_rxmode, 8791 port_id, UINT16); 8792 cmdline_parse_token_string_t cmd_set_vf_rxmode_vf = 8793 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_rxmode, 8794 vf, "vf"); 8795 cmdline_parse_token_num_t cmd_set_vf_rxmode_vfid = 8796 TOKEN_NUM_INITIALIZER(struct cmd_set_vf_rxmode, 8797 vf_id, UINT8); 8798 cmdline_parse_token_string_t cmd_set_vf_rxmode_what = 8799 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_rxmode, 8800 what, "rxmode"); 8801 cmdline_parse_token_string_t cmd_set_vf_rxmode_mode = 8802 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_rxmode, 8803 mode, "AUPE#ROPE#BAM#MPE"); 8804 cmdline_parse_token_string_t cmd_set_vf_rxmode_on = 8805 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_rxmode, 8806 on, "on#off"); 8807 8808 cmdline_parse_inst_t cmd_set_vf_rxmode = { 8809 .f = cmd_set_vf_rxmode_parsed, 8810 .data = NULL, 8811 .help_str = "set port <port_id> vf <vf_id> rxmode " 8812 "AUPE|ROPE|BAM|MPE on|off", 8813 .tokens = { 8814 (void *)&cmd_set_vf_rxmode_set, 8815 (void *)&cmd_set_vf_rxmode_port, 8816 (void *)&cmd_set_vf_rxmode_portid, 8817 (void *)&cmd_set_vf_rxmode_vf, 8818 (void *)&cmd_set_vf_rxmode_vfid, 8819 (void *)&cmd_set_vf_rxmode_what, 8820 (void *)&cmd_set_vf_rxmode_mode, 8821 (void *)&cmd_set_vf_rxmode_on, 8822 NULL, 8823 }, 8824 }; 8825 8826 /* *** ADD MAC ADDRESS FILTER FOR A VF OF A PORT *** */ 8827 struct cmd_vf_mac_addr_result { 8828 cmdline_fixed_string_t mac_addr_cmd; 8829 cmdline_fixed_string_t what; 8830 cmdline_fixed_string_t port; 8831 uint16_t port_num; 8832 cmdline_fixed_string_t vf; 8833 uint8_t vf_num; 8834 struct rte_ether_addr address; 8835 }; 8836 8837 static void cmd_vf_mac_addr_parsed(void *parsed_result, 8838 __rte_unused struct cmdline *cl, 8839 __rte_unused void *data) 8840 { 8841 struct cmd_vf_mac_addr_result *res = parsed_result; 8842 int ret = -ENOTSUP; 8843 8844 if (strcmp(res->what, "add") != 0) 8845 return; 8846 8847 #ifdef RTE_LIBRTE_I40E_PMD 8848 if (ret == -ENOTSUP) 8849 ret = rte_pmd_i40e_add_vf_mac_addr(res->port_num, res->vf_num, 8850 &res->address); 8851 #endif 8852 #ifdef RTE_LIBRTE_BNXT_PMD 8853 if (ret == -ENOTSUP) 8854 ret = rte_pmd_bnxt_mac_addr_add(res->port_num, &res->address, 8855 res->vf_num); 8856 #endif 8857 8858 if(ret < 0) 8859 printf("vf_mac_addr_cmd error: (%s)\n", strerror(-ret)); 8860 8861 } 8862 8863 cmdline_parse_token_string_t cmd_vf_mac_addr_cmd = 8864 TOKEN_STRING_INITIALIZER(struct cmd_vf_mac_addr_result, 8865 mac_addr_cmd,"mac_addr"); 8866 cmdline_parse_token_string_t cmd_vf_mac_addr_what = 8867 TOKEN_STRING_INITIALIZER(struct cmd_vf_mac_addr_result, 8868 what,"add"); 8869 cmdline_parse_token_string_t cmd_vf_mac_addr_port = 8870 TOKEN_STRING_INITIALIZER(struct cmd_vf_mac_addr_result, 8871 port,"port"); 8872 cmdline_parse_token_num_t cmd_vf_mac_addr_portnum = 8873 TOKEN_NUM_INITIALIZER(struct cmd_vf_mac_addr_result, 8874 port_num, UINT16); 8875 cmdline_parse_token_string_t cmd_vf_mac_addr_vf = 8876 TOKEN_STRING_INITIALIZER(struct cmd_vf_mac_addr_result, 8877 vf,"vf"); 8878 cmdline_parse_token_num_t cmd_vf_mac_addr_vfnum = 8879 TOKEN_NUM_INITIALIZER(struct cmd_vf_mac_addr_result, 8880 vf_num, UINT8); 8881 cmdline_parse_token_etheraddr_t cmd_vf_mac_addr_addr = 8882 TOKEN_ETHERADDR_INITIALIZER(struct cmd_vf_mac_addr_result, 8883 address); 8884 8885 cmdline_parse_inst_t cmd_vf_mac_addr_filter = { 8886 .f = cmd_vf_mac_addr_parsed, 8887 .data = (void *)0, 8888 .help_str = "mac_addr add port <port_id> vf <vf_id> <mac_addr>: " 8889 "Add MAC address filtering for a VF on port_id", 8890 .tokens = { 8891 (void *)&cmd_vf_mac_addr_cmd, 8892 (void *)&cmd_vf_mac_addr_what, 8893 (void *)&cmd_vf_mac_addr_port, 8894 (void *)&cmd_vf_mac_addr_portnum, 8895 (void *)&cmd_vf_mac_addr_vf, 8896 (void *)&cmd_vf_mac_addr_vfnum, 8897 (void *)&cmd_vf_mac_addr_addr, 8898 NULL, 8899 }, 8900 }; 8901 8902 /* *** ADD/REMOVE A VLAN IDENTIFIER TO/FROM A PORT VLAN RX FILTER *** */ 8903 struct cmd_vf_rx_vlan_filter { 8904 cmdline_fixed_string_t rx_vlan; 8905 cmdline_fixed_string_t what; 8906 uint16_t vlan_id; 8907 cmdline_fixed_string_t port; 8908 portid_t port_id; 8909 cmdline_fixed_string_t vf; 8910 uint64_t vf_mask; 8911 }; 8912 8913 static void 8914 cmd_vf_rx_vlan_filter_parsed(void *parsed_result, 8915 __rte_unused struct cmdline *cl, 8916 __rte_unused void *data) 8917 { 8918 struct cmd_vf_rx_vlan_filter *res = parsed_result; 8919 int ret = -ENOTSUP; 8920 8921 __rte_unused int is_add = (strcmp(res->what, "add") == 0) ? 1 : 0; 8922 8923 #ifdef RTE_LIBRTE_IXGBE_PMD 8924 if (ret == -ENOTSUP) 8925 ret = rte_pmd_ixgbe_set_vf_vlan_filter(res->port_id, 8926 res->vlan_id, res->vf_mask, is_add); 8927 #endif 8928 #ifdef RTE_LIBRTE_I40E_PMD 8929 if (ret == -ENOTSUP) 8930 ret = rte_pmd_i40e_set_vf_vlan_filter(res->port_id, 8931 res->vlan_id, res->vf_mask, is_add); 8932 #endif 8933 #ifdef RTE_LIBRTE_BNXT_PMD 8934 if (ret == -ENOTSUP) 8935 ret = rte_pmd_bnxt_set_vf_vlan_filter(res->port_id, 8936 res->vlan_id, res->vf_mask, is_add); 8937 #endif 8938 8939 switch (ret) { 8940 case 0: 8941 break; 8942 case -EINVAL: 8943 printf("invalid vlan_id %d or vf_mask %"PRIu64"\n", 8944 res->vlan_id, res->vf_mask); 8945 break; 8946 case -ENODEV: 8947 printf("invalid port_id %d\n", res->port_id); 8948 break; 8949 case -ENOTSUP: 8950 printf("function not implemented or supported\n"); 8951 break; 8952 default: 8953 printf("programming error: (%s)\n", strerror(-ret)); 8954 } 8955 } 8956 8957 cmdline_parse_token_string_t cmd_vf_rx_vlan_filter_rx_vlan = 8958 TOKEN_STRING_INITIALIZER(struct cmd_vf_rx_vlan_filter, 8959 rx_vlan, "rx_vlan"); 8960 cmdline_parse_token_string_t cmd_vf_rx_vlan_filter_what = 8961 TOKEN_STRING_INITIALIZER(struct cmd_vf_rx_vlan_filter, 8962 what, "add#rm"); 8963 cmdline_parse_token_num_t cmd_vf_rx_vlan_filter_vlanid = 8964 TOKEN_NUM_INITIALIZER(struct cmd_vf_rx_vlan_filter, 8965 vlan_id, UINT16); 8966 cmdline_parse_token_string_t cmd_vf_rx_vlan_filter_port = 8967 TOKEN_STRING_INITIALIZER(struct cmd_vf_rx_vlan_filter, 8968 port, "port"); 8969 cmdline_parse_token_num_t cmd_vf_rx_vlan_filter_portid = 8970 TOKEN_NUM_INITIALIZER(struct cmd_vf_rx_vlan_filter, 8971 port_id, UINT16); 8972 cmdline_parse_token_string_t cmd_vf_rx_vlan_filter_vf = 8973 TOKEN_STRING_INITIALIZER(struct cmd_vf_rx_vlan_filter, 8974 vf, "vf"); 8975 cmdline_parse_token_num_t cmd_vf_rx_vlan_filter_vf_mask = 8976 TOKEN_NUM_INITIALIZER(struct cmd_vf_rx_vlan_filter, 8977 vf_mask, UINT64); 8978 8979 cmdline_parse_inst_t cmd_vf_rxvlan_filter = { 8980 .f = cmd_vf_rx_vlan_filter_parsed, 8981 .data = NULL, 8982 .help_str = "rx_vlan add|rm <vlan_id> port <port_id> vf <vf_mask>: " 8983 "(vf_mask = hexadecimal VF mask)", 8984 .tokens = { 8985 (void *)&cmd_vf_rx_vlan_filter_rx_vlan, 8986 (void *)&cmd_vf_rx_vlan_filter_what, 8987 (void *)&cmd_vf_rx_vlan_filter_vlanid, 8988 (void *)&cmd_vf_rx_vlan_filter_port, 8989 (void *)&cmd_vf_rx_vlan_filter_portid, 8990 (void *)&cmd_vf_rx_vlan_filter_vf, 8991 (void *)&cmd_vf_rx_vlan_filter_vf_mask, 8992 NULL, 8993 }, 8994 }; 8995 8996 /* *** SET RATE LIMIT FOR A QUEUE OF A PORT *** */ 8997 struct cmd_queue_rate_limit_result { 8998 cmdline_fixed_string_t set; 8999 cmdline_fixed_string_t port; 9000 uint16_t port_num; 9001 cmdline_fixed_string_t queue; 9002 uint8_t queue_num; 9003 cmdline_fixed_string_t rate; 9004 uint16_t rate_num; 9005 }; 9006 9007 static void cmd_queue_rate_limit_parsed(void *parsed_result, 9008 __rte_unused struct cmdline *cl, 9009 __rte_unused void *data) 9010 { 9011 struct cmd_queue_rate_limit_result *res = parsed_result; 9012 int ret = 0; 9013 9014 if ((strcmp(res->set, "set") == 0) && (strcmp(res->port, "port") == 0) 9015 && (strcmp(res->queue, "queue") == 0) 9016 && (strcmp(res->rate, "rate") == 0)) 9017 ret = set_queue_rate_limit(res->port_num, res->queue_num, 9018 res->rate_num); 9019 if (ret < 0) 9020 printf("queue_rate_limit_cmd error: (%s)\n", strerror(-ret)); 9021 9022 } 9023 9024 cmdline_parse_token_string_t cmd_queue_rate_limit_set = 9025 TOKEN_STRING_INITIALIZER(struct cmd_queue_rate_limit_result, 9026 set, "set"); 9027 cmdline_parse_token_string_t cmd_queue_rate_limit_port = 9028 TOKEN_STRING_INITIALIZER(struct cmd_queue_rate_limit_result, 9029 port, "port"); 9030 cmdline_parse_token_num_t cmd_queue_rate_limit_portnum = 9031 TOKEN_NUM_INITIALIZER(struct cmd_queue_rate_limit_result, 9032 port_num, UINT16); 9033 cmdline_parse_token_string_t cmd_queue_rate_limit_queue = 9034 TOKEN_STRING_INITIALIZER(struct cmd_queue_rate_limit_result, 9035 queue, "queue"); 9036 cmdline_parse_token_num_t cmd_queue_rate_limit_queuenum = 9037 TOKEN_NUM_INITIALIZER(struct cmd_queue_rate_limit_result, 9038 queue_num, UINT8); 9039 cmdline_parse_token_string_t cmd_queue_rate_limit_rate = 9040 TOKEN_STRING_INITIALIZER(struct cmd_queue_rate_limit_result, 9041 rate, "rate"); 9042 cmdline_parse_token_num_t cmd_queue_rate_limit_ratenum = 9043 TOKEN_NUM_INITIALIZER(struct cmd_queue_rate_limit_result, 9044 rate_num, UINT16); 9045 9046 cmdline_parse_inst_t cmd_queue_rate_limit = { 9047 .f = cmd_queue_rate_limit_parsed, 9048 .data = (void *)0, 9049 .help_str = "set port <port_id> queue <queue_id> rate <rate_value>: " 9050 "Set rate limit for a queue on port_id", 9051 .tokens = { 9052 (void *)&cmd_queue_rate_limit_set, 9053 (void *)&cmd_queue_rate_limit_port, 9054 (void *)&cmd_queue_rate_limit_portnum, 9055 (void *)&cmd_queue_rate_limit_queue, 9056 (void *)&cmd_queue_rate_limit_queuenum, 9057 (void *)&cmd_queue_rate_limit_rate, 9058 (void *)&cmd_queue_rate_limit_ratenum, 9059 NULL, 9060 }, 9061 }; 9062 9063 /* *** SET RATE LIMIT FOR A VF OF A PORT *** */ 9064 struct cmd_vf_rate_limit_result { 9065 cmdline_fixed_string_t set; 9066 cmdline_fixed_string_t port; 9067 uint16_t port_num; 9068 cmdline_fixed_string_t vf; 9069 uint8_t vf_num; 9070 cmdline_fixed_string_t rate; 9071 uint16_t rate_num; 9072 cmdline_fixed_string_t q_msk; 9073 uint64_t q_msk_val; 9074 }; 9075 9076 static void cmd_vf_rate_limit_parsed(void *parsed_result, 9077 __rte_unused struct cmdline *cl, 9078 __rte_unused void *data) 9079 { 9080 struct cmd_vf_rate_limit_result *res = parsed_result; 9081 int ret = 0; 9082 9083 if ((strcmp(res->set, "set") == 0) && (strcmp(res->port, "port") == 0) 9084 && (strcmp(res->vf, "vf") == 0) 9085 && (strcmp(res->rate, "rate") == 0) 9086 && (strcmp(res->q_msk, "queue_mask") == 0)) 9087 ret = set_vf_rate_limit(res->port_num, res->vf_num, 9088 res->rate_num, res->q_msk_val); 9089 if (ret < 0) 9090 printf("vf_rate_limit_cmd error: (%s)\n", strerror(-ret)); 9091 9092 } 9093 9094 cmdline_parse_token_string_t cmd_vf_rate_limit_set = 9095 TOKEN_STRING_INITIALIZER(struct cmd_vf_rate_limit_result, 9096 set, "set"); 9097 cmdline_parse_token_string_t cmd_vf_rate_limit_port = 9098 TOKEN_STRING_INITIALIZER(struct cmd_vf_rate_limit_result, 9099 port, "port"); 9100 cmdline_parse_token_num_t cmd_vf_rate_limit_portnum = 9101 TOKEN_NUM_INITIALIZER(struct cmd_vf_rate_limit_result, 9102 port_num, UINT16); 9103 cmdline_parse_token_string_t cmd_vf_rate_limit_vf = 9104 TOKEN_STRING_INITIALIZER(struct cmd_vf_rate_limit_result, 9105 vf, "vf"); 9106 cmdline_parse_token_num_t cmd_vf_rate_limit_vfnum = 9107 TOKEN_NUM_INITIALIZER(struct cmd_vf_rate_limit_result, 9108 vf_num, UINT8); 9109 cmdline_parse_token_string_t cmd_vf_rate_limit_rate = 9110 TOKEN_STRING_INITIALIZER(struct cmd_vf_rate_limit_result, 9111 rate, "rate"); 9112 cmdline_parse_token_num_t cmd_vf_rate_limit_ratenum = 9113 TOKEN_NUM_INITIALIZER(struct cmd_vf_rate_limit_result, 9114 rate_num, UINT16); 9115 cmdline_parse_token_string_t cmd_vf_rate_limit_q_msk = 9116 TOKEN_STRING_INITIALIZER(struct cmd_vf_rate_limit_result, 9117 q_msk, "queue_mask"); 9118 cmdline_parse_token_num_t cmd_vf_rate_limit_q_msk_val = 9119 TOKEN_NUM_INITIALIZER(struct cmd_vf_rate_limit_result, 9120 q_msk_val, UINT64); 9121 9122 cmdline_parse_inst_t cmd_vf_rate_limit = { 9123 .f = cmd_vf_rate_limit_parsed, 9124 .data = (void *)0, 9125 .help_str = "set port <port_id> vf <vf_id> rate <rate_value> " 9126 "queue_mask <queue_mask_value>: " 9127 "Set rate limit for queues of VF on port_id", 9128 .tokens = { 9129 (void *)&cmd_vf_rate_limit_set, 9130 (void *)&cmd_vf_rate_limit_port, 9131 (void *)&cmd_vf_rate_limit_portnum, 9132 (void *)&cmd_vf_rate_limit_vf, 9133 (void *)&cmd_vf_rate_limit_vfnum, 9134 (void *)&cmd_vf_rate_limit_rate, 9135 (void *)&cmd_vf_rate_limit_ratenum, 9136 (void *)&cmd_vf_rate_limit_q_msk, 9137 (void *)&cmd_vf_rate_limit_q_msk_val, 9138 NULL, 9139 }, 9140 }; 9141 9142 /* *** ADD TUNNEL FILTER OF A PORT *** */ 9143 struct cmd_tunnel_filter_result { 9144 cmdline_fixed_string_t cmd; 9145 cmdline_fixed_string_t what; 9146 portid_t port_id; 9147 struct rte_ether_addr outer_mac; 9148 struct rte_ether_addr inner_mac; 9149 cmdline_ipaddr_t ip_value; 9150 uint16_t inner_vlan; 9151 cmdline_fixed_string_t tunnel_type; 9152 cmdline_fixed_string_t filter_type; 9153 uint32_t tenant_id; 9154 uint16_t queue_num; 9155 }; 9156 9157 static void 9158 cmd_tunnel_filter_parsed(void *parsed_result, 9159 __rte_unused struct cmdline *cl, 9160 __rte_unused void *data) 9161 { 9162 struct cmd_tunnel_filter_result *res = parsed_result; 9163 struct rte_eth_tunnel_filter_conf tunnel_filter_conf; 9164 int ret = 0; 9165 9166 memset(&tunnel_filter_conf, 0, sizeof(tunnel_filter_conf)); 9167 9168 rte_ether_addr_copy(&res->outer_mac, &tunnel_filter_conf.outer_mac); 9169 rte_ether_addr_copy(&res->inner_mac, &tunnel_filter_conf.inner_mac); 9170 tunnel_filter_conf.inner_vlan = res->inner_vlan; 9171 9172 if (res->ip_value.family == AF_INET) { 9173 tunnel_filter_conf.ip_addr.ipv4_addr = 9174 res->ip_value.addr.ipv4.s_addr; 9175 tunnel_filter_conf.ip_type = RTE_TUNNEL_IPTYPE_IPV4; 9176 } else { 9177 memcpy(&(tunnel_filter_conf.ip_addr.ipv6_addr), 9178 &(res->ip_value.addr.ipv6), 9179 sizeof(struct in6_addr)); 9180 tunnel_filter_conf.ip_type = RTE_TUNNEL_IPTYPE_IPV6; 9181 } 9182 9183 if (!strcmp(res->filter_type, "imac-ivlan")) 9184 tunnel_filter_conf.filter_type = RTE_TUNNEL_FILTER_IMAC_IVLAN; 9185 else if (!strcmp(res->filter_type, "imac-ivlan-tenid")) 9186 tunnel_filter_conf.filter_type = 9187 RTE_TUNNEL_FILTER_IMAC_IVLAN_TENID; 9188 else if (!strcmp(res->filter_type, "imac-tenid")) 9189 tunnel_filter_conf.filter_type = RTE_TUNNEL_FILTER_IMAC_TENID; 9190 else if (!strcmp(res->filter_type, "imac")) 9191 tunnel_filter_conf.filter_type = ETH_TUNNEL_FILTER_IMAC; 9192 else if (!strcmp(res->filter_type, "omac-imac-tenid")) 9193 tunnel_filter_conf.filter_type = 9194 RTE_TUNNEL_FILTER_OMAC_TENID_IMAC; 9195 else if (!strcmp(res->filter_type, "oip")) 9196 tunnel_filter_conf.filter_type = ETH_TUNNEL_FILTER_OIP; 9197 else if (!strcmp(res->filter_type, "iip")) 9198 tunnel_filter_conf.filter_type = ETH_TUNNEL_FILTER_IIP; 9199 else { 9200 printf("The filter type is not supported"); 9201 return; 9202 } 9203 9204 if (!strcmp(res->tunnel_type, "vxlan")) 9205 tunnel_filter_conf.tunnel_type = RTE_TUNNEL_TYPE_VXLAN; 9206 else if (!strcmp(res->tunnel_type, "vxlan-gpe")) 9207 tunnel_filter_conf.tunnel_type = RTE_TUNNEL_TYPE_VXLAN_GPE; 9208 else if (!strcmp(res->tunnel_type, "nvgre")) 9209 tunnel_filter_conf.tunnel_type = RTE_TUNNEL_TYPE_NVGRE; 9210 else if (!strcmp(res->tunnel_type, "ipingre")) 9211 tunnel_filter_conf.tunnel_type = RTE_TUNNEL_TYPE_IP_IN_GRE; 9212 else { 9213 printf("The tunnel type %s not supported.\n", res->tunnel_type); 9214 return; 9215 } 9216 9217 tunnel_filter_conf.tenant_id = res->tenant_id; 9218 tunnel_filter_conf.queue_id = res->queue_num; 9219 if (!strcmp(res->what, "add")) 9220 ret = rte_eth_dev_filter_ctrl(res->port_id, 9221 RTE_ETH_FILTER_TUNNEL, 9222 RTE_ETH_FILTER_ADD, 9223 &tunnel_filter_conf); 9224 else 9225 ret = rte_eth_dev_filter_ctrl(res->port_id, 9226 RTE_ETH_FILTER_TUNNEL, 9227 RTE_ETH_FILTER_DELETE, 9228 &tunnel_filter_conf); 9229 if (ret < 0) 9230 printf("cmd_tunnel_filter_parsed error: (%s)\n", 9231 strerror(-ret)); 9232 9233 } 9234 cmdline_parse_token_string_t cmd_tunnel_filter_cmd = 9235 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_filter_result, 9236 cmd, "tunnel_filter"); 9237 cmdline_parse_token_string_t cmd_tunnel_filter_what = 9238 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_filter_result, 9239 what, "add#rm"); 9240 cmdline_parse_token_num_t cmd_tunnel_filter_port_id = 9241 TOKEN_NUM_INITIALIZER(struct cmd_tunnel_filter_result, 9242 port_id, UINT16); 9243 cmdline_parse_token_etheraddr_t cmd_tunnel_filter_outer_mac = 9244 TOKEN_ETHERADDR_INITIALIZER(struct cmd_tunnel_filter_result, 9245 outer_mac); 9246 cmdline_parse_token_etheraddr_t cmd_tunnel_filter_inner_mac = 9247 TOKEN_ETHERADDR_INITIALIZER(struct cmd_tunnel_filter_result, 9248 inner_mac); 9249 cmdline_parse_token_num_t cmd_tunnel_filter_innner_vlan = 9250 TOKEN_NUM_INITIALIZER(struct cmd_tunnel_filter_result, 9251 inner_vlan, UINT16); 9252 cmdline_parse_token_ipaddr_t cmd_tunnel_filter_ip_value = 9253 TOKEN_IPADDR_INITIALIZER(struct cmd_tunnel_filter_result, 9254 ip_value); 9255 cmdline_parse_token_string_t cmd_tunnel_filter_tunnel_type = 9256 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_filter_result, 9257 tunnel_type, "vxlan#nvgre#ipingre#vxlan-gpe"); 9258 9259 cmdline_parse_token_string_t cmd_tunnel_filter_filter_type = 9260 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_filter_result, 9261 filter_type, "oip#iip#imac-ivlan#imac-ivlan-tenid#imac-tenid#" 9262 "imac#omac-imac-tenid"); 9263 cmdline_parse_token_num_t cmd_tunnel_filter_tenant_id = 9264 TOKEN_NUM_INITIALIZER(struct cmd_tunnel_filter_result, 9265 tenant_id, UINT32); 9266 cmdline_parse_token_num_t cmd_tunnel_filter_queue_num = 9267 TOKEN_NUM_INITIALIZER(struct cmd_tunnel_filter_result, 9268 queue_num, UINT16); 9269 9270 cmdline_parse_inst_t cmd_tunnel_filter = { 9271 .f = cmd_tunnel_filter_parsed, 9272 .data = (void *)0, 9273 .help_str = "tunnel_filter add|rm <port_id> <outer_mac> <inner_mac> " 9274 "<ip> <inner_vlan> vxlan|nvgre|ipingre oip|iip|imac-ivlan|" 9275 "imac-ivlan-tenid|imac-tenid|imac|omac-imac-tenid <tenant_id> " 9276 "<queue_id>: Add/Rm tunnel filter of a port", 9277 .tokens = { 9278 (void *)&cmd_tunnel_filter_cmd, 9279 (void *)&cmd_tunnel_filter_what, 9280 (void *)&cmd_tunnel_filter_port_id, 9281 (void *)&cmd_tunnel_filter_outer_mac, 9282 (void *)&cmd_tunnel_filter_inner_mac, 9283 (void *)&cmd_tunnel_filter_ip_value, 9284 (void *)&cmd_tunnel_filter_innner_vlan, 9285 (void *)&cmd_tunnel_filter_tunnel_type, 9286 (void *)&cmd_tunnel_filter_filter_type, 9287 (void *)&cmd_tunnel_filter_tenant_id, 9288 (void *)&cmd_tunnel_filter_queue_num, 9289 NULL, 9290 }, 9291 }; 9292 9293 /* *** CONFIGURE TUNNEL UDP PORT *** */ 9294 struct cmd_tunnel_udp_config { 9295 cmdline_fixed_string_t cmd; 9296 cmdline_fixed_string_t what; 9297 uint16_t udp_port; 9298 portid_t port_id; 9299 }; 9300 9301 static void 9302 cmd_tunnel_udp_config_parsed(void *parsed_result, 9303 __rte_unused struct cmdline *cl, 9304 __rte_unused void *data) 9305 { 9306 struct cmd_tunnel_udp_config *res = parsed_result; 9307 struct rte_eth_udp_tunnel tunnel_udp; 9308 int ret; 9309 9310 tunnel_udp.udp_port = res->udp_port; 9311 9312 if (!strcmp(res->cmd, "rx_vxlan_port")) 9313 tunnel_udp.prot_type = RTE_TUNNEL_TYPE_VXLAN; 9314 9315 if (!strcmp(res->what, "add")) 9316 ret = rte_eth_dev_udp_tunnel_port_add(res->port_id, 9317 &tunnel_udp); 9318 else 9319 ret = rte_eth_dev_udp_tunnel_port_delete(res->port_id, 9320 &tunnel_udp); 9321 9322 if (ret < 0) 9323 printf("udp tunneling add error: (%s)\n", strerror(-ret)); 9324 } 9325 9326 cmdline_parse_token_string_t cmd_tunnel_udp_config_cmd = 9327 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_udp_config, 9328 cmd, "rx_vxlan_port"); 9329 cmdline_parse_token_string_t cmd_tunnel_udp_config_what = 9330 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_udp_config, 9331 what, "add#rm"); 9332 cmdline_parse_token_num_t cmd_tunnel_udp_config_udp_port = 9333 TOKEN_NUM_INITIALIZER(struct cmd_tunnel_udp_config, 9334 udp_port, UINT16); 9335 cmdline_parse_token_num_t cmd_tunnel_udp_config_port_id = 9336 TOKEN_NUM_INITIALIZER(struct cmd_tunnel_udp_config, 9337 port_id, UINT16); 9338 9339 cmdline_parse_inst_t cmd_tunnel_udp_config = { 9340 .f = cmd_tunnel_udp_config_parsed, 9341 .data = (void *)0, 9342 .help_str = "rx_vxlan_port add|rm <udp_port> <port_id>: " 9343 "Add/Remove a tunneling UDP port filter", 9344 .tokens = { 9345 (void *)&cmd_tunnel_udp_config_cmd, 9346 (void *)&cmd_tunnel_udp_config_what, 9347 (void *)&cmd_tunnel_udp_config_udp_port, 9348 (void *)&cmd_tunnel_udp_config_port_id, 9349 NULL, 9350 }, 9351 }; 9352 9353 struct cmd_config_tunnel_udp_port { 9354 cmdline_fixed_string_t port; 9355 cmdline_fixed_string_t config; 9356 portid_t port_id; 9357 cmdline_fixed_string_t udp_tunnel_port; 9358 cmdline_fixed_string_t action; 9359 cmdline_fixed_string_t tunnel_type; 9360 uint16_t udp_port; 9361 }; 9362 9363 static void 9364 cmd_cfg_tunnel_udp_port_parsed(void *parsed_result, 9365 __rte_unused struct cmdline *cl, 9366 __rte_unused void *data) 9367 { 9368 struct cmd_config_tunnel_udp_port *res = parsed_result; 9369 struct rte_eth_udp_tunnel tunnel_udp; 9370 int ret = 0; 9371 9372 if (port_id_is_invalid(res->port_id, ENABLED_WARN)) 9373 return; 9374 9375 tunnel_udp.udp_port = res->udp_port; 9376 9377 if (!strcmp(res->tunnel_type, "vxlan")) { 9378 tunnel_udp.prot_type = RTE_TUNNEL_TYPE_VXLAN; 9379 } else if (!strcmp(res->tunnel_type, "geneve")) { 9380 tunnel_udp.prot_type = RTE_TUNNEL_TYPE_GENEVE; 9381 } else if (!strcmp(res->tunnel_type, "vxlan-gpe")) { 9382 tunnel_udp.prot_type = RTE_TUNNEL_TYPE_VXLAN_GPE; 9383 } else { 9384 printf("Invalid tunnel type\n"); 9385 return; 9386 } 9387 9388 if (!strcmp(res->action, "add")) 9389 ret = rte_eth_dev_udp_tunnel_port_add(res->port_id, 9390 &tunnel_udp); 9391 else 9392 ret = rte_eth_dev_udp_tunnel_port_delete(res->port_id, 9393 &tunnel_udp); 9394 9395 if (ret < 0) 9396 printf("udp tunneling port add error: (%s)\n", strerror(-ret)); 9397 } 9398 9399 cmdline_parse_token_string_t cmd_config_tunnel_udp_port_port = 9400 TOKEN_STRING_INITIALIZER(struct cmd_config_tunnel_udp_port, port, 9401 "port"); 9402 cmdline_parse_token_string_t cmd_config_tunnel_udp_port_config = 9403 TOKEN_STRING_INITIALIZER(struct cmd_config_tunnel_udp_port, config, 9404 "config"); 9405 cmdline_parse_token_num_t cmd_config_tunnel_udp_port_port_id = 9406 TOKEN_NUM_INITIALIZER(struct cmd_config_tunnel_udp_port, port_id, 9407 UINT16); 9408 cmdline_parse_token_string_t cmd_config_tunnel_udp_port_tunnel_port = 9409 TOKEN_STRING_INITIALIZER(struct cmd_config_tunnel_udp_port, 9410 udp_tunnel_port, 9411 "udp_tunnel_port"); 9412 cmdline_parse_token_string_t cmd_config_tunnel_udp_port_action = 9413 TOKEN_STRING_INITIALIZER(struct cmd_config_tunnel_udp_port, action, 9414 "add#rm"); 9415 cmdline_parse_token_string_t cmd_config_tunnel_udp_port_tunnel_type = 9416 TOKEN_STRING_INITIALIZER(struct cmd_config_tunnel_udp_port, tunnel_type, 9417 "vxlan#geneve#vxlan-gpe"); 9418 cmdline_parse_token_num_t cmd_config_tunnel_udp_port_value = 9419 TOKEN_NUM_INITIALIZER(struct cmd_config_tunnel_udp_port, udp_port, 9420 UINT16); 9421 9422 cmdline_parse_inst_t cmd_cfg_tunnel_udp_port = { 9423 .f = cmd_cfg_tunnel_udp_port_parsed, 9424 .data = NULL, 9425 .help_str = "port config <port_id> udp_tunnel_port add|rm vxlan|geneve|vxlan-gpe <udp_port>", 9426 .tokens = { 9427 (void *)&cmd_config_tunnel_udp_port_port, 9428 (void *)&cmd_config_tunnel_udp_port_config, 9429 (void *)&cmd_config_tunnel_udp_port_port_id, 9430 (void *)&cmd_config_tunnel_udp_port_tunnel_port, 9431 (void *)&cmd_config_tunnel_udp_port_action, 9432 (void *)&cmd_config_tunnel_udp_port_tunnel_type, 9433 (void *)&cmd_config_tunnel_udp_port_value, 9434 NULL, 9435 }, 9436 }; 9437 9438 /* *** GLOBAL CONFIG *** */ 9439 struct cmd_global_config_result { 9440 cmdline_fixed_string_t cmd; 9441 portid_t port_id; 9442 cmdline_fixed_string_t cfg_type; 9443 uint8_t len; 9444 }; 9445 9446 static void 9447 cmd_global_config_parsed(void *parsed_result, 9448 __rte_unused struct cmdline *cl, 9449 __rte_unused void *data) 9450 { 9451 struct cmd_global_config_result *res = parsed_result; 9452 struct rte_eth_global_cfg conf; 9453 int ret; 9454 9455 memset(&conf, 0, sizeof(conf)); 9456 conf.cfg_type = RTE_ETH_GLOBAL_CFG_TYPE_GRE_KEY_LEN; 9457 conf.cfg.gre_key_len = res->len; 9458 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_NONE, 9459 RTE_ETH_FILTER_SET, &conf); 9460 #ifdef RTE_LIBRTE_I40E_PMD 9461 if (ret == -ENOTSUP) 9462 ret = rte_pmd_i40e_set_gre_key_len(res->port_id, res->len); 9463 #endif 9464 if (ret != 0) 9465 printf("Global config error\n"); 9466 } 9467 9468 cmdline_parse_token_string_t cmd_global_config_cmd = 9469 TOKEN_STRING_INITIALIZER(struct cmd_global_config_result, cmd, 9470 "global_config"); 9471 cmdline_parse_token_num_t cmd_global_config_port_id = 9472 TOKEN_NUM_INITIALIZER(struct cmd_global_config_result, port_id, 9473 UINT16); 9474 cmdline_parse_token_string_t cmd_global_config_type = 9475 TOKEN_STRING_INITIALIZER(struct cmd_global_config_result, 9476 cfg_type, "gre-key-len"); 9477 cmdline_parse_token_num_t cmd_global_config_gre_key_len = 9478 TOKEN_NUM_INITIALIZER(struct cmd_global_config_result, 9479 len, UINT8); 9480 9481 cmdline_parse_inst_t cmd_global_config = { 9482 .f = cmd_global_config_parsed, 9483 .data = (void *)NULL, 9484 .help_str = "global_config <port_id> gre-key-len <key_len>", 9485 .tokens = { 9486 (void *)&cmd_global_config_cmd, 9487 (void *)&cmd_global_config_port_id, 9488 (void *)&cmd_global_config_type, 9489 (void *)&cmd_global_config_gre_key_len, 9490 NULL, 9491 }, 9492 }; 9493 9494 /* *** CONFIGURE VM MIRROR VLAN/POOL RULE *** */ 9495 struct cmd_set_mirror_mask_result { 9496 cmdline_fixed_string_t set; 9497 cmdline_fixed_string_t port; 9498 portid_t port_id; 9499 cmdline_fixed_string_t mirror; 9500 uint8_t rule_id; 9501 cmdline_fixed_string_t what; 9502 cmdline_fixed_string_t value; 9503 cmdline_fixed_string_t dstpool; 9504 uint8_t dstpool_id; 9505 cmdline_fixed_string_t on; 9506 }; 9507 9508 cmdline_parse_token_string_t cmd_mirror_mask_set = 9509 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result, 9510 set, "set"); 9511 cmdline_parse_token_string_t cmd_mirror_mask_port = 9512 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result, 9513 port, "port"); 9514 cmdline_parse_token_num_t cmd_mirror_mask_portid = 9515 TOKEN_NUM_INITIALIZER(struct cmd_set_mirror_mask_result, 9516 port_id, UINT16); 9517 cmdline_parse_token_string_t cmd_mirror_mask_mirror = 9518 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result, 9519 mirror, "mirror-rule"); 9520 cmdline_parse_token_num_t cmd_mirror_mask_ruleid = 9521 TOKEN_NUM_INITIALIZER(struct cmd_set_mirror_mask_result, 9522 rule_id, UINT8); 9523 cmdline_parse_token_string_t cmd_mirror_mask_what = 9524 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result, 9525 what, "pool-mirror-up#pool-mirror-down" 9526 "#vlan-mirror"); 9527 cmdline_parse_token_string_t cmd_mirror_mask_value = 9528 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result, 9529 value, NULL); 9530 cmdline_parse_token_string_t cmd_mirror_mask_dstpool = 9531 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result, 9532 dstpool, "dst-pool"); 9533 cmdline_parse_token_num_t cmd_mirror_mask_poolid = 9534 TOKEN_NUM_INITIALIZER(struct cmd_set_mirror_mask_result, 9535 dstpool_id, UINT8); 9536 cmdline_parse_token_string_t cmd_mirror_mask_on = 9537 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result, 9538 on, "on#off"); 9539 9540 static void 9541 cmd_set_mirror_mask_parsed(void *parsed_result, 9542 __rte_unused struct cmdline *cl, 9543 __rte_unused void *data) 9544 { 9545 int ret,nb_item,i; 9546 struct cmd_set_mirror_mask_result *res = parsed_result; 9547 struct rte_eth_mirror_conf mr_conf; 9548 9549 memset(&mr_conf, 0, sizeof(struct rte_eth_mirror_conf)); 9550 9551 unsigned int vlan_list[ETH_MIRROR_MAX_VLANS]; 9552 9553 mr_conf.dst_pool = res->dstpool_id; 9554 9555 if (!strcmp(res->what, "pool-mirror-up")) { 9556 mr_conf.pool_mask = strtoull(res->value, NULL, 16); 9557 mr_conf.rule_type = ETH_MIRROR_VIRTUAL_POOL_UP; 9558 } else if (!strcmp(res->what, "pool-mirror-down")) { 9559 mr_conf.pool_mask = strtoull(res->value, NULL, 16); 9560 mr_conf.rule_type = ETH_MIRROR_VIRTUAL_POOL_DOWN; 9561 } else if (!strcmp(res->what, "vlan-mirror")) { 9562 mr_conf.rule_type = ETH_MIRROR_VLAN; 9563 nb_item = parse_item_list(res->value, "vlan", 9564 ETH_MIRROR_MAX_VLANS, vlan_list, 1); 9565 if (nb_item <= 0) 9566 return; 9567 9568 for (i = 0; i < nb_item; i++) { 9569 if (vlan_list[i] > RTE_ETHER_MAX_VLAN_ID) { 9570 printf("Invalid vlan_id: must be < 4096\n"); 9571 return; 9572 } 9573 9574 mr_conf.vlan.vlan_id[i] = (uint16_t)vlan_list[i]; 9575 mr_conf.vlan.vlan_mask |= 1ULL << i; 9576 } 9577 } 9578 9579 if (!strcmp(res->on, "on")) 9580 ret = rte_eth_mirror_rule_set(res->port_id, &mr_conf, 9581 res->rule_id, 1); 9582 else 9583 ret = rte_eth_mirror_rule_set(res->port_id, &mr_conf, 9584 res->rule_id, 0); 9585 if (ret < 0) 9586 printf("mirror rule add error: (%s)\n", strerror(-ret)); 9587 } 9588 9589 cmdline_parse_inst_t cmd_set_mirror_mask = { 9590 .f = cmd_set_mirror_mask_parsed, 9591 .data = NULL, 9592 .help_str = "set port <port_id> mirror-rule <rule_id> " 9593 "pool-mirror-up|pool-mirror-down|vlan-mirror " 9594 "<pool_mask|vlan_id[,vlan_id]*> dst-pool <pool_id> on|off", 9595 .tokens = { 9596 (void *)&cmd_mirror_mask_set, 9597 (void *)&cmd_mirror_mask_port, 9598 (void *)&cmd_mirror_mask_portid, 9599 (void *)&cmd_mirror_mask_mirror, 9600 (void *)&cmd_mirror_mask_ruleid, 9601 (void *)&cmd_mirror_mask_what, 9602 (void *)&cmd_mirror_mask_value, 9603 (void *)&cmd_mirror_mask_dstpool, 9604 (void *)&cmd_mirror_mask_poolid, 9605 (void *)&cmd_mirror_mask_on, 9606 NULL, 9607 }, 9608 }; 9609 9610 /* *** CONFIGURE VM MIRROR UPLINK/DOWNLINK RULE *** */ 9611 struct cmd_set_mirror_link_result { 9612 cmdline_fixed_string_t set; 9613 cmdline_fixed_string_t port; 9614 portid_t port_id; 9615 cmdline_fixed_string_t mirror; 9616 uint8_t rule_id; 9617 cmdline_fixed_string_t what; 9618 cmdline_fixed_string_t dstpool; 9619 uint8_t dstpool_id; 9620 cmdline_fixed_string_t on; 9621 }; 9622 9623 cmdline_parse_token_string_t cmd_mirror_link_set = 9624 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_link_result, 9625 set, "set"); 9626 cmdline_parse_token_string_t cmd_mirror_link_port = 9627 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_link_result, 9628 port, "port"); 9629 cmdline_parse_token_num_t cmd_mirror_link_portid = 9630 TOKEN_NUM_INITIALIZER(struct cmd_set_mirror_link_result, 9631 port_id, UINT16); 9632 cmdline_parse_token_string_t cmd_mirror_link_mirror = 9633 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_link_result, 9634 mirror, "mirror-rule"); 9635 cmdline_parse_token_num_t cmd_mirror_link_ruleid = 9636 TOKEN_NUM_INITIALIZER(struct cmd_set_mirror_link_result, 9637 rule_id, UINT8); 9638 cmdline_parse_token_string_t cmd_mirror_link_what = 9639 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_link_result, 9640 what, "uplink-mirror#downlink-mirror"); 9641 cmdline_parse_token_string_t cmd_mirror_link_dstpool = 9642 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_link_result, 9643 dstpool, "dst-pool"); 9644 cmdline_parse_token_num_t cmd_mirror_link_poolid = 9645 TOKEN_NUM_INITIALIZER(struct cmd_set_mirror_link_result, 9646 dstpool_id, UINT8); 9647 cmdline_parse_token_string_t cmd_mirror_link_on = 9648 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_link_result, 9649 on, "on#off"); 9650 9651 static void 9652 cmd_set_mirror_link_parsed(void *parsed_result, 9653 __rte_unused struct cmdline *cl, 9654 __rte_unused void *data) 9655 { 9656 int ret; 9657 struct cmd_set_mirror_link_result *res = parsed_result; 9658 struct rte_eth_mirror_conf mr_conf; 9659 9660 memset(&mr_conf, 0, sizeof(struct rte_eth_mirror_conf)); 9661 if (!strcmp(res->what, "uplink-mirror")) 9662 mr_conf.rule_type = ETH_MIRROR_UPLINK_PORT; 9663 else 9664 mr_conf.rule_type = ETH_MIRROR_DOWNLINK_PORT; 9665 9666 mr_conf.dst_pool = res->dstpool_id; 9667 9668 if (!strcmp(res->on, "on")) 9669 ret = rte_eth_mirror_rule_set(res->port_id, &mr_conf, 9670 res->rule_id, 1); 9671 else 9672 ret = rte_eth_mirror_rule_set(res->port_id, &mr_conf, 9673 res->rule_id, 0); 9674 9675 /* check the return value and print it if is < 0 */ 9676 if (ret < 0) 9677 printf("mirror rule add error: (%s)\n", strerror(-ret)); 9678 9679 } 9680 9681 cmdline_parse_inst_t cmd_set_mirror_link = { 9682 .f = cmd_set_mirror_link_parsed, 9683 .data = NULL, 9684 .help_str = "set port <port_id> mirror-rule <rule_id> " 9685 "uplink-mirror|downlink-mirror dst-pool <pool_id> on|off", 9686 .tokens = { 9687 (void *)&cmd_mirror_link_set, 9688 (void *)&cmd_mirror_link_port, 9689 (void *)&cmd_mirror_link_portid, 9690 (void *)&cmd_mirror_link_mirror, 9691 (void *)&cmd_mirror_link_ruleid, 9692 (void *)&cmd_mirror_link_what, 9693 (void *)&cmd_mirror_link_dstpool, 9694 (void *)&cmd_mirror_link_poolid, 9695 (void *)&cmd_mirror_link_on, 9696 NULL, 9697 }, 9698 }; 9699 9700 /* *** RESET VM MIRROR RULE *** */ 9701 struct cmd_rm_mirror_rule_result { 9702 cmdline_fixed_string_t reset; 9703 cmdline_fixed_string_t port; 9704 portid_t port_id; 9705 cmdline_fixed_string_t mirror; 9706 uint8_t rule_id; 9707 }; 9708 9709 cmdline_parse_token_string_t cmd_rm_mirror_rule_reset = 9710 TOKEN_STRING_INITIALIZER(struct cmd_rm_mirror_rule_result, 9711 reset, "reset"); 9712 cmdline_parse_token_string_t cmd_rm_mirror_rule_port = 9713 TOKEN_STRING_INITIALIZER(struct cmd_rm_mirror_rule_result, 9714 port, "port"); 9715 cmdline_parse_token_num_t cmd_rm_mirror_rule_portid = 9716 TOKEN_NUM_INITIALIZER(struct cmd_rm_mirror_rule_result, 9717 port_id, UINT16); 9718 cmdline_parse_token_string_t cmd_rm_mirror_rule_mirror = 9719 TOKEN_STRING_INITIALIZER(struct cmd_rm_mirror_rule_result, 9720 mirror, "mirror-rule"); 9721 cmdline_parse_token_num_t cmd_rm_mirror_rule_ruleid = 9722 TOKEN_NUM_INITIALIZER(struct cmd_rm_mirror_rule_result, 9723 rule_id, UINT8); 9724 9725 static void 9726 cmd_reset_mirror_rule_parsed(void *parsed_result, 9727 __rte_unused struct cmdline *cl, 9728 __rte_unused void *data) 9729 { 9730 int ret; 9731 struct cmd_set_mirror_link_result *res = parsed_result; 9732 /* check rule_id */ 9733 ret = rte_eth_mirror_rule_reset(res->port_id,res->rule_id); 9734 if(ret < 0) 9735 printf("mirror rule remove error: (%s)\n", strerror(-ret)); 9736 } 9737 9738 cmdline_parse_inst_t cmd_reset_mirror_rule = { 9739 .f = cmd_reset_mirror_rule_parsed, 9740 .data = NULL, 9741 .help_str = "reset port <port_id> mirror-rule <rule_id>", 9742 .tokens = { 9743 (void *)&cmd_rm_mirror_rule_reset, 9744 (void *)&cmd_rm_mirror_rule_port, 9745 (void *)&cmd_rm_mirror_rule_portid, 9746 (void *)&cmd_rm_mirror_rule_mirror, 9747 (void *)&cmd_rm_mirror_rule_ruleid, 9748 NULL, 9749 }, 9750 }; 9751 9752 /* ******************************************************************************** */ 9753 9754 struct cmd_dump_result { 9755 cmdline_fixed_string_t dump; 9756 }; 9757 9758 static void 9759 dump_struct_sizes(void) 9760 { 9761 #define DUMP_SIZE(t) printf("sizeof(" #t ") = %u\n", (unsigned)sizeof(t)); 9762 DUMP_SIZE(struct rte_mbuf); 9763 DUMP_SIZE(struct rte_mempool); 9764 DUMP_SIZE(struct rte_ring); 9765 #undef DUMP_SIZE 9766 } 9767 9768 9769 /* Dump the socket memory statistics on console */ 9770 static void 9771 dump_socket_mem(FILE *f) 9772 { 9773 struct rte_malloc_socket_stats socket_stats; 9774 unsigned int i; 9775 size_t total = 0; 9776 size_t alloc = 0; 9777 size_t free = 0; 9778 unsigned int n_alloc = 0; 9779 unsigned int n_free = 0; 9780 static size_t last_allocs; 9781 static size_t last_total; 9782 9783 9784 for (i = 0; i < RTE_MAX_NUMA_NODES; i++) { 9785 if (rte_malloc_get_socket_stats(i, &socket_stats) || 9786 !socket_stats.heap_totalsz_bytes) 9787 continue; 9788 total += socket_stats.heap_totalsz_bytes; 9789 alloc += socket_stats.heap_allocsz_bytes; 9790 free += socket_stats.heap_freesz_bytes; 9791 n_alloc += socket_stats.alloc_count; 9792 n_free += socket_stats.free_count; 9793 fprintf(f, 9794 "Socket %u: size(M) total: %.6lf alloc: %.6lf(%.3lf%%) free: %.6lf \tcount alloc: %-4u free: %u\n", 9795 i, 9796 (double)socket_stats.heap_totalsz_bytes / (1024 * 1024), 9797 (double)socket_stats.heap_allocsz_bytes / (1024 * 1024), 9798 (double)socket_stats.heap_allocsz_bytes * 100 / 9799 (double)socket_stats.heap_totalsz_bytes, 9800 (double)socket_stats.heap_freesz_bytes / (1024 * 1024), 9801 socket_stats.alloc_count, 9802 socket_stats.free_count); 9803 } 9804 fprintf(f, 9805 "Total : size(M) total: %.6lf alloc: %.6lf(%.3lf%%) free: %.6lf \tcount alloc: %-4u free: %u\n", 9806 (double)total / (1024 * 1024), (double)alloc / (1024 * 1024), 9807 (double)alloc * 100 / (double)total, 9808 (double)free / (1024 * 1024), 9809 n_alloc, n_free); 9810 if (last_allocs) 9811 fprintf(stdout, "Memory total change: %.6lf(M), allocation change: %.6lf(M)\n", 9812 ((double)total - (double)last_total) / (1024 * 1024), 9813 (double)(alloc - (double)last_allocs) / 1024 / 1024); 9814 last_allocs = alloc; 9815 last_total = total; 9816 } 9817 9818 static void cmd_dump_parsed(void *parsed_result, 9819 __rte_unused struct cmdline *cl, 9820 __rte_unused void *data) 9821 { 9822 struct cmd_dump_result *res = parsed_result; 9823 9824 if (!strcmp(res->dump, "dump_physmem")) 9825 rte_dump_physmem_layout(stdout); 9826 else if (!strcmp(res->dump, "dump_socket_mem")) 9827 dump_socket_mem(stdout); 9828 else if (!strcmp(res->dump, "dump_memzone")) 9829 rte_memzone_dump(stdout); 9830 else if (!strcmp(res->dump, "dump_struct_sizes")) 9831 dump_struct_sizes(); 9832 else if (!strcmp(res->dump, "dump_ring")) 9833 rte_ring_list_dump(stdout); 9834 else if (!strcmp(res->dump, "dump_mempool")) 9835 rte_mempool_list_dump(stdout); 9836 else if (!strcmp(res->dump, "dump_devargs")) 9837 rte_devargs_dump(stdout); 9838 else if (!strcmp(res->dump, "dump_log_types")) 9839 rte_log_dump(stdout); 9840 } 9841 9842 cmdline_parse_token_string_t cmd_dump_dump = 9843 TOKEN_STRING_INITIALIZER(struct cmd_dump_result, dump, 9844 "dump_physmem#" 9845 "dump_memzone#" 9846 "dump_socket_mem#" 9847 "dump_struct_sizes#" 9848 "dump_ring#" 9849 "dump_mempool#" 9850 "dump_devargs#" 9851 "dump_log_types"); 9852 9853 cmdline_parse_inst_t cmd_dump = { 9854 .f = cmd_dump_parsed, /* function to call */ 9855 .data = NULL, /* 2nd arg of func */ 9856 .help_str = "Dump status", 9857 .tokens = { /* token list, NULL terminated */ 9858 (void *)&cmd_dump_dump, 9859 NULL, 9860 }, 9861 }; 9862 9863 /* ******************************************************************************** */ 9864 9865 struct cmd_dump_one_result { 9866 cmdline_fixed_string_t dump; 9867 cmdline_fixed_string_t name; 9868 }; 9869 9870 static void cmd_dump_one_parsed(void *parsed_result, struct cmdline *cl, 9871 __rte_unused void *data) 9872 { 9873 struct cmd_dump_one_result *res = parsed_result; 9874 9875 if (!strcmp(res->dump, "dump_ring")) { 9876 struct rte_ring *r; 9877 r = rte_ring_lookup(res->name); 9878 if (r == NULL) { 9879 cmdline_printf(cl, "Cannot find ring\n"); 9880 return; 9881 } 9882 rte_ring_dump(stdout, r); 9883 } else if (!strcmp(res->dump, "dump_mempool")) { 9884 struct rte_mempool *mp; 9885 mp = rte_mempool_lookup(res->name); 9886 if (mp == NULL) { 9887 cmdline_printf(cl, "Cannot find mempool\n"); 9888 return; 9889 } 9890 rte_mempool_dump(stdout, mp); 9891 } 9892 } 9893 9894 cmdline_parse_token_string_t cmd_dump_one_dump = 9895 TOKEN_STRING_INITIALIZER(struct cmd_dump_one_result, dump, 9896 "dump_ring#dump_mempool"); 9897 9898 cmdline_parse_token_string_t cmd_dump_one_name = 9899 TOKEN_STRING_INITIALIZER(struct cmd_dump_one_result, name, NULL); 9900 9901 cmdline_parse_inst_t cmd_dump_one = { 9902 .f = cmd_dump_one_parsed, /* function to call */ 9903 .data = NULL, /* 2nd arg of func */ 9904 .help_str = "dump_ring|dump_mempool <name>: Dump one ring/mempool", 9905 .tokens = { /* token list, NULL terminated */ 9906 (void *)&cmd_dump_one_dump, 9907 (void *)&cmd_dump_one_name, 9908 NULL, 9909 }, 9910 }; 9911 9912 /* *** Add/Del syn filter *** */ 9913 struct cmd_syn_filter_result { 9914 cmdline_fixed_string_t filter; 9915 portid_t port_id; 9916 cmdline_fixed_string_t ops; 9917 cmdline_fixed_string_t priority; 9918 cmdline_fixed_string_t high; 9919 cmdline_fixed_string_t queue; 9920 uint16_t queue_id; 9921 }; 9922 9923 static void 9924 cmd_syn_filter_parsed(void *parsed_result, 9925 __rte_unused struct cmdline *cl, 9926 __rte_unused void *data) 9927 { 9928 struct cmd_syn_filter_result *res = parsed_result; 9929 struct rte_eth_syn_filter syn_filter; 9930 int ret = 0; 9931 9932 ret = rte_eth_dev_filter_supported(res->port_id, 9933 RTE_ETH_FILTER_SYN); 9934 if (ret < 0) { 9935 printf("syn filter is not supported on port %u.\n", 9936 res->port_id); 9937 return; 9938 } 9939 9940 memset(&syn_filter, 0, sizeof(syn_filter)); 9941 9942 if (!strcmp(res->ops, "add")) { 9943 if (!strcmp(res->high, "high")) 9944 syn_filter.hig_pri = 1; 9945 else 9946 syn_filter.hig_pri = 0; 9947 9948 syn_filter.queue = res->queue_id; 9949 ret = rte_eth_dev_filter_ctrl(res->port_id, 9950 RTE_ETH_FILTER_SYN, 9951 RTE_ETH_FILTER_ADD, 9952 &syn_filter); 9953 } else 9954 ret = rte_eth_dev_filter_ctrl(res->port_id, 9955 RTE_ETH_FILTER_SYN, 9956 RTE_ETH_FILTER_DELETE, 9957 &syn_filter); 9958 9959 if (ret < 0) 9960 printf("syn filter programming error: (%s)\n", 9961 strerror(-ret)); 9962 } 9963 9964 cmdline_parse_token_string_t cmd_syn_filter_filter = 9965 TOKEN_STRING_INITIALIZER(struct cmd_syn_filter_result, 9966 filter, "syn_filter"); 9967 cmdline_parse_token_num_t cmd_syn_filter_port_id = 9968 TOKEN_NUM_INITIALIZER(struct cmd_syn_filter_result, 9969 port_id, UINT16); 9970 cmdline_parse_token_string_t cmd_syn_filter_ops = 9971 TOKEN_STRING_INITIALIZER(struct cmd_syn_filter_result, 9972 ops, "add#del"); 9973 cmdline_parse_token_string_t cmd_syn_filter_priority = 9974 TOKEN_STRING_INITIALIZER(struct cmd_syn_filter_result, 9975 priority, "priority"); 9976 cmdline_parse_token_string_t cmd_syn_filter_high = 9977 TOKEN_STRING_INITIALIZER(struct cmd_syn_filter_result, 9978 high, "high#low"); 9979 cmdline_parse_token_string_t cmd_syn_filter_queue = 9980 TOKEN_STRING_INITIALIZER(struct cmd_syn_filter_result, 9981 queue, "queue"); 9982 cmdline_parse_token_num_t cmd_syn_filter_queue_id = 9983 TOKEN_NUM_INITIALIZER(struct cmd_syn_filter_result, 9984 queue_id, UINT16); 9985 9986 cmdline_parse_inst_t cmd_syn_filter = { 9987 .f = cmd_syn_filter_parsed, 9988 .data = NULL, 9989 .help_str = "syn_filter <port_id> add|del priority high|low queue " 9990 "<queue_id>: Add/Delete syn filter", 9991 .tokens = { 9992 (void *)&cmd_syn_filter_filter, 9993 (void *)&cmd_syn_filter_port_id, 9994 (void *)&cmd_syn_filter_ops, 9995 (void *)&cmd_syn_filter_priority, 9996 (void *)&cmd_syn_filter_high, 9997 (void *)&cmd_syn_filter_queue, 9998 (void *)&cmd_syn_filter_queue_id, 9999 NULL, 10000 }, 10001 }; 10002 10003 /* *** queue region set *** */ 10004 struct cmd_queue_region_result { 10005 cmdline_fixed_string_t set; 10006 cmdline_fixed_string_t port; 10007 portid_t port_id; 10008 cmdline_fixed_string_t cmd; 10009 cmdline_fixed_string_t region; 10010 uint8_t region_id; 10011 cmdline_fixed_string_t queue_start_index; 10012 uint8_t queue_id; 10013 cmdline_fixed_string_t queue_num; 10014 uint8_t queue_num_value; 10015 }; 10016 10017 static void 10018 cmd_queue_region_parsed(void *parsed_result, 10019 __rte_unused struct cmdline *cl, 10020 __rte_unused void *data) 10021 { 10022 struct cmd_queue_region_result *res = parsed_result; 10023 int ret = -ENOTSUP; 10024 #ifdef RTE_LIBRTE_I40E_PMD 10025 struct rte_pmd_i40e_queue_region_conf region_conf; 10026 enum rte_pmd_i40e_queue_region_op op_type; 10027 #endif 10028 10029 if (port_id_is_invalid(res->port_id, ENABLED_WARN)) 10030 return; 10031 10032 #ifdef RTE_LIBRTE_I40E_PMD 10033 memset(®ion_conf, 0, sizeof(region_conf)); 10034 op_type = RTE_PMD_I40E_RSS_QUEUE_REGION_SET; 10035 region_conf.region_id = res->region_id; 10036 region_conf.queue_num = res->queue_num_value; 10037 region_conf.queue_start_index = res->queue_id; 10038 10039 ret = rte_pmd_i40e_rss_queue_region_conf(res->port_id, 10040 op_type, ®ion_conf); 10041 #endif 10042 10043 switch (ret) { 10044 case 0: 10045 break; 10046 case -ENOTSUP: 10047 printf("function not implemented or supported\n"); 10048 break; 10049 default: 10050 printf("queue region config error: (%s)\n", strerror(-ret)); 10051 } 10052 } 10053 10054 cmdline_parse_token_string_t cmd_queue_region_set = 10055 TOKEN_STRING_INITIALIZER(struct cmd_queue_region_result, 10056 set, "set"); 10057 cmdline_parse_token_string_t cmd_queue_region_port = 10058 TOKEN_STRING_INITIALIZER(struct cmd_queue_region_result, port, "port"); 10059 cmdline_parse_token_num_t cmd_queue_region_port_id = 10060 TOKEN_NUM_INITIALIZER(struct cmd_queue_region_result, 10061 port_id, UINT16); 10062 cmdline_parse_token_string_t cmd_queue_region_cmd = 10063 TOKEN_STRING_INITIALIZER(struct cmd_queue_region_result, 10064 cmd, "queue-region"); 10065 cmdline_parse_token_string_t cmd_queue_region_id = 10066 TOKEN_STRING_INITIALIZER(struct cmd_queue_region_result, 10067 region, "region_id"); 10068 cmdline_parse_token_num_t cmd_queue_region_index = 10069 TOKEN_NUM_INITIALIZER(struct cmd_queue_region_result, 10070 region_id, UINT8); 10071 cmdline_parse_token_string_t cmd_queue_region_queue_start_index = 10072 TOKEN_STRING_INITIALIZER(struct cmd_queue_region_result, 10073 queue_start_index, "queue_start_index"); 10074 cmdline_parse_token_num_t cmd_queue_region_queue_id = 10075 TOKEN_NUM_INITIALIZER(struct cmd_queue_region_result, 10076 queue_id, UINT8); 10077 cmdline_parse_token_string_t cmd_queue_region_queue_num = 10078 TOKEN_STRING_INITIALIZER(struct cmd_queue_region_result, 10079 queue_num, "queue_num"); 10080 cmdline_parse_token_num_t cmd_queue_region_queue_num_value = 10081 TOKEN_NUM_INITIALIZER(struct cmd_queue_region_result, 10082 queue_num_value, UINT8); 10083 10084 cmdline_parse_inst_t cmd_queue_region = { 10085 .f = cmd_queue_region_parsed, 10086 .data = NULL, 10087 .help_str = "set port <port_id> queue-region region_id <value> " 10088 "queue_start_index <value> queue_num <value>: Set a queue region", 10089 .tokens = { 10090 (void *)&cmd_queue_region_set, 10091 (void *)&cmd_queue_region_port, 10092 (void *)&cmd_queue_region_port_id, 10093 (void *)&cmd_queue_region_cmd, 10094 (void *)&cmd_queue_region_id, 10095 (void *)&cmd_queue_region_index, 10096 (void *)&cmd_queue_region_queue_start_index, 10097 (void *)&cmd_queue_region_queue_id, 10098 (void *)&cmd_queue_region_queue_num, 10099 (void *)&cmd_queue_region_queue_num_value, 10100 NULL, 10101 }, 10102 }; 10103 10104 /* *** queue region and flowtype set *** */ 10105 struct cmd_region_flowtype_result { 10106 cmdline_fixed_string_t set; 10107 cmdline_fixed_string_t port; 10108 portid_t port_id; 10109 cmdline_fixed_string_t cmd; 10110 cmdline_fixed_string_t region; 10111 uint8_t region_id; 10112 cmdline_fixed_string_t flowtype; 10113 uint8_t flowtype_id; 10114 }; 10115 10116 static void 10117 cmd_region_flowtype_parsed(void *parsed_result, 10118 __rte_unused struct cmdline *cl, 10119 __rte_unused void *data) 10120 { 10121 struct cmd_region_flowtype_result *res = parsed_result; 10122 int ret = -ENOTSUP; 10123 #ifdef RTE_LIBRTE_I40E_PMD 10124 struct rte_pmd_i40e_queue_region_conf region_conf; 10125 enum rte_pmd_i40e_queue_region_op op_type; 10126 #endif 10127 10128 if (port_id_is_invalid(res->port_id, ENABLED_WARN)) 10129 return; 10130 10131 #ifdef RTE_LIBRTE_I40E_PMD 10132 memset(®ion_conf, 0, sizeof(region_conf)); 10133 10134 op_type = RTE_PMD_I40E_RSS_QUEUE_REGION_FLOWTYPE_SET; 10135 region_conf.region_id = res->region_id; 10136 region_conf.hw_flowtype = res->flowtype_id; 10137 10138 ret = rte_pmd_i40e_rss_queue_region_conf(res->port_id, 10139 op_type, ®ion_conf); 10140 #endif 10141 10142 switch (ret) { 10143 case 0: 10144 break; 10145 case -ENOTSUP: 10146 printf("function not implemented or supported\n"); 10147 break; 10148 default: 10149 printf("region flowtype config error: (%s)\n", strerror(-ret)); 10150 } 10151 } 10152 10153 cmdline_parse_token_string_t cmd_region_flowtype_set = 10154 TOKEN_STRING_INITIALIZER(struct cmd_region_flowtype_result, 10155 set, "set"); 10156 cmdline_parse_token_string_t cmd_region_flowtype_port = 10157 TOKEN_STRING_INITIALIZER(struct cmd_region_flowtype_result, 10158 port, "port"); 10159 cmdline_parse_token_num_t cmd_region_flowtype_port_index = 10160 TOKEN_NUM_INITIALIZER(struct cmd_region_flowtype_result, 10161 port_id, UINT16); 10162 cmdline_parse_token_string_t cmd_region_flowtype_cmd = 10163 TOKEN_STRING_INITIALIZER(struct cmd_region_flowtype_result, 10164 cmd, "queue-region"); 10165 cmdline_parse_token_string_t cmd_region_flowtype_index = 10166 TOKEN_STRING_INITIALIZER(struct cmd_region_flowtype_result, 10167 region, "region_id"); 10168 cmdline_parse_token_num_t cmd_region_flowtype_id = 10169 TOKEN_NUM_INITIALIZER(struct cmd_region_flowtype_result, 10170 region_id, UINT8); 10171 cmdline_parse_token_string_t cmd_region_flowtype_flow_index = 10172 TOKEN_STRING_INITIALIZER(struct cmd_region_flowtype_result, 10173 flowtype, "flowtype"); 10174 cmdline_parse_token_num_t cmd_region_flowtype_flow_id = 10175 TOKEN_NUM_INITIALIZER(struct cmd_region_flowtype_result, 10176 flowtype_id, UINT8); 10177 cmdline_parse_inst_t cmd_region_flowtype = { 10178 .f = cmd_region_flowtype_parsed, 10179 .data = NULL, 10180 .help_str = "set port <port_id> queue-region region_id <value> " 10181 "flowtype <value>: Set a flowtype region index", 10182 .tokens = { 10183 (void *)&cmd_region_flowtype_set, 10184 (void *)&cmd_region_flowtype_port, 10185 (void *)&cmd_region_flowtype_port_index, 10186 (void *)&cmd_region_flowtype_cmd, 10187 (void *)&cmd_region_flowtype_index, 10188 (void *)&cmd_region_flowtype_id, 10189 (void *)&cmd_region_flowtype_flow_index, 10190 (void *)&cmd_region_flowtype_flow_id, 10191 NULL, 10192 }, 10193 }; 10194 10195 /* *** User Priority (UP) to queue region (region_id) set *** */ 10196 struct cmd_user_priority_region_result { 10197 cmdline_fixed_string_t set; 10198 cmdline_fixed_string_t port; 10199 portid_t port_id; 10200 cmdline_fixed_string_t cmd; 10201 cmdline_fixed_string_t user_priority; 10202 uint8_t user_priority_id; 10203 cmdline_fixed_string_t region; 10204 uint8_t region_id; 10205 }; 10206 10207 static void 10208 cmd_user_priority_region_parsed(void *parsed_result, 10209 __rte_unused struct cmdline *cl, 10210 __rte_unused void *data) 10211 { 10212 struct cmd_user_priority_region_result *res = parsed_result; 10213 int ret = -ENOTSUP; 10214 #ifdef RTE_LIBRTE_I40E_PMD 10215 struct rte_pmd_i40e_queue_region_conf region_conf; 10216 enum rte_pmd_i40e_queue_region_op op_type; 10217 #endif 10218 10219 if (port_id_is_invalid(res->port_id, ENABLED_WARN)) 10220 return; 10221 10222 #ifdef RTE_LIBRTE_I40E_PMD 10223 memset(®ion_conf, 0, sizeof(region_conf)); 10224 op_type = RTE_PMD_I40E_RSS_QUEUE_REGION_USER_PRIORITY_SET; 10225 region_conf.user_priority = res->user_priority_id; 10226 region_conf.region_id = res->region_id; 10227 10228 ret = rte_pmd_i40e_rss_queue_region_conf(res->port_id, 10229 op_type, ®ion_conf); 10230 #endif 10231 10232 switch (ret) { 10233 case 0: 10234 break; 10235 case -ENOTSUP: 10236 printf("function not implemented or supported\n"); 10237 break; 10238 default: 10239 printf("user_priority region config error: (%s)\n", 10240 strerror(-ret)); 10241 } 10242 } 10243 10244 cmdline_parse_token_string_t cmd_user_priority_region_set = 10245 TOKEN_STRING_INITIALIZER(struct cmd_user_priority_region_result, 10246 set, "set"); 10247 cmdline_parse_token_string_t cmd_user_priority_region_port = 10248 TOKEN_STRING_INITIALIZER(struct cmd_user_priority_region_result, 10249 port, "port"); 10250 cmdline_parse_token_num_t cmd_user_priority_region_port_index = 10251 TOKEN_NUM_INITIALIZER(struct cmd_user_priority_region_result, 10252 port_id, UINT16); 10253 cmdline_parse_token_string_t cmd_user_priority_region_cmd = 10254 TOKEN_STRING_INITIALIZER(struct cmd_user_priority_region_result, 10255 cmd, "queue-region"); 10256 cmdline_parse_token_string_t cmd_user_priority_region_UP = 10257 TOKEN_STRING_INITIALIZER(struct cmd_user_priority_region_result, 10258 user_priority, "UP"); 10259 cmdline_parse_token_num_t cmd_user_priority_region_UP_id = 10260 TOKEN_NUM_INITIALIZER(struct cmd_user_priority_region_result, 10261 user_priority_id, UINT8); 10262 cmdline_parse_token_string_t cmd_user_priority_region_region = 10263 TOKEN_STRING_INITIALIZER(struct cmd_user_priority_region_result, 10264 region, "region_id"); 10265 cmdline_parse_token_num_t cmd_user_priority_region_region_id = 10266 TOKEN_NUM_INITIALIZER(struct cmd_user_priority_region_result, 10267 region_id, UINT8); 10268 10269 cmdline_parse_inst_t cmd_user_priority_region = { 10270 .f = cmd_user_priority_region_parsed, 10271 .data = NULL, 10272 .help_str = "set port <port_id> queue-region UP <value> " 10273 "region_id <value>: Set the mapping of User Priority (UP) " 10274 "to queue region (region_id) ", 10275 .tokens = { 10276 (void *)&cmd_user_priority_region_set, 10277 (void *)&cmd_user_priority_region_port, 10278 (void *)&cmd_user_priority_region_port_index, 10279 (void *)&cmd_user_priority_region_cmd, 10280 (void *)&cmd_user_priority_region_UP, 10281 (void *)&cmd_user_priority_region_UP_id, 10282 (void *)&cmd_user_priority_region_region, 10283 (void *)&cmd_user_priority_region_region_id, 10284 NULL, 10285 }, 10286 }; 10287 10288 /* *** flush all queue region related configuration *** */ 10289 struct cmd_flush_queue_region_result { 10290 cmdline_fixed_string_t set; 10291 cmdline_fixed_string_t port; 10292 portid_t port_id; 10293 cmdline_fixed_string_t cmd; 10294 cmdline_fixed_string_t flush; 10295 cmdline_fixed_string_t what; 10296 }; 10297 10298 static void 10299 cmd_flush_queue_region_parsed(void *parsed_result, 10300 __rte_unused struct cmdline *cl, 10301 __rte_unused void *data) 10302 { 10303 struct cmd_flush_queue_region_result *res = parsed_result; 10304 int ret = -ENOTSUP; 10305 #ifdef RTE_LIBRTE_I40E_PMD 10306 struct rte_pmd_i40e_queue_region_conf region_conf; 10307 enum rte_pmd_i40e_queue_region_op op_type; 10308 #endif 10309 10310 if (port_id_is_invalid(res->port_id, ENABLED_WARN)) 10311 return; 10312 10313 #ifdef RTE_LIBRTE_I40E_PMD 10314 memset(®ion_conf, 0, sizeof(region_conf)); 10315 10316 if (strcmp(res->what, "on") == 0) 10317 op_type = RTE_PMD_I40E_RSS_QUEUE_REGION_ALL_FLUSH_ON; 10318 else 10319 op_type = RTE_PMD_I40E_RSS_QUEUE_REGION_ALL_FLUSH_OFF; 10320 10321 ret = rte_pmd_i40e_rss_queue_region_conf(res->port_id, 10322 op_type, ®ion_conf); 10323 #endif 10324 10325 switch (ret) { 10326 case 0: 10327 break; 10328 case -ENOTSUP: 10329 printf("function not implemented or supported\n"); 10330 break; 10331 default: 10332 printf("queue region config flush error: (%s)\n", 10333 strerror(-ret)); 10334 } 10335 } 10336 10337 cmdline_parse_token_string_t cmd_flush_queue_region_set = 10338 TOKEN_STRING_INITIALIZER(struct cmd_flush_queue_region_result, 10339 set, "set"); 10340 cmdline_parse_token_string_t cmd_flush_queue_region_port = 10341 TOKEN_STRING_INITIALIZER(struct cmd_flush_queue_region_result, 10342 port, "port"); 10343 cmdline_parse_token_num_t cmd_flush_queue_region_port_index = 10344 TOKEN_NUM_INITIALIZER(struct cmd_flush_queue_region_result, 10345 port_id, UINT16); 10346 cmdline_parse_token_string_t cmd_flush_queue_region_cmd = 10347 TOKEN_STRING_INITIALIZER(struct cmd_flush_queue_region_result, 10348 cmd, "queue-region"); 10349 cmdline_parse_token_string_t cmd_flush_queue_region_flush = 10350 TOKEN_STRING_INITIALIZER(struct cmd_flush_queue_region_result, 10351 flush, "flush"); 10352 cmdline_parse_token_string_t cmd_flush_queue_region_what = 10353 TOKEN_STRING_INITIALIZER(struct cmd_flush_queue_region_result, 10354 what, "on#off"); 10355 10356 cmdline_parse_inst_t cmd_flush_queue_region = { 10357 .f = cmd_flush_queue_region_parsed, 10358 .data = NULL, 10359 .help_str = "set port <port_id> queue-region flush on|off" 10360 ": flush all queue region related configuration", 10361 .tokens = { 10362 (void *)&cmd_flush_queue_region_set, 10363 (void *)&cmd_flush_queue_region_port, 10364 (void *)&cmd_flush_queue_region_port_index, 10365 (void *)&cmd_flush_queue_region_cmd, 10366 (void *)&cmd_flush_queue_region_flush, 10367 (void *)&cmd_flush_queue_region_what, 10368 NULL, 10369 }, 10370 }; 10371 10372 /* *** get all queue region related configuration info *** */ 10373 struct cmd_show_queue_region_info { 10374 cmdline_fixed_string_t show; 10375 cmdline_fixed_string_t port; 10376 portid_t port_id; 10377 cmdline_fixed_string_t cmd; 10378 }; 10379 10380 static void 10381 cmd_show_queue_region_info_parsed(void *parsed_result, 10382 __rte_unused struct cmdline *cl, 10383 __rte_unused void *data) 10384 { 10385 struct cmd_show_queue_region_info *res = parsed_result; 10386 int ret = -ENOTSUP; 10387 #ifdef RTE_LIBRTE_I40E_PMD 10388 struct rte_pmd_i40e_queue_regions rte_pmd_regions; 10389 enum rte_pmd_i40e_queue_region_op op_type; 10390 #endif 10391 10392 if (port_id_is_invalid(res->port_id, ENABLED_WARN)) 10393 return; 10394 10395 #ifdef RTE_LIBRTE_I40E_PMD 10396 memset(&rte_pmd_regions, 0, sizeof(rte_pmd_regions)); 10397 10398 op_type = RTE_PMD_I40E_RSS_QUEUE_REGION_INFO_GET; 10399 10400 ret = rte_pmd_i40e_rss_queue_region_conf(res->port_id, 10401 op_type, &rte_pmd_regions); 10402 10403 port_queue_region_info_display(res->port_id, &rte_pmd_regions); 10404 #endif 10405 10406 switch (ret) { 10407 case 0: 10408 break; 10409 case -ENOTSUP: 10410 printf("function not implemented or supported\n"); 10411 break; 10412 default: 10413 printf("queue region config info show error: (%s)\n", 10414 strerror(-ret)); 10415 } 10416 } 10417 10418 cmdline_parse_token_string_t cmd_show_queue_region_info_get = 10419 TOKEN_STRING_INITIALIZER(struct cmd_show_queue_region_info, 10420 show, "show"); 10421 cmdline_parse_token_string_t cmd_show_queue_region_info_port = 10422 TOKEN_STRING_INITIALIZER(struct cmd_show_queue_region_info, 10423 port, "port"); 10424 cmdline_parse_token_num_t cmd_show_queue_region_info_port_index = 10425 TOKEN_NUM_INITIALIZER(struct cmd_show_queue_region_info, 10426 port_id, UINT16); 10427 cmdline_parse_token_string_t cmd_show_queue_region_info_cmd = 10428 TOKEN_STRING_INITIALIZER(struct cmd_show_queue_region_info, 10429 cmd, "queue-region"); 10430 10431 cmdline_parse_inst_t cmd_show_queue_region_info_all = { 10432 .f = cmd_show_queue_region_info_parsed, 10433 .data = NULL, 10434 .help_str = "show port <port_id> queue-region" 10435 ": show all queue region related configuration info", 10436 .tokens = { 10437 (void *)&cmd_show_queue_region_info_get, 10438 (void *)&cmd_show_queue_region_info_port, 10439 (void *)&cmd_show_queue_region_info_port_index, 10440 (void *)&cmd_show_queue_region_info_cmd, 10441 NULL, 10442 }, 10443 }; 10444 10445 /* *** ADD/REMOVE A 2tuple FILTER *** */ 10446 struct cmd_2tuple_filter_result { 10447 cmdline_fixed_string_t filter; 10448 portid_t port_id; 10449 cmdline_fixed_string_t ops; 10450 cmdline_fixed_string_t dst_port; 10451 uint16_t dst_port_value; 10452 cmdline_fixed_string_t protocol; 10453 uint8_t protocol_value; 10454 cmdline_fixed_string_t mask; 10455 uint8_t mask_value; 10456 cmdline_fixed_string_t tcp_flags; 10457 uint8_t tcp_flags_value; 10458 cmdline_fixed_string_t priority; 10459 uint8_t priority_value; 10460 cmdline_fixed_string_t queue; 10461 uint16_t queue_id; 10462 }; 10463 10464 static void 10465 cmd_2tuple_filter_parsed(void *parsed_result, 10466 __rte_unused struct cmdline *cl, 10467 __rte_unused void *data) 10468 { 10469 struct rte_eth_ntuple_filter filter; 10470 struct cmd_2tuple_filter_result *res = parsed_result; 10471 int ret = 0; 10472 10473 ret = rte_eth_dev_filter_supported(res->port_id, RTE_ETH_FILTER_NTUPLE); 10474 if (ret < 0) { 10475 printf("ntuple filter is not supported on port %u.\n", 10476 res->port_id); 10477 return; 10478 } 10479 10480 memset(&filter, 0, sizeof(struct rte_eth_ntuple_filter)); 10481 10482 filter.flags = RTE_2TUPLE_FLAGS; 10483 filter.dst_port_mask = (res->mask_value & 0x02) ? UINT16_MAX : 0; 10484 filter.proto_mask = (res->mask_value & 0x01) ? UINT8_MAX : 0; 10485 filter.proto = res->protocol_value; 10486 filter.priority = res->priority_value; 10487 if (res->tcp_flags_value != 0 && filter.proto != IPPROTO_TCP) { 10488 printf("nonzero tcp_flags is only meaningful" 10489 " when protocol is TCP.\n"); 10490 return; 10491 } 10492 if (res->tcp_flags_value > RTE_NTUPLE_TCP_FLAGS_MASK) { 10493 printf("invalid TCP flags.\n"); 10494 return; 10495 } 10496 10497 if (res->tcp_flags_value != 0) { 10498 filter.flags |= RTE_NTUPLE_FLAGS_TCP_FLAG; 10499 filter.tcp_flags = res->tcp_flags_value; 10500 } 10501 10502 /* need convert to big endian. */ 10503 filter.dst_port = rte_cpu_to_be_16(res->dst_port_value); 10504 filter.queue = res->queue_id; 10505 10506 if (!strcmp(res->ops, "add")) 10507 ret = rte_eth_dev_filter_ctrl(res->port_id, 10508 RTE_ETH_FILTER_NTUPLE, 10509 RTE_ETH_FILTER_ADD, 10510 &filter); 10511 else 10512 ret = rte_eth_dev_filter_ctrl(res->port_id, 10513 RTE_ETH_FILTER_NTUPLE, 10514 RTE_ETH_FILTER_DELETE, 10515 &filter); 10516 if (ret < 0) 10517 printf("2tuple filter programming error: (%s)\n", 10518 strerror(-ret)); 10519 10520 } 10521 10522 cmdline_parse_token_string_t cmd_2tuple_filter_filter = 10523 TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result, 10524 filter, "2tuple_filter"); 10525 cmdline_parse_token_num_t cmd_2tuple_filter_port_id = 10526 TOKEN_NUM_INITIALIZER(struct cmd_2tuple_filter_result, 10527 port_id, UINT16); 10528 cmdline_parse_token_string_t cmd_2tuple_filter_ops = 10529 TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result, 10530 ops, "add#del"); 10531 cmdline_parse_token_string_t cmd_2tuple_filter_dst_port = 10532 TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result, 10533 dst_port, "dst_port"); 10534 cmdline_parse_token_num_t cmd_2tuple_filter_dst_port_value = 10535 TOKEN_NUM_INITIALIZER(struct cmd_2tuple_filter_result, 10536 dst_port_value, UINT16); 10537 cmdline_parse_token_string_t cmd_2tuple_filter_protocol = 10538 TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result, 10539 protocol, "protocol"); 10540 cmdline_parse_token_num_t cmd_2tuple_filter_protocol_value = 10541 TOKEN_NUM_INITIALIZER(struct cmd_2tuple_filter_result, 10542 protocol_value, UINT8); 10543 cmdline_parse_token_string_t cmd_2tuple_filter_mask = 10544 TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result, 10545 mask, "mask"); 10546 cmdline_parse_token_num_t cmd_2tuple_filter_mask_value = 10547 TOKEN_NUM_INITIALIZER(struct cmd_2tuple_filter_result, 10548 mask_value, INT8); 10549 cmdline_parse_token_string_t cmd_2tuple_filter_tcp_flags = 10550 TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result, 10551 tcp_flags, "tcp_flags"); 10552 cmdline_parse_token_num_t cmd_2tuple_filter_tcp_flags_value = 10553 TOKEN_NUM_INITIALIZER(struct cmd_2tuple_filter_result, 10554 tcp_flags_value, UINT8); 10555 cmdline_parse_token_string_t cmd_2tuple_filter_priority = 10556 TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result, 10557 priority, "priority"); 10558 cmdline_parse_token_num_t cmd_2tuple_filter_priority_value = 10559 TOKEN_NUM_INITIALIZER(struct cmd_2tuple_filter_result, 10560 priority_value, UINT8); 10561 cmdline_parse_token_string_t cmd_2tuple_filter_queue = 10562 TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result, 10563 queue, "queue"); 10564 cmdline_parse_token_num_t cmd_2tuple_filter_queue_id = 10565 TOKEN_NUM_INITIALIZER(struct cmd_2tuple_filter_result, 10566 queue_id, UINT16); 10567 10568 cmdline_parse_inst_t cmd_2tuple_filter = { 10569 .f = cmd_2tuple_filter_parsed, 10570 .data = NULL, 10571 .help_str = "2tuple_filter <port_id> add|del dst_port <value> protocol " 10572 "<value> mask <value> tcp_flags <value> priority <value> queue " 10573 "<queue_id>: Add a 2tuple filter", 10574 .tokens = { 10575 (void *)&cmd_2tuple_filter_filter, 10576 (void *)&cmd_2tuple_filter_port_id, 10577 (void *)&cmd_2tuple_filter_ops, 10578 (void *)&cmd_2tuple_filter_dst_port, 10579 (void *)&cmd_2tuple_filter_dst_port_value, 10580 (void *)&cmd_2tuple_filter_protocol, 10581 (void *)&cmd_2tuple_filter_protocol_value, 10582 (void *)&cmd_2tuple_filter_mask, 10583 (void *)&cmd_2tuple_filter_mask_value, 10584 (void *)&cmd_2tuple_filter_tcp_flags, 10585 (void *)&cmd_2tuple_filter_tcp_flags_value, 10586 (void *)&cmd_2tuple_filter_priority, 10587 (void *)&cmd_2tuple_filter_priority_value, 10588 (void *)&cmd_2tuple_filter_queue, 10589 (void *)&cmd_2tuple_filter_queue_id, 10590 NULL, 10591 }, 10592 }; 10593 10594 /* *** ADD/REMOVE A 5tuple FILTER *** */ 10595 struct cmd_5tuple_filter_result { 10596 cmdline_fixed_string_t filter; 10597 portid_t port_id; 10598 cmdline_fixed_string_t ops; 10599 cmdline_fixed_string_t dst_ip; 10600 cmdline_ipaddr_t dst_ip_value; 10601 cmdline_fixed_string_t src_ip; 10602 cmdline_ipaddr_t src_ip_value; 10603 cmdline_fixed_string_t dst_port; 10604 uint16_t dst_port_value; 10605 cmdline_fixed_string_t src_port; 10606 uint16_t src_port_value; 10607 cmdline_fixed_string_t protocol; 10608 uint8_t protocol_value; 10609 cmdline_fixed_string_t mask; 10610 uint8_t mask_value; 10611 cmdline_fixed_string_t tcp_flags; 10612 uint8_t tcp_flags_value; 10613 cmdline_fixed_string_t priority; 10614 uint8_t priority_value; 10615 cmdline_fixed_string_t queue; 10616 uint16_t queue_id; 10617 }; 10618 10619 static void 10620 cmd_5tuple_filter_parsed(void *parsed_result, 10621 __rte_unused struct cmdline *cl, 10622 __rte_unused void *data) 10623 { 10624 struct rte_eth_ntuple_filter filter; 10625 struct cmd_5tuple_filter_result *res = parsed_result; 10626 int ret = 0; 10627 10628 ret = rte_eth_dev_filter_supported(res->port_id, RTE_ETH_FILTER_NTUPLE); 10629 if (ret < 0) { 10630 printf("ntuple filter is not supported on port %u.\n", 10631 res->port_id); 10632 return; 10633 } 10634 10635 memset(&filter, 0, sizeof(struct rte_eth_ntuple_filter)); 10636 10637 filter.flags = RTE_5TUPLE_FLAGS; 10638 filter.dst_ip_mask = (res->mask_value & 0x10) ? UINT32_MAX : 0; 10639 filter.src_ip_mask = (res->mask_value & 0x08) ? UINT32_MAX : 0; 10640 filter.dst_port_mask = (res->mask_value & 0x04) ? UINT16_MAX : 0; 10641 filter.src_port_mask = (res->mask_value & 0x02) ? UINT16_MAX : 0; 10642 filter.proto_mask = (res->mask_value & 0x01) ? UINT8_MAX : 0; 10643 filter.proto = res->protocol_value; 10644 filter.priority = res->priority_value; 10645 if (res->tcp_flags_value != 0 && filter.proto != IPPROTO_TCP) { 10646 printf("nonzero tcp_flags is only meaningful" 10647 " when protocol is TCP.\n"); 10648 return; 10649 } 10650 if (res->tcp_flags_value > RTE_NTUPLE_TCP_FLAGS_MASK) { 10651 printf("invalid TCP flags.\n"); 10652 return; 10653 } 10654 10655 if (res->tcp_flags_value != 0) { 10656 filter.flags |= RTE_NTUPLE_FLAGS_TCP_FLAG; 10657 filter.tcp_flags = res->tcp_flags_value; 10658 } 10659 10660 if (res->dst_ip_value.family == AF_INET) 10661 /* no need to convert, already big endian. */ 10662 filter.dst_ip = res->dst_ip_value.addr.ipv4.s_addr; 10663 else { 10664 if (filter.dst_ip_mask == 0) { 10665 printf("can not support ipv6 involved compare.\n"); 10666 return; 10667 } 10668 filter.dst_ip = 0; 10669 } 10670 10671 if (res->src_ip_value.family == AF_INET) 10672 /* no need to convert, already big endian. */ 10673 filter.src_ip = res->src_ip_value.addr.ipv4.s_addr; 10674 else { 10675 if (filter.src_ip_mask == 0) { 10676 printf("can not support ipv6 involved compare.\n"); 10677 return; 10678 } 10679 filter.src_ip = 0; 10680 } 10681 /* need convert to big endian. */ 10682 filter.dst_port = rte_cpu_to_be_16(res->dst_port_value); 10683 filter.src_port = rte_cpu_to_be_16(res->src_port_value); 10684 filter.queue = res->queue_id; 10685 10686 if (!strcmp(res->ops, "add")) 10687 ret = rte_eth_dev_filter_ctrl(res->port_id, 10688 RTE_ETH_FILTER_NTUPLE, 10689 RTE_ETH_FILTER_ADD, 10690 &filter); 10691 else 10692 ret = rte_eth_dev_filter_ctrl(res->port_id, 10693 RTE_ETH_FILTER_NTUPLE, 10694 RTE_ETH_FILTER_DELETE, 10695 &filter); 10696 if (ret < 0) 10697 printf("5tuple filter programming error: (%s)\n", 10698 strerror(-ret)); 10699 } 10700 10701 cmdline_parse_token_string_t cmd_5tuple_filter_filter = 10702 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result, 10703 filter, "5tuple_filter"); 10704 cmdline_parse_token_num_t cmd_5tuple_filter_port_id = 10705 TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result, 10706 port_id, UINT16); 10707 cmdline_parse_token_string_t cmd_5tuple_filter_ops = 10708 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result, 10709 ops, "add#del"); 10710 cmdline_parse_token_string_t cmd_5tuple_filter_dst_ip = 10711 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result, 10712 dst_ip, "dst_ip"); 10713 cmdline_parse_token_ipaddr_t cmd_5tuple_filter_dst_ip_value = 10714 TOKEN_IPADDR_INITIALIZER(struct cmd_5tuple_filter_result, 10715 dst_ip_value); 10716 cmdline_parse_token_string_t cmd_5tuple_filter_src_ip = 10717 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result, 10718 src_ip, "src_ip"); 10719 cmdline_parse_token_ipaddr_t cmd_5tuple_filter_src_ip_value = 10720 TOKEN_IPADDR_INITIALIZER(struct cmd_5tuple_filter_result, 10721 src_ip_value); 10722 cmdline_parse_token_string_t cmd_5tuple_filter_dst_port = 10723 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result, 10724 dst_port, "dst_port"); 10725 cmdline_parse_token_num_t cmd_5tuple_filter_dst_port_value = 10726 TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result, 10727 dst_port_value, UINT16); 10728 cmdline_parse_token_string_t cmd_5tuple_filter_src_port = 10729 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result, 10730 src_port, "src_port"); 10731 cmdline_parse_token_num_t cmd_5tuple_filter_src_port_value = 10732 TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result, 10733 src_port_value, UINT16); 10734 cmdline_parse_token_string_t cmd_5tuple_filter_protocol = 10735 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result, 10736 protocol, "protocol"); 10737 cmdline_parse_token_num_t cmd_5tuple_filter_protocol_value = 10738 TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result, 10739 protocol_value, UINT8); 10740 cmdline_parse_token_string_t cmd_5tuple_filter_mask = 10741 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result, 10742 mask, "mask"); 10743 cmdline_parse_token_num_t cmd_5tuple_filter_mask_value = 10744 TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result, 10745 mask_value, INT8); 10746 cmdline_parse_token_string_t cmd_5tuple_filter_tcp_flags = 10747 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result, 10748 tcp_flags, "tcp_flags"); 10749 cmdline_parse_token_num_t cmd_5tuple_filter_tcp_flags_value = 10750 TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result, 10751 tcp_flags_value, UINT8); 10752 cmdline_parse_token_string_t cmd_5tuple_filter_priority = 10753 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result, 10754 priority, "priority"); 10755 cmdline_parse_token_num_t cmd_5tuple_filter_priority_value = 10756 TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result, 10757 priority_value, UINT8); 10758 cmdline_parse_token_string_t cmd_5tuple_filter_queue = 10759 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result, 10760 queue, "queue"); 10761 cmdline_parse_token_num_t cmd_5tuple_filter_queue_id = 10762 TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result, 10763 queue_id, UINT16); 10764 10765 cmdline_parse_inst_t cmd_5tuple_filter = { 10766 .f = cmd_5tuple_filter_parsed, 10767 .data = NULL, 10768 .help_str = "5tuple_filter <port_id> add|del dst_ip <value> " 10769 "src_ip <value> dst_port <value> src_port <value> " 10770 "protocol <value> mask <value> tcp_flags <value> " 10771 "priority <value> queue <queue_id>: Add/Del a 5tuple filter", 10772 .tokens = { 10773 (void *)&cmd_5tuple_filter_filter, 10774 (void *)&cmd_5tuple_filter_port_id, 10775 (void *)&cmd_5tuple_filter_ops, 10776 (void *)&cmd_5tuple_filter_dst_ip, 10777 (void *)&cmd_5tuple_filter_dst_ip_value, 10778 (void *)&cmd_5tuple_filter_src_ip, 10779 (void *)&cmd_5tuple_filter_src_ip_value, 10780 (void *)&cmd_5tuple_filter_dst_port, 10781 (void *)&cmd_5tuple_filter_dst_port_value, 10782 (void *)&cmd_5tuple_filter_src_port, 10783 (void *)&cmd_5tuple_filter_src_port_value, 10784 (void *)&cmd_5tuple_filter_protocol, 10785 (void *)&cmd_5tuple_filter_protocol_value, 10786 (void *)&cmd_5tuple_filter_mask, 10787 (void *)&cmd_5tuple_filter_mask_value, 10788 (void *)&cmd_5tuple_filter_tcp_flags, 10789 (void *)&cmd_5tuple_filter_tcp_flags_value, 10790 (void *)&cmd_5tuple_filter_priority, 10791 (void *)&cmd_5tuple_filter_priority_value, 10792 (void *)&cmd_5tuple_filter_queue, 10793 (void *)&cmd_5tuple_filter_queue_id, 10794 NULL, 10795 }, 10796 }; 10797 10798 /* *** ADD/REMOVE A flex FILTER *** */ 10799 struct cmd_flex_filter_result { 10800 cmdline_fixed_string_t filter; 10801 cmdline_fixed_string_t ops; 10802 portid_t port_id; 10803 cmdline_fixed_string_t len; 10804 uint8_t len_value; 10805 cmdline_fixed_string_t bytes; 10806 cmdline_fixed_string_t bytes_value; 10807 cmdline_fixed_string_t mask; 10808 cmdline_fixed_string_t mask_value; 10809 cmdline_fixed_string_t priority; 10810 uint8_t priority_value; 10811 cmdline_fixed_string_t queue; 10812 uint16_t queue_id; 10813 }; 10814 10815 static int xdigit2val(unsigned char c) 10816 { 10817 int val; 10818 if (isdigit(c)) 10819 val = c - '0'; 10820 else if (isupper(c)) 10821 val = c - 'A' + 10; 10822 else 10823 val = c - 'a' + 10; 10824 return val; 10825 } 10826 10827 static void 10828 cmd_flex_filter_parsed(void *parsed_result, 10829 __rte_unused struct cmdline *cl, 10830 __rte_unused void *data) 10831 { 10832 int ret = 0; 10833 struct rte_eth_flex_filter filter; 10834 struct cmd_flex_filter_result *res = parsed_result; 10835 char *bytes_ptr, *mask_ptr; 10836 uint16_t len, i, j = 0; 10837 char c; 10838 int val; 10839 uint8_t byte = 0; 10840 10841 if (res->len_value > RTE_FLEX_FILTER_MAXLEN) { 10842 printf("the len exceed the max length 128\n"); 10843 return; 10844 } 10845 memset(&filter, 0, sizeof(struct rte_eth_flex_filter)); 10846 filter.len = res->len_value; 10847 filter.priority = res->priority_value; 10848 filter.queue = res->queue_id; 10849 bytes_ptr = res->bytes_value; 10850 mask_ptr = res->mask_value; 10851 10852 /* translate bytes string to array. */ 10853 if (bytes_ptr[0] == '0' && ((bytes_ptr[1] == 'x') || 10854 (bytes_ptr[1] == 'X'))) 10855 bytes_ptr += 2; 10856 len = strnlen(bytes_ptr, res->len_value * 2); 10857 if (len == 0 || (len % 8 != 0)) { 10858 printf("please check len and bytes input\n"); 10859 return; 10860 } 10861 for (i = 0; i < len; i++) { 10862 c = bytes_ptr[i]; 10863 if (isxdigit(c) == 0) { 10864 /* invalid characters. */ 10865 printf("invalid input\n"); 10866 return; 10867 } 10868 val = xdigit2val(c); 10869 if (i % 2) { 10870 byte |= val; 10871 filter.bytes[j] = byte; 10872 printf("bytes[%d]:%02x ", j, filter.bytes[j]); 10873 j++; 10874 byte = 0; 10875 } else 10876 byte |= val << 4; 10877 } 10878 printf("\n"); 10879 /* translate mask string to uint8_t array. */ 10880 if (mask_ptr[0] == '0' && ((mask_ptr[1] == 'x') || 10881 (mask_ptr[1] == 'X'))) 10882 mask_ptr += 2; 10883 len = strnlen(mask_ptr, (res->len_value + 3) / 4); 10884 if (len == 0) { 10885 printf("invalid input\n"); 10886 return; 10887 } 10888 j = 0; 10889 byte = 0; 10890 for (i = 0; i < len; i++) { 10891 c = mask_ptr[i]; 10892 if (isxdigit(c) == 0) { 10893 /* invalid characters. */ 10894 printf("invalid input\n"); 10895 return; 10896 } 10897 val = xdigit2val(c); 10898 if (i % 2) { 10899 byte |= val; 10900 filter.mask[j] = byte; 10901 printf("mask[%d]:%02x ", j, filter.mask[j]); 10902 j++; 10903 byte = 0; 10904 } else 10905 byte |= val << 4; 10906 } 10907 printf("\n"); 10908 10909 if (!strcmp(res->ops, "add")) 10910 ret = rte_eth_dev_filter_ctrl(res->port_id, 10911 RTE_ETH_FILTER_FLEXIBLE, 10912 RTE_ETH_FILTER_ADD, 10913 &filter); 10914 else 10915 ret = rte_eth_dev_filter_ctrl(res->port_id, 10916 RTE_ETH_FILTER_FLEXIBLE, 10917 RTE_ETH_FILTER_DELETE, 10918 &filter); 10919 10920 if (ret < 0) 10921 printf("flex filter setting error: (%s)\n", strerror(-ret)); 10922 } 10923 10924 cmdline_parse_token_string_t cmd_flex_filter_filter = 10925 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result, 10926 filter, "flex_filter"); 10927 cmdline_parse_token_num_t cmd_flex_filter_port_id = 10928 TOKEN_NUM_INITIALIZER(struct cmd_flex_filter_result, 10929 port_id, UINT16); 10930 cmdline_parse_token_string_t cmd_flex_filter_ops = 10931 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result, 10932 ops, "add#del"); 10933 cmdline_parse_token_string_t cmd_flex_filter_len = 10934 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result, 10935 len, "len"); 10936 cmdline_parse_token_num_t cmd_flex_filter_len_value = 10937 TOKEN_NUM_INITIALIZER(struct cmd_flex_filter_result, 10938 len_value, UINT8); 10939 cmdline_parse_token_string_t cmd_flex_filter_bytes = 10940 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result, 10941 bytes, "bytes"); 10942 cmdline_parse_token_string_t cmd_flex_filter_bytes_value = 10943 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result, 10944 bytes_value, NULL); 10945 cmdline_parse_token_string_t cmd_flex_filter_mask = 10946 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result, 10947 mask, "mask"); 10948 cmdline_parse_token_string_t cmd_flex_filter_mask_value = 10949 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result, 10950 mask_value, NULL); 10951 cmdline_parse_token_string_t cmd_flex_filter_priority = 10952 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result, 10953 priority, "priority"); 10954 cmdline_parse_token_num_t cmd_flex_filter_priority_value = 10955 TOKEN_NUM_INITIALIZER(struct cmd_flex_filter_result, 10956 priority_value, UINT8); 10957 cmdline_parse_token_string_t cmd_flex_filter_queue = 10958 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result, 10959 queue, "queue"); 10960 cmdline_parse_token_num_t cmd_flex_filter_queue_id = 10961 TOKEN_NUM_INITIALIZER(struct cmd_flex_filter_result, 10962 queue_id, UINT16); 10963 cmdline_parse_inst_t cmd_flex_filter = { 10964 .f = cmd_flex_filter_parsed, 10965 .data = NULL, 10966 .help_str = "flex_filter <port_id> add|del len <value> bytes " 10967 "<value> mask <value> priority <value> queue <queue_id>: " 10968 "Add/Del a flex filter", 10969 .tokens = { 10970 (void *)&cmd_flex_filter_filter, 10971 (void *)&cmd_flex_filter_port_id, 10972 (void *)&cmd_flex_filter_ops, 10973 (void *)&cmd_flex_filter_len, 10974 (void *)&cmd_flex_filter_len_value, 10975 (void *)&cmd_flex_filter_bytes, 10976 (void *)&cmd_flex_filter_bytes_value, 10977 (void *)&cmd_flex_filter_mask, 10978 (void *)&cmd_flex_filter_mask_value, 10979 (void *)&cmd_flex_filter_priority, 10980 (void *)&cmd_flex_filter_priority_value, 10981 (void *)&cmd_flex_filter_queue, 10982 (void *)&cmd_flex_filter_queue_id, 10983 NULL, 10984 }, 10985 }; 10986 10987 /* *** Filters Control *** */ 10988 10989 /* *** deal with ethertype filter *** */ 10990 struct cmd_ethertype_filter_result { 10991 cmdline_fixed_string_t filter; 10992 portid_t port_id; 10993 cmdline_fixed_string_t ops; 10994 cmdline_fixed_string_t mac; 10995 struct rte_ether_addr mac_addr; 10996 cmdline_fixed_string_t ethertype; 10997 uint16_t ethertype_value; 10998 cmdline_fixed_string_t drop; 10999 cmdline_fixed_string_t queue; 11000 uint16_t queue_id; 11001 }; 11002 11003 cmdline_parse_token_string_t cmd_ethertype_filter_filter = 11004 TOKEN_STRING_INITIALIZER(struct cmd_ethertype_filter_result, 11005 filter, "ethertype_filter"); 11006 cmdline_parse_token_num_t cmd_ethertype_filter_port_id = 11007 TOKEN_NUM_INITIALIZER(struct cmd_ethertype_filter_result, 11008 port_id, UINT16); 11009 cmdline_parse_token_string_t cmd_ethertype_filter_ops = 11010 TOKEN_STRING_INITIALIZER(struct cmd_ethertype_filter_result, 11011 ops, "add#del"); 11012 cmdline_parse_token_string_t cmd_ethertype_filter_mac = 11013 TOKEN_STRING_INITIALIZER(struct cmd_ethertype_filter_result, 11014 mac, "mac_addr#mac_ignr"); 11015 cmdline_parse_token_etheraddr_t cmd_ethertype_filter_mac_addr = 11016 TOKEN_ETHERADDR_INITIALIZER(struct cmd_ethertype_filter_result, 11017 mac_addr); 11018 cmdline_parse_token_string_t cmd_ethertype_filter_ethertype = 11019 TOKEN_STRING_INITIALIZER(struct cmd_ethertype_filter_result, 11020 ethertype, "ethertype"); 11021 cmdline_parse_token_num_t cmd_ethertype_filter_ethertype_value = 11022 TOKEN_NUM_INITIALIZER(struct cmd_ethertype_filter_result, 11023 ethertype_value, UINT16); 11024 cmdline_parse_token_string_t cmd_ethertype_filter_drop = 11025 TOKEN_STRING_INITIALIZER(struct cmd_ethertype_filter_result, 11026 drop, "drop#fwd"); 11027 cmdline_parse_token_string_t cmd_ethertype_filter_queue = 11028 TOKEN_STRING_INITIALIZER(struct cmd_ethertype_filter_result, 11029 queue, "queue"); 11030 cmdline_parse_token_num_t cmd_ethertype_filter_queue_id = 11031 TOKEN_NUM_INITIALIZER(struct cmd_ethertype_filter_result, 11032 queue_id, UINT16); 11033 11034 static void 11035 cmd_ethertype_filter_parsed(void *parsed_result, 11036 __rte_unused struct cmdline *cl, 11037 __rte_unused void *data) 11038 { 11039 struct cmd_ethertype_filter_result *res = parsed_result; 11040 struct rte_eth_ethertype_filter filter; 11041 int ret = 0; 11042 11043 ret = rte_eth_dev_filter_supported(res->port_id, 11044 RTE_ETH_FILTER_ETHERTYPE); 11045 if (ret < 0) { 11046 printf("ethertype filter is not supported on port %u.\n", 11047 res->port_id); 11048 return; 11049 } 11050 11051 memset(&filter, 0, sizeof(filter)); 11052 if (!strcmp(res->mac, "mac_addr")) { 11053 filter.flags |= RTE_ETHTYPE_FLAGS_MAC; 11054 rte_memcpy(&filter.mac_addr, &res->mac_addr, 11055 sizeof(struct rte_ether_addr)); 11056 } 11057 if (!strcmp(res->drop, "drop")) 11058 filter.flags |= RTE_ETHTYPE_FLAGS_DROP; 11059 filter.ether_type = res->ethertype_value; 11060 filter.queue = res->queue_id; 11061 11062 if (!strcmp(res->ops, "add")) 11063 ret = rte_eth_dev_filter_ctrl(res->port_id, 11064 RTE_ETH_FILTER_ETHERTYPE, 11065 RTE_ETH_FILTER_ADD, 11066 &filter); 11067 else 11068 ret = rte_eth_dev_filter_ctrl(res->port_id, 11069 RTE_ETH_FILTER_ETHERTYPE, 11070 RTE_ETH_FILTER_DELETE, 11071 &filter); 11072 if (ret < 0) 11073 printf("ethertype filter programming error: (%s)\n", 11074 strerror(-ret)); 11075 } 11076 11077 cmdline_parse_inst_t cmd_ethertype_filter = { 11078 .f = cmd_ethertype_filter_parsed, 11079 .data = NULL, 11080 .help_str = "ethertype_filter <port_id> add|del mac_addr|mac_ignr " 11081 "<mac_addr> ethertype <value> drop|fw queue <queue_id>: " 11082 "Add or delete an ethertype filter entry", 11083 .tokens = { 11084 (void *)&cmd_ethertype_filter_filter, 11085 (void *)&cmd_ethertype_filter_port_id, 11086 (void *)&cmd_ethertype_filter_ops, 11087 (void *)&cmd_ethertype_filter_mac, 11088 (void *)&cmd_ethertype_filter_mac_addr, 11089 (void *)&cmd_ethertype_filter_ethertype, 11090 (void *)&cmd_ethertype_filter_ethertype_value, 11091 (void *)&cmd_ethertype_filter_drop, 11092 (void *)&cmd_ethertype_filter_queue, 11093 (void *)&cmd_ethertype_filter_queue_id, 11094 NULL, 11095 }, 11096 }; 11097 11098 /* *** deal with flow director filter *** */ 11099 struct cmd_flow_director_result { 11100 cmdline_fixed_string_t flow_director_filter; 11101 portid_t port_id; 11102 cmdline_fixed_string_t mode; 11103 cmdline_fixed_string_t mode_value; 11104 cmdline_fixed_string_t ops; 11105 cmdline_fixed_string_t flow; 11106 cmdline_fixed_string_t flow_type; 11107 cmdline_fixed_string_t ether; 11108 uint16_t ether_type; 11109 cmdline_fixed_string_t src; 11110 cmdline_ipaddr_t ip_src; 11111 uint16_t port_src; 11112 cmdline_fixed_string_t dst; 11113 cmdline_ipaddr_t ip_dst; 11114 uint16_t port_dst; 11115 cmdline_fixed_string_t verify_tag; 11116 uint32_t verify_tag_value; 11117 cmdline_fixed_string_t tos; 11118 uint8_t tos_value; 11119 cmdline_fixed_string_t proto; 11120 uint8_t proto_value; 11121 cmdline_fixed_string_t ttl; 11122 uint8_t ttl_value; 11123 cmdline_fixed_string_t vlan; 11124 uint16_t vlan_value; 11125 cmdline_fixed_string_t flexbytes; 11126 cmdline_fixed_string_t flexbytes_value; 11127 cmdline_fixed_string_t pf_vf; 11128 cmdline_fixed_string_t drop; 11129 cmdline_fixed_string_t queue; 11130 uint16_t queue_id; 11131 cmdline_fixed_string_t fd_id; 11132 uint32_t fd_id_value; 11133 cmdline_fixed_string_t mac; 11134 struct rte_ether_addr mac_addr; 11135 cmdline_fixed_string_t tunnel; 11136 cmdline_fixed_string_t tunnel_type; 11137 cmdline_fixed_string_t tunnel_id; 11138 uint32_t tunnel_id_value; 11139 cmdline_fixed_string_t packet; 11140 char filepath[]; 11141 }; 11142 11143 static inline int 11144 parse_flexbytes(const char *q_arg, uint8_t *flexbytes, uint16_t max_num) 11145 { 11146 char s[256]; 11147 const char *p, *p0 = q_arg; 11148 char *end; 11149 unsigned long int_fld; 11150 char *str_fld[max_num]; 11151 int i; 11152 unsigned size; 11153 int ret = -1; 11154 11155 p = strchr(p0, '('); 11156 if (p == NULL) 11157 return -1; 11158 ++p; 11159 p0 = strchr(p, ')'); 11160 if (p0 == NULL) 11161 return -1; 11162 11163 size = p0 - p; 11164 if (size >= sizeof(s)) 11165 return -1; 11166 11167 snprintf(s, sizeof(s), "%.*s", size, p); 11168 ret = rte_strsplit(s, sizeof(s), str_fld, max_num, ','); 11169 if (ret < 0 || ret > max_num) 11170 return -1; 11171 for (i = 0; i < ret; i++) { 11172 errno = 0; 11173 int_fld = strtoul(str_fld[i], &end, 0); 11174 if (errno != 0 || *end != '\0' || int_fld > UINT8_MAX) 11175 return -1; 11176 flexbytes[i] = (uint8_t)int_fld; 11177 } 11178 return ret; 11179 } 11180 11181 static uint16_t 11182 str2flowtype(char *string) 11183 { 11184 uint8_t i = 0; 11185 static const struct { 11186 char str[32]; 11187 uint16_t type; 11188 } flowtype_str[] = { 11189 {"raw", RTE_ETH_FLOW_RAW}, 11190 {"ipv4", RTE_ETH_FLOW_IPV4}, 11191 {"ipv4-frag", RTE_ETH_FLOW_FRAG_IPV4}, 11192 {"ipv4-tcp", RTE_ETH_FLOW_NONFRAG_IPV4_TCP}, 11193 {"ipv4-udp", RTE_ETH_FLOW_NONFRAG_IPV4_UDP}, 11194 {"ipv4-sctp", RTE_ETH_FLOW_NONFRAG_IPV4_SCTP}, 11195 {"ipv4-other", RTE_ETH_FLOW_NONFRAG_IPV4_OTHER}, 11196 {"ipv6", RTE_ETH_FLOW_IPV6}, 11197 {"ipv6-frag", RTE_ETH_FLOW_FRAG_IPV6}, 11198 {"ipv6-tcp", RTE_ETH_FLOW_NONFRAG_IPV6_TCP}, 11199 {"ipv6-udp", RTE_ETH_FLOW_NONFRAG_IPV6_UDP}, 11200 {"ipv6-sctp", RTE_ETH_FLOW_NONFRAG_IPV6_SCTP}, 11201 {"ipv6-other", RTE_ETH_FLOW_NONFRAG_IPV6_OTHER}, 11202 {"l2_payload", RTE_ETH_FLOW_L2_PAYLOAD}, 11203 }; 11204 11205 for (i = 0; i < RTE_DIM(flowtype_str); i++) { 11206 if (!strcmp(flowtype_str[i].str, string)) 11207 return flowtype_str[i].type; 11208 } 11209 11210 if (isdigit(string[0]) && atoi(string) > 0 && atoi(string) < 64) 11211 return (uint16_t)atoi(string); 11212 11213 return RTE_ETH_FLOW_UNKNOWN; 11214 } 11215 11216 static enum rte_eth_fdir_tunnel_type 11217 str2fdir_tunneltype(char *string) 11218 { 11219 uint8_t i = 0; 11220 11221 static const struct { 11222 char str[32]; 11223 enum rte_eth_fdir_tunnel_type type; 11224 } tunneltype_str[] = { 11225 {"NVGRE", RTE_FDIR_TUNNEL_TYPE_NVGRE}, 11226 {"VxLAN", RTE_FDIR_TUNNEL_TYPE_VXLAN}, 11227 }; 11228 11229 for (i = 0; i < RTE_DIM(tunneltype_str); i++) { 11230 if (!strcmp(tunneltype_str[i].str, string)) 11231 return tunneltype_str[i].type; 11232 } 11233 return RTE_FDIR_TUNNEL_TYPE_UNKNOWN; 11234 } 11235 11236 #define IPV4_ADDR_TO_UINT(ip_addr, ip) \ 11237 do { \ 11238 if ((ip_addr).family == AF_INET) \ 11239 (ip) = (ip_addr).addr.ipv4.s_addr; \ 11240 else { \ 11241 printf("invalid parameter.\n"); \ 11242 return; \ 11243 } \ 11244 } while (0) 11245 11246 #define IPV6_ADDR_TO_ARRAY(ip_addr, ip) \ 11247 do { \ 11248 if ((ip_addr).family == AF_INET6) \ 11249 rte_memcpy(&(ip), \ 11250 &((ip_addr).addr.ipv6), \ 11251 sizeof(struct in6_addr)); \ 11252 else { \ 11253 printf("invalid parameter.\n"); \ 11254 return; \ 11255 } \ 11256 } while (0) 11257 11258 static void 11259 cmd_flow_director_filter_parsed(void *parsed_result, 11260 __rte_unused struct cmdline *cl, 11261 __rte_unused void *data) 11262 { 11263 struct cmd_flow_director_result *res = parsed_result; 11264 struct rte_eth_fdir_filter entry; 11265 uint8_t flexbytes[RTE_ETH_FDIR_MAX_FLEXLEN]; 11266 char *end; 11267 unsigned long vf_id; 11268 int ret = 0; 11269 11270 ret = rte_eth_dev_filter_supported(res->port_id, RTE_ETH_FILTER_FDIR); 11271 if (ret < 0) { 11272 printf("flow director is not supported on port %u.\n", 11273 res->port_id); 11274 return; 11275 } 11276 memset(flexbytes, 0, sizeof(flexbytes)); 11277 memset(&entry, 0, sizeof(struct rte_eth_fdir_filter)); 11278 11279 if (fdir_conf.mode == RTE_FDIR_MODE_PERFECT_MAC_VLAN) { 11280 if (strcmp(res->mode_value, "MAC-VLAN")) { 11281 printf("Please set mode to MAC-VLAN.\n"); 11282 return; 11283 } 11284 } else if (fdir_conf.mode == RTE_FDIR_MODE_PERFECT_TUNNEL) { 11285 if (strcmp(res->mode_value, "Tunnel")) { 11286 printf("Please set mode to Tunnel.\n"); 11287 return; 11288 } 11289 } else { 11290 if (!strcmp(res->mode_value, "raw")) { 11291 #ifdef RTE_LIBRTE_I40E_PMD 11292 struct rte_pmd_i40e_flow_type_mapping 11293 mapping[RTE_PMD_I40E_FLOW_TYPE_MAX]; 11294 struct rte_pmd_i40e_pkt_template_conf conf; 11295 uint16_t flow_type = str2flowtype(res->flow_type); 11296 uint16_t i, port = res->port_id; 11297 uint8_t add; 11298 11299 memset(&conf, 0, sizeof(conf)); 11300 11301 if (flow_type == RTE_ETH_FLOW_UNKNOWN) { 11302 printf("Invalid flow type specified.\n"); 11303 return; 11304 } 11305 ret = rte_pmd_i40e_flow_type_mapping_get(res->port_id, 11306 mapping); 11307 if (ret) 11308 return; 11309 if (mapping[flow_type].pctype == 0ULL) { 11310 printf("Invalid flow type specified.\n"); 11311 return; 11312 } 11313 for (i = 0; i < RTE_PMD_I40E_PCTYPE_MAX; i++) { 11314 if (mapping[flow_type].pctype & (1ULL << i)) { 11315 conf.input.pctype = i; 11316 break; 11317 } 11318 } 11319 11320 conf.input.packet = open_file(res->filepath, 11321 &conf.input.length); 11322 if (!conf.input.packet) 11323 return; 11324 if (!strcmp(res->drop, "drop")) 11325 conf.action.behavior = 11326 RTE_PMD_I40E_PKT_TEMPLATE_REJECT; 11327 else 11328 conf.action.behavior = 11329 RTE_PMD_I40E_PKT_TEMPLATE_ACCEPT; 11330 conf.action.report_status = 11331 RTE_PMD_I40E_PKT_TEMPLATE_REPORT_ID; 11332 conf.action.rx_queue = res->queue_id; 11333 conf.soft_id = res->fd_id_value; 11334 add = strcmp(res->ops, "del") ? 1 : 0; 11335 ret = rte_pmd_i40e_flow_add_del_packet_template(port, 11336 &conf, 11337 add); 11338 if (ret < 0) 11339 printf("flow director config error: (%s)\n", 11340 strerror(-ret)); 11341 close_file(conf.input.packet); 11342 #endif 11343 return; 11344 } else if (strcmp(res->mode_value, "IP")) { 11345 printf("Please set mode to IP or raw.\n"); 11346 return; 11347 } 11348 entry.input.flow_type = str2flowtype(res->flow_type); 11349 } 11350 11351 ret = parse_flexbytes(res->flexbytes_value, 11352 flexbytes, 11353 RTE_ETH_FDIR_MAX_FLEXLEN); 11354 if (ret < 0) { 11355 printf("error: Cannot parse flexbytes input.\n"); 11356 return; 11357 } 11358 11359 switch (entry.input.flow_type) { 11360 case RTE_ETH_FLOW_FRAG_IPV4: 11361 case RTE_ETH_FLOW_NONFRAG_IPV4_OTHER: 11362 entry.input.flow.ip4_flow.proto = res->proto_value; 11363 /* fall-through */ 11364 case RTE_ETH_FLOW_NONFRAG_IPV4_UDP: 11365 case RTE_ETH_FLOW_NONFRAG_IPV4_TCP: 11366 IPV4_ADDR_TO_UINT(res->ip_dst, 11367 entry.input.flow.ip4_flow.dst_ip); 11368 IPV4_ADDR_TO_UINT(res->ip_src, 11369 entry.input.flow.ip4_flow.src_ip); 11370 entry.input.flow.ip4_flow.tos = res->tos_value; 11371 entry.input.flow.ip4_flow.ttl = res->ttl_value; 11372 /* need convert to big endian. */ 11373 entry.input.flow.udp4_flow.dst_port = 11374 rte_cpu_to_be_16(res->port_dst); 11375 entry.input.flow.udp4_flow.src_port = 11376 rte_cpu_to_be_16(res->port_src); 11377 break; 11378 case RTE_ETH_FLOW_NONFRAG_IPV4_SCTP: 11379 IPV4_ADDR_TO_UINT(res->ip_dst, 11380 entry.input.flow.sctp4_flow.ip.dst_ip); 11381 IPV4_ADDR_TO_UINT(res->ip_src, 11382 entry.input.flow.sctp4_flow.ip.src_ip); 11383 entry.input.flow.ip4_flow.tos = res->tos_value; 11384 entry.input.flow.ip4_flow.ttl = res->ttl_value; 11385 /* need convert to big endian. */ 11386 entry.input.flow.sctp4_flow.dst_port = 11387 rte_cpu_to_be_16(res->port_dst); 11388 entry.input.flow.sctp4_flow.src_port = 11389 rte_cpu_to_be_16(res->port_src); 11390 entry.input.flow.sctp4_flow.verify_tag = 11391 rte_cpu_to_be_32(res->verify_tag_value); 11392 break; 11393 case RTE_ETH_FLOW_FRAG_IPV6: 11394 case RTE_ETH_FLOW_NONFRAG_IPV6_OTHER: 11395 entry.input.flow.ipv6_flow.proto = res->proto_value; 11396 /* fall-through */ 11397 case RTE_ETH_FLOW_NONFRAG_IPV6_UDP: 11398 case RTE_ETH_FLOW_NONFRAG_IPV6_TCP: 11399 IPV6_ADDR_TO_ARRAY(res->ip_dst, 11400 entry.input.flow.ipv6_flow.dst_ip); 11401 IPV6_ADDR_TO_ARRAY(res->ip_src, 11402 entry.input.flow.ipv6_flow.src_ip); 11403 entry.input.flow.ipv6_flow.tc = res->tos_value; 11404 entry.input.flow.ipv6_flow.hop_limits = res->ttl_value; 11405 /* need convert to big endian. */ 11406 entry.input.flow.udp6_flow.dst_port = 11407 rte_cpu_to_be_16(res->port_dst); 11408 entry.input.flow.udp6_flow.src_port = 11409 rte_cpu_to_be_16(res->port_src); 11410 break; 11411 case RTE_ETH_FLOW_NONFRAG_IPV6_SCTP: 11412 IPV6_ADDR_TO_ARRAY(res->ip_dst, 11413 entry.input.flow.sctp6_flow.ip.dst_ip); 11414 IPV6_ADDR_TO_ARRAY(res->ip_src, 11415 entry.input.flow.sctp6_flow.ip.src_ip); 11416 entry.input.flow.ipv6_flow.tc = res->tos_value; 11417 entry.input.flow.ipv6_flow.hop_limits = res->ttl_value; 11418 /* need convert to big endian. */ 11419 entry.input.flow.sctp6_flow.dst_port = 11420 rte_cpu_to_be_16(res->port_dst); 11421 entry.input.flow.sctp6_flow.src_port = 11422 rte_cpu_to_be_16(res->port_src); 11423 entry.input.flow.sctp6_flow.verify_tag = 11424 rte_cpu_to_be_32(res->verify_tag_value); 11425 break; 11426 case RTE_ETH_FLOW_L2_PAYLOAD: 11427 entry.input.flow.l2_flow.ether_type = 11428 rte_cpu_to_be_16(res->ether_type); 11429 break; 11430 default: 11431 break; 11432 } 11433 11434 if (fdir_conf.mode == RTE_FDIR_MODE_PERFECT_MAC_VLAN) 11435 rte_memcpy(&entry.input.flow.mac_vlan_flow.mac_addr, 11436 &res->mac_addr, 11437 sizeof(struct rte_ether_addr)); 11438 11439 if (fdir_conf.mode == RTE_FDIR_MODE_PERFECT_TUNNEL) { 11440 rte_memcpy(&entry.input.flow.tunnel_flow.mac_addr, 11441 &res->mac_addr, 11442 sizeof(struct rte_ether_addr)); 11443 entry.input.flow.tunnel_flow.tunnel_type = 11444 str2fdir_tunneltype(res->tunnel_type); 11445 entry.input.flow.tunnel_flow.tunnel_id = 11446 rte_cpu_to_be_32(res->tunnel_id_value); 11447 } 11448 11449 rte_memcpy(entry.input.flow_ext.flexbytes, 11450 flexbytes, 11451 RTE_ETH_FDIR_MAX_FLEXLEN); 11452 11453 entry.input.flow_ext.vlan_tci = rte_cpu_to_be_16(res->vlan_value); 11454 11455 entry.action.flex_off = 0; /*use 0 by default */ 11456 if (!strcmp(res->drop, "drop")) 11457 entry.action.behavior = RTE_ETH_FDIR_REJECT; 11458 else 11459 entry.action.behavior = RTE_ETH_FDIR_ACCEPT; 11460 11461 if (fdir_conf.mode != RTE_FDIR_MODE_PERFECT_MAC_VLAN && 11462 fdir_conf.mode != RTE_FDIR_MODE_PERFECT_TUNNEL) { 11463 if (!strcmp(res->pf_vf, "pf")) 11464 entry.input.flow_ext.is_vf = 0; 11465 else if (!strncmp(res->pf_vf, "vf", 2)) { 11466 struct rte_eth_dev_info dev_info; 11467 11468 ret = eth_dev_info_get_print_err(res->port_id, 11469 &dev_info); 11470 if (ret != 0) 11471 return; 11472 11473 errno = 0; 11474 vf_id = strtoul(res->pf_vf + 2, &end, 10); 11475 if (errno != 0 || *end != '\0' || 11476 vf_id >= dev_info.max_vfs) { 11477 printf("invalid parameter %s.\n", res->pf_vf); 11478 return; 11479 } 11480 entry.input.flow_ext.is_vf = 1; 11481 entry.input.flow_ext.dst_id = (uint16_t)vf_id; 11482 } else { 11483 printf("invalid parameter %s.\n", res->pf_vf); 11484 return; 11485 } 11486 } 11487 11488 /* set to report FD ID by default */ 11489 entry.action.report_status = RTE_ETH_FDIR_REPORT_ID; 11490 entry.action.rx_queue = res->queue_id; 11491 entry.soft_id = res->fd_id_value; 11492 if (!strcmp(res->ops, "add")) 11493 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_FDIR, 11494 RTE_ETH_FILTER_ADD, &entry); 11495 else if (!strcmp(res->ops, "del")) 11496 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_FDIR, 11497 RTE_ETH_FILTER_DELETE, &entry); 11498 else 11499 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_FDIR, 11500 RTE_ETH_FILTER_UPDATE, &entry); 11501 if (ret < 0) 11502 printf("flow director programming error: (%s)\n", 11503 strerror(-ret)); 11504 } 11505 11506 cmdline_parse_token_string_t cmd_flow_director_filter = 11507 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result, 11508 flow_director_filter, "flow_director_filter"); 11509 cmdline_parse_token_num_t cmd_flow_director_port_id = 11510 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result, 11511 port_id, UINT16); 11512 cmdline_parse_token_string_t cmd_flow_director_ops = 11513 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result, 11514 ops, "add#del#update"); 11515 cmdline_parse_token_string_t cmd_flow_director_flow = 11516 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result, 11517 flow, "flow"); 11518 cmdline_parse_token_string_t cmd_flow_director_flow_type = 11519 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result, 11520 flow_type, NULL); 11521 cmdline_parse_token_string_t cmd_flow_director_ether = 11522 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result, 11523 ether, "ether"); 11524 cmdline_parse_token_num_t cmd_flow_director_ether_type = 11525 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result, 11526 ether_type, UINT16); 11527 cmdline_parse_token_string_t cmd_flow_director_src = 11528 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result, 11529 src, "src"); 11530 cmdline_parse_token_ipaddr_t cmd_flow_director_ip_src = 11531 TOKEN_IPADDR_INITIALIZER(struct cmd_flow_director_result, 11532 ip_src); 11533 cmdline_parse_token_num_t cmd_flow_director_port_src = 11534 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result, 11535 port_src, UINT16); 11536 cmdline_parse_token_string_t cmd_flow_director_dst = 11537 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result, 11538 dst, "dst"); 11539 cmdline_parse_token_ipaddr_t cmd_flow_director_ip_dst = 11540 TOKEN_IPADDR_INITIALIZER(struct cmd_flow_director_result, 11541 ip_dst); 11542 cmdline_parse_token_num_t cmd_flow_director_port_dst = 11543 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result, 11544 port_dst, UINT16); 11545 cmdline_parse_token_string_t cmd_flow_director_verify_tag = 11546 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result, 11547 verify_tag, "verify_tag"); 11548 cmdline_parse_token_num_t cmd_flow_director_verify_tag_value = 11549 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result, 11550 verify_tag_value, UINT32); 11551 cmdline_parse_token_string_t cmd_flow_director_tos = 11552 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result, 11553 tos, "tos"); 11554 cmdline_parse_token_num_t cmd_flow_director_tos_value = 11555 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result, 11556 tos_value, UINT8); 11557 cmdline_parse_token_string_t cmd_flow_director_proto = 11558 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result, 11559 proto, "proto"); 11560 cmdline_parse_token_num_t cmd_flow_director_proto_value = 11561 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result, 11562 proto_value, UINT8); 11563 cmdline_parse_token_string_t cmd_flow_director_ttl = 11564 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result, 11565 ttl, "ttl"); 11566 cmdline_parse_token_num_t cmd_flow_director_ttl_value = 11567 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result, 11568 ttl_value, UINT8); 11569 cmdline_parse_token_string_t cmd_flow_director_vlan = 11570 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result, 11571 vlan, "vlan"); 11572 cmdline_parse_token_num_t cmd_flow_director_vlan_value = 11573 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result, 11574 vlan_value, UINT16); 11575 cmdline_parse_token_string_t cmd_flow_director_flexbytes = 11576 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result, 11577 flexbytes, "flexbytes"); 11578 cmdline_parse_token_string_t cmd_flow_director_flexbytes_value = 11579 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result, 11580 flexbytes_value, NULL); 11581 cmdline_parse_token_string_t cmd_flow_director_drop = 11582 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result, 11583 drop, "drop#fwd"); 11584 cmdline_parse_token_string_t cmd_flow_director_pf_vf = 11585 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result, 11586 pf_vf, NULL); 11587 cmdline_parse_token_string_t cmd_flow_director_queue = 11588 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result, 11589 queue, "queue"); 11590 cmdline_parse_token_num_t cmd_flow_director_queue_id = 11591 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result, 11592 queue_id, UINT16); 11593 cmdline_parse_token_string_t cmd_flow_director_fd_id = 11594 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result, 11595 fd_id, "fd_id"); 11596 cmdline_parse_token_num_t cmd_flow_director_fd_id_value = 11597 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result, 11598 fd_id_value, UINT32); 11599 11600 cmdline_parse_token_string_t cmd_flow_director_mode = 11601 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result, 11602 mode, "mode"); 11603 cmdline_parse_token_string_t cmd_flow_director_mode_ip = 11604 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result, 11605 mode_value, "IP"); 11606 cmdline_parse_token_string_t cmd_flow_director_mode_mac_vlan = 11607 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result, 11608 mode_value, "MAC-VLAN"); 11609 cmdline_parse_token_string_t cmd_flow_director_mode_tunnel = 11610 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result, 11611 mode_value, "Tunnel"); 11612 cmdline_parse_token_string_t cmd_flow_director_mode_raw = 11613 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result, 11614 mode_value, "raw"); 11615 cmdline_parse_token_string_t cmd_flow_director_mac = 11616 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result, 11617 mac, "mac"); 11618 cmdline_parse_token_etheraddr_t cmd_flow_director_mac_addr = 11619 TOKEN_ETHERADDR_INITIALIZER(struct cmd_flow_director_result, 11620 mac_addr); 11621 cmdline_parse_token_string_t cmd_flow_director_tunnel = 11622 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result, 11623 tunnel, "tunnel"); 11624 cmdline_parse_token_string_t cmd_flow_director_tunnel_type = 11625 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result, 11626 tunnel_type, "NVGRE#VxLAN"); 11627 cmdline_parse_token_string_t cmd_flow_director_tunnel_id = 11628 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result, 11629 tunnel_id, "tunnel-id"); 11630 cmdline_parse_token_num_t cmd_flow_director_tunnel_id_value = 11631 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result, 11632 tunnel_id_value, UINT32); 11633 cmdline_parse_token_string_t cmd_flow_director_packet = 11634 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result, 11635 packet, "packet"); 11636 cmdline_parse_token_string_t cmd_flow_director_filepath = 11637 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result, 11638 filepath, NULL); 11639 11640 cmdline_parse_inst_t cmd_add_del_ip_flow_director = { 11641 .f = cmd_flow_director_filter_parsed, 11642 .data = NULL, 11643 .help_str = "flow_director_filter <port_id> mode IP add|del|update flow" 11644 " ipv4-other|ipv4-frag|ipv4-tcp|ipv4-udp|ipv4-sctp|" 11645 "ipv6-other|ipv6-frag|ipv6-tcp|ipv6-udp|ipv6-sctp|" 11646 "l2_payload src <src_ip> dst <dst_ip> tos <tos_value> " 11647 "proto <proto_value> ttl <ttl_value> vlan <vlan_value> " 11648 "flexbytes <flexbyte_values> drop|fw <pf_vf> queue <queue_id> " 11649 "fd_id <fd_id_value>: " 11650 "Add or delete an ip flow director entry on NIC", 11651 .tokens = { 11652 (void *)&cmd_flow_director_filter, 11653 (void *)&cmd_flow_director_port_id, 11654 (void *)&cmd_flow_director_mode, 11655 (void *)&cmd_flow_director_mode_ip, 11656 (void *)&cmd_flow_director_ops, 11657 (void *)&cmd_flow_director_flow, 11658 (void *)&cmd_flow_director_flow_type, 11659 (void *)&cmd_flow_director_src, 11660 (void *)&cmd_flow_director_ip_src, 11661 (void *)&cmd_flow_director_dst, 11662 (void *)&cmd_flow_director_ip_dst, 11663 (void *)&cmd_flow_director_tos, 11664 (void *)&cmd_flow_director_tos_value, 11665 (void *)&cmd_flow_director_proto, 11666 (void *)&cmd_flow_director_proto_value, 11667 (void *)&cmd_flow_director_ttl, 11668 (void *)&cmd_flow_director_ttl_value, 11669 (void *)&cmd_flow_director_vlan, 11670 (void *)&cmd_flow_director_vlan_value, 11671 (void *)&cmd_flow_director_flexbytes, 11672 (void *)&cmd_flow_director_flexbytes_value, 11673 (void *)&cmd_flow_director_drop, 11674 (void *)&cmd_flow_director_pf_vf, 11675 (void *)&cmd_flow_director_queue, 11676 (void *)&cmd_flow_director_queue_id, 11677 (void *)&cmd_flow_director_fd_id, 11678 (void *)&cmd_flow_director_fd_id_value, 11679 NULL, 11680 }, 11681 }; 11682 11683 cmdline_parse_inst_t cmd_add_del_udp_flow_director = { 11684 .f = cmd_flow_director_filter_parsed, 11685 .data = NULL, 11686 .help_str = "flow_director_filter ... : Add or delete an udp/tcp flow " 11687 "director entry on NIC", 11688 .tokens = { 11689 (void *)&cmd_flow_director_filter, 11690 (void *)&cmd_flow_director_port_id, 11691 (void *)&cmd_flow_director_mode, 11692 (void *)&cmd_flow_director_mode_ip, 11693 (void *)&cmd_flow_director_ops, 11694 (void *)&cmd_flow_director_flow, 11695 (void *)&cmd_flow_director_flow_type, 11696 (void *)&cmd_flow_director_src, 11697 (void *)&cmd_flow_director_ip_src, 11698 (void *)&cmd_flow_director_port_src, 11699 (void *)&cmd_flow_director_dst, 11700 (void *)&cmd_flow_director_ip_dst, 11701 (void *)&cmd_flow_director_port_dst, 11702 (void *)&cmd_flow_director_tos, 11703 (void *)&cmd_flow_director_tos_value, 11704 (void *)&cmd_flow_director_ttl, 11705 (void *)&cmd_flow_director_ttl_value, 11706 (void *)&cmd_flow_director_vlan, 11707 (void *)&cmd_flow_director_vlan_value, 11708 (void *)&cmd_flow_director_flexbytes, 11709 (void *)&cmd_flow_director_flexbytes_value, 11710 (void *)&cmd_flow_director_drop, 11711 (void *)&cmd_flow_director_pf_vf, 11712 (void *)&cmd_flow_director_queue, 11713 (void *)&cmd_flow_director_queue_id, 11714 (void *)&cmd_flow_director_fd_id, 11715 (void *)&cmd_flow_director_fd_id_value, 11716 NULL, 11717 }, 11718 }; 11719 11720 cmdline_parse_inst_t cmd_add_del_sctp_flow_director = { 11721 .f = cmd_flow_director_filter_parsed, 11722 .data = NULL, 11723 .help_str = "flow_director_filter ... : Add or delete a sctp flow " 11724 "director entry on NIC", 11725 .tokens = { 11726 (void *)&cmd_flow_director_filter, 11727 (void *)&cmd_flow_director_port_id, 11728 (void *)&cmd_flow_director_mode, 11729 (void *)&cmd_flow_director_mode_ip, 11730 (void *)&cmd_flow_director_ops, 11731 (void *)&cmd_flow_director_flow, 11732 (void *)&cmd_flow_director_flow_type, 11733 (void *)&cmd_flow_director_src, 11734 (void *)&cmd_flow_director_ip_src, 11735 (void *)&cmd_flow_director_port_src, 11736 (void *)&cmd_flow_director_dst, 11737 (void *)&cmd_flow_director_ip_dst, 11738 (void *)&cmd_flow_director_port_dst, 11739 (void *)&cmd_flow_director_verify_tag, 11740 (void *)&cmd_flow_director_verify_tag_value, 11741 (void *)&cmd_flow_director_tos, 11742 (void *)&cmd_flow_director_tos_value, 11743 (void *)&cmd_flow_director_ttl, 11744 (void *)&cmd_flow_director_ttl_value, 11745 (void *)&cmd_flow_director_vlan, 11746 (void *)&cmd_flow_director_vlan_value, 11747 (void *)&cmd_flow_director_flexbytes, 11748 (void *)&cmd_flow_director_flexbytes_value, 11749 (void *)&cmd_flow_director_drop, 11750 (void *)&cmd_flow_director_pf_vf, 11751 (void *)&cmd_flow_director_queue, 11752 (void *)&cmd_flow_director_queue_id, 11753 (void *)&cmd_flow_director_fd_id, 11754 (void *)&cmd_flow_director_fd_id_value, 11755 NULL, 11756 }, 11757 }; 11758 11759 cmdline_parse_inst_t cmd_add_del_l2_flow_director = { 11760 .f = cmd_flow_director_filter_parsed, 11761 .data = NULL, 11762 .help_str = "flow_director_filter ... : Add or delete a L2 flow " 11763 "director entry on NIC", 11764 .tokens = { 11765 (void *)&cmd_flow_director_filter, 11766 (void *)&cmd_flow_director_port_id, 11767 (void *)&cmd_flow_director_mode, 11768 (void *)&cmd_flow_director_mode_ip, 11769 (void *)&cmd_flow_director_ops, 11770 (void *)&cmd_flow_director_flow, 11771 (void *)&cmd_flow_director_flow_type, 11772 (void *)&cmd_flow_director_ether, 11773 (void *)&cmd_flow_director_ether_type, 11774 (void *)&cmd_flow_director_flexbytes, 11775 (void *)&cmd_flow_director_flexbytes_value, 11776 (void *)&cmd_flow_director_drop, 11777 (void *)&cmd_flow_director_pf_vf, 11778 (void *)&cmd_flow_director_queue, 11779 (void *)&cmd_flow_director_queue_id, 11780 (void *)&cmd_flow_director_fd_id, 11781 (void *)&cmd_flow_director_fd_id_value, 11782 NULL, 11783 }, 11784 }; 11785 11786 cmdline_parse_inst_t cmd_add_del_mac_vlan_flow_director = { 11787 .f = cmd_flow_director_filter_parsed, 11788 .data = NULL, 11789 .help_str = "flow_director_filter ... : Add or delete a MAC VLAN flow " 11790 "director entry on NIC", 11791 .tokens = { 11792 (void *)&cmd_flow_director_filter, 11793 (void *)&cmd_flow_director_port_id, 11794 (void *)&cmd_flow_director_mode, 11795 (void *)&cmd_flow_director_mode_mac_vlan, 11796 (void *)&cmd_flow_director_ops, 11797 (void *)&cmd_flow_director_mac, 11798 (void *)&cmd_flow_director_mac_addr, 11799 (void *)&cmd_flow_director_vlan, 11800 (void *)&cmd_flow_director_vlan_value, 11801 (void *)&cmd_flow_director_flexbytes, 11802 (void *)&cmd_flow_director_flexbytes_value, 11803 (void *)&cmd_flow_director_drop, 11804 (void *)&cmd_flow_director_queue, 11805 (void *)&cmd_flow_director_queue_id, 11806 (void *)&cmd_flow_director_fd_id, 11807 (void *)&cmd_flow_director_fd_id_value, 11808 NULL, 11809 }, 11810 }; 11811 11812 cmdline_parse_inst_t cmd_add_del_tunnel_flow_director = { 11813 .f = cmd_flow_director_filter_parsed, 11814 .data = NULL, 11815 .help_str = "flow_director_filter ... : Add or delete a tunnel flow " 11816 "director entry on NIC", 11817 .tokens = { 11818 (void *)&cmd_flow_director_filter, 11819 (void *)&cmd_flow_director_port_id, 11820 (void *)&cmd_flow_director_mode, 11821 (void *)&cmd_flow_director_mode_tunnel, 11822 (void *)&cmd_flow_director_ops, 11823 (void *)&cmd_flow_director_mac, 11824 (void *)&cmd_flow_director_mac_addr, 11825 (void *)&cmd_flow_director_vlan, 11826 (void *)&cmd_flow_director_vlan_value, 11827 (void *)&cmd_flow_director_tunnel, 11828 (void *)&cmd_flow_director_tunnel_type, 11829 (void *)&cmd_flow_director_tunnel_id, 11830 (void *)&cmd_flow_director_tunnel_id_value, 11831 (void *)&cmd_flow_director_flexbytes, 11832 (void *)&cmd_flow_director_flexbytes_value, 11833 (void *)&cmd_flow_director_drop, 11834 (void *)&cmd_flow_director_queue, 11835 (void *)&cmd_flow_director_queue_id, 11836 (void *)&cmd_flow_director_fd_id, 11837 (void *)&cmd_flow_director_fd_id_value, 11838 NULL, 11839 }, 11840 }; 11841 11842 cmdline_parse_inst_t cmd_add_del_raw_flow_director = { 11843 .f = cmd_flow_director_filter_parsed, 11844 .data = NULL, 11845 .help_str = "flow_director_filter ... : Add or delete a raw flow " 11846 "director entry on NIC", 11847 .tokens = { 11848 (void *)&cmd_flow_director_filter, 11849 (void *)&cmd_flow_director_port_id, 11850 (void *)&cmd_flow_director_mode, 11851 (void *)&cmd_flow_director_mode_raw, 11852 (void *)&cmd_flow_director_ops, 11853 (void *)&cmd_flow_director_flow, 11854 (void *)&cmd_flow_director_flow_type, 11855 (void *)&cmd_flow_director_drop, 11856 (void *)&cmd_flow_director_queue, 11857 (void *)&cmd_flow_director_queue_id, 11858 (void *)&cmd_flow_director_fd_id, 11859 (void *)&cmd_flow_director_fd_id_value, 11860 (void *)&cmd_flow_director_packet, 11861 (void *)&cmd_flow_director_filepath, 11862 NULL, 11863 }, 11864 }; 11865 11866 struct cmd_flush_flow_director_result { 11867 cmdline_fixed_string_t flush_flow_director; 11868 portid_t port_id; 11869 }; 11870 11871 cmdline_parse_token_string_t cmd_flush_flow_director_flush = 11872 TOKEN_STRING_INITIALIZER(struct cmd_flush_flow_director_result, 11873 flush_flow_director, "flush_flow_director"); 11874 cmdline_parse_token_num_t cmd_flush_flow_director_port_id = 11875 TOKEN_NUM_INITIALIZER(struct cmd_flush_flow_director_result, 11876 port_id, UINT16); 11877 11878 static void 11879 cmd_flush_flow_director_parsed(void *parsed_result, 11880 __rte_unused struct cmdline *cl, 11881 __rte_unused void *data) 11882 { 11883 struct cmd_flow_director_result *res = parsed_result; 11884 int ret = 0; 11885 11886 ret = rte_eth_dev_filter_supported(res->port_id, RTE_ETH_FILTER_FDIR); 11887 if (ret < 0) { 11888 printf("flow director is not supported on port %u.\n", 11889 res->port_id); 11890 return; 11891 } 11892 11893 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_FDIR, 11894 RTE_ETH_FILTER_FLUSH, NULL); 11895 if (ret < 0) 11896 printf("flow director table flushing error: (%s)\n", 11897 strerror(-ret)); 11898 } 11899 11900 cmdline_parse_inst_t cmd_flush_flow_director = { 11901 .f = cmd_flush_flow_director_parsed, 11902 .data = NULL, 11903 .help_str = "flush_flow_director <port_id>: " 11904 "Flush all flow director entries of a device on NIC", 11905 .tokens = { 11906 (void *)&cmd_flush_flow_director_flush, 11907 (void *)&cmd_flush_flow_director_port_id, 11908 NULL, 11909 }, 11910 }; 11911 11912 /* *** deal with flow director mask *** */ 11913 struct cmd_flow_director_mask_result { 11914 cmdline_fixed_string_t flow_director_mask; 11915 portid_t port_id; 11916 cmdline_fixed_string_t mode; 11917 cmdline_fixed_string_t mode_value; 11918 cmdline_fixed_string_t vlan; 11919 uint16_t vlan_mask; 11920 cmdline_fixed_string_t src_mask; 11921 cmdline_ipaddr_t ipv4_src; 11922 cmdline_ipaddr_t ipv6_src; 11923 uint16_t port_src; 11924 cmdline_fixed_string_t dst_mask; 11925 cmdline_ipaddr_t ipv4_dst; 11926 cmdline_ipaddr_t ipv6_dst; 11927 uint16_t port_dst; 11928 cmdline_fixed_string_t mac; 11929 uint8_t mac_addr_byte_mask; 11930 cmdline_fixed_string_t tunnel_id; 11931 uint32_t tunnel_id_mask; 11932 cmdline_fixed_string_t tunnel_type; 11933 uint8_t tunnel_type_mask; 11934 }; 11935 11936 static void 11937 cmd_flow_director_mask_parsed(void *parsed_result, 11938 __rte_unused struct cmdline *cl, 11939 __rte_unused void *data) 11940 { 11941 struct cmd_flow_director_mask_result *res = parsed_result; 11942 struct rte_eth_fdir_masks *mask; 11943 struct rte_port *port; 11944 11945 port = &ports[res->port_id]; 11946 /** Check if the port is not started **/ 11947 if (port->port_status != RTE_PORT_STOPPED) { 11948 printf("Please stop port %d first\n", res->port_id); 11949 return; 11950 } 11951 11952 mask = &port->dev_conf.fdir_conf.mask; 11953 11954 if (fdir_conf.mode == RTE_FDIR_MODE_PERFECT_MAC_VLAN) { 11955 if (strcmp(res->mode_value, "MAC-VLAN")) { 11956 printf("Please set mode to MAC-VLAN.\n"); 11957 return; 11958 } 11959 11960 mask->vlan_tci_mask = rte_cpu_to_be_16(res->vlan_mask); 11961 } else if (fdir_conf.mode == RTE_FDIR_MODE_PERFECT_TUNNEL) { 11962 if (strcmp(res->mode_value, "Tunnel")) { 11963 printf("Please set mode to Tunnel.\n"); 11964 return; 11965 } 11966 11967 mask->vlan_tci_mask = rte_cpu_to_be_16(res->vlan_mask); 11968 mask->mac_addr_byte_mask = res->mac_addr_byte_mask; 11969 mask->tunnel_id_mask = rte_cpu_to_be_32(res->tunnel_id_mask); 11970 mask->tunnel_type_mask = res->tunnel_type_mask; 11971 } else { 11972 if (strcmp(res->mode_value, "IP")) { 11973 printf("Please set mode to IP.\n"); 11974 return; 11975 } 11976 11977 mask->vlan_tci_mask = rte_cpu_to_be_16(res->vlan_mask); 11978 IPV4_ADDR_TO_UINT(res->ipv4_src, mask->ipv4_mask.src_ip); 11979 IPV4_ADDR_TO_UINT(res->ipv4_dst, mask->ipv4_mask.dst_ip); 11980 IPV6_ADDR_TO_ARRAY(res->ipv6_src, mask->ipv6_mask.src_ip); 11981 IPV6_ADDR_TO_ARRAY(res->ipv6_dst, mask->ipv6_mask.dst_ip); 11982 mask->src_port_mask = rte_cpu_to_be_16(res->port_src); 11983 mask->dst_port_mask = rte_cpu_to_be_16(res->port_dst); 11984 } 11985 11986 cmd_reconfig_device_queue(res->port_id, 1, 1); 11987 } 11988 11989 cmdline_parse_token_string_t cmd_flow_director_mask = 11990 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result, 11991 flow_director_mask, "flow_director_mask"); 11992 cmdline_parse_token_num_t cmd_flow_director_mask_port_id = 11993 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_mask_result, 11994 port_id, UINT16); 11995 cmdline_parse_token_string_t cmd_flow_director_mask_vlan = 11996 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result, 11997 vlan, "vlan"); 11998 cmdline_parse_token_num_t cmd_flow_director_mask_vlan_value = 11999 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_mask_result, 12000 vlan_mask, UINT16); 12001 cmdline_parse_token_string_t cmd_flow_director_mask_src = 12002 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result, 12003 src_mask, "src_mask"); 12004 cmdline_parse_token_ipaddr_t cmd_flow_director_mask_ipv4_src = 12005 TOKEN_IPADDR_INITIALIZER(struct cmd_flow_director_mask_result, 12006 ipv4_src); 12007 cmdline_parse_token_ipaddr_t cmd_flow_director_mask_ipv6_src = 12008 TOKEN_IPADDR_INITIALIZER(struct cmd_flow_director_mask_result, 12009 ipv6_src); 12010 cmdline_parse_token_num_t cmd_flow_director_mask_port_src = 12011 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_mask_result, 12012 port_src, UINT16); 12013 cmdline_parse_token_string_t cmd_flow_director_mask_dst = 12014 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result, 12015 dst_mask, "dst_mask"); 12016 cmdline_parse_token_ipaddr_t cmd_flow_director_mask_ipv4_dst = 12017 TOKEN_IPADDR_INITIALIZER(struct cmd_flow_director_mask_result, 12018 ipv4_dst); 12019 cmdline_parse_token_ipaddr_t cmd_flow_director_mask_ipv6_dst = 12020 TOKEN_IPADDR_INITIALIZER(struct cmd_flow_director_mask_result, 12021 ipv6_dst); 12022 cmdline_parse_token_num_t cmd_flow_director_mask_port_dst = 12023 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_mask_result, 12024 port_dst, UINT16); 12025 12026 cmdline_parse_token_string_t cmd_flow_director_mask_mode = 12027 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result, 12028 mode, "mode"); 12029 cmdline_parse_token_string_t cmd_flow_director_mask_mode_ip = 12030 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result, 12031 mode_value, "IP"); 12032 cmdline_parse_token_string_t cmd_flow_director_mask_mode_mac_vlan = 12033 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result, 12034 mode_value, "MAC-VLAN"); 12035 cmdline_parse_token_string_t cmd_flow_director_mask_mode_tunnel = 12036 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result, 12037 mode_value, "Tunnel"); 12038 cmdline_parse_token_string_t cmd_flow_director_mask_mac = 12039 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result, 12040 mac, "mac"); 12041 cmdline_parse_token_num_t cmd_flow_director_mask_mac_value = 12042 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_mask_result, 12043 mac_addr_byte_mask, UINT8); 12044 cmdline_parse_token_string_t cmd_flow_director_mask_tunnel_type = 12045 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result, 12046 tunnel_type, "tunnel-type"); 12047 cmdline_parse_token_num_t cmd_flow_director_mask_tunnel_type_value = 12048 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_mask_result, 12049 tunnel_type_mask, UINT8); 12050 cmdline_parse_token_string_t cmd_flow_director_mask_tunnel_id = 12051 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result, 12052 tunnel_id, "tunnel-id"); 12053 cmdline_parse_token_num_t cmd_flow_director_mask_tunnel_id_value = 12054 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_mask_result, 12055 tunnel_id_mask, UINT32); 12056 12057 cmdline_parse_inst_t cmd_set_flow_director_ip_mask = { 12058 .f = cmd_flow_director_mask_parsed, 12059 .data = NULL, 12060 .help_str = "flow_director_mask ... : " 12061 "Set IP mode flow director's mask on NIC", 12062 .tokens = { 12063 (void *)&cmd_flow_director_mask, 12064 (void *)&cmd_flow_director_mask_port_id, 12065 (void *)&cmd_flow_director_mask_mode, 12066 (void *)&cmd_flow_director_mask_mode_ip, 12067 (void *)&cmd_flow_director_mask_vlan, 12068 (void *)&cmd_flow_director_mask_vlan_value, 12069 (void *)&cmd_flow_director_mask_src, 12070 (void *)&cmd_flow_director_mask_ipv4_src, 12071 (void *)&cmd_flow_director_mask_ipv6_src, 12072 (void *)&cmd_flow_director_mask_port_src, 12073 (void *)&cmd_flow_director_mask_dst, 12074 (void *)&cmd_flow_director_mask_ipv4_dst, 12075 (void *)&cmd_flow_director_mask_ipv6_dst, 12076 (void *)&cmd_flow_director_mask_port_dst, 12077 NULL, 12078 }, 12079 }; 12080 12081 cmdline_parse_inst_t cmd_set_flow_director_mac_vlan_mask = { 12082 .f = cmd_flow_director_mask_parsed, 12083 .data = NULL, 12084 .help_str = "flow_director_mask ... : Set MAC VLAN mode " 12085 "flow director's mask on NIC", 12086 .tokens = { 12087 (void *)&cmd_flow_director_mask, 12088 (void *)&cmd_flow_director_mask_port_id, 12089 (void *)&cmd_flow_director_mask_mode, 12090 (void *)&cmd_flow_director_mask_mode_mac_vlan, 12091 (void *)&cmd_flow_director_mask_vlan, 12092 (void *)&cmd_flow_director_mask_vlan_value, 12093 NULL, 12094 }, 12095 }; 12096 12097 cmdline_parse_inst_t cmd_set_flow_director_tunnel_mask = { 12098 .f = cmd_flow_director_mask_parsed, 12099 .data = NULL, 12100 .help_str = "flow_director_mask ... : Set tunnel mode " 12101 "flow director's mask on NIC", 12102 .tokens = { 12103 (void *)&cmd_flow_director_mask, 12104 (void *)&cmd_flow_director_mask_port_id, 12105 (void *)&cmd_flow_director_mask_mode, 12106 (void *)&cmd_flow_director_mask_mode_tunnel, 12107 (void *)&cmd_flow_director_mask_vlan, 12108 (void *)&cmd_flow_director_mask_vlan_value, 12109 (void *)&cmd_flow_director_mask_mac, 12110 (void *)&cmd_flow_director_mask_mac_value, 12111 (void *)&cmd_flow_director_mask_tunnel_type, 12112 (void *)&cmd_flow_director_mask_tunnel_type_value, 12113 (void *)&cmd_flow_director_mask_tunnel_id, 12114 (void *)&cmd_flow_director_mask_tunnel_id_value, 12115 NULL, 12116 }, 12117 }; 12118 12119 /* *** deal with flow director mask on flexible payload *** */ 12120 struct cmd_flow_director_flex_mask_result { 12121 cmdline_fixed_string_t flow_director_flexmask; 12122 portid_t port_id; 12123 cmdline_fixed_string_t flow; 12124 cmdline_fixed_string_t flow_type; 12125 cmdline_fixed_string_t mask; 12126 }; 12127 12128 static void 12129 cmd_flow_director_flex_mask_parsed(void *parsed_result, 12130 __rte_unused struct cmdline *cl, 12131 __rte_unused void *data) 12132 { 12133 struct cmd_flow_director_flex_mask_result *res = parsed_result; 12134 struct rte_eth_fdir_info fdir_info; 12135 struct rte_eth_fdir_flex_mask flex_mask; 12136 struct rte_port *port; 12137 uint64_t flow_type_mask; 12138 uint16_t i; 12139 int ret; 12140 12141 port = &ports[res->port_id]; 12142 /** Check if the port is not started **/ 12143 if (port->port_status != RTE_PORT_STOPPED) { 12144 printf("Please stop port %d first\n", res->port_id); 12145 return; 12146 } 12147 12148 memset(&flex_mask, 0, sizeof(struct rte_eth_fdir_flex_mask)); 12149 ret = parse_flexbytes(res->mask, 12150 flex_mask.mask, 12151 RTE_ETH_FDIR_MAX_FLEXLEN); 12152 if (ret < 0) { 12153 printf("error: Cannot parse mask input.\n"); 12154 return; 12155 } 12156 12157 memset(&fdir_info, 0, sizeof(fdir_info)); 12158 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_FDIR, 12159 RTE_ETH_FILTER_INFO, &fdir_info); 12160 if (ret < 0) { 12161 printf("Cannot get FDir filter info\n"); 12162 return; 12163 } 12164 12165 if (!strcmp(res->flow_type, "none")) { 12166 /* means don't specify the flow type */ 12167 flex_mask.flow_type = RTE_ETH_FLOW_UNKNOWN; 12168 for (i = 0; i < RTE_ETH_FLOW_MAX; i++) 12169 memset(&port->dev_conf.fdir_conf.flex_conf.flex_mask[i], 12170 0, sizeof(struct rte_eth_fdir_flex_mask)); 12171 port->dev_conf.fdir_conf.flex_conf.nb_flexmasks = 1; 12172 rte_memcpy(&port->dev_conf.fdir_conf.flex_conf.flex_mask[0], 12173 &flex_mask, 12174 sizeof(struct rte_eth_fdir_flex_mask)); 12175 cmd_reconfig_device_queue(res->port_id, 1, 1); 12176 return; 12177 } 12178 flow_type_mask = fdir_info.flow_types_mask[0]; 12179 if (!strcmp(res->flow_type, "all")) { 12180 if (!flow_type_mask) { 12181 printf("No flow type supported\n"); 12182 return; 12183 } 12184 for (i = RTE_ETH_FLOW_UNKNOWN; i < RTE_ETH_FLOW_MAX; i++) { 12185 if (flow_type_mask & (1ULL << i)) { 12186 flex_mask.flow_type = i; 12187 fdir_set_flex_mask(res->port_id, &flex_mask); 12188 } 12189 } 12190 cmd_reconfig_device_queue(res->port_id, 1, 1); 12191 return; 12192 } 12193 flex_mask.flow_type = str2flowtype(res->flow_type); 12194 if (!(flow_type_mask & (1ULL << flex_mask.flow_type))) { 12195 printf("Flow type %s not supported on port %d\n", 12196 res->flow_type, res->port_id); 12197 return; 12198 } 12199 fdir_set_flex_mask(res->port_id, &flex_mask); 12200 cmd_reconfig_device_queue(res->port_id, 1, 1); 12201 } 12202 12203 cmdline_parse_token_string_t cmd_flow_director_flexmask = 12204 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_flex_mask_result, 12205 flow_director_flexmask, 12206 "flow_director_flex_mask"); 12207 cmdline_parse_token_num_t cmd_flow_director_flexmask_port_id = 12208 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_flex_mask_result, 12209 port_id, UINT16); 12210 cmdline_parse_token_string_t cmd_flow_director_flexmask_flow = 12211 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_flex_mask_result, 12212 flow, "flow"); 12213 cmdline_parse_token_string_t cmd_flow_director_flexmask_flow_type = 12214 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_flex_mask_result, 12215 flow_type, "none#ipv4-other#ipv4-frag#ipv4-tcp#ipv4-udp#ipv4-sctp#" 12216 "ipv6-other#ipv6-frag#ipv6-tcp#ipv6-udp#ipv6-sctp#l2_payload#all"); 12217 cmdline_parse_token_string_t cmd_flow_director_flexmask_mask = 12218 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_flex_mask_result, 12219 mask, NULL); 12220 12221 cmdline_parse_inst_t cmd_set_flow_director_flex_mask = { 12222 .f = cmd_flow_director_flex_mask_parsed, 12223 .data = NULL, 12224 .help_str = "flow_director_flex_mask ... : " 12225 "Set flow director's flex mask on NIC", 12226 .tokens = { 12227 (void *)&cmd_flow_director_flexmask, 12228 (void *)&cmd_flow_director_flexmask_port_id, 12229 (void *)&cmd_flow_director_flexmask_flow, 12230 (void *)&cmd_flow_director_flexmask_flow_type, 12231 (void *)&cmd_flow_director_flexmask_mask, 12232 NULL, 12233 }, 12234 }; 12235 12236 /* *** deal with flow director flexible payload configuration *** */ 12237 struct cmd_flow_director_flexpayload_result { 12238 cmdline_fixed_string_t flow_director_flexpayload; 12239 portid_t port_id; 12240 cmdline_fixed_string_t payload_layer; 12241 cmdline_fixed_string_t payload_cfg; 12242 }; 12243 12244 static inline int 12245 parse_offsets(const char *q_arg, uint16_t *offsets, uint16_t max_num) 12246 { 12247 char s[256]; 12248 const char *p, *p0 = q_arg; 12249 char *end; 12250 unsigned long int_fld; 12251 char *str_fld[max_num]; 12252 int i; 12253 unsigned size; 12254 int ret = -1; 12255 12256 p = strchr(p0, '('); 12257 if (p == NULL) 12258 return -1; 12259 ++p; 12260 p0 = strchr(p, ')'); 12261 if (p0 == NULL) 12262 return -1; 12263 12264 size = p0 - p; 12265 if (size >= sizeof(s)) 12266 return -1; 12267 12268 snprintf(s, sizeof(s), "%.*s", size, p); 12269 ret = rte_strsplit(s, sizeof(s), str_fld, max_num, ','); 12270 if (ret < 0 || ret > max_num) 12271 return -1; 12272 for (i = 0; i < ret; i++) { 12273 errno = 0; 12274 int_fld = strtoul(str_fld[i], &end, 0); 12275 if (errno != 0 || *end != '\0' || int_fld > UINT16_MAX) 12276 return -1; 12277 offsets[i] = (uint16_t)int_fld; 12278 } 12279 return ret; 12280 } 12281 12282 static void 12283 cmd_flow_director_flxpld_parsed(void *parsed_result, 12284 __rte_unused struct cmdline *cl, 12285 __rte_unused void *data) 12286 { 12287 struct cmd_flow_director_flexpayload_result *res = parsed_result; 12288 struct rte_eth_flex_payload_cfg flex_cfg; 12289 struct rte_port *port; 12290 int ret = 0; 12291 12292 port = &ports[res->port_id]; 12293 /** Check if the port is not started **/ 12294 if (port->port_status != RTE_PORT_STOPPED) { 12295 printf("Please stop port %d first\n", res->port_id); 12296 return; 12297 } 12298 12299 memset(&flex_cfg, 0, sizeof(struct rte_eth_flex_payload_cfg)); 12300 12301 if (!strcmp(res->payload_layer, "raw")) 12302 flex_cfg.type = RTE_ETH_RAW_PAYLOAD; 12303 else if (!strcmp(res->payload_layer, "l2")) 12304 flex_cfg.type = RTE_ETH_L2_PAYLOAD; 12305 else if (!strcmp(res->payload_layer, "l3")) 12306 flex_cfg.type = RTE_ETH_L3_PAYLOAD; 12307 else if (!strcmp(res->payload_layer, "l4")) 12308 flex_cfg.type = RTE_ETH_L4_PAYLOAD; 12309 12310 ret = parse_offsets(res->payload_cfg, flex_cfg.src_offset, 12311 RTE_ETH_FDIR_MAX_FLEXLEN); 12312 if (ret < 0) { 12313 printf("error: Cannot parse flex payload input.\n"); 12314 return; 12315 } 12316 12317 fdir_set_flex_payload(res->port_id, &flex_cfg); 12318 cmd_reconfig_device_queue(res->port_id, 1, 1); 12319 } 12320 12321 cmdline_parse_token_string_t cmd_flow_director_flexpayload = 12322 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_flexpayload_result, 12323 flow_director_flexpayload, 12324 "flow_director_flex_payload"); 12325 cmdline_parse_token_num_t cmd_flow_director_flexpayload_port_id = 12326 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_flexpayload_result, 12327 port_id, UINT16); 12328 cmdline_parse_token_string_t cmd_flow_director_flexpayload_payload_layer = 12329 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_flexpayload_result, 12330 payload_layer, "raw#l2#l3#l4"); 12331 cmdline_parse_token_string_t cmd_flow_director_flexpayload_payload_cfg = 12332 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_flexpayload_result, 12333 payload_cfg, NULL); 12334 12335 cmdline_parse_inst_t cmd_set_flow_director_flex_payload = { 12336 .f = cmd_flow_director_flxpld_parsed, 12337 .data = NULL, 12338 .help_str = "flow_director_flexpayload ... : " 12339 "Set flow director's flex payload on NIC", 12340 .tokens = { 12341 (void *)&cmd_flow_director_flexpayload, 12342 (void *)&cmd_flow_director_flexpayload_port_id, 12343 (void *)&cmd_flow_director_flexpayload_payload_layer, 12344 (void *)&cmd_flow_director_flexpayload_payload_cfg, 12345 NULL, 12346 }, 12347 }; 12348 12349 /* Generic flow interface command. */ 12350 extern cmdline_parse_inst_t cmd_flow; 12351 12352 /* *** Classification Filters Control *** */ 12353 /* *** Get symmetric hash enable per port *** */ 12354 struct cmd_get_sym_hash_ena_per_port_result { 12355 cmdline_fixed_string_t get_sym_hash_ena_per_port; 12356 portid_t port_id; 12357 }; 12358 12359 static void 12360 cmd_get_sym_hash_per_port_parsed(void *parsed_result, 12361 __rte_unused struct cmdline *cl, 12362 __rte_unused void *data) 12363 { 12364 struct cmd_get_sym_hash_ena_per_port_result *res = parsed_result; 12365 struct rte_eth_hash_filter_info info; 12366 int ret; 12367 12368 if (rte_eth_dev_filter_supported(res->port_id, 12369 RTE_ETH_FILTER_HASH) < 0) { 12370 printf("RTE_ETH_FILTER_HASH not supported on port: %d\n", 12371 res->port_id); 12372 return; 12373 } 12374 12375 memset(&info, 0, sizeof(info)); 12376 info.info_type = RTE_ETH_HASH_FILTER_SYM_HASH_ENA_PER_PORT; 12377 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_HASH, 12378 RTE_ETH_FILTER_GET, &info); 12379 12380 if (ret < 0) { 12381 printf("Cannot get symmetric hash enable per port " 12382 "on port %u\n", res->port_id); 12383 return; 12384 } 12385 12386 printf("Symmetric hash is %s on port %u\n", info.info.enable ? 12387 "enabled" : "disabled", res->port_id); 12388 } 12389 12390 cmdline_parse_token_string_t cmd_get_sym_hash_ena_per_port_all = 12391 TOKEN_STRING_INITIALIZER(struct cmd_get_sym_hash_ena_per_port_result, 12392 get_sym_hash_ena_per_port, "get_sym_hash_ena_per_port"); 12393 cmdline_parse_token_num_t cmd_get_sym_hash_ena_per_port_port_id = 12394 TOKEN_NUM_INITIALIZER(struct cmd_get_sym_hash_ena_per_port_result, 12395 port_id, UINT16); 12396 12397 cmdline_parse_inst_t cmd_get_sym_hash_ena_per_port = { 12398 .f = cmd_get_sym_hash_per_port_parsed, 12399 .data = NULL, 12400 .help_str = "get_sym_hash_ena_per_port <port_id>", 12401 .tokens = { 12402 (void *)&cmd_get_sym_hash_ena_per_port_all, 12403 (void *)&cmd_get_sym_hash_ena_per_port_port_id, 12404 NULL, 12405 }, 12406 }; 12407 12408 /* *** Set symmetric hash enable per port *** */ 12409 struct cmd_set_sym_hash_ena_per_port_result { 12410 cmdline_fixed_string_t set_sym_hash_ena_per_port; 12411 cmdline_fixed_string_t enable; 12412 portid_t port_id; 12413 }; 12414 12415 static void 12416 cmd_set_sym_hash_per_port_parsed(void *parsed_result, 12417 __rte_unused struct cmdline *cl, 12418 __rte_unused void *data) 12419 { 12420 struct cmd_set_sym_hash_ena_per_port_result *res = parsed_result; 12421 struct rte_eth_hash_filter_info info; 12422 int ret; 12423 12424 if (rte_eth_dev_filter_supported(res->port_id, 12425 RTE_ETH_FILTER_HASH) < 0) { 12426 printf("RTE_ETH_FILTER_HASH not supported on port: %d\n", 12427 res->port_id); 12428 return; 12429 } 12430 12431 memset(&info, 0, sizeof(info)); 12432 info.info_type = RTE_ETH_HASH_FILTER_SYM_HASH_ENA_PER_PORT; 12433 if (!strcmp(res->enable, "enable")) 12434 info.info.enable = 1; 12435 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_HASH, 12436 RTE_ETH_FILTER_SET, &info); 12437 if (ret < 0) { 12438 printf("Cannot set symmetric hash enable per port on " 12439 "port %u\n", res->port_id); 12440 return; 12441 } 12442 printf("Symmetric hash has been set to %s on port %u\n", 12443 res->enable, res->port_id); 12444 } 12445 12446 cmdline_parse_token_string_t cmd_set_sym_hash_ena_per_port_all = 12447 TOKEN_STRING_INITIALIZER(struct cmd_set_sym_hash_ena_per_port_result, 12448 set_sym_hash_ena_per_port, "set_sym_hash_ena_per_port"); 12449 cmdline_parse_token_num_t cmd_set_sym_hash_ena_per_port_port_id = 12450 TOKEN_NUM_INITIALIZER(struct cmd_set_sym_hash_ena_per_port_result, 12451 port_id, UINT16); 12452 cmdline_parse_token_string_t cmd_set_sym_hash_ena_per_port_enable = 12453 TOKEN_STRING_INITIALIZER(struct cmd_set_sym_hash_ena_per_port_result, 12454 enable, "enable#disable"); 12455 12456 cmdline_parse_inst_t cmd_set_sym_hash_ena_per_port = { 12457 .f = cmd_set_sym_hash_per_port_parsed, 12458 .data = NULL, 12459 .help_str = "set_sym_hash_ena_per_port <port_id> enable|disable", 12460 .tokens = { 12461 (void *)&cmd_set_sym_hash_ena_per_port_all, 12462 (void *)&cmd_set_sym_hash_ena_per_port_port_id, 12463 (void *)&cmd_set_sym_hash_ena_per_port_enable, 12464 NULL, 12465 }, 12466 }; 12467 12468 /* Get global config of hash function */ 12469 struct cmd_get_hash_global_config_result { 12470 cmdline_fixed_string_t get_hash_global_config; 12471 portid_t port_id; 12472 }; 12473 12474 static char * 12475 flowtype_to_str(uint16_t ftype) 12476 { 12477 uint16_t i; 12478 static struct { 12479 char str[16]; 12480 uint16_t ftype; 12481 } ftype_table[] = { 12482 {"ipv4", RTE_ETH_FLOW_IPV4}, 12483 {"ipv4-frag", RTE_ETH_FLOW_FRAG_IPV4}, 12484 {"ipv4-tcp", RTE_ETH_FLOW_NONFRAG_IPV4_TCP}, 12485 {"ipv4-udp", RTE_ETH_FLOW_NONFRAG_IPV4_UDP}, 12486 {"ipv4-sctp", RTE_ETH_FLOW_NONFRAG_IPV4_SCTP}, 12487 {"ipv4-other", RTE_ETH_FLOW_NONFRAG_IPV4_OTHER}, 12488 {"ipv6", RTE_ETH_FLOW_IPV6}, 12489 {"ipv6-frag", RTE_ETH_FLOW_FRAG_IPV6}, 12490 {"ipv6-tcp", RTE_ETH_FLOW_NONFRAG_IPV6_TCP}, 12491 {"ipv6-udp", RTE_ETH_FLOW_NONFRAG_IPV6_UDP}, 12492 {"ipv6-sctp", RTE_ETH_FLOW_NONFRAG_IPV6_SCTP}, 12493 {"ipv6-other", RTE_ETH_FLOW_NONFRAG_IPV6_OTHER}, 12494 {"l2_payload", RTE_ETH_FLOW_L2_PAYLOAD}, 12495 {"port", RTE_ETH_FLOW_PORT}, 12496 {"vxlan", RTE_ETH_FLOW_VXLAN}, 12497 {"geneve", RTE_ETH_FLOW_GENEVE}, 12498 {"nvgre", RTE_ETH_FLOW_NVGRE}, 12499 {"vxlan-gpe", RTE_ETH_FLOW_VXLAN_GPE}, 12500 }; 12501 12502 for (i = 0; i < RTE_DIM(ftype_table); i++) { 12503 if (ftype_table[i].ftype == ftype) 12504 return ftype_table[i].str; 12505 } 12506 12507 return NULL; 12508 } 12509 12510 static void 12511 cmd_get_hash_global_config_parsed(void *parsed_result, 12512 __rte_unused struct cmdline *cl, 12513 __rte_unused void *data) 12514 { 12515 struct cmd_get_hash_global_config_result *res = parsed_result; 12516 struct rte_eth_hash_filter_info info; 12517 uint32_t idx, offset; 12518 uint16_t i; 12519 char *str; 12520 int ret; 12521 12522 if (rte_eth_dev_filter_supported(res->port_id, 12523 RTE_ETH_FILTER_HASH) < 0) { 12524 printf("RTE_ETH_FILTER_HASH not supported on port %d\n", 12525 res->port_id); 12526 return; 12527 } 12528 12529 memset(&info, 0, sizeof(info)); 12530 info.info_type = RTE_ETH_HASH_FILTER_GLOBAL_CONFIG; 12531 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_HASH, 12532 RTE_ETH_FILTER_GET, &info); 12533 if (ret < 0) { 12534 printf("Cannot get hash global configurations by port %d\n", 12535 res->port_id); 12536 return; 12537 } 12538 12539 switch (info.info.global_conf.hash_func) { 12540 case RTE_ETH_HASH_FUNCTION_TOEPLITZ: 12541 printf("Hash function is Toeplitz\n"); 12542 break; 12543 case RTE_ETH_HASH_FUNCTION_SIMPLE_XOR: 12544 printf("Hash function is Simple XOR\n"); 12545 break; 12546 case RTE_ETH_HASH_FUNCTION_SYMMETRIC_TOEPLITZ: 12547 printf("Hash function is Symmetric Toeplitz\n"); 12548 break; 12549 default: 12550 printf("Unknown hash function\n"); 12551 break; 12552 } 12553 12554 for (i = 0; i < RTE_ETH_FLOW_MAX; i++) { 12555 idx = i / UINT64_BIT; 12556 offset = i % UINT64_BIT; 12557 if (!(info.info.global_conf.valid_bit_mask[idx] & 12558 (1ULL << offset))) 12559 continue; 12560 str = flowtype_to_str(i); 12561 if (!str) 12562 continue; 12563 printf("Symmetric hash is %s globally for flow type %s " 12564 "by port %d\n", 12565 ((info.info.global_conf.sym_hash_enable_mask[idx] & 12566 (1ULL << offset)) ? "enabled" : "disabled"), str, 12567 res->port_id); 12568 } 12569 } 12570 12571 cmdline_parse_token_string_t cmd_get_hash_global_config_all = 12572 TOKEN_STRING_INITIALIZER(struct cmd_get_hash_global_config_result, 12573 get_hash_global_config, "get_hash_global_config"); 12574 cmdline_parse_token_num_t cmd_get_hash_global_config_port_id = 12575 TOKEN_NUM_INITIALIZER(struct cmd_get_hash_global_config_result, 12576 port_id, UINT16); 12577 12578 cmdline_parse_inst_t cmd_get_hash_global_config = { 12579 .f = cmd_get_hash_global_config_parsed, 12580 .data = NULL, 12581 .help_str = "get_hash_global_config <port_id>", 12582 .tokens = { 12583 (void *)&cmd_get_hash_global_config_all, 12584 (void *)&cmd_get_hash_global_config_port_id, 12585 NULL, 12586 }, 12587 }; 12588 12589 /* Set global config of hash function */ 12590 struct cmd_set_hash_global_config_result { 12591 cmdline_fixed_string_t set_hash_global_config; 12592 portid_t port_id; 12593 cmdline_fixed_string_t hash_func; 12594 cmdline_fixed_string_t flow_type; 12595 cmdline_fixed_string_t enable; 12596 }; 12597 12598 static void 12599 cmd_set_hash_global_config_parsed(void *parsed_result, 12600 __rte_unused struct cmdline *cl, 12601 __rte_unused void *data) 12602 { 12603 struct cmd_set_hash_global_config_result *res = parsed_result; 12604 struct rte_eth_hash_filter_info info; 12605 uint32_t ftype, idx, offset; 12606 int ret; 12607 12608 if (rte_eth_dev_filter_supported(res->port_id, 12609 RTE_ETH_FILTER_HASH) < 0) { 12610 printf("RTE_ETH_FILTER_HASH not supported on port %d\n", 12611 res->port_id); 12612 return; 12613 } 12614 memset(&info, 0, sizeof(info)); 12615 info.info_type = RTE_ETH_HASH_FILTER_GLOBAL_CONFIG; 12616 if (!strcmp(res->hash_func, "toeplitz")) 12617 info.info.global_conf.hash_func = 12618 RTE_ETH_HASH_FUNCTION_TOEPLITZ; 12619 else if (!strcmp(res->hash_func, "simple_xor")) 12620 info.info.global_conf.hash_func = 12621 RTE_ETH_HASH_FUNCTION_SIMPLE_XOR; 12622 else if (!strcmp(res->hash_func, "symmetric_toeplitz")) 12623 info.info.global_conf.hash_func = 12624 RTE_ETH_HASH_FUNCTION_SYMMETRIC_TOEPLITZ; 12625 else if (!strcmp(res->hash_func, "default")) 12626 info.info.global_conf.hash_func = 12627 RTE_ETH_HASH_FUNCTION_DEFAULT; 12628 12629 ftype = str2flowtype(res->flow_type); 12630 idx = ftype / UINT64_BIT; 12631 offset = ftype % UINT64_BIT; 12632 info.info.global_conf.valid_bit_mask[idx] |= (1ULL << offset); 12633 if (!strcmp(res->enable, "enable")) 12634 info.info.global_conf.sym_hash_enable_mask[idx] |= 12635 (1ULL << offset); 12636 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_HASH, 12637 RTE_ETH_FILTER_SET, &info); 12638 if (ret < 0) 12639 printf("Cannot set global hash configurations by port %d\n", 12640 res->port_id); 12641 else 12642 printf("Global hash configurations have been set " 12643 "successfully by port %d\n", res->port_id); 12644 } 12645 12646 cmdline_parse_token_string_t cmd_set_hash_global_config_all = 12647 TOKEN_STRING_INITIALIZER(struct cmd_set_hash_global_config_result, 12648 set_hash_global_config, "set_hash_global_config"); 12649 cmdline_parse_token_num_t cmd_set_hash_global_config_port_id = 12650 TOKEN_NUM_INITIALIZER(struct cmd_set_hash_global_config_result, 12651 port_id, UINT16); 12652 cmdline_parse_token_string_t cmd_set_hash_global_config_hash_func = 12653 TOKEN_STRING_INITIALIZER(struct cmd_set_hash_global_config_result, 12654 hash_func, "toeplitz#simple_xor#symmetric_toeplitz#default"); 12655 cmdline_parse_token_string_t cmd_set_hash_global_config_flow_type = 12656 TOKEN_STRING_INITIALIZER(struct cmd_set_hash_global_config_result, 12657 flow_type, 12658 "ipv4#ipv4-frag#ipv4-tcp#ipv4-udp#ipv4-sctp#ipv4-other#ipv6#" 12659 "ipv6-frag#ipv6-tcp#ipv6-udp#ipv6-sctp#ipv6-other#l2_payload"); 12660 cmdline_parse_token_string_t cmd_set_hash_global_config_enable = 12661 TOKEN_STRING_INITIALIZER(struct cmd_set_hash_global_config_result, 12662 enable, "enable#disable"); 12663 12664 cmdline_parse_inst_t cmd_set_hash_global_config = { 12665 .f = cmd_set_hash_global_config_parsed, 12666 .data = NULL, 12667 .help_str = "set_hash_global_config <port_id> " 12668 "toeplitz|simple_xor|symmetric_toeplitz|default " 12669 "ipv4|ipv4-frag|ipv4-tcp|ipv4-udp|ipv4-sctp|ipv4-other|" 12670 "ipv6|ipv6-frag|ipv6-tcp|ipv6-udp|ipv6-sctp|ipv6-other|" 12671 "l2_payload enable|disable", 12672 .tokens = { 12673 (void *)&cmd_set_hash_global_config_all, 12674 (void *)&cmd_set_hash_global_config_port_id, 12675 (void *)&cmd_set_hash_global_config_hash_func, 12676 (void *)&cmd_set_hash_global_config_flow_type, 12677 (void *)&cmd_set_hash_global_config_enable, 12678 NULL, 12679 }, 12680 }; 12681 12682 /* Set hash input set */ 12683 struct cmd_set_hash_input_set_result { 12684 cmdline_fixed_string_t set_hash_input_set; 12685 portid_t port_id; 12686 cmdline_fixed_string_t flow_type; 12687 cmdline_fixed_string_t inset_field; 12688 cmdline_fixed_string_t select; 12689 }; 12690 12691 static enum rte_eth_input_set_field 12692 str2inset(char *string) 12693 { 12694 uint16_t i; 12695 12696 static const struct { 12697 char str[32]; 12698 enum rte_eth_input_set_field inset; 12699 } inset_table[] = { 12700 {"ethertype", RTE_ETH_INPUT_SET_L2_ETHERTYPE}, 12701 {"ovlan", RTE_ETH_INPUT_SET_L2_OUTER_VLAN}, 12702 {"ivlan", RTE_ETH_INPUT_SET_L2_INNER_VLAN}, 12703 {"src-ipv4", RTE_ETH_INPUT_SET_L3_SRC_IP4}, 12704 {"dst-ipv4", RTE_ETH_INPUT_SET_L3_DST_IP4}, 12705 {"ipv4-tos", RTE_ETH_INPUT_SET_L3_IP4_TOS}, 12706 {"ipv4-proto", RTE_ETH_INPUT_SET_L3_IP4_PROTO}, 12707 {"ipv4-ttl", RTE_ETH_INPUT_SET_L3_IP4_TTL}, 12708 {"src-ipv6", RTE_ETH_INPUT_SET_L3_SRC_IP6}, 12709 {"dst-ipv6", RTE_ETH_INPUT_SET_L3_DST_IP6}, 12710 {"ipv6-tc", RTE_ETH_INPUT_SET_L3_IP6_TC}, 12711 {"ipv6-next-header", RTE_ETH_INPUT_SET_L3_IP6_NEXT_HEADER}, 12712 {"ipv6-hop-limits", RTE_ETH_INPUT_SET_L3_IP6_HOP_LIMITS}, 12713 {"udp-src-port", RTE_ETH_INPUT_SET_L4_UDP_SRC_PORT}, 12714 {"udp-dst-port", RTE_ETH_INPUT_SET_L4_UDP_DST_PORT}, 12715 {"tcp-src-port", RTE_ETH_INPUT_SET_L4_TCP_SRC_PORT}, 12716 {"tcp-dst-port", RTE_ETH_INPUT_SET_L4_TCP_DST_PORT}, 12717 {"sctp-src-port", RTE_ETH_INPUT_SET_L4_SCTP_SRC_PORT}, 12718 {"sctp-dst-port", RTE_ETH_INPUT_SET_L4_SCTP_DST_PORT}, 12719 {"sctp-veri-tag", RTE_ETH_INPUT_SET_L4_SCTP_VERIFICATION_TAG}, 12720 {"udp-key", RTE_ETH_INPUT_SET_TUNNEL_L4_UDP_KEY}, 12721 {"gre-key", RTE_ETH_INPUT_SET_TUNNEL_GRE_KEY}, 12722 {"fld-1st", RTE_ETH_INPUT_SET_FLEX_PAYLOAD_1ST_WORD}, 12723 {"fld-2nd", RTE_ETH_INPUT_SET_FLEX_PAYLOAD_2ND_WORD}, 12724 {"fld-3rd", RTE_ETH_INPUT_SET_FLEX_PAYLOAD_3RD_WORD}, 12725 {"fld-4th", RTE_ETH_INPUT_SET_FLEX_PAYLOAD_4TH_WORD}, 12726 {"fld-5th", RTE_ETH_INPUT_SET_FLEX_PAYLOAD_5TH_WORD}, 12727 {"fld-6th", RTE_ETH_INPUT_SET_FLEX_PAYLOAD_6TH_WORD}, 12728 {"fld-7th", RTE_ETH_INPUT_SET_FLEX_PAYLOAD_7TH_WORD}, 12729 {"fld-8th", RTE_ETH_INPUT_SET_FLEX_PAYLOAD_8TH_WORD}, 12730 {"none", RTE_ETH_INPUT_SET_NONE}, 12731 }; 12732 12733 for (i = 0; i < RTE_DIM(inset_table); i++) { 12734 if (!strcmp(string, inset_table[i].str)) 12735 return inset_table[i].inset; 12736 } 12737 12738 return RTE_ETH_INPUT_SET_UNKNOWN; 12739 } 12740 12741 static void 12742 cmd_set_hash_input_set_parsed(void *parsed_result, 12743 __rte_unused struct cmdline *cl, 12744 __rte_unused void *data) 12745 { 12746 struct cmd_set_hash_input_set_result *res = parsed_result; 12747 struct rte_eth_hash_filter_info info; 12748 12749 memset(&info, 0, sizeof(info)); 12750 info.info_type = RTE_ETH_HASH_FILTER_INPUT_SET_SELECT; 12751 info.info.input_set_conf.flow_type = str2flowtype(res->flow_type); 12752 info.info.input_set_conf.field[0] = str2inset(res->inset_field); 12753 info.info.input_set_conf.inset_size = 1; 12754 if (!strcmp(res->select, "select")) 12755 info.info.input_set_conf.op = RTE_ETH_INPUT_SET_SELECT; 12756 else if (!strcmp(res->select, "add")) 12757 info.info.input_set_conf.op = RTE_ETH_INPUT_SET_ADD; 12758 rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_HASH, 12759 RTE_ETH_FILTER_SET, &info); 12760 } 12761 12762 cmdline_parse_token_string_t cmd_set_hash_input_set_cmd = 12763 TOKEN_STRING_INITIALIZER(struct cmd_set_hash_input_set_result, 12764 set_hash_input_set, "set_hash_input_set"); 12765 cmdline_parse_token_num_t cmd_set_hash_input_set_port_id = 12766 TOKEN_NUM_INITIALIZER(struct cmd_set_hash_input_set_result, 12767 port_id, UINT16); 12768 cmdline_parse_token_string_t cmd_set_hash_input_set_flow_type = 12769 TOKEN_STRING_INITIALIZER(struct cmd_set_hash_input_set_result, 12770 flow_type, NULL); 12771 cmdline_parse_token_string_t cmd_set_hash_input_set_field = 12772 TOKEN_STRING_INITIALIZER(struct cmd_set_hash_input_set_result, 12773 inset_field, 12774 "ovlan#ivlan#src-ipv4#dst-ipv4#src-ipv6#dst-ipv6#" 12775 "ipv4-tos#ipv4-proto#ipv6-tc#ipv6-next-header#udp-src-port#" 12776 "udp-dst-port#tcp-src-port#tcp-dst-port#sctp-src-port#" 12777 "sctp-dst-port#sctp-veri-tag#udp-key#gre-key#fld-1st#" 12778 "fld-2nd#fld-3rd#fld-4th#fld-5th#fld-6th#fld-7th#" 12779 "fld-8th#none"); 12780 cmdline_parse_token_string_t cmd_set_hash_input_set_select = 12781 TOKEN_STRING_INITIALIZER(struct cmd_set_hash_input_set_result, 12782 select, "select#add"); 12783 12784 cmdline_parse_inst_t cmd_set_hash_input_set = { 12785 .f = cmd_set_hash_input_set_parsed, 12786 .data = NULL, 12787 .help_str = "set_hash_input_set <port_id> " 12788 "ipv4-frag|ipv4-tcp|ipv4-udp|ipv4-sctp|ipv4-other|" 12789 "ipv6-frag|ipv6-tcp|ipv6-udp|ipv6-sctp|ipv6-other|l2_payload|<flowtype_id> " 12790 "ovlan|ivlan|src-ipv4|dst-ipv4|src-ipv6|dst-ipv6|ipv4-tos|ipv4-proto|" 12791 "ipv6-tc|ipv6-next-header|udp-src-port|udp-dst-port|tcp-src-port|" 12792 "tcp-dst-port|sctp-src-port|sctp-dst-port|sctp-veri-tag|udp-key|" 12793 "gre-key|fld-1st|fld-2nd|fld-3rd|fld-4th|fld-5th|fld-6th|" 12794 "fld-7th|fld-8th|none select|add", 12795 .tokens = { 12796 (void *)&cmd_set_hash_input_set_cmd, 12797 (void *)&cmd_set_hash_input_set_port_id, 12798 (void *)&cmd_set_hash_input_set_flow_type, 12799 (void *)&cmd_set_hash_input_set_field, 12800 (void *)&cmd_set_hash_input_set_select, 12801 NULL, 12802 }, 12803 }; 12804 12805 /* Set flow director input set */ 12806 struct cmd_set_fdir_input_set_result { 12807 cmdline_fixed_string_t set_fdir_input_set; 12808 portid_t port_id; 12809 cmdline_fixed_string_t flow_type; 12810 cmdline_fixed_string_t inset_field; 12811 cmdline_fixed_string_t select; 12812 }; 12813 12814 static void 12815 cmd_set_fdir_input_set_parsed(void *parsed_result, 12816 __rte_unused struct cmdline *cl, 12817 __rte_unused void *data) 12818 { 12819 struct cmd_set_fdir_input_set_result *res = parsed_result; 12820 struct rte_eth_fdir_filter_info info; 12821 12822 memset(&info, 0, sizeof(info)); 12823 info.info_type = RTE_ETH_FDIR_FILTER_INPUT_SET_SELECT; 12824 info.info.input_set_conf.flow_type = str2flowtype(res->flow_type); 12825 info.info.input_set_conf.field[0] = str2inset(res->inset_field); 12826 info.info.input_set_conf.inset_size = 1; 12827 if (!strcmp(res->select, "select")) 12828 info.info.input_set_conf.op = RTE_ETH_INPUT_SET_SELECT; 12829 else if (!strcmp(res->select, "add")) 12830 info.info.input_set_conf.op = RTE_ETH_INPUT_SET_ADD; 12831 rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_FDIR, 12832 RTE_ETH_FILTER_SET, &info); 12833 } 12834 12835 cmdline_parse_token_string_t cmd_set_fdir_input_set_cmd = 12836 TOKEN_STRING_INITIALIZER(struct cmd_set_fdir_input_set_result, 12837 set_fdir_input_set, "set_fdir_input_set"); 12838 cmdline_parse_token_num_t cmd_set_fdir_input_set_port_id = 12839 TOKEN_NUM_INITIALIZER(struct cmd_set_fdir_input_set_result, 12840 port_id, UINT16); 12841 cmdline_parse_token_string_t cmd_set_fdir_input_set_flow_type = 12842 TOKEN_STRING_INITIALIZER(struct cmd_set_fdir_input_set_result, 12843 flow_type, 12844 "ipv4-frag#ipv4-tcp#ipv4-udp#ipv4-sctp#ipv4-other#" 12845 "ipv6-frag#ipv6-tcp#ipv6-udp#ipv6-sctp#ipv6-other#l2_payload"); 12846 cmdline_parse_token_string_t cmd_set_fdir_input_set_field = 12847 TOKEN_STRING_INITIALIZER(struct cmd_set_fdir_input_set_result, 12848 inset_field, 12849 "ivlan#ethertype#src-ipv4#dst-ipv4#src-ipv6#dst-ipv6#" 12850 "ipv4-tos#ipv4-proto#ipv4-ttl#ipv6-tc#ipv6-next-header#" 12851 "ipv6-hop-limits#udp-src-port#udp-dst-port#" 12852 "tcp-src-port#tcp-dst-port#sctp-src-port#sctp-dst-port#" 12853 "sctp-veri-tag#none"); 12854 cmdline_parse_token_string_t cmd_set_fdir_input_set_select = 12855 TOKEN_STRING_INITIALIZER(struct cmd_set_fdir_input_set_result, 12856 select, "select#add"); 12857 12858 cmdline_parse_inst_t cmd_set_fdir_input_set = { 12859 .f = cmd_set_fdir_input_set_parsed, 12860 .data = NULL, 12861 .help_str = "set_fdir_input_set <port_id> " 12862 "ipv4-frag|ipv4-tcp|ipv4-udp|ipv4-sctp|ipv4-other|" 12863 "ipv6-frag|ipv6-tcp|ipv6-udp|ipv6-sctp|ipv6-other|l2_payload " 12864 "ivlan|ethertype|src-ipv4|dst-ipv4|src-ipv6|dst-ipv6|" 12865 "ipv4-tos|ipv4-proto|ipv4-ttl|ipv6-tc|ipv6-next-header|" 12866 "ipv6-hop-limits|udp-src-port|udp-dst-port|" 12867 "tcp-src-port|tcp-dst-port|sctp-src-port|sctp-dst-port|" 12868 "sctp-veri-tag|none select|add", 12869 .tokens = { 12870 (void *)&cmd_set_fdir_input_set_cmd, 12871 (void *)&cmd_set_fdir_input_set_port_id, 12872 (void *)&cmd_set_fdir_input_set_flow_type, 12873 (void *)&cmd_set_fdir_input_set_field, 12874 (void *)&cmd_set_fdir_input_set_select, 12875 NULL, 12876 }, 12877 }; 12878 12879 /* *** ADD/REMOVE A MULTICAST MAC ADDRESS TO/FROM A PORT *** */ 12880 struct cmd_mcast_addr_result { 12881 cmdline_fixed_string_t mcast_addr_cmd; 12882 cmdline_fixed_string_t what; 12883 uint16_t port_num; 12884 struct rte_ether_addr mc_addr; 12885 }; 12886 12887 static void cmd_mcast_addr_parsed(void *parsed_result, 12888 __rte_unused struct cmdline *cl, 12889 __rte_unused void *data) 12890 { 12891 struct cmd_mcast_addr_result *res = parsed_result; 12892 12893 if (!rte_is_multicast_ether_addr(&res->mc_addr)) { 12894 printf("Invalid multicast addr %02X:%02X:%02X:%02X:%02X:%02X\n", 12895 res->mc_addr.addr_bytes[0], res->mc_addr.addr_bytes[1], 12896 res->mc_addr.addr_bytes[2], res->mc_addr.addr_bytes[3], 12897 res->mc_addr.addr_bytes[4], res->mc_addr.addr_bytes[5]); 12898 return; 12899 } 12900 if (strcmp(res->what, "add") == 0) 12901 mcast_addr_add(res->port_num, &res->mc_addr); 12902 else 12903 mcast_addr_remove(res->port_num, &res->mc_addr); 12904 } 12905 12906 cmdline_parse_token_string_t cmd_mcast_addr_cmd = 12907 TOKEN_STRING_INITIALIZER(struct cmd_mcast_addr_result, 12908 mcast_addr_cmd, "mcast_addr"); 12909 cmdline_parse_token_string_t cmd_mcast_addr_what = 12910 TOKEN_STRING_INITIALIZER(struct cmd_mcast_addr_result, what, 12911 "add#remove"); 12912 cmdline_parse_token_num_t cmd_mcast_addr_portnum = 12913 TOKEN_NUM_INITIALIZER(struct cmd_mcast_addr_result, port_num, UINT16); 12914 cmdline_parse_token_etheraddr_t cmd_mcast_addr_addr = 12915 TOKEN_ETHERADDR_INITIALIZER(struct cmd_mac_addr_result, address); 12916 12917 cmdline_parse_inst_t cmd_mcast_addr = { 12918 .f = cmd_mcast_addr_parsed, 12919 .data = (void *)0, 12920 .help_str = "mcast_addr add|remove <port_id> <mcast_addr>: " 12921 "Add/Remove multicast MAC address on port_id", 12922 .tokens = { 12923 (void *)&cmd_mcast_addr_cmd, 12924 (void *)&cmd_mcast_addr_what, 12925 (void *)&cmd_mcast_addr_portnum, 12926 (void *)&cmd_mcast_addr_addr, 12927 NULL, 12928 }, 12929 }; 12930 12931 /* l2 tunnel config 12932 * only support E-tag now. 12933 */ 12934 12935 /* Ether type config */ 12936 struct cmd_config_l2_tunnel_eth_type_result { 12937 cmdline_fixed_string_t port; 12938 cmdline_fixed_string_t config; 12939 cmdline_fixed_string_t all; 12940 portid_t id; 12941 cmdline_fixed_string_t l2_tunnel; 12942 cmdline_fixed_string_t l2_tunnel_type; 12943 cmdline_fixed_string_t eth_type; 12944 uint16_t eth_type_val; 12945 }; 12946 12947 cmdline_parse_token_string_t cmd_config_l2_tunnel_eth_type_port = 12948 TOKEN_STRING_INITIALIZER 12949 (struct cmd_config_l2_tunnel_eth_type_result, 12950 port, "port"); 12951 cmdline_parse_token_string_t cmd_config_l2_tunnel_eth_type_config = 12952 TOKEN_STRING_INITIALIZER 12953 (struct cmd_config_l2_tunnel_eth_type_result, 12954 config, "config"); 12955 cmdline_parse_token_string_t cmd_config_l2_tunnel_eth_type_all_str = 12956 TOKEN_STRING_INITIALIZER 12957 (struct cmd_config_l2_tunnel_eth_type_result, 12958 all, "all"); 12959 cmdline_parse_token_num_t cmd_config_l2_tunnel_eth_type_id = 12960 TOKEN_NUM_INITIALIZER 12961 (struct cmd_config_l2_tunnel_eth_type_result, 12962 id, UINT16); 12963 cmdline_parse_token_string_t cmd_config_l2_tunnel_eth_type_l2_tunnel = 12964 TOKEN_STRING_INITIALIZER 12965 (struct cmd_config_l2_tunnel_eth_type_result, 12966 l2_tunnel, "l2-tunnel"); 12967 cmdline_parse_token_string_t cmd_config_l2_tunnel_eth_type_l2_tunnel_type = 12968 TOKEN_STRING_INITIALIZER 12969 (struct cmd_config_l2_tunnel_eth_type_result, 12970 l2_tunnel_type, "E-tag"); 12971 cmdline_parse_token_string_t cmd_config_l2_tunnel_eth_type_eth_type = 12972 TOKEN_STRING_INITIALIZER 12973 (struct cmd_config_l2_tunnel_eth_type_result, 12974 eth_type, "ether-type"); 12975 cmdline_parse_token_num_t cmd_config_l2_tunnel_eth_type_eth_type_val = 12976 TOKEN_NUM_INITIALIZER 12977 (struct cmd_config_l2_tunnel_eth_type_result, 12978 eth_type_val, UINT16); 12979 12980 static enum rte_eth_tunnel_type 12981 str2fdir_l2_tunnel_type(char *string) 12982 { 12983 uint32_t i = 0; 12984 12985 static const struct { 12986 char str[32]; 12987 enum rte_eth_tunnel_type type; 12988 } l2_tunnel_type_str[] = { 12989 {"E-tag", RTE_L2_TUNNEL_TYPE_E_TAG}, 12990 }; 12991 12992 for (i = 0; i < RTE_DIM(l2_tunnel_type_str); i++) { 12993 if (!strcmp(l2_tunnel_type_str[i].str, string)) 12994 return l2_tunnel_type_str[i].type; 12995 } 12996 return RTE_TUNNEL_TYPE_NONE; 12997 } 12998 12999 /* ether type config for all ports */ 13000 static void 13001 cmd_config_l2_tunnel_eth_type_all_parsed 13002 (void *parsed_result, 13003 __rte_unused struct cmdline *cl, 13004 __rte_unused void *data) 13005 { 13006 struct cmd_config_l2_tunnel_eth_type_result *res = parsed_result; 13007 struct rte_eth_l2_tunnel_conf entry; 13008 portid_t pid; 13009 13010 entry.l2_tunnel_type = str2fdir_l2_tunnel_type(res->l2_tunnel_type); 13011 entry.ether_type = res->eth_type_val; 13012 13013 RTE_ETH_FOREACH_DEV(pid) { 13014 rte_eth_dev_l2_tunnel_eth_type_conf(pid, &entry); 13015 } 13016 } 13017 13018 cmdline_parse_inst_t cmd_config_l2_tunnel_eth_type_all = { 13019 .f = cmd_config_l2_tunnel_eth_type_all_parsed, 13020 .data = NULL, 13021 .help_str = "port config all l2-tunnel E-tag ether-type <value>", 13022 .tokens = { 13023 (void *)&cmd_config_l2_tunnel_eth_type_port, 13024 (void *)&cmd_config_l2_tunnel_eth_type_config, 13025 (void *)&cmd_config_l2_tunnel_eth_type_all_str, 13026 (void *)&cmd_config_l2_tunnel_eth_type_l2_tunnel, 13027 (void *)&cmd_config_l2_tunnel_eth_type_l2_tunnel_type, 13028 (void *)&cmd_config_l2_tunnel_eth_type_eth_type, 13029 (void *)&cmd_config_l2_tunnel_eth_type_eth_type_val, 13030 NULL, 13031 }, 13032 }; 13033 13034 /* ether type config for a specific port */ 13035 static void 13036 cmd_config_l2_tunnel_eth_type_specific_parsed( 13037 void *parsed_result, 13038 __rte_unused struct cmdline *cl, 13039 __rte_unused void *data) 13040 { 13041 struct cmd_config_l2_tunnel_eth_type_result *res = 13042 parsed_result; 13043 struct rte_eth_l2_tunnel_conf entry; 13044 13045 if (port_id_is_invalid(res->id, ENABLED_WARN)) 13046 return; 13047 13048 entry.l2_tunnel_type = str2fdir_l2_tunnel_type(res->l2_tunnel_type); 13049 entry.ether_type = res->eth_type_val; 13050 13051 rte_eth_dev_l2_tunnel_eth_type_conf(res->id, &entry); 13052 } 13053 13054 cmdline_parse_inst_t cmd_config_l2_tunnel_eth_type_specific = { 13055 .f = cmd_config_l2_tunnel_eth_type_specific_parsed, 13056 .data = NULL, 13057 .help_str = "port config <port_id> l2-tunnel E-tag ether-type <value>", 13058 .tokens = { 13059 (void *)&cmd_config_l2_tunnel_eth_type_port, 13060 (void *)&cmd_config_l2_tunnel_eth_type_config, 13061 (void *)&cmd_config_l2_tunnel_eth_type_id, 13062 (void *)&cmd_config_l2_tunnel_eth_type_l2_tunnel, 13063 (void *)&cmd_config_l2_tunnel_eth_type_l2_tunnel_type, 13064 (void *)&cmd_config_l2_tunnel_eth_type_eth_type, 13065 (void *)&cmd_config_l2_tunnel_eth_type_eth_type_val, 13066 NULL, 13067 }, 13068 }; 13069 13070 /* Enable/disable l2 tunnel */ 13071 struct cmd_config_l2_tunnel_en_dis_result { 13072 cmdline_fixed_string_t port; 13073 cmdline_fixed_string_t config; 13074 cmdline_fixed_string_t all; 13075 portid_t id; 13076 cmdline_fixed_string_t l2_tunnel; 13077 cmdline_fixed_string_t l2_tunnel_type; 13078 cmdline_fixed_string_t en_dis; 13079 }; 13080 13081 cmdline_parse_token_string_t cmd_config_l2_tunnel_en_dis_port = 13082 TOKEN_STRING_INITIALIZER 13083 (struct cmd_config_l2_tunnel_en_dis_result, 13084 port, "port"); 13085 cmdline_parse_token_string_t cmd_config_l2_tunnel_en_dis_config = 13086 TOKEN_STRING_INITIALIZER 13087 (struct cmd_config_l2_tunnel_en_dis_result, 13088 config, "config"); 13089 cmdline_parse_token_string_t cmd_config_l2_tunnel_en_dis_all_str = 13090 TOKEN_STRING_INITIALIZER 13091 (struct cmd_config_l2_tunnel_en_dis_result, 13092 all, "all"); 13093 cmdline_parse_token_num_t cmd_config_l2_tunnel_en_dis_id = 13094 TOKEN_NUM_INITIALIZER 13095 (struct cmd_config_l2_tunnel_en_dis_result, 13096 id, UINT16); 13097 cmdline_parse_token_string_t cmd_config_l2_tunnel_en_dis_l2_tunnel = 13098 TOKEN_STRING_INITIALIZER 13099 (struct cmd_config_l2_tunnel_en_dis_result, 13100 l2_tunnel, "l2-tunnel"); 13101 cmdline_parse_token_string_t cmd_config_l2_tunnel_en_dis_l2_tunnel_type = 13102 TOKEN_STRING_INITIALIZER 13103 (struct cmd_config_l2_tunnel_en_dis_result, 13104 l2_tunnel_type, "E-tag"); 13105 cmdline_parse_token_string_t cmd_config_l2_tunnel_en_dis_en_dis = 13106 TOKEN_STRING_INITIALIZER 13107 (struct cmd_config_l2_tunnel_en_dis_result, 13108 en_dis, "enable#disable"); 13109 13110 /* enable/disable l2 tunnel for all ports */ 13111 static void 13112 cmd_config_l2_tunnel_en_dis_all_parsed( 13113 void *parsed_result, 13114 __rte_unused struct cmdline *cl, 13115 __rte_unused void *data) 13116 { 13117 struct cmd_config_l2_tunnel_en_dis_result *res = parsed_result; 13118 struct rte_eth_l2_tunnel_conf entry; 13119 portid_t pid; 13120 uint8_t en; 13121 13122 entry.l2_tunnel_type = str2fdir_l2_tunnel_type(res->l2_tunnel_type); 13123 13124 if (!strcmp("enable", res->en_dis)) 13125 en = 1; 13126 else 13127 en = 0; 13128 13129 RTE_ETH_FOREACH_DEV(pid) { 13130 rte_eth_dev_l2_tunnel_offload_set(pid, 13131 &entry, 13132 ETH_L2_TUNNEL_ENABLE_MASK, 13133 en); 13134 } 13135 } 13136 13137 cmdline_parse_inst_t cmd_config_l2_tunnel_en_dis_all = { 13138 .f = cmd_config_l2_tunnel_en_dis_all_parsed, 13139 .data = NULL, 13140 .help_str = "port config all l2-tunnel E-tag enable|disable", 13141 .tokens = { 13142 (void *)&cmd_config_l2_tunnel_en_dis_port, 13143 (void *)&cmd_config_l2_tunnel_en_dis_config, 13144 (void *)&cmd_config_l2_tunnel_en_dis_all_str, 13145 (void *)&cmd_config_l2_tunnel_en_dis_l2_tunnel, 13146 (void *)&cmd_config_l2_tunnel_en_dis_l2_tunnel_type, 13147 (void *)&cmd_config_l2_tunnel_en_dis_en_dis, 13148 NULL, 13149 }, 13150 }; 13151 13152 /* enable/disable l2 tunnel for a port */ 13153 static void 13154 cmd_config_l2_tunnel_en_dis_specific_parsed( 13155 void *parsed_result, 13156 __rte_unused struct cmdline *cl, 13157 __rte_unused void *data) 13158 { 13159 struct cmd_config_l2_tunnel_en_dis_result *res = 13160 parsed_result; 13161 struct rte_eth_l2_tunnel_conf entry; 13162 13163 if (port_id_is_invalid(res->id, ENABLED_WARN)) 13164 return; 13165 13166 entry.l2_tunnel_type = str2fdir_l2_tunnel_type(res->l2_tunnel_type); 13167 13168 if (!strcmp("enable", res->en_dis)) 13169 rte_eth_dev_l2_tunnel_offload_set(res->id, 13170 &entry, 13171 ETH_L2_TUNNEL_ENABLE_MASK, 13172 1); 13173 else 13174 rte_eth_dev_l2_tunnel_offload_set(res->id, 13175 &entry, 13176 ETH_L2_TUNNEL_ENABLE_MASK, 13177 0); 13178 } 13179 13180 cmdline_parse_inst_t cmd_config_l2_tunnel_en_dis_specific = { 13181 .f = cmd_config_l2_tunnel_en_dis_specific_parsed, 13182 .data = NULL, 13183 .help_str = "port config <port_id> l2-tunnel E-tag enable|disable", 13184 .tokens = { 13185 (void *)&cmd_config_l2_tunnel_en_dis_port, 13186 (void *)&cmd_config_l2_tunnel_en_dis_config, 13187 (void *)&cmd_config_l2_tunnel_en_dis_id, 13188 (void *)&cmd_config_l2_tunnel_en_dis_l2_tunnel, 13189 (void *)&cmd_config_l2_tunnel_en_dis_l2_tunnel_type, 13190 (void *)&cmd_config_l2_tunnel_en_dis_en_dis, 13191 NULL, 13192 }, 13193 }; 13194 13195 /* E-tag configuration */ 13196 13197 /* Common result structure for all E-tag configuration */ 13198 struct cmd_config_e_tag_result { 13199 cmdline_fixed_string_t e_tag; 13200 cmdline_fixed_string_t set; 13201 cmdline_fixed_string_t insertion; 13202 cmdline_fixed_string_t stripping; 13203 cmdline_fixed_string_t forwarding; 13204 cmdline_fixed_string_t filter; 13205 cmdline_fixed_string_t add; 13206 cmdline_fixed_string_t del; 13207 cmdline_fixed_string_t on; 13208 cmdline_fixed_string_t off; 13209 cmdline_fixed_string_t on_off; 13210 cmdline_fixed_string_t port_tag_id; 13211 uint32_t port_tag_id_val; 13212 cmdline_fixed_string_t e_tag_id; 13213 uint16_t e_tag_id_val; 13214 cmdline_fixed_string_t dst_pool; 13215 uint8_t dst_pool_val; 13216 cmdline_fixed_string_t port; 13217 portid_t port_id; 13218 cmdline_fixed_string_t vf; 13219 uint8_t vf_id; 13220 }; 13221 13222 /* Common CLI fields for all E-tag configuration */ 13223 cmdline_parse_token_string_t cmd_config_e_tag_e_tag = 13224 TOKEN_STRING_INITIALIZER 13225 (struct cmd_config_e_tag_result, 13226 e_tag, "E-tag"); 13227 cmdline_parse_token_string_t cmd_config_e_tag_set = 13228 TOKEN_STRING_INITIALIZER 13229 (struct cmd_config_e_tag_result, 13230 set, "set"); 13231 cmdline_parse_token_string_t cmd_config_e_tag_insertion = 13232 TOKEN_STRING_INITIALIZER 13233 (struct cmd_config_e_tag_result, 13234 insertion, "insertion"); 13235 cmdline_parse_token_string_t cmd_config_e_tag_stripping = 13236 TOKEN_STRING_INITIALIZER 13237 (struct cmd_config_e_tag_result, 13238 stripping, "stripping"); 13239 cmdline_parse_token_string_t cmd_config_e_tag_forwarding = 13240 TOKEN_STRING_INITIALIZER 13241 (struct cmd_config_e_tag_result, 13242 forwarding, "forwarding"); 13243 cmdline_parse_token_string_t cmd_config_e_tag_filter = 13244 TOKEN_STRING_INITIALIZER 13245 (struct cmd_config_e_tag_result, 13246 filter, "filter"); 13247 cmdline_parse_token_string_t cmd_config_e_tag_add = 13248 TOKEN_STRING_INITIALIZER 13249 (struct cmd_config_e_tag_result, 13250 add, "add"); 13251 cmdline_parse_token_string_t cmd_config_e_tag_del = 13252 TOKEN_STRING_INITIALIZER 13253 (struct cmd_config_e_tag_result, 13254 del, "del"); 13255 cmdline_parse_token_string_t cmd_config_e_tag_on = 13256 TOKEN_STRING_INITIALIZER 13257 (struct cmd_config_e_tag_result, 13258 on, "on"); 13259 cmdline_parse_token_string_t cmd_config_e_tag_off = 13260 TOKEN_STRING_INITIALIZER 13261 (struct cmd_config_e_tag_result, 13262 off, "off"); 13263 cmdline_parse_token_string_t cmd_config_e_tag_on_off = 13264 TOKEN_STRING_INITIALIZER 13265 (struct cmd_config_e_tag_result, 13266 on_off, "on#off"); 13267 cmdline_parse_token_string_t cmd_config_e_tag_port_tag_id = 13268 TOKEN_STRING_INITIALIZER 13269 (struct cmd_config_e_tag_result, 13270 port_tag_id, "port-tag-id"); 13271 cmdline_parse_token_num_t cmd_config_e_tag_port_tag_id_val = 13272 TOKEN_NUM_INITIALIZER 13273 (struct cmd_config_e_tag_result, 13274 port_tag_id_val, UINT32); 13275 cmdline_parse_token_string_t cmd_config_e_tag_e_tag_id = 13276 TOKEN_STRING_INITIALIZER 13277 (struct cmd_config_e_tag_result, 13278 e_tag_id, "e-tag-id"); 13279 cmdline_parse_token_num_t cmd_config_e_tag_e_tag_id_val = 13280 TOKEN_NUM_INITIALIZER 13281 (struct cmd_config_e_tag_result, 13282 e_tag_id_val, UINT16); 13283 cmdline_parse_token_string_t cmd_config_e_tag_dst_pool = 13284 TOKEN_STRING_INITIALIZER 13285 (struct cmd_config_e_tag_result, 13286 dst_pool, "dst-pool"); 13287 cmdline_parse_token_num_t cmd_config_e_tag_dst_pool_val = 13288 TOKEN_NUM_INITIALIZER 13289 (struct cmd_config_e_tag_result, 13290 dst_pool_val, UINT8); 13291 cmdline_parse_token_string_t cmd_config_e_tag_port = 13292 TOKEN_STRING_INITIALIZER 13293 (struct cmd_config_e_tag_result, 13294 port, "port"); 13295 cmdline_parse_token_num_t cmd_config_e_tag_port_id = 13296 TOKEN_NUM_INITIALIZER 13297 (struct cmd_config_e_tag_result, 13298 port_id, UINT16); 13299 cmdline_parse_token_string_t cmd_config_e_tag_vf = 13300 TOKEN_STRING_INITIALIZER 13301 (struct cmd_config_e_tag_result, 13302 vf, "vf"); 13303 cmdline_parse_token_num_t cmd_config_e_tag_vf_id = 13304 TOKEN_NUM_INITIALIZER 13305 (struct cmd_config_e_tag_result, 13306 vf_id, UINT8); 13307 13308 /* E-tag insertion configuration */ 13309 static void 13310 cmd_config_e_tag_insertion_en_parsed( 13311 void *parsed_result, 13312 __rte_unused struct cmdline *cl, 13313 __rte_unused void *data) 13314 { 13315 struct cmd_config_e_tag_result *res = 13316 parsed_result; 13317 struct rte_eth_l2_tunnel_conf entry; 13318 13319 if (port_id_is_invalid(res->port_id, ENABLED_WARN)) 13320 return; 13321 13322 entry.l2_tunnel_type = RTE_L2_TUNNEL_TYPE_E_TAG; 13323 entry.tunnel_id = res->port_tag_id_val; 13324 entry.vf_id = res->vf_id; 13325 rte_eth_dev_l2_tunnel_offload_set(res->port_id, 13326 &entry, 13327 ETH_L2_TUNNEL_INSERTION_MASK, 13328 1); 13329 } 13330 13331 static void 13332 cmd_config_e_tag_insertion_dis_parsed( 13333 void *parsed_result, 13334 __rte_unused struct cmdline *cl, 13335 __rte_unused void *data) 13336 { 13337 struct cmd_config_e_tag_result *res = 13338 parsed_result; 13339 struct rte_eth_l2_tunnel_conf entry; 13340 13341 if (port_id_is_invalid(res->port_id, ENABLED_WARN)) 13342 return; 13343 13344 entry.l2_tunnel_type = RTE_L2_TUNNEL_TYPE_E_TAG; 13345 entry.vf_id = res->vf_id; 13346 13347 rte_eth_dev_l2_tunnel_offload_set(res->port_id, 13348 &entry, 13349 ETH_L2_TUNNEL_INSERTION_MASK, 13350 0); 13351 } 13352 13353 cmdline_parse_inst_t cmd_config_e_tag_insertion_en = { 13354 .f = cmd_config_e_tag_insertion_en_parsed, 13355 .data = NULL, 13356 .help_str = "E-tag ... : E-tag insertion enable", 13357 .tokens = { 13358 (void *)&cmd_config_e_tag_e_tag, 13359 (void *)&cmd_config_e_tag_set, 13360 (void *)&cmd_config_e_tag_insertion, 13361 (void *)&cmd_config_e_tag_on, 13362 (void *)&cmd_config_e_tag_port_tag_id, 13363 (void *)&cmd_config_e_tag_port_tag_id_val, 13364 (void *)&cmd_config_e_tag_port, 13365 (void *)&cmd_config_e_tag_port_id, 13366 (void *)&cmd_config_e_tag_vf, 13367 (void *)&cmd_config_e_tag_vf_id, 13368 NULL, 13369 }, 13370 }; 13371 13372 cmdline_parse_inst_t cmd_config_e_tag_insertion_dis = { 13373 .f = cmd_config_e_tag_insertion_dis_parsed, 13374 .data = NULL, 13375 .help_str = "E-tag ... : E-tag insertion disable", 13376 .tokens = { 13377 (void *)&cmd_config_e_tag_e_tag, 13378 (void *)&cmd_config_e_tag_set, 13379 (void *)&cmd_config_e_tag_insertion, 13380 (void *)&cmd_config_e_tag_off, 13381 (void *)&cmd_config_e_tag_port, 13382 (void *)&cmd_config_e_tag_port_id, 13383 (void *)&cmd_config_e_tag_vf, 13384 (void *)&cmd_config_e_tag_vf_id, 13385 NULL, 13386 }, 13387 }; 13388 13389 /* E-tag stripping configuration */ 13390 static void 13391 cmd_config_e_tag_stripping_parsed( 13392 void *parsed_result, 13393 __rte_unused struct cmdline *cl, 13394 __rte_unused void *data) 13395 { 13396 struct cmd_config_e_tag_result *res = 13397 parsed_result; 13398 struct rte_eth_l2_tunnel_conf entry; 13399 13400 if (port_id_is_invalid(res->port_id, ENABLED_WARN)) 13401 return; 13402 13403 entry.l2_tunnel_type = RTE_L2_TUNNEL_TYPE_E_TAG; 13404 13405 if (!strcmp(res->on_off, "on")) 13406 rte_eth_dev_l2_tunnel_offload_set 13407 (res->port_id, 13408 &entry, 13409 ETH_L2_TUNNEL_STRIPPING_MASK, 13410 1); 13411 else 13412 rte_eth_dev_l2_tunnel_offload_set 13413 (res->port_id, 13414 &entry, 13415 ETH_L2_TUNNEL_STRIPPING_MASK, 13416 0); 13417 } 13418 13419 cmdline_parse_inst_t cmd_config_e_tag_stripping_en_dis = { 13420 .f = cmd_config_e_tag_stripping_parsed, 13421 .data = NULL, 13422 .help_str = "E-tag ... : E-tag stripping enable/disable", 13423 .tokens = { 13424 (void *)&cmd_config_e_tag_e_tag, 13425 (void *)&cmd_config_e_tag_set, 13426 (void *)&cmd_config_e_tag_stripping, 13427 (void *)&cmd_config_e_tag_on_off, 13428 (void *)&cmd_config_e_tag_port, 13429 (void *)&cmd_config_e_tag_port_id, 13430 NULL, 13431 }, 13432 }; 13433 13434 /* E-tag forwarding configuration */ 13435 static void 13436 cmd_config_e_tag_forwarding_parsed( 13437 void *parsed_result, 13438 __rte_unused struct cmdline *cl, 13439 __rte_unused void *data) 13440 { 13441 struct cmd_config_e_tag_result *res = parsed_result; 13442 struct rte_eth_l2_tunnel_conf entry; 13443 13444 if (port_id_is_invalid(res->port_id, ENABLED_WARN)) 13445 return; 13446 13447 entry.l2_tunnel_type = RTE_L2_TUNNEL_TYPE_E_TAG; 13448 13449 if (!strcmp(res->on_off, "on")) 13450 rte_eth_dev_l2_tunnel_offload_set 13451 (res->port_id, 13452 &entry, 13453 ETH_L2_TUNNEL_FORWARDING_MASK, 13454 1); 13455 else 13456 rte_eth_dev_l2_tunnel_offload_set 13457 (res->port_id, 13458 &entry, 13459 ETH_L2_TUNNEL_FORWARDING_MASK, 13460 0); 13461 } 13462 13463 cmdline_parse_inst_t cmd_config_e_tag_forwarding_en_dis = { 13464 .f = cmd_config_e_tag_forwarding_parsed, 13465 .data = NULL, 13466 .help_str = "E-tag ... : E-tag forwarding enable/disable", 13467 .tokens = { 13468 (void *)&cmd_config_e_tag_e_tag, 13469 (void *)&cmd_config_e_tag_set, 13470 (void *)&cmd_config_e_tag_forwarding, 13471 (void *)&cmd_config_e_tag_on_off, 13472 (void *)&cmd_config_e_tag_port, 13473 (void *)&cmd_config_e_tag_port_id, 13474 NULL, 13475 }, 13476 }; 13477 13478 /* E-tag filter configuration */ 13479 static void 13480 cmd_config_e_tag_filter_add_parsed( 13481 void *parsed_result, 13482 __rte_unused struct cmdline *cl, 13483 __rte_unused void *data) 13484 { 13485 struct cmd_config_e_tag_result *res = parsed_result; 13486 struct rte_eth_l2_tunnel_conf entry; 13487 int ret = 0; 13488 13489 if (port_id_is_invalid(res->port_id, ENABLED_WARN)) 13490 return; 13491 13492 if (res->e_tag_id_val > 0x3fff) { 13493 printf("e-tag-id must be equal or less than 0x3fff.\n"); 13494 return; 13495 } 13496 13497 ret = rte_eth_dev_filter_supported(res->port_id, 13498 RTE_ETH_FILTER_L2_TUNNEL); 13499 if (ret < 0) { 13500 printf("E-tag filter is not supported on port %u.\n", 13501 res->port_id); 13502 return; 13503 } 13504 13505 entry.l2_tunnel_type = RTE_L2_TUNNEL_TYPE_E_TAG; 13506 entry.tunnel_id = res->e_tag_id_val; 13507 entry.pool = res->dst_pool_val; 13508 13509 ret = rte_eth_dev_filter_ctrl(res->port_id, 13510 RTE_ETH_FILTER_L2_TUNNEL, 13511 RTE_ETH_FILTER_ADD, 13512 &entry); 13513 if (ret < 0) 13514 printf("E-tag filter programming error: (%s)\n", 13515 strerror(-ret)); 13516 } 13517 13518 cmdline_parse_inst_t cmd_config_e_tag_filter_add = { 13519 .f = cmd_config_e_tag_filter_add_parsed, 13520 .data = NULL, 13521 .help_str = "E-tag ... : E-tag filter add", 13522 .tokens = { 13523 (void *)&cmd_config_e_tag_e_tag, 13524 (void *)&cmd_config_e_tag_set, 13525 (void *)&cmd_config_e_tag_filter, 13526 (void *)&cmd_config_e_tag_add, 13527 (void *)&cmd_config_e_tag_e_tag_id, 13528 (void *)&cmd_config_e_tag_e_tag_id_val, 13529 (void *)&cmd_config_e_tag_dst_pool, 13530 (void *)&cmd_config_e_tag_dst_pool_val, 13531 (void *)&cmd_config_e_tag_port, 13532 (void *)&cmd_config_e_tag_port_id, 13533 NULL, 13534 }, 13535 }; 13536 13537 static void 13538 cmd_config_e_tag_filter_del_parsed( 13539 void *parsed_result, 13540 __rte_unused struct cmdline *cl, 13541 __rte_unused void *data) 13542 { 13543 struct cmd_config_e_tag_result *res = parsed_result; 13544 struct rte_eth_l2_tunnel_conf entry; 13545 int ret = 0; 13546 13547 if (port_id_is_invalid(res->port_id, ENABLED_WARN)) 13548 return; 13549 13550 if (res->e_tag_id_val > 0x3fff) { 13551 printf("e-tag-id must be less than 0x3fff.\n"); 13552 return; 13553 } 13554 13555 ret = rte_eth_dev_filter_supported(res->port_id, 13556 RTE_ETH_FILTER_L2_TUNNEL); 13557 if (ret < 0) { 13558 printf("E-tag filter is not supported on port %u.\n", 13559 res->port_id); 13560 return; 13561 } 13562 13563 entry.l2_tunnel_type = RTE_L2_TUNNEL_TYPE_E_TAG; 13564 entry.tunnel_id = res->e_tag_id_val; 13565 13566 ret = rte_eth_dev_filter_ctrl(res->port_id, 13567 RTE_ETH_FILTER_L2_TUNNEL, 13568 RTE_ETH_FILTER_DELETE, 13569 &entry); 13570 if (ret < 0) 13571 printf("E-tag filter programming error: (%s)\n", 13572 strerror(-ret)); 13573 } 13574 13575 cmdline_parse_inst_t cmd_config_e_tag_filter_del = { 13576 .f = cmd_config_e_tag_filter_del_parsed, 13577 .data = NULL, 13578 .help_str = "E-tag ... : E-tag filter delete", 13579 .tokens = { 13580 (void *)&cmd_config_e_tag_e_tag, 13581 (void *)&cmd_config_e_tag_set, 13582 (void *)&cmd_config_e_tag_filter, 13583 (void *)&cmd_config_e_tag_del, 13584 (void *)&cmd_config_e_tag_e_tag_id, 13585 (void *)&cmd_config_e_tag_e_tag_id_val, 13586 (void *)&cmd_config_e_tag_port, 13587 (void *)&cmd_config_e_tag_port_id, 13588 NULL, 13589 }, 13590 }; 13591 13592 /* vf vlan anti spoof configuration */ 13593 13594 /* Common result structure for vf vlan anti spoof */ 13595 struct cmd_vf_vlan_anti_spoof_result { 13596 cmdline_fixed_string_t set; 13597 cmdline_fixed_string_t vf; 13598 cmdline_fixed_string_t vlan; 13599 cmdline_fixed_string_t antispoof; 13600 portid_t port_id; 13601 uint32_t vf_id; 13602 cmdline_fixed_string_t on_off; 13603 }; 13604 13605 /* Common CLI fields for vf vlan anti spoof enable disable */ 13606 cmdline_parse_token_string_t cmd_vf_vlan_anti_spoof_set = 13607 TOKEN_STRING_INITIALIZER 13608 (struct cmd_vf_vlan_anti_spoof_result, 13609 set, "set"); 13610 cmdline_parse_token_string_t cmd_vf_vlan_anti_spoof_vf = 13611 TOKEN_STRING_INITIALIZER 13612 (struct cmd_vf_vlan_anti_spoof_result, 13613 vf, "vf"); 13614 cmdline_parse_token_string_t cmd_vf_vlan_anti_spoof_vlan = 13615 TOKEN_STRING_INITIALIZER 13616 (struct cmd_vf_vlan_anti_spoof_result, 13617 vlan, "vlan"); 13618 cmdline_parse_token_string_t cmd_vf_vlan_anti_spoof_antispoof = 13619 TOKEN_STRING_INITIALIZER 13620 (struct cmd_vf_vlan_anti_spoof_result, 13621 antispoof, "antispoof"); 13622 cmdline_parse_token_num_t cmd_vf_vlan_anti_spoof_port_id = 13623 TOKEN_NUM_INITIALIZER 13624 (struct cmd_vf_vlan_anti_spoof_result, 13625 port_id, UINT16); 13626 cmdline_parse_token_num_t cmd_vf_vlan_anti_spoof_vf_id = 13627 TOKEN_NUM_INITIALIZER 13628 (struct cmd_vf_vlan_anti_spoof_result, 13629 vf_id, UINT32); 13630 cmdline_parse_token_string_t cmd_vf_vlan_anti_spoof_on_off = 13631 TOKEN_STRING_INITIALIZER 13632 (struct cmd_vf_vlan_anti_spoof_result, 13633 on_off, "on#off"); 13634 13635 static void 13636 cmd_set_vf_vlan_anti_spoof_parsed( 13637 void *parsed_result, 13638 __rte_unused struct cmdline *cl, 13639 __rte_unused void *data) 13640 { 13641 struct cmd_vf_vlan_anti_spoof_result *res = parsed_result; 13642 int ret = -ENOTSUP; 13643 13644 __rte_unused int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0; 13645 13646 if (port_id_is_invalid(res->port_id, ENABLED_WARN)) 13647 return; 13648 13649 #ifdef RTE_LIBRTE_IXGBE_PMD 13650 if (ret == -ENOTSUP) 13651 ret = rte_pmd_ixgbe_set_vf_vlan_anti_spoof(res->port_id, 13652 res->vf_id, is_on); 13653 #endif 13654 #ifdef RTE_LIBRTE_I40E_PMD 13655 if (ret == -ENOTSUP) 13656 ret = rte_pmd_i40e_set_vf_vlan_anti_spoof(res->port_id, 13657 res->vf_id, is_on); 13658 #endif 13659 #ifdef RTE_LIBRTE_BNXT_PMD 13660 if (ret == -ENOTSUP) 13661 ret = rte_pmd_bnxt_set_vf_vlan_anti_spoof(res->port_id, 13662 res->vf_id, is_on); 13663 #endif 13664 13665 switch (ret) { 13666 case 0: 13667 break; 13668 case -EINVAL: 13669 printf("invalid vf_id %d\n", res->vf_id); 13670 break; 13671 case -ENODEV: 13672 printf("invalid port_id %d\n", res->port_id); 13673 break; 13674 case -ENOTSUP: 13675 printf("function not implemented\n"); 13676 break; 13677 default: 13678 printf("programming error: (%s)\n", strerror(-ret)); 13679 } 13680 } 13681 13682 cmdline_parse_inst_t cmd_set_vf_vlan_anti_spoof = { 13683 .f = cmd_set_vf_vlan_anti_spoof_parsed, 13684 .data = NULL, 13685 .help_str = "set vf vlan antispoof <port_id> <vf_id> on|off", 13686 .tokens = { 13687 (void *)&cmd_vf_vlan_anti_spoof_set, 13688 (void *)&cmd_vf_vlan_anti_spoof_vf, 13689 (void *)&cmd_vf_vlan_anti_spoof_vlan, 13690 (void *)&cmd_vf_vlan_anti_spoof_antispoof, 13691 (void *)&cmd_vf_vlan_anti_spoof_port_id, 13692 (void *)&cmd_vf_vlan_anti_spoof_vf_id, 13693 (void *)&cmd_vf_vlan_anti_spoof_on_off, 13694 NULL, 13695 }, 13696 }; 13697 13698 /* vf mac anti spoof configuration */ 13699 13700 /* Common result structure for vf mac anti spoof */ 13701 struct cmd_vf_mac_anti_spoof_result { 13702 cmdline_fixed_string_t set; 13703 cmdline_fixed_string_t vf; 13704 cmdline_fixed_string_t mac; 13705 cmdline_fixed_string_t antispoof; 13706 portid_t port_id; 13707 uint32_t vf_id; 13708 cmdline_fixed_string_t on_off; 13709 }; 13710 13711 /* Common CLI fields for vf mac anti spoof enable disable */ 13712 cmdline_parse_token_string_t cmd_vf_mac_anti_spoof_set = 13713 TOKEN_STRING_INITIALIZER 13714 (struct cmd_vf_mac_anti_spoof_result, 13715 set, "set"); 13716 cmdline_parse_token_string_t cmd_vf_mac_anti_spoof_vf = 13717 TOKEN_STRING_INITIALIZER 13718 (struct cmd_vf_mac_anti_spoof_result, 13719 vf, "vf"); 13720 cmdline_parse_token_string_t cmd_vf_mac_anti_spoof_mac = 13721 TOKEN_STRING_INITIALIZER 13722 (struct cmd_vf_mac_anti_spoof_result, 13723 mac, "mac"); 13724 cmdline_parse_token_string_t cmd_vf_mac_anti_spoof_antispoof = 13725 TOKEN_STRING_INITIALIZER 13726 (struct cmd_vf_mac_anti_spoof_result, 13727 antispoof, "antispoof"); 13728 cmdline_parse_token_num_t cmd_vf_mac_anti_spoof_port_id = 13729 TOKEN_NUM_INITIALIZER 13730 (struct cmd_vf_mac_anti_spoof_result, 13731 port_id, UINT16); 13732 cmdline_parse_token_num_t cmd_vf_mac_anti_spoof_vf_id = 13733 TOKEN_NUM_INITIALIZER 13734 (struct cmd_vf_mac_anti_spoof_result, 13735 vf_id, UINT32); 13736 cmdline_parse_token_string_t cmd_vf_mac_anti_spoof_on_off = 13737 TOKEN_STRING_INITIALIZER 13738 (struct cmd_vf_mac_anti_spoof_result, 13739 on_off, "on#off"); 13740 13741 static void 13742 cmd_set_vf_mac_anti_spoof_parsed( 13743 void *parsed_result, 13744 __rte_unused struct cmdline *cl, 13745 __rte_unused void *data) 13746 { 13747 struct cmd_vf_mac_anti_spoof_result *res = parsed_result; 13748 int ret = -ENOTSUP; 13749 13750 __rte_unused int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0; 13751 13752 if (port_id_is_invalid(res->port_id, ENABLED_WARN)) 13753 return; 13754 13755 #ifdef RTE_LIBRTE_IXGBE_PMD 13756 if (ret == -ENOTSUP) 13757 ret = rte_pmd_ixgbe_set_vf_mac_anti_spoof(res->port_id, 13758 res->vf_id, is_on); 13759 #endif 13760 #ifdef RTE_LIBRTE_I40E_PMD 13761 if (ret == -ENOTSUP) 13762 ret = rte_pmd_i40e_set_vf_mac_anti_spoof(res->port_id, 13763 res->vf_id, is_on); 13764 #endif 13765 #ifdef RTE_LIBRTE_BNXT_PMD 13766 if (ret == -ENOTSUP) 13767 ret = rte_pmd_bnxt_set_vf_mac_anti_spoof(res->port_id, 13768 res->vf_id, is_on); 13769 #endif 13770 13771 switch (ret) { 13772 case 0: 13773 break; 13774 case -EINVAL: 13775 printf("invalid vf_id %d or is_on %d\n", res->vf_id, is_on); 13776 break; 13777 case -ENODEV: 13778 printf("invalid port_id %d\n", res->port_id); 13779 break; 13780 case -ENOTSUP: 13781 printf("function not implemented\n"); 13782 break; 13783 default: 13784 printf("programming error: (%s)\n", strerror(-ret)); 13785 } 13786 } 13787 13788 cmdline_parse_inst_t cmd_set_vf_mac_anti_spoof = { 13789 .f = cmd_set_vf_mac_anti_spoof_parsed, 13790 .data = NULL, 13791 .help_str = "set vf mac antispoof <port_id> <vf_id> on|off", 13792 .tokens = { 13793 (void *)&cmd_vf_mac_anti_spoof_set, 13794 (void *)&cmd_vf_mac_anti_spoof_vf, 13795 (void *)&cmd_vf_mac_anti_spoof_mac, 13796 (void *)&cmd_vf_mac_anti_spoof_antispoof, 13797 (void *)&cmd_vf_mac_anti_spoof_port_id, 13798 (void *)&cmd_vf_mac_anti_spoof_vf_id, 13799 (void *)&cmd_vf_mac_anti_spoof_on_off, 13800 NULL, 13801 }, 13802 }; 13803 13804 /* vf vlan strip queue configuration */ 13805 13806 /* Common result structure for vf mac anti spoof */ 13807 struct cmd_vf_vlan_stripq_result { 13808 cmdline_fixed_string_t set; 13809 cmdline_fixed_string_t vf; 13810 cmdline_fixed_string_t vlan; 13811 cmdline_fixed_string_t stripq; 13812 portid_t port_id; 13813 uint16_t vf_id; 13814 cmdline_fixed_string_t on_off; 13815 }; 13816 13817 /* Common CLI fields for vf vlan strip enable disable */ 13818 cmdline_parse_token_string_t cmd_vf_vlan_stripq_set = 13819 TOKEN_STRING_INITIALIZER 13820 (struct cmd_vf_vlan_stripq_result, 13821 set, "set"); 13822 cmdline_parse_token_string_t cmd_vf_vlan_stripq_vf = 13823 TOKEN_STRING_INITIALIZER 13824 (struct cmd_vf_vlan_stripq_result, 13825 vf, "vf"); 13826 cmdline_parse_token_string_t cmd_vf_vlan_stripq_vlan = 13827 TOKEN_STRING_INITIALIZER 13828 (struct cmd_vf_vlan_stripq_result, 13829 vlan, "vlan"); 13830 cmdline_parse_token_string_t cmd_vf_vlan_stripq_stripq = 13831 TOKEN_STRING_INITIALIZER 13832 (struct cmd_vf_vlan_stripq_result, 13833 stripq, "stripq"); 13834 cmdline_parse_token_num_t cmd_vf_vlan_stripq_port_id = 13835 TOKEN_NUM_INITIALIZER 13836 (struct cmd_vf_vlan_stripq_result, 13837 port_id, UINT16); 13838 cmdline_parse_token_num_t cmd_vf_vlan_stripq_vf_id = 13839 TOKEN_NUM_INITIALIZER 13840 (struct cmd_vf_vlan_stripq_result, 13841 vf_id, UINT16); 13842 cmdline_parse_token_string_t cmd_vf_vlan_stripq_on_off = 13843 TOKEN_STRING_INITIALIZER 13844 (struct cmd_vf_vlan_stripq_result, 13845 on_off, "on#off"); 13846 13847 static void 13848 cmd_set_vf_vlan_stripq_parsed( 13849 void *parsed_result, 13850 __rte_unused struct cmdline *cl, 13851 __rte_unused void *data) 13852 { 13853 struct cmd_vf_vlan_stripq_result *res = parsed_result; 13854 int ret = -ENOTSUP; 13855 13856 __rte_unused int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0; 13857 13858 if (port_id_is_invalid(res->port_id, ENABLED_WARN)) 13859 return; 13860 13861 #ifdef RTE_LIBRTE_IXGBE_PMD 13862 if (ret == -ENOTSUP) 13863 ret = rte_pmd_ixgbe_set_vf_vlan_stripq(res->port_id, 13864 res->vf_id, is_on); 13865 #endif 13866 #ifdef RTE_LIBRTE_I40E_PMD 13867 if (ret == -ENOTSUP) 13868 ret = rte_pmd_i40e_set_vf_vlan_stripq(res->port_id, 13869 res->vf_id, is_on); 13870 #endif 13871 #ifdef RTE_LIBRTE_BNXT_PMD 13872 if (ret == -ENOTSUP) 13873 ret = rte_pmd_bnxt_set_vf_vlan_stripq(res->port_id, 13874 res->vf_id, is_on); 13875 #endif 13876 13877 switch (ret) { 13878 case 0: 13879 break; 13880 case -EINVAL: 13881 printf("invalid vf_id %d or is_on %d\n", res->vf_id, is_on); 13882 break; 13883 case -ENODEV: 13884 printf("invalid port_id %d\n", res->port_id); 13885 break; 13886 case -ENOTSUP: 13887 printf("function not implemented\n"); 13888 break; 13889 default: 13890 printf("programming error: (%s)\n", strerror(-ret)); 13891 } 13892 } 13893 13894 cmdline_parse_inst_t cmd_set_vf_vlan_stripq = { 13895 .f = cmd_set_vf_vlan_stripq_parsed, 13896 .data = NULL, 13897 .help_str = "set vf vlan stripq <port_id> <vf_id> on|off", 13898 .tokens = { 13899 (void *)&cmd_vf_vlan_stripq_set, 13900 (void *)&cmd_vf_vlan_stripq_vf, 13901 (void *)&cmd_vf_vlan_stripq_vlan, 13902 (void *)&cmd_vf_vlan_stripq_stripq, 13903 (void *)&cmd_vf_vlan_stripq_port_id, 13904 (void *)&cmd_vf_vlan_stripq_vf_id, 13905 (void *)&cmd_vf_vlan_stripq_on_off, 13906 NULL, 13907 }, 13908 }; 13909 13910 /* vf vlan insert configuration */ 13911 13912 /* Common result structure for vf vlan insert */ 13913 struct cmd_vf_vlan_insert_result { 13914 cmdline_fixed_string_t set; 13915 cmdline_fixed_string_t vf; 13916 cmdline_fixed_string_t vlan; 13917 cmdline_fixed_string_t insert; 13918 portid_t port_id; 13919 uint16_t vf_id; 13920 uint16_t vlan_id; 13921 }; 13922 13923 /* Common CLI fields for vf vlan insert enable disable */ 13924 cmdline_parse_token_string_t cmd_vf_vlan_insert_set = 13925 TOKEN_STRING_INITIALIZER 13926 (struct cmd_vf_vlan_insert_result, 13927 set, "set"); 13928 cmdline_parse_token_string_t cmd_vf_vlan_insert_vf = 13929 TOKEN_STRING_INITIALIZER 13930 (struct cmd_vf_vlan_insert_result, 13931 vf, "vf"); 13932 cmdline_parse_token_string_t cmd_vf_vlan_insert_vlan = 13933 TOKEN_STRING_INITIALIZER 13934 (struct cmd_vf_vlan_insert_result, 13935 vlan, "vlan"); 13936 cmdline_parse_token_string_t cmd_vf_vlan_insert_insert = 13937 TOKEN_STRING_INITIALIZER 13938 (struct cmd_vf_vlan_insert_result, 13939 insert, "insert"); 13940 cmdline_parse_token_num_t cmd_vf_vlan_insert_port_id = 13941 TOKEN_NUM_INITIALIZER 13942 (struct cmd_vf_vlan_insert_result, 13943 port_id, UINT16); 13944 cmdline_parse_token_num_t cmd_vf_vlan_insert_vf_id = 13945 TOKEN_NUM_INITIALIZER 13946 (struct cmd_vf_vlan_insert_result, 13947 vf_id, UINT16); 13948 cmdline_parse_token_num_t cmd_vf_vlan_insert_vlan_id = 13949 TOKEN_NUM_INITIALIZER 13950 (struct cmd_vf_vlan_insert_result, 13951 vlan_id, UINT16); 13952 13953 static void 13954 cmd_set_vf_vlan_insert_parsed( 13955 void *parsed_result, 13956 __rte_unused struct cmdline *cl, 13957 __rte_unused void *data) 13958 { 13959 struct cmd_vf_vlan_insert_result *res = parsed_result; 13960 int ret = -ENOTSUP; 13961 13962 if (port_id_is_invalid(res->port_id, ENABLED_WARN)) 13963 return; 13964 13965 #ifdef RTE_LIBRTE_IXGBE_PMD 13966 if (ret == -ENOTSUP) 13967 ret = rte_pmd_ixgbe_set_vf_vlan_insert(res->port_id, res->vf_id, 13968 res->vlan_id); 13969 #endif 13970 #ifdef RTE_LIBRTE_I40E_PMD 13971 if (ret == -ENOTSUP) 13972 ret = rte_pmd_i40e_set_vf_vlan_insert(res->port_id, res->vf_id, 13973 res->vlan_id); 13974 #endif 13975 #ifdef RTE_LIBRTE_BNXT_PMD 13976 if (ret == -ENOTSUP) 13977 ret = rte_pmd_bnxt_set_vf_vlan_insert(res->port_id, res->vf_id, 13978 res->vlan_id); 13979 #endif 13980 13981 switch (ret) { 13982 case 0: 13983 break; 13984 case -EINVAL: 13985 printf("invalid vf_id %d or vlan_id %d\n", res->vf_id, res->vlan_id); 13986 break; 13987 case -ENODEV: 13988 printf("invalid port_id %d\n", res->port_id); 13989 break; 13990 case -ENOTSUP: 13991 printf("function not implemented\n"); 13992 break; 13993 default: 13994 printf("programming error: (%s)\n", strerror(-ret)); 13995 } 13996 } 13997 13998 cmdline_parse_inst_t cmd_set_vf_vlan_insert = { 13999 .f = cmd_set_vf_vlan_insert_parsed, 14000 .data = NULL, 14001 .help_str = "set vf vlan insert <port_id> <vf_id> <vlan_id>", 14002 .tokens = { 14003 (void *)&cmd_vf_vlan_insert_set, 14004 (void *)&cmd_vf_vlan_insert_vf, 14005 (void *)&cmd_vf_vlan_insert_vlan, 14006 (void *)&cmd_vf_vlan_insert_insert, 14007 (void *)&cmd_vf_vlan_insert_port_id, 14008 (void *)&cmd_vf_vlan_insert_vf_id, 14009 (void *)&cmd_vf_vlan_insert_vlan_id, 14010 NULL, 14011 }, 14012 }; 14013 14014 /* tx loopback configuration */ 14015 14016 /* Common result structure for tx loopback */ 14017 struct cmd_tx_loopback_result { 14018 cmdline_fixed_string_t set; 14019 cmdline_fixed_string_t tx; 14020 cmdline_fixed_string_t loopback; 14021 portid_t port_id; 14022 cmdline_fixed_string_t on_off; 14023 }; 14024 14025 /* Common CLI fields for tx loopback enable disable */ 14026 cmdline_parse_token_string_t cmd_tx_loopback_set = 14027 TOKEN_STRING_INITIALIZER 14028 (struct cmd_tx_loopback_result, 14029 set, "set"); 14030 cmdline_parse_token_string_t cmd_tx_loopback_tx = 14031 TOKEN_STRING_INITIALIZER 14032 (struct cmd_tx_loopback_result, 14033 tx, "tx"); 14034 cmdline_parse_token_string_t cmd_tx_loopback_loopback = 14035 TOKEN_STRING_INITIALIZER 14036 (struct cmd_tx_loopback_result, 14037 loopback, "loopback"); 14038 cmdline_parse_token_num_t cmd_tx_loopback_port_id = 14039 TOKEN_NUM_INITIALIZER 14040 (struct cmd_tx_loopback_result, 14041 port_id, UINT16); 14042 cmdline_parse_token_string_t cmd_tx_loopback_on_off = 14043 TOKEN_STRING_INITIALIZER 14044 (struct cmd_tx_loopback_result, 14045 on_off, "on#off"); 14046 14047 static void 14048 cmd_set_tx_loopback_parsed( 14049 void *parsed_result, 14050 __rte_unused struct cmdline *cl, 14051 __rte_unused void *data) 14052 { 14053 struct cmd_tx_loopback_result *res = parsed_result; 14054 int ret = -ENOTSUP; 14055 14056 __rte_unused int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0; 14057 14058 if (port_id_is_invalid(res->port_id, ENABLED_WARN)) 14059 return; 14060 14061 #ifdef RTE_LIBRTE_IXGBE_PMD 14062 if (ret == -ENOTSUP) 14063 ret = rte_pmd_ixgbe_set_tx_loopback(res->port_id, is_on); 14064 #endif 14065 #ifdef RTE_LIBRTE_I40E_PMD 14066 if (ret == -ENOTSUP) 14067 ret = rte_pmd_i40e_set_tx_loopback(res->port_id, is_on); 14068 #endif 14069 #ifdef RTE_LIBRTE_BNXT_PMD 14070 if (ret == -ENOTSUP) 14071 ret = rte_pmd_bnxt_set_tx_loopback(res->port_id, is_on); 14072 #endif 14073 #if defined RTE_LIBRTE_DPAA_BUS && defined RTE_LIBRTE_DPAA_PMD 14074 if (ret == -ENOTSUP) 14075 ret = rte_pmd_dpaa_set_tx_loopback(res->port_id, is_on); 14076 #endif 14077 14078 switch (ret) { 14079 case 0: 14080 break; 14081 case -EINVAL: 14082 printf("invalid is_on %d\n", is_on); 14083 break; 14084 case -ENODEV: 14085 printf("invalid port_id %d\n", res->port_id); 14086 break; 14087 case -ENOTSUP: 14088 printf("function not implemented\n"); 14089 break; 14090 default: 14091 printf("programming error: (%s)\n", strerror(-ret)); 14092 } 14093 } 14094 14095 cmdline_parse_inst_t cmd_set_tx_loopback = { 14096 .f = cmd_set_tx_loopback_parsed, 14097 .data = NULL, 14098 .help_str = "set tx loopback <port_id> on|off", 14099 .tokens = { 14100 (void *)&cmd_tx_loopback_set, 14101 (void *)&cmd_tx_loopback_tx, 14102 (void *)&cmd_tx_loopback_loopback, 14103 (void *)&cmd_tx_loopback_port_id, 14104 (void *)&cmd_tx_loopback_on_off, 14105 NULL, 14106 }, 14107 }; 14108 14109 /* all queues drop enable configuration */ 14110 14111 /* Common result structure for all queues drop enable */ 14112 struct cmd_all_queues_drop_en_result { 14113 cmdline_fixed_string_t set; 14114 cmdline_fixed_string_t all; 14115 cmdline_fixed_string_t queues; 14116 cmdline_fixed_string_t drop; 14117 portid_t port_id; 14118 cmdline_fixed_string_t on_off; 14119 }; 14120 14121 /* Common CLI fields for tx loopback enable disable */ 14122 cmdline_parse_token_string_t cmd_all_queues_drop_en_set = 14123 TOKEN_STRING_INITIALIZER 14124 (struct cmd_all_queues_drop_en_result, 14125 set, "set"); 14126 cmdline_parse_token_string_t cmd_all_queues_drop_en_all = 14127 TOKEN_STRING_INITIALIZER 14128 (struct cmd_all_queues_drop_en_result, 14129 all, "all"); 14130 cmdline_parse_token_string_t cmd_all_queues_drop_en_queues = 14131 TOKEN_STRING_INITIALIZER 14132 (struct cmd_all_queues_drop_en_result, 14133 queues, "queues"); 14134 cmdline_parse_token_string_t cmd_all_queues_drop_en_drop = 14135 TOKEN_STRING_INITIALIZER 14136 (struct cmd_all_queues_drop_en_result, 14137 drop, "drop"); 14138 cmdline_parse_token_num_t cmd_all_queues_drop_en_port_id = 14139 TOKEN_NUM_INITIALIZER 14140 (struct cmd_all_queues_drop_en_result, 14141 port_id, UINT16); 14142 cmdline_parse_token_string_t cmd_all_queues_drop_en_on_off = 14143 TOKEN_STRING_INITIALIZER 14144 (struct cmd_all_queues_drop_en_result, 14145 on_off, "on#off"); 14146 14147 static void 14148 cmd_set_all_queues_drop_en_parsed( 14149 void *parsed_result, 14150 __rte_unused struct cmdline *cl, 14151 __rte_unused void *data) 14152 { 14153 struct cmd_all_queues_drop_en_result *res = parsed_result; 14154 int ret = -ENOTSUP; 14155 int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0; 14156 14157 if (port_id_is_invalid(res->port_id, ENABLED_WARN)) 14158 return; 14159 14160 #ifdef RTE_LIBRTE_IXGBE_PMD 14161 if (ret == -ENOTSUP) 14162 ret = rte_pmd_ixgbe_set_all_queues_drop_en(res->port_id, is_on); 14163 #endif 14164 #ifdef RTE_LIBRTE_BNXT_PMD 14165 if (ret == -ENOTSUP) 14166 ret = rte_pmd_bnxt_set_all_queues_drop_en(res->port_id, is_on); 14167 #endif 14168 switch (ret) { 14169 case 0: 14170 break; 14171 case -EINVAL: 14172 printf("invalid is_on %d\n", is_on); 14173 break; 14174 case -ENODEV: 14175 printf("invalid port_id %d\n", res->port_id); 14176 break; 14177 case -ENOTSUP: 14178 printf("function not implemented\n"); 14179 break; 14180 default: 14181 printf("programming error: (%s)\n", strerror(-ret)); 14182 } 14183 } 14184 14185 cmdline_parse_inst_t cmd_set_all_queues_drop_en = { 14186 .f = cmd_set_all_queues_drop_en_parsed, 14187 .data = NULL, 14188 .help_str = "set all queues drop <port_id> on|off", 14189 .tokens = { 14190 (void *)&cmd_all_queues_drop_en_set, 14191 (void *)&cmd_all_queues_drop_en_all, 14192 (void *)&cmd_all_queues_drop_en_queues, 14193 (void *)&cmd_all_queues_drop_en_drop, 14194 (void *)&cmd_all_queues_drop_en_port_id, 14195 (void *)&cmd_all_queues_drop_en_on_off, 14196 NULL, 14197 }, 14198 }; 14199 14200 /* vf split drop enable configuration */ 14201 14202 /* Common result structure for vf split drop enable */ 14203 struct cmd_vf_split_drop_en_result { 14204 cmdline_fixed_string_t set; 14205 cmdline_fixed_string_t vf; 14206 cmdline_fixed_string_t split; 14207 cmdline_fixed_string_t drop; 14208 portid_t port_id; 14209 uint16_t vf_id; 14210 cmdline_fixed_string_t on_off; 14211 }; 14212 14213 /* Common CLI fields for vf split drop enable disable */ 14214 cmdline_parse_token_string_t cmd_vf_split_drop_en_set = 14215 TOKEN_STRING_INITIALIZER 14216 (struct cmd_vf_split_drop_en_result, 14217 set, "set"); 14218 cmdline_parse_token_string_t cmd_vf_split_drop_en_vf = 14219 TOKEN_STRING_INITIALIZER 14220 (struct cmd_vf_split_drop_en_result, 14221 vf, "vf"); 14222 cmdline_parse_token_string_t cmd_vf_split_drop_en_split = 14223 TOKEN_STRING_INITIALIZER 14224 (struct cmd_vf_split_drop_en_result, 14225 split, "split"); 14226 cmdline_parse_token_string_t cmd_vf_split_drop_en_drop = 14227 TOKEN_STRING_INITIALIZER 14228 (struct cmd_vf_split_drop_en_result, 14229 drop, "drop"); 14230 cmdline_parse_token_num_t cmd_vf_split_drop_en_port_id = 14231 TOKEN_NUM_INITIALIZER 14232 (struct cmd_vf_split_drop_en_result, 14233 port_id, UINT16); 14234 cmdline_parse_token_num_t cmd_vf_split_drop_en_vf_id = 14235 TOKEN_NUM_INITIALIZER 14236 (struct cmd_vf_split_drop_en_result, 14237 vf_id, UINT16); 14238 cmdline_parse_token_string_t cmd_vf_split_drop_en_on_off = 14239 TOKEN_STRING_INITIALIZER 14240 (struct cmd_vf_split_drop_en_result, 14241 on_off, "on#off"); 14242 14243 static void 14244 cmd_set_vf_split_drop_en_parsed( 14245 void *parsed_result, 14246 __rte_unused struct cmdline *cl, 14247 __rte_unused void *data) 14248 { 14249 struct cmd_vf_split_drop_en_result *res = parsed_result; 14250 int ret = -ENOTSUP; 14251 int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0; 14252 14253 if (port_id_is_invalid(res->port_id, ENABLED_WARN)) 14254 return; 14255 14256 #ifdef RTE_LIBRTE_IXGBE_PMD 14257 ret = rte_pmd_ixgbe_set_vf_split_drop_en(res->port_id, res->vf_id, 14258 is_on); 14259 #endif 14260 switch (ret) { 14261 case 0: 14262 break; 14263 case -EINVAL: 14264 printf("invalid vf_id %d or is_on %d\n", res->vf_id, is_on); 14265 break; 14266 case -ENODEV: 14267 printf("invalid port_id %d\n", res->port_id); 14268 break; 14269 case -ENOTSUP: 14270 printf("not supported on port %d\n", res->port_id); 14271 break; 14272 default: 14273 printf("programming error: (%s)\n", strerror(-ret)); 14274 } 14275 } 14276 14277 cmdline_parse_inst_t cmd_set_vf_split_drop_en = { 14278 .f = cmd_set_vf_split_drop_en_parsed, 14279 .data = NULL, 14280 .help_str = "set vf split drop <port_id> <vf_id> on|off", 14281 .tokens = { 14282 (void *)&cmd_vf_split_drop_en_set, 14283 (void *)&cmd_vf_split_drop_en_vf, 14284 (void *)&cmd_vf_split_drop_en_split, 14285 (void *)&cmd_vf_split_drop_en_drop, 14286 (void *)&cmd_vf_split_drop_en_port_id, 14287 (void *)&cmd_vf_split_drop_en_vf_id, 14288 (void *)&cmd_vf_split_drop_en_on_off, 14289 NULL, 14290 }, 14291 }; 14292 14293 /* vf mac address configuration */ 14294 14295 /* Common result structure for vf mac address */ 14296 struct cmd_set_vf_mac_addr_result { 14297 cmdline_fixed_string_t set; 14298 cmdline_fixed_string_t vf; 14299 cmdline_fixed_string_t mac; 14300 cmdline_fixed_string_t addr; 14301 portid_t port_id; 14302 uint16_t vf_id; 14303 struct rte_ether_addr mac_addr; 14304 14305 }; 14306 14307 /* Common CLI fields for vf split drop enable disable */ 14308 cmdline_parse_token_string_t cmd_set_vf_mac_addr_set = 14309 TOKEN_STRING_INITIALIZER 14310 (struct cmd_set_vf_mac_addr_result, 14311 set, "set"); 14312 cmdline_parse_token_string_t cmd_set_vf_mac_addr_vf = 14313 TOKEN_STRING_INITIALIZER 14314 (struct cmd_set_vf_mac_addr_result, 14315 vf, "vf"); 14316 cmdline_parse_token_string_t cmd_set_vf_mac_addr_mac = 14317 TOKEN_STRING_INITIALIZER 14318 (struct cmd_set_vf_mac_addr_result, 14319 mac, "mac"); 14320 cmdline_parse_token_string_t cmd_set_vf_mac_addr_addr = 14321 TOKEN_STRING_INITIALIZER 14322 (struct cmd_set_vf_mac_addr_result, 14323 addr, "addr"); 14324 cmdline_parse_token_num_t cmd_set_vf_mac_addr_port_id = 14325 TOKEN_NUM_INITIALIZER 14326 (struct cmd_set_vf_mac_addr_result, 14327 port_id, UINT16); 14328 cmdline_parse_token_num_t cmd_set_vf_mac_addr_vf_id = 14329 TOKEN_NUM_INITIALIZER 14330 (struct cmd_set_vf_mac_addr_result, 14331 vf_id, UINT16); 14332 cmdline_parse_token_etheraddr_t cmd_set_vf_mac_addr_mac_addr = 14333 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_vf_mac_addr_result, 14334 mac_addr); 14335 14336 static void 14337 cmd_set_vf_mac_addr_parsed( 14338 void *parsed_result, 14339 __rte_unused struct cmdline *cl, 14340 __rte_unused void *data) 14341 { 14342 struct cmd_set_vf_mac_addr_result *res = parsed_result; 14343 int ret = -ENOTSUP; 14344 14345 if (port_id_is_invalid(res->port_id, ENABLED_WARN)) 14346 return; 14347 14348 #ifdef RTE_LIBRTE_IXGBE_PMD 14349 if (ret == -ENOTSUP) 14350 ret = rte_pmd_ixgbe_set_vf_mac_addr(res->port_id, res->vf_id, 14351 &res->mac_addr); 14352 #endif 14353 #ifdef RTE_LIBRTE_I40E_PMD 14354 if (ret == -ENOTSUP) 14355 ret = rte_pmd_i40e_set_vf_mac_addr(res->port_id, res->vf_id, 14356 &res->mac_addr); 14357 #endif 14358 #ifdef RTE_LIBRTE_BNXT_PMD 14359 if (ret == -ENOTSUP) 14360 ret = rte_pmd_bnxt_set_vf_mac_addr(res->port_id, res->vf_id, 14361 &res->mac_addr); 14362 #endif 14363 14364 switch (ret) { 14365 case 0: 14366 break; 14367 case -EINVAL: 14368 printf("invalid vf_id %d or mac_addr\n", res->vf_id); 14369 break; 14370 case -ENODEV: 14371 printf("invalid port_id %d\n", res->port_id); 14372 break; 14373 case -ENOTSUP: 14374 printf("function not implemented\n"); 14375 break; 14376 default: 14377 printf("programming error: (%s)\n", strerror(-ret)); 14378 } 14379 } 14380 14381 cmdline_parse_inst_t cmd_set_vf_mac_addr = { 14382 .f = cmd_set_vf_mac_addr_parsed, 14383 .data = NULL, 14384 .help_str = "set vf mac addr <port_id> <vf_id> <mac_addr>", 14385 .tokens = { 14386 (void *)&cmd_set_vf_mac_addr_set, 14387 (void *)&cmd_set_vf_mac_addr_vf, 14388 (void *)&cmd_set_vf_mac_addr_mac, 14389 (void *)&cmd_set_vf_mac_addr_addr, 14390 (void *)&cmd_set_vf_mac_addr_port_id, 14391 (void *)&cmd_set_vf_mac_addr_vf_id, 14392 (void *)&cmd_set_vf_mac_addr_mac_addr, 14393 NULL, 14394 }, 14395 }; 14396 14397 /* MACsec configuration */ 14398 14399 /* Common result structure for MACsec offload enable */ 14400 struct cmd_macsec_offload_on_result { 14401 cmdline_fixed_string_t set; 14402 cmdline_fixed_string_t macsec; 14403 cmdline_fixed_string_t offload; 14404 portid_t port_id; 14405 cmdline_fixed_string_t on; 14406 cmdline_fixed_string_t encrypt; 14407 cmdline_fixed_string_t en_on_off; 14408 cmdline_fixed_string_t replay_protect; 14409 cmdline_fixed_string_t rp_on_off; 14410 }; 14411 14412 /* Common CLI fields for MACsec offload disable */ 14413 cmdline_parse_token_string_t cmd_macsec_offload_on_set = 14414 TOKEN_STRING_INITIALIZER 14415 (struct cmd_macsec_offload_on_result, 14416 set, "set"); 14417 cmdline_parse_token_string_t cmd_macsec_offload_on_macsec = 14418 TOKEN_STRING_INITIALIZER 14419 (struct cmd_macsec_offload_on_result, 14420 macsec, "macsec"); 14421 cmdline_parse_token_string_t cmd_macsec_offload_on_offload = 14422 TOKEN_STRING_INITIALIZER 14423 (struct cmd_macsec_offload_on_result, 14424 offload, "offload"); 14425 cmdline_parse_token_num_t cmd_macsec_offload_on_port_id = 14426 TOKEN_NUM_INITIALIZER 14427 (struct cmd_macsec_offload_on_result, 14428 port_id, UINT16); 14429 cmdline_parse_token_string_t cmd_macsec_offload_on_on = 14430 TOKEN_STRING_INITIALIZER 14431 (struct cmd_macsec_offload_on_result, 14432 on, "on"); 14433 cmdline_parse_token_string_t cmd_macsec_offload_on_encrypt = 14434 TOKEN_STRING_INITIALIZER 14435 (struct cmd_macsec_offload_on_result, 14436 encrypt, "encrypt"); 14437 cmdline_parse_token_string_t cmd_macsec_offload_on_en_on_off = 14438 TOKEN_STRING_INITIALIZER 14439 (struct cmd_macsec_offload_on_result, 14440 en_on_off, "on#off"); 14441 cmdline_parse_token_string_t cmd_macsec_offload_on_replay_protect = 14442 TOKEN_STRING_INITIALIZER 14443 (struct cmd_macsec_offload_on_result, 14444 replay_protect, "replay-protect"); 14445 cmdline_parse_token_string_t cmd_macsec_offload_on_rp_on_off = 14446 TOKEN_STRING_INITIALIZER 14447 (struct cmd_macsec_offload_on_result, 14448 rp_on_off, "on#off"); 14449 14450 static void 14451 cmd_set_macsec_offload_on_parsed( 14452 void *parsed_result, 14453 __rte_unused struct cmdline *cl, 14454 __rte_unused void *data) 14455 { 14456 struct cmd_macsec_offload_on_result *res = parsed_result; 14457 int ret = -ENOTSUP; 14458 portid_t port_id = res->port_id; 14459 int en = (strcmp(res->en_on_off, "on") == 0) ? 1 : 0; 14460 int rp = (strcmp(res->rp_on_off, "on") == 0) ? 1 : 0; 14461 struct rte_eth_dev_info dev_info; 14462 14463 if (port_id_is_invalid(port_id, ENABLED_WARN)) 14464 return; 14465 if (!port_is_stopped(port_id)) { 14466 printf("Please stop port %d first\n", port_id); 14467 return; 14468 } 14469 14470 ret = eth_dev_info_get_print_err(port_id, &dev_info); 14471 if (ret != 0) 14472 return; 14473 14474 if (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_MACSEC_INSERT) { 14475 #ifdef RTE_LIBRTE_IXGBE_PMD 14476 ret = rte_pmd_ixgbe_macsec_enable(port_id, en, rp); 14477 #endif 14478 } 14479 RTE_SET_USED(en); 14480 RTE_SET_USED(rp); 14481 14482 switch (ret) { 14483 case 0: 14484 ports[port_id].dev_conf.txmode.offloads |= 14485 DEV_TX_OFFLOAD_MACSEC_INSERT; 14486 cmd_reconfig_device_queue(port_id, 1, 1); 14487 break; 14488 case -ENODEV: 14489 printf("invalid port_id %d\n", port_id); 14490 break; 14491 case -ENOTSUP: 14492 printf("not supported on port %d\n", port_id); 14493 break; 14494 default: 14495 printf("programming error: (%s)\n", strerror(-ret)); 14496 } 14497 } 14498 14499 cmdline_parse_inst_t cmd_set_macsec_offload_on = { 14500 .f = cmd_set_macsec_offload_on_parsed, 14501 .data = NULL, 14502 .help_str = "set macsec offload <port_id> on " 14503 "encrypt on|off replay-protect on|off", 14504 .tokens = { 14505 (void *)&cmd_macsec_offload_on_set, 14506 (void *)&cmd_macsec_offload_on_macsec, 14507 (void *)&cmd_macsec_offload_on_offload, 14508 (void *)&cmd_macsec_offload_on_port_id, 14509 (void *)&cmd_macsec_offload_on_on, 14510 (void *)&cmd_macsec_offload_on_encrypt, 14511 (void *)&cmd_macsec_offload_on_en_on_off, 14512 (void *)&cmd_macsec_offload_on_replay_protect, 14513 (void *)&cmd_macsec_offload_on_rp_on_off, 14514 NULL, 14515 }, 14516 }; 14517 14518 /* Common result structure for MACsec offload disable */ 14519 struct cmd_macsec_offload_off_result { 14520 cmdline_fixed_string_t set; 14521 cmdline_fixed_string_t macsec; 14522 cmdline_fixed_string_t offload; 14523 portid_t port_id; 14524 cmdline_fixed_string_t off; 14525 }; 14526 14527 /* Common CLI fields for MACsec offload disable */ 14528 cmdline_parse_token_string_t cmd_macsec_offload_off_set = 14529 TOKEN_STRING_INITIALIZER 14530 (struct cmd_macsec_offload_off_result, 14531 set, "set"); 14532 cmdline_parse_token_string_t cmd_macsec_offload_off_macsec = 14533 TOKEN_STRING_INITIALIZER 14534 (struct cmd_macsec_offload_off_result, 14535 macsec, "macsec"); 14536 cmdline_parse_token_string_t cmd_macsec_offload_off_offload = 14537 TOKEN_STRING_INITIALIZER 14538 (struct cmd_macsec_offload_off_result, 14539 offload, "offload"); 14540 cmdline_parse_token_num_t cmd_macsec_offload_off_port_id = 14541 TOKEN_NUM_INITIALIZER 14542 (struct cmd_macsec_offload_off_result, 14543 port_id, UINT16); 14544 cmdline_parse_token_string_t cmd_macsec_offload_off_off = 14545 TOKEN_STRING_INITIALIZER 14546 (struct cmd_macsec_offload_off_result, 14547 off, "off"); 14548 14549 static void 14550 cmd_set_macsec_offload_off_parsed( 14551 void *parsed_result, 14552 __rte_unused struct cmdline *cl, 14553 __rte_unused void *data) 14554 { 14555 struct cmd_macsec_offload_off_result *res = parsed_result; 14556 int ret = -ENOTSUP; 14557 struct rte_eth_dev_info dev_info; 14558 portid_t port_id = res->port_id; 14559 14560 if (port_id_is_invalid(port_id, ENABLED_WARN)) 14561 return; 14562 if (!port_is_stopped(port_id)) { 14563 printf("Please stop port %d first\n", port_id); 14564 return; 14565 } 14566 14567 ret = eth_dev_info_get_print_err(port_id, &dev_info); 14568 if (ret != 0) 14569 return; 14570 14571 if (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_MACSEC_INSERT) { 14572 #ifdef RTE_LIBRTE_IXGBE_PMD 14573 ret = rte_pmd_ixgbe_macsec_disable(port_id); 14574 #endif 14575 } 14576 switch (ret) { 14577 case 0: 14578 ports[port_id].dev_conf.txmode.offloads &= 14579 ~DEV_TX_OFFLOAD_MACSEC_INSERT; 14580 cmd_reconfig_device_queue(port_id, 1, 1); 14581 break; 14582 case -ENODEV: 14583 printf("invalid port_id %d\n", port_id); 14584 break; 14585 case -ENOTSUP: 14586 printf("not supported on port %d\n", port_id); 14587 break; 14588 default: 14589 printf("programming error: (%s)\n", strerror(-ret)); 14590 } 14591 } 14592 14593 cmdline_parse_inst_t cmd_set_macsec_offload_off = { 14594 .f = cmd_set_macsec_offload_off_parsed, 14595 .data = NULL, 14596 .help_str = "set macsec offload <port_id> off", 14597 .tokens = { 14598 (void *)&cmd_macsec_offload_off_set, 14599 (void *)&cmd_macsec_offload_off_macsec, 14600 (void *)&cmd_macsec_offload_off_offload, 14601 (void *)&cmd_macsec_offload_off_port_id, 14602 (void *)&cmd_macsec_offload_off_off, 14603 NULL, 14604 }, 14605 }; 14606 14607 /* Common result structure for MACsec secure connection configure */ 14608 struct cmd_macsec_sc_result { 14609 cmdline_fixed_string_t set; 14610 cmdline_fixed_string_t macsec; 14611 cmdline_fixed_string_t sc; 14612 cmdline_fixed_string_t tx_rx; 14613 portid_t port_id; 14614 struct rte_ether_addr mac; 14615 uint16_t pi; 14616 }; 14617 14618 /* Common CLI fields for MACsec secure connection configure */ 14619 cmdline_parse_token_string_t cmd_macsec_sc_set = 14620 TOKEN_STRING_INITIALIZER 14621 (struct cmd_macsec_sc_result, 14622 set, "set"); 14623 cmdline_parse_token_string_t cmd_macsec_sc_macsec = 14624 TOKEN_STRING_INITIALIZER 14625 (struct cmd_macsec_sc_result, 14626 macsec, "macsec"); 14627 cmdline_parse_token_string_t cmd_macsec_sc_sc = 14628 TOKEN_STRING_INITIALIZER 14629 (struct cmd_macsec_sc_result, 14630 sc, "sc"); 14631 cmdline_parse_token_string_t cmd_macsec_sc_tx_rx = 14632 TOKEN_STRING_INITIALIZER 14633 (struct cmd_macsec_sc_result, 14634 tx_rx, "tx#rx"); 14635 cmdline_parse_token_num_t cmd_macsec_sc_port_id = 14636 TOKEN_NUM_INITIALIZER 14637 (struct cmd_macsec_sc_result, 14638 port_id, UINT16); 14639 cmdline_parse_token_etheraddr_t cmd_macsec_sc_mac = 14640 TOKEN_ETHERADDR_INITIALIZER 14641 (struct cmd_macsec_sc_result, 14642 mac); 14643 cmdline_parse_token_num_t cmd_macsec_sc_pi = 14644 TOKEN_NUM_INITIALIZER 14645 (struct cmd_macsec_sc_result, 14646 pi, UINT16); 14647 14648 static void 14649 cmd_set_macsec_sc_parsed( 14650 void *parsed_result, 14651 __rte_unused struct cmdline *cl, 14652 __rte_unused void *data) 14653 { 14654 struct cmd_macsec_sc_result *res = parsed_result; 14655 int ret = -ENOTSUP; 14656 int is_tx = (strcmp(res->tx_rx, "tx") == 0) ? 1 : 0; 14657 14658 #ifdef RTE_LIBRTE_IXGBE_PMD 14659 ret = is_tx ? 14660 rte_pmd_ixgbe_macsec_config_txsc(res->port_id, 14661 res->mac.addr_bytes) : 14662 rte_pmd_ixgbe_macsec_config_rxsc(res->port_id, 14663 res->mac.addr_bytes, res->pi); 14664 #endif 14665 RTE_SET_USED(is_tx); 14666 14667 switch (ret) { 14668 case 0: 14669 break; 14670 case -ENODEV: 14671 printf("invalid port_id %d\n", res->port_id); 14672 break; 14673 case -ENOTSUP: 14674 printf("not supported on port %d\n", res->port_id); 14675 break; 14676 default: 14677 printf("programming error: (%s)\n", strerror(-ret)); 14678 } 14679 } 14680 14681 cmdline_parse_inst_t cmd_set_macsec_sc = { 14682 .f = cmd_set_macsec_sc_parsed, 14683 .data = NULL, 14684 .help_str = "set macsec sc tx|rx <port_id> <mac> <pi>", 14685 .tokens = { 14686 (void *)&cmd_macsec_sc_set, 14687 (void *)&cmd_macsec_sc_macsec, 14688 (void *)&cmd_macsec_sc_sc, 14689 (void *)&cmd_macsec_sc_tx_rx, 14690 (void *)&cmd_macsec_sc_port_id, 14691 (void *)&cmd_macsec_sc_mac, 14692 (void *)&cmd_macsec_sc_pi, 14693 NULL, 14694 }, 14695 }; 14696 14697 /* Common result structure for MACsec secure connection configure */ 14698 struct cmd_macsec_sa_result { 14699 cmdline_fixed_string_t set; 14700 cmdline_fixed_string_t macsec; 14701 cmdline_fixed_string_t sa; 14702 cmdline_fixed_string_t tx_rx; 14703 portid_t port_id; 14704 uint8_t idx; 14705 uint8_t an; 14706 uint32_t pn; 14707 cmdline_fixed_string_t key; 14708 }; 14709 14710 /* Common CLI fields for MACsec secure connection configure */ 14711 cmdline_parse_token_string_t cmd_macsec_sa_set = 14712 TOKEN_STRING_INITIALIZER 14713 (struct cmd_macsec_sa_result, 14714 set, "set"); 14715 cmdline_parse_token_string_t cmd_macsec_sa_macsec = 14716 TOKEN_STRING_INITIALIZER 14717 (struct cmd_macsec_sa_result, 14718 macsec, "macsec"); 14719 cmdline_parse_token_string_t cmd_macsec_sa_sa = 14720 TOKEN_STRING_INITIALIZER 14721 (struct cmd_macsec_sa_result, 14722 sa, "sa"); 14723 cmdline_parse_token_string_t cmd_macsec_sa_tx_rx = 14724 TOKEN_STRING_INITIALIZER 14725 (struct cmd_macsec_sa_result, 14726 tx_rx, "tx#rx"); 14727 cmdline_parse_token_num_t cmd_macsec_sa_port_id = 14728 TOKEN_NUM_INITIALIZER 14729 (struct cmd_macsec_sa_result, 14730 port_id, UINT16); 14731 cmdline_parse_token_num_t cmd_macsec_sa_idx = 14732 TOKEN_NUM_INITIALIZER 14733 (struct cmd_macsec_sa_result, 14734 idx, UINT8); 14735 cmdline_parse_token_num_t cmd_macsec_sa_an = 14736 TOKEN_NUM_INITIALIZER 14737 (struct cmd_macsec_sa_result, 14738 an, UINT8); 14739 cmdline_parse_token_num_t cmd_macsec_sa_pn = 14740 TOKEN_NUM_INITIALIZER 14741 (struct cmd_macsec_sa_result, 14742 pn, UINT32); 14743 cmdline_parse_token_string_t cmd_macsec_sa_key = 14744 TOKEN_STRING_INITIALIZER 14745 (struct cmd_macsec_sa_result, 14746 key, NULL); 14747 14748 static void 14749 cmd_set_macsec_sa_parsed( 14750 void *parsed_result, 14751 __rte_unused struct cmdline *cl, 14752 __rte_unused void *data) 14753 { 14754 struct cmd_macsec_sa_result *res = parsed_result; 14755 int ret = -ENOTSUP; 14756 int is_tx = (strcmp(res->tx_rx, "tx") == 0) ? 1 : 0; 14757 uint8_t key[16] = { 0 }; 14758 uint8_t xdgt0; 14759 uint8_t xdgt1; 14760 int key_len; 14761 int i; 14762 14763 key_len = strlen(res->key) / 2; 14764 if (key_len > 16) 14765 key_len = 16; 14766 14767 for (i = 0; i < key_len; i++) { 14768 xdgt0 = parse_and_check_key_hexa_digit(res->key, (i * 2)); 14769 if (xdgt0 == 0xFF) 14770 return; 14771 xdgt1 = parse_and_check_key_hexa_digit(res->key, (i * 2) + 1); 14772 if (xdgt1 == 0xFF) 14773 return; 14774 key[i] = (uint8_t) ((xdgt0 * 16) + xdgt1); 14775 } 14776 14777 #ifdef RTE_LIBRTE_IXGBE_PMD 14778 ret = is_tx ? 14779 rte_pmd_ixgbe_macsec_select_txsa(res->port_id, 14780 res->idx, res->an, res->pn, key) : 14781 rte_pmd_ixgbe_macsec_select_rxsa(res->port_id, 14782 res->idx, res->an, res->pn, key); 14783 #endif 14784 RTE_SET_USED(is_tx); 14785 RTE_SET_USED(key); 14786 14787 switch (ret) { 14788 case 0: 14789 break; 14790 case -EINVAL: 14791 printf("invalid idx %d or an %d\n", res->idx, res->an); 14792 break; 14793 case -ENODEV: 14794 printf("invalid port_id %d\n", res->port_id); 14795 break; 14796 case -ENOTSUP: 14797 printf("not supported on port %d\n", res->port_id); 14798 break; 14799 default: 14800 printf("programming error: (%s)\n", strerror(-ret)); 14801 } 14802 } 14803 14804 cmdline_parse_inst_t cmd_set_macsec_sa = { 14805 .f = cmd_set_macsec_sa_parsed, 14806 .data = NULL, 14807 .help_str = "set macsec sa tx|rx <port_id> <idx> <an> <pn> <key>", 14808 .tokens = { 14809 (void *)&cmd_macsec_sa_set, 14810 (void *)&cmd_macsec_sa_macsec, 14811 (void *)&cmd_macsec_sa_sa, 14812 (void *)&cmd_macsec_sa_tx_rx, 14813 (void *)&cmd_macsec_sa_port_id, 14814 (void *)&cmd_macsec_sa_idx, 14815 (void *)&cmd_macsec_sa_an, 14816 (void *)&cmd_macsec_sa_pn, 14817 (void *)&cmd_macsec_sa_key, 14818 NULL, 14819 }, 14820 }; 14821 14822 /* VF unicast promiscuous mode configuration */ 14823 14824 /* Common result structure for VF unicast promiscuous mode */ 14825 struct cmd_vf_promisc_result { 14826 cmdline_fixed_string_t set; 14827 cmdline_fixed_string_t vf; 14828 cmdline_fixed_string_t promisc; 14829 portid_t port_id; 14830 uint32_t vf_id; 14831 cmdline_fixed_string_t on_off; 14832 }; 14833 14834 /* Common CLI fields for VF unicast promiscuous mode enable disable */ 14835 cmdline_parse_token_string_t cmd_vf_promisc_set = 14836 TOKEN_STRING_INITIALIZER 14837 (struct cmd_vf_promisc_result, 14838 set, "set"); 14839 cmdline_parse_token_string_t cmd_vf_promisc_vf = 14840 TOKEN_STRING_INITIALIZER 14841 (struct cmd_vf_promisc_result, 14842 vf, "vf"); 14843 cmdline_parse_token_string_t cmd_vf_promisc_promisc = 14844 TOKEN_STRING_INITIALIZER 14845 (struct cmd_vf_promisc_result, 14846 promisc, "promisc"); 14847 cmdline_parse_token_num_t cmd_vf_promisc_port_id = 14848 TOKEN_NUM_INITIALIZER 14849 (struct cmd_vf_promisc_result, 14850 port_id, UINT16); 14851 cmdline_parse_token_num_t cmd_vf_promisc_vf_id = 14852 TOKEN_NUM_INITIALIZER 14853 (struct cmd_vf_promisc_result, 14854 vf_id, UINT32); 14855 cmdline_parse_token_string_t cmd_vf_promisc_on_off = 14856 TOKEN_STRING_INITIALIZER 14857 (struct cmd_vf_promisc_result, 14858 on_off, "on#off"); 14859 14860 static void 14861 cmd_set_vf_promisc_parsed( 14862 void *parsed_result, 14863 __rte_unused struct cmdline *cl, 14864 __rte_unused void *data) 14865 { 14866 struct cmd_vf_promisc_result *res = parsed_result; 14867 int ret = -ENOTSUP; 14868 14869 __rte_unused int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0; 14870 14871 if (port_id_is_invalid(res->port_id, ENABLED_WARN)) 14872 return; 14873 14874 #ifdef RTE_LIBRTE_I40E_PMD 14875 ret = rte_pmd_i40e_set_vf_unicast_promisc(res->port_id, 14876 res->vf_id, is_on); 14877 #endif 14878 14879 switch (ret) { 14880 case 0: 14881 break; 14882 case -EINVAL: 14883 printf("invalid vf_id %d\n", res->vf_id); 14884 break; 14885 case -ENODEV: 14886 printf("invalid port_id %d\n", res->port_id); 14887 break; 14888 case -ENOTSUP: 14889 printf("function not implemented\n"); 14890 break; 14891 default: 14892 printf("programming error: (%s)\n", strerror(-ret)); 14893 } 14894 } 14895 14896 cmdline_parse_inst_t cmd_set_vf_promisc = { 14897 .f = cmd_set_vf_promisc_parsed, 14898 .data = NULL, 14899 .help_str = "set vf promisc <port_id> <vf_id> on|off: " 14900 "Set unicast promiscuous mode for a VF from the PF", 14901 .tokens = { 14902 (void *)&cmd_vf_promisc_set, 14903 (void *)&cmd_vf_promisc_vf, 14904 (void *)&cmd_vf_promisc_promisc, 14905 (void *)&cmd_vf_promisc_port_id, 14906 (void *)&cmd_vf_promisc_vf_id, 14907 (void *)&cmd_vf_promisc_on_off, 14908 NULL, 14909 }, 14910 }; 14911 14912 /* VF multicast promiscuous mode configuration */ 14913 14914 /* Common result structure for VF multicast promiscuous mode */ 14915 struct cmd_vf_allmulti_result { 14916 cmdline_fixed_string_t set; 14917 cmdline_fixed_string_t vf; 14918 cmdline_fixed_string_t allmulti; 14919 portid_t port_id; 14920 uint32_t vf_id; 14921 cmdline_fixed_string_t on_off; 14922 }; 14923 14924 /* Common CLI fields for VF multicast promiscuous mode enable disable */ 14925 cmdline_parse_token_string_t cmd_vf_allmulti_set = 14926 TOKEN_STRING_INITIALIZER 14927 (struct cmd_vf_allmulti_result, 14928 set, "set"); 14929 cmdline_parse_token_string_t cmd_vf_allmulti_vf = 14930 TOKEN_STRING_INITIALIZER 14931 (struct cmd_vf_allmulti_result, 14932 vf, "vf"); 14933 cmdline_parse_token_string_t cmd_vf_allmulti_allmulti = 14934 TOKEN_STRING_INITIALIZER 14935 (struct cmd_vf_allmulti_result, 14936 allmulti, "allmulti"); 14937 cmdline_parse_token_num_t cmd_vf_allmulti_port_id = 14938 TOKEN_NUM_INITIALIZER 14939 (struct cmd_vf_allmulti_result, 14940 port_id, UINT16); 14941 cmdline_parse_token_num_t cmd_vf_allmulti_vf_id = 14942 TOKEN_NUM_INITIALIZER 14943 (struct cmd_vf_allmulti_result, 14944 vf_id, UINT32); 14945 cmdline_parse_token_string_t cmd_vf_allmulti_on_off = 14946 TOKEN_STRING_INITIALIZER 14947 (struct cmd_vf_allmulti_result, 14948 on_off, "on#off"); 14949 14950 static void 14951 cmd_set_vf_allmulti_parsed( 14952 void *parsed_result, 14953 __rte_unused struct cmdline *cl, 14954 __rte_unused void *data) 14955 { 14956 struct cmd_vf_allmulti_result *res = parsed_result; 14957 int ret = -ENOTSUP; 14958 14959 __rte_unused int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0; 14960 14961 if (port_id_is_invalid(res->port_id, ENABLED_WARN)) 14962 return; 14963 14964 #ifdef RTE_LIBRTE_I40E_PMD 14965 ret = rte_pmd_i40e_set_vf_multicast_promisc(res->port_id, 14966 res->vf_id, is_on); 14967 #endif 14968 14969 switch (ret) { 14970 case 0: 14971 break; 14972 case -EINVAL: 14973 printf("invalid vf_id %d\n", res->vf_id); 14974 break; 14975 case -ENODEV: 14976 printf("invalid port_id %d\n", res->port_id); 14977 break; 14978 case -ENOTSUP: 14979 printf("function not implemented\n"); 14980 break; 14981 default: 14982 printf("programming error: (%s)\n", strerror(-ret)); 14983 } 14984 } 14985 14986 cmdline_parse_inst_t cmd_set_vf_allmulti = { 14987 .f = cmd_set_vf_allmulti_parsed, 14988 .data = NULL, 14989 .help_str = "set vf allmulti <port_id> <vf_id> on|off: " 14990 "Set multicast promiscuous mode for a VF from the PF", 14991 .tokens = { 14992 (void *)&cmd_vf_allmulti_set, 14993 (void *)&cmd_vf_allmulti_vf, 14994 (void *)&cmd_vf_allmulti_allmulti, 14995 (void *)&cmd_vf_allmulti_port_id, 14996 (void *)&cmd_vf_allmulti_vf_id, 14997 (void *)&cmd_vf_allmulti_on_off, 14998 NULL, 14999 }, 15000 }; 15001 15002 /* vf broadcast mode configuration */ 15003 15004 /* Common result structure for vf broadcast */ 15005 struct cmd_set_vf_broadcast_result { 15006 cmdline_fixed_string_t set; 15007 cmdline_fixed_string_t vf; 15008 cmdline_fixed_string_t broadcast; 15009 portid_t port_id; 15010 uint16_t vf_id; 15011 cmdline_fixed_string_t on_off; 15012 }; 15013 15014 /* Common CLI fields for vf broadcast enable disable */ 15015 cmdline_parse_token_string_t cmd_set_vf_broadcast_set = 15016 TOKEN_STRING_INITIALIZER 15017 (struct cmd_set_vf_broadcast_result, 15018 set, "set"); 15019 cmdline_parse_token_string_t cmd_set_vf_broadcast_vf = 15020 TOKEN_STRING_INITIALIZER 15021 (struct cmd_set_vf_broadcast_result, 15022 vf, "vf"); 15023 cmdline_parse_token_string_t cmd_set_vf_broadcast_broadcast = 15024 TOKEN_STRING_INITIALIZER 15025 (struct cmd_set_vf_broadcast_result, 15026 broadcast, "broadcast"); 15027 cmdline_parse_token_num_t cmd_set_vf_broadcast_port_id = 15028 TOKEN_NUM_INITIALIZER 15029 (struct cmd_set_vf_broadcast_result, 15030 port_id, UINT16); 15031 cmdline_parse_token_num_t cmd_set_vf_broadcast_vf_id = 15032 TOKEN_NUM_INITIALIZER 15033 (struct cmd_set_vf_broadcast_result, 15034 vf_id, UINT16); 15035 cmdline_parse_token_string_t cmd_set_vf_broadcast_on_off = 15036 TOKEN_STRING_INITIALIZER 15037 (struct cmd_set_vf_broadcast_result, 15038 on_off, "on#off"); 15039 15040 static void 15041 cmd_set_vf_broadcast_parsed( 15042 void *parsed_result, 15043 __rte_unused struct cmdline *cl, 15044 __rte_unused void *data) 15045 { 15046 struct cmd_set_vf_broadcast_result *res = parsed_result; 15047 int ret = -ENOTSUP; 15048 15049 __rte_unused int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0; 15050 15051 if (port_id_is_invalid(res->port_id, ENABLED_WARN)) 15052 return; 15053 15054 #ifdef RTE_LIBRTE_I40E_PMD 15055 ret = rte_pmd_i40e_set_vf_broadcast(res->port_id, 15056 res->vf_id, is_on); 15057 #endif 15058 15059 switch (ret) { 15060 case 0: 15061 break; 15062 case -EINVAL: 15063 printf("invalid vf_id %d or is_on %d\n", res->vf_id, is_on); 15064 break; 15065 case -ENODEV: 15066 printf("invalid port_id %d\n", res->port_id); 15067 break; 15068 case -ENOTSUP: 15069 printf("function not implemented\n"); 15070 break; 15071 default: 15072 printf("programming error: (%s)\n", strerror(-ret)); 15073 } 15074 } 15075 15076 cmdline_parse_inst_t cmd_set_vf_broadcast = { 15077 .f = cmd_set_vf_broadcast_parsed, 15078 .data = NULL, 15079 .help_str = "set vf broadcast <port_id> <vf_id> on|off", 15080 .tokens = { 15081 (void *)&cmd_set_vf_broadcast_set, 15082 (void *)&cmd_set_vf_broadcast_vf, 15083 (void *)&cmd_set_vf_broadcast_broadcast, 15084 (void *)&cmd_set_vf_broadcast_port_id, 15085 (void *)&cmd_set_vf_broadcast_vf_id, 15086 (void *)&cmd_set_vf_broadcast_on_off, 15087 NULL, 15088 }, 15089 }; 15090 15091 /* vf vlan tag configuration */ 15092 15093 /* Common result structure for vf vlan tag */ 15094 struct cmd_set_vf_vlan_tag_result { 15095 cmdline_fixed_string_t set; 15096 cmdline_fixed_string_t vf; 15097 cmdline_fixed_string_t vlan; 15098 cmdline_fixed_string_t tag; 15099 portid_t port_id; 15100 uint16_t vf_id; 15101 cmdline_fixed_string_t on_off; 15102 }; 15103 15104 /* Common CLI fields for vf vlan tag enable disable */ 15105 cmdline_parse_token_string_t cmd_set_vf_vlan_tag_set = 15106 TOKEN_STRING_INITIALIZER 15107 (struct cmd_set_vf_vlan_tag_result, 15108 set, "set"); 15109 cmdline_parse_token_string_t cmd_set_vf_vlan_tag_vf = 15110 TOKEN_STRING_INITIALIZER 15111 (struct cmd_set_vf_vlan_tag_result, 15112 vf, "vf"); 15113 cmdline_parse_token_string_t cmd_set_vf_vlan_tag_vlan = 15114 TOKEN_STRING_INITIALIZER 15115 (struct cmd_set_vf_vlan_tag_result, 15116 vlan, "vlan"); 15117 cmdline_parse_token_string_t cmd_set_vf_vlan_tag_tag = 15118 TOKEN_STRING_INITIALIZER 15119 (struct cmd_set_vf_vlan_tag_result, 15120 tag, "tag"); 15121 cmdline_parse_token_num_t cmd_set_vf_vlan_tag_port_id = 15122 TOKEN_NUM_INITIALIZER 15123 (struct cmd_set_vf_vlan_tag_result, 15124 port_id, UINT16); 15125 cmdline_parse_token_num_t cmd_set_vf_vlan_tag_vf_id = 15126 TOKEN_NUM_INITIALIZER 15127 (struct cmd_set_vf_vlan_tag_result, 15128 vf_id, UINT16); 15129 cmdline_parse_token_string_t cmd_set_vf_vlan_tag_on_off = 15130 TOKEN_STRING_INITIALIZER 15131 (struct cmd_set_vf_vlan_tag_result, 15132 on_off, "on#off"); 15133 15134 static void 15135 cmd_set_vf_vlan_tag_parsed( 15136 void *parsed_result, 15137 __rte_unused struct cmdline *cl, 15138 __rte_unused void *data) 15139 { 15140 struct cmd_set_vf_vlan_tag_result *res = parsed_result; 15141 int ret = -ENOTSUP; 15142 15143 __rte_unused int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0; 15144 15145 if (port_id_is_invalid(res->port_id, ENABLED_WARN)) 15146 return; 15147 15148 #ifdef RTE_LIBRTE_I40E_PMD 15149 ret = rte_pmd_i40e_set_vf_vlan_tag(res->port_id, 15150 res->vf_id, is_on); 15151 #endif 15152 15153 switch (ret) { 15154 case 0: 15155 break; 15156 case -EINVAL: 15157 printf("invalid vf_id %d or is_on %d\n", res->vf_id, is_on); 15158 break; 15159 case -ENODEV: 15160 printf("invalid port_id %d\n", res->port_id); 15161 break; 15162 case -ENOTSUP: 15163 printf("function not implemented\n"); 15164 break; 15165 default: 15166 printf("programming error: (%s)\n", strerror(-ret)); 15167 } 15168 } 15169 15170 cmdline_parse_inst_t cmd_set_vf_vlan_tag = { 15171 .f = cmd_set_vf_vlan_tag_parsed, 15172 .data = NULL, 15173 .help_str = "set vf vlan tag <port_id> <vf_id> on|off", 15174 .tokens = { 15175 (void *)&cmd_set_vf_vlan_tag_set, 15176 (void *)&cmd_set_vf_vlan_tag_vf, 15177 (void *)&cmd_set_vf_vlan_tag_vlan, 15178 (void *)&cmd_set_vf_vlan_tag_tag, 15179 (void *)&cmd_set_vf_vlan_tag_port_id, 15180 (void *)&cmd_set_vf_vlan_tag_vf_id, 15181 (void *)&cmd_set_vf_vlan_tag_on_off, 15182 NULL, 15183 }, 15184 }; 15185 15186 /* Common definition of VF and TC TX bandwidth configuration */ 15187 struct cmd_vf_tc_bw_result { 15188 cmdline_fixed_string_t set; 15189 cmdline_fixed_string_t vf; 15190 cmdline_fixed_string_t tc; 15191 cmdline_fixed_string_t tx; 15192 cmdline_fixed_string_t min_bw; 15193 cmdline_fixed_string_t max_bw; 15194 cmdline_fixed_string_t strict_link_prio; 15195 portid_t port_id; 15196 uint16_t vf_id; 15197 uint8_t tc_no; 15198 uint32_t bw; 15199 cmdline_fixed_string_t bw_list; 15200 uint8_t tc_map; 15201 }; 15202 15203 cmdline_parse_token_string_t cmd_vf_tc_bw_set = 15204 TOKEN_STRING_INITIALIZER 15205 (struct cmd_vf_tc_bw_result, 15206 set, "set"); 15207 cmdline_parse_token_string_t cmd_vf_tc_bw_vf = 15208 TOKEN_STRING_INITIALIZER 15209 (struct cmd_vf_tc_bw_result, 15210 vf, "vf"); 15211 cmdline_parse_token_string_t cmd_vf_tc_bw_tc = 15212 TOKEN_STRING_INITIALIZER 15213 (struct cmd_vf_tc_bw_result, 15214 tc, "tc"); 15215 cmdline_parse_token_string_t cmd_vf_tc_bw_tx = 15216 TOKEN_STRING_INITIALIZER 15217 (struct cmd_vf_tc_bw_result, 15218 tx, "tx"); 15219 cmdline_parse_token_string_t cmd_vf_tc_bw_strict_link_prio = 15220 TOKEN_STRING_INITIALIZER 15221 (struct cmd_vf_tc_bw_result, 15222 strict_link_prio, "strict-link-priority"); 15223 cmdline_parse_token_string_t cmd_vf_tc_bw_min_bw = 15224 TOKEN_STRING_INITIALIZER 15225 (struct cmd_vf_tc_bw_result, 15226 min_bw, "min-bandwidth"); 15227 cmdline_parse_token_string_t cmd_vf_tc_bw_max_bw = 15228 TOKEN_STRING_INITIALIZER 15229 (struct cmd_vf_tc_bw_result, 15230 max_bw, "max-bandwidth"); 15231 cmdline_parse_token_num_t cmd_vf_tc_bw_port_id = 15232 TOKEN_NUM_INITIALIZER 15233 (struct cmd_vf_tc_bw_result, 15234 port_id, UINT16); 15235 cmdline_parse_token_num_t cmd_vf_tc_bw_vf_id = 15236 TOKEN_NUM_INITIALIZER 15237 (struct cmd_vf_tc_bw_result, 15238 vf_id, UINT16); 15239 cmdline_parse_token_num_t cmd_vf_tc_bw_tc_no = 15240 TOKEN_NUM_INITIALIZER 15241 (struct cmd_vf_tc_bw_result, 15242 tc_no, UINT8); 15243 cmdline_parse_token_num_t cmd_vf_tc_bw_bw = 15244 TOKEN_NUM_INITIALIZER 15245 (struct cmd_vf_tc_bw_result, 15246 bw, UINT32); 15247 cmdline_parse_token_string_t cmd_vf_tc_bw_bw_list = 15248 TOKEN_STRING_INITIALIZER 15249 (struct cmd_vf_tc_bw_result, 15250 bw_list, NULL); 15251 cmdline_parse_token_num_t cmd_vf_tc_bw_tc_map = 15252 TOKEN_NUM_INITIALIZER 15253 (struct cmd_vf_tc_bw_result, 15254 tc_map, UINT8); 15255 15256 /* VF max bandwidth setting */ 15257 static void 15258 cmd_vf_max_bw_parsed( 15259 void *parsed_result, 15260 __rte_unused struct cmdline *cl, 15261 __rte_unused void *data) 15262 { 15263 struct cmd_vf_tc_bw_result *res = parsed_result; 15264 int ret = -ENOTSUP; 15265 15266 if (port_id_is_invalid(res->port_id, ENABLED_WARN)) 15267 return; 15268 15269 #ifdef RTE_LIBRTE_I40E_PMD 15270 ret = rte_pmd_i40e_set_vf_max_bw(res->port_id, 15271 res->vf_id, res->bw); 15272 #endif 15273 15274 switch (ret) { 15275 case 0: 15276 break; 15277 case -EINVAL: 15278 printf("invalid vf_id %d or bandwidth %d\n", 15279 res->vf_id, res->bw); 15280 break; 15281 case -ENODEV: 15282 printf("invalid port_id %d\n", res->port_id); 15283 break; 15284 case -ENOTSUP: 15285 printf("function not implemented\n"); 15286 break; 15287 default: 15288 printf("programming error: (%s)\n", strerror(-ret)); 15289 } 15290 } 15291 15292 cmdline_parse_inst_t cmd_vf_max_bw = { 15293 .f = cmd_vf_max_bw_parsed, 15294 .data = NULL, 15295 .help_str = "set vf tx max-bandwidth <port_id> <vf_id> <bandwidth>", 15296 .tokens = { 15297 (void *)&cmd_vf_tc_bw_set, 15298 (void *)&cmd_vf_tc_bw_vf, 15299 (void *)&cmd_vf_tc_bw_tx, 15300 (void *)&cmd_vf_tc_bw_max_bw, 15301 (void *)&cmd_vf_tc_bw_port_id, 15302 (void *)&cmd_vf_tc_bw_vf_id, 15303 (void *)&cmd_vf_tc_bw_bw, 15304 NULL, 15305 }, 15306 }; 15307 15308 static int 15309 vf_tc_min_bw_parse_bw_list(uint8_t *bw_list, 15310 uint8_t *tc_num, 15311 char *str) 15312 { 15313 uint32_t size; 15314 const char *p, *p0 = str; 15315 char s[256]; 15316 char *end; 15317 char *str_fld[16]; 15318 uint16_t i; 15319 int ret; 15320 15321 p = strchr(p0, '('); 15322 if (p == NULL) { 15323 printf("The bandwidth-list should be '(bw1, bw2, ...)'\n"); 15324 return -1; 15325 } 15326 p++; 15327 p0 = strchr(p, ')'); 15328 if (p0 == NULL) { 15329 printf("The bandwidth-list should be '(bw1, bw2, ...)'\n"); 15330 return -1; 15331 } 15332 size = p0 - p; 15333 if (size >= sizeof(s)) { 15334 printf("The string size exceeds the internal buffer size\n"); 15335 return -1; 15336 } 15337 snprintf(s, sizeof(s), "%.*s", size, p); 15338 ret = rte_strsplit(s, sizeof(s), str_fld, 16, ','); 15339 if (ret <= 0) { 15340 printf("Failed to get the bandwidth list. "); 15341 return -1; 15342 } 15343 *tc_num = ret; 15344 for (i = 0; i < ret; i++) 15345 bw_list[i] = (uint8_t)strtoul(str_fld[i], &end, 0); 15346 15347 return 0; 15348 } 15349 15350 /* TC min bandwidth setting */ 15351 static void 15352 cmd_vf_tc_min_bw_parsed( 15353 void *parsed_result, 15354 __rte_unused struct cmdline *cl, 15355 __rte_unused void *data) 15356 { 15357 struct cmd_vf_tc_bw_result *res = parsed_result; 15358 uint8_t tc_num; 15359 uint8_t bw[16]; 15360 int ret = -ENOTSUP; 15361 15362 if (port_id_is_invalid(res->port_id, ENABLED_WARN)) 15363 return; 15364 15365 ret = vf_tc_min_bw_parse_bw_list(bw, &tc_num, res->bw_list); 15366 if (ret) 15367 return; 15368 15369 #ifdef RTE_LIBRTE_I40E_PMD 15370 ret = rte_pmd_i40e_set_vf_tc_bw_alloc(res->port_id, res->vf_id, 15371 tc_num, bw); 15372 #endif 15373 15374 switch (ret) { 15375 case 0: 15376 break; 15377 case -EINVAL: 15378 printf("invalid vf_id %d or bandwidth\n", res->vf_id); 15379 break; 15380 case -ENODEV: 15381 printf("invalid port_id %d\n", res->port_id); 15382 break; 15383 case -ENOTSUP: 15384 printf("function not implemented\n"); 15385 break; 15386 default: 15387 printf("programming error: (%s)\n", strerror(-ret)); 15388 } 15389 } 15390 15391 cmdline_parse_inst_t cmd_vf_tc_min_bw = { 15392 .f = cmd_vf_tc_min_bw_parsed, 15393 .data = NULL, 15394 .help_str = "set vf tc tx min-bandwidth <port_id> <vf_id>" 15395 " <bw1, bw2, ...>", 15396 .tokens = { 15397 (void *)&cmd_vf_tc_bw_set, 15398 (void *)&cmd_vf_tc_bw_vf, 15399 (void *)&cmd_vf_tc_bw_tc, 15400 (void *)&cmd_vf_tc_bw_tx, 15401 (void *)&cmd_vf_tc_bw_min_bw, 15402 (void *)&cmd_vf_tc_bw_port_id, 15403 (void *)&cmd_vf_tc_bw_vf_id, 15404 (void *)&cmd_vf_tc_bw_bw_list, 15405 NULL, 15406 }, 15407 }; 15408 15409 static void 15410 cmd_tc_min_bw_parsed( 15411 void *parsed_result, 15412 __rte_unused struct cmdline *cl, 15413 __rte_unused void *data) 15414 { 15415 struct cmd_vf_tc_bw_result *res = parsed_result; 15416 struct rte_port *port; 15417 uint8_t tc_num; 15418 uint8_t bw[16]; 15419 int ret = -ENOTSUP; 15420 15421 if (port_id_is_invalid(res->port_id, ENABLED_WARN)) 15422 return; 15423 15424 port = &ports[res->port_id]; 15425 /** Check if the port is not started **/ 15426 if (port->port_status != RTE_PORT_STOPPED) { 15427 printf("Please stop port %d first\n", res->port_id); 15428 return; 15429 } 15430 15431 ret = vf_tc_min_bw_parse_bw_list(bw, &tc_num, res->bw_list); 15432 if (ret) 15433 return; 15434 15435 #ifdef RTE_LIBRTE_IXGBE_PMD 15436 ret = rte_pmd_ixgbe_set_tc_bw_alloc(res->port_id, tc_num, bw); 15437 #endif 15438 15439 switch (ret) { 15440 case 0: 15441 break; 15442 case -EINVAL: 15443 printf("invalid bandwidth\n"); 15444 break; 15445 case -ENODEV: 15446 printf("invalid port_id %d\n", res->port_id); 15447 break; 15448 case -ENOTSUP: 15449 printf("function not implemented\n"); 15450 break; 15451 default: 15452 printf("programming error: (%s)\n", strerror(-ret)); 15453 } 15454 } 15455 15456 cmdline_parse_inst_t cmd_tc_min_bw = { 15457 .f = cmd_tc_min_bw_parsed, 15458 .data = NULL, 15459 .help_str = "set tc tx min-bandwidth <port_id> <bw1, bw2, ...>", 15460 .tokens = { 15461 (void *)&cmd_vf_tc_bw_set, 15462 (void *)&cmd_vf_tc_bw_tc, 15463 (void *)&cmd_vf_tc_bw_tx, 15464 (void *)&cmd_vf_tc_bw_min_bw, 15465 (void *)&cmd_vf_tc_bw_port_id, 15466 (void *)&cmd_vf_tc_bw_bw_list, 15467 NULL, 15468 }, 15469 }; 15470 15471 /* TC max bandwidth setting */ 15472 static void 15473 cmd_vf_tc_max_bw_parsed( 15474 void *parsed_result, 15475 __rte_unused struct cmdline *cl, 15476 __rte_unused void *data) 15477 { 15478 struct cmd_vf_tc_bw_result *res = parsed_result; 15479 int ret = -ENOTSUP; 15480 15481 if (port_id_is_invalid(res->port_id, ENABLED_WARN)) 15482 return; 15483 15484 #ifdef RTE_LIBRTE_I40E_PMD 15485 ret = rte_pmd_i40e_set_vf_tc_max_bw(res->port_id, res->vf_id, 15486 res->tc_no, res->bw); 15487 #endif 15488 15489 switch (ret) { 15490 case 0: 15491 break; 15492 case -EINVAL: 15493 printf("invalid vf_id %d, tc_no %d or bandwidth %d\n", 15494 res->vf_id, res->tc_no, res->bw); 15495 break; 15496 case -ENODEV: 15497 printf("invalid port_id %d\n", res->port_id); 15498 break; 15499 case -ENOTSUP: 15500 printf("function not implemented\n"); 15501 break; 15502 default: 15503 printf("programming error: (%s)\n", strerror(-ret)); 15504 } 15505 } 15506 15507 cmdline_parse_inst_t cmd_vf_tc_max_bw = { 15508 .f = cmd_vf_tc_max_bw_parsed, 15509 .data = NULL, 15510 .help_str = "set vf tc tx max-bandwidth <port_id> <vf_id> <tc_no>" 15511 " <bandwidth>", 15512 .tokens = { 15513 (void *)&cmd_vf_tc_bw_set, 15514 (void *)&cmd_vf_tc_bw_vf, 15515 (void *)&cmd_vf_tc_bw_tc, 15516 (void *)&cmd_vf_tc_bw_tx, 15517 (void *)&cmd_vf_tc_bw_max_bw, 15518 (void *)&cmd_vf_tc_bw_port_id, 15519 (void *)&cmd_vf_tc_bw_vf_id, 15520 (void *)&cmd_vf_tc_bw_tc_no, 15521 (void *)&cmd_vf_tc_bw_bw, 15522 NULL, 15523 }, 15524 }; 15525 15526 /** Set VXLAN encapsulation details */ 15527 struct cmd_set_vxlan_result { 15528 cmdline_fixed_string_t set; 15529 cmdline_fixed_string_t vxlan; 15530 cmdline_fixed_string_t pos_token; 15531 cmdline_fixed_string_t ip_version; 15532 uint32_t vlan_present:1; 15533 uint32_t vni; 15534 uint16_t udp_src; 15535 uint16_t udp_dst; 15536 cmdline_ipaddr_t ip_src; 15537 cmdline_ipaddr_t ip_dst; 15538 uint16_t tci; 15539 uint8_t tos; 15540 uint8_t ttl; 15541 struct rte_ether_addr eth_src; 15542 struct rte_ether_addr eth_dst; 15543 }; 15544 15545 cmdline_parse_token_string_t cmd_set_vxlan_set = 15546 TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, set, "set"); 15547 cmdline_parse_token_string_t cmd_set_vxlan_vxlan = 15548 TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, vxlan, "vxlan"); 15549 cmdline_parse_token_string_t cmd_set_vxlan_vxlan_tos_ttl = 15550 TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, vxlan, 15551 "vxlan-tos-ttl"); 15552 cmdline_parse_token_string_t cmd_set_vxlan_vxlan_with_vlan = 15553 TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, vxlan, 15554 "vxlan-with-vlan"); 15555 cmdline_parse_token_string_t cmd_set_vxlan_ip_version = 15556 TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, pos_token, 15557 "ip-version"); 15558 cmdline_parse_token_string_t cmd_set_vxlan_ip_version_value = 15559 TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, ip_version, 15560 "ipv4#ipv6"); 15561 cmdline_parse_token_string_t cmd_set_vxlan_vni = 15562 TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, pos_token, 15563 "vni"); 15564 cmdline_parse_token_num_t cmd_set_vxlan_vni_value = 15565 TOKEN_NUM_INITIALIZER(struct cmd_set_vxlan_result, vni, UINT32); 15566 cmdline_parse_token_string_t cmd_set_vxlan_udp_src = 15567 TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, pos_token, 15568 "udp-src"); 15569 cmdline_parse_token_num_t cmd_set_vxlan_udp_src_value = 15570 TOKEN_NUM_INITIALIZER(struct cmd_set_vxlan_result, udp_src, UINT16); 15571 cmdline_parse_token_string_t cmd_set_vxlan_udp_dst = 15572 TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, pos_token, 15573 "udp-dst"); 15574 cmdline_parse_token_num_t cmd_set_vxlan_udp_dst_value = 15575 TOKEN_NUM_INITIALIZER(struct cmd_set_vxlan_result, udp_dst, UINT16); 15576 cmdline_parse_token_string_t cmd_set_vxlan_ip_tos = 15577 TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, pos_token, 15578 "ip-tos"); 15579 cmdline_parse_token_num_t cmd_set_vxlan_ip_tos_value = 15580 TOKEN_NUM_INITIALIZER(struct cmd_set_vxlan_result, tos, UINT8); 15581 cmdline_parse_token_string_t cmd_set_vxlan_ip_ttl = 15582 TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, pos_token, 15583 "ip-ttl"); 15584 cmdline_parse_token_num_t cmd_set_vxlan_ip_ttl_value = 15585 TOKEN_NUM_INITIALIZER(struct cmd_set_vxlan_result, ttl, UINT8); 15586 cmdline_parse_token_string_t cmd_set_vxlan_ip_src = 15587 TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, pos_token, 15588 "ip-src"); 15589 cmdline_parse_token_ipaddr_t cmd_set_vxlan_ip_src_value = 15590 TOKEN_IPADDR_INITIALIZER(struct cmd_set_vxlan_result, ip_src); 15591 cmdline_parse_token_string_t cmd_set_vxlan_ip_dst = 15592 TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, pos_token, 15593 "ip-dst"); 15594 cmdline_parse_token_ipaddr_t cmd_set_vxlan_ip_dst_value = 15595 TOKEN_IPADDR_INITIALIZER(struct cmd_set_vxlan_result, ip_dst); 15596 cmdline_parse_token_string_t cmd_set_vxlan_vlan = 15597 TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, pos_token, 15598 "vlan-tci"); 15599 cmdline_parse_token_num_t cmd_set_vxlan_vlan_value = 15600 TOKEN_NUM_INITIALIZER(struct cmd_set_vxlan_result, tci, UINT16); 15601 cmdline_parse_token_string_t cmd_set_vxlan_eth_src = 15602 TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, pos_token, 15603 "eth-src"); 15604 cmdline_parse_token_etheraddr_t cmd_set_vxlan_eth_src_value = 15605 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_vxlan_result, eth_src); 15606 cmdline_parse_token_string_t cmd_set_vxlan_eth_dst = 15607 TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, pos_token, 15608 "eth-dst"); 15609 cmdline_parse_token_etheraddr_t cmd_set_vxlan_eth_dst_value = 15610 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_vxlan_result, eth_dst); 15611 15612 static void cmd_set_vxlan_parsed(void *parsed_result, 15613 __rte_unused struct cmdline *cl, 15614 __rte_unused void *data) 15615 { 15616 struct cmd_set_vxlan_result *res = parsed_result; 15617 union { 15618 uint32_t vxlan_id; 15619 uint8_t vni[4]; 15620 } id = { 15621 .vxlan_id = rte_cpu_to_be_32(res->vni) & RTE_BE32(0x00ffffff), 15622 }; 15623 15624 vxlan_encap_conf.select_tos_ttl = 0; 15625 if (strcmp(res->vxlan, "vxlan") == 0) 15626 vxlan_encap_conf.select_vlan = 0; 15627 else if (strcmp(res->vxlan, "vxlan-with-vlan") == 0) 15628 vxlan_encap_conf.select_vlan = 1; 15629 else if (strcmp(res->vxlan, "vxlan-tos-ttl") == 0) { 15630 vxlan_encap_conf.select_vlan = 0; 15631 vxlan_encap_conf.select_tos_ttl = 1; 15632 } 15633 if (strcmp(res->ip_version, "ipv4") == 0) 15634 vxlan_encap_conf.select_ipv4 = 1; 15635 else if (strcmp(res->ip_version, "ipv6") == 0) 15636 vxlan_encap_conf.select_ipv4 = 0; 15637 else 15638 return; 15639 rte_memcpy(vxlan_encap_conf.vni, &id.vni[1], 3); 15640 vxlan_encap_conf.udp_src = rte_cpu_to_be_16(res->udp_src); 15641 vxlan_encap_conf.udp_dst = rte_cpu_to_be_16(res->udp_dst); 15642 vxlan_encap_conf.ip_tos = res->tos; 15643 vxlan_encap_conf.ip_ttl = res->ttl; 15644 if (vxlan_encap_conf.select_ipv4) { 15645 IPV4_ADDR_TO_UINT(res->ip_src, vxlan_encap_conf.ipv4_src); 15646 IPV4_ADDR_TO_UINT(res->ip_dst, vxlan_encap_conf.ipv4_dst); 15647 } else { 15648 IPV6_ADDR_TO_ARRAY(res->ip_src, vxlan_encap_conf.ipv6_src); 15649 IPV6_ADDR_TO_ARRAY(res->ip_dst, vxlan_encap_conf.ipv6_dst); 15650 } 15651 if (vxlan_encap_conf.select_vlan) 15652 vxlan_encap_conf.vlan_tci = rte_cpu_to_be_16(res->tci); 15653 rte_memcpy(vxlan_encap_conf.eth_src, res->eth_src.addr_bytes, 15654 RTE_ETHER_ADDR_LEN); 15655 rte_memcpy(vxlan_encap_conf.eth_dst, res->eth_dst.addr_bytes, 15656 RTE_ETHER_ADDR_LEN); 15657 } 15658 15659 cmdline_parse_inst_t cmd_set_vxlan = { 15660 .f = cmd_set_vxlan_parsed, 15661 .data = NULL, 15662 .help_str = "set vxlan ip-version ipv4|ipv6 vni <vni> udp-src" 15663 " <udp-src> udp-dst <udp-dst> ip-src <ip-src> ip-dst <ip-dst>" 15664 " eth-src <eth-src> eth-dst <eth-dst>", 15665 .tokens = { 15666 (void *)&cmd_set_vxlan_set, 15667 (void *)&cmd_set_vxlan_vxlan, 15668 (void *)&cmd_set_vxlan_ip_version, 15669 (void *)&cmd_set_vxlan_ip_version_value, 15670 (void *)&cmd_set_vxlan_vni, 15671 (void *)&cmd_set_vxlan_vni_value, 15672 (void *)&cmd_set_vxlan_udp_src, 15673 (void *)&cmd_set_vxlan_udp_src_value, 15674 (void *)&cmd_set_vxlan_udp_dst, 15675 (void *)&cmd_set_vxlan_udp_dst_value, 15676 (void *)&cmd_set_vxlan_ip_src, 15677 (void *)&cmd_set_vxlan_ip_src_value, 15678 (void *)&cmd_set_vxlan_ip_dst, 15679 (void *)&cmd_set_vxlan_ip_dst_value, 15680 (void *)&cmd_set_vxlan_eth_src, 15681 (void *)&cmd_set_vxlan_eth_src_value, 15682 (void *)&cmd_set_vxlan_eth_dst, 15683 (void *)&cmd_set_vxlan_eth_dst_value, 15684 NULL, 15685 }, 15686 }; 15687 15688 cmdline_parse_inst_t cmd_set_vxlan_tos_ttl = { 15689 .f = cmd_set_vxlan_parsed, 15690 .data = NULL, 15691 .help_str = "set vxlan-tos-ttl ip-version ipv4|ipv6 vni <vni> udp-src" 15692 " <udp-src> udp-dst <udp-dst> ip-tos <ip-tos> ip-ttl <ip-ttl>" 15693 " ip-src <ip-src> ip-dst <ip-dst> eth-src <eth-src>" 15694 " eth-dst <eth-dst>", 15695 .tokens = { 15696 (void *)&cmd_set_vxlan_set, 15697 (void *)&cmd_set_vxlan_vxlan_tos_ttl, 15698 (void *)&cmd_set_vxlan_ip_version, 15699 (void *)&cmd_set_vxlan_ip_version_value, 15700 (void *)&cmd_set_vxlan_vni, 15701 (void *)&cmd_set_vxlan_vni_value, 15702 (void *)&cmd_set_vxlan_udp_src, 15703 (void *)&cmd_set_vxlan_udp_src_value, 15704 (void *)&cmd_set_vxlan_udp_dst, 15705 (void *)&cmd_set_vxlan_udp_dst_value, 15706 (void *)&cmd_set_vxlan_ip_tos, 15707 (void *)&cmd_set_vxlan_ip_tos_value, 15708 (void *)&cmd_set_vxlan_ip_ttl, 15709 (void *)&cmd_set_vxlan_ip_ttl_value, 15710 (void *)&cmd_set_vxlan_ip_src, 15711 (void *)&cmd_set_vxlan_ip_src_value, 15712 (void *)&cmd_set_vxlan_ip_dst, 15713 (void *)&cmd_set_vxlan_ip_dst_value, 15714 (void *)&cmd_set_vxlan_eth_src, 15715 (void *)&cmd_set_vxlan_eth_src_value, 15716 (void *)&cmd_set_vxlan_eth_dst, 15717 (void *)&cmd_set_vxlan_eth_dst_value, 15718 NULL, 15719 }, 15720 }; 15721 15722 cmdline_parse_inst_t cmd_set_vxlan_with_vlan = { 15723 .f = cmd_set_vxlan_parsed, 15724 .data = NULL, 15725 .help_str = "set vxlan-with-vlan ip-version ipv4|ipv6 vni <vni>" 15726 " udp-src <udp-src> udp-dst <udp-dst> ip-src <ip-src> ip-dst" 15727 " <ip-dst> vlan-tci <vlan-tci> eth-src <eth-src> eth-dst" 15728 " <eth-dst>", 15729 .tokens = { 15730 (void *)&cmd_set_vxlan_set, 15731 (void *)&cmd_set_vxlan_vxlan_with_vlan, 15732 (void *)&cmd_set_vxlan_ip_version, 15733 (void *)&cmd_set_vxlan_ip_version_value, 15734 (void *)&cmd_set_vxlan_vni, 15735 (void *)&cmd_set_vxlan_vni_value, 15736 (void *)&cmd_set_vxlan_udp_src, 15737 (void *)&cmd_set_vxlan_udp_src_value, 15738 (void *)&cmd_set_vxlan_udp_dst, 15739 (void *)&cmd_set_vxlan_udp_dst_value, 15740 (void *)&cmd_set_vxlan_ip_src, 15741 (void *)&cmd_set_vxlan_ip_src_value, 15742 (void *)&cmd_set_vxlan_ip_dst, 15743 (void *)&cmd_set_vxlan_ip_dst_value, 15744 (void *)&cmd_set_vxlan_vlan, 15745 (void *)&cmd_set_vxlan_vlan_value, 15746 (void *)&cmd_set_vxlan_eth_src, 15747 (void *)&cmd_set_vxlan_eth_src_value, 15748 (void *)&cmd_set_vxlan_eth_dst, 15749 (void *)&cmd_set_vxlan_eth_dst_value, 15750 NULL, 15751 }, 15752 }; 15753 15754 /** Set NVGRE encapsulation details */ 15755 struct cmd_set_nvgre_result { 15756 cmdline_fixed_string_t set; 15757 cmdline_fixed_string_t nvgre; 15758 cmdline_fixed_string_t pos_token; 15759 cmdline_fixed_string_t ip_version; 15760 uint32_t tni; 15761 cmdline_ipaddr_t ip_src; 15762 cmdline_ipaddr_t ip_dst; 15763 uint16_t tci; 15764 struct rte_ether_addr eth_src; 15765 struct rte_ether_addr eth_dst; 15766 }; 15767 15768 cmdline_parse_token_string_t cmd_set_nvgre_set = 15769 TOKEN_STRING_INITIALIZER(struct cmd_set_nvgre_result, set, "set"); 15770 cmdline_parse_token_string_t cmd_set_nvgre_nvgre = 15771 TOKEN_STRING_INITIALIZER(struct cmd_set_nvgre_result, nvgre, "nvgre"); 15772 cmdline_parse_token_string_t cmd_set_nvgre_nvgre_with_vlan = 15773 TOKEN_STRING_INITIALIZER(struct cmd_set_nvgre_result, nvgre, 15774 "nvgre-with-vlan"); 15775 cmdline_parse_token_string_t cmd_set_nvgre_ip_version = 15776 TOKEN_STRING_INITIALIZER(struct cmd_set_nvgre_result, pos_token, 15777 "ip-version"); 15778 cmdline_parse_token_string_t cmd_set_nvgre_ip_version_value = 15779 TOKEN_STRING_INITIALIZER(struct cmd_set_nvgre_result, ip_version, 15780 "ipv4#ipv6"); 15781 cmdline_parse_token_string_t cmd_set_nvgre_tni = 15782 TOKEN_STRING_INITIALIZER(struct cmd_set_nvgre_result, pos_token, 15783 "tni"); 15784 cmdline_parse_token_num_t cmd_set_nvgre_tni_value = 15785 TOKEN_NUM_INITIALIZER(struct cmd_set_nvgre_result, tni, UINT32); 15786 cmdline_parse_token_string_t cmd_set_nvgre_ip_src = 15787 TOKEN_STRING_INITIALIZER(struct cmd_set_nvgre_result, pos_token, 15788 "ip-src"); 15789 cmdline_parse_token_num_t cmd_set_nvgre_ip_src_value = 15790 TOKEN_IPADDR_INITIALIZER(struct cmd_set_nvgre_result, ip_src); 15791 cmdline_parse_token_string_t cmd_set_nvgre_ip_dst = 15792 TOKEN_STRING_INITIALIZER(struct cmd_set_nvgre_result, pos_token, 15793 "ip-dst"); 15794 cmdline_parse_token_ipaddr_t cmd_set_nvgre_ip_dst_value = 15795 TOKEN_IPADDR_INITIALIZER(struct cmd_set_nvgre_result, ip_dst); 15796 cmdline_parse_token_string_t cmd_set_nvgre_vlan = 15797 TOKEN_STRING_INITIALIZER(struct cmd_set_nvgre_result, pos_token, 15798 "vlan-tci"); 15799 cmdline_parse_token_num_t cmd_set_nvgre_vlan_value = 15800 TOKEN_NUM_INITIALIZER(struct cmd_set_nvgre_result, tci, UINT16); 15801 cmdline_parse_token_string_t cmd_set_nvgre_eth_src = 15802 TOKEN_STRING_INITIALIZER(struct cmd_set_nvgre_result, pos_token, 15803 "eth-src"); 15804 cmdline_parse_token_etheraddr_t cmd_set_nvgre_eth_src_value = 15805 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_nvgre_result, eth_src); 15806 cmdline_parse_token_string_t cmd_set_nvgre_eth_dst = 15807 TOKEN_STRING_INITIALIZER(struct cmd_set_nvgre_result, pos_token, 15808 "eth-dst"); 15809 cmdline_parse_token_etheraddr_t cmd_set_nvgre_eth_dst_value = 15810 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_nvgre_result, eth_dst); 15811 15812 static void cmd_set_nvgre_parsed(void *parsed_result, 15813 __rte_unused struct cmdline *cl, 15814 __rte_unused void *data) 15815 { 15816 struct cmd_set_nvgre_result *res = parsed_result; 15817 union { 15818 uint32_t nvgre_tni; 15819 uint8_t tni[4]; 15820 } id = { 15821 .nvgre_tni = rte_cpu_to_be_32(res->tni) & RTE_BE32(0x00ffffff), 15822 }; 15823 15824 if (strcmp(res->nvgre, "nvgre") == 0) 15825 nvgre_encap_conf.select_vlan = 0; 15826 else if (strcmp(res->nvgre, "nvgre-with-vlan") == 0) 15827 nvgre_encap_conf.select_vlan = 1; 15828 if (strcmp(res->ip_version, "ipv4") == 0) 15829 nvgre_encap_conf.select_ipv4 = 1; 15830 else if (strcmp(res->ip_version, "ipv6") == 0) 15831 nvgre_encap_conf.select_ipv4 = 0; 15832 else 15833 return; 15834 rte_memcpy(nvgre_encap_conf.tni, &id.tni[1], 3); 15835 if (nvgre_encap_conf.select_ipv4) { 15836 IPV4_ADDR_TO_UINT(res->ip_src, nvgre_encap_conf.ipv4_src); 15837 IPV4_ADDR_TO_UINT(res->ip_dst, nvgre_encap_conf.ipv4_dst); 15838 } else { 15839 IPV6_ADDR_TO_ARRAY(res->ip_src, nvgre_encap_conf.ipv6_src); 15840 IPV6_ADDR_TO_ARRAY(res->ip_dst, nvgre_encap_conf.ipv6_dst); 15841 } 15842 if (nvgre_encap_conf.select_vlan) 15843 nvgre_encap_conf.vlan_tci = rte_cpu_to_be_16(res->tci); 15844 rte_memcpy(nvgre_encap_conf.eth_src, res->eth_src.addr_bytes, 15845 RTE_ETHER_ADDR_LEN); 15846 rte_memcpy(nvgre_encap_conf.eth_dst, res->eth_dst.addr_bytes, 15847 RTE_ETHER_ADDR_LEN); 15848 } 15849 15850 cmdline_parse_inst_t cmd_set_nvgre = { 15851 .f = cmd_set_nvgre_parsed, 15852 .data = NULL, 15853 .help_str = "set nvgre ip-version <ipv4|ipv6> tni <tni> ip-src" 15854 " <ip-src> ip-dst <ip-dst> eth-src <eth-src>" 15855 " eth-dst <eth-dst>", 15856 .tokens = { 15857 (void *)&cmd_set_nvgre_set, 15858 (void *)&cmd_set_nvgre_nvgre, 15859 (void *)&cmd_set_nvgre_ip_version, 15860 (void *)&cmd_set_nvgre_ip_version_value, 15861 (void *)&cmd_set_nvgre_tni, 15862 (void *)&cmd_set_nvgre_tni_value, 15863 (void *)&cmd_set_nvgre_ip_src, 15864 (void *)&cmd_set_nvgre_ip_src_value, 15865 (void *)&cmd_set_nvgre_ip_dst, 15866 (void *)&cmd_set_nvgre_ip_dst_value, 15867 (void *)&cmd_set_nvgre_eth_src, 15868 (void *)&cmd_set_nvgre_eth_src_value, 15869 (void *)&cmd_set_nvgre_eth_dst, 15870 (void *)&cmd_set_nvgre_eth_dst_value, 15871 NULL, 15872 }, 15873 }; 15874 15875 cmdline_parse_inst_t cmd_set_nvgre_with_vlan = { 15876 .f = cmd_set_nvgre_parsed, 15877 .data = NULL, 15878 .help_str = "set nvgre-with-vlan ip-version <ipv4|ipv6> tni <tni>" 15879 " ip-src <ip-src> ip-dst <ip-dst> vlan-tci <vlan-tci>" 15880 " eth-src <eth-src> eth-dst <eth-dst>", 15881 .tokens = { 15882 (void *)&cmd_set_nvgre_set, 15883 (void *)&cmd_set_nvgre_nvgre_with_vlan, 15884 (void *)&cmd_set_nvgre_ip_version, 15885 (void *)&cmd_set_nvgre_ip_version_value, 15886 (void *)&cmd_set_nvgre_tni, 15887 (void *)&cmd_set_nvgre_tni_value, 15888 (void *)&cmd_set_nvgre_ip_src, 15889 (void *)&cmd_set_nvgre_ip_src_value, 15890 (void *)&cmd_set_nvgre_ip_dst, 15891 (void *)&cmd_set_nvgre_ip_dst_value, 15892 (void *)&cmd_set_nvgre_vlan, 15893 (void *)&cmd_set_nvgre_vlan_value, 15894 (void *)&cmd_set_nvgre_eth_src, 15895 (void *)&cmd_set_nvgre_eth_src_value, 15896 (void *)&cmd_set_nvgre_eth_dst, 15897 (void *)&cmd_set_nvgre_eth_dst_value, 15898 NULL, 15899 }, 15900 }; 15901 15902 /** Set L2 encapsulation details */ 15903 struct cmd_set_l2_encap_result { 15904 cmdline_fixed_string_t set; 15905 cmdline_fixed_string_t l2_encap; 15906 cmdline_fixed_string_t pos_token; 15907 cmdline_fixed_string_t ip_version; 15908 uint32_t vlan_present:1; 15909 uint16_t tci; 15910 struct rte_ether_addr eth_src; 15911 struct rte_ether_addr eth_dst; 15912 }; 15913 15914 cmdline_parse_token_string_t cmd_set_l2_encap_set = 15915 TOKEN_STRING_INITIALIZER(struct cmd_set_l2_encap_result, set, "set"); 15916 cmdline_parse_token_string_t cmd_set_l2_encap_l2_encap = 15917 TOKEN_STRING_INITIALIZER(struct cmd_set_l2_encap_result, l2_encap, "l2_encap"); 15918 cmdline_parse_token_string_t cmd_set_l2_encap_l2_encap_with_vlan = 15919 TOKEN_STRING_INITIALIZER(struct cmd_set_l2_encap_result, l2_encap, 15920 "l2_encap-with-vlan"); 15921 cmdline_parse_token_string_t cmd_set_l2_encap_ip_version = 15922 TOKEN_STRING_INITIALIZER(struct cmd_set_l2_encap_result, pos_token, 15923 "ip-version"); 15924 cmdline_parse_token_string_t cmd_set_l2_encap_ip_version_value = 15925 TOKEN_STRING_INITIALIZER(struct cmd_set_l2_encap_result, ip_version, 15926 "ipv4#ipv6"); 15927 cmdline_parse_token_string_t cmd_set_l2_encap_vlan = 15928 TOKEN_STRING_INITIALIZER(struct cmd_set_l2_encap_result, pos_token, 15929 "vlan-tci"); 15930 cmdline_parse_token_num_t cmd_set_l2_encap_vlan_value = 15931 TOKEN_NUM_INITIALIZER(struct cmd_set_l2_encap_result, tci, UINT16); 15932 cmdline_parse_token_string_t cmd_set_l2_encap_eth_src = 15933 TOKEN_STRING_INITIALIZER(struct cmd_set_l2_encap_result, pos_token, 15934 "eth-src"); 15935 cmdline_parse_token_etheraddr_t cmd_set_l2_encap_eth_src_value = 15936 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_l2_encap_result, eth_src); 15937 cmdline_parse_token_string_t cmd_set_l2_encap_eth_dst = 15938 TOKEN_STRING_INITIALIZER(struct cmd_set_l2_encap_result, pos_token, 15939 "eth-dst"); 15940 cmdline_parse_token_etheraddr_t cmd_set_l2_encap_eth_dst_value = 15941 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_l2_encap_result, eth_dst); 15942 15943 static void cmd_set_l2_encap_parsed(void *parsed_result, 15944 __rte_unused struct cmdline *cl, 15945 __rte_unused void *data) 15946 { 15947 struct cmd_set_l2_encap_result *res = parsed_result; 15948 15949 if (strcmp(res->l2_encap, "l2_encap") == 0) 15950 l2_encap_conf.select_vlan = 0; 15951 else if (strcmp(res->l2_encap, "l2_encap-with-vlan") == 0) 15952 l2_encap_conf.select_vlan = 1; 15953 if (strcmp(res->ip_version, "ipv4") == 0) 15954 l2_encap_conf.select_ipv4 = 1; 15955 else if (strcmp(res->ip_version, "ipv6") == 0) 15956 l2_encap_conf.select_ipv4 = 0; 15957 else 15958 return; 15959 if (l2_encap_conf.select_vlan) 15960 l2_encap_conf.vlan_tci = rte_cpu_to_be_16(res->tci); 15961 rte_memcpy(l2_encap_conf.eth_src, res->eth_src.addr_bytes, 15962 RTE_ETHER_ADDR_LEN); 15963 rte_memcpy(l2_encap_conf.eth_dst, res->eth_dst.addr_bytes, 15964 RTE_ETHER_ADDR_LEN); 15965 } 15966 15967 cmdline_parse_inst_t cmd_set_l2_encap = { 15968 .f = cmd_set_l2_encap_parsed, 15969 .data = NULL, 15970 .help_str = "set l2_encap ip-version ipv4|ipv6" 15971 " eth-src <eth-src> eth-dst <eth-dst>", 15972 .tokens = { 15973 (void *)&cmd_set_l2_encap_set, 15974 (void *)&cmd_set_l2_encap_l2_encap, 15975 (void *)&cmd_set_l2_encap_ip_version, 15976 (void *)&cmd_set_l2_encap_ip_version_value, 15977 (void *)&cmd_set_l2_encap_eth_src, 15978 (void *)&cmd_set_l2_encap_eth_src_value, 15979 (void *)&cmd_set_l2_encap_eth_dst, 15980 (void *)&cmd_set_l2_encap_eth_dst_value, 15981 NULL, 15982 }, 15983 }; 15984 15985 cmdline_parse_inst_t cmd_set_l2_encap_with_vlan = { 15986 .f = cmd_set_l2_encap_parsed, 15987 .data = NULL, 15988 .help_str = "set l2_encap-with-vlan ip-version ipv4|ipv6" 15989 " vlan-tci <vlan-tci> eth-src <eth-src> eth-dst <eth-dst>", 15990 .tokens = { 15991 (void *)&cmd_set_l2_encap_set, 15992 (void *)&cmd_set_l2_encap_l2_encap_with_vlan, 15993 (void *)&cmd_set_l2_encap_ip_version, 15994 (void *)&cmd_set_l2_encap_ip_version_value, 15995 (void *)&cmd_set_l2_encap_vlan, 15996 (void *)&cmd_set_l2_encap_vlan_value, 15997 (void *)&cmd_set_l2_encap_eth_src, 15998 (void *)&cmd_set_l2_encap_eth_src_value, 15999 (void *)&cmd_set_l2_encap_eth_dst, 16000 (void *)&cmd_set_l2_encap_eth_dst_value, 16001 NULL, 16002 }, 16003 }; 16004 16005 /** Set L2 decapsulation details */ 16006 struct cmd_set_l2_decap_result { 16007 cmdline_fixed_string_t set; 16008 cmdline_fixed_string_t l2_decap; 16009 cmdline_fixed_string_t pos_token; 16010 uint32_t vlan_present:1; 16011 }; 16012 16013 cmdline_parse_token_string_t cmd_set_l2_decap_set = 16014 TOKEN_STRING_INITIALIZER(struct cmd_set_l2_decap_result, set, "set"); 16015 cmdline_parse_token_string_t cmd_set_l2_decap_l2_decap = 16016 TOKEN_STRING_INITIALIZER(struct cmd_set_l2_decap_result, l2_decap, 16017 "l2_decap"); 16018 cmdline_parse_token_string_t cmd_set_l2_decap_l2_decap_with_vlan = 16019 TOKEN_STRING_INITIALIZER(struct cmd_set_l2_decap_result, l2_decap, 16020 "l2_decap-with-vlan"); 16021 16022 static void cmd_set_l2_decap_parsed(void *parsed_result, 16023 __rte_unused struct cmdline *cl, 16024 __rte_unused void *data) 16025 { 16026 struct cmd_set_l2_decap_result *res = parsed_result; 16027 16028 if (strcmp(res->l2_decap, "l2_decap") == 0) 16029 l2_decap_conf.select_vlan = 0; 16030 else if (strcmp(res->l2_decap, "l2_decap-with-vlan") == 0) 16031 l2_decap_conf.select_vlan = 1; 16032 } 16033 16034 cmdline_parse_inst_t cmd_set_l2_decap = { 16035 .f = cmd_set_l2_decap_parsed, 16036 .data = NULL, 16037 .help_str = "set l2_decap", 16038 .tokens = { 16039 (void *)&cmd_set_l2_decap_set, 16040 (void *)&cmd_set_l2_decap_l2_decap, 16041 NULL, 16042 }, 16043 }; 16044 16045 cmdline_parse_inst_t cmd_set_l2_decap_with_vlan = { 16046 .f = cmd_set_l2_decap_parsed, 16047 .data = NULL, 16048 .help_str = "set l2_decap-with-vlan", 16049 .tokens = { 16050 (void *)&cmd_set_l2_decap_set, 16051 (void *)&cmd_set_l2_decap_l2_decap_with_vlan, 16052 NULL, 16053 }, 16054 }; 16055 16056 /** Set MPLSoGRE encapsulation details */ 16057 struct cmd_set_mplsogre_encap_result { 16058 cmdline_fixed_string_t set; 16059 cmdline_fixed_string_t mplsogre; 16060 cmdline_fixed_string_t pos_token; 16061 cmdline_fixed_string_t ip_version; 16062 uint32_t vlan_present:1; 16063 uint32_t label; 16064 cmdline_ipaddr_t ip_src; 16065 cmdline_ipaddr_t ip_dst; 16066 uint16_t tci; 16067 struct rte_ether_addr eth_src; 16068 struct rte_ether_addr eth_dst; 16069 }; 16070 16071 cmdline_parse_token_string_t cmd_set_mplsogre_encap_set = 16072 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_encap_result, set, 16073 "set"); 16074 cmdline_parse_token_string_t cmd_set_mplsogre_encap_mplsogre_encap = 16075 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_encap_result, mplsogre, 16076 "mplsogre_encap"); 16077 cmdline_parse_token_string_t cmd_set_mplsogre_encap_mplsogre_encap_with_vlan = 16078 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_encap_result, 16079 mplsogre, "mplsogre_encap-with-vlan"); 16080 cmdline_parse_token_string_t cmd_set_mplsogre_encap_ip_version = 16081 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_encap_result, 16082 pos_token, "ip-version"); 16083 cmdline_parse_token_string_t cmd_set_mplsogre_encap_ip_version_value = 16084 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_encap_result, 16085 ip_version, "ipv4#ipv6"); 16086 cmdline_parse_token_string_t cmd_set_mplsogre_encap_label = 16087 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_encap_result, 16088 pos_token, "label"); 16089 cmdline_parse_token_num_t cmd_set_mplsogre_encap_label_value = 16090 TOKEN_NUM_INITIALIZER(struct cmd_set_mplsogre_encap_result, label, 16091 UINT32); 16092 cmdline_parse_token_string_t cmd_set_mplsogre_encap_ip_src = 16093 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_encap_result, 16094 pos_token, "ip-src"); 16095 cmdline_parse_token_ipaddr_t cmd_set_mplsogre_encap_ip_src_value = 16096 TOKEN_IPADDR_INITIALIZER(struct cmd_set_mplsogre_encap_result, ip_src); 16097 cmdline_parse_token_string_t cmd_set_mplsogre_encap_ip_dst = 16098 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_encap_result, 16099 pos_token, "ip-dst"); 16100 cmdline_parse_token_ipaddr_t cmd_set_mplsogre_encap_ip_dst_value = 16101 TOKEN_IPADDR_INITIALIZER(struct cmd_set_mplsogre_encap_result, ip_dst); 16102 cmdline_parse_token_string_t cmd_set_mplsogre_encap_vlan = 16103 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_encap_result, 16104 pos_token, "vlan-tci"); 16105 cmdline_parse_token_num_t cmd_set_mplsogre_encap_vlan_value = 16106 TOKEN_NUM_INITIALIZER(struct cmd_set_mplsogre_encap_result, tci, 16107 UINT16); 16108 cmdline_parse_token_string_t cmd_set_mplsogre_encap_eth_src = 16109 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_encap_result, 16110 pos_token, "eth-src"); 16111 cmdline_parse_token_etheraddr_t cmd_set_mplsogre_encap_eth_src_value = 16112 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_mplsogre_encap_result, 16113 eth_src); 16114 cmdline_parse_token_string_t cmd_set_mplsogre_encap_eth_dst = 16115 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_encap_result, 16116 pos_token, "eth-dst"); 16117 cmdline_parse_token_etheraddr_t cmd_set_mplsogre_encap_eth_dst_value = 16118 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_mplsogre_encap_result, 16119 eth_dst); 16120 16121 static void cmd_set_mplsogre_encap_parsed(void *parsed_result, 16122 __rte_unused struct cmdline *cl, 16123 __rte_unused void *data) 16124 { 16125 struct cmd_set_mplsogre_encap_result *res = parsed_result; 16126 union { 16127 uint32_t mplsogre_label; 16128 uint8_t label[4]; 16129 } id = { 16130 .mplsogre_label = rte_cpu_to_be_32(res->label<<12), 16131 }; 16132 16133 if (strcmp(res->mplsogre, "mplsogre_encap") == 0) 16134 mplsogre_encap_conf.select_vlan = 0; 16135 else if (strcmp(res->mplsogre, "mplsogre_encap-with-vlan") == 0) 16136 mplsogre_encap_conf.select_vlan = 1; 16137 if (strcmp(res->ip_version, "ipv4") == 0) 16138 mplsogre_encap_conf.select_ipv4 = 1; 16139 else if (strcmp(res->ip_version, "ipv6") == 0) 16140 mplsogre_encap_conf.select_ipv4 = 0; 16141 else 16142 return; 16143 rte_memcpy(mplsogre_encap_conf.label, &id.label, 3); 16144 if (mplsogre_encap_conf.select_ipv4) { 16145 IPV4_ADDR_TO_UINT(res->ip_src, mplsogre_encap_conf.ipv4_src); 16146 IPV4_ADDR_TO_UINT(res->ip_dst, mplsogre_encap_conf.ipv4_dst); 16147 } else { 16148 IPV6_ADDR_TO_ARRAY(res->ip_src, mplsogre_encap_conf.ipv6_src); 16149 IPV6_ADDR_TO_ARRAY(res->ip_dst, mplsogre_encap_conf.ipv6_dst); 16150 } 16151 if (mplsogre_encap_conf.select_vlan) 16152 mplsogre_encap_conf.vlan_tci = rte_cpu_to_be_16(res->tci); 16153 rte_memcpy(mplsogre_encap_conf.eth_src, res->eth_src.addr_bytes, 16154 RTE_ETHER_ADDR_LEN); 16155 rte_memcpy(mplsogre_encap_conf.eth_dst, res->eth_dst.addr_bytes, 16156 RTE_ETHER_ADDR_LEN); 16157 } 16158 16159 cmdline_parse_inst_t cmd_set_mplsogre_encap = { 16160 .f = cmd_set_mplsogre_encap_parsed, 16161 .data = NULL, 16162 .help_str = "set mplsogre_encap ip-version ipv4|ipv6 label <label>" 16163 " ip-src <ip-src> ip-dst <ip-dst> eth-src <eth-src>" 16164 " eth-dst <eth-dst>", 16165 .tokens = { 16166 (void *)&cmd_set_mplsogre_encap_set, 16167 (void *)&cmd_set_mplsogre_encap_mplsogre_encap, 16168 (void *)&cmd_set_mplsogre_encap_ip_version, 16169 (void *)&cmd_set_mplsogre_encap_ip_version_value, 16170 (void *)&cmd_set_mplsogre_encap_label, 16171 (void *)&cmd_set_mplsogre_encap_label_value, 16172 (void *)&cmd_set_mplsogre_encap_ip_src, 16173 (void *)&cmd_set_mplsogre_encap_ip_src_value, 16174 (void *)&cmd_set_mplsogre_encap_ip_dst, 16175 (void *)&cmd_set_mplsogre_encap_ip_dst_value, 16176 (void *)&cmd_set_mplsogre_encap_eth_src, 16177 (void *)&cmd_set_mplsogre_encap_eth_src_value, 16178 (void *)&cmd_set_mplsogre_encap_eth_dst, 16179 (void *)&cmd_set_mplsogre_encap_eth_dst_value, 16180 NULL, 16181 }, 16182 }; 16183 16184 cmdline_parse_inst_t cmd_set_mplsogre_encap_with_vlan = { 16185 .f = cmd_set_mplsogre_encap_parsed, 16186 .data = NULL, 16187 .help_str = "set mplsogre_encap-with-vlan ip-version ipv4|ipv6" 16188 " label <label> ip-src <ip-src> ip-dst <ip-dst>" 16189 " vlan-tci <vlan-tci> eth-src <eth-src> eth-dst <eth-dst>", 16190 .tokens = { 16191 (void *)&cmd_set_mplsogre_encap_set, 16192 (void *)&cmd_set_mplsogre_encap_mplsogre_encap_with_vlan, 16193 (void *)&cmd_set_mplsogre_encap_ip_version, 16194 (void *)&cmd_set_mplsogre_encap_ip_version_value, 16195 (void *)&cmd_set_mplsogre_encap_label, 16196 (void *)&cmd_set_mplsogre_encap_label_value, 16197 (void *)&cmd_set_mplsogre_encap_ip_src, 16198 (void *)&cmd_set_mplsogre_encap_ip_src_value, 16199 (void *)&cmd_set_mplsogre_encap_ip_dst, 16200 (void *)&cmd_set_mplsogre_encap_ip_dst_value, 16201 (void *)&cmd_set_mplsogre_encap_vlan, 16202 (void *)&cmd_set_mplsogre_encap_vlan_value, 16203 (void *)&cmd_set_mplsogre_encap_eth_src, 16204 (void *)&cmd_set_mplsogre_encap_eth_src_value, 16205 (void *)&cmd_set_mplsogre_encap_eth_dst, 16206 (void *)&cmd_set_mplsogre_encap_eth_dst_value, 16207 NULL, 16208 }, 16209 }; 16210 16211 /** Set MPLSoGRE decapsulation details */ 16212 struct cmd_set_mplsogre_decap_result { 16213 cmdline_fixed_string_t set; 16214 cmdline_fixed_string_t mplsogre; 16215 cmdline_fixed_string_t pos_token; 16216 cmdline_fixed_string_t ip_version; 16217 uint32_t vlan_present:1; 16218 }; 16219 16220 cmdline_parse_token_string_t cmd_set_mplsogre_decap_set = 16221 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_decap_result, set, 16222 "set"); 16223 cmdline_parse_token_string_t cmd_set_mplsogre_decap_mplsogre_decap = 16224 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_decap_result, mplsogre, 16225 "mplsogre_decap"); 16226 cmdline_parse_token_string_t cmd_set_mplsogre_decap_mplsogre_decap_with_vlan = 16227 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_decap_result, 16228 mplsogre, "mplsogre_decap-with-vlan"); 16229 cmdline_parse_token_string_t cmd_set_mplsogre_decap_ip_version = 16230 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_decap_result, 16231 pos_token, "ip-version"); 16232 cmdline_parse_token_string_t cmd_set_mplsogre_decap_ip_version_value = 16233 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_decap_result, 16234 ip_version, "ipv4#ipv6"); 16235 16236 static void cmd_set_mplsogre_decap_parsed(void *parsed_result, 16237 __rte_unused struct cmdline *cl, 16238 __rte_unused void *data) 16239 { 16240 struct cmd_set_mplsogre_decap_result *res = parsed_result; 16241 16242 if (strcmp(res->mplsogre, "mplsogre_decap") == 0) 16243 mplsogre_decap_conf.select_vlan = 0; 16244 else if (strcmp(res->mplsogre, "mplsogre_decap-with-vlan") == 0) 16245 mplsogre_decap_conf.select_vlan = 1; 16246 if (strcmp(res->ip_version, "ipv4") == 0) 16247 mplsogre_decap_conf.select_ipv4 = 1; 16248 else if (strcmp(res->ip_version, "ipv6") == 0) 16249 mplsogre_decap_conf.select_ipv4 = 0; 16250 } 16251 16252 cmdline_parse_inst_t cmd_set_mplsogre_decap = { 16253 .f = cmd_set_mplsogre_decap_parsed, 16254 .data = NULL, 16255 .help_str = "set mplsogre_decap ip-version ipv4|ipv6", 16256 .tokens = { 16257 (void *)&cmd_set_mplsogre_decap_set, 16258 (void *)&cmd_set_mplsogre_decap_mplsogre_decap, 16259 (void *)&cmd_set_mplsogre_decap_ip_version, 16260 (void *)&cmd_set_mplsogre_decap_ip_version_value, 16261 NULL, 16262 }, 16263 }; 16264 16265 cmdline_parse_inst_t cmd_set_mplsogre_decap_with_vlan = { 16266 .f = cmd_set_mplsogre_decap_parsed, 16267 .data = NULL, 16268 .help_str = "set mplsogre_decap-with-vlan ip-version ipv4|ipv6", 16269 .tokens = { 16270 (void *)&cmd_set_mplsogre_decap_set, 16271 (void *)&cmd_set_mplsogre_decap_mplsogre_decap_with_vlan, 16272 (void *)&cmd_set_mplsogre_decap_ip_version, 16273 (void *)&cmd_set_mplsogre_decap_ip_version_value, 16274 NULL, 16275 }, 16276 }; 16277 16278 /** Set MPLSoUDP encapsulation details */ 16279 struct cmd_set_mplsoudp_encap_result { 16280 cmdline_fixed_string_t set; 16281 cmdline_fixed_string_t mplsoudp; 16282 cmdline_fixed_string_t pos_token; 16283 cmdline_fixed_string_t ip_version; 16284 uint32_t vlan_present:1; 16285 uint32_t label; 16286 uint16_t udp_src; 16287 uint16_t udp_dst; 16288 cmdline_ipaddr_t ip_src; 16289 cmdline_ipaddr_t ip_dst; 16290 uint16_t tci; 16291 struct rte_ether_addr eth_src; 16292 struct rte_ether_addr eth_dst; 16293 }; 16294 16295 cmdline_parse_token_string_t cmd_set_mplsoudp_encap_set = 16296 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_encap_result, set, 16297 "set"); 16298 cmdline_parse_token_string_t cmd_set_mplsoudp_encap_mplsoudp_encap = 16299 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_encap_result, mplsoudp, 16300 "mplsoudp_encap"); 16301 cmdline_parse_token_string_t cmd_set_mplsoudp_encap_mplsoudp_encap_with_vlan = 16302 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_encap_result, 16303 mplsoudp, "mplsoudp_encap-with-vlan"); 16304 cmdline_parse_token_string_t cmd_set_mplsoudp_encap_ip_version = 16305 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_encap_result, 16306 pos_token, "ip-version"); 16307 cmdline_parse_token_string_t cmd_set_mplsoudp_encap_ip_version_value = 16308 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_encap_result, 16309 ip_version, "ipv4#ipv6"); 16310 cmdline_parse_token_string_t cmd_set_mplsoudp_encap_label = 16311 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_encap_result, 16312 pos_token, "label"); 16313 cmdline_parse_token_num_t cmd_set_mplsoudp_encap_label_value = 16314 TOKEN_NUM_INITIALIZER(struct cmd_set_mplsoudp_encap_result, label, 16315 UINT32); 16316 cmdline_parse_token_string_t cmd_set_mplsoudp_encap_udp_src = 16317 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_encap_result, 16318 pos_token, "udp-src"); 16319 cmdline_parse_token_num_t cmd_set_mplsoudp_encap_udp_src_value = 16320 TOKEN_NUM_INITIALIZER(struct cmd_set_mplsoudp_encap_result, udp_src, 16321 UINT16); 16322 cmdline_parse_token_string_t cmd_set_mplsoudp_encap_udp_dst = 16323 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_encap_result, 16324 pos_token, "udp-dst"); 16325 cmdline_parse_token_num_t cmd_set_mplsoudp_encap_udp_dst_value = 16326 TOKEN_NUM_INITIALIZER(struct cmd_set_mplsoudp_encap_result, udp_dst, 16327 UINT16); 16328 cmdline_parse_token_string_t cmd_set_mplsoudp_encap_ip_src = 16329 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_encap_result, 16330 pos_token, "ip-src"); 16331 cmdline_parse_token_ipaddr_t cmd_set_mplsoudp_encap_ip_src_value = 16332 TOKEN_IPADDR_INITIALIZER(struct cmd_set_mplsoudp_encap_result, ip_src); 16333 cmdline_parse_token_string_t cmd_set_mplsoudp_encap_ip_dst = 16334 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_encap_result, 16335 pos_token, "ip-dst"); 16336 cmdline_parse_token_ipaddr_t cmd_set_mplsoudp_encap_ip_dst_value = 16337 TOKEN_IPADDR_INITIALIZER(struct cmd_set_mplsoudp_encap_result, ip_dst); 16338 cmdline_parse_token_string_t cmd_set_mplsoudp_encap_vlan = 16339 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_encap_result, 16340 pos_token, "vlan-tci"); 16341 cmdline_parse_token_num_t cmd_set_mplsoudp_encap_vlan_value = 16342 TOKEN_NUM_INITIALIZER(struct cmd_set_mplsoudp_encap_result, tci, 16343 UINT16); 16344 cmdline_parse_token_string_t cmd_set_mplsoudp_encap_eth_src = 16345 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_encap_result, 16346 pos_token, "eth-src"); 16347 cmdline_parse_token_etheraddr_t cmd_set_mplsoudp_encap_eth_src_value = 16348 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_mplsoudp_encap_result, 16349 eth_src); 16350 cmdline_parse_token_string_t cmd_set_mplsoudp_encap_eth_dst = 16351 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_encap_result, 16352 pos_token, "eth-dst"); 16353 cmdline_parse_token_etheraddr_t cmd_set_mplsoudp_encap_eth_dst_value = 16354 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_mplsoudp_encap_result, 16355 eth_dst); 16356 16357 static void cmd_set_mplsoudp_encap_parsed(void *parsed_result, 16358 __rte_unused struct cmdline *cl, 16359 __rte_unused void *data) 16360 { 16361 struct cmd_set_mplsoudp_encap_result *res = parsed_result; 16362 union { 16363 uint32_t mplsoudp_label; 16364 uint8_t label[4]; 16365 } id = { 16366 .mplsoudp_label = rte_cpu_to_be_32(res->label<<12), 16367 }; 16368 16369 if (strcmp(res->mplsoudp, "mplsoudp_encap") == 0) 16370 mplsoudp_encap_conf.select_vlan = 0; 16371 else if (strcmp(res->mplsoudp, "mplsoudp_encap-with-vlan") == 0) 16372 mplsoudp_encap_conf.select_vlan = 1; 16373 if (strcmp(res->ip_version, "ipv4") == 0) 16374 mplsoudp_encap_conf.select_ipv4 = 1; 16375 else if (strcmp(res->ip_version, "ipv6") == 0) 16376 mplsoudp_encap_conf.select_ipv4 = 0; 16377 else 16378 return; 16379 rte_memcpy(mplsoudp_encap_conf.label, &id.label, 3); 16380 mplsoudp_encap_conf.udp_src = rte_cpu_to_be_16(res->udp_src); 16381 mplsoudp_encap_conf.udp_dst = rte_cpu_to_be_16(res->udp_dst); 16382 if (mplsoudp_encap_conf.select_ipv4) { 16383 IPV4_ADDR_TO_UINT(res->ip_src, mplsoudp_encap_conf.ipv4_src); 16384 IPV4_ADDR_TO_UINT(res->ip_dst, mplsoudp_encap_conf.ipv4_dst); 16385 } else { 16386 IPV6_ADDR_TO_ARRAY(res->ip_src, mplsoudp_encap_conf.ipv6_src); 16387 IPV6_ADDR_TO_ARRAY(res->ip_dst, mplsoudp_encap_conf.ipv6_dst); 16388 } 16389 if (mplsoudp_encap_conf.select_vlan) 16390 mplsoudp_encap_conf.vlan_tci = rte_cpu_to_be_16(res->tci); 16391 rte_memcpy(mplsoudp_encap_conf.eth_src, res->eth_src.addr_bytes, 16392 RTE_ETHER_ADDR_LEN); 16393 rte_memcpy(mplsoudp_encap_conf.eth_dst, res->eth_dst.addr_bytes, 16394 RTE_ETHER_ADDR_LEN); 16395 } 16396 16397 cmdline_parse_inst_t cmd_set_mplsoudp_encap = { 16398 .f = cmd_set_mplsoudp_encap_parsed, 16399 .data = NULL, 16400 .help_str = "set mplsoudp_encap ip-version ipv4|ipv6 label <label>" 16401 " udp-src <udp-src> udp-dst <udp-dst> ip-src <ip-src>" 16402 " ip-dst <ip-dst> eth-src <eth-src> eth-dst <eth-dst>", 16403 .tokens = { 16404 (void *)&cmd_set_mplsoudp_encap_set, 16405 (void *)&cmd_set_mplsoudp_encap_mplsoudp_encap, 16406 (void *)&cmd_set_mplsoudp_encap_ip_version, 16407 (void *)&cmd_set_mplsoudp_encap_ip_version_value, 16408 (void *)&cmd_set_mplsoudp_encap_label, 16409 (void *)&cmd_set_mplsoudp_encap_label_value, 16410 (void *)&cmd_set_mplsoudp_encap_udp_src, 16411 (void *)&cmd_set_mplsoudp_encap_udp_src_value, 16412 (void *)&cmd_set_mplsoudp_encap_udp_dst, 16413 (void *)&cmd_set_mplsoudp_encap_udp_dst_value, 16414 (void *)&cmd_set_mplsoudp_encap_ip_src, 16415 (void *)&cmd_set_mplsoudp_encap_ip_src_value, 16416 (void *)&cmd_set_mplsoudp_encap_ip_dst, 16417 (void *)&cmd_set_mplsoudp_encap_ip_dst_value, 16418 (void *)&cmd_set_mplsoudp_encap_eth_src, 16419 (void *)&cmd_set_mplsoudp_encap_eth_src_value, 16420 (void *)&cmd_set_mplsoudp_encap_eth_dst, 16421 (void *)&cmd_set_mplsoudp_encap_eth_dst_value, 16422 NULL, 16423 }, 16424 }; 16425 16426 cmdline_parse_inst_t cmd_set_mplsoudp_encap_with_vlan = { 16427 .f = cmd_set_mplsoudp_encap_parsed, 16428 .data = NULL, 16429 .help_str = "set mplsoudp_encap-with-vlan ip-version ipv4|ipv6" 16430 " label <label> udp-src <udp-src> udp-dst <udp-dst>" 16431 " ip-src <ip-src> ip-dst <ip-dst> vlan-tci <vlan-tci>" 16432 " eth-src <eth-src> eth-dst <eth-dst>", 16433 .tokens = { 16434 (void *)&cmd_set_mplsoudp_encap_set, 16435 (void *)&cmd_set_mplsoudp_encap_mplsoudp_encap_with_vlan, 16436 (void *)&cmd_set_mplsoudp_encap_ip_version, 16437 (void *)&cmd_set_mplsoudp_encap_ip_version_value, 16438 (void *)&cmd_set_mplsoudp_encap_label, 16439 (void *)&cmd_set_mplsoudp_encap_label_value, 16440 (void *)&cmd_set_mplsoudp_encap_udp_src, 16441 (void *)&cmd_set_mplsoudp_encap_udp_src_value, 16442 (void *)&cmd_set_mplsoudp_encap_udp_dst, 16443 (void *)&cmd_set_mplsoudp_encap_udp_dst_value, 16444 (void *)&cmd_set_mplsoudp_encap_ip_src, 16445 (void *)&cmd_set_mplsoudp_encap_ip_src_value, 16446 (void *)&cmd_set_mplsoudp_encap_ip_dst, 16447 (void *)&cmd_set_mplsoudp_encap_ip_dst_value, 16448 (void *)&cmd_set_mplsoudp_encap_vlan, 16449 (void *)&cmd_set_mplsoudp_encap_vlan_value, 16450 (void *)&cmd_set_mplsoudp_encap_eth_src, 16451 (void *)&cmd_set_mplsoudp_encap_eth_src_value, 16452 (void *)&cmd_set_mplsoudp_encap_eth_dst, 16453 (void *)&cmd_set_mplsoudp_encap_eth_dst_value, 16454 NULL, 16455 }, 16456 }; 16457 16458 /** Set MPLSoUDP decapsulation details */ 16459 struct cmd_set_mplsoudp_decap_result { 16460 cmdline_fixed_string_t set; 16461 cmdline_fixed_string_t mplsoudp; 16462 cmdline_fixed_string_t pos_token; 16463 cmdline_fixed_string_t ip_version; 16464 uint32_t vlan_present:1; 16465 }; 16466 16467 cmdline_parse_token_string_t cmd_set_mplsoudp_decap_set = 16468 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_decap_result, set, 16469 "set"); 16470 cmdline_parse_token_string_t cmd_set_mplsoudp_decap_mplsoudp_decap = 16471 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_decap_result, mplsoudp, 16472 "mplsoudp_decap"); 16473 cmdline_parse_token_string_t cmd_set_mplsoudp_decap_mplsoudp_decap_with_vlan = 16474 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_decap_result, 16475 mplsoudp, "mplsoudp_decap-with-vlan"); 16476 cmdline_parse_token_string_t cmd_set_mplsoudp_decap_ip_version = 16477 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_decap_result, 16478 pos_token, "ip-version"); 16479 cmdline_parse_token_string_t cmd_set_mplsoudp_decap_ip_version_value = 16480 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_decap_result, 16481 ip_version, "ipv4#ipv6"); 16482 16483 static void cmd_set_mplsoudp_decap_parsed(void *parsed_result, 16484 __rte_unused struct cmdline *cl, 16485 __rte_unused void *data) 16486 { 16487 struct cmd_set_mplsoudp_decap_result *res = parsed_result; 16488 16489 if (strcmp(res->mplsoudp, "mplsoudp_decap") == 0) 16490 mplsoudp_decap_conf.select_vlan = 0; 16491 else if (strcmp(res->mplsoudp, "mplsoudp_decap-with-vlan") == 0) 16492 mplsoudp_decap_conf.select_vlan = 1; 16493 if (strcmp(res->ip_version, "ipv4") == 0) 16494 mplsoudp_decap_conf.select_ipv4 = 1; 16495 else if (strcmp(res->ip_version, "ipv6") == 0) 16496 mplsoudp_decap_conf.select_ipv4 = 0; 16497 } 16498 16499 cmdline_parse_inst_t cmd_set_mplsoudp_decap = { 16500 .f = cmd_set_mplsoudp_decap_parsed, 16501 .data = NULL, 16502 .help_str = "set mplsoudp_decap ip-version ipv4|ipv6", 16503 .tokens = { 16504 (void *)&cmd_set_mplsoudp_decap_set, 16505 (void *)&cmd_set_mplsoudp_decap_mplsoudp_decap, 16506 (void *)&cmd_set_mplsoudp_decap_ip_version, 16507 (void *)&cmd_set_mplsoudp_decap_ip_version_value, 16508 NULL, 16509 }, 16510 }; 16511 16512 cmdline_parse_inst_t cmd_set_mplsoudp_decap_with_vlan = { 16513 .f = cmd_set_mplsoudp_decap_parsed, 16514 .data = NULL, 16515 .help_str = "set mplsoudp_decap-with-vlan ip-version ipv4|ipv6", 16516 .tokens = { 16517 (void *)&cmd_set_mplsoudp_decap_set, 16518 (void *)&cmd_set_mplsoudp_decap_mplsoudp_decap_with_vlan, 16519 (void *)&cmd_set_mplsoudp_decap_ip_version, 16520 (void *)&cmd_set_mplsoudp_decap_ip_version_value, 16521 NULL, 16522 }, 16523 }; 16524 16525 /* Strict link priority scheduling mode setting */ 16526 static void 16527 cmd_strict_link_prio_parsed( 16528 void *parsed_result, 16529 __rte_unused struct cmdline *cl, 16530 __rte_unused void *data) 16531 { 16532 struct cmd_vf_tc_bw_result *res = parsed_result; 16533 int ret = -ENOTSUP; 16534 16535 if (port_id_is_invalid(res->port_id, ENABLED_WARN)) 16536 return; 16537 16538 #ifdef RTE_LIBRTE_I40E_PMD 16539 ret = rte_pmd_i40e_set_tc_strict_prio(res->port_id, res->tc_map); 16540 #endif 16541 16542 switch (ret) { 16543 case 0: 16544 break; 16545 case -EINVAL: 16546 printf("invalid tc_bitmap 0x%x\n", res->tc_map); 16547 break; 16548 case -ENODEV: 16549 printf("invalid port_id %d\n", res->port_id); 16550 break; 16551 case -ENOTSUP: 16552 printf("function not implemented\n"); 16553 break; 16554 default: 16555 printf("programming error: (%s)\n", strerror(-ret)); 16556 } 16557 } 16558 16559 cmdline_parse_inst_t cmd_strict_link_prio = { 16560 .f = cmd_strict_link_prio_parsed, 16561 .data = NULL, 16562 .help_str = "set tx strict-link-priority <port_id> <tc_bitmap>", 16563 .tokens = { 16564 (void *)&cmd_vf_tc_bw_set, 16565 (void *)&cmd_vf_tc_bw_tx, 16566 (void *)&cmd_vf_tc_bw_strict_link_prio, 16567 (void *)&cmd_vf_tc_bw_port_id, 16568 (void *)&cmd_vf_tc_bw_tc_map, 16569 NULL, 16570 }, 16571 }; 16572 16573 /* Load dynamic device personalization*/ 16574 struct cmd_ddp_add_result { 16575 cmdline_fixed_string_t ddp; 16576 cmdline_fixed_string_t add; 16577 portid_t port_id; 16578 char filepath[]; 16579 }; 16580 16581 cmdline_parse_token_string_t cmd_ddp_add_ddp = 16582 TOKEN_STRING_INITIALIZER(struct cmd_ddp_add_result, ddp, "ddp"); 16583 cmdline_parse_token_string_t cmd_ddp_add_add = 16584 TOKEN_STRING_INITIALIZER(struct cmd_ddp_add_result, add, "add"); 16585 cmdline_parse_token_num_t cmd_ddp_add_port_id = 16586 TOKEN_NUM_INITIALIZER(struct cmd_ddp_add_result, port_id, UINT16); 16587 cmdline_parse_token_string_t cmd_ddp_add_filepath = 16588 TOKEN_STRING_INITIALIZER(struct cmd_ddp_add_result, filepath, NULL); 16589 16590 static void 16591 cmd_ddp_add_parsed( 16592 void *parsed_result, 16593 __rte_unused struct cmdline *cl, 16594 __rte_unused void *data) 16595 { 16596 struct cmd_ddp_add_result *res = parsed_result; 16597 uint8_t *buff; 16598 uint32_t size; 16599 char *filepath; 16600 char *file_fld[2]; 16601 int file_num; 16602 int ret = -ENOTSUP; 16603 16604 if (!all_ports_stopped()) { 16605 printf("Please stop all ports first\n"); 16606 return; 16607 } 16608 16609 filepath = strdup(res->filepath); 16610 if (filepath == NULL) { 16611 printf("Failed to allocate memory\n"); 16612 return; 16613 } 16614 file_num = rte_strsplit(filepath, strlen(filepath), file_fld, 2, ','); 16615 16616 buff = open_file(file_fld[0], &size); 16617 if (!buff) { 16618 free((void *)filepath); 16619 return; 16620 } 16621 16622 #ifdef RTE_LIBRTE_I40E_PMD 16623 if (ret == -ENOTSUP) 16624 ret = rte_pmd_i40e_process_ddp_package(res->port_id, 16625 buff, size, 16626 RTE_PMD_I40E_PKG_OP_WR_ADD); 16627 #endif 16628 16629 if (ret == -EEXIST) 16630 printf("Profile has already existed.\n"); 16631 else if (ret < 0) 16632 printf("Failed to load profile.\n"); 16633 else if (file_num == 2) 16634 save_file(file_fld[1], buff, size); 16635 16636 close_file(buff); 16637 free((void *)filepath); 16638 } 16639 16640 cmdline_parse_inst_t cmd_ddp_add = { 16641 .f = cmd_ddp_add_parsed, 16642 .data = NULL, 16643 .help_str = "ddp add <port_id> <profile_path[,backup_profile_path]>", 16644 .tokens = { 16645 (void *)&cmd_ddp_add_ddp, 16646 (void *)&cmd_ddp_add_add, 16647 (void *)&cmd_ddp_add_port_id, 16648 (void *)&cmd_ddp_add_filepath, 16649 NULL, 16650 }, 16651 }; 16652 16653 /* Delete dynamic device personalization*/ 16654 struct cmd_ddp_del_result { 16655 cmdline_fixed_string_t ddp; 16656 cmdline_fixed_string_t del; 16657 portid_t port_id; 16658 char filepath[]; 16659 }; 16660 16661 cmdline_parse_token_string_t cmd_ddp_del_ddp = 16662 TOKEN_STRING_INITIALIZER(struct cmd_ddp_del_result, ddp, "ddp"); 16663 cmdline_parse_token_string_t cmd_ddp_del_del = 16664 TOKEN_STRING_INITIALIZER(struct cmd_ddp_del_result, del, "del"); 16665 cmdline_parse_token_num_t cmd_ddp_del_port_id = 16666 TOKEN_NUM_INITIALIZER(struct cmd_ddp_del_result, port_id, UINT16); 16667 cmdline_parse_token_string_t cmd_ddp_del_filepath = 16668 TOKEN_STRING_INITIALIZER(struct cmd_ddp_del_result, filepath, NULL); 16669 16670 static void 16671 cmd_ddp_del_parsed( 16672 void *parsed_result, 16673 __rte_unused struct cmdline *cl, 16674 __rte_unused void *data) 16675 { 16676 struct cmd_ddp_del_result *res = parsed_result; 16677 uint8_t *buff; 16678 uint32_t size; 16679 int ret = -ENOTSUP; 16680 16681 if (!all_ports_stopped()) { 16682 printf("Please stop all ports first\n"); 16683 return; 16684 } 16685 16686 buff = open_file(res->filepath, &size); 16687 if (!buff) 16688 return; 16689 16690 #ifdef RTE_LIBRTE_I40E_PMD 16691 if (ret == -ENOTSUP) 16692 ret = rte_pmd_i40e_process_ddp_package(res->port_id, 16693 buff, size, 16694 RTE_PMD_I40E_PKG_OP_WR_DEL); 16695 #endif 16696 16697 if (ret == -EACCES) 16698 printf("Profile does not exist.\n"); 16699 else if (ret < 0) 16700 printf("Failed to delete profile.\n"); 16701 16702 close_file(buff); 16703 } 16704 16705 cmdline_parse_inst_t cmd_ddp_del = { 16706 .f = cmd_ddp_del_parsed, 16707 .data = NULL, 16708 .help_str = "ddp del <port_id> <backup_profile_path>", 16709 .tokens = { 16710 (void *)&cmd_ddp_del_ddp, 16711 (void *)&cmd_ddp_del_del, 16712 (void *)&cmd_ddp_del_port_id, 16713 (void *)&cmd_ddp_del_filepath, 16714 NULL, 16715 }, 16716 }; 16717 16718 /* Get dynamic device personalization profile info */ 16719 struct cmd_ddp_info_result { 16720 cmdline_fixed_string_t ddp; 16721 cmdline_fixed_string_t get; 16722 cmdline_fixed_string_t info; 16723 char filepath[]; 16724 }; 16725 16726 cmdline_parse_token_string_t cmd_ddp_info_ddp = 16727 TOKEN_STRING_INITIALIZER(struct cmd_ddp_info_result, ddp, "ddp"); 16728 cmdline_parse_token_string_t cmd_ddp_info_get = 16729 TOKEN_STRING_INITIALIZER(struct cmd_ddp_info_result, get, "get"); 16730 cmdline_parse_token_string_t cmd_ddp_info_info = 16731 TOKEN_STRING_INITIALIZER(struct cmd_ddp_info_result, info, "info"); 16732 cmdline_parse_token_string_t cmd_ddp_info_filepath = 16733 TOKEN_STRING_INITIALIZER(struct cmd_ddp_info_result, filepath, NULL); 16734 16735 static void 16736 cmd_ddp_info_parsed( 16737 void *parsed_result, 16738 __rte_unused struct cmdline *cl, 16739 __rte_unused void *data) 16740 { 16741 struct cmd_ddp_info_result *res = parsed_result; 16742 uint8_t *pkg; 16743 uint32_t pkg_size; 16744 int ret = -ENOTSUP; 16745 #ifdef RTE_LIBRTE_I40E_PMD 16746 uint32_t i, j, n; 16747 uint8_t *buff; 16748 uint32_t buff_size = 0; 16749 struct rte_pmd_i40e_profile_info info; 16750 uint32_t dev_num = 0; 16751 struct rte_pmd_i40e_ddp_device_id *devs; 16752 uint32_t proto_num = 0; 16753 struct rte_pmd_i40e_proto_info *proto = NULL; 16754 uint32_t pctype_num = 0; 16755 struct rte_pmd_i40e_ptype_info *pctype; 16756 uint32_t ptype_num = 0; 16757 struct rte_pmd_i40e_ptype_info *ptype; 16758 uint8_t proto_id; 16759 16760 #endif 16761 16762 pkg = open_file(res->filepath, &pkg_size); 16763 if (!pkg) 16764 return; 16765 16766 #ifdef RTE_LIBRTE_I40E_PMD 16767 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size, 16768 (uint8_t *)&info, sizeof(info), 16769 RTE_PMD_I40E_PKG_INFO_GLOBAL_HEADER); 16770 if (!ret) { 16771 printf("Global Track id: 0x%x\n", info.track_id); 16772 printf("Global Version: %d.%d.%d.%d\n", 16773 info.version.major, 16774 info.version.minor, 16775 info.version.update, 16776 info.version.draft); 16777 printf("Global Package name: %s\n\n", info.name); 16778 } 16779 16780 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size, 16781 (uint8_t *)&info, sizeof(info), 16782 RTE_PMD_I40E_PKG_INFO_HEADER); 16783 if (!ret) { 16784 printf("i40e Profile Track id: 0x%x\n", info.track_id); 16785 printf("i40e Profile Version: %d.%d.%d.%d\n", 16786 info.version.major, 16787 info.version.minor, 16788 info.version.update, 16789 info.version.draft); 16790 printf("i40e Profile name: %s\n\n", info.name); 16791 } 16792 16793 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size, 16794 (uint8_t *)&buff_size, sizeof(buff_size), 16795 RTE_PMD_I40E_PKG_INFO_GLOBAL_NOTES_SIZE); 16796 if (!ret && buff_size) { 16797 buff = (uint8_t *)malloc(buff_size); 16798 if (buff) { 16799 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size, 16800 buff, buff_size, 16801 RTE_PMD_I40E_PKG_INFO_GLOBAL_NOTES); 16802 if (!ret) 16803 printf("Package Notes:\n%s\n\n", buff); 16804 free(buff); 16805 } 16806 } 16807 16808 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size, 16809 (uint8_t *)&dev_num, sizeof(dev_num), 16810 RTE_PMD_I40E_PKG_INFO_DEVID_NUM); 16811 if (!ret && dev_num) { 16812 buff_size = dev_num * sizeof(struct rte_pmd_i40e_ddp_device_id); 16813 devs = (struct rte_pmd_i40e_ddp_device_id *)malloc(buff_size); 16814 if (devs) { 16815 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size, 16816 (uint8_t *)devs, buff_size, 16817 RTE_PMD_I40E_PKG_INFO_DEVID_LIST); 16818 if (!ret) { 16819 printf("List of supported devices:\n"); 16820 for (i = 0; i < dev_num; i++) { 16821 printf(" %04X:%04X %04X:%04X\n", 16822 devs[i].vendor_dev_id >> 16, 16823 devs[i].vendor_dev_id & 0xFFFF, 16824 devs[i].sub_vendor_dev_id >> 16, 16825 devs[i].sub_vendor_dev_id & 0xFFFF); 16826 } 16827 printf("\n"); 16828 } 16829 free(devs); 16830 } 16831 } 16832 16833 /* get information about protocols and packet types */ 16834 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size, 16835 (uint8_t *)&proto_num, sizeof(proto_num), 16836 RTE_PMD_I40E_PKG_INFO_PROTOCOL_NUM); 16837 if (ret || !proto_num) 16838 goto no_print_return; 16839 16840 buff_size = proto_num * sizeof(struct rte_pmd_i40e_proto_info); 16841 proto = (struct rte_pmd_i40e_proto_info *)malloc(buff_size); 16842 if (!proto) 16843 goto no_print_return; 16844 16845 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size, (uint8_t *)proto, 16846 buff_size, 16847 RTE_PMD_I40E_PKG_INFO_PROTOCOL_LIST); 16848 if (!ret) { 16849 printf("List of used protocols:\n"); 16850 for (i = 0; i < proto_num; i++) 16851 printf(" %2u: %s\n", proto[i].proto_id, 16852 proto[i].name); 16853 printf("\n"); 16854 } 16855 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size, 16856 (uint8_t *)&pctype_num, sizeof(pctype_num), 16857 RTE_PMD_I40E_PKG_INFO_PCTYPE_NUM); 16858 if (ret || !pctype_num) 16859 goto no_print_pctypes; 16860 16861 buff_size = pctype_num * sizeof(struct rte_pmd_i40e_ptype_info); 16862 pctype = (struct rte_pmd_i40e_ptype_info *)malloc(buff_size); 16863 if (!pctype) 16864 goto no_print_pctypes; 16865 16866 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size, (uint8_t *)pctype, 16867 buff_size, 16868 RTE_PMD_I40E_PKG_INFO_PCTYPE_LIST); 16869 if (ret) { 16870 free(pctype); 16871 goto no_print_pctypes; 16872 } 16873 16874 printf("List of defined packet classification types:\n"); 16875 for (i = 0; i < pctype_num; i++) { 16876 printf(" %2u:", pctype[i].ptype_id); 16877 for (j = 0; j < RTE_PMD_I40E_PROTO_NUM; j++) { 16878 proto_id = pctype[i].protocols[j]; 16879 if (proto_id != RTE_PMD_I40E_PROTO_UNUSED) { 16880 for (n = 0; n < proto_num; n++) { 16881 if (proto[n].proto_id == proto_id) { 16882 printf(" %s", proto[n].name); 16883 break; 16884 } 16885 } 16886 } 16887 } 16888 printf("\n"); 16889 } 16890 printf("\n"); 16891 free(pctype); 16892 16893 no_print_pctypes: 16894 16895 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size, (uint8_t *)&ptype_num, 16896 sizeof(ptype_num), 16897 RTE_PMD_I40E_PKG_INFO_PTYPE_NUM); 16898 if (ret || !ptype_num) 16899 goto no_print_return; 16900 16901 buff_size = ptype_num * sizeof(struct rte_pmd_i40e_ptype_info); 16902 ptype = (struct rte_pmd_i40e_ptype_info *)malloc(buff_size); 16903 if (!ptype) 16904 goto no_print_return; 16905 16906 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size, (uint8_t *)ptype, 16907 buff_size, 16908 RTE_PMD_I40E_PKG_INFO_PTYPE_LIST); 16909 if (ret) { 16910 free(ptype); 16911 goto no_print_return; 16912 } 16913 printf("List of defined packet types:\n"); 16914 for (i = 0; i < ptype_num; i++) { 16915 printf(" %2u:", ptype[i].ptype_id); 16916 for (j = 0; j < RTE_PMD_I40E_PROTO_NUM; j++) { 16917 proto_id = ptype[i].protocols[j]; 16918 if (proto_id != RTE_PMD_I40E_PROTO_UNUSED) { 16919 for (n = 0; n < proto_num; n++) { 16920 if (proto[n].proto_id == proto_id) { 16921 printf(" %s", proto[n].name); 16922 break; 16923 } 16924 } 16925 } 16926 } 16927 printf("\n"); 16928 } 16929 free(ptype); 16930 printf("\n"); 16931 16932 ret = 0; 16933 no_print_return: 16934 if (proto) 16935 free(proto); 16936 #endif 16937 if (ret == -ENOTSUP) 16938 printf("Function not supported in PMD driver\n"); 16939 close_file(pkg); 16940 } 16941 16942 cmdline_parse_inst_t cmd_ddp_get_info = { 16943 .f = cmd_ddp_info_parsed, 16944 .data = NULL, 16945 .help_str = "ddp get info <profile_path>", 16946 .tokens = { 16947 (void *)&cmd_ddp_info_ddp, 16948 (void *)&cmd_ddp_info_get, 16949 (void *)&cmd_ddp_info_info, 16950 (void *)&cmd_ddp_info_filepath, 16951 NULL, 16952 }, 16953 }; 16954 16955 /* Get dynamic device personalization profile info list*/ 16956 #define PROFILE_INFO_SIZE 48 16957 #define MAX_PROFILE_NUM 16 16958 16959 struct cmd_ddp_get_list_result { 16960 cmdline_fixed_string_t ddp; 16961 cmdline_fixed_string_t get; 16962 cmdline_fixed_string_t list; 16963 portid_t port_id; 16964 }; 16965 16966 cmdline_parse_token_string_t cmd_ddp_get_list_ddp = 16967 TOKEN_STRING_INITIALIZER(struct cmd_ddp_get_list_result, ddp, "ddp"); 16968 cmdline_parse_token_string_t cmd_ddp_get_list_get = 16969 TOKEN_STRING_INITIALIZER(struct cmd_ddp_get_list_result, get, "get"); 16970 cmdline_parse_token_string_t cmd_ddp_get_list_list = 16971 TOKEN_STRING_INITIALIZER(struct cmd_ddp_get_list_result, list, "list"); 16972 cmdline_parse_token_num_t cmd_ddp_get_list_port_id = 16973 TOKEN_NUM_INITIALIZER(struct cmd_ddp_get_list_result, port_id, UINT16); 16974 16975 static void 16976 cmd_ddp_get_list_parsed( 16977 __rte_unused void *parsed_result, 16978 __rte_unused struct cmdline *cl, 16979 __rte_unused void *data) 16980 { 16981 #ifdef RTE_LIBRTE_I40E_PMD 16982 struct cmd_ddp_get_list_result *res = parsed_result; 16983 struct rte_pmd_i40e_profile_list *p_list; 16984 struct rte_pmd_i40e_profile_info *p_info; 16985 uint32_t p_num; 16986 uint32_t size; 16987 uint32_t i; 16988 #endif 16989 int ret = -ENOTSUP; 16990 16991 #ifdef RTE_LIBRTE_I40E_PMD 16992 size = PROFILE_INFO_SIZE * MAX_PROFILE_NUM + 4; 16993 p_list = (struct rte_pmd_i40e_profile_list *)malloc(size); 16994 if (!p_list) { 16995 printf("%s: Failed to malloc buffer\n", __func__); 16996 return; 16997 } 16998 16999 if (ret == -ENOTSUP) 17000 ret = rte_pmd_i40e_get_ddp_list(res->port_id, 17001 (uint8_t *)p_list, size); 17002 17003 if (!ret) { 17004 p_num = p_list->p_count; 17005 printf("Profile number is: %d\n\n", p_num); 17006 17007 for (i = 0; i < p_num; i++) { 17008 p_info = &p_list->p_info[i]; 17009 printf("Profile %d:\n", i); 17010 printf("Track id: 0x%x\n", p_info->track_id); 17011 printf("Version: %d.%d.%d.%d\n", 17012 p_info->version.major, 17013 p_info->version.minor, 17014 p_info->version.update, 17015 p_info->version.draft); 17016 printf("Profile name: %s\n\n", p_info->name); 17017 } 17018 } 17019 17020 free(p_list); 17021 #endif 17022 17023 if (ret < 0) 17024 printf("Failed to get ddp list\n"); 17025 } 17026 17027 cmdline_parse_inst_t cmd_ddp_get_list = { 17028 .f = cmd_ddp_get_list_parsed, 17029 .data = NULL, 17030 .help_str = "ddp get list <port_id>", 17031 .tokens = { 17032 (void *)&cmd_ddp_get_list_ddp, 17033 (void *)&cmd_ddp_get_list_get, 17034 (void *)&cmd_ddp_get_list_list, 17035 (void *)&cmd_ddp_get_list_port_id, 17036 NULL, 17037 }, 17038 }; 17039 17040 /* Configure input set */ 17041 struct cmd_cfg_input_set_result { 17042 cmdline_fixed_string_t port; 17043 cmdline_fixed_string_t cfg; 17044 portid_t port_id; 17045 cmdline_fixed_string_t pctype; 17046 uint8_t pctype_id; 17047 cmdline_fixed_string_t inset_type; 17048 cmdline_fixed_string_t opt; 17049 cmdline_fixed_string_t field; 17050 uint8_t field_idx; 17051 }; 17052 17053 static void 17054 cmd_cfg_input_set_parsed( 17055 __rte_unused void *parsed_result, 17056 __rte_unused struct cmdline *cl, 17057 __rte_unused void *data) 17058 { 17059 #ifdef RTE_LIBRTE_I40E_PMD 17060 struct cmd_cfg_input_set_result *res = parsed_result; 17061 enum rte_pmd_i40e_inset_type inset_type = INSET_NONE; 17062 struct rte_pmd_i40e_inset inset; 17063 #endif 17064 int ret = -ENOTSUP; 17065 17066 if (!all_ports_stopped()) { 17067 printf("Please stop all ports first\n"); 17068 return; 17069 } 17070 17071 #ifdef RTE_LIBRTE_I40E_PMD 17072 if (!strcmp(res->inset_type, "hash_inset")) 17073 inset_type = INSET_HASH; 17074 else if (!strcmp(res->inset_type, "fdir_inset")) 17075 inset_type = INSET_FDIR; 17076 else if (!strcmp(res->inset_type, "fdir_flx_inset")) 17077 inset_type = INSET_FDIR_FLX; 17078 ret = rte_pmd_i40e_inset_get(res->port_id, res->pctype_id, 17079 &inset, inset_type); 17080 if (ret) { 17081 printf("Failed to get input set.\n"); 17082 return; 17083 } 17084 17085 if (!strcmp(res->opt, "get")) { 17086 ret = rte_pmd_i40e_inset_field_get(inset.inset, 17087 res->field_idx); 17088 if (ret) 17089 printf("Field index %d is enabled.\n", res->field_idx); 17090 else 17091 printf("Field index %d is disabled.\n", res->field_idx); 17092 return; 17093 } else if (!strcmp(res->opt, "set")) 17094 ret = rte_pmd_i40e_inset_field_set(&inset.inset, 17095 res->field_idx); 17096 else if (!strcmp(res->opt, "clear")) 17097 ret = rte_pmd_i40e_inset_field_clear(&inset.inset, 17098 res->field_idx); 17099 if (ret) { 17100 printf("Failed to configure input set field.\n"); 17101 return; 17102 } 17103 17104 ret = rte_pmd_i40e_inset_set(res->port_id, res->pctype_id, 17105 &inset, inset_type); 17106 if (ret) { 17107 printf("Failed to set input set.\n"); 17108 return; 17109 } 17110 #endif 17111 17112 if (ret == -ENOTSUP) 17113 printf("Function not supported\n"); 17114 } 17115 17116 cmdline_parse_token_string_t cmd_cfg_input_set_port = 17117 TOKEN_STRING_INITIALIZER(struct cmd_cfg_input_set_result, 17118 port, "port"); 17119 cmdline_parse_token_string_t cmd_cfg_input_set_cfg = 17120 TOKEN_STRING_INITIALIZER(struct cmd_cfg_input_set_result, 17121 cfg, "config"); 17122 cmdline_parse_token_num_t cmd_cfg_input_set_port_id = 17123 TOKEN_NUM_INITIALIZER(struct cmd_cfg_input_set_result, 17124 port_id, UINT16); 17125 cmdline_parse_token_string_t cmd_cfg_input_set_pctype = 17126 TOKEN_STRING_INITIALIZER(struct cmd_cfg_input_set_result, 17127 pctype, "pctype"); 17128 cmdline_parse_token_num_t cmd_cfg_input_set_pctype_id = 17129 TOKEN_NUM_INITIALIZER(struct cmd_cfg_input_set_result, 17130 pctype_id, UINT8); 17131 cmdline_parse_token_string_t cmd_cfg_input_set_inset_type = 17132 TOKEN_STRING_INITIALIZER(struct cmd_cfg_input_set_result, 17133 inset_type, 17134 "hash_inset#fdir_inset#fdir_flx_inset"); 17135 cmdline_parse_token_string_t cmd_cfg_input_set_opt = 17136 TOKEN_STRING_INITIALIZER(struct cmd_cfg_input_set_result, 17137 opt, "get#set#clear"); 17138 cmdline_parse_token_string_t cmd_cfg_input_set_field = 17139 TOKEN_STRING_INITIALIZER(struct cmd_cfg_input_set_result, 17140 field, "field"); 17141 cmdline_parse_token_num_t cmd_cfg_input_set_field_idx = 17142 TOKEN_NUM_INITIALIZER(struct cmd_cfg_input_set_result, 17143 field_idx, UINT8); 17144 17145 cmdline_parse_inst_t cmd_cfg_input_set = { 17146 .f = cmd_cfg_input_set_parsed, 17147 .data = NULL, 17148 .help_str = "port config <port_id> pctype <pctype_id> hash_inset|" 17149 "fdir_inset|fdir_flx_inset get|set|clear field <field_idx>", 17150 .tokens = { 17151 (void *)&cmd_cfg_input_set_port, 17152 (void *)&cmd_cfg_input_set_cfg, 17153 (void *)&cmd_cfg_input_set_port_id, 17154 (void *)&cmd_cfg_input_set_pctype, 17155 (void *)&cmd_cfg_input_set_pctype_id, 17156 (void *)&cmd_cfg_input_set_inset_type, 17157 (void *)&cmd_cfg_input_set_opt, 17158 (void *)&cmd_cfg_input_set_field, 17159 (void *)&cmd_cfg_input_set_field_idx, 17160 NULL, 17161 }, 17162 }; 17163 17164 /* Clear input set */ 17165 struct cmd_clear_input_set_result { 17166 cmdline_fixed_string_t port; 17167 cmdline_fixed_string_t cfg; 17168 portid_t port_id; 17169 cmdline_fixed_string_t pctype; 17170 uint8_t pctype_id; 17171 cmdline_fixed_string_t inset_type; 17172 cmdline_fixed_string_t clear; 17173 cmdline_fixed_string_t all; 17174 }; 17175 17176 static void 17177 cmd_clear_input_set_parsed( 17178 __rte_unused void *parsed_result, 17179 __rte_unused struct cmdline *cl, 17180 __rte_unused void *data) 17181 { 17182 #ifdef RTE_LIBRTE_I40E_PMD 17183 struct cmd_clear_input_set_result *res = parsed_result; 17184 enum rte_pmd_i40e_inset_type inset_type = INSET_NONE; 17185 struct rte_pmd_i40e_inset inset; 17186 #endif 17187 int ret = -ENOTSUP; 17188 17189 if (!all_ports_stopped()) { 17190 printf("Please stop all ports first\n"); 17191 return; 17192 } 17193 17194 #ifdef RTE_LIBRTE_I40E_PMD 17195 if (!strcmp(res->inset_type, "hash_inset")) 17196 inset_type = INSET_HASH; 17197 else if (!strcmp(res->inset_type, "fdir_inset")) 17198 inset_type = INSET_FDIR; 17199 else if (!strcmp(res->inset_type, "fdir_flx_inset")) 17200 inset_type = INSET_FDIR_FLX; 17201 17202 memset(&inset, 0, sizeof(inset)); 17203 17204 ret = rte_pmd_i40e_inset_set(res->port_id, res->pctype_id, 17205 &inset, inset_type); 17206 if (ret) { 17207 printf("Failed to clear input set.\n"); 17208 return; 17209 } 17210 17211 #endif 17212 17213 if (ret == -ENOTSUP) 17214 printf("Function not supported\n"); 17215 } 17216 17217 cmdline_parse_token_string_t cmd_clear_input_set_port = 17218 TOKEN_STRING_INITIALIZER(struct cmd_clear_input_set_result, 17219 port, "port"); 17220 cmdline_parse_token_string_t cmd_clear_input_set_cfg = 17221 TOKEN_STRING_INITIALIZER(struct cmd_clear_input_set_result, 17222 cfg, "config"); 17223 cmdline_parse_token_num_t cmd_clear_input_set_port_id = 17224 TOKEN_NUM_INITIALIZER(struct cmd_clear_input_set_result, 17225 port_id, UINT16); 17226 cmdline_parse_token_string_t cmd_clear_input_set_pctype = 17227 TOKEN_STRING_INITIALIZER(struct cmd_clear_input_set_result, 17228 pctype, "pctype"); 17229 cmdline_parse_token_num_t cmd_clear_input_set_pctype_id = 17230 TOKEN_NUM_INITIALIZER(struct cmd_clear_input_set_result, 17231 pctype_id, UINT8); 17232 cmdline_parse_token_string_t cmd_clear_input_set_inset_type = 17233 TOKEN_STRING_INITIALIZER(struct cmd_clear_input_set_result, 17234 inset_type, 17235 "hash_inset#fdir_inset#fdir_flx_inset"); 17236 cmdline_parse_token_string_t cmd_clear_input_set_clear = 17237 TOKEN_STRING_INITIALIZER(struct cmd_clear_input_set_result, 17238 clear, "clear"); 17239 cmdline_parse_token_string_t cmd_clear_input_set_all = 17240 TOKEN_STRING_INITIALIZER(struct cmd_clear_input_set_result, 17241 all, "all"); 17242 17243 cmdline_parse_inst_t cmd_clear_input_set = { 17244 .f = cmd_clear_input_set_parsed, 17245 .data = NULL, 17246 .help_str = "port config <port_id> pctype <pctype_id> hash_inset|" 17247 "fdir_inset|fdir_flx_inset clear all", 17248 .tokens = { 17249 (void *)&cmd_clear_input_set_port, 17250 (void *)&cmd_clear_input_set_cfg, 17251 (void *)&cmd_clear_input_set_port_id, 17252 (void *)&cmd_clear_input_set_pctype, 17253 (void *)&cmd_clear_input_set_pctype_id, 17254 (void *)&cmd_clear_input_set_inset_type, 17255 (void *)&cmd_clear_input_set_clear, 17256 (void *)&cmd_clear_input_set_all, 17257 NULL, 17258 }, 17259 }; 17260 17261 /* show vf stats */ 17262 17263 /* Common result structure for show vf stats */ 17264 struct cmd_show_vf_stats_result { 17265 cmdline_fixed_string_t show; 17266 cmdline_fixed_string_t vf; 17267 cmdline_fixed_string_t stats; 17268 portid_t port_id; 17269 uint16_t vf_id; 17270 }; 17271 17272 /* Common CLI fields show vf stats*/ 17273 cmdline_parse_token_string_t cmd_show_vf_stats_show = 17274 TOKEN_STRING_INITIALIZER 17275 (struct cmd_show_vf_stats_result, 17276 show, "show"); 17277 cmdline_parse_token_string_t cmd_show_vf_stats_vf = 17278 TOKEN_STRING_INITIALIZER 17279 (struct cmd_show_vf_stats_result, 17280 vf, "vf"); 17281 cmdline_parse_token_string_t cmd_show_vf_stats_stats = 17282 TOKEN_STRING_INITIALIZER 17283 (struct cmd_show_vf_stats_result, 17284 stats, "stats"); 17285 cmdline_parse_token_num_t cmd_show_vf_stats_port_id = 17286 TOKEN_NUM_INITIALIZER 17287 (struct cmd_show_vf_stats_result, 17288 port_id, UINT16); 17289 cmdline_parse_token_num_t cmd_show_vf_stats_vf_id = 17290 TOKEN_NUM_INITIALIZER 17291 (struct cmd_show_vf_stats_result, 17292 vf_id, UINT16); 17293 17294 static void 17295 cmd_show_vf_stats_parsed( 17296 void *parsed_result, 17297 __rte_unused struct cmdline *cl, 17298 __rte_unused void *data) 17299 { 17300 struct cmd_show_vf_stats_result *res = parsed_result; 17301 struct rte_eth_stats stats; 17302 int ret = -ENOTSUP; 17303 static const char *nic_stats_border = "########################"; 17304 17305 if (port_id_is_invalid(res->port_id, ENABLED_WARN)) 17306 return; 17307 17308 memset(&stats, 0, sizeof(stats)); 17309 17310 #ifdef RTE_LIBRTE_I40E_PMD 17311 if (ret == -ENOTSUP) 17312 ret = rte_pmd_i40e_get_vf_stats(res->port_id, 17313 res->vf_id, 17314 &stats); 17315 #endif 17316 #ifdef RTE_LIBRTE_BNXT_PMD 17317 if (ret == -ENOTSUP) 17318 ret = rte_pmd_bnxt_get_vf_stats(res->port_id, 17319 res->vf_id, 17320 &stats); 17321 #endif 17322 17323 switch (ret) { 17324 case 0: 17325 break; 17326 case -EINVAL: 17327 printf("invalid vf_id %d\n", res->vf_id); 17328 break; 17329 case -ENODEV: 17330 printf("invalid port_id %d\n", res->port_id); 17331 break; 17332 case -ENOTSUP: 17333 printf("function not implemented\n"); 17334 break; 17335 default: 17336 printf("programming error: (%s)\n", strerror(-ret)); 17337 } 17338 17339 printf("\n %s NIC statistics for port %-2d vf %-2d %s\n", 17340 nic_stats_border, res->port_id, res->vf_id, nic_stats_border); 17341 17342 printf(" RX-packets: %-10"PRIu64" RX-missed: %-10"PRIu64" RX-bytes: " 17343 "%-"PRIu64"\n", 17344 stats.ipackets, stats.imissed, stats.ibytes); 17345 printf(" RX-errors: %-"PRIu64"\n", stats.ierrors); 17346 printf(" RX-nombuf: %-10"PRIu64"\n", 17347 stats.rx_nombuf); 17348 printf(" TX-packets: %-10"PRIu64" TX-errors: %-10"PRIu64" TX-bytes: " 17349 "%-"PRIu64"\n", 17350 stats.opackets, stats.oerrors, stats.obytes); 17351 17352 printf(" %s############################%s\n", 17353 nic_stats_border, nic_stats_border); 17354 } 17355 17356 cmdline_parse_inst_t cmd_show_vf_stats = { 17357 .f = cmd_show_vf_stats_parsed, 17358 .data = NULL, 17359 .help_str = "show vf stats <port_id> <vf_id>", 17360 .tokens = { 17361 (void *)&cmd_show_vf_stats_show, 17362 (void *)&cmd_show_vf_stats_vf, 17363 (void *)&cmd_show_vf_stats_stats, 17364 (void *)&cmd_show_vf_stats_port_id, 17365 (void *)&cmd_show_vf_stats_vf_id, 17366 NULL, 17367 }, 17368 }; 17369 17370 /* clear vf stats */ 17371 17372 /* Common result structure for clear vf stats */ 17373 struct cmd_clear_vf_stats_result { 17374 cmdline_fixed_string_t clear; 17375 cmdline_fixed_string_t vf; 17376 cmdline_fixed_string_t stats; 17377 portid_t port_id; 17378 uint16_t vf_id; 17379 }; 17380 17381 /* Common CLI fields clear vf stats*/ 17382 cmdline_parse_token_string_t cmd_clear_vf_stats_clear = 17383 TOKEN_STRING_INITIALIZER 17384 (struct cmd_clear_vf_stats_result, 17385 clear, "clear"); 17386 cmdline_parse_token_string_t cmd_clear_vf_stats_vf = 17387 TOKEN_STRING_INITIALIZER 17388 (struct cmd_clear_vf_stats_result, 17389 vf, "vf"); 17390 cmdline_parse_token_string_t cmd_clear_vf_stats_stats = 17391 TOKEN_STRING_INITIALIZER 17392 (struct cmd_clear_vf_stats_result, 17393 stats, "stats"); 17394 cmdline_parse_token_num_t cmd_clear_vf_stats_port_id = 17395 TOKEN_NUM_INITIALIZER 17396 (struct cmd_clear_vf_stats_result, 17397 port_id, UINT16); 17398 cmdline_parse_token_num_t cmd_clear_vf_stats_vf_id = 17399 TOKEN_NUM_INITIALIZER 17400 (struct cmd_clear_vf_stats_result, 17401 vf_id, UINT16); 17402 17403 static void 17404 cmd_clear_vf_stats_parsed( 17405 void *parsed_result, 17406 __rte_unused struct cmdline *cl, 17407 __rte_unused void *data) 17408 { 17409 struct cmd_clear_vf_stats_result *res = parsed_result; 17410 int ret = -ENOTSUP; 17411 17412 if (port_id_is_invalid(res->port_id, ENABLED_WARN)) 17413 return; 17414 17415 #ifdef RTE_LIBRTE_I40E_PMD 17416 if (ret == -ENOTSUP) 17417 ret = rte_pmd_i40e_reset_vf_stats(res->port_id, 17418 res->vf_id); 17419 #endif 17420 #ifdef RTE_LIBRTE_BNXT_PMD 17421 if (ret == -ENOTSUP) 17422 ret = rte_pmd_bnxt_reset_vf_stats(res->port_id, 17423 res->vf_id); 17424 #endif 17425 17426 switch (ret) { 17427 case 0: 17428 break; 17429 case -EINVAL: 17430 printf("invalid vf_id %d\n", res->vf_id); 17431 break; 17432 case -ENODEV: 17433 printf("invalid port_id %d\n", res->port_id); 17434 break; 17435 case -ENOTSUP: 17436 printf("function not implemented\n"); 17437 break; 17438 default: 17439 printf("programming error: (%s)\n", strerror(-ret)); 17440 } 17441 } 17442 17443 cmdline_parse_inst_t cmd_clear_vf_stats = { 17444 .f = cmd_clear_vf_stats_parsed, 17445 .data = NULL, 17446 .help_str = "clear vf stats <port_id> <vf_id>", 17447 .tokens = { 17448 (void *)&cmd_clear_vf_stats_clear, 17449 (void *)&cmd_clear_vf_stats_vf, 17450 (void *)&cmd_clear_vf_stats_stats, 17451 (void *)&cmd_clear_vf_stats_port_id, 17452 (void *)&cmd_clear_vf_stats_vf_id, 17453 NULL, 17454 }, 17455 }; 17456 17457 /* port config pctype mapping reset */ 17458 17459 /* Common result structure for port config pctype mapping reset */ 17460 struct cmd_pctype_mapping_reset_result { 17461 cmdline_fixed_string_t port; 17462 cmdline_fixed_string_t config; 17463 portid_t port_id; 17464 cmdline_fixed_string_t pctype; 17465 cmdline_fixed_string_t mapping; 17466 cmdline_fixed_string_t reset; 17467 }; 17468 17469 /* Common CLI fields for port config pctype mapping reset*/ 17470 cmdline_parse_token_string_t cmd_pctype_mapping_reset_port = 17471 TOKEN_STRING_INITIALIZER 17472 (struct cmd_pctype_mapping_reset_result, 17473 port, "port"); 17474 cmdline_parse_token_string_t cmd_pctype_mapping_reset_config = 17475 TOKEN_STRING_INITIALIZER 17476 (struct cmd_pctype_mapping_reset_result, 17477 config, "config"); 17478 cmdline_parse_token_num_t cmd_pctype_mapping_reset_port_id = 17479 TOKEN_NUM_INITIALIZER 17480 (struct cmd_pctype_mapping_reset_result, 17481 port_id, UINT16); 17482 cmdline_parse_token_string_t cmd_pctype_mapping_reset_pctype = 17483 TOKEN_STRING_INITIALIZER 17484 (struct cmd_pctype_mapping_reset_result, 17485 pctype, "pctype"); 17486 cmdline_parse_token_string_t cmd_pctype_mapping_reset_mapping = 17487 TOKEN_STRING_INITIALIZER 17488 (struct cmd_pctype_mapping_reset_result, 17489 mapping, "mapping"); 17490 cmdline_parse_token_string_t cmd_pctype_mapping_reset_reset = 17491 TOKEN_STRING_INITIALIZER 17492 (struct cmd_pctype_mapping_reset_result, 17493 reset, "reset"); 17494 17495 static void 17496 cmd_pctype_mapping_reset_parsed( 17497 void *parsed_result, 17498 __rte_unused struct cmdline *cl, 17499 __rte_unused void *data) 17500 { 17501 struct cmd_pctype_mapping_reset_result *res = parsed_result; 17502 int ret = -ENOTSUP; 17503 17504 if (port_id_is_invalid(res->port_id, ENABLED_WARN)) 17505 return; 17506 17507 #ifdef RTE_LIBRTE_I40E_PMD 17508 ret = rte_pmd_i40e_flow_type_mapping_reset(res->port_id); 17509 #endif 17510 17511 switch (ret) { 17512 case 0: 17513 break; 17514 case -ENODEV: 17515 printf("invalid port_id %d\n", res->port_id); 17516 break; 17517 case -ENOTSUP: 17518 printf("function not implemented\n"); 17519 break; 17520 default: 17521 printf("programming error: (%s)\n", strerror(-ret)); 17522 } 17523 } 17524 17525 cmdline_parse_inst_t cmd_pctype_mapping_reset = { 17526 .f = cmd_pctype_mapping_reset_parsed, 17527 .data = NULL, 17528 .help_str = "port config <port_id> pctype mapping reset", 17529 .tokens = { 17530 (void *)&cmd_pctype_mapping_reset_port, 17531 (void *)&cmd_pctype_mapping_reset_config, 17532 (void *)&cmd_pctype_mapping_reset_port_id, 17533 (void *)&cmd_pctype_mapping_reset_pctype, 17534 (void *)&cmd_pctype_mapping_reset_mapping, 17535 (void *)&cmd_pctype_mapping_reset_reset, 17536 NULL, 17537 }, 17538 }; 17539 17540 /* show port pctype mapping */ 17541 17542 /* Common result structure for show port pctype mapping */ 17543 struct cmd_pctype_mapping_get_result { 17544 cmdline_fixed_string_t show; 17545 cmdline_fixed_string_t port; 17546 portid_t port_id; 17547 cmdline_fixed_string_t pctype; 17548 cmdline_fixed_string_t mapping; 17549 }; 17550 17551 /* Common CLI fields for pctype mapping get */ 17552 cmdline_parse_token_string_t cmd_pctype_mapping_get_show = 17553 TOKEN_STRING_INITIALIZER 17554 (struct cmd_pctype_mapping_get_result, 17555 show, "show"); 17556 cmdline_parse_token_string_t cmd_pctype_mapping_get_port = 17557 TOKEN_STRING_INITIALIZER 17558 (struct cmd_pctype_mapping_get_result, 17559 port, "port"); 17560 cmdline_parse_token_num_t cmd_pctype_mapping_get_port_id = 17561 TOKEN_NUM_INITIALIZER 17562 (struct cmd_pctype_mapping_get_result, 17563 port_id, UINT16); 17564 cmdline_parse_token_string_t cmd_pctype_mapping_get_pctype = 17565 TOKEN_STRING_INITIALIZER 17566 (struct cmd_pctype_mapping_get_result, 17567 pctype, "pctype"); 17568 cmdline_parse_token_string_t cmd_pctype_mapping_get_mapping = 17569 TOKEN_STRING_INITIALIZER 17570 (struct cmd_pctype_mapping_get_result, 17571 mapping, "mapping"); 17572 17573 static void 17574 cmd_pctype_mapping_get_parsed( 17575 void *parsed_result, 17576 __rte_unused struct cmdline *cl, 17577 __rte_unused void *data) 17578 { 17579 struct cmd_pctype_mapping_get_result *res = parsed_result; 17580 int ret = -ENOTSUP; 17581 #ifdef RTE_LIBRTE_I40E_PMD 17582 struct rte_pmd_i40e_flow_type_mapping 17583 mapping[RTE_PMD_I40E_FLOW_TYPE_MAX]; 17584 int i, j, first_pctype; 17585 #endif 17586 17587 if (port_id_is_invalid(res->port_id, ENABLED_WARN)) 17588 return; 17589 17590 #ifdef RTE_LIBRTE_I40E_PMD 17591 ret = rte_pmd_i40e_flow_type_mapping_get(res->port_id, mapping); 17592 #endif 17593 17594 switch (ret) { 17595 case 0: 17596 break; 17597 case -ENODEV: 17598 printf("invalid port_id %d\n", res->port_id); 17599 return; 17600 case -ENOTSUP: 17601 printf("function not implemented\n"); 17602 return; 17603 default: 17604 printf("programming error: (%s)\n", strerror(-ret)); 17605 return; 17606 } 17607 17608 #ifdef RTE_LIBRTE_I40E_PMD 17609 for (i = 0; i < RTE_PMD_I40E_FLOW_TYPE_MAX; i++) { 17610 if (mapping[i].pctype != 0ULL) { 17611 first_pctype = 1; 17612 17613 printf("pctype: "); 17614 for (j = 0; j < RTE_PMD_I40E_PCTYPE_MAX; j++) { 17615 if (mapping[i].pctype & (1ULL << j)) { 17616 printf(first_pctype ? 17617 "%02d" : ",%02d", j); 17618 first_pctype = 0; 17619 } 17620 } 17621 printf(" -> flowtype: %02d\n", mapping[i].flow_type); 17622 } 17623 } 17624 #endif 17625 } 17626 17627 cmdline_parse_inst_t cmd_pctype_mapping_get = { 17628 .f = cmd_pctype_mapping_get_parsed, 17629 .data = NULL, 17630 .help_str = "show port <port_id> pctype mapping", 17631 .tokens = { 17632 (void *)&cmd_pctype_mapping_get_show, 17633 (void *)&cmd_pctype_mapping_get_port, 17634 (void *)&cmd_pctype_mapping_get_port_id, 17635 (void *)&cmd_pctype_mapping_get_pctype, 17636 (void *)&cmd_pctype_mapping_get_mapping, 17637 NULL, 17638 }, 17639 }; 17640 17641 /* port config pctype mapping update */ 17642 17643 /* Common result structure for port config pctype mapping update */ 17644 struct cmd_pctype_mapping_update_result { 17645 cmdline_fixed_string_t port; 17646 cmdline_fixed_string_t config; 17647 portid_t port_id; 17648 cmdline_fixed_string_t pctype; 17649 cmdline_fixed_string_t mapping; 17650 cmdline_fixed_string_t update; 17651 cmdline_fixed_string_t pctype_list; 17652 uint16_t flow_type; 17653 }; 17654 17655 /* Common CLI fields for pctype mapping update*/ 17656 cmdline_parse_token_string_t cmd_pctype_mapping_update_port = 17657 TOKEN_STRING_INITIALIZER 17658 (struct cmd_pctype_mapping_update_result, 17659 port, "port"); 17660 cmdline_parse_token_string_t cmd_pctype_mapping_update_config = 17661 TOKEN_STRING_INITIALIZER 17662 (struct cmd_pctype_mapping_update_result, 17663 config, "config"); 17664 cmdline_parse_token_num_t cmd_pctype_mapping_update_port_id = 17665 TOKEN_NUM_INITIALIZER 17666 (struct cmd_pctype_mapping_update_result, 17667 port_id, UINT16); 17668 cmdline_parse_token_string_t cmd_pctype_mapping_update_pctype = 17669 TOKEN_STRING_INITIALIZER 17670 (struct cmd_pctype_mapping_update_result, 17671 pctype, "pctype"); 17672 cmdline_parse_token_string_t cmd_pctype_mapping_update_mapping = 17673 TOKEN_STRING_INITIALIZER 17674 (struct cmd_pctype_mapping_update_result, 17675 mapping, "mapping"); 17676 cmdline_parse_token_string_t cmd_pctype_mapping_update_update = 17677 TOKEN_STRING_INITIALIZER 17678 (struct cmd_pctype_mapping_update_result, 17679 update, "update"); 17680 cmdline_parse_token_string_t cmd_pctype_mapping_update_pc_type = 17681 TOKEN_STRING_INITIALIZER 17682 (struct cmd_pctype_mapping_update_result, 17683 pctype_list, NULL); 17684 cmdline_parse_token_num_t cmd_pctype_mapping_update_flow_type = 17685 TOKEN_NUM_INITIALIZER 17686 (struct cmd_pctype_mapping_update_result, 17687 flow_type, UINT16); 17688 17689 static void 17690 cmd_pctype_mapping_update_parsed( 17691 void *parsed_result, 17692 __rte_unused struct cmdline *cl, 17693 __rte_unused void *data) 17694 { 17695 struct cmd_pctype_mapping_update_result *res = parsed_result; 17696 int ret = -ENOTSUP; 17697 #ifdef RTE_LIBRTE_I40E_PMD 17698 struct rte_pmd_i40e_flow_type_mapping mapping; 17699 unsigned int i; 17700 unsigned int nb_item; 17701 unsigned int pctype_list[RTE_PMD_I40E_PCTYPE_MAX]; 17702 #endif 17703 17704 if (port_id_is_invalid(res->port_id, ENABLED_WARN)) 17705 return; 17706 17707 #ifdef RTE_LIBRTE_I40E_PMD 17708 nb_item = parse_item_list(res->pctype_list, "pctypes", 17709 RTE_PMD_I40E_PCTYPE_MAX, pctype_list, 1); 17710 mapping.flow_type = res->flow_type; 17711 for (i = 0, mapping.pctype = 0ULL; i < nb_item; i++) 17712 mapping.pctype |= (1ULL << pctype_list[i]); 17713 ret = rte_pmd_i40e_flow_type_mapping_update(res->port_id, 17714 &mapping, 17715 1, 17716 0); 17717 #endif 17718 17719 switch (ret) { 17720 case 0: 17721 break; 17722 case -EINVAL: 17723 printf("invalid pctype or flow type\n"); 17724 break; 17725 case -ENODEV: 17726 printf("invalid port_id %d\n", res->port_id); 17727 break; 17728 case -ENOTSUP: 17729 printf("function not implemented\n"); 17730 break; 17731 default: 17732 printf("programming error: (%s)\n", strerror(-ret)); 17733 } 17734 } 17735 17736 cmdline_parse_inst_t cmd_pctype_mapping_update = { 17737 .f = cmd_pctype_mapping_update_parsed, 17738 .data = NULL, 17739 .help_str = "port config <port_id> pctype mapping update" 17740 " <pctype_id_0,[pctype_id_1]*> <flowtype_id>", 17741 .tokens = { 17742 (void *)&cmd_pctype_mapping_update_port, 17743 (void *)&cmd_pctype_mapping_update_config, 17744 (void *)&cmd_pctype_mapping_update_port_id, 17745 (void *)&cmd_pctype_mapping_update_pctype, 17746 (void *)&cmd_pctype_mapping_update_mapping, 17747 (void *)&cmd_pctype_mapping_update_update, 17748 (void *)&cmd_pctype_mapping_update_pc_type, 17749 (void *)&cmd_pctype_mapping_update_flow_type, 17750 NULL, 17751 }, 17752 }; 17753 17754 /* ptype mapping get */ 17755 17756 /* Common result structure for ptype mapping get */ 17757 struct cmd_ptype_mapping_get_result { 17758 cmdline_fixed_string_t ptype; 17759 cmdline_fixed_string_t mapping; 17760 cmdline_fixed_string_t get; 17761 portid_t port_id; 17762 uint8_t valid_only; 17763 }; 17764 17765 /* Common CLI fields for ptype mapping get */ 17766 cmdline_parse_token_string_t cmd_ptype_mapping_get_ptype = 17767 TOKEN_STRING_INITIALIZER 17768 (struct cmd_ptype_mapping_get_result, 17769 ptype, "ptype"); 17770 cmdline_parse_token_string_t cmd_ptype_mapping_get_mapping = 17771 TOKEN_STRING_INITIALIZER 17772 (struct cmd_ptype_mapping_get_result, 17773 mapping, "mapping"); 17774 cmdline_parse_token_string_t cmd_ptype_mapping_get_get = 17775 TOKEN_STRING_INITIALIZER 17776 (struct cmd_ptype_mapping_get_result, 17777 get, "get"); 17778 cmdline_parse_token_num_t cmd_ptype_mapping_get_port_id = 17779 TOKEN_NUM_INITIALIZER 17780 (struct cmd_ptype_mapping_get_result, 17781 port_id, UINT16); 17782 cmdline_parse_token_num_t cmd_ptype_mapping_get_valid_only = 17783 TOKEN_NUM_INITIALIZER 17784 (struct cmd_ptype_mapping_get_result, 17785 valid_only, UINT8); 17786 17787 static void 17788 cmd_ptype_mapping_get_parsed( 17789 void *parsed_result, 17790 __rte_unused struct cmdline *cl, 17791 __rte_unused void *data) 17792 { 17793 struct cmd_ptype_mapping_get_result *res = parsed_result; 17794 int ret = -ENOTSUP; 17795 #ifdef RTE_LIBRTE_I40E_PMD 17796 int max_ptype_num = 256; 17797 struct rte_pmd_i40e_ptype_mapping mapping[max_ptype_num]; 17798 uint16_t count; 17799 int i; 17800 #endif 17801 17802 if (port_id_is_invalid(res->port_id, ENABLED_WARN)) 17803 return; 17804 17805 #ifdef RTE_LIBRTE_I40E_PMD 17806 ret = rte_pmd_i40e_ptype_mapping_get(res->port_id, 17807 mapping, 17808 max_ptype_num, 17809 &count, 17810 res->valid_only); 17811 #endif 17812 17813 switch (ret) { 17814 case 0: 17815 break; 17816 case -ENODEV: 17817 printf("invalid port_id %d\n", res->port_id); 17818 break; 17819 case -ENOTSUP: 17820 printf("function not implemented\n"); 17821 break; 17822 default: 17823 printf("programming error: (%s)\n", strerror(-ret)); 17824 } 17825 17826 #ifdef RTE_LIBRTE_I40E_PMD 17827 if (!ret) { 17828 for (i = 0; i < count; i++) 17829 printf("%3d\t0x%08x\n", 17830 mapping[i].hw_ptype, mapping[i].sw_ptype); 17831 } 17832 #endif 17833 } 17834 17835 cmdline_parse_inst_t cmd_ptype_mapping_get = { 17836 .f = cmd_ptype_mapping_get_parsed, 17837 .data = NULL, 17838 .help_str = "ptype mapping get <port_id> <valid_only>", 17839 .tokens = { 17840 (void *)&cmd_ptype_mapping_get_ptype, 17841 (void *)&cmd_ptype_mapping_get_mapping, 17842 (void *)&cmd_ptype_mapping_get_get, 17843 (void *)&cmd_ptype_mapping_get_port_id, 17844 (void *)&cmd_ptype_mapping_get_valid_only, 17845 NULL, 17846 }, 17847 }; 17848 17849 /* ptype mapping replace */ 17850 17851 /* Common result structure for ptype mapping replace */ 17852 struct cmd_ptype_mapping_replace_result { 17853 cmdline_fixed_string_t ptype; 17854 cmdline_fixed_string_t mapping; 17855 cmdline_fixed_string_t replace; 17856 portid_t port_id; 17857 uint32_t target; 17858 uint8_t mask; 17859 uint32_t pkt_type; 17860 }; 17861 17862 /* Common CLI fields for ptype mapping replace */ 17863 cmdline_parse_token_string_t cmd_ptype_mapping_replace_ptype = 17864 TOKEN_STRING_INITIALIZER 17865 (struct cmd_ptype_mapping_replace_result, 17866 ptype, "ptype"); 17867 cmdline_parse_token_string_t cmd_ptype_mapping_replace_mapping = 17868 TOKEN_STRING_INITIALIZER 17869 (struct cmd_ptype_mapping_replace_result, 17870 mapping, "mapping"); 17871 cmdline_parse_token_string_t cmd_ptype_mapping_replace_replace = 17872 TOKEN_STRING_INITIALIZER 17873 (struct cmd_ptype_mapping_replace_result, 17874 replace, "replace"); 17875 cmdline_parse_token_num_t cmd_ptype_mapping_replace_port_id = 17876 TOKEN_NUM_INITIALIZER 17877 (struct cmd_ptype_mapping_replace_result, 17878 port_id, UINT16); 17879 cmdline_parse_token_num_t cmd_ptype_mapping_replace_target = 17880 TOKEN_NUM_INITIALIZER 17881 (struct cmd_ptype_mapping_replace_result, 17882 target, UINT32); 17883 cmdline_parse_token_num_t cmd_ptype_mapping_replace_mask = 17884 TOKEN_NUM_INITIALIZER 17885 (struct cmd_ptype_mapping_replace_result, 17886 mask, UINT8); 17887 cmdline_parse_token_num_t cmd_ptype_mapping_replace_pkt_type = 17888 TOKEN_NUM_INITIALIZER 17889 (struct cmd_ptype_mapping_replace_result, 17890 pkt_type, UINT32); 17891 17892 static void 17893 cmd_ptype_mapping_replace_parsed( 17894 void *parsed_result, 17895 __rte_unused struct cmdline *cl, 17896 __rte_unused void *data) 17897 { 17898 struct cmd_ptype_mapping_replace_result *res = parsed_result; 17899 int ret = -ENOTSUP; 17900 17901 if (port_id_is_invalid(res->port_id, ENABLED_WARN)) 17902 return; 17903 17904 #ifdef RTE_LIBRTE_I40E_PMD 17905 ret = rte_pmd_i40e_ptype_mapping_replace(res->port_id, 17906 res->target, 17907 res->mask, 17908 res->pkt_type); 17909 #endif 17910 17911 switch (ret) { 17912 case 0: 17913 break; 17914 case -EINVAL: 17915 printf("invalid ptype 0x%8x or 0x%8x\n", 17916 res->target, res->pkt_type); 17917 break; 17918 case -ENODEV: 17919 printf("invalid port_id %d\n", res->port_id); 17920 break; 17921 case -ENOTSUP: 17922 printf("function not implemented\n"); 17923 break; 17924 default: 17925 printf("programming error: (%s)\n", strerror(-ret)); 17926 } 17927 } 17928 17929 cmdline_parse_inst_t cmd_ptype_mapping_replace = { 17930 .f = cmd_ptype_mapping_replace_parsed, 17931 .data = NULL, 17932 .help_str = 17933 "ptype mapping replace <port_id> <target> <mask> <pkt_type>", 17934 .tokens = { 17935 (void *)&cmd_ptype_mapping_replace_ptype, 17936 (void *)&cmd_ptype_mapping_replace_mapping, 17937 (void *)&cmd_ptype_mapping_replace_replace, 17938 (void *)&cmd_ptype_mapping_replace_port_id, 17939 (void *)&cmd_ptype_mapping_replace_target, 17940 (void *)&cmd_ptype_mapping_replace_mask, 17941 (void *)&cmd_ptype_mapping_replace_pkt_type, 17942 NULL, 17943 }, 17944 }; 17945 17946 /* ptype mapping reset */ 17947 17948 /* Common result structure for ptype mapping reset */ 17949 struct cmd_ptype_mapping_reset_result { 17950 cmdline_fixed_string_t ptype; 17951 cmdline_fixed_string_t mapping; 17952 cmdline_fixed_string_t reset; 17953 portid_t port_id; 17954 }; 17955 17956 /* Common CLI fields for ptype mapping reset*/ 17957 cmdline_parse_token_string_t cmd_ptype_mapping_reset_ptype = 17958 TOKEN_STRING_INITIALIZER 17959 (struct cmd_ptype_mapping_reset_result, 17960 ptype, "ptype"); 17961 cmdline_parse_token_string_t cmd_ptype_mapping_reset_mapping = 17962 TOKEN_STRING_INITIALIZER 17963 (struct cmd_ptype_mapping_reset_result, 17964 mapping, "mapping"); 17965 cmdline_parse_token_string_t cmd_ptype_mapping_reset_reset = 17966 TOKEN_STRING_INITIALIZER 17967 (struct cmd_ptype_mapping_reset_result, 17968 reset, "reset"); 17969 cmdline_parse_token_num_t cmd_ptype_mapping_reset_port_id = 17970 TOKEN_NUM_INITIALIZER 17971 (struct cmd_ptype_mapping_reset_result, 17972 port_id, UINT16); 17973 17974 static void 17975 cmd_ptype_mapping_reset_parsed( 17976 void *parsed_result, 17977 __rte_unused struct cmdline *cl, 17978 __rte_unused void *data) 17979 { 17980 struct cmd_ptype_mapping_reset_result *res = parsed_result; 17981 int ret = -ENOTSUP; 17982 17983 if (port_id_is_invalid(res->port_id, ENABLED_WARN)) 17984 return; 17985 17986 #ifdef RTE_LIBRTE_I40E_PMD 17987 ret = rte_pmd_i40e_ptype_mapping_reset(res->port_id); 17988 #endif 17989 17990 switch (ret) { 17991 case 0: 17992 break; 17993 case -ENODEV: 17994 printf("invalid port_id %d\n", res->port_id); 17995 break; 17996 case -ENOTSUP: 17997 printf("function not implemented\n"); 17998 break; 17999 default: 18000 printf("programming error: (%s)\n", strerror(-ret)); 18001 } 18002 } 18003 18004 cmdline_parse_inst_t cmd_ptype_mapping_reset = { 18005 .f = cmd_ptype_mapping_reset_parsed, 18006 .data = NULL, 18007 .help_str = "ptype mapping reset <port_id>", 18008 .tokens = { 18009 (void *)&cmd_ptype_mapping_reset_ptype, 18010 (void *)&cmd_ptype_mapping_reset_mapping, 18011 (void *)&cmd_ptype_mapping_reset_reset, 18012 (void *)&cmd_ptype_mapping_reset_port_id, 18013 NULL, 18014 }, 18015 }; 18016 18017 /* ptype mapping update */ 18018 18019 /* Common result structure for ptype mapping update */ 18020 struct cmd_ptype_mapping_update_result { 18021 cmdline_fixed_string_t ptype; 18022 cmdline_fixed_string_t mapping; 18023 cmdline_fixed_string_t reset; 18024 portid_t port_id; 18025 uint8_t hw_ptype; 18026 uint32_t sw_ptype; 18027 }; 18028 18029 /* Common CLI fields for ptype mapping update*/ 18030 cmdline_parse_token_string_t cmd_ptype_mapping_update_ptype = 18031 TOKEN_STRING_INITIALIZER 18032 (struct cmd_ptype_mapping_update_result, 18033 ptype, "ptype"); 18034 cmdline_parse_token_string_t cmd_ptype_mapping_update_mapping = 18035 TOKEN_STRING_INITIALIZER 18036 (struct cmd_ptype_mapping_update_result, 18037 mapping, "mapping"); 18038 cmdline_parse_token_string_t cmd_ptype_mapping_update_update = 18039 TOKEN_STRING_INITIALIZER 18040 (struct cmd_ptype_mapping_update_result, 18041 reset, "update"); 18042 cmdline_parse_token_num_t cmd_ptype_mapping_update_port_id = 18043 TOKEN_NUM_INITIALIZER 18044 (struct cmd_ptype_mapping_update_result, 18045 port_id, UINT16); 18046 cmdline_parse_token_num_t cmd_ptype_mapping_update_hw_ptype = 18047 TOKEN_NUM_INITIALIZER 18048 (struct cmd_ptype_mapping_update_result, 18049 hw_ptype, UINT8); 18050 cmdline_parse_token_num_t cmd_ptype_mapping_update_sw_ptype = 18051 TOKEN_NUM_INITIALIZER 18052 (struct cmd_ptype_mapping_update_result, 18053 sw_ptype, UINT32); 18054 18055 static void 18056 cmd_ptype_mapping_update_parsed( 18057 void *parsed_result, 18058 __rte_unused struct cmdline *cl, 18059 __rte_unused void *data) 18060 { 18061 struct cmd_ptype_mapping_update_result *res = parsed_result; 18062 int ret = -ENOTSUP; 18063 #ifdef RTE_LIBRTE_I40E_PMD 18064 struct rte_pmd_i40e_ptype_mapping mapping; 18065 #endif 18066 if (port_id_is_invalid(res->port_id, ENABLED_WARN)) 18067 return; 18068 18069 #ifdef RTE_LIBRTE_I40E_PMD 18070 mapping.hw_ptype = res->hw_ptype; 18071 mapping.sw_ptype = res->sw_ptype; 18072 ret = rte_pmd_i40e_ptype_mapping_update(res->port_id, 18073 &mapping, 18074 1, 18075 0); 18076 #endif 18077 18078 switch (ret) { 18079 case 0: 18080 break; 18081 case -EINVAL: 18082 printf("invalid ptype 0x%8x\n", res->sw_ptype); 18083 break; 18084 case -ENODEV: 18085 printf("invalid port_id %d\n", res->port_id); 18086 break; 18087 case -ENOTSUP: 18088 printf("function not implemented\n"); 18089 break; 18090 default: 18091 printf("programming error: (%s)\n", strerror(-ret)); 18092 } 18093 } 18094 18095 cmdline_parse_inst_t cmd_ptype_mapping_update = { 18096 .f = cmd_ptype_mapping_update_parsed, 18097 .data = NULL, 18098 .help_str = "ptype mapping update <port_id> <hw_ptype> <sw_ptype>", 18099 .tokens = { 18100 (void *)&cmd_ptype_mapping_update_ptype, 18101 (void *)&cmd_ptype_mapping_update_mapping, 18102 (void *)&cmd_ptype_mapping_update_update, 18103 (void *)&cmd_ptype_mapping_update_port_id, 18104 (void *)&cmd_ptype_mapping_update_hw_ptype, 18105 (void *)&cmd_ptype_mapping_update_sw_ptype, 18106 NULL, 18107 }, 18108 }; 18109 18110 /* Common result structure for file commands */ 18111 struct cmd_cmdfile_result { 18112 cmdline_fixed_string_t load; 18113 cmdline_fixed_string_t filename; 18114 }; 18115 18116 /* Common CLI fields for file commands */ 18117 cmdline_parse_token_string_t cmd_load_cmdfile = 18118 TOKEN_STRING_INITIALIZER(struct cmd_cmdfile_result, load, "load"); 18119 cmdline_parse_token_string_t cmd_load_cmdfile_filename = 18120 TOKEN_STRING_INITIALIZER(struct cmd_cmdfile_result, filename, NULL); 18121 18122 static void 18123 cmd_load_from_file_parsed( 18124 void *parsed_result, 18125 __rte_unused struct cmdline *cl, 18126 __rte_unused void *data) 18127 { 18128 struct cmd_cmdfile_result *res = parsed_result; 18129 18130 cmdline_read_from_file(res->filename); 18131 } 18132 18133 cmdline_parse_inst_t cmd_load_from_file = { 18134 .f = cmd_load_from_file_parsed, 18135 .data = NULL, 18136 .help_str = "load <filename>", 18137 .tokens = { 18138 (void *)&cmd_load_cmdfile, 18139 (void *)&cmd_load_cmdfile_filename, 18140 NULL, 18141 }, 18142 }; 18143 18144 /* Get Rx offloads capabilities */ 18145 struct cmd_rx_offload_get_capa_result { 18146 cmdline_fixed_string_t show; 18147 cmdline_fixed_string_t port; 18148 portid_t port_id; 18149 cmdline_fixed_string_t rx_offload; 18150 cmdline_fixed_string_t capabilities; 18151 }; 18152 18153 cmdline_parse_token_string_t cmd_rx_offload_get_capa_show = 18154 TOKEN_STRING_INITIALIZER 18155 (struct cmd_rx_offload_get_capa_result, 18156 show, "show"); 18157 cmdline_parse_token_string_t cmd_rx_offload_get_capa_port = 18158 TOKEN_STRING_INITIALIZER 18159 (struct cmd_rx_offload_get_capa_result, 18160 port, "port"); 18161 cmdline_parse_token_num_t cmd_rx_offload_get_capa_port_id = 18162 TOKEN_NUM_INITIALIZER 18163 (struct cmd_rx_offload_get_capa_result, 18164 port_id, UINT16); 18165 cmdline_parse_token_string_t cmd_rx_offload_get_capa_rx_offload = 18166 TOKEN_STRING_INITIALIZER 18167 (struct cmd_rx_offload_get_capa_result, 18168 rx_offload, "rx_offload"); 18169 cmdline_parse_token_string_t cmd_rx_offload_get_capa_capabilities = 18170 TOKEN_STRING_INITIALIZER 18171 (struct cmd_rx_offload_get_capa_result, 18172 capabilities, "capabilities"); 18173 18174 static void 18175 print_rx_offloads(uint64_t offloads) 18176 { 18177 uint64_t single_offload; 18178 int begin; 18179 int end; 18180 int bit; 18181 18182 if (offloads == 0) 18183 return; 18184 18185 begin = __builtin_ctzll(offloads); 18186 end = sizeof(offloads) * CHAR_BIT - __builtin_clzll(offloads); 18187 18188 single_offload = 1ULL << begin; 18189 for (bit = begin; bit < end; bit++) { 18190 if (offloads & single_offload) 18191 printf(" %s", 18192 rte_eth_dev_rx_offload_name(single_offload)); 18193 single_offload <<= 1; 18194 } 18195 } 18196 18197 static void 18198 cmd_rx_offload_get_capa_parsed( 18199 void *parsed_result, 18200 __rte_unused struct cmdline *cl, 18201 __rte_unused void *data) 18202 { 18203 struct cmd_rx_offload_get_capa_result *res = parsed_result; 18204 struct rte_eth_dev_info dev_info; 18205 portid_t port_id = res->port_id; 18206 uint64_t queue_offloads; 18207 uint64_t port_offloads; 18208 int ret; 18209 18210 ret = eth_dev_info_get_print_err(port_id, &dev_info); 18211 if (ret != 0) 18212 return; 18213 18214 queue_offloads = dev_info.rx_queue_offload_capa; 18215 port_offloads = dev_info.rx_offload_capa ^ queue_offloads; 18216 18217 printf("Rx Offloading Capabilities of port %d :\n", port_id); 18218 printf(" Per Queue :"); 18219 print_rx_offloads(queue_offloads); 18220 18221 printf("\n"); 18222 printf(" Per Port :"); 18223 print_rx_offloads(port_offloads); 18224 printf("\n\n"); 18225 } 18226 18227 cmdline_parse_inst_t cmd_rx_offload_get_capa = { 18228 .f = cmd_rx_offload_get_capa_parsed, 18229 .data = NULL, 18230 .help_str = "show port <port_id> rx_offload capabilities", 18231 .tokens = { 18232 (void *)&cmd_rx_offload_get_capa_show, 18233 (void *)&cmd_rx_offload_get_capa_port, 18234 (void *)&cmd_rx_offload_get_capa_port_id, 18235 (void *)&cmd_rx_offload_get_capa_rx_offload, 18236 (void *)&cmd_rx_offload_get_capa_capabilities, 18237 NULL, 18238 } 18239 }; 18240 18241 /* Get Rx offloads configuration */ 18242 struct cmd_rx_offload_get_configuration_result { 18243 cmdline_fixed_string_t show; 18244 cmdline_fixed_string_t port; 18245 portid_t port_id; 18246 cmdline_fixed_string_t rx_offload; 18247 cmdline_fixed_string_t configuration; 18248 }; 18249 18250 cmdline_parse_token_string_t cmd_rx_offload_get_configuration_show = 18251 TOKEN_STRING_INITIALIZER 18252 (struct cmd_rx_offload_get_configuration_result, 18253 show, "show"); 18254 cmdline_parse_token_string_t cmd_rx_offload_get_configuration_port = 18255 TOKEN_STRING_INITIALIZER 18256 (struct cmd_rx_offload_get_configuration_result, 18257 port, "port"); 18258 cmdline_parse_token_num_t cmd_rx_offload_get_configuration_port_id = 18259 TOKEN_NUM_INITIALIZER 18260 (struct cmd_rx_offload_get_configuration_result, 18261 port_id, UINT16); 18262 cmdline_parse_token_string_t cmd_rx_offload_get_configuration_rx_offload = 18263 TOKEN_STRING_INITIALIZER 18264 (struct cmd_rx_offload_get_configuration_result, 18265 rx_offload, "rx_offload"); 18266 cmdline_parse_token_string_t cmd_rx_offload_get_configuration_configuration = 18267 TOKEN_STRING_INITIALIZER 18268 (struct cmd_rx_offload_get_configuration_result, 18269 configuration, "configuration"); 18270 18271 static void 18272 cmd_rx_offload_get_configuration_parsed( 18273 void *parsed_result, 18274 __rte_unused struct cmdline *cl, 18275 __rte_unused void *data) 18276 { 18277 struct cmd_rx_offload_get_configuration_result *res = parsed_result; 18278 struct rte_eth_dev_info dev_info; 18279 portid_t port_id = res->port_id; 18280 struct rte_port *port = &ports[port_id]; 18281 uint64_t port_offloads; 18282 uint64_t queue_offloads; 18283 uint16_t nb_rx_queues; 18284 int q; 18285 int ret; 18286 18287 printf("Rx Offloading Configuration of port %d :\n", port_id); 18288 18289 port_offloads = port->dev_conf.rxmode.offloads; 18290 printf(" Port :"); 18291 print_rx_offloads(port_offloads); 18292 printf("\n"); 18293 18294 ret = eth_dev_info_get_print_err(port_id, &dev_info); 18295 if (ret != 0) 18296 return; 18297 18298 nb_rx_queues = dev_info.nb_rx_queues; 18299 for (q = 0; q < nb_rx_queues; q++) { 18300 queue_offloads = port->rx_conf[q].offloads; 18301 printf(" Queue[%2d] :", q); 18302 print_rx_offloads(queue_offloads); 18303 printf("\n"); 18304 } 18305 printf("\n"); 18306 } 18307 18308 cmdline_parse_inst_t cmd_rx_offload_get_configuration = { 18309 .f = cmd_rx_offload_get_configuration_parsed, 18310 .data = NULL, 18311 .help_str = "show port <port_id> rx_offload configuration", 18312 .tokens = { 18313 (void *)&cmd_rx_offload_get_configuration_show, 18314 (void *)&cmd_rx_offload_get_configuration_port, 18315 (void *)&cmd_rx_offload_get_configuration_port_id, 18316 (void *)&cmd_rx_offload_get_configuration_rx_offload, 18317 (void *)&cmd_rx_offload_get_configuration_configuration, 18318 NULL, 18319 } 18320 }; 18321 18322 /* Enable/Disable a per port offloading */ 18323 struct cmd_config_per_port_rx_offload_result { 18324 cmdline_fixed_string_t port; 18325 cmdline_fixed_string_t config; 18326 portid_t port_id; 18327 cmdline_fixed_string_t rx_offload; 18328 cmdline_fixed_string_t offload; 18329 cmdline_fixed_string_t on_off; 18330 }; 18331 18332 cmdline_parse_token_string_t cmd_config_per_port_rx_offload_result_port = 18333 TOKEN_STRING_INITIALIZER 18334 (struct cmd_config_per_port_rx_offload_result, 18335 port, "port"); 18336 cmdline_parse_token_string_t cmd_config_per_port_rx_offload_result_config = 18337 TOKEN_STRING_INITIALIZER 18338 (struct cmd_config_per_port_rx_offload_result, 18339 config, "config"); 18340 cmdline_parse_token_num_t cmd_config_per_port_rx_offload_result_port_id = 18341 TOKEN_NUM_INITIALIZER 18342 (struct cmd_config_per_port_rx_offload_result, 18343 port_id, UINT16); 18344 cmdline_parse_token_string_t cmd_config_per_port_rx_offload_result_rx_offload = 18345 TOKEN_STRING_INITIALIZER 18346 (struct cmd_config_per_port_rx_offload_result, 18347 rx_offload, "rx_offload"); 18348 cmdline_parse_token_string_t cmd_config_per_port_rx_offload_result_offload = 18349 TOKEN_STRING_INITIALIZER 18350 (struct cmd_config_per_port_rx_offload_result, 18351 offload, "vlan_strip#ipv4_cksum#udp_cksum#tcp_cksum#tcp_lro#" 18352 "qinq_strip#outer_ipv4_cksum#macsec_strip#" 18353 "header_split#vlan_filter#vlan_extend#jumbo_frame#" 18354 "scatter#timestamp#security#keep_crc#rss_hash"); 18355 cmdline_parse_token_string_t cmd_config_per_port_rx_offload_result_on_off = 18356 TOKEN_STRING_INITIALIZER 18357 (struct cmd_config_per_port_rx_offload_result, 18358 on_off, "on#off"); 18359 18360 static uint64_t 18361 search_rx_offload(const char *name) 18362 { 18363 uint64_t single_offload; 18364 const char *single_name; 18365 int found = 0; 18366 unsigned int bit; 18367 18368 single_offload = 1; 18369 for (bit = 0; bit < sizeof(single_offload) * CHAR_BIT; bit++) { 18370 single_name = rte_eth_dev_rx_offload_name(single_offload); 18371 if (!strcasecmp(single_name, name)) { 18372 found = 1; 18373 break; 18374 } 18375 single_offload <<= 1; 18376 } 18377 18378 if (found) 18379 return single_offload; 18380 18381 return 0; 18382 } 18383 18384 static void 18385 cmd_config_per_port_rx_offload_parsed(void *parsed_result, 18386 __rte_unused struct cmdline *cl, 18387 __rte_unused void *data) 18388 { 18389 struct cmd_config_per_port_rx_offload_result *res = parsed_result; 18390 portid_t port_id = res->port_id; 18391 struct rte_eth_dev_info dev_info; 18392 struct rte_port *port = &ports[port_id]; 18393 uint64_t single_offload; 18394 uint16_t nb_rx_queues; 18395 int q; 18396 int ret; 18397 18398 if (port->port_status != RTE_PORT_STOPPED) { 18399 printf("Error: Can't config offload when Port %d " 18400 "is not stopped\n", port_id); 18401 return; 18402 } 18403 18404 single_offload = search_rx_offload(res->offload); 18405 if (single_offload == 0) { 18406 printf("Unknown offload name: %s\n", res->offload); 18407 return; 18408 } 18409 18410 ret = eth_dev_info_get_print_err(port_id, &dev_info); 18411 if (ret != 0) 18412 return; 18413 18414 nb_rx_queues = dev_info.nb_rx_queues; 18415 if (!strcmp(res->on_off, "on")) { 18416 port->dev_conf.rxmode.offloads |= single_offload; 18417 for (q = 0; q < nb_rx_queues; q++) 18418 port->rx_conf[q].offloads |= single_offload; 18419 } else { 18420 port->dev_conf.rxmode.offloads &= ~single_offload; 18421 for (q = 0; q < nb_rx_queues; q++) 18422 port->rx_conf[q].offloads &= ~single_offload; 18423 } 18424 18425 cmd_reconfig_device_queue(port_id, 1, 1); 18426 } 18427 18428 cmdline_parse_inst_t cmd_config_per_port_rx_offload = { 18429 .f = cmd_config_per_port_rx_offload_parsed, 18430 .data = NULL, 18431 .help_str = "port config <port_id> rx_offload vlan_strip|ipv4_cksum|" 18432 "udp_cksum|tcp_cksum|tcp_lro|qinq_strip|outer_ipv4_cksum|" 18433 "macsec_strip|header_split|vlan_filter|vlan_extend|" 18434 "jumbo_frame|scatter|timestamp|security|keep_crc|rss_hash " 18435 "on|off", 18436 .tokens = { 18437 (void *)&cmd_config_per_port_rx_offload_result_port, 18438 (void *)&cmd_config_per_port_rx_offload_result_config, 18439 (void *)&cmd_config_per_port_rx_offload_result_port_id, 18440 (void *)&cmd_config_per_port_rx_offload_result_rx_offload, 18441 (void *)&cmd_config_per_port_rx_offload_result_offload, 18442 (void *)&cmd_config_per_port_rx_offload_result_on_off, 18443 NULL, 18444 } 18445 }; 18446 18447 /* Enable/Disable a per queue offloading */ 18448 struct cmd_config_per_queue_rx_offload_result { 18449 cmdline_fixed_string_t port; 18450 portid_t port_id; 18451 cmdline_fixed_string_t rxq; 18452 uint16_t queue_id; 18453 cmdline_fixed_string_t rx_offload; 18454 cmdline_fixed_string_t offload; 18455 cmdline_fixed_string_t on_off; 18456 }; 18457 18458 cmdline_parse_token_string_t cmd_config_per_queue_rx_offload_result_port = 18459 TOKEN_STRING_INITIALIZER 18460 (struct cmd_config_per_queue_rx_offload_result, 18461 port, "port"); 18462 cmdline_parse_token_num_t cmd_config_per_queue_rx_offload_result_port_id = 18463 TOKEN_NUM_INITIALIZER 18464 (struct cmd_config_per_queue_rx_offload_result, 18465 port_id, UINT16); 18466 cmdline_parse_token_string_t cmd_config_per_queue_rx_offload_result_rxq = 18467 TOKEN_STRING_INITIALIZER 18468 (struct cmd_config_per_queue_rx_offload_result, 18469 rxq, "rxq"); 18470 cmdline_parse_token_num_t cmd_config_per_queue_rx_offload_result_queue_id = 18471 TOKEN_NUM_INITIALIZER 18472 (struct cmd_config_per_queue_rx_offload_result, 18473 queue_id, UINT16); 18474 cmdline_parse_token_string_t cmd_config_per_queue_rx_offload_result_rxoffload = 18475 TOKEN_STRING_INITIALIZER 18476 (struct cmd_config_per_queue_rx_offload_result, 18477 rx_offload, "rx_offload"); 18478 cmdline_parse_token_string_t cmd_config_per_queue_rx_offload_result_offload = 18479 TOKEN_STRING_INITIALIZER 18480 (struct cmd_config_per_queue_rx_offload_result, 18481 offload, "vlan_strip#ipv4_cksum#udp_cksum#tcp_cksum#tcp_lro#" 18482 "qinq_strip#outer_ipv4_cksum#macsec_strip#" 18483 "header_split#vlan_filter#vlan_extend#jumbo_frame#" 18484 "scatter#timestamp#security#keep_crc"); 18485 cmdline_parse_token_string_t cmd_config_per_queue_rx_offload_result_on_off = 18486 TOKEN_STRING_INITIALIZER 18487 (struct cmd_config_per_queue_rx_offload_result, 18488 on_off, "on#off"); 18489 18490 static void 18491 cmd_config_per_queue_rx_offload_parsed(void *parsed_result, 18492 __rte_unused struct cmdline *cl, 18493 __rte_unused void *data) 18494 { 18495 struct cmd_config_per_queue_rx_offload_result *res = parsed_result; 18496 struct rte_eth_dev_info dev_info; 18497 portid_t port_id = res->port_id; 18498 uint16_t queue_id = res->queue_id; 18499 struct rte_port *port = &ports[port_id]; 18500 uint64_t single_offload; 18501 int ret; 18502 18503 if (port->port_status != RTE_PORT_STOPPED) { 18504 printf("Error: Can't config offload when Port %d " 18505 "is not stopped\n", port_id); 18506 return; 18507 } 18508 18509 ret = eth_dev_info_get_print_err(port_id, &dev_info); 18510 if (ret != 0) 18511 return; 18512 18513 if (queue_id >= dev_info.nb_rx_queues) { 18514 printf("Error: input queue_id should be 0 ... " 18515 "%d\n", dev_info.nb_rx_queues - 1); 18516 return; 18517 } 18518 18519 single_offload = search_rx_offload(res->offload); 18520 if (single_offload == 0) { 18521 printf("Unknown offload name: %s\n", res->offload); 18522 return; 18523 } 18524 18525 if (!strcmp(res->on_off, "on")) 18526 port->rx_conf[queue_id].offloads |= single_offload; 18527 else 18528 port->rx_conf[queue_id].offloads &= ~single_offload; 18529 18530 cmd_reconfig_device_queue(port_id, 1, 1); 18531 } 18532 18533 cmdline_parse_inst_t cmd_config_per_queue_rx_offload = { 18534 .f = cmd_config_per_queue_rx_offload_parsed, 18535 .data = NULL, 18536 .help_str = "port <port_id> rxq <queue_id> rx_offload " 18537 "vlan_strip|ipv4_cksum|" 18538 "udp_cksum|tcp_cksum|tcp_lro|qinq_strip|outer_ipv4_cksum|" 18539 "macsec_strip|header_split|vlan_filter|vlan_extend|" 18540 "jumbo_frame|scatter|timestamp|security|keep_crc " 18541 "on|off", 18542 .tokens = { 18543 (void *)&cmd_config_per_queue_rx_offload_result_port, 18544 (void *)&cmd_config_per_queue_rx_offload_result_port_id, 18545 (void *)&cmd_config_per_queue_rx_offload_result_rxq, 18546 (void *)&cmd_config_per_queue_rx_offload_result_queue_id, 18547 (void *)&cmd_config_per_queue_rx_offload_result_rxoffload, 18548 (void *)&cmd_config_per_queue_rx_offload_result_offload, 18549 (void *)&cmd_config_per_queue_rx_offload_result_on_off, 18550 NULL, 18551 } 18552 }; 18553 18554 /* Get Tx offloads capabilities */ 18555 struct cmd_tx_offload_get_capa_result { 18556 cmdline_fixed_string_t show; 18557 cmdline_fixed_string_t port; 18558 portid_t port_id; 18559 cmdline_fixed_string_t tx_offload; 18560 cmdline_fixed_string_t capabilities; 18561 }; 18562 18563 cmdline_parse_token_string_t cmd_tx_offload_get_capa_show = 18564 TOKEN_STRING_INITIALIZER 18565 (struct cmd_tx_offload_get_capa_result, 18566 show, "show"); 18567 cmdline_parse_token_string_t cmd_tx_offload_get_capa_port = 18568 TOKEN_STRING_INITIALIZER 18569 (struct cmd_tx_offload_get_capa_result, 18570 port, "port"); 18571 cmdline_parse_token_num_t cmd_tx_offload_get_capa_port_id = 18572 TOKEN_NUM_INITIALIZER 18573 (struct cmd_tx_offload_get_capa_result, 18574 port_id, UINT16); 18575 cmdline_parse_token_string_t cmd_tx_offload_get_capa_tx_offload = 18576 TOKEN_STRING_INITIALIZER 18577 (struct cmd_tx_offload_get_capa_result, 18578 tx_offload, "tx_offload"); 18579 cmdline_parse_token_string_t cmd_tx_offload_get_capa_capabilities = 18580 TOKEN_STRING_INITIALIZER 18581 (struct cmd_tx_offload_get_capa_result, 18582 capabilities, "capabilities"); 18583 18584 static void 18585 print_tx_offloads(uint64_t offloads) 18586 { 18587 uint64_t single_offload; 18588 int begin; 18589 int end; 18590 int bit; 18591 18592 if (offloads == 0) 18593 return; 18594 18595 begin = __builtin_ctzll(offloads); 18596 end = sizeof(offloads) * CHAR_BIT - __builtin_clzll(offloads); 18597 18598 single_offload = 1ULL << begin; 18599 for (bit = begin; bit < end; bit++) { 18600 if (offloads & single_offload) 18601 printf(" %s", 18602 rte_eth_dev_tx_offload_name(single_offload)); 18603 single_offload <<= 1; 18604 } 18605 } 18606 18607 static void 18608 cmd_tx_offload_get_capa_parsed( 18609 void *parsed_result, 18610 __rte_unused struct cmdline *cl, 18611 __rte_unused void *data) 18612 { 18613 struct cmd_tx_offload_get_capa_result *res = parsed_result; 18614 struct rte_eth_dev_info dev_info; 18615 portid_t port_id = res->port_id; 18616 uint64_t queue_offloads; 18617 uint64_t port_offloads; 18618 int ret; 18619 18620 ret = eth_dev_info_get_print_err(port_id, &dev_info); 18621 if (ret != 0) 18622 return; 18623 18624 queue_offloads = dev_info.tx_queue_offload_capa; 18625 port_offloads = dev_info.tx_offload_capa ^ queue_offloads; 18626 18627 printf("Tx Offloading Capabilities of port %d :\n", port_id); 18628 printf(" Per Queue :"); 18629 print_tx_offloads(queue_offloads); 18630 18631 printf("\n"); 18632 printf(" Per Port :"); 18633 print_tx_offloads(port_offloads); 18634 printf("\n\n"); 18635 } 18636 18637 cmdline_parse_inst_t cmd_tx_offload_get_capa = { 18638 .f = cmd_tx_offload_get_capa_parsed, 18639 .data = NULL, 18640 .help_str = "show port <port_id> tx_offload capabilities", 18641 .tokens = { 18642 (void *)&cmd_tx_offload_get_capa_show, 18643 (void *)&cmd_tx_offload_get_capa_port, 18644 (void *)&cmd_tx_offload_get_capa_port_id, 18645 (void *)&cmd_tx_offload_get_capa_tx_offload, 18646 (void *)&cmd_tx_offload_get_capa_capabilities, 18647 NULL, 18648 } 18649 }; 18650 18651 /* Get Tx offloads configuration */ 18652 struct cmd_tx_offload_get_configuration_result { 18653 cmdline_fixed_string_t show; 18654 cmdline_fixed_string_t port; 18655 portid_t port_id; 18656 cmdline_fixed_string_t tx_offload; 18657 cmdline_fixed_string_t configuration; 18658 }; 18659 18660 cmdline_parse_token_string_t cmd_tx_offload_get_configuration_show = 18661 TOKEN_STRING_INITIALIZER 18662 (struct cmd_tx_offload_get_configuration_result, 18663 show, "show"); 18664 cmdline_parse_token_string_t cmd_tx_offload_get_configuration_port = 18665 TOKEN_STRING_INITIALIZER 18666 (struct cmd_tx_offload_get_configuration_result, 18667 port, "port"); 18668 cmdline_parse_token_num_t cmd_tx_offload_get_configuration_port_id = 18669 TOKEN_NUM_INITIALIZER 18670 (struct cmd_tx_offload_get_configuration_result, 18671 port_id, UINT16); 18672 cmdline_parse_token_string_t cmd_tx_offload_get_configuration_tx_offload = 18673 TOKEN_STRING_INITIALIZER 18674 (struct cmd_tx_offload_get_configuration_result, 18675 tx_offload, "tx_offload"); 18676 cmdline_parse_token_string_t cmd_tx_offload_get_configuration_configuration = 18677 TOKEN_STRING_INITIALIZER 18678 (struct cmd_tx_offload_get_configuration_result, 18679 configuration, "configuration"); 18680 18681 static void 18682 cmd_tx_offload_get_configuration_parsed( 18683 void *parsed_result, 18684 __rte_unused struct cmdline *cl, 18685 __rte_unused void *data) 18686 { 18687 struct cmd_tx_offload_get_configuration_result *res = parsed_result; 18688 struct rte_eth_dev_info dev_info; 18689 portid_t port_id = res->port_id; 18690 struct rte_port *port = &ports[port_id]; 18691 uint64_t port_offloads; 18692 uint64_t queue_offloads; 18693 uint16_t nb_tx_queues; 18694 int q; 18695 int ret; 18696 18697 printf("Tx Offloading Configuration of port %d :\n", port_id); 18698 18699 port_offloads = port->dev_conf.txmode.offloads; 18700 printf(" Port :"); 18701 print_tx_offloads(port_offloads); 18702 printf("\n"); 18703 18704 ret = eth_dev_info_get_print_err(port_id, &dev_info); 18705 if (ret != 0) 18706 return; 18707 18708 nb_tx_queues = dev_info.nb_tx_queues; 18709 for (q = 0; q < nb_tx_queues; q++) { 18710 queue_offloads = port->tx_conf[q].offloads; 18711 printf(" Queue[%2d] :", q); 18712 print_tx_offloads(queue_offloads); 18713 printf("\n"); 18714 } 18715 printf("\n"); 18716 } 18717 18718 cmdline_parse_inst_t cmd_tx_offload_get_configuration = { 18719 .f = cmd_tx_offload_get_configuration_parsed, 18720 .data = NULL, 18721 .help_str = "show port <port_id> tx_offload configuration", 18722 .tokens = { 18723 (void *)&cmd_tx_offload_get_configuration_show, 18724 (void *)&cmd_tx_offload_get_configuration_port, 18725 (void *)&cmd_tx_offload_get_configuration_port_id, 18726 (void *)&cmd_tx_offload_get_configuration_tx_offload, 18727 (void *)&cmd_tx_offload_get_configuration_configuration, 18728 NULL, 18729 } 18730 }; 18731 18732 /* Enable/Disable a per port offloading */ 18733 struct cmd_config_per_port_tx_offload_result { 18734 cmdline_fixed_string_t port; 18735 cmdline_fixed_string_t config; 18736 portid_t port_id; 18737 cmdline_fixed_string_t tx_offload; 18738 cmdline_fixed_string_t offload; 18739 cmdline_fixed_string_t on_off; 18740 }; 18741 18742 cmdline_parse_token_string_t cmd_config_per_port_tx_offload_result_port = 18743 TOKEN_STRING_INITIALIZER 18744 (struct cmd_config_per_port_tx_offload_result, 18745 port, "port"); 18746 cmdline_parse_token_string_t cmd_config_per_port_tx_offload_result_config = 18747 TOKEN_STRING_INITIALIZER 18748 (struct cmd_config_per_port_tx_offload_result, 18749 config, "config"); 18750 cmdline_parse_token_num_t cmd_config_per_port_tx_offload_result_port_id = 18751 TOKEN_NUM_INITIALIZER 18752 (struct cmd_config_per_port_tx_offload_result, 18753 port_id, UINT16); 18754 cmdline_parse_token_string_t cmd_config_per_port_tx_offload_result_tx_offload = 18755 TOKEN_STRING_INITIALIZER 18756 (struct cmd_config_per_port_tx_offload_result, 18757 tx_offload, "tx_offload"); 18758 cmdline_parse_token_string_t cmd_config_per_port_tx_offload_result_offload = 18759 TOKEN_STRING_INITIALIZER 18760 (struct cmd_config_per_port_tx_offload_result, 18761 offload, "vlan_insert#ipv4_cksum#udp_cksum#tcp_cksum#" 18762 "sctp_cksum#tcp_tso#udp_tso#outer_ipv4_cksum#" 18763 "qinq_insert#vxlan_tnl_tso#gre_tnl_tso#" 18764 "ipip_tnl_tso#geneve_tnl_tso#macsec_insert#" 18765 "mt_lockfree#multi_segs#mbuf_fast_free#security#" 18766 "send_on_timestamp"); 18767 cmdline_parse_token_string_t cmd_config_per_port_tx_offload_result_on_off = 18768 TOKEN_STRING_INITIALIZER 18769 (struct cmd_config_per_port_tx_offload_result, 18770 on_off, "on#off"); 18771 18772 static uint64_t 18773 search_tx_offload(const char *name) 18774 { 18775 uint64_t single_offload; 18776 const char *single_name; 18777 int found = 0; 18778 unsigned int bit; 18779 18780 single_offload = 1; 18781 for (bit = 0; bit < sizeof(single_offload) * CHAR_BIT; bit++) { 18782 single_name = rte_eth_dev_tx_offload_name(single_offload); 18783 if (single_name == NULL) 18784 break; 18785 if (!strcasecmp(single_name, name)) { 18786 found = 1; 18787 break; 18788 } else if (!strcasecmp(single_name, "UNKNOWN")) 18789 break; 18790 single_offload <<= 1; 18791 } 18792 18793 if (found) 18794 return single_offload; 18795 18796 return 0; 18797 } 18798 18799 static void 18800 cmd_config_per_port_tx_offload_parsed(void *parsed_result, 18801 __rte_unused struct cmdline *cl, 18802 __rte_unused void *data) 18803 { 18804 struct cmd_config_per_port_tx_offload_result *res = parsed_result; 18805 portid_t port_id = res->port_id; 18806 struct rte_eth_dev_info dev_info; 18807 struct rte_port *port = &ports[port_id]; 18808 uint64_t single_offload; 18809 uint16_t nb_tx_queues; 18810 int q; 18811 int ret; 18812 18813 if (port->port_status != RTE_PORT_STOPPED) { 18814 printf("Error: Can't config offload when Port %d " 18815 "is not stopped\n", port_id); 18816 return; 18817 } 18818 18819 single_offload = search_tx_offload(res->offload); 18820 if (single_offload == 0) { 18821 printf("Unknown offload name: %s\n", res->offload); 18822 return; 18823 } 18824 18825 ret = eth_dev_info_get_print_err(port_id, &dev_info); 18826 if (ret != 0) 18827 return; 18828 18829 nb_tx_queues = dev_info.nb_tx_queues; 18830 if (!strcmp(res->on_off, "on")) { 18831 port->dev_conf.txmode.offloads |= single_offload; 18832 for (q = 0; q < nb_tx_queues; q++) 18833 port->tx_conf[q].offloads |= single_offload; 18834 } else { 18835 port->dev_conf.txmode.offloads &= ~single_offload; 18836 for (q = 0; q < nb_tx_queues; q++) 18837 port->tx_conf[q].offloads &= ~single_offload; 18838 } 18839 18840 cmd_reconfig_device_queue(port_id, 1, 1); 18841 } 18842 18843 cmdline_parse_inst_t cmd_config_per_port_tx_offload = { 18844 .f = cmd_config_per_port_tx_offload_parsed, 18845 .data = NULL, 18846 .help_str = "port config <port_id> tx_offload " 18847 "vlan_insert|ipv4_cksum|udp_cksum|tcp_cksum|" 18848 "sctp_cksum|tcp_tso|udp_tso|outer_ipv4_cksum|" 18849 "qinq_insert|vxlan_tnl_tso|gre_tnl_tso|" 18850 "ipip_tnl_tso|geneve_tnl_tso|macsec_insert|" 18851 "mt_lockfree|multi_segs|mbuf_fast_free|security|" 18852 "send_on_timestamp on|off", 18853 .tokens = { 18854 (void *)&cmd_config_per_port_tx_offload_result_port, 18855 (void *)&cmd_config_per_port_tx_offload_result_config, 18856 (void *)&cmd_config_per_port_tx_offload_result_port_id, 18857 (void *)&cmd_config_per_port_tx_offload_result_tx_offload, 18858 (void *)&cmd_config_per_port_tx_offload_result_offload, 18859 (void *)&cmd_config_per_port_tx_offload_result_on_off, 18860 NULL, 18861 } 18862 }; 18863 18864 /* Enable/Disable a per queue offloading */ 18865 struct cmd_config_per_queue_tx_offload_result { 18866 cmdline_fixed_string_t port; 18867 portid_t port_id; 18868 cmdline_fixed_string_t txq; 18869 uint16_t queue_id; 18870 cmdline_fixed_string_t tx_offload; 18871 cmdline_fixed_string_t offload; 18872 cmdline_fixed_string_t on_off; 18873 }; 18874 18875 cmdline_parse_token_string_t cmd_config_per_queue_tx_offload_result_port = 18876 TOKEN_STRING_INITIALIZER 18877 (struct cmd_config_per_queue_tx_offload_result, 18878 port, "port"); 18879 cmdline_parse_token_num_t cmd_config_per_queue_tx_offload_result_port_id = 18880 TOKEN_NUM_INITIALIZER 18881 (struct cmd_config_per_queue_tx_offload_result, 18882 port_id, UINT16); 18883 cmdline_parse_token_string_t cmd_config_per_queue_tx_offload_result_txq = 18884 TOKEN_STRING_INITIALIZER 18885 (struct cmd_config_per_queue_tx_offload_result, 18886 txq, "txq"); 18887 cmdline_parse_token_num_t cmd_config_per_queue_tx_offload_result_queue_id = 18888 TOKEN_NUM_INITIALIZER 18889 (struct cmd_config_per_queue_tx_offload_result, 18890 queue_id, UINT16); 18891 cmdline_parse_token_string_t cmd_config_per_queue_tx_offload_result_txoffload = 18892 TOKEN_STRING_INITIALIZER 18893 (struct cmd_config_per_queue_tx_offload_result, 18894 tx_offload, "tx_offload"); 18895 cmdline_parse_token_string_t cmd_config_per_queue_tx_offload_result_offload = 18896 TOKEN_STRING_INITIALIZER 18897 (struct cmd_config_per_queue_tx_offload_result, 18898 offload, "vlan_insert#ipv4_cksum#udp_cksum#tcp_cksum#" 18899 "sctp_cksum#tcp_tso#udp_tso#outer_ipv4_cksum#" 18900 "qinq_insert#vxlan_tnl_tso#gre_tnl_tso#" 18901 "ipip_tnl_tso#geneve_tnl_tso#macsec_insert#" 18902 "mt_lockfree#multi_segs#mbuf_fast_free#security"); 18903 cmdline_parse_token_string_t cmd_config_per_queue_tx_offload_result_on_off = 18904 TOKEN_STRING_INITIALIZER 18905 (struct cmd_config_per_queue_tx_offload_result, 18906 on_off, "on#off"); 18907 18908 static void 18909 cmd_config_per_queue_tx_offload_parsed(void *parsed_result, 18910 __rte_unused struct cmdline *cl, 18911 __rte_unused void *data) 18912 { 18913 struct cmd_config_per_queue_tx_offload_result *res = parsed_result; 18914 struct rte_eth_dev_info dev_info; 18915 portid_t port_id = res->port_id; 18916 uint16_t queue_id = res->queue_id; 18917 struct rte_port *port = &ports[port_id]; 18918 uint64_t single_offload; 18919 int ret; 18920 18921 if (port->port_status != RTE_PORT_STOPPED) { 18922 printf("Error: Can't config offload when Port %d " 18923 "is not stopped\n", port_id); 18924 return; 18925 } 18926 18927 ret = eth_dev_info_get_print_err(port_id, &dev_info); 18928 if (ret != 0) 18929 return; 18930 18931 if (queue_id >= dev_info.nb_tx_queues) { 18932 printf("Error: input queue_id should be 0 ... " 18933 "%d\n", dev_info.nb_tx_queues - 1); 18934 return; 18935 } 18936 18937 single_offload = search_tx_offload(res->offload); 18938 if (single_offload == 0) { 18939 printf("Unknown offload name: %s\n", res->offload); 18940 return; 18941 } 18942 18943 if (!strcmp(res->on_off, "on")) 18944 port->tx_conf[queue_id].offloads |= single_offload; 18945 else 18946 port->tx_conf[queue_id].offloads &= ~single_offload; 18947 18948 cmd_reconfig_device_queue(port_id, 1, 1); 18949 } 18950 18951 cmdline_parse_inst_t cmd_config_per_queue_tx_offload = { 18952 .f = cmd_config_per_queue_tx_offload_parsed, 18953 .data = NULL, 18954 .help_str = "port <port_id> txq <queue_id> tx_offload " 18955 "vlan_insert|ipv4_cksum|udp_cksum|tcp_cksum|" 18956 "sctp_cksum|tcp_tso|udp_tso|outer_ipv4_cksum|" 18957 "qinq_insert|vxlan_tnl_tso|gre_tnl_tso|" 18958 "ipip_tnl_tso|geneve_tnl_tso|macsec_insert|" 18959 "mt_lockfree|multi_segs|mbuf_fast_free|security " 18960 "on|off", 18961 .tokens = { 18962 (void *)&cmd_config_per_queue_tx_offload_result_port, 18963 (void *)&cmd_config_per_queue_tx_offload_result_port_id, 18964 (void *)&cmd_config_per_queue_tx_offload_result_txq, 18965 (void *)&cmd_config_per_queue_tx_offload_result_queue_id, 18966 (void *)&cmd_config_per_queue_tx_offload_result_txoffload, 18967 (void *)&cmd_config_per_queue_tx_offload_result_offload, 18968 (void *)&cmd_config_per_queue_tx_offload_result_on_off, 18969 NULL, 18970 } 18971 }; 18972 18973 /* *** configure tx_metadata for specific port *** */ 18974 struct cmd_config_tx_metadata_specific_result { 18975 cmdline_fixed_string_t port; 18976 cmdline_fixed_string_t keyword; 18977 uint16_t port_id; 18978 cmdline_fixed_string_t item; 18979 uint32_t value; 18980 }; 18981 18982 static void 18983 cmd_config_tx_metadata_specific_parsed(void *parsed_result, 18984 __rte_unused struct cmdline *cl, 18985 __rte_unused void *data) 18986 { 18987 struct cmd_config_tx_metadata_specific_result *res = parsed_result; 18988 18989 if (port_id_is_invalid(res->port_id, ENABLED_WARN)) 18990 return; 18991 ports[res->port_id].tx_metadata = res->value; 18992 /* Add/remove callback to insert valid metadata in every Tx packet. */ 18993 if (ports[res->port_id].tx_metadata) 18994 add_tx_md_callback(res->port_id); 18995 else 18996 remove_tx_md_callback(res->port_id); 18997 rte_flow_dynf_metadata_register(); 18998 } 18999 19000 cmdline_parse_token_string_t cmd_config_tx_metadata_specific_port = 19001 TOKEN_STRING_INITIALIZER(struct cmd_config_tx_metadata_specific_result, 19002 port, "port"); 19003 cmdline_parse_token_string_t cmd_config_tx_metadata_specific_keyword = 19004 TOKEN_STRING_INITIALIZER(struct cmd_config_tx_metadata_specific_result, 19005 keyword, "config"); 19006 cmdline_parse_token_num_t cmd_config_tx_metadata_specific_id = 19007 TOKEN_NUM_INITIALIZER(struct cmd_config_tx_metadata_specific_result, 19008 port_id, UINT16); 19009 cmdline_parse_token_string_t cmd_config_tx_metadata_specific_item = 19010 TOKEN_STRING_INITIALIZER(struct cmd_config_tx_metadata_specific_result, 19011 item, "tx_metadata"); 19012 cmdline_parse_token_num_t cmd_config_tx_metadata_specific_value = 19013 TOKEN_NUM_INITIALIZER(struct cmd_config_tx_metadata_specific_result, 19014 value, UINT32); 19015 19016 cmdline_parse_inst_t cmd_config_tx_metadata_specific = { 19017 .f = cmd_config_tx_metadata_specific_parsed, 19018 .data = NULL, 19019 .help_str = "port config <port_id> tx_metadata <value>", 19020 .tokens = { 19021 (void *)&cmd_config_tx_metadata_specific_port, 19022 (void *)&cmd_config_tx_metadata_specific_keyword, 19023 (void *)&cmd_config_tx_metadata_specific_id, 19024 (void *)&cmd_config_tx_metadata_specific_item, 19025 (void *)&cmd_config_tx_metadata_specific_value, 19026 NULL, 19027 }, 19028 }; 19029 19030 /* *** set dynf *** */ 19031 struct cmd_config_tx_dynf_specific_result { 19032 cmdline_fixed_string_t port; 19033 cmdline_fixed_string_t keyword; 19034 uint16_t port_id; 19035 cmdline_fixed_string_t item; 19036 cmdline_fixed_string_t name; 19037 cmdline_fixed_string_t value; 19038 }; 19039 19040 static void 19041 cmd_config_dynf_specific_parsed(void *parsed_result, 19042 __rte_unused struct cmdline *cl, 19043 __rte_unused void *data) 19044 { 19045 struct cmd_config_tx_dynf_specific_result *res = parsed_result; 19046 struct rte_mbuf_dynflag desc_flag; 19047 int flag; 19048 uint64_t old_port_flags; 19049 19050 if (port_id_is_invalid(res->port_id, ENABLED_WARN)) 19051 return; 19052 flag = rte_mbuf_dynflag_lookup(res->name, NULL); 19053 if (flag <= 0) { 19054 if (strlcpy(desc_flag.name, res->name, 19055 RTE_MBUF_DYN_NAMESIZE) >= RTE_MBUF_DYN_NAMESIZE) { 19056 printf("Flag name too long\n"); 19057 return; 19058 } 19059 desc_flag.flags = 0; 19060 flag = rte_mbuf_dynflag_register(&desc_flag); 19061 if (flag < 0) { 19062 printf("Can't register flag\n"); 19063 return; 19064 } 19065 strcpy(dynf_names[flag], desc_flag.name); 19066 } 19067 old_port_flags = ports[res->port_id].mbuf_dynf; 19068 if (!strcmp(res->value, "set")) { 19069 ports[res->port_id].mbuf_dynf |= 1UL << flag; 19070 if (old_port_flags == 0) 19071 add_tx_dynf_callback(res->port_id); 19072 } else { 19073 ports[res->port_id].mbuf_dynf &= ~(1UL << flag); 19074 if (ports[res->port_id].mbuf_dynf == 0) 19075 remove_tx_dynf_callback(res->port_id); 19076 } 19077 } 19078 19079 cmdline_parse_token_string_t cmd_config_tx_dynf_specific_port = 19080 TOKEN_STRING_INITIALIZER(struct cmd_config_tx_dynf_specific_result, 19081 keyword, "port"); 19082 cmdline_parse_token_string_t cmd_config_tx_dynf_specific_keyword = 19083 TOKEN_STRING_INITIALIZER(struct cmd_config_tx_dynf_specific_result, 19084 keyword, "config"); 19085 cmdline_parse_token_num_t cmd_config_tx_dynf_specific_port_id = 19086 TOKEN_NUM_INITIALIZER(struct cmd_config_tx_dynf_specific_result, 19087 port_id, UINT16); 19088 cmdline_parse_token_string_t cmd_config_tx_dynf_specific_item = 19089 TOKEN_STRING_INITIALIZER(struct cmd_config_tx_dynf_specific_result, 19090 item, "dynf"); 19091 cmdline_parse_token_string_t cmd_config_tx_dynf_specific_name = 19092 TOKEN_STRING_INITIALIZER(struct cmd_config_tx_dynf_specific_result, 19093 name, NULL); 19094 cmdline_parse_token_string_t cmd_config_tx_dynf_specific_value = 19095 TOKEN_STRING_INITIALIZER(struct cmd_config_tx_dynf_specific_result, 19096 value, "set#clear"); 19097 19098 cmdline_parse_inst_t cmd_config_tx_dynf_specific = { 19099 .f = cmd_config_dynf_specific_parsed, 19100 .data = NULL, 19101 .help_str = "port config <port id> dynf <name> set|clear", 19102 .tokens = { 19103 (void *)&cmd_config_tx_dynf_specific_port, 19104 (void *)&cmd_config_tx_dynf_specific_keyword, 19105 (void *)&cmd_config_tx_dynf_specific_port_id, 19106 (void *)&cmd_config_tx_dynf_specific_item, 19107 (void *)&cmd_config_tx_dynf_specific_name, 19108 (void *)&cmd_config_tx_dynf_specific_value, 19109 NULL, 19110 }, 19111 }; 19112 19113 /* *** display tx_metadata per port configuration *** */ 19114 struct cmd_show_tx_metadata_result { 19115 cmdline_fixed_string_t cmd_show; 19116 cmdline_fixed_string_t cmd_port; 19117 cmdline_fixed_string_t cmd_keyword; 19118 portid_t cmd_pid; 19119 }; 19120 19121 static void 19122 cmd_show_tx_metadata_parsed(void *parsed_result, 19123 __rte_unused struct cmdline *cl, 19124 __rte_unused void *data) 19125 { 19126 struct cmd_show_tx_metadata_result *res = parsed_result; 19127 19128 if (!rte_eth_dev_is_valid_port(res->cmd_pid)) { 19129 printf("invalid port id %u\n", res->cmd_pid); 19130 return; 19131 } 19132 if (!strcmp(res->cmd_keyword, "tx_metadata")) { 19133 printf("Port %u tx_metadata: %u\n", res->cmd_pid, 19134 ports[res->cmd_pid].tx_metadata); 19135 } 19136 } 19137 19138 cmdline_parse_token_string_t cmd_show_tx_metadata_show = 19139 TOKEN_STRING_INITIALIZER(struct cmd_show_tx_metadata_result, 19140 cmd_show, "show"); 19141 cmdline_parse_token_string_t cmd_show_tx_metadata_port = 19142 TOKEN_STRING_INITIALIZER(struct cmd_show_tx_metadata_result, 19143 cmd_port, "port"); 19144 cmdline_parse_token_num_t cmd_show_tx_metadata_pid = 19145 TOKEN_NUM_INITIALIZER(struct cmd_show_tx_metadata_result, 19146 cmd_pid, UINT16); 19147 cmdline_parse_token_string_t cmd_show_tx_metadata_keyword = 19148 TOKEN_STRING_INITIALIZER(struct cmd_show_tx_metadata_result, 19149 cmd_keyword, "tx_metadata"); 19150 19151 cmdline_parse_inst_t cmd_show_tx_metadata = { 19152 .f = cmd_show_tx_metadata_parsed, 19153 .data = NULL, 19154 .help_str = "show port <port_id> tx_metadata", 19155 .tokens = { 19156 (void *)&cmd_show_tx_metadata_show, 19157 (void *)&cmd_show_tx_metadata_port, 19158 (void *)&cmd_show_tx_metadata_pid, 19159 (void *)&cmd_show_tx_metadata_keyword, 19160 NULL, 19161 }, 19162 }; 19163 19164 /* show port supported ptypes */ 19165 19166 /* Common result structure for show port ptypes */ 19167 struct cmd_show_port_supported_ptypes_result { 19168 cmdline_fixed_string_t show; 19169 cmdline_fixed_string_t port; 19170 portid_t port_id; 19171 cmdline_fixed_string_t ptypes; 19172 }; 19173 19174 /* Common CLI fields for show port ptypes */ 19175 cmdline_parse_token_string_t cmd_show_port_supported_ptypes_show = 19176 TOKEN_STRING_INITIALIZER 19177 (struct cmd_show_port_supported_ptypes_result, 19178 show, "show"); 19179 cmdline_parse_token_string_t cmd_show_port_supported_ptypes_port = 19180 TOKEN_STRING_INITIALIZER 19181 (struct cmd_show_port_supported_ptypes_result, 19182 port, "port"); 19183 cmdline_parse_token_num_t cmd_show_port_supported_ptypes_port_id = 19184 TOKEN_NUM_INITIALIZER 19185 (struct cmd_show_port_supported_ptypes_result, 19186 port_id, UINT16); 19187 cmdline_parse_token_string_t cmd_show_port_supported_ptypes_ptypes = 19188 TOKEN_STRING_INITIALIZER 19189 (struct cmd_show_port_supported_ptypes_result, 19190 ptypes, "ptypes"); 19191 19192 static void 19193 cmd_show_port_supported_ptypes_parsed( 19194 void *parsed_result, 19195 __rte_unused struct cmdline *cl, 19196 __rte_unused void *data) 19197 { 19198 #define RSVD_PTYPE_MASK 0xf0000000 19199 #define MAX_PTYPES_PER_LAYER 16 19200 #define LTYPE_NAMESIZE 32 19201 #define PTYPE_NAMESIZE 256 19202 struct cmd_show_port_supported_ptypes_result *res = parsed_result; 19203 char buf[PTYPE_NAMESIZE], ltype[LTYPE_NAMESIZE]; 19204 uint32_t ptype_mask = RTE_PTYPE_L2_MASK; 19205 uint32_t ptypes[MAX_PTYPES_PER_LAYER]; 19206 uint16_t port_id = res->port_id; 19207 int ret, i; 19208 19209 ret = rte_eth_dev_get_supported_ptypes(port_id, ptype_mask, NULL, 0); 19210 if (ret < 0) 19211 return; 19212 19213 while (ptype_mask != RSVD_PTYPE_MASK) { 19214 19215 switch (ptype_mask) { 19216 case RTE_PTYPE_L2_MASK: 19217 strlcpy(ltype, "L2", sizeof(ltype)); 19218 break; 19219 case RTE_PTYPE_L3_MASK: 19220 strlcpy(ltype, "L3", sizeof(ltype)); 19221 break; 19222 case RTE_PTYPE_L4_MASK: 19223 strlcpy(ltype, "L4", sizeof(ltype)); 19224 break; 19225 case RTE_PTYPE_TUNNEL_MASK: 19226 strlcpy(ltype, "Tunnel", sizeof(ltype)); 19227 break; 19228 case RTE_PTYPE_INNER_L2_MASK: 19229 strlcpy(ltype, "Inner L2", sizeof(ltype)); 19230 break; 19231 case RTE_PTYPE_INNER_L3_MASK: 19232 strlcpy(ltype, "Inner L3", sizeof(ltype)); 19233 break; 19234 case RTE_PTYPE_INNER_L4_MASK: 19235 strlcpy(ltype, "Inner L4", sizeof(ltype)); 19236 break; 19237 default: 19238 return; 19239 } 19240 19241 ret = rte_eth_dev_get_supported_ptypes(res->port_id, 19242 ptype_mask, ptypes, 19243 MAX_PTYPES_PER_LAYER); 19244 19245 if (ret > 0) 19246 printf("Supported %s ptypes:\n", ltype); 19247 else 19248 printf("%s ptypes unsupported\n", ltype); 19249 19250 for (i = 0; i < ret; ++i) { 19251 rte_get_ptype_name(ptypes[i], buf, sizeof(buf)); 19252 printf("%s\n", buf); 19253 } 19254 19255 ptype_mask <<= 4; 19256 } 19257 } 19258 19259 cmdline_parse_inst_t cmd_show_port_supported_ptypes = { 19260 .f = cmd_show_port_supported_ptypes_parsed, 19261 .data = NULL, 19262 .help_str = "show port <port_id> ptypes", 19263 .tokens = { 19264 (void *)&cmd_show_port_supported_ptypes_show, 19265 (void *)&cmd_show_port_supported_ptypes_port, 19266 (void *)&cmd_show_port_supported_ptypes_port_id, 19267 (void *)&cmd_show_port_supported_ptypes_ptypes, 19268 NULL, 19269 }, 19270 }; 19271 19272 /* *** display rx/tx descriptor status *** */ 19273 struct cmd_show_rx_tx_desc_status_result { 19274 cmdline_fixed_string_t cmd_show; 19275 cmdline_fixed_string_t cmd_port; 19276 cmdline_fixed_string_t cmd_keyword; 19277 cmdline_fixed_string_t cmd_desc; 19278 cmdline_fixed_string_t cmd_status; 19279 portid_t cmd_pid; 19280 portid_t cmd_qid; 19281 portid_t cmd_did; 19282 }; 19283 19284 static void 19285 cmd_show_rx_tx_desc_status_parsed(void *parsed_result, 19286 __rte_unused struct cmdline *cl, 19287 __rte_unused void *data) 19288 { 19289 struct cmd_show_rx_tx_desc_status_result *res = parsed_result; 19290 int rc; 19291 19292 if (!rte_eth_dev_is_valid_port(res->cmd_pid)) { 19293 printf("invalid port id %u\n", res->cmd_pid); 19294 return; 19295 } 19296 19297 if (!strcmp(res->cmd_keyword, "rxq")) { 19298 rc = rte_eth_rx_descriptor_status(res->cmd_pid, res->cmd_qid, 19299 res->cmd_did); 19300 if (rc < 0) { 19301 printf("Invalid queueid = %d\n", res->cmd_qid); 19302 return; 19303 } 19304 if (rc == RTE_ETH_RX_DESC_AVAIL) 19305 printf("Desc status = AVAILABLE\n"); 19306 else if (rc == RTE_ETH_RX_DESC_DONE) 19307 printf("Desc status = DONE\n"); 19308 else 19309 printf("Desc status = UNAVAILABLE\n"); 19310 } else if (!strcmp(res->cmd_keyword, "txq")) { 19311 rc = rte_eth_tx_descriptor_status(res->cmd_pid, res->cmd_qid, 19312 res->cmd_did); 19313 if (rc < 0) { 19314 printf("Invalid queueid = %d\n", res->cmd_qid); 19315 return; 19316 } 19317 if (rc == RTE_ETH_TX_DESC_FULL) 19318 printf("Desc status = FULL\n"); 19319 else if (rc == RTE_ETH_TX_DESC_DONE) 19320 printf("Desc status = DONE\n"); 19321 else 19322 printf("Desc status = UNAVAILABLE\n"); 19323 } 19324 } 19325 19326 cmdline_parse_token_string_t cmd_show_rx_tx_desc_status_show = 19327 TOKEN_STRING_INITIALIZER(struct cmd_show_rx_tx_desc_status_result, 19328 cmd_show, "show"); 19329 cmdline_parse_token_string_t cmd_show_rx_tx_desc_status_port = 19330 TOKEN_STRING_INITIALIZER(struct cmd_show_rx_tx_desc_status_result, 19331 cmd_port, "port"); 19332 cmdline_parse_token_num_t cmd_show_rx_tx_desc_status_pid = 19333 TOKEN_NUM_INITIALIZER(struct cmd_show_rx_tx_desc_status_result, 19334 cmd_pid, UINT16); 19335 cmdline_parse_token_string_t cmd_show_rx_tx_desc_status_keyword = 19336 TOKEN_STRING_INITIALIZER(struct cmd_show_rx_tx_desc_status_result, 19337 cmd_keyword, "rxq#txq"); 19338 cmdline_parse_token_num_t cmd_show_rx_tx_desc_status_qid = 19339 TOKEN_NUM_INITIALIZER(struct cmd_show_rx_tx_desc_status_result, 19340 cmd_qid, UINT16); 19341 cmdline_parse_token_string_t cmd_show_rx_tx_desc_status_desc = 19342 TOKEN_STRING_INITIALIZER(struct cmd_show_rx_tx_desc_status_result, 19343 cmd_desc, "desc"); 19344 cmdline_parse_token_num_t cmd_show_rx_tx_desc_status_did = 19345 TOKEN_NUM_INITIALIZER(struct cmd_show_rx_tx_desc_status_result, 19346 cmd_did, UINT16); 19347 cmdline_parse_token_string_t cmd_show_rx_tx_desc_status_status = 19348 TOKEN_STRING_INITIALIZER(struct cmd_show_rx_tx_desc_status_result, 19349 cmd_status, "status"); 19350 cmdline_parse_inst_t cmd_show_rx_tx_desc_status = { 19351 .f = cmd_show_rx_tx_desc_status_parsed, 19352 .data = NULL, 19353 .help_str = "show port <port_id> rxq|txq <queue_id> desc <desc_id> " 19354 "status", 19355 .tokens = { 19356 (void *)&cmd_show_rx_tx_desc_status_show, 19357 (void *)&cmd_show_rx_tx_desc_status_port, 19358 (void *)&cmd_show_rx_tx_desc_status_pid, 19359 (void *)&cmd_show_rx_tx_desc_status_keyword, 19360 (void *)&cmd_show_rx_tx_desc_status_qid, 19361 (void *)&cmd_show_rx_tx_desc_status_desc, 19362 (void *)&cmd_show_rx_tx_desc_status_did, 19363 (void *)&cmd_show_rx_tx_desc_status_status, 19364 NULL, 19365 }, 19366 }; 19367 19368 /* Common result structure for set port ptypes */ 19369 struct cmd_set_port_ptypes_result { 19370 cmdline_fixed_string_t set; 19371 cmdline_fixed_string_t port; 19372 portid_t port_id; 19373 cmdline_fixed_string_t ptype_mask; 19374 uint32_t mask; 19375 }; 19376 19377 /* Common CLI fields for set port ptypes */ 19378 cmdline_parse_token_string_t cmd_set_port_ptypes_set = 19379 TOKEN_STRING_INITIALIZER 19380 (struct cmd_set_port_ptypes_result, 19381 set, "set"); 19382 cmdline_parse_token_string_t cmd_set_port_ptypes_port = 19383 TOKEN_STRING_INITIALIZER 19384 (struct cmd_set_port_ptypes_result, 19385 port, "port"); 19386 cmdline_parse_token_num_t cmd_set_port_ptypes_port_id = 19387 TOKEN_NUM_INITIALIZER 19388 (struct cmd_set_port_ptypes_result, 19389 port_id, UINT16); 19390 cmdline_parse_token_string_t cmd_set_port_ptypes_mask_str = 19391 TOKEN_STRING_INITIALIZER 19392 (struct cmd_set_port_ptypes_result, 19393 ptype_mask, "ptype_mask"); 19394 cmdline_parse_token_num_t cmd_set_port_ptypes_mask_u32 = 19395 TOKEN_NUM_INITIALIZER 19396 (struct cmd_set_port_ptypes_result, 19397 mask, UINT32); 19398 19399 static void 19400 cmd_set_port_ptypes_parsed( 19401 void *parsed_result, 19402 __rte_unused struct cmdline *cl, 19403 __rte_unused void *data) 19404 { 19405 struct cmd_set_port_ptypes_result *res = parsed_result; 19406 #define PTYPE_NAMESIZE 256 19407 char ptype_name[PTYPE_NAMESIZE]; 19408 uint16_t port_id = res->port_id; 19409 uint32_t ptype_mask = res->mask; 19410 int ret, i; 19411 19412 ret = rte_eth_dev_get_supported_ptypes(port_id, RTE_PTYPE_ALL_MASK, 19413 NULL, 0); 19414 if (ret <= 0) { 19415 printf("Port %d doesn't support any ptypes.\n", port_id); 19416 return; 19417 } 19418 19419 uint32_t ptypes[ret]; 19420 19421 ret = rte_eth_dev_set_ptypes(port_id, ptype_mask, ptypes, ret); 19422 if (ret < 0) { 19423 printf("Unable to set requested ptypes for Port %d\n", port_id); 19424 return; 19425 } 19426 19427 printf("Successfully set following ptypes for Port %d\n", port_id); 19428 for (i = 0; i < ret && ptypes[i] != RTE_PTYPE_UNKNOWN; i++) { 19429 rte_get_ptype_name(ptypes[i], ptype_name, sizeof(ptype_name)); 19430 printf("%s\n", ptype_name); 19431 } 19432 19433 clear_ptypes = false; 19434 } 19435 19436 cmdline_parse_inst_t cmd_set_port_ptypes = { 19437 .f = cmd_set_port_ptypes_parsed, 19438 .data = NULL, 19439 .help_str = "set port <port_id> ptype_mask <mask>", 19440 .tokens = { 19441 (void *)&cmd_set_port_ptypes_set, 19442 (void *)&cmd_set_port_ptypes_port, 19443 (void *)&cmd_set_port_ptypes_port_id, 19444 (void *)&cmd_set_port_ptypes_mask_str, 19445 (void *)&cmd_set_port_ptypes_mask_u32, 19446 NULL, 19447 }, 19448 }; 19449 19450 /* *** display mac addresses added to a port *** */ 19451 struct cmd_showport_macs_result { 19452 cmdline_fixed_string_t cmd_show; 19453 cmdline_fixed_string_t cmd_port; 19454 cmdline_fixed_string_t cmd_keyword; 19455 portid_t cmd_pid; 19456 }; 19457 19458 static void 19459 cmd_showport_macs_parsed(void *parsed_result, 19460 __rte_unused struct cmdline *cl, 19461 __rte_unused void *data) 19462 { 19463 struct cmd_showport_macs_result *res = parsed_result; 19464 19465 if (port_id_is_invalid(res->cmd_pid, ENABLED_WARN)) 19466 return; 19467 19468 if (!strcmp(res->cmd_keyword, "macs")) 19469 show_macs(res->cmd_pid); 19470 else if (!strcmp(res->cmd_keyword, "mcast_macs")) 19471 show_mcast_macs(res->cmd_pid); 19472 } 19473 19474 cmdline_parse_token_string_t cmd_showport_macs_show = 19475 TOKEN_STRING_INITIALIZER(struct cmd_showport_macs_result, 19476 cmd_show, "show"); 19477 cmdline_parse_token_string_t cmd_showport_macs_port = 19478 TOKEN_STRING_INITIALIZER(struct cmd_showport_macs_result, 19479 cmd_port, "port"); 19480 cmdline_parse_token_num_t cmd_showport_macs_pid = 19481 TOKEN_NUM_INITIALIZER(struct cmd_showport_macs_result, 19482 cmd_pid, UINT16); 19483 cmdline_parse_token_string_t cmd_showport_macs_keyword = 19484 TOKEN_STRING_INITIALIZER(struct cmd_showport_macs_result, 19485 cmd_keyword, "macs#mcast_macs"); 19486 19487 cmdline_parse_inst_t cmd_showport_macs = { 19488 .f = cmd_showport_macs_parsed, 19489 .data = NULL, 19490 .help_str = "show port <port_id> macs|mcast_macs", 19491 .tokens = { 19492 (void *)&cmd_showport_macs_show, 19493 (void *)&cmd_showport_macs_port, 19494 (void *)&cmd_showport_macs_pid, 19495 (void *)&cmd_showport_macs_keyword, 19496 NULL, 19497 }, 19498 }; 19499 19500 /* ******************************************************************************** */ 19501 19502 /* list of instructions */ 19503 cmdline_parse_ctx_t main_ctx[] = { 19504 (cmdline_parse_inst_t *)&cmd_help_brief, 19505 (cmdline_parse_inst_t *)&cmd_help_long, 19506 (cmdline_parse_inst_t *)&cmd_quit, 19507 (cmdline_parse_inst_t *)&cmd_load_from_file, 19508 (cmdline_parse_inst_t *)&cmd_showport, 19509 (cmdline_parse_inst_t *)&cmd_showqueue, 19510 (cmdline_parse_inst_t *)&cmd_showportall, 19511 (cmdline_parse_inst_t *)&cmd_showdevice, 19512 (cmdline_parse_inst_t *)&cmd_showcfg, 19513 (cmdline_parse_inst_t *)&cmd_showfwdall, 19514 (cmdline_parse_inst_t *)&cmd_start, 19515 (cmdline_parse_inst_t *)&cmd_start_tx_first, 19516 (cmdline_parse_inst_t *)&cmd_start_tx_first_n, 19517 (cmdline_parse_inst_t *)&cmd_set_link_up, 19518 (cmdline_parse_inst_t *)&cmd_set_link_down, 19519 (cmdline_parse_inst_t *)&cmd_reset, 19520 (cmdline_parse_inst_t *)&cmd_set_numbers, 19521 (cmdline_parse_inst_t *)&cmd_set_log, 19522 (cmdline_parse_inst_t *)&cmd_set_txpkts, 19523 (cmdline_parse_inst_t *)&cmd_set_txsplit, 19524 (cmdline_parse_inst_t *)&cmd_set_txtimes, 19525 (cmdline_parse_inst_t *)&cmd_set_fwd_list, 19526 (cmdline_parse_inst_t *)&cmd_set_fwd_mask, 19527 (cmdline_parse_inst_t *)&cmd_set_fwd_mode, 19528 (cmdline_parse_inst_t *)&cmd_set_fwd_retry_mode, 19529 (cmdline_parse_inst_t *)&cmd_set_burst_tx_retry, 19530 (cmdline_parse_inst_t *)&cmd_set_promisc_mode_one, 19531 (cmdline_parse_inst_t *)&cmd_set_promisc_mode_all, 19532 (cmdline_parse_inst_t *)&cmd_set_allmulti_mode_one, 19533 (cmdline_parse_inst_t *)&cmd_set_allmulti_mode_all, 19534 (cmdline_parse_inst_t *)&cmd_set_flush_rx, 19535 (cmdline_parse_inst_t *)&cmd_set_link_check, 19536 (cmdline_parse_inst_t *)&cmd_set_bypass_mode, 19537 (cmdline_parse_inst_t *)&cmd_set_bypass_event, 19538 (cmdline_parse_inst_t *)&cmd_set_bypass_timeout, 19539 (cmdline_parse_inst_t *)&cmd_show_bypass_config, 19540 #ifdef RTE_LIBRTE_PMD_BOND 19541 (cmdline_parse_inst_t *) &cmd_set_bonding_mode, 19542 (cmdline_parse_inst_t *) &cmd_show_bonding_config, 19543 (cmdline_parse_inst_t *) &cmd_set_bonding_primary, 19544 (cmdline_parse_inst_t *) &cmd_add_bonding_slave, 19545 (cmdline_parse_inst_t *) &cmd_remove_bonding_slave, 19546 (cmdline_parse_inst_t *) &cmd_create_bonded_device, 19547 (cmdline_parse_inst_t *) &cmd_set_bond_mac_addr, 19548 (cmdline_parse_inst_t *) &cmd_set_balance_xmit_policy, 19549 (cmdline_parse_inst_t *) &cmd_set_bond_mon_period, 19550 (cmdline_parse_inst_t *) &cmd_set_lacp_dedicated_queues, 19551 (cmdline_parse_inst_t *) &cmd_set_bonding_agg_mode_policy, 19552 #endif 19553 (cmdline_parse_inst_t *)&cmd_vlan_offload, 19554 (cmdline_parse_inst_t *)&cmd_vlan_tpid, 19555 (cmdline_parse_inst_t *)&cmd_rx_vlan_filter_all, 19556 (cmdline_parse_inst_t *)&cmd_rx_vlan_filter, 19557 (cmdline_parse_inst_t *)&cmd_tx_vlan_set, 19558 (cmdline_parse_inst_t *)&cmd_tx_vlan_set_qinq, 19559 (cmdline_parse_inst_t *)&cmd_tx_vlan_reset, 19560 (cmdline_parse_inst_t *)&cmd_tx_vlan_set_pvid, 19561 (cmdline_parse_inst_t *)&cmd_csum_set, 19562 (cmdline_parse_inst_t *)&cmd_csum_show, 19563 (cmdline_parse_inst_t *)&cmd_csum_tunnel, 19564 (cmdline_parse_inst_t *)&cmd_tso_set, 19565 (cmdline_parse_inst_t *)&cmd_tso_show, 19566 (cmdline_parse_inst_t *)&cmd_tunnel_tso_set, 19567 (cmdline_parse_inst_t *)&cmd_tunnel_tso_show, 19568 (cmdline_parse_inst_t *)&cmd_gro_enable, 19569 (cmdline_parse_inst_t *)&cmd_gro_flush, 19570 (cmdline_parse_inst_t *)&cmd_gro_show, 19571 (cmdline_parse_inst_t *)&cmd_gso_enable, 19572 (cmdline_parse_inst_t *)&cmd_gso_size, 19573 (cmdline_parse_inst_t *)&cmd_gso_show, 19574 (cmdline_parse_inst_t *)&cmd_link_flow_control_set, 19575 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_rx, 19576 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_tx, 19577 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_hw, 19578 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_lw, 19579 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_pt, 19580 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_xon, 19581 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_macfwd, 19582 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_autoneg, 19583 (cmdline_parse_inst_t *)&cmd_priority_flow_control_set, 19584 (cmdline_parse_inst_t *)&cmd_config_dcb, 19585 (cmdline_parse_inst_t *)&cmd_read_reg, 19586 (cmdline_parse_inst_t *)&cmd_read_reg_bit_field, 19587 (cmdline_parse_inst_t *)&cmd_read_reg_bit, 19588 (cmdline_parse_inst_t *)&cmd_write_reg, 19589 (cmdline_parse_inst_t *)&cmd_write_reg_bit_field, 19590 (cmdline_parse_inst_t *)&cmd_write_reg_bit, 19591 (cmdline_parse_inst_t *)&cmd_read_rxd_txd, 19592 (cmdline_parse_inst_t *)&cmd_stop, 19593 (cmdline_parse_inst_t *)&cmd_mac_addr, 19594 (cmdline_parse_inst_t *)&cmd_set_fwd_eth_peer, 19595 (cmdline_parse_inst_t *)&cmd_set_qmap, 19596 (cmdline_parse_inst_t *)&cmd_set_xstats_hide_zero, 19597 (cmdline_parse_inst_t *)&cmd_set_record_core_cycles, 19598 (cmdline_parse_inst_t *)&cmd_set_record_burst_stats, 19599 (cmdline_parse_inst_t *)&cmd_operate_port, 19600 (cmdline_parse_inst_t *)&cmd_operate_specific_port, 19601 (cmdline_parse_inst_t *)&cmd_operate_attach_port, 19602 (cmdline_parse_inst_t *)&cmd_operate_detach_port, 19603 (cmdline_parse_inst_t *)&cmd_operate_detach_device, 19604 (cmdline_parse_inst_t *)&cmd_set_port_setup_on, 19605 (cmdline_parse_inst_t *)&cmd_config_speed_all, 19606 (cmdline_parse_inst_t *)&cmd_config_speed_specific, 19607 (cmdline_parse_inst_t *)&cmd_config_loopback_all, 19608 (cmdline_parse_inst_t *)&cmd_config_loopback_specific, 19609 (cmdline_parse_inst_t *)&cmd_config_rx_tx, 19610 (cmdline_parse_inst_t *)&cmd_config_mtu, 19611 (cmdline_parse_inst_t *)&cmd_config_max_pkt_len, 19612 (cmdline_parse_inst_t *)&cmd_config_max_lro_pkt_size, 19613 (cmdline_parse_inst_t *)&cmd_config_rx_mode_flag, 19614 (cmdline_parse_inst_t *)&cmd_config_rss, 19615 (cmdline_parse_inst_t *)&cmd_config_rxtx_ring_size, 19616 (cmdline_parse_inst_t *)&cmd_config_rxtx_queue, 19617 (cmdline_parse_inst_t *)&cmd_config_deferred_start_rxtx_queue, 19618 (cmdline_parse_inst_t *)&cmd_setup_rxtx_queue, 19619 (cmdline_parse_inst_t *)&cmd_config_rss_reta, 19620 (cmdline_parse_inst_t *)&cmd_showport_reta, 19621 (cmdline_parse_inst_t *)&cmd_showport_macs, 19622 (cmdline_parse_inst_t *)&cmd_config_burst, 19623 (cmdline_parse_inst_t *)&cmd_config_thresh, 19624 (cmdline_parse_inst_t *)&cmd_config_threshold, 19625 (cmdline_parse_inst_t *)&cmd_set_uc_hash_filter, 19626 (cmdline_parse_inst_t *)&cmd_set_uc_all_hash_filter, 19627 (cmdline_parse_inst_t *)&cmd_vf_mac_addr_filter, 19628 (cmdline_parse_inst_t *)&cmd_set_vf_macvlan_filter, 19629 (cmdline_parse_inst_t *)&cmd_queue_rate_limit, 19630 (cmdline_parse_inst_t *)&cmd_tunnel_filter, 19631 (cmdline_parse_inst_t *)&cmd_tunnel_udp_config, 19632 (cmdline_parse_inst_t *)&cmd_global_config, 19633 (cmdline_parse_inst_t *)&cmd_set_mirror_mask, 19634 (cmdline_parse_inst_t *)&cmd_set_mirror_link, 19635 (cmdline_parse_inst_t *)&cmd_reset_mirror_rule, 19636 (cmdline_parse_inst_t *)&cmd_showport_rss_hash, 19637 (cmdline_parse_inst_t *)&cmd_showport_rss_hash_key, 19638 (cmdline_parse_inst_t *)&cmd_config_rss_hash_key, 19639 (cmdline_parse_inst_t *)&cmd_dump, 19640 (cmdline_parse_inst_t *)&cmd_dump_one, 19641 (cmdline_parse_inst_t *)&cmd_ethertype_filter, 19642 (cmdline_parse_inst_t *)&cmd_syn_filter, 19643 (cmdline_parse_inst_t *)&cmd_2tuple_filter, 19644 (cmdline_parse_inst_t *)&cmd_5tuple_filter, 19645 (cmdline_parse_inst_t *)&cmd_flex_filter, 19646 (cmdline_parse_inst_t *)&cmd_add_del_ip_flow_director, 19647 (cmdline_parse_inst_t *)&cmd_add_del_udp_flow_director, 19648 (cmdline_parse_inst_t *)&cmd_add_del_sctp_flow_director, 19649 (cmdline_parse_inst_t *)&cmd_add_del_l2_flow_director, 19650 (cmdline_parse_inst_t *)&cmd_add_del_mac_vlan_flow_director, 19651 (cmdline_parse_inst_t *)&cmd_add_del_tunnel_flow_director, 19652 (cmdline_parse_inst_t *)&cmd_add_del_raw_flow_director, 19653 (cmdline_parse_inst_t *)&cmd_flush_flow_director, 19654 (cmdline_parse_inst_t *)&cmd_set_flow_director_ip_mask, 19655 (cmdline_parse_inst_t *)&cmd_set_flow_director_mac_vlan_mask, 19656 (cmdline_parse_inst_t *)&cmd_set_flow_director_tunnel_mask, 19657 (cmdline_parse_inst_t *)&cmd_set_flow_director_flex_mask, 19658 (cmdline_parse_inst_t *)&cmd_set_flow_director_flex_payload, 19659 (cmdline_parse_inst_t *)&cmd_get_sym_hash_ena_per_port, 19660 (cmdline_parse_inst_t *)&cmd_set_sym_hash_ena_per_port, 19661 (cmdline_parse_inst_t *)&cmd_get_hash_global_config, 19662 (cmdline_parse_inst_t *)&cmd_set_hash_global_config, 19663 (cmdline_parse_inst_t *)&cmd_set_hash_input_set, 19664 (cmdline_parse_inst_t *)&cmd_set_fdir_input_set, 19665 (cmdline_parse_inst_t *)&cmd_flow, 19666 (cmdline_parse_inst_t *)&cmd_show_port_meter_cap, 19667 (cmdline_parse_inst_t *)&cmd_add_port_meter_profile_srtcm, 19668 (cmdline_parse_inst_t *)&cmd_add_port_meter_profile_trtcm, 19669 (cmdline_parse_inst_t *)&cmd_del_port_meter_profile, 19670 (cmdline_parse_inst_t *)&cmd_create_port_meter, 19671 (cmdline_parse_inst_t *)&cmd_enable_port_meter, 19672 (cmdline_parse_inst_t *)&cmd_disable_port_meter, 19673 (cmdline_parse_inst_t *)&cmd_del_port_meter, 19674 (cmdline_parse_inst_t *)&cmd_set_port_meter_profile, 19675 (cmdline_parse_inst_t *)&cmd_set_port_meter_dscp_table, 19676 (cmdline_parse_inst_t *)&cmd_set_port_meter_policer_action, 19677 (cmdline_parse_inst_t *)&cmd_set_port_meter_stats_mask, 19678 (cmdline_parse_inst_t *)&cmd_show_port_meter_stats, 19679 (cmdline_parse_inst_t *)&cmd_mcast_addr, 19680 (cmdline_parse_inst_t *)&cmd_config_l2_tunnel_eth_type_all, 19681 (cmdline_parse_inst_t *)&cmd_config_l2_tunnel_eth_type_specific, 19682 (cmdline_parse_inst_t *)&cmd_config_l2_tunnel_en_dis_all, 19683 (cmdline_parse_inst_t *)&cmd_config_l2_tunnel_en_dis_specific, 19684 (cmdline_parse_inst_t *)&cmd_config_e_tag_insertion_en, 19685 (cmdline_parse_inst_t *)&cmd_config_e_tag_insertion_dis, 19686 (cmdline_parse_inst_t *)&cmd_config_e_tag_stripping_en_dis, 19687 (cmdline_parse_inst_t *)&cmd_config_e_tag_forwarding_en_dis, 19688 (cmdline_parse_inst_t *)&cmd_config_e_tag_filter_add, 19689 (cmdline_parse_inst_t *)&cmd_config_e_tag_filter_del, 19690 (cmdline_parse_inst_t *)&cmd_set_vf_vlan_anti_spoof, 19691 (cmdline_parse_inst_t *)&cmd_set_vf_mac_anti_spoof, 19692 (cmdline_parse_inst_t *)&cmd_set_vf_vlan_stripq, 19693 (cmdline_parse_inst_t *)&cmd_set_vf_vlan_insert, 19694 (cmdline_parse_inst_t *)&cmd_set_tx_loopback, 19695 (cmdline_parse_inst_t *)&cmd_set_all_queues_drop_en, 19696 (cmdline_parse_inst_t *)&cmd_set_vf_split_drop_en, 19697 (cmdline_parse_inst_t *)&cmd_set_macsec_offload_on, 19698 (cmdline_parse_inst_t *)&cmd_set_macsec_offload_off, 19699 (cmdline_parse_inst_t *)&cmd_set_macsec_sc, 19700 (cmdline_parse_inst_t *)&cmd_set_macsec_sa, 19701 (cmdline_parse_inst_t *)&cmd_set_vf_traffic, 19702 (cmdline_parse_inst_t *)&cmd_set_vf_rxmode, 19703 (cmdline_parse_inst_t *)&cmd_vf_rate_limit, 19704 (cmdline_parse_inst_t *)&cmd_vf_rxvlan_filter, 19705 (cmdline_parse_inst_t *)&cmd_set_vf_mac_addr, 19706 (cmdline_parse_inst_t *)&cmd_set_vf_promisc, 19707 (cmdline_parse_inst_t *)&cmd_set_vf_allmulti, 19708 (cmdline_parse_inst_t *)&cmd_set_vf_broadcast, 19709 (cmdline_parse_inst_t *)&cmd_set_vf_vlan_tag, 19710 (cmdline_parse_inst_t *)&cmd_vf_max_bw, 19711 (cmdline_parse_inst_t *)&cmd_vf_tc_min_bw, 19712 (cmdline_parse_inst_t *)&cmd_vf_tc_max_bw, 19713 (cmdline_parse_inst_t *)&cmd_strict_link_prio, 19714 (cmdline_parse_inst_t *)&cmd_tc_min_bw, 19715 (cmdline_parse_inst_t *)&cmd_set_vxlan, 19716 (cmdline_parse_inst_t *)&cmd_set_vxlan_tos_ttl, 19717 (cmdline_parse_inst_t *)&cmd_set_vxlan_with_vlan, 19718 (cmdline_parse_inst_t *)&cmd_set_nvgre, 19719 (cmdline_parse_inst_t *)&cmd_set_nvgre_with_vlan, 19720 (cmdline_parse_inst_t *)&cmd_set_l2_encap, 19721 (cmdline_parse_inst_t *)&cmd_set_l2_encap_with_vlan, 19722 (cmdline_parse_inst_t *)&cmd_set_l2_decap, 19723 (cmdline_parse_inst_t *)&cmd_set_l2_decap_with_vlan, 19724 (cmdline_parse_inst_t *)&cmd_set_mplsogre_encap, 19725 (cmdline_parse_inst_t *)&cmd_set_mplsogre_encap_with_vlan, 19726 (cmdline_parse_inst_t *)&cmd_set_mplsogre_decap, 19727 (cmdline_parse_inst_t *)&cmd_set_mplsogre_decap_with_vlan, 19728 (cmdline_parse_inst_t *)&cmd_set_mplsoudp_encap, 19729 (cmdline_parse_inst_t *)&cmd_set_mplsoudp_encap_with_vlan, 19730 (cmdline_parse_inst_t *)&cmd_set_mplsoudp_decap, 19731 (cmdline_parse_inst_t *)&cmd_set_mplsoudp_decap_with_vlan, 19732 (cmdline_parse_inst_t *)&cmd_ddp_add, 19733 (cmdline_parse_inst_t *)&cmd_ddp_del, 19734 (cmdline_parse_inst_t *)&cmd_ddp_get_list, 19735 (cmdline_parse_inst_t *)&cmd_ddp_get_info, 19736 (cmdline_parse_inst_t *)&cmd_cfg_input_set, 19737 (cmdline_parse_inst_t *)&cmd_clear_input_set, 19738 (cmdline_parse_inst_t *)&cmd_show_vf_stats, 19739 (cmdline_parse_inst_t *)&cmd_clear_vf_stats, 19740 (cmdline_parse_inst_t *)&cmd_show_port_supported_ptypes, 19741 (cmdline_parse_inst_t *)&cmd_set_port_ptypes, 19742 (cmdline_parse_inst_t *)&cmd_ptype_mapping_get, 19743 (cmdline_parse_inst_t *)&cmd_ptype_mapping_replace, 19744 (cmdline_parse_inst_t *)&cmd_ptype_mapping_reset, 19745 (cmdline_parse_inst_t *)&cmd_ptype_mapping_update, 19746 19747 (cmdline_parse_inst_t *)&cmd_pctype_mapping_get, 19748 (cmdline_parse_inst_t *)&cmd_pctype_mapping_reset, 19749 (cmdline_parse_inst_t *)&cmd_pctype_mapping_update, 19750 (cmdline_parse_inst_t *)&cmd_queue_region, 19751 (cmdline_parse_inst_t *)&cmd_region_flowtype, 19752 (cmdline_parse_inst_t *)&cmd_user_priority_region, 19753 (cmdline_parse_inst_t *)&cmd_flush_queue_region, 19754 (cmdline_parse_inst_t *)&cmd_show_queue_region_info_all, 19755 (cmdline_parse_inst_t *)&cmd_show_port_tm_cap, 19756 (cmdline_parse_inst_t *)&cmd_show_port_tm_level_cap, 19757 (cmdline_parse_inst_t *)&cmd_show_port_tm_node_cap, 19758 (cmdline_parse_inst_t *)&cmd_show_port_tm_node_type, 19759 (cmdline_parse_inst_t *)&cmd_show_port_tm_node_stats, 19760 (cmdline_parse_inst_t *)&cmd_add_port_tm_node_shaper_profile, 19761 (cmdline_parse_inst_t *)&cmd_del_port_tm_node_shaper_profile, 19762 (cmdline_parse_inst_t *)&cmd_add_port_tm_node_shared_shaper, 19763 (cmdline_parse_inst_t *)&cmd_del_port_tm_node_shared_shaper, 19764 (cmdline_parse_inst_t *)&cmd_add_port_tm_node_wred_profile, 19765 (cmdline_parse_inst_t *)&cmd_del_port_tm_node_wred_profile, 19766 (cmdline_parse_inst_t *)&cmd_set_port_tm_node_shaper_profile, 19767 (cmdline_parse_inst_t *)&cmd_add_port_tm_nonleaf_node, 19768 (cmdline_parse_inst_t *)&cmd_add_port_tm_nonleaf_node_pmode, 19769 (cmdline_parse_inst_t *)&cmd_add_port_tm_leaf_node, 19770 (cmdline_parse_inst_t *)&cmd_del_port_tm_node, 19771 (cmdline_parse_inst_t *)&cmd_set_port_tm_node_parent, 19772 (cmdline_parse_inst_t *)&cmd_suspend_port_tm_node, 19773 (cmdline_parse_inst_t *)&cmd_resume_port_tm_node, 19774 (cmdline_parse_inst_t *)&cmd_port_tm_hierarchy_commit, 19775 (cmdline_parse_inst_t *)&cmd_port_tm_mark_ip_ecn, 19776 (cmdline_parse_inst_t *)&cmd_port_tm_mark_ip_dscp, 19777 (cmdline_parse_inst_t *)&cmd_port_tm_mark_vlan_dei, 19778 (cmdline_parse_inst_t *)&cmd_cfg_tunnel_udp_port, 19779 (cmdline_parse_inst_t *)&cmd_rx_offload_get_capa, 19780 (cmdline_parse_inst_t *)&cmd_rx_offload_get_configuration, 19781 (cmdline_parse_inst_t *)&cmd_config_per_port_rx_offload, 19782 (cmdline_parse_inst_t *)&cmd_config_per_queue_rx_offload, 19783 (cmdline_parse_inst_t *)&cmd_tx_offload_get_capa, 19784 (cmdline_parse_inst_t *)&cmd_tx_offload_get_configuration, 19785 (cmdline_parse_inst_t *)&cmd_config_per_port_tx_offload, 19786 (cmdline_parse_inst_t *)&cmd_config_per_queue_tx_offload, 19787 #ifdef RTE_LIBRTE_BPF 19788 (cmdline_parse_inst_t *)&cmd_operate_bpf_ld_parse, 19789 (cmdline_parse_inst_t *)&cmd_operate_bpf_unld_parse, 19790 #endif 19791 (cmdline_parse_inst_t *)&cmd_config_tx_metadata_specific, 19792 (cmdline_parse_inst_t *)&cmd_show_tx_metadata, 19793 (cmdline_parse_inst_t *)&cmd_show_rx_tx_desc_status, 19794 (cmdline_parse_inst_t *)&cmd_set_raw, 19795 (cmdline_parse_inst_t *)&cmd_show_set_raw, 19796 (cmdline_parse_inst_t *)&cmd_show_set_raw_all, 19797 (cmdline_parse_inst_t *)&cmd_config_tx_dynf_specific, 19798 NULL, 19799 }; 19800 19801 /* read cmdline commands from file */ 19802 void 19803 cmdline_read_from_file(const char *filename) 19804 { 19805 struct cmdline *cl; 19806 19807 cl = cmdline_file_new(main_ctx, "testpmd> ", filename); 19808 if (cl == NULL) { 19809 printf("Failed to create file based cmdline context: %s\n", 19810 filename); 19811 return; 19812 } 19813 19814 cmdline_interact(cl); 19815 cmdline_quit(cl); 19816 19817 cmdline_free(cl); 19818 19819 printf("Read CLI commands from %s\n", filename); 19820 } 19821 19822 /* prompt function, called from main on MASTER lcore */ 19823 void 19824 prompt(void) 19825 { 19826 /* initialize non-constant commands */ 19827 cmd_set_fwd_mode_init(); 19828 cmd_set_fwd_retry_mode_init(); 19829 19830 testpmd_cl = cmdline_stdin_new(main_ctx, "testpmd> "); 19831 if (testpmd_cl == NULL) 19832 return; 19833 cmdline_interact(testpmd_cl); 19834 cmdline_stdin_exit(testpmd_cl); 19835 } 19836 19837 void 19838 prompt_exit(void) 19839 { 19840 if (testpmd_cl != NULL) 19841 cmdline_quit(testpmd_cl); 19842 } 19843 19844 static void 19845 cmd_reconfig_device_queue(portid_t id, uint8_t dev, uint8_t queue) 19846 { 19847 if (id == (portid_t)RTE_PORT_ALL) { 19848 portid_t pid; 19849 19850 RTE_ETH_FOREACH_DEV(pid) { 19851 /* check if need_reconfig has been set to 1 */ 19852 if (ports[pid].need_reconfig == 0) 19853 ports[pid].need_reconfig = dev; 19854 /* check if need_reconfig_queues has been set to 1 */ 19855 if (ports[pid].need_reconfig_queues == 0) 19856 ports[pid].need_reconfig_queues = queue; 19857 } 19858 } else if (!port_id_is_invalid(id, DISABLED_WARN)) { 19859 /* check if need_reconfig has been set to 1 */ 19860 if (ports[id].need_reconfig == 0) 19861 ports[id].need_reconfig = dev; 19862 /* check if need_reconfig_queues has been set to 1 */ 19863 if (ports[id].need_reconfig_queues == 0) 19864 ports[id].need_reconfig_queues = queue; 19865 } 19866 } 19867