1 /*- 2 * BSD LICENSE 3 * 4 * Copyright(c) 2010-2016 Intel Corporation. All rights reserved. 5 * Copyright(c) 2014 6WIND S.A. 6 * All rights reserved. 7 * 8 * Redistribution and use in source and binary forms, with or without 9 * modification, are permitted provided that the following conditions 10 * are met: 11 * 12 * * Redistributions of source code must retain the above copyright 13 * notice, this list of conditions and the following disclaimer. 14 * * Redistributions in binary form must reproduce the above copyright 15 * notice, this list of conditions and the following disclaimer in 16 * the documentation and/or other materials provided with the 17 * distribution. 18 * * Neither the name of Intel Corporation nor the names of its 19 * contributors may be used to endorse or promote products derived 20 * from this software without specific prior written permission. 21 * 22 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 23 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 24 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 25 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 26 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 27 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 28 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 29 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 30 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 31 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 32 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 33 */ 34 35 #include <stdarg.h> 36 #include <errno.h> 37 #include <stdio.h> 38 #include <stdint.h> 39 #include <string.h> 40 #include <termios.h> 41 #include <unistd.h> 42 #include <inttypes.h> 43 #ifndef __linux__ 44 #ifndef __FreeBSD__ 45 #include <net/socket.h> 46 #else 47 #include <sys/socket.h> 48 #endif 49 #endif 50 #include <netinet/in.h> 51 52 #include <sys/queue.h> 53 54 #include <rte_common.h> 55 #include <rte_byteorder.h> 56 #include <rte_log.h> 57 #include <rte_debug.h> 58 #include <rte_cycles.h> 59 #include <rte_memory.h> 60 #include <rte_memzone.h> 61 #include <rte_malloc.h> 62 #include <rte_launch.h> 63 #include <rte_eal.h> 64 #include <rte_per_lcore.h> 65 #include <rte_lcore.h> 66 #include <rte_atomic.h> 67 #include <rte_branch_prediction.h> 68 #include <rte_ring.h> 69 #include <rte_mempool.h> 70 #include <rte_interrupts.h> 71 #include <rte_pci.h> 72 #include <rte_ether.h> 73 #include <rte_ethdev.h> 74 #include <rte_string_fns.h> 75 #include <rte_devargs.h> 76 #include <rte_eth_ctrl.h> 77 #include <rte_flow.h> 78 #include <rte_gro.h> 79 80 #include <cmdline_rdline.h> 81 #include <cmdline_parse.h> 82 #include <cmdline_parse_num.h> 83 #include <cmdline_parse_string.h> 84 #include <cmdline_parse_ipaddr.h> 85 #include <cmdline_parse_etheraddr.h> 86 #include <cmdline_socket.h> 87 #include <cmdline.h> 88 #ifdef RTE_LIBRTE_PMD_BOND 89 #include <rte_eth_bond.h> 90 #include <rte_eth_bond_8023ad.h> 91 #endif 92 #ifdef RTE_LIBRTE_IXGBE_PMD 93 #include <rte_pmd_ixgbe.h> 94 #endif 95 #ifdef RTE_LIBRTE_I40E_PMD 96 #include <rte_pmd_i40e.h> 97 #endif 98 #ifdef RTE_LIBRTE_BNXT_PMD 99 #include <rte_pmd_bnxt.h> 100 #endif 101 #include "testpmd.h" 102 #include "cmdline_mtr.h" 103 #include "cmdline_tm.h" 104 105 static struct cmdline *testpmd_cl; 106 107 static void cmd_reconfig_device_queue(portid_t id, uint8_t dev, uint8_t queue); 108 109 /* *** Help command with introduction. *** */ 110 struct cmd_help_brief_result { 111 cmdline_fixed_string_t help; 112 }; 113 114 static void cmd_help_brief_parsed(__attribute__((unused)) void *parsed_result, 115 struct cmdline *cl, 116 __attribute__((unused)) void *data) 117 { 118 cmdline_printf( 119 cl, 120 "\n" 121 "Help is available for the following sections:\n\n" 122 " help control : Start and stop forwarding.\n" 123 " help display : Displaying port, stats and config " 124 "information.\n" 125 " help config : Configuration information.\n" 126 " help ports : Configuring ports.\n" 127 " help registers : Reading and setting port registers.\n" 128 " help filters : Filters configuration help.\n" 129 " help all : All of the above sections.\n\n" 130 ); 131 132 } 133 134 cmdline_parse_token_string_t cmd_help_brief_help = 135 TOKEN_STRING_INITIALIZER(struct cmd_help_brief_result, help, "help"); 136 137 cmdline_parse_inst_t cmd_help_brief = { 138 .f = cmd_help_brief_parsed, 139 .data = NULL, 140 .help_str = "help: Show help", 141 .tokens = { 142 (void *)&cmd_help_brief_help, 143 NULL, 144 }, 145 }; 146 147 /* *** Help command with help sections. *** */ 148 struct cmd_help_long_result { 149 cmdline_fixed_string_t help; 150 cmdline_fixed_string_t section; 151 }; 152 153 static void cmd_help_long_parsed(void *parsed_result, 154 struct cmdline *cl, 155 __attribute__((unused)) void *data) 156 { 157 int show_all = 0; 158 struct cmd_help_long_result *res = parsed_result; 159 160 if (!strcmp(res->section, "all")) 161 show_all = 1; 162 163 if (show_all || !strcmp(res->section, "control")) { 164 165 cmdline_printf( 166 cl, 167 "\n" 168 "Control forwarding:\n" 169 "-------------------\n\n" 170 171 "start\n" 172 " Start packet forwarding with current configuration.\n\n" 173 174 "start tx_first\n" 175 " Start packet forwarding with current config" 176 " after sending one burst of packets.\n\n" 177 178 "stop\n" 179 " Stop packet forwarding, and display accumulated" 180 " statistics.\n\n" 181 182 "quit\n" 183 " Quit to prompt.\n\n" 184 ); 185 } 186 187 if (show_all || !strcmp(res->section, "display")) { 188 189 cmdline_printf( 190 cl, 191 "\n" 192 "Display:\n" 193 "--------\n\n" 194 195 "show port (info|stats|xstats|fdir|stat_qmap|dcb_tc|cap) (port_id|all)\n" 196 " Display information for port_id, or all.\n\n" 197 198 "show port X rss reta (size) (mask0,mask1,...)\n" 199 " Display the rss redirection table entry indicated" 200 " by masks on port X. size is used to indicate the" 201 " hardware supported reta size\n\n" 202 203 "show port rss-hash ipv4|ipv4-frag|ipv4-tcp|ipv4-udp|" 204 "ipv4-sctp|ipv4-other|ipv6|ipv6-frag|ipv6-tcp|ipv6-udp|ipv6-sctp|" 205 "ipv6-other|l2-payload|ipv6-ex|ipv6-tcp-ex|ipv6-udp-ex [key]\n" 206 " Display the RSS hash functions and RSS hash key" 207 " of port X\n\n" 208 209 "clear port (info|stats|xstats|fdir|stat_qmap) (port_id|all)\n" 210 " Clear information for port_id, or all.\n\n" 211 212 "show (rxq|txq) info (port_id) (queue_id)\n" 213 " Display information for configured RX/TX queue.\n\n" 214 215 "show config (rxtx|cores|fwd|txpkts)\n" 216 " Display the given configuration.\n\n" 217 218 "read rxd (port_id) (queue_id) (rxd_id)\n" 219 " Display an RX descriptor of a port RX queue.\n\n" 220 221 "read txd (port_id) (queue_id) (txd_id)\n" 222 " Display a TX descriptor of a port TX queue.\n\n" 223 224 "ddp get list (port_id)\n" 225 " Get ddp profile info list\n\n" 226 227 "ddp get info (profile_path)\n" 228 " Get ddp profile information.\n\n" 229 230 "show vf stats (port_id) (vf_id)\n" 231 " Display a VF's statistics.\n\n" 232 233 "clear vf stats (port_id) (vf_id)\n" 234 " Reset a VF's statistics.\n\n" 235 236 "show port (port_id) pctype mapping\n" 237 " Get flow ptype to pctype mapping on a port\n\n" 238 239 "show port meter stats (port_id) (meter_id) (clear)\n" 240 " Get meter stats on a port\n\n" 241 "show port tm cap (port_id)\n" 242 " Display the port TM capability.\n\n" 243 244 "show port tm level cap (port_id) (level_id)\n" 245 " Display the port TM hierarchical level capability.\n\n" 246 247 "show port tm node cap (port_id) (node_id)\n" 248 " Display the port TM node capability.\n\n" 249 250 "show port tm node type (port_id) (node_id)\n" 251 " Display the port TM node type.\n\n" 252 253 "show port tm node stats (port_id) (node_id) (clear)\n" 254 " Display the port TM node stats.\n\n" 255 256 ); 257 } 258 259 if (show_all || !strcmp(res->section, "config")) { 260 cmdline_printf( 261 cl, 262 "\n" 263 "Configuration:\n" 264 "--------------\n" 265 "Configuration changes only become active when" 266 " forwarding is started/restarted.\n\n" 267 268 "set default\n" 269 " Reset forwarding to the default configuration.\n\n" 270 271 "set verbose (level)\n" 272 " Set the debug verbosity level X.\n\n" 273 274 "set nbport (num)\n" 275 " Set number of ports.\n\n" 276 277 "set nbcore (num)\n" 278 " Set number of cores.\n\n" 279 280 "set coremask (mask)\n" 281 " Set the forwarding cores hexadecimal mask.\n\n" 282 283 "set portmask (mask)\n" 284 " Set the forwarding ports hexadecimal mask.\n\n" 285 286 "set burst (num)\n" 287 " Set number of packets per burst.\n\n" 288 289 "set burst tx delay (microseconds) retry (num)\n" 290 " Set the transmit delay time and number of retries," 291 " effective when retry is enabled.\n\n" 292 293 "set txpkts (x[,y]*)\n" 294 " Set the length of each segment of TXONLY" 295 " and optionally CSUM packets.\n\n" 296 297 "set txsplit (off|on|rand)\n" 298 " Set the split policy for the TX packets." 299 " Right now only applicable for CSUM and TXONLY" 300 " modes\n\n" 301 302 "set corelist (x[,y]*)\n" 303 " Set the list of forwarding cores.\n\n" 304 305 "set portlist (x[,y]*)\n" 306 " Set the list of forwarding ports.\n\n" 307 308 "set tx loopback (port_id) (on|off)\n" 309 " Enable or disable tx loopback.\n\n" 310 311 "set all queues drop (port_id) (on|off)\n" 312 " Set drop enable bit for all queues.\n\n" 313 314 "set vf split drop (port_id) (vf_id) (on|off)\n" 315 " Set split drop enable bit for a VF from the PF.\n\n" 316 317 "set vf mac antispoof (port_id) (vf_id) (on|off).\n" 318 " Set MAC antispoof for a VF from the PF.\n\n" 319 320 "set macsec offload (port_id) on encrypt (on|off) replay-protect (on|off)\n" 321 " Enable MACsec offload.\n\n" 322 323 "set macsec offload (port_id) off\n" 324 " Disable MACsec offload.\n\n" 325 326 "set macsec sc (tx|rx) (port_id) (mac) (pi)\n" 327 " Configure MACsec secure connection (SC).\n\n" 328 329 "set macsec sa (tx|rx) (port_id) (idx) (an) (pn) (key)\n" 330 " Configure MACsec secure association (SA).\n\n" 331 332 "set vf broadcast (port_id) (vf_id) (on|off)\n" 333 " Set VF broadcast for a VF from the PF.\n\n" 334 335 "vlan set strip (on|off) (port_id)\n" 336 " Set the VLAN strip on a port.\n\n" 337 338 "vlan set stripq (on|off) (port_id,queue_id)\n" 339 " Set the VLAN strip for a queue on a port.\n\n" 340 341 "set vf vlan stripq (port_id) (vf_id) (on|off)\n" 342 " Set the VLAN strip for all queues in a pool for a VF from the PF.\n\n" 343 344 "set vf vlan insert (port_id) (vf_id) (vlan_id)\n" 345 " Set VLAN insert for a VF from the PF.\n\n" 346 347 "set vf vlan antispoof (port_id) (vf_id) (on|off)\n" 348 " Set VLAN antispoof for a VF from the PF.\n\n" 349 350 "set vf vlan tag (port_id) (vf_id) (on|off)\n" 351 " Set VLAN tag for a VF from the PF.\n\n" 352 353 "set vf tx max-bandwidth (port_id) (vf_id) (bandwidth)\n" 354 " Set a VF's max bandwidth(Mbps).\n\n" 355 356 "set vf tc tx min-bandwidth (port_id) (vf_id) (bw1, bw2, ...)\n" 357 " Set all TCs' min bandwidth(%%) on a VF.\n\n" 358 359 "set vf tc tx max-bandwidth (port_id) (vf_id) (tc_no) (bandwidth)\n" 360 " Set a TC's max bandwidth(Mbps) on a VF.\n\n" 361 362 "set tx strict-link-priority (port_id) (tc_bitmap)\n" 363 " Set some TCs' strict link priority mode on a physical port.\n\n" 364 365 "set tc tx min-bandwidth (port_id) (bw1, bw2, ...)\n" 366 " Set all TCs' min bandwidth(%%) for all PF and VFs.\n\n" 367 368 "vlan set filter (on|off) (port_id)\n" 369 " Set the VLAN filter on a port.\n\n" 370 371 "vlan set qinq (on|off) (port_id)\n" 372 " Set the VLAN QinQ (extended queue in queue)" 373 " on a port.\n\n" 374 375 "vlan set (inner|outer) tpid (value) (port_id)\n" 376 " Set the VLAN TPID for Packet Filtering on" 377 " a port\n\n" 378 379 "rx_vlan add (vlan_id|all) (port_id)\n" 380 " Add a vlan_id, or all identifiers, to the set" 381 " of VLAN identifiers filtered by port_id.\n\n" 382 383 "rx_vlan rm (vlan_id|all) (port_id)\n" 384 " Remove a vlan_id, or all identifiers, from the set" 385 " of VLAN identifiers filtered by port_id.\n\n" 386 387 "rx_vlan add (vlan_id) port (port_id) vf (vf_mask)\n" 388 " Add a vlan_id, to the set of VLAN identifiers" 389 "filtered for VF(s) from port_id.\n\n" 390 391 "rx_vlan rm (vlan_id) port (port_id) vf (vf_mask)\n" 392 " Remove a vlan_id, to the set of VLAN identifiers" 393 "filtered for VF(s) from port_id.\n\n" 394 395 "tunnel_filter add (port_id) (outer_mac) (inner_mac) (ip_addr) " 396 "(inner_vlan) (vxlan|nvgre|ipingre) (imac-ivlan|imac-ivlan-tenid|" 397 "imac-tenid|imac|omac-imac-tenid|oip|iip) (tenant_id) (queue_id)\n" 398 " add a tunnel filter of a port.\n\n" 399 400 "tunnel_filter rm (port_id) (outer_mac) (inner_mac) (ip_addr) " 401 "(inner_vlan) (vxlan|nvgre|ipingre) (imac-ivlan|imac-ivlan-tenid|" 402 "imac-tenid|imac|omac-imac-tenid|oip|iip) (tenant_id) (queue_id)\n" 403 " remove a tunnel filter of a port.\n\n" 404 405 "rx_vxlan_port add (udp_port) (port_id)\n" 406 " Add an UDP port for VXLAN packet filter on a port\n\n" 407 408 "rx_vxlan_port rm (udp_port) (port_id)\n" 409 " Remove an UDP port for VXLAN packet filter on a port\n\n" 410 411 "tx_vlan set (port_id) vlan_id[, vlan_id_outer]\n" 412 " Set hardware insertion of VLAN IDs (single or double VLAN " 413 "depends on the number of VLAN IDs) in packets sent on a port.\n\n" 414 415 "tx_vlan set pvid port_id vlan_id (on|off)\n" 416 " Set port based TX VLAN insertion.\n\n" 417 418 "tx_vlan reset (port_id)\n" 419 " Disable hardware insertion of a VLAN header in" 420 " packets sent on a port.\n\n" 421 422 "csum set (ip|udp|tcp|sctp|outer-ip) (hw|sw) (port_id)\n" 423 " Select hardware or software calculation of the" 424 " checksum when transmitting a packet using the" 425 " csum forward engine.\n" 426 " ip|udp|tcp|sctp always concern the inner layer.\n" 427 " outer-ip concerns the outer IP layer in" 428 " case the packet is recognized as a tunnel packet by" 429 " the forward engine (vxlan, gre and ipip are supported)\n" 430 " Please check the NIC datasheet for HW limits.\n\n" 431 432 "csum parse-tunnel (on|off) (tx_port_id)\n" 433 " If disabled, treat tunnel packets as non-tunneled" 434 " packets (treat inner headers as payload). The port\n" 435 " argument is the port used for TX in csum forward" 436 " engine.\n\n" 437 438 "csum show (port_id)\n" 439 " Display tx checksum offload configuration\n\n" 440 441 "tso set (segsize) (portid)\n" 442 " Enable TCP Segmentation Offload in csum forward" 443 " engine.\n" 444 " Please check the NIC datasheet for HW limits.\n\n" 445 446 "tso show (portid)" 447 " Display the status of TCP Segmentation Offload.\n\n" 448 449 "set port (port_id) gro on|off\n" 450 " Enable or disable Generic Receive Offload in" 451 " csum forwarding engine.\n\n" 452 453 "show port (port_id) gro\n" 454 " Display GRO configuration.\n\n" 455 456 "set gro flush (cycles)\n" 457 " Set the cycle to flush GROed packets from" 458 " reassembly tables.\n\n" 459 460 "set port (port_id) gso (on|off)" 461 " Enable or disable Generic Segmentation Offload in" 462 " csum forwarding engine.\n\n" 463 464 "set gso segsz (length)\n" 465 " Set max packet length for output GSO segments," 466 " including packet header and payload.\n\n" 467 468 "show port (port_id) gso\n" 469 " Show GSO configuration.\n\n" 470 471 "set fwd (%s)\n" 472 " Set packet forwarding mode.\n\n" 473 474 "mac_addr add (port_id) (XX:XX:XX:XX:XX:XX)\n" 475 " Add a MAC address on port_id.\n\n" 476 477 "mac_addr remove (port_id) (XX:XX:XX:XX:XX:XX)\n" 478 " Remove a MAC address from port_id.\n\n" 479 480 "mac_addr set (port_id) (XX:XX:XX:XX:XX:XX)\n" 481 " Set the default MAC address for port_id.\n\n" 482 483 "mac_addr add port (port_id) vf (vf_id) (mac_address)\n" 484 " Add a MAC address for a VF on the port.\n\n" 485 486 "set vf mac addr (port_id) (vf_id) (XX:XX:XX:XX:XX:XX)\n" 487 " Set the MAC address for a VF from the PF.\n\n" 488 489 "set port (port_id) uta (mac_address|all) (on|off)\n" 490 " Add/Remove a or all unicast hash filter(s)" 491 "from port X.\n\n" 492 493 "set promisc (port_id|all) (on|off)\n" 494 " Set the promiscuous mode on port_id, or all.\n\n" 495 496 "set allmulti (port_id|all) (on|off)\n" 497 " Set the allmulti mode on port_id, or all.\n\n" 498 499 "set vf promisc (port_id) (vf_id) (on|off)\n" 500 " Set unicast promiscuous mode for a VF from the PF.\n\n" 501 502 "set vf allmulti (port_id) (vf_id) (on|off)\n" 503 " Set multicast promiscuous mode for a VF from the PF.\n\n" 504 505 "set flow_ctrl rx (on|off) tx (on|off) (high_water)" 506 " (low_water) (pause_time) (send_xon) mac_ctrl_frame_fwd" 507 " (on|off) autoneg (on|off) (port_id)\n" 508 "set flow_ctrl rx (on|off) (portid)\n" 509 "set flow_ctrl tx (on|off) (portid)\n" 510 "set flow_ctrl high_water (high_water) (portid)\n" 511 "set flow_ctrl low_water (low_water) (portid)\n" 512 "set flow_ctrl pause_time (pause_time) (portid)\n" 513 "set flow_ctrl send_xon (send_xon) (portid)\n" 514 "set flow_ctrl mac_ctrl_frame_fwd (on|off) (portid)\n" 515 "set flow_ctrl autoneg (on|off) (port_id)\n" 516 " Set the link flow control parameter on a port.\n\n" 517 518 "set pfc_ctrl rx (on|off) tx (on|off) (high_water)" 519 " (low_water) (pause_time) (priority) (port_id)\n" 520 " Set the priority flow control parameter on a" 521 " port.\n\n" 522 523 "set stat_qmap (tx|rx) (port_id) (queue_id) (qmapping)\n" 524 " Set statistics mapping (qmapping 0..15) for RX/TX" 525 " queue on port.\n" 526 " e.g., 'set stat_qmap rx 0 2 5' sets rx queue 2" 527 " on port 0 to mapping 5.\n\n" 528 529 "set xstats-hide-zero on|off\n" 530 " Set the option to hide the zero values" 531 " for xstats display.\n" 532 533 "set port (port_id) vf (vf_id) rx|tx on|off\n" 534 " Enable/Disable a VF receive/tranmit from a port\n\n" 535 536 "set port (port_id) vf (vf_id) (mac_addr)" 537 " (exact-mac#exact-mac-vlan#hashmac|hashmac-vlan) on|off\n" 538 " Add/Remove unicast or multicast MAC addr filter" 539 " for a VF.\n\n" 540 541 "set port (port_id) vf (vf_id) rxmode (AUPE|ROPE|BAM" 542 "|MPE) (on|off)\n" 543 " AUPE:accepts untagged VLAN;" 544 "ROPE:accept unicast hash\n\n" 545 " BAM:accepts broadcast packets;" 546 "MPE:accepts all multicast packets\n\n" 547 " Enable/Disable a VF receive mode of a port\n\n" 548 549 "set port (port_id) queue (queue_id) rate (rate_num)\n" 550 " Set rate limit for a queue of a port\n\n" 551 552 "set port (port_id) vf (vf_id) rate (rate_num) " 553 "queue_mask (queue_mask_value)\n" 554 " Set rate limit for queues in VF of a port\n\n" 555 556 "set port (port_id) mirror-rule (rule_id)" 557 " (pool-mirror-up|pool-mirror-down|vlan-mirror)" 558 " (poolmask|vlanid[,vlanid]*) dst-pool (pool_id) (on|off)\n" 559 " Set pool or vlan type mirror rule on a port.\n" 560 " e.g., 'set port 0 mirror-rule 0 vlan-mirror 0,1" 561 " dst-pool 0 on' enable mirror traffic with vlan 0,1" 562 " to pool 0.\n\n" 563 564 "set port (port_id) mirror-rule (rule_id)" 565 " (uplink-mirror|downlink-mirror) dst-pool" 566 " (pool_id) (on|off)\n" 567 " Set uplink or downlink type mirror rule on a port.\n" 568 " e.g., 'set port 0 mirror-rule 0 uplink-mirror dst-pool" 569 " 0 on' enable mirror income traffic to pool 0.\n\n" 570 571 "reset port (port_id) mirror-rule (rule_id)\n" 572 " Reset a mirror rule.\n\n" 573 574 "set flush_rx (on|off)\n" 575 " Flush (default) or don't flush RX streams before" 576 " forwarding. Mainly used with PCAP drivers.\n\n" 577 578 "set bypass mode (normal|bypass|isolate) (port_id)\n" 579 " Set the bypass mode for the lowest port on bypass enabled" 580 " NIC.\n\n" 581 582 "set bypass event (timeout|os_on|os_off|power_on|power_off) " 583 "mode (normal|bypass|isolate) (port_id)\n" 584 " Set the event required to initiate specified bypass mode for" 585 " the lowest port on a bypass enabled NIC where:\n" 586 " timeout = enable bypass after watchdog timeout.\n" 587 " os_on = enable bypass when OS/board is powered on.\n" 588 " os_off = enable bypass when OS/board is powered off.\n" 589 " power_on = enable bypass when power supply is turned on.\n" 590 " power_off = enable bypass when power supply is turned off." 591 "\n\n" 592 593 "set bypass timeout (0|1.5|2|3|4|8|16|32)\n" 594 " Set the bypass watchdog timeout to 'n' seconds" 595 " where 0 = instant.\n\n" 596 597 "show bypass config (port_id)\n" 598 " Show the bypass configuration for a bypass enabled NIC" 599 " using the lowest port on the NIC.\n\n" 600 601 #ifdef RTE_LIBRTE_PMD_BOND 602 "create bonded device (mode) (socket)\n" 603 " Create a new bonded device with specific bonding mode and socket.\n\n" 604 605 "add bonding slave (slave_id) (port_id)\n" 606 " Add a slave device to a bonded device.\n\n" 607 608 "remove bonding slave (slave_id) (port_id)\n" 609 " Remove a slave device from a bonded device.\n\n" 610 611 "set bonding mode (value) (port_id)\n" 612 " Set the bonding mode on a bonded device.\n\n" 613 614 "set bonding primary (slave_id) (port_id)\n" 615 " Set the primary slave for a bonded device.\n\n" 616 617 "show bonding config (port_id)\n" 618 " Show the bonding config for port_id.\n\n" 619 620 "set bonding mac_addr (port_id) (address)\n" 621 " Set the MAC address of a bonded device.\n\n" 622 623 "set bonding mode IEEE802.3AD aggregator policy (port_id) (agg_name)" 624 " Set Aggregation mode for IEEE802.3AD (mode 4)" 625 626 "set bonding xmit_balance_policy (port_id) (l2|l23|l34)\n" 627 " Set the transmit balance policy for bonded device running in balance mode.\n\n" 628 629 "set bonding mon_period (port_id) (value)\n" 630 " Set the bonding link status monitoring polling period in ms.\n\n" 631 632 "set bonding lacp dedicated_queues <port_id> (enable|disable)\n" 633 " Enable/disable dedicated queues for LACP control traffic.\n\n" 634 635 #endif 636 "set link-up port (port_id)\n" 637 " Set link up for a port.\n\n" 638 639 "set link-down port (port_id)\n" 640 " Set link down for a port.\n\n" 641 642 "E-tag set insertion on port-tag-id (value)" 643 " port (port_id) vf (vf_id)\n" 644 " Enable E-tag insertion for a VF on a port\n\n" 645 646 "E-tag set insertion off port (port_id) vf (vf_id)\n" 647 " Disable E-tag insertion for a VF on a port\n\n" 648 649 "E-tag set stripping (on|off) port (port_id)\n" 650 " Enable/disable E-tag stripping on a port\n\n" 651 652 "E-tag set forwarding (on|off) port (port_id)\n" 653 " Enable/disable E-tag based forwarding" 654 " on a port\n\n" 655 656 "E-tag set filter add e-tag-id (value) dst-pool" 657 " (pool_id) port (port_id)\n" 658 " Add an E-tag forwarding filter on a port\n\n" 659 660 "E-tag set filter del e-tag-id (value) port (port_id)\n" 661 " Delete an E-tag forwarding filter on a port\n\n" 662 663 #if defined RTE_LIBRTE_PMD_SOFTNIC && defined RTE_LIBRTE_SCHED 664 "set port tm hierarchy default (port_id)\n" 665 " Set default traffic Management hierarchy on a port\n\n" 666 667 #endif 668 "ddp add (port_id) (profile_path[,output_path])\n" 669 " Load a profile package on a port\n\n" 670 671 "ddp del (port_id) (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) queue-region region_id (value) " 687 "queue_start_index (value) queue_num (value)\n" 688 " Set a queue region on a port\n\n" 689 690 "set port (port_id) queue-region region_id (value) " 691 "flowtype (value)\n" 692 " Set a flowtype region index on a port\n\n" 693 694 "set port (port_id) queue-region UP (value) region_id (value)\n" 695 " Set the mapping of User Priority to " 696 "queue region on a port\n\n" 697 698 "set port (port_id) queue-region flush (on|off)\n" 699 " flush all queue region related configuration\n\n" 700 701 "show port meter cap (port_id)\n" 702 " Show port meter capability information\n\n" 703 704 "add port meter profile srtcm_rfc2697 (port_id) (profile_id) (cir) (cbs) (ebs)\n" 705 " meter profile add - srtcm rfc 2697\n\n" 706 707 "add port meter profile trtcm_rfc2698 (port_id) (profile_id) (cir) (pir) (cbs) (pbs)\n" 708 " meter profile add - trtcm rfc 2698\n\n" 709 710 "add port meter profile trtcm_rfc4115 (port_id) (profile_id) (cir) (eir) (cbs) (ebs)\n" 711 " meter profile add - trtcm rfc 4115\n\n" 712 713 "del port meter profile (port_id) (profile_id)\n" 714 " meter profile delete\n\n" 715 716 "create port meter (port_id) (mtr_id) (profile_id) (meter_enable)\n" 717 "(g_action) (y_action) (r_action) (stats_mask) (shared)\n" 718 "(use_pre_meter_color) [(dscp_tbl_entry0) (dscp_tbl_entry1)...\n" 719 "(dscp_tbl_entry63)]\n" 720 " meter create\n\n" 721 722 "enable port meter (port_id) (mtr_id)\n" 723 " meter enable\n\n" 724 725 "disable port meter (port_id) (mtr_id)\n" 726 " meter disable\n\n" 727 728 "del port meter (port_id) (mtr_id)\n" 729 " meter delete\n\n" 730 731 "set port meter profile (port_id) (mtr_id) (profile_id)\n" 732 " meter update meter profile\n\n" 733 734 "set port meter dscp table (port_id) (mtr_id) [(dscp_tbl_entry0)\n" 735 "(dscp_tbl_entry1)...(dscp_tbl_entry63)]\n" 736 " update meter dscp table entries\n\n" 737 738 "set port meter policer action (port_id) (mtr_id) (action_mask)\n" 739 "(action0) [(action1) (action2)]\n" 740 " meter update policer action\n\n" 741 742 "set port meter stats mask (port_id) (mtr_id) (stats_mask)\n" 743 " meter update stats\n\n" 744 745 "show port (port_id) queue-region\n" 746 " show all queue region related configuration info\n\n" 747 748 "add port tm node shaper profile (port_id) (shaper_profile_id)" 749 " (tb_rate) (tb_size) (packet_length_adjust)\n" 750 " Add port tm node private shaper profile.\n\n" 751 752 "del port tm node shaper profile (port_id) (shaper_profile_id)\n" 753 " Delete port tm node private shaper profile.\n\n" 754 755 "add port tm node shared shaper (port_id) (shared_shaper_id)" 756 " (shaper_profile_id)\n" 757 " Add/update port tm node shared shaper.\n\n" 758 759 "del port tm node shared shaper (port_id) (shared_shaper_id)\n" 760 " Delete port tm node shared shaper.\n\n" 761 762 "set port tm node shaper profile (port_id) (node_id)" 763 " (shaper_profile_id)\n" 764 " Set port tm node shaper profile.\n\n" 765 766 "add port tm node wred profile (port_id) (wred_profile_id)" 767 " (color_g) (min_th_g) (max_th_g) (maxp_inv_g) (wq_log2_g)" 768 " (color_y) (min_th_y) (max_th_y) (maxp_inv_y) (wq_log2_y)" 769 " (color_r) (min_th_r) (max_th_r) (maxp_inv_r) (wq_log2_r)\n" 770 " Add port tm node wred profile.\n\n" 771 772 "del port tm node wred profile (port_id) (wred_profile_id)\n" 773 " Delete port tm node wred profile.\n\n" 774 775 "add port tm nonleaf node (port_id) (node_id) (parent_node_id)" 776 " (priority) (weight) (level_id) (shaper_profile_id)" 777 " (n_sp_priorities) (stats_mask) (n_shared_shapers)" 778 " [(shared_shaper_id_0) (shared_shaper_id_1)...]\n" 779 " Add port tm nonleaf node.\n\n" 780 781 "add port tm leaf node (port_id) (node_id) (parent_node_id)" 782 " (priority) (weight) (level_id) (shaper_profile_id)" 783 " (cman_mode) (wred_profile_id) (stats_mask) (n_shared_shapers)" 784 " [(shared_shaper_id_0) (shared_shaper_id_1)...]\n" 785 " Add port tm leaf node.\n\n" 786 787 "del port tm node (port_id) (node_id)\n" 788 " Delete port tm node.\n\n" 789 790 "set port tm node parent (port_id) (node_id) (parent_node_id)" 791 " (priority) (weight)\n" 792 " Set port tm node parent.\n\n" 793 794 "port tm hierarchy commit (port_id) (clean_on_fail)\n" 795 " Commit tm hierarchy.\n\n" 796 797 , list_pkt_forwarding_modes() 798 ); 799 } 800 801 if (show_all || !strcmp(res->section, "ports")) { 802 803 cmdline_printf( 804 cl, 805 "\n" 806 "Port Operations:\n" 807 "----------------\n\n" 808 809 "port start (port_id|all)\n" 810 " Start all ports or port_id.\n\n" 811 812 "port stop (port_id|all)\n" 813 " Stop all ports or port_id.\n\n" 814 815 "port close (port_id|all)\n" 816 " Close all ports or port_id.\n\n" 817 818 "port attach (ident)\n" 819 " Attach physical or virtual dev by pci address or virtual device name\n\n" 820 821 "port detach (port_id)\n" 822 " Detach physical or virtual dev by port_id\n\n" 823 824 "port config (port_id|all)" 825 " speed (10|100|1000|10000|25000|40000|50000|100000|auto)" 826 " duplex (half|full|auto)\n" 827 " Set speed and duplex for all ports or port_id\n\n" 828 829 "port config all (rxq|txq|rxd|txd) (value)\n" 830 " Set number for rxq/txq/rxd/txd.\n\n" 831 832 "port config all max-pkt-len (value)\n" 833 " Set the max packet length.\n\n" 834 835 "port config all (crc-strip|scatter|rx-cksum|rx-timestamp|hw-vlan|hw-vlan-filter|" 836 "hw-vlan-strip|hw-vlan-extend|drop-en)" 837 " (on|off)\n" 838 " Set crc-strip/scatter/rx-checksum/hardware-vlan/drop_en" 839 " for ports.\n\n" 840 841 "port config all rss (all|ip|tcp|udp|sctp|ether|port|vxlan|" 842 "geneve|nvgre|none|<flowtype_id>)\n" 843 " Set the RSS mode.\n\n" 844 845 "port config port-id rss reta (hash,queue)[,(hash,queue)]\n" 846 " Set the RSS redirection table.\n\n" 847 848 "port config (port_id) dcb vt (on|off) (traffic_class)" 849 " pfc (on|off)\n" 850 " Set the DCB mode.\n\n" 851 852 "port config all burst (value)\n" 853 " Set the number of packets per burst.\n\n" 854 855 "port config all (txpt|txht|txwt|rxpt|rxht|rxwt)" 856 " (value)\n" 857 " Set the ring prefetch/host/writeback threshold" 858 " for tx/rx queue.\n\n" 859 860 "port config all (txfreet|txrst|rxfreet) (value)\n" 861 " Set free threshold for rx/tx, or set" 862 " tx rs bit threshold.\n\n" 863 "port config mtu X value\n" 864 " Set the MTU of port X to a given value\n\n" 865 866 "port (port_id) (rxq|txq) (queue_id) (start|stop)\n" 867 " Start/stop a rx/tx queue of port X. Only take effect" 868 " when port X is started\n\n" 869 870 "port config (port_id|all) l2-tunnel E-tag ether-type" 871 " (value)\n" 872 " Set the value of E-tag ether-type.\n\n" 873 874 "port config (port_id|all) l2-tunnel E-tag" 875 " (enable|disable)\n" 876 " Enable/disable the E-tag support.\n\n" 877 878 "port config (port_id) pctype mapping reset\n" 879 " Reset flow type to pctype mapping on a port\n\n" 880 881 "port config (port_id) pctype mapping update" 882 " (pctype_id_0[,pctype_id_1]*) (flow_type_id)\n" 883 " Update a flow type to pctype mapping item on a port\n\n" 884 ); 885 } 886 887 if (show_all || !strcmp(res->section, "registers")) { 888 889 cmdline_printf( 890 cl, 891 "\n" 892 "Registers:\n" 893 "----------\n\n" 894 895 "read reg (port_id) (address)\n" 896 " Display value of a port register.\n\n" 897 898 "read regfield (port_id) (address) (bit_x) (bit_y)\n" 899 " Display a port register bit field.\n\n" 900 901 "read regbit (port_id) (address) (bit_x)\n" 902 " Display a single port register bit.\n\n" 903 904 "write reg (port_id) (address) (value)\n" 905 " Set value of a port register.\n\n" 906 907 "write regfield (port_id) (address) (bit_x) (bit_y)" 908 " (value)\n" 909 " Set bit field of a port register.\n\n" 910 911 "write regbit (port_id) (address) (bit_x) (value)\n" 912 " Set single bit value of a port register.\n\n" 913 ); 914 } 915 if (show_all || !strcmp(res->section, "filters")) { 916 917 cmdline_printf( 918 cl, 919 "\n" 920 "filters:\n" 921 "--------\n\n" 922 923 "ethertype_filter (port_id) (add|del)" 924 " (mac_addr|mac_ignr) (mac_address) ethertype" 925 " (ether_type) (drop|fwd) queue (queue_id)\n" 926 " Add/Del an ethertype filter.\n\n" 927 928 "2tuple_filter (port_id) (add|del)" 929 " dst_port (dst_port_value) protocol (protocol_value)" 930 " mask (mask_value) tcp_flags (tcp_flags_value)" 931 " priority (prio_value) queue (queue_id)\n" 932 " Add/Del a 2tuple filter.\n\n" 933 934 "5tuple_filter (port_id) (add|del)" 935 " dst_ip (dst_address) src_ip (src_address)" 936 " dst_port (dst_port_value) src_port (src_port_value)" 937 " protocol (protocol_value)" 938 " mask (mask_value) tcp_flags (tcp_flags_value)" 939 " priority (prio_value) queue (queue_id)\n" 940 " Add/Del a 5tuple filter.\n\n" 941 942 "syn_filter (port_id) (add|del) priority (high|low) queue (queue_id)" 943 " Add/Del syn filter.\n\n" 944 945 "flex_filter (port_id) (add|del) len (len_value)" 946 " bytes (bytes_value) mask (mask_value)" 947 " priority (prio_value) queue (queue_id)\n" 948 " Add/Del a flex filter.\n\n" 949 950 "flow_director_filter (port_id) mode IP (add|del|update)" 951 " flow (ipv4-other|ipv4-frag|ipv6-other|ipv6-frag)" 952 " src (src_ip_address) dst (dst_ip_address)" 953 " tos (tos_value) proto (proto_value) ttl (ttl_value)" 954 " vlan (vlan_value) flexbytes (flexbytes_value)" 955 " (drop|fwd) pf|vf(vf_id) queue (queue_id)" 956 " fd_id (fd_id_value)\n" 957 " Add/Del an IP type flow director filter.\n\n" 958 959 "flow_director_filter (port_id) mode IP (add|del|update)" 960 " flow (ipv4-tcp|ipv4-udp|ipv6-tcp|ipv6-udp)" 961 " src (src_ip_address) (src_port)" 962 " dst (dst_ip_address) (dst_port)" 963 " tos (tos_value) ttl (ttl_value)" 964 " vlan (vlan_value) flexbytes (flexbytes_value)" 965 " (drop|fwd) pf|vf(vf_id) queue (queue_id)" 966 " fd_id (fd_id_value)\n" 967 " Add/Del an UDP/TCP type flow director filter.\n\n" 968 969 "flow_director_filter (port_id) mode IP (add|del|update)" 970 " flow (ipv4-sctp|ipv6-sctp)" 971 " src (src_ip_address) (src_port)" 972 " dst (dst_ip_address) (dst_port)" 973 " tag (verification_tag) " 974 " tos (tos_value) ttl (ttl_value)" 975 " vlan (vlan_value)" 976 " flexbytes (flexbytes_value) (drop|fwd)" 977 " pf|vf(vf_id) queue (queue_id) fd_id (fd_id_value)\n" 978 " Add/Del a SCTP type flow director filter.\n\n" 979 980 "flow_director_filter (port_id) mode IP (add|del|update)" 981 " flow l2_payload ether (ethertype)" 982 " flexbytes (flexbytes_value) (drop|fwd)" 983 " pf|vf(vf_id) queue (queue_id) fd_id (fd_id_value)\n" 984 " Add/Del a l2 payload type flow director filter.\n\n" 985 986 "flow_director_filter (port_id) mode MAC-VLAN (add|del|update)" 987 " mac (mac_address) vlan (vlan_value)" 988 " flexbytes (flexbytes_value) (drop|fwd)" 989 " queue (queue_id) fd_id (fd_id_value)\n" 990 " Add/Del a MAC-VLAN flow director filter.\n\n" 991 992 "flow_director_filter (port_id) mode Tunnel (add|del|update)" 993 " mac (mac_address) vlan (vlan_value)" 994 " tunnel (NVGRE|VxLAN) tunnel-id (tunnel_id_value)" 995 " flexbytes (flexbytes_value) (drop|fwd)" 996 " queue (queue_id) fd_id (fd_id_value)\n" 997 " Add/Del a Tunnel flow director filter.\n\n" 998 999 "flush_flow_director (port_id)\n" 1000 " Flush all flow director entries of a device.\n\n" 1001 1002 "flow_director_mask (port_id) mode IP vlan (vlan_value)" 1003 " src_mask (ipv4_src) (ipv6_src) (src_port)" 1004 " dst_mask (ipv4_dst) (ipv6_dst) (dst_port)\n" 1005 " Set flow director IP mask.\n\n" 1006 1007 "flow_director_mask (port_id) mode MAC-VLAN" 1008 " vlan (vlan_value)\n" 1009 " Set flow director MAC-VLAN mask.\n\n" 1010 1011 "flow_director_mask (port_id) mode Tunnel" 1012 " vlan (vlan_value) mac (mac_value)" 1013 " tunnel-type (tunnel_type_value)" 1014 " tunnel-id (tunnel_id_value)\n" 1015 " Set flow director Tunnel mask.\n\n" 1016 1017 "flow_director_flex_mask (port_id)" 1018 " flow (none|ipv4-other|ipv4-frag|ipv4-tcp|ipv4-udp|ipv4-sctp|" 1019 "ipv6-other|ipv6-frag|ipv6-tcp|ipv6-udp|ipv6-sctp|l2_payload|all)" 1020 " (mask)\n" 1021 " Configure mask of flex payload.\n\n" 1022 1023 "flow_director_flex_payload (port_id)" 1024 " (raw|l2|l3|l4) (config)\n" 1025 " Configure flex payload selection.\n\n" 1026 1027 "get_sym_hash_ena_per_port (port_id)\n" 1028 " get symmetric hash enable configuration per port.\n\n" 1029 1030 "set_sym_hash_ena_per_port (port_id) (enable|disable)\n" 1031 " set symmetric hash enable configuration per port" 1032 " to enable or disable.\n\n" 1033 1034 "get_hash_global_config (port_id)\n" 1035 " Get the global configurations of hash filters.\n\n" 1036 1037 "set_hash_global_config (port_id) (toeplitz|simple_xor|default)" 1038 " (ipv4|ipv4-frag|ipv4-tcp|ipv4-udp|ipv4-sctp|ipv4-other|ipv6|" 1039 "ipv6-frag|ipv6-tcp|ipv6-udp|ipv6-sctp|ipv6-other|l2_payload)" 1040 " (enable|disable)\n" 1041 " Set the global configurations of hash filters.\n\n" 1042 1043 "set_hash_input_set (port_id) (ipv4|ipv4-frag|" 1044 "ipv4-tcp|ipv4-udp|ipv4-sctp|ipv4-other|ipv6|" 1045 "ipv6-frag|ipv6-tcp|ipv6-udp|ipv6-sctp|ipv6-other|" 1046 "l2_payload|<flowtype_id>) (ovlan|ivlan|src-ipv4|dst-ipv4|" 1047 "src-ipv6|dst-ipv6|ipv4-tos|ipv4-proto|ipv6-tc|" 1048 "ipv6-next-header|udp-src-port|udp-dst-port|" 1049 "tcp-src-port|tcp-dst-port|sctp-src-port|" 1050 "sctp-dst-port|sctp-veri-tag|udp-key|gre-key|fld-1st|" 1051 "fld-2nd|fld-3rd|fld-4th|fld-5th|fld-6th|fld-7th|" 1052 "fld-8th|none) (select|add)\n" 1053 " Set the input set for hash.\n\n" 1054 1055 "set_fdir_input_set (port_id) " 1056 "(ipv4-frag|ipv4-tcp|ipv4-udp|ipv4-sctp|ipv4-other|" 1057 "ipv6-frag|ipv6-tcp|ipv6-udp|ipv6-sctp|ipv6-other|" 1058 "l2_payload) (ivlan|ethertype|src-ipv4|dst-ipv4|src-ipv6|" 1059 "dst-ipv6|ipv4-tos|ipv4-proto|ipv4-ttl|ipv6-tc|" 1060 "ipv6-next-header|ipv6-hop-limits|udp-src-port|" 1061 "udp-dst-port|tcp-src-port|tcp-dst-port|" 1062 "sctp-src-port|sctp-dst-port|sctp-veri-tag|none)" 1063 " (select|add)\n" 1064 " Set the input set for FDir.\n\n" 1065 1066 "flow validate {port_id}" 1067 " [group {group_id}] [priority {level}]" 1068 " [ingress] [egress]" 1069 " pattern {item} [/ {item} [...]] / end" 1070 " actions {action} [/ {action} [...]] / end\n" 1071 " Check whether a flow rule can be created.\n\n" 1072 1073 "flow create {port_id}" 1074 " [group {group_id}] [priority {level}]" 1075 " [ingress] [egress]" 1076 " pattern {item} [/ {item} [...]] / end" 1077 " actions {action} [/ {action} [...]] / end\n" 1078 " Create a flow rule.\n\n" 1079 1080 "flow destroy {port_id} rule {rule_id} [...]\n" 1081 " Destroy specific flow rules.\n\n" 1082 1083 "flow flush {port_id}\n" 1084 " Destroy all flow rules.\n\n" 1085 1086 "flow query {port_id} {rule_id} {action}\n" 1087 " Query an existing flow rule.\n\n" 1088 1089 "flow list {port_id} [group {group_id}] [...]\n" 1090 " List existing flow rules sorted by priority," 1091 " filtered by group identifiers.\n\n" 1092 1093 "flow isolate {port_id} {boolean}\n" 1094 " Restrict ingress traffic to the defined" 1095 " flow rules\n\n" 1096 ); 1097 } 1098 } 1099 1100 cmdline_parse_token_string_t cmd_help_long_help = 1101 TOKEN_STRING_INITIALIZER(struct cmd_help_long_result, help, "help"); 1102 1103 cmdline_parse_token_string_t cmd_help_long_section = 1104 TOKEN_STRING_INITIALIZER(struct cmd_help_long_result, section, 1105 "all#control#display#config#" 1106 "ports#registers#filters"); 1107 1108 cmdline_parse_inst_t cmd_help_long = { 1109 .f = cmd_help_long_parsed, 1110 .data = NULL, 1111 .help_str = "help all|control|display|config|ports|register|filters: " 1112 "Show help", 1113 .tokens = { 1114 (void *)&cmd_help_long_help, 1115 (void *)&cmd_help_long_section, 1116 NULL, 1117 }, 1118 }; 1119 1120 1121 /* *** start/stop/close all ports *** */ 1122 struct cmd_operate_port_result { 1123 cmdline_fixed_string_t keyword; 1124 cmdline_fixed_string_t name; 1125 cmdline_fixed_string_t value; 1126 }; 1127 1128 static void cmd_operate_port_parsed(void *parsed_result, 1129 __attribute__((unused)) struct cmdline *cl, 1130 __attribute__((unused)) void *data) 1131 { 1132 struct cmd_operate_port_result *res = parsed_result; 1133 1134 if (!strcmp(res->name, "start")) 1135 start_port(RTE_PORT_ALL); 1136 else if (!strcmp(res->name, "stop")) 1137 stop_port(RTE_PORT_ALL); 1138 else if (!strcmp(res->name, "close")) 1139 close_port(RTE_PORT_ALL); 1140 else if (!strcmp(res->name, "reset")) 1141 reset_port(RTE_PORT_ALL); 1142 else 1143 printf("Unknown parameter\n"); 1144 } 1145 1146 cmdline_parse_token_string_t cmd_operate_port_all_cmd = 1147 TOKEN_STRING_INITIALIZER(struct cmd_operate_port_result, keyword, 1148 "port"); 1149 cmdline_parse_token_string_t cmd_operate_port_all_port = 1150 TOKEN_STRING_INITIALIZER(struct cmd_operate_port_result, name, 1151 "start#stop#close#reset"); 1152 cmdline_parse_token_string_t cmd_operate_port_all_all = 1153 TOKEN_STRING_INITIALIZER(struct cmd_operate_port_result, value, "all"); 1154 1155 cmdline_parse_inst_t cmd_operate_port = { 1156 .f = cmd_operate_port_parsed, 1157 .data = NULL, 1158 .help_str = "port start|stop|close all: Start/Stop/Close/Reset all ports", 1159 .tokens = { 1160 (void *)&cmd_operate_port_all_cmd, 1161 (void *)&cmd_operate_port_all_port, 1162 (void *)&cmd_operate_port_all_all, 1163 NULL, 1164 }, 1165 }; 1166 1167 /* *** start/stop/close specific port *** */ 1168 struct cmd_operate_specific_port_result { 1169 cmdline_fixed_string_t keyword; 1170 cmdline_fixed_string_t name; 1171 uint8_t value; 1172 }; 1173 1174 static void cmd_operate_specific_port_parsed(void *parsed_result, 1175 __attribute__((unused)) struct cmdline *cl, 1176 __attribute__((unused)) void *data) 1177 { 1178 struct cmd_operate_specific_port_result *res = parsed_result; 1179 1180 if (!strcmp(res->name, "start")) 1181 start_port(res->value); 1182 else if (!strcmp(res->name, "stop")) 1183 stop_port(res->value); 1184 else if (!strcmp(res->name, "close")) 1185 close_port(res->value); 1186 else if (!strcmp(res->name, "reset")) 1187 reset_port(res->value); 1188 else 1189 printf("Unknown parameter\n"); 1190 } 1191 1192 cmdline_parse_token_string_t cmd_operate_specific_port_cmd = 1193 TOKEN_STRING_INITIALIZER(struct cmd_operate_specific_port_result, 1194 keyword, "port"); 1195 cmdline_parse_token_string_t cmd_operate_specific_port_port = 1196 TOKEN_STRING_INITIALIZER(struct cmd_operate_specific_port_result, 1197 name, "start#stop#close#reset"); 1198 cmdline_parse_token_num_t cmd_operate_specific_port_id = 1199 TOKEN_NUM_INITIALIZER(struct cmd_operate_specific_port_result, 1200 value, UINT8); 1201 1202 cmdline_parse_inst_t cmd_operate_specific_port = { 1203 .f = cmd_operate_specific_port_parsed, 1204 .data = NULL, 1205 .help_str = "port start|stop|close <port_id>: Start/Stop/Close/Reset port_id", 1206 .tokens = { 1207 (void *)&cmd_operate_specific_port_cmd, 1208 (void *)&cmd_operate_specific_port_port, 1209 (void *)&cmd_operate_specific_port_id, 1210 NULL, 1211 }, 1212 }; 1213 1214 /* *** attach a specified port *** */ 1215 struct cmd_operate_attach_port_result { 1216 cmdline_fixed_string_t port; 1217 cmdline_fixed_string_t keyword; 1218 cmdline_fixed_string_t identifier; 1219 }; 1220 1221 static void cmd_operate_attach_port_parsed(void *parsed_result, 1222 __attribute__((unused)) struct cmdline *cl, 1223 __attribute__((unused)) void *data) 1224 { 1225 struct cmd_operate_attach_port_result *res = parsed_result; 1226 1227 if (!strcmp(res->keyword, "attach")) 1228 attach_port(res->identifier); 1229 else 1230 printf("Unknown parameter\n"); 1231 } 1232 1233 cmdline_parse_token_string_t cmd_operate_attach_port_port = 1234 TOKEN_STRING_INITIALIZER(struct cmd_operate_attach_port_result, 1235 port, "port"); 1236 cmdline_parse_token_string_t cmd_operate_attach_port_keyword = 1237 TOKEN_STRING_INITIALIZER(struct cmd_operate_attach_port_result, 1238 keyword, "attach"); 1239 cmdline_parse_token_string_t cmd_operate_attach_port_identifier = 1240 TOKEN_STRING_INITIALIZER(struct cmd_operate_attach_port_result, 1241 identifier, NULL); 1242 1243 cmdline_parse_inst_t cmd_operate_attach_port = { 1244 .f = cmd_operate_attach_port_parsed, 1245 .data = NULL, 1246 .help_str = "port attach <identifier>: " 1247 "(identifier: pci address or virtual dev name)", 1248 .tokens = { 1249 (void *)&cmd_operate_attach_port_port, 1250 (void *)&cmd_operate_attach_port_keyword, 1251 (void *)&cmd_operate_attach_port_identifier, 1252 NULL, 1253 }, 1254 }; 1255 1256 /* *** detach a specified port *** */ 1257 struct cmd_operate_detach_port_result { 1258 cmdline_fixed_string_t port; 1259 cmdline_fixed_string_t keyword; 1260 portid_t port_id; 1261 }; 1262 1263 static void cmd_operate_detach_port_parsed(void *parsed_result, 1264 __attribute__((unused)) struct cmdline *cl, 1265 __attribute__((unused)) void *data) 1266 { 1267 struct cmd_operate_detach_port_result *res = parsed_result; 1268 1269 if (!strcmp(res->keyword, "detach")) 1270 detach_port(res->port_id); 1271 else 1272 printf("Unknown parameter\n"); 1273 } 1274 1275 cmdline_parse_token_string_t cmd_operate_detach_port_port = 1276 TOKEN_STRING_INITIALIZER(struct cmd_operate_detach_port_result, 1277 port, "port"); 1278 cmdline_parse_token_string_t cmd_operate_detach_port_keyword = 1279 TOKEN_STRING_INITIALIZER(struct cmd_operate_detach_port_result, 1280 keyword, "detach"); 1281 cmdline_parse_token_num_t cmd_operate_detach_port_port_id = 1282 TOKEN_NUM_INITIALIZER(struct cmd_operate_detach_port_result, 1283 port_id, UINT16); 1284 1285 cmdline_parse_inst_t cmd_operate_detach_port = { 1286 .f = cmd_operate_detach_port_parsed, 1287 .data = NULL, 1288 .help_str = "port detach <port_id>", 1289 .tokens = { 1290 (void *)&cmd_operate_detach_port_port, 1291 (void *)&cmd_operate_detach_port_keyword, 1292 (void *)&cmd_operate_detach_port_port_id, 1293 NULL, 1294 }, 1295 }; 1296 1297 /* *** configure speed for all ports *** */ 1298 struct cmd_config_speed_all { 1299 cmdline_fixed_string_t port; 1300 cmdline_fixed_string_t keyword; 1301 cmdline_fixed_string_t all; 1302 cmdline_fixed_string_t item1; 1303 cmdline_fixed_string_t item2; 1304 cmdline_fixed_string_t value1; 1305 cmdline_fixed_string_t value2; 1306 }; 1307 1308 static int 1309 parse_and_check_speed_duplex(char *speedstr, char *duplexstr, uint32_t *speed) 1310 { 1311 1312 int duplex; 1313 1314 if (!strcmp(duplexstr, "half")) { 1315 duplex = ETH_LINK_HALF_DUPLEX; 1316 } else if (!strcmp(duplexstr, "full")) { 1317 duplex = ETH_LINK_FULL_DUPLEX; 1318 } else if (!strcmp(duplexstr, "auto")) { 1319 duplex = ETH_LINK_FULL_DUPLEX; 1320 } else { 1321 printf("Unknown duplex parameter\n"); 1322 return -1; 1323 } 1324 1325 if (!strcmp(speedstr, "10")) { 1326 *speed = (duplex == ETH_LINK_HALF_DUPLEX) ? 1327 ETH_LINK_SPEED_10M_HD : ETH_LINK_SPEED_10M; 1328 } else if (!strcmp(speedstr, "100")) { 1329 *speed = (duplex == ETH_LINK_HALF_DUPLEX) ? 1330 ETH_LINK_SPEED_100M_HD : ETH_LINK_SPEED_100M; 1331 } else { 1332 if (duplex != ETH_LINK_FULL_DUPLEX) { 1333 printf("Invalid speed/duplex parameters\n"); 1334 return -1; 1335 } 1336 if (!strcmp(speedstr, "1000")) { 1337 *speed = ETH_LINK_SPEED_1G; 1338 } else if (!strcmp(speedstr, "10000")) { 1339 *speed = ETH_LINK_SPEED_10G; 1340 } else if (!strcmp(speedstr, "25000")) { 1341 *speed = ETH_LINK_SPEED_25G; 1342 } else if (!strcmp(speedstr, "40000")) { 1343 *speed = ETH_LINK_SPEED_40G; 1344 } else if (!strcmp(speedstr, "50000")) { 1345 *speed = ETH_LINK_SPEED_50G; 1346 } else if (!strcmp(speedstr, "100000")) { 1347 *speed = ETH_LINK_SPEED_100G; 1348 } else if (!strcmp(speedstr, "auto")) { 1349 *speed = ETH_LINK_SPEED_AUTONEG; 1350 } else { 1351 printf("Unknown speed parameter\n"); 1352 return -1; 1353 } 1354 } 1355 1356 return 0; 1357 } 1358 1359 static void 1360 cmd_config_speed_all_parsed(void *parsed_result, 1361 __attribute__((unused)) struct cmdline *cl, 1362 __attribute__((unused)) void *data) 1363 { 1364 struct cmd_config_speed_all *res = parsed_result; 1365 uint32_t link_speed; 1366 portid_t pid; 1367 1368 if (!all_ports_stopped()) { 1369 printf("Please stop all ports first\n"); 1370 return; 1371 } 1372 1373 if (parse_and_check_speed_duplex(res->value1, res->value2, 1374 &link_speed) < 0) 1375 return; 1376 1377 RTE_ETH_FOREACH_DEV(pid) { 1378 ports[pid].dev_conf.link_speeds = link_speed; 1379 } 1380 1381 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1); 1382 } 1383 1384 cmdline_parse_token_string_t cmd_config_speed_all_port = 1385 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_all, port, "port"); 1386 cmdline_parse_token_string_t cmd_config_speed_all_keyword = 1387 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_all, keyword, 1388 "config"); 1389 cmdline_parse_token_string_t cmd_config_speed_all_all = 1390 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_all, all, "all"); 1391 cmdline_parse_token_string_t cmd_config_speed_all_item1 = 1392 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_all, item1, "speed"); 1393 cmdline_parse_token_string_t cmd_config_speed_all_value1 = 1394 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_all, value1, 1395 "10#100#1000#10000#25000#40000#50000#100000#auto"); 1396 cmdline_parse_token_string_t cmd_config_speed_all_item2 = 1397 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_all, item2, "duplex"); 1398 cmdline_parse_token_string_t cmd_config_speed_all_value2 = 1399 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_all, value2, 1400 "half#full#auto"); 1401 1402 cmdline_parse_inst_t cmd_config_speed_all = { 1403 .f = cmd_config_speed_all_parsed, 1404 .data = NULL, 1405 .help_str = "port config all speed " 1406 "10|100|1000|10000|25000|40000|50000|100000|auto duplex " 1407 "half|full|auto", 1408 .tokens = { 1409 (void *)&cmd_config_speed_all_port, 1410 (void *)&cmd_config_speed_all_keyword, 1411 (void *)&cmd_config_speed_all_all, 1412 (void *)&cmd_config_speed_all_item1, 1413 (void *)&cmd_config_speed_all_value1, 1414 (void *)&cmd_config_speed_all_item2, 1415 (void *)&cmd_config_speed_all_value2, 1416 NULL, 1417 }, 1418 }; 1419 1420 /* *** configure speed for specific port *** */ 1421 struct cmd_config_speed_specific { 1422 cmdline_fixed_string_t port; 1423 cmdline_fixed_string_t keyword; 1424 uint8_t id; 1425 cmdline_fixed_string_t item1; 1426 cmdline_fixed_string_t item2; 1427 cmdline_fixed_string_t value1; 1428 cmdline_fixed_string_t value2; 1429 }; 1430 1431 static void 1432 cmd_config_speed_specific_parsed(void *parsed_result, 1433 __attribute__((unused)) struct cmdline *cl, 1434 __attribute__((unused)) void *data) 1435 { 1436 struct cmd_config_speed_specific *res = parsed_result; 1437 uint32_t link_speed; 1438 1439 if (!all_ports_stopped()) { 1440 printf("Please stop all ports first\n"); 1441 return; 1442 } 1443 1444 if (port_id_is_invalid(res->id, ENABLED_WARN)) 1445 return; 1446 1447 if (parse_and_check_speed_duplex(res->value1, res->value2, 1448 &link_speed) < 0) 1449 return; 1450 1451 ports[res->id].dev_conf.link_speeds = link_speed; 1452 1453 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1); 1454 } 1455 1456 1457 cmdline_parse_token_string_t cmd_config_speed_specific_port = 1458 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_specific, port, 1459 "port"); 1460 cmdline_parse_token_string_t cmd_config_speed_specific_keyword = 1461 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_specific, keyword, 1462 "config"); 1463 cmdline_parse_token_num_t cmd_config_speed_specific_id = 1464 TOKEN_NUM_INITIALIZER(struct cmd_config_speed_specific, id, UINT8); 1465 cmdline_parse_token_string_t cmd_config_speed_specific_item1 = 1466 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_specific, item1, 1467 "speed"); 1468 cmdline_parse_token_string_t cmd_config_speed_specific_value1 = 1469 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_specific, value1, 1470 "10#100#1000#10000#25000#40000#50000#100000#auto"); 1471 cmdline_parse_token_string_t cmd_config_speed_specific_item2 = 1472 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_specific, item2, 1473 "duplex"); 1474 cmdline_parse_token_string_t cmd_config_speed_specific_value2 = 1475 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_specific, value2, 1476 "half#full#auto"); 1477 1478 cmdline_parse_inst_t cmd_config_speed_specific = { 1479 .f = cmd_config_speed_specific_parsed, 1480 .data = NULL, 1481 .help_str = "port config <port_id> speed " 1482 "10|100|1000|10000|25000|40000|50000|100000|auto duplex " 1483 "half|full|auto", 1484 .tokens = { 1485 (void *)&cmd_config_speed_specific_port, 1486 (void *)&cmd_config_speed_specific_keyword, 1487 (void *)&cmd_config_speed_specific_id, 1488 (void *)&cmd_config_speed_specific_item1, 1489 (void *)&cmd_config_speed_specific_value1, 1490 (void *)&cmd_config_speed_specific_item2, 1491 (void *)&cmd_config_speed_specific_value2, 1492 NULL, 1493 }, 1494 }; 1495 1496 /* *** configure txq/rxq, txd/rxd *** */ 1497 struct cmd_config_rx_tx { 1498 cmdline_fixed_string_t port; 1499 cmdline_fixed_string_t keyword; 1500 cmdline_fixed_string_t all; 1501 cmdline_fixed_string_t name; 1502 uint16_t value; 1503 }; 1504 1505 static void 1506 cmd_config_rx_tx_parsed(void *parsed_result, 1507 __attribute__((unused)) struct cmdline *cl, 1508 __attribute__((unused)) void *data) 1509 { 1510 struct cmd_config_rx_tx *res = parsed_result; 1511 1512 if (!all_ports_stopped()) { 1513 printf("Please stop all ports first\n"); 1514 return; 1515 } 1516 if (!strcmp(res->name, "rxq")) { 1517 if (!res->value && !nb_txq) { 1518 printf("Warning: Either rx or tx queues should be non zero\n"); 1519 return; 1520 } 1521 nb_rxq = res->value; 1522 } 1523 else if (!strcmp(res->name, "txq")) { 1524 if (!res->value && !nb_rxq) { 1525 printf("Warning: Either rx or tx queues should be non zero\n"); 1526 return; 1527 } 1528 nb_txq = res->value; 1529 } 1530 else if (!strcmp(res->name, "rxd")) { 1531 if (res->value <= 0 || res->value > RTE_TEST_RX_DESC_MAX) { 1532 printf("rxd %d invalid - must be > 0 && <= %d\n", 1533 res->value, RTE_TEST_RX_DESC_MAX); 1534 return; 1535 } 1536 nb_rxd = res->value; 1537 } else if (!strcmp(res->name, "txd")) { 1538 if (res->value <= 0 || res->value > RTE_TEST_TX_DESC_MAX) { 1539 printf("txd %d invalid - must be > 0 && <= %d\n", 1540 res->value, RTE_TEST_TX_DESC_MAX); 1541 return; 1542 } 1543 nb_txd = res->value; 1544 } else { 1545 printf("Unknown parameter\n"); 1546 return; 1547 } 1548 1549 fwd_config_setup(); 1550 1551 init_port_config(); 1552 1553 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1); 1554 } 1555 1556 cmdline_parse_token_string_t cmd_config_rx_tx_port = 1557 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_tx, port, "port"); 1558 cmdline_parse_token_string_t cmd_config_rx_tx_keyword = 1559 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_tx, keyword, "config"); 1560 cmdline_parse_token_string_t cmd_config_rx_tx_all = 1561 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_tx, all, "all"); 1562 cmdline_parse_token_string_t cmd_config_rx_tx_name = 1563 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_tx, name, 1564 "rxq#txq#rxd#txd"); 1565 cmdline_parse_token_num_t cmd_config_rx_tx_value = 1566 TOKEN_NUM_INITIALIZER(struct cmd_config_rx_tx, value, UINT16); 1567 1568 cmdline_parse_inst_t cmd_config_rx_tx = { 1569 .f = cmd_config_rx_tx_parsed, 1570 .data = NULL, 1571 .help_str = "port config all rxq|txq|rxd|txd <value>", 1572 .tokens = { 1573 (void *)&cmd_config_rx_tx_port, 1574 (void *)&cmd_config_rx_tx_keyword, 1575 (void *)&cmd_config_rx_tx_all, 1576 (void *)&cmd_config_rx_tx_name, 1577 (void *)&cmd_config_rx_tx_value, 1578 NULL, 1579 }, 1580 }; 1581 1582 /* *** config max packet length *** */ 1583 struct cmd_config_max_pkt_len_result { 1584 cmdline_fixed_string_t port; 1585 cmdline_fixed_string_t keyword; 1586 cmdline_fixed_string_t all; 1587 cmdline_fixed_string_t name; 1588 uint32_t value; 1589 }; 1590 1591 static void 1592 cmd_config_max_pkt_len_parsed(void *parsed_result, 1593 __attribute__((unused)) struct cmdline *cl, 1594 __attribute__((unused)) void *data) 1595 { 1596 struct cmd_config_max_pkt_len_result *res = parsed_result; 1597 uint64_t rx_offloads = rx_mode.offloads; 1598 1599 if (!all_ports_stopped()) { 1600 printf("Please stop all ports first\n"); 1601 return; 1602 } 1603 1604 if (!strcmp(res->name, "max-pkt-len")) { 1605 if (res->value < ETHER_MIN_LEN) { 1606 printf("max-pkt-len can not be less than %d\n", 1607 ETHER_MIN_LEN); 1608 return; 1609 } 1610 if (res->value == rx_mode.max_rx_pkt_len) 1611 return; 1612 1613 rx_mode.max_rx_pkt_len = res->value; 1614 if (res->value > ETHER_MAX_LEN) 1615 rx_offloads |= DEV_RX_OFFLOAD_JUMBO_FRAME; 1616 else 1617 rx_offloads &= ~DEV_RX_OFFLOAD_JUMBO_FRAME; 1618 } else { 1619 printf("Unknown parameter\n"); 1620 return; 1621 } 1622 1623 rx_mode.offloads = rx_offloads; 1624 1625 init_port_config(); 1626 1627 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1); 1628 } 1629 1630 cmdline_parse_token_string_t cmd_config_max_pkt_len_port = 1631 TOKEN_STRING_INITIALIZER(struct cmd_config_max_pkt_len_result, port, 1632 "port"); 1633 cmdline_parse_token_string_t cmd_config_max_pkt_len_keyword = 1634 TOKEN_STRING_INITIALIZER(struct cmd_config_max_pkt_len_result, keyword, 1635 "config"); 1636 cmdline_parse_token_string_t cmd_config_max_pkt_len_all = 1637 TOKEN_STRING_INITIALIZER(struct cmd_config_max_pkt_len_result, all, 1638 "all"); 1639 cmdline_parse_token_string_t cmd_config_max_pkt_len_name = 1640 TOKEN_STRING_INITIALIZER(struct cmd_config_max_pkt_len_result, name, 1641 "max-pkt-len"); 1642 cmdline_parse_token_num_t cmd_config_max_pkt_len_value = 1643 TOKEN_NUM_INITIALIZER(struct cmd_config_max_pkt_len_result, value, 1644 UINT32); 1645 1646 cmdline_parse_inst_t cmd_config_max_pkt_len = { 1647 .f = cmd_config_max_pkt_len_parsed, 1648 .data = NULL, 1649 .help_str = "port config all max-pkt-len <value>", 1650 .tokens = { 1651 (void *)&cmd_config_max_pkt_len_port, 1652 (void *)&cmd_config_max_pkt_len_keyword, 1653 (void *)&cmd_config_max_pkt_len_all, 1654 (void *)&cmd_config_max_pkt_len_name, 1655 (void *)&cmd_config_max_pkt_len_value, 1656 NULL, 1657 }, 1658 }; 1659 1660 /* *** configure port MTU *** */ 1661 struct cmd_config_mtu_result { 1662 cmdline_fixed_string_t port; 1663 cmdline_fixed_string_t keyword; 1664 cmdline_fixed_string_t mtu; 1665 portid_t port_id; 1666 uint16_t value; 1667 }; 1668 1669 static void 1670 cmd_config_mtu_parsed(void *parsed_result, 1671 __attribute__((unused)) struct cmdline *cl, 1672 __attribute__((unused)) void *data) 1673 { 1674 struct cmd_config_mtu_result *res = parsed_result; 1675 1676 if (res->value < ETHER_MIN_LEN) { 1677 printf("mtu cannot be less than %d\n", ETHER_MIN_LEN); 1678 return; 1679 } 1680 port_mtu_set(res->port_id, res->value); 1681 } 1682 1683 cmdline_parse_token_string_t cmd_config_mtu_port = 1684 TOKEN_STRING_INITIALIZER(struct cmd_config_mtu_result, port, 1685 "port"); 1686 cmdline_parse_token_string_t cmd_config_mtu_keyword = 1687 TOKEN_STRING_INITIALIZER(struct cmd_config_mtu_result, keyword, 1688 "config"); 1689 cmdline_parse_token_string_t cmd_config_mtu_mtu = 1690 TOKEN_STRING_INITIALIZER(struct cmd_config_mtu_result, keyword, 1691 "mtu"); 1692 cmdline_parse_token_num_t cmd_config_mtu_port_id = 1693 TOKEN_NUM_INITIALIZER(struct cmd_config_mtu_result, port_id, UINT16); 1694 cmdline_parse_token_num_t cmd_config_mtu_value = 1695 TOKEN_NUM_INITIALIZER(struct cmd_config_mtu_result, value, UINT16); 1696 1697 cmdline_parse_inst_t cmd_config_mtu = { 1698 .f = cmd_config_mtu_parsed, 1699 .data = NULL, 1700 .help_str = "port config mtu <port_id> <value>", 1701 .tokens = { 1702 (void *)&cmd_config_mtu_port, 1703 (void *)&cmd_config_mtu_keyword, 1704 (void *)&cmd_config_mtu_mtu, 1705 (void *)&cmd_config_mtu_port_id, 1706 (void *)&cmd_config_mtu_value, 1707 NULL, 1708 }, 1709 }; 1710 1711 /* *** configure rx mode *** */ 1712 struct cmd_config_rx_mode_flag { 1713 cmdline_fixed_string_t port; 1714 cmdline_fixed_string_t keyword; 1715 cmdline_fixed_string_t all; 1716 cmdline_fixed_string_t name; 1717 cmdline_fixed_string_t value; 1718 }; 1719 1720 static void 1721 cmd_config_rx_mode_flag_parsed(void *parsed_result, 1722 __attribute__((unused)) struct cmdline *cl, 1723 __attribute__((unused)) void *data) 1724 { 1725 struct cmd_config_rx_mode_flag *res = parsed_result; 1726 uint64_t rx_offloads = rx_mode.offloads; 1727 1728 if (!all_ports_stopped()) { 1729 printf("Please stop all ports first\n"); 1730 return; 1731 } 1732 1733 if (!strcmp(res->name, "crc-strip")) { 1734 if (!strcmp(res->value, "on")) 1735 rx_offloads |= DEV_RX_OFFLOAD_CRC_STRIP; 1736 else if (!strcmp(res->value, "off")) 1737 rx_offloads &= ~DEV_RX_OFFLOAD_CRC_STRIP; 1738 else { 1739 printf("Unknown parameter\n"); 1740 return; 1741 } 1742 } else if (!strcmp(res->name, "scatter")) { 1743 if (!strcmp(res->value, "on")) { 1744 rx_offloads |= DEV_RX_OFFLOAD_SCATTER; 1745 } else if (!strcmp(res->value, "off")) { 1746 rx_offloads &= ~DEV_RX_OFFLOAD_SCATTER; 1747 } else { 1748 printf("Unknown parameter\n"); 1749 return; 1750 } 1751 } else if (!strcmp(res->name, "rx-cksum")) { 1752 if (!strcmp(res->value, "on")) 1753 rx_offloads |= DEV_RX_OFFLOAD_CHECKSUM; 1754 else if (!strcmp(res->value, "off")) 1755 rx_offloads &= ~DEV_RX_OFFLOAD_CHECKSUM; 1756 else { 1757 printf("Unknown parameter\n"); 1758 return; 1759 } 1760 } else if (!strcmp(res->name, "rx-timestamp")) { 1761 if (!strcmp(res->value, "on")) 1762 rx_offloads |= DEV_RX_OFFLOAD_TIMESTAMP; 1763 else if (!strcmp(res->value, "off")) 1764 rx_offloads &= ~DEV_RX_OFFLOAD_TIMESTAMP; 1765 else { 1766 printf("Unknown parameter\n"); 1767 return; 1768 } 1769 } else if (!strcmp(res->name, "hw-vlan")) { 1770 if (!strcmp(res->value, "on")) { 1771 rx_offloads |= (DEV_RX_OFFLOAD_VLAN_FILTER | 1772 DEV_RX_OFFLOAD_VLAN_STRIP); 1773 } 1774 else if (!strcmp(res->value, "off")) { 1775 rx_offloads &= ~(DEV_RX_OFFLOAD_VLAN_FILTER | 1776 DEV_RX_OFFLOAD_VLAN_STRIP); 1777 } 1778 else { 1779 printf("Unknown parameter\n"); 1780 return; 1781 } 1782 } else if (!strcmp(res->name, "hw-vlan-filter")) { 1783 if (!strcmp(res->value, "on")) 1784 rx_offloads |= DEV_RX_OFFLOAD_VLAN_FILTER; 1785 else if (!strcmp(res->value, "off")) 1786 rx_offloads &= ~DEV_RX_OFFLOAD_VLAN_FILTER; 1787 else { 1788 printf("Unknown parameter\n"); 1789 return; 1790 } 1791 } else if (!strcmp(res->name, "hw-vlan-strip")) { 1792 if (!strcmp(res->value, "on")) 1793 rx_offloads |= DEV_RX_OFFLOAD_VLAN_STRIP; 1794 else if (!strcmp(res->value, "off")) 1795 rx_offloads &= ~DEV_RX_OFFLOAD_VLAN_STRIP; 1796 else { 1797 printf("Unknown parameter\n"); 1798 return; 1799 } 1800 } else if (!strcmp(res->name, "hw-vlan-extend")) { 1801 if (!strcmp(res->value, "on")) 1802 rx_offloads |= DEV_RX_OFFLOAD_VLAN_EXTEND; 1803 else if (!strcmp(res->value, "off")) 1804 rx_offloads &= ~DEV_RX_OFFLOAD_VLAN_EXTEND; 1805 else { 1806 printf("Unknown parameter\n"); 1807 return; 1808 } 1809 } else if (!strcmp(res->name, "drop-en")) { 1810 if (!strcmp(res->value, "on")) 1811 rx_drop_en = 1; 1812 else if (!strcmp(res->value, "off")) 1813 rx_drop_en = 0; 1814 else { 1815 printf("Unknown parameter\n"); 1816 return; 1817 } 1818 } else { 1819 printf("Unknown parameter\n"); 1820 return; 1821 } 1822 rx_mode.offloads = rx_offloads; 1823 1824 init_port_config(); 1825 1826 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1); 1827 } 1828 1829 cmdline_parse_token_string_t cmd_config_rx_mode_flag_port = 1830 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_mode_flag, port, "port"); 1831 cmdline_parse_token_string_t cmd_config_rx_mode_flag_keyword = 1832 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_mode_flag, keyword, 1833 "config"); 1834 cmdline_parse_token_string_t cmd_config_rx_mode_flag_all = 1835 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_mode_flag, all, "all"); 1836 cmdline_parse_token_string_t cmd_config_rx_mode_flag_name = 1837 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_mode_flag, name, 1838 "crc-strip#scatter#rx-cksum#rx-timestamp#hw-vlan#" 1839 "hw-vlan-filter#hw-vlan-strip#hw-vlan-extend"); 1840 cmdline_parse_token_string_t cmd_config_rx_mode_flag_value = 1841 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_mode_flag, value, 1842 "on#off"); 1843 1844 cmdline_parse_inst_t cmd_config_rx_mode_flag = { 1845 .f = cmd_config_rx_mode_flag_parsed, 1846 .data = NULL, 1847 .help_str = "port config all crc-strip|scatter|rx-cksum|rx-timestamp|hw-vlan|" 1848 "hw-vlan-filter|hw-vlan-strip|hw-vlan-extend on|off", 1849 .tokens = { 1850 (void *)&cmd_config_rx_mode_flag_port, 1851 (void *)&cmd_config_rx_mode_flag_keyword, 1852 (void *)&cmd_config_rx_mode_flag_all, 1853 (void *)&cmd_config_rx_mode_flag_name, 1854 (void *)&cmd_config_rx_mode_flag_value, 1855 NULL, 1856 }, 1857 }; 1858 1859 /* *** configure rss *** */ 1860 struct cmd_config_rss { 1861 cmdline_fixed_string_t port; 1862 cmdline_fixed_string_t keyword; 1863 cmdline_fixed_string_t all; 1864 cmdline_fixed_string_t name; 1865 cmdline_fixed_string_t value; 1866 }; 1867 1868 static void 1869 cmd_config_rss_parsed(void *parsed_result, 1870 __attribute__((unused)) struct cmdline *cl, 1871 __attribute__((unused)) void *data) 1872 { 1873 struct cmd_config_rss *res = parsed_result; 1874 struct rte_eth_rss_conf rss_conf = { .rss_key_len = 0, }; 1875 int diag; 1876 uint8_t i; 1877 1878 if (!strcmp(res->value, "all")) 1879 rss_conf.rss_hf = ETH_RSS_IP | ETH_RSS_TCP | 1880 ETH_RSS_UDP | ETH_RSS_SCTP | 1881 ETH_RSS_L2_PAYLOAD; 1882 else if (!strcmp(res->value, "ip")) 1883 rss_conf.rss_hf = ETH_RSS_IP; 1884 else if (!strcmp(res->value, "udp")) 1885 rss_conf.rss_hf = ETH_RSS_UDP; 1886 else if (!strcmp(res->value, "tcp")) 1887 rss_conf.rss_hf = ETH_RSS_TCP; 1888 else if (!strcmp(res->value, "sctp")) 1889 rss_conf.rss_hf = ETH_RSS_SCTP; 1890 else if (!strcmp(res->value, "ether")) 1891 rss_conf.rss_hf = ETH_RSS_L2_PAYLOAD; 1892 else if (!strcmp(res->value, "port")) 1893 rss_conf.rss_hf = ETH_RSS_PORT; 1894 else if (!strcmp(res->value, "vxlan")) 1895 rss_conf.rss_hf = ETH_RSS_VXLAN; 1896 else if (!strcmp(res->value, "geneve")) 1897 rss_conf.rss_hf = ETH_RSS_GENEVE; 1898 else if (!strcmp(res->value, "nvgre")) 1899 rss_conf.rss_hf = ETH_RSS_NVGRE; 1900 else if (!strcmp(res->value, "none")) 1901 rss_conf.rss_hf = 0; 1902 else if (isdigit(res->value[0]) && atoi(res->value) > 0 && 1903 atoi(res->value) < 64) 1904 rss_conf.rss_hf = 1ULL << atoi(res->value); 1905 else { 1906 printf("Unknown parameter\n"); 1907 return; 1908 } 1909 rss_conf.rss_key = NULL; 1910 for (i = 0; i < rte_eth_dev_count(); i++) { 1911 diag = rte_eth_dev_rss_hash_update(i, &rss_conf); 1912 if (diag < 0) 1913 printf("Configuration of RSS hash at ethernet port %d " 1914 "failed with error (%d): %s.\n", 1915 i, -diag, strerror(-diag)); 1916 } 1917 } 1918 1919 cmdline_parse_token_string_t cmd_config_rss_port = 1920 TOKEN_STRING_INITIALIZER(struct cmd_config_rss, port, "port"); 1921 cmdline_parse_token_string_t cmd_config_rss_keyword = 1922 TOKEN_STRING_INITIALIZER(struct cmd_config_rss, keyword, "config"); 1923 cmdline_parse_token_string_t cmd_config_rss_all = 1924 TOKEN_STRING_INITIALIZER(struct cmd_config_rss, all, "all"); 1925 cmdline_parse_token_string_t cmd_config_rss_name = 1926 TOKEN_STRING_INITIALIZER(struct cmd_config_rss, name, "rss"); 1927 cmdline_parse_token_string_t cmd_config_rss_value = 1928 TOKEN_STRING_INITIALIZER(struct cmd_config_rss, value, NULL); 1929 1930 cmdline_parse_inst_t cmd_config_rss = { 1931 .f = cmd_config_rss_parsed, 1932 .data = NULL, 1933 .help_str = "port config all rss " 1934 "all|ip|tcp|udp|sctp|ether|port|vxlan|geneve|nvgre|none|<flowtype_id>", 1935 .tokens = { 1936 (void *)&cmd_config_rss_port, 1937 (void *)&cmd_config_rss_keyword, 1938 (void *)&cmd_config_rss_all, 1939 (void *)&cmd_config_rss_name, 1940 (void *)&cmd_config_rss_value, 1941 NULL, 1942 }, 1943 }; 1944 1945 /* *** configure rss hash key *** */ 1946 struct cmd_config_rss_hash_key { 1947 cmdline_fixed_string_t port; 1948 cmdline_fixed_string_t config; 1949 portid_t port_id; 1950 cmdline_fixed_string_t rss_hash_key; 1951 cmdline_fixed_string_t rss_type; 1952 cmdline_fixed_string_t key; 1953 }; 1954 1955 static uint8_t 1956 hexa_digit_to_value(char hexa_digit) 1957 { 1958 if ((hexa_digit >= '0') && (hexa_digit <= '9')) 1959 return (uint8_t) (hexa_digit - '0'); 1960 if ((hexa_digit >= 'a') && (hexa_digit <= 'f')) 1961 return (uint8_t) ((hexa_digit - 'a') + 10); 1962 if ((hexa_digit >= 'A') && (hexa_digit <= 'F')) 1963 return (uint8_t) ((hexa_digit - 'A') + 10); 1964 /* Invalid hexa digit */ 1965 return 0xFF; 1966 } 1967 1968 static uint8_t 1969 parse_and_check_key_hexa_digit(char *key, int idx) 1970 { 1971 uint8_t hexa_v; 1972 1973 hexa_v = hexa_digit_to_value(key[idx]); 1974 if (hexa_v == 0xFF) 1975 printf("invalid key: character %c at position %d is not a " 1976 "valid hexa digit\n", key[idx], idx); 1977 return hexa_v; 1978 } 1979 1980 static void 1981 cmd_config_rss_hash_key_parsed(void *parsed_result, 1982 __attribute__((unused)) struct cmdline *cl, 1983 __attribute__((unused)) void *data) 1984 { 1985 struct cmd_config_rss_hash_key *res = parsed_result; 1986 uint8_t hash_key[RSS_HASH_KEY_LENGTH]; 1987 uint8_t xdgt0; 1988 uint8_t xdgt1; 1989 int i; 1990 struct rte_eth_dev_info dev_info; 1991 uint8_t hash_key_size; 1992 uint32_t key_len; 1993 1994 memset(&dev_info, 0, sizeof(dev_info)); 1995 rte_eth_dev_info_get(res->port_id, &dev_info); 1996 if (dev_info.hash_key_size > 0 && 1997 dev_info.hash_key_size <= sizeof(hash_key)) 1998 hash_key_size = dev_info.hash_key_size; 1999 else { 2000 printf("dev_info did not provide a valid hash key size\n"); 2001 return; 2002 } 2003 /* Check the length of the RSS hash key */ 2004 key_len = strlen(res->key); 2005 if (key_len != (hash_key_size * 2)) { 2006 printf("key length: %d invalid - key must be a string of %d" 2007 " hexa-decimal numbers\n", 2008 (int) key_len, hash_key_size * 2); 2009 return; 2010 } 2011 /* Translate RSS hash key into binary representation */ 2012 for (i = 0; i < hash_key_size; i++) { 2013 xdgt0 = parse_and_check_key_hexa_digit(res->key, (i * 2)); 2014 if (xdgt0 == 0xFF) 2015 return; 2016 xdgt1 = parse_and_check_key_hexa_digit(res->key, (i * 2) + 1); 2017 if (xdgt1 == 0xFF) 2018 return; 2019 hash_key[i] = (uint8_t) ((xdgt0 * 16) + xdgt1); 2020 } 2021 port_rss_hash_key_update(res->port_id, res->rss_type, hash_key, 2022 hash_key_size); 2023 } 2024 2025 cmdline_parse_token_string_t cmd_config_rss_hash_key_port = 2026 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_hash_key, port, "port"); 2027 cmdline_parse_token_string_t cmd_config_rss_hash_key_config = 2028 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_hash_key, config, 2029 "config"); 2030 cmdline_parse_token_num_t cmd_config_rss_hash_key_port_id = 2031 TOKEN_NUM_INITIALIZER(struct cmd_config_rss_hash_key, port_id, UINT16); 2032 cmdline_parse_token_string_t cmd_config_rss_hash_key_rss_hash_key = 2033 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_hash_key, 2034 rss_hash_key, "rss-hash-key"); 2035 cmdline_parse_token_string_t cmd_config_rss_hash_key_rss_type = 2036 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_hash_key, rss_type, 2037 "ipv4#ipv4-frag#ipv4-tcp#ipv4-udp#ipv4-sctp#" 2038 "ipv4-other#ipv6#ipv6-frag#ipv6-tcp#ipv6-udp#" 2039 "ipv6-sctp#ipv6-other#l2-payload#ipv6-ex#" 2040 "ipv6-tcp-ex#ipv6-udp-ex"); 2041 cmdline_parse_token_string_t cmd_config_rss_hash_key_value = 2042 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_hash_key, key, NULL); 2043 2044 cmdline_parse_inst_t cmd_config_rss_hash_key = { 2045 .f = cmd_config_rss_hash_key_parsed, 2046 .data = NULL, 2047 .help_str = "port config <port_id> rss-hash-key " 2048 "ipv4|ipv4-frag|ipv4-tcp|ipv4-udp|ipv4-sctp|ipv4-other|" 2049 "ipv6|ipv6-frag|ipv6-tcp|ipv6-udp|ipv6-sctp|ipv6-other|" 2050 "l2-payload|ipv6-ex|ipv6-tcp-ex|ipv6-udp-ex " 2051 "<string of hex digits (variable length, NIC dependent)>", 2052 .tokens = { 2053 (void *)&cmd_config_rss_hash_key_port, 2054 (void *)&cmd_config_rss_hash_key_config, 2055 (void *)&cmd_config_rss_hash_key_port_id, 2056 (void *)&cmd_config_rss_hash_key_rss_hash_key, 2057 (void *)&cmd_config_rss_hash_key_rss_type, 2058 (void *)&cmd_config_rss_hash_key_value, 2059 NULL, 2060 }, 2061 }; 2062 2063 /* *** configure port rxq/txq start/stop *** */ 2064 struct cmd_config_rxtx_queue { 2065 cmdline_fixed_string_t port; 2066 portid_t portid; 2067 cmdline_fixed_string_t rxtxq; 2068 uint16_t qid; 2069 cmdline_fixed_string_t opname; 2070 }; 2071 2072 static void 2073 cmd_config_rxtx_queue_parsed(void *parsed_result, 2074 __attribute__((unused)) struct cmdline *cl, 2075 __attribute__((unused)) void *data) 2076 { 2077 struct cmd_config_rxtx_queue *res = parsed_result; 2078 uint8_t isrx; 2079 uint8_t isstart; 2080 int ret = 0; 2081 2082 if (test_done == 0) { 2083 printf("Please stop forwarding first\n"); 2084 return; 2085 } 2086 2087 if (port_id_is_invalid(res->portid, ENABLED_WARN)) 2088 return; 2089 2090 if (port_is_started(res->portid) != 1) { 2091 printf("Please start port %u first\n", res->portid); 2092 return; 2093 } 2094 2095 if (!strcmp(res->rxtxq, "rxq")) 2096 isrx = 1; 2097 else if (!strcmp(res->rxtxq, "txq")) 2098 isrx = 0; 2099 else { 2100 printf("Unknown parameter\n"); 2101 return; 2102 } 2103 2104 if (isrx && rx_queue_id_is_invalid(res->qid)) 2105 return; 2106 else if (!isrx && tx_queue_id_is_invalid(res->qid)) 2107 return; 2108 2109 if (!strcmp(res->opname, "start")) 2110 isstart = 1; 2111 else if (!strcmp(res->opname, "stop")) 2112 isstart = 0; 2113 else { 2114 printf("Unknown parameter\n"); 2115 return; 2116 } 2117 2118 if (isstart && isrx) 2119 ret = rte_eth_dev_rx_queue_start(res->portid, res->qid); 2120 else if (!isstart && isrx) 2121 ret = rte_eth_dev_rx_queue_stop(res->portid, res->qid); 2122 else if (isstart && !isrx) 2123 ret = rte_eth_dev_tx_queue_start(res->portid, res->qid); 2124 else 2125 ret = rte_eth_dev_tx_queue_stop(res->portid, res->qid); 2126 2127 if (ret == -ENOTSUP) 2128 printf("Function not supported in PMD driver\n"); 2129 } 2130 2131 cmdline_parse_token_string_t cmd_config_rxtx_queue_port = 2132 TOKEN_STRING_INITIALIZER(struct cmd_config_rxtx_queue, port, "port"); 2133 cmdline_parse_token_num_t cmd_config_rxtx_queue_portid = 2134 TOKEN_NUM_INITIALIZER(struct cmd_config_rxtx_queue, portid, UINT16); 2135 cmdline_parse_token_string_t cmd_config_rxtx_queue_rxtxq = 2136 TOKEN_STRING_INITIALIZER(struct cmd_config_rxtx_queue, rxtxq, "rxq#txq"); 2137 cmdline_parse_token_num_t cmd_config_rxtx_queue_qid = 2138 TOKEN_NUM_INITIALIZER(struct cmd_config_rxtx_queue, qid, UINT16); 2139 cmdline_parse_token_string_t cmd_config_rxtx_queue_opname = 2140 TOKEN_STRING_INITIALIZER(struct cmd_config_rxtx_queue, opname, 2141 "start#stop"); 2142 2143 cmdline_parse_inst_t cmd_config_rxtx_queue = { 2144 .f = cmd_config_rxtx_queue_parsed, 2145 .data = NULL, 2146 .help_str = "port <port_id> rxq|txq <queue_id> start|stop", 2147 .tokens = { 2148 (void *)&cmd_config_speed_all_port, 2149 (void *)&cmd_config_rxtx_queue_portid, 2150 (void *)&cmd_config_rxtx_queue_rxtxq, 2151 (void *)&cmd_config_rxtx_queue_qid, 2152 (void *)&cmd_config_rxtx_queue_opname, 2153 NULL, 2154 }, 2155 }; 2156 2157 /* *** Configure RSS RETA *** */ 2158 struct cmd_config_rss_reta { 2159 cmdline_fixed_string_t port; 2160 cmdline_fixed_string_t keyword; 2161 portid_t port_id; 2162 cmdline_fixed_string_t name; 2163 cmdline_fixed_string_t list_name; 2164 cmdline_fixed_string_t list_of_items; 2165 }; 2166 2167 static int 2168 parse_reta_config(const char *str, 2169 struct rte_eth_rss_reta_entry64 *reta_conf, 2170 uint16_t nb_entries) 2171 { 2172 int i; 2173 unsigned size; 2174 uint16_t hash_index, idx, shift; 2175 uint16_t nb_queue; 2176 char s[256]; 2177 const char *p, *p0 = str; 2178 char *end; 2179 enum fieldnames { 2180 FLD_HASH_INDEX = 0, 2181 FLD_QUEUE, 2182 _NUM_FLD 2183 }; 2184 unsigned long int_fld[_NUM_FLD]; 2185 char *str_fld[_NUM_FLD]; 2186 2187 while ((p = strchr(p0,'(')) != NULL) { 2188 ++p; 2189 if((p0 = strchr(p,')')) == NULL) 2190 return -1; 2191 2192 size = p0 - p; 2193 if(size >= sizeof(s)) 2194 return -1; 2195 2196 snprintf(s, sizeof(s), "%.*s", size, p); 2197 if (rte_strsplit(s, sizeof(s), str_fld, _NUM_FLD, ',') != _NUM_FLD) 2198 return -1; 2199 for (i = 0; i < _NUM_FLD; i++) { 2200 errno = 0; 2201 int_fld[i] = strtoul(str_fld[i], &end, 0); 2202 if (errno != 0 || end == str_fld[i] || 2203 int_fld[i] > 65535) 2204 return -1; 2205 } 2206 2207 hash_index = (uint16_t)int_fld[FLD_HASH_INDEX]; 2208 nb_queue = (uint16_t)int_fld[FLD_QUEUE]; 2209 2210 if (hash_index >= nb_entries) { 2211 printf("Invalid RETA hash index=%d\n", hash_index); 2212 return -1; 2213 } 2214 2215 idx = hash_index / RTE_RETA_GROUP_SIZE; 2216 shift = hash_index % RTE_RETA_GROUP_SIZE; 2217 reta_conf[idx].mask |= (1ULL << shift); 2218 reta_conf[idx].reta[shift] = nb_queue; 2219 } 2220 2221 return 0; 2222 } 2223 2224 static void 2225 cmd_set_rss_reta_parsed(void *parsed_result, 2226 __attribute__((unused)) struct cmdline *cl, 2227 __attribute__((unused)) void *data) 2228 { 2229 int ret; 2230 struct rte_eth_dev_info dev_info; 2231 struct rte_eth_rss_reta_entry64 reta_conf[8]; 2232 struct cmd_config_rss_reta *res = parsed_result; 2233 2234 memset(&dev_info, 0, sizeof(dev_info)); 2235 rte_eth_dev_info_get(res->port_id, &dev_info); 2236 if (dev_info.reta_size == 0) { 2237 printf("Redirection table size is 0 which is " 2238 "invalid for RSS\n"); 2239 return; 2240 } else 2241 printf("The reta size of port %d is %u\n", 2242 res->port_id, dev_info.reta_size); 2243 if (dev_info.reta_size > ETH_RSS_RETA_SIZE_512) { 2244 printf("Currently do not support more than %u entries of " 2245 "redirection table\n", ETH_RSS_RETA_SIZE_512); 2246 return; 2247 } 2248 2249 memset(reta_conf, 0, sizeof(reta_conf)); 2250 if (!strcmp(res->list_name, "reta")) { 2251 if (parse_reta_config(res->list_of_items, reta_conf, 2252 dev_info.reta_size)) { 2253 printf("Invalid RSS Redirection Table " 2254 "config entered\n"); 2255 return; 2256 } 2257 ret = rte_eth_dev_rss_reta_update(res->port_id, 2258 reta_conf, dev_info.reta_size); 2259 if (ret != 0) 2260 printf("Bad redirection table parameter, " 2261 "return code = %d \n", ret); 2262 } 2263 } 2264 2265 cmdline_parse_token_string_t cmd_config_rss_reta_port = 2266 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_reta, port, "port"); 2267 cmdline_parse_token_string_t cmd_config_rss_reta_keyword = 2268 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_reta, keyword, "config"); 2269 cmdline_parse_token_num_t cmd_config_rss_reta_port_id = 2270 TOKEN_NUM_INITIALIZER(struct cmd_config_rss_reta, port_id, UINT16); 2271 cmdline_parse_token_string_t cmd_config_rss_reta_name = 2272 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_reta, name, "rss"); 2273 cmdline_parse_token_string_t cmd_config_rss_reta_list_name = 2274 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_reta, list_name, "reta"); 2275 cmdline_parse_token_string_t cmd_config_rss_reta_list_of_items = 2276 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_reta, list_of_items, 2277 NULL); 2278 cmdline_parse_inst_t cmd_config_rss_reta = { 2279 .f = cmd_set_rss_reta_parsed, 2280 .data = NULL, 2281 .help_str = "port config <port_id> rss reta <hash,queue[,hash,queue]*>", 2282 .tokens = { 2283 (void *)&cmd_config_rss_reta_port, 2284 (void *)&cmd_config_rss_reta_keyword, 2285 (void *)&cmd_config_rss_reta_port_id, 2286 (void *)&cmd_config_rss_reta_name, 2287 (void *)&cmd_config_rss_reta_list_name, 2288 (void *)&cmd_config_rss_reta_list_of_items, 2289 NULL, 2290 }, 2291 }; 2292 2293 /* *** SHOW PORT RETA INFO *** */ 2294 struct cmd_showport_reta { 2295 cmdline_fixed_string_t show; 2296 cmdline_fixed_string_t port; 2297 portid_t port_id; 2298 cmdline_fixed_string_t rss; 2299 cmdline_fixed_string_t reta; 2300 uint16_t size; 2301 cmdline_fixed_string_t list_of_items; 2302 }; 2303 2304 static int 2305 showport_parse_reta_config(struct rte_eth_rss_reta_entry64 *conf, 2306 uint16_t nb_entries, 2307 char *str) 2308 { 2309 uint32_t size; 2310 const char *p, *p0 = str; 2311 char s[256]; 2312 char *end; 2313 char *str_fld[8]; 2314 uint16_t i; 2315 uint16_t num = (nb_entries + RTE_RETA_GROUP_SIZE - 1) / 2316 RTE_RETA_GROUP_SIZE; 2317 int ret; 2318 2319 p = strchr(p0, '('); 2320 if (p == NULL) 2321 return -1; 2322 p++; 2323 p0 = strchr(p, ')'); 2324 if (p0 == NULL) 2325 return -1; 2326 size = p0 - p; 2327 if (size >= sizeof(s)) { 2328 printf("The string size exceeds the internal buffer size\n"); 2329 return -1; 2330 } 2331 snprintf(s, sizeof(s), "%.*s", size, p); 2332 ret = rte_strsplit(s, sizeof(s), str_fld, num, ','); 2333 if (ret <= 0 || ret != num) { 2334 printf("The bits of masks do not match the number of " 2335 "reta entries: %u\n", num); 2336 return -1; 2337 } 2338 for (i = 0; i < ret; i++) 2339 conf[i].mask = (uint64_t)strtoul(str_fld[i], &end, 0); 2340 2341 return 0; 2342 } 2343 2344 static void 2345 cmd_showport_reta_parsed(void *parsed_result, 2346 __attribute__((unused)) struct cmdline *cl, 2347 __attribute__((unused)) void *data) 2348 { 2349 struct cmd_showport_reta *res = parsed_result; 2350 struct rte_eth_rss_reta_entry64 reta_conf[8]; 2351 struct rte_eth_dev_info dev_info; 2352 uint16_t max_reta_size; 2353 2354 memset(&dev_info, 0, sizeof(dev_info)); 2355 rte_eth_dev_info_get(res->port_id, &dev_info); 2356 max_reta_size = RTE_MIN(dev_info.reta_size, ETH_RSS_RETA_SIZE_512); 2357 if (res->size == 0 || res->size > max_reta_size) { 2358 printf("Invalid redirection table size: %u (1-%u)\n", 2359 res->size, max_reta_size); 2360 return; 2361 } 2362 2363 memset(reta_conf, 0, sizeof(reta_conf)); 2364 if (showport_parse_reta_config(reta_conf, res->size, 2365 res->list_of_items) < 0) { 2366 printf("Invalid string: %s for reta masks\n", 2367 res->list_of_items); 2368 return; 2369 } 2370 port_rss_reta_info(res->port_id, reta_conf, res->size); 2371 } 2372 2373 cmdline_parse_token_string_t cmd_showport_reta_show = 2374 TOKEN_STRING_INITIALIZER(struct cmd_showport_reta, show, "show"); 2375 cmdline_parse_token_string_t cmd_showport_reta_port = 2376 TOKEN_STRING_INITIALIZER(struct cmd_showport_reta, port, "port"); 2377 cmdline_parse_token_num_t cmd_showport_reta_port_id = 2378 TOKEN_NUM_INITIALIZER(struct cmd_showport_reta, port_id, UINT16); 2379 cmdline_parse_token_string_t cmd_showport_reta_rss = 2380 TOKEN_STRING_INITIALIZER(struct cmd_showport_reta, rss, "rss"); 2381 cmdline_parse_token_string_t cmd_showport_reta_reta = 2382 TOKEN_STRING_INITIALIZER(struct cmd_showport_reta, reta, "reta"); 2383 cmdline_parse_token_num_t cmd_showport_reta_size = 2384 TOKEN_NUM_INITIALIZER(struct cmd_showport_reta, size, UINT16); 2385 cmdline_parse_token_string_t cmd_showport_reta_list_of_items = 2386 TOKEN_STRING_INITIALIZER(struct cmd_showport_reta, 2387 list_of_items, NULL); 2388 2389 cmdline_parse_inst_t cmd_showport_reta = { 2390 .f = cmd_showport_reta_parsed, 2391 .data = NULL, 2392 .help_str = "show port <port_id> rss reta <size> <mask0[,mask1]*>", 2393 .tokens = { 2394 (void *)&cmd_showport_reta_show, 2395 (void *)&cmd_showport_reta_port, 2396 (void *)&cmd_showport_reta_port_id, 2397 (void *)&cmd_showport_reta_rss, 2398 (void *)&cmd_showport_reta_reta, 2399 (void *)&cmd_showport_reta_size, 2400 (void *)&cmd_showport_reta_list_of_items, 2401 NULL, 2402 }, 2403 }; 2404 2405 /* *** Show RSS hash configuration *** */ 2406 struct cmd_showport_rss_hash { 2407 cmdline_fixed_string_t show; 2408 cmdline_fixed_string_t port; 2409 portid_t port_id; 2410 cmdline_fixed_string_t rss_hash; 2411 cmdline_fixed_string_t rss_type; 2412 cmdline_fixed_string_t key; /* optional argument */ 2413 }; 2414 2415 static void cmd_showport_rss_hash_parsed(void *parsed_result, 2416 __attribute__((unused)) struct cmdline *cl, 2417 void *show_rss_key) 2418 { 2419 struct cmd_showport_rss_hash *res = parsed_result; 2420 2421 port_rss_hash_conf_show(res->port_id, res->rss_type, 2422 show_rss_key != NULL); 2423 } 2424 2425 cmdline_parse_token_string_t cmd_showport_rss_hash_show = 2426 TOKEN_STRING_INITIALIZER(struct cmd_showport_rss_hash, show, "show"); 2427 cmdline_parse_token_string_t cmd_showport_rss_hash_port = 2428 TOKEN_STRING_INITIALIZER(struct cmd_showport_rss_hash, port, "port"); 2429 cmdline_parse_token_num_t cmd_showport_rss_hash_port_id = 2430 TOKEN_NUM_INITIALIZER(struct cmd_showport_rss_hash, port_id, UINT16); 2431 cmdline_parse_token_string_t cmd_showport_rss_hash_rss_hash = 2432 TOKEN_STRING_INITIALIZER(struct cmd_showport_rss_hash, rss_hash, 2433 "rss-hash"); 2434 cmdline_parse_token_string_t cmd_showport_rss_hash_rss_hash_info = 2435 TOKEN_STRING_INITIALIZER(struct cmd_showport_rss_hash, rss_type, 2436 "ipv4#ipv4-frag#ipv4-tcp#ipv4-udp#ipv4-sctp#" 2437 "ipv4-other#ipv6#ipv6-frag#ipv6-tcp#ipv6-udp#" 2438 "ipv6-sctp#ipv6-other#l2-payload#ipv6-ex#" 2439 "ipv6-tcp-ex#ipv6-udp-ex"); 2440 cmdline_parse_token_string_t cmd_showport_rss_hash_rss_key = 2441 TOKEN_STRING_INITIALIZER(struct cmd_showport_rss_hash, key, "key"); 2442 2443 cmdline_parse_inst_t cmd_showport_rss_hash = { 2444 .f = cmd_showport_rss_hash_parsed, 2445 .data = NULL, 2446 .help_str = "show port <port_id> rss-hash " 2447 "ipv4|ipv4-frag|ipv4-tcp|ipv4-udp|ipv4-sctp|ipv4-other|" 2448 "ipv6|ipv6-frag|ipv6-tcp|ipv6-udp|ipv6-sctp|ipv6-other|" 2449 "l2-payload|ipv6-ex|ipv6-tcp-ex|ipv6-udp-ex", 2450 .tokens = { 2451 (void *)&cmd_showport_rss_hash_show, 2452 (void *)&cmd_showport_rss_hash_port, 2453 (void *)&cmd_showport_rss_hash_port_id, 2454 (void *)&cmd_showport_rss_hash_rss_hash, 2455 (void *)&cmd_showport_rss_hash_rss_hash_info, 2456 NULL, 2457 }, 2458 }; 2459 2460 cmdline_parse_inst_t cmd_showport_rss_hash_key = { 2461 .f = cmd_showport_rss_hash_parsed, 2462 .data = (void *)1, 2463 .help_str = "show port <port_id> rss-hash " 2464 "ipv4|ipv4-frag|ipv4-tcp|ipv4-udp|ipv4-sctp|ipv4-other|" 2465 "ipv6|ipv6-frag|ipv6-tcp|ipv6-udp|ipv6-sctp|ipv6-other|" 2466 "l2-payload|ipv6-ex|ipv6-tcp-ex|ipv6-udp-ex key", 2467 .tokens = { 2468 (void *)&cmd_showport_rss_hash_show, 2469 (void *)&cmd_showport_rss_hash_port, 2470 (void *)&cmd_showport_rss_hash_port_id, 2471 (void *)&cmd_showport_rss_hash_rss_hash, 2472 (void *)&cmd_showport_rss_hash_rss_hash_info, 2473 (void *)&cmd_showport_rss_hash_rss_key, 2474 NULL, 2475 }, 2476 }; 2477 2478 /* *** Configure DCB *** */ 2479 struct cmd_config_dcb { 2480 cmdline_fixed_string_t port; 2481 cmdline_fixed_string_t config; 2482 portid_t port_id; 2483 cmdline_fixed_string_t dcb; 2484 cmdline_fixed_string_t vt; 2485 cmdline_fixed_string_t vt_en; 2486 uint8_t num_tcs; 2487 cmdline_fixed_string_t pfc; 2488 cmdline_fixed_string_t pfc_en; 2489 }; 2490 2491 static void 2492 cmd_config_dcb_parsed(void *parsed_result, 2493 __attribute__((unused)) struct cmdline *cl, 2494 __attribute__((unused)) void *data) 2495 { 2496 struct cmd_config_dcb *res = parsed_result; 2497 portid_t port_id = res->port_id; 2498 struct rte_port *port; 2499 uint8_t pfc_en; 2500 int ret; 2501 2502 port = &ports[port_id]; 2503 /** Check if the port is not started **/ 2504 if (port->port_status != RTE_PORT_STOPPED) { 2505 printf("Please stop port %d first\n", port_id); 2506 return; 2507 } 2508 2509 if ((res->num_tcs != ETH_4_TCS) && (res->num_tcs != ETH_8_TCS)) { 2510 printf("The invalid number of traffic class," 2511 " only 4 or 8 allowed.\n"); 2512 return; 2513 } 2514 2515 if (nb_fwd_lcores < res->num_tcs) { 2516 printf("nb_cores shouldn't be less than number of TCs.\n"); 2517 return; 2518 } 2519 if (!strncmp(res->pfc_en, "on", 2)) 2520 pfc_en = 1; 2521 else 2522 pfc_en = 0; 2523 2524 /* DCB in VT mode */ 2525 if (!strncmp(res->vt_en, "on", 2)) 2526 ret = init_port_dcb_config(port_id, DCB_VT_ENABLED, 2527 (enum rte_eth_nb_tcs)res->num_tcs, 2528 pfc_en); 2529 else 2530 ret = init_port_dcb_config(port_id, DCB_ENABLED, 2531 (enum rte_eth_nb_tcs)res->num_tcs, 2532 pfc_en); 2533 2534 2535 if (ret != 0) { 2536 printf("Cannot initialize network ports.\n"); 2537 return; 2538 } 2539 2540 cmd_reconfig_device_queue(port_id, 1, 1); 2541 } 2542 2543 cmdline_parse_token_string_t cmd_config_dcb_port = 2544 TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, port, "port"); 2545 cmdline_parse_token_string_t cmd_config_dcb_config = 2546 TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, config, "config"); 2547 cmdline_parse_token_num_t cmd_config_dcb_port_id = 2548 TOKEN_NUM_INITIALIZER(struct cmd_config_dcb, port_id, UINT16); 2549 cmdline_parse_token_string_t cmd_config_dcb_dcb = 2550 TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, dcb, "dcb"); 2551 cmdline_parse_token_string_t cmd_config_dcb_vt = 2552 TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, vt, "vt"); 2553 cmdline_parse_token_string_t cmd_config_dcb_vt_en = 2554 TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, vt_en, "on#off"); 2555 cmdline_parse_token_num_t cmd_config_dcb_num_tcs = 2556 TOKEN_NUM_INITIALIZER(struct cmd_config_dcb, num_tcs, UINT8); 2557 cmdline_parse_token_string_t cmd_config_dcb_pfc= 2558 TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, pfc, "pfc"); 2559 cmdline_parse_token_string_t cmd_config_dcb_pfc_en = 2560 TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, pfc_en, "on#off"); 2561 2562 cmdline_parse_inst_t cmd_config_dcb = { 2563 .f = cmd_config_dcb_parsed, 2564 .data = NULL, 2565 .help_str = "port config <port-id> dcb vt on|off <num_tcs> pfc on|off", 2566 .tokens = { 2567 (void *)&cmd_config_dcb_port, 2568 (void *)&cmd_config_dcb_config, 2569 (void *)&cmd_config_dcb_port_id, 2570 (void *)&cmd_config_dcb_dcb, 2571 (void *)&cmd_config_dcb_vt, 2572 (void *)&cmd_config_dcb_vt_en, 2573 (void *)&cmd_config_dcb_num_tcs, 2574 (void *)&cmd_config_dcb_pfc, 2575 (void *)&cmd_config_dcb_pfc_en, 2576 NULL, 2577 }, 2578 }; 2579 2580 /* *** configure number of packets per burst *** */ 2581 struct cmd_config_burst { 2582 cmdline_fixed_string_t port; 2583 cmdline_fixed_string_t keyword; 2584 cmdline_fixed_string_t all; 2585 cmdline_fixed_string_t name; 2586 uint16_t value; 2587 }; 2588 2589 static void 2590 cmd_config_burst_parsed(void *parsed_result, 2591 __attribute__((unused)) struct cmdline *cl, 2592 __attribute__((unused)) void *data) 2593 { 2594 struct cmd_config_burst *res = parsed_result; 2595 2596 if (!all_ports_stopped()) { 2597 printf("Please stop all ports first\n"); 2598 return; 2599 } 2600 2601 if (!strcmp(res->name, "burst")) { 2602 if (res->value < 1 || res->value > MAX_PKT_BURST) { 2603 printf("burst must be >= 1 && <= %d\n", MAX_PKT_BURST); 2604 return; 2605 } 2606 nb_pkt_per_burst = res->value; 2607 } else { 2608 printf("Unknown parameter\n"); 2609 return; 2610 } 2611 2612 init_port_config(); 2613 2614 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1); 2615 } 2616 2617 cmdline_parse_token_string_t cmd_config_burst_port = 2618 TOKEN_STRING_INITIALIZER(struct cmd_config_burst, port, "port"); 2619 cmdline_parse_token_string_t cmd_config_burst_keyword = 2620 TOKEN_STRING_INITIALIZER(struct cmd_config_burst, keyword, "config"); 2621 cmdline_parse_token_string_t cmd_config_burst_all = 2622 TOKEN_STRING_INITIALIZER(struct cmd_config_burst, all, "all"); 2623 cmdline_parse_token_string_t cmd_config_burst_name = 2624 TOKEN_STRING_INITIALIZER(struct cmd_config_burst, name, "burst"); 2625 cmdline_parse_token_num_t cmd_config_burst_value = 2626 TOKEN_NUM_INITIALIZER(struct cmd_config_burst, value, UINT16); 2627 2628 cmdline_parse_inst_t cmd_config_burst = { 2629 .f = cmd_config_burst_parsed, 2630 .data = NULL, 2631 .help_str = "port config all burst <value>", 2632 .tokens = { 2633 (void *)&cmd_config_burst_port, 2634 (void *)&cmd_config_burst_keyword, 2635 (void *)&cmd_config_burst_all, 2636 (void *)&cmd_config_burst_name, 2637 (void *)&cmd_config_burst_value, 2638 NULL, 2639 }, 2640 }; 2641 2642 /* *** configure rx/tx queues *** */ 2643 struct cmd_config_thresh { 2644 cmdline_fixed_string_t port; 2645 cmdline_fixed_string_t keyword; 2646 cmdline_fixed_string_t all; 2647 cmdline_fixed_string_t name; 2648 uint8_t value; 2649 }; 2650 2651 static void 2652 cmd_config_thresh_parsed(void *parsed_result, 2653 __attribute__((unused)) struct cmdline *cl, 2654 __attribute__((unused)) void *data) 2655 { 2656 struct cmd_config_thresh *res = parsed_result; 2657 2658 if (!all_ports_stopped()) { 2659 printf("Please stop all ports first\n"); 2660 return; 2661 } 2662 2663 if (!strcmp(res->name, "txpt")) 2664 tx_pthresh = res->value; 2665 else if(!strcmp(res->name, "txht")) 2666 tx_hthresh = res->value; 2667 else if(!strcmp(res->name, "txwt")) 2668 tx_wthresh = res->value; 2669 else if(!strcmp(res->name, "rxpt")) 2670 rx_pthresh = res->value; 2671 else if(!strcmp(res->name, "rxht")) 2672 rx_hthresh = res->value; 2673 else if(!strcmp(res->name, "rxwt")) 2674 rx_wthresh = res->value; 2675 else { 2676 printf("Unknown parameter\n"); 2677 return; 2678 } 2679 2680 init_port_config(); 2681 2682 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1); 2683 } 2684 2685 cmdline_parse_token_string_t cmd_config_thresh_port = 2686 TOKEN_STRING_INITIALIZER(struct cmd_config_thresh, port, "port"); 2687 cmdline_parse_token_string_t cmd_config_thresh_keyword = 2688 TOKEN_STRING_INITIALIZER(struct cmd_config_thresh, keyword, "config"); 2689 cmdline_parse_token_string_t cmd_config_thresh_all = 2690 TOKEN_STRING_INITIALIZER(struct cmd_config_thresh, all, "all"); 2691 cmdline_parse_token_string_t cmd_config_thresh_name = 2692 TOKEN_STRING_INITIALIZER(struct cmd_config_thresh, name, 2693 "txpt#txht#txwt#rxpt#rxht#rxwt"); 2694 cmdline_parse_token_num_t cmd_config_thresh_value = 2695 TOKEN_NUM_INITIALIZER(struct cmd_config_thresh, value, UINT8); 2696 2697 cmdline_parse_inst_t cmd_config_thresh = { 2698 .f = cmd_config_thresh_parsed, 2699 .data = NULL, 2700 .help_str = "port config all txpt|txht|txwt|rxpt|rxht|rxwt <value>", 2701 .tokens = { 2702 (void *)&cmd_config_thresh_port, 2703 (void *)&cmd_config_thresh_keyword, 2704 (void *)&cmd_config_thresh_all, 2705 (void *)&cmd_config_thresh_name, 2706 (void *)&cmd_config_thresh_value, 2707 NULL, 2708 }, 2709 }; 2710 2711 /* *** configure free/rs threshold *** */ 2712 struct cmd_config_threshold { 2713 cmdline_fixed_string_t port; 2714 cmdline_fixed_string_t keyword; 2715 cmdline_fixed_string_t all; 2716 cmdline_fixed_string_t name; 2717 uint16_t value; 2718 }; 2719 2720 static void 2721 cmd_config_threshold_parsed(void *parsed_result, 2722 __attribute__((unused)) struct cmdline *cl, 2723 __attribute__((unused)) void *data) 2724 { 2725 struct cmd_config_threshold *res = parsed_result; 2726 2727 if (!all_ports_stopped()) { 2728 printf("Please stop all ports first\n"); 2729 return; 2730 } 2731 2732 if (!strcmp(res->name, "txfreet")) 2733 tx_free_thresh = res->value; 2734 else if (!strcmp(res->name, "txrst")) 2735 tx_rs_thresh = res->value; 2736 else if (!strcmp(res->name, "rxfreet")) 2737 rx_free_thresh = res->value; 2738 else { 2739 printf("Unknown parameter\n"); 2740 return; 2741 } 2742 2743 init_port_config(); 2744 2745 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1); 2746 } 2747 2748 cmdline_parse_token_string_t cmd_config_threshold_port = 2749 TOKEN_STRING_INITIALIZER(struct cmd_config_threshold, port, "port"); 2750 cmdline_parse_token_string_t cmd_config_threshold_keyword = 2751 TOKEN_STRING_INITIALIZER(struct cmd_config_threshold, keyword, 2752 "config"); 2753 cmdline_parse_token_string_t cmd_config_threshold_all = 2754 TOKEN_STRING_INITIALIZER(struct cmd_config_threshold, all, "all"); 2755 cmdline_parse_token_string_t cmd_config_threshold_name = 2756 TOKEN_STRING_INITIALIZER(struct cmd_config_threshold, name, 2757 "txfreet#txrst#rxfreet"); 2758 cmdline_parse_token_num_t cmd_config_threshold_value = 2759 TOKEN_NUM_INITIALIZER(struct cmd_config_threshold, value, UINT16); 2760 2761 cmdline_parse_inst_t cmd_config_threshold = { 2762 .f = cmd_config_threshold_parsed, 2763 .data = NULL, 2764 .help_str = "port config all txfreet|txrst|rxfreet <value>", 2765 .tokens = { 2766 (void *)&cmd_config_threshold_port, 2767 (void *)&cmd_config_threshold_keyword, 2768 (void *)&cmd_config_threshold_all, 2769 (void *)&cmd_config_threshold_name, 2770 (void *)&cmd_config_threshold_value, 2771 NULL, 2772 }, 2773 }; 2774 2775 /* *** stop *** */ 2776 struct cmd_stop_result { 2777 cmdline_fixed_string_t stop; 2778 }; 2779 2780 static void cmd_stop_parsed(__attribute__((unused)) void *parsed_result, 2781 __attribute__((unused)) struct cmdline *cl, 2782 __attribute__((unused)) void *data) 2783 { 2784 stop_packet_forwarding(); 2785 } 2786 2787 cmdline_parse_token_string_t cmd_stop_stop = 2788 TOKEN_STRING_INITIALIZER(struct cmd_stop_result, stop, "stop"); 2789 2790 cmdline_parse_inst_t cmd_stop = { 2791 .f = cmd_stop_parsed, 2792 .data = NULL, 2793 .help_str = "stop: Stop packet forwarding", 2794 .tokens = { 2795 (void *)&cmd_stop_stop, 2796 NULL, 2797 }, 2798 }; 2799 2800 /* *** SET CORELIST and PORTLIST CONFIGURATION *** */ 2801 2802 unsigned int 2803 parse_item_list(char* str, const char* item_name, unsigned int max_items, 2804 unsigned int *parsed_items, int check_unique_values) 2805 { 2806 unsigned int nb_item; 2807 unsigned int value; 2808 unsigned int i; 2809 unsigned int j; 2810 int value_ok; 2811 char c; 2812 2813 /* 2814 * First parse all items in the list and store their value. 2815 */ 2816 value = 0; 2817 nb_item = 0; 2818 value_ok = 0; 2819 for (i = 0; i < strnlen(str, STR_TOKEN_SIZE); i++) { 2820 c = str[i]; 2821 if ((c >= '0') && (c <= '9')) { 2822 value = (unsigned int) (value * 10 + (c - '0')); 2823 value_ok = 1; 2824 continue; 2825 } 2826 if (c != ',') { 2827 printf("character %c is not a decimal digit\n", c); 2828 return 0; 2829 } 2830 if (! value_ok) { 2831 printf("No valid value before comma\n"); 2832 return 0; 2833 } 2834 if (nb_item < max_items) { 2835 parsed_items[nb_item] = value; 2836 value_ok = 0; 2837 value = 0; 2838 } 2839 nb_item++; 2840 } 2841 if (nb_item >= max_items) { 2842 printf("Number of %s = %u > %u (maximum items)\n", 2843 item_name, nb_item + 1, max_items); 2844 return 0; 2845 } 2846 parsed_items[nb_item++] = value; 2847 if (! check_unique_values) 2848 return nb_item; 2849 2850 /* 2851 * Then, check that all values in the list are differents. 2852 * No optimization here... 2853 */ 2854 for (i = 0; i < nb_item; i++) { 2855 for (j = i + 1; j < nb_item; j++) { 2856 if (parsed_items[j] == parsed_items[i]) { 2857 printf("duplicated %s %u at index %u and %u\n", 2858 item_name, parsed_items[i], i, j); 2859 return 0; 2860 } 2861 } 2862 } 2863 return nb_item; 2864 } 2865 2866 struct cmd_set_list_result { 2867 cmdline_fixed_string_t cmd_keyword; 2868 cmdline_fixed_string_t list_name; 2869 cmdline_fixed_string_t list_of_items; 2870 }; 2871 2872 static void cmd_set_list_parsed(void *parsed_result, 2873 __attribute__((unused)) struct cmdline *cl, 2874 __attribute__((unused)) void *data) 2875 { 2876 struct cmd_set_list_result *res; 2877 union { 2878 unsigned int lcorelist[RTE_MAX_LCORE]; 2879 unsigned int portlist[RTE_MAX_ETHPORTS]; 2880 } parsed_items; 2881 unsigned int nb_item; 2882 2883 if (test_done == 0) { 2884 printf("Please stop forwarding first\n"); 2885 return; 2886 } 2887 2888 res = parsed_result; 2889 if (!strcmp(res->list_name, "corelist")) { 2890 nb_item = parse_item_list(res->list_of_items, "core", 2891 RTE_MAX_LCORE, 2892 parsed_items.lcorelist, 1); 2893 if (nb_item > 0) { 2894 set_fwd_lcores_list(parsed_items.lcorelist, nb_item); 2895 fwd_config_setup(); 2896 } 2897 return; 2898 } 2899 if (!strcmp(res->list_name, "portlist")) { 2900 nb_item = parse_item_list(res->list_of_items, "port", 2901 RTE_MAX_ETHPORTS, 2902 parsed_items.portlist, 1); 2903 if (nb_item > 0) { 2904 set_fwd_ports_list(parsed_items.portlist, nb_item); 2905 fwd_config_setup(); 2906 } 2907 } 2908 } 2909 2910 cmdline_parse_token_string_t cmd_set_list_keyword = 2911 TOKEN_STRING_INITIALIZER(struct cmd_set_list_result, cmd_keyword, 2912 "set"); 2913 cmdline_parse_token_string_t cmd_set_list_name = 2914 TOKEN_STRING_INITIALIZER(struct cmd_set_list_result, list_name, 2915 "corelist#portlist"); 2916 cmdline_parse_token_string_t cmd_set_list_of_items = 2917 TOKEN_STRING_INITIALIZER(struct cmd_set_list_result, list_of_items, 2918 NULL); 2919 2920 cmdline_parse_inst_t cmd_set_fwd_list = { 2921 .f = cmd_set_list_parsed, 2922 .data = NULL, 2923 .help_str = "set corelist|portlist <list0[,list1]*>", 2924 .tokens = { 2925 (void *)&cmd_set_list_keyword, 2926 (void *)&cmd_set_list_name, 2927 (void *)&cmd_set_list_of_items, 2928 NULL, 2929 }, 2930 }; 2931 2932 /* *** SET COREMASK and PORTMASK CONFIGURATION *** */ 2933 2934 struct cmd_setmask_result { 2935 cmdline_fixed_string_t set; 2936 cmdline_fixed_string_t mask; 2937 uint64_t hexavalue; 2938 }; 2939 2940 static void cmd_set_mask_parsed(void *parsed_result, 2941 __attribute__((unused)) struct cmdline *cl, 2942 __attribute__((unused)) void *data) 2943 { 2944 struct cmd_setmask_result *res = parsed_result; 2945 2946 if (test_done == 0) { 2947 printf("Please stop forwarding first\n"); 2948 return; 2949 } 2950 if (!strcmp(res->mask, "coremask")) { 2951 set_fwd_lcores_mask(res->hexavalue); 2952 fwd_config_setup(); 2953 } else if (!strcmp(res->mask, "portmask")) { 2954 set_fwd_ports_mask(res->hexavalue); 2955 fwd_config_setup(); 2956 } 2957 } 2958 2959 cmdline_parse_token_string_t cmd_setmask_set = 2960 TOKEN_STRING_INITIALIZER(struct cmd_setmask_result, set, "set"); 2961 cmdline_parse_token_string_t cmd_setmask_mask = 2962 TOKEN_STRING_INITIALIZER(struct cmd_setmask_result, mask, 2963 "coremask#portmask"); 2964 cmdline_parse_token_num_t cmd_setmask_value = 2965 TOKEN_NUM_INITIALIZER(struct cmd_setmask_result, hexavalue, UINT64); 2966 2967 cmdline_parse_inst_t cmd_set_fwd_mask = { 2968 .f = cmd_set_mask_parsed, 2969 .data = NULL, 2970 .help_str = "set coremask|portmask <hexadecimal value>", 2971 .tokens = { 2972 (void *)&cmd_setmask_set, 2973 (void *)&cmd_setmask_mask, 2974 (void *)&cmd_setmask_value, 2975 NULL, 2976 }, 2977 }; 2978 2979 /* 2980 * SET NBPORT, NBCORE, PACKET BURST, and VERBOSE LEVEL CONFIGURATION 2981 */ 2982 struct cmd_set_result { 2983 cmdline_fixed_string_t set; 2984 cmdline_fixed_string_t what; 2985 uint16_t value; 2986 }; 2987 2988 static void cmd_set_parsed(void *parsed_result, 2989 __attribute__((unused)) struct cmdline *cl, 2990 __attribute__((unused)) void *data) 2991 { 2992 struct cmd_set_result *res = parsed_result; 2993 if (!strcmp(res->what, "nbport")) { 2994 set_fwd_ports_number(res->value); 2995 fwd_config_setup(); 2996 } else if (!strcmp(res->what, "nbcore")) { 2997 set_fwd_lcores_number(res->value); 2998 fwd_config_setup(); 2999 } else if (!strcmp(res->what, "burst")) 3000 set_nb_pkt_per_burst(res->value); 3001 else if (!strcmp(res->what, "verbose")) 3002 set_verbose_level(res->value); 3003 } 3004 3005 cmdline_parse_token_string_t cmd_set_set = 3006 TOKEN_STRING_INITIALIZER(struct cmd_set_result, set, "set"); 3007 cmdline_parse_token_string_t cmd_set_what = 3008 TOKEN_STRING_INITIALIZER(struct cmd_set_result, what, 3009 "nbport#nbcore#burst#verbose"); 3010 cmdline_parse_token_num_t cmd_set_value = 3011 TOKEN_NUM_INITIALIZER(struct cmd_set_result, value, UINT16); 3012 3013 cmdline_parse_inst_t cmd_set_numbers = { 3014 .f = cmd_set_parsed, 3015 .data = NULL, 3016 .help_str = "set nbport|nbcore|burst|verbose <value>", 3017 .tokens = { 3018 (void *)&cmd_set_set, 3019 (void *)&cmd_set_what, 3020 (void *)&cmd_set_value, 3021 NULL, 3022 }, 3023 }; 3024 3025 /* *** SET SEGMENT LENGTHS OF TXONLY PACKETS *** */ 3026 3027 struct cmd_set_txpkts_result { 3028 cmdline_fixed_string_t cmd_keyword; 3029 cmdline_fixed_string_t txpkts; 3030 cmdline_fixed_string_t seg_lengths; 3031 }; 3032 3033 static void 3034 cmd_set_txpkts_parsed(void *parsed_result, 3035 __attribute__((unused)) struct cmdline *cl, 3036 __attribute__((unused)) void *data) 3037 { 3038 struct cmd_set_txpkts_result *res; 3039 unsigned seg_lengths[RTE_MAX_SEGS_PER_PKT]; 3040 unsigned int nb_segs; 3041 3042 res = parsed_result; 3043 nb_segs = parse_item_list(res->seg_lengths, "segment lengths", 3044 RTE_MAX_SEGS_PER_PKT, seg_lengths, 0); 3045 if (nb_segs > 0) 3046 set_tx_pkt_segments(seg_lengths, nb_segs); 3047 } 3048 3049 cmdline_parse_token_string_t cmd_set_txpkts_keyword = 3050 TOKEN_STRING_INITIALIZER(struct cmd_set_txpkts_result, 3051 cmd_keyword, "set"); 3052 cmdline_parse_token_string_t cmd_set_txpkts_name = 3053 TOKEN_STRING_INITIALIZER(struct cmd_set_txpkts_result, 3054 txpkts, "txpkts"); 3055 cmdline_parse_token_string_t cmd_set_txpkts_lengths = 3056 TOKEN_STRING_INITIALIZER(struct cmd_set_txpkts_result, 3057 seg_lengths, NULL); 3058 3059 cmdline_parse_inst_t cmd_set_txpkts = { 3060 .f = cmd_set_txpkts_parsed, 3061 .data = NULL, 3062 .help_str = "set txpkts <len0[,len1]*>", 3063 .tokens = { 3064 (void *)&cmd_set_txpkts_keyword, 3065 (void *)&cmd_set_txpkts_name, 3066 (void *)&cmd_set_txpkts_lengths, 3067 NULL, 3068 }, 3069 }; 3070 3071 /* *** SET COPY AND SPLIT POLICY ON TX PACKETS *** */ 3072 3073 struct cmd_set_txsplit_result { 3074 cmdline_fixed_string_t cmd_keyword; 3075 cmdline_fixed_string_t txsplit; 3076 cmdline_fixed_string_t mode; 3077 }; 3078 3079 static void 3080 cmd_set_txsplit_parsed(void *parsed_result, 3081 __attribute__((unused)) struct cmdline *cl, 3082 __attribute__((unused)) void *data) 3083 { 3084 struct cmd_set_txsplit_result *res; 3085 3086 res = parsed_result; 3087 set_tx_pkt_split(res->mode); 3088 } 3089 3090 cmdline_parse_token_string_t cmd_set_txsplit_keyword = 3091 TOKEN_STRING_INITIALIZER(struct cmd_set_txsplit_result, 3092 cmd_keyword, "set"); 3093 cmdline_parse_token_string_t cmd_set_txsplit_name = 3094 TOKEN_STRING_INITIALIZER(struct cmd_set_txsplit_result, 3095 txsplit, "txsplit"); 3096 cmdline_parse_token_string_t cmd_set_txsplit_mode = 3097 TOKEN_STRING_INITIALIZER(struct cmd_set_txsplit_result, 3098 mode, NULL); 3099 3100 cmdline_parse_inst_t cmd_set_txsplit = { 3101 .f = cmd_set_txsplit_parsed, 3102 .data = NULL, 3103 .help_str = "set txsplit on|off|rand", 3104 .tokens = { 3105 (void *)&cmd_set_txsplit_keyword, 3106 (void *)&cmd_set_txsplit_name, 3107 (void *)&cmd_set_txsplit_mode, 3108 NULL, 3109 }, 3110 }; 3111 3112 /* *** CONFIG TX QUEUE FLAGS *** */ 3113 3114 struct cmd_config_txqflags_result { 3115 cmdline_fixed_string_t port; 3116 cmdline_fixed_string_t config; 3117 cmdline_fixed_string_t all; 3118 cmdline_fixed_string_t what; 3119 int32_t hexvalue; 3120 }; 3121 3122 static void cmd_config_txqflags_parsed(void *parsed_result, 3123 __attribute__((unused)) struct cmdline *cl, 3124 __attribute__((unused)) void *data) 3125 { 3126 struct cmd_config_txqflags_result *res = parsed_result; 3127 3128 if (!all_ports_stopped()) { 3129 printf("Please stop all ports first\n"); 3130 return; 3131 } 3132 3133 if (strcmp(res->what, "txqflags")) { 3134 printf("Unknown parameter\n"); 3135 return; 3136 } 3137 3138 if (res->hexvalue >= 0) { 3139 txq_flags = res->hexvalue; 3140 } else { 3141 printf("txqflags must be >= 0\n"); 3142 return; 3143 } 3144 3145 init_port_config(); 3146 3147 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1); 3148 } 3149 3150 cmdline_parse_token_string_t cmd_config_txqflags_port = 3151 TOKEN_STRING_INITIALIZER(struct cmd_config_txqflags_result, port, 3152 "port"); 3153 cmdline_parse_token_string_t cmd_config_txqflags_config = 3154 TOKEN_STRING_INITIALIZER(struct cmd_config_txqflags_result, config, 3155 "config"); 3156 cmdline_parse_token_string_t cmd_config_txqflags_all = 3157 TOKEN_STRING_INITIALIZER(struct cmd_config_txqflags_result, all, 3158 "all"); 3159 cmdline_parse_token_string_t cmd_config_txqflags_what = 3160 TOKEN_STRING_INITIALIZER(struct cmd_config_txqflags_result, what, 3161 "txqflags"); 3162 cmdline_parse_token_num_t cmd_config_txqflags_value = 3163 TOKEN_NUM_INITIALIZER(struct cmd_config_txqflags_result, 3164 hexvalue, INT32); 3165 3166 cmdline_parse_inst_t cmd_config_txqflags = { 3167 .f = cmd_config_txqflags_parsed, 3168 .data = NULL, 3169 .help_str = "port config all txqflags <value>", 3170 .tokens = { 3171 (void *)&cmd_config_txqflags_port, 3172 (void *)&cmd_config_txqflags_config, 3173 (void *)&cmd_config_txqflags_all, 3174 (void *)&cmd_config_txqflags_what, 3175 (void *)&cmd_config_txqflags_value, 3176 NULL, 3177 }, 3178 }; 3179 3180 /* *** ADD/REMOVE ALL VLAN IDENTIFIERS TO/FROM A PORT VLAN RX FILTER *** */ 3181 struct cmd_rx_vlan_filter_all_result { 3182 cmdline_fixed_string_t rx_vlan; 3183 cmdline_fixed_string_t what; 3184 cmdline_fixed_string_t all; 3185 portid_t port_id; 3186 }; 3187 3188 static void 3189 cmd_rx_vlan_filter_all_parsed(void *parsed_result, 3190 __attribute__((unused)) struct cmdline *cl, 3191 __attribute__((unused)) void *data) 3192 { 3193 struct cmd_rx_vlan_filter_all_result *res = parsed_result; 3194 3195 if (!strcmp(res->what, "add")) 3196 rx_vlan_all_filter_set(res->port_id, 1); 3197 else 3198 rx_vlan_all_filter_set(res->port_id, 0); 3199 } 3200 3201 cmdline_parse_token_string_t cmd_rx_vlan_filter_all_rx_vlan = 3202 TOKEN_STRING_INITIALIZER(struct cmd_rx_vlan_filter_all_result, 3203 rx_vlan, "rx_vlan"); 3204 cmdline_parse_token_string_t cmd_rx_vlan_filter_all_what = 3205 TOKEN_STRING_INITIALIZER(struct cmd_rx_vlan_filter_all_result, 3206 what, "add#rm"); 3207 cmdline_parse_token_string_t cmd_rx_vlan_filter_all_all = 3208 TOKEN_STRING_INITIALIZER(struct cmd_rx_vlan_filter_all_result, 3209 all, "all"); 3210 cmdline_parse_token_num_t cmd_rx_vlan_filter_all_portid = 3211 TOKEN_NUM_INITIALIZER(struct cmd_rx_vlan_filter_all_result, 3212 port_id, UINT16); 3213 3214 cmdline_parse_inst_t cmd_rx_vlan_filter_all = { 3215 .f = cmd_rx_vlan_filter_all_parsed, 3216 .data = NULL, 3217 .help_str = "rx_vlan add|rm all <port_id>: " 3218 "Add/Remove all identifiers to/from the set of VLAN " 3219 "identifiers filtered by a port", 3220 .tokens = { 3221 (void *)&cmd_rx_vlan_filter_all_rx_vlan, 3222 (void *)&cmd_rx_vlan_filter_all_what, 3223 (void *)&cmd_rx_vlan_filter_all_all, 3224 (void *)&cmd_rx_vlan_filter_all_portid, 3225 NULL, 3226 }, 3227 }; 3228 3229 /* *** VLAN OFFLOAD SET ON A PORT *** */ 3230 struct cmd_vlan_offload_result { 3231 cmdline_fixed_string_t vlan; 3232 cmdline_fixed_string_t set; 3233 cmdline_fixed_string_t vlan_type; 3234 cmdline_fixed_string_t what; 3235 cmdline_fixed_string_t on; 3236 cmdline_fixed_string_t port_id; 3237 }; 3238 3239 static void 3240 cmd_vlan_offload_parsed(void *parsed_result, 3241 __attribute__((unused)) struct cmdline *cl, 3242 __attribute__((unused)) void *data) 3243 { 3244 int on; 3245 struct cmd_vlan_offload_result *res = parsed_result; 3246 char *str; 3247 int i, len = 0; 3248 portid_t port_id = 0; 3249 unsigned int tmp; 3250 3251 str = res->port_id; 3252 len = strnlen(str, STR_TOKEN_SIZE); 3253 i = 0; 3254 /* Get port_id first */ 3255 while(i < len){ 3256 if(str[i] == ',') 3257 break; 3258 3259 i++; 3260 } 3261 str[i]='\0'; 3262 tmp = strtoul(str, NULL, 0); 3263 /* If port_id greater that what portid_t can represent, return */ 3264 if(tmp >= RTE_MAX_ETHPORTS) 3265 return; 3266 port_id = (portid_t)tmp; 3267 3268 if (!strcmp(res->on, "on")) 3269 on = 1; 3270 else 3271 on = 0; 3272 3273 if (!strcmp(res->what, "strip")) 3274 rx_vlan_strip_set(port_id, on); 3275 else if(!strcmp(res->what, "stripq")){ 3276 uint16_t queue_id = 0; 3277 3278 /* No queue_id, return */ 3279 if(i + 1 >= len) { 3280 printf("must specify (port,queue_id)\n"); 3281 return; 3282 } 3283 tmp = strtoul(str + i + 1, NULL, 0); 3284 /* If queue_id greater that what 16-bits can represent, return */ 3285 if(tmp > 0xffff) 3286 return; 3287 3288 queue_id = (uint16_t)tmp; 3289 rx_vlan_strip_set_on_queue(port_id, queue_id, on); 3290 } 3291 else if (!strcmp(res->what, "filter")) 3292 rx_vlan_filter_set(port_id, on); 3293 else 3294 vlan_extend_set(port_id, on); 3295 3296 return; 3297 } 3298 3299 cmdline_parse_token_string_t cmd_vlan_offload_vlan = 3300 TOKEN_STRING_INITIALIZER(struct cmd_vlan_offload_result, 3301 vlan, "vlan"); 3302 cmdline_parse_token_string_t cmd_vlan_offload_set = 3303 TOKEN_STRING_INITIALIZER(struct cmd_vlan_offload_result, 3304 set, "set"); 3305 cmdline_parse_token_string_t cmd_vlan_offload_what = 3306 TOKEN_STRING_INITIALIZER(struct cmd_vlan_offload_result, 3307 what, "strip#filter#qinq#stripq"); 3308 cmdline_parse_token_string_t cmd_vlan_offload_on = 3309 TOKEN_STRING_INITIALIZER(struct cmd_vlan_offload_result, 3310 on, "on#off"); 3311 cmdline_parse_token_string_t cmd_vlan_offload_portid = 3312 TOKEN_STRING_INITIALIZER(struct cmd_vlan_offload_result, 3313 port_id, NULL); 3314 3315 cmdline_parse_inst_t cmd_vlan_offload = { 3316 .f = cmd_vlan_offload_parsed, 3317 .data = NULL, 3318 .help_str = "vlan set strip|filter|qinq|stripq on|off " 3319 "<port_id[,queue_id]>: " 3320 "Filter/Strip for rx side qinq(extended) for both rx/tx sides", 3321 .tokens = { 3322 (void *)&cmd_vlan_offload_vlan, 3323 (void *)&cmd_vlan_offload_set, 3324 (void *)&cmd_vlan_offload_what, 3325 (void *)&cmd_vlan_offload_on, 3326 (void *)&cmd_vlan_offload_portid, 3327 NULL, 3328 }, 3329 }; 3330 3331 /* *** VLAN TPID SET ON A PORT *** */ 3332 struct cmd_vlan_tpid_result { 3333 cmdline_fixed_string_t vlan; 3334 cmdline_fixed_string_t set; 3335 cmdline_fixed_string_t vlan_type; 3336 cmdline_fixed_string_t what; 3337 uint16_t tp_id; 3338 portid_t port_id; 3339 }; 3340 3341 static void 3342 cmd_vlan_tpid_parsed(void *parsed_result, 3343 __attribute__((unused)) struct cmdline *cl, 3344 __attribute__((unused)) void *data) 3345 { 3346 struct cmd_vlan_tpid_result *res = parsed_result; 3347 enum rte_vlan_type vlan_type; 3348 3349 if (!strcmp(res->vlan_type, "inner")) 3350 vlan_type = ETH_VLAN_TYPE_INNER; 3351 else if (!strcmp(res->vlan_type, "outer")) 3352 vlan_type = ETH_VLAN_TYPE_OUTER; 3353 else { 3354 printf("Unknown vlan type\n"); 3355 return; 3356 } 3357 vlan_tpid_set(res->port_id, vlan_type, res->tp_id); 3358 } 3359 3360 cmdline_parse_token_string_t cmd_vlan_tpid_vlan = 3361 TOKEN_STRING_INITIALIZER(struct cmd_vlan_tpid_result, 3362 vlan, "vlan"); 3363 cmdline_parse_token_string_t cmd_vlan_tpid_set = 3364 TOKEN_STRING_INITIALIZER(struct cmd_vlan_tpid_result, 3365 set, "set"); 3366 cmdline_parse_token_string_t cmd_vlan_type = 3367 TOKEN_STRING_INITIALIZER(struct cmd_vlan_tpid_result, 3368 vlan_type, "inner#outer"); 3369 cmdline_parse_token_string_t cmd_vlan_tpid_what = 3370 TOKEN_STRING_INITIALIZER(struct cmd_vlan_tpid_result, 3371 what, "tpid"); 3372 cmdline_parse_token_num_t cmd_vlan_tpid_tpid = 3373 TOKEN_NUM_INITIALIZER(struct cmd_vlan_tpid_result, 3374 tp_id, UINT16); 3375 cmdline_parse_token_num_t cmd_vlan_tpid_portid = 3376 TOKEN_NUM_INITIALIZER(struct cmd_vlan_tpid_result, 3377 port_id, UINT16); 3378 3379 cmdline_parse_inst_t cmd_vlan_tpid = { 3380 .f = cmd_vlan_tpid_parsed, 3381 .data = NULL, 3382 .help_str = "vlan set inner|outer tpid <tp_id> <port_id>: " 3383 "Set the VLAN Ether type", 3384 .tokens = { 3385 (void *)&cmd_vlan_tpid_vlan, 3386 (void *)&cmd_vlan_tpid_set, 3387 (void *)&cmd_vlan_type, 3388 (void *)&cmd_vlan_tpid_what, 3389 (void *)&cmd_vlan_tpid_tpid, 3390 (void *)&cmd_vlan_tpid_portid, 3391 NULL, 3392 }, 3393 }; 3394 3395 /* *** ADD/REMOVE A VLAN IDENTIFIER TO/FROM A PORT VLAN RX FILTER *** */ 3396 struct cmd_rx_vlan_filter_result { 3397 cmdline_fixed_string_t rx_vlan; 3398 cmdline_fixed_string_t what; 3399 uint16_t vlan_id; 3400 portid_t port_id; 3401 }; 3402 3403 static void 3404 cmd_rx_vlan_filter_parsed(void *parsed_result, 3405 __attribute__((unused)) struct cmdline *cl, 3406 __attribute__((unused)) void *data) 3407 { 3408 struct cmd_rx_vlan_filter_result *res = parsed_result; 3409 3410 if (!strcmp(res->what, "add")) 3411 rx_vft_set(res->port_id, res->vlan_id, 1); 3412 else 3413 rx_vft_set(res->port_id, res->vlan_id, 0); 3414 } 3415 3416 cmdline_parse_token_string_t cmd_rx_vlan_filter_rx_vlan = 3417 TOKEN_STRING_INITIALIZER(struct cmd_rx_vlan_filter_result, 3418 rx_vlan, "rx_vlan"); 3419 cmdline_parse_token_string_t cmd_rx_vlan_filter_what = 3420 TOKEN_STRING_INITIALIZER(struct cmd_rx_vlan_filter_result, 3421 what, "add#rm"); 3422 cmdline_parse_token_num_t cmd_rx_vlan_filter_vlanid = 3423 TOKEN_NUM_INITIALIZER(struct cmd_rx_vlan_filter_result, 3424 vlan_id, UINT16); 3425 cmdline_parse_token_num_t cmd_rx_vlan_filter_portid = 3426 TOKEN_NUM_INITIALIZER(struct cmd_rx_vlan_filter_result, 3427 port_id, UINT16); 3428 3429 cmdline_parse_inst_t cmd_rx_vlan_filter = { 3430 .f = cmd_rx_vlan_filter_parsed, 3431 .data = NULL, 3432 .help_str = "rx_vlan add|rm <vlan_id> <port_id>: " 3433 "Add/Remove a VLAN identifier to/from the set of VLAN " 3434 "identifiers filtered by a port", 3435 .tokens = { 3436 (void *)&cmd_rx_vlan_filter_rx_vlan, 3437 (void *)&cmd_rx_vlan_filter_what, 3438 (void *)&cmd_rx_vlan_filter_vlanid, 3439 (void *)&cmd_rx_vlan_filter_portid, 3440 NULL, 3441 }, 3442 }; 3443 3444 /* *** ENABLE HARDWARE INSERTION OF VLAN HEADER IN TX PACKETS *** */ 3445 struct cmd_tx_vlan_set_result { 3446 cmdline_fixed_string_t tx_vlan; 3447 cmdline_fixed_string_t set; 3448 portid_t port_id; 3449 uint16_t vlan_id; 3450 }; 3451 3452 static void 3453 cmd_tx_vlan_set_parsed(void *parsed_result, 3454 __attribute__((unused)) struct cmdline *cl, 3455 __attribute__((unused)) void *data) 3456 { 3457 struct cmd_tx_vlan_set_result *res = parsed_result; 3458 3459 if (!port_is_stopped(res->port_id)) { 3460 printf("Please stop port %d first\n", res->port_id); 3461 return; 3462 } 3463 3464 tx_vlan_set(res->port_id, res->vlan_id); 3465 3466 cmd_reconfig_device_queue(res->port_id, 1, 1); 3467 } 3468 3469 cmdline_parse_token_string_t cmd_tx_vlan_set_tx_vlan = 3470 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_result, 3471 tx_vlan, "tx_vlan"); 3472 cmdline_parse_token_string_t cmd_tx_vlan_set_set = 3473 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_result, 3474 set, "set"); 3475 cmdline_parse_token_num_t cmd_tx_vlan_set_portid = 3476 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_result, 3477 port_id, UINT16); 3478 cmdline_parse_token_num_t cmd_tx_vlan_set_vlanid = 3479 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_result, 3480 vlan_id, UINT16); 3481 3482 cmdline_parse_inst_t cmd_tx_vlan_set = { 3483 .f = cmd_tx_vlan_set_parsed, 3484 .data = NULL, 3485 .help_str = "tx_vlan set <port_id> <vlan_id>: " 3486 "Enable hardware insertion of a single VLAN header " 3487 "with a given TAG Identifier in packets sent on a port", 3488 .tokens = { 3489 (void *)&cmd_tx_vlan_set_tx_vlan, 3490 (void *)&cmd_tx_vlan_set_set, 3491 (void *)&cmd_tx_vlan_set_portid, 3492 (void *)&cmd_tx_vlan_set_vlanid, 3493 NULL, 3494 }, 3495 }; 3496 3497 /* *** ENABLE HARDWARE INSERTION OF Double VLAN HEADER IN TX PACKETS *** */ 3498 struct cmd_tx_vlan_set_qinq_result { 3499 cmdline_fixed_string_t tx_vlan; 3500 cmdline_fixed_string_t set; 3501 portid_t port_id; 3502 uint16_t vlan_id; 3503 uint16_t vlan_id_outer; 3504 }; 3505 3506 static void 3507 cmd_tx_vlan_set_qinq_parsed(void *parsed_result, 3508 __attribute__((unused)) struct cmdline *cl, 3509 __attribute__((unused)) void *data) 3510 { 3511 struct cmd_tx_vlan_set_qinq_result *res = parsed_result; 3512 3513 if (!port_is_stopped(res->port_id)) { 3514 printf("Please stop port %d first\n", res->port_id); 3515 return; 3516 } 3517 3518 tx_qinq_set(res->port_id, res->vlan_id, res->vlan_id_outer); 3519 3520 cmd_reconfig_device_queue(res->port_id, 1, 1); 3521 } 3522 3523 cmdline_parse_token_string_t cmd_tx_vlan_set_qinq_tx_vlan = 3524 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_qinq_result, 3525 tx_vlan, "tx_vlan"); 3526 cmdline_parse_token_string_t cmd_tx_vlan_set_qinq_set = 3527 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_qinq_result, 3528 set, "set"); 3529 cmdline_parse_token_num_t cmd_tx_vlan_set_qinq_portid = 3530 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_qinq_result, 3531 port_id, UINT16); 3532 cmdline_parse_token_num_t cmd_tx_vlan_set_qinq_vlanid = 3533 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_qinq_result, 3534 vlan_id, UINT16); 3535 cmdline_parse_token_num_t cmd_tx_vlan_set_qinq_vlanid_outer = 3536 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_qinq_result, 3537 vlan_id_outer, UINT16); 3538 3539 cmdline_parse_inst_t cmd_tx_vlan_set_qinq = { 3540 .f = cmd_tx_vlan_set_qinq_parsed, 3541 .data = NULL, 3542 .help_str = "tx_vlan set <port_id> <vlan_id> <outer_vlan_id>: " 3543 "Enable hardware insertion of double VLAN header " 3544 "with given TAG Identifiers in packets sent on a port", 3545 .tokens = { 3546 (void *)&cmd_tx_vlan_set_qinq_tx_vlan, 3547 (void *)&cmd_tx_vlan_set_qinq_set, 3548 (void *)&cmd_tx_vlan_set_qinq_portid, 3549 (void *)&cmd_tx_vlan_set_qinq_vlanid, 3550 (void *)&cmd_tx_vlan_set_qinq_vlanid_outer, 3551 NULL, 3552 }, 3553 }; 3554 3555 /* *** ENABLE/DISABLE PORT BASED TX VLAN INSERTION *** */ 3556 struct cmd_tx_vlan_set_pvid_result { 3557 cmdline_fixed_string_t tx_vlan; 3558 cmdline_fixed_string_t set; 3559 cmdline_fixed_string_t pvid; 3560 portid_t port_id; 3561 uint16_t vlan_id; 3562 cmdline_fixed_string_t mode; 3563 }; 3564 3565 static void 3566 cmd_tx_vlan_set_pvid_parsed(void *parsed_result, 3567 __attribute__((unused)) struct cmdline *cl, 3568 __attribute__((unused)) void *data) 3569 { 3570 struct cmd_tx_vlan_set_pvid_result *res = parsed_result; 3571 3572 if (strcmp(res->mode, "on") == 0) 3573 tx_vlan_pvid_set(res->port_id, res->vlan_id, 1); 3574 else 3575 tx_vlan_pvid_set(res->port_id, res->vlan_id, 0); 3576 } 3577 3578 cmdline_parse_token_string_t cmd_tx_vlan_set_pvid_tx_vlan = 3579 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_pvid_result, 3580 tx_vlan, "tx_vlan"); 3581 cmdline_parse_token_string_t cmd_tx_vlan_set_pvid_set = 3582 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_pvid_result, 3583 set, "set"); 3584 cmdline_parse_token_string_t cmd_tx_vlan_set_pvid_pvid = 3585 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_pvid_result, 3586 pvid, "pvid"); 3587 cmdline_parse_token_num_t cmd_tx_vlan_set_pvid_port_id = 3588 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_pvid_result, 3589 port_id, UINT16); 3590 cmdline_parse_token_num_t cmd_tx_vlan_set_pvid_vlan_id = 3591 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_pvid_result, 3592 vlan_id, UINT16); 3593 cmdline_parse_token_string_t cmd_tx_vlan_set_pvid_mode = 3594 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_pvid_result, 3595 mode, "on#off"); 3596 3597 cmdline_parse_inst_t cmd_tx_vlan_set_pvid = { 3598 .f = cmd_tx_vlan_set_pvid_parsed, 3599 .data = NULL, 3600 .help_str = "tx_vlan set pvid <port_id> <vlan_id> on|off", 3601 .tokens = { 3602 (void *)&cmd_tx_vlan_set_pvid_tx_vlan, 3603 (void *)&cmd_tx_vlan_set_pvid_set, 3604 (void *)&cmd_tx_vlan_set_pvid_pvid, 3605 (void *)&cmd_tx_vlan_set_pvid_port_id, 3606 (void *)&cmd_tx_vlan_set_pvid_vlan_id, 3607 (void *)&cmd_tx_vlan_set_pvid_mode, 3608 NULL, 3609 }, 3610 }; 3611 3612 /* *** DISABLE HARDWARE INSERTION OF VLAN HEADER IN TX PACKETS *** */ 3613 struct cmd_tx_vlan_reset_result { 3614 cmdline_fixed_string_t tx_vlan; 3615 cmdline_fixed_string_t reset; 3616 portid_t port_id; 3617 }; 3618 3619 static void 3620 cmd_tx_vlan_reset_parsed(void *parsed_result, 3621 __attribute__((unused)) struct cmdline *cl, 3622 __attribute__((unused)) void *data) 3623 { 3624 struct cmd_tx_vlan_reset_result *res = parsed_result; 3625 3626 if (!port_is_stopped(res->port_id)) { 3627 printf("Please stop port %d first\n", res->port_id); 3628 return; 3629 } 3630 3631 tx_vlan_reset(res->port_id); 3632 3633 cmd_reconfig_device_queue(res->port_id, 1, 1); 3634 } 3635 3636 cmdline_parse_token_string_t cmd_tx_vlan_reset_tx_vlan = 3637 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_reset_result, 3638 tx_vlan, "tx_vlan"); 3639 cmdline_parse_token_string_t cmd_tx_vlan_reset_reset = 3640 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_reset_result, 3641 reset, "reset"); 3642 cmdline_parse_token_num_t cmd_tx_vlan_reset_portid = 3643 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_reset_result, 3644 port_id, UINT16); 3645 3646 cmdline_parse_inst_t cmd_tx_vlan_reset = { 3647 .f = cmd_tx_vlan_reset_parsed, 3648 .data = NULL, 3649 .help_str = "tx_vlan reset <port_id>: Disable hardware insertion of a " 3650 "VLAN header in packets sent on a port", 3651 .tokens = { 3652 (void *)&cmd_tx_vlan_reset_tx_vlan, 3653 (void *)&cmd_tx_vlan_reset_reset, 3654 (void *)&cmd_tx_vlan_reset_portid, 3655 NULL, 3656 }, 3657 }; 3658 3659 3660 /* *** ENABLE HARDWARE INSERTION OF CHECKSUM IN TX PACKETS *** */ 3661 struct cmd_csum_result { 3662 cmdline_fixed_string_t csum; 3663 cmdline_fixed_string_t mode; 3664 cmdline_fixed_string_t proto; 3665 cmdline_fixed_string_t hwsw; 3666 portid_t port_id; 3667 }; 3668 3669 static void 3670 csum_show(int port_id) 3671 { 3672 struct rte_eth_dev_info dev_info; 3673 uint64_t tx_offloads; 3674 3675 tx_offloads = ports[port_id].dev_conf.txmode.offloads; 3676 printf("Parse tunnel is %s\n", 3677 (ports[port_id].parse_tunnel) ? "on" : "off"); 3678 printf("IP checksum offload is %s\n", 3679 (tx_offloads & DEV_TX_OFFLOAD_IPV4_CKSUM) ? "hw" : "sw"); 3680 printf("UDP checksum offload is %s\n", 3681 (tx_offloads & DEV_TX_OFFLOAD_UDP_CKSUM) ? "hw" : "sw"); 3682 printf("TCP checksum offload is %s\n", 3683 (tx_offloads & DEV_TX_OFFLOAD_TCP_CKSUM) ? "hw" : "sw"); 3684 printf("SCTP checksum offload is %s\n", 3685 (tx_offloads & DEV_TX_OFFLOAD_SCTP_CKSUM) ? "hw" : "sw"); 3686 printf("Outer-Ip checksum offload is %s\n", 3687 (tx_offloads & DEV_TX_OFFLOAD_OUTER_IPV4_CKSUM) ? "hw" : "sw"); 3688 3689 /* display warnings if configuration is not supported by the NIC */ 3690 rte_eth_dev_info_get(port_id, &dev_info); 3691 if ((tx_offloads & DEV_TX_OFFLOAD_IPV4_CKSUM) && 3692 (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_IPV4_CKSUM) == 0) { 3693 printf("Warning: hardware IP checksum enabled but not " 3694 "supported by port %d\n", port_id); 3695 } 3696 if ((tx_offloads & DEV_TX_OFFLOAD_UDP_CKSUM) && 3697 (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_UDP_CKSUM) == 0) { 3698 printf("Warning: hardware UDP checksum enabled but not " 3699 "supported by port %d\n", port_id); 3700 } 3701 if ((tx_offloads & DEV_TX_OFFLOAD_TCP_CKSUM) && 3702 (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_TCP_CKSUM) == 0) { 3703 printf("Warning: hardware TCP checksum enabled but not " 3704 "supported by port %d\n", port_id); 3705 } 3706 if ((tx_offloads & DEV_TX_OFFLOAD_SCTP_CKSUM) && 3707 (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_SCTP_CKSUM) == 0) { 3708 printf("Warning: hardware SCTP checksum enabled but not " 3709 "supported by port %d\n", port_id); 3710 } 3711 if ((tx_offloads & DEV_TX_OFFLOAD_OUTER_IPV4_CKSUM) && 3712 (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_OUTER_IPV4_CKSUM) == 0) { 3713 printf("Warning: hardware outer IP checksum enabled but not " 3714 "supported by port %d\n", port_id); 3715 } 3716 } 3717 3718 static void 3719 cmd_csum_parsed(void *parsed_result, 3720 __attribute__((unused)) struct cmdline *cl, 3721 __attribute__((unused)) void *data) 3722 { 3723 struct cmd_csum_result *res = parsed_result; 3724 int hw = 0; 3725 uint64_t csum_offloads = 0; 3726 3727 if (port_id_is_invalid(res->port_id, ENABLED_WARN)) { 3728 printf("invalid port %d\n", res->port_id); 3729 return; 3730 } 3731 if (!port_is_stopped(res->port_id)) { 3732 printf("Please stop port %d first\n", res->port_id); 3733 return; 3734 } 3735 3736 if (!strcmp(res->mode, "set")) { 3737 3738 if (!strcmp(res->hwsw, "hw")) 3739 hw = 1; 3740 3741 if (!strcmp(res->proto, "ip")) { 3742 csum_offloads |= DEV_TX_OFFLOAD_IPV4_CKSUM; 3743 } else if (!strcmp(res->proto, "udp")) { 3744 csum_offloads |= DEV_TX_OFFLOAD_UDP_CKSUM; 3745 } else if (!strcmp(res->proto, "tcp")) { 3746 csum_offloads |= DEV_TX_OFFLOAD_TCP_CKSUM; 3747 } else if (!strcmp(res->proto, "sctp")) { 3748 csum_offloads |= DEV_TX_OFFLOAD_SCTP_CKSUM; 3749 } else if (!strcmp(res->proto, "outer-ip")) { 3750 csum_offloads |= DEV_TX_OFFLOAD_OUTER_IPV4_CKSUM; 3751 } 3752 3753 if (hw) { 3754 ports[res->port_id].dev_conf.txmode.offloads |= 3755 csum_offloads; 3756 } else { 3757 ports[res->port_id].dev_conf.txmode.offloads &= 3758 (~csum_offloads); 3759 } 3760 } 3761 csum_show(res->port_id); 3762 3763 cmd_reconfig_device_queue(res->port_id, 1, 1); 3764 } 3765 3766 cmdline_parse_token_string_t cmd_csum_csum = 3767 TOKEN_STRING_INITIALIZER(struct cmd_csum_result, 3768 csum, "csum"); 3769 cmdline_parse_token_string_t cmd_csum_mode = 3770 TOKEN_STRING_INITIALIZER(struct cmd_csum_result, 3771 mode, "set"); 3772 cmdline_parse_token_string_t cmd_csum_proto = 3773 TOKEN_STRING_INITIALIZER(struct cmd_csum_result, 3774 proto, "ip#tcp#udp#sctp#outer-ip"); 3775 cmdline_parse_token_string_t cmd_csum_hwsw = 3776 TOKEN_STRING_INITIALIZER(struct cmd_csum_result, 3777 hwsw, "hw#sw"); 3778 cmdline_parse_token_num_t cmd_csum_portid = 3779 TOKEN_NUM_INITIALIZER(struct cmd_csum_result, 3780 port_id, UINT16); 3781 3782 cmdline_parse_inst_t cmd_csum_set = { 3783 .f = cmd_csum_parsed, 3784 .data = NULL, 3785 .help_str = "csum set ip|tcp|udp|sctp|outer-ip hw|sw <port_id>: " 3786 "Enable/Disable hardware calculation of L3/L4 checksum when " 3787 "using csum forward engine", 3788 .tokens = { 3789 (void *)&cmd_csum_csum, 3790 (void *)&cmd_csum_mode, 3791 (void *)&cmd_csum_proto, 3792 (void *)&cmd_csum_hwsw, 3793 (void *)&cmd_csum_portid, 3794 NULL, 3795 }, 3796 }; 3797 3798 cmdline_parse_token_string_t cmd_csum_mode_show = 3799 TOKEN_STRING_INITIALIZER(struct cmd_csum_result, 3800 mode, "show"); 3801 3802 cmdline_parse_inst_t cmd_csum_show = { 3803 .f = cmd_csum_parsed, 3804 .data = NULL, 3805 .help_str = "csum show <port_id>: Show checksum offload configuration", 3806 .tokens = { 3807 (void *)&cmd_csum_csum, 3808 (void *)&cmd_csum_mode_show, 3809 (void *)&cmd_csum_portid, 3810 NULL, 3811 }, 3812 }; 3813 3814 /* Enable/disable tunnel parsing */ 3815 struct cmd_csum_tunnel_result { 3816 cmdline_fixed_string_t csum; 3817 cmdline_fixed_string_t parse; 3818 cmdline_fixed_string_t onoff; 3819 portid_t port_id; 3820 }; 3821 3822 static void 3823 cmd_csum_tunnel_parsed(void *parsed_result, 3824 __attribute__((unused)) struct cmdline *cl, 3825 __attribute__((unused)) void *data) 3826 { 3827 struct cmd_csum_tunnel_result *res = parsed_result; 3828 3829 if (port_id_is_invalid(res->port_id, ENABLED_WARN)) 3830 return; 3831 3832 if (!strcmp(res->onoff, "on")) 3833 ports[res->port_id].parse_tunnel = 1; 3834 else 3835 ports[res->port_id].parse_tunnel = 0; 3836 3837 csum_show(res->port_id); 3838 } 3839 3840 cmdline_parse_token_string_t cmd_csum_tunnel_csum = 3841 TOKEN_STRING_INITIALIZER(struct cmd_csum_tunnel_result, 3842 csum, "csum"); 3843 cmdline_parse_token_string_t cmd_csum_tunnel_parse = 3844 TOKEN_STRING_INITIALIZER(struct cmd_csum_tunnel_result, 3845 parse, "parse_tunnel"); 3846 cmdline_parse_token_string_t cmd_csum_tunnel_onoff = 3847 TOKEN_STRING_INITIALIZER(struct cmd_csum_tunnel_result, 3848 onoff, "on#off"); 3849 cmdline_parse_token_num_t cmd_csum_tunnel_portid = 3850 TOKEN_NUM_INITIALIZER(struct cmd_csum_tunnel_result, 3851 port_id, UINT16); 3852 3853 cmdline_parse_inst_t cmd_csum_tunnel = { 3854 .f = cmd_csum_tunnel_parsed, 3855 .data = NULL, 3856 .help_str = "csum parse_tunnel on|off <port_id>: " 3857 "Enable/Disable parsing of tunnels for csum engine", 3858 .tokens = { 3859 (void *)&cmd_csum_tunnel_csum, 3860 (void *)&cmd_csum_tunnel_parse, 3861 (void *)&cmd_csum_tunnel_onoff, 3862 (void *)&cmd_csum_tunnel_portid, 3863 NULL, 3864 }, 3865 }; 3866 3867 /* *** ENABLE HARDWARE SEGMENTATION IN TX NON-TUNNELED PACKETS *** */ 3868 struct cmd_tso_set_result { 3869 cmdline_fixed_string_t tso; 3870 cmdline_fixed_string_t mode; 3871 uint16_t tso_segsz; 3872 portid_t port_id; 3873 }; 3874 3875 static void 3876 cmd_tso_set_parsed(void *parsed_result, 3877 __attribute__((unused)) struct cmdline *cl, 3878 __attribute__((unused)) void *data) 3879 { 3880 struct cmd_tso_set_result *res = parsed_result; 3881 struct rte_eth_dev_info dev_info; 3882 3883 if (port_id_is_invalid(res->port_id, ENABLED_WARN)) 3884 return; 3885 if (!port_is_stopped(res->port_id)) { 3886 printf("Please stop port %d first\n", res->port_id); 3887 return; 3888 } 3889 3890 if (!strcmp(res->mode, "set")) 3891 ports[res->port_id].tso_segsz = res->tso_segsz; 3892 3893 if (ports[res->port_id].tso_segsz == 0) { 3894 ports[res->port_id].dev_conf.txmode.offloads &= 3895 ~DEV_TX_OFFLOAD_TCP_TSO; 3896 printf("TSO for non-tunneled packets is disabled\n"); 3897 } else { 3898 ports[res->port_id].dev_conf.txmode.offloads |= 3899 DEV_TX_OFFLOAD_TCP_TSO; 3900 printf("TSO segment size for non-tunneled packets is %d\n", 3901 ports[res->port_id].tso_segsz); 3902 } 3903 3904 /* display warnings if configuration is not supported by the NIC */ 3905 rte_eth_dev_info_get(res->port_id, &dev_info); 3906 if ((ports[res->port_id].tso_segsz != 0) && 3907 (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_TCP_TSO) == 0) { 3908 printf("Warning: TSO enabled but not " 3909 "supported by port %d\n", res->port_id); 3910 } 3911 3912 cmd_reconfig_device_queue(res->port_id, 1, 1); 3913 } 3914 3915 cmdline_parse_token_string_t cmd_tso_set_tso = 3916 TOKEN_STRING_INITIALIZER(struct cmd_tso_set_result, 3917 tso, "tso"); 3918 cmdline_parse_token_string_t cmd_tso_set_mode = 3919 TOKEN_STRING_INITIALIZER(struct cmd_tso_set_result, 3920 mode, "set"); 3921 cmdline_parse_token_num_t cmd_tso_set_tso_segsz = 3922 TOKEN_NUM_INITIALIZER(struct cmd_tso_set_result, 3923 tso_segsz, UINT16); 3924 cmdline_parse_token_num_t cmd_tso_set_portid = 3925 TOKEN_NUM_INITIALIZER(struct cmd_tso_set_result, 3926 port_id, UINT16); 3927 3928 cmdline_parse_inst_t cmd_tso_set = { 3929 .f = cmd_tso_set_parsed, 3930 .data = NULL, 3931 .help_str = "tso set <tso_segsz> <port_id>: " 3932 "Set TSO segment size of non-tunneled packets for csum engine " 3933 "(0 to disable)", 3934 .tokens = { 3935 (void *)&cmd_tso_set_tso, 3936 (void *)&cmd_tso_set_mode, 3937 (void *)&cmd_tso_set_tso_segsz, 3938 (void *)&cmd_tso_set_portid, 3939 NULL, 3940 }, 3941 }; 3942 3943 cmdline_parse_token_string_t cmd_tso_show_mode = 3944 TOKEN_STRING_INITIALIZER(struct cmd_tso_set_result, 3945 mode, "show"); 3946 3947 3948 cmdline_parse_inst_t cmd_tso_show = { 3949 .f = cmd_tso_set_parsed, 3950 .data = NULL, 3951 .help_str = "tso show <port_id>: " 3952 "Show TSO segment size of non-tunneled packets for csum engine", 3953 .tokens = { 3954 (void *)&cmd_tso_set_tso, 3955 (void *)&cmd_tso_show_mode, 3956 (void *)&cmd_tso_set_portid, 3957 NULL, 3958 }, 3959 }; 3960 3961 /* *** ENABLE HARDWARE SEGMENTATION IN TX TUNNELED PACKETS *** */ 3962 struct cmd_tunnel_tso_set_result { 3963 cmdline_fixed_string_t tso; 3964 cmdline_fixed_string_t mode; 3965 uint16_t tso_segsz; 3966 portid_t port_id; 3967 }; 3968 3969 static void 3970 check_tunnel_tso_nic_support(portid_t port_id) 3971 { 3972 struct rte_eth_dev_info dev_info; 3973 3974 rte_eth_dev_info_get(port_id, &dev_info); 3975 if (!(dev_info.tx_offload_capa & DEV_TX_OFFLOAD_VXLAN_TNL_TSO)) 3976 printf("Warning: TSO enabled but VXLAN TUNNEL TSO not " 3977 "supported by port %d\n", port_id); 3978 if (!(dev_info.tx_offload_capa & DEV_TX_OFFLOAD_GRE_TNL_TSO)) 3979 printf("Warning: TSO enabled but GRE TUNNEL TSO not " 3980 "supported by port %d\n", port_id); 3981 if (!(dev_info.tx_offload_capa & DEV_TX_OFFLOAD_IPIP_TNL_TSO)) 3982 printf("Warning: TSO enabled but IPIP TUNNEL TSO not " 3983 "supported by port %d\n", port_id); 3984 if (!(dev_info.tx_offload_capa & DEV_TX_OFFLOAD_GENEVE_TNL_TSO)) 3985 printf("Warning: TSO enabled but GENEVE TUNNEL TSO not " 3986 "supported by port %d\n", port_id); 3987 } 3988 3989 static void 3990 cmd_tunnel_tso_set_parsed(void *parsed_result, 3991 __attribute__((unused)) struct cmdline *cl, 3992 __attribute__((unused)) void *data) 3993 { 3994 struct cmd_tunnel_tso_set_result *res = parsed_result; 3995 3996 if (port_id_is_invalid(res->port_id, ENABLED_WARN)) 3997 return; 3998 if (!port_is_stopped(res->port_id)) { 3999 printf("Please stop port %d first\n", res->port_id); 4000 return; 4001 } 4002 4003 if (!strcmp(res->mode, "set")) 4004 ports[res->port_id].tunnel_tso_segsz = res->tso_segsz; 4005 4006 if (ports[res->port_id].tunnel_tso_segsz == 0) { 4007 ports[res->port_id].dev_conf.txmode.offloads &= 4008 ~(DEV_TX_OFFLOAD_VXLAN_TNL_TSO | 4009 DEV_TX_OFFLOAD_GRE_TNL_TSO | 4010 DEV_TX_OFFLOAD_IPIP_TNL_TSO | 4011 DEV_TX_OFFLOAD_GENEVE_TNL_TSO); 4012 printf("TSO for tunneled packets is disabled\n"); 4013 } else { 4014 ports[res->port_id].dev_conf.txmode.offloads |= 4015 (DEV_TX_OFFLOAD_VXLAN_TNL_TSO | 4016 DEV_TX_OFFLOAD_GRE_TNL_TSO | 4017 DEV_TX_OFFLOAD_IPIP_TNL_TSO | 4018 DEV_TX_OFFLOAD_GENEVE_TNL_TSO); 4019 printf("TSO segment size for tunneled packets is %d\n", 4020 ports[res->port_id].tunnel_tso_segsz); 4021 4022 /* Below conditions are needed to make it work: 4023 * (1) tunnel TSO is supported by the NIC; 4024 * (2) "csum parse_tunnel" must be set so that tunneled pkts 4025 * are recognized; 4026 * (3) for tunneled pkts with outer L3 of IPv4, 4027 * "csum set outer-ip" must be set to hw, because after tso, 4028 * total_len of outer IP header is changed, and the checksum 4029 * of outer IP header calculated by sw should be wrong; that 4030 * is not necessary for IPv6 tunneled pkts because there's no 4031 * checksum in IP header anymore. 4032 */ 4033 check_tunnel_tso_nic_support(res->port_id); 4034 4035 if (!ports[res->port_id].parse_tunnel) 4036 printf("Warning: csum parse_tunnel must be set " 4037 "so that tunneled packets are recognized\n"); 4038 if (!(ports[res->port_id].dev_conf.txmode.offloads & 4039 DEV_TX_OFFLOAD_OUTER_IPV4_CKSUM)) 4040 printf("Warning: csum set outer-ip must be set to hw " 4041 "if outer L3 is IPv4; not necessary for IPv6\n"); 4042 } 4043 4044 cmd_reconfig_device_queue(res->port_id, 1, 1); 4045 } 4046 4047 cmdline_parse_token_string_t cmd_tunnel_tso_set_tso = 4048 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_tso_set_result, 4049 tso, "tunnel_tso"); 4050 cmdline_parse_token_string_t cmd_tunnel_tso_set_mode = 4051 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_tso_set_result, 4052 mode, "set"); 4053 cmdline_parse_token_num_t cmd_tunnel_tso_set_tso_segsz = 4054 TOKEN_NUM_INITIALIZER(struct cmd_tunnel_tso_set_result, 4055 tso_segsz, UINT16); 4056 cmdline_parse_token_num_t cmd_tunnel_tso_set_portid = 4057 TOKEN_NUM_INITIALIZER(struct cmd_tunnel_tso_set_result, 4058 port_id, UINT16); 4059 4060 cmdline_parse_inst_t cmd_tunnel_tso_set = { 4061 .f = cmd_tunnel_tso_set_parsed, 4062 .data = NULL, 4063 .help_str = "tunnel_tso set <tso_segsz> <port_id>: " 4064 "Set TSO segment size of tunneled packets for csum engine " 4065 "(0 to disable)", 4066 .tokens = { 4067 (void *)&cmd_tunnel_tso_set_tso, 4068 (void *)&cmd_tunnel_tso_set_mode, 4069 (void *)&cmd_tunnel_tso_set_tso_segsz, 4070 (void *)&cmd_tunnel_tso_set_portid, 4071 NULL, 4072 }, 4073 }; 4074 4075 cmdline_parse_token_string_t cmd_tunnel_tso_show_mode = 4076 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_tso_set_result, 4077 mode, "show"); 4078 4079 4080 cmdline_parse_inst_t cmd_tunnel_tso_show = { 4081 .f = cmd_tunnel_tso_set_parsed, 4082 .data = NULL, 4083 .help_str = "tunnel_tso show <port_id> " 4084 "Show TSO segment size of tunneled packets for csum engine", 4085 .tokens = { 4086 (void *)&cmd_tunnel_tso_set_tso, 4087 (void *)&cmd_tunnel_tso_show_mode, 4088 (void *)&cmd_tunnel_tso_set_portid, 4089 NULL, 4090 }, 4091 }; 4092 4093 /* *** SET GRO FOR A PORT *** */ 4094 struct cmd_gro_enable_result { 4095 cmdline_fixed_string_t cmd_set; 4096 cmdline_fixed_string_t cmd_port; 4097 cmdline_fixed_string_t cmd_keyword; 4098 cmdline_fixed_string_t cmd_onoff; 4099 portid_t cmd_pid; 4100 }; 4101 4102 static void 4103 cmd_gro_enable_parsed(void *parsed_result, 4104 __attribute__((unused)) struct cmdline *cl, 4105 __attribute__((unused)) void *data) 4106 { 4107 struct cmd_gro_enable_result *res; 4108 4109 res = parsed_result; 4110 if (!strcmp(res->cmd_keyword, "gro")) 4111 setup_gro(res->cmd_onoff, res->cmd_pid); 4112 } 4113 4114 cmdline_parse_token_string_t cmd_gro_enable_set = 4115 TOKEN_STRING_INITIALIZER(struct cmd_gro_enable_result, 4116 cmd_set, "set"); 4117 cmdline_parse_token_string_t cmd_gro_enable_port = 4118 TOKEN_STRING_INITIALIZER(struct cmd_gro_enable_result, 4119 cmd_keyword, "port"); 4120 cmdline_parse_token_num_t cmd_gro_enable_pid = 4121 TOKEN_NUM_INITIALIZER(struct cmd_gro_enable_result, 4122 cmd_pid, UINT16); 4123 cmdline_parse_token_string_t cmd_gro_enable_keyword = 4124 TOKEN_STRING_INITIALIZER(struct cmd_gro_enable_result, 4125 cmd_keyword, "gro"); 4126 cmdline_parse_token_string_t cmd_gro_enable_onoff = 4127 TOKEN_STRING_INITIALIZER(struct cmd_gro_enable_result, 4128 cmd_onoff, "on#off"); 4129 4130 cmdline_parse_inst_t cmd_gro_enable = { 4131 .f = cmd_gro_enable_parsed, 4132 .data = NULL, 4133 .help_str = "set port <port_id> gro on|off", 4134 .tokens = { 4135 (void *)&cmd_gro_enable_set, 4136 (void *)&cmd_gro_enable_port, 4137 (void *)&cmd_gro_enable_pid, 4138 (void *)&cmd_gro_enable_keyword, 4139 (void *)&cmd_gro_enable_onoff, 4140 NULL, 4141 }, 4142 }; 4143 4144 /* *** DISPLAY GRO CONFIGURATION *** */ 4145 struct cmd_gro_show_result { 4146 cmdline_fixed_string_t cmd_show; 4147 cmdline_fixed_string_t cmd_port; 4148 cmdline_fixed_string_t cmd_keyword; 4149 portid_t cmd_pid; 4150 }; 4151 4152 static void 4153 cmd_gro_show_parsed(void *parsed_result, 4154 __attribute__((unused)) struct cmdline *cl, 4155 __attribute__((unused)) void *data) 4156 { 4157 struct cmd_gro_show_result *res; 4158 4159 res = parsed_result; 4160 if (!strcmp(res->cmd_keyword, "gro")) 4161 show_gro(res->cmd_pid); 4162 } 4163 4164 cmdline_parse_token_string_t cmd_gro_show_show = 4165 TOKEN_STRING_INITIALIZER(struct cmd_gro_show_result, 4166 cmd_show, "show"); 4167 cmdline_parse_token_string_t cmd_gro_show_port = 4168 TOKEN_STRING_INITIALIZER(struct cmd_gro_show_result, 4169 cmd_port, "port"); 4170 cmdline_parse_token_num_t cmd_gro_show_pid = 4171 TOKEN_NUM_INITIALIZER(struct cmd_gro_show_result, 4172 cmd_pid, UINT16); 4173 cmdline_parse_token_string_t cmd_gro_show_keyword = 4174 TOKEN_STRING_INITIALIZER(struct cmd_gro_show_result, 4175 cmd_keyword, "gro"); 4176 4177 cmdline_parse_inst_t cmd_gro_show = { 4178 .f = cmd_gro_show_parsed, 4179 .data = NULL, 4180 .help_str = "show port <port_id> gro", 4181 .tokens = { 4182 (void *)&cmd_gro_show_show, 4183 (void *)&cmd_gro_show_port, 4184 (void *)&cmd_gro_show_pid, 4185 (void *)&cmd_gro_show_keyword, 4186 NULL, 4187 }, 4188 }; 4189 4190 /* *** SET FLUSH CYCLES FOR GRO *** */ 4191 struct cmd_gro_flush_result { 4192 cmdline_fixed_string_t cmd_set; 4193 cmdline_fixed_string_t cmd_keyword; 4194 cmdline_fixed_string_t cmd_flush; 4195 uint8_t cmd_cycles; 4196 }; 4197 4198 static void 4199 cmd_gro_flush_parsed(void *parsed_result, 4200 __attribute__((unused)) struct cmdline *cl, 4201 __attribute__((unused)) void *data) 4202 { 4203 struct cmd_gro_flush_result *res; 4204 4205 res = parsed_result; 4206 if ((!strcmp(res->cmd_keyword, "gro")) && 4207 (!strcmp(res->cmd_flush, "flush"))) 4208 setup_gro_flush_cycles(res->cmd_cycles); 4209 } 4210 4211 cmdline_parse_token_string_t cmd_gro_flush_set = 4212 TOKEN_STRING_INITIALIZER(struct cmd_gro_flush_result, 4213 cmd_set, "set"); 4214 cmdline_parse_token_string_t cmd_gro_flush_keyword = 4215 TOKEN_STRING_INITIALIZER(struct cmd_gro_flush_result, 4216 cmd_keyword, "gro"); 4217 cmdline_parse_token_string_t cmd_gro_flush_flush = 4218 TOKEN_STRING_INITIALIZER(struct cmd_gro_flush_result, 4219 cmd_flush, "flush"); 4220 cmdline_parse_token_num_t cmd_gro_flush_cycles = 4221 TOKEN_NUM_INITIALIZER(struct cmd_gro_flush_result, 4222 cmd_cycles, UINT8); 4223 4224 cmdline_parse_inst_t cmd_gro_flush = { 4225 .f = cmd_gro_flush_parsed, 4226 .data = NULL, 4227 .help_str = "set gro flush <cycles>", 4228 .tokens = { 4229 (void *)&cmd_gro_flush_set, 4230 (void *)&cmd_gro_flush_keyword, 4231 (void *)&cmd_gro_flush_flush, 4232 (void *)&cmd_gro_flush_cycles, 4233 NULL, 4234 }, 4235 }; 4236 4237 /* *** ENABLE/DISABLE GSO *** */ 4238 struct cmd_gso_enable_result { 4239 cmdline_fixed_string_t cmd_set; 4240 cmdline_fixed_string_t cmd_port; 4241 cmdline_fixed_string_t cmd_keyword; 4242 cmdline_fixed_string_t cmd_mode; 4243 portid_t cmd_pid; 4244 }; 4245 4246 static void 4247 cmd_gso_enable_parsed(void *parsed_result, 4248 __attribute__((unused)) struct cmdline *cl, 4249 __attribute__((unused)) void *data) 4250 { 4251 struct cmd_gso_enable_result *res; 4252 4253 res = parsed_result; 4254 if (!strcmp(res->cmd_keyword, "gso")) 4255 setup_gso(res->cmd_mode, res->cmd_pid); 4256 } 4257 4258 cmdline_parse_token_string_t cmd_gso_enable_set = 4259 TOKEN_STRING_INITIALIZER(struct cmd_gso_enable_result, 4260 cmd_set, "set"); 4261 cmdline_parse_token_string_t cmd_gso_enable_port = 4262 TOKEN_STRING_INITIALIZER(struct cmd_gso_enable_result, 4263 cmd_port, "port"); 4264 cmdline_parse_token_string_t cmd_gso_enable_keyword = 4265 TOKEN_STRING_INITIALIZER(struct cmd_gso_enable_result, 4266 cmd_keyword, "gso"); 4267 cmdline_parse_token_string_t cmd_gso_enable_mode = 4268 TOKEN_STRING_INITIALIZER(struct cmd_gso_enable_result, 4269 cmd_mode, "on#off"); 4270 cmdline_parse_token_num_t cmd_gso_enable_pid = 4271 TOKEN_NUM_INITIALIZER(struct cmd_gso_enable_result, 4272 cmd_pid, UINT16); 4273 4274 cmdline_parse_inst_t cmd_gso_enable = { 4275 .f = cmd_gso_enable_parsed, 4276 .data = NULL, 4277 .help_str = "set port <port_id> gso on|off", 4278 .tokens = { 4279 (void *)&cmd_gso_enable_set, 4280 (void *)&cmd_gso_enable_port, 4281 (void *)&cmd_gso_enable_pid, 4282 (void *)&cmd_gso_enable_keyword, 4283 (void *)&cmd_gso_enable_mode, 4284 NULL, 4285 }, 4286 }; 4287 4288 /* *** SET MAX PACKET LENGTH FOR GSO SEGMENTS *** */ 4289 struct cmd_gso_size_result { 4290 cmdline_fixed_string_t cmd_set; 4291 cmdline_fixed_string_t cmd_keyword; 4292 cmdline_fixed_string_t cmd_segsz; 4293 uint16_t cmd_size; 4294 }; 4295 4296 static void 4297 cmd_gso_size_parsed(void *parsed_result, 4298 __attribute__((unused)) struct cmdline *cl, 4299 __attribute__((unused)) void *data) 4300 { 4301 struct cmd_gso_size_result *res = parsed_result; 4302 4303 if (test_done == 0) { 4304 printf("Before setting GSO segsz, please first" 4305 " stop fowarding\n"); 4306 return; 4307 } 4308 4309 if (!strcmp(res->cmd_keyword, "gso") && 4310 !strcmp(res->cmd_segsz, "segsz")) { 4311 if (res->cmd_size < RTE_GSO_SEG_SIZE_MIN) 4312 printf("gso_size should be larger than %zu." 4313 " Please input a legal value\n", 4314 RTE_GSO_SEG_SIZE_MIN); 4315 else 4316 gso_max_segment_size = res->cmd_size; 4317 } 4318 } 4319 4320 cmdline_parse_token_string_t cmd_gso_size_set = 4321 TOKEN_STRING_INITIALIZER(struct cmd_gso_size_result, 4322 cmd_set, "set"); 4323 cmdline_parse_token_string_t cmd_gso_size_keyword = 4324 TOKEN_STRING_INITIALIZER(struct cmd_gso_size_result, 4325 cmd_keyword, "gso"); 4326 cmdline_parse_token_string_t cmd_gso_size_segsz = 4327 TOKEN_STRING_INITIALIZER(struct cmd_gso_size_result, 4328 cmd_segsz, "segsz"); 4329 cmdline_parse_token_num_t cmd_gso_size_size = 4330 TOKEN_NUM_INITIALIZER(struct cmd_gso_size_result, 4331 cmd_size, UINT16); 4332 4333 cmdline_parse_inst_t cmd_gso_size = { 4334 .f = cmd_gso_size_parsed, 4335 .data = NULL, 4336 .help_str = "set gso segsz <length>", 4337 .tokens = { 4338 (void *)&cmd_gso_size_set, 4339 (void *)&cmd_gso_size_keyword, 4340 (void *)&cmd_gso_size_segsz, 4341 (void *)&cmd_gso_size_size, 4342 NULL, 4343 }, 4344 }; 4345 4346 /* *** SHOW GSO CONFIGURATION *** */ 4347 struct cmd_gso_show_result { 4348 cmdline_fixed_string_t cmd_show; 4349 cmdline_fixed_string_t cmd_port; 4350 cmdline_fixed_string_t cmd_keyword; 4351 portid_t cmd_pid; 4352 }; 4353 4354 static void 4355 cmd_gso_show_parsed(void *parsed_result, 4356 __attribute__((unused)) struct cmdline *cl, 4357 __attribute__((unused)) void *data) 4358 { 4359 struct cmd_gso_show_result *res = parsed_result; 4360 4361 if (!rte_eth_dev_is_valid_port(res->cmd_pid)) { 4362 printf("invalid port id %u\n", res->cmd_pid); 4363 return; 4364 } 4365 if (!strcmp(res->cmd_keyword, "gso")) { 4366 if (gso_ports[res->cmd_pid].enable) { 4367 printf("Max GSO'd packet size: %uB\n" 4368 "Supported GSO types: TCP/IPv4, " 4369 "VxLAN with inner TCP/IPv4 packet, " 4370 "GRE with inner TCP/IPv4 packet\n", 4371 gso_max_segment_size); 4372 } else 4373 printf("GSO is not enabled on Port %u\n", res->cmd_pid); 4374 } 4375 } 4376 4377 cmdline_parse_token_string_t cmd_gso_show_show = 4378 TOKEN_STRING_INITIALIZER(struct cmd_gso_show_result, 4379 cmd_show, "show"); 4380 cmdline_parse_token_string_t cmd_gso_show_port = 4381 TOKEN_STRING_INITIALIZER(struct cmd_gso_show_result, 4382 cmd_port, "port"); 4383 cmdline_parse_token_string_t cmd_gso_show_keyword = 4384 TOKEN_STRING_INITIALIZER(struct cmd_gso_show_result, 4385 cmd_keyword, "gso"); 4386 cmdline_parse_token_num_t cmd_gso_show_pid = 4387 TOKEN_NUM_INITIALIZER(struct cmd_gso_show_result, 4388 cmd_pid, UINT16); 4389 4390 cmdline_parse_inst_t cmd_gso_show = { 4391 .f = cmd_gso_show_parsed, 4392 .data = NULL, 4393 .help_str = "show port <port_id> gso", 4394 .tokens = { 4395 (void *)&cmd_gso_show_show, 4396 (void *)&cmd_gso_show_port, 4397 (void *)&cmd_gso_show_pid, 4398 (void *)&cmd_gso_show_keyword, 4399 NULL, 4400 }, 4401 }; 4402 4403 /* *** ENABLE/DISABLE FLUSH ON RX STREAMS *** */ 4404 struct cmd_set_flush_rx { 4405 cmdline_fixed_string_t set; 4406 cmdline_fixed_string_t flush_rx; 4407 cmdline_fixed_string_t mode; 4408 }; 4409 4410 static void 4411 cmd_set_flush_rx_parsed(void *parsed_result, 4412 __attribute__((unused)) struct cmdline *cl, 4413 __attribute__((unused)) void *data) 4414 { 4415 struct cmd_set_flush_rx *res = parsed_result; 4416 no_flush_rx = (uint8_t)((strcmp(res->mode, "on") == 0) ? 0 : 1); 4417 } 4418 4419 cmdline_parse_token_string_t cmd_setflushrx_set = 4420 TOKEN_STRING_INITIALIZER(struct cmd_set_flush_rx, 4421 set, "set"); 4422 cmdline_parse_token_string_t cmd_setflushrx_flush_rx = 4423 TOKEN_STRING_INITIALIZER(struct cmd_set_flush_rx, 4424 flush_rx, "flush_rx"); 4425 cmdline_parse_token_string_t cmd_setflushrx_mode = 4426 TOKEN_STRING_INITIALIZER(struct cmd_set_flush_rx, 4427 mode, "on#off"); 4428 4429 4430 cmdline_parse_inst_t cmd_set_flush_rx = { 4431 .f = cmd_set_flush_rx_parsed, 4432 .help_str = "set flush_rx on|off: Enable/Disable flush on rx streams", 4433 .data = NULL, 4434 .tokens = { 4435 (void *)&cmd_setflushrx_set, 4436 (void *)&cmd_setflushrx_flush_rx, 4437 (void *)&cmd_setflushrx_mode, 4438 NULL, 4439 }, 4440 }; 4441 4442 /* *** ENABLE/DISABLE LINK STATUS CHECK *** */ 4443 struct cmd_set_link_check { 4444 cmdline_fixed_string_t set; 4445 cmdline_fixed_string_t link_check; 4446 cmdline_fixed_string_t mode; 4447 }; 4448 4449 static void 4450 cmd_set_link_check_parsed(void *parsed_result, 4451 __attribute__((unused)) struct cmdline *cl, 4452 __attribute__((unused)) void *data) 4453 { 4454 struct cmd_set_link_check *res = parsed_result; 4455 no_link_check = (uint8_t)((strcmp(res->mode, "on") == 0) ? 0 : 1); 4456 } 4457 4458 cmdline_parse_token_string_t cmd_setlinkcheck_set = 4459 TOKEN_STRING_INITIALIZER(struct cmd_set_link_check, 4460 set, "set"); 4461 cmdline_parse_token_string_t cmd_setlinkcheck_link_check = 4462 TOKEN_STRING_INITIALIZER(struct cmd_set_link_check, 4463 link_check, "link_check"); 4464 cmdline_parse_token_string_t cmd_setlinkcheck_mode = 4465 TOKEN_STRING_INITIALIZER(struct cmd_set_link_check, 4466 mode, "on#off"); 4467 4468 4469 cmdline_parse_inst_t cmd_set_link_check = { 4470 .f = cmd_set_link_check_parsed, 4471 .help_str = "set link_check on|off: Enable/Disable link status check " 4472 "when starting/stopping a port", 4473 .data = NULL, 4474 .tokens = { 4475 (void *)&cmd_setlinkcheck_set, 4476 (void *)&cmd_setlinkcheck_link_check, 4477 (void *)&cmd_setlinkcheck_mode, 4478 NULL, 4479 }, 4480 }; 4481 4482 /* *** SET NIC BYPASS MODE *** */ 4483 struct cmd_set_bypass_mode_result { 4484 cmdline_fixed_string_t set; 4485 cmdline_fixed_string_t bypass; 4486 cmdline_fixed_string_t mode; 4487 cmdline_fixed_string_t value; 4488 portid_t port_id; 4489 }; 4490 4491 static void 4492 cmd_set_bypass_mode_parsed(void *parsed_result, 4493 __attribute__((unused)) struct cmdline *cl, 4494 __attribute__((unused)) void *data) 4495 { 4496 struct cmd_set_bypass_mode_result *res = parsed_result; 4497 portid_t port_id = res->port_id; 4498 int32_t rc = -EINVAL; 4499 4500 #if defined RTE_LIBRTE_IXGBE_PMD && defined RTE_LIBRTE_IXGBE_BYPASS 4501 uint32_t bypass_mode = RTE_PMD_IXGBE_BYPASS_MODE_NORMAL; 4502 4503 if (!strcmp(res->value, "bypass")) 4504 bypass_mode = RTE_PMD_IXGBE_BYPASS_MODE_BYPASS; 4505 else if (!strcmp(res->value, "isolate")) 4506 bypass_mode = RTE_PMD_IXGBE_BYPASS_MODE_ISOLATE; 4507 else 4508 bypass_mode = RTE_PMD_IXGBE_BYPASS_MODE_NORMAL; 4509 4510 /* Set the bypass mode for the relevant port. */ 4511 rc = rte_pmd_ixgbe_bypass_state_set(port_id, &bypass_mode); 4512 #endif 4513 if (rc != 0) 4514 printf("\t Failed to set bypass mode for port = %d.\n", port_id); 4515 } 4516 4517 cmdline_parse_token_string_t cmd_setbypass_mode_set = 4518 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_mode_result, 4519 set, "set"); 4520 cmdline_parse_token_string_t cmd_setbypass_mode_bypass = 4521 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_mode_result, 4522 bypass, "bypass"); 4523 cmdline_parse_token_string_t cmd_setbypass_mode_mode = 4524 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_mode_result, 4525 mode, "mode"); 4526 cmdline_parse_token_string_t cmd_setbypass_mode_value = 4527 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_mode_result, 4528 value, "normal#bypass#isolate"); 4529 cmdline_parse_token_num_t cmd_setbypass_mode_port = 4530 TOKEN_NUM_INITIALIZER(struct cmd_set_bypass_mode_result, 4531 port_id, UINT16); 4532 4533 cmdline_parse_inst_t cmd_set_bypass_mode = { 4534 .f = cmd_set_bypass_mode_parsed, 4535 .help_str = "set bypass mode normal|bypass|isolate <port_id>: " 4536 "Set the NIC bypass mode for port_id", 4537 .data = NULL, 4538 .tokens = { 4539 (void *)&cmd_setbypass_mode_set, 4540 (void *)&cmd_setbypass_mode_bypass, 4541 (void *)&cmd_setbypass_mode_mode, 4542 (void *)&cmd_setbypass_mode_value, 4543 (void *)&cmd_setbypass_mode_port, 4544 NULL, 4545 }, 4546 }; 4547 4548 /* *** SET NIC BYPASS EVENT *** */ 4549 struct cmd_set_bypass_event_result { 4550 cmdline_fixed_string_t set; 4551 cmdline_fixed_string_t bypass; 4552 cmdline_fixed_string_t event; 4553 cmdline_fixed_string_t event_value; 4554 cmdline_fixed_string_t mode; 4555 cmdline_fixed_string_t mode_value; 4556 portid_t port_id; 4557 }; 4558 4559 static void 4560 cmd_set_bypass_event_parsed(void *parsed_result, 4561 __attribute__((unused)) struct cmdline *cl, 4562 __attribute__((unused)) void *data) 4563 { 4564 int32_t rc = -EINVAL; 4565 struct cmd_set_bypass_event_result *res = parsed_result; 4566 portid_t port_id = res->port_id; 4567 4568 #if defined RTE_LIBRTE_IXGBE_PMD && defined RTE_LIBRTE_IXGBE_BYPASS 4569 uint32_t bypass_event = RTE_PMD_IXGBE_BYPASS_EVENT_NONE; 4570 uint32_t bypass_mode = RTE_PMD_IXGBE_BYPASS_MODE_NORMAL; 4571 4572 if (!strcmp(res->event_value, "timeout")) 4573 bypass_event = RTE_PMD_IXGBE_BYPASS_EVENT_TIMEOUT; 4574 else if (!strcmp(res->event_value, "os_on")) 4575 bypass_event = RTE_PMD_IXGBE_BYPASS_EVENT_OS_ON; 4576 else if (!strcmp(res->event_value, "os_off")) 4577 bypass_event = RTE_PMD_IXGBE_BYPASS_EVENT_OS_OFF; 4578 else if (!strcmp(res->event_value, "power_on")) 4579 bypass_event = RTE_PMD_IXGBE_BYPASS_EVENT_POWER_ON; 4580 else if (!strcmp(res->event_value, "power_off")) 4581 bypass_event = RTE_PMD_IXGBE_BYPASS_EVENT_POWER_OFF; 4582 else 4583 bypass_event = RTE_PMD_IXGBE_BYPASS_EVENT_NONE; 4584 4585 if (!strcmp(res->mode_value, "bypass")) 4586 bypass_mode = RTE_PMD_IXGBE_BYPASS_MODE_BYPASS; 4587 else if (!strcmp(res->mode_value, "isolate")) 4588 bypass_mode = RTE_PMD_IXGBE_BYPASS_MODE_ISOLATE; 4589 else 4590 bypass_mode = RTE_PMD_IXGBE_BYPASS_MODE_NORMAL; 4591 4592 /* Set the watchdog timeout. */ 4593 if (bypass_event == RTE_PMD_IXGBE_BYPASS_EVENT_TIMEOUT) { 4594 4595 rc = -EINVAL; 4596 if (RTE_PMD_IXGBE_BYPASS_TMT_VALID(bypass_timeout)) { 4597 rc = rte_pmd_ixgbe_bypass_wd_timeout_store(port_id, 4598 bypass_timeout); 4599 } 4600 if (rc != 0) { 4601 printf("Failed to set timeout value %u " 4602 "for port %d, errto code: %d.\n", 4603 bypass_timeout, port_id, rc); 4604 } 4605 } 4606 4607 /* Set the bypass event to transition to bypass mode. */ 4608 rc = rte_pmd_ixgbe_bypass_event_store(port_id, bypass_event, 4609 bypass_mode); 4610 #endif 4611 4612 if (rc != 0) 4613 printf("\t Failed to set bypass event for port = %d.\n", 4614 port_id); 4615 } 4616 4617 cmdline_parse_token_string_t cmd_setbypass_event_set = 4618 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_event_result, 4619 set, "set"); 4620 cmdline_parse_token_string_t cmd_setbypass_event_bypass = 4621 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_event_result, 4622 bypass, "bypass"); 4623 cmdline_parse_token_string_t cmd_setbypass_event_event = 4624 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_event_result, 4625 event, "event"); 4626 cmdline_parse_token_string_t cmd_setbypass_event_event_value = 4627 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_event_result, 4628 event_value, "none#timeout#os_off#os_on#power_on#power_off"); 4629 cmdline_parse_token_string_t cmd_setbypass_event_mode = 4630 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_event_result, 4631 mode, "mode"); 4632 cmdline_parse_token_string_t cmd_setbypass_event_mode_value = 4633 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_event_result, 4634 mode_value, "normal#bypass#isolate"); 4635 cmdline_parse_token_num_t cmd_setbypass_event_port = 4636 TOKEN_NUM_INITIALIZER(struct cmd_set_bypass_event_result, 4637 port_id, UINT16); 4638 4639 cmdline_parse_inst_t cmd_set_bypass_event = { 4640 .f = cmd_set_bypass_event_parsed, 4641 .help_str = "set bypass event none|timeout|os_on|os_off|power_on|" 4642 "power_off mode normal|bypass|isolate <port_id>: " 4643 "Set the NIC bypass event mode for port_id", 4644 .data = NULL, 4645 .tokens = { 4646 (void *)&cmd_setbypass_event_set, 4647 (void *)&cmd_setbypass_event_bypass, 4648 (void *)&cmd_setbypass_event_event, 4649 (void *)&cmd_setbypass_event_event_value, 4650 (void *)&cmd_setbypass_event_mode, 4651 (void *)&cmd_setbypass_event_mode_value, 4652 (void *)&cmd_setbypass_event_port, 4653 NULL, 4654 }, 4655 }; 4656 4657 4658 /* *** SET NIC BYPASS TIMEOUT *** */ 4659 struct cmd_set_bypass_timeout_result { 4660 cmdline_fixed_string_t set; 4661 cmdline_fixed_string_t bypass; 4662 cmdline_fixed_string_t timeout; 4663 cmdline_fixed_string_t value; 4664 }; 4665 4666 static void 4667 cmd_set_bypass_timeout_parsed(void *parsed_result, 4668 __attribute__((unused)) struct cmdline *cl, 4669 __attribute__((unused)) void *data) 4670 { 4671 __rte_unused struct cmd_set_bypass_timeout_result *res = parsed_result; 4672 4673 #if defined RTE_LIBRTE_IXGBE_PMD && defined RTE_LIBRTE_IXGBE_BYPASS 4674 if (!strcmp(res->value, "1.5")) 4675 bypass_timeout = RTE_PMD_IXGBE_BYPASS_TMT_1_5_SEC; 4676 else if (!strcmp(res->value, "2")) 4677 bypass_timeout = RTE_PMD_IXGBE_BYPASS_TMT_2_SEC; 4678 else if (!strcmp(res->value, "3")) 4679 bypass_timeout = RTE_PMD_IXGBE_BYPASS_TMT_3_SEC; 4680 else if (!strcmp(res->value, "4")) 4681 bypass_timeout = RTE_PMD_IXGBE_BYPASS_TMT_4_SEC; 4682 else if (!strcmp(res->value, "8")) 4683 bypass_timeout = RTE_PMD_IXGBE_BYPASS_TMT_8_SEC; 4684 else if (!strcmp(res->value, "16")) 4685 bypass_timeout = RTE_PMD_IXGBE_BYPASS_TMT_16_SEC; 4686 else if (!strcmp(res->value, "32")) 4687 bypass_timeout = RTE_PMD_IXGBE_BYPASS_TMT_32_SEC; 4688 else 4689 bypass_timeout = RTE_PMD_IXGBE_BYPASS_TMT_OFF; 4690 #endif 4691 } 4692 4693 cmdline_parse_token_string_t cmd_setbypass_timeout_set = 4694 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_timeout_result, 4695 set, "set"); 4696 cmdline_parse_token_string_t cmd_setbypass_timeout_bypass = 4697 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_timeout_result, 4698 bypass, "bypass"); 4699 cmdline_parse_token_string_t cmd_setbypass_timeout_timeout = 4700 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_timeout_result, 4701 timeout, "timeout"); 4702 cmdline_parse_token_string_t cmd_setbypass_timeout_value = 4703 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_timeout_result, 4704 value, "0#1.5#2#3#4#8#16#32"); 4705 4706 cmdline_parse_inst_t cmd_set_bypass_timeout = { 4707 .f = cmd_set_bypass_timeout_parsed, 4708 .help_str = "set bypass timeout 0|1.5|2|3|4|8|16|32: " 4709 "Set the NIC bypass watchdog timeout in seconds", 4710 .data = NULL, 4711 .tokens = { 4712 (void *)&cmd_setbypass_timeout_set, 4713 (void *)&cmd_setbypass_timeout_bypass, 4714 (void *)&cmd_setbypass_timeout_timeout, 4715 (void *)&cmd_setbypass_timeout_value, 4716 NULL, 4717 }, 4718 }; 4719 4720 /* *** SHOW NIC BYPASS MODE *** */ 4721 struct cmd_show_bypass_config_result { 4722 cmdline_fixed_string_t show; 4723 cmdline_fixed_string_t bypass; 4724 cmdline_fixed_string_t config; 4725 portid_t port_id; 4726 }; 4727 4728 static void 4729 cmd_show_bypass_config_parsed(void *parsed_result, 4730 __attribute__((unused)) struct cmdline *cl, 4731 __attribute__((unused)) void *data) 4732 { 4733 struct cmd_show_bypass_config_result *res = parsed_result; 4734 portid_t port_id = res->port_id; 4735 int rc = -EINVAL; 4736 #if defined RTE_LIBRTE_IXGBE_PMD && defined RTE_LIBRTE_IXGBE_BYPASS 4737 uint32_t event_mode; 4738 uint32_t bypass_mode; 4739 uint32_t timeout = bypass_timeout; 4740 int i; 4741 4742 static const char * const timeouts[RTE_PMD_IXGBE_BYPASS_TMT_NUM] = 4743 {"off", "1.5", "2", "3", "4", "8", "16", "32"}; 4744 static const char * const modes[RTE_PMD_IXGBE_BYPASS_MODE_NUM] = 4745 {"UNKNOWN", "normal", "bypass", "isolate"}; 4746 static const char * const events[RTE_PMD_IXGBE_BYPASS_EVENT_NUM] = { 4747 "NONE", 4748 "OS/board on", 4749 "power supply on", 4750 "OS/board off", 4751 "power supply off", 4752 "timeout"}; 4753 int num_events = (sizeof events) / (sizeof events[0]); 4754 4755 /* Display the bypass mode.*/ 4756 if (rte_pmd_ixgbe_bypass_state_show(port_id, &bypass_mode) != 0) { 4757 printf("\tFailed to get bypass mode for port = %d\n", port_id); 4758 return; 4759 } 4760 else { 4761 if (!RTE_PMD_IXGBE_BYPASS_MODE_VALID(bypass_mode)) 4762 bypass_mode = RTE_PMD_IXGBE_BYPASS_MODE_NONE; 4763 4764 printf("\tbypass mode = %s\n", modes[bypass_mode]); 4765 } 4766 4767 /* Display the bypass timeout.*/ 4768 if (!RTE_PMD_IXGBE_BYPASS_TMT_VALID(timeout)) 4769 timeout = RTE_PMD_IXGBE_BYPASS_TMT_OFF; 4770 4771 printf("\tbypass timeout = %s\n", timeouts[timeout]); 4772 4773 /* Display the bypass events and associated modes. */ 4774 for (i = RTE_PMD_IXGBE_BYPASS_EVENT_START; i < num_events; i++) { 4775 4776 if (rte_pmd_ixgbe_bypass_event_show(port_id, i, &event_mode)) { 4777 printf("\tFailed to get bypass mode for event = %s\n", 4778 events[i]); 4779 } else { 4780 if (!RTE_PMD_IXGBE_BYPASS_MODE_VALID(event_mode)) 4781 event_mode = RTE_PMD_IXGBE_BYPASS_MODE_NONE; 4782 4783 printf("\tbypass event: %-16s = %s\n", events[i], 4784 modes[event_mode]); 4785 } 4786 } 4787 #endif 4788 if (rc != 0) 4789 printf("\tFailed to get bypass configuration for port = %d\n", 4790 port_id); 4791 } 4792 4793 cmdline_parse_token_string_t cmd_showbypass_config_show = 4794 TOKEN_STRING_INITIALIZER(struct cmd_show_bypass_config_result, 4795 show, "show"); 4796 cmdline_parse_token_string_t cmd_showbypass_config_bypass = 4797 TOKEN_STRING_INITIALIZER(struct cmd_show_bypass_config_result, 4798 bypass, "bypass"); 4799 cmdline_parse_token_string_t cmd_showbypass_config_config = 4800 TOKEN_STRING_INITIALIZER(struct cmd_show_bypass_config_result, 4801 config, "config"); 4802 cmdline_parse_token_num_t cmd_showbypass_config_port = 4803 TOKEN_NUM_INITIALIZER(struct cmd_show_bypass_config_result, 4804 port_id, UINT16); 4805 4806 cmdline_parse_inst_t cmd_show_bypass_config = { 4807 .f = cmd_show_bypass_config_parsed, 4808 .help_str = "show bypass config <port_id>: " 4809 "Show the NIC bypass config for port_id", 4810 .data = NULL, 4811 .tokens = { 4812 (void *)&cmd_showbypass_config_show, 4813 (void *)&cmd_showbypass_config_bypass, 4814 (void *)&cmd_showbypass_config_config, 4815 (void *)&cmd_showbypass_config_port, 4816 NULL, 4817 }, 4818 }; 4819 4820 #ifdef RTE_LIBRTE_PMD_BOND 4821 /* *** SET BONDING MODE *** */ 4822 struct cmd_set_bonding_mode_result { 4823 cmdline_fixed_string_t set; 4824 cmdline_fixed_string_t bonding; 4825 cmdline_fixed_string_t mode; 4826 uint8_t value; 4827 portid_t port_id; 4828 }; 4829 4830 static void cmd_set_bonding_mode_parsed(void *parsed_result, 4831 __attribute__((unused)) struct cmdline *cl, 4832 __attribute__((unused)) void *data) 4833 { 4834 struct cmd_set_bonding_mode_result *res = parsed_result; 4835 portid_t port_id = res->port_id; 4836 4837 /* Set the bonding mode for the relevant port. */ 4838 if (0 != rte_eth_bond_mode_set(port_id, res->value)) 4839 printf("\t Failed to set bonding mode for port = %d.\n", port_id); 4840 } 4841 4842 cmdline_parse_token_string_t cmd_setbonding_mode_set = 4843 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_mode_result, 4844 set, "set"); 4845 cmdline_parse_token_string_t cmd_setbonding_mode_bonding = 4846 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_mode_result, 4847 bonding, "bonding"); 4848 cmdline_parse_token_string_t cmd_setbonding_mode_mode = 4849 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_mode_result, 4850 mode, "mode"); 4851 cmdline_parse_token_num_t cmd_setbonding_mode_value = 4852 TOKEN_NUM_INITIALIZER(struct cmd_set_bonding_mode_result, 4853 value, UINT8); 4854 cmdline_parse_token_num_t cmd_setbonding_mode_port = 4855 TOKEN_NUM_INITIALIZER(struct cmd_set_bonding_mode_result, 4856 port_id, UINT16); 4857 4858 cmdline_parse_inst_t cmd_set_bonding_mode = { 4859 .f = cmd_set_bonding_mode_parsed, 4860 .help_str = "set bonding mode <mode_value> <port_id>: " 4861 "Set the bonding mode for port_id", 4862 .data = NULL, 4863 .tokens = { 4864 (void *) &cmd_setbonding_mode_set, 4865 (void *) &cmd_setbonding_mode_bonding, 4866 (void *) &cmd_setbonding_mode_mode, 4867 (void *) &cmd_setbonding_mode_value, 4868 (void *) &cmd_setbonding_mode_port, 4869 NULL 4870 } 4871 }; 4872 4873 /* *** SET BONDING SLOW_QUEUE SW/HW *** */ 4874 struct cmd_set_bonding_lacp_dedicated_queues_result { 4875 cmdline_fixed_string_t set; 4876 cmdline_fixed_string_t bonding; 4877 cmdline_fixed_string_t lacp; 4878 cmdline_fixed_string_t dedicated_queues; 4879 portid_t port_id; 4880 cmdline_fixed_string_t mode; 4881 }; 4882 4883 static void cmd_set_bonding_lacp_dedicated_queues_parsed(void *parsed_result, 4884 __attribute__((unused)) struct cmdline *cl, 4885 __attribute__((unused)) void *data) 4886 { 4887 struct cmd_set_bonding_lacp_dedicated_queues_result *res = parsed_result; 4888 portid_t port_id = res->port_id; 4889 struct rte_port *port; 4890 4891 port = &ports[port_id]; 4892 4893 /** Check if the port is not started **/ 4894 if (port->port_status != RTE_PORT_STOPPED) { 4895 printf("Please stop port %d first\n", port_id); 4896 return; 4897 } 4898 4899 if (!strcmp(res->mode, "enable")) { 4900 if (rte_eth_bond_8023ad_dedicated_queues_enable(port_id) == 0) 4901 printf("Dedicate queues for LACP control packets" 4902 " enabled\n"); 4903 else 4904 printf("Enabling dedicate queues for LACP control " 4905 "packets on port %d failed\n", port_id); 4906 } else if (!strcmp(res->mode, "disable")) { 4907 if (rte_eth_bond_8023ad_dedicated_queues_disable(port_id) == 0) 4908 printf("Dedicated queues for LACP control packets " 4909 "disabled\n"); 4910 else 4911 printf("Disabling dedicated queues for LACP control " 4912 "traffic on port %d failed\n", port_id); 4913 } 4914 } 4915 4916 cmdline_parse_token_string_t cmd_setbonding_lacp_dedicated_queues_set = 4917 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_lacp_dedicated_queues_result, 4918 set, "set"); 4919 cmdline_parse_token_string_t cmd_setbonding_lacp_dedicated_queues_bonding = 4920 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_lacp_dedicated_queues_result, 4921 bonding, "bonding"); 4922 cmdline_parse_token_string_t cmd_setbonding_lacp_dedicated_queues_lacp = 4923 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_lacp_dedicated_queues_result, 4924 lacp, "lacp"); 4925 cmdline_parse_token_string_t cmd_setbonding_lacp_dedicated_queues_dedicated_queues = 4926 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_lacp_dedicated_queues_result, 4927 dedicated_queues, "dedicated_queues"); 4928 cmdline_parse_token_num_t cmd_setbonding_lacp_dedicated_queues_port_id = 4929 TOKEN_NUM_INITIALIZER(struct cmd_set_bonding_lacp_dedicated_queues_result, 4930 port_id, UINT16); 4931 cmdline_parse_token_string_t cmd_setbonding_lacp_dedicated_queues_mode = 4932 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_lacp_dedicated_queues_result, 4933 mode, "enable#disable"); 4934 4935 cmdline_parse_inst_t cmd_set_lacp_dedicated_queues = { 4936 .f = cmd_set_bonding_lacp_dedicated_queues_parsed, 4937 .help_str = "set bonding lacp dedicated_queues <port_id> " 4938 "enable|disable: " 4939 "Enable/disable dedicated queues for LACP control traffic for port_id", 4940 .data = NULL, 4941 .tokens = { 4942 (void *)&cmd_setbonding_lacp_dedicated_queues_set, 4943 (void *)&cmd_setbonding_lacp_dedicated_queues_bonding, 4944 (void *)&cmd_setbonding_lacp_dedicated_queues_lacp, 4945 (void *)&cmd_setbonding_lacp_dedicated_queues_dedicated_queues, 4946 (void *)&cmd_setbonding_lacp_dedicated_queues_port_id, 4947 (void *)&cmd_setbonding_lacp_dedicated_queues_mode, 4948 NULL 4949 } 4950 }; 4951 4952 /* *** SET BALANCE XMIT POLICY *** */ 4953 struct cmd_set_bonding_balance_xmit_policy_result { 4954 cmdline_fixed_string_t set; 4955 cmdline_fixed_string_t bonding; 4956 cmdline_fixed_string_t balance_xmit_policy; 4957 portid_t port_id; 4958 cmdline_fixed_string_t policy; 4959 }; 4960 4961 static void cmd_set_bonding_balance_xmit_policy_parsed(void *parsed_result, 4962 __attribute__((unused)) struct cmdline *cl, 4963 __attribute__((unused)) void *data) 4964 { 4965 struct cmd_set_bonding_balance_xmit_policy_result *res = parsed_result; 4966 portid_t port_id = res->port_id; 4967 uint8_t policy; 4968 4969 if (!strcmp(res->policy, "l2")) { 4970 policy = BALANCE_XMIT_POLICY_LAYER2; 4971 } else if (!strcmp(res->policy, "l23")) { 4972 policy = BALANCE_XMIT_POLICY_LAYER23; 4973 } else if (!strcmp(res->policy, "l34")) { 4974 policy = BALANCE_XMIT_POLICY_LAYER34; 4975 } else { 4976 printf("\t Invalid xmit policy selection"); 4977 return; 4978 } 4979 4980 /* Set the bonding mode for the relevant port. */ 4981 if (0 != rte_eth_bond_xmit_policy_set(port_id, policy)) { 4982 printf("\t Failed to set bonding balance xmit policy for port = %d.\n", 4983 port_id); 4984 } 4985 } 4986 4987 cmdline_parse_token_string_t cmd_setbonding_balance_xmit_policy_set = 4988 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_balance_xmit_policy_result, 4989 set, "set"); 4990 cmdline_parse_token_string_t cmd_setbonding_balance_xmit_policy_bonding = 4991 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_balance_xmit_policy_result, 4992 bonding, "bonding"); 4993 cmdline_parse_token_string_t cmd_setbonding_balance_xmit_policy_balance_xmit_policy = 4994 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_balance_xmit_policy_result, 4995 balance_xmit_policy, "balance_xmit_policy"); 4996 cmdline_parse_token_num_t cmd_setbonding_balance_xmit_policy_port = 4997 TOKEN_NUM_INITIALIZER(struct cmd_set_bonding_balance_xmit_policy_result, 4998 port_id, UINT16); 4999 cmdline_parse_token_string_t cmd_setbonding_balance_xmit_policy_policy = 5000 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_balance_xmit_policy_result, 5001 policy, "l2#l23#l34"); 5002 5003 cmdline_parse_inst_t cmd_set_balance_xmit_policy = { 5004 .f = cmd_set_bonding_balance_xmit_policy_parsed, 5005 .help_str = "set bonding balance_xmit_policy <port_id> " 5006 "l2|l23|l34: " 5007 "Set the bonding balance_xmit_policy for port_id", 5008 .data = NULL, 5009 .tokens = { 5010 (void *)&cmd_setbonding_balance_xmit_policy_set, 5011 (void *)&cmd_setbonding_balance_xmit_policy_bonding, 5012 (void *)&cmd_setbonding_balance_xmit_policy_balance_xmit_policy, 5013 (void *)&cmd_setbonding_balance_xmit_policy_port, 5014 (void *)&cmd_setbonding_balance_xmit_policy_policy, 5015 NULL 5016 } 5017 }; 5018 5019 /* *** SHOW NIC BONDING CONFIGURATION *** */ 5020 struct cmd_show_bonding_config_result { 5021 cmdline_fixed_string_t show; 5022 cmdline_fixed_string_t bonding; 5023 cmdline_fixed_string_t config; 5024 portid_t port_id; 5025 }; 5026 5027 static void cmd_show_bonding_config_parsed(void *parsed_result, 5028 __attribute__((unused)) struct cmdline *cl, 5029 __attribute__((unused)) void *data) 5030 { 5031 struct cmd_show_bonding_config_result *res = parsed_result; 5032 int bonding_mode, agg_mode; 5033 portid_t slaves[RTE_MAX_ETHPORTS]; 5034 int num_slaves, num_active_slaves; 5035 int primary_id; 5036 int i; 5037 portid_t port_id = res->port_id; 5038 5039 /* Display the bonding mode.*/ 5040 bonding_mode = rte_eth_bond_mode_get(port_id); 5041 if (bonding_mode < 0) { 5042 printf("\tFailed to get bonding mode for port = %d\n", port_id); 5043 return; 5044 } else 5045 printf("\tBonding mode: %d\n", bonding_mode); 5046 5047 if (bonding_mode == BONDING_MODE_BALANCE) { 5048 int balance_xmit_policy; 5049 5050 balance_xmit_policy = rte_eth_bond_xmit_policy_get(port_id); 5051 if (balance_xmit_policy < 0) { 5052 printf("\tFailed to get balance xmit policy for port = %d\n", 5053 port_id); 5054 return; 5055 } else { 5056 printf("\tBalance Xmit Policy: "); 5057 5058 switch (balance_xmit_policy) { 5059 case BALANCE_XMIT_POLICY_LAYER2: 5060 printf("BALANCE_XMIT_POLICY_LAYER2"); 5061 break; 5062 case BALANCE_XMIT_POLICY_LAYER23: 5063 printf("BALANCE_XMIT_POLICY_LAYER23"); 5064 break; 5065 case BALANCE_XMIT_POLICY_LAYER34: 5066 printf("BALANCE_XMIT_POLICY_LAYER34"); 5067 break; 5068 } 5069 printf("\n"); 5070 } 5071 } 5072 5073 if (bonding_mode == BONDING_MODE_8023AD) { 5074 agg_mode = rte_eth_bond_8023ad_agg_selection_get(port_id); 5075 printf("\tIEEE802.3AD Aggregator Mode: "); 5076 switch (agg_mode) { 5077 case AGG_BANDWIDTH: 5078 printf("bandwidth"); 5079 break; 5080 case AGG_STABLE: 5081 printf("stable"); 5082 break; 5083 case AGG_COUNT: 5084 printf("count"); 5085 break; 5086 } 5087 printf("\n"); 5088 } 5089 5090 num_slaves = rte_eth_bond_slaves_get(port_id, slaves, RTE_MAX_ETHPORTS); 5091 5092 if (num_slaves < 0) { 5093 printf("\tFailed to get slave list for port = %d\n", port_id); 5094 return; 5095 } 5096 if (num_slaves > 0) { 5097 printf("\tSlaves (%d): [", num_slaves); 5098 for (i = 0; i < num_slaves - 1; i++) 5099 printf("%d ", slaves[i]); 5100 5101 printf("%d]\n", slaves[num_slaves - 1]); 5102 } else { 5103 printf("\tSlaves: []\n"); 5104 5105 } 5106 5107 num_active_slaves = rte_eth_bond_active_slaves_get(port_id, slaves, 5108 RTE_MAX_ETHPORTS); 5109 5110 if (num_active_slaves < 0) { 5111 printf("\tFailed to get active slave list for port = %d\n", port_id); 5112 return; 5113 } 5114 if (num_active_slaves > 0) { 5115 printf("\tActive Slaves (%d): [", num_active_slaves); 5116 for (i = 0; i < num_active_slaves - 1; i++) 5117 printf("%d ", slaves[i]); 5118 5119 printf("%d]\n", slaves[num_active_slaves - 1]); 5120 5121 } else { 5122 printf("\tActive Slaves: []\n"); 5123 5124 } 5125 5126 primary_id = rte_eth_bond_primary_get(port_id); 5127 if (primary_id < 0) { 5128 printf("\tFailed to get primary slave for port = %d\n", port_id); 5129 return; 5130 } else 5131 printf("\tPrimary: [%d]\n", primary_id); 5132 5133 } 5134 5135 cmdline_parse_token_string_t cmd_showbonding_config_show = 5136 TOKEN_STRING_INITIALIZER(struct cmd_show_bonding_config_result, 5137 show, "show"); 5138 cmdline_parse_token_string_t cmd_showbonding_config_bonding = 5139 TOKEN_STRING_INITIALIZER(struct cmd_show_bonding_config_result, 5140 bonding, "bonding"); 5141 cmdline_parse_token_string_t cmd_showbonding_config_config = 5142 TOKEN_STRING_INITIALIZER(struct cmd_show_bonding_config_result, 5143 config, "config"); 5144 cmdline_parse_token_num_t cmd_showbonding_config_port = 5145 TOKEN_NUM_INITIALIZER(struct cmd_show_bonding_config_result, 5146 port_id, UINT16); 5147 5148 cmdline_parse_inst_t cmd_show_bonding_config = { 5149 .f = cmd_show_bonding_config_parsed, 5150 .help_str = "show bonding config <port_id>: " 5151 "Show the bonding config for port_id", 5152 .data = NULL, 5153 .tokens = { 5154 (void *)&cmd_showbonding_config_show, 5155 (void *)&cmd_showbonding_config_bonding, 5156 (void *)&cmd_showbonding_config_config, 5157 (void *)&cmd_showbonding_config_port, 5158 NULL 5159 } 5160 }; 5161 5162 /* *** SET BONDING PRIMARY *** */ 5163 struct cmd_set_bonding_primary_result { 5164 cmdline_fixed_string_t set; 5165 cmdline_fixed_string_t bonding; 5166 cmdline_fixed_string_t primary; 5167 portid_t slave_id; 5168 portid_t port_id; 5169 }; 5170 5171 static void cmd_set_bonding_primary_parsed(void *parsed_result, 5172 __attribute__((unused)) struct cmdline *cl, 5173 __attribute__((unused)) void *data) 5174 { 5175 struct cmd_set_bonding_primary_result *res = parsed_result; 5176 portid_t master_port_id = res->port_id; 5177 portid_t slave_port_id = res->slave_id; 5178 5179 /* Set the primary slave for a bonded device. */ 5180 if (0 != rte_eth_bond_primary_set(master_port_id, slave_port_id)) { 5181 printf("\t Failed to set primary slave for port = %d.\n", 5182 master_port_id); 5183 return; 5184 } 5185 init_port_config(); 5186 } 5187 5188 cmdline_parse_token_string_t cmd_setbonding_primary_set = 5189 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_primary_result, 5190 set, "set"); 5191 cmdline_parse_token_string_t cmd_setbonding_primary_bonding = 5192 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_primary_result, 5193 bonding, "bonding"); 5194 cmdline_parse_token_string_t cmd_setbonding_primary_primary = 5195 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_primary_result, 5196 primary, "primary"); 5197 cmdline_parse_token_num_t cmd_setbonding_primary_slave = 5198 TOKEN_NUM_INITIALIZER(struct cmd_set_bonding_primary_result, 5199 slave_id, UINT16); 5200 cmdline_parse_token_num_t cmd_setbonding_primary_port = 5201 TOKEN_NUM_INITIALIZER(struct cmd_set_bonding_primary_result, 5202 port_id, UINT16); 5203 5204 cmdline_parse_inst_t cmd_set_bonding_primary = { 5205 .f = cmd_set_bonding_primary_parsed, 5206 .help_str = "set bonding primary <slave_id> <port_id>: " 5207 "Set the primary slave for port_id", 5208 .data = NULL, 5209 .tokens = { 5210 (void *)&cmd_setbonding_primary_set, 5211 (void *)&cmd_setbonding_primary_bonding, 5212 (void *)&cmd_setbonding_primary_primary, 5213 (void *)&cmd_setbonding_primary_slave, 5214 (void *)&cmd_setbonding_primary_port, 5215 NULL 5216 } 5217 }; 5218 5219 /* *** ADD SLAVE *** */ 5220 struct cmd_add_bonding_slave_result { 5221 cmdline_fixed_string_t add; 5222 cmdline_fixed_string_t bonding; 5223 cmdline_fixed_string_t slave; 5224 portid_t slave_id; 5225 portid_t port_id; 5226 }; 5227 5228 static void cmd_add_bonding_slave_parsed(void *parsed_result, 5229 __attribute__((unused)) struct cmdline *cl, 5230 __attribute__((unused)) void *data) 5231 { 5232 struct cmd_add_bonding_slave_result *res = parsed_result; 5233 portid_t master_port_id = res->port_id; 5234 portid_t slave_port_id = res->slave_id; 5235 5236 /* add the slave for a bonded device. */ 5237 if (0 != rte_eth_bond_slave_add(master_port_id, slave_port_id)) { 5238 printf("\t Failed to add slave %d to master port = %d.\n", 5239 slave_port_id, master_port_id); 5240 return; 5241 } 5242 init_port_config(); 5243 set_port_slave_flag(slave_port_id); 5244 } 5245 5246 cmdline_parse_token_string_t cmd_addbonding_slave_add = 5247 TOKEN_STRING_INITIALIZER(struct cmd_add_bonding_slave_result, 5248 add, "add"); 5249 cmdline_parse_token_string_t cmd_addbonding_slave_bonding = 5250 TOKEN_STRING_INITIALIZER(struct cmd_add_bonding_slave_result, 5251 bonding, "bonding"); 5252 cmdline_parse_token_string_t cmd_addbonding_slave_slave = 5253 TOKEN_STRING_INITIALIZER(struct cmd_add_bonding_slave_result, 5254 slave, "slave"); 5255 cmdline_parse_token_num_t cmd_addbonding_slave_slaveid = 5256 TOKEN_NUM_INITIALIZER(struct cmd_add_bonding_slave_result, 5257 slave_id, UINT16); 5258 cmdline_parse_token_num_t cmd_addbonding_slave_port = 5259 TOKEN_NUM_INITIALIZER(struct cmd_add_bonding_slave_result, 5260 port_id, UINT16); 5261 5262 cmdline_parse_inst_t cmd_add_bonding_slave = { 5263 .f = cmd_add_bonding_slave_parsed, 5264 .help_str = "add bonding slave <slave_id> <port_id>: " 5265 "Add a slave device to a bonded device", 5266 .data = NULL, 5267 .tokens = { 5268 (void *)&cmd_addbonding_slave_add, 5269 (void *)&cmd_addbonding_slave_bonding, 5270 (void *)&cmd_addbonding_slave_slave, 5271 (void *)&cmd_addbonding_slave_slaveid, 5272 (void *)&cmd_addbonding_slave_port, 5273 NULL 5274 } 5275 }; 5276 5277 /* *** REMOVE SLAVE *** */ 5278 struct cmd_remove_bonding_slave_result { 5279 cmdline_fixed_string_t remove; 5280 cmdline_fixed_string_t bonding; 5281 cmdline_fixed_string_t slave; 5282 portid_t slave_id; 5283 portid_t port_id; 5284 }; 5285 5286 static void cmd_remove_bonding_slave_parsed(void *parsed_result, 5287 __attribute__((unused)) struct cmdline *cl, 5288 __attribute__((unused)) void *data) 5289 { 5290 struct cmd_remove_bonding_slave_result *res = parsed_result; 5291 portid_t master_port_id = res->port_id; 5292 portid_t slave_port_id = res->slave_id; 5293 5294 /* remove the slave from a bonded device. */ 5295 if (0 != rte_eth_bond_slave_remove(master_port_id, slave_port_id)) { 5296 printf("\t Failed to remove slave %d from master port = %d.\n", 5297 slave_port_id, master_port_id); 5298 return; 5299 } 5300 init_port_config(); 5301 clear_port_slave_flag(slave_port_id); 5302 } 5303 5304 cmdline_parse_token_string_t cmd_removebonding_slave_remove = 5305 TOKEN_STRING_INITIALIZER(struct cmd_remove_bonding_slave_result, 5306 remove, "remove"); 5307 cmdline_parse_token_string_t cmd_removebonding_slave_bonding = 5308 TOKEN_STRING_INITIALIZER(struct cmd_remove_bonding_slave_result, 5309 bonding, "bonding"); 5310 cmdline_parse_token_string_t cmd_removebonding_slave_slave = 5311 TOKEN_STRING_INITIALIZER(struct cmd_remove_bonding_slave_result, 5312 slave, "slave"); 5313 cmdline_parse_token_num_t cmd_removebonding_slave_slaveid = 5314 TOKEN_NUM_INITIALIZER(struct cmd_remove_bonding_slave_result, 5315 slave_id, UINT16); 5316 cmdline_parse_token_num_t cmd_removebonding_slave_port = 5317 TOKEN_NUM_INITIALIZER(struct cmd_remove_bonding_slave_result, 5318 port_id, UINT16); 5319 5320 cmdline_parse_inst_t cmd_remove_bonding_slave = { 5321 .f = cmd_remove_bonding_slave_parsed, 5322 .help_str = "remove bonding slave <slave_id> <port_id>: " 5323 "Remove a slave device from a bonded device", 5324 .data = NULL, 5325 .tokens = { 5326 (void *)&cmd_removebonding_slave_remove, 5327 (void *)&cmd_removebonding_slave_bonding, 5328 (void *)&cmd_removebonding_slave_slave, 5329 (void *)&cmd_removebonding_slave_slaveid, 5330 (void *)&cmd_removebonding_slave_port, 5331 NULL 5332 } 5333 }; 5334 5335 /* *** CREATE BONDED DEVICE *** */ 5336 struct cmd_create_bonded_device_result { 5337 cmdline_fixed_string_t create; 5338 cmdline_fixed_string_t bonded; 5339 cmdline_fixed_string_t device; 5340 uint8_t mode; 5341 uint8_t socket; 5342 }; 5343 5344 static int bond_dev_num = 0; 5345 5346 static void cmd_create_bonded_device_parsed(void *parsed_result, 5347 __attribute__((unused)) struct cmdline *cl, 5348 __attribute__((unused)) void *data) 5349 { 5350 struct cmd_create_bonded_device_result *res = parsed_result; 5351 char ethdev_name[RTE_ETH_NAME_MAX_LEN]; 5352 int port_id; 5353 5354 if (test_done == 0) { 5355 printf("Please stop forwarding first\n"); 5356 return; 5357 } 5358 5359 snprintf(ethdev_name, RTE_ETH_NAME_MAX_LEN, "net_bonding_testpmd_%d", 5360 bond_dev_num++); 5361 5362 /* Create a new bonded device. */ 5363 port_id = rte_eth_bond_create(ethdev_name, res->mode, res->socket); 5364 if (port_id < 0) { 5365 printf("\t Failed to create bonded device.\n"); 5366 return; 5367 } else { 5368 printf("Created new bonded device %s on (port %d).\n", ethdev_name, 5369 port_id); 5370 5371 /* Update number of ports */ 5372 nb_ports = rte_eth_dev_count(); 5373 reconfig(port_id, res->socket); 5374 rte_eth_promiscuous_enable(port_id); 5375 } 5376 5377 } 5378 5379 cmdline_parse_token_string_t cmd_createbonded_device_create = 5380 TOKEN_STRING_INITIALIZER(struct cmd_create_bonded_device_result, 5381 create, "create"); 5382 cmdline_parse_token_string_t cmd_createbonded_device_bonded = 5383 TOKEN_STRING_INITIALIZER(struct cmd_create_bonded_device_result, 5384 bonded, "bonded"); 5385 cmdline_parse_token_string_t cmd_createbonded_device_device = 5386 TOKEN_STRING_INITIALIZER(struct cmd_create_bonded_device_result, 5387 device, "device"); 5388 cmdline_parse_token_num_t cmd_createbonded_device_mode = 5389 TOKEN_NUM_INITIALIZER(struct cmd_create_bonded_device_result, 5390 mode, UINT8); 5391 cmdline_parse_token_num_t cmd_createbonded_device_socket = 5392 TOKEN_NUM_INITIALIZER(struct cmd_create_bonded_device_result, 5393 socket, UINT8); 5394 5395 cmdline_parse_inst_t cmd_create_bonded_device = { 5396 .f = cmd_create_bonded_device_parsed, 5397 .help_str = "create bonded device <mode> <socket>: " 5398 "Create a new bonded device with specific bonding mode and socket", 5399 .data = NULL, 5400 .tokens = { 5401 (void *)&cmd_createbonded_device_create, 5402 (void *)&cmd_createbonded_device_bonded, 5403 (void *)&cmd_createbonded_device_device, 5404 (void *)&cmd_createbonded_device_mode, 5405 (void *)&cmd_createbonded_device_socket, 5406 NULL 5407 } 5408 }; 5409 5410 /* *** SET MAC ADDRESS IN BONDED DEVICE *** */ 5411 struct cmd_set_bond_mac_addr_result { 5412 cmdline_fixed_string_t set; 5413 cmdline_fixed_string_t bonding; 5414 cmdline_fixed_string_t mac_addr; 5415 uint16_t port_num; 5416 struct ether_addr address; 5417 }; 5418 5419 static void cmd_set_bond_mac_addr_parsed(void *parsed_result, 5420 __attribute__((unused)) struct cmdline *cl, 5421 __attribute__((unused)) void *data) 5422 { 5423 struct cmd_set_bond_mac_addr_result *res = parsed_result; 5424 int ret; 5425 5426 if (port_id_is_invalid(res->port_num, ENABLED_WARN)) 5427 return; 5428 5429 ret = rte_eth_bond_mac_address_set(res->port_num, &res->address); 5430 5431 /* check the return value and print it if is < 0 */ 5432 if (ret < 0) 5433 printf("set_bond_mac_addr error: (%s)\n", strerror(-ret)); 5434 } 5435 5436 cmdline_parse_token_string_t cmd_set_bond_mac_addr_set = 5437 TOKEN_STRING_INITIALIZER(struct cmd_set_bond_mac_addr_result, set, "set"); 5438 cmdline_parse_token_string_t cmd_set_bond_mac_addr_bonding = 5439 TOKEN_STRING_INITIALIZER(struct cmd_set_bond_mac_addr_result, bonding, 5440 "bonding"); 5441 cmdline_parse_token_string_t cmd_set_bond_mac_addr_mac = 5442 TOKEN_STRING_INITIALIZER(struct cmd_set_bond_mac_addr_result, mac_addr, 5443 "mac_addr"); 5444 cmdline_parse_token_num_t cmd_set_bond_mac_addr_portnum = 5445 TOKEN_NUM_INITIALIZER(struct cmd_set_bond_mac_addr_result, 5446 port_num, UINT16); 5447 cmdline_parse_token_etheraddr_t cmd_set_bond_mac_addr_addr = 5448 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_bond_mac_addr_result, address); 5449 5450 cmdline_parse_inst_t cmd_set_bond_mac_addr = { 5451 .f = cmd_set_bond_mac_addr_parsed, 5452 .data = (void *) 0, 5453 .help_str = "set bonding mac_addr <port_id> <mac_addr>", 5454 .tokens = { 5455 (void *)&cmd_set_bond_mac_addr_set, 5456 (void *)&cmd_set_bond_mac_addr_bonding, 5457 (void *)&cmd_set_bond_mac_addr_mac, 5458 (void *)&cmd_set_bond_mac_addr_portnum, 5459 (void *)&cmd_set_bond_mac_addr_addr, 5460 NULL 5461 } 5462 }; 5463 5464 5465 /* *** SET LINK STATUS MONITORING POLLING PERIOD ON BONDED DEVICE *** */ 5466 struct cmd_set_bond_mon_period_result { 5467 cmdline_fixed_string_t set; 5468 cmdline_fixed_string_t bonding; 5469 cmdline_fixed_string_t mon_period; 5470 uint16_t port_num; 5471 uint32_t period_ms; 5472 }; 5473 5474 static void cmd_set_bond_mon_period_parsed(void *parsed_result, 5475 __attribute__((unused)) struct cmdline *cl, 5476 __attribute__((unused)) void *data) 5477 { 5478 struct cmd_set_bond_mon_period_result *res = parsed_result; 5479 int ret; 5480 5481 if (res->port_num >= nb_ports) { 5482 printf("Port id %d must be less than %d\n", res->port_num, nb_ports); 5483 return; 5484 } 5485 5486 ret = rte_eth_bond_link_monitoring_set(res->port_num, res->period_ms); 5487 5488 /* check the return value and print it if is < 0 */ 5489 if (ret < 0) 5490 printf("set_bond_mac_addr error: (%s)\n", strerror(-ret)); 5491 } 5492 5493 cmdline_parse_token_string_t cmd_set_bond_mon_period_set = 5494 TOKEN_STRING_INITIALIZER(struct cmd_set_bond_mon_period_result, 5495 set, "set"); 5496 cmdline_parse_token_string_t cmd_set_bond_mon_period_bonding = 5497 TOKEN_STRING_INITIALIZER(struct cmd_set_bond_mon_period_result, 5498 bonding, "bonding"); 5499 cmdline_parse_token_string_t cmd_set_bond_mon_period_mon_period = 5500 TOKEN_STRING_INITIALIZER(struct cmd_set_bond_mon_period_result, 5501 mon_period, "mon_period"); 5502 cmdline_parse_token_num_t cmd_set_bond_mon_period_portnum = 5503 TOKEN_NUM_INITIALIZER(struct cmd_set_bond_mon_period_result, 5504 port_num, UINT16); 5505 cmdline_parse_token_num_t cmd_set_bond_mon_period_period_ms = 5506 TOKEN_NUM_INITIALIZER(struct cmd_set_bond_mon_period_result, 5507 period_ms, UINT32); 5508 5509 cmdline_parse_inst_t cmd_set_bond_mon_period = { 5510 .f = cmd_set_bond_mon_period_parsed, 5511 .data = (void *) 0, 5512 .help_str = "set bonding mon_period <port_id> <period_ms>", 5513 .tokens = { 5514 (void *)&cmd_set_bond_mon_period_set, 5515 (void *)&cmd_set_bond_mon_period_bonding, 5516 (void *)&cmd_set_bond_mon_period_mon_period, 5517 (void *)&cmd_set_bond_mon_period_portnum, 5518 (void *)&cmd_set_bond_mon_period_period_ms, 5519 NULL 5520 } 5521 }; 5522 5523 5524 5525 struct cmd_set_bonding_agg_mode_policy_result { 5526 cmdline_fixed_string_t set; 5527 cmdline_fixed_string_t bonding; 5528 cmdline_fixed_string_t agg_mode; 5529 uint16_t port_num; 5530 cmdline_fixed_string_t policy; 5531 }; 5532 5533 5534 static void 5535 cmd_set_bonding_agg_mode(void *parsed_result, 5536 __attribute__((unused)) struct cmdline *cl, 5537 __attribute__((unused)) void *data) 5538 { 5539 struct cmd_set_bonding_agg_mode_policy_result *res = parsed_result; 5540 uint8_t policy = AGG_BANDWIDTH; 5541 5542 if (res->port_num >= nb_ports) { 5543 printf("Port id %d must be less than %d\n", 5544 res->port_num, nb_ports); 5545 return; 5546 } 5547 5548 if (!strcmp(res->policy, "bandwidth")) 5549 policy = AGG_BANDWIDTH; 5550 else if (!strcmp(res->policy, "stable")) 5551 policy = AGG_STABLE; 5552 else if (!strcmp(res->policy, "count")) 5553 policy = AGG_COUNT; 5554 5555 rte_eth_bond_8023ad_agg_selection_set(res->port_num, policy); 5556 } 5557 5558 5559 cmdline_parse_token_string_t cmd_set_bonding_agg_mode_set = 5560 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_agg_mode_policy_result, 5561 set, "set"); 5562 cmdline_parse_token_string_t cmd_set_bonding_agg_mode_bonding = 5563 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_agg_mode_policy_result, 5564 bonding, "bonding"); 5565 5566 cmdline_parse_token_string_t cmd_set_bonding_agg_mode_agg_mode = 5567 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_agg_mode_policy_result, 5568 agg_mode, "agg_mode"); 5569 5570 cmdline_parse_token_num_t cmd_set_bonding_agg_mode_portnum = 5571 TOKEN_NUM_INITIALIZER(struct cmd_set_bonding_agg_mode_policy_result, 5572 port_num, UINT16); 5573 5574 cmdline_parse_token_string_t cmd_set_bonding_agg_mode_policy_string = 5575 TOKEN_STRING_INITIALIZER( 5576 struct cmd_set_bonding_balance_xmit_policy_result, 5577 policy, "stable#bandwidth#count"); 5578 5579 cmdline_parse_inst_t cmd_set_bonding_agg_mode_policy = { 5580 .f = cmd_set_bonding_agg_mode, 5581 .data = (void *) 0, 5582 .help_str = "set bonding mode IEEE802.3AD aggregator policy <port_id> <agg_name>", 5583 .tokens = { 5584 (void *)&cmd_set_bonding_agg_mode_set, 5585 (void *)&cmd_set_bonding_agg_mode_bonding, 5586 (void *)&cmd_set_bonding_agg_mode_agg_mode, 5587 (void *)&cmd_set_bonding_agg_mode_portnum, 5588 (void *)&cmd_set_bonding_agg_mode_policy_string, 5589 NULL 5590 } 5591 }; 5592 5593 5594 #endif /* RTE_LIBRTE_PMD_BOND */ 5595 5596 /* *** SET FORWARDING MODE *** */ 5597 struct cmd_set_fwd_mode_result { 5598 cmdline_fixed_string_t set; 5599 cmdline_fixed_string_t fwd; 5600 cmdline_fixed_string_t mode; 5601 }; 5602 5603 static void cmd_set_fwd_mode_parsed(void *parsed_result, 5604 __attribute__((unused)) struct cmdline *cl, 5605 __attribute__((unused)) void *data) 5606 { 5607 struct cmd_set_fwd_mode_result *res = parsed_result; 5608 5609 retry_enabled = 0; 5610 set_pkt_forwarding_mode(res->mode); 5611 } 5612 5613 cmdline_parse_token_string_t cmd_setfwd_set = 5614 TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_mode_result, set, "set"); 5615 cmdline_parse_token_string_t cmd_setfwd_fwd = 5616 TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_mode_result, fwd, "fwd"); 5617 cmdline_parse_token_string_t cmd_setfwd_mode = 5618 TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_mode_result, mode, 5619 "" /* defined at init */); 5620 5621 cmdline_parse_inst_t cmd_set_fwd_mode = { 5622 .f = cmd_set_fwd_mode_parsed, 5623 .data = NULL, 5624 .help_str = NULL, /* defined at init */ 5625 .tokens = { 5626 (void *)&cmd_setfwd_set, 5627 (void *)&cmd_setfwd_fwd, 5628 (void *)&cmd_setfwd_mode, 5629 NULL, 5630 }, 5631 }; 5632 5633 static void cmd_set_fwd_mode_init(void) 5634 { 5635 char *modes, *c; 5636 static char token[128]; 5637 static char help[256]; 5638 cmdline_parse_token_string_t *token_struct; 5639 5640 modes = list_pkt_forwarding_modes(); 5641 snprintf(help, sizeof(help), "set fwd %s: " 5642 "Set packet forwarding mode", modes); 5643 cmd_set_fwd_mode.help_str = help; 5644 5645 /* string token separator is # */ 5646 for (c = token; *modes != '\0'; modes++) 5647 if (*modes == '|') 5648 *c++ = '#'; 5649 else 5650 *c++ = *modes; 5651 token_struct = (cmdline_parse_token_string_t*)cmd_set_fwd_mode.tokens[2]; 5652 token_struct->string_data.str = token; 5653 } 5654 5655 /* *** SET RETRY FORWARDING MODE *** */ 5656 struct cmd_set_fwd_retry_mode_result { 5657 cmdline_fixed_string_t set; 5658 cmdline_fixed_string_t fwd; 5659 cmdline_fixed_string_t mode; 5660 cmdline_fixed_string_t retry; 5661 }; 5662 5663 static void cmd_set_fwd_retry_mode_parsed(void *parsed_result, 5664 __attribute__((unused)) struct cmdline *cl, 5665 __attribute__((unused)) void *data) 5666 { 5667 struct cmd_set_fwd_retry_mode_result *res = parsed_result; 5668 5669 retry_enabled = 1; 5670 set_pkt_forwarding_mode(res->mode); 5671 } 5672 5673 cmdline_parse_token_string_t cmd_setfwd_retry_set = 5674 TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_retry_mode_result, 5675 set, "set"); 5676 cmdline_parse_token_string_t cmd_setfwd_retry_fwd = 5677 TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_retry_mode_result, 5678 fwd, "fwd"); 5679 cmdline_parse_token_string_t cmd_setfwd_retry_mode = 5680 TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_retry_mode_result, 5681 mode, 5682 "" /* defined at init */); 5683 cmdline_parse_token_string_t cmd_setfwd_retry_retry = 5684 TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_retry_mode_result, 5685 retry, "retry"); 5686 5687 cmdline_parse_inst_t cmd_set_fwd_retry_mode = { 5688 .f = cmd_set_fwd_retry_mode_parsed, 5689 .data = NULL, 5690 .help_str = NULL, /* defined at init */ 5691 .tokens = { 5692 (void *)&cmd_setfwd_retry_set, 5693 (void *)&cmd_setfwd_retry_fwd, 5694 (void *)&cmd_setfwd_retry_mode, 5695 (void *)&cmd_setfwd_retry_retry, 5696 NULL, 5697 }, 5698 }; 5699 5700 static void cmd_set_fwd_retry_mode_init(void) 5701 { 5702 char *modes, *c; 5703 static char token[128]; 5704 static char help[256]; 5705 cmdline_parse_token_string_t *token_struct; 5706 5707 modes = list_pkt_forwarding_retry_modes(); 5708 snprintf(help, sizeof(help), "set fwd %s retry: " 5709 "Set packet forwarding mode with retry", modes); 5710 cmd_set_fwd_retry_mode.help_str = help; 5711 5712 /* string token separator is # */ 5713 for (c = token; *modes != '\0'; modes++) 5714 if (*modes == '|') 5715 *c++ = '#'; 5716 else 5717 *c++ = *modes; 5718 token_struct = (cmdline_parse_token_string_t *) 5719 cmd_set_fwd_retry_mode.tokens[2]; 5720 token_struct->string_data.str = token; 5721 } 5722 5723 /* *** SET BURST TX DELAY TIME RETRY NUMBER *** */ 5724 struct cmd_set_burst_tx_retry_result { 5725 cmdline_fixed_string_t set; 5726 cmdline_fixed_string_t burst; 5727 cmdline_fixed_string_t tx; 5728 cmdline_fixed_string_t delay; 5729 uint32_t time; 5730 cmdline_fixed_string_t retry; 5731 uint32_t retry_num; 5732 }; 5733 5734 static void cmd_set_burst_tx_retry_parsed(void *parsed_result, 5735 __attribute__((unused)) struct cmdline *cl, 5736 __attribute__((unused)) void *data) 5737 { 5738 struct cmd_set_burst_tx_retry_result *res = parsed_result; 5739 5740 if (!strcmp(res->set, "set") && !strcmp(res->burst, "burst") 5741 && !strcmp(res->tx, "tx")) { 5742 if (!strcmp(res->delay, "delay")) 5743 burst_tx_delay_time = res->time; 5744 if (!strcmp(res->retry, "retry")) 5745 burst_tx_retry_num = res->retry_num; 5746 } 5747 5748 } 5749 5750 cmdline_parse_token_string_t cmd_set_burst_tx_retry_set = 5751 TOKEN_STRING_INITIALIZER(struct cmd_set_burst_tx_retry_result, set, "set"); 5752 cmdline_parse_token_string_t cmd_set_burst_tx_retry_burst = 5753 TOKEN_STRING_INITIALIZER(struct cmd_set_burst_tx_retry_result, burst, 5754 "burst"); 5755 cmdline_parse_token_string_t cmd_set_burst_tx_retry_tx = 5756 TOKEN_STRING_INITIALIZER(struct cmd_set_burst_tx_retry_result, tx, "tx"); 5757 cmdline_parse_token_string_t cmd_set_burst_tx_retry_delay = 5758 TOKEN_STRING_INITIALIZER(struct cmd_set_burst_tx_retry_result, delay, "delay"); 5759 cmdline_parse_token_num_t cmd_set_burst_tx_retry_time = 5760 TOKEN_NUM_INITIALIZER(struct cmd_set_burst_tx_retry_result, time, UINT32); 5761 cmdline_parse_token_string_t cmd_set_burst_tx_retry_retry = 5762 TOKEN_STRING_INITIALIZER(struct cmd_set_burst_tx_retry_result, retry, "retry"); 5763 cmdline_parse_token_num_t cmd_set_burst_tx_retry_retry_num = 5764 TOKEN_NUM_INITIALIZER(struct cmd_set_burst_tx_retry_result, retry_num, UINT32); 5765 5766 cmdline_parse_inst_t cmd_set_burst_tx_retry = { 5767 .f = cmd_set_burst_tx_retry_parsed, 5768 .help_str = "set burst tx delay <delay_usec> retry <num_retry>", 5769 .tokens = { 5770 (void *)&cmd_set_burst_tx_retry_set, 5771 (void *)&cmd_set_burst_tx_retry_burst, 5772 (void *)&cmd_set_burst_tx_retry_tx, 5773 (void *)&cmd_set_burst_tx_retry_delay, 5774 (void *)&cmd_set_burst_tx_retry_time, 5775 (void *)&cmd_set_burst_tx_retry_retry, 5776 (void *)&cmd_set_burst_tx_retry_retry_num, 5777 NULL, 5778 }, 5779 }; 5780 5781 /* *** SET PROMISC MODE *** */ 5782 struct cmd_set_promisc_mode_result { 5783 cmdline_fixed_string_t set; 5784 cmdline_fixed_string_t promisc; 5785 cmdline_fixed_string_t port_all; /* valid if "allports" argument == 1 */ 5786 uint16_t port_num; /* valid if "allports" argument == 0 */ 5787 cmdline_fixed_string_t mode; 5788 }; 5789 5790 static void cmd_set_promisc_mode_parsed(void *parsed_result, 5791 __attribute__((unused)) struct cmdline *cl, 5792 void *allports) 5793 { 5794 struct cmd_set_promisc_mode_result *res = parsed_result; 5795 int enable; 5796 portid_t i; 5797 5798 if (!strcmp(res->mode, "on")) 5799 enable = 1; 5800 else 5801 enable = 0; 5802 5803 /* all ports */ 5804 if (allports) { 5805 RTE_ETH_FOREACH_DEV(i) { 5806 if (enable) 5807 rte_eth_promiscuous_enable(i); 5808 else 5809 rte_eth_promiscuous_disable(i); 5810 } 5811 } 5812 else { 5813 if (enable) 5814 rte_eth_promiscuous_enable(res->port_num); 5815 else 5816 rte_eth_promiscuous_disable(res->port_num); 5817 } 5818 } 5819 5820 cmdline_parse_token_string_t cmd_setpromisc_set = 5821 TOKEN_STRING_INITIALIZER(struct cmd_set_promisc_mode_result, set, "set"); 5822 cmdline_parse_token_string_t cmd_setpromisc_promisc = 5823 TOKEN_STRING_INITIALIZER(struct cmd_set_promisc_mode_result, promisc, 5824 "promisc"); 5825 cmdline_parse_token_string_t cmd_setpromisc_portall = 5826 TOKEN_STRING_INITIALIZER(struct cmd_set_promisc_mode_result, port_all, 5827 "all"); 5828 cmdline_parse_token_num_t cmd_setpromisc_portnum = 5829 TOKEN_NUM_INITIALIZER(struct cmd_set_promisc_mode_result, port_num, 5830 UINT8); 5831 cmdline_parse_token_string_t cmd_setpromisc_mode = 5832 TOKEN_STRING_INITIALIZER(struct cmd_set_promisc_mode_result, mode, 5833 "on#off"); 5834 5835 cmdline_parse_inst_t cmd_set_promisc_mode_all = { 5836 .f = cmd_set_promisc_mode_parsed, 5837 .data = (void *)1, 5838 .help_str = "set promisc all on|off: Set promisc mode for all ports", 5839 .tokens = { 5840 (void *)&cmd_setpromisc_set, 5841 (void *)&cmd_setpromisc_promisc, 5842 (void *)&cmd_setpromisc_portall, 5843 (void *)&cmd_setpromisc_mode, 5844 NULL, 5845 }, 5846 }; 5847 5848 cmdline_parse_inst_t cmd_set_promisc_mode_one = { 5849 .f = cmd_set_promisc_mode_parsed, 5850 .data = (void *)0, 5851 .help_str = "set promisc <port_id> on|off: Set promisc mode on port_id", 5852 .tokens = { 5853 (void *)&cmd_setpromisc_set, 5854 (void *)&cmd_setpromisc_promisc, 5855 (void *)&cmd_setpromisc_portnum, 5856 (void *)&cmd_setpromisc_mode, 5857 NULL, 5858 }, 5859 }; 5860 5861 /* *** SET ALLMULTI MODE *** */ 5862 struct cmd_set_allmulti_mode_result { 5863 cmdline_fixed_string_t set; 5864 cmdline_fixed_string_t allmulti; 5865 cmdline_fixed_string_t port_all; /* valid if "allports" argument == 1 */ 5866 uint16_t port_num; /* valid if "allports" argument == 0 */ 5867 cmdline_fixed_string_t mode; 5868 }; 5869 5870 static void cmd_set_allmulti_mode_parsed(void *parsed_result, 5871 __attribute__((unused)) struct cmdline *cl, 5872 void *allports) 5873 { 5874 struct cmd_set_allmulti_mode_result *res = parsed_result; 5875 int enable; 5876 portid_t i; 5877 5878 if (!strcmp(res->mode, "on")) 5879 enable = 1; 5880 else 5881 enable = 0; 5882 5883 /* all ports */ 5884 if (allports) { 5885 RTE_ETH_FOREACH_DEV(i) { 5886 if (enable) 5887 rte_eth_allmulticast_enable(i); 5888 else 5889 rte_eth_allmulticast_disable(i); 5890 } 5891 } 5892 else { 5893 if (enable) 5894 rte_eth_allmulticast_enable(res->port_num); 5895 else 5896 rte_eth_allmulticast_disable(res->port_num); 5897 } 5898 } 5899 5900 cmdline_parse_token_string_t cmd_setallmulti_set = 5901 TOKEN_STRING_INITIALIZER(struct cmd_set_allmulti_mode_result, set, "set"); 5902 cmdline_parse_token_string_t cmd_setallmulti_allmulti = 5903 TOKEN_STRING_INITIALIZER(struct cmd_set_allmulti_mode_result, allmulti, 5904 "allmulti"); 5905 cmdline_parse_token_string_t cmd_setallmulti_portall = 5906 TOKEN_STRING_INITIALIZER(struct cmd_set_allmulti_mode_result, port_all, 5907 "all"); 5908 cmdline_parse_token_num_t cmd_setallmulti_portnum = 5909 TOKEN_NUM_INITIALIZER(struct cmd_set_allmulti_mode_result, port_num, 5910 UINT16); 5911 cmdline_parse_token_string_t cmd_setallmulti_mode = 5912 TOKEN_STRING_INITIALIZER(struct cmd_set_allmulti_mode_result, mode, 5913 "on#off"); 5914 5915 cmdline_parse_inst_t cmd_set_allmulti_mode_all = { 5916 .f = cmd_set_allmulti_mode_parsed, 5917 .data = (void *)1, 5918 .help_str = "set allmulti all on|off: Set allmulti mode for all ports", 5919 .tokens = { 5920 (void *)&cmd_setallmulti_set, 5921 (void *)&cmd_setallmulti_allmulti, 5922 (void *)&cmd_setallmulti_portall, 5923 (void *)&cmd_setallmulti_mode, 5924 NULL, 5925 }, 5926 }; 5927 5928 cmdline_parse_inst_t cmd_set_allmulti_mode_one = { 5929 .f = cmd_set_allmulti_mode_parsed, 5930 .data = (void *)0, 5931 .help_str = "set allmulti <port_id> on|off: " 5932 "Set allmulti mode on port_id", 5933 .tokens = { 5934 (void *)&cmd_setallmulti_set, 5935 (void *)&cmd_setallmulti_allmulti, 5936 (void *)&cmd_setallmulti_portnum, 5937 (void *)&cmd_setallmulti_mode, 5938 NULL, 5939 }, 5940 }; 5941 5942 /* *** SETUP ETHERNET LINK FLOW CONTROL *** */ 5943 struct cmd_link_flow_ctrl_set_result { 5944 cmdline_fixed_string_t set; 5945 cmdline_fixed_string_t flow_ctrl; 5946 cmdline_fixed_string_t rx; 5947 cmdline_fixed_string_t rx_lfc_mode; 5948 cmdline_fixed_string_t tx; 5949 cmdline_fixed_string_t tx_lfc_mode; 5950 cmdline_fixed_string_t mac_ctrl_frame_fwd; 5951 cmdline_fixed_string_t mac_ctrl_frame_fwd_mode; 5952 cmdline_fixed_string_t autoneg_str; 5953 cmdline_fixed_string_t autoneg; 5954 cmdline_fixed_string_t hw_str; 5955 uint32_t high_water; 5956 cmdline_fixed_string_t lw_str; 5957 uint32_t low_water; 5958 cmdline_fixed_string_t pt_str; 5959 uint16_t pause_time; 5960 cmdline_fixed_string_t xon_str; 5961 uint16_t send_xon; 5962 portid_t port_id; 5963 }; 5964 5965 cmdline_parse_token_string_t cmd_lfc_set_set = 5966 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result, 5967 set, "set"); 5968 cmdline_parse_token_string_t cmd_lfc_set_flow_ctrl = 5969 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result, 5970 flow_ctrl, "flow_ctrl"); 5971 cmdline_parse_token_string_t cmd_lfc_set_rx = 5972 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result, 5973 rx, "rx"); 5974 cmdline_parse_token_string_t cmd_lfc_set_rx_mode = 5975 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result, 5976 rx_lfc_mode, "on#off"); 5977 cmdline_parse_token_string_t cmd_lfc_set_tx = 5978 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result, 5979 tx, "tx"); 5980 cmdline_parse_token_string_t cmd_lfc_set_tx_mode = 5981 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result, 5982 tx_lfc_mode, "on#off"); 5983 cmdline_parse_token_string_t cmd_lfc_set_high_water_str = 5984 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result, 5985 hw_str, "high_water"); 5986 cmdline_parse_token_num_t cmd_lfc_set_high_water = 5987 TOKEN_NUM_INITIALIZER(struct cmd_link_flow_ctrl_set_result, 5988 high_water, UINT32); 5989 cmdline_parse_token_string_t cmd_lfc_set_low_water_str = 5990 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result, 5991 lw_str, "low_water"); 5992 cmdline_parse_token_num_t cmd_lfc_set_low_water = 5993 TOKEN_NUM_INITIALIZER(struct cmd_link_flow_ctrl_set_result, 5994 low_water, UINT32); 5995 cmdline_parse_token_string_t cmd_lfc_set_pause_time_str = 5996 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result, 5997 pt_str, "pause_time"); 5998 cmdline_parse_token_num_t cmd_lfc_set_pause_time = 5999 TOKEN_NUM_INITIALIZER(struct cmd_link_flow_ctrl_set_result, 6000 pause_time, UINT16); 6001 cmdline_parse_token_string_t cmd_lfc_set_send_xon_str = 6002 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result, 6003 xon_str, "send_xon"); 6004 cmdline_parse_token_num_t cmd_lfc_set_send_xon = 6005 TOKEN_NUM_INITIALIZER(struct cmd_link_flow_ctrl_set_result, 6006 send_xon, UINT16); 6007 cmdline_parse_token_string_t cmd_lfc_set_mac_ctrl_frame_fwd_mode = 6008 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result, 6009 mac_ctrl_frame_fwd, "mac_ctrl_frame_fwd"); 6010 cmdline_parse_token_string_t cmd_lfc_set_mac_ctrl_frame_fwd = 6011 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result, 6012 mac_ctrl_frame_fwd_mode, "on#off"); 6013 cmdline_parse_token_string_t cmd_lfc_set_autoneg_str = 6014 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result, 6015 autoneg_str, "autoneg"); 6016 cmdline_parse_token_string_t cmd_lfc_set_autoneg = 6017 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result, 6018 autoneg, "on#off"); 6019 cmdline_parse_token_num_t cmd_lfc_set_portid = 6020 TOKEN_NUM_INITIALIZER(struct cmd_link_flow_ctrl_set_result, 6021 port_id, UINT16); 6022 6023 /* forward declaration */ 6024 static void 6025 cmd_link_flow_ctrl_set_parsed(void *parsed_result, struct cmdline *cl, 6026 void *data); 6027 6028 cmdline_parse_inst_t cmd_link_flow_control_set = { 6029 .f = cmd_link_flow_ctrl_set_parsed, 6030 .data = NULL, 6031 .help_str = "set flow_ctrl rx on|off tx on|off <high_water> " 6032 "<low_water> <pause_time> <send_xon> mac_ctrl_frame_fwd on|off " 6033 "autoneg on|off <port_id>: Configure the Ethernet flow control", 6034 .tokens = { 6035 (void *)&cmd_lfc_set_set, 6036 (void *)&cmd_lfc_set_flow_ctrl, 6037 (void *)&cmd_lfc_set_rx, 6038 (void *)&cmd_lfc_set_rx_mode, 6039 (void *)&cmd_lfc_set_tx, 6040 (void *)&cmd_lfc_set_tx_mode, 6041 (void *)&cmd_lfc_set_high_water, 6042 (void *)&cmd_lfc_set_low_water, 6043 (void *)&cmd_lfc_set_pause_time, 6044 (void *)&cmd_lfc_set_send_xon, 6045 (void *)&cmd_lfc_set_mac_ctrl_frame_fwd_mode, 6046 (void *)&cmd_lfc_set_mac_ctrl_frame_fwd, 6047 (void *)&cmd_lfc_set_autoneg_str, 6048 (void *)&cmd_lfc_set_autoneg, 6049 (void *)&cmd_lfc_set_portid, 6050 NULL, 6051 }, 6052 }; 6053 6054 cmdline_parse_inst_t cmd_link_flow_control_set_rx = { 6055 .f = cmd_link_flow_ctrl_set_parsed, 6056 .data = (void *)&cmd_link_flow_control_set_rx, 6057 .help_str = "set flow_ctrl rx on|off <port_id>: " 6058 "Change rx flow control parameter", 6059 .tokens = { 6060 (void *)&cmd_lfc_set_set, 6061 (void *)&cmd_lfc_set_flow_ctrl, 6062 (void *)&cmd_lfc_set_rx, 6063 (void *)&cmd_lfc_set_rx_mode, 6064 (void *)&cmd_lfc_set_portid, 6065 NULL, 6066 }, 6067 }; 6068 6069 cmdline_parse_inst_t cmd_link_flow_control_set_tx = { 6070 .f = cmd_link_flow_ctrl_set_parsed, 6071 .data = (void *)&cmd_link_flow_control_set_tx, 6072 .help_str = "set flow_ctrl tx on|off <port_id>: " 6073 "Change tx flow control parameter", 6074 .tokens = { 6075 (void *)&cmd_lfc_set_set, 6076 (void *)&cmd_lfc_set_flow_ctrl, 6077 (void *)&cmd_lfc_set_tx, 6078 (void *)&cmd_lfc_set_tx_mode, 6079 (void *)&cmd_lfc_set_portid, 6080 NULL, 6081 }, 6082 }; 6083 6084 cmdline_parse_inst_t cmd_link_flow_control_set_hw = { 6085 .f = cmd_link_flow_ctrl_set_parsed, 6086 .data = (void *)&cmd_link_flow_control_set_hw, 6087 .help_str = "set flow_ctrl high_water <value> <port_id>: " 6088 "Change high water flow control parameter", 6089 .tokens = { 6090 (void *)&cmd_lfc_set_set, 6091 (void *)&cmd_lfc_set_flow_ctrl, 6092 (void *)&cmd_lfc_set_high_water_str, 6093 (void *)&cmd_lfc_set_high_water, 6094 (void *)&cmd_lfc_set_portid, 6095 NULL, 6096 }, 6097 }; 6098 6099 cmdline_parse_inst_t cmd_link_flow_control_set_lw = { 6100 .f = cmd_link_flow_ctrl_set_parsed, 6101 .data = (void *)&cmd_link_flow_control_set_lw, 6102 .help_str = "set flow_ctrl low_water <value> <port_id>: " 6103 "Change low water flow control parameter", 6104 .tokens = { 6105 (void *)&cmd_lfc_set_set, 6106 (void *)&cmd_lfc_set_flow_ctrl, 6107 (void *)&cmd_lfc_set_low_water_str, 6108 (void *)&cmd_lfc_set_low_water, 6109 (void *)&cmd_lfc_set_portid, 6110 NULL, 6111 }, 6112 }; 6113 6114 cmdline_parse_inst_t cmd_link_flow_control_set_pt = { 6115 .f = cmd_link_flow_ctrl_set_parsed, 6116 .data = (void *)&cmd_link_flow_control_set_pt, 6117 .help_str = "set flow_ctrl pause_time <value> <port_id>: " 6118 "Change pause time flow control parameter", 6119 .tokens = { 6120 (void *)&cmd_lfc_set_set, 6121 (void *)&cmd_lfc_set_flow_ctrl, 6122 (void *)&cmd_lfc_set_pause_time_str, 6123 (void *)&cmd_lfc_set_pause_time, 6124 (void *)&cmd_lfc_set_portid, 6125 NULL, 6126 }, 6127 }; 6128 6129 cmdline_parse_inst_t cmd_link_flow_control_set_xon = { 6130 .f = cmd_link_flow_ctrl_set_parsed, 6131 .data = (void *)&cmd_link_flow_control_set_xon, 6132 .help_str = "set flow_ctrl send_xon <value> <port_id>: " 6133 "Change send_xon flow control parameter", 6134 .tokens = { 6135 (void *)&cmd_lfc_set_set, 6136 (void *)&cmd_lfc_set_flow_ctrl, 6137 (void *)&cmd_lfc_set_send_xon_str, 6138 (void *)&cmd_lfc_set_send_xon, 6139 (void *)&cmd_lfc_set_portid, 6140 NULL, 6141 }, 6142 }; 6143 6144 cmdline_parse_inst_t cmd_link_flow_control_set_macfwd = { 6145 .f = cmd_link_flow_ctrl_set_parsed, 6146 .data = (void *)&cmd_link_flow_control_set_macfwd, 6147 .help_str = "set flow_ctrl mac_ctrl_frame_fwd on|off <port_id>: " 6148 "Change mac ctrl fwd flow control parameter", 6149 .tokens = { 6150 (void *)&cmd_lfc_set_set, 6151 (void *)&cmd_lfc_set_flow_ctrl, 6152 (void *)&cmd_lfc_set_mac_ctrl_frame_fwd_mode, 6153 (void *)&cmd_lfc_set_mac_ctrl_frame_fwd, 6154 (void *)&cmd_lfc_set_portid, 6155 NULL, 6156 }, 6157 }; 6158 6159 cmdline_parse_inst_t cmd_link_flow_control_set_autoneg = { 6160 .f = cmd_link_flow_ctrl_set_parsed, 6161 .data = (void *)&cmd_link_flow_control_set_autoneg, 6162 .help_str = "set flow_ctrl autoneg on|off <port_id>: " 6163 "Change autoneg flow control parameter", 6164 .tokens = { 6165 (void *)&cmd_lfc_set_set, 6166 (void *)&cmd_lfc_set_flow_ctrl, 6167 (void *)&cmd_lfc_set_autoneg_str, 6168 (void *)&cmd_lfc_set_autoneg, 6169 (void *)&cmd_lfc_set_portid, 6170 NULL, 6171 }, 6172 }; 6173 6174 static void 6175 cmd_link_flow_ctrl_set_parsed(void *parsed_result, 6176 __attribute__((unused)) struct cmdline *cl, 6177 void *data) 6178 { 6179 struct cmd_link_flow_ctrl_set_result *res = parsed_result; 6180 cmdline_parse_inst_t *cmd = data; 6181 struct rte_eth_fc_conf fc_conf; 6182 int rx_fc_en = 0; 6183 int tx_fc_en = 0; 6184 int ret; 6185 6186 /* 6187 * Rx on/off, flow control is enabled/disabled on RX side. This can indicate 6188 * the RTE_FC_TX_PAUSE, Transmit pause frame at the Rx side. 6189 * Tx on/off, flow control is enabled/disabled on TX side. This can indicate 6190 * the RTE_FC_RX_PAUSE, Respond to the pause frame at the Tx side. 6191 */ 6192 static enum rte_eth_fc_mode rx_tx_onoff_2_lfc_mode[2][2] = { 6193 {RTE_FC_NONE, RTE_FC_TX_PAUSE}, {RTE_FC_RX_PAUSE, RTE_FC_FULL} 6194 }; 6195 6196 /* Partial command line, retrieve current configuration */ 6197 if (cmd) { 6198 ret = rte_eth_dev_flow_ctrl_get(res->port_id, &fc_conf); 6199 if (ret != 0) { 6200 printf("cannot get current flow ctrl parameters, return" 6201 "code = %d\n", ret); 6202 return; 6203 } 6204 6205 if ((fc_conf.mode == RTE_FC_RX_PAUSE) || 6206 (fc_conf.mode == RTE_FC_FULL)) 6207 rx_fc_en = 1; 6208 if ((fc_conf.mode == RTE_FC_TX_PAUSE) || 6209 (fc_conf.mode == RTE_FC_FULL)) 6210 tx_fc_en = 1; 6211 } 6212 6213 if (!cmd || cmd == &cmd_link_flow_control_set_rx) 6214 rx_fc_en = (!strcmp(res->rx_lfc_mode, "on")) ? 1 : 0; 6215 6216 if (!cmd || cmd == &cmd_link_flow_control_set_tx) 6217 tx_fc_en = (!strcmp(res->tx_lfc_mode, "on")) ? 1 : 0; 6218 6219 fc_conf.mode = rx_tx_onoff_2_lfc_mode[rx_fc_en][tx_fc_en]; 6220 6221 if (!cmd || cmd == &cmd_link_flow_control_set_hw) 6222 fc_conf.high_water = res->high_water; 6223 6224 if (!cmd || cmd == &cmd_link_flow_control_set_lw) 6225 fc_conf.low_water = res->low_water; 6226 6227 if (!cmd || cmd == &cmd_link_flow_control_set_pt) 6228 fc_conf.pause_time = res->pause_time; 6229 6230 if (!cmd || cmd == &cmd_link_flow_control_set_xon) 6231 fc_conf.send_xon = res->send_xon; 6232 6233 if (!cmd || cmd == &cmd_link_flow_control_set_macfwd) { 6234 if (!strcmp(res->mac_ctrl_frame_fwd_mode, "on")) 6235 fc_conf.mac_ctrl_frame_fwd = 1; 6236 else 6237 fc_conf.mac_ctrl_frame_fwd = 0; 6238 } 6239 6240 if (!cmd || cmd == &cmd_link_flow_control_set_autoneg) 6241 fc_conf.autoneg = (!strcmp(res->autoneg, "on")) ? 1 : 0; 6242 6243 ret = rte_eth_dev_flow_ctrl_set(res->port_id, &fc_conf); 6244 if (ret != 0) 6245 printf("bad flow contrl parameter, return code = %d \n", ret); 6246 } 6247 6248 /* *** SETUP ETHERNET PRIORITY FLOW CONTROL *** */ 6249 struct cmd_priority_flow_ctrl_set_result { 6250 cmdline_fixed_string_t set; 6251 cmdline_fixed_string_t pfc_ctrl; 6252 cmdline_fixed_string_t rx; 6253 cmdline_fixed_string_t rx_pfc_mode; 6254 cmdline_fixed_string_t tx; 6255 cmdline_fixed_string_t tx_pfc_mode; 6256 uint32_t high_water; 6257 uint32_t low_water; 6258 uint16_t pause_time; 6259 uint8_t priority; 6260 portid_t port_id; 6261 }; 6262 6263 static void 6264 cmd_priority_flow_ctrl_set_parsed(void *parsed_result, 6265 __attribute__((unused)) struct cmdline *cl, 6266 __attribute__((unused)) void *data) 6267 { 6268 struct cmd_priority_flow_ctrl_set_result *res = parsed_result; 6269 struct rte_eth_pfc_conf pfc_conf; 6270 int rx_fc_enable, tx_fc_enable; 6271 int ret; 6272 6273 /* 6274 * Rx on/off, flow control is enabled/disabled on RX side. This can indicate 6275 * the RTE_FC_TX_PAUSE, Transmit pause frame at the Rx side. 6276 * Tx on/off, flow control is enabled/disabled on TX side. This can indicate 6277 * the RTE_FC_RX_PAUSE, Respond to the pause frame at the Tx side. 6278 */ 6279 static enum rte_eth_fc_mode rx_tx_onoff_2_pfc_mode[2][2] = { 6280 {RTE_FC_NONE, RTE_FC_RX_PAUSE}, {RTE_FC_TX_PAUSE, RTE_FC_FULL} 6281 }; 6282 6283 rx_fc_enable = (!strncmp(res->rx_pfc_mode, "on",2)) ? 1 : 0; 6284 tx_fc_enable = (!strncmp(res->tx_pfc_mode, "on",2)) ? 1 : 0; 6285 pfc_conf.fc.mode = rx_tx_onoff_2_pfc_mode[rx_fc_enable][tx_fc_enable]; 6286 pfc_conf.fc.high_water = res->high_water; 6287 pfc_conf.fc.low_water = res->low_water; 6288 pfc_conf.fc.pause_time = res->pause_time; 6289 pfc_conf.priority = res->priority; 6290 6291 ret = rte_eth_dev_priority_flow_ctrl_set(res->port_id, &pfc_conf); 6292 if (ret != 0) 6293 printf("bad priority flow contrl parameter, return code = %d \n", ret); 6294 } 6295 6296 cmdline_parse_token_string_t cmd_pfc_set_set = 6297 TOKEN_STRING_INITIALIZER(struct cmd_priority_flow_ctrl_set_result, 6298 set, "set"); 6299 cmdline_parse_token_string_t cmd_pfc_set_flow_ctrl = 6300 TOKEN_STRING_INITIALIZER(struct cmd_priority_flow_ctrl_set_result, 6301 pfc_ctrl, "pfc_ctrl"); 6302 cmdline_parse_token_string_t cmd_pfc_set_rx = 6303 TOKEN_STRING_INITIALIZER(struct cmd_priority_flow_ctrl_set_result, 6304 rx, "rx"); 6305 cmdline_parse_token_string_t cmd_pfc_set_rx_mode = 6306 TOKEN_STRING_INITIALIZER(struct cmd_priority_flow_ctrl_set_result, 6307 rx_pfc_mode, "on#off"); 6308 cmdline_parse_token_string_t cmd_pfc_set_tx = 6309 TOKEN_STRING_INITIALIZER(struct cmd_priority_flow_ctrl_set_result, 6310 tx, "tx"); 6311 cmdline_parse_token_string_t cmd_pfc_set_tx_mode = 6312 TOKEN_STRING_INITIALIZER(struct cmd_priority_flow_ctrl_set_result, 6313 tx_pfc_mode, "on#off"); 6314 cmdline_parse_token_num_t cmd_pfc_set_high_water = 6315 TOKEN_NUM_INITIALIZER(struct cmd_priority_flow_ctrl_set_result, 6316 high_water, UINT32); 6317 cmdline_parse_token_num_t cmd_pfc_set_low_water = 6318 TOKEN_NUM_INITIALIZER(struct cmd_priority_flow_ctrl_set_result, 6319 low_water, UINT32); 6320 cmdline_parse_token_num_t cmd_pfc_set_pause_time = 6321 TOKEN_NUM_INITIALIZER(struct cmd_priority_flow_ctrl_set_result, 6322 pause_time, UINT16); 6323 cmdline_parse_token_num_t cmd_pfc_set_priority = 6324 TOKEN_NUM_INITIALIZER(struct cmd_priority_flow_ctrl_set_result, 6325 priority, UINT8); 6326 cmdline_parse_token_num_t cmd_pfc_set_portid = 6327 TOKEN_NUM_INITIALIZER(struct cmd_priority_flow_ctrl_set_result, 6328 port_id, UINT16); 6329 6330 cmdline_parse_inst_t cmd_priority_flow_control_set = { 6331 .f = cmd_priority_flow_ctrl_set_parsed, 6332 .data = NULL, 6333 .help_str = "set pfc_ctrl rx on|off tx on|off <high_water> <low_water> " 6334 "<pause_time> <priority> <port_id>: " 6335 "Configure the Ethernet priority flow control", 6336 .tokens = { 6337 (void *)&cmd_pfc_set_set, 6338 (void *)&cmd_pfc_set_flow_ctrl, 6339 (void *)&cmd_pfc_set_rx, 6340 (void *)&cmd_pfc_set_rx_mode, 6341 (void *)&cmd_pfc_set_tx, 6342 (void *)&cmd_pfc_set_tx_mode, 6343 (void *)&cmd_pfc_set_high_water, 6344 (void *)&cmd_pfc_set_low_water, 6345 (void *)&cmd_pfc_set_pause_time, 6346 (void *)&cmd_pfc_set_priority, 6347 (void *)&cmd_pfc_set_portid, 6348 NULL, 6349 }, 6350 }; 6351 6352 /* *** RESET CONFIGURATION *** */ 6353 struct cmd_reset_result { 6354 cmdline_fixed_string_t reset; 6355 cmdline_fixed_string_t def; 6356 }; 6357 6358 static void cmd_reset_parsed(__attribute__((unused)) void *parsed_result, 6359 struct cmdline *cl, 6360 __attribute__((unused)) void *data) 6361 { 6362 cmdline_printf(cl, "Reset to default forwarding configuration...\n"); 6363 set_def_fwd_config(); 6364 } 6365 6366 cmdline_parse_token_string_t cmd_reset_set = 6367 TOKEN_STRING_INITIALIZER(struct cmd_reset_result, reset, "set"); 6368 cmdline_parse_token_string_t cmd_reset_def = 6369 TOKEN_STRING_INITIALIZER(struct cmd_reset_result, def, 6370 "default"); 6371 6372 cmdline_parse_inst_t cmd_reset = { 6373 .f = cmd_reset_parsed, 6374 .data = NULL, 6375 .help_str = "set default: Reset default forwarding configuration", 6376 .tokens = { 6377 (void *)&cmd_reset_set, 6378 (void *)&cmd_reset_def, 6379 NULL, 6380 }, 6381 }; 6382 6383 /* *** START FORWARDING *** */ 6384 struct cmd_start_result { 6385 cmdline_fixed_string_t start; 6386 }; 6387 6388 cmdline_parse_token_string_t cmd_start_start = 6389 TOKEN_STRING_INITIALIZER(struct cmd_start_result, start, "start"); 6390 6391 static void cmd_start_parsed(__attribute__((unused)) void *parsed_result, 6392 __attribute__((unused)) struct cmdline *cl, 6393 __attribute__((unused)) void *data) 6394 { 6395 start_packet_forwarding(0); 6396 } 6397 6398 cmdline_parse_inst_t cmd_start = { 6399 .f = cmd_start_parsed, 6400 .data = NULL, 6401 .help_str = "start: Start packet forwarding", 6402 .tokens = { 6403 (void *)&cmd_start_start, 6404 NULL, 6405 }, 6406 }; 6407 6408 /* *** START FORWARDING WITH ONE TX BURST FIRST *** */ 6409 struct cmd_start_tx_first_result { 6410 cmdline_fixed_string_t start; 6411 cmdline_fixed_string_t tx_first; 6412 }; 6413 6414 static void 6415 cmd_start_tx_first_parsed(__attribute__((unused)) void *parsed_result, 6416 __attribute__((unused)) struct cmdline *cl, 6417 __attribute__((unused)) void *data) 6418 { 6419 start_packet_forwarding(1); 6420 } 6421 6422 cmdline_parse_token_string_t cmd_start_tx_first_start = 6423 TOKEN_STRING_INITIALIZER(struct cmd_start_tx_first_result, start, 6424 "start"); 6425 cmdline_parse_token_string_t cmd_start_tx_first_tx_first = 6426 TOKEN_STRING_INITIALIZER(struct cmd_start_tx_first_result, 6427 tx_first, "tx_first"); 6428 6429 cmdline_parse_inst_t cmd_start_tx_first = { 6430 .f = cmd_start_tx_first_parsed, 6431 .data = NULL, 6432 .help_str = "start tx_first: Start packet forwarding, " 6433 "after sending 1 burst of packets", 6434 .tokens = { 6435 (void *)&cmd_start_tx_first_start, 6436 (void *)&cmd_start_tx_first_tx_first, 6437 NULL, 6438 }, 6439 }; 6440 6441 /* *** START FORWARDING WITH N TX BURST FIRST *** */ 6442 struct cmd_start_tx_first_n_result { 6443 cmdline_fixed_string_t start; 6444 cmdline_fixed_string_t tx_first; 6445 uint32_t tx_num; 6446 }; 6447 6448 static void 6449 cmd_start_tx_first_n_parsed(void *parsed_result, 6450 __attribute__((unused)) struct cmdline *cl, 6451 __attribute__((unused)) void *data) 6452 { 6453 struct cmd_start_tx_first_n_result *res = parsed_result; 6454 6455 start_packet_forwarding(res->tx_num); 6456 } 6457 6458 cmdline_parse_token_string_t cmd_start_tx_first_n_start = 6459 TOKEN_STRING_INITIALIZER(struct cmd_start_tx_first_n_result, 6460 start, "start"); 6461 cmdline_parse_token_string_t cmd_start_tx_first_n_tx_first = 6462 TOKEN_STRING_INITIALIZER(struct cmd_start_tx_first_n_result, 6463 tx_first, "tx_first"); 6464 cmdline_parse_token_num_t cmd_start_tx_first_n_tx_num = 6465 TOKEN_NUM_INITIALIZER(struct cmd_start_tx_first_n_result, 6466 tx_num, UINT32); 6467 6468 cmdline_parse_inst_t cmd_start_tx_first_n = { 6469 .f = cmd_start_tx_first_n_parsed, 6470 .data = NULL, 6471 .help_str = "start tx_first <num>: " 6472 "packet forwarding, after sending <num> bursts of packets", 6473 .tokens = { 6474 (void *)&cmd_start_tx_first_n_start, 6475 (void *)&cmd_start_tx_first_n_tx_first, 6476 (void *)&cmd_start_tx_first_n_tx_num, 6477 NULL, 6478 }, 6479 }; 6480 6481 /* *** SET LINK UP *** */ 6482 struct cmd_set_link_up_result { 6483 cmdline_fixed_string_t set; 6484 cmdline_fixed_string_t link_up; 6485 cmdline_fixed_string_t port; 6486 portid_t port_id; 6487 }; 6488 6489 cmdline_parse_token_string_t cmd_set_link_up_set = 6490 TOKEN_STRING_INITIALIZER(struct cmd_set_link_up_result, set, "set"); 6491 cmdline_parse_token_string_t cmd_set_link_up_link_up = 6492 TOKEN_STRING_INITIALIZER(struct cmd_set_link_up_result, link_up, 6493 "link-up"); 6494 cmdline_parse_token_string_t cmd_set_link_up_port = 6495 TOKEN_STRING_INITIALIZER(struct cmd_set_link_up_result, port, "port"); 6496 cmdline_parse_token_num_t cmd_set_link_up_port_id = 6497 TOKEN_NUM_INITIALIZER(struct cmd_set_link_up_result, port_id, UINT16); 6498 6499 static void cmd_set_link_up_parsed(__attribute__((unused)) void *parsed_result, 6500 __attribute__((unused)) struct cmdline *cl, 6501 __attribute__((unused)) void *data) 6502 { 6503 struct cmd_set_link_up_result *res = parsed_result; 6504 dev_set_link_up(res->port_id); 6505 } 6506 6507 cmdline_parse_inst_t cmd_set_link_up = { 6508 .f = cmd_set_link_up_parsed, 6509 .data = NULL, 6510 .help_str = "set link-up port <port id>", 6511 .tokens = { 6512 (void *)&cmd_set_link_up_set, 6513 (void *)&cmd_set_link_up_link_up, 6514 (void *)&cmd_set_link_up_port, 6515 (void *)&cmd_set_link_up_port_id, 6516 NULL, 6517 }, 6518 }; 6519 6520 /* *** SET LINK DOWN *** */ 6521 struct cmd_set_link_down_result { 6522 cmdline_fixed_string_t set; 6523 cmdline_fixed_string_t link_down; 6524 cmdline_fixed_string_t port; 6525 portid_t port_id; 6526 }; 6527 6528 cmdline_parse_token_string_t cmd_set_link_down_set = 6529 TOKEN_STRING_INITIALIZER(struct cmd_set_link_down_result, set, "set"); 6530 cmdline_parse_token_string_t cmd_set_link_down_link_down = 6531 TOKEN_STRING_INITIALIZER(struct cmd_set_link_down_result, link_down, 6532 "link-down"); 6533 cmdline_parse_token_string_t cmd_set_link_down_port = 6534 TOKEN_STRING_INITIALIZER(struct cmd_set_link_down_result, port, "port"); 6535 cmdline_parse_token_num_t cmd_set_link_down_port_id = 6536 TOKEN_NUM_INITIALIZER(struct cmd_set_link_down_result, port_id, UINT16); 6537 6538 static void cmd_set_link_down_parsed( 6539 __attribute__((unused)) void *parsed_result, 6540 __attribute__((unused)) struct cmdline *cl, 6541 __attribute__((unused)) void *data) 6542 { 6543 struct cmd_set_link_down_result *res = parsed_result; 6544 dev_set_link_down(res->port_id); 6545 } 6546 6547 cmdline_parse_inst_t cmd_set_link_down = { 6548 .f = cmd_set_link_down_parsed, 6549 .data = NULL, 6550 .help_str = "set link-down port <port id>", 6551 .tokens = { 6552 (void *)&cmd_set_link_down_set, 6553 (void *)&cmd_set_link_down_link_down, 6554 (void *)&cmd_set_link_down_port, 6555 (void *)&cmd_set_link_down_port_id, 6556 NULL, 6557 }, 6558 }; 6559 6560 /* *** SHOW CFG *** */ 6561 struct cmd_showcfg_result { 6562 cmdline_fixed_string_t show; 6563 cmdline_fixed_string_t cfg; 6564 cmdline_fixed_string_t what; 6565 }; 6566 6567 static void cmd_showcfg_parsed(void *parsed_result, 6568 __attribute__((unused)) struct cmdline *cl, 6569 __attribute__((unused)) void *data) 6570 { 6571 struct cmd_showcfg_result *res = parsed_result; 6572 if (!strcmp(res->what, "rxtx")) 6573 rxtx_config_display(); 6574 else if (!strcmp(res->what, "cores")) 6575 fwd_lcores_config_display(); 6576 else if (!strcmp(res->what, "fwd")) 6577 pkt_fwd_config_display(&cur_fwd_config); 6578 else if (!strcmp(res->what, "txpkts")) 6579 show_tx_pkt_segments(); 6580 } 6581 6582 cmdline_parse_token_string_t cmd_showcfg_show = 6583 TOKEN_STRING_INITIALIZER(struct cmd_showcfg_result, show, "show"); 6584 cmdline_parse_token_string_t cmd_showcfg_port = 6585 TOKEN_STRING_INITIALIZER(struct cmd_showcfg_result, cfg, "config"); 6586 cmdline_parse_token_string_t cmd_showcfg_what = 6587 TOKEN_STRING_INITIALIZER(struct cmd_showcfg_result, what, 6588 "rxtx#cores#fwd#txpkts"); 6589 6590 cmdline_parse_inst_t cmd_showcfg = { 6591 .f = cmd_showcfg_parsed, 6592 .data = NULL, 6593 .help_str = "show config rxtx|cores|fwd|txpkts", 6594 .tokens = { 6595 (void *)&cmd_showcfg_show, 6596 (void *)&cmd_showcfg_port, 6597 (void *)&cmd_showcfg_what, 6598 NULL, 6599 }, 6600 }; 6601 6602 /* *** SHOW ALL PORT INFO *** */ 6603 struct cmd_showportall_result { 6604 cmdline_fixed_string_t show; 6605 cmdline_fixed_string_t port; 6606 cmdline_fixed_string_t what; 6607 cmdline_fixed_string_t all; 6608 }; 6609 6610 static void cmd_showportall_parsed(void *parsed_result, 6611 __attribute__((unused)) struct cmdline *cl, 6612 __attribute__((unused)) void *data) 6613 { 6614 portid_t i; 6615 6616 struct cmd_showportall_result *res = parsed_result; 6617 if (!strcmp(res->show, "clear")) { 6618 if (!strcmp(res->what, "stats")) 6619 RTE_ETH_FOREACH_DEV(i) 6620 nic_stats_clear(i); 6621 else if (!strcmp(res->what, "xstats")) 6622 RTE_ETH_FOREACH_DEV(i) 6623 nic_xstats_clear(i); 6624 } else if (!strcmp(res->what, "info")) 6625 RTE_ETH_FOREACH_DEV(i) 6626 port_infos_display(i); 6627 else if (!strcmp(res->what, "stats")) 6628 RTE_ETH_FOREACH_DEV(i) 6629 nic_stats_display(i); 6630 else if (!strcmp(res->what, "xstats")) 6631 RTE_ETH_FOREACH_DEV(i) 6632 nic_xstats_display(i); 6633 else if (!strcmp(res->what, "fdir")) 6634 RTE_ETH_FOREACH_DEV(i) 6635 fdir_get_infos(i); 6636 else if (!strcmp(res->what, "stat_qmap")) 6637 RTE_ETH_FOREACH_DEV(i) 6638 nic_stats_mapping_display(i); 6639 else if (!strcmp(res->what, "dcb_tc")) 6640 RTE_ETH_FOREACH_DEV(i) 6641 port_dcb_info_display(i); 6642 else if (!strcmp(res->what, "cap")) 6643 RTE_ETH_FOREACH_DEV(i) 6644 port_offload_cap_display(i); 6645 } 6646 6647 cmdline_parse_token_string_t cmd_showportall_show = 6648 TOKEN_STRING_INITIALIZER(struct cmd_showportall_result, show, 6649 "show#clear"); 6650 cmdline_parse_token_string_t cmd_showportall_port = 6651 TOKEN_STRING_INITIALIZER(struct cmd_showportall_result, port, "port"); 6652 cmdline_parse_token_string_t cmd_showportall_what = 6653 TOKEN_STRING_INITIALIZER(struct cmd_showportall_result, what, 6654 "info#stats#xstats#fdir#stat_qmap#dcb_tc#cap"); 6655 cmdline_parse_token_string_t cmd_showportall_all = 6656 TOKEN_STRING_INITIALIZER(struct cmd_showportall_result, all, "all"); 6657 cmdline_parse_inst_t cmd_showportall = { 6658 .f = cmd_showportall_parsed, 6659 .data = NULL, 6660 .help_str = "show|clear port " 6661 "info|stats|xstats|fdir|stat_qmap|dcb_tc|cap all", 6662 .tokens = { 6663 (void *)&cmd_showportall_show, 6664 (void *)&cmd_showportall_port, 6665 (void *)&cmd_showportall_what, 6666 (void *)&cmd_showportall_all, 6667 NULL, 6668 }, 6669 }; 6670 6671 /* *** SHOW PORT INFO *** */ 6672 struct cmd_showport_result { 6673 cmdline_fixed_string_t show; 6674 cmdline_fixed_string_t port; 6675 cmdline_fixed_string_t what; 6676 uint16_t portnum; 6677 }; 6678 6679 static void cmd_showport_parsed(void *parsed_result, 6680 __attribute__((unused)) struct cmdline *cl, 6681 __attribute__((unused)) void *data) 6682 { 6683 struct cmd_showport_result *res = parsed_result; 6684 if (!strcmp(res->show, "clear")) { 6685 if (!strcmp(res->what, "stats")) 6686 nic_stats_clear(res->portnum); 6687 else if (!strcmp(res->what, "xstats")) 6688 nic_xstats_clear(res->portnum); 6689 } else if (!strcmp(res->what, "info")) 6690 port_infos_display(res->portnum); 6691 else if (!strcmp(res->what, "stats")) 6692 nic_stats_display(res->portnum); 6693 else if (!strcmp(res->what, "xstats")) 6694 nic_xstats_display(res->portnum); 6695 else if (!strcmp(res->what, "fdir")) 6696 fdir_get_infos(res->portnum); 6697 else if (!strcmp(res->what, "stat_qmap")) 6698 nic_stats_mapping_display(res->portnum); 6699 else if (!strcmp(res->what, "dcb_tc")) 6700 port_dcb_info_display(res->portnum); 6701 else if (!strcmp(res->what, "cap")) 6702 port_offload_cap_display(res->portnum); 6703 } 6704 6705 cmdline_parse_token_string_t cmd_showport_show = 6706 TOKEN_STRING_INITIALIZER(struct cmd_showport_result, show, 6707 "show#clear"); 6708 cmdline_parse_token_string_t cmd_showport_port = 6709 TOKEN_STRING_INITIALIZER(struct cmd_showport_result, port, "port"); 6710 cmdline_parse_token_string_t cmd_showport_what = 6711 TOKEN_STRING_INITIALIZER(struct cmd_showport_result, what, 6712 "info#stats#xstats#fdir#stat_qmap#dcb_tc#cap"); 6713 cmdline_parse_token_num_t cmd_showport_portnum = 6714 TOKEN_NUM_INITIALIZER(struct cmd_showport_result, portnum, UINT16); 6715 6716 cmdline_parse_inst_t cmd_showport = { 6717 .f = cmd_showport_parsed, 6718 .data = NULL, 6719 .help_str = "show|clear port " 6720 "info|stats|xstats|fdir|stat_qmap|dcb_tc|cap " 6721 "<port_id>", 6722 .tokens = { 6723 (void *)&cmd_showport_show, 6724 (void *)&cmd_showport_port, 6725 (void *)&cmd_showport_what, 6726 (void *)&cmd_showport_portnum, 6727 NULL, 6728 }, 6729 }; 6730 6731 /* *** SHOW QUEUE INFO *** */ 6732 struct cmd_showqueue_result { 6733 cmdline_fixed_string_t show; 6734 cmdline_fixed_string_t type; 6735 cmdline_fixed_string_t what; 6736 uint16_t portnum; 6737 uint16_t queuenum; 6738 }; 6739 6740 static void 6741 cmd_showqueue_parsed(void *parsed_result, 6742 __attribute__((unused)) struct cmdline *cl, 6743 __attribute__((unused)) void *data) 6744 { 6745 struct cmd_showqueue_result *res = parsed_result; 6746 6747 if (!strcmp(res->type, "rxq")) 6748 rx_queue_infos_display(res->portnum, res->queuenum); 6749 else if (!strcmp(res->type, "txq")) 6750 tx_queue_infos_display(res->portnum, res->queuenum); 6751 } 6752 6753 cmdline_parse_token_string_t cmd_showqueue_show = 6754 TOKEN_STRING_INITIALIZER(struct cmd_showqueue_result, show, "show"); 6755 cmdline_parse_token_string_t cmd_showqueue_type = 6756 TOKEN_STRING_INITIALIZER(struct cmd_showqueue_result, type, "rxq#txq"); 6757 cmdline_parse_token_string_t cmd_showqueue_what = 6758 TOKEN_STRING_INITIALIZER(struct cmd_showqueue_result, what, "info"); 6759 cmdline_parse_token_num_t cmd_showqueue_portnum = 6760 TOKEN_NUM_INITIALIZER(struct cmd_showqueue_result, portnum, UINT16); 6761 cmdline_parse_token_num_t cmd_showqueue_queuenum = 6762 TOKEN_NUM_INITIALIZER(struct cmd_showqueue_result, queuenum, UINT16); 6763 6764 cmdline_parse_inst_t cmd_showqueue = { 6765 .f = cmd_showqueue_parsed, 6766 .data = NULL, 6767 .help_str = "show rxq|txq info <port_id> <queue_id>", 6768 .tokens = { 6769 (void *)&cmd_showqueue_show, 6770 (void *)&cmd_showqueue_type, 6771 (void *)&cmd_showqueue_what, 6772 (void *)&cmd_showqueue_portnum, 6773 (void *)&cmd_showqueue_queuenum, 6774 NULL, 6775 }, 6776 }; 6777 6778 /* *** READ PORT REGISTER *** */ 6779 struct cmd_read_reg_result { 6780 cmdline_fixed_string_t read; 6781 cmdline_fixed_string_t reg; 6782 portid_t port_id; 6783 uint32_t reg_off; 6784 }; 6785 6786 static void 6787 cmd_read_reg_parsed(void *parsed_result, 6788 __attribute__((unused)) struct cmdline *cl, 6789 __attribute__((unused)) void *data) 6790 { 6791 struct cmd_read_reg_result *res = parsed_result; 6792 port_reg_display(res->port_id, res->reg_off); 6793 } 6794 6795 cmdline_parse_token_string_t cmd_read_reg_read = 6796 TOKEN_STRING_INITIALIZER(struct cmd_read_reg_result, read, "read"); 6797 cmdline_parse_token_string_t cmd_read_reg_reg = 6798 TOKEN_STRING_INITIALIZER(struct cmd_read_reg_result, reg, "reg"); 6799 cmdline_parse_token_num_t cmd_read_reg_port_id = 6800 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_result, port_id, UINT16); 6801 cmdline_parse_token_num_t cmd_read_reg_reg_off = 6802 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_result, reg_off, UINT32); 6803 6804 cmdline_parse_inst_t cmd_read_reg = { 6805 .f = cmd_read_reg_parsed, 6806 .data = NULL, 6807 .help_str = "read reg <port_id> <reg_off>", 6808 .tokens = { 6809 (void *)&cmd_read_reg_read, 6810 (void *)&cmd_read_reg_reg, 6811 (void *)&cmd_read_reg_port_id, 6812 (void *)&cmd_read_reg_reg_off, 6813 NULL, 6814 }, 6815 }; 6816 6817 /* *** READ PORT REGISTER BIT FIELD *** */ 6818 struct cmd_read_reg_bit_field_result { 6819 cmdline_fixed_string_t read; 6820 cmdline_fixed_string_t regfield; 6821 portid_t port_id; 6822 uint32_t reg_off; 6823 uint8_t bit1_pos; 6824 uint8_t bit2_pos; 6825 }; 6826 6827 static void 6828 cmd_read_reg_bit_field_parsed(void *parsed_result, 6829 __attribute__((unused)) struct cmdline *cl, 6830 __attribute__((unused)) void *data) 6831 { 6832 struct cmd_read_reg_bit_field_result *res = parsed_result; 6833 port_reg_bit_field_display(res->port_id, res->reg_off, 6834 res->bit1_pos, res->bit2_pos); 6835 } 6836 6837 cmdline_parse_token_string_t cmd_read_reg_bit_field_read = 6838 TOKEN_STRING_INITIALIZER(struct cmd_read_reg_bit_field_result, read, 6839 "read"); 6840 cmdline_parse_token_string_t cmd_read_reg_bit_field_regfield = 6841 TOKEN_STRING_INITIALIZER(struct cmd_read_reg_bit_field_result, 6842 regfield, "regfield"); 6843 cmdline_parse_token_num_t cmd_read_reg_bit_field_port_id = 6844 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_field_result, port_id, 6845 UINT16); 6846 cmdline_parse_token_num_t cmd_read_reg_bit_field_reg_off = 6847 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_field_result, reg_off, 6848 UINT32); 6849 cmdline_parse_token_num_t cmd_read_reg_bit_field_bit1_pos = 6850 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_field_result, bit1_pos, 6851 UINT8); 6852 cmdline_parse_token_num_t cmd_read_reg_bit_field_bit2_pos = 6853 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_field_result, bit2_pos, 6854 UINT8); 6855 6856 cmdline_parse_inst_t cmd_read_reg_bit_field = { 6857 .f = cmd_read_reg_bit_field_parsed, 6858 .data = NULL, 6859 .help_str = "read regfield <port_id> <reg_off> <bit_x> <bit_y>: " 6860 "Read register bit field between bit_x and bit_y included", 6861 .tokens = { 6862 (void *)&cmd_read_reg_bit_field_read, 6863 (void *)&cmd_read_reg_bit_field_regfield, 6864 (void *)&cmd_read_reg_bit_field_port_id, 6865 (void *)&cmd_read_reg_bit_field_reg_off, 6866 (void *)&cmd_read_reg_bit_field_bit1_pos, 6867 (void *)&cmd_read_reg_bit_field_bit2_pos, 6868 NULL, 6869 }, 6870 }; 6871 6872 /* *** READ PORT REGISTER BIT *** */ 6873 struct cmd_read_reg_bit_result { 6874 cmdline_fixed_string_t read; 6875 cmdline_fixed_string_t regbit; 6876 portid_t port_id; 6877 uint32_t reg_off; 6878 uint8_t bit_pos; 6879 }; 6880 6881 static void 6882 cmd_read_reg_bit_parsed(void *parsed_result, 6883 __attribute__((unused)) struct cmdline *cl, 6884 __attribute__((unused)) void *data) 6885 { 6886 struct cmd_read_reg_bit_result *res = parsed_result; 6887 port_reg_bit_display(res->port_id, res->reg_off, res->bit_pos); 6888 } 6889 6890 cmdline_parse_token_string_t cmd_read_reg_bit_read = 6891 TOKEN_STRING_INITIALIZER(struct cmd_read_reg_bit_result, read, "read"); 6892 cmdline_parse_token_string_t cmd_read_reg_bit_regbit = 6893 TOKEN_STRING_INITIALIZER(struct cmd_read_reg_bit_result, 6894 regbit, "regbit"); 6895 cmdline_parse_token_num_t cmd_read_reg_bit_port_id = 6896 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_result, port_id, UINT16); 6897 cmdline_parse_token_num_t cmd_read_reg_bit_reg_off = 6898 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_result, reg_off, UINT32); 6899 cmdline_parse_token_num_t cmd_read_reg_bit_bit_pos = 6900 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_result, bit_pos, UINT8); 6901 6902 cmdline_parse_inst_t cmd_read_reg_bit = { 6903 .f = cmd_read_reg_bit_parsed, 6904 .data = NULL, 6905 .help_str = "read regbit <port_id> <reg_off> <bit_x>: 0 <= bit_x <= 31", 6906 .tokens = { 6907 (void *)&cmd_read_reg_bit_read, 6908 (void *)&cmd_read_reg_bit_regbit, 6909 (void *)&cmd_read_reg_bit_port_id, 6910 (void *)&cmd_read_reg_bit_reg_off, 6911 (void *)&cmd_read_reg_bit_bit_pos, 6912 NULL, 6913 }, 6914 }; 6915 6916 /* *** WRITE PORT REGISTER *** */ 6917 struct cmd_write_reg_result { 6918 cmdline_fixed_string_t write; 6919 cmdline_fixed_string_t reg; 6920 portid_t port_id; 6921 uint32_t reg_off; 6922 uint32_t value; 6923 }; 6924 6925 static void 6926 cmd_write_reg_parsed(void *parsed_result, 6927 __attribute__((unused)) struct cmdline *cl, 6928 __attribute__((unused)) void *data) 6929 { 6930 struct cmd_write_reg_result *res = parsed_result; 6931 port_reg_set(res->port_id, res->reg_off, res->value); 6932 } 6933 6934 cmdline_parse_token_string_t cmd_write_reg_write = 6935 TOKEN_STRING_INITIALIZER(struct cmd_write_reg_result, write, "write"); 6936 cmdline_parse_token_string_t cmd_write_reg_reg = 6937 TOKEN_STRING_INITIALIZER(struct cmd_write_reg_result, reg, "reg"); 6938 cmdline_parse_token_num_t cmd_write_reg_port_id = 6939 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_result, port_id, UINT16); 6940 cmdline_parse_token_num_t cmd_write_reg_reg_off = 6941 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_result, reg_off, UINT32); 6942 cmdline_parse_token_num_t cmd_write_reg_value = 6943 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_result, value, UINT32); 6944 6945 cmdline_parse_inst_t cmd_write_reg = { 6946 .f = cmd_write_reg_parsed, 6947 .data = NULL, 6948 .help_str = "write reg <port_id> <reg_off> <reg_value>", 6949 .tokens = { 6950 (void *)&cmd_write_reg_write, 6951 (void *)&cmd_write_reg_reg, 6952 (void *)&cmd_write_reg_port_id, 6953 (void *)&cmd_write_reg_reg_off, 6954 (void *)&cmd_write_reg_value, 6955 NULL, 6956 }, 6957 }; 6958 6959 /* *** WRITE PORT REGISTER BIT FIELD *** */ 6960 struct cmd_write_reg_bit_field_result { 6961 cmdline_fixed_string_t write; 6962 cmdline_fixed_string_t regfield; 6963 portid_t port_id; 6964 uint32_t reg_off; 6965 uint8_t bit1_pos; 6966 uint8_t bit2_pos; 6967 uint32_t value; 6968 }; 6969 6970 static void 6971 cmd_write_reg_bit_field_parsed(void *parsed_result, 6972 __attribute__((unused)) struct cmdline *cl, 6973 __attribute__((unused)) void *data) 6974 { 6975 struct cmd_write_reg_bit_field_result *res = parsed_result; 6976 port_reg_bit_field_set(res->port_id, res->reg_off, 6977 res->bit1_pos, res->bit2_pos, res->value); 6978 } 6979 6980 cmdline_parse_token_string_t cmd_write_reg_bit_field_write = 6981 TOKEN_STRING_INITIALIZER(struct cmd_write_reg_bit_field_result, write, 6982 "write"); 6983 cmdline_parse_token_string_t cmd_write_reg_bit_field_regfield = 6984 TOKEN_STRING_INITIALIZER(struct cmd_write_reg_bit_field_result, 6985 regfield, "regfield"); 6986 cmdline_parse_token_num_t cmd_write_reg_bit_field_port_id = 6987 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_field_result, port_id, 6988 UINT16); 6989 cmdline_parse_token_num_t cmd_write_reg_bit_field_reg_off = 6990 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_field_result, reg_off, 6991 UINT32); 6992 cmdline_parse_token_num_t cmd_write_reg_bit_field_bit1_pos = 6993 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_field_result, bit1_pos, 6994 UINT8); 6995 cmdline_parse_token_num_t cmd_write_reg_bit_field_bit2_pos = 6996 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_field_result, bit2_pos, 6997 UINT8); 6998 cmdline_parse_token_num_t cmd_write_reg_bit_field_value = 6999 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_field_result, value, 7000 UINT32); 7001 7002 cmdline_parse_inst_t cmd_write_reg_bit_field = { 7003 .f = cmd_write_reg_bit_field_parsed, 7004 .data = NULL, 7005 .help_str = "write regfield <port_id> <reg_off> <bit_x> <bit_y> " 7006 "<reg_value>: " 7007 "Set register bit field between bit_x and bit_y included", 7008 .tokens = { 7009 (void *)&cmd_write_reg_bit_field_write, 7010 (void *)&cmd_write_reg_bit_field_regfield, 7011 (void *)&cmd_write_reg_bit_field_port_id, 7012 (void *)&cmd_write_reg_bit_field_reg_off, 7013 (void *)&cmd_write_reg_bit_field_bit1_pos, 7014 (void *)&cmd_write_reg_bit_field_bit2_pos, 7015 (void *)&cmd_write_reg_bit_field_value, 7016 NULL, 7017 }, 7018 }; 7019 7020 /* *** WRITE PORT REGISTER BIT *** */ 7021 struct cmd_write_reg_bit_result { 7022 cmdline_fixed_string_t write; 7023 cmdline_fixed_string_t regbit; 7024 portid_t port_id; 7025 uint32_t reg_off; 7026 uint8_t bit_pos; 7027 uint8_t value; 7028 }; 7029 7030 static void 7031 cmd_write_reg_bit_parsed(void *parsed_result, 7032 __attribute__((unused)) struct cmdline *cl, 7033 __attribute__((unused)) void *data) 7034 { 7035 struct cmd_write_reg_bit_result *res = parsed_result; 7036 port_reg_bit_set(res->port_id, res->reg_off, res->bit_pos, res->value); 7037 } 7038 7039 cmdline_parse_token_string_t cmd_write_reg_bit_write = 7040 TOKEN_STRING_INITIALIZER(struct cmd_write_reg_bit_result, write, 7041 "write"); 7042 cmdline_parse_token_string_t cmd_write_reg_bit_regbit = 7043 TOKEN_STRING_INITIALIZER(struct cmd_write_reg_bit_result, 7044 regbit, "regbit"); 7045 cmdline_parse_token_num_t cmd_write_reg_bit_port_id = 7046 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_result, port_id, UINT16); 7047 cmdline_parse_token_num_t cmd_write_reg_bit_reg_off = 7048 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_result, reg_off, UINT32); 7049 cmdline_parse_token_num_t cmd_write_reg_bit_bit_pos = 7050 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_result, bit_pos, UINT8); 7051 cmdline_parse_token_num_t cmd_write_reg_bit_value = 7052 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_result, value, UINT8); 7053 7054 cmdline_parse_inst_t cmd_write_reg_bit = { 7055 .f = cmd_write_reg_bit_parsed, 7056 .data = NULL, 7057 .help_str = "write regbit <port_id> <reg_off> <bit_x> 0|1: " 7058 "0 <= bit_x <= 31", 7059 .tokens = { 7060 (void *)&cmd_write_reg_bit_write, 7061 (void *)&cmd_write_reg_bit_regbit, 7062 (void *)&cmd_write_reg_bit_port_id, 7063 (void *)&cmd_write_reg_bit_reg_off, 7064 (void *)&cmd_write_reg_bit_bit_pos, 7065 (void *)&cmd_write_reg_bit_value, 7066 NULL, 7067 }, 7068 }; 7069 7070 /* *** READ A RING DESCRIPTOR OF A PORT RX/TX QUEUE *** */ 7071 struct cmd_read_rxd_txd_result { 7072 cmdline_fixed_string_t read; 7073 cmdline_fixed_string_t rxd_txd; 7074 portid_t port_id; 7075 uint16_t queue_id; 7076 uint16_t desc_id; 7077 }; 7078 7079 static void 7080 cmd_read_rxd_txd_parsed(void *parsed_result, 7081 __attribute__((unused)) struct cmdline *cl, 7082 __attribute__((unused)) void *data) 7083 { 7084 struct cmd_read_rxd_txd_result *res = parsed_result; 7085 7086 if (!strcmp(res->rxd_txd, "rxd")) 7087 rx_ring_desc_display(res->port_id, res->queue_id, res->desc_id); 7088 else if (!strcmp(res->rxd_txd, "txd")) 7089 tx_ring_desc_display(res->port_id, res->queue_id, res->desc_id); 7090 } 7091 7092 cmdline_parse_token_string_t cmd_read_rxd_txd_read = 7093 TOKEN_STRING_INITIALIZER(struct cmd_read_rxd_txd_result, read, "read"); 7094 cmdline_parse_token_string_t cmd_read_rxd_txd_rxd_txd = 7095 TOKEN_STRING_INITIALIZER(struct cmd_read_rxd_txd_result, rxd_txd, 7096 "rxd#txd"); 7097 cmdline_parse_token_num_t cmd_read_rxd_txd_port_id = 7098 TOKEN_NUM_INITIALIZER(struct cmd_read_rxd_txd_result, port_id, UINT16); 7099 cmdline_parse_token_num_t cmd_read_rxd_txd_queue_id = 7100 TOKEN_NUM_INITIALIZER(struct cmd_read_rxd_txd_result, queue_id, UINT16); 7101 cmdline_parse_token_num_t cmd_read_rxd_txd_desc_id = 7102 TOKEN_NUM_INITIALIZER(struct cmd_read_rxd_txd_result, desc_id, UINT16); 7103 7104 cmdline_parse_inst_t cmd_read_rxd_txd = { 7105 .f = cmd_read_rxd_txd_parsed, 7106 .data = NULL, 7107 .help_str = "read rxd|txd <port_id> <queue_id> <desc_id>", 7108 .tokens = { 7109 (void *)&cmd_read_rxd_txd_read, 7110 (void *)&cmd_read_rxd_txd_rxd_txd, 7111 (void *)&cmd_read_rxd_txd_port_id, 7112 (void *)&cmd_read_rxd_txd_queue_id, 7113 (void *)&cmd_read_rxd_txd_desc_id, 7114 NULL, 7115 }, 7116 }; 7117 7118 /* *** QUIT *** */ 7119 struct cmd_quit_result { 7120 cmdline_fixed_string_t quit; 7121 }; 7122 7123 static void cmd_quit_parsed(__attribute__((unused)) void *parsed_result, 7124 struct cmdline *cl, 7125 __attribute__((unused)) void *data) 7126 { 7127 pmd_test_exit(); 7128 cmdline_quit(cl); 7129 } 7130 7131 cmdline_parse_token_string_t cmd_quit_quit = 7132 TOKEN_STRING_INITIALIZER(struct cmd_quit_result, quit, "quit"); 7133 7134 cmdline_parse_inst_t cmd_quit = { 7135 .f = cmd_quit_parsed, 7136 .data = NULL, 7137 .help_str = "quit: Exit application", 7138 .tokens = { 7139 (void *)&cmd_quit_quit, 7140 NULL, 7141 }, 7142 }; 7143 7144 /* *** ADD/REMOVE MAC ADDRESS FROM A PORT *** */ 7145 struct cmd_mac_addr_result { 7146 cmdline_fixed_string_t mac_addr_cmd; 7147 cmdline_fixed_string_t what; 7148 uint16_t port_num; 7149 struct ether_addr address; 7150 }; 7151 7152 static void cmd_mac_addr_parsed(void *parsed_result, 7153 __attribute__((unused)) struct cmdline *cl, 7154 __attribute__((unused)) void *data) 7155 { 7156 struct cmd_mac_addr_result *res = parsed_result; 7157 int ret; 7158 7159 if (strcmp(res->what, "add") == 0) 7160 ret = rte_eth_dev_mac_addr_add(res->port_num, &res->address, 0); 7161 else if (strcmp(res->what, "set") == 0) 7162 ret = rte_eth_dev_default_mac_addr_set(res->port_num, 7163 &res->address); 7164 else 7165 ret = rte_eth_dev_mac_addr_remove(res->port_num, &res->address); 7166 7167 /* check the return value and print it if is < 0 */ 7168 if(ret < 0) 7169 printf("mac_addr_cmd error: (%s)\n", strerror(-ret)); 7170 7171 } 7172 7173 cmdline_parse_token_string_t cmd_mac_addr_cmd = 7174 TOKEN_STRING_INITIALIZER(struct cmd_mac_addr_result, mac_addr_cmd, 7175 "mac_addr"); 7176 cmdline_parse_token_string_t cmd_mac_addr_what = 7177 TOKEN_STRING_INITIALIZER(struct cmd_mac_addr_result, what, 7178 "add#remove#set"); 7179 cmdline_parse_token_num_t cmd_mac_addr_portnum = 7180 TOKEN_NUM_INITIALIZER(struct cmd_mac_addr_result, port_num, 7181 UINT16); 7182 cmdline_parse_token_etheraddr_t cmd_mac_addr_addr = 7183 TOKEN_ETHERADDR_INITIALIZER(struct cmd_mac_addr_result, address); 7184 7185 cmdline_parse_inst_t cmd_mac_addr = { 7186 .f = cmd_mac_addr_parsed, 7187 .data = (void *)0, 7188 .help_str = "mac_addr add|remove|set <port_id> <mac_addr>: " 7189 "Add/Remove/Set MAC address on port_id", 7190 .tokens = { 7191 (void *)&cmd_mac_addr_cmd, 7192 (void *)&cmd_mac_addr_what, 7193 (void *)&cmd_mac_addr_portnum, 7194 (void *)&cmd_mac_addr_addr, 7195 NULL, 7196 }, 7197 }; 7198 7199 7200 /* *** CONFIGURE QUEUE STATS COUNTER MAPPINGS *** */ 7201 struct cmd_set_qmap_result { 7202 cmdline_fixed_string_t set; 7203 cmdline_fixed_string_t qmap; 7204 cmdline_fixed_string_t what; 7205 portid_t port_id; 7206 uint16_t queue_id; 7207 uint8_t map_value; 7208 }; 7209 7210 static void 7211 cmd_set_qmap_parsed(void *parsed_result, 7212 __attribute__((unused)) struct cmdline *cl, 7213 __attribute__((unused)) void *data) 7214 { 7215 struct cmd_set_qmap_result *res = parsed_result; 7216 int is_rx = (strcmp(res->what, "tx") == 0) ? 0 : 1; 7217 7218 set_qmap(res->port_id, (uint8_t)is_rx, res->queue_id, res->map_value); 7219 } 7220 7221 cmdline_parse_token_string_t cmd_setqmap_set = 7222 TOKEN_STRING_INITIALIZER(struct cmd_set_qmap_result, 7223 set, "set"); 7224 cmdline_parse_token_string_t cmd_setqmap_qmap = 7225 TOKEN_STRING_INITIALIZER(struct cmd_set_qmap_result, 7226 qmap, "stat_qmap"); 7227 cmdline_parse_token_string_t cmd_setqmap_what = 7228 TOKEN_STRING_INITIALIZER(struct cmd_set_qmap_result, 7229 what, "tx#rx"); 7230 cmdline_parse_token_num_t cmd_setqmap_portid = 7231 TOKEN_NUM_INITIALIZER(struct cmd_set_qmap_result, 7232 port_id, UINT16); 7233 cmdline_parse_token_num_t cmd_setqmap_queueid = 7234 TOKEN_NUM_INITIALIZER(struct cmd_set_qmap_result, 7235 queue_id, UINT16); 7236 cmdline_parse_token_num_t cmd_setqmap_mapvalue = 7237 TOKEN_NUM_INITIALIZER(struct cmd_set_qmap_result, 7238 map_value, UINT8); 7239 7240 cmdline_parse_inst_t cmd_set_qmap = { 7241 .f = cmd_set_qmap_parsed, 7242 .data = NULL, 7243 .help_str = "set stat_qmap rx|tx <port_id> <queue_id> <map_value>: " 7244 "Set statistics mapping value on tx|rx queue_id of port_id", 7245 .tokens = { 7246 (void *)&cmd_setqmap_set, 7247 (void *)&cmd_setqmap_qmap, 7248 (void *)&cmd_setqmap_what, 7249 (void *)&cmd_setqmap_portid, 7250 (void *)&cmd_setqmap_queueid, 7251 (void *)&cmd_setqmap_mapvalue, 7252 NULL, 7253 }, 7254 }; 7255 7256 /* *** SET OPTION TO HIDE ZERO VALUES FOR XSTATS DISPLAY *** */ 7257 struct cmd_set_xstats_hide_zero_result { 7258 cmdline_fixed_string_t keyword; 7259 cmdline_fixed_string_t name; 7260 cmdline_fixed_string_t on_off; 7261 }; 7262 7263 static void 7264 cmd_set_xstats_hide_zero_parsed(void *parsed_result, 7265 __attribute__((unused)) struct cmdline *cl, 7266 __attribute__((unused)) void *data) 7267 { 7268 struct cmd_set_xstats_hide_zero_result *res; 7269 uint16_t on_off = 0; 7270 7271 res = parsed_result; 7272 on_off = !strcmp(res->on_off, "on") ? 1 : 0; 7273 set_xstats_hide_zero(on_off); 7274 } 7275 7276 cmdline_parse_token_string_t cmd_set_xstats_hide_zero_keyword = 7277 TOKEN_STRING_INITIALIZER(struct cmd_set_xstats_hide_zero_result, 7278 keyword, "set"); 7279 cmdline_parse_token_string_t cmd_set_xstats_hide_zero_name = 7280 TOKEN_STRING_INITIALIZER(struct cmd_set_xstats_hide_zero_result, 7281 name, "xstats-hide-zero"); 7282 cmdline_parse_token_string_t cmd_set_xstats_hide_zero_on_off = 7283 TOKEN_STRING_INITIALIZER(struct cmd_set_xstats_hide_zero_result, 7284 on_off, "on#off"); 7285 7286 cmdline_parse_inst_t cmd_set_xstats_hide_zero = { 7287 .f = cmd_set_xstats_hide_zero_parsed, 7288 .data = NULL, 7289 .help_str = "set xstats-hide-zero on|off", 7290 .tokens = { 7291 (void *)&cmd_set_xstats_hide_zero_keyword, 7292 (void *)&cmd_set_xstats_hide_zero_name, 7293 (void *)&cmd_set_xstats_hide_zero_on_off, 7294 NULL, 7295 }, 7296 }; 7297 7298 /* *** CONFIGURE UNICAST HASH TABLE *** */ 7299 struct cmd_set_uc_hash_table { 7300 cmdline_fixed_string_t set; 7301 cmdline_fixed_string_t port; 7302 portid_t port_id; 7303 cmdline_fixed_string_t what; 7304 struct ether_addr address; 7305 cmdline_fixed_string_t mode; 7306 }; 7307 7308 static void 7309 cmd_set_uc_hash_parsed(void *parsed_result, 7310 __attribute__((unused)) struct cmdline *cl, 7311 __attribute__((unused)) void *data) 7312 { 7313 int ret=0; 7314 struct cmd_set_uc_hash_table *res = parsed_result; 7315 7316 int is_on = (strcmp(res->mode, "on") == 0) ? 1 : 0; 7317 7318 if (strcmp(res->what, "uta") == 0) 7319 ret = rte_eth_dev_uc_hash_table_set(res->port_id, 7320 &res->address,(uint8_t)is_on); 7321 if (ret < 0) 7322 printf("bad unicast hash table parameter, return code = %d \n", ret); 7323 7324 } 7325 7326 cmdline_parse_token_string_t cmd_set_uc_hash_set = 7327 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_hash_table, 7328 set, "set"); 7329 cmdline_parse_token_string_t cmd_set_uc_hash_port = 7330 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_hash_table, 7331 port, "port"); 7332 cmdline_parse_token_num_t cmd_set_uc_hash_portid = 7333 TOKEN_NUM_INITIALIZER(struct cmd_set_uc_hash_table, 7334 port_id, UINT16); 7335 cmdline_parse_token_string_t cmd_set_uc_hash_what = 7336 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_hash_table, 7337 what, "uta"); 7338 cmdline_parse_token_etheraddr_t cmd_set_uc_hash_mac = 7339 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_uc_hash_table, 7340 address); 7341 cmdline_parse_token_string_t cmd_set_uc_hash_mode = 7342 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_hash_table, 7343 mode, "on#off"); 7344 7345 cmdline_parse_inst_t cmd_set_uc_hash_filter = { 7346 .f = cmd_set_uc_hash_parsed, 7347 .data = NULL, 7348 .help_str = "set port <port_id> uta <mac_addr> on|off)", 7349 .tokens = { 7350 (void *)&cmd_set_uc_hash_set, 7351 (void *)&cmd_set_uc_hash_port, 7352 (void *)&cmd_set_uc_hash_portid, 7353 (void *)&cmd_set_uc_hash_what, 7354 (void *)&cmd_set_uc_hash_mac, 7355 (void *)&cmd_set_uc_hash_mode, 7356 NULL, 7357 }, 7358 }; 7359 7360 struct cmd_set_uc_all_hash_table { 7361 cmdline_fixed_string_t set; 7362 cmdline_fixed_string_t port; 7363 portid_t port_id; 7364 cmdline_fixed_string_t what; 7365 cmdline_fixed_string_t value; 7366 cmdline_fixed_string_t mode; 7367 }; 7368 7369 static void 7370 cmd_set_uc_all_hash_parsed(void *parsed_result, 7371 __attribute__((unused)) struct cmdline *cl, 7372 __attribute__((unused)) void *data) 7373 { 7374 int ret=0; 7375 struct cmd_set_uc_all_hash_table *res = parsed_result; 7376 7377 int is_on = (strcmp(res->mode, "on") == 0) ? 1 : 0; 7378 7379 if ((strcmp(res->what, "uta") == 0) && 7380 (strcmp(res->value, "all") == 0)) 7381 ret = rte_eth_dev_uc_all_hash_table_set(res->port_id,(uint8_t) is_on); 7382 if (ret < 0) 7383 printf("bad unicast hash table parameter," 7384 "return code = %d \n", ret); 7385 } 7386 7387 cmdline_parse_token_string_t cmd_set_uc_all_hash_set = 7388 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_all_hash_table, 7389 set, "set"); 7390 cmdline_parse_token_string_t cmd_set_uc_all_hash_port = 7391 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_all_hash_table, 7392 port, "port"); 7393 cmdline_parse_token_num_t cmd_set_uc_all_hash_portid = 7394 TOKEN_NUM_INITIALIZER(struct cmd_set_uc_all_hash_table, 7395 port_id, UINT16); 7396 cmdline_parse_token_string_t cmd_set_uc_all_hash_what = 7397 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_all_hash_table, 7398 what, "uta"); 7399 cmdline_parse_token_string_t cmd_set_uc_all_hash_value = 7400 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_all_hash_table, 7401 value,"all"); 7402 cmdline_parse_token_string_t cmd_set_uc_all_hash_mode = 7403 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_all_hash_table, 7404 mode, "on#off"); 7405 7406 cmdline_parse_inst_t cmd_set_uc_all_hash_filter = { 7407 .f = cmd_set_uc_all_hash_parsed, 7408 .data = NULL, 7409 .help_str = "set port <port_id> uta all on|off", 7410 .tokens = { 7411 (void *)&cmd_set_uc_all_hash_set, 7412 (void *)&cmd_set_uc_all_hash_port, 7413 (void *)&cmd_set_uc_all_hash_portid, 7414 (void *)&cmd_set_uc_all_hash_what, 7415 (void *)&cmd_set_uc_all_hash_value, 7416 (void *)&cmd_set_uc_all_hash_mode, 7417 NULL, 7418 }, 7419 }; 7420 7421 /* *** CONFIGURE MACVLAN FILTER FOR VF(s) *** */ 7422 struct cmd_set_vf_macvlan_filter { 7423 cmdline_fixed_string_t set; 7424 cmdline_fixed_string_t port; 7425 portid_t port_id; 7426 cmdline_fixed_string_t vf; 7427 uint8_t vf_id; 7428 struct ether_addr address; 7429 cmdline_fixed_string_t filter_type; 7430 cmdline_fixed_string_t mode; 7431 }; 7432 7433 static void 7434 cmd_set_vf_macvlan_parsed(void *parsed_result, 7435 __attribute__((unused)) struct cmdline *cl, 7436 __attribute__((unused)) void *data) 7437 { 7438 int is_on, ret = 0; 7439 struct cmd_set_vf_macvlan_filter *res = parsed_result; 7440 struct rte_eth_mac_filter filter; 7441 7442 memset(&filter, 0, sizeof(struct rte_eth_mac_filter)); 7443 7444 rte_memcpy(&filter.mac_addr, &res->address, ETHER_ADDR_LEN); 7445 7446 /* set VF MAC filter */ 7447 filter.is_vf = 1; 7448 7449 /* set VF ID */ 7450 filter.dst_id = res->vf_id; 7451 7452 if (!strcmp(res->filter_type, "exact-mac")) 7453 filter.filter_type = RTE_MAC_PERFECT_MATCH; 7454 else if (!strcmp(res->filter_type, "exact-mac-vlan")) 7455 filter.filter_type = RTE_MACVLAN_PERFECT_MATCH; 7456 else if (!strcmp(res->filter_type, "hashmac")) 7457 filter.filter_type = RTE_MAC_HASH_MATCH; 7458 else if (!strcmp(res->filter_type, "hashmac-vlan")) 7459 filter.filter_type = RTE_MACVLAN_HASH_MATCH; 7460 7461 is_on = (strcmp(res->mode, "on") == 0) ? 1 : 0; 7462 7463 if (is_on) 7464 ret = rte_eth_dev_filter_ctrl(res->port_id, 7465 RTE_ETH_FILTER_MACVLAN, 7466 RTE_ETH_FILTER_ADD, 7467 &filter); 7468 else 7469 ret = rte_eth_dev_filter_ctrl(res->port_id, 7470 RTE_ETH_FILTER_MACVLAN, 7471 RTE_ETH_FILTER_DELETE, 7472 &filter); 7473 7474 if (ret < 0) 7475 printf("bad set MAC hash parameter, return code = %d\n", ret); 7476 7477 } 7478 7479 cmdline_parse_token_string_t cmd_set_vf_macvlan_set = 7480 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_macvlan_filter, 7481 set, "set"); 7482 cmdline_parse_token_string_t cmd_set_vf_macvlan_port = 7483 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_macvlan_filter, 7484 port, "port"); 7485 cmdline_parse_token_num_t cmd_set_vf_macvlan_portid = 7486 TOKEN_NUM_INITIALIZER(struct cmd_set_vf_macvlan_filter, 7487 port_id, UINT16); 7488 cmdline_parse_token_string_t cmd_set_vf_macvlan_vf = 7489 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_macvlan_filter, 7490 vf, "vf"); 7491 cmdline_parse_token_num_t cmd_set_vf_macvlan_vf_id = 7492 TOKEN_NUM_INITIALIZER(struct cmd_set_vf_macvlan_filter, 7493 vf_id, UINT8); 7494 cmdline_parse_token_etheraddr_t cmd_set_vf_macvlan_mac = 7495 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_vf_macvlan_filter, 7496 address); 7497 cmdline_parse_token_string_t cmd_set_vf_macvlan_filter_type = 7498 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_macvlan_filter, 7499 filter_type, "exact-mac#exact-mac-vlan" 7500 "#hashmac#hashmac-vlan"); 7501 cmdline_parse_token_string_t cmd_set_vf_macvlan_mode = 7502 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_macvlan_filter, 7503 mode, "on#off"); 7504 7505 cmdline_parse_inst_t cmd_set_vf_macvlan_filter = { 7506 .f = cmd_set_vf_macvlan_parsed, 7507 .data = NULL, 7508 .help_str = "set port <port_id> vf <vf_id> <mac_addr> " 7509 "exact-mac|exact-mac-vlan|hashmac|hashmac-vlan on|off: " 7510 "Exact match rule: exact match of MAC or MAC and VLAN; " 7511 "hash match rule: hash match of MAC and exact match of VLAN", 7512 .tokens = { 7513 (void *)&cmd_set_vf_macvlan_set, 7514 (void *)&cmd_set_vf_macvlan_port, 7515 (void *)&cmd_set_vf_macvlan_portid, 7516 (void *)&cmd_set_vf_macvlan_vf, 7517 (void *)&cmd_set_vf_macvlan_vf_id, 7518 (void *)&cmd_set_vf_macvlan_mac, 7519 (void *)&cmd_set_vf_macvlan_filter_type, 7520 (void *)&cmd_set_vf_macvlan_mode, 7521 NULL, 7522 }, 7523 }; 7524 7525 /* *** CONFIGURE VF TRAFFIC CONTROL *** */ 7526 struct cmd_set_vf_traffic { 7527 cmdline_fixed_string_t set; 7528 cmdline_fixed_string_t port; 7529 portid_t port_id; 7530 cmdline_fixed_string_t vf; 7531 uint8_t vf_id; 7532 cmdline_fixed_string_t what; 7533 cmdline_fixed_string_t mode; 7534 }; 7535 7536 static void 7537 cmd_set_vf_traffic_parsed(void *parsed_result, 7538 __attribute__((unused)) struct cmdline *cl, 7539 __attribute__((unused)) void *data) 7540 { 7541 struct cmd_set_vf_traffic *res = parsed_result; 7542 int is_rx = (strcmp(res->what, "rx") == 0) ? 1 : 0; 7543 int is_on = (strcmp(res->mode, "on") == 0) ? 1 : 0; 7544 7545 set_vf_traffic(res->port_id, (uint8_t)is_rx, res->vf_id,(uint8_t) is_on); 7546 } 7547 7548 cmdline_parse_token_string_t cmd_setvf_traffic_set = 7549 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_traffic, 7550 set, "set"); 7551 cmdline_parse_token_string_t cmd_setvf_traffic_port = 7552 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_traffic, 7553 port, "port"); 7554 cmdline_parse_token_num_t cmd_setvf_traffic_portid = 7555 TOKEN_NUM_INITIALIZER(struct cmd_set_vf_traffic, 7556 port_id, UINT16); 7557 cmdline_parse_token_string_t cmd_setvf_traffic_vf = 7558 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_traffic, 7559 vf, "vf"); 7560 cmdline_parse_token_num_t cmd_setvf_traffic_vfid = 7561 TOKEN_NUM_INITIALIZER(struct cmd_set_vf_traffic, 7562 vf_id, UINT8); 7563 cmdline_parse_token_string_t cmd_setvf_traffic_what = 7564 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_traffic, 7565 what, "tx#rx"); 7566 cmdline_parse_token_string_t cmd_setvf_traffic_mode = 7567 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_traffic, 7568 mode, "on#off"); 7569 7570 cmdline_parse_inst_t cmd_set_vf_traffic = { 7571 .f = cmd_set_vf_traffic_parsed, 7572 .data = NULL, 7573 .help_str = "set port <port_id> vf <vf_id> rx|tx on|off", 7574 .tokens = { 7575 (void *)&cmd_setvf_traffic_set, 7576 (void *)&cmd_setvf_traffic_port, 7577 (void *)&cmd_setvf_traffic_portid, 7578 (void *)&cmd_setvf_traffic_vf, 7579 (void *)&cmd_setvf_traffic_vfid, 7580 (void *)&cmd_setvf_traffic_what, 7581 (void *)&cmd_setvf_traffic_mode, 7582 NULL, 7583 }, 7584 }; 7585 7586 /* *** CONFIGURE VF RECEIVE MODE *** */ 7587 struct cmd_set_vf_rxmode { 7588 cmdline_fixed_string_t set; 7589 cmdline_fixed_string_t port; 7590 portid_t port_id; 7591 cmdline_fixed_string_t vf; 7592 uint8_t vf_id; 7593 cmdline_fixed_string_t what; 7594 cmdline_fixed_string_t mode; 7595 cmdline_fixed_string_t on; 7596 }; 7597 7598 static void 7599 cmd_set_vf_rxmode_parsed(void *parsed_result, 7600 __attribute__((unused)) struct cmdline *cl, 7601 __attribute__((unused)) void *data) 7602 { 7603 int ret = -ENOTSUP; 7604 uint16_t rx_mode = 0; 7605 struct cmd_set_vf_rxmode *res = parsed_result; 7606 7607 int is_on = (strcmp(res->on, "on") == 0) ? 1 : 0; 7608 if (!strcmp(res->what,"rxmode")) { 7609 if (!strcmp(res->mode, "AUPE")) 7610 rx_mode |= ETH_VMDQ_ACCEPT_UNTAG; 7611 else if (!strcmp(res->mode, "ROPE")) 7612 rx_mode |= ETH_VMDQ_ACCEPT_HASH_UC; 7613 else if (!strcmp(res->mode, "BAM")) 7614 rx_mode |= ETH_VMDQ_ACCEPT_BROADCAST; 7615 else if (!strncmp(res->mode, "MPE",3)) 7616 rx_mode |= ETH_VMDQ_ACCEPT_MULTICAST; 7617 } 7618 7619 RTE_SET_USED(is_on); 7620 7621 #ifdef RTE_LIBRTE_IXGBE_PMD 7622 if (ret == -ENOTSUP) 7623 ret = rte_pmd_ixgbe_set_vf_rxmode(res->port_id, res->vf_id, 7624 rx_mode, (uint8_t)is_on); 7625 #endif 7626 #ifdef RTE_LIBRTE_BNXT_PMD 7627 if (ret == -ENOTSUP) 7628 ret = rte_pmd_bnxt_set_vf_rxmode(res->port_id, res->vf_id, 7629 rx_mode, (uint8_t)is_on); 7630 #endif 7631 if (ret < 0) 7632 printf("bad VF receive mode parameter, return code = %d \n", 7633 ret); 7634 } 7635 7636 cmdline_parse_token_string_t cmd_set_vf_rxmode_set = 7637 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_rxmode, 7638 set, "set"); 7639 cmdline_parse_token_string_t cmd_set_vf_rxmode_port = 7640 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_rxmode, 7641 port, "port"); 7642 cmdline_parse_token_num_t cmd_set_vf_rxmode_portid = 7643 TOKEN_NUM_INITIALIZER(struct cmd_set_vf_rxmode, 7644 port_id, UINT16); 7645 cmdline_parse_token_string_t cmd_set_vf_rxmode_vf = 7646 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_rxmode, 7647 vf, "vf"); 7648 cmdline_parse_token_num_t cmd_set_vf_rxmode_vfid = 7649 TOKEN_NUM_INITIALIZER(struct cmd_set_vf_rxmode, 7650 vf_id, UINT8); 7651 cmdline_parse_token_string_t cmd_set_vf_rxmode_what = 7652 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_rxmode, 7653 what, "rxmode"); 7654 cmdline_parse_token_string_t cmd_set_vf_rxmode_mode = 7655 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_rxmode, 7656 mode, "AUPE#ROPE#BAM#MPE"); 7657 cmdline_parse_token_string_t cmd_set_vf_rxmode_on = 7658 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_rxmode, 7659 on, "on#off"); 7660 7661 cmdline_parse_inst_t cmd_set_vf_rxmode = { 7662 .f = cmd_set_vf_rxmode_parsed, 7663 .data = NULL, 7664 .help_str = "set port <port_id> vf <vf_id> rxmode " 7665 "AUPE|ROPE|BAM|MPE on|off", 7666 .tokens = { 7667 (void *)&cmd_set_vf_rxmode_set, 7668 (void *)&cmd_set_vf_rxmode_port, 7669 (void *)&cmd_set_vf_rxmode_portid, 7670 (void *)&cmd_set_vf_rxmode_vf, 7671 (void *)&cmd_set_vf_rxmode_vfid, 7672 (void *)&cmd_set_vf_rxmode_what, 7673 (void *)&cmd_set_vf_rxmode_mode, 7674 (void *)&cmd_set_vf_rxmode_on, 7675 NULL, 7676 }, 7677 }; 7678 7679 /* *** ADD MAC ADDRESS FILTER FOR A VF OF A PORT *** */ 7680 struct cmd_vf_mac_addr_result { 7681 cmdline_fixed_string_t mac_addr_cmd; 7682 cmdline_fixed_string_t what; 7683 cmdline_fixed_string_t port; 7684 uint16_t port_num; 7685 cmdline_fixed_string_t vf; 7686 uint8_t vf_num; 7687 struct ether_addr address; 7688 }; 7689 7690 static void cmd_vf_mac_addr_parsed(void *parsed_result, 7691 __attribute__((unused)) struct cmdline *cl, 7692 __attribute__((unused)) void *data) 7693 { 7694 struct cmd_vf_mac_addr_result *res = parsed_result; 7695 int ret = -ENOTSUP; 7696 7697 if (strcmp(res->what, "add") != 0) 7698 return; 7699 7700 #ifdef RTE_LIBRTE_I40E_PMD 7701 if (ret == -ENOTSUP) 7702 ret = rte_pmd_i40e_add_vf_mac_addr(res->port_num, res->vf_num, 7703 &res->address); 7704 #endif 7705 #ifdef RTE_LIBRTE_BNXT_PMD 7706 if (ret == -ENOTSUP) 7707 ret = rte_pmd_bnxt_mac_addr_add(res->port_num, &res->address, 7708 res->vf_num); 7709 #endif 7710 7711 if(ret < 0) 7712 printf("vf_mac_addr_cmd error: (%s)\n", strerror(-ret)); 7713 7714 } 7715 7716 cmdline_parse_token_string_t cmd_vf_mac_addr_cmd = 7717 TOKEN_STRING_INITIALIZER(struct cmd_vf_mac_addr_result, 7718 mac_addr_cmd,"mac_addr"); 7719 cmdline_parse_token_string_t cmd_vf_mac_addr_what = 7720 TOKEN_STRING_INITIALIZER(struct cmd_vf_mac_addr_result, 7721 what,"add"); 7722 cmdline_parse_token_string_t cmd_vf_mac_addr_port = 7723 TOKEN_STRING_INITIALIZER(struct cmd_vf_mac_addr_result, 7724 port,"port"); 7725 cmdline_parse_token_num_t cmd_vf_mac_addr_portnum = 7726 TOKEN_NUM_INITIALIZER(struct cmd_vf_mac_addr_result, 7727 port_num, UINT16); 7728 cmdline_parse_token_string_t cmd_vf_mac_addr_vf = 7729 TOKEN_STRING_INITIALIZER(struct cmd_vf_mac_addr_result, 7730 vf,"vf"); 7731 cmdline_parse_token_num_t cmd_vf_mac_addr_vfnum = 7732 TOKEN_NUM_INITIALIZER(struct cmd_vf_mac_addr_result, 7733 vf_num, UINT8); 7734 cmdline_parse_token_etheraddr_t cmd_vf_mac_addr_addr = 7735 TOKEN_ETHERADDR_INITIALIZER(struct cmd_vf_mac_addr_result, 7736 address); 7737 7738 cmdline_parse_inst_t cmd_vf_mac_addr_filter = { 7739 .f = cmd_vf_mac_addr_parsed, 7740 .data = (void *)0, 7741 .help_str = "mac_addr add port <port_id> vf <vf_id> <mac_addr>: " 7742 "Add MAC address filtering for a VF on port_id", 7743 .tokens = { 7744 (void *)&cmd_vf_mac_addr_cmd, 7745 (void *)&cmd_vf_mac_addr_what, 7746 (void *)&cmd_vf_mac_addr_port, 7747 (void *)&cmd_vf_mac_addr_portnum, 7748 (void *)&cmd_vf_mac_addr_vf, 7749 (void *)&cmd_vf_mac_addr_vfnum, 7750 (void *)&cmd_vf_mac_addr_addr, 7751 NULL, 7752 }, 7753 }; 7754 7755 /* *** ADD/REMOVE A VLAN IDENTIFIER TO/FROM A PORT VLAN RX FILTER *** */ 7756 struct cmd_vf_rx_vlan_filter { 7757 cmdline_fixed_string_t rx_vlan; 7758 cmdline_fixed_string_t what; 7759 uint16_t vlan_id; 7760 cmdline_fixed_string_t port; 7761 portid_t port_id; 7762 cmdline_fixed_string_t vf; 7763 uint64_t vf_mask; 7764 }; 7765 7766 static void 7767 cmd_vf_rx_vlan_filter_parsed(void *parsed_result, 7768 __attribute__((unused)) struct cmdline *cl, 7769 __attribute__((unused)) void *data) 7770 { 7771 struct cmd_vf_rx_vlan_filter *res = parsed_result; 7772 int ret = -ENOTSUP; 7773 7774 __rte_unused int is_add = (strcmp(res->what, "add") == 0) ? 1 : 0; 7775 7776 #ifdef RTE_LIBRTE_IXGBE_PMD 7777 if (ret == -ENOTSUP) 7778 ret = rte_pmd_ixgbe_set_vf_vlan_filter(res->port_id, 7779 res->vlan_id, res->vf_mask, is_add); 7780 #endif 7781 #ifdef RTE_LIBRTE_I40E_PMD 7782 if (ret == -ENOTSUP) 7783 ret = rte_pmd_i40e_set_vf_vlan_filter(res->port_id, 7784 res->vlan_id, res->vf_mask, is_add); 7785 #endif 7786 #ifdef RTE_LIBRTE_BNXT_PMD 7787 if (ret == -ENOTSUP) 7788 ret = rte_pmd_bnxt_set_vf_vlan_filter(res->port_id, 7789 res->vlan_id, res->vf_mask, is_add); 7790 #endif 7791 7792 switch (ret) { 7793 case 0: 7794 break; 7795 case -EINVAL: 7796 printf("invalid vlan_id %d or vf_mask %"PRIu64"\n", 7797 res->vlan_id, res->vf_mask); 7798 break; 7799 case -ENODEV: 7800 printf("invalid port_id %d\n", res->port_id); 7801 break; 7802 case -ENOTSUP: 7803 printf("function not implemented or supported\n"); 7804 break; 7805 default: 7806 printf("programming error: (%s)\n", strerror(-ret)); 7807 } 7808 } 7809 7810 cmdline_parse_token_string_t cmd_vf_rx_vlan_filter_rx_vlan = 7811 TOKEN_STRING_INITIALIZER(struct cmd_vf_rx_vlan_filter, 7812 rx_vlan, "rx_vlan"); 7813 cmdline_parse_token_string_t cmd_vf_rx_vlan_filter_what = 7814 TOKEN_STRING_INITIALIZER(struct cmd_vf_rx_vlan_filter, 7815 what, "add#rm"); 7816 cmdline_parse_token_num_t cmd_vf_rx_vlan_filter_vlanid = 7817 TOKEN_NUM_INITIALIZER(struct cmd_vf_rx_vlan_filter, 7818 vlan_id, UINT16); 7819 cmdline_parse_token_string_t cmd_vf_rx_vlan_filter_port = 7820 TOKEN_STRING_INITIALIZER(struct cmd_vf_rx_vlan_filter, 7821 port, "port"); 7822 cmdline_parse_token_num_t cmd_vf_rx_vlan_filter_portid = 7823 TOKEN_NUM_INITIALIZER(struct cmd_vf_rx_vlan_filter, 7824 port_id, UINT16); 7825 cmdline_parse_token_string_t cmd_vf_rx_vlan_filter_vf = 7826 TOKEN_STRING_INITIALIZER(struct cmd_vf_rx_vlan_filter, 7827 vf, "vf"); 7828 cmdline_parse_token_num_t cmd_vf_rx_vlan_filter_vf_mask = 7829 TOKEN_NUM_INITIALIZER(struct cmd_vf_rx_vlan_filter, 7830 vf_mask, UINT64); 7831 7832 cmdline_parse_inst_t cmd_vf_rxvlan_filter = { 7833 .f = cmd_vf_rx_vlan_filter_parsed, 7834 .data = NULL, 7835 .help_str = "rx_vlan add|rm <vlan_id> port <port_id> vf <vf_mask>: " 7836 "(vf_mask = hexadecimal VF mask)", 7837 .tokens = { 7838 (void *)&cmd_vf_rx_vlan_filter_rx_vlan, 7839 (void *)&cmd_vf_rx_vlan_filter_what, 7840 (void *)&cmd_vf_rx_vlan_filter_vlanid, 7841 (void *)&cmd_vf_rx_vlan_filter_port, 7842 (void *)&cmd_vf_rx_vlan_filter_portid, 7843 (void *)&cmd_vf_rx_vlan_filter_vf, 7844 (void *)&cmd_vf_rx_vlan_filter_vf_mask, 7845 NULL, 7846 }, 7847 }; 7848 7849 /* *** SET RATE LIMIT FOR A QUEUE OF A PORT *** */ 7850 struct cmd_queue_rate_limit_result { 7851 cmdline_fixed_string_t set; 7852 cmdline_fixed_string_t port; 7853 uint16_t port_num; 7854 cmdline_fixed_string_t queue; 7855 uint8_t queue_num; 7856 cmdline_fixed_string_t rate; 7857 uint16_t rate_num; 7858 }; 7859 7860 static void cmd_queue_rate_limit_parsed(void *parsed_result, 7861 __attribute__((unused)) struct cmdline *cl, 7862 __attribute__((unused)) void *data) 7863 { 7864 struct cmd_queue_rate_limit_result *res = parsed_result; 7865 int ret = 0; 7866 7867 if ((strcmp(res->set, "set") == 0) && (strcmp(res->port, "port") == 0) 7868 && (strcmp(res->queue, "queue") == 0) 7869 && (strcmp(res->rate, "rate") == 0)) 7870 ret = set_queue_rate_limit(res->port_num, res->queue_num, 7871 res->rate_num); 7872 if (ret < 0) 7873 printf("queue_rate_limit_cmd error: (%s)\n", strerror(-ret)); 7874 7875 } 7876 7877 cmdline_parse_token_string_t cmd_queue_rate_limit_set = 7878 TOKEN_STRING_INITIALIZER(struct cmd_queue_rate_limit_result, 7879 set, "set"); 7880 cmdline_parse_token_string_t cmd_queue_rate_limit_port = 7881 TOKEN_STRING_INITIALIZER(struct cmd_queue_rate_limit_result, 7882 port, "port"); 7883 cmdline_parse_token_num_t cmd_queue_rate_limit_portnum = 7884 TOKEN_NUM_INITIALIZER(struct cmd_queue_rate_limit_result, 7885 port_num, UINT16); 7886 cmdline_parse_token_string_t cmd_queue_rate_limit_queue = 7887 TOKEN_STRING_INITIALIZER(struct cmd_queue_rate_limit_result, 7888 queue, "queue"); 7889 cmdline_parse_token_num_t cmd_queue_rate_limit_queuenum = 7890 TOKEN_NUM_INITIALIZER(struct cmd_queue_rate_limit_result, 7891 queue_num, UINT8); 7892 cmdline_parse_token_string_t cmd_queue_rate_limit_rate = 7893 TOKEN_STRING_INITIALIZER(struct cmd_queue_rate_limit_result, 7894 rate, "rate"); 7895 cmdline_parse_token_num_t cmd_queue_rate_limit_ratenum = 7896 TOKEN_NUM_INITIALIZER(struct cmd_queue_rate_limit_result, 7897 rate_num, UINT16); 7898 7899 cmdline_parse_inst_t cmd_queue_rate_limit = { 7900 .f = cmd_queue_rate_limit_parsed, 7901 .data = (void *)0, 7902 .help_str = "set port <port_id> queue <queue_id> rate <rate_value>: " 7903 "Set rate limit for a queue on port_id", 7904 .tokens = { 7905 (void *)&cmd_queue_rate_limit_set, 7906 (void *)&cmd_queue_rate_limit_port, 7907 (void *)&cmd_queue_rate_limit_portnum, 7908 (void *)&cmd_queue_rate_limit_queue, 7909 (void *)&cmd_queue_rate_limit_queuenum, 7910 (void *)&cmd_queue_rate_limit_rate, 7911 (void *)&cmd_queue_rate_limit_ratenum, 7912 NULL, 7913 }, 7914 }; 7915 7916 /* *** SET RATE LIMIT FOR A VF OF A PORT *** */ 7917 struct cmd_vf_rate_limit_result { 7918 cmdline_fixed_string_t set; 7919 cmdline_fixed_string_t port; 7920 uint16_t port_num; 7921 cmdline_fixed_string_t vf; 7922 uint8_t vf_num; 7923 cmdline_fixed_string_t rate; 7924 uint16_t rate_num; 7925 cmdline_fixed_string_t q_msk; 7926 uint64_t q_msk_val; 7927 }; 7928 7929 static void cmd_vf_rate_limit_parsed(void *parsed_result, 7930 __attribute__((unused)) struct cmdline *cl, 7931 __attribute__((unused)) void *data) 7932 { 7933 struct cmd_vf_rate_limit_result *res = parsed_result; 7934 int ret = 0; 7935 7936 if ((strcmp(res->set, "set") == 0) && (strcmp(res->port, "port") == 0) 7937 && (strcmp(res->vf, "vf") == 0) 7938 && (strcmp(res->rate, "rate") == 0) 7939 && (strcmp(res->q_msk, "queue_mask") == 0)) 7940 ret = set_vf_rate_limit(res->port_num, res->vf_num, 7941 res->rate_num, res->q_msk_val); 7942 if (ret < 0) 7943 printf("vf_rate_limit_cmd error: (%s)\n", strerror(-ret)); 7944 7945 } 7946 7947 cmdline_parse_token_string_t cmd_vf_rate_limit_set = 7948 TOKEN_STRING_INITIALIZER(struct cmd_vf_rate_limit_result, 7949 set, "set"); 7950 cmdline_parse_token_string_t cmd_vf_rate_limit_port = 7951 TOKEN_STRING_INITIALIZER(struct cmd_vf_rate_limit_result, 7952 port, "port"); 7953 cmdline_parse_token_num_t cmd_vf_rate_limit_portnum = 7954 TOKEN_NUM_INITIALIZER(struct cmd_vf_rate_limit_result, 7955 port_num, UINT16); 7956 cmdline_parse_token_string_t cmd_vf_rate_limit_vf = 7957 TOKEN_STRING_INITIALIZER(struct cmd_vf_rate_limit_result, 7958 vf, "vf"); 7959 cmdline_parse_token_num_t cmd_vf_rate_limit_vfnum = 7960 TOKEN_NUM_INITIALIZER(struct cmd_vf_rate_limit_result, 7961 vf_num, UINT8); 7962 cmdline_parse_token_string_t cmd_vf_rate_limit_rate = 7963 TOKEN_STRING_INITIALIZER(struct cmd_vf_rate_limit_result, 7964 rate, "rate"); 7965 cmdline_parse_token_num_t cmd_vf_rate_limit_ratenum = 7966 TOKEN_NUM_INITIALIZER(struct cmd_vf_rate_limit_result, 7967 rate_num, UINT16); 7968 cmdline_parse_token_string_t cmd_vf_rate_limit_q_msk = 7969 TOKEN_STRING_INITIALIZER(struct cmd_vf_rate_limit_result, 7970 q_msk, "queue_mask"); 7971 cmdline_parse_token_num_t cmd_vf_rate_limit_q_msk_val = 7972 TOKEN_NUM_INITIALIZER(struct cmd_vf_rate_limit_result, 7973 q_msk_val, UINT64); 7974 7975 cmdline_parse_inst_t cmd_vf_rate_limit = { 7976 .f = cmd_vf_rate_limit_parsed, 7977 .data = (void *)0, 7978 .help_str = "set port <port_id> vf <vf_id> rate <rate_value> " 7979 "queue_mask <queue_mask_value>: " 7980 "Set rate limit for queues of VF on port_id", 7981 .tokens = { 7982 (void *)&cmd_vf_rate_limit_set, 7983 (void *)&cmd_vf_rate_limit_port, 7984 (void *)&cmd_vf_rate_limit_portnum, 7985 (void *)&cmd_vf_rate_limit_vf, 7986 (void *)&cmd_vf_rate_limit_vfnum, 7987 (void *)&cmd_vf_rate_limit_rate, 7988 (void *)&cmd_vf_rate_limit_ratenum, 7989 (void *)&cmd_vf_rate_limit_q_msk, 7990 (void *)&cmd_vf_rate_limit_q_msk_val, 7991 NULL, 7992 }, 7993 }; 7994 7995 /* *** ADD TUNNEL FILTER OF A PORT *** */ 7996 struct cmd_tunnel_filter_result { 7997 cmdline_fixed_string_t cmd; 7998 cmdline_fixed_string_t what; 7999 portid_t port_id; 8000 struct ether_addr outer_mac; 8001 struct ether_addr inner_mac; 8002 cmdline_ipaddr_t ip_value; 8003 uint16_t inner_vlan; 8004 cmdline_fixed_string_t tunnel_type; 8005 cmdline_fixed_string_t filter_type; 8006 uint32_t tenant_id; 8007 uint16_t queue_num; 8008 }; 8009 8010 static void 8011 cmd_tunnel_filter_parsed(void *parsed_result, 8012 __attribute__((unused)) struct cmdline *cl, 8013 __attribute__((unused)) void *data) 8014 { 8015 struct cmd_tunnel_filter_result *res = parsed_result; 8016 struct rte_eth_tunnel_filter_conf tunnel_filter_conf; 8017 int ret = 0; 8018 8019 memset(&tunnel_filter_conf, 0, sizeof(tunnel_filter_conf)); 8020 8021 ether_addr_copy(&res->outer_mac, &tunnel_filter_conf.outer_mac); 8022 ether_addr_copy(&res->inner_mac, &tunnel_filter_conf.inner_mac); 8023 tunnel_filter_conf.inner_vlan = res->inner_vlan; 8024 8025 if (res->ip_value.family == AF_INET) { 8026 tunnel_filter_conf.ip_addr.ipv4_addr = 8027 res->ip_value.addr.ipv4.s_addr; 8028 tunnel_filter_conf.ip_type = RTE_TUNNEL_IPTYPE_IPV4; 8029 } else { 8030 memcpy(&(tunnel_filter_conf.ip_addr.ipv6_addr), 8031 &(res->ip_value.addr.ipv6), 8032 sizeof(struct in6_addr)); 8033 tunnel_filter_conf.ip_type = RTE_TUNNEL_IPTYPE_IPV6; 8034 } 8035 8036 if (!strcmp(res->filter_type, "imac-ivlan")) 8037 tunnel_filter_conf.filter_type = RTE_TUNNEL_FILTER_IMAC_IVLAN; 8038 else if (!strcmp(res->filter_type, "imac-ivlan-tenid")) 8039 tunnel_filter_conf.filter_type = 8040 RTE_TUNNEL_FILTER_IMAC_IVLAN_TENID; 8041 else if (!strcmp(res->filter_type, "imac-tenid")) 8042 tunnel_filter_conf.filter_type = RTE_TUNNEL_FILTER_IMAC_TENID; 8043 else if (!strcmp(res->filter_type, "imac")) 8044 tunnel_filter_conf.filter_type = ETH_TUNNEL_FILTER_IMAC; 8045 else if (!strcmp(res->filter_type, "omac-imac-tenid")) 8046 tunnel_filter_conf.filter_type = 8047 RTE_TUNNEL_FILTER_OMAC_TENID_IMAC; 8048 else if (!strcmp(res->filter_type, "oip")) 8049 tunnel_filter_conf.filter_type = ETH_TUNNEL_FILTER_OIP; 8050 else if (!strcmp(res->filter_type, "iip")) 8051 tunnel_filter_conf.filter_type = ETH_TUNNEL_FILTER_IIP; 8052 else { 8053 printf("The filter type is not supported"); 8054 return; 8055 } 8056 8057 if (!strcmp(res->tunnel_type, "vxlan")) 8058 tunnel_filter_conf.tunnel_type = RTE_TUNNEL_TYPE_VXLAN; 8059 else if (!strcmp(res->tunnel_type, "nvgre")) 8060 tunnel_filter_conf.tunnel_type = RTE_TUNNEL_TYPE_NVGRE; 8061 else if (!strcmp(res->tunnel_type, "ipingre")) 8062 tunnel_filter_conf.tunnel_type = RTE_TUNNEL_TYPE_IP_IN_GRE; 8063 else { 8064 printf("The tunnel type %s not supported.\n", res->tunnel_type); 8065 return; 8066 } 8067 8068 tunnel_filter_conf.tenant_id = res->tenant_id; 8069 tunnel_filter_conf.queue_id = res->queue_num; 8070 if (!strcmp(res->what, "add")) 8071 ret = rte_eth_dev_filter_ctrl(res->port_id, 8072 RTE_ETH_FILTER_TUNNEL, 8073 RTE_ETH_FILTER_ADD, 8074 &tunnel_filter_conf); 8075 else 8076 ret = rte_eth_dev_filter_ctrl(res->port_id, 8077 RTE_ETH_FILTER_TUNNEL, 8078 RTE_ETH_FILTER_DELETE, 8079 &tunnel_filter_conf); 8080 if (ret < 0) 8081 printf("cmd_tunnel_filter_parsed error: (%s)\n", 8082 strerror(-ret)); 8083 8084 } 8085 cmdline_parse_token_string_t cmd_tunnel_filter_cmd = 8086 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_filter_result, 8087 cmd, "tunnel_filter"); 8088 cmdline_parse_token_string_t cmd_tunnel_filter_what = 8089 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_filter_result, 8090 what, "add#rm"); 8091 cmdline_parse_token_num_t cmd_tunnel_filter_port_id = 8092 TOKEN_NUM_INITIALIZER(struct cmd_tunnel_filter_result, 8093 port_id, UINT16); 8094 cmdline_parse_token_etheraddr_t cmd_tunnel_filter_outer_mac = 8095 TOKEN_ETHERADDR_INITIALIZER(struct cmd_tunnel_filter_result, 8096 outer_mac); 8097 cmdline_parse_token_etheraddr_t cmd_tunnel_filter_inner_mac = 8098 TOKEN_ETHERADDR_INITIALIZER(struct cmd_tunnel_filter_result, 8099 inner_mac); 8100 cmdline_parse_token_num_t cmd_tunnel_filter_innner_vlan = 8101 TOKEN_NUM_INITIALIZER(struct cmd_tunnel_filter_result, 8102 inner_vlan, UINT16); 8103 cmdline_parse_token_ipaddr_t cmd_tunnel_filter_ip_value = 8104 TOKEN_IPADDR_INITIALIZER(struct cmd_tunnel_filter_result, 8105 ip_value); 8106 cmdline_parse_token_string_t cmd_tunnel_filter_tunnel_type = 8107 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_filter_result, 8108 tunnel_type, "vxlan#nvgre#ipingre"); 8109 8110 cmdline_parse_token_string_t cmd_tunnel_filter_filter_type = 8111 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_filter_result, 8112 filter_type, "oip#iip#imac-ivlan#imac-ivlan-tenid#imac-tenid#" 8113 "imac#omac-imac-tenid"); 8114 cmdline_parse_token_num_t cmd_tunnel_filter_tenant_id = 8115 TOKEN_NUM_INITIALIZER(struct cmd_tunnel_filter_result, 8116 tenant_id, UINT32); 8117 cmdline_parse_token_num_t cmd_tunnel_filter_queue_num = 8118 TOKEN_NUM_INITIALIZER(struct cmd_tunnel_filter_result, 8119 queue_num, UINT16); 8120 8121 cmdline_parse_inst_t cmd_tunnel_filter = { 8122 .f = cmd_tunnel_filter_parsed, 8123 .data = (void *)0, 8124 .help_str = "tunnel_filter add|rm <port_id> <outer_mac> <inner_mac> " 8125 "<ip> <inner_vlan> vxlan|nvgre|ipingre oip|iip|imac-ivlan|" 8126 "imac-ivlan-tenid|imac-tenid|imac|omac-imac-tenid <tenant_id> " 8127 "<queue_id>: Add/Rm tunnel filter of a port", 8128 .tokens = { 8129 (void *)&cmd_tunnel_filter_cmd, 8130 (void *)&cmd_tunnel_filter_what, 8131 (void *)&cmd_tunnel_filter_port_id, 8132 (void *)&cmd_tunnel_filter_outer_mac, 8133 (void *)&cmd_tunnel_filter_inner_mac, 8134 (void *)&cmd_tunnel_filter_ip_value, 8135 (void *)&cmd_tunnel_filter_innner_vlan, 8136 (void *)&cmd_tunnel_filter_tunnel_type, 8137 (void *)&cmd_tunnel_filter_filter_type, 8138 (void *)&cmd_tunnel_filter_tenant_id, 8139 (void *)&cmd_tunnel_filter_queue_num, 8140 NULL, 8141 }, 8142 }; 8143 8144 /* *** CONFIGURE TUNNEL UDP PORT *** */ 8145 struct cmd_tunnel_udp_config { 8146 cmdline_fixed_string_t cmd; 8147 cmdline_fixed_string_t what; 8148 uint16_t udp_port; 8149 portid_t port_id; 8150 }; 8151 8152 static void 8153 cmd_tunnel_udp_config_parsed(void *parsed_result, 8154 __attribute__((unused)) struct cmdline *cl, 8155 __attribute__((unused)) void *data) 8156 { 8157 struct cmd_tunnel_udp_config *res = parsed_result; 8158 struct rte_eth_udp_tunnel tunnel_udp; 8159 int ret; 8160 8161 tunnel_udp.udp_port = res->udp_port; 8162 8163 if (!strcmp(res->cmd, "rx_vxlan_port")) 8164 tunnel_udp.prot_type = RTE_TUNNEL_TYPE_VXLAN; 8165 8166 if (!strcmp(res->what, "add")) 8167 ret = rte_eth_dev_udp_tunnel_port_add(res->port_id, 8168 &tunnel_udp); 8169 else 8170 ret = rte_eth_dev_udp_tunnel_port_delete(res->port_id, 8171 &tunnel_udp); 8172 8173 if (ret < 0) 8174 printf("udp tunneling add error: (%s)\n", strerror(-ret)); 8175 } 8176 8177 cmdline_parse_token_string_t cmd_tunnel_udp_config_cmd = 8178 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_udp_config, 8179 cmd, "rx_vxlan_port"); 8180 cmdline_parse_token_string_t cmd_tunnel_udp_config_what = 8181 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_udp_config, 8182 what, "add#rm"); 8183 cmdline_parse_token_num_t cmd_tunnel_udp_config_udp_port = 8184 TOKEN_NUM_INITIALIZER(struct cmd_tunnel_udp_config, 8185 udp_port, UINT16); 8186 cmdline_parse_token_num_t cmd_tunnel_udp_config_port_id = 8187 TOKEN_NUM_INITIALIZER(struct cmd_tunnel_udp_config, 8188 port_id, UINT16); 8189 8190 cmdline_parse_inst_t cmd_tunnel_udp_config = { 8191 .f = cmd_tunnel_udp_config_parsed, 8192 .data = (void *)0, 8193 .help_str = "rx_vxlan_port add|rm <udp_port> <port_id>: " 8194 "Add/Remove a tunneling UDP port filter", 8195 .tokens = { 8196 (void *)&cmd_tunnel_udp_config_cmd, 8197 (void *)&cmd_tunnel_udp_config_what, 8198 (void *)&cmd_tunnel_udp_config_udp_port, 8199 (void *)&cmd_tunnel_udp_config_port_id, 8200 NULL, 8201 }, 8202 }; 8203 8204 /* *** GLOBAL CONFIG *** */ 8205 struct cmd_global_config_result { 8206 cmdline_fixed_string_t cmd; 8207 portid_t port_id; 8208 cmdline_fixed_string_t cfg_type; 8209 uint8_t len; 8210 }; 8211 8212 static void 8213 cmd_global_config_parsed(void *parsed_result, 8214 __attribute__((unused)) struct cmdline *cl, 8215 __attribute__((unused)) void *data) 8216 { 8217 struct cmd_global_config_result *res = parsed_result; 8218 struct rte_eth_global_cfg conf; 8219 int ret; 8220 8221 memset(&conf, 0, sizeof(conf)); 8222 conf.cfg_type = RTE_ETH_GLOBAL_CFG_TYPE_GRE_KEY_LEN; 8223 conf.cfg.gre_key_len = res->len; 8224 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_NONE, 8225 RTE_ETH_FILTER_SET, &conf); 8226 if (ret != 0) 8227 printf("Global config error\n"); 8228 } 8229 8230 cmdline_parse_token_string_t cmd_global_config_cmd = 8231 TOKEN_STRING_INITIALIZER(struct cmd_global_config_result, cmd, 8232 "global_config"); 8233 cmdline_parse_token_num_t cmd_global_config_port_id = 8234 TOKEN_NUM_INITIALIZER(struct cmd_global_config_result, port_id, 8235 UINT16); 8236 cmdline_parse_token_string_t cmd_global_config_type = 8237 TOKEN_STRING_INITIALIZER(struct cmd_global_config_result, 8238 cfg_type, "gre-key-len"); 8239 cmdline_parse_token_num_t cmd_global_config_gre_key_len = 8240 TOKEN_NUM_INITIALIZER(struct cmd_global_config_result, 8241 len, UINT8); 8242 8243 cmdline_parse_inst_t cmd_global_config = { 8244 .f = cmd_global_config_parsed, 8245 .data = (void *)NULL, 8246 .help_str = "global_config <port_id> gre-key-len <key_len>", 8247 .tokens = { 8248 (void *)&cmd_global_config_cmd, 8249 (void *)&cmd_global_config_port_id, 8250 (void *)&cmd_global_config_type, 8251 (void *)&cmd_global_config_gre_key_len, 8252 NULL, 8253 }, 8254 }; 8255 8256 /* *** CONFIGURE VM MIRROR VLAN/POOL RULE *** */ 8257 struct cmd_set_mirror_mask_result { 8258 cmdline_fixed_string_t set; 8259 cmdline_fixed_string_t port; 8260 portid_t port_id; 8261 cmdline_fixed_string_t mirror; 8262 uint8_t rule_id; 8263 cmdline_fixed_string_t what; 8264 cmdline_fixed_string_t value; 8265 cmdline_fixed_string_t dstpool; 8266 uint8_t dstpool_id; 8267 cmdline_fixed_string_t on; 8268 }; 8269 8270 cmdline_parse_token_string_t cmd_mirror_mask_set = 8271 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result, 8272 set, "set"); 8273 cmdline_parse_token_string_t cmd_mirror_mask_port = 8274 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result, 8275 port, "port"); 8276 cmdline_parse_token_num_t cmd_mirror_mask_portid = 8277 TOKEN_NUM_INITIALIZER(struct cmd_set_mirror_mask_result, 8278 port_id, UINT16); 8279 cmdline_parse_token_string_t cmd_mirror_mask_mirror = 8280 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result, 8281 mirror, "mirror-rule"); 8282 cmdline_parse_token_num_t cmd_mirror_mask_ruleid = 8283 TOKEN_NUM_INITIALIZER(struct cmd_set_mirror_mask_result, 8284 rule_id, UINT8); 8285 cmdline_parse_token_string_t cmd_mirror_mask_what = 8286 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result, 8287 what, "pool-mirror-up#pool-mirror-down" 8288 "#vlan-mirror"); 8289 cmdline_parse_token_string_t cmd_mirror_mask_value = 8290 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result, 8291 value, NULL); 8292 cmdline_parse_token_string_t cmd_mirror_mask_dstpool = 8293 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result, 8294 dstpool, "dst-pool"); 8295 cmdline_parse_token_num_t cmd_mirror_mask_poolid = 8296 TOKEN_NUM_INITIALIZER(struct cmd_set_mirror_mask_result, 8297 dstpool_id, UINT8); 8298 cmdline_parse_token_string_t cmd_mirror_mask_on = 8299 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result, 8300 on, "on#off"); 8301 8302 static void 8303 cmd_set_mirror_mask_parsed(void *parsed_result, 8304 __attribute__((unused)) struct cmdline *cl, 8305 __attribute__((unused)) void *data) 8306 { 8307 int ret,nb_item,i; 8308 struct cmd_set_mirror_mask_result *res = parsed_result; 8309 struct rte_eth_mirror_conf mr_conf; 8310 8311 memset(&mr_conf, 0, sizeof(struct rte_eth_mirror_conf)); 8312 8313 unsigned int vlan_list[ETH_MIRROR_MAX_VLANS]; 8314 8315 mr_conf.dst_pool = res->dstpool_id; 8316 8317 if (!strcmp(res->what, "pool-mirror-up")) { 8318 mr_conf.pool_mask = strtoull(res->value, NULL, 16); 8319 mr_conf.rule_type = ETH_MIRROR_VIRTUAL_POOL_UP; 8320 } else if (!strcmp(res->what, "pool-mirror-down")) { 8321 mr_conf.pool_mask = strtoull(res->value, NULL, 16); 8322 mr_conf.rule_type = ETH_MIRROR_VIRTUAL_POOL_DOWN; 8323 } else if (!strcmp(res->what, "vlan-mirror")) { 8324 mr_conf.rule_type = ETH_MIRROR_VLAN; 8325 nb_item = parse_item_list(res->value, "vlan", 8326 ETH_MIRROR_MAX_VLANS, vlan_list, 1); 8327 if (nb_item <= 0) 8328 return; 8329 8330 for (i = 0; i < nb_item; i++) { 8331 if (vlan_list[i] > ETHER_MAX_VLAN_ID) { 8332 printf("Invalid vlan_id: must be < 4096\n"); 8333 return; 8334 } 8335 8336 mr_conf.vlan.vlan_id[i] = (uint16_t)vlan_list[i]; 8337 mr_conf.vlan.vlan_mask |= 1ULL << i; 8338 } 8339 } 8340 8341 if (!strcmp(res->on, "on")) 8342 ret = rte_eth_mirror_rule_set(res->port_id, &mr_conf, 8343 res->rule_id, 1); 8344 else 8345 ret = rte_eth_mirror_rule_set(res->port_id, &mr_conf, 8346 res->rule_id, 0); 8347 if (ret < 0) 8348 printf("mirror rule add error: (%s)\n", strerror(-ret)); 8349 } 8350 8351 cmdline_parse_inst_t cmd_set_mirror_mask = { 8352 .f = cmd_set_mirror_mask_parsed, 8353 .data = NULL, 8354 .help_str = "set port <port_id> mirror-rule <rule_id> " 8355 "pool-mirror-up|pool-mirror-down|vlan-mirror " 8356 "<pool_mask|vlan_id[,vlan_id]*> dst-pool <pool_id> on|off", 8357 .tokens = { 8358 (void *)&cmd_mirror_mask_set, 8359 (void *)&cmd_mirror_mask_port, 8360 (void *)&cmd_mirror_mask_portid, 8361 (void *)&cmd_mirror_mask_mirror, 8362 (void *)&cmd_mirror_mask_ruleid, 8363 (void *)&cmd_mirror_mask_what, 8364 (void *)&cmd_mirror_mask_value, 8365 (void *)&cmd_mirror_mask_dstpool, 8366 (void *)&cmd_mirror_mask_poolid, 8367 (void *)&cmd_mirror_mask_on, 8368 NULL, 8369 }, 8370 }; 8371 8372 /* *** CONFIGURE VM MIRROR UPLINK/DOWNLINK RULE *** */ 8373 struct cmd_set_mirror_link_result { 8374 cmdline_fixed_string_t set; 8375 cmdline_fixed_string_t port; 8376 portid_t port_id; 8377 cmdline_fixed_string_t mirror; 8378 uint8_t rule_id; 8379 cmdline_fixed_string_t what; 8380 cmdline_fixed_string_t dstpool; 8381 uint8_t dstpool_id; 8382 cmdline_fixed_string_t on; 8383 }; 8384 8385 cmdline_parse_token_string_t cmd_mirror_link_set = 8386 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_link_result, 8387 set, "set"); 8388 cmdline_parse_token_string_t cmd_mirror_link_port = 8389 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_link_result, 8390 port, "port"); 8391 cmdline_parse_token_num_t cmd_mirror_link_portid = 8392 TOKEN_NUM_INITIALIZER(struct cmd_set_mirror_link_result, 8393 port_id, UINT16); 8394 cmdline_parse_token_string_t cmd_mirror_link_mirror = 8395 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_link_result, 8396 mirror, "mirror-rule"); 8397 cmdline_parse_token_num_t cmd_mirror_link_ruleid = 8398 TOKEN_NUM_INITIALIZER(struct cmd_set_mirror_link_result, 8399 rule_id, UINT8); 8400 cmdline_parse_token_string_t cmd_mirror_link_what = 8401 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_link_result, 8402 what, "uplink-mirror#downlink-mirror"); 8403 cmdline_parse_token_string_t cmd_mirror_link_dstpool = 8404 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_link_result, 8405 dstpool, "dst-pool"); 8406 cmdline_parse_token_num_t cmd_mirror_link_poolid = 8407 TOKEN_NUM_INITIALIZER(struct cmd_set_mirror_link_result, 8408 dstpool_id, UINT8); 8409 cmdline_parse_token_string_t cmd_mirror_link_on = 8410 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_link_result, 8411 on, "on#off"); 8412 8413 static void 8414 cmd_set_mirror_link_parsed(void *parsed_result, 8415 __attribute__((unused)) struct cmdline *cl, 8416 __attribute__((unused)) void *data) 8417 { 8418 int ret; 8419 struct cmd_set_mirror_link_result *res = parsed_result; 8420 struct rte_eth_mirror_conf mr_conf; 8421 8422 memset(&mr_conf, 0, sizeof(struct rte_eth_mirror_conf)); 8423 if (!strcmp(res->what, "uplink-mirror")) 8424 mr_conf.rule_type = ETH_MIRROR_UPLINK_PORT; 8425 else 8426 mr_conf.rule_type = ETH_MIRROR_DOWNLINK_PORT; 8427 8428 mr_conf.dst_pool = res->dstpool_id; 8429 8430 if (!strcmp(res->on, "on")) 8431 ret = rte_eth_mirror_rule_set(res->port_id, &mr_conf, 8432 res->rule_id, 1); 8433 else 8434 ret = rte_eth_mirror_rule_set(res->port_id, &mr_conf, 8435 res->rule_id, 0); 8436 8437 /* check the return value and print it if is < 0 */ 8438 if (ret < 0) 8439 printf("mirror rule add error: (%s)\n", strerror(-ret)); 8440 8441 } 8442 8443 cmdline_parse_inst_t cmd_set_mirror_link = { 8444 .f = cmd_set_mirror_link_parsed, 8445 .data = NULL, 8446 .help_str = "set port <port_id> mirror-rule <rule_id> " 8447 "uplink-mirror|downlink-mirror dst-pool <pool_id> on|off", 8448 .tokens = { 8449 (void *)&cmd_mirror_link_set, 8450 (void *)&cmd_mirror_link_port, 8451 (void *)&cmd_mirror_link_portid, 8452 (void *)&cmd_mirror_link_mirror, 8453 (void *)&cmd_mirror_link_ruleid, 8454 (void *)&cmd_mirror_link_what, 8455 (void *)&cmd_mirror_link_dstpool, 8456 (void *)&cmd_mirror_link_poolid, 8457 (void *)&cmd_mirror_link_on, 8458 NULL, 8459 }, 8460 }; 8461 8462 /* *** RESET VM MIRROR RULE *** */ 8463 struct cmd_rm_mirror_rule_result { 8464 cmdline_fixed_string_t reset; 8465 cmdline_fixed_string_t port; 8466 portid_t port_id; 8467 cmdline_fixed_string_t mirror; 8468 uint8_t rule_id; 8469 }; 8470 8471 cmdline_parse_token_string_t cmd_rm_mirror_rule_reset = 8472 TOKEN_STRING_INITIALIZER(struct cmd_rm_mirror_rule_result, 8473 reset, "reset"); 8474 cmdline_parse_token_string_t cmd_rm_mirror_rule_port = 8475 TOKEN_STRING_INITIALIZER(struct cmd_rm_mirror_rule_result, 8476 port, "port"); 8477 cmdline_parse_token_num_t cmd_rm_mirror_rule_portid = 8478 TOKEN_NUM_INITIALIZER(struct cmd_rm_mirror_rule_result, 8479 port_id, UINT16); 8480 cmdline_parse_token_string_t cmd_rm_mirror_rule_mirror = 8481 TOKEN_STRING_INITIALIZER(struct cmd_rm_mirror_rule_result, 8482 mirror, "mirror-rule"); 8483 cmdline_parse_token_num_t cmd_rm_mirror_rule_ruleid = 8484 TOKEN_NUM_INITIALIZER(struct cmd_rm_mirror_rule_result, 8485 rule_id, UINT8); 8486 8487 static void 8488 cmd_reset_mirror_rule_parsed(void *parsed_result, 8489 __attribute__((unused)) struct cmdline *cl, 8490 __attribute__((unused)) void *data) 8491 { 8492 int ret; 8493 struct cmd_set_mirror_link_result *res = parsed_result; 8494 /* check rule_id */ 8495 ret = rte_eth_mirror_rule_reset(res->port_id,res->rule_id); 8496 if(ret < 0) 8497 printf("mirror rule remove error: (%s)\n", strerror(-ret)); 8498 } 8499 8500 cmdline_parse_inst_t cmd_reset_mirror_rule = { 8501 .f = cmd_reset_mirror_rule_parsed, 8502 .data = NULL, 8503 .help_str = "reset port <port_id> mirror-rule <rule_id>", 8504 .tokens = { 8505 (void *)&cmd_rm_mirror_rule_reset, 8506 (void *)&cmd_rm_mirror_rule_port, 8507 (void *)&cmd_rm_mirror_rule_portid, 8508 (void *)&cmd_rm_mirror_rule_mirror, 8509 (void *)&cmd_rm_mirror_rule_ruleid, 8510 NULL, 8511 }, 8512 }; 8513 8514 /* ******************************************************************************** */ 8515 8516 struct cmd_dump_result { 8517 cmdline_fixed_string_t dump; 8518 }; 8519 8520 static void 8521 dump_struct_sizes(void) 8522 { 8523 #define DUMP_SIZE(t) printf("sizeof(" #t ") = %u\n", (unsigned)sizeof(t)); 8524 DUMP_SIZE(struct rte_mbuf); 8525 DUMP_SIZE(struct rte_mempool); 8526 DUMP_SIZE(struct rte_ring); 8527 #undef DUMP_SIZE 8528 } 8529 8530 static void cmd_dump_parsed(void *parsed_result, 8531 __attribute__((unused)) struct cmdline *cl, 8532 __attribute__((unused)) void *data) 8533 { 8534 struct cmd_dump_result *res = parsed_result; 8535 8536 if (!strcmp(res->dump, "dump_physmem")) 8537 rte_dump_physmem_layout(stdout); 8538 else if (!strcmp(res->dump, "dump_memzone")) 8539 rte_memzone_dump(stdout); 8540 else if (!strcmp(res->dump, "dump_struct_sizes")) 8541 dump_struct_sizes(); 8542 else if (!strcmp(res->dump, "dump_ring")) 8543 rte_ring_list_dump(stdout); 8544 else if (!strcmp(res->dump, "dump_mempool")) 8545 rte_mempool_list_dump(stdout); 8546 else if (!strcmp(res->dump, "dump_devargs")) 8547 rte_eal_devargs_dump(stdout); 8548 else if (!strcmp(res->dump, "dump_log_types")) 8549 rte_log_dump(stdout); 8550 } 8551 8552 cmdline_parse_token_string_t cmd_dump_dump = 8553 TOKEN_STRING_INITIALIZER(struct cmd_dump_result, dump, 8554 "dump_physmem#" 8555 "dump_memzone#" 8556 "dump_struct_sizes#" 8557 "dump_ring#" 8558 "dump_mempool#" 8559 "dump_devargs#" 8560 "dump_log_types"); 8561 8562 cmdline_parse_inst_t cmd_dump = { 8563 .f = cmd_dump_parsed, /* function to call */ 8564 .data = NULL, /* 2nd arg of func */ 8565 .help_str = "Dump status", 8566 .tokens = { /* token list, NULL terminated */ 8567 (void *)&cmd_dump_dump, 8568 NULL, 8569 }, 8570 }; 8571 8572 /* ******************************************************************************** */ 8573 8574 struct cmd_dump_one_result { 8575 cmdline_fixed_string_t dump; 8576 cmdline_fixed_string_t name; 8577 }; 8578 8579 static void cmd_dump_one_parsed(void *parsed_result, struct cmdline *cl, 8580 __attribute__((unused)) void *data) 8581 { 8582 struct cmd_dump_one_result *res = parsed_result; 8583 8584 if (!strcmp(res->dump, "dump_ring")) { 8585 struct rte_ring *r; 8586 r = rte_ring_lookup(res->name); 8587 if (r == NULL) { 8588 cmdline_printf(cl, "Cannot find ring\n"); 8589 return; 8590 } 8591 rte_ring_dump(stdout, r); 8592 } else if (!strcmp(res->dump, "dump_mempool")) { 8593 struct rte_mempool *mp; 8594 mp = rte_mempool_lookup(res->name); 8595 if (mp == NULL) { 8596 cmdline_printf(cl, "Cannot find mempool\n"); 8597 return; 8598 } 8599 rte_mempool_dump(stdout, mp); 8600 } 8601 } 8602 8603 cmdline_parse_token_string_t cmd_dump_one_dump = 8604 TOKEN_STRING_INITIALIZER(struct cmd_dump_one_result, dump, 8605 "dump_ring#dump_mempool"); 8606 8607 cmdline_parse_token_string_t cmd_dump_one_name = 8608 TOKEN_STRING_INITIALIZER(struct cmd_dump_one_result, name, NULL); 8609 8610 cmdline_parse_inst_t cmd_dump_one = { 8611 .f = cmd_dump_one_parsed, /* function to call */ 8612 .data = NULL, /* 2nd arg of func */ 8613 .help_str = "dump_ring|dump_mempool <name>: Dump one ring/mempool", 8614 .tokens = { /* token list, NULL terminated */ 8615 (void *)&cmd_dump_one_dump, 8616 (void *)&cmd_dump_one_name, 8617 NULL, 8618 }, 8619 }; 8620 8621 /* *** Add/Del syn filter *** */ 8622 struct cmd_syn_filter_result { 8623 cmdline_fixed_string_t filter; 8624 portid_t port_id; 8625 cmdline_fixed_string_t ops; 8626 cmdline_fixed_string_t priority; 8627 cmdline_fixed_string_t high; 8628 cmdline_fixed_string_t queue; 8629 uint16_t queue_id; 8630 }; 8631 8632 static void 8633 cmd_syn_filter_parsed(void *parsed_result, 8634 __attribute__((unused)) struct cmdline *cl, 8635 __attribute__((unused)) void *data) 8636 { 8637 struct cmd_syn_filter_result *res = parsed_result; 8638 struct rte_eth_syn_filter syn_filter; 8639 int ret = 0; 8640 8641 ret = rte_eth_dev_filter_supported(res->port_id, 8642 RTE_ETH_FILTER_SYN); 8643 if (ret < 0) { 8644 printf("syn filter is not supported on port %u.\n", 8645 res->port_id); 8646 return; 8647 } 8648 8649 memset(&syn_filter, 0, sizeof(syn_filter)); 8650 8651 if (!strcmp(res->ops, "add")) { 8652 if (!strcmp(res->high, "high")) 8653 syn_filter.hig_pri = 1; 8654 else 8655 syn_filter.hig_pri = 0; 8656 8657 syn_filter.queue = res->queue_id; 8658 ret = rte_eth_dev_filter_ctrl(res->port_id, 8659 RTE_ETH_FILTER_SYN, 8660 RTE_ETH_FILTER_ADD, 8661 &syn_filter); 8662 } else 8663 ret = rte_eth_dev_filter_ctrl(res->port_id, 8664 RTE_ETH_FILTER_SYN, 8665 RTE_ETH_FILTER_DELETE, 8666 &syn_filter); 8667 8668 if (ret < 0) 8669 printf("syn filter programming error: (%s)\n", 8670 strerror(-ret)); 8671 } 8672 8673 cmdline_parse_token_string_t cmd_syn_filter_filter = 8674 TOKEN_STRING_INITIALIZER(struct cmd_syn_filter_result, 8675 filter, "syn_filter"); 8676 cmdline_parse_token_num_t cmd_syn_filter_port_id = 8677 TOKEN_NUM_INITIALIZER(struct cmd_syn_filter_result, 8678 port_id, UINT16); 8679 cmdline_parse_token_string_t cmd_syn_filter_ops = 8680 TOKEN_STRING_INITIALIZER(struct cmd_syn_filter_result, 8681 ops, "add#del"); 8682 cmdline_parse_token_string_t cmd_syn_filter_priority = 8683 TOKEN_STRING_INITIALIZER(struct cmd_syn_filter_result, 8684 priority, "priority"); 8685 cmdline_parse_token_string_t cmd_syn_filter_high = 8686 TOKEN_STRING_INITIALIZER(struct cmd_syn_filter_result, 8687 high, "high#low"); 8688 cmdline_parse_token_string_t cmd_syn_filter_queue = 8689 TOKEN_STRING_INITIALIZER(struct cmd_syn_filter_result, 8690 queue, "queue"); 8691 cmdline_parse_token_num_t cmd_syn_filter_queue_id = 8692 TOKEN_NUM_INITIALIZER(struct cmd_syn_filter_result, 8693 queue_id, UINT16); 8694 8695 cmdline_parse_inst_t cmd_syn_filter = { 8696 .f = cmd_syn_filter_parsed, 8697 .data = NULL, 8698 .help_str = "syn_filter <port_id> add|del priority high|low queue " 8699 "<queue_id>: Add/Delete syn filter", 8700 .tokens = { 8701 (void *)&cmd_syn_filter_filter, 8702 (void *)&cmd_syn_filter_port_id, 8703 (void *)&cmd_syn_filter_ops, 8704 (void *)&cmd_syn_filter_priority, 8705 (void *)&cmd_syn_filter_high, 8706 (void *)&cmd_syn_filter_queue, 8707 (void *)&cmd_syn_filter_queue_id, 8708 NULL, 8709 }, 8710 }; 8711 8712 /* *** queue region set *** */ 8713 struct cmd_queue_region_result { 8714 cmdline_fixed_string_t set; 8715 cmdline_fixed_string_t port; 8716 portid_t port_id; 8717 cmdline_fixed_string_t cmd; 8718 cmdline_fixed_string_t region; 8719 uint8_t region_id; 8720 cmdline_fixed_string_t queue_start_index; 8721 uint8_t queue_id; 8722 cmdline_fixed_string_t queue_num; 8723 uint8_t queue_num_value; 8724 }; 8725 8726 static void 8727 cmd_queue_region_parsed(void *parsed_result, 8728 __attribute__((unused)) struct cmdline *cl, 8729 __attribute__((unused)) void *data) 8730 { 8731 struct cmd_queue_region_result *res = parsed_result; 8732 int ret = -ENOTSUP; 8733 #ifdef RTE_LIBRTE_I40E_PMD 8734 struct rte_pmd_i40e_queue_region_conf region_conf; 8735 enum rte_pmd_i40e_queue_region_op op_type; 8736 #endif 8737 8738 if (port_id_is_invalid(res->port_id, ENABLED_WARN)) 8739 return; 8740 8741 #ifdef RTE_LIBRTE_I40E_PMD 8742 memset(®ion_conf, 0, sizeof(region_conf)); 8743 op_type = RTE_PMD_I40E_RSS_QUEUE_REGION_SET; 8744 region_conf.region_id = res->region_id; 8745 region_conf.queue_num = res->queue_num_value; 8746 region_conf.queue_start_index = res->queue_id; 8747 8748 ret = rte_pmd_i40e_rss_queue_region_conf(res->port_id, 8749 op_type, ®ion_conf); 8750 #endif 8751 8752 switch (ret) { 8753 case 0: 8754 break; 8755 case -ENOTSUP: 8756 printf("function not implemented or supported\n"); 8757 break; 8758 default: 8759 printf("queue region config error: (%s)\n", strerror(-ret)); 8760 } 8761 } 8762 8763 cmdline_parse_token_string_t cmd_queue_region_set = 8764 TOKEN_STRING_INITIALIZER(struct cmd_queue_region_result, 8765 set, "set"); 8766 cmdline_parse_token_string_t cmd_queue_region_port = 8767 TOKEN_STRING_INITIALIZER(struct cmd_queue_region_result, port, "port"); 8768 cmdline_parse_token_num_t cmd_queue_region_port_id = 8769 TOKEN_NUM_INITIALIZER(struct cmd_queue_region_result, 8770 port_id, UINT16); 8771 cmdline_parse_token_string_t cmd_queue_region_cmd = 8772 TOKEN_STRING_INITIALIZER(struct cmd_queue_region_result, 8773 cmd, "queue-region"); 8774 cmdline_parse_token_string_t cmd_queue_region_id = 8775 TOKEN_STRING_INITIALIZER(struct cmd_queue_region_result, 8776 region, "region_id"); 8777 cmdline_parse_token_num_t cmd_queue_region_index = 8778 TOKEN_NUM_INITIALIZER(struct cmd_queue_region_result, 8779 region_id, UINT8); 8780 cmdline_parse_token_string_t cmd_queue_region_queue_start_index = 8781 TOKEN_STRING_INITIALIZER(struct cmd_queue_region_result, 8782 queue_start_index, "queue_start_index"); 8783 cmdline_parse_token_num_t cmd_queue_region_queue_id = 8784 TOKEN_NUM_INITIALIZER(struct cmd_queue_region_result, 8785 queue_id, UINT8); 8786 cmdline_parse_token_string_t cmd_queue_region_queue_num = 8787 TOKEN_STRING_INITIALIZER(struct cmd_queue_region_result, 8788 queue_num, "queue_num"); 8789 cmdline_parse_token_num_t cmd_queue_region_queue_num_value = 8790 TOKEN_NUM_INITIALIZER(struct cmd_queue_region_result, 8791 queue_num_value, UINT8); 8792 8793 cmdline_parse_inst_t cmd_queue_region = { 8794 .f = cmd_queue_region_parsed, 8795 .data = NULL, 8796 .help_str = "set port <port_id> queue-region region_id <value> " 8797 "queue_start_index <value> queue_num <value>: Set a queue region", 8798 .tokens = { 8799 (void *)&cmd_queue_region_set, 8800 (void *)&cmd_queue_region_port, 8801 (void *)&cmd_queue_region_port_id, 8802 (void *)&cmd_queue_region_cmd, 8803 (void *)&cmd_queue_region_id, 8804 (void *)&cmd_queue_region_index, 8805 (void *)&cmd_queue_region_queue_start_index, 8806 (void *)&cmd_queue_region_queue_id, 8807 (void *)&cmd_queue_region_queue_num, 8808 (void *)&cmd_queue_region_queue_num_value, 8809 NULL, 8810 }, 8811 }; 8812 8813 /* *** queue region and flowtype set *** */ 8814 struct cmd_region_flowtype_result { 8815 cmdline_fixed_string_t set; 8816 cmdline_fixed_string_t port; 8817 portid_t port_id; 8818 cmdline_fixed_string_t cmd; 8819 cmdline_fixed_string_t region; 8820 uint8_t region_id; 8821 cmdline_fixed_string_t flowtype; 8822 uint8_t flowtype_id; 8823 }; 8824 8825 static void 8826 cmd_region_flowtype_parsed(void *parsed_result, 8827 __attribute__((unused)) struct cmdline *cl, 8828 __attribute__((unused)) void *data) 8829 { 8830 struct cmd_region_flowtype_result *res = parsed_result; 8831 int ret = -ENOTSUP; 8832 #ifdef RTE_LIBRTE_I40E_PMD 8833 struct rte_pmd_i40e_queue_region_conf region_conf; 8834 enum rte_pmd_i40e_queue_region_op op_type; 8835 #endif 8836 8837 if (port_id_is_invalid(res->port_id, ENABLED_WARN)) 8838 return; 8839 8840 #ifdef RTE_LIBRTE_I40E_PMD 8841 memset(®ion_conf, 0, sizeof(region_conf)); 8842 8843 op_type = RTE_PMD_I40E_RSS_QUEUE_REGION_FLOWTYPE_SET; 8844 region_conf.region_id = res->region_id; 8845 region_conf.hw_flowtype = res->flowtype_id; 8846 8847 ret = rte_pmd_i40e_rss_queue_region_conf(res->port_id, 8848 op_type, ®ion_conf); 8849 #endif 8850 8851 switch (ret) { 8852 case 0: 8853 break; 8854 case -ENOTSUP: 8855 printf("function not implemented or supported\n"); 8856 break; 8857 default: 8858 printf("region flowtype config error: (%s)\n", strerror(-ret)); 8859 } 8860 } 8861 8862 cmdline_parse_token_string_t cmd_region_flowtype_set = 8863 TOKEN_STRING_INITIALIZER(struct cmd_region_flowtype_result, 8864 set, "set"); 8865 cmdline_parse_token_string_t cmd_region_flowtype_port = 8866 TOKEN_STRING_INITIALIZER(struct cmd_region_flowtype_result, 8867 port, "port"); 8868 cmdline_parse_token_num_t cmd_region_flowtype_port_index = 8869 TOKEN_NUM_INITIALIZER(struct cmd_region_flowtype_result, 8870 port_id, UINT16); 8871 cmdline_parse_token_string_t cmd_region_flowtype_cmd = 8872 TOKEN_STRING_INITIALIZER(struct cmd_region_flowtype_result, 8873 cmd, "queue-region"); 8874 cmdline_parse_token_string_t cmd_region_flowtype_index = 8875 TOKEN_STRING_INITIALIZER(struct cmd_region_flowtype_result, 8876 region, "region_id"); 8877 cmdline_parse_token_num_t cmd_region_flowtype_id = 8878 TOKEN_NUM_INITIALIZER(struct cmd_region_flowtype_result, 8879 region_id, UINT8); 8880 cmdline_parse_token_string_t cmd_region_flowtype_flow_index = 8881 TOKEN_STRING_INITIALIZER(struct cmd_region_flowtype_result, 8882 flowtype, "flowtype"); 8883 cmdline_parse_token_num_t cmd_region_flowtype_flow_id = 8884 TOKEN_NUM_INITIALIZER(struct cmd_region_flowtype_result, 8885 flowtype_id, UINT8); 8886 cmdline_parse_inst_t cmd_region_flowtype = { 8887 .f = cmd_region_flowtype_parsed, 8888 .data = NULL, 8889 .help_str = "set port <port_id> queue-region region_id <value> " 8890 "flowtype <value>: Set a flowtype region index", 8891 .tokens = { 8892 (void *)&cmd_region_flowtype_set, 8893 (void *)&cmd_region_flowtype_port, 8894 (void *)&cmd_region_flowtype_port_index, 8895 (void *)&cmd_region_flowtype_cmd, 8896 (void *)&cmd_region_flowtype_index, 8897 (void *)&cmd_region_flowtype_id, 8898 (void *)&cmd_region_flowtype_flow_index, 8899 (void *)&cmd_region_flowtype_flow_id, 8900 NULL, 8901 }, 8902 }; 8903 8904 /* *** User Priority (UP) to queue region (region_id) set *** */ 8905 struct cmd_user_priority_region_result { 8906 cmdline_fixed_string_t set; 8907 cmdline_fixed_string_t port; 8908 portid_t port_id; 8909 cmdline_fixed_string_t cmd; 8910 cmdline_fixed_string_t user_priority; 8911 uint8_t user_priority_id; 8912 cmdline_fixed_string_t region; 8913 uint8_t region_id; 8914 }; 8915 8916 static void 8917 cmd_user_priority_region_parsed(void *parsed_result, 8918 __attribute__((unused)) struct cmdline *cl, 8919 __attribute__((unused)) void *data) 8920 { 8921 struct cmd_user_priority_region_result *res = parsed_result; 8922 int ret = -ENOTSUP; 8923 #ifdef RTE_LIBRTE_I40E_PMD 8924 struct rte_pmd_i40e_queue_region_conf region_conf; 8925 enum rte_pmd_i40e_queue_region_op op_type; 8926 #endif 8927 8928 if (port_id_is_invalid(res->port_id, ENABLED_WARN)) 8929 return; 8930 8931 #ifdef RTE_LIBRTE_I40E_PMD 8932 memset(®ion_conf, 0, sizeof(region_conf)); 8933 op_type = RTE_PMD_I40E_RSS_QUEUE_REGION_USER_PRIORITY_SET; 8934 region_conf.user_priority = res->user_priority_id; 8935 region_conf.region_id = res->region_id; 8936 8937 ret = rte_pmd_i40e_rss_queue_region_conf(res->port_id, 8938 op_type, ®ion_conf); 8939 #endif 8940 8941 switch (ret) { 8942 case 0: 8943 break; 8944 case -ENOTSUP: 8945 printf("function not implemented or supported\n"); 8946 break; 8947 default: 8948 printf("user_priority region config error: (%s)\n", 8949 strerror(-ret)); 8950 } 8951 } 8952 8953 cmdline_parse_token_string_t cmd_user_priority_region_set = 8954 TOKEN_STRING_INITIALIZER(struct cmd_user_priority_region_result, 8955 set, "set"); 8956 cmdline_parse_token_string_t cmd_user_priority_region_port = 8957 TOKEN_STRING_INITIALIZER(struct cmd_user_priority_region_result, 8958 port, "port"); 8959 cmdline_parse_token_num_t cmd_user_priority_region_port_index = 8960 TOKEN_NUM_INITIALIZER(struct cmd_user_priority_region_result, 8961 port_id, UINT16); 8962 cmdline_parse_token_string_t cmd_user_priority_region_cmd = 8963 TOKEN_STRING_INITIALIZER(struct cmd_user_priority_region_result, 8964 cmd, "queue-region"); 8965 cmdline_parse_token_string_t cmd_user_priority_region_UP = 8966 TOKEN_STRING_INITIALIZER(struct cmd_user_priority_region_result, 8967 user_priority, "UP"); 8968 cmdline_parse_token_num_t cmd_user_priority_region_UP_id = 8969 TOKEN_NUM_INITIALIZER(struct cmd_user_priority_region_result, 8970 user_priority_id, UINT8); 8971 cmdline_parse_token_string_t cmd_user_priority_region_region = 8972 TOKEN_STRING_INITIALIZER(struct cmd_user_priority_region_result, 8973 region, "region_id"); 8974 cmdline_parse_token_num_t cmd_user_priority_region_region_id = 8975 TOKEN_NUM_INITIALIZER(struct cmd_user_priority_region_result, 8976 region_id, UINT8); 8977 8978 cmdline_parse_inst_t cmd_user_priority_region = { 8979 .f = cmd_user_priority_region_parsed, 8980 .data = NULL, 8981 .help_str = "set port <port_id> queue-region UP <value> " 8982 "region_id <value>: Set the mapping of User Priority (UP) " 8983 "to queue region (region_id) ", 8984 .tokens = { 8985 (void *)&cmd_user_priority_region_set, 8986 (void *)&cmd_user_priority_region_port, 8987 (void *)&cmd_user_priority_region_port_index, 8988 (void *)&cmd_user_priority_region_cmd, 8989 (void *)&cmd_user_priority_region_UP, 8990 (void *)&cmd_user_priority_region_UP_id, 8991 (void *)&cmd_user_priority_region_region, 8992 (void *)&cmd_user_priority_region_region_id, 8993 NULL, 8994 }, 8995 }; 8996 8997 /* *** flush all queue region related configuration *** */ 8998 struct cmd_flush_queue_region_result { 8999 cmdline_fixed_string_t set; 9000 cmdline_fixed_string_t port; 9001 portid_t port_id; 9002 cmdline_fixed_string_t cmd; 9003 cmdline_fixed_string_t flush; 9004 cmdline_fixed_string_t what; 9005 }; 9006 9007 static void 9008 cmd_flush_queue_region_parsed(void *parsed_result, 9009 __attribute__((unused)) struct cmdline *cl, 9010 __attribute__((unused)) void *data) 9011 { 9012 struct cmd_flush_queue_region_result *res = parsed_result; 9013 int ret = -ENOTSUP; 9014 #ifdef RTE_LIBRTE_I40E_PMD 9015 struct rte_pmd_i40e_queue_region_conf region_conf; 9016 enum rte_pmd_i40e_queue_region_op op_type; 9017 #endif 9018 9019 if (port_id_is_invalid(res->port_id, ENABLED_WARN)) 9020 return; 9021 9022 #ifdef RTE_LIBRTE_I40E_PMD 9023 memset(®ion_conf, 0, sizeof(region_conf)); 9024 9025 if (strcmp(res->what, "on") == 0) 9026 op_type = RTE_PMD_I40E_RSS_QUEUE_REGION_ALL_FLUSH_ON; 9027 else 9028 op_type = RTE_PMD_I40E_RSS_QUEUE_REGION_ALL_FLUSH_OFF; 9029 9030 ret = rte_pmd_i40e_rss_queue_region_conf(res->port_id, 9031 op_type, ®ion_conf); 9032 #endif 9033 9034 switch (ret) { 9035 case 0: 9036 break; 9037 case -ENOTSUP: 9038 printf("function not implemented or supported\n"); 9039 break; 9040 default: 9041 printf("queue region config flush error: (%s)\n", 9042 strerror(-ret)); 9043 } 9044 } 9045 9046 cmdline_parse_token_string_t cmd_flush_queue_region_set = 9047 TOKEN_STRING_INITIALIZER(struct cmd_flush_queue_region_result, 9048 set, "set"); 9049 cmdline_parse_token_string_t cmd_flush_queue_region_port = 9050 TOKEN_STRING_INITIALIZER(struct cmd_flush_queue_region_result, 9051 port, "port"); 9052 cmdline_parse_token_num_t cmd_flush_queue_region_port_index = 9053 TOKEN_NUM_INITIALIZER(struct cmd_flush_queue_region_result, 9054 port_id, UINT16); 9055 cmdline_parse_token_string_t cmd_flush_queue_region_cmd = 9056 TOKEN_STRING_INITIALIZER(struct cmd_flush_queue_region_result, 9057 cmd, "queue-region"); 9058 cmdline_parse_token_string_t cmd_flush_queue_region_flush = 9059 TOKEN_STRING_INITIALIZER(struct cmd_flush_queue_region_result, 9060 flush, "flush"); 9061 cmdline_parse_token_string_t cmd_flush_queue_region_what = 9062 TOKEN_STRING_INITIALIZER(struct cmd_flush_queue_region_result, 9063 what, "on#off"); 9064 9065 cmdline_parse_inst_t cmd_flush_queue_region = { 9066 .f = cmd_flush_queue_region_parsed, 9067 .data = NULL, 9068 .help_str = "set port <port_id> queue-region flush on|off" 9069 ": flush all queue region related configuration", 9070 .tokens = { 9071 (void *)&cmd_flush_queue_region_set, 9072 (void *)&cmd_flush_queue_region_port, 9073 (void *)&cmd_flush_queue_region_port_index, 9074 (void *)&cmd_flush_queue_region_cmd, 9075 (void *)&cmd_flush_queue_region_flush, 9076 (void *)&cmd_flush_queue_region_what, 9077 NULL, 9078 }, 9079 }; 9080 9081 /* *** get all queue region related configuration info *** */ 9082 struct cmd_show_queue_region_info { 9083 cmdline_fixed_string_t show; 9084 cmdline_fixed_string_t port; 9085 portid_t port_id; 9086 cmdline_fixed_string_t cmd; 9087 }; 9088 9089 static void 9090 cmd_show_queue_region_info_parsed(void *parsed_result, 9091 __attribute__((unused)) struct cmdline *cl, 9092 __attribute__((unused)) void *data) 9093 { 9094 struct cmd_show_queue_region_info *res = parsed_result; 9095 int ret = -ENOTSUP; 9096 #ifdef RTE_LIBRTE_I40E_PMD 9097 struct rte_pmd_i40e_queue_regions rte_pmd_regions; 9098 enum rte_pmd_i40e_queue_region_op op_type; 9099 #endif 9100 9101 if (port_id_is_invalid(res->port_id, ENABLED_WARN)) 9102 return; 9103 9104 #ifdef RTE_LIBRTE_I40E_PMD 9105 memset(&rte_pmd_regions, 0, sizeof(rte_pmd_regions)); 9106 9107 op_type = RTE_PMD_I40E_RSS_QUEUE_REGION_INFO_GET; 9108 9109 ret = rte_pmd_i40e_rss_queue_region_conf(res->port_id, 9110 op_type, &rte_pmd_regions); 9111 9112 port_queue_region_info_display(res->port_id, &rte_pmd_regions); 9113 #endif 9114 9115 switch (ret) { 9116 case 0: 9117 break; 9118 case -ENOTSUP: 9119 printf("function not implemented or supported\n"); 9120 break; 9121 default: 9122 printf("queue region config info show error: (%s)\n", 9123 strerror(-ret)); 9124 } 9125 } 9126 9127 cmdline_parse_token_string_t cmd_show_queue_region_info_get = 9128 TOKEN_STRING_INITIALIZER(struct cmd_show_queue_region_info, 9129 show, "show"); 9130 cmdline_parse_token_string_t cmd_show_queue_region_info_port = 9131 TOKEN_STRING_INITIALIZER(struct cmd_show_queue_region_info, 9132 port, "port"); 9133 cmdline_parse_token_num_t cmd_show_queue_region_info_port_index = 9134 TOKEN_NUM_INITIALIZER(struct cmd_show_queue_region_info, 9135 port_id, UINT16); 9136 cmdline_parse_token_string_t cmd_show_queue_region_info_cmd = 9137 TOKEN_STRING_INITIALIZER(struct cmd_show_queue_region_info, 9138 cmd, "queue-region"); 9139 9140 cmdline_parse_inst_t cmd_show_queue_region_info_all = { 9141 .f = cmd_show_queue_region_info_parsed, 9142 .data = NULL, 9143 .help_str = "show port <port_id> queue-region" 9144 ": show all queue region related configuration info", 9145 .tokens = { 9146 (void *)&cmd_show_queue_region_info_get, 9147 (void *)&cmd_show_queue_region_info_port, 9148 (void *)&cmd_show_queue_region_info_port_index, 9149 (void *)&cmd_show_queue_region_info_cmd, 9150 NULL, 9151 }, 9152 }; 9153 9154 /* *** ADD/REMOVE A 2tuple FILTER *** */ 9155 struct cmd_2tuple_filter_result { 9156 cmdline_fixed_string_t filter; 9157 portid_t port_id; 9158 cmdline_fixed_string_t ops; 9159 cmdline_fixed_string_t dst_port; 9160 uint16_t dst_port_value; 9161 cmdline_fixed_string_t protocol; 9162 uint8_t protocol_value; 9163 cmdline_fixed_string_t mask; 9164 uint8_t mask_value; 9165 cmdline_fixed_string_t tcp_flags; 9166 uint8_t tcp_flags_value; 9167 cmdline_fixed_string_t priority; 9168 uint8_t priority_value; 9169 cmdline_fixed_string_t queue; 9170 uint16_t queue_id; 9171 }; 9172 9173 static void 9174 cmd_2tuple_filter_parsed(void *parsed_result, 9175 __attribute__((unused)) struct cmdline *cl, 9176 __attribute__((unused)) void *data) 9177 { 9178 struct rte_eth_ntuple_filter filter; 9179 struct cmd_2tuple_filter_result *res = parsed_result; 9180 int ret = 0; 9181 9182 ret = rte_eth_dev_filter_supported(res->port_id, RTE_ETH_FILTER_NTUPLE); 9183 if (ret < 0) { 9184 printf("ntuple filter is not supported on port %u.\n", 9185 res->port_id); 9186 return; 9187 } 9188 9189 memset(&filter, 0, sizeof(struct rte_eth_ntuple_filter)); 9190 9191 filter.flags = RTE_2TUPLE_FLAGS; 9192 filter.dst_port_mask = (res->mask_value & 0x02) ? UINT16_MAX : 0; 9193 filter.proto_mask = (res->mask_value & 0x01) ? UINT8_MAX : 0; 9194 filter.proto = res->protocol_value; 9195 filter.priority = res->priority_value; 9196 if (res->tcp_flags_value != 0 && filter.proto != IPPROTO_TCP) { 9197 printf("nonzero tcp_flags is only meaningful" 9198 " when protocol is TCP.\n"); 9199 return; 9200 } 9201 if (res->tcp_flags_value > TCP_FLAG_ALL) { 9202 printf("invalid TCP flags.\n"); 9203 return; 9204 } 9205 9206 if (res->tcp_flags_value != 0) { 9207 filter.flags |= RTE_NTUPLE_FLAGS_TCP_FLAG; 9208 filter.tcp_flags = res->tcp_flags_value; 9209 } 9210 9211 /* need convert to big endian. */ 9212 filter.dst_port = rte_cpu_to_be_16(res->dst_port_value); 9213 filter.queue = res->queue_id; 9214 9215 if (!strcmp(res->ops, "add")) 9216 ret = rte_eth_dev_filter_ctrl(res->port_id, 9217 RTE_ETH_FILTER_NTUPLE, 9218 RTE_ETH_FILTER_ADD, 9219 &filter); 9220 else 9221 ret = rte_eth_dev_filter_ctrl(res->port_id, 9222 RTE_ETH_FILTER_NTUPLE, 9223 RTE_ETH_FILTER_DELETE, 9224 &filter); 9225 if (ret < 0) 9226 printf("2tuple filter programming error: (%s)\n", 9227 strerror(-ret)); 9228 9229 } 9230 9231 cmdline_parse_token_string_t cmd_2tuple_filter_filter = 9232 TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result, 9233 filter, "2tuple_filter"); 9234 cmdline_parse_token_num_t cmd_2tuple_filter_port_id = 9235 TOKEN_NUM_INITIALIZER(struct cmd_2tuple_filter_result, 9236 port_id, UINT16); 9237 cmdline_parse_token_string_t cmd_2tuple_filter_ops = 9238 TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result, 9239 ops, "add#del"); 9240 cmdline_parse_token_string_t cmd_2tuple_filter_dst_port = 9241 TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result, 9242 dst_port, "dst_port"); 9243 cmdline_parse_token_num_t cmd_2tuple_filter_dst_port_value = 9244 TOKEN_NUM_INITIALIZER(struct cmd_2tuple_filter_result, 9245 dst_port_value, UINT16); 9246 cmdline_parse_token_string_t cmd_2tuple_filter_protocol = 9247 TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result, 9248 protocol, "protocol"); 9249 cmdline_parse_token_num_t cmd_2tuple_filter_protocol_value = 9250 TOKEN_NUM_INITIALIZER(struct cmd_2tuple_filter_result, 9251 protocol_value, UINT8); 9252 cmdline_parse_token_string_t cmd_2tuple_filter_mask = 9253 TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result, 9254 mask, "mask"); 9255 cmdline_parse_token_num_t cmd_2tuple_filter_mask_value = 9256 TOKEN_NUM_INITIALIZER(struct cmd_2tuple_filter_result, 9257 mask_value, INT8); 9258 cmdline_parse_token_string_t cmd_2tuple_filter_tcp_flags = 9259 TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result, 9260 tcp_flags, "tcp_flags"); 9261 cmdline_parse_token_num_t cmd_2tuple_filter_tcp_flags_value = 9262 TOKEN_NUM_INITIALIZER(struct cmd_2tuple_filter_result, 9263 tcp_flags_value, UINT8); 9264 cmdline_parse_token_string_t cmd_2tuple_filter_priority = 9265 TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result, 9266 priority, "priority"); 9267 cmdline_parse_token_num_t cmd_2tuple_filter_priority_value = 9268 TOKEN_NUM_INITIALIZER(struct cmd_2tuple_filter_result, 9269 priority_value, UINT8); 9270 cmdline_parse_token_string_t cmd_2tuple_filter_queue = 9271 TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result, 9272 queue, "queue"); 9273 cmdline_parse_token_num_t cmd_2tuple_filter_queue_id = 9274 TOKEN_NUM_INITIALIZER(struct cmd_2tuple_filter_result, 9275 queue_id, UINT16); 9276 9277 cmdline_parse_inst_t cmd_2tuple_filter = { 9278 .f = cmd_2tuple_filter_parsed, 9279 .data = NULL, 9280 .help_str = "2tuple_filter <port_id> add|del dst_port <value> protocol " 9281 "<value> mask <value> tcp_flags <value> priority <value> queue " 9282 "<queue_id>: Add a 2tuple filter", 9283 .tokens = { 9284 (void *)&cmd_2tuple_filter_filter, 9285 (void *)&cmd_2tuple_filter_port_id, 9286 (void *)&cmd_2tuple_filter_ops, 9287 (void *)&cmd_2tuple_filter_dst_port, 9288 (void *)&cmd_2tuple_filter_dst_port_value, 9289 (void *)&cmd_2tuple_filter_protocol, 9290 (void *)&cmd_2tuple_filter_protocol_value, 9291 (void *)&cmd_2tuple_filter_mask, 9292 (void *)&cmd_2tuple_filter_mask_value, 9293 (void *)&cmd_2tuple_filter_tcp_flags, 9294 (void *)&cmd_2tuple_filter_tcp_flags_value, 9295 (void *)&cmd_2tuple_filter_priority, 9296 (void *)&cmd_2tuple_filter_priority_value, 9297 (void *)&cmd_2tuple_filter_queue, 9298 (void *)&cmd_2tuple_filter_queue_id, 9299 NULL, 9300 }, 9301 }; 9302 9303 /* *** ADD/REMOVE A 5tuple FILTER *** */ 9304 struct cmd_5tuple_filter_result { 9305 cmdline_fixed_string_t filter; 9306 portid_t port_id; 9307 cmdline_fixed_string_t ops; 9308 cmdline_fixed_string_t dst_ip; 9309 cmdline_ipaddr_t dst_ip_value; 9310 cmdline_fixed_string_t src_ip; 9311 cmdline_ipaddr_t src_ip_value; 9312 cmdline_fixed_string_t dst_port; 9313 uint16_t dst_port_value; 9314 cmdline_fixed_string_t src_port; 9315 uint16_t src_port_value; 9316 cmdline_fixed_string_t protocol; 9317 uint8_t protocol_value; 9318 cmdline_fixed_string_t mask; 9319 uint8_t mask_value; 9320 cmdline_fixed_string_t tcp_flags; 9321 uint8_t tcp_flags_value; 9322 cmdline_fixed_string_t priority; 9323 uint8_t priority_value; 9324 cmdline_fixed_string_t queue; 9325 uint16_t queue_id; 9326 }; 9327 9328 static void 9329 cmd_5tuple_filter_parsed(void *parsed_result, 9330 __attribute__((unused)) struct cmdline *cl, 9331 __attribute__((unused)) void *data) 9332 { 9333 struct rte_eth_ntuple_filter filter; 9334 struct cmd_5tuple_filter_result *res = parsed_result; 9335 int ret = 0; 9336 9337 ret = rte_eth_dev_filter_supported(res->port_id, RTE_ETH_FILTER_NTUPLE); 9338 if (ret < 0) { 9339 printf("ntuple filter is not supported on port %u.\n", 9340 res->port_id); 9341 return; 9342 } 9343 9344 memset(&filter, 0, sizeof(struct rte_eth_ntuple_filter)); 9345 9346 filter.flags = RTE_5TUPLE_FLAGS; 9347 filter.dst_ip_mask = (res->mask_value & 0x10) ? UINT32_MAX : 0; 9348 filter.src_ip_mask = (res->mask_value & 0x08) ? UINT32_MAX : 0; 9349 filter.dst_port_mask = (res->mask_value & 0x04) ? UINT16_MAX : 0; 9350 filter.src_port_mask = (res->mask_value & 0x02) ? UINT16_MAX : 0; 9351 filter.proto_mask = (res->mask_value & 0x01) ? UINT8_MAX : 0; 9352 filter.proto = res->protocol_value; 9353 filter.priority = res->priority_value; 9354 if (res->tcp_flags_value != 0 && filter.proto != IPPROTO_TCP) { 9355 printf("nonzero tcp_flags is only meaningful" 9356 " when protocol is TCP.\n"); 9357 return; 9358 } 9359 if (res->tcp_flags_value > TCP_FLAG_ALL) { 9360 printf("invalid TCP flags.\n"); 9361 return; 9362 } 9363 9364 if (res->tcp_flags_value != 0) { 9365 filter.flags |= RTE_NTUPLE_FLAGS_TCP_FLAG; 9366 filter.tcp_flags = res->tcp_flags_value; 9367 } 9368 9369 if (res->dst_ip_value.family == AF_INET) 9370 /* no need to convert, already big endian. */ 9371 filter.dst_ip = res->dst_ip_value.addr.ipv4.s_addr; 9372 else { 9373 if (filter.dst_ip_mask == 0) { 9374 printf("can not support ipv6 involved compare.\n"); 9375 return; 9376 } 9377 filter.dst_ip = 0; 9378 } 9379 9380 if (res->src_ip_value.family == AF_INET) 9381 /* no need to convert, already big endian. */ 9382 filter.src_ip = res->src_ip_value.addr.ipv4.s_addr; 9383 else { 9384 if (filter.src_ip_mask == 0) { 9385 printf("can not support ipv6 involved compare.\n"); 9386 return; 9387 } 9388 filter.src_ip = 0; 9389 } 9390 /* need convert to big endian. */ 9391 filter.dst_port = rte_cpu_to_be_16(res->dst_port_value); 9392 filter.src_port = rte_cpu_to_be_16(res->src_port_value); 9393 filter.queue = res->queue_id; 9394 9395 if (!strcmp(res->ops, "add")) 9396 ret = rte_eth_dev_filter_ctrl(res->port_id, 9397 RTE_ETH_FILTER_NTUPLE, 9398 RTE_ETH_FILTER_ADD, 9399 &filter); 9400 else 9401 ret = rte_eth_dev_filter_ctrl(res->port_id, 9402 RTE_ETH_FILTER_NTUPLE, 9403 RTE_ETH_FILTER_DELETE, 9404 &filter); 9405 if (ret < 0) 9406 printf("5tuple filter programming error: (%s)\n", 9407 strerror(-ret)); 9408 } 9409 9410 cmdline_parse_token_string_t cmd_5tuple_filter_filter = 9411 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result, 9412 filter, "5tuple_filter"); 9413 cmdline_parse_token_num_t cmd_5tuple_filter_port_id = 9414 TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result, 9415 port_id, UINT16); 9416 cmdline_parse_token_string_t cmd_5tuple_filter_ops = 9417 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result, 9418 ops, "add#del"); 9419 cmdline_parse_token_string_t cmd_5tuple_filter_dst_ip = 9420 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result, 9421 dst_ip, "dst_ip"); 9422 cmdline_parse_token_ipaddr_t cmd_5tuple_filter_dst_ip_value = 9423 TOKEN_IPADDR_INITIALIZER(struct cmd_5tuple_filter_result, 9424 dst_ip_value); 9425 cmdline_parse_token_string_t cmd_5tuple_filter_src_ip = 9426 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result, 9427 src_ip, "src_ip"); 9428 cmdline_parse_token_ipaddr_t cmd_5tuple_filter_src_ip_value = 9429 TOKEN_IPADDR_INITIALIZER(struct cmd_5tuple_filter_result, 9430 src_ip_value); 9431 cmdline_parse_token_string_t cmd_5tuple_filter_dst_port = 9432 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result, 9433 dst_port, "dst_port"); 9434 cmdline_parse_token_num_t cmd_5tuple_filter_dst_port_value = 9435 TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result, 9436 dst_port_value, UINT16); 9437 cmdline_parse_token_string_t cmd_5tuple_filter_src_port = 9438 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result, 9439 src_port, "src_port"); 9440 cmdline_parse_token_num_t cmd_5tuple_filter_src_port_value = 9441 TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result, 9442 src_port_value, UINT16); 9443 cmdline_parse_token_string_t cmd_5tuple_filter_protocol = 9444 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result, 9445 protocol, "protocol"); 9446 cmdline_parse_token_num_t cmd_5tuple_filter_protocol_value = 9447 TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result, 9448 protocol_value, UINT8); 9449 cmdline_parse_token_string_t cmd_5tuple_filter_mask = 9450 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result, 9451 mask, "mask"); 9452 cmdline_parse_token_num_t cmd_5tuple_filter_mask_value = 9453 TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result, 9454 mask_value, INT8); 9455 cmdline_parse_token_string_t cmd_5tuple_filter_tcp_flags = 9456 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result, 9457 tcp_flags, "tcp_flags"); 9458 cmdline_parse_token_num_t cmd_5tuple_filter_tcp_flags_value = 9459 TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result, 9460 tcp_flags_value, UINT8); 9461 cmdline_parse_token_string_t cmd_5tuple_filter_priority = 9462 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result, 9463 priority, "priority"); 9464 cmdline_parse_token_num_t cmd_5tuple_filter_priority_value = 9465 TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result, 9466 priority_value, UINT8); 9467 cmdline_parse_token_string_t cmd_5tuple_filter_queue = 9468 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result, 9469 queue, "queue"); 9470 cmdline_parse_token_num_t cmd_5tuple_filter_queue_id = 9471 TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result, 9472 queue_id, UINT16); 9473 9474 cmdline_parse_inst_t cmd_5tuple_filter = { 9475 .f = cmd_5tuple_filter_parsed, 9476 .data = NULL, 9477 .help_str = "5tuple_filter <port_id> add|del dst_ip <value> " 9478 "src_ip <value> dst_port <value> src_port <value> " 9479 "protocol <value> mask <value> tcp_flags <value> " 9480 "priority <value> queue <queue_id>: Add/Del a 5tuple filter", 9481 .tokens = { 9482 (void *)&cmd_5tuple_filter_filter, 9483 (void *)&cmd_5tuple_filter_port_id, 9484 (void *)&cmd_5tuple_filter_ops, 9485 (void *)&cmd_5tuple_filter_dst_ip, 9486 (void *)&cmd_5tuple_filter_dst_ip_value, 9487 (void *)&cmd_5tuple_filter_src_ip, 9488 (void *)&cmd_5tuple_filter_src_ip_value, 9489 (void *)&cmd_5tuple_filter_dst_port, 9490 (void *)&cmd_5tuple_filter_dst_port_value, 9491 (void *)&cmd_5tuple_filter_src_port, 9492 (void *)&cmd_5tuple_filter_src_port_value, 9493 (void *)&cmd_5tuple_filter_protocol, 9494 (void *)&cmd_5tuple_filter_protocol_value, 9495 (void *)&cmd_5tuple_filter_mask, 9496 (void *)&cmd_5tuple_filter_mask_value, 9497 (void *)&cmd_5tuple_filter_tcp_flags, 9498 (void *)&cmd_5tuple_filter_tcp_flags_value, 9499 (void *)&cmd_5tuple_filter_priority, 9500 (void *)&cmd_5tuple_filter_priority_value, 9501 (void *)&cmd_5tuple_filter_queue, 9502 (void *)&cmd_5tuple_filter_queue_id, 9503 NULL, 9504 }, 9505 }; 9506 9507 /* *** ADD/REMOVE A flex FILTER *** */ 9508 struct cmd_flex_filter_result { 9509 cmdline_fixed_string_t filter; 9510 cmdline_fixed_string_t ops; 9511 portid_t port_id; 9512 cmdline_fixed_string_t len; 9513 uint8_t len_value; 9514 cmdline_fixed_string_t bytes; 9515 cmdline_fixed_string_t bytes_value; 9516 cmdline_fixed_string_t mask; 9517 cmdline_fixed_string_t mask_value; 9518 cmdline_fixed_string_t priority; 9519 uint8_t priority_value; 9520 cmdline_fixed_string_t queue; 9521 uint16_t queue_id; 9522 }; 9523 9524 static int xdigit2val(unsigned char c) 9525 { 9526 int val; 9527 if (isdigit(c)) 9528 val = c - '0'; 9529 else if (isupper(c)) 9530 val = c - 'A' + 10; 9531 else 9532 val = c - 'a' + 10; 9533 return val; 9534 } 9535 9536 static void 9537 cmd_flex_filter_parsed(void *parsed_result, 9538 __attribute__((unused)) struct cmdline *cl, 9539 __attribute__((unused)) void *data) 9540 { 9541 int ret = 0; 9542 struct rte_eth_flex_filter filter; 9543 struct cmd_flex_filter_result *res = parsed_result; 9544 char *bytes_ptr, *mask_ptr; 9545 uint16_t len, i, j = 0; 9546 char c; 9547 int val; 9548 uint8_t byte = 0; 9549 9550 if (res->len_value > RTE_FLEX_FILTER_MAXLEN) { 9551 printf("the len exceed the max length 128\n"); 9552 return; 9553 } 9554 memset(&filter, 0, sizeof(struct rte_eth_flex_filter)); 9555 filter.len = res->len_value; 9556 filter.priority = res->priority_value; 9557 filter.queue = res->queue_id; 9558 bytes_ptr = res->bytes_value; 9559 mask_ptr = res->mask_value; 9560 9561 /* translate bytes string to array. */ 9562 if (bytes_ptr[0] == '0' && ((bytes_ptr[1] == 'x') || 9563 (bytes_ptr[1] == 'X'))) 9564 bytes_ptr += 2; 9565 len = strnlen(bytes_ptr, res->len_value * 2); 9566 if (len == 0 || (len % 8 != 0)) { 9567 printf("please check len and bytes input\n"); 9568 return; 9569 } 9570 for (i = 0; i < len; i++) { 9571 c = bytes_ptr[i]; 9572 if (isxdigit(c) == 0) { 9573 /* invalid characters. */ 9574 printf("invalid input\n"); 9575 return; 9576 } 9577 val = xdigit2val(c); 9578 if (i % 2) { 9579 byte |= val; 9580 filter.bytes[j] = byte; 9581 printf("bytes[%d]:%02x ", j, filter.bytes[j]); 9582 j++; 9583 byte = 0; 9584 } else 9585 byte |= val << 4; 9586 } 9587 printf("\n"); 9588 /* translate mask string to uint8_t array. */ 9589 if (mask_ptr[0] == '0' && ((mask_ptr[1] == 'x') || 9590 (mask_ptr[1] == 'X'))) 9591 mask_ptr += 2; 9592 len = strnlen(mask_ptr, (res->len_value + 3) / 4); 9593 if (len == 0) { 9594 printf("invalid input\n"); 9595 return; 9596 } 9597 j = 0; 9598 byte = 0; 9599 for (i = 0; i < len; i++) { 9600 c = mask_ptr[i]; 9601 if (isxdigit(c) == 0) { 9602 /* invalid characters. */ 9603 printf("invalid input\n"); 9604 return; 9605 } 9606 val = xdigit2val(c); 9607 if (i % 2) { 9608 byte |= val; 9609 filter.mask[j] = byte; 9610 printf("mask[%d]:%02x ", j, filter.mask[j]); 9611 j++; 9612 byte = 0; 9613 } else 9614 byte |= val << 4; 9615 } 9616 printf("\n"); 9617 9618 if (!strcmp(res->ops, "add")) 9619 ret = rte_eth_dev_filter_ctrl(res->port_id, 9620 RTE_ETH_FILTER_FLEXIBLE, 9621 RTE_ETH_FILTER_ADD, 9622 &filter); 9623 else 9624 ret = rte_eth_dev_filter_ctrl(res->port_id, 9625 RTE_ETH_FILTER_FLEXIBLE, 9626 RTE_ETH_FILTER_DELETE, 9627 &filter); 9628 9629 if (ret < 0) 9630 printf("flex filter setting error: (%s)\n", strerror(-ret)); 9631 } 9632 9633 cmdline_parse_token_string_t cmd_flex_filter_filter = 9634 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result, 9635 filter, "flex_filter"); 9636 cmdline_parse_token_num_t cmd_flex_filter_port_id = 9637 TOKEN_NUM_INITIALIZER(struct cmd_flex_filter_result, 9638 port_id, UINT16); 9639 cmdline_parse_token_string_t cmd_flex_filter_ops = 9640 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result, 9641 ops, "add#del"); 9642 cmdline_parse_token_string_t cmd_flex_filter_len = 9643 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result, 9644 len, "len"); 9645 cmdline_parse_token_num_t cmd_flex_filter_len_value = 9646 TOKEN_NUM_INITIALIZER(struct cmd_flex_filter_result, 9647 len_value, UINT8); 9648 cmdline_parse_token_string_t cmd_flex_filter_bytes = 9649 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result, 9650 bytes, "bytes"); 9651 cmdline_parse_token_string_t cmd_flex_filter_bytes_value = 9652 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result, 9653 bytes_value, NULL); 9654 cmdline_parse_token_string_t cmd_flex_filter_mask = 9655 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result, 9656 mask, "mask"); 9657 cmdline_parse_token_string_t cmd_flex_filter_mask_value = 9658 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result, 9659 mask_value, NULL); 9660 cmdline_parse_token_string_t cmd_flex_filter_priority = 9661 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result, 9662 priority, "priority"); 9663 cmdline_parse_token_num_t cmd_flex_filter_priority_value = 9664 TOKEN_NUM_INITIALIZER(struct cmd_flex_filter_result, 9665 priority_value, UINT8); 9666 cmdline_parse_token_string_t cmd_flex_filter_queue = 9667 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result, 9668 queue, "queue"); 9669 cmdline_parse_token_num_t cmd_flex_filter_queue_id = 9670 TOKEN_NUM_INITIALIZER(struct cmd_flex_filter_result, 9671 queue_id, UINT16); 9672 cmdline_parse_inst_t cmd_flex_filter = { 9673 .f = cmd_flex_filter_parsed, 9674 .data = NULL, 9675 .help_str = "flex_filter <port_id> add|del len <value> bytes " 9676 "<value> mask <value> priority <value> queue <queue_id>: " 9677 "Add/Del a flex filter", 9678 .tokens = { 9679 (void *)&cmd_flex_filter_filter, 9680 (void *)&cmd_flex_filter_port_id, 9681 (void *)&cmd_flex_filter_ops, 9682 (void *)&cmd_flex_filter_len, 9683 (void *)&cmd_flex_filter_len_value, 9684 (void *)&cmd_flex_filter_bytes, 9685 (void *)&cmd_flex_filter_bytes_value, 9686 (void *)&cmd_flex_filter_mask, 9687 (void *)&cmd_flex_filter_mask_value, 9688 (void *)&cmd_flex_filter_priority, 9689 (void *)&cmd_flex_filter_priority_value, 9690 (void *)&cmd_flex_filter_queue, 9691 (void *)&cmd_flex_filter_queue_id, 9692 NULL, 9693 }, 9694 }; 9695 9696 /* *** Filters Control *** */ 9697 9698 /* *** deal with ethertype filter *** */ 9699 struct cmd_ethertype_filter_result { 9700 cmdline_fixed_string_t filter; 9701 portid_t port_id; 9702 cmdline_fixed_string_t ops; 9703 cmdline_fixed_string_t mac; 9704 struct ether_addr mac_addr; 9705 cmdline_fixed_string_t ethertype; 9706 uint16_t ethertype_value; 9707 cmdline_fixed_string_t drop; 9708 cmdline_fixed_string_t queue; 9709 uint16_t queue_id; 9710 }; 9711 9712 cmdline_parse_token_string_t cmd_ethertype_filter_filter = 9713 TOKEN_STRING_INITIALIZER(struct cmd_ethertype_filter_result, 9714 filter, "ethertype_filter"); 9715 cmdline_parse_token_num_t cmd_ethertype_filter_port_id = 9716 TOKEN_NUM_INITIALIZER(struct cmd_ethertype_filter_result, 9717 port_id, UINT16); 9718 cmdline_parse_token_string_t cmd_ethertype_filter_ops = 9719 TOKEN_STRING_INITIALIZER(struct cmd_ethertype_filter_result, 9720 ops, "add#del"); 9721 cmdline_parse_token_string_t cmd_ethertype_filter_mac = 9722 TOKEN_STRING_INITIALIZER(struct cmd_ethertype_filter_result, 9723 mac, "mac_addr#mac_ignr"); 9724 cmdline_parse_token_etheraddr_t cmd_ethertype_filter_mac_addr = 9725 TOKEN_ETHERADDR_INITIALIZER(struct cmd_ethertype_filter_result, 9726 mac_addr); 9727 cmdline_parse_token_string_t cmd_ethertype_filter_ethertype = 9728 TOKEN_STRING_INITIALIZER(struct cmd_ethertype_filter_result, 9729 ethertype, "ethertype"); 9730 cmdline_parse_token_num_t cmd_ethertype_filter_ethertype_value = 9731 TOKEN_NUM_INITIALIZER(struct cmd_ethertype_filter_result, 9732 ethertype_value, UINT16); 9733 cmdline_parse_token_string_t cmd_ethertype_filter_drop = 9734 TOKEN_STRING_INITIALIZER(struct cmd_ethertype_filter_result, 9735 drop, "drop#fwd"); 9736 cmdline_parse_token_string_t cmd_ethertype_filter_queue = 9737 TOKEN_STRING_INITIALIZER(struct cmd_ethertype_filter_result, 9738 queue, "queue"); 9739 cmdline_parse_token_num_t cmd_ethertype_filter_queue_id = 9740 TOKEN_NUM_INITIALIZER(struct cmd_ethertype_filter_result, 9741 queue_id, UINT16); 9742 9743 static void 9744 cmd_ethertype_filter_parsed(void *parsed_result, 9745 __attribute__((unused)) struct cmdline *cl, 9746 __attribute__((unused)) void *data) 9747 { 9748 struct cmd_ethertype_filter_result *res = parsed_result; 9749 struct rte_eth_ethertype_filter filter; 9750 int ret = 0; 9751 9752 ret = rte_eth_dev_filter_supported(res->port_id, 9753 RTE_ETH_FILTER_ETHERTYPE); 9754 if (ret < 0) { 9755 printf("ethertype filter is not supported on port %u.\n", 9756 res->port_id); 9757 return; 9758 } 9759 9760 memset(&filter, 0, sizeof(filter)); 9761 if (!strcmp(res->mac, "mac_addr")) { 9762 filter.flags |= RTE_ETHTYPE_FLAGS_MAC; 9763 rte_memcpy(&filter.mac_addr, &res->mac_addr, 9764 sizeof(struct ether_addr)); 9765 } 9766 if (!strcmp(res->drop, "drop")) 9767 filter.flags |= RTE_ETHTYPE_FLAGS_DROP; 9768 filter.ether_type = res->ethertype_value; 9769 filter.queue = res->queue_id; 9770 9771 if (!strcmp(res->ops, "add")) 9772 ret = rte_eth_dev_filter_ctrl(res->port_id, 9773 RTE_ETH_FILTER_ETHERTYPE, 9774 RTE_ETH_FILTER_ADD, 9775 &filter); 9776 else 9777 ret = rte_eth_dev_filter_ctrl(res->port_id, 9778 RTE_ETH_FILTER_ETHERTYPE, 9779 RTE_ETH_FILTER_DELETE, 9780 &filter); 9781 if (ret < 0) 9782 printf("ethertype filter programming error: (%s)\n", 9783 strerror(-ret)); 9784 } 9785 9786 cmdline_parse_inst_t cmd_ethertype_filter = { 9787 .f = cmd_ethertype_filter_parsed, 9788 .data = NULL, 9789 .help_str = "ethertype_filter <port_id> add|del mac_addr|mac_ignr " 9790 "<mac_addr> ethertype <value> drop|fw queue <queue_id>: " 9791 "Add or delete an ethertype filter entry", 9792 .tokens = { 9793 (void *)&cmd_ethertype_filter_filter, 9794 (void *)&cmd_ethertype_filter_port_id, 9795 (void *)&cmd_ethertype_filter_ops, 9796 (void *)&cmd_ethertype_filter_mac, 9797 (void *)&cmd_ethertype_filter_mac_addr, 9798 (void *)&cmd_ethertype_filter_ethertype, 9799 (void *)&cmd_ethertype_filter_ethertype_value, 9800 (void *)&cmd_ethertype_filter_drop, 9801 (void *)&cmd_ethertype_filter_queue, 9802 (void *)&cmd_ethertype_filter_queue_id, 9803 NULL, 9804 }, 9805 }; 9806 9807 /* *** deal with flow director filter *** */ 9808 struct cmd_flow_director_result { 9809 cmdline_fixed_string_t flow_director_filter; 9810 portid_t port_id; 9811 cmdline_fixed_string_t mode; 9812 cmdline_fixed_string_t mode_value; 9813 cmdline_fixed_string_t ops; 9814 cmdline_fixed_string_t flow; 9815 cmdline_fixed_string_t flow_type; 9816 cmdline_fixed_string_t ether; 9817 uint16_t ether_type; 9818 cmdline_fixed_string_t src; 9819 cmdline_ipaddr_t ip_src; 9820 uint16_t port_src; 9821 cmdline_fixed_string_t dst; 9822 cmdline_ipaddr_t ip_dst; 9823 uint16_t port_dst; 9824 cmdline_fixed_string_t verify_tag; 9825 uint32_t verify_tag_value; 9826 cmdline_ipaddr_t tos; 9827 uint8_t tos_value; 9828 cmdline_ipaddr_t proto; 9829 uint8_t proto_value; 9830 cmdline_ipaddr_t ttl; 9831 uint8_t ttl_value; 9832 cmdline_fixed_string_t vlan; 9833 uint16_t vlan_value; 9834 cmdline_fixed_string_t flexbytes; 9835 cmdline_fixed_string_t flexbytes_value; 9836 cmdline_fixed_string_t pf_vf; 9837 cmdline_fixed_string_t drop; 9838 cmdline_fixed_string_t queue; 9839 uint16_t queue_id; 9840 cmdline_fixed_string_t fd_id; 9841 uint32_t fd_id_value; 9842 cmdline_fixed_string_t mac; 9843 struct ether_addr mac_addr; 9844 cmdline_fixed_string_t tunnel; 9845 cmdline_fixed_string_t tunnel_type; 9846 cmdline_fixed_string_t tunnel_id; 9847 uint32_t tunnel_id_value; 9848 }; 9849 9850 static inline int 9851 parse_flexbytes(const char *q_arg, uint8_t *flexbytes, uint16_t max_num) 9852 { 9853 char s[256]; 9854 const char *p, *p0 = q_arg; 9855 char *end; 9856 unsigned long int_fld; 9857 char *str_fld[max_num]; 9858 int i; 9859 unsigned size; 9860 int ret = -1; 9861 9862 p = strchr(p0, '('); 9863 if (p == NULL) 9864 return -1; 9865 ++p; 9866 p0 = strchr(p, ')'); 9867 if (p0 == NULL) 9868 return -1; 9869 9870 size = p0 - p; 9871 if (size >= sizeof(s)) 9872 return -1; 9873 9874 snprintf(s, sizeof(s), "%.*s", size, p); 9875 ret = rte_strsplit(s, sizeof(s), str_fld, max_num, ','); 9876 if (ret < 0 || ret > max_num) 9877 return -1; 9878 for (i = 0; i < ret; i++) { 9879 errno = 0; 9880 int_fld = strtoul(str_fld[i], &end, 0); 9881 if (errno != 0 || *end != '\0' || int_fld > UINT8_MAX) 9882 return -1; 9883 flexbytes[i] = (uint8_t)int_fld; 9884 } 9885 return ret; 9886 } 9887 9888 static uint16_t 9889 str2flowtype(char *string) 9890 { 9891 uint8_t i = 0; 9892 static const struct { 9893 char str[32]; 9894 uint16_t type; 9895 } flowtype_str[] = { 9896 {"raw", RTE_ETH_FLOW_RAW}, 9897 {"ipv4", RTE_ETH_FLOW_IPV4}, 9898 {"ipv4-frag", RTE_ETH_FLOW_FRAG_IPV4}, 9899 {"ipv4-tcp", RTE_ETH_FLOW_NONFRAG_IPV4_TCP}, 9900 {"ipv4-udp", RTE_ETH_FLOW_NONFRAG_IPV4_UDP}, 9901 {"ipv4-sctp", RTE_ETH_FLOW_NONFRAG_IPV4_SCTP}, 9902 {"ipv4-other", RTE_ETH_FLOW_NONFRAG_IPV4_OTHER}, 9903 {"ipv6", RTE_ETH_FLOW_IPV6}, 9904 {"ipv6-frag", RTE_ETH_FLOW_FRAG_IPV6}, 9905 {"ipv6-tcp", RTE_ETH_FLOW_NONFRAG_IPV6_TCP}, 9906 {"ipv6-udp", RTE_ETH_FLOW_NONFRAG_IPV6_UDP}, 9907 {"ipv6-sctp", RTE_ETH_FLOW_NONFRAG_IPV6_SCTP}, 9908 {"ipv6-other", RTE_ETH_FLOW_NONFRAG_IPV6_OTHER}, 9909 {"l2_payload", RTE_ETH_FLOW_L2_PAYLOAD}, 9910 }; 9911 9912 for (i = 0; i < RTE_DIM(flowtype_str); i++) { 9913 if (!strcmp(flowtype_str[i].str, string)) 9914 return flowtype_str[i].type; 9915 } 9916 9917 if (isdigit(string[0]) && atoi(string) > 0 && atoi(string) < 64) 9918 return (uint16_t)atoi(string); 9919 9920 return RTE_ETH_FLOW_UNKNOWN; 9921 } 9922 9923 static enum rte_eth_fdir_tunnel_type 9924 str2fdir_tunneltype(char *string) 9925 { 9926 uint8_t i = 0; 9927 9928 static const struct { 9929 char str[32]; 9930 enum rte_eth_fdir_tunnel_type type; 9931 } tunneltype_str[] = { 9932 {"NVGRE", RTE_FDIR_TUNNEL_TYPE_NVGRE}, 9933 {"VxLAN", RTE_FDIR_TUNNEL_TYPE_VXLAN}, 9934 }; 9935 9936 for (i = 0; i < RTE_DIM(tunneltype_str); i++) { 9937 if (!strcmp(tunneltype_str[i].str, string)) 9938 return tunneltype_str[i].type; 9939 } 9940 return RTE_FDIR_TUNNEL_TYPE_UNKNOWN; 9941 } 9942 9943 #define IPV4_ADDR_TO_UINT(ip_addr, ip) \ 9944 do { \ 9945 if ((ip_addr).family == AF_INET) \ 9946 (ip) = (ip_addr).addr.ipv4.s_addr; \ 9947 else { \ 9948 printf("invalid parameter.\n"); \ 9949 return; \ 9950 } \ 9951 } while (0) 9952 9953 #define IPV6_ADDR_TO_ARRAY(ip_addr, ip) \ 9954 do { \ 9955 if ((ip_addr).family == AF_INET6) \ 9956 rte_memcpy(&(ip), \ 9957 &((ip_addr).addr.ipv6), \ 9958 sizeof(struct in6_addr)); \ 9959 else { \ 9960 printf("invalid parameter.\n"); \ 9961 return; \ 9962 } \ 9963 } while (0) 9964 9965 static void 9966 cmd_flow_director_filter_parsed(void *parsed_result, 9967 __attribute__((unused)) struct cmdline *cl, 9968 __attribute__((unused)) void *data) 9969 { 9970 struct cmd_flow_director_result *res = parsed_result; 9971 struct rte_eth_fdir_filter entry; 9972 uint8_t flexbytes[RTE_ETH_FDIR_MAX_FLEXLEN]; 9973 char *end; 9974 unsigned long vf_id; 9975 int ret = 0; 9976 9977 ret = rte_eth_dev_filter_supported(res->port_id, RTE_ETH_FILTER_FDIR); 9978 if (ret < 0) { 9979 printf("flow director is not supported on port %u.\n", 9980 res->port_id); 9981 return; 9982 } 9983 memset(flexbytes, 0, sizeof(flexbytes)); 9984 memset(&entry, 0, sizeof(struct rte_eth_fdir_filter)); 9985 9986 if (fdir_conf.mode == RTE_FDIR_MODE_PERFECT_MAC_VLAN) { 9987 if (strcmp(res->mode_value, "MAC-VLAN")) { 9988 printf("Please set mode to MAC-VLAN.\n"); 9989 return; 9990 } 9991 } else if (fdir_conf.mode == RTE_FDIR_MODE_PERFECT_TUNNEL) { 9992 if (strcmp(res->mode_value, "Tunnel")) { 9993 printf("Please set mode to Tunnel.\n"); 9994 return; 9995 } 9996 } else { 9997 if (strcmp(res->mode_value, "IP")) { 9998 printf("Please set mode to IP.\n"); 9999 return; 10000 } 10001 entry.input.flow_type = str2flowtype(res->flow_type); 10002 } 10003 10004 ret = parse_flexbytes(res->flexbytes_value, 10005 flexbytes, 10006 RTE_ETH_FDIR_MAX_FLEXLEN); 10007 if (ret < 0) { 10008 printf("error: Cannot parse flexbytes input.\n"); 10009 return; 10010 } 10011 10012 switch (entry.input.flow_type) { 10013 case RTE_ETH_FLOW_FRAG_IPV4: 10014 case RTE_ETH_FLOW_NONFRAG_IPV4_OTHER: 10015 entry.input.flow.ip4_flow.proto = res->proto_value; 10016 /* fall-through */ 10017 case RTE_ETH_FLOW_NONFRAG_IPV4_UDP: 10018 case RTE_ETH_FLOW_NONFRAG_IPV4_TCP: 10019 IPV4_ADDR_TO_UINT(res->ip_dst, 10020 entry.input.flow.ip4_flow.dst_ip); 10021 IPV4_ADDR_TO_UINT(res->ip_src, 10022 entry.input.flow.ip4_flow.src_ip); 10023 entry.input.flow.ip4_flow.tos = res->tos_value; 10024 entry.input.flow.ip4_flow.ttl = res->ttl_value; 10025 /* need convert to big endian. */ 10026 entry.input.flow.udp4_flow.dst_port = 10027 rte_cpu_to_be_16(res->port_dst); 10028 entry.input.flow.udp4_flow.src_port = 10029 rte_cpu_to_be_16(res->port_src); 10030 break; 10031 case RTE_ETH_FLOW_NONFRAG_IPV4_SCTP: 10032 IPV4_ADDR_TO_UINT(res->ip_dst, 10033 entry.input.flow.sctp4_flow.ip.dst_ip); 10034 IPV4_ADDR_TO_UINT(res->ip_src, 10035 entry.input.flow.sctp4_flow.ip.src_ip); 10036 entry.input.flow.ip4_flow.tos = res->tos_value; 10037 entry.input.flow.ip4_flow.ttl = res->ttl_value; 10038 /* need convert to big endian. */ 10039 entry.input.flow.sctp4_flow.dst_port = 10040 rte_cpu_to_be_16(res->port_dst); 10041 entry.input.flow.sctp4_flow.src_port = 10042 rte_cpu_to_be_16(res->port_src); 10043 entry.input.flow.sctp4_flow.verify_tag = 10044 rte_cpu_to_be_32(res->verify_tag_value); 10045 break; 10046 case RTE_ETH_FLOW_FRAG_IPV6: 10047 case RTE_ETH_FLOW_NONFRAG_IPV6_OTHER: 10048 entry.input.flow.ipv6_flow.proto = res->proto_value; 10049 /* fall-through */ 10050 case RTE_ETH_FLOW_NONFRAG_IPV6_UDP: 10051 case RTE_ETH_FLOW_NONFRAG_IPV6_TCP: 10052 IPV6_ADDR_TO_ARRAY(res->ip_dst, 10053 entry.input.flow.ipv6_flow.dst_ip); 10054 IPV6_ADDR_TO_ARRAY(res->ip_src, 10055 entry.input.flow.ipv6_flow.src_ip); 10056 entry.input.flow.ipv6_flow.tc = res->tos_value; 10057 entry.input.flow.ipv6_flow.hop_limits = res->ttl_value; 10058 /* need convert to big endian. */ 10059 entry.input.flow.udp6_flow.dst_port = 10060 rte_cpu_to_be_16(res->port_dst); 10061 entry.input.flow.udp6_flow.src_port = 10062 rte_cpu_to_be_16(res->port_src); 10063 break; 10064 case RTE_ETH_FLOW_NONFRAG_IPV6_SCTP: 10065 IPV6_ADDR_TO_ARRAY(res->ip_dst, 10066 entry.input.flow.sctp6_flow.ip.dst_ip); 10067 IPV6_ADDR_TO_ARRAY(res->ip_src, 10068 entry.input.flow.sctp6_flow.ip.src_ip); 10069 entry.input.flow.ipv6_flow.tc = res->tos_value; 10070 entry.input.flow.ipv6_flow.hop_limits = res->ttl_value; 10071 /* need convert to big endian. */ 10072 entry.input.flow.sctp6_flow.dst_port = 10073 rte_cpu_to_be_16(res->port_dst); 10074 entry.input.flow.sctp6_flow.src_port = 10075 rte_cpu_to_be_16(res->port_src); 10076 entry.input.flow.sctp6_flow.verify_tag = 10077 rte_cpu_to_be_32(res->verify_tag_value); 10078 break; 10079 case RTE_ETH_FLOW_L2_PAYLOAD: 10080 entry.input.flow.l2_flow.ether_type = 10081 rte_cpu_to_be_16(res->ether_type); 10082 break; 10083 default: 10084 break; 10085 } 10086 10087 if (fdir_conf.mode == RTE_FDIR_MODE_PERFECT_MAC_VLAN) 10088 rte_memcpy(&entry.input.flow.mac_vlan_flow.mac_addr, 10089 &res->mac_addr, 10090 sizeof(struct ether_addr)); 10091 10092 if (fdir_conf.mode == RTE_FDIR_MODE_PERFECT_TUNNEL) { 10093 rte_memcpy(&entry.input.flow.tunnel_flow.mac_addr, 10094 &res->mac_addr, 10095 sizeof(struct ether_addr)); 10096 entry.input.flow.tunnel_flow.tunnel_type = 10097 str2fdir_tunneltype(res->tunnel_type); 10098 entry.input.flow.tunnel_flow.tunnel_id = 10099 rte_cpu_to_be_32(res->tunnel_id_value); 10100 } 10101 10102 rte_memcpy(entry.input.flow_ext.flexbytes, 10103 flexbytes, 10104 RTE_ETH_FDIR_MAX_FLEXLEN); 10105 10106 entry.input.flow_ext.vlan_tci = rte_cpu_to_be_16(res->vlan_value); 10107 10108 entry.action.flex_off = 0; /*use 0 by default */ 10109 if (!strcmp(res->drop, "drop")) 10110 entry.action.behavior = RTE_ETH_FDIR_REJECT; 10111 else 10112 entry.action.behavior = RTE_ETH_FDIR_ACCEPT; 10113 10114 if (fdir_conf.mode != RTE_FDIR_MODE_PERFECT_MAC_VLAN && 10115 fdir_conf.mode != RTE_FDIR_MODE_PERFECT_TUNNEL) { 10116 if (!strcmp(res->pf_vf, "pf")) 10117 entry.input.flow_ext.is_vf = 0; 10118 else if (!strncmp(res->pf_vf, "vf", 2)) { 10119 struct rte_eth_dev_info dev_info; 10120 10121 memset(&dev_info, 0, sizeof(dev_info)); 10122 rte_eth_dev_info_get(res->port_id, &dev_info); 10123 errno = 0; 10124 vf_id = strtoul(res->pf_vf + 2, &end, 10); 10125 if (errno != 0 || *end != '\0' || 10126 vf_id >= dev_info.max_vfs) { 10127 printf("invalid parameter %s.\n", res->pf_vf); 10128 return; 10129 } 10130 entry.input.flow_ext.is_vf = 1; 10131 entry.input.flow_ext.dst_id = (uint16_t)vf_id; 10132 } else { 10133 printf("invalid parameter %s.\n", res->pf_vf); 10134 return; 10135 } 10136 } 10137 10138 /* set to report FD ID by default */ 10139 entry.action.report_status = RTE_ETH_FDIR_REPORT_ID; 10140 entry.action.rx_queue = res->queue_id; 10141 entry.soft_id = res->fd_id_value; 10142 if (!strcmp(res->ops, "add")) 10143 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_FDIR, 10144 RTE_ETH_FILTER_ADD, &entry); 10145 else if (!strcmp(res->ops, "del")) 10146 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_FDIR, 10147 RTE_ETH_FILTER_DELETE, &entry); 10148 else 10149 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_FDIR, 10150 RTE_ETH_FILTER_UPDATE, &entry); 10151 if (ret < 0) 10152 printf("flow director programming error: (%s)\n", 10153 strerror(-ret)); 10154 } 10155 10156 cmdline_parse_token_string_t cmd_flow_director_filter = 10157 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result, 10158 flow_director_filter, "flow_director_filter"); 10159 cmdline_parse_token_num_t cmd_flow_director_port_id = 10160 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result, 10161 port_id, UINT16); 10162 cmdline_parse_token_string_t cmd_flow_director_ops = 10163 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result, 10164 ops, "add#del#update"); 10165 cmdline_parse_token_string_t cmd_flow_director_flow = 10166 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result, 10167 flow, "flow"); 10168 cmdline_parse_token_string_t cmd_flow_director_flow_type = 10169 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result, 10170 flow_type, "ipv4-other#ipv4-frag#ipv4-tcp#ipv4-udp#ipv4-sctp#" 10171 "ipv6-other#ipv6-frag#ipv6-tcp#ipv6-udp#ipv6-sctp#l2_payload"); 10172 cmdline_parse_token_string_t cmd_flow_director_ether = 10173 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result, 10174 ether, "ether"); 10175 cmdline_parse_token_num_t cmd_flow_director_ether_type = 10176 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result, 10177 ether_type, UINT16); 10178 cmdline_parse_token_string_t cmd_flow_director_src = 10179 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result, 10180 src, "src"); 10181 cmdline_parse_token_ipaddr_t cmd_flow_director_ip_src = 10182 TOKEN_IPADDR_INITIALIZER(struct cmd_flow_director_result, 10183 ip_src); 10184 cmdline_parse_token_num_t cmd_flow_director_port_src = 10185 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result, 10186 port_src, UINT16); 10187 cmdline_parse_token_string_t cmd_flow_director_dst = 10188 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result, 10189 dst, "dst"); 10190 cmdline_parse_token_ipaddr_t cmd_flow_director_ip_dst = 10191 TOKEN_IPADDR_INITIALIZER(struct cmd_flow_director_result, 10192 ip_dst); 10193 cmdline_parse_token_num_t cmd_flow_director_port_dst = 10194 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result, 10195 port_dst, UINT16); 10196 cmdline_parse_token_string_t cmd_flow_director_verify_tag = 10197 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result, 10198 verify_tag, "verify_tag"); 10199 cmdline_parse_token_num_t cmd_flow_director_verify_tag_value = 10200 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result, 10201 verify_tag_value, UINT32); 10202 cmdline_parse_token_string_t cmd_flow_director_tos = 10203 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result, 10204 tos, "tos"); 10205 cmdline_parse_token_num_t cmd_flow_director_tos_value = 10206 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result, 10207 tos_value, UINT8); 10208 cmdline_parse_token_string_t cmd_flow_director_proto = 10209 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result, 10210 proto, "proto"); 10211 cmdline_parse_token_num_t cmd_flow_director_proto_value = 10212 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result, 10213 proto_value, UINT8); 10214 cmdline_parse_token_string_t cmd_flow_director_ttl = 10215 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result, 10216 ttl, "ttl"); 10217 cmdline_parse_token_num_t cmd_flow_director_ttl_value = 10218 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result, 10219 ttl_value, UINT8); 10220 cmdline_parse_token_string_t cmd_flow_director_vlan = 10221 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result, 10222 vlan, "vlan"); 10223 cmdline_parse_token_num_t cmd_flow_director_vlan_value = 10224 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result, 10225 vlan_value, UINT16); 10226 cmdline_parse_token_string_t cmd_flow_director_flexbytes = 10227 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result, 10228 flexbytes, "flexbytes"); 10229 cmdline_parse_token_string_t cmd_flow_director_flexbytes_value = 10230 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result, 10231 flexbytes_value, NULL); 10232 cmdline_parse_token_string_t cmd_flow_director_drop = 10233 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result, 10234 drop, "drop#fwd"); 10235 cmdline_parse_token_string_t cmd_flow_director_pf_vf = 10236 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result, 10237 pf_vf, NULL); 10238 cmdline_parse_token_string_t cmd_flow_director_queue = 10239 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result, 10240 queue, "queue"); 10241 cmdline_parse_token_num_t cmd_flow_director_queue_id = 10242 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result, 10243 queue_id, UINT16); 10244 cmdline_parse_token_string_t cmd_flow_director_fd_id = 10245 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result, 10246 fd_id, "fd_id"); 10247 cmdline_parse_token_num_t cmd_flow_director_fd_id_value = 10248 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result, 10249 fd_id_value, UINT32); 10250 10251 cmdline_parse_token_string_t cmd_flow_director_mode = 10252 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result, 10253 mode, "mode"); 10254 cmdline_parse_token_string_t cmd_flow_director_mode_ip = 10255 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result, 10256 mode_value, "IP"); 10257 cmdline_parse_token_string_t cmd_flow_director_mode_mac_vlan = 10258 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result, 10259 mode_value, "MAC-VLAN"); 10260 cmdline_parse_token_string_t cmd_flow_director_mode_tunnel = 10261 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result, 10262 mode_value, "Tunnel"); 10263 cmdline_parse_token_string_t cmd_flow_director_mac = 10264 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result, 10265 mac, "mac"); 10266 cmdline_parse_token_etheraddr_t cmd_flow_director_mac_addr = 10267 TOKEN_ETHERADDR_INITIALIZER(struct cmd_flow_director_result, 10268 mac_addr); 10269 cmdline_parse_token_string_t cmd_flow_director_tunnel = 10270 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result, 10271 tunnel, "tunnel"); 10272 cmdline_parse_token_string_t cmd_flow_director_tunnel_type = 10273 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result, 10274 tunnel_type, "NVGRE#VxLAN"); 10275 cmdline_parse_token_string_t cmd_flow_director_tunnel_id = 10276 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result, 10277 tunnel_id, "tunnel-id"); 10278 cmdline_parse_token_num_t cmd_flow_director_tunnel_id_value = 10279 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result, 10280 tunnel_id_value, UINT32); 10281 10282 cmdline_parse_inst_t cmd_add_del_ip_flow_director = { 10283 .f = cmd_flow_director_filter_parsed, 10284 .data = NULL, 10285 .help_str = "flow_director_filter <port_id> mode IP add|del|update flow" 10286 " ipv4-other|ipv4-frag|ipv4-tcp|ipv4-udp|ipv4-sctp|" 10287 "ipv6-other|ipv6-frag|ipv6-tcp|ipv6-udp|ipv6-sctp|" 10288 "l2_payload src <src_ip> dst <dst_ip> tos <tos_value> " 10289 "proto <proto_value> ttl <ttl_value> vlan <vlan_value> " 10290 "flexbytes <flexbyte_values> drop|fw <pf_vf> queue <queue_id> " 10291 "fd_id <fd_id_value>: " 10292 "Add or delete an ip flow director entry on NIC", 10293 .tokens = { 10294 (void *)&cmd_flow_director_filter, 10295 (void *)&cmd_flow_director_port_id, 10296 (void *)&cmd_flow_director_mode, 10297 (void *)&cmd_flow_director_mode_ip, 10298 (void *)&cmd_flow_director_ops, 10299 (void *)&cmd_flow_director_flow, 10300 (void *)&cmd_flow_director_flow_type, 10301 (void *)&cmd_flow_director_src, 10302 (void *)&cmd_flow_director_ip_src, 10303 (void *)&cmd_flow_director_dst, 10304 (void *)&cmd_flow_director_ip_dst, 10305 (void *)&cmd_flow_director_tos, 10306 (void *)&cmd_flow_director_tos_value, 10307 (void *)&cmd_flow_director_proto, 10308 (void *)&cmd_flow_director_proto_value, 10309 (void *)&cmd_flow_director_ttl, 10310 (void *)&cmd_flow_director_ttl_value, 10311 (void *)&cmd_flow_director_vlan, 10312 (void *)&cmd_flow_director_vlan_value, 10313 (void *)&cmd_flow_director_flexbytes, 10314 (void *)&cmd_flow_director_flexbytes_value, 10315 (void *)&cmd_flow_director_drop, 10316 (void *)&cmd_flow_director_pf_vf, 10317 (void *)&cmd_flow_director_queue, 10318 (void *)&cmd_flow_director_queue_id, 10319 (void *)&cmd_flow_director_fd_id, 10320 (void *)&cmd_flow_director_fd_id_value, 10321 NULL, 10322 }, 10323 }; 10324 10325 cmdline_parse_inst_t cmd_add_del_udp_flow_director = { 10326 .f = cmd_flow_director_filter_parsed, 10327 .data = NULL, 10328 .help_str = "flow_director_filter ... : Add or delete an udp/tcp flow " 10329 "director entry on NIC", 10330 .tokens = { 10331 (void *)&cmd_flow_director_filter, 10332 (void *)&cmd_flow_director_port_id, 10333 (void *)&cmd_flow_director_mode, 10334 (void *)&cmd_flow_director_mode_ip, 10335 (void *)&cmd_flow_director_ops, 10336 (void *)&cmd_flow_director_flow, 10337 (void *)&cmd_flow_director_flow_type, 10338 (void *)&cmd_flow_director_src, 10339 (void *)&cmd_flow_director_ip_src, 10340 (void *)&cmd_flow_director_port_src, 10341 (void *)&cmd_flow_director_dst, 10342 (void *)&cmd_flow_director_ip_dst, 10343 (void *)&cmd_flow_director_port_dst, 10344 (void *)&cmd_flow_director_tos, 10345 (void *)&cmd_flow_director_tos_value, 10346 (void *)&cmd_flow_director_ttl, 10347 (void *)&cmd_flow_director_ttl_value, 10348 (void *)&cmd_flow_director_vlan, 10349 (void *)&cmd_flow_director_vlan_value, 10350 (void *)&cmd_flow_director_flexbytes, 10351 (void *)&cmd_flow_director_flexbytes_value, 10352 (void *)&cmd_flow_director_drop, 10353 (void *)&cmd_flow_director_pf_vf, 10354 (void *)&cmd_flow_director_queue, 10355 (void *)&cmd_flow_director_queue_id, 10356 (void *)&cmd_flow_director_fd_id, 10357 (void *)&cmd_flow_director_fd_id_value, 10358 NULL, 10359 }, 10360 }; 10361 10362 cmdline_parse_inst_t cmd_add_del_sctp_flow_director = { 10363 .f = cmd_flow_director_filter_parsed, 10364 .data = NULL, 10365 .help_str = "flow_director_filter ... : Add or delete a sctp flow " 10366 "director entry on NIC", 10367 .tokens = { 10368 (void *)&cmd_flow_director_filter, 10369 (void *)&cmd_flow_director_port_id, 10370 (void *)&cmd_flow_director_mode, 10371 (void *)&cmd_flow_director_mode_ip, 10372 (void *)&cmd_flow_director_ops, 10373 (void *)&cmd_flow_director_flow, 10374 (void *)&cmd_flow_director_flow_type, 10375 (void *)&cmd_flow_director_src, 10376 (void *)&cmd_flow_director_ip_src, 10377 (void *)&cmd_flow_director_port_dst, 10378 (void *)&cmd_flow_director_dst, 10379 (void *)&cmd_flow_director_ip_dst, 10380 (void *)&cmd_flow_director_port_dst, 10381 (void *)&cmd_flow_director_verify_tag, 10382 (void *)&cmd_flow_director_verify_tag_value, 10383 (void *)&cmd_flow_director_tos, 10384 (void *)&cmd_flow_director_tos_value, 10385 (void *)&cmd_flow_director_ttl, 10386 (void *)&cmd_flow_director_ttl_value, 10387 (void *)&cmd_flow_director_vlan, 10388 (void *)&cmd_flow_director_vlan_value, 10389 (void *)&cmd_flow_director_flexbytes, 10390 (void *)&cmd_flow_director_flexbytes_value, 10391 (void *)&cmd_flow_director_drop, 10392 (void *)&cmd_flow_director_pf_vf, 10393 (void *)&cmd_flow_director_queue, 10394 (void *)&cmd_flow_director_queue_id, 10395 (void *)&cmd_flow_director_fd_id, 10396 (void *)&cmd_flow_director_fd_id_value, 10397 NULL, 10398 }, 10399 }; 10400 10401 cmdline_parse_inst_t cmd_add_del_l2_flow_director = { 10402 .f = cmd_flow_director_filter_parsed, 10403 .data = NULL, 10404 .help_str = "flow_director_filter ... : Add or delete a L2 flow " 10405 "director entry on NIC", 10406 .tokens = { 10407 (void *)&cmd_flow_director_filter, 10408 (void *)&cmd_flow_director_port_id, 10409 (void *)&cmd_flow_director_mode, 10410 (void *)&cmd_flow_director_mode_ip, 10411 (void *)&cmd_flow_director_ops, 10412 (void *)&cmd_flow_director_flow, 10413 (void *)&cmd_flow_director_flow_type, 10414 (void *)&cmd_flow_director_ether, 10415 (void *)&cmd_flow_director_ether_type, 10416 (void *)&cmd_flow_director_flexbytes, 10417 (void *)&cmd_flow_director_flexbytes_value, 10418 (void *)&cmd_flow_director_drop, 10419 (void *)&cmd_flow_director_pf_vf, 10420 (void *)&cmd_flow_director_queue, 10421 (void *)&cmd_flow_director_queue_id, 10422 (void *)&cmd_flow_director_fd_id, 10423 (void *)&cmd_flow_director_fd_id_value, 10424 NULL, 10425 }, 10426 }; 10427 10428 cmdline_parse_inst_t cmd_add_del_mac_vlan_flow_director = { 10429 .f = cmd_flow_director_filter_parsed, 10430 .data = NULL, 10431 .help_str = "flow_director_filter ... : Add or delete a MAC VLAN flow " 10432 "director entry on NIC", 10433 .tokens = { 10434 (void *)&cmd_flow_director_filter, 10435 (void *)&cmd_flow_director_port_id, 10436 (void *)&cmd_flow_director_mode, 10437 (void *)&cmd_flow_director_mode_mac_vlan, 10438 (void *)&cmd_flow_director_ops, 10439 (void *)&cmd_flow_director_mac, 10440 (void *)&cmd_flow_director_mac_addr, 10441 (void *)&cmd_flow_director_vlan, 10442 (void *)&cmd_flow_director_vlan_value, 10443 (void *)&cmd_flow_director_flexbytes, 10444 (void *)&cmd_flow_director_flexbytes_value, 10445 (void *)&cmd_flow_director_drop, 10446 (void *)&cmd_flow_director_queue, 10447 (void *)&cmd_flow_director_queue_id, 10448 (void *)&cmd_flow_director_fd_id, 10449 (void *)&cmd_flow_director_fd_id_value, 10450 NULL, 10451 }, 10452 }; 10453 10454 cmdline_parse_inst_t cmd_add_del_tunnel_flow_director = { 10455 .f = cmd_flow_director_filter_parsed, 10456 .data = NULL, 10457 .help_str = "flow_director_filter ... : Add or delete a tunnel flow " 10458 "director entry on NIC", 10459 .tokens = { 10460 (void *)&cmd_flow_director_filter, 10461 (void *)&cmd_flow_director_port_id, 10462 (void *)&cmd_flow_director_mode, 10463 (void *)&cmd_flow_director_mode_tunnel, 10464 (void *)&cmd_flow_director_ops, 10465 (void *)&cmd_flow_director_mac, 10466 (void *)&cmd_flow_director_mac_addr, 10467 (void *)&cmd_flow_director_vlan, 10468 (void *)&cmd_flow_director_vlan_value, 10469 (void *)&cmd_flow_director_tunnel, 10470 (void *)&cmd_flow_director_tunnel_type, 10471 (void *)&cmd_flow_director_tunnel_id, 10472 (void *)&cmd_flow_director_tunnel_id_value, 10473 (void *)&cmd_flow_director_flexbytes, 10474 (void *)&cmd_flow_director_flexbytes_value, 10475 (void *)&cmd_flow_director_drop, 10476 (void *)&cmd_flow_director_queue, 10477 (void *)&cmd_flow_director_queue_id, 10478 (void *)&cmd_flow_director_fd_id, 10479 (void *)&cmd_flow_director_fd_id_value, 10480 NULL, 10481 }, 10482 }; 10483 10484 struct cmd_flush_flow_director_result { 10485 cmdline_fixed_string_t flush_flow_director; 10486 portid_t port_id; 10487 }; 10488 10489 cmdline_parse_token_string_t cmd_flush_flow_director_flush = 10490 TOKEN_STRING_INITIALIZER(struct cmd_flush_flow_director_result, 10491 flush_flow_director, "flush_flow_director"); 10492 cmdline_parse_token_num_t cmd_flush_flow_director_port_id = 10493 TOKEN_NUM_INITIALIZER(struct cmd_flush_flow_director_result, 10494 port_id, UINT16); 10495 10496 static void 10497 cmd_flush_flow_director_parsed(void *parsed_result, 10498 __attribute__((unused)) struct cmdline *cl, 10499 __attribute__((unused)) void *data) 10500 { 10501 struct cmd_flow_director_result *res = parsed_result; 10502 int ret = 0; 10503 10504 ret = rte_eth_dev_filter_supported(res->port_id, RTE_ETH_FILTER_FDIR); 10505 if (ret < 0) { 10506 printf("flow director is not supported on port %u.\n", 10507 res->port_id); 10508 return; 10509 } 10510 10511 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_FDIR, 10512 RTE_ETH_FILTER_FLUSH, NULL); 10513 if (ret < 0) 10514 printf("flow director table flushing error: (%s)\n", 10515 strerror(-ret)); 10516 } 10517 10518 cmdline_parse_inst_t cmd_flush_flow_director = { 10519 .f = cmd_flush_flow_director_parsed, 10520 .data = NULL, 10521 .help_str = "flush_flow_director <port_id>: " 10522 "Flush all flow director entries of a device on NIC", 10523 .tokens = { 10524 (void *)&cmd_flush_flow_director_flush, 10525 (void *)&cmd_flush_flow_director_port_id, 10526 NULL, 10527 }, 10528 }; 10529 10530 /* *** deal with flow director mask *** */ 10531 struct cmd_flow_director_mask_result { 10532 cmdline_fixed_string_t flow_director_mask; 10533 portid_t port_id; 10534 cmdline_fixed_string_t mode; 10535 cmdline_fixed_string_t mode_value; 10536 cmdline_fixed_string_t vlan; 10537 uint16_t vlan_mask; 10538 cmdline_fixed_string_t src_mask; 10539 cmdline_ipaddr_t ipv4_src; 10540 cmdline_ipaddr_t ipv6_src; 10541 uint16_t port_src; 10542 cmdline_fixed_string_t dst_mask; 10543 cmdline_ipaddr_t ipv4_dst; 10544 cmdline_ipaddr_t ipv6_dst; 10545 uint16_t port_dst; 10546 cmdline_fixed_string_t mac; 10547 uint8_t mac_addr_byte_mask; 10548 cmdline_fixed_string_t tunnel_id; 10549 uint32_t tunnel_id_mask; 10550 cmdline_fixed_string_t tunnel_type; 10551 uint8_t tunnel_type_mask; 10552 }; 10553 10554 static void 10555 cmd_flow_director_mask_parsed(void *parsed_result, 10556 __attribute__((unused)) struct cmdline *cl, 10557 __attribute__((unused)) void *data) 10558 { 10559 struct cmd_flow_director_mask_result *res = parsed_result; 10560 struct rte_eth_fdir_masks *mask; 10561 struct rte_port *port; 10562 10563 if (res->port_id > nb_ports) { 10564 printf("Invalid port, range is [0, %d]\n", nb_ports - 1); 10565 return; 10566 } 10567 10568 port = &ports[res->port_id]; 10569 /** Check if the port is not started **/ 10570 if (port->port_status != RTE_PORT_STOPPED) { 10571 printf("Please stop port %d first\n", res->port_id); 10572 return; 10573 } 10574 10575 mask = &port->dev_conf.fdir_conf.mask; 10576 10577 if (fdir_conf.mode == RTE_FDIR_MODE_PERFECT_MAC_VLAN) { 10578 if (strcmp(res->mode_value, "MAC-VLAN")) { 10579 printf("Please set mode to MAC-VLAN.\n"); 10580 return; 10581 } 10582 10583 mask->vlan_tci_mask = rte_cpu_to_be_16(res->vlan_mask); 10584 } else if (fdir_conf.mode == RTE_FDIR_MODE_PERFECT_TUNNEL) { 10585 if (strcmp(res->mode_value, "Tunnel")) { 10586 printf("Please set mode to Tunnel.\n"); 10587 return; 10588 } 10589 10590 mask->vlan_tci_mask = rte_cpu_to_be_16(res->vlan_mask); 10591 mask->mac_addr_byte_mask = res->mac_addr_byte_mask; 10592 mask->tunnel_id_mask = rte_cpu_to_be_32(res->tunnel_id_mask); 10593 mask->tunnel_type_mask = res->tunnel_type_mask; 10594 } else { 10595 if (strcmp(res->mode_value, "IP")) { 10596 printf("Please set mode to IP.\n"); 10597 return; 10598 } 10599 10600 mask->vlan_tci_mask = rte_cpu_to_be_16(res->vlan_mask); 10601 IPV4_ADDR_TO_UINT(res->ipv4_src, mask->ipv4_mask.src_ip); 10602 IPV4_ADDR_TO_UINT(res->ipv4_dst, mask->ipv4_mask.dst_ip); 10603 IPV6_ADDR_TO_ARRAY(res->ipv6_src, mask->ipv6_mask.src_ip); 10604 IPV6_ADDR_TO_ARRAY(res->ipv6_dst, mask->ipv6_mask.dst_ip); 10605 mask->src_port_mask = rte_cpu_to_be_16(res->port_src); 10606 mask->dst_port_mask = rte_cpu_to_be_16(res->port_dst); 10607 } 10608 10609 cmd_reconfig_device_queue(res->port_id, 1, 1); 10610 } 10611 10612 cmdline_parse_token_string_t cmd_flow_director_mask = 10613 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result, 10614 flow_director_mask, "flow_director_mask"); 10615 cmdline_parse_token_num_t cmd_flow_director_mask_port_id = 10616 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_mask_result, 10617 port_id, UINT16); 10618 cmdline_parse_token_string_t cmd_flow_director_mask_vlan = 10619 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result, 10620 vlan, "vlan"); 10621 cmdline_parse_token_num_t cmd_flow_director_mask_vlan_value = 10622 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_mask_result, 10623 vlan_mask, UINT16); 10624 cmdline_parse_token_string_t cmd_flow_director_mask_src = 10625 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result, 10626 src_mask, "src_mask"); 10627 cmdline_parse_token_ipaddr_t cmd_flow_director_mask_ipv4_src = 10628 TOKEN_IPADDR_INITIALIZER(struct cmd_flow_director_mask_result, 10629 ipv4_src); 10630 cmdline_parse_token_ipaddr_t cmd_flow_director_mask_ipv6_src = 10631 TOKEN_IPADDR_INITIALIZER(struct cmd_flow_director_mask_result, 10632 ipv6_src); 10633 cmdline_parse_token_num_t cmd_flow_director_mask_port_src = 10634 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_mask_result, 10635 port_src, UINT16); 10636 cmdline_parse_token_string_t cmd_flow_director_mask_dst = 10637 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result, 10638 dst_mask, "dst_mask"); 10639 cmdline_parse_token_ipaddr_t cmd_flow_director_mask_ipv4_dst = 10640 TOKEN_IPADDR_INITIALIZER(struct cmd_flow_director_mask_result, 10641 ipv4_dst); 10642 cmdline_parse_token_ipaddr_t cmd_flow_director_mask_ipv6_dst = 10643 TOKEN_IPADDR_INITIALIZER(struct cmd_flow_director_mask_result, 10644 ipv6_dst); 10645 cmdline_parse_token_num_t cmd_flow_director_mask_port_dst = 10646 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_mask_result, 10647 port_dst, UINT16); 10648 10649 cmdline_parse_token_string_t cmd_flow_director_mask_mode = 10650 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result, 10651 mode, "mode"); 10652 cmdline_parse_token_string_t cmd_flow_director_mask_mode_ip = 10653 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result, 10654 mode_value, "IP"); 10655 cmdline_parse_token_string_t cmd_flow_director_mask_mode_mac_vlan = 10656 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result, 10657 mode_value, "MAC-VLAN"); 10658 cmdline_parse_token_string_t cmd_flow_director_mask_mode_tunnel = 10659 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result, 10660 mode_value, "Tunnel"); 10661 cmdline_parse_token_string_t cmd_flow_director_mask_mac = 10662 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result, 10663 mac, "mac"); 10664 cmdline_parse_token_num_t cmd_flow_director_mask_mac_value = 10665 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_mask_result, 10666 mac_addr_byte_mask, UINT8); 10667 cmdline_parse_token_string_t cmd_flow_director_mask_tunnel_type = 10668 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result, 10669 tunnel_type, "tunnel-type"); 10670 cmdline_parse_token_num_t cmd_flow_director_mask_tunnel_type_value = 10671 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_mask_result, 10672 tunnel_type_mask, UINT8); 10673 cmdline_parse_token_string_t cmd_flow_director_mask_tunnel_id = 10674 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result, 10675 tunnel_id, "tunnel-id"); 10676 cmdline_parse_token_num_t cmd_flow_director_mask_tunnel_id_value = 10677 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_mask_result, 10678 tunnel_id_mask, UINT32); 10679 10680 cmdline_parse_inst_t cmd_set_flow_director_ip_mask = { 10681 .f = cmd_flow_director_mask_parsed, 10682 .data = NULL, 10683 .help_str = "flow_director_mask ... : " 10684 "Set IP mode flow director's mask on NIC", 10685 .tokens = { 10686 (void *)&cmd_flow_director_mask, 10687 (void *)&cmd_flow_director_mask_port_id, 10688 (void *)&cmd_flow_director_mask_mode, 10689 (void *)&cmd_flow_director_mask_mode_ip, 10690 (void *)&cmd_flow_director_mask_vlan, 10691 (void *)&cmd_flow_director_mask_vlan_value, 10692 (void *)&cmd_flow_director_mask_src, 10693 (void *)&cmd_flow_director_mask_ipv4_src, 10694 (void *)&cmd_flow_director_mask_ipv6_src, 10695 (void *)&cmd_flow_director_mask_port_src, 10696 (void *)&cmd_flow_director_mask_dst, 10697 (void *)&cmd_flow_director_mask_ipv4_dst, 10698 (void *)&cmd_flow_director_mask_ipv6_dst, 10699 (void *)&cmd_flow_director_mask_port_dst, 10700 NULL, 10701 }, 10702 }; 10703 10704 cmdline_parse_inst_t cmd_set_flow_director_mac_vlan_mask = { 10705 .f = cmd_flow_director_mask_parsed, 10706 .data = NULL, 10707 .help_str = "flow_director_mask ... : Set MAC VLAN mode " 10708 "flow director's mask on NIC", 10709 .tokens = { 10710 (void *)&cmd_flow_director_mask, 10711 (void *)&cmd_flow_director_mask_port_id, 10712 (void *)&cmd_flow_director_mask_mode, 10713 (void *)&cmd_flow_director_mask_mode_mac_vlan, 10714 (void *)&cmd_flow_director_mask_vlan, 10715 (void *)&cmd_flow_director_mask_vlan_value, 10716 NULL, 10717 }, 10718 }; 10719 10720 cmdline_parse_inst_t cmd_set_flow_director_tunnel_mask = { 10721 .f = cmd_flow_director_mask_parsed, 10722 .data = NULL, 10723 .help_str = "flow_director_mask ... : Set tunnel mode " 10724 "flow director's mask on NIC", 10725 .tokens = { 10726 (void *)&cmd_flow_director_mask, 10727 (void *)&cmd_flow_director_mask_port_id, 10728 (void *)&cmd_flow_director_mask_mode, 10729 (void *)&cmd_flow_director_mask_mode_tunnel, 10730 (void *)&cmd_flow_director_mask_vlan, 10731 (void *)&cmd_flow_director_mask_vlan_value, 10732 (void *)&cmd_flow_director_mask_mac, 10733 (void *)&cmd_flow_director_mask_mac_value, 10734 (void *)&cmd_flow_director_mask_tunnel_type, 10735 (void *)&cmd_flow_director_mask_tunnel_type_value, 10736 (void *)&cmd_flow_director_mask_tunnel_id, 10737 (void *)&cmd_flow_director_mask_tunnel_id_value, 10738 NULL, 10739 }, 10740 }; 10741 10742 /* *** deal with flow director mask on flexible payload *** */ 10743 struct cmd_flow_director_flex_mask_result { 10744 cmdline_fixed_string_t flow_director_flexmask; 10745 portid_t port_id; 10746 cmdline_fixed_string_t flow; 10747 cmdline_fixed_string_t flow_type; 10748 cmdline_fixed_string_t mask; 10749 }; 10750 10751 static void 10752 cmd_flow_director_flex_mask_parsed(void *parsed_result, 10753 __attribute__((unused)) struct cmdline *cl, 10754 __attribute__((unused)) void *data) 10755 { 10756 struct cmd_flow_director_flex_mask_result *res = parsed_result; 10757 struct rte_eth_fdir_info fdir_info; 10758 struct rte_eth_fdir_flex_mask flex_mask; 10759 struct rte_port *port; 10760 uint32_t flow_type_mask; 10761 uint16_t i; 10762 int ret; 10763 10764 if (res->port_id > nb_ports) { 10765 printf("Invalid port, range is [0, %d]\n", nb_ports - 1); 10766 return; 10767 } 10768 10769 port = &ports[res->port_id]; 10770 /** Check if the port is not started **/ 10771 if (port->port_status != RTE_PORT_STOPPED) { 10772 printf("Please stop port %d first\n", res->port_id); 10773 return; 10774 } 10775 10776 memset(&flex_mask, 0, sizeof(struct rte_eth_fdir_flex_mask)); 10777 ret = parse_flexbytes(res->mask, 10778 flex_mask.mask, 10779 RTE_ETH_FDIR_MAX_FLEXLEN); 10780 if (ret < 0) { 10781 printf("error: Cannot parse mask input.\n"); 10782 return; 10783 } 10784 10785 memset(&fdir_info, 0, sizeof(fdir_info)); 10786 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_FDIR, 10787 RTE_ETH_FILTER_INFO, &fdir_info); 10788 if (ret < 0) { 10789 printf("Cannot get FDir filter info\n"); 10790 return; 10791 } 10792 10793 if (!strcmp(res->flow_type, "none")) { 10794 /* means don't specify the flow type */ 10795 flex_mask.flow_type = RTE_ETH_FLOW_UNKNOWN; 10796 for (i = 0; i < RTE_ETH_FLOW_MAX; i++) 10797 memset(&port->dev_conf.fdir_conf.flex_conf.flex_mask[i], 10798 0, sizeof(struct rte_eth_fdir_flex_mask)); 10799 port->dev_conf.fdir_conf.flex_conf.nb_flexmasks = 1; 10800 rte_memcpy(&port->dev_conf.fdir_conf.flex_conf.flex_mask[0], 10801 &flex_mask, 10802 sizeof(struct rte_eth_fdir_flex_mask)); 10803 cmd_reconfig_device_queue(res->port_id, 1, 1); 10804 return; 10805 } 10806 flow_type_mask = fdir_info.flow_types_mask[0]; 10807 if (!strcmp(res->flow_type, "all")) { 10808 if (!flow_type_mask) { 10809 printf("No flow type supported\n"); 10810 return; 10811 } 10812 for (i = RTE_ETH_FLOW_UNKNOWN; i < RTE_ETH_FLOW_MAX; i++) { 10813 if (flow_type_mask & (1 << i)) { 10814 flex_mask.flow_type = i; 10815 fdir_set_flex_mask(res->port_id, &flex_mask); 10816 } 10817 } 10818 cmd_reconfig_device_queue(res->port_id, 1, 1); 10819 return; 10820 } 10821 flex_mask.flow_type = str2flowtype(res->flow_type); 10822 if (!(flow_type_mask & (1 << flex_mask.flow_type))) { 10823 printf("Flow type %s not supported on port %d\n", 10824 res->flow_type, res->port_id); 10825 return; 10826 } 10827 fdir_set_flex_mask(res->port_id, &flex_mask); 10828 cmd_reconfig_device_queue(res->port_id, 1, 1); 10829 } 10830 10831 cmdline_parse_token_string_t cmd_flow_director_flexmask = 10832 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_flex_mask_result, 10833 flow_director_flexmask, 10834 "flow_director_flex_mask"); 10835 cmdline_parse_token_num_t cmd_flow_director_flexmask_port_id = 10836 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_flex_mask_result, 10837 port_id, UINT16); 10838 cmdline_parse_token_string_t cmd_flow_director_flexmask_flow = 10839 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_flex_mask_result, 10840 flow, "flow"); 10841 cmdline_parse_token_string_t cmd_flow_director_flexmask_flow_type = 10842 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_flex_mask_result, 10843 flow_type, "none#ipv4-other#ipv4-frag#ipv4-tcp#ipv4-udp#ipv4-sctp#" 10844 "ipv6-other#ipv6-frag#ipv6-tcp#ipv6-udp#ipv6-sctp#l2_payload#all"); 10845 cmdline_parse_token_string_t cmd_flow_director_flexmask_mask = 10846 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_flex_mask_result, 10847 mask, NULL); 10848 10849 cmdline_parse_inst_t cmd_set_flow_director_flex_mask = { 10850 .f = cmd_flow_director_flex_mask_parsed, 10851 .data = NULL, 10852 .help_str = "flow_director_flex_mask ... : " 10853 "Set flow director's flex mask on NIC", 10854 .tokens = { 10855 (void *)&cmd_flow_director_flexmask, 10856 (void *)&cmd_flow_director_flexmask_port_id, 10857 (void *)&cmd_flow_director_flexmask_flow, 10858 (void *)&cmd_flow_director_flexmask_flow_type, 10859 (void *)&cmd_flow_director_flexmask_mask, 10860 NULL, 10861 }, 10862 }; 10863 10864 /* *** deal with flow director flexible payload configuration *** */ 10865 struct cmd_flow_director_flexpayload_result { 10866 cmdline_fixed_string_t flow_director_flexpayload; 10867 portid_t port_id; 10868 cmdline_fixed_string_t payload_layer; 10869 cmdline_fixed_string_t payload_cfg; 10870 }; 10871 10872 static inline int 10873 parse_offsets(const char *q_arg, uint16_t *offsets, uint16_t max_num) 10874 { 10875 char s[256]; 10876 const char *p, *p0 = q_arg; 10877 char *end; 10878 unsigned long int_fld; 10879 char *str_fld[max_num]; 10880 int i; 10881 unsigned size; 10882 int ret = -1; 10883 10884 p = strchr(p0, '('); 10885 if (p == NULL) 10886 return -1; 10887 ++p; 10888 p0 = strchr(p, ')'); 10889 if (p0 == NULL) 10890 return -1; 10891 10892 size = p0 - p; 10893 if (size >= sizeof(s)) 10894 return -1; 10895 10896 snprintf(s, sizeof(s), "%.*s", size, p); 10897 ret = rte_strsplit(s, sizeof(s), str_fld, max_num, ','); 10898 if (ret < 0 || ret > max_num) 10899 return -1; 10900 for (i = 0; i < ret; i++) { 10901 errno = 0; 10902 int_fld = strtoul(str_fld[i], &end, 0); 10903 if (errno != 0 || *end != '\0' || int_fld > UINT16_MAX) 10904 return -1; 10905 offsets[i] = (uint16_t)int_fld; 10906 } 10907 return ret; 10908 } 10909 10910 static void 10911 cmd_flow_director_flxpld_parsed(void *parsed_result, 10912 __attribute__((unused)) struct cmdline *cl, 10913 __attribute__((unused)) void *data) 10914 { 10915 struct cmd_flow_director_flexpayload_result *res = parsed_result; 10916 struct rte_eth_flex_payload_cfg flex_cfg; 10917 struct rte_port *port; 10918 int ret = 0; 10919 10920 if (res->port_id > nb_ports) { 10921 printf("Invalid port, range is [0, %d]\n", nb_ports - 1); 10922 return; 10923 } 10924 10925 port = &ports[res->port_id]; 10926 /** Check if the port is not started **/ 10927 if (port->port_status != RTE_PORT_STOPPED) { 10928 printf("Please stop port %d first\n", res->port_id); 10929 return; 10930 } 10931 10932 memset(&flex_cfg, 0, sizeof(struct rte_eth_flex_payload_cfg)); 10933 10934 if (!strcmp(res->payload_layer, "raw")) 10935 flex_cfg.type = RTE_ETH_RAW_PAYLOAD; 10936 else if (!strcmp(res->payload_layer, "l2")) 10937 flex_cfg.type = RTE_ETH_L2_PAYLOAD; 10938 else if (!strcmp(res->payload_layer, "l3")) 10939 flex_cfg.type = RTE_ETH_L3_PAYLOAD; 10940 else if (!strcmp(res->payload_layer, "l4")) 10941 flex_cfg.type = RTE_ETH_L4_PAYLOAD; 10942 10943 ret = parse_offsets(res->payload_cfg, flex_cfg.src_offset, 10944 RTE_ETH_FDIR_MAX_FLEXLEN); 10945 if (ret < 0) { 10946 printf("error: Cannot parse flex payload input.\n"); 10947 return; 10948 } 10949 10950 fdir_set_flex_payload(res->port_id, &flex_cfg); 10951 cmd_reconfig_device_queue(res->port_id, 1, 1); 10952 } 10953 10954 cmdline_parse_token_string_t cmd_flow_director_flexpayload = 10955 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_flexpayload_result, 10956 flow_director_flexpayload, 10957 "flow_director_flex_payload"); 10958 cmdline_parse_token_num_t cmd_flow_director_flexpayload_port_id = 10959 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_flexpayload_result, 10960 port_id, UINT16); 10961 cmdline_parse_token_string_t cmd_flow_director_flexpayload_payload_layer = 10962 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_flexpayload_result, 10963 payload_layer, "raw#l2#l3#l4"); 10964 cmdline_parse_token_string_t cmd_flow_director_flexpayload_payload_cfg = 10965 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_flexpayload_result, 10966 payload_cfg, NULL); 10967 10968 cmdline_parse_inst_t cmd_set_flow_director_flex_payload = { 10969 .f = cmd_flow_director_flxpld_parsed, 10970 .data = NULL, 10971 .help_str = "flow_director_flexpayload ... : " 10972 "Set flow director's flex payload on NIC", 10973 .tokens = { 10974 (void *)&cmd_flow_director_flexpayload, 10975 (void *)&cmd_flow_director_flexpayload_port_id, 10976 (void *)&cmd_flow_director_flexpayload_payload_layer, 10977 (void *)&cmd_flow_director_flexpayload_payload_cfg, 10978 NULL, 10979 }, 10980 }; 10981 10982 /* Generic flow interface command. */ 10983 extern cmdline_parse_inst_t cmd_flow; 10984 10985 /* *** Classification Filters Control *** */ 10986 /* *** Get symmetric hash enable per port *** */ 10987 struct cmd_get_sym_hash_ena_per_port_result { 10988 cmdline_fixed_string_t get_sym_hash_ena_per_port; 10989 portid_t port_id; 10990 }; 10991 10992 static void 10993 cmd_get_sym_hash_per_port_parsed(void *parsed_result, 10994 __rte_unused struct cmdline *cl, 10995 __rte_unused void *data) 10996 { 10997 struct cmd_get_sym_hash_ena_per_port_result *res = parsed_result; 10998 struct rte_eth_hash_filter_info info; 10999 int ret; 11000 11001 if (rte_eth_dev_filter_supported(res->port_id, 11002 RTE_ETH_FILTER_HASH) < 0) { 11003 printf("RTE_ETH_FILTER_HASH not supported on port: %d\n", 11004 res->port_id); 11005 return; 11006 } 11007 11008 memset(&info, 0, sizeof(info)); 11009 info.info_type = RTE_ETH_HASH_FILTER_SYM_HASH_ENA_PER_PORT; 11010 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_HASH, 11011 RTE_ETH_FILTER_GET, &info); 11012 11013 if (ret < 0) { 11014 printf("Cannot get symmetric hash enable per port " 11015 "on port %u\n", res->port_id); 11016 return; 11017 } 11018 11019 printf("Symmetric hash is %s on port %u\n", info.info.enable ? 11020 "enabled" : "disabled", res->port_id); 11021 } 11022 11023 cmdline_parse_token_string_t cmd_get_sym_hash_ena_per_port_all = 11024 TOKEN_STRING_INITIALIZER(struct cmd_get_sym_hash_ena_per_port_result, 11025 get_sym_hash_ena_per_port, "get_sym_hash_ena_per_port"); 11026 cmdline_parse_token_num_t cmd_get_sym_hash_ena_per_port_port_id = 11027 TOKEN_NUM_INITIALIZER(struct cmd_get_sym_hash_ena_per_port_result, 11028 port_id, UINT16); 11029 11030 cmdline_parse_inst_t cmd_get_sym_hash_ena_per_port = { 11031 .f = cmd_get_sym_hash_per_port_parsed, 11032 .data = NULL, 11033 .help_str = "get_sym_hash_ena_per_port <port_id>", 11034 .tokens = { 11035 (void *)&cmd_get_sym_hash_ena_per_port_all, 11036 (void *)&cmd_get_sym_hash_ena_per_port_port_id, 11037 NULL, 11038 }, 11039 }; 11040 11041 /* *** Set symmetric hash enable per port *** */ 11042 struct cmd_set_sym_hash_ena_per_port_result { 11043 cmdline_fixed_string_t set_sym_hash_ena_per_port; 11044 cmdline_fixed_string_t enable; 11045 portid_t port_id; 11046 }; 11047 11048 static void 11049 cmd_set_sym_hash_per_port_parsed(void *parsed_result, 11050 __rte_unused struct cmdline *cl, 11051 __rte_unused void *data) 11052 { 11053 struct cmd_set_sym_hash_ena_per_port_result *res = parsed_result; 11054 struct rte_eth_hash_filter_info info; 11055 int ret; 11056 11057 if (rte_eth_dev_filter_supported(res->port_id, 11058 RTE_ETH_FILTER_HASH) < 0) { 11059 printf("RTE_ETH_FILTER_HASH not supported on port: %d\n", 11060 res->port_id); 11061 return; 11062 } 11063 11064 memset(&info, 0, sizeof(info)); 11065 info.info_type = RTE_ETH_HASH_FILTER_SYM_HASH_ENA_PER_PORT; 11066 if (!strcmp(res->enable, "enable")) 11067 info.info.enable = 1; 11068 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_HASH, 11069 RTE_ETH_FILTER_SET, &info); 11070 if (ret < 0) { 11071 printf("Cannot set symmetric hash enable per port on " 11072 "port %u\n", res->port_id); 11073 return; 11074 } 11075 printf("Symmetric hash has been set to %s on port %u\n", 11076 res->enable, res->port_id); 11077 } 11078 11079 cmdline_parse_token_string_t cmd_set_sym_hash_ena_per_port_all = 11080 TOKEN_STRING_INITIALIZER(struct cmd_set_sym_hash_ena_per_port_result, 11081 set_sym_hash_ena_per_port, "set_sym_hash_ena_per_port"); 11082 cmdline_parse_token_num_t cmd_set_sym_hash_ena_per_port_port_id = 11083 TOKEN_NUM_INITIALIZER(struct cmd_set_sym_hash_ena_per_port_result, 11084 port_id, UINT16); 11085 cmdline_parse_token_string_t cmd_set_sym_hash_ena_per_port_enable = 11086 TOKEN_STRING_INITIALIZER(struct cmd_set_sym_hash_ena_per_port_result, 11087 enable, "enable#disable"); 11088 11089 cmdline_parse_inst_t cmd_set_sym_hash_ena_per_port = { 11090 .f = cmd_set_sym_hash_per_port_parsed, 11091 .data = NULL, 11092 .help_str = "set_sym_hash_ena_per_port <port_id> enable|disable", 11093 .tokens = { 11094 (void *)&cmd_set_sym_hash_ena_per_port_all, 11095 (void *)&cmd_set_sym_hash_ena_per_port_port_id, 11096 (void *)&cmd_set_sym_hash_ena_per_port_enable, 11097 NULL, 11098 }, 11099 }; 11100 11101 /* Get global config of hash function */ 11102 struct cmd_get_hash_global_config_result { 11103 cmdline_fixed_string_t get_hash_global_config; 11104 portid_t port_id; 11105 }; 11106 11107 static char * 11108 flowtype_to_str(uint16_t ftype) 11109 { 11110 uint16_t i; 11111 static struct { 11112 char str[16]; 11113 uint16_t ftype; 11114 } ftype_table[] = { 11115 {"ipv4", RTE_ETH_FLOW_IPV4}, 11116 {"ipv4-frag", RTE_ETH_FLOW_FRAG_IPV4}, 11117 {"ipv4-tcp", RTE_ETH_FLOW_NONFRAG_IPV4_TCP}, 11118 {"ipv4-udp", RTE_ETH_FLOW_NONFRAG_IPV4_UDP}, 11119 {"ipv4-sctp", RTE_ETH_FLOW_NONFRAG_IPV4_SCTP}, 11120 {"ipv4-other", RTE_ETH_FLOW_NONFRAG_IPV4_OTHER}, 11121 {"ipv6", RTE_ETH_FLOW_IPV6}, 11122 {"ipv6-frag", RTE_ETH_FLOW_FRAG_IPV6}, 11123 {"ipv6-tcp", RTE_ETH_FLOW_NONFRAG_IPV6_TCP}, 11124 {"ipv6-udp", RTE_ETH_FLOW_NONFRAG_IPV6_UDP}, 11125 {"ipv6-sctp", RTE_ETH_FLOW_NONFRAG_IPV6_SCTP}, 11126 {"ipv6-other", RTE_ETH_FLOW_NONFRAG_IPV6_OTHER}, 11127 {"l2_payload", RTE_ETH_FLOW_L2_PAYLOAD}, 11128 {"port", RTE_ETH_FLOW_PORT}, 11129 {"vxlan", RTE_ETH_FLOW_VXLAN}, 11130 {"geneve", RTE_ETH_FLOW_GENEVE}, 11131 {"nvgre", RTE_ETH_FLOW_NVGRE}, 11132 }; 11133 11134 for (i = 0; i < RTE_DIM(ftype_table); i++) { 11135 if (ftype_table[i].ftype == ftype) 11136 return ftype_table[i].str; 11137 } 11138 11139 return NULL; 11140 } 11141 11142 static void 11143 cmd_get_hash_global_config_parsed(void *parsed_result, 11144 __rte_unused struct cmdline *cl, 11145 __rte_unused void *data) 11146 { 11147 struct cmd_get_hash_global_config_result *res = parsed_result; 11148 struct rte_eth_hash_filter_info info; 11149 uint32_t idx, offset; 11150 uint16_t i; 11151 char *str; 11152 int ret; 11153 11154 if (rte_eth_dev_filter_supported(res->port_id, 11155 RTE_ETH_FILTER_HASH) < 0) { 11156 printf("RTE_ETH_FILTER_HASH not supported on port %d\n", 11157 res->port_id); 11158 return; 11159 } 11160 11161 memset(&info, 0, sizeof(info)); 11162 info.info_type = RTE_ETH_HASH_FILTER_GLOBAL_CONFIG; 11163 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_HASH, 11164 RTE_ETH_FILTER_GET, &info); 11165 if (ret < 0) { 11166 printf("Cannot get hash global configurations by port %d\n", 11167 res->port_id); 11168 return; 11169 } 11170 11171 switch (info.info.global_conf.hash_func) { 11172 case RTE_ETH_HASH_FUNCTION_TOEPLITZ: 11173 printf("Hash function is Toeplitz\n"); 11174 break; 11175 case RTE_ETH_HASH_FUNCTION_SIMPLE_XOR: 11176 printf("Hash function is Simple XOR\n"); 11177 break; 11178 default: 11179 printf("Unknown hash function\n"); 11180 break; 11181 } 11182 11183 for (i = 0; i < RTE_ETH_FLOW_MAX; i++) { 11184 idx = i / UINT32_BIT; 11185 offset = i % UINT32_BIT; 11186 if (!(info.info.global_conf.valid_bit_mask[idx] & 11187 (1UL << offset))) 11188 continue; 11189 str = flowtype_to_str(i); 11190 if (!str) 11191 continue; 11192 printf("Symmetric hash is %s globally for flow type %s " 11193 "by port %d\n", 11194 ((info.info.global_conf.sym_hash_enable_mask[idx] & 11195 (1UL << offset)) ? "enabled" : "disabled"), str, 11196 res->port_id); 11197 } 11198 } 11199 11200 cmdline_parse_token_string_t cmd_get_hash_global_config_all = 11201 TOKEN_STRING_INITIALIZER(struct cmd_get_hash_global_config_result, 11202 get_hash_global_config, "get_hash_global_config"); 11203 cmdline_parse_token_num_t cmd_get_hash_global_config_port_id = 11204 TOKEN_NUM_INITIALIZER(struct cmd_get_hash_global_config_result, 11205 port_id, UINT16); 11206 11207 cmdline_parse_inst_t cmd_get_hash_global_config = { 11208 .f = cmd_get_hash_global_config_parsed, 11209 .data = NULL, 11210 .help_str = "get_hash_global_config <port_id>", 11211 .tokens = { 11212 (void *)&cmd_get_hash_global_config_all, 11213 (void *)&cmd_get_hash_global_config_port_id, 11214 NULL, 11215 }, 11216 }; 11217 11218 /* Set global config of hash function */ 11219 struct cmd_set_hash_global_config_result { 11220 cmdline_fixed_string_t set_hash_global_config; 11221 portid_t port_id; 11222 cmdline_fixed_string_t hash_func; 11223 cmdline_fixed_string_t flow_type; 11224 cmdline_fixed_string_t enable; 11225 }; 11226 11227 static void 11228 cmd_set_hash_global_config_parsed(void *parsed_result, 11229 __rte_unused struct cmdline *cl, 11230 __rte_unused void *data) 11231 { 11232 struct cmd_set_hash_global_config_result *res = parsed_result; 11233 struct rte_eth_hash_filter_info info; 11234 uint32_t ftype, idx, offset; 11235 int ret; 11236 11237 if (rte_eth_dev_filter_supported(res->port_id, 11238 RTE_ETH_FILTER_HASH) < 0) { 11239 printf("RTE_ETH_FILTER_HASH not supported on port %d\n", 11240 res->port_id); 11241 return; 11242 } 11243 memset(&info, 0, sizeof(info)); 11244 info.info_type = RTE_ETH_HASH_FILTER_GLOBAL_CONFIG; 11245 if (!strcmp(res->hash_func, "toeplitz")) 11246 info.info.global_conf.hash_func = 11247 RTE_ETH_HASH_FUNCTION_TOEPLITZ; 11248 else if (!strcmp(res->hash_func, "simple_xor")) 11249 info.info.global_conf.hash_func = 11250 RTE_ETH_HASH_FUNCTION_SIMPLE_XOR; 11251 else if (!strcmp(res->hash_func, "default")) 11252 info.info.global_conf.hash_func = 11253 RTE_ETH_HASH_FUNCTION_DEFAULT; 11254 11255 ftype = str2flowtype(res->flow_type); 11256 idx = ftype / (CHAR_BIT * sizeof(uint32_t)); 11257 offset = ftype % (CHAR_BIT * sizeof(uint32_t)); 11258 info.info.global_conf.valid_bit_mask[idx] |= (1UL << offset); 11259 if (!strcmp(res->enable, "enable")) 11260 info.info.global_conf.sym_hash_enable_mask[idx] |= 11261 (1UL << offset); 11262 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_HASH, 11263 RTE_ETH_FILTER_SET, &info); 11264 if (ret < 0) 11265 printf("Cannot set global hash configurations by port %d\n", 11266 res->port_id); 11267 else 11268 printf("Global hash configurations have been set " 11269 "succcessfully by port %d\n", res->port_id); 11270 } 11271 11272 cmdline_parse_token_string_t cmd_set_hash_global_config_all = 11273 TOKEN_STRING_INITIALIZER(struct cmd_set_hash_global_config_result, 11274 set_hash_global_config, "set_hash_global_config"); 11275 cmdline_parse_token_num_t cmd_set_hash_global_config_port_id = 11276 TOKEN_NUM_INITIALIZER(struct cmd_set_hash_global_config_result, 11277 port_id, UINT16); 11278 cmdline_parse_token_string_t cmd_set_hash_global_config_hash_func = 11279 TOKEN_STRING_INITIALIZER(struct cmd_set_hash_global_config_result, 11280 hash_func, "toeplitz#simple_xor#default"); 11281 cmdline_parse_token_string_t cmd_set_hash_global_config_flow_type = 11282 TOKEN_STRING_INITIALIZER(struct cmd_set_hash_global_config_result, 11283 flow_type, 11284 "ipv4#ipv4-frag#ipv4-tcp#ipv4-udp#ipv4-sctp#ipv4-other#ipv6#" 11285 "ipv6-frag#ipv6-tcp#ipv6-udp#ipv6-sctp#ipv6-other#l2_payload"); 11286 cmdline_parse_token_string_t cmd_set_hash_global_config_enable = 11287 TOKEN_STRING_INITIALIZER(struct cmd_set_hash_global_config_result, 11288 enable, "enable#disable"); 11289 11290 cmdline_parse_inst_t cmd_set_hash_global_config = { 11291 .f = cmd_set_hash_global_config_parsed, 11292 .data = NULL, 11293 .help_str = "set_hash_global_config <port_id> " 11294 "toeplitz|simple_xor|default " 11295 "ipv4|ipv4-frag|ipv4-tcp|ipv4-udp|ipv4-sctp|ipv4-other|" 11296 "ipv6|ipv6-frag|ipv6-tcp|ipv6-udp|ipv6-sctp|ipv6-other|" 11297 "l2_payload enable|disable", 11298 .tokens = { 11299 (void *)&cmd_set_hash_global_config_all, 11300 (void *)&cmd_set_hash_global_config_port_id, 11301 (void *)&cmd_set_hash_global_config_hash_func, 11302 (void *)&cmd_set_hash_global_config_flow_type, 11303 (void *)&cmd_set_hash_global_config_enable, 11304 NULL, 11305 }, 11306 }; 11307 11308 /* Set hash input set */ 11309 struct cmd_set_hash_input_set_result { 11310 cmdline_fixed_string_t set_hash_input_set; 11311 portid_t port_id; 11312 cmdline_fixed_string_t flow_type; 11313 cmdline_fixed_string_t inset_field; 11314 cmdline_fixed_string_t select; 11315 }; 11316 11317 static enum rte_eth_input_set_field 11318 str2inset(char *string) 11319 { 11320 uint16_t i; 11321 11322 static const struct { 11323 char str[32]; 11324 enum rte_eth_input_set_field inset; 11325 } inset_table[] = { 11326 {"ethertype", RTE_ETH_INPUT_SET_L2_ETHERTYPE}, 11327 {"ovlan", RTE_ETH_INPUT_SET_L2_OUTER_VLAN}, 11328 {"ivlan", RTE_ETH_INPUT_SET_L2_INNER_VLAN}, 11329 {"src-ipv4", RTE_ETH_INPUT_SET_L3_SRC_IP4}, 11330 {"dst-ipv4", RTE_ETH_INPUT_SET_L3_DST_IP4}, 11331 {"ipv4-tos", RTE_ETH_INPUT_SET_L3_IP4_TOS}, 11332 {"ipv4-proto", RTE_ETH_INPUT_SET_L3_IP4_PROTO}, 11333 {"ipv4-ttl", RTE_ETH_INPUT_SET_L3_IP4_TTL}, 11334 {"src-ipv6", RTE_ETH_INPUT_SET_L3_SRC_IP6}, 11335 {"dst-ipv6", RTE_ETH_INPUT_SET_L3_DST_IP6}, 11336 {"ipv6-tc", RTE_ETH_INPUT_SET_L3_IP6_TC}, 11337 {"ipv6-next-header", RTE_ETH_INPUT_SET_L3_IP6_NEXT_HEADER}, 11338 {"ipv6-hop-limits", RTE_ETH_INPUT_SET_L3_IP6_HOP_LIMITS}, 11339 {"udp-src-port", RTE_ETH_INPUT_SET_L4_UDP_SRC_PORT}, 11340 {"udp-dst-port", RTE_ETH_INPUT_SET_L4_UDP_DST_PORT}, 11341 {"tcp-src-port", RTE_ETH_INPUT_SET_L4_TCP_SRC_PORT}, 11342 {"tcp-dst-port", RTE_ETH_INPUT_SET_L4_TCP_DST_PORT}, 11343 {"sctp-src-port", RTE_ETH_INPUT_SET_L4_SCTP_SRC_PORT}, 11344 {"sctp-dst-port", RTE_ETH_INPUT_SET_L4_SCTP_DST_PORT}, 11345 {"sctp-veri-tag", RTE_ETH_INPUT_SET_L4_SCTP_VERIFICATION_TAG}, 11346 {"udp-key", RTE_ETH_INPUT_SET_TUNNEL_L4_UDP_KEY}, 11347 {"gre-key", RTE_ETH_INPUT_SET_TUNNEL_GRE_KEY}, 11348 {"fld-1st", RTE_ETH_INPUT_SET_FLEX_PAYLOAD_1ST_WORD}, 11349 {"fld-2nd", RTE_ETH_INPUT_SET_FLEX_PAYLOAD_2ND_WORD}, 11350 {"fld-3rd", RTE_ETH_INPUT_SET_FLEX_PAYLOAD_3RD_WORD}, 11351 {"fld-4th", RTE_ETH_INPUT_SET_FLEX_PAYLOAD_4TH_WORD}, 11352 {"fld-5th", RTE_ETH_INPUT_SET_FLEX_PAYLOAD_5TH_WORD}, 11353 {"fld-6th", RTE_ETH_INPUT_SET_FLEX_PAYLOAD_6TH_WORD}, 11354 {"fld-7th", RTE_ETH_INPUT_SET_FLEX_PAYLOAD_7TH_WORD}, 11355 {"fld-8th", RTE_ETH_INPUT_SET_FLEX_PAYLOAD_8TH_WORD}, 11356 {"none", RTE_ETH_INPUT_SET_NONE}, 11357 }; 11358 11359 for (i = 0; i < RTE_DIM(inset_table); i++) { 11360 if (!strcmp(string, inset_table[i].str)) 11361 return inset_table[i].inset; 11362 } 11363 11364 return RTE_ETH_INPUT_SET_UNKNOWN; 11365 } 11366 11367 static void 11368 cmd_set_hash_input_set_parsed(void *parsed_result, 11369 __rte_unused struct cmdline *cl, 11370 __rte_unused void *data) 11371 { 11372 struct cmd_set_hash_input_set_result *res = parsed_result; 11373 struct rte_eth_hash_filter_info info; 11374 11375 memset(&info, 0, sizeof(info)); 11376 info.info_type = RTE_ETH_HASH_FILTER_INPUT_SET_SELECT; 11377 info.info.input_set_conf.flow_type = str2flowtype(res->flow_type); 11378 info.info.input_set_conf.field[0] = str2inset(res->inset_field); 11379 info.info.input_set_conf.inset_size = 1; 11380 if (!strcmp(res->select, "select")) 11381 info.info.input_set_conf.op = RTE_ETH_INPUT_SET_SELECT; 11382 else if (!strcmp(res->select, "add")) 11383 info.info.input_set_conf.op = RTE_ETH_INPUT_SET_ADD; 11384 rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_HASH, 11385 RTE_ETH_FILTER_SET, &info); 11386 } 11387 11388 cmdline_parse_token_string_t cmd_set_hash_input_set_cmd = 11389 TOKEN_STRING_INITIALIZER(struct cmd_set_hash_input_set_result, 11390 set_hash_input_set, "set_hash_input_set"); 11391 cmdline_parse_token_num_t cmd_set_hash_input_set_port_id = 11392 TOKEN_NUM_INITIALIZER(struct cmd_set_hash_input_set_result, 11393 port_id, UINT16); 11394 cmdline_parse_token_string_t cmd_set_hash_input_set_flow_type = 11395 TOKEN_STRING_INITIALIZER(struct cmd_set_hash_input_set_result, 11396 flow_type, NULL); 11397 cmdline_parse_token_string_t cmd_set_hash_input_set_field = 11398 TOKEN_STRING_INITIALIZER(struct cmd_set_hash_input_set_result, 11399 inset_field, 11400 "ovlan#ivlan#src-ipv4#dst-ipv4#src-ipv6#dst-ipv6#" 11401 "ipv4-tos#ipv4-proto#ipv6-tc#ipv6-next-header#udp-src-port#" 11402 "udp-dst-port#tcp-src-port#tcp-dst-port#sctp-src-port#" 11403 "sctp-dst-port#sctp-veri-tag#udp-key#gre-key#fld-1st#" 11404 "fld-2nd#fld-3rd#fld-4th#fld-5th#fld-6th#fld-7th#" 11405 "fld-8th#none"); 11406 cmdline_parse_token_string_t cmd_set_hash_input_set_select = 11407 TOKEN_STRING_INITIALIZER(struct cmd_set_hash_input_set_result, 11408 select, "select#add"); 11409 11410 cmdline_parse_inst_t cmd_set_hash_input_set = { 11411 .f = cmd_set_hash_input_set_parsed, 11412 .data = NULL, 11413 .help_str = "set_hash_input_set <port_id> " 11414 "ipv4-frag|ipv4-tcp|ipv4-udp|ipv4-sctp|ipv4-other|" 11415 "ipv6-frag|ipv6-tcp|ipv6-udp|ipv6-sctp|ipv6-other|l2_payload|<flowtype_id> " 11416 "ovlan|ivlan|src-ipv4|dst-ipv4|src-ipv6|dst-ipv6|ipv4-tos|ipv4-proto|" 11417 "ipv6-tc|ipv6-next-header|udp-src-port|udp-dst-port|tcp-src-port|" 11418 "tcp-dst-port|sctp-src-port|sctp-dst-port|sctp-veri-tag|udp-key|" 11419 "gre-key|fld-1st|fld-2nd|fld-3rd|fld-4th|fld-5th|fld-6th|" 11420 "fld-7th|fld-8th|none select|add", 11421 .tokens = { 11422 (void *)&cmd_set_hash_input_set_cmd, 11423 (void *)&cmd_set_hash_input_set_port_id, 11424 (void *)&cmd_set_hash_input_set_flow_type, 11425 (void *)&cmd_set_hash_input_set_field, 11426 (void *)&cmd_set_hash_input_set_select, 11427 NULL, 11428 }, 11429 }; 11430 11431 /* Set flow director input set */ 11432 struct cmd_set_fdir_input_set_result { 11433 cmdline_fixed_string_t set_fdir_input_set; 11434 portid_t port_id; 11435 cmdline_fixed_string_t flow_type; 11436 cmdline_fixed_string_t inset_field; 11437 cmdline_fixed_string_t select; 11438 }; 11439 11440 static void 11441 cmd_set_fdir_input_set_parsed(void *parsed_result, 11442 __rte_unused struct cmdline *cl, 11443 __rte_unused void *data) 11444 { 11445 struct cmd_set_fdir_input_set_result *res = parsed_result; 11446 struct rte_eth_fdir_filter_info info; 11447 11448 memset(&info, 0, sizeof(info)); 11449 info.info_type = RTE_ETH_FDIR_FILTER_INPUT_SET_SELECT; 11450 info.info.input_set_conf.flow_type = str2flowtype(res->flow_type); 11451 info.info.input_set_conf.field[0] = str2inset(res->inset_field); 11452 info.info.input_set_conf.inset_size = 1; 11453 if (!strcmp(res->select, "select")) 11454 info.info.input_set_conf.op = RTE_ETH_INPUT_SET_SELECT; 11455 else if (!strcmp(res->select, "add")) 11456 info.info.input_set_conf.op = RTE_ETH_INPUT_SET_ADD; 11457 rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_FDIR, 11458 RTE_ETH_FILTER_SET, &info); 11459 } 11460 11461 cmdline_parse_token_string_t cmd_set_fdir_input_set_cmd = 11462 TOKEN_STRING_INITIALIZER(struct cmd_set_fdir_input_set_result, 11463 set_fdir_input_set, "set_fdir_input_set"); 11464 cmdline_parse_token_num_t cmd_set_fdir_input_set_port_id = 11465 TOKEN_NUM_INITIALIZER(struct cmd_set_fdir_input_set_result, 11466 port_id, UINT16); 11467 cmdline_parse_token_string_t cmd_set_fdir_input_set_flow_type = 11468 TOKEN_STRING_INITIALIZER(struct cmd_set_fdir_input_set_result, 11469 flow_type, 11470 "ipv4-frag#ipv4-tcp#ipv4-udp#ipv4-sctp#ipv4-other#" 11471 "ipv6-frag#ipv6-tcp#ipv6-udp#ipv6-sctp#ipv6-other#l2_payload"); 11472 cmdline_parse_token_string_t cmd_set_fdir_input_set_field = 11473 TOKEN_STRING_INITIALIZER(struct cmd_set_fdir_input_set_result, 11474 inset_field, 11475 "ivlan#ethertype#src-ipv4#dst-ipv4#src-ipv6#dst-ipv6#" 11476 "ipv4-tos#ipv4-proto#ipv4-ttl#ipv6-tc#ipv6-next-header#" 11477 "ipv6-hop-limits#udp-src-port#udp-dst-port#" 11478 "tcp-src-port#tcp-dst-port#sctp-src-port#sctp-dst-port#" 11479 "sctp-veri-tag#none"); 11480 cmdline_parse_token_string_t cmd_set_fdir_input_set_select = 11481 TOKEN_STRING_INITIALIZER(struct cmd_set_fdir_input_set_result, 11482 select, "select#add"); 11483 11484 cmdline_parse_inst_t cmd_set_fdir_input_set = { 11485 .f = cmd_set_fdir_input_set_parsed, 11486 .data = NULL, 11487 .help_str = "set_fdir_input_set <port_id> " 11488 "ipv4-frag|ipv4-tcp|ipv4-udp|ipv4-sctp|ipv4-other|" 11489 "ipv6-frag|ipv6-tcp|ipv6-udp|ipv6-sctp|ipv6-other|l2_payload " 11490 "ivlan|ethertype|src-ipv4|dst-ipv4|src-ipv6|dst-ipv6|" 11491 "ipv4-tos|ipv4-proto|ipv4-ttl|ipv6-tc|ipv6-next-header|" 11492 "ipv6-hop-limits|udp-src-port|udp-dst-port|" 11493 "tcp-src-port|tcp-dst-port|sctp-src-port|sctp-dst-port|" 11494 "sctp-veri-tag|none select|add", 11495 .tokens = { 11496 (void *)&cmd_set_fdir_input_set_cmd, 11497 (void *)&cmd_set_fdir_input_set_port_id, 11498 (void *)&cmd_set_fdir_input_set_flow_type, 11499 (void *)&cmd_set_fdir_input_set_field, 11500 (void *)&cmd_set_fdir_input_set_select, 11501 NULL, 11502 }, 11503 }; 11504 11505 /* *** ADD/REMOVE A MULTICAST MAC ADDRESS TO/FROM A PORT *** */ 11506 struct cmd_mcast_addr_result { 11507 cmdline_fixed_string_t mcast_addr_cmd; 11508 cmdline_fixed_string_t what; 11509 uint16_t port_num; 11510 struct ether_addr mc_addr; 11511 }; 11512 11513 static void cmd_mcast_addr_parsed(void *parsed_result, 11514 __attribute__((unused)) struct cmdline *cl, 11515 __attribute__((unused)) void *data) 11516 { 11517 struct cmd_mcast_addr_result *res = parsed_result; 11518 11519 if (!is_multicast_ether_addr(&res->mc_addr)) { 11520 printf("Invalid multicast addr %02X:%02X:%02X:%02X:%02X:%02X\n", 11521 res->mc_addr.addr_bytes[0], res->mc_addr.addr_bytes[1], 11522 res->mc_addr.addr_bytes[2], res->mc_addr.addr_bytes[3], 11523 res->mc_addr.addr_bytes[4], res->mc_addr.addr_bytes[5]); 11524 return; 11525 } 11526 if (strcmp(res->what, "add") == 0) 11527 mcast_addr_add(res->port_num, &res->mc_addr); 11528 else 11529 mcast_addr_remove(res->port_num, &res->mc_addr); 11530 } 11531 11532 cmdline_parse_token_string_t cmd_mcast_addr_cmd = 11533 TOKEN_STRING_INITIALIZER(struct cmd_mcast_addr_result, 11534 mcast_addr_cmd, "mcast_addr"); 11535 cmdline_parse_token_string_t cmd_mcast_addr_what = 11536 TOKEN_STRING_INITIALIZER(struct cmd_mcast_addr_result, what, 11537 "add#remove"); 11538 cmdline_parse_token_num_t cmd_mcast_addr_portnum = 11539 TOKEN_NUM_INITIALIZER(struct cmd_mcast_addr_result, port_num, UINT16); 11540 cmdline_parse_token_etheraddr_t cmd_mcast_addr_addr = 11541 TOKEN_ETHERADDR_INITIALIZER(struct cmd_mac_addr_result, address); 11542 11543 cmdline_parse_inst_t cmd_mcast_addr = { 11544 .f = cmd_mcast_addr_parsed, 11545 .data = (void *)0, 11546 .help_str = "mcast_addr add|remove <port_id> <mcast_addr>: " 11547 "Add/Remove multicast MAC address on port_id", 11548 .tokens = { 11549 (void *)&cmd_mcast_addr_cmd, 11550 (void *)&cmd_mcast_addr_what, 11551 (void *)&cmd_mcast_addr_portnum, 11552 (void *)&cmd_mcast_addr_addr, 11553 NULL, 11554 }, 11555 }; 11556 11557 /* l2 tunnel config 11558 * only support E-tag now. 11559 */ 11560 11561 /* Ether type config */ 11562 struct cmd_config_l2_tunnel_eth_type_result { 11563 cmdline_fixed_string_t port; 11564 cmdline_fixed_string_t config; 11565 cmdline_fixed_string_t all; 11566 uint8_t id; 11567 cmdline_fixed_string_t l2_tunnel; 11568 cmdline_fixed_string_t l2_tunnel_type; 11569 cmdline_fixed_string_t eth_type; 11570 uint16_t eth_type_val; 11571 }; 11572 11573 cmdline_parse_token_string_t cmd_config_l2_tunnel_eth_type_port = 11574 TOKEN_STRING_INITIALIZER 11575 (struct cmd_config_l2_tunnel_eth_type_result, 11576 port, "port"); 11577 cmdline_parse_token_string_t cmd_config_l2_tunnel_eth_type_config = 11578 TOKEN_STRING_INITIALIZER 11579 (struct cmd_config_l2_tunnel_eth_type_result, 11580 config, "config"); 11581 cmdline_parse_token_string_t cmd_config_l2_tunnel_eth_type_all_str = 11582 TOKEN_STRING_INITIALIZER 11583 (struct cmd_config_l2_tunnel_eth_type_result, 11584 all, "all"); 11585 cmdline_parse_token_num_t cmd_config_l2_tunnel_eth_type_id = 11586 TOKEN_NUM_INITIALIZER 11587 (struct cmd_config_l2_tunnel_eth_type_result, 11588 id, UINT8); 11589 cmdline_parse_token_string_t cmd_config_l2_tunnel_eth_type_l2_tunnel = 11590 TOKEN_STRING_INITIALIZER 11591 (struct cmd_config_l2_tunnel_eth_type_result, 11592 l2_tunnel, "l2-tunnel"); 11593 cmdline_parse_token_string_t cmd_config_l2_tunnel_eth_type_l2_tunnel_type = 11594 TOKEN_STRING_INITIALIZER 11595 (struct cmd_config_l2_tunnel_eth_type_result, 11596 l2_tunnel_type, "E-tag"); 11597 cmdline_parse_token_string_t cmd_config_l2_tunnel_eth_type_eth_type = 11598 TOKEN_STRING_INITIALIZER 11599 (struct cmd_config_l2_tunnel_eth_type_result, 11600 eth_type, "ether-type"); 11601 cmdline_parse_token_num_t cmd_config_l2_tunnel_eth_type_eth_type_val = 11602 TOKEN_NUM_INITIALIZER 11603 (struct cmd_config_l2_tunnel_eth_type_result, 11604 eth_type_val, UINT16); 11605 11606 static enum rte_eth_tunnel_type 11607 str2fdir_l2_tunnel_type(char *string) 11608 { 11609 uint32_t i = 0; 11610 11611 static const struct { 11612 char str[32]; 11613 enum rte_eth_tunnel_type type; 11614 } l2_tunnel_type_str[] = { 11615 {"E-tag", RTE_L2_TUNNEL_TYPE_E_TAG}, 11616 }; 11617 11618 for (i = 0; i < RTE_DIM(l2_tunnel_type_str); i++) { 11619 if (!strcmp(l2_tunnel_type_str[i].str, string)) 11620 return l2_tunnel_type_str[i].type; 11621 } 11622 return RTE_TUNNEL_TYPE_NONE; 11623 } 11624 11625 /* ether type config for all ports */ 11626 static void 11627 cmd_config_l2_tunnel_eth_type_all_parsed 11628 (void *parsed_result, 11629 __attribute__((unused)) struct cmdline *cl, 11630 __attribute__((unused)) void *data) 11631 { 11632 struct cmd_config_l2_tunnel_eth_type_result *res = parsed_result; 11633 struct rte_eth_l2_tunnel_conf entry; 11634 portid_t pid; 11635 11636 entry.l2_tunnel_type = str2fdir_l2_tunnel_type(res->l2_tunnel_type); 11637 entry.ether_type = res->eth_type_val; 11638 11639 RTE_ETH_FOREACH_DEV(pid) { 11640 rte_eth_dev_l2_tunnel_eth_type_conf(pid, &entry); 11641 } 11642 } 11643 11644 cmdline_parse_inst_t cmd_config_l2_tunnel_eth_type_all = { 11645 .f = cmd_config_l2_tunnel_eth_type_all_parsed, 11646 .data = NULL, 11647 .help_str = "port config all l2-tunnel E-tag ether-type <value>", 11648 .tokens = { 11649 (void *)&cmd_config_l2_tunnel_eth_type_port, 11650 (void *)&cmd_config_l2_tunnel_eth_type_config, 11651 (void *)&cmd_config_l2_tunnel_eth_type_all_str, 11652 (void *)&cmd_config_l2_tunnel_eth_type_l2_tunnel, 11653 (void *)&cmd_config_l2_tunnel_eth_type_l2_tunnel_type, 11654 (void *)&cmd_config_l2_tunnel_eth_type_eth_type, 11655 (void *)&cmd_config_l2_tunnel_eth_type_eth_type_val, 11656 NULL, 11657 }, 11658 }; 11659 11660 /* ether type config for a specific port */ 11661 static void 11662 cmd_config_l2_tunnel_eth_type_specific_parsed( 11663 void *parsed_result, 11664 __attribute__((unused)) struct cmdline *cl, 11665 __attribute__((unused)) void *data) 11666 { 11667 struct cmd_config_l2_tunnel_eth_type_result *res = 11668 parsed_result; 11669 struct rte_eth_l2_tunnel_conf entry; 11670 11671 if (port_id_is_invalid(res->id, ENABLED_WARN)) 11672 return; 11673 11674 entry.l2_tunnel_type = str2fdir_l2_tunnel_type(res->l2_tunnel_type); 11675 entry.ether_type = res->eth_type_val; 11676 11677 rte_eth_dev_l2_tunnel_eth_type_conf(res->id, &entry); 11678 } 11679 11680 cmdline_parse_inst_t cmd_config_l2_tunnel_eth_type_specific = { 11681 .f = cmd_config_l2_tunnel_eth_type_specific_parsed, 11682 .data = NULL, 11683 .help_str = "port config <port_id> l2-tunnel E-tag ether-type <value>", 11684 .tokens = { 11685 (void *)&cmd_config_l2_tunnel_eth_type_port, 11686 (void *)&cmd_config_l2_tunnel_eth_type_config, 11687 (void *)&cmd_config_l2_tunnel_eth_type_id, 11688 (void *)&cmd_config_l2_tunnel_eth_type_l2_tunnel, 11689 (void *)&cmd_config_l2_tunnel_eth_type_l2_tunnel_type, 11690 (void *)&cmd_config_l2_tunnel_eth_type_eth_type, 11691 (void *)&cmd_config_l2_tunnel_eth_type_eth_type_val, 11692 NULL, 11693 }, 11694 }; 11695 11696 /* Enable/disable l2 tunnel */ 11697 struct cmd_config_l2_tunnel_en_dis_result { 11698 cmdline_fixed_string_t port; 11699 cmdline_fixed_string_t config; 11700 cmdline_fixed_string_t all; 11701 uint8_t id; 11702 cmdline_fixed_string_t l2_tunnel; 11703 cmdline_fixed_string_t l2_tunnel_type; 11704 cmdline_fixed_string_t en_dis; 11705 }; 11706 11707 cmdline_parse_token_string_t cmd_config_l2_tunnel_en_dis_port = 11708 TOKEN_STRING_INITIALIZER 11709 (struct cmd_config_l2_tunnel_en_dis_result, 11710 port, "port"); 11711 cmdline_parse_token_string_t cmd_config_l2_tunnel_en_dis_config = 11712 TOKEN_STRING_INITIALIZER 11713 (struct cmd_config_l2_tunnel_en_dis_result, 11714 config, "config"); 11715 cmdline_parse_token_string_t cmd_config_l2_tunnel_en_dis_all_str = 11716 TOKEN_STRING_INITIALIZER 11717 (struct cmd_config_l2_tunnel_en_dis_result, 11718 all, "all"); 11719 cmdline_parse_token_num_t cmd_config_l2_tunnel_en_dis_id = 11720 TOKEN_NUM_INITIALIZER 11721 (struct cmd_config_l2_tunnel_en_dis_result, 11722 id, UINT8); 11723 cmdline_parse_token_string_t cmd_config_l2_tunnel_en_dis_l2_tunnel = 11724 TOKEN_STRING_INITIALIZER 11725 (struct cmd_config_l2_tunnel_en_dis_result, 11726 l2_tunnel, "l2-tunnel"); 11727 cmdline_parse_token_string_t cmd_config_l2_tunnel_en_dis_l2_tunnel_type = 11728 TOKEN_STRING_INITIALIZER 11729 (struct cmd_config_l2_tunnel_en_dis_result, 11730 l2_tunnel_type, "E-tag"); 11731 cmdline_parse_token_string_t cmd_config_l2_tunnel_en_dis_en_dis = 11732 TOKEN_STRING_INITIALIZER 11733 (struct cmd_config_l2_tunnel_en_dis_result, 11734 en_dis, "enable#disable"); 11735 11736 /* enable/disable l2 tunnel for all ports */ 11737 static void 11738 cmd_config_l2_tunnel_en_dis_all_parsed( 11739 void *parsed_result, 11740 __attribute__((unused)) struct cmdline *cl, 11741 __attribute__((unused)) void *data) 11742 { 11743 struct cmd_config_l2_tunnel_en_dis_result *res = parsed_result; 11744 struct rte_eth_l2_tunnel_conf entry; 11745 portid_t pid; 11746 uint8_t en; 11747 11748 entry.l2_tunnel_type = str2fdir_l2_tunnel_type(res->l2_tunnel_type); 11749 11750 if (!strcmp("enable", res->en_dis)) 11751 en = 1; 11752 else 11753 en = 0; 11754 11755 RTE_ETH_FOREACH_DEV(pid) { 11756 rte_eth_dev_l2_tunnel_offload_set(pid, 11757 &entry, 11758 ETH_L2_TUNNEL_ENABLE_MASK, 11759 en); 11760 } 11761 } 11762 11763 cmdline_parse_inst_t cmd_config_l2_tunnel_en_dis_all = { 11764 .f = cmd_config_l2_tunnel_en_dis_all_parsed, 11765 .data = NULL, 11766 .help_str = "port config all l2-tunnel E-tag enable|disable", 11767 .tokens = { 11768 (void *)&cmd_config_l2_tunnel_en_dis_port, 11769 (void *)&cmd_config_l2_tunnel_en_dis_config, 11770 (void *)&cmd_config_l2_tunnel_en_dis_all_str, 11771 (void *)&cmd_config_l2_tunnel_en_dis_l2_tunnel, 11772 (void *)&cmd_config_l2_tunnel_en_dis_l2_tunnel_type, 11773 (void *)&cmd_config_l2_tunnel_en_dis_en_dis, 11774 NULL, 11775 }, 11776 }; 11777 11778 /* enable/disable l2 tunnel for a port */ 11779 static void 11780 cmd_config_l2_tunnel_en_dis_specific_parsed( 11781 void *parsed_result, 11782 __attribute__((unused)) struct cmdline *cl, 11783 __attribute__((unused)) void *data) 11784 { 11785 struct cmd_config_l2_tunnel_en_dis_result *res = 11786 parsed_result; 11787 struct rte_eth_l2_tunnel_conf entry; 11788 11789 if (port_id_is_invalid(res->id, ENABLED_WARN)) 11790 return; 11791 11792 entry.l2_tunnel_type = str2fdir_l2_tunnel_type(res->l2_tunnel_type); 11793 11794 if (!strcmp("enable", res->en_dis)) 11795 rte_eth_dev_l2_tunnel_offload_set(res->id, 11796 &entry, 11797 ETH_L2_TUNNEL_ENABLE_MASK, 11798 1); 11799 else 11800 rte_eth_dev_l2_tunnel_offload_set(res->id, 11801 &entry, 11802 ETH_L2_TUNNEL_ENABLE_MASK, 11803 0); 11804 } 11805 11806 cmdline_parse_inst_t cmd_config_l2_tunnel_en_dis_specific = { 11807 .f = cmd_config_l2_tunnel_en_dis_specific_parsed, 11808 .data = NULL, 11809 .help_str = "port config <port_id> l2-tunnel E-tag enable|disable", 11810 .tokens = { 11811 (void *)&cmd_config_l2_tunnel_en_dis_port, 11812 (void *)&cmd_config_l2_tunnel_en_dis_config, 11813 (void *)&cmd_config_l2_tunnel_en_dis_id, 11814 (void *)&cmd_config_l2_tunnel_en_dis_l2_tunnel, 11815 (void *)&cmd_config_l2_tunnel_en_dis_l2_tunnel_type, 11816 (void *)&cmd_config_l2_tunnel_en_dis_en_dis, 11817 NULL, 11818 }, 11819 }; 11820 11821 /* E-tag configuration */ 11822 11823 /* Common result structure for all E-tag configuration */ 11824 struct cmd_config_e_tag_result { 11825 cmdline_fixed_string_t e_tag; 11826 cmdline_fixed_string_t set; 11827 cmdline_fixed_string_t insertion; 11828 cmdline_fixed_string_t stripping; 11829 cmdline_fixed_string_t forwarding; 11830 cmdline_fixed_string_t filter; 11831 cmdline_fixed_string_t add; 11832 cmdline_fixed_string_t del; 11833 cmdline_fixed_string_t on; 11834 cmdline_fixed_string_t off; 11835 cmdline_fixed_string_t on_off; 11836 cmdline_fixed_string_t port_tag_id; 11837 uint32_t port_tag_id_val; 11838 cmdline_fixed_string_t e_tag_id; 11839 uint16_t e_tag_id_val; 11840 cmdline_fixed_string_t dst_pool; 11841 uint8_t dst_pool_val; 11842 cmdline_fixed_string_t port; 11843 portid_t port_id; 11844 cmdline_fixed_string_t vf; 11845 uint8_t vf_id; 11846 }; 11847 11848 /* Common CLI fields for all E-tag configuration */ 11849 cmdline_parse_token_string_t cmd_config_e_tag_e_tag = 11850 TOKEN_STRING_INITIALIZER 11851 (struct cmd_config_e_tag_result, 11852 e_tag, "E-tag"); 11853 cmdline_parse_token_string_t cmd_config_e_tag_set = 11854 TOKEN_STRING_INITIALIZER 11855 (struct cmd_config_e_tag_result, 11856 set, "set"); 11857 cmdline_parse_token_string_t cmd_config_e_tag_insertion = 11858 TOKEN_STRING_INITIALIZER 11859 (struct cmd_config_e_tag_result, 11860 insertion, "insertion"); 11861 cmdline_parse_token_string_t cmd_config_e_tag_stripping = 11862 TOKEN_STRING_INITIALIZER 11863 (struct cmd_config_e_tag_result, 11864 stripping, "stripping"); 11865 cmdline_parse_token_string_t cmd_config_e_tag_forwarding = 11866 TOKEN_STRING_INITIALIZER 11867 (struct cmd_config_e_tag_result, 11868 forwarding, "forwarding"); 11869 cmdline_parse_token_string_t cmd_config_e_tag_filter = 11870 TOKEN_STRING_INITIALIZER 11871 (struct cmd_config_e_tag_result, 11872 filter, "filter"); 11873 cmdline_parse_token_string_t cmd_config_e_tag_add = 11874 TOKEN_STRING_INITIALIZER 11875 (struct cmd_config_e_tag_result, 11876 add, "add"); 11877 cmdline_parse_token_string_t cmd_config_e_tag_del = 11878 TOKEN_STRING_INITIALIZER 11879 (struct cmd_config_e_tag_result, 11880 del, "del"); 11881 cmdline_parse_token_string_t cmd_config_e_tag_on = 11882 TOKEN_STRING_INITIALIZER 11883 (struct cmd_config_e_tag_result, 11884 on, "on"); 11885 cmdline_parse_token_string_t cmd_config_e_tag_off = 11886 TOKEN_STRING_INITIALIZER 11887 (struct cmd_config_e_tag_result, 11888 off, "off"); 11889 cmdline_parse_token_string_t cmd_config_e_tag_on_off = 11890 TOKEN_STRING_INITIALIZER 11891 (struct cmd_config_e_tag_result, 11892 on_off, "on#off"); 11893 cmdline_parse_token_string_t cmd_config_e_tag_port_tag_id = 11894 TOKEN_STRING_INITIALIZER 11895 (struct cmd_config_e_tag_result, 11896 port_tag_id, "port-tag-id"); 11897 cmdline_parse_token_num_t cmd_config_e_tag_port_tag_id_val = 11898 TOKEN_NUM_INITIALIZER 11899 (struct cmd_config_e_tag_result, 11900 port_tag_id_val, UINT32); 11901 cmdline_parse_token_string_t cmd_config_e_tag_e_tag_id = 11902 TOKEN_STRING_INITIALIZER 11903 (struct cmd_config_e_tag_result, 11904 e_tag_id, "e-tag-id"); 11905 cmdline_parse_token_num_t cmd_config_e_tag_e_tag_id_val = 11906 TOKEN_NUM_INITIALIZER 11907 (struct cmd_config_e_tag_result, 11908 e_tag_id_val, UINT16); 11909 cmdline_parse_token_string_t cmd_config_e_tag_dst_pool = 11910 TOKEN_STRING_INITIALIZER 11911 (struct cmd_config_e_tag_result, 11912 dst_pool, "dst-pool"); 11913 cmdline_parse_token_num_t cmd_config_e_tag_dst_pool_val = 11914 TOKEN_NUM_INITIALIZER 11915 (struct cmd_config_e_tag_result, 11916 dst_pool_val, UINT8); 11917 cmdline_parse_token_string_t cmd_config_e_tag_port = 11918 TOKEN_STRING_INITIALIZER 11919 (struct cmd_config_e_tag_result, 11920 port, "port"); 11921 cmdline_parse_token_num_t cmd_config_e_tag_port_id = 11922 TOKEN_NUM_INITIALIZER 11923 (struct cmd_config_e_tag_result, 11924 port_id, UINT16); 11925 cmdline_parse_token_string_t cmd_config_e_tag_vf = 11926 TOKEN_STRING_INITIALIZER 11927 (struct cmd_config_e_tag_result, 11928 vf, "vf"); 11929 cmdline_parse_token_num_t cmd_config_e_tag_vf_id = 11930 TOKEN_NUM_INITIALIZER 11931 (struct cmd_config_e_tag_result, 11932 vf_id, UINT8); 11933 11934 /* E-tag insertion configuration */ 11935 static void 11936 cmd_config_e_tag_insertion_en_parsed( 11937 void *parsed_result, 11938 __attribute__((unused)) struct cmdline *cl, 11939 __attribute__((unused)) void *data) 11940 { 11941 struct cmd_config_e_tag_result *res = 11942 parsed_result; 11943 struct rte_eth_l2_tunnel_conf entry; 11944 11945 if (port_id_is_invalid(res->port_id, ENABLED_WARN)) 11946 return; 11947 11948 entry.l2_tunnel_type = RTE_L2_TUNNEL_TYPE_E_TAG; 11949 entry.tunnel_id = res->port_tag_id_val; 11950 entry.vf_id = res->vf_id; 11951 rte_eth_dev_l2_tunnel_offload_set(res->port_id, 11952 &entry, 11953 ETH_L2_TUNNEL_INSERTION_MASK, 11954 1); 11955 } 11956 11957 static void 11958 cmd_config_e_tag_insertion_dis_parsed( 11959 void *parsed_result, 11960 __attribute__((unused)) struct cmdline *cl, 11961 __attribute__((unused)) void *data) 11962 { 11963 struct cmd_config_e_tag_result *res = 11964 parsed_result; 11965 struct rte_eth_l2_tunnel_conf entry; 11966 11967 if (port_id_is_invalid(res->port_id, ENABLED_WARN)) 11968 return; 11969 11970 entry.l2_tunnel_type = RTE_L2_TUNNEL_TYPE_E_TAG; 11971 entry.vf_id = res->vf_id; 11972 11973 rte_eth_dev_l2_tunnel_offload_set(res->port_id, 11974 &entry, 11975 ETH_L2_TUNNEL_INSERTION_MASK, 11976 0); 11977 } 11978 11979 cmdline_parse_inst_t cmd_config_e_tag_insertion_en = { 11980 .f = cmd_config_e_tag_insertion_en_parsed, 11981 .data = NULL, 11982 .help_str = "E-tag ... : E-tag insertion enable", 11983 .tokens = { 11984 (void *)&cmd_config_e_tag_e_tag, 11985 (void *)&cmd_config_e_tag_set, 11986 (void *)&cmd_config_e_tag_insertion, 11987 (void *)&cmd_config_e_tag_on, 11988 (void *)&cmd_config_e_tag_port_tag_id, 11989 (void *)&cmd_config_e_tag_port_tag_id_val, 11990 (void *)&cmd_config_e_tag_port, 11991 (void *)&cmd_config_e_tag_port_id, 11992 (void *)&cmd_config_e_tag_vf, 11993 (void *)&cmd_config_e_tag_vf_id, 11994 NULL, 11995 }, 11996 }; 11997 11998 cmdline_parse_inst_t cmd_config_e_tag_insertion_dis = { 11999 .f = cmd_config_e_tag_insertion_dis_parsed, 12000 .data = NULL, 12001 .help_str = "E-tag ... : E-tag insertion disable", 12002 .tokens = { 12003 (void *)&cmd_config_e_tag_e_tag, 12004 (void *)&cmd_config_e_tag_set, 12005 (void *)&cmd_config_e_tag_insertion, 12006 (void *)&cmd_config_e_tag_off, 12007 (void *)&cmd_config_e_tag_port, 12008 (void *)&cmd_config_e_tag_port_id, 12009 (void *)&cmd_config_e_tag_vf, 12010 (void *)&cmd_config_e_tag_vf_id, 12011 NULL, 12012 }, 12013 }; 12014 12015 /* E-tag stripping configuration */ 12016 static void 12017 cmd_config_e_tag_stripping_parsed( 12018 void *parsed_result, 12019 __attribute__((unused)) struct cmdline *cl, 12020 __attribute__((unused)) void *data) 12021 { 12022 struct cmd_config_e_tag_result *res = 12023 parsed_result; 12024 struct rte_eth_l2_tunnel_conf entry; 12025 12026 if (port_id_is_invalid(res->port_id, ENABLED_WARN)) 12027 return; 12028 12029 entry.l2_tunnel_type = RTE_L2_TUNNEL_TYPE_E_TAG; 12030 12031 if (!strcmp(res->on_off, "on")) 12032 rte_eth_dev_l2_tunnel_offload_set 12033 (res->port_id, 12034 &entry, 12035 ETH_L2_TUNNEL_STRIPPING_MASK, 12036 1); 12037 else 12038 rte_eth_dev_l2_tunnel_offload_set 12039 (res->port_id, 12040 &entry, 12041 ETH_L2_TUNNEL_STRIPPING_MASK, 12042 0); 12043 } 12044 12045 cmdline_parse_inst_t cmd_config_e_tag_stripping_en_dis = { 12046 .f = cmd_config_e_tag_stripping_parsed, 12047 .data = NULL, 12048 .help_str = "E-tag ... : E-tag stripping enable/disable", 12049 .tokens = { 12050 (void *)&cmd_config_e_tag_e_tag, 12051 (void *)&cmd_config_e_tag_set, 12052 (void *)&cmd_config_e_tag_stripping, 12053 (void *)&cmd_config_e_tag_on_off, 12054 (void *)&cmd_config_e_tag_port, 12055 (void *)&cmd_config_e_tag_port_id, 12056 NULL, 12057 }, 12058 }; 12059 12060 /* E-tag forwarding configuration */ 12061 static void 12062 cmd_config_e_tag_forwarding_parsed( 12063 void *parsed_result, 12064 __attribute__((unused)) struct cmdline *cl, 12065 __attribute__((unused)) void *data) 12066 { 12067 struct cmd_config_e_tag_result *res = parsed_result; 12068 struct rte_eth_l2_tunnel_conf entry; 12069 12070 if (port_id_is_invalid(res->port_id, ENABLED_WARN)) 12071 return; 12072 12073 entry.l2_tunnel_type = RTE_L2_TUNNEL_TYPE_E_TAG; 12074 12075 if (!strcmp(res->on_off, "on")) 12076 rte_eth_dev_l2_tunnel_offload_set 12077 (res->port_id, 12078 &entry, 12079 ETH_L2_TUNNEL_FORWARDING_MASK, 12080 1); 12081 else 12082 rte_eth_dev_l2_tunnel_offload_set 12083 (res->port_id, 12084 &entry, 12085 ETH_L2_TUNNEL_FORWARDING_MASK, 12086 0); 12087 } 12088 12089 cmdline_parse_inst_t cmd_config_e_tag_forwarding_en_dis = { 12090 .f = cmd_config_e_tag_forwarding_parsed, 12091 .data = NULL, 12092 .help_str = "E-tag ... : E-tag forwarding enable/disable", 12093 .tokens = { 12094 (void *)&cmd_config_e_tag_e_tag, 12095 (void *)&cmd_config_e_tag_set, 12096 (void *)&cmd_config_e_tag_forwarding, 12097 (void *)&cmd_config_e_tag_on_off, 12098 (void *)&cmd_config_e_tag_port, 12099 (void *)&cmd_config_e_tag_port_id, 12100 NULL, 12101 }, 12102 }; 12103 12104 /* E-tag filter configuration */ 12105 static void 12106 cmd_config_e_tag_filter_add_parsed( 12107 void *parsed_result, 12108 __attribute__((unused)) struct cmdline *cl, 12109 __attribute__((unused)) void *data) 12110 { 12111 struct cmd_config_e_tag_result *res = parsed_result; 12112 struct rte_eth_l2_tunnel_conf entry; 12113 int ret = 0; 12114 12115 if (port_id_is_invalid(res->port_id, ENABLED_WARN)) 12116 return; 12117 12118 if (res->e_tag_id_val > 0x3fff) { 12119 printf("e-tag-id must be equal or less than 0x3fff.\n"); 12120 return; 12121 } 12122 12123 ret = rte_eth_dev_filter_supported(res->port_id, 12124 RTE_ETH_FILTER_L2_TUNNEL); 12125 if (ret < 0) { 12126 printf("E-tag filter is not supported on port %u.\n", 12127 res->port_id); 12128 return; 12129 } 12130 12131 entry.l2_tunnel_type = RTE_L2_TUNNEL_TYPE_E_TAG; 12132 entry.tunnel_id = res->e_tag_id_val; 12133 entry.pool = res->dst_pool_val; 12134 12135 ret = rte_eth_dev_filter_ctrl(res->port_id, 12136 RTE_ETH_FILTER_L2_TUNNEL, 12137 RTE_ETH_FILTER_ADD, 12138 &entry); 12139 if (ret < 0) 12140 printf("E-tag filter programming error: (%s)\n", 12141 strerror(-ret)); 12142 } 12143 12144 cmdline_parse_inst_t cmd_config_e_tag_filter_add = { 12145 .f = cmd_config_e_tag_filter_add_parsed, 12146 .data = NULL, 12147 .help_str = "E-tag ... : E-tag filter add", 12148 .tokens = { 12149 (void *)&cmd_config_e_tag_e_tag, 12150 (void *)&cmd_config_e_tag_set, 12151 (void *)&cmd_config_e_tag_filter, 12152 (void *)&cmd_config_e_tag_add, 12153 (void *)&cmd_config_e_tag_e_tag_id, 12154 (void *)&cmd_config_e_tag_e_tag_id_val, 12155 (void *)&cmd_config_e_tag_dst_pool, 12156 (void *)&cmd_config_e_tag_dst_pool_val, 12157 (void *)&cmd_config_e_tag_port, 12158 (void *)&cmd_config_e_tag_port_id, 12159 NULL, 12160 }, 12161 }; 12162 12163 static void 12164 cmd_config_e_tag_filter_del_parsed( 12165 void *parsed_result, 12166 __attribute__((unused)) struct cmdline *cl, 12167 __attribute__((unused)) void *data) 12168 { 12169 struct cmd_config_e_tag_result *res = parsed_result; 12170 struct rte_eth_l2_tunnel_conf entry; 12171 int ret = 0; 12172 12173 if (port_id_is_invalid(res->port_id, ENABLED_WARN)) 12174 return; 12175 12176 if (res->e_tag_id_val > 0x3fff) { 12177 printf("e-tag-id must be less than 0x3fff.\n"); 12178 return; 12179 } 12180 12181 ret = rte_eth_dev_filter_supported(res->port_id, 12182 RTE_ETH_FILTER_L2_TUNNEL); 12183 if (ret < 0) { 12184 printf("E-tag filter is not supported on port %u.\n", 12185 res->port_id); 12186 return; 12187 } 12188 12189 entry.l2_tunnel_type = RTE_L2_TUNNEL_TYPE_E_TAG; 12190 entry.tunnel_id = res->e_tag_id_val; 12191 12192 ret = rte_eth_dev_filter_ctrl(res->port_id, 12193 RTE_ETH_FILTER_L2_TUNNEL, 12194 RTE_ETH_FILTER_DELETE, 12195 &entry); 12196 if (ret < 0) 12197 printf("E-tag filter programming error: (%s)\n", 12198 strerror(-ret)); 12199 } 12200 12201 cmdline_parse_inst_t cmd_config_e_tag_filter_del = { 12202 .f = cmd_config_e_tag_filter_del_parsed, 12203 .data = NULL, 12204 .help_str = "E-tag ... : E-tag filter delete", 12205 .tokens = { 12206 (void *)&cmd_config_e_tag_e_tag, 12207 (void *)&cmd_config_e_tag_set, 12208 (void *)&cmd_config_e_tag_filter, 12209 (void *)&cmd_config_e_tag_del, 12210 (void *)&cmd_config_e_tag_e_tag_id, 12211 (void *)&cmd_config_e_tag_e_tag_id_val, 12212 (void *)&cmd_config_e_tag_port, 12213 (void *)&cmd_config_e_tag_port_id, 12214 NULL, 12215 }, 12216 }; 12217 12218 /* vf vlan anti spoof configuration */ 12219 12220 /* Common result structure for vf vlan anti spoof */ 12221 struct cmd_vf_vlan_anti_spoof_result { 12222 cmdline_fixed_string_t set; 12223 cmdline_fixed_string_t vf; 12224 cmdline_fixed_string_t vlan; 12225 cmdline_fixed_string_t antispoof; 12226 portid_t port_id; 12227 uint32_t vf_id; 12228 cmdline_fixed_string_t on_off; 12229 }; 12230 12231 /* Common CLI fields for vf vlan anti spoof enable disable */ 12232 cmdline_parse_token_string_t cmd_vf_vlan_anti_spoof_set = 12233 TOKEN_STRING_INITIALIZER 12234 (struct cmd_vf_vlan_anti_spoof_result, 12235 set, "set"); 12236 cmdline_parse_token_string_t cmd_vf_vlan_anti_spoof_vf = 12237 TOKEN_STRING_INITIALIZER 12238 (struct cmd_vf_vlan_anti_spoof_result, 12239 vf, "vf"); 12240 cmdline_parse_token_string_t cmd_vf_vlan_anti_spoof_vlan = 12241 TOKEN_STRING_INITIALIZER 12242 (struct cmd_vf_vlan_anti_spoof_result, 12243 vlan, "vlan"); 12244 cmdline_parse_token_string_t cmd_vf_vlan_anti_spoof_antispoof = 12245 TOKEN_STRING_INITIALIZER 12246 (struct cmd_vf_vlan_anti_spoof_result, 12247 antispoof, "antispoof"); 12248 cmdline_parse_token_num_t cmd_vf_vlan_anti_spoof_port_id = 12249 TOKEN_NUM_INITIALIZER 12250 (struct cmd_vf_vlan_anti_spoof_result, 12251 port_id, UINT16); 12252 cmdline_parse_token_num_t cmd_vf_vlan_anti_spoof_vf_id = 12253 TOKEN_NUM_INITIALIZER 12254 (struct cmd_vf_vlan_anti_spoof_result, 12255 vf_id, UINT32); 12256 cmdline_parse_token_string_t cmd_vf_vlan_anti_spoof_on_off = 12257 TOKEN_STRING_INITIALIZER 12258 (struct cmd_vf_vlan_anti_spoof_result, 12259 on_off, "on#off"); 12260 12261 static void 12262 cmd_set_vf_vlan_anti_spoof_parsed( 12263 void *parsed_result, 12264 __attribute__((unused)) struct cmdline *cl, 12265 __attribute__((unused)) void *data) 12266 { 12267 struct cmd_vf_vlan_anti_spoof_result *res = parsed_result; 12268 int ret = -ENOTSUP; 12269 12270 __rte_unused int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0; 12271 12272 if (port_id_is_invalid(res->port_id, ENABLED_WARN)) 12273 return; 12274 12275 #ifdef RTE_LIBRTE_IXGBE_PMD 12276 if (ret == -ENOTSUP) 12277 ret = rte_pmd_ixgbe_set_vf_vlan_anti_spoof(res->port_id, 12278 res->vf_id, is_on); 12279 #endif 12280 #ifdef RTE_LIBRTE_I40E_PMD 12281 if (ret == -ENOTSUP) 12282 ret = rte_pmd_i40e_set_vf_vlan_anti_spoof(res->port_id, 12283 res->vf_id, is_on); 12284 #endif 12285 #ifdef RTE_LIBRTE_BNXT_PMD 12286 if (ret == -ENOTSUP) 12287 ret = rte_pmd_bnxt_set_vf_vlan_anti_spoof(res->port_id, 12288 res->vf_id, is_on); 12289 #endif 12290 12291 switch (ret) { 12292 case 0: 12293 break; 12294 case -EINVAL: 12295 printf("invalid vf_id %d\n", res->vf_id); 12296 break; 12297 case -ENODEV: 12298 printf("invalid port_id %d\n", res->port_id); 12299 break; 12300 case -ENOTSUP: 12301 printf("function not implemented\n"); 12302 break; 12303 default: 12304 printf("programming error: (%s)\n", strerror(-ret)); 12305 } 12306 } 12307 12308 cmdline_parse_inst_t cmd_set_vf_vlan_anti_spoof = { 12309 .f = cmd_set_vf_vlan_anti_spoof_parsed, 12310 .data = NULL, 12311 .help_str = "set vf vlan antispoof <port_id> <vf_id> on|off", 12312 .tokens = { 12313 (void *)&cmd_vf_vlan_anti_spoof_set, 12314 (void *)&cmd_vf_vlan_anti_spoof_vf, 12315 (void *)&cmd_vf_vlan_anti_spoof_vlan, 12316 (void *)&cmd_vf_vlan_anti_spoof_antispoof, 12317 (void *)&cmd_vf_vlan_anti_spoof_port_id, 12318 (void *)&cmd_vf_vlan_anti_spoof_vf_id, 12319 (void *)&cmd_vf_vlan_anti_spoof_on_off, 12320 NULL, 12321 }, 12322 }; 12323 12324 /* vf mac anti spoof configuration */ 12325 12326 /* Common result structure for vf mac anti spoof */ 12327 struct cmd_vf_mac_anti_spoof_result { 12328 cmdline_fixed_string_t set; 12329 cmdline_fixed_string_t vf; 12330 cmdline_fixed_string_t mac; 12331 cmdline_fixed_string_t antispoof; 12332 portid_t port_id; 12333 uint32_t vf_id; 12334 cmdline_fixed_string_t on_off; 12335 }; 12336 12337 /* Common CLI fields for vf mac anti spoof enable disable */ 12338 cmdline_parse_token_string_t cmd_vf_mac_anti_spoof_set = 12339 TOKEN_STRING_INITIALIZER 12340 (struct cmd_vf_mac_anti_spoof_result, 12341 set, "set"); 12342 cmdline_parse_token_string_t cmd_vf_mac_anti_spoof_vf = 12343 TOKEN_STRING_INITIALIZER 12344 (struct cmd_vf_mac_anti_spoof_result, 12345 vf, "vf"); 12346 cmdline_parse_token_string_t cmd_vf_mac_anti_spoof_mac = 12347 TOKEN_STRING_INITIALIZER 12348 (struct cmd_vf_mac_anti_spoof_result, 12349 mac, "mac"); 12350 cmdline_parse_token_string_t cmd_vf_mac_anti_spoof_antispoof = 12351 TOKEN_STRING_INITIALIZER 12352 (struct cmd_vf_mac_anti_spoof_result, 12353 antispoof, "antispoof"); 12354 cmdline_parse_token_num_t cmd_vf_mac_anti_spoof_port_id = 12355 TOKEN_NUM_INITIALIZER 12356 (struct cmd_vf_mac_anti_spoof_result, 12357 port_id, UINT16); 12358 cmdline_parse_token_num_t cmd_vf_mac_anti_spoof_vf_id = 12359 TOKEN_NUM_INITIALIZER 12360 (struct cmd_vf_mac_anti_spoof_result, 12361 vf_id, UINT32); 12362 cmdline_parse_token_string_t cmd_vf_mac_anti_spoof_on_off = 12363 TOKEN_STRING_INITIALIZER 12364 (struct cmd_vf_mac_anti_spoof_result, 12365 on_off, "on#off"); 12366 12367 static void 12368 cmd_set_vf_mac_anti_spoof_parsed( 12369 void *parsed_result, 12370 __attribute__((unused)) struct cmdline *cl, 12371 __attribute__((unused)) void *data) 12372 { 12373 struct cmd_vf_mac_anti_spoof_result *res = parsed_result; 12374 int ret = -ENOTSUP; 12375 12376 __rte_unused int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0; 12377 12378 if (port_id_is_invalid(res->port_id, ENABLED_WARN)) 12379 return; 12380 12381 #ifdef RTE_LIBRTE_IXGBE_PMD 12382 if (ret == -ENOTSUP) 12383 ret = rte_pmd_ixgbe_set_vf_mac_anti_spoof(res->port_id, 12384 res->vf_id, is_on); 12385 #endif 12386 #ifdef RTE_LIBRTE_I40E_PMD 12387 if (ret == -ENOTSUP) 12388 ret = rte_pmd_i40e_set_vf_mac_anti_spoof(res->port_id, 12389 res->vf_id, is_on); 12390 #endif 12391 #ifdef RTE_LIBRTE_BNXT_PMD 12392 if (ret == -ENOTSUP) 12393 ret = rte_pmd_bnxt_set_vf_mac_anti_spoof(res->port_id, 12394 res->vf_id, is_on); 12395 #endif 12396 12397 switch (ret) { 12398 case 0: 12399 break; 12400 case -EINVAL: 12401 printf("invalid vf_id %d or is_on %d\n", res->vf_id, is_on); 12402 break; 12403 case -ENODEV: 12404 printf("invalid port_id %d\n", res->port_id); 12405 break; 12406 case -ENOTSUP: 12407 printf("function not implemented\n"); 12408 break; 12409 default: 12410 printf("programming error: (%s)\n", strerror(-ret)); 12411 } 12412 } 12413 12414 cmdline_parse_inst_t cmd_set_vf_mac_anti_spoof = { 12415 .f = cmd_set_vf_mac_anti_spoof_parsed, 12416 .data = NULL, 12417 .help_str = "set vf mac antispoof <port_id> <vf_id> on|off", 12418 .tokens = { 12419 (void *)&cmd_vf_mac_anti_spoof_set, 12420 (void *)&cmd_vf_mac_anti_spoof_vf, 12421 (void *)&cmd_vf_mac_anti_spoof_mac, 12422 (void *)&cmd_vf_mac_anti_spoof_antispoof, 12423 (void *)&cmd_vf_mac_anti_spoof_port_id, 12424 (void *)&cmd_vf_mac_anti_spoof_vf_id, 12425 (void *)&cmd_vf_mac_anti_spoof_on_off, 12426 NULL, 12427 }, 12428 }; 12429 12430 /* vf vlan strip queue configuration */ 12431 12432 /* Common result structure for vf mac anti spoof */ 12433 struct cmd_vf_vlan_stripq_result { 12434 cmdline_fixed_string_t set; 12435 cmdline_fixed_string_t vf; 12436 cmdline_fixed_string_t vlan; 12437 cmdline_fixed_string_t stripq; 12438 portid_t port_id; 12439 uint16_t vf_id; 12440 cmdline_fixed_string_t on_off; 12441 }; 12442 12443 /* Common CLI fields for vf vlan strip enable disable */ 12444 cmdline_parse_token_string_t cmd_vf_vlan_stripq_set = 12445 TOKEN_STRING_INITIALIZER 12446 (struct cmd_vf_vlan_stripq_result, 12447 set, "set"); 12448 cmdline_parse_token_string_t cmd_vf_vlan_stripq_vf = 12449 TOKEN_STRING_INITIALIZER 12450 (struct cmd_vf_vlan_stripq_result, 12451 vf, "vf"); 12452 cmdline_parse_token_string_t cmd_vf_vlan_stripq_vlan = 12453 TOKEN_STRING_INITIALIZER 12454 (struct cmd_vf_vlan_stripq_result, 12455 vlan, "vlan"); 12456 cmdline_parse_token_string_t cmd_vf_vlan_stripq_stripq = 12457 TOKEN_STRING_INITIALIZER 12458 (struct cmd_vf_vlan_stripq_result, 12459 stripq, "stripq"); 12460 cmdline_parse_token_num_t cmd_vf_vlan_stripq_port_id = 12461 TOKEN_NUM_INITIALIZER 12462 (struct cmd_vf_vlan_stripq_result, 12463 port_id, UINT16); 12464 cmdline_parse_token_num_t cmd_vf_vlan_stripq_vf_id = 12465 TOKEN_NUM_INITIALIZER 12466 (struct cmd_vf_vlan_stripq_result, 12467 vf_id, UINT16); 12468 cmdline_parse_token_string_t cmd_vf_vlan_stripq_on_off = 12469 TOKEN_STRING_INITIALIZER 12470 (struct cmd_vf_vlan_stripq_result, 12471 on_off, "on#off"); 12472 12473 static void 12474 cmd_set_vf_vlan_stripq_parsed( 12475 void *parsed_result, 12476 __attribute__((unused)) struct cmdline *cl, 12477 __attribute__((unused)) void *data) 12478 { 12479 struct cmd_vf_vlan_stripq_result *res = parsed_result; 12480 int ret = -ENOTSUP; 12481 12482 __rte_unused int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0; 12483 12484 if (port_id_is_invalid(res->port_id, ENABLED_WARN)) 12485 return; 12486 12487 #ifdef RTE_LIBRTE_IXGBE_PMD 12488 if (ret == -ENOTSUP) 12489 ret = rte_pmd_ixgbe_set_vf_vlan_stripq(res->port_id, 12490 res->vf_id, is_on); 12491 #endif 12492 #ifdef RTE_LIBRTE_I40E_PMD 12493 if (ret == -ENOTSUP) 12494 ret = rte_pmd_i40e_set_vf_vlan_stripq(res->port_id, 12495 res->vf_id, is_on); 12496 #endif 12497 #ifdef RTE_LIBRTE_BNXT_PMD 12498 if (ret == -ENOTSUP) 12499 ret = rte_pmd_bnxt_set_vf_vlan_stripq(res->port_id, 12500 res->vf_id, is_on); 12501 #endif 12502 12503 switch (ret) { 12504 case 0: 12505 break; 12506 case -EINVAL: 12507 printf("invalid vf_id %d or is_on %d\n", res->vf_id, is_on); 12508 break; 12509 case -ENODEV: 12510 printf("invalid port_id %d\n", res->port_id); 12511 break; 12512 case -ENOTSUP: 12513 printf("function not implemented\n"); 12514 break; 12515 default: 12516 printf("programming error: (%s)\n", strerror(-ret)); 12517 } 12518 } 12519 12520 cmdline_parse_inst_t cmd_set_vf_vlan_stripq = { 12521 .f = cmd_set_vf_vlan_stripq_parsed, 12522 .data = NULL, 12523 .help_str = "set vf vlan stripq <port_id> <vf_id> on|off", 12524 .tokens = { 12525 (void *)&cmd_vf_vlan_stripq_set, 12526 (void *)&cmd_vf_vlan_stripq_vf, 12527 (void *)&cmd_vf_vlan_stripq_vlan, 12528 (void *)&cmd_vf_vlan_stripq_stripq, 12529 (void *)&cmd_vf_vlan_stripq_port_id, 12530 (void *)&cmd_vf_vlan_stripq_vf_id, 12531 (void *)&cmd_vf_vlan_stripq_on_off, 12532 NULL, 12533 }, 12534 }; 12535 12536 /* vf vlan insert configuration */ 12537 12538 /* Common result structure for vf vlan insert */ 12539 struct cmd_vf_vlan_insert_result { 12540 cmdline_fixed_string_t set; 12541 cmdline_fixed_string_t vf; 12542 cmdline_fixed_string_t vlan; 12543 cmdline_fixed_string_t insert; 12544 portid_t port_id; 12545 uint16_t vf_id; 12546 uint16_t vlan_id; 12547 }; 12548 12549 /* Common CLI fields for vf vlan insert enable disable */ 12550 cmdline_parse_token_string_t cmd_vf_vlan_insert_set = 12551 TOKEN_STRING_INITIALIZER 12552 (struct cmd_vf_vlan_insert_result, 12553 set, "set"); 12554 cmdline_parse_token_string_t cmd_vf_vlan_insert_vf = 12555 TOKEN_STRING_INITIALIZER 12556 (struct cmd_vf_vlan_insert_result, 12557 vf, "vf"); 12558 cmdline_parse_token_string_t cmd_vf_vlan_insert_vlan = 12559 TOKEN_STRING_INITIALIZER 12560 (struct cmd_vf_vlan_insert_result, 12561 vlan, "vlan"); 12562 cmdline_parse_token_string_t cmd_vf_vlan_insert_insert = 12563 TOKEN_STRING_INITIALIZER 12564 (struct cmd_vf_vlan_insert_result, 12565 insert, "insert"); 12566 cmdline_parse_token_num_t cmd_vf_vlan_insert_port_id = 12567 TOKEN_NUM_INITIALIZER 12568 (struct cmd_vf_vlan_insert_result, 12569 port_id, UINT16); 12570 cmdline_parse_token_num_t cmd_vf_vlan_insert_vf_id = 12571 TOKEN_NUM_INITIALIZER 12572 (struct cmd_vf_vlan_insert_result, 12573 vf_id, UINT16); 12574 cmdline_parse_token_num_t cmd_vf_vlan_insert_vlan_id = 12575 TOKEN_NUM_INITIALIZER 12576 (struct cmd_vf_vlan_insert_result, 12577 vlan_id, UINT16); 12578 12579 static void 12580 cmd_set_vf_vlan_insert_parsed( 12581 void *parsed_result, 12582 __attribute__((unused)) struct cmdline *cl, 12583 __attribute__((unused)) void *data) 12584 { 12585 struct cmd_vf_vlan_insert_result *res = parsed_result; 12586 int ret = -ENOTSUP; 12587 12588 if (port_id_is_invalid(res->port_id, ENABLED_WARN)) 12589 return; 12590 12591 #ifdef RTE_LIBRTE_IXGBE_PMD 12592 if (ret == -ENOTSUP) 12593 ret = rte_pmd_ixgbe_set_vf_vlan_insert(res->port_id, res->vf_id, 12594 res->vlan_id); 12595 #endif 12596 #ifdef RTE_LIBRTE_I40E_PMD 12597 if (ret == -ENOTSUP) 12598 ret = rte_pmd_i40e_set_vf_vlan_insert(res->port_id, res->vf_id, 12599 res->vlan_id); 12600 #endif 12601 #ifdef RTE_LIBRTE_BNXT_PMD 12602 if (ret == -ENOTSUP) 12603 ret = rte_pmd_bnxt_set_vf_vlan_insert(res->port_id, res->vf_id, 12604 res->vlan_id); 12605 #endif 12606 12607 switch (ret) { 12608 case 0: 12609 break; 12610 case -EINVAL: 12611 printf("invalid vf_id %d or vlan_id %d\n", res->vf_id, res->vlan_id); 12612 break; 12613 case -ENODEV: 12614 printf("invalid port_id %d\n", res->port_id); 12615 break; 12616 case -ENOTSUP: 12617 printf("function not implemented\n"); 12618 break; 12619 default: 12620 printf("programming error: (%s)\n", strerror(-ret)); 12621 } 12622 } 12623 12624 cmdline_parse_inst_t cmd_set_vf_vlan_insert = { 12625 .f = cmd_set_vf_vlan_insert_parsed, 12626 .data = NULL, 12627 .help_str = "set vf vlan insert <port_id> <vf_id> <vlan_id>", 12628 .tokens = { 12629 (void *)&cmd_vf_vlan_insert_set, 12630 (void *)&cmd_vf_vlan_insert_vf, 12631 (void *)&cmd_vf_vlan_insert_vlan, 12632 (void *)&cmd_vf_vlan_insert_insert, 12633 (void *)&cmd_vf_vlan_insert_port_id, 12634 (void *)&cmd_vf_vlan_insert_vf_id, 12635 (void *)&cmd_vf_vlan_insert_vlan_id, 12636 NULL, 12637 }, 12638 }; 12639 12640 /* tx loopback configuration */ 12641 12642 /* Common result structure for tx loopback */ 12643 struct cmd_tx_loopback_result { 12644 cmdline_fixed_string_t set; 12645 cmdline_fixed_string_t tx; 12646 cmdline_fixed_string_t loopback; 12647 portid_t port_id; 12648 cmdline_fixed_string_t on_off; 12649 }; 12650 12651 /* Common CLI fields for tx loopback enable disable */ 12652 cmdline_parse_token_string_t cmd_tx_loopback_set = 12653 TOKEN_STRING_INITIALIZER 12654 (struct cmd_tx_loopback_result, 12655 set, "set"); 12656 cmdline_parse_token_string_t cmd_tx_loopback_tx = 12657 TOKEN_STRING_INITIALIZER 12658 (struct cmd_tx_loopback_result, 12659 tx, "tx"); 12660 cmdline_parse_token_string_t cmd_tx_loopback_loopback = 12661 TOKEN_STRING_INITIALIZER 12662 (struct cmd_tx_loopback_result, 12663 loopback, "loopback"); 12664 cmdline_parse_token_num_t cmd_tx_loopback_port_id = 12665 TOKEN_NUM_INITIALIZER 12666 (struct cmd_tx_loopback_result, 12667 port_id, UINT16); 12668 cmdline_parse_token_string_t cmd_tx_loopback_on_off = 12669 TOKEN_STRING_INITIALIZER 12670 (struct cmd_tx_loopback_result, 12671 on_off, "on#off"); 12672 12673 static void 12674 cmd_set_tx_loopback_parsed( 12675 void *parsed_result, 12676 __attribute__((unused)) struct cmdline *cl, 12677 __attribute__((unused)) void *data) 12678 { 12679 struct cmd_tx_loopback_result *res = parsed_result; 12680 int ret = -ENOTSUP; 12681 12682 __rte_unused int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0; 12683 12684 if (port_id_is_invalid(res->port_id, ENABLED_WARN)) 12685 return; 12686 12687 #ifdef RTE_LIBRTE_IXGBE_PMD 12688 if (ret == -ENOTSUP) 12689 ret = rte_pmd_ixgbe_set_tx_loopback(res->port_id, is_on); 12690 #endif 12691 #ifdef RTE_LIBRTE_I40E_PMD 12692 if (ret == -ENOTSUP) 12693 ret = rte_pmd_i40e_set_tx_loopback(res->port_id, is_on); 12694 #endif 12695 #ifdef RTE_LIBRTE_BNXT_PMD 12696 if (ret == -ENOTSUP) 12697 ret = rte_pmd_bnxt_set_tx_loopback(res->port_id, is_on); 12698 #endif 12699 12700 switch (ret) { 12701 case 0: 12702 break; 12703 case -EINVAL: 12704 printf("invalid is_on %d\n", is_on); 12705 break; 12706 case -ENODEV: 12707 printf("invalid port_id %d\n", res->port_id); 12708 break; 12709 case -ENOTSUP: 12710 printf("function not implemented\n"); 12711 break; 12712 default: 12713 printf("programming error: (%s)\n", strerror(-ret)); 12714 } 12715 } 12716 12717 cmdline_parse_inst_t cmd_set_tx_loopback = { 12718 .f = cmd_set_tx_loopback_parsed, 12719 .data = NULL, 12720 .help_str = "set tx loopback <port_id> on|off", 12721 .tokens = { 12722 (void *)&cmd_tx_loopback_set, 12723 (void *)&cmd_tx_loopback_tx, 12724 (void *)&cmd_tx_loopback_loopback, 12725 (void *)&cmd_tx_loopback_port_id, 12726 (void *)&cmd_tx_loopback_on_off, 12727 NULL, 12728 }, 12729 }; 12730 12731 /* all queues drop enable configuration */ 12732 12733 /* Common result structure for all queues drop enable */ 12734 struct cmd_all_queues_drop_en_result { 12735 cmdline_fixed_string_t set; 12736 cmdline_fixed_string_t all; 12737 cmdline_fixed_string_t queues; 12738 cmdline_fixed_string_t drop; 12739 portid_t port_id; 12740 cmdline_fixed_string_t on_off; 12741 }; 12742 12743 /* Common CLI fields for tx loopback enable disable */ 12744 cmdline_parse_token_string_t cmd_all_queues_drop_en_set = 12745 TOKEN_STRING_INITIALIZER 12746 (struct cmd_all_queues_drop_en_result, 12747 set, "set"); 12748 cmdline_parse_token_string_t cmd_all_queues_drop_en_all = 12749 TOKEN_STRING_INITIALIZER 12750 (struct cmd_all_queues_drop_en_result, 12751 all, "all"); 12752 cmdline_parse_token_string_t cmd_all_queues_drop_en_queues = 12753 TOKEN_STRING_INITIALIZER 12754 (struct cmd_all_queues_drop_en_result, 12755 queues, "queues"); 12756 cmdline_parse_token_string_t cmd_all_queues_drop_en_drop = 12757 TOKEN_STRING_INITIALIZER 12758 (struct cmd_all_queues_drop_en_result, 12759 drop, "drop"); 12760 cmdline_parse_token_num_t cmd_all_queues_drop_en_port_id = 12761 TOKEN_NUM_INITIALIZER 12762 (struct cmd_all_queues_drop_en_result, 12763 port_id, UINT16); 12764 cmdline_parse_token_string_t cmd_all_queues_drop_en_on_off = 12765 TOKEN_STRING_INITIALIZER 12766 (struct cmd_all_queues_drop_en_result, 12767 on_off, "on#off"); 12768 12769 static void 12770 cmd_set_all_queues_drop_en_parsed( 12771 void *parsed_result, 12772 __attribute__((unused)) struct cmdline *cl, 12773 __attribute__((unused)) void *data) 12774 { 12775 struct cmd_all_queues_drop_en_result *res = parsed_result; 12776 int ret = -ENOTSUP; 12777 int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0; 12778 12779 if (port_id_is_invalid(res->port_id, ENABLED_WARN)) 12780 return; 12781 12782 #ifdef RTE_LIBRTE_IXGBE_PMD 12783 if (ret == -ENOTSUP) 12784 ret = rte_pmd_ixgbe_set_all_queues_drop_en(res->port_id, is_on); 12785 #endif 12786 #ifdef RTE_LIBRTE_BNXT_PMD 12787 if (ret == -ENOTSUP) 12788 ret = rte_pmd_bnxt_set_all_queues_drop_en(res->port_id, is_on); 12789 #endif 12790 switch (ret) { 12791 case 0: 12792 break; 12793 case -EINVAL: 12794 printf("invalid is_on %d\n", is_on); 12795 break; 12796 case -ENODEV: 12797 printf("invalid port_id %d\n", res->port_id); 12798 break; 12799 case -ENOTSUP: 12800 printf("function not implemented\n"); 12801 break; 12802 default: 12803 printf("programming error: (%s)\n", strerror(-ret)); 12804 } 12805 } 12806 12807 cmdline_parse_inst_t cmd_set_all_queues_drop_en = { 12808 .f = cmd_set_all_queues_drop_en_parsed, 12809 .data = NULL, 12810 .help_str = "set all queues drop <port_id> on|off", 12811 .tokens = { 12812 (void *)&cmd_all_queues_drop_en_set, 12813 (void *)&cmd_all_queues_drop_en_all, 12814 (void *)&cmd_all_queues_drop_en_queues, 12815 (void *)&cmd_all_queues_drop_en_drop, 12816 (void *)&cmd_all_queues_drop_en_port_id, 12817 (void *)&cmd_all_queues_drop_en_on_off, 12818 NULL, 12819 }, 12820 }; 12821 12822 /* vf split drop enable configuration */ 12823 12824 /* Common result structure for vf split drop enable */ 12825 struct cmd_vf_split_drop_en_result { 12826 cmdline_fixed_string_t set; 12827 cmdline_fixed_string_t vf; 12828 cmdline_fixed_string_t split; 12829 cmdline_fixed_string_t drop; 12830 portid_t port_id; 12831 uint16_t vf_id; 12832 cmdline_fixed_string_t on_off; 12833 }; 12834 12835 /* Common CLI fields for vf split drop enable disable */ 12836 cmdline_parse_token_string_t cmd_vf_split_drop_en_set = 12837 TOKEN_STRING_INITIALIZER 12838 (struct cmd_vf_split_drop_en_result, 12839 set, "set"); 12840 cmdline_parse_token_string_t cmd_vf_split_drop_en_vf = 12841 TOKEN_STRING_INITIALIZER 12842 (struct cmd_vf_split_drop_en_result, 12843 vf, "vf"); 12844 cmdline_parse_token_string_t cmd_vf_split_drop_en_split = 12845 TOKEN_STRING_INITIALIZER 12846 (struct cmd_vf_split_drop_en_result, 12847 split, "split"); 12848 cmdline_parse_token_string_t cmd_vf_split_drop_en_drop = 12849 TOKEN_STRING_INITIALIZER 12850 (struct cmd_vf_split_drop_en_result, 12851 drop, "drop"); 12852 cmdline_parse_token_num_t cmd_vf_split_drop_en_port_id = 12853 TOKEN_NUM_INITIALIZER 12854 (struct cmd_vf_split_drop_en_result, 12855 port_id, UINT16); 12856 cmdline_parse_token_num_t cmd_vf_split_drop_en_vf_id = 12857 TOKEN_NUM_INITIALIZER 12858 (struct cmd_vf_split_drop_en_result, 12859 vf_id, UINT16); 12860 cmdline_parse_token_string_t cmd_vf_split_drop_en_on_off = 12861 TOKEN_STRING_INITIALIZER 12862 (struct cmd_vf_split_drop_en_result, 12863 on_off, "on#off"); 12864 12865 static void 12866 cmd_set_vf_split_drop_en_parsed( 12867 void *parsed_result, 12868 __attribute__((unused)) struct cmdline *cl, 12869 __attribute__((unused)) void *data) 12870 { 12871 struct cmd_vf_split_drop_en_result *res = parsed_result; 12872 int ret = -ENOTSUP; 12873 int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0; 12874 12875 if (port_id_is_invalid(res->port_id, ENABLED_WARN)) 12876 return; 12877 12878 #ifdef RTE_LIBRTE_IXGBE_PMD 12879 ret = rte_pmd_ixgbe_set_vf_split_drop_en(res->port_id, res->vf_id, 12880 is_on); 12881 #endif 12882 switch (ret) { 12883 case 0: 12884 break; 12885 case -EINVAL: 12886 printf("invalid vf_id %d or is_on %d\n", res->vf_id, is_on); 12887 break; 12888 case -ENODEV: 12889 printf("invalid port_id %d\n", res->port_id); 12890 break; 12891 case -ENOTSUP: 12892 printf("not supported on port %d\n", res->port_id); 12893 break; 12894 default: 12895 printf("programming error: (%s)\n", strerror(-ret)); 12896 } 12897 } 12898 12899 cmdline_parse_inst_t cmd_set_vf_split_drop_en = { 12900 .f = cmd_set_vf_split_drop_en_parsed, 12901 .data = NULL, 12902 .help_str = "set vf split drop <port_id> <vf_id> on|off", 12903 .tokens = { 12904 (void *)&cmd_vf_split_drop_en_set, 12905 (void *)&cmd_vf_split_drop_en_vf, 12906 (void *)&cmd_vf_split_drop_en_split, 12907 (void *)&cmd_vf_split_drop_en_drop, 12908 (void *)&cmd_vf_split_drop_en_port_id, 12909 (void *)&cmd_vf_split_drop_en_vf_id, 12910 (void *)&cmd_vf_split_drop_en_on_off, 12911 NULL, 12912 }, 12913 }; 12914 12915 /* vf mac address configuration */ 12916 12917 /* Common result structure for vf mac address */ 12918 struct cmd_set_vf_mac_addr_result { 12919 cmdline_fixed_string_t set; 12920 cmdline_fixed_string_t vf; 12921 cmdline_fixed_string_t mac; 12922 cmdline_fixed_string_t addr; 12923 portid_t port_id; 12924 uint16_t vf_id; 12925 struct ether_addr mac_addr; 12926 12927 }; 12928 12929 /* Common CLI fields for vf split drop enable disable */ 12930 cmdline_parse_token_string_t cmd_set_vf_mac_addr_set = 12931 TOKEN_STRING_INITIALIZER 12932 (struct cmd_set_vf_mac_addr_result, 12933 set, "set"); 12934 cmdline_parse_token_string_t cmd_set_vf_mac_addr_vf = 12935 TOKEN_STRING_INITIALIZER 12936 (struct cmd_set_vf_mac_addr_result, 12937 vf, "vf"); 12938 cmdline_parse_token_string_t cmd_set_vf_mac_addr_mac = 12939 TOKEN_STRING_INITIALIZER 12940 (struct cmd_set_vf_mac_addr_result, 12941 mac, "mac"); 12942 cmdline_parse_token_string_t cmd_set_vf_mac_addr_addr = 12943 TOKEN_STRING_INITIALIZER 12944 (struct cmd_set_vf_mac_addr_result, 12945 addr, "addr"); 12946 cmdline_parse_token_num_t cmd_set_vf_mac_addr_port_id = 12947 TOKEN_NUM_INITIALIZER 12948 (struct cmd_set_vf_mac_addr_result, 12949 port_id, UINT16); 12950 cmdline_parse_token_num_t cmd_set_vf_mac_addr_vf_id = 12951 TOKEN_NUM_INITIALIZER 12952 (struct cmd_set_vf_mac_addr_result, 12953 vf_id, UINT16); 12954 cmdline_parse_token_etheraddr_t cmd_set_vf_mac_addr_mac_addr = 12955 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_vf_mac_addr_result, 12956 mac_addr); 12957 12958 static void 12959 cmd_set_vf_mac_addr_parsed( 12960 void *parsed_result, 12961 __attribute__((unused)) struct cmdline *cl, 12962 __attribute__((unused)) void *data) 12963 { 12964 struct cmd_set_vf_mac_addr_result *res = parsed_result; 12965 int ret = -ENOTSUP; 12966 12967 if (port_id_is_invalid(res->port_id, ENABLED_WARN)) 12968 return; 12969 12970 #ifdef RTE_LIBRTE_IXGBE_PMD 12971 if (ret == -ENOTSUP) 12972 ret = rte_pmd_ixgbe_set_vf_mac_addr(res->port_id, res->vf_id, 12973 &res->mac_addr); 12974 #endif 12975 #ifdef RTE_LIBRTE_I40E_PMD 12976 if (ret == -ENOTSUP) 12977 ret = rte_pmd_i40e_set_vf_mac_addr(res->port_id, res->vf_id, 12978 &res->mac_addr); 12979 #endif 12980 #ifdef RTE_LIBRTE_BNXT_PMD 12981 if (ret == -ENOTSUP) 12982 ret = rte_pmd_bnxt_set_vf_mac_addr(res->port_id, res->vf_id, 12983 &res->mac_addr); 12984 #endif 12985 12986 switch (ret) { 12987 case 0: 12988 break; 12989 case -EINVAL: 12990 printf("invalid vf_id %d or mac_addr\n", res->vf_id); 12991 break; 12992 case -ENODEV: 12993 printf("invalid port_id %d\n", res->port_id); 12994 break; 12995 case -ENOTSUP: 12996 printf("function not implemented\n"); 12997 break; 12998 default: 12999 printf("programming error: (%s)\n", strerror(-ret)); 13000 } 13001 } 13002 13003 cmdline_parse_inst_t cmd_set_vf_mac_addr = { 13004 .f = cmd_set_vf_mac_addr_parsed, 13005 .data = NULL, 13006 .help_str = "set vf mac addr <port_id> <vf_id> <mac_addr>", 13007 .tokens = { 13008 (void *)&cmd_set_vf_mac_addr_set, 13009 (void *)&cmd_set_vf_mac_addr_vf, 13010 (void *)&cmd_set_vf_mac_addr_mac, 13011 (void *)&cmd_set_vf_mac_addr_addr, 13012 (void *)&cmd_set_vf_mac_addr_port_id, 13013 (void *)&cmd_set_vf_mac_addr_vf_id, 13014 (void *)&cmd_set_vf_mac_addr_mac_addr, 13015 NULL, 13016 }, 13017 }; 13018 13019 /* MACsec configuration */ 13020 13021 /* Common result structure for MACsec offload enable */ 13022 struct cmd_macsec_offload_on_result { 13023 cmdline_fixed_string_t set; 13024 cmdline_fixed_string_t macsec; 13025 cmdline_fixed_string_t offload; 13026 portid_t port_id; 13027 cmdline_fixed_string_t on; 13028 cmdline_fixed_string_t encrypt; 13029 cmdline_fixed_string_t en_on_off; 13030 cmdline_fixed_string_t replay_protect; 13031 cmdline_fixed_string_t rp_on_off; 13032 }; 13033 13034 /* Common CLI fields for MACsec offload disable */ 13035 cmdline_parse_token_string_t cmd_macsec_offload_on_set = 13036 TOKEN_STRING_INITIALIZER 13037 (struct cmd_macsec_offload_on_result, 13038 set, "set"); 13039 cmdline_parse_token_string_t cmd_macsec_offload_on_macsec = 13040 TOKEN_STRING_INITIALIZER 13041 (struct cmd_macsec_offload_on_result, 13042 macsec, "macsec"); 13043 cmdline_parse_token_string_t cmd_macsec_offload_on_offload = 13044 TOKEN_STRING_INITIALIZER 13045 (struct cmd_macsec_offload_on_result, 13046 offload, "offload"); 13047 cmdline_parse_token_num_t cmd_macsec_offload_on_port_id = 13048 TOKEN_NUM_INITIALIZER 13049 (struct cmd_macsec_offload_on_result, 13050 port_id, UINT16); 13051 cmdline_parse_token_string_t cmd_macsec_offload_on_on = 13052 TOKEN_STRING_INITIALIZER 13053 (struct cmd_macsec_offload_on_result, 13054 on, "on"); 13055 cmdline_parse_token_string_t cmd_macsec_offload_on_encrypt = 13056 TOKEN_STRING_INITIALIZER 13057 (struct cmd_macsec_offload_on_result, 13058 encrypt, "encrypt"); 13059 cmdline_parse_token_string_t cmd_macsec_offload_on_en_on_off = 13060 TOKEN_STRING_INITIALIZER 13061 (struct cmd_macsec_offload_on_result, 13062 en_on_off, "on#off"); 13063 cmdline_parse_token_string_t cmd_macsec_offload_on_replay_protect = 13064 TOKEN_STRING_INITIALIZER 13065 (struct cmd_macsec_offload_on_result, 13066 replay_protect, "replay-protect"); 13067 cmdline_parse_token_string_t cmd_macsec_offload_on_rp_on_off = 13068 TOKEN_STRING_INITIALIZER 13069 (struct cmd_macsec_offload_on_result, 13070 rp_on_off, "on#off"); 13071 13072 static void 13073 cmd_set_macsec_offload_on_parsed( 13074 void *parsed_result, 13075 __attribute__((unused)) struct cmdline *cl, 13076 __attribute__((unused)) void *data) 13077 { 13078 struct cmd_macsec_offload_on_result *res = parsed_result; 13079 int ret = -ENOTSUP; 13080 portid_t port_id = res->port_id; 13081 int en = (strcmp(res->en_on_off, "on") == 0) ? 1 : 0; 13082 int rp = (strcmp(res->rp_on_off, "on") == 0) ? 1 : 0; 13083 13084 if (port_id_is_invalid(port_id, ENABLED_WARN)) 13085 return; 13086 if (!port_is_stopped(port_id)) { 13087 printf("Please stop port %d first\n", port_id); 13088 return; 13089 } 13090 13091 ports[port_id].dev_conf.txmode.offloads |= DEV_TX_OFFLOAD_MACSEC_INSERT; 13092 #ifdef RTE_LIBRTE_IXGBE_PMD 13093 ret = rte_pmd_ixgbe_macsec_enable(port_id, en, rp); 13094 #endif 13095 RTE_SET_USED(en); 13096 RTE_SET_USED(rp); 13097 13098 switch (ret) { 13099 case 0: 13100 cmd_reconfig_device_queue(port_id, 1, 1); 13101 break; 13102 case -ENODEV: 13103 printf("invalid port_id %d\n", port_id); 13104 break; 13105 case -ENOTSUP: 13106 printf("not supported on port %d\n", port_id); 13107 break; 13108 default: 13109 printf("programming error: (%s)\n", strerror(-ret)); 13110 } 13111 } 13112 13113 cmdline_parse_inst_t cmd_set_macsec_offload_on = { 13114 .f = cmd_set_macsec_offload_on_parsed, 13115 .data = NULL, 13116 .help_str = "set macsec offload <port_id> on " 13117 "encrypt on|off replay-protect on|off", 13118 .tokens = { 13119 (void *)&cmd_macsec_offload_on_set, 13120 (void *)&cmd_macsec_offload_on_macsec, 13121 (void *)&cmd_macsec_offload_on_offload, 13122 (void *)&cmd_macsec_offload_on_port_id, 13123 (void *)&cmd_macsec_offload_on_on, 13124 (void *)&cmd_macsec_offload_on_encrypt, 13125 (void *)&cmd_macsec_offload_on_en_on_off, 13126 (void *)&cmd_macsec_offload_on_replay_protect, 13127 (void *)&cmd_macsec_offload_on_rp_on_off, 13128 NULL, 13129 }, 13130 }; 13131 13132 /* Common result structure for MACsec offload disable */ 13133 struct cmd_macsec_offload_off_result { 13134 cmdline_fixed_string_t set; 13135 cmdline_fixed_string_t macsec; 13136 cmdline_fixed_string_t offload; 13137 portid_t port_id; 13138 cmdline_fixed_string_t off; 13139 }; 13140 13141 /* Common CLI fields for MACsec offload disable */ 13142 cmdline_parse_token_string_t cmd_macsec_offload_off_set = 13143 TOKEN_STRING_INITIALIZER 13144 (struct cmd_macsec_offload_off_result, 13145 set, "set"); 13146 cmdline_parse_token_string_t cmd_macsec_offload_off_macsec = 13147 TOKEN_STRING_INITIALIZER 13148 (struct cmd_macsec_offload_off_result, 13149 macsec, "macsec"); 13150 cmdline_parse_token_string_t cmd_macsec_offload_off_offload = 13151 TOKEN_STRING_INITIALIZER 13152 (struct cmd_macsec_offload_off_result, 13153 offload, "offload"); 13154 cmdline_parse_token_num_t cmd_macsec_offload_off_port_id = 13155 TOKEN_NUM_INITIALIZER 13156 (struct cmd_macsec_offload_off_result, 13157 port_id, UINT16); 13158 cmdline_parse_token_string_t cmd_macsec_offload_off_off = 13159 TOKEN_STRING_INITIALIZER 13160 (struct cmd_macsec_offload_off_result, 13161 off, "off"); 13162 13163 static void 13164 cmd_set_macsec_offload_off_parsed( 13165 void *parsed_result, 13166 __attribute__((unused)) struct cmdline *cl, 13167 __attribute__((unused)) void *data) 13168 { 13169 struct cmd_macsec_offload_off_result *res = parsed_result; 13170 int ret = -ENOTSUP; 13171 portid_t port_id = res->port_id; 13172 13173 if (port_id_is_invalid(port_id, ENABLED_WARN)) 13174 return; 13175 if (!port_is_stopped(port_id)) { 13176 printf("Please stop port %d first\n", port_id); 13177 return; 13178 } 13179 13180 ports[port_id].dev_conf.txmode.offloads &= 13181 ~DEV_TX_OFFLOAD_MACSEC_INSERT; 13182 #ifdef RTE_LIBRTE_IXGBE_PMD 13183 ret = rte_pmd_ixgbe_macsec_disable(port_id); 13184 #endif 13185 13186 switch (ret) { 13187 case 0: 13188 cmd_reconfig_device_queue(port_id, 1, 1); 13189 break; 13190 case -ENODEV: 13191 printf("invalid port_id %d\n", port_id); 13192 break; 13193 case -ENOTSUP: 13194 printf("not supported on port %d\n", port_id); 13195 break; 13196 default: 13197 printf("programming error: (%s)\n", strerror(-ret)); 13198 } 13199 } 13200 13201 cmdline_parse_inst_t cmd_set_macsec_offload_off = { 13202 .f = cmd_set_macsec_offload_off_parsed, 13203 .data = NULL, 13204 .help_str = "set macsec offload <port_id> off", 13205 .tokens = { 13206 (void *)&cmd_macsec_offload_off_set, 13207 (void *)&cmd_macsec_offload_off_macsec, 13208 (void *)&cmd_macsec_offload_off_offload, 13209 (void *)&cmd_macsec_offload_off_port_id, 13210 (void *)&cmd_macsec_offload_off_off, 13211 NULL, 13212 }, 13213 }; 13214 13215 /* Common result structure for MACsec secure connection configure */ 13216 struct cmd_macsec_sc_result { 13217 cmdline_fixed_string_t set; 13218 cmdline_fixed_string_t macsec; 13219 cmdline_fixed_string_t sc; 13220 cmdline_fixed_string_t tx_rx; 13221 portid_t port_id; 13222 struct ether_addr mac; 13223 uint16_t pi; 13224 }; 13225 13226 /* Common CLI fields for MACsec secure connection configure */ 13227 cmdline_parse_token_string_t cmd_macsec_sc_set = 13228 TOKEN_STRING_INITIALIZER 13229 (struct cmd_macsec_sc_result, 13230 set, "set"); 13231 cmdline_parse_token_string_t cmd_macsec_sc_macsec = 13232 TOKEN_STRING_INITIALIZER 13233 (struct cmd_macsec_sc_result, 13234 macsec, "macsec"); 13235 cmdline_parse_token_string_t cmd_macsec_sc_sc = 13236 TOKEN_STRING_INITIALIZER 13237 (struct cmd_macsec_sc_result, 13238 sc, "sc"); 13239 cmdline_parse_token_string_t cmd_macsec_sc_tx_rx = 13240 TOKEN_STRING_INITIALIZER 13241 (struct cmd_macsec_sc_result, 13242 tx_rx, "tx#rx"); 13243 cmdline_parse_token_num_t cmd_macsec_sc_port_id = 13244 TOKEN_NUM_INITIALIZER 13245 (struct cmd_macsec_sc_result, 13246 port_id, UINT16); 13247 cmdline_parse_token_etheraddr_t cmd_macsec_sc_mac = 13248 TOKEN_ETHERADDR_INITIALIZER 13249 (struct cmd_macsec_sc_result, 13250 mac); 13251 cmdline_parse_token_num_t cmd_macsec_sc_pi = 13252 TOKEN_NUM_INITIALIZER 13253 (struct cmd_macsec_sc_result, 13254 pi, UINT16); 13255 13256 static void 13257 cmd_set_macsec_sc_parsed( 13258 void *parsed_result, 13259 __attribute__((unused)) struct cmdline *cl, 13260 __attribute__((unused)) void *data) 13261 { 13262 struct cmd_macsec_sc_result *res = parsed_result; 13263 int ret = -ENOTSUP; 13264 int is_tx = (strcmp(res->tx_rx, "tx") == 0) ? 1 : 0; 13265 13266 #ifdef RTE_LIBRTE_IXGBE_PMD 13267 ret = is_tx ? 13268 rte_pmd_ixgbe_macsec_config_txsc(res->port_id, 13269 res->mac.addr_bytes) : 13270 rte_pmd_ixgbe_macsec_config_rxsc(res->port_id, 13271 res->mac.addr_bytes, res->pi); 13272 #endif 13273 RTE_SET_USED(is_tx); 13274 13275 switch (ret) { 13276 case 0: 13277 break; 13278 case -ENODEV: 13279 printf("invalid port_id %d\n", res->port_id); 13280 break; 13281 case -ENOTSUP: 13282 printf("not supported on port %d\n", res->port_id); 13283 break; 13284 default: 13285 printf("programming error: (%s)\n", strerror(-ret)); 13286 } 13287 } 13288 13289 cmdline_parse_inst_t cmd_set_macsec_sc = { 13290 .f = cmd_set_macsec_sc_parsed, 13291 .data = NULL, 13292 .help_str = "set macsec sc tx|rx <port_id> <mac> <pi>", 13293 .tokens = { 13294 (void *)&cmd_macsec_sc_set, 13295 (void *)&cmd_macsec_sc_macsec, 13296 (void *)&cmd_macsec_sc_sc, 13297 (void *)&cmd_macsec_sc_tx_rx, 13298 (void *)&cmd_macsec_sc_port_id, 13299 (void *)&cmd_macsec_sc_mac, 13300 (void *)&cmd_macsec_sc_pi, 13301 NULL, 13302 }, 13303 }; 13304 13305 /* Common result structure for MACsec secure connection configure */ 13306 struct cmd_macsec_sa_result { 13307 cmdline_fixed_string_t set; 13308 cmdline_fixed_string_t macsec; 13309 cmdline_fixed_string_t sa; 13310 cmdline_fixed_string_t tx_rx; 13311 portid_t port_id; 13312 uint8_t idx; 13313 uint8_t an; 13314 uint32_t pn; 13315 cmdline_fixed_string_t key; 13316 }; 13317 13318 /* Common CLI fields for MACsec secure connection configure */ 13319 cmdline_parse_token_string_t cmd_macsec_sa_set = 13320 TOKEN_STRING_INITIALIZER 13321 (struct cmd_macsec_sa_result, 13322 set, "set"); 13323 cmdline_parse_token_string_t cmd_macsec_sa_macsec = 13324 TOKEN_STRING_INITIALIZER 13325 (struct cmd_macsec_sa_result, 13326 macsec, "macsec"); 13327 cmdline_parse_token_string_t cmd_macsec_sa_sa = 13328 TOKEN_STRING_INITIALIZER 13329 (struct cmd_macsec_sa_result, 13330 sa, "sa"); 13331 cmdline_parse_token_string_t cmd_macsec_sa_tx_rx = 13332 TOKEN_STRING_INITIALIZER 13333 (struct cmd_macsec_sa_result, 13334 tx_rx, "tx#rx"); 13335 cmdline_parse_token_num_t cmd_macsec_sa_port_id = 13336 TOKEN_NUM_INITIALIZER 13337 (struct cmd_macsec_sa_result, 13338 port_id, UINT16); 13339 cmdline_parse_token_num_t cmd_macsec_sa_idx = 13340 TOKEN_NUM_INITIALIZER 13341 (struct cmd_macsec_sa_result, 13342 idx, UINT8); 13343 cmdline_parse_token_num_t cmd_macsec_sa_an = 13344 TOKEN_NUM_INITIALIZER 13345 (struct cmd_macsec_sa_result, 13346 an, UINT8); 13347 cmdline_parse_token_num_t cmd_macsec_sa_pn = 13348 TOKEN_NUM_INITIALIZER 13349 (struct cmd_macsec_sa_result, 13350 pn, UINT32); 13351 cmdline_parse_token_string_t cmd_macsec_sa_key = 13352 TOKEN_STRING_INITIALIZER 13353 (struct cmd_macsec_sa_result, 13354 key, NULL); 13355 13356 static void 13357 cmd_set_macsec_sa_parsed( 13358 void *parsed_result, 13359 __attribute__((unused)) struct cmdline *cl, 13360 __attribute__((unused)) void *data) 13361 { 13362 struct cmd_macsec_sa_result *res = parsed_result; 13363 int ret = -ENOTSUP; 13364 int is_tx = (strcmp(res->tx_rx, "tx") == 0) ? 1 : 0; 13365 uint8_t key[16] = { 0 }; 13366 uint8_t xdgt0; 13367 uint8_t xdgt1; 13368 int key_len; 13369 int i; 13370 13371 key_len = strlen(res->key) / 2; 13372 if (key_len > 16) 13373 key_len = 16; 13374 13375 for (i = 0; i < key_len; i++) { 13376 xdgt0 = parse_and_check_key_hexa_digit(res->key, (i * 2)); 13377 if (xdgt0 == 0xFF) 13378 return; 13379 xdgt1 = parse_and_check_key_hexa_digit(res->key, (i * 2) + 1); 13380 if (xdgt1 == 0xFF) 13381 return; 13382 key[i] = (uint8_t) ((xdgt0 * 16) + xdgt1); 13383 } 13384 13385 #ifdef RTE_LIBRTE_IXGBE_PMD 13386 ret = is_tx ? 13387 rte_pmd_ixgbe_macsec_select_txsa(res->port_id, 13388 res->idx, res->an, res->pn, key) : 13389 rte_pmd_ixgbe_macsec_select_rxsa(res->port_id, 13390 res->idx, res->an, res->pn, key); 13391 #endif 13392 RTE_SET_USED(is_tx); 13393 RTE_SET_USED(key); 13394 13395 switch (ret) { 13396 case 0: 13397 break; 13398 case -EINVAL: 13399 printf("invalid idx %d or an %d\n", res->idx, res->an); 13400 break; 13401 case -ENODEV: 13402 printf("invalid port_id %d\n", res->port_id); 13403 break; 13404 case -ENOTSUP: 13405 printf("not supported on port %d\n", res->port_id); 13406 break; 13407 default: 13408 printf("programming error: (%s)\n", strerror(-ret)); 13409 } 13410 } 13411 13412 cmdline_parse_inst_t cmd_set_macsec_sa = { 13413 .f = cmd_set_macsec_sa_parsed, 13414 .data = NULL, 13415 .help_str = "set macsec sa tx|rx <port_id> <idx> <an> <pn> <key>", 13416 .tokens = { 13417 (void *)&cmd_macsec_sa_set, 13418 (void *)&cmd_macsec_sa_macsec, 13419 (void *)&cmd_macsec_sa_sa, 13420 (void *)&cmd_macsec_sa_tx_rx, 13421 (void *)&cmd_macsec_sa_port_id, 13422 (void *)&cmd_macsec_sa_idx, 13423 (void *)&cmd_macsec_sa_an, 13424 (void *)&cmd_macsec_sa_pn, 13425 (void *)&cmd_macsec_sa_key, 13426 NULL, 13427 }, 13428 }; 13429 13430 /* VF unicast promiscuous mode configuration */ 13431 13432 /* Common result structure for VF unicast promiscuous mode */ 13433 struct cmd_vf_promisc_result { 13434 cmdline_fixed_string_t set; 13435 cmdline_fixed_string_t vf; 13436 cmdline_fixed_string_t promisc; 13437 portid_t port_id; 13438 uint32_t vf_id; 13439 cmdline_fixed_string_t on_off; 13440 }; 13441 13442 /* Common CLI fields for VF unicast promiscuous mode enable disable */ 13443 cmdline_parse_token_string_t cmd_vf_promisc_set = 13444 TOKEN_STRING_INITIALIZER 13445 (struct cmd_vf_promisc_result, 13446 set, "set"); 13447 cmdline_parse_token_string_t cmd_vf_promisc_vf = 13448 TOKEN_STRING_INITIALIZER 13449 (struct cmd_vf_promisc_result, 13450 vf, "vf"); 13451 cmdline_parse_token_string_t cmd_vf_promisc_promisc = 13452 TOKEN_STRING_INITIALIZER 13453 (struct cmd_vf_promisc_result, 13454 promisc, "promisc"); 13455 cmdline_parse_token_num_t cmd_vf_promisc_port_id = 13456 TOKEN_NUM_INITIALIZER 13457 (struct cmd_vf_promisc_result, 13458 port_id, UINT16); 13459 cmdline_parse_token_num_t cmd_vf_promisc_vf_id = 13460 TOKEN_NUM_INITIALIZER 13461 (struct cmd_vf_promisc_result, 13462 vf_id, UINT32); 13463 cmdline_parse_token_string_t cmd_vf_promisc_on_off = 13464 TOKEN_STRING_INITIALIZER 13465 (struct cmd_vf_promisc_result, 13466 on_off, "on#off"); 13467 13468 static void 13469 cmd_set_vf_promisc_parsed( 13470 void *parsed_result, 13471 __attribute__((unused)) struct cmdline *cl, 13472 __attribute__((unused)) void *data) 13473 { 13474 struct cmd_vf_promisc_result *res = parsed_result; 13475 int ret = -ENOTSUP; 13476 13477 __rte_unused int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0; 13478 13479 if (port_id_is_invalid(res->port_id, ENABLED_WARN)) 13480 return; 13481 13482 #ifdef RTE_LIBRTE_I40E_PMD 13483 ret = rte_pmd_i40e_set_vf_unicast_promisc(res->port_id, 13484 res->vf_id, is_on); 13485 #endif 13486 13487 switch (ret) { 13488 case 0: 13489 break; 13490 case -EINVAL: 13491 printf("invalid vf_id %d\n", res->vf_id); 13492 break; 13493 case -ENODEV: 13494 printf("invalid port_id %d\n", res->port_id); 13495 break; 13496 case -ENOTSUP: 13497 printf("function not implemented\n"); 13498 break; 13499 default: 13500 printf("programming error: (%s)\n", strerror(-ret)); 13501 } 13502 } 13503 13504 cmdline_parse_inst_t cmd_set_vf_promisc = { 13505 .f = cmd_set_vf_promisc_parsed, 13506 .data = NULL, 13507 .help_str = "set vf promisc <port_id> <vf_id> on|off: " 13508 "Set unicast promiscuous mode for a VF from the PF", 13509 .tokens = { 13510 (void *)&cmd_vf_promisc_set, 13511 (void *)&cmd_vf_promisc_vf, 13512 (void *)&cmd_vf_promisc_promisc, 13513 (void *)&cmd_vf_promisc_port_id, 13514 (void *)&cmd_vf_promisc_vf_id, 13515 (void *)&cmd_vf_promisc_on_off, 13516 NULL, 13517 }, 13518 }; 13519 13520 /* VF multicast promiscuous mode configuration */ 13521 13522 /* Common result structure for VF multicast promiscuous mode */ 13523 struct cmd_vf_allmulti_result { 13524 cmdline_fixed_string_t set; 13525 cmdline_fixed_string_t vf; 13526 cmdline_fixed_string_t allmulti; 13527 portid_t port_id; 13528 uint32_t vf_id; 13529 cmdline_fixed_string_t on_off; 13530 }; 13531 13532 /* Common CLI fields for VF multicast promiscuous mode enable disable */ 13533 cmdline_parse_token_string_t cmd_vf_allmulti_set = 13534 TOKEN_STRING_INITIALIZER 13535 (struct cmd_vf_allmulti_result, 13536 set, "set"); 13537 cmdline_parse_token_string_t cmd_vf_allmulti_vf = 13538 TOKEN_STRING_INITIALIZER 13539 (struct cmd_vf_allmulti_result, 13540 vf, "vf"); 13541 cmdline_parse_token_string_t cmd_vf_allmulti_allmulti = 13542 TOKEN_STRING_INITIALIZER 13543 (struct cmd_vf_allmulti_result, 13544 allmulti, "allmulti"); 13545 cmdline_parse_token_num_t cmd_vf_allmulti_port_id = 13546 TOKEN_NUM_INITIALIZER 13547 (struct cmd_vf_allmulti_result, 13548 port_id, UINT16); 13549 cmdline_parse_token_num_t cmd_vf_allmulti_vf_id = 13550 TOKEN_NUM_INITIALIZER 13551 (struct cmd_vf_allmulti_result, 13552 vf_id, UINT32); 13553 cmdline_parse_token_string_t cmd_vf_allmulti_on_off = 13554 TOKEN_STRING_INITIALIZER 13555 (struct cmd_vf_allmulti_result, 13556 on_off, "on#off"); 13557 13558 static void 13559 cmd_set_vf_allmulti_parsed( 13560 void *parsed_result, 13561 __attribute__((unused)) struct cmdline *cl, 13562 __attribute__((unused)) void *data) 13563 { 13564 struct cmd_vf_allmulti_result *res = parsed_result; 13565 int ret = -ENOTSUP; 13566 13567 __rte_unused int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0; 13568 13569 if (port_id_is_invalid(res->port_id, ENABLED_WARN)) 13570 return; 13571 13572 #ifdef RTE_LIBRTE_I40E_PMD 13573 ret = rte_pmd_i40e_set_vf_multicast_promisc(res->port_id, 13574 res->vf_id, is_on); 13575 #endif 13576 13577 switch (ret) { 13578 case 0: 13579 break; 13580 case -EINVAL: 13581 printf("invalid vf_id %d\n", res->vf_id); 13582 break; 13583 case -ENODEV: 13584 printf("invalid port_id %d\n", res->port_id); 13585 break; 13586 case -ENOTSUP: 13587 printf("function not implemented\n"); 13588 break; 13589 default: 13590 printf("programming error: (%s)\n", strerror(-ret)); 13591 } 13592 } 13593 13594 cmdline_parse_inst_t cmd_set_vf_allmulti = { 13595 .f = cmd_set_vf_allmulti_parsed, 13596 .data = NULL, 13597 .help_str = "set vf allmulti <port_id> <vf_id> on|off: " 13598 "Set multicast promiscuous mode for a VF from the PF", 13599 .tokens = { 13600 (void *)&cmd_vf_allmulti_set, 13601 (void *)&cmd_vf_allmulti_vf, 13602 (void *)&cmd_vf_allmulti_allmulti, 13603 (void *)&cmd_vf_allmulti_port_id, 13604 (void *)&cmd_vf_allmulti_vf_id, 13605 (void *)&cmd_vf_allmulti_on_off, 13606 NULL, 13607 }, 13608 }; 13609 13610 /* vf broadcast mode configuration */ 13611 13612 /* Common result structure for vf broadcast */ 13613 struct cmd_set_vf_broadcast_result { 13614 cmdline_fixed_string_t set; 13615 cmdline_fixed_string_t vf; 13616 cmdline_fixed_string_t broadcast; 13617 portid_t port_id; 13618 uint16_t vf_id; 13619 cmdline_fixed_string_t on_off; 13620 }; 13621 13622 /* Common CLI fields for vf broadcast enable disable */ 13623 cmdline_parse_token_string_t cmd_set_vf_broadcast_set = 13624 TOKEN_STRING_INITIALIZER 13625 (struct cmd_set_vf_broadcast_result, 13626 set, "set"); 13627 cmdline_parse_token_string_t cmd_set_vf_broadcast_vf = 13628 TOKEN_STRING_INITIALIZER 13629 (struct cmd_set_vf_broadcast_result, 13630 vf, "vf"); 13631 cmdline_parse_token_string_t cmd_set_vf_broadcast_broadcast = 13632 TOKEN_STRING_INITIALIZER 13633 (struct cmd_set_vf_broadcast_result, 13634 broadcast, "broadcast"); 13635 cmdline_parse_token_num_t cmd_set_vf_broadcast_port_id = 13636 TOKEN_NUM_INITIALIZER 13637 (struct cmd_set_vf_broadcast_result, 13638 port_id, UINT16); 13639 cmdline_parse_token_num_t cmd_set_vf_broadcast_vf_id = 13640 TOKEN_NUM_INITIALIZER 13641 (struct cmd_set_vf_broadcast_result, 13642 vf_id, UINT16); 13643 cmdline_parse_token_string_t cmd_set_vf_broadcast_on_off = 13644 TOKEN_STRING_INITIALIZER 13645 (struct cmd_set_vf_broadcast_result, 13646 on_off, "on#off"); 13647 13648 static void 13649 cmd_set_vf_broadcast_parsed( 13650 void *parsed_result, 13651 __attribute__((unused)) struct cmdline *cl, 13652 __attribute__((unused)) void *data) 13653 { 13654 struct cmd_set_vf_broadcast_result *res = parsed_result; 13655 int ret = -ENOTSUP; 13656 13657 __rte_unused int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0; 13658 13659 if (port_id_is_invalid(res->port_id, ENABLED_WARN)) 13660 return; 13661 13662 #ifdef RTE_LIBRTE_I40E_PMD 13663 ret = rte_pmd_i40e_set_vf_broadcast(res->port_id, 13664 res->vf_id, is_on); 13665 #endif 13666 13667 switch (ret) { 13668 case 0: 13669 break; 13670 case -EINVAL: 13671 printf("invalid vf_id %d or is_on %d\n", res->vf_id, is_on); 13672 break; 13673 case -ENODEV: 13674 printf("invalid port_id %d\n", res->port_id); 13675 break; 13676 case -ENOTSUP: 13677 printf("function not implemented\n"); 13678 break; 13679 default: 13680 printf("programming error: (%s)\n", strerror(-ret)); 13681 } 13682 } 13683 13684 cmdline_parse_inst_t cmd_set_vf_broadcast = { 13685 .f = cmd_set_vf_broadcast_parsed, 13686 .data = NULL, 13687 .help_str = "set vf broadcast <port_id> <vf_id> on|off", 13688 .tokens = { 13689 (void *)&cmd_set_vf_broadcast_set, 13690 (void *)&cmd_set_vf_broadcast_vf, 13691 (void *)&cmd_set_vf_broadcast_broadcast, 13692 (void *)&cmd_set_vf_broadcast_port_id, 13693 (void *)&cmd_set_vf_broadcast_vf_id, 13694 (void *)&cmd_set_vf_broadcast_on_off, 13695 NULL, 13696 }, 13697 }; 13698 13699 /* vf vlan tag configuration */ 13700 13701 /* Common result structure for vf vlan tag */ 13702 struct cmd_set_vf_vlan_tag_result { 13703 cmdline_fixed_string_t set; 13704 cmdline_fixed_string_t vf; 13705 cmdline_fixed_string_t vlan; 13706 cmdline_fixed_string_t tag; 13707 portid_t port_id; 13708 uint16_t vf_id; 13709 cmdline_fixed_string_t on_off; 13710 }; 13711 13712 /* Common CLI fields for vf vlan tag enable disable */ 13713 cmdline_parse_token_string_t cmd_set_vf_vlan_tag_set = 13714 TOKEN_STRING_INITIALIZER 13715 (struct cmd_set_vf_vlan_tag_result, 13716 set, "set"); 13717 cmdline_parse_token_string_t cmd_set_vf_vlan_tag_vf = 13718 TOKEN_STRING_INITIALIZER 13719 (struct cmd_set_vf_vlan_tag_result, 13720 vf, "vf"); 13721 cmdline_parse_token_string_t cmd_set_vf_vlan_tag_vlan = 13722 TOKEN_STRING_INITIALIZER 13723 (struct cmd_set_vf_vlan_tag_result, 13724 vlan, "vlan"); 13725 cmdline_parse_token_string_t cmd_set_vf_vlan_tag_tag = 13726 TOKEN_STRING_INITIALIZER 13727 (struct cmd_set_vf_vlan_tag_result, 13728 tag, "tag"); 13729 cmdline_parse_token_num_t cmd_set_vf_vlan_tag_port_id = 13730 TOKEN_NUM_INITIALIZER 13731 (struct cmd_set_vf_vlan_tag_result, 13732 port_id, UINT16); 13733 cmdline_parse_token_num_t cmd_set_vf_vlan_tag_vf_id = 13734 TOKEN_NUM_INITIALIZER 13735 (struct cmd_set_vf_vlan_tag_result, 13736 vf_id, UINT16); 13737 cmdline_parse_token_string_t cmd_set_vf_vlan_tag_on_off = 13738 TOKEN_STRING_INITIALIZER 13739 (struct cmd_set_vf_vlan_tag_result, 13740 on_off, "on#off"); 13741 13742 static void 13743 cmd_set_vf_vlan_tag_parsed( 13744 void *parsed_result, 13745 __attribute__((unused)) struct cmdline *cl, 13746 __attribute__((unused)) void *data) 13747 { 13748 struct cmd_set_vf_vlan_tag_result *res = parsed_result; 13749 int ret = -ENOTSUP; 13750 13751 __rte_unused int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0; 13752 13753 if (port_id_is_invalid(res->port_id, ENABLED_WARN)) 13754 return; 13755 13756 #ifdef RTE_LIBRTE_I40E_PMD 13757 ret = rte_pmd_i40e_set_vf_vlan_tag(res->port_id, 13758 res->vf_id, is_on); 13759 #endif 13760 13761 switch (ret) { 13762 case 0: 13763 break; 13764 case -EINVAL: 13765 printf("invalid vf_id %d or is_on %d\n", res->vf_id, is_on); 13766 break; 13767 case -ENODEV: 13768 printf("invalid port_id %d\n", res->port_id); 13769 break; 13770 case -ENOTSUP: 13771 printf("function not implemented\n"); 13772 break; 13773 default: 13774 printf("programming error: (%s)\n", strerror(-ret)); 13775 } 13776 } 13777 13778 cmdline_parse_inst_t cmd_set_vf_vlan_tag = { 13779 .f = cmd_set_vf_vlan_tag_parsed, 13780 .data = NULL, 13781 .help_str = "set vf vlan tag <port_id> <vf_id> on|off", 13782 .tokens = { 13783 (void *)&cmd_set_vf_vlan_tag_set, 13784 (void *)&cmd_set_vf_vlan_tag_vf, 13785 (void *)&cmd_set_vf_vlan_tag_vlan, 13786 (void *)&cmd_set_vf_vlan_tag_tag, 13787 (void *)&cmd_set_vf_vlan_tag_port_id, 13788 (void *)&cmd_set_vf_vlan_tag_vf_id, 13789 (void *)&cmd_set_vf_vlan_tag_on_off, 13790 NULL, 13791 }, 13792 }; 13793 13794 /* Common definition of VF and TC TX bandwidth configuration */ 13795 struct cmd_vf_tc_bw_result { 13796 cmdline_fixed_string_t set; 13797 cmdline_fixed_string_t vf; 13798 cmdline_fixed_string_t tc; 13799 cmdline_fixed_string_t tx; 13800 cmdline_fixed_string_t min_bw; 13801 cmdline_fixed_string_t max_bw; 13802 cmdline_fixed_string_t strict_link_prio; 13803 portid_t port_id; 13804 uint16_t vf_id; 13805 uint8_t tc_no; 13806 uint32_t bw; 13807 cmdline_fixed_string_t bw_list; 13808 uint8_t tc_map; 13809 }; 13810 13811 cmdline_parse_token_string_t cmd_vf_tc_bw_set = 13812 TOKEN_STRING_INITIALIZER 13813 (struct cmd_vf_tc_bw_result, 13814 set, "set"); 13815 cmdline_parse_token_string_t cmd_vf_tc_bw_vf = 13816 TOKEN_STRING_INITIALIZER 13817 (struct cmd_vf_tc_bw_result, 13818 vf, "vf"); 13819 cmdline_parse_token_string_t cmd_vf_tc_bw_tc = 13820 TOKEN_STRING_INITIALIZER 13821 (struct cmd_vf_tc_bw_result, 13822 tc, "tc"); 13823 cmdline_parse_token_string_t cmd_vf_tc_bw_tx = 13824 TOKEN_STRING_INITIALIZER 13825 (struct cmd_vf_tc_bw_result, 13826 tx, "tx"); 13827 cmdline_parse_token_string_t cmd_vf_tc_bw_strict_link_prio = 13828 TOKEN_STRING_INITIALIZER 13829 (struct cmd_vf_tc_bw_result, 13830 strict_link_prio, "strict-link-priority"); 13831 cmdline_parse_token_string_t cmd_vf_tc_bw_min_bw = 13832 TOKEN_STRING_INITIALIZER 13833 (struct cmd_vf_tc_bw_result, 13834 min_bw, "min-bandwidth"); 13835 cmdline_parse_token_string_t cmd_vf_tc_bw_max_bw = 13836 TOKEN_STRING_INITIALIZER 13837 (struct cmd_vf_tc_bw_result, 13838 max_bw, "max-bandwidth"); 13839 cmdline_parse_token_num_t cmd_vf_tc_bw_port_id = 13840 TOKEN_NUM_INITIALIZER 13841 (struct cmd_vf_tc_bw_result, 13842 port_id, UINT16); 13843 cmdline_parse_token_num_t cmd_vf_tc_bw_vf_id = 13844 TOKEN_NUM_INITIALIZER 13845 (struct cmd_vf_tc_bw_result, 13846 vf_id, UINT16); 13847 cmdline_parse_token_num_t cmd_vf_tc_bw_tc_no = 13848 TOKEN_NUM_INITIALIZER 13849 (struct cmd_vf_tc_bw_result, 13850 tc_no, UINT8); 13851 cmdline_parse_token_num_t cmd_vf_tc_bw_bw = 13852 TOKEN_NUM_INITIALIZER 13853 (struct cmd_vf_tc_bw_result, 13854 bw, UINT32); 13855 cmdline_parse_token_string_t cmd_vf_tc_bw_bw_list = 13856 TOKEN_STRING_INITIALIZER 13857 (struct cmd_vf_tc_bw_result, 13858 bw_list, NULL); 13859 cmdline_parse_token_num_t cmd_vf_tc_bw_tc_map = 13860 TOKEN_NUM_INITIALIZER 13861 (struct cmd_vf_tc_bw_result, 13862 tc_map, UINT8); 13863 13864 /* VF max bandwidth setting */ 13865 static void 13866 cmd_vf_max_bw_parsed( 13867 void *parsed_result, 13868 __attribute__((unused)) struct cmdline *cl, 13869 __attribute__((unused)) void *data) 13870 { 13871 struct cmd_vf_tc_bw_result *res = parsed_result; 13872 int ret = -ENOTSUP; 13873 13874 if (port_id_is_invalid(res->port_id, ENABLED_WARN)) 13875 return; 13876 13877 #ifdef RTE_LIBRTE_I40E_PMD 13878 ret = rte_pmd_i40e_set_vf_max_bw(res->port_id, 13879 res->vf_id, res->bw); 13880 #endif 13881 13882 switch (ret) { 13883 case 0: 13884 break; 13885 case -EINVAL: 13886 printf("invalid vf_id %d or bandwidth %d\n", 13887 res->vf_id, res->bw); 13888 break; 13889 case -ENODEV: 13890 printf("invalid port_id %d\n", res->port_id); 13891 break; 13892 case -ENOTSUP: 13893 printf("function not implemented\n"); 13894 break; 13895 default: 13896 printf("programming error: (%s)\n", strerror(-ret)); 13897 } 13898 } 13899 13900 cmdline_parse_inst_t cmd_vf_max_bw = { 13901 .f = cmd_vf_max_bw_parsed, 13902 .data = NULL, 13903 .help_str = "set vf tx max-bandwidth <port_id> <vf_id> <bandwidth>", 13904 .tokens = { 13905 (void *)&cmd_vf_tc_bw_set, 13906 (void *)&cmd_vf_tc_bw_vf, 13907 (void *)&cmd_vf_tc_bw_tx, 13908 (void *)&cmd_vf_tc_bw_max_bw, 13909 (void *)&cmd_vf_tc_bw_port_id, 13910 (void *)&cmd_vf_tc_bw_vf_id, 13911 (void *)&cmd_vf_tc_bw_bw, 13912 NULL, 13913 }, 13914 }; 13915 13916 static int 13917 vf_tc_min_bw_parse_bw_list(uint8_t *bw_list, 13918 uint8_t *tc_num, 13919 char *str) 13920 { 13921 uint32_t size; 13922 const char *p, *p0 = str; 13923 char s[256]; 13924 char *end; 13925 char *str_fld[16]; 13926 uint16_t i; 13927 int ret; 13928 13929 p = strchr(p0, '('); 13930 if (p == NULL) { 13931 printf("The bandwidth-list should be '(bw1, bw2, ...)'\n"); 13932 return -1; 13933 } 13934 p++; 13935 p0 = strchr(p, ')'); 13936 if (p0 == NULL) { 13937 printf("The bandwidth-list should be '(bw1, bw2, ...)'\n"); 13938 return -1; 13939 } 13940 size = p0 - p; 13941 if (size >= sizeof(s)) { 13942 printf("The string size exceeds the internal buffer size\n"); 13943 return -1; 13944 } 13945 snprintf(s, sizeof(s), "%.*s", size, p); 13946 ret = rte_strsplit(s, sizeof(s), str_fld, 16, ','); 13947 if (ret <= 0) { 13948 printf("Failed to get the bandwidth list. "); 13949 return -1; 13950 } 13951 *tc_num = ret; 13952 for (i = 0; i < ret; i++) 13953 bw_list[i] = (uint8_t)strtoul(str_fld[i], &end, 0); 13954 13955 return 0; 13956 } 13957 13958 /* TC min bandwidth setting */ 13959 static void 13960 cmd_vf_tc_min_bw_parsed( 13961 void *parsed_result, 13962 __attribute__((unused)) struct cmdline *cl, 13963 __attribute__((unused)) void *data) 13964 { 13965 struct cmd_vf_tc_bw_result *res = parsed_result; 13966 uint8_t tc_num; 13967 uint8_t bw[16]; 13968 int ret = -ENOTSUP; 13969 13970 if (port_id_is_invalid(res->port_id, ENABLED_WARN)) 13971 return; 13972 13973 ret = vf_tc_min_bw_parse_bw_list(bw, &tc_num, res->bw_list); 13974 if (ret) 13975 return; 13976 13977 #ifdef RTE_LIBRTE_I40E_PMD 13978 ret = rte_pmd_i40e_set_vf_tc_bw_alloc(res->port_id, res->vf_id, 13979 tc_num, bw); 13980 #endif 13981 13982 switch (ret) { 13983 case 0: 13984 break; 13985 case -EINVAL: 13986 printf("invalid vf_id %d or bandwidth\n", res->vf_id); 13987 break; 13988 case -ENODEV: 13989 printf("invalid port_id %d\n", res->port_id); 13990 break; 13991 case -ENOTSUP: 13992 printf("function not implemented\n"); 13993 break; 13994 default: 13995 printf("programming error: (%s)\n", strerror(-ret)); 13996 } 13997 } 13998 13999 cmdline_parse_inst_t cmd_vf_tc_min_bw = { 14000 .f = cmd_vf_tc_min_bw_parsed, 14001 .data = NULL, 14002 .help_str = "set vf tc tx min-bandwidth <port_id> <vf_id>" 14003 " <bw1, bw2, ...>", 14004 .tokens = { 14005 (void *)&cmd_vf_tc_bw_set, 14006 (void *)&cmd_vf_tc_bw_vf, 14007 (void *)&cmd_vf_tc_bw_tc, 14008 (void *)&cmd_vf_tc_bw_tx, 14009 (void *)&cmd_vf_tc_bw_min_bw, 14010 (void *)&cmd_vf_tc_bw_port_id, 14011 (void *)&cmd_vf_tc_bw_vf_id, 14012 (void *)&cmd_vf_tc_bw_bw_list, 14013 NULL, 14014 }, 14015 }; 14016 14017 static void 14018 cmd_tc_min_bw_parsed( 14019 void *parsed_result, 14020 __attribute__((unused)) struct cmdline *cl, 14021 __attribute__((unused)) void *data) 14022 { 14023 struct cmd_vf_tc_bw_result *res = parsed_result; 14024 struct rte_port *port; 14025 uint8_t tc_num; 14026 uint8_t bw[16]; 14027 int ret = -ENOTSUP; 14028 14029 if (port_id_is_invalid(res->port_id, ENABLED_WARN)) 14030 return; 14031 14032 port = &ports[res->port_id]; 14033 /** Check if the port is not started **/ 14034 if (port->port_status != RTE_PORT_STOPPED) { 14035 printf("Please stop port %d first\n", res->port_id); 14036 return; 14037 } 14038 14039 ret = vf_tc_min_bw_parse_bw_list(bw, &tc_num, res->bw_list); 14040 if (ret) 14041 return; 14042 14043 #ifdef RTE_LIBRTE_IXGBE_PMD 14044 ret = rte_pmd_ixgbe_set_tc_bw_alloc(res->port_id, tc_num, bw); 14045 #endif 14046 14047 switch (ret) { 14048 case 0: 14049 break; 14050 case -EINVAL: 14051 printf("invalid bandwidth\n"); 14052 break; 14053 case -ENODEV: 14054 printf("invalid port_id %d\n", res->port_id); 14055 break; 14056 case -ENOTSUP: 14057 printf("function not implemented\n"); 14058 break; 14059 default: 14060 printf("programming error: (%s)\n", strerror(-ret)); 14061 } 14062 } 14063 14064 cmdline_parse_inst_t cmd_tc_min_bw = { 14065 .f = cmd_tc_min_bw_parsed, 14066 .data = NULL, 14067 .help_str = "set tc tx min-bandwidth <port_id> <bw1, bw2, ...>", 14068 .tokens = { 14069 (void *)&cmd_vf_tc_bw_set, 14070 (void *)&cmd_vf_tc_bw_tc, 14071 (void *)&cmd_vf_tc_bw_tx, 14072 (void *)&cmd_vf_tc_bw_min_bw, 14073 (void *)&cmd_vf_tc_bw_port_id, 14074 (void *)&cmd_vf_tc_bw_bw_list, 14075 NULL, 14076 }, 14077 }; 14078 14079 /* TC max bandwidth setting */ 14080 static void 14081 cmd_vf_tc_max_bw_parsed( 14082 void *parsed_result, 14083 __attribute__((unused)) struct cmdline *cl, 14084 __attribute__((unused)) void *data) 14085 { 14086 struct cmd_vf_tc_bw_result *res = parsed_result; 14087 int ret = -ENOTSUP; 14088 14089 if (port_id_is_invalid(res->port_id, ENABLED_WARN)) 14090 return; 14091 14092 #ifdef RTE_LIBRTE_I40E_PMD 14093 ret = rte_pmd_i40e_set_vf_tc_max_bw(res->port_id, res->vf_id, 14094 res->tc_no, res->bw); 14095 #endif 14096 14097 switch (ret) { 14098 case 0: 14099 break; 14100 case -EINVAL: 14101 printf("invalid vf_id %d, tc_no %d or bandwidth %d\n", 14102 res->vf_id, res->tc_no, res->bw); 14103 break; 14104 case -ENODEV: 14105 printf("invalid port_id %d\n", res->port_id); 14106 break; 14107 case -ENOTSUP: 14108 printf("function not implemented\n"); 14109 break; 14110 default: 14111 printf("programming error: (%s)\n", strerror(-ret)); 14112 } 14113 } 14114 14115 cmdline_parse_inst_t cmd_vf_tc_max_bw = { 14116 .f = cmd_vf_tc_max_bw_parsed, 14117 .data = NULL, 14118 .help_str = "set vf tc tx max-bandwidth <port_id> <vf_id> <tc_no>" 14119 " <bandwidth>", 14120 .tokens = { 14121 (void *)&cmd_vf_tc_bw_set, 14122 (void *)&cmd_vf_tc_bw_vf, 14123 (void *)&cmd_vf_tc_bw_tc, 14124 (void *)&cmd_vf_tc_bw_tx, 14125 (void *)&cmd_vf_tc_bw_max_bw, 14126 (void *)&cmd_vf_tc_bw_port_id, 14127 (void *)&cmd_vf_tc_bw_vf_id, 14128 (void *)&cmd_vf_tc_bw_tc_no, 14129 (void *)&cmd_vf_tc_bw_bw, 14130 NULL, 14131 }, 14132 }; 14133 14134 14135 #if defined RTE_LIBRTE_PMD_SOFTNIC && defined RTE_LIBRTE_SCHED 14136 14137 /* *** Set Port default Traffic Management Hierarchy *** */ 14138 struct cmd_set_port_tm_hierarchy_default_result { 14139 cmdline_fixed_string_t set; 14140 cmdline_fixed_string_t port; 14141 cmdline_fixed_string_t tm; 14142 cmdline_fixed_string_t hierarchy; 14143 cmdline_fixed_string_t def; 14144 portid_t port_id; 14145 }; 14146 14147 cmdline_parse_token_string_t cmd_set_port_tm_hierarchy_default_set = 14148 TOKEN_STRING_INITIALIZER( 14149 struct cmd_set_port_tm_hierarchy_default_result, set, "set"); 14150 cmdline_parse_token_string_t cmd_set_port_tm_hierarchy_default_port = 14151 TOKEN_STRING_INITIALIZER( 14152 struct cmd_set_port_tm_hierarchy_default_result, port, "port"); 14153 cmdline_parse_token_string_t cmd_set_port_tm_hierarchy_default_tm = 14154 TOKEN_STRING_INITIALIZER( 14155 struct cmd_set_port_tm_hierarchy_default_result, tm, "tm"); 14156 cmdline_parse_token_string_t cmd_set_port_tm_hierarchy_default_hierarchy = 14157 TOKEN_STRING_INITIALIZER( 14158 struct cmd_set_port_tm_hierarchy_default_result, 14159 hierarchy, "hierarchy"); 14160 cmdline_parse_token_string_t cmd_set_port_tm_hierarchy_default_default = 14161 TOKEN_STRING_INITIALIZER( 14162 struct cmd_set_port_tm_hierarchy_default_result, 14163 def, "default"); 14164 cmdline_parse_token_num_t cmd_set_port_tm_hierarchy_default_port_id = 14165 TOKEN_NUM_INITIALIZER( 14166 struct cmd_set_port_tm_hierarchy_default_result, 14167 port_id, UINT16); 14168 14169 static void cmd_set_port_tm_hierarchy_default_parsed(void *parsed_result, 14170 __attribute__((unused)) struct cmdline *cl, 14171 __attribute__((unused)) void *data) 14172 { 14173 struct cmd_set_port_tm_hierarchy_default_result *res = parsed_result; 14174 struct rte_port *p; 14175 portid_t port_id = res->port_id; 14176 14177 if (port_id_is_invalid(port_id, ENABLED_WARN)) 14178 return; 14179 14180 p = &ports[port_id]; 14181 14182 /* Port tm flag */ 14183 if (p->softport.tm_flag == 0) { 14184 printf(" tm not enabled on port %u (error)\n", port_id); 14185 return; 14186 } 14187 14188 /* Forward mode: tm */ 14189 if (strcmp(cur_fwd_config.fwd_eng->fwd_mode_name, "tm")) { 14190 printf(" tm mode not enabled(error)\n"); 14191 return; 14192 } 14193 14194 /* Set the default tm hierarchy */ 14195 p->softport.tm.default_hierarchy_enable = 1; 14196 } 14197 14198 cmdline_parse_inst_t cmd_set_port_tm_hierarchy_default = { 14199 .f = cmd_set_port_tm_hierarchy_default_parsed, 14200 .data = NULL, 14201 .help_str = "set port tm hierarchy default <port_id>", 14202 .tokens = { 14203 (void *)&cmd_set_port_tm_hierarchy_default_set, 14204 (void *)&cmd_set_port_tm_hierarchy_default_port, 14205 (void *)&cmd_set_port_tm_hierarchy_default_tm, 14206 (void *)&cmd_set_port_tm_hierarchy_default_hierarchy, 14207 (void *)&cmd_set_port_tm_hierarchy_default_default, 14208 (void *)&cmd_set_port_tm_hierarchy_default_port_id, 14209 NULL, 14210 }, 14211 }; 14212 #endif 14213 14214 /* Strict link priority scheduling mode setting */ 14215 static void 14216 cmd_strict_link_prio_parsed( 14217 void *parsed_result, 14218 __attribute__((unused)) struct cmdline *cl, 14219 __attribute__((unused)) void *data) 14220 { 14221 struct cmd_vf_tc_bw_result *res = parsed_result; 14222 int ret = -ENOTSUP; 14223 14224 if (port_id_is_invalid(res->port_id, ENABLED_WARN)) 14225 return; 14226 14227 #ifdef RTE_LIBRTE_I40E_PMD 14228 ret = rte_pmd_i40e_set_tc_strict_prio(res->port_id, res->tc_map); 14229 #endif 14230 14231 switch (ret) { 14232 case 0: 14233 break; 14234 case -EINVAL: 14235 printf("invalid tc_bitmap 0x%x\n", res->tc_map); 14236 break; 14237 case -ENODEV: 14238 printf("invalid port_id %d\n", res->port_id); 14239 break; 14240 case -ENOTSUP: 14241 printf("function not implemented\n"); 14242 break; 14243 default: 14244 printf("programming error: (%s)\n", strerror(-ret)); 14245 } 14246 } 14247 14248 cmdline_parse_inst_t cmd_strict_link_prio = { 14249 .f = cmd_strict_link_prio_parsed, 14250 .data = NULL, 14251 .help_str = "set tx strict-link-priority <port_id> <tc_bitmap>", 14252 .tokens = { 14253 (void *)&cmd_vf_tc_bw_set, 14254 (void *)&cmd_vf_tc_bw_tx, 14255 (void *)&cmd_vf_tc_bw_strict_link_prio, 14256 (void *)&cmd_vf_tc_bw_port_id, 14257 (void *)&cmd_vf_tc_bw_tc_map, 14258 NULL, 14259 }, 14260 }; 14261 14262 /* Load dynamic device personalization*/ 14263 struct cmd_ddp_add_result { 14264 cmdline_fixed_string_t ddp; 14265 cmdline_fixed_string_t add; 14266 portid_t port_id; 14267 char filepath[]; 14268 }; 14269 14270 cmdline_parse_token_string_t cmd_ddp_add_ddp = 14271 TOKEN_STRING_INITIALIZER(struct cmd_ddp_add_result, ddp, "ddp"); 14272 cmdline_parse_token_string_t cmd_ddp_add_add = 14273 TOKEN_STRING_INITIALIZER(struct cmd_ddp_add_result, add, "add"); 14274 cmdline_parse_token_num_t cmd_ddp_add_port_id = 14275 TOKEN_NUM_INITIALIZER(struct cmd_ddp_add_result, port_id, UINT16); 14276 cmdline_parse_token_string_t cmd_ddp_add_filepath = 14277 TOKEN_STRING_INITIALIZER(struct cmd_ddp_add_result, filepath, NULL); 14278 14279 static void 14280 cmd_ddp_add_parsed( 14281 void *parsed_result, 14282 __attribute__((unused)) struct cmdline *cl, 14283 __attribute__((unused)) void *data) 14284 { 14285 struct cmd_ddp_add_result *res = parsed_result; 14286 uint8_t *buff; 14287 uint32_t size; 14288 char *filepath; 14289 char *file_fld[2]; 14290 int file_num; 14291 int ret = -ENOTSUP; 14292 14293 if (res->port_id > nb_ports) { 14294 printf("Invalid port, range is [0, %d]\n", nb_ports - 1); 14295 return; 14296 } 14297 14298 if (!all_ports_stopped()) { 14299 printf("Please stop all ports first\n"); 14300 return; 14301 } 14302 14303 filepath = strdup(res->filepath); 14304 if (filepath == NULL) { 14305 printf("Failed to allocate memory\n"); 14306 return; 14307 } 14308 file_num = rte_strsplit(filepath, strlen(filepath), file_fld, 2, ','); 14309 14310 buff = open_ddp_package_file(file_fld[0], &size); 14311 if (!buff) { 14312 free((void *)filepath); 14313 return; 14314 } 14315 14316 #ifdef RTE_LIBRTE_I40E_PMD 14317 if (ret == -ENOTSUP) 14318 ret = rte_pmd_i40e_process_ddp_package(res->port_id, 14319 buff, size, 14320 RTE_PMD_I40E_PKG_OP_WR_ADD); 14321 #endif 14322 14323 if (ret == -EEXIST) 14324 printf("Profile has already existed.\n"); 14325 else if (ret < 0) 14326 printf("Failed to load profile.\n"); 14327 else if (file_num == 2) 14328 save_ddp_package_file(file_fld[1], buff, size); 14329 14330 close_ddp_package_file(buff); 14331 free((void *)filepath); 14332 } 14333 14334 cmdline_parse_inst_t cmd_ddp_add = { 14335 .f = cmd_ddp_add_parsed, 14336 .data = NULL, 14337 .help_str = "ddp add <port_id> <profile_path[,output_path]>", 14338 .tokens = { 14339 (void *)&cmd_ddp_add_ddp, 14340 (void *)&cmd_ddp_add_add, 14341 (void *)&cmd_ddp_add_port_id, 14342 (void *)&cmd_ddp_add_filepath, 14343 NULL, 14344 }, 14345 }; 14346 14347 /* Delete dynamic device personalization*/ 14348 struct cmd_ddp_del_result { 14349 cmdline_fixed_string_t ddp; 14350 cmdline_fixed_string_t del; 14351 portid_t port_id; 14352 char filepath[]; 14353 }; 14354 14355 cmdline_parse_token_string_t cmd_ddp_del_ddp = 14356 TOKEN_STRING_INITIALIZER(struct cmd_ddp_del_result, ddp, "ddp"); 14357 cmdline_parse_token_string_t cmd_ddp_del_del = 14358 TOKEN_STRING_INITIALIZER(struct cmd_ddp_del_result, del, "del"); 14359 cmdline_parse_token_num_t cmd_ddp_del_port_id = 14360 TOKEN_NUM_INITIALIZER(struct cmd_ddp_del_result, port_id, UINT16); 14361 cmdline_parse_token_string_t cmd_ddp_del_filepath = 14362 TOKEN_STRING_INITIALIZER(struct cmd_ddp_del_result, filepath, NULL); 14363 14364 static void 14365 cmd_ddp_del_parsed( 14366 void *parsed_result, 14367 __attribute__((unused)) struct cmdline *cl, 14368 __attribute__((unused)) void *data) 14369 { 14370 struct cmd_ddp_del_result *res = parsed_result; 14371 uint8_t *buff; 14372 uint32_t size; 14373 int ret = -ENOTSUP; 14374 14375 if (res->port_id > nb_ports) { 14376 printf("Invalid port, range is [0, %d]\n", nb_ports - 1); 14377 return; 14378 } 14379 14380 if (!all_ports_stopped()) { 14381 printf("Please stop all ports first\n"); 14382 return; 14383 } 14384 14385 buff = open_ddp_package_file(res->filepath, &size); 14386 if (!buff) 14387 return; 14388 14389 #ifdef RTE_LIBRTE_I40E_PMD 14390 if (ret == -ENOTSUP) 14391 ret = rte_pmd_i40e_process_ddp_package(res->port_id, 14392 buff, size, 14393 RTE_PMD_I40E_PKG_OP_WR_DEL); 14394 #endif 14395 14396 if (ret == -EACCES) 14397 printf("Profile does not exist.\n"); 14398 else if (ret < 0) 14399 printf("Failed to delete profile.\n"); 14400 14401 close_ddp_package_file(buff); 14402 } 14403 14404 cmdline_parse_inst_t cmd_ddp_del = { 14405 .f = cmd_ddp_del_parsed, 14406 .data = NULL, 14407 .help_str = "ddp del <port_id> <profile_path>", 14408 .tokens = { 14409 (void *)&cmd_ddp_del_ddp, 14410 (void *)&cmd_ddp_del_del, 14411 (void *)&cmd_ddp_del_port_id, 14412 (void *)&cmd_ddp_del_filepath, 14413 NULL, 14414 }, 14415 }; 14416 14417 /* Get dynamic device personalization profile info */ 14418 struct cmd_ddp_info_result { 14419 cmdline_fixed_string_t ddp; 14420 cmdline_fixed_string_t get; 14421 cmdline_fixed_string_t info; 14422 char filepath[]; 14423 }; 14424 14425 cmdline_parse_token_string_t cmd_ddp_info_ddp = 14426 TOKEN_STRING_INITIALIZER(struct cmd_ddp_info_result, ddp, "ddp"); 14427 cmdline_parse_token_string_t cmd_ddp_info_get = 14428 TOKEN_STRING_INITIALIZER(struct cmd_ddp_info_result, get, "get"); 14429 cmdline_parse_token_string_t cmd_ddp_info_info = 14430 TOKEN_STRING_INITIALIZER(struct cmd_ddp_info_result, info, "info"); 14431 cmdline_parse_token_string_t cmd_ddp_info_filepath = 14432 TOKEN_STRING_INITIALIZER(struct cmd_ddp_info_result, filepath, NULL); 14433 14434 static void 14435 cmd_ddp_info_parsed( 14436 void *parsed_result, 14437 __attribute__((unused)) struct cmdline *cl, 14438 __attribute__((unused)) void *data) 14439 { 14440 struct cmd_ddp_info_result *res = parsed_result; 14441 uint8_t *pkg; 14442 uint32_t pkg_size; 14443 int ret = -ENOTSUP; 14444 #ifdef RTE_LIBRTE_I40E_PMD 14445 uint32_t i, j, n; 14446 uint8_t *buff; 14447 uint32_t buff_size = 0; 14448 struct rte_pmd_i40e_profile_info info; 14449 uint32_t dev_num = 0; 14450 struct rte_pmd_i40e_ddp_device_id *devs; 14451 uint32_t proto_num = 0; 14452 struct rte_pmd_i40e_proto_info *proto = NULL; 14453 uint32_t pctype_num = 0; 14454 struct rte_pmd_i40e_ptype_info *pctype; 14455 uint32_t ptype_num = 0; 14456 struct rte_pmd_i40e_ptype_info *ptype; 14457 uint8_t proto_id; 14458 14459 #endif 14460 14461 pkg = open_ddp_package_file(res->filepath, &pkg_size); 14462 if (!pkg) 14463 return; 14464 14465 #ifdef RTE_LIBRTE_I40E_PMD 14466 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size, 14467 (uint8_t *)&info, sizeof(info), 14468 RTE_PMD_I40E_PKG_INFO_GLOBAL_HEADER); 14469 if (!ret) { 14470 printf("Global Track id: 0x%x\n", info.track_id); 14471 printf("Global Version: %d.%d.%d.%d\n", 14472 info.version.major, 14473 info.version.minor, 14474 info.version.update, 14475 info.version.draft); 14476 printf("Global Package name: %s\n\n", info.name); 14477 } 14478 14479 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size, 14480 (uint8_t *)&info, sizeof(info), 14481 RTE_PMD_I40E_PKG_INFO_HEADER); 14482 if (!ret) { 14483 printf("i40e Profile Track id: 0x%x\n", info.track_id); 14484 printf("i40e Profile Version: %d.%d.%d.%d\n", 14485 info.version.major, 14486 info.version.minor, 14487 info.version.update, 14488 info.version.draft); 14489 printf("i40e Profile name: %s\n\n", info.name); 14490 } 14491 14492 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size, 14493 (uint8_t *)&buff_size, sizeof(buff_size), 14494 RTE_PMD_I40E_PKG_INFO_GLOBAL_NOTES_SIZE); 14495 if (!ret && buff_size) { 14496 buff = (uint8_t *)malloc(buff_size); 14497 if (buff) { 14498 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size, 14499 buff, buff_size, 14500 RTE_PMD_I40E_PKG_INFO_GLOBAL_NOTES); 14501 if (!ret) 14502 printf("Package Notes:\n%s\n\n", buff); 14503 free(buff); 14504 } 14505 } 14506 14507 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size, 14508 (uint8_t *)&dev_num, sizeof(dev_num), 14509 RTE_PMD_I40E_PKG_INFO_DEVID_NUM); 14510 if (!ret && dev_num) { 14511 buff_size = dev_num * sizeof(struct rte_pmd_i40e_ddp_device_id); 14512 devs = (struct rte_pmd_i40e_ddp_device_id *)malloc(buff_size); 14513 if (devs) { 14514 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size, 14515 (uint8_t *)devs, buff_size, 14516 RTE_PMD_I40E_PKG_INFO_DEVID_LIST); 14517 if (!ret) { 14518 printf("List of supported devices:\n"); 14519 for (i = 0; i < dev_num; i++) { 14520 printf(" %04X:%04X %04X:%04X\n", 14521 devs[i].vendor_dev_id >> 16, 14522 devs[i].vendor_dev_id & 0xFFFF, 14523 devs[i].sub_vendor_dev_id >> 16, 14524 devs[i].sub_vendor_dev_id & 0xFFFF); 14525 } 14526 printf("\n"); 14527 } 14528 free(devs); 14529 } 14530 } 14531 14532 /* get information about protocols and packet types */ 14533 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size, 14534 (uint8_t *)&proto_num, sizeof(proto_num), 14535 RTE_PMD_I40E_PKG_INFO_PROTOCOL_NUM); 14536 if (ret || !proto_num) 14537 goto no_print_return; 14538 14539 buff_size = proto_num * sizeof(struct rte_pmd_i40e_proto_info); 14540 proto = (struct rte_pmd_i40e_proto_info *)malloc(buff_size); 14541 if (!proto) 14542 goto no_print_return; 14543 14544 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size, (uint8_t *)proto, 14545 buff_size, 14546 RTE_PMD_I40E_PKG_INFO_PROTOCOL_LIST); 14547 if (!ret) { 14548 printf("List of used protocols:\n"); 14549 for (i = 0; i < proto_num; i++) 14550 printf(" %2u: %s\n", proto[i].proto_id, 14551 proto[i].name); 14552 printf("\n"); 14553 } 14554 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size, 14555 (uint8_t *)&pctype_num, sizeof(pctype_num), 14556 RTE_PMD_I40E_PKG_INFO_PCTYPE_NUM); 14557 if (ret || !pctype_num) 14558 goto no_print_pctypes; 14559 14560 buff_size = pctype_num * sizeof(struct rte_pmd_i40e_ptype_info); 14561 pctype = (struct rte_pmd_i40e_ptype_info *)malloc(buff_size); 14562 if (!pctype) 14563 goto no_print_pctypes; 14564 14565 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size, (uint8_t *)pctype, 14566 buff_size, 14567 RTE_PMD_I40E_PKG_INFO_PCTYPE_LIST); 14568 if (ret) { 14569 free(pctype); 14570 goto no_print_pctypes; 14571 } 14572 14573 printf("List of defined packet classification types:\n"); 14574 for (i = 0; i < pctype_num; i++) { 14575 printf(" %2u:", pctype[i].ptype_id); 14576 for (j = 0; j < RTE_PMD_I40E_PROTO_NUM; j++) { 14577 proto_id = pctype[i].protocols[j]; 14578 if (proto_id != RTE_PMD_I40E_PROTO_UNUSED) { 14579 for (n = 0; n < proto_num; n++) { 14580 if (proto[n].proto_id == proto_id) { 14581 printf(" %s", proto[n].name); 14582 break; 14583 } 14584 } 14585 } 14586 } 14587 printf("\n"); 14588 } 14589 printf("\n"); 14590 free(pctype); 14591 14592 no_print_pctypes: 14593 14594 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size, (uint8_t *)&ptype_num, 14595 sizeof(ptype_num), 14596 RTE_PMD_I40E_PKG_INFO_PTYPE_NUM); 14597 if (ret || !ptype_num) 14598 goto no_print_return; 14599 14600 buff_size = ptype_num * sizeof(struct rte_pmd_i40e_ptype_info); 14601 ptype = (struct rte_pmd_i40e_ptype_info *)malloc(buff_size); 14602 if (!ptype) 14603 goto no_print_return; 14604 14605 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size, (uint8_t *)ptype, 14606 buff_size, 14607 RTE_PMD_I40E_PKG_INFO_PTYPE_LIST); 14608 if (ret) { 14609 free(ptype); 14610 goto no_print_return; 14611 } 14612 printf("List of defined packet types:\n"); 14613 for (i = 0; i < ptype_num; i++) { 14614 printf(" %2u:", ptype[i].ptype_id); 14615 for (j = 0; j < RTE_PMD_I40E_PROTO_NUM; j++) { 14616 proto_id = ptype[i].protocols[j]; 14617 if (proto_id != RTE_PMD_I40E_PROTO_UNUSED) { 14618 for (n = 0; n < proto_num; n++) { 14619 if (proto[n].proto_id == proto_id) { 14620 printf(" %s", proto[n].name); 14621 break; 14622 } 14623 } 14624 } 14625 } 14626 printf("\n"); 14627 } 14628 free(ptype); 14629 printf("\n"); 14630 14631 ret = 0; 14632 no_print_return: 14633 if (proto) 14634 free(proto); 14635 #endif 14636 if (ret == -ENOTSUP) 14637 printf("Function not supported in PMD driver\n"); 14638 close_ddp_package_file(pkg); 14639 } 14640 14641 cmdline_parse_inst_t cmd_ddp_get_info = { 14642 .f = cmd_ddp_info_parsed, 14643 .data = NULL, 14644 .help_str = "ddp get info <profile_path>", 14645 .tokens = { 14646 (void *)&cmd_ddp_info_ddp, 14647 (void *)&cmd_ddp_info_get, 14648 (void *)&cmd_ddp_info_info, 14649 (void *)&cmd_ddp_info_filepath, 14650 NULL, 14651 }, 14652 }; 14653 14654 /* Get dynamic device personalization profile info list*/ 14655 #define PROFILE_INFO_SIZE 48 14656 #define MAX_PROFILE_NUM 16 14657 14658 struct cmd_ddp_get_list_result { 14659 cmdline_fixed_string_t ddp; 14660 cmdline_fixed_string_t get; 14661 cmdline_fixed_string_t list; 14662 portid_t port_id; 14663 }; 14664 14665 cmdline_parse_token_string_t cmd_ddp_get_list_ddp = 14666 TOKEN_STRING_INITIALIZER(struct cmd_ddp_get_list_result, ddp, "ddp"); 14667 cmdline_parse_token_string_t cmd_ddp_get_list_get = 14668 TOKEN_STRING_INITIALIZER(struct cmd_ddp_get_list_result, get, "get"); 14669 cmdline_parse_token_string_t cmd_ddp_get_list_list = 14670 TOKEN_STRING_INITIALIZER(struct cmd_ddp_get_list_result, list, "list"); 14671 cmdline_parse_token_num_t cmd_ddp_get_list_port_id = 14672 TOKEN_NUM_INITIALIZER(struct cmd_ddp_get_list_result, port_id, UINT16); 14673 14674 static void 14675 cmd_ddp_get_list_parsed( 14676 void *parsed_result, 14677 __attribute__((unused)) struct cmdline *cl, 14678 __attribute__((unused)) void *data) 14679 { 14680 struct cmd_ddp_get_list_result *res = parsed_result; 14681 #ifdef RTE_LIBRTE_I40E_PMD 14682 struct rte_pmd_i40e_profile_list *p_list; 14683 struct rte_pmd_i40e_profile_info *p_info; 14684 uint32_t p_num; 14685 uint32_t size; 14686 uint32_t i; 14687 #endif 14688 int ret = -ENOTSUP; 14689 14690 if (res->port_id > nb_ports) { 14691 printf("Invalid port, range is [0, %d]\n", nb_ports - 1); 14692 return; 14693 } 14694 14695 #ifdef RTE_LIBRTE_I40E_PMD 14696 size = PROFILE_INFO_SIZE * MAX_PROFILE_NUM + 4; 14697 p_list = (struct rte_pmd_i40e_profile_list *)malloc(size); 14698 if (!p_list) 14699 printf("%s: Failed to malloc buffer\n", __func__); 14700 14701 if (ret == -ENOTSUP) 14702 ret = rte_pmd_i40e_get_ddp_list(res->port_id, 14703 (uint8_t *)p_list, size); 14704 14705 if (!ret) { 14706 p_num = p_list->p_count; 14707 printf("Profile number is: %d\n\n", p_num); 14708 14709 for (i = 0; i < p_num; i++) { 14710 p_info = &p_list->p_info[i]; 14711 printf("Profile %d:\n", i); 14712 printf("Track id: 0x%x\n", p_info->track_id); 14713 printf("Version: %d.%d.%d.%d\n", 14714 p_info->version.major, 14715 p_info->version.minor, 14716 p_info->version.update, 14717 p_info->version.draft); 14718 printf("Profile name: %s\n\n", p_info->name); 14719 } 14720 } 14721 14722 free(p_list); 14723 #endif 14724 14725 if (ret < 0) 14726 printf("Failed to get ddp list\n"); 14727 } 14728 14729 cmdline_parse_inst_t cmd_ddp_get_list = { 14730 .f = cmd_ddp_get_list_parsed, 14731 .data = NULL, 14732 .help_str = "ddp get list <port_id>", 14733 .tokens = { 14734 (void *)&cmd_ddp_get_list_ddp, 14735 (void *)&cmd_ddp_get_list_get, 14736 (void *)&cmd_ddp_get_list_list, 14737 (void *)&cmd_ddp_get_list_port_id, 14738 NULL, 14739 }, 14740 }; 14741 14742 /* show vf stats */ 14743 14744 /* Common result structure for show vf stats */ 14745 struct cmd_show_vf_stats_result { 14746 cmdline_fixed_string_t show; 14747 cmdline_fixed_string_t vf; 14748 cmdline_fixed_string_t stats; 14749 portid_t port_id; 14750 uint16_t vf_id; 14751 }; 14752 14753 /* Common CLI fields show vf stats*/ 14754 cmdline_parse_token_string_t cmd_show_vf_stats_show = 14755 TOKEN_STRING_INITIALIZER 14756 (struct cmd_show_vf_stats_result, 14757 show, "show"); 14758 cmdline_parse_token_string_t cmd_show_vf_stats_vf = 14759 TOKEN_STRING_INITIALIZER 14760 (struct cmd_show_vf_stats_result, 14761 vf, "vf"); 14762 cmdline_parse_token_string_t cmd_show_vf_stats_stats = 14763 TOKEN_STRING_INITIALIZER 14764 (struct cmd_show_vf_stats_result, 14765 stats, "stats"); 14766 cmdline_parse_token_num_t cmd_show_vf_stats_port_id = 14767 TOKEN_NUM_INITIALIZER 14768 (struct cmd_show_vf_stats_result, 14769 port_id, UINT16); 14770 cmdline_parse_token_num_t cmd_show_vf_stats_vf_id = 14771 TOKEN_NUM_INITIALIZER 14772 (struct cmd_show_vf_stats_result, 14773 vf_id, UINT16); 14774 14775 static void 14776 cmd_show_vf_stats_parsed( 14777 void *parsed_result, 14778 __attribute__((unused)) struct cmdline *cl, 14779 __attribute__((unused)) void *data) 14780 { 14781 struct cmd_show_vf_stats_result *res = parsed_result; 14782 struct rte_eth_stats stats; 14783 int ret = -ENOTSUP; 14784 static const char *nic_stats_border = "########################"; 14785 14786 if (port_id_is_invalid(res->port_id, ENABLED_WARN)) 14787 return; 14788 14789 memset(&stats, 0, sizeof(stats)); 14790 14791 #ifdef RTE_LIBRTE_I40E_PMD 14792 if (ret == -ENOTSUP) 14793 ret = rte_pmd_i40e_get_vf_stats(res->port_id, 14794 res->vf_id, 14795 &stats); 14796 #endif 14797 #ifdef RTE_LIBRTE_BNXT_PMD 14798 if (ret == -ENOTSUP) 14799 ret = rte_pmd_bnxt_get_vf_stats(res->port_id, 14800 res->vf_id, 14801 &stats); 14802 #endif 14803 14804 switch (ret) { 14805 case 0: 14806 break; 14807 case -EINVAL: 14808 printf("invalid vf_id %d\n", res->vf_id); 14809 break; 14810 case -ENODEV: 14811 printf("invalid port_id %d\n", res->port_id); 14812 break; 14813 case -ENOTSUP: 14814 printf("function not implemented\n"); 14815 break; 14816 default: 14817 printf("programming error: (%s)\n", strerror(-ret)); 14818 } 14819 14820 printf("\n %s NIC statistics for port %-2d vf %-2d %s\n", 14821 nic_stats_border, res->port_id, res->vf_id, nic_stats_border); 14822 14823 printf(" RX-packets: %-10"PRIu64" RX-missed: %-10"PRIu64" RX-bytes: " 14824 "%-"PRIu64"\n", 14825 stats.ipackets, stats.imissed, stats.ibytes); 14826 printf(" RX-errors: %-"PRIu64"\n", stats.ierrors); 14827 printf(" RX-nombuf: %-10"PRIu64"\n", 14828 stats.rx_nombuf); 14829 printf(" TX-packets: %-10"PRIu64" TX-errors: %-10"PRIu64" TX-bytes: " 14830 "%-"PRIu64"\n", 14831 stats.opackets, stats.oerrors, stats.obytes); 14832 14833 printf(" %s############################%s\n", 14834 nic_stats_border, nic_stats_border); 14835 } 14836 14837 cmdline_parse_inst_t cmd_show_vf_stats = { 14838 .f = cmd_show_vf_stats_parsed, 14839 .data = NULL, 14840 .help_str = "show vf stats <port_id> <vf_id>", 14841 .tokens = { 14842 (void *)&cmd_show_vf_stats_show, 14843 (void *)&cmd_show_vf_stats_vf, 14844 (void *)&cmd_show_vf_stats_stats, 14845 (void *)&cmd_show_vf_stats_port_id, 14846 (void *)&cmd_show_vf_stats_vf_id, 14847 NULL, 14848 }, 14849 }; 14850 14851 /* clear vf stats */ 14852 14853 /* Common result structure for clear vf stats */ 14854 struct cmd_clear_vf_stats_result { 14855 cmdline_fixed_string_t clear; 14856 cmdline_fixed_string_t vf; 14857 cmdline_fixed_string_t stats; 14858 portid_t port_id; 14859 uint16_t vf_id; 14860 }; 14861 14862 /* Common CLI fields clear vf stats*/ 14863 cmdline_parse_token_string_t cmd_clear_vf_stats_clear = 14864 TOKEN_STRING_INITIALIZER 14865 (struct cmd_clear_vf_stats_result, 14866 clear, "clear"); 14867 cmdline_parse_token_string_t cmd_clear_vf_stats_vf = 14868 TOKEN_STRING_INITIALIZER 14869 (struct cmd_clear_vf_stats_result, 14870 vf, "vf"); 14871 cmdline_parse_token_string_t cmd_clear_vf_stats_stats = 14872 TOKEN_STRING_INITIALIZER 14873 (struct cmd_clear_vf_stats_result, 14874 stats, "stats"); 14875 cmdline_parse_token_num_t cmd_clear_vf_stats_port_id = 14876 TOKEN_NUM_INITIALIZER 14877 (struct cmd_clear_vf_stats_result, 14878 port_id, UINT16); 14879 cmdline_parse_token_num_t cmd_clear_vf_stats_vf_id = 14880 TOKEN_NUM_INITIALIZER 14881 (struct cmd_clear_vf_stats_result, 14882 vf_id, UINT16); 14883 14884 static void 14885 cmd_clear_vf_stats_parsed( 14886 void *parsed_result, 14887 __attribute__((unused)) struct cmdline *cl, 14888 __attribute__((unused)) void *data) 14889 { 14890 struct cmd_clear_vf_stats_result *res = parsed_result; 14891 int ret = -ENOTSUP; 14892 14893 if (port_id_is_invalid(res->port_id, ENABLED_WARN)) 14894 return; 14895 14896 #ifdef RTE_LIBRTE_I40E_PMD 14897 if (ret == -ENOTSUP) 14898 ret = rte_pmd_i40e_reset_vf_stats(res->port_id, 14899 res->vf_id); 14900 #endif 14901 #ifdef RTE_LIBRTE_BNXT_PMD 14902 if (ret == -ENOTSUP) 14903 ret = rte_pmd_bnxt_reset_vf_stats(res->port_id, 14904 res->vf_id); 14905 #endif 14906 14907 switch (ret) { 14908 case 0: 14909 break; 14910 case -EINVAL: 14911 printf("invalid vf_id %d\n", res->vf_id); 14912 break; 14913 case -ENODEV: 14914 printf("invalid port_id %d\n", res->port_id); 14915 break; 14916 case -ENOTSUP: 14917 printf("function not implemented\n"); 14918 break; 14919 default: 14920 printf("programming error: (%s)\n", strerror(-ret)); 14921 } 14922 } 14923 14924 cmdline_parse_inst_t cmd_clear_vf_stats = { 14925 .f = cmd_clear_vf_stats_parsed, 14926 .data = NULL, 14927 .help_str = "clear vf stats <port_id> <vf_id>", 14928 .tokens = { 14929 (void *)&cmd_clear_vf_stats_clear, 14930 (void *)&cmd_clear_vf_stats_vf, 14931 (void *)&cmd_clear_vf_stats_stats, 14932 (void *)&cmd_clear_vf_stats_port_id, 14933 (void *)&cmd_clear_vf_stats_vf_id, 14934 NULL, 14935 }, 14936 }; 14937 14938 /* port config pctype mapping reset */ 14939 14940 /* Common result structure for port config pctype mapping reset */ 14941 struct cmd_pctype_mapping_reset_result { 14942 cmdline_fixed_string_t port; 14943 cmdline_fixed_string_t config; 14944 portid_t port_id; 14945 cmdline_fixed_string_t pctype; 14946 cmdline_fixed_string_t mapping; 14947 cmdline_fixed_string_t reset; 14948 }; 14949 14950 /* Common CLI fields for port config pctype mapping reset*/ 14951 cmdline_parse_token_string_t cmd_pctype_mapping_reset_port = 14952 TOKEN_STRING_INITIALIZER 14953 (struct cmd_pctype_mapping_reset_result, 14954 port, "port"); 14955 cmdline_parse_token_string_t cmd_pctype_mapping_reset_config = 14956 TOKEN_STRING_INITIALIZER 14957 (struct cmd_pctype_mapping_reset_result, 14958 config, "config"); 14959 cmdline_parse_token_num_t cmd_pctype_mapping_reset_port_id = 14960 TOKEN_NUM_INITIALIZER 14961 (struct cmd_pctype_mapping_reset_result, 14962 port_id, UINT16); 14963 cmdline_parse_token_string_t cmd_pctype_mapping_reset_pctype = 14964 TOKEN_STRING_INITIALIZER 14965 (struct cmd_pctype_mapping_reset_result, 14966 pctype, "pctype"); 14967 cmdline_parse_token_string_t cmd_pctype_mapping_reset_mapping = 14968 TOKEN_STRING_INITIALIZER 14969 (struct cmd_pctype_mapping_reset_result, 14970 mapping, "mapping"); 14971 cmdline_parse_token_string_t cmd_pctype_mapping_reset_reset = 14972 TOKEN_STRING_INITIALIZER 14973 (struct cmd_pctype_mapping_reset_result, 14974 reset, "reset"); 14975 14976 static void 14977 cmd_pctype_mapping_reset_parsed( 14978 void *parsed_result, 14979 __attribute__((unused)) struct cmdline *cl, 14980 __attribute__((unused)) void *data) 14981 { 14982 struct cmd_pctype_mapping_reset_result *res = parsed_result; 14983 int ret = -ENOTSUP; 14984 14985 if (port_id_is_invalid(res->port_id, ENABLED_WARN)) 14986 return; 14987 14988 #ifdef RTE_LIBRTE_I40E_PMD 14989 ret = rte_pmd_i40e_flow_type_mapping_reset(res->port_id); 14990 #endif 14991 14992 switch (ret) { 14993 case 0: 14994 break; 14995 case -ENODEV: 14996 printf("invalid port_id %d\n", res->port_id); 14997 break; 14998 case -ENOTSUP: 14999 printf("function not implemented\n"); 15000 break; 15001 default: 15002 printf("programming error: (%s)\n", strerror(-ret)); 15003 } 15004 } 15005 15006 cmdline_parse_inst_t cmd_pctype_mapping_reset = { 15007 .f = cmd_pctype_mapping_reset_parsed, 15008 .data = NULL, 15009 .help_str = "port config <port_id> pctype mapping reset", 15010 .tokens = { 15011 (void *)&cmd_pctype_mapping_reset_port, 15012 (void *)&cmd_pctype_mapping_reset_config, 15013 (void *)&cmd_pctype_mapping_reset_port_id, 15014 (void *)&cmd_pctype_mapping_reset_pctype, 15015 (void *)&cmd_pctype_mapping_reset_mapping, 15016 (void *)&cmd_pctype_mapping_reset_reset, 15017 NULL, 15018 }, 15019 }; 15020 15021 /* show port pctype mapping */ 15022 15023 /* Common result structure for show port pctype mapping */ 15024 struct cmd_pctype_mapping_get_result { 15025 cmdline_fixed_string_t show; 15026 cmdline_fixed_string_t port; 15027 portid_t port_id; 15028 cmdline_fixed_string_t pctype; 15029 cmdline_fixed_string_t mapping; 15030 }; 15031 15032 /* Common CLI fields for pctype mapping get */ 15033 cmdline_parse_token_string_t cmd_pctype_mapping_get_show = 15034 TOKEN_STRING_INITIALIZER 15035 (struct cmd_pctype_mapping_get_result, 15036 show, "show"); 15037 cmdline_parse_token_string_t cmd_pctype_mapping_get_port = 15038 TOKEN_STRING_INITIALIZER 15039 (struct cmd_pctype_mapping_get_result, 15040 port, "port"); 15041 cmdline_parse_token_num_t cmd_pctype_mapping_get_port_id = 15042 TOKEN_NUM_INITIALIZER 15043 (struct cmd_pctype_mapping_get_result, 15044 port_id, UINT16); 15045 cmdline_parse_token_string_t cmd_pctype_mapping_get_pctype = 15046 TOKEN_STRING_INITIALIZER 15047 (struct cmd_pctype_mapping_get_result, 15048 pctype, "pctype"); 15049 cmdline_parse_token_string_t cmd_pctype_mapping_get_mapping = 15050 TOKEN_STRING_INITIALIZER 15051 (struct cmd_pctype_mapping_get_result, 15052 mapping, "mapping"); 15053 15054 static void 15055 cmd_pctype_mapping_get_parsed( 15056 void *parsed_result, 15057 __attribute__((unused)) struct cmdline *cl, 15058 __attribute__((unused)) void *data) 15059 { 15060 struct cmd_pctype_mapping_get_result *res = parsed_result; 15061 int ret = -ENOTSUP; 15062 #ifdef RTE_LIBRTE_I40E_PMD 15063 struct rte_pmd_i40e_flow_type_mapping 15064 mapping[RTE_PMD_I40E_FLOW_TYPE_MAX]; 15065 int i, j, first_pctype; 15066 #endif 15067 15068 if (port_id_is_invalid(res->port_id, ENABLED_WARN)) 15069 return; 15070 15071 #ifdef RTE_LIBRTE_I40E_PMD 15072 ret = rte_pmd_i40e_flow_type_mapping_get(res->port_id, mapping); 15073 #endif 15074 15075 switch (ret) { 15076 case 0: 15077 break; 15078 case -ENODEV: 15079 printf("invalid port_id %d\n", res->port_id); 15080 return; 15081 case -ENOTSUP: 15082 printf("function not implemented\n"); 15083 return; 15084 default: 15085 printf("programming error: (%s)\n", strerror(-ret)); 15086 return; 15087 } 15088 15089 #ifdef RTE_LIBRTE_I40E_PMD 15090 for (i = 0; i < RTE_PMD_I40E_FLOW_TYPE_MAX; i++) { 15091 if (mapping[i].pctype != 0ULL) { 15092 first_pctype = 1; 15093 15094 printf("pctype: "); 15095 for (j = 0; j < RTE_PMD_I40E_PCTYPE_MAX; j++) { 15096 if (mapping[i].pctype & (1ULL << j)) { 15097 printf(first_pctype ? 15098 "%02d" : ",%02d", j); 15099 first_pctype = 0; 15100 } 15101 } 15102 printf(" -> flowtype: %02d\n", mapping[i].flow_type); 15103 } 15104 } 15105 #endif 15106 } 15107 15108 cmdline_parse_inst_t cmd_pctype_mapping_get = { 15109 .f = cmd_pctype_mapping_get_parsed, 15110 .data = NULL, 15111 .help_str = "show port <port_id> pctype mapping", 15112 .tokens = { 15113 (void *)&cmd_pctype_mapping_get_show, 15114 (void *)&cmd_pctype_mapping_get_port, 15115 (void *)&cmd_pctype_mapping_get_port_id, 15116 (void *)&cmd_pctype_mapping_get_pctype, 15117 (void *)&cmd_pctype_mapping_get_mapping, 15118 NULL, 15119 }, 15120 }; 15121 15122 /* port config pctype mapping update */ 15123 15124 /* Common result structure for port config pctype mapping update */ 15125 struct cmd_pctype_mapping_update_result { 15126 cmdline_fixed_string_t port; 15127 cmdline_fixed_string_t config; 15128 portid_t port_id; 15129 cmdline_fixed_string_t pctype; 15130 cmdline_fixed_string_t mapping; 15131 cmdline_fixed_string_t update; 15132 cmdline_fixed_string_t pctype_list; 15133 uint16_t flow_type; 15134 }; 15135 15136 /* Common CLI fields for pctype mapping update*/ 15137 cmdline_parse_token_string_t cmd_pctype_mapping_update_port = 15138 TOKEN_STRING_INITIALIZER 15139 (struct cmd_pctype_mapping_update_result, 15140 port, "port"); 15141 cmdline_parse_token_string_t cmd_pctype_mapping_update_config = 15142 TOKEN_STRING_INITIALIZER 15143 (struct cmd_pctype_mapping_update_result, 15144 config, "config"); 15145 cmdline_parse_token_num_t cmd_pctype_mapping_update_port_id = 15146 TOKEN_NUM_INITIALIZER 15147 (struct cmd_pctype_mapping_update_result, 15148 port_id, UINT16); 15149 cmdline_parse_token_string_t cmd_pctype_mapping_update_pctype = 15150 TOKEN_STRING_INITIALIZER 15151 (struct cmd_pctype_mapping_update_result, 15152 pctype, "pctype"); 15153 cmdline_parse_token_string_t cmd_pctype_mapping_update_mapping = 15154 TOKEN_STRING_INITIALIZER 15155 (struct cmd_pctype_mapping_update_result, 15156 mapping, "mapping"); 15157 cmdline_parse_token_string_t cmd_pctype_mapping_update_update = 15158 TOKEN_STRING_INITIALIZER 15159 (struct cmd_pctype_mapping_update_result, 15160 update, "update"); 15161 cmdline_parse_token_string_t cmd_pctype_mapping_update_pc_type = 15162 TOKEN_STRING_INITIALIZER 15163 (struct cmd_pctype_mapping_update_result, 15164 pctype_list, NULL); 15165 cmdline_parse_token_num_t cmd_pctype_mapping_update_flow_type = 15166 TOKEN_NUM_INITIALIZER 15167 (struct cmd_pctype_mapping_update_result, 15168 flow_type, UINT16); 15169 15170 static void 15171 cmd_pctype_mapping_update_parsed( 15172 void *parsed_result, 15173 __attribute__((unused)) struct cmdline *cl, 15174 __attribute__((unused)) void *data) 15175 { 15176 struct cmd_pctype_mapping_update_result *res = parsed_result; 15177 int ret = -ENOTSUP; 15178 #ifdef RTE_LIBRTE_I40E_PMD 15179 struct rte_pmd_i40e_flow_type_mapping mapping; 15180 unsigned int i; 15181 unsigned int nb_item; 15182 unsigned int pctype_list[RTE_PMD_I40E_PCTYPE_MAX]; 15183 #endif 15184 15185 if (port_id_is_invalid(res->port_id, ENABLED_WARN)) 15186 return; 15187 15188 #ifdef RTE_LIBRTE_I40E_PMD 15189 nb_item = parse_item_list(res->pctype_list, "pctypes", 15190 RTE_PMD_I40E_PCTYPE_MAX, pctype_list, 1); 15191 mapping.flow_type = res->flow_type; 15192 for (i = 0, mapping.pctype = 0ULL; i < nb_item; i++) 15193 mapping.pctype |= (1ULL << pctype_list[i]); 15194 ret = rte_pmd_i40e_flow_type_mapping_update(res->port_id, 15195 &mapping, 15196 1, 15197 0); 15198 #endif 15199 15200 switch (ret) { 15201 case 0: 15202 break; 15203 case -EINVAL: 15204 printf("invalid pctype or flow type\n"); 15205 break; 15206 case -ENODEV: 15207 printf("invalid port_id %d\n", res->port_id); 15208 break; 15209 case -ENOTSUP: 15210 printf("function not implemented\n"); 15211 break; 15212 default: 15213 printf("programming error: (%s)\n", strerror(-ret)); 15214 } 15215 } 15216 15217 cmdline_parse_inst_t cmd_pctype_mapping_update = { 15218 .f = cmd_pctype_mapping_update_parsed, 15219 .data = NULL, 15220 .help_str = "port config <port_id> pctype mapping update" 15221 " <pctype_id_0,[pctype_id_1]*> <flowtype_id>", 15222 .tokens = { 15223 (void *)&cmd_pctype_mapping_update_port, 15224 (void *)&cmd_pctype_mapping_update_config, 15225 (void *)&cmd_pctype_mapping_update_port_id, 15226 (void *)&cmd_pctype_mapping_update_pctype, 15227 (void *)&cmd_pctype_mapping_update_mapping, 15228 (void *)&cmd_pctype_mapping_update_update, 15229 (void *)&cmd_pctype_mapping_update_pc_type, 15230 (void *)&cmd_pctype_mapping_update_flow_type, 15231 NULL, 15232 }, 15233 }; 15234 15235 /* ptype mapping get */ 15236 15237 /* Common result structure for ptype mapping get */ 15238 struct cmd_ptype_mapping_get_result { 15239 cmdline_fixed_string_t ptype; 15240 cmdline_fixed_string_t mapping; 15241 cmdline_fixed_string_t get; 15242 portid_t port_id; 15243 uint8_t valid_only; 15244 }; 15245 15246 /* Common CLI fields for ptype mapping get */ 15247 cmdline_parse_token_string_t cmd_ptype_mapping_get_ptype = 15248 TOKEN_STRING_INITIALIZER 15249 (struct cmd_ptype_mapping_get_result, 15250 ptype, "ptype"); 15251 cmdline_parse_token_string_t cmd_ptype_mapping_get_mapping = 15252 TOKEN_STRING_INITIALIZER 15253 (struct cmd_ptype_mapping_get_result, 15254 mapping, "mapping"); 15255 cmdline_parse_token_string_t cmd_ptype_mapping_get_get = 15256 TOKEN_STRING_INITIALIZER 15257 (struct cmd_ptype_mapping_get_result, 15258 get, "get"); 15259 cmdline_parse_token_num_t cmd_ptype_mapping_get_port_id = 15260 TOKEN_NUM_INITIALIZER 15261 (struct cmd_ptype_mapping_get_result, 15262 port_id, UINT16); 15263 cmdline_parse_token_num_t cmd_ptype_mapping_get_valid_only = 15264 TOKEN_NUM_INITIALIZER 15265 (struct cmd_ptype_mapping_get_result, 15266 valid_only, UINT8); 15267 15268 static void 15269 cmd_ptype_mapping_get_parsed( 15270 void *parsed_result, 15271 __attribute__((unused)) struct cmdline *cl, 15272 __attribute__((unused)) void *data) 15273 { 15274 struct cmd_ptype_mapping_get_result *res = parsed_result; 15275 int ret = -ENOTSUP; 15276 #ifdef RTE_LIBRTE_I40E_PMD 15277 int max_ptype_num = 256; 15278 struct rte_pmd_i40e_ptype_mapping mapping[max_ptype_num]; 15279 uint16_t count; 15280 int i; 15281 #endif 15282 15283 if (port_id_is_invalid(res->port_id, ENABLED_WARN)) 15284 return; 15285 15286 #ifdef RTE_LIBRTE_I40E_PMD 15287 ret = rte_pmd_i40e_ptype_mapping_get(res->port_id, 15288 mapping, 15289 max_ptype_num, 15290 &count, 15291 res->valid_only); 15292 #endif 15293 15294 switch (ret) { 15295 case 0: 15296 break; 15297 case -ENODEV: 15298 printf("invalid port_id %d\n", res->port_id); 15299 break; 15300 case -ENOTSUP: 15301 printf("function not implemented\n"); 15302 break; 15303 default: 15304 printf("programming error: (%s)\n", strerror(-ret)); 15305 } 15306 15307 #ifdef RTE_LIBRTE_I40E_PMD 15308 if (!ret) { 15309 for (i = 0; i < count; i++) 15310 printf("%3d\t0x%08x\n", 15311 mapping[i].hw_ptype, mapping[i].sw_ptype); 15312 } 15313 #endif 15314 } 15315 15316 cmdline_parse_inst_t cmd_ptype_mapping_get = { 15317 .f = cmd_ptype_mapping_get_parsed, 15318 .data = NULL, 15319 .help_str = "ptype mapping get <port_id> <valid_only>", 15320 .tokens = { 15321 (void *)&cmd_ptype_mapping_get_ptype, 15322 (void *)&cmd_ptype_mapping_get_mapping, 15323 (void *)&cmd_ptype_mapping_get_get, 15324 (void *)&cmd_ptype_mapping_get_port_id, 15325 (void *)&cmd_ptype_mapping_get_valid_only, 15326 NULL, 15327 }, 15328 }; 15329 15330 /* ptype mapping replace */ 15331 15332 /* Common result structure for ptype mapping replace */ 15333 struct cmd_ptype_mapping_replace_result { 15334 cmdline_fixed_string_t ptype; 15335 cmdline_fixed_string_t mapping; 15336 cmdline_fixed_string_t replace; 15337 portid_t port_id; 15338 uint32_t target; 15339 uint8_t mask; 15340 uint32_t pkt_type; 15341 }; 15342 15343 /* Common CLI fields for ptype mapping replace */ 15344 cmdline_parse_token_string_t cmd_ptype_mapping_replace_ptype = 15345 TOKEN_STRING_INITIALIZER 15346 (struct cmd_ptype_mapping_replace_result, 15347 ptype, "ptype"); 15348 cmdline_parse_token_string_t cmd_ptype_mapping_replace_mapping = 15349 TOKEN_STRING_INITIALIZER 15350 (struct cmd_ptype_mapping_replace_result, 15351 mapping, "mapping"); 15352 cmdline_parse_token_string_t cmd_ptype_mapping_replace_replace = 15353 TOKEN_STRING_INITIALIZER 15354 (struct cmd_ptype_mapping_replace_result, 15355 replace, "replace"); 15356 cmdline_parse_token_num_t cmd_ptype_mapping_replace_port_id = 15357 TOKEN_NUM_INITIALIZER 15358 (struct cmd_ptype_mapping_replace_result, 15359 port_id, UINT16); 15360 cmdline_parse_token_num_t cmd_ptype_mapping_replace_target = 15361 TOKEN_NUM_INITIALIZER 15362 (struct cmd_ptype_mapping_replace_result, 15363 target, UINT32); 15364 cmdline_parse_token_num_t cmd_ptype_mapping_replace_mask = 15365 TOKEN_NUM_INITIALIZER 15366 (struct cmd_ptype_mapping_replace_result, 15367 mask, UINT8); 15368 cmdline_parse_token_num_t cmd_ptype_mapping_replace_pkt_type = 15369 TOKEN_NUM_INITIALIZER 15370 (struct cmd_ptype_mapping_replace_result, 15371 pkt_type, UINT32); 15372 15373 static void 15374 cmd_ptype_mapping_replace_parsed( 15375 void *parsed_result, 15376 __attribute__((unused)) struct cmdline *cl, 15377 __attribute__((unused)) void *data) 15378 { 15379 struct cmd_ptype_mapping_replace_result *res = parsed_result; 15380 int ret = -ENOTSUP; 15381 15382 if (port_id_is_invalid(res->port_id, ENABLED_WARN)) 15383 return; 15384 15385 #ifdef RTE_LIBRTE_I40E_PMD 15386 ret = rte_pmd_i40e_ptype_mapping_replace(res->port_id, 15387 res->target, 15388 res->mask, 15389 res->pkt_type); 15390 #endif 15391 15392 switch (ret) { 15393 case 0: 15394 break; 15395 case -EINVAL: 15396 printf("invalid ptype 0x%8x or 0x%8x\n", 15397 res->target, res->pkt_type); 15398 break; 15399 case -ENODEV: 15400 printf("invalid port_id %d\n", res->port_id); 15401 break; 15402 case -ENOTSUP: 15403 printf("function not implemented\n"); 15404 break; 15405 default: 15406 printf("programming error: (%s)\n", strerror(-ret)); 15407 } 15408 } 15409 15410 cmdline_parse_inst_t cmd_ptype_mapping_replace = { 15411 .f = cmd_ptype_mapping_replace_parsed, 15412 .data = NULL, 15413 .help_str = 15414 "ptype mapping replace <port_id> <target> <mask> <pkt_type>", 15415 .tokens = { 15416 (void *)&cmd_ptype_mapping_replace_ptype, 15417 (void *)&cmd_ptype_mapping_replace_mapping, 15418 (void *)&cmd_ptype_mapping_replace_replace, 15419 (void *)&cmd_ptype_mapping_replace_port_id, 15420 (void *)&cmd_ptype_mapping_replace_target, 15421 (void *)&cmd_ptype_mapping_replace_mask, 15422 (void *)&cmd_ptype_mapping_replace_pkt_type, 15423 NULL, 15424 }, 15425 }; 15426 15427 /* ptype mapping reset */ 15428 15429 /* Common result structure for ptype mapping reset */ 15430 struct cmd_ptype_mapping_reset_result { 15431 cmdline_fixed_string_t ptype; 15432 cmdline_fixed_string_t mapping; 15433 cmdline_fixed_string_t reset; 15434 portid_t port_id; 15435 }; 15436 15437 /* Common CLI fields for ptype mapping reset*/ 15438 cmdline_parse_token_string_t cmd_ptype_mapping_reset_ptype = 15439 TOKEN_STRING_INITIALIZER 15440 (struct cmd_ptype_mapping_reset_result, 15441 ptype, "ptype"); 15442 cmdline_parse_token_string_t cmd_ptype_mapping_reset_mapping = 15443 TOKEN_STRING_INITIALIZER 15444 (struct cmd_ptype_mapping_reset_result, 15445 mapping, "mapping"); 15446 cmdline_parse_token_string_t cmd_ptype_mapping_reset_reset = 15447 TOKEN_STRING_INITIALIZER 15448 (struct cmd_ptype_mapping_reset_result, 15449 reset, "reset"); 15450 cmdline_parse_token_num_t cmd_ptype_mapping_reset_port_id = 15451 TOKEN_NUM_INITIALIZER 15452 (struct cmd_ptype_mapping_reset_result, 15453 port_id, UINT16); 15454 15455 static void 15456 cmd_ptype_mapping_reset_parsed( 15457 void *parsed_result, 15458 __attribute__((unused)) struct cmdline *cl, 15459 __attribute__((unused)) void *data) 15460 { 15461 struct cmd_ptype_mapping_reset_result *res = parsed_result; 15462 int ret = -ENOTSUP; 15463 15464 if (port_id_is_invalid(res->port_id, ENABLED_WARN)) 15465 return; 15466 15467 #ifdef RTE_LIBRTE_I40E_PMD 15468 ret = rte_pmd_i40e_ptype_mapping_reset(res->port_id); 15469 #endif 15470 15471 switch (ret) { 15472 case 0: 15473 break; 15474 case -ENODEV: 15475 printf("invalid port_id %d\n", res->port_id); 15476 break; 15477 case -ENOTSUP: 15478 printf("function not implemented\n"); 15479 break; 15480 default: 15481 printf("programming error: (%s)\n", strerror(-ret)); 15482 } 15483 } 15484 15485 cmdline_parse_inst_t cmd_ptype_mapping_reset = { 15486 .f = cmd_ptype_mapping_reset_parsed, 15487 .data = NULL, 15488 .help_str = "ptype mapping reset <port_id>", 15489 .tokens = { 15490 (void *)&cmd_ptype_mapping_reset_ptype, 15491 (void *)&cmd_ptype_mapping_reset_mapping, 15492 (void *)&cmd_ptype_mapping_reset_reset, 15493 (void *)&cmd_ptype_mapping_reset_port_id, 15494 NULL, 15495 }, 15496 }; 15497 15498 /* ptype mapping update */ 15499 15500 /* Common result structure for ptype mapping update */ 15501 struct cmd_ptype_mapping_update_result { 15502 cmdline_fixed_string_t ptype; 15503 cmdline_fixed_string_t mapping; 15504 cmdline_fixed_string_t reset; 15505 portid_t port_id; 15506 uint8_t hw_ptype; 15507 uint32_t sw_ptype; 15508 }; 15509 15510 /* Common CLI fields for ptype mapping update*/ 15511 cmdline_parse_token_string_t cmd_ptype_mapping_update_ptype = 15512 TOKEN_STRING_INITIALIZER 15513 (struct cmd_ptype_mapping_update_result, 15514 ptype, "ptype"); 15515 cmdline_parse_token_string_t cmd_ptype_mapping_update_mapping = 15516 TOKEN_STRING_INITIALIZER 15517 (struct cmd_ptype_mapping_update_result, 15518 mapping, "mapping"); 15519 cmdline_parse_token_string_t cmd_ptype_mapping_update_update = 15520 TOKEN_STRING_INITIALIZER 15521 (struct cmd_ptype_mapping_update_result, 15522 reset, "update"); 15523 cmdline_parse_token_num_t cmd_ptype_mapping_update_port_id = 15524 TOKEN_NUM_INITIALIZER 15525 (struct cmd_ptype_mapping_update_result, 15526 port_id, UINT16); 15527 cmdline_parse_token_num_t cmd_ptype_mapping_update_hw_ptype = 15528 TOKEN_NUM_INITIALIZER 15529 (struct cmd_ptype_mapping_update_result, 15530 hw_ptype, UINT8); 15531 cmdline_parse_token_num_t cmd_ptype_mapping_update_sw_ptype = 15532 TOKEN_NUM_INITIALIZER 15533 (struct cmd_ptype_mapping_update_result, 15534 sw_ptype, UINT32); 15535 15536 static void 15537 cmd_ptype_mapping_update_parsed( 15538 void *parsed_result, 15539 __attribute__((unused)) struct cmdline *cl, 15540 __attribute__((unused)) void *data) 15541 { 15542 struct cmd_ptype_mapping_update_result *res = parsed_result; 15543 int ret = -ENOTSUP; 15544 #ifdef RTE_LIBRTE_I40E_PMD 15545 struct rte_pmd_i40e_ptype_mapping mapping; 15546 #endif 15547 if (port_id_is_invalid(res->port_id, ENABLED_WARN)) 15548 return; 15549 15550 #ifdef RTE_LIBRTE_I40E_PMD 15551 mapping.hw_ptype = res->hw_ptype; 15552 mapping.sw_ptype = res->sw_ptype; 15553 ret = rte_pmd_i40e_ptype_mapping_update(res->port_id, 15554 &mapping, 15555 1, 15556 0); 15557 #endif 15558 15559 switch (ret) { 15560 case 0: 15561 break; 15562 case -EINVAL: 15563 printf("invalid ptype 0x%8x\n", res->sw_ptype); 15564 break; 15565 case -ENODEV: 15566 printf("invalid port_id %d\n", res->port_id); 15567 break; 15568 case -ENOTSUP: 15569 printf("function not implemented\n"); 15570 break; 15571 default: 15572 printf("programming error: (%s)\n", strerror(-ret)); 15573 } 15574 } 15575 15576 cmdline_parse_inst_t cmd_ptype_mapping_update = { 15577 .f = cmd_ptype_mapping_update_parsed, 15578 .data = NULL, 15579 .help_str = "ptype mapping update <port_id> <hw_ptype> <sw_ptype>", 15580 .tokens = { 15581 (void *)&cmd_ptype_mapping_update_ptype, 15582 (void *)&cmd_ptype_mapping_update_mapping, 15583 (void *)&cmd_ptype_mapping_update_update, 15584 (void *)&cmd_ptype_mapping_update_port_id, 15585 (void *)&cmd_ptype_mapping_update_hw_ptype, 15586 (void *)&cmd_ptype_mapping_update_sw_ptype, 15587 NULL, 15588 }, 15589 }; 15590 15591 /* Common result structure for file commands */ 15592 struct cmd_cmdfile_result { 15593 cmdline_fixed_string_t load; 15594 cmdline_fixed_string_t filename; 15595 }; 15596 15597 /* Common CLI fields for file commands */ 15598 cmdline_parse_token_string_t cmd_load_cmdfile = 15599 TOKEN_STRING_INITIALIZER(struct cmd_cmdfile_result, load, "load"); 15600 cmdline_parse_token_string_t cmd_load_cmdfile_filename = 15601 TOKEN_STRING_INITIALIZER(struct cmd_cmdfile_result, filename, NULL); 15602 15603 static void 15604 cmd_load_from_file_parsed( 15605 void *parsed_result, 15606 __attribute__((unused)) struct cmdline *cl, 15607 __attribute__((unused)) void *data) 15608 { 15609 struct cmd_cmdfile_result *res = parsed_result; 15610 15611 cmdline_read_from_file(res->filename); 15612 } 15613 15614 cmdline_parse_inst_t cmd_load_from_file = { 15615 .f = cmd_load_from_file_parsed, 15616 .data = NULL, 15617 .help_str = "load <filename>", 15618 .tokens = { 15619 (void *)&cmd_load_cmdfile, 15620 (void *)&cmd_load_cmdfile_filename, 15621 NULL, 15622 }, 15623 }; 15624 15625 /* ******************************************************************************** */ 15626 15627 /* list of instructions */ 15628 cmdline_parse_ctx_t main_ctx[] = { 15629 (cmdline_parse_inst_t *)&cmd_help_brief, 15630 (cmdline_parse_inst_t *)&cmd_help_long, 15631 (cmdline_parse_inst_t *)&cmd_quit, 15632 (cmdline_parse_inst_t *)&cmd_load_from_file, 15633 (cmdline_parse_inst_t *)&cmd_showport, 15634 (cmdline_parse_inst_t *)&cmd_showqueue, 15635 (cmdline_parse_inst_t *)&cmd_showportall, 15636 (cmdline_parse_inst_t *)&cmd_showcfg, 15637 (cmdline_parse_inst_t *)&cmd_start, 15638 (cmdline_parse_inst_t *)&cmd_start_tx_first, 15639 (cmdline_parse_inst_t *)&cmd_start_tx_first_n, 15640 (cmdline_parse_inst_t *)&cmd_set_link_up, 15641 (cmdline_parse_inst_t *)&cmd_set_link_down, 15642 (cmdline_parse_inst_t *)&cmd_reset, 15643 (cmdline_parse_inst_t *)&cmd_set_numbers, 15644 (cmdline_parse_inst_t *)&cmd_set_txpkts, 15645 (cmdline_parse_inst_t *)&cmd_set_txsplit, 15646 (cmdline_parse_inst_t *)&cmd_set_fwd_list, 15647 (cmdline_parse_inst_t *)&cmd_set_fwd_mask, 15648 (cmdline_parse_inst_t *)&cmd_set_fwd_mode, 15649 (cmdline_parse_inst_t *)&cmd_set_fwd_retry_mode, 15650 (cmdline_parse_inst_t *)&cmd_set_burst_tx_retry, 15651 (cmdline_parse_inst_t *)&cmd_set_promisc_mode_one, 15652 (cmdline_parse_inst_t *)&cmd_set_promisc_mode_all, 15653 (cmdline_parse_inst_t *)&cmd_set_allmulti_mode_one, 15654 (cmdline_parse_inst_t *)&cmd_set_allmulti_mode_all, 15655 (cmdline_parse_inst_t *)&cmd_set_flush_rx, 15656 (cmdline_parse_inst_t *)&cmd_set_link_check, 15657 (cmdline_parse_inst_t *)&cmd_set_bypass_mode, 15658 (cmdline_parse_inst_t *)&cmd_set_bypass_event, 15659 (cmdline_parse_inst_t *)&cmd_set_bypass_timeout, 15660 (cmdline_parse_inst_t *)&cmd_show_bypass_config, 15661 #ifdef RTE_LIBRTE_PMD_BOND 15662 (cmdline_parse_inst_t *) &cmd_set_bonding_mode, 15663 (cmdline_parse_inst_t *) &cmd_show_bonding_config, 15664 (cmdline_parse_inst_t *) &cmd_set_bonding_primary, 15665 (cmdline_parse_inst_t *) &cmd_add_bonding_slave, 15666 (cmdline_parse_inst_t *) &cmd_remove_bonding_slave, 15667 (cmdline_parse_inst_t *) &cmd_create_bonded_device, 15668 (cmdline_parse_inst_t *) &cmd_set_bond_mac_addr, 15669 (cmdline_parse_inst_t *) &cmd_set_balance_xmit_policy, 15670 (cmdline_parse_inst_t *) &cmd_set_bond_mon_period, 15671 (cmdline_parse_inst_t *) &cmd_set_lacp_dedicated_queues, 15672 (cmdline_parse_inst_t *) &cmd_set_bonding_agg_mode_policy, 15673 #endif 15674 (cmdline_parse_inst_t *)&cmd_vlan_offload, 15675 (cmdline_parse_inst_t *)&cmd_vlan_tpid, 15676 (cmdline_parse_inst_t *)&cmd_rx_vlan_filter_all, 15677 (cmdline_parse_inst_t *)&cmd_rx_vlan_filter, 15678 (cmdline_parse_inst_t *)&cmd_tx_vlan_set, 15679 (cmdline_parse_inst_t *)&cmd_tx_vlan_set_qinq, 15680 (cmdline_parse_inst_t *)&cmd_tx_vlan_reset, 15681 (cmdline_parse_inst_t *)&cmd_tx_vlan_set_pvid, 15682 (cmdline_parse_inst_t *)&cmd_csum_set, 15683 (cmdline_parse_inst_t *)&cmd_csum_show, 15684 (cmdline_parse_inst_t *)&cmd_csum_tunnel, 15685 (cmdline_parse_inst_t *)&cmd_tso_set, 15686 (cmdline_parse_inst_t *)&cmd_tso_show, 15687 (cmdline_parse_inst_t *)&cmd_tunnel_tso_set, 15688 (cmdline_parse_inst_t *)&cmd_tunnel_tso_show, 15689 (cmdline_parse_inst_t *)&cmd_gro_enable, 15690 (cmdline_parse_inst_t *)&cmd_gro_flush, 15691 (cmdline_parse_inst_t *)&cmd_gro_show, 15692 (cmdline_parse_inst_t *)&cmd_gso_enable, 15693 (cmdline_parse_inst_t *)&cmd_gso_size, 15694 (cmdline_parse_inst_t *)&cmd_gso_show, 15695 (cmdline_parse_inst_t *)&cmd_link_flow_control_set, 15696 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_rx, 15697 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_tx, 15698 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_hw, 15699 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_lw, 15700 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_pt, 15701 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_xon, 15702 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_macfwd, 15703 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_autoneg, 15704 (cmdline_parse_inst_t *)&cmd_priority_flow_control_set, 15705 (cmdline_parse_inst_t *)&cmd_config_dcb, 15706 (cmdline_parse_inst_t *)&cmd_read_reg, 15707 (cmdline_parse_inst_t *)&cmd_read_reg_bit_field, 15708 (cmdline_parse_inst_t *)&cmd_read_reg_bit, 15709 (cmdline_parse_inst_t *)&cmd_write_reg, 15710 (cmdline_parse_inst_t *)&cmd_write_reg_bit_field, 15711 (cmdline_parse_inst_t *)&cmd_write_reg_bit, 15712 (cmdline_parse_inst_t *)&cmd_read_rxd_txd, 15713 (cmdline_parse_inst_t *)&cmd_stop, 15714 (cmdline_parse_inst_t *)&cmd_mac_addr, 15715 (cmdline_parse_inst_t *)&cmd_set_qmap, 15716 (cmdline_parse_inst_t *)&cmd_set_xstats_hide_zero, 15717 (cmdline_parse_inst_t *)&cmd_operate_port, 15718 (cmdline_parse_inst_t *)&cmd_operate_specific_port, 15719 (cmdline_parse_inst_t *)&cmd_operate_attach_port, 15720 (cmdline_parse_inst_t *)&cmd_operate_detach_port, 15721 (cmdline_parse_inst_t *)&cmd_config_speed_all, 15722 (cmdline_parse_inst_t *)&cmd_config_speed_specific, 15723 (cmdline_parse_inst_t *)&cmd_config_rx_tx, 15724 (cmdline_parse_inst_t *)&cmd_config_mtu, 15725 (cmdline_parse_inst_t *)&cmd_config_max_pkt_len, 15726 (cmdline_parse_inst_t *)&cmd_config_rx_mode_flag, 15727 (cmdline_parse_inst_t *)&cmd_config_rss, 15728 (cmdline_parse_inst_t *)&cmd_config_rxtx_queue, 15729 (cmdline_parse_inst_t *)&cmd_config_txqflags, 15730 (cmdline_parse_inst_t *)&cmd_config_rss_reta, 15731 (cmdline_parse_inst_t *)&cmd_showport_reta, 15732 (cmdline_parse_inst_t *)&cmd_config_burst, 15733 (cmdline_parse_inst_t *)&cmd_config_thresh, 15734 (cmdline_parse_inst_t *)&cmd_config_threshold, 15735 (cmdline_parse_inst_t *)&cmd_set_uc_hash_filter, 15736 (cmdline_parse_inst_t *)&cmd_set_uc_all_hash_filter, 15737 (cmdline_parse_inst_t *)&cmd_vf_mac_addr_filter, 15738 (cmdline_parse_inst_t *)&cmd_set_vf_macvlan_filter, 15739 (cmdline_parse_inst_t *)&cmd_queue_rate_limit, 15740 (cmdline_parse_inst_t *)&cmd_tunnel_filter, 15741 (cmdline_parse_inst_t *)&cmd_tunnel_udp_config, 15742 (cmdline_parse_inst_t *)&cmd_global_config, 15743 (cmdline_parse_inst_t *)&cmd_set_mirror_mask, 15744 (cmdline_parse_inst_t *)&cmd_set_mirror_link, 15745 (cmdline_parse_inst_t *)&cmd_reset_mirror_rule, 15746 (cmdline_parse_inst_t *)&cmd_showport_rss_hash, 15747 (cmdline_parse_inst_t *)&cmd_showport_rss_hash_key, 15748 (cmdline_parse_inst_t *)&cmd_config_rss_hash_key, 15749 (cmdline_parse_inst_t *)&cmd_dump, 15750 (cmdline_parse_inst_t *)&cmd_dump_one, 15751 (cmdline_parse_inst_t *)&cmd_ethertype_filter, 15752 (cmdline_parse_inst_t *)&cmd_syn_filter, 15753 (cmdline_parse_inst_t *)&cmd_2tuple_filter, 15754 (cmdline_parse_inst_t *)&cmd_5tuple_filter, 15755 (cmdline_parse_inst_t *)&cmd_flex_filter, 15756 (cmdline_parse_inst_t *)&cmd_add_del_ip_flow_director, 15757 (cmdline_parse_inst_t *)&cmd_add_del_udp_flow_director, 15758 (cmdline_parse_inst_t *)&cmd_add_del_sctp_flow_director, 15759 (cmdline_parse_inst_t *)&cmd_add_del_l2_flow_director, 15760 (cmdline_parse_inst_t *)&cmd_add_del_mac_vlan_flow_director, 15761 (cmdline_parse_inst_t *)&cmd_add_del_tunnel_flow_director, 15762 (cmdline_parse_inst_t *)&cmd_flush_flow_director, 15763 (cmdline_parse_inst_t *)&cmd_set_flow_director_ip_mask, 15764 (cmdline_parse_inst_t *)&cmd_set_flow_director_mac_vlan_mask, 15765 (cmdline_parse_inst_t *)&cmd_set_flow_director_tunnel_mask, 15766 (cmdline_parse_inst_t *)&cmd_set_flow_director_flex_mask, 15767 (cmdline_parse_inst_t *)&cmd_set_flow_director_flex_payload, 15768 (cmdline_parse_inst_t *)&cmd_get_sym_hash_ena_per_port, 15769 (cmdline_parse_inst_t *)&cmd_set_sym_hash_ena_per_port, 15770 (cmdline_parse_inst_t *)&cmd_get_hash_global_config, 15771 (cmdline_parse_inst_t *)&cmd_set_hash_global_config, 15772 (cmdline_parse_inst_t *)&cmd_set_hash_input_set, 15773 (cmdline_parse_inst_t *)&cmd_set_fdir_input_set, 15774 (cmdline_parse_inst_t *)&cmd_flow, 15775 (cmdline_parse_inst_t *)&cmd_show_port_meter_cap, 15776 (cmdline_parse_inst_t *)&cmd_add_port_meter_profile_srtcm, 15777 (cmdline_parse_inst_t *)&cmd_add_port_meter_profile_trtcm, 15778 (cmdline_parse_inst_t *)&cmd_del_port_meter_profile, 15779 (cmdline_parse_inst_t *)&cmd_create_port_meter, 15780 (cmdline_parse_inst_t *)&cmd_enable_port_meter, 15781 (cmdline_parse_inst_t *)&cmd_disable_port_meter, 15782 (cmdline_parse_inst_t *)&cmd_del_port_meter, 15783 (cmdline_parse_inst_t *)&cmd_set_port_meter_profile, 15784 (cmdline_parse_inst_t *)&cmd_set_port_meter_dscp_table, 15785 (cmdline_parse_inst_t *)&cmd_set_port_meter_policer_action, 15786 (cmdline_parse_inst_t *)&cmd_set_port_meter_stats_mask, 15787 (cmdline_parse_inst_t *)&cmd_show_port_meter_stats, 15788 (cmdline_parse_inst_t *)&cmd_mcast_addr, 15789 (cmdline_parse_inst_t *)&cmd_config_l2_tunnel_eth_type_all, 15790 (cmdline_parse_inst_t *)&cmd_config_l2_tunnel_eth_type_specific, 15791 (cmdline_parse_inst_t *)&cmd_config_l2_tunnel_en_dis_all, 15792 (cmdline_parse_inst_t *)&cmd_config_l2_tunnel_en_dis_specific, 15793 (cmdline_parse_inst_t *)&cmd_config_e_tag_insertion_en, 15794 (cmdline_parse_inst_t *)&cmd_config_e_tag_insertion_dis, 15795 (cmdline_parse_inst_t *)&cmd_config_e_tag_stripping_en_dis, 15796 (cmdline_parse_inst_t *)&cmd_config_e_tag_forwarding_en_dis, 15797 (cmdline_parse_inst_t *)&cmd_config_e_tag_filter_add, 15798 (cmdline_parse_inst_t *)&cmd_config_e_tag_filter_del, 15799 (cmdline_parse_inst_t *)&cmd_set_vf_vlan_anti_spoof, 15800 (cmdline_parse_inst_t *)&cmd_set_vf_mac_anti_spoof, 15801 (cmdline_parse_inst_t *)&cmd_set_vf_vlan_stripq, 15802 (cmdline_parse_inst_t *)&cmd_set_vf_vlan_insert, 15803 (cmdline_parse_inst_t *)&cmd_set_tx_loopback, 15804 (cmdline_parse_inst_t *)&cmd_set_all_queues_drop_en, 15805 (cmdline_parse_inst_t *)&cmd_set_vf_split_drop_en, 15806 (cmdline_parse_inst_t *)&cmd_set_macsec_offload_on, 15807 (cmdline_parse_inst_t *)&cmd_set_macsec_offload_off, 15808 (cmdline_parse_inst_t *)&cmd_set_macsec_sc, 15809 (cmdline_parse_inst_t *)&cmd_set_macsec_sa, 15810 (cmdline_parse_inst_t *)&cmd_set_vf_traffic, 15811 (cmdline_parse_inst_t *)&cmd_set_vf_rxmode, 15812 (cmdline_parse_inst_t *)&cmd_vf_rate_limit, 15813 (cmdline_parse_inst_t *)&cmd_vf_rxvlan_filter, 15814 (cmdline_parse_inst_t *)&cmd_set_vf_mac_addr, 15815 (cmdline_parse_inst_t *)&cmd_set_vf_promisc, 15816 (cmdline_parse_inst_t *)&cmd_set_vf_allmulti, 15817 (cmdline_parse_inst_t *)&cmd_set_vf_broadcast, 15818 (cmdline_parse_inst_t *)&cmd_set_vf_vlan_tag, 15819 (cmdline_parse_inst_t *)&cmd_vf_max_bw, 15820 (cmdline_parse_inst_t *)&cmd_vf_tc_min_bw, 15821 (cmdline_parse_inst_t *)&cmd_vf_tc_max_bw, 15822 (cmdline_parse_inst_t *)&cmd_strict_link_prio, 15823 (cmdline_parse_inst_t *)&cmd_tc_min_bw, 15824 #if defined RTE_LIBRTE_PMD_SOFTNIC && defined RTE_LIBRTE_SCHED 15825 (cmdline_parse_inst_t *)&cmd_set_port_tm_hierarchy_default, 15826 #endif 15827 (cmdline_parse_inst_t *)&cmd_ddp_add, 15828 (cmdline_parse_inst_t *)&cmd_ddp_del, 15829 (cmdline_parse_inst_t *)&cmd_ddp_get_list, 15830 (cmdline_parse_inst_t *)&cmd_ddp_get_info, 15831 (cmdline_parse_inst_t *)&cmd_show_vf_stats, 15832 (cmdline_parse_inst_t *)&cmd_clear_vf_stats, 15833 (cmdline_parse_inst_t *)&cmd_ptype_mapping_get, 15834 (cmdline_parse_inst_t *)&cmd_ptype_mapping_replace, 15835 (cmdline_parse_inst_t *)&cmd_ptype_mapping_reset, 15836 (cmdline_parse_inst_t *)&cmd_ptype_mapping_update, 15837 15838 (cmdline_parse_inst_t *)&cmd_pctype_mapping_get, 15839 (cmdline_parse_inst_t *)&cmd_pctype_mapping_reset, 15840 (cmdline_parse_inst_t *)&cmd_pctype_mapping_update, 15841 (cmdline_parse_inst_t *)&cmd_queue_region, 15842 (cmdline_parse_inst_t *)&cmd_region_flowtype, 15843 (cmdline_parse_inst_t *)&cmd_user_priority_region, 15844 (cmdline_parse_inst_t *)&cmd_flush_queue_region, 15845 (cmdline_parse_inst_t *)&cmd_show_queue_region_info_all, 15846 (cmdline_parse_inst_t *)&cmd_show_port_tm_cap, 15847 (cmdline_parse_inst_t *)&cmd_show_port_tm_level_cap, 15848 (cmdline_parse_inst_t *)&cmd_show_port_tm_node_cap, 15849 (cmdline_parse_inst_t *)&cmd_show_port_tm_node_type, 15850 (cmdline_parse_inst_t *)&cmd_show_port_tm_node_stats, 15851 (cmdline_parse_inst_t *)&cmd_add_port_tm_node_shaper_profile, 15852 (cmdline_parse_inst_t *)&cmd_del_port_tm_node_shaper_profile, 15853 (cmdline_parse_inst_t *)&cmd_add_port_tm_node_shared_shaper, 15854 (cmdline_parse_inst_t *)&cmd_del_port_tm_node_shared_shaper, 15855 (cmdline_parse_inst_t *)&cmd_add_port_tm_node_wred_profile, 15856 (cmdline_parse_inst_t *)&cmd_del_port_tm_node_wred_profile, 15857 (cmdline_parse_inst_t *)&cmd_set_port_tm_node_shaper_profile, 15858 (cmdline_parse_inst_t *)&cmd_add_port_tm_nonleaf_node, 15859 (cmdline_parse_inst_t *)&cmd_add_port_tm_leaf_node, 15860 (cmdline_parse_inst_t *)&cmd_del_port_tm_node, 15861 (cmdline_parse_inst_t *)&cmd_set_port_tm_node_parent, 15862 (cmdline_parse_inst_t *)&cmd_port_tm_hierarchy_commit, 15863 NULL, 15864 }; 15865 15866 /* read cmdline commands from file */ 15867 void 15868 cmdline_read_from_file(const char *filename) 15869 { 15870 struct cmdline *cl; 15871 15872 cl = cmdline_file_new(main_ctx, "testpmd> ", filename); 15873 if (cl == NULL) { 15874 printf("Failed to create file based cmdline context: %s\n", 15875 filename); 15876 return; 15877 } 15878 15879 cmdline_interact(cl); 15880 cmdline_quit(cl); 15881 15882 cmdline_free(cl); 15883 15884 printf("Read CLI commands from %s\n", filename); 15885 } 15886 15887 /* prompt function, called from main on MASTER lcore */ 15888 void 15889 prompt(void) 15890 { 15891 /* initialize non-constant commands */ 15892 cmd_set_fwd_mode_init(); 15893 cmd_set_fwd_retry_mode_init(); 15894 15895 testpmd_cl = cmdline_stdin_new(main_ctx, "testpmd> "); 15896 if (testpmd_cl == NULL) 15897 return; 15898 cmdline_interact(testpmd_cl); 15899 cmdline_stdin_exit(testpmd_cl); 15900 } 15901 15902 void 15903 prompt_exit(void) 15904 { 15905 if (testpmd_cl != NULL) 15906 cmdline_quit(testpmd_cl); 15907 } 15908 15909 static void 15910 cmd_reconfig_device_queue(portid_t id, uint8_t dev, uint8_t queue) 15911 { 15912 if (id == (portid_t)RTE_PORT_ALL) { 15913 portid_t pid; 15914 15915 RTE_ETH_FOREACH_DEV(pid) { 15916 /* check if need_reconfig has been set to 1 */ 15917 if (ports[pid].need_reconfig == 0) 15918 ports[pid].need_reconfig = dev; 15919 /* check if need_reconfig_queues has been set to 1 */ 15920 if (ports[pid].need_reconfig_queues == 0) 15921 ports[pid].need_reconfig_queues = queue; 15922 } 15923 } else if (!port_id_is_invalid(id, DISABLED_WARN)) { 15924 /* check if need_reconfig has been set to 1 */ 15925 if (ports[id].need_reconfig == 0) 15926 ports[id].need_reconfig = dev; 15927 /* check if need_reconfig_queues has been set to 1 */ 15928 if (ports[id].need_reconfig_queues == 0) 15929 ports[id].need_reconfig_queues = queue; 15930 } 15931 } 15932