1 /* SPDX-License-Identifier: BSD-3-Clause 2 * Copyright(c) 2010-2016 Intel Corporation. 3 * Copyright(c) 2014 6WIND S.A. 4 */ 5 6 #include <stdarg.h> 7 #include <errno.h> 8 #include <stdio.h> 9 #include <stdint.h> 10 #include <string.h> 11 #include <termios.h> 12 #include <unistd.h> 13 #include <inttypes.h> 14 #ifdef RTE_EXEC_ENV_FREEBSD 15 #include <sys/socket.h> 16 #endif 17 #include <netinet/in.h> 18 19 #include <sys/queue.h> 20 21 #include <rte_common.h> 22 #include <rte_byteorder.h> 23 #include <rte_log.h> 24 #include <rte_debug.h> 25 #include <rte_cycles.h> 26 #include <rte_memory.h> 27 #include <rte_memzone.h> 28 #include <rte_malloc.h> 29 #include <rte_launch.h> 30 #include <rte_eal.h> 31 #include <rte_per_lcore.h> 32 #include <rte_lcore.h> 33 #include <rte_atomic.h> 34 #include <rte_branch_prediction.h> 35 #include <rte_ring.h> 36 #include <rte_mempool.h> 37 #include <rte_interrupts.h> 38 #include <rte_pci.h> 39 #include <rte_ether.h> 40 #include <rte_ethdev.h> 41 #include <rte_string_fns.h> 42 #include <rte_devargs.h> 43 #include <rte_flow.h> 44 #include <rte_gro.h> 45 46 #include <cmdline_rdline.h> 47 #include <cmdline_parse.h> 48 #include <cmdline_parse_num.h> 49 #include <cmdline_parse_string.h> 50 #include <cmdline_parse_ipaddr.h> 51 #include <cmdline_parse_etheraddr.h> 52 #include <cmdline_socket.h> 53 #include <cmdline.h> 54 #ifdef RTE_LIBRTE_PMD_BOND 55 #include <rte_eth_bond.h> 56 #include <rte_eth_bond_8023ad.h> 57 #endif 58 #if defined RTE_LIBRTE_DPAA_BUS && defined RTE_LIBRTE_DPAA_PMD 59 #include <rte_pmd_dpaa.h> 60 #endif 61 #ifdef RTE_LIBRTE_IXGBE_PMD 62 #include <rte_pmd_ixgbe.h> 63 #endif 64 #ifdef RTE_LIBRTE_I40E_PMD 65 #include <rte_pmd_i40e.h> 66 #endif 67 #ifdef RTE_LIBRTE_BNXT_PMD 68 #include <rte_pmd_bnxt.h> 69 #endif 70 #include "testpmd.h" 71 #include "cmdline_mtr.h" 72 #include "cmdline_tm.h" 73 #include "bpf_cmd.h" 74 75 static struct cmdline *testpmd_cl; 76 77 static void cmd_reconfig_device_queue(portid_t id, uint8_t dev, uint8_t queue); 78 79 /* *** Help command with introduction. *** */ 80 struct cmd_help_brief_result { 81 cmdline_fixed_string_t help; 82 }; 83 84 static void cmd_help_brief_parsed(__attribute__((unused)) void *parsed_result, 85 struct cmdline *cl, 86 __attribute__((unused)) void *data) 87 { 88 cmdline_printf( 89 cl, 90 "\n" 91 "Help is available for the following sections:\n\n" 92 " help control : Start and stop forwarding.\n" 93 " help display : Displaying port, stats and config " 94 "information.\n" 95 " help config : Configuration information.\n" 96 " help ports : Configuring ports.\n" 97 " help registers : Reading and setting port registers.\n" 98 " help filters : Filters configuration help.\n" 99 " help traffic_management : Traffic Management commmands.\n" 100 " help devices : Device related cmds.\n" 101 " help all : All of the above sections.\n\n" 102 ); 103 104 } 105 106 cmdline_parse_token_string_t cmd_help_brief_help = 107 TOKEN_STRING_INITIALIZER(struct cmd_help_brief_result, help, "help"); 108 109 cmdline_parse_inst_t cmd_help_brief = { 110 .f = cmd_help_brief_parsed, 111 .data = NULL, 112 .help_str = "help: Show help", 113 .tokens = { 114 (void *)&cmd_help_brief_help, 115 NULL, 116 }, 117 }; 118 119 /* *** Help command with help sections. *** */ 120 struct cmd_help_long_result { 121 cmdline_fixed_string_t help; 122 cmdline_fixed_string_t section; 123 }; 124 125 static void cmd_help_long_parsed(void *parsed_result, 126 struct cmdline *cl, 127 __attribute__((unused)) void *data) 128 { 129 int show_all = 0; 130 struct cmd_help_long_result *res = parsed_result; 131 132 if (!strcmp(res->section, "all")) 133 show_all = 1; 134 135 if (show_all || !strcmp(res->section, "control")) { 136 137 cmdline_printf( 138 cl, 139 "\n" 140 "Control forwarding:\n" 141 "-------------------\n\n" 142 143 "start\n" 144 " Start packet forwarding with current configuration.\n\n" 145 146 "start tx_first\n" 147 " Start packet forwarding with current config" 148 " after sending one burst of packets.\n\n" 149 150 "stop\n" 151 " Stop packet forwarding, and display accumulated" 152 " statistics.\n\n" 153 154 "quit\n" 155 " Quit to prompt.\n\n" 156 ); 157 } 158 159 if (show_all || !strcmp(res->section, "display")) { 160 161 cmdline_printf( 162 cl, 163 "\n" 164 "Display:\n" 165 "--------\n\n" 166 167 "show port (info|stats|summary|xstats|fdir|stat_qmap|dcb_tc|cap) (port_id|all)\n" 168 " Display information for port_id, or all.\n\n" 169 170 "show port X rss reta (size) (mask0,mask1,...)\n" 171 " Display the rss redirection table entry indicated" 172 " by masks on port X. size is used to indicate the" 173 " hardware supported reta size\n\n" 174 175 "show port (port_id) rss-hash [key]\n" 176 " Display the RSS hash functions and RSS hash key of port\n\n" 177 178 "clear port (info|stats|xstats|fdir|stat_qmap) (port_id|all)\n" 179 " Clear information for port_id, or all.\n\n" 180 181 "show (rxq|txq) info (port_id) (queue_id)\n" 182 " Display information for configured RX/TX queue.\n\n" 183 184 "show config (rxtx|cores|fwd|txpkts)\n" 185 " Display the given configuration.\n\n" 186 187 "read rxd (port_id) (queue_id) (rxd_id)\n" 188 " Display an RX descriptor of a port RX queue.\n\n" 189 190 "read txd (port_id) (queue_id) (txd_id)\n" 191 " Display a TX descriptor of a port TX queue.\n\n" 192 193 "ddp get list (port_id)\n" 194 " Get ddp profile info list\n\n" 195 196 "ddp get info (profile_path)\n" 197 " Get ddp profile information.\n\n" 198 199 "show vf stats (port_id) (vf_id)\n" 200 " Display a VF's statistics.\n\n" 201 202 "clear vf stats (port_id) (vf_id)\n" 203 " Reset a VF's statistics.\n\n" 204 205 "show port (port_id) pctype mapping\n" 206 " Get flow ptype to pctype mapping on a port\n\n" 207 208 "show port meter stats (port_id) (meter_id) (clear)\n" 209 " Get meter stats on a port\n\n" 210 211 "show fwd stats all\n" 212 " Display statistics for all fwd engines.\n\n" 213 214 "clear fwd stats all\n" 215 " Clear statistics for all fwd engines.\n\n" 216 217 "show port (port_id) rx_offload capabilities\n" 218 " List all per queue and per port Rx offloading" 219 " capabilities of a port\n\n" 220 221 "show port (port_id) rx_offload configuration\n" 222 " List port level and all queue level" 223 " Rx offloading configuration\n\n" 224 225 "show port (port_id) tx_offload capabilities\n" 226 " List all per queue and per port" 227 " Tx offloading capabilities of a port\n\n" 228 229 "show port (port_id) tx_offload configuration\n" 230 " List port level and all queue level" 231 " Tx offloading configuration\n\n" 232 233 "show port (port_id) tx_metadata\n" 234 " Show Tx metadata value set" 235 " for a specific port\n\n" 236 237 "show port (port_id) ptypes\n" 238 " Show port supported ptypes" 239 " for a specific port\n\n" 240 241 "show device info (<identifier>|all)" 242 " Show general information about devices probed.\n\n" 243 244 "show port (port_id) rxq|txq (queue_id) desc (desc_id) status" 245 " Show status of rx|tx descriptor.\n\n" 246 ); 247 } 248 249 if (show_all || !strcmp(res->section, "config")) { 250 cmdline_printf( 251 cl, 252 "\n" 253 "Configuration:\n" 254 "--------------\n" 255 "Configuration changes only become active when" 256 " forwarding is started/restarted.\n\n" 257 258 "set default\n" 259 " Reset forwarding to the default configuration.\n\n" 260 261 "set verbose (level)\n" 262 " Set the debug verbosity level X.\n\n" 263 264 "set log global|(type) (level)\n" 265 " Set the log level.\n\n" 266 267 "set nbport (num)\n" 268 " Set number of ports.\n\n" 269 270 "set nbcore (num)\n" 271 " Set number of cores.\n\n" 272 273 "set coremask (mask)\n" 274 " Set the forwarding cores hexadecimal mask.\n\n" 275 276 "set portmask (mask)\n" 277 " Set the forwarding ports hexadecimal mask.\n\n" 278 279 "set burst (num)\n" 280 " Set number of packets per burst.\n\n" 281 282 "set burst tx delay (microseconds) retry (num)\n" 283 " Set the transmit delay time and number of retries," 284 " effective when retry is enabled.\n\n" 285 286 "set txpkts (x[,y]*)\n" 287 " Set the length of each segment of TXONLY" 288 " and optionally CSUM packets.\n\n" 289 290 "set txsplit (off|on|rand)\n" 291 " Set the split policy for the TX packets." 292 " Right now only applicable for CSUM and TXONLY" 293 " modes\n\n" 294 295 "set corelist (x[,y]*)\n" 296 " Set the list of forwarding cores.\n\n" 297 298 "set portlist (x[,y]*)\n" 299 " Set the list of forwarding ports.\n\n" 300 301 "set port setup on (iterator|event)\n" 302 " Select how attached port is retrieved for setup.\n\n" 303 304 "set tx loopback (port_id) (on|off)\n" 305 " Enable or disable tx loopback.\n\n" 306 307 "set all queues drop (port_id) (on|off)\n" 308 " Set drop enable bit for all queues.\n\n" 309 310 "set vf split drop (port_id) (vf_id) (on|off)\n" 311 " Set split drop enable bit for a VF from the PF.\n\n" 312 313 "set vf mac antispoof (port_id) (vf_id) (on|off).\n" 314 " Set MAC antispoof for a VF from the PF.\n\n" 315 316 "set macsec offload (port_id) on encrypt (on|off) replay-protect (on|off)\n" 317 " Enable MACsec offload.\n\n" 318 319 "set macsec offload (port_id) off\n" 320 " Disable MACsec offload.\n\n" 321 322 "set macsec sc (tx|rx) (port_id) (mac) (pi)\n" 323 " Configure MACsec secure connection (SC).\n\n" 324 325 "set macsec sa (tx|rx) (port_id) (idx) (an) (pn) (key)\n" 326 " Configure MACsec secure association (SA).\n\n" 327 328 "set vf broadcast (port_id) (vf_id) (on|off)\n" 329 " Set VF broadcast for a VF from the PF.\n\n" 330 331 "vlan set stripq (on|off) (port_id,queue_id)\n" 332 " Set the VLAN strip for a queue on a port.\n\n" 333 334 "set vf vlan stripq (port_id) (vf_id) (on|off)\n" 335 " Set the VLAN strip for all queues in a pool for a VF from the PF.\n\n" 336 337 "set vf vlan insert (port_id) (vf_id) (vlan_id)\n" 338 " Set VLAN insert for a VF from the PF.\n\n" 339 340 "set vf vlan antispoof (port_id) (vf_id) (on|off)\n" 341 " Set VLAN antispoof for a VF from the PF.\n\n" 342 343 "set vf vlan tag (port_id) (vf_id) (on|off)\n" 344 " Set VLAN tag for a VF from the PF.\n\n" 345 346 "set vf tx max-bandwidth (port_id) (vf_id) (bandwidth)\n" 347 " Set a VF's max bandwidth(Mbps).\n\n" 348 349 "set vf tc tx min-bandwidth (port_id) (vf_id) (bw1, bw2, ...)\n" 350 " Set all TCs' min bandwidth(%%) on a VF.\n\n" 351 352 "set vf tc tx max-bandwidth (port_id) (vf_id) (tc_no) (bandwidth)\n" 353 " Set a TC's max bandwidth(Mbps) on a VF.\n\n" 354 355 "set tx strict-link-priority (port_id) (tc_bitmap)\n" 356 " Set some TCs' strict link priority mode on a physical port.\n\n" 357 358 "set tc tx min-bandwidth (port_id) (bw1, bw2, ...)\n" 359 " Set all TCs' min bandwidth(%%) for all PF and VFs.\n\n" 360 361 "vlan set (strip|filter|qinq_strip|extend) (on|off) (port_id)\n" 362 " Set the VLAN strip or filter or qinq strip or extend\n\n" 363 364 "vlan set (inner|outer) tpid (value) (port_id)\n" 365 " Set the VLAN TPID for Packet Filtering on" 366 " a port\n\n" 367 368 "rx_vlan add (vlan_id|all) (port_id)\n" 369 " Add a vlan_id, or all identifiers, to the set" 370 " of VLAN identifiers filtered by port_id.\n\n" 371 372 "rx_vlan rm (vlan_id|all) (port_id)\n" 373 " Remove a vlan_id, or all identifiers, from the set" 374 " of VLAN identifiers filtered by port_id.\n\n" 375 376 "rx_vlan add (vlan_id) port (port_id) vf (vf_mask)\n" 377 " Add a vlan_id, to the set of VLAN identifiers" 378 "filtered for VF(s) from port_id.\n\n" 379 380 "rx_vlan rm (vlan_id) port (port_id) vf (vf_mask)\n" 381 " Remove a vlan_id, to the set of VLAN identifiers" 382 "filtered for VF(s) from port_id.\n\n" 383 384 "tunnel_filter add (port_id) (outer_mac) (inner_mac) (ip_addr) " 385 "(inner_vlan) (vxlan|nvgre|ipingre|vxlan-gpe) (imac-ivlan|imac-ivlan-tenid|" 386 "imac-tenid|imac|omac-imac-tenid|oip|iip) (tenant_id) (queue_id)\n" 387 " add a tunnel filter of a port.\n\n" 388 389 "tunnel_filter rm (port_id) (outer_mac) (inner_mac) (ip_addr) " 390 "(inner_vlan) (vxlan|nvgre|ipingre|vxlan-gpe) (imac-ivlan|imac-ivlan-tenid|" 391 "imac-tenid|imac|omac-imac-tenid|oip|iip) (tenant_id) (queue_id)\n" 392 " remove a tunnel filter of a port.\n\n" 393 394 "rx_vxlan_port add (udp_port) (port_id)\n" 395 " Add an UDP port for VXLAN packet filter on a port\n\n" 396 397 "rx_vxlan_port rm (udp_port) (port_id)\n" 398 " Remove an UDP port for VXLAN packet filter on a port\n\n" 399 400 "tx_vlan set (port_id) vlan_id[, vlan_id_outer]\n" 401 " Set hardware insertion of VLAN IDs (single or double VLAN " 402 "depends on the number of VLAN IDs) in packets sent on a port.\n\n" 403 404 "tx_vlan set pvid port_id vlan_id (on|off)\n" 405 " Set port based TX VLAN insertion.\n\n" 406 407 "tx_vlan reset (port_id)\n" 408 " Disable hardware insertion of a VLAN header in" 409 " packets sent on a port.\n\n" 410 411 "csum set (ip|udp|tcp|sctp|outer-ip|outer-udp) (hw|sw) (port_id)\n" 412 " Select hardware or software calculation of the" 413 " checksum when transmitting a packet using the" 414 " csum forward engine.\n" 415 " ip|udp|tcp|sctp always concern the inner layer.\n" 416 " outer-ip concerns the outer IP layer in" 417 " outer-udp concerns the outer UDP layer in" 418 " case the packet is recognized as a tunnel packet by" 419 " the forward engine (vxlan, gre and ipip are supported)\n" 420 " Please check the NIC datasheet for HW limits.\n\n" 421 422 "csum parse-tunnel (on|off) (tx_port_id)\n" 423 " If disabled, treat tunnel packets as non-tunneled" 424 " packets (treat inner headers as payload). The port\n" 425 " argument is the port used for TX in csum forward" 426 " engine.\n\n" 427 428 "csum show (port_id)\n" 429 " Display tx checksum offload configuration\n\n" 430 431 "tso set (segsize) (portid)\n" 432 " Enable TCP Segmentation Offload in csum forward" 433 " engine.\n" 434 " Please check the NIC datasheet for HW limits.\n\n" 435 436 "tso show (portid)" 437 " Display the status of TCP Segmentation Offload.\n\n" 438 439 "set port (port_id) gro on|off\n" 440 " Enable or disable Generic Receive Offload in" 441 " csum forwarding engine.\n\n" 442 443 "show port (port_id) gro\n" 444 " Display GRO configuration.\n\n" 445 446 "set gro flush (cycles)\n" 447 " Set the cycle to flush GROed packets from" 448 " reassembly tables.\n\n" 449 450 "set port (port_id) gso (on|off)" 451 " Enable or disable Generic Segmentation Offload in" 452 " csum forwarding engine.\n\n" 453 454 "set gso segsz (length)\n" 455 " Set max packet length for output GSO segments," 456 " including packet header and payload.\n\n" 457 458 "show port (port_id) gso\n" 459 " Show GSO configuration.\n\n" 460 461 "set fwd (%s)\n" 462 " Set packet forwarding mode.\n\n" 463 464 "mac_addr add (port_id) (XX:XX:XX:XX:XX:XX)\n" 465 " Add a MAC address on port_id.\n\n" 466 467 "mac_addr remove (port_id) (XX:XX:XX:XX:XX:XX)\n" 468 " Remove a MAC address from port_id.\n\n" 469 470 "mac_addr set (port_id) (XX:XX:XX:XX:XX:XX)\n" 471 " Set the default MAC address for port_id.\n\n" 472 473 "mac_addr add port (port_id) vf (vf_id) (mac_address)\n" 474 " Add a MAC address for a VF on the port.\n\n" 475 476 "set vf mac addr (port_id) (vf_id) (XX:XX:XX:XX:XX:XX)\n" 477 " Set the MAC address for a VF from the PF.\n\n" 478 479 "set eth-peer (port_id) (peer_addr)\n" 480 " set the peer address for certain port.\n\n" 481 482 "set port (port_id) uta (mac_address|all) (on|off)\n" 483 " Add/Remove a or all unicast hash filter(s)" 484 "from port X.\n\n" 485 486 "set promisc (port_id|all) (on|off)\n" 487 " Set the promiscuous mode on port_id, or all.\n\n" 488 489 "set allmulti (port_id|all) (on|off)\n" 490 " Set the allmulti mode on port_id, or all.\n\n" 491 492 "set vf promisc (port_id) (vf_id) (on|off)\n" 493 " Set unicast promiscuous mode for a VF from the PF.\n\n" 494 495 "set vf allmulti (port_id) (vf_id) (on|off)\n" 496 " Set multicast promiscuous mode for a VF from the PF.\n\n" 497 498 "set flow_ctrl rx (on|off) tx (on|off) (high_water)" 499 " (low_water) (pause_time) (send_xon) mac_ctrl_frame_fwd" 500 " (on|off) autoneg (on|off) (port_id)\n" 501 "set flow_ctrl rx (on|off) (portid)\n" 502 "set flow_ctrl tx (on|off) (portid)\n" 503 "set flow_ctrl high_water (high_water) (portid)\n" 504 "set flow_ctrl low_water (low_water) (portid)\n" 505 "set flow_ctrl pause_time (pause_time) (portid)\n" 506 "set flow_ctrl send_xon (send_xon) (portid)\n" 507 "set flow_ctrl mac_ctrl_frame_fwd (on|off) (portid)\n" 508 "set flow_ctrl autoneg (on|off) (port_id)\n" 509 " Set the link flow control parameter on a port.\n\n" 510 511 "set pfc_ctrl rx (on|off) tx (on|off) (high_water)" 512 " (low_water) (pause_time) (priority) (port_id)\n" 513 " Set the priority flow control parameter on a" 514 " port.\n\n" 515 516 "set stat_qmap (tx|rx) (port_id) (queue_id) (qmapping)\n" 517 " Set statistics mapping (qmapping 0..15) for RX/TX" 518 " queue on port.\n" 519 " e.g., 'set stat_qmap rx 0 2 5' sets rx queue 2" 520 " on port 0 to mapping 5.\n\n" 521 522 "set xstats-hide-zero on|off\n" 523 " Set the option to hide the zero values" 524 " for xstats display.\n" 525 526 "set port (port_id) vf (vf_id) rx|tx on|off\n" 527 " Enable/Disable a VF receive/tranmit from a port\n\n" 528 529 "set port (port_id) vf (vf_id) (mac_addr)" 530 " (exact-mac#exact-mac-vlan#hashmac|hashmac-vlan) on|off\n" 531 " Add/Remove unicast or multicast MAC addr filter" 532 " for a VF.\n\n" 533 534 "set port (port_id) vf (vf_id) rxmode (AUPE|ROPE|BAM" 535 "|MPE) (on|off)\n" 536 " AUPE:accepts untagged VLAN;" 537 "ROPE:accept unicast hash\n\n" 538 " BAM:accepts broadcast packets;" 539 "MPE:accepts all multicast packets\n\n" 540 " Enable/Disable a VF receive mode of a port\n\n" 541 542 "set port (port_id) queue (queue_id) rate (rate_num)\n" 543 " Set rate limit for a queue of a port\n\n" 544 545 "set port (port_id) vf (vf_id) rate (rate_num) " 546 "queue_mask (queue_mask_value)\n" 547 " Set rate limit for queues in VF of a port\n\n" 548 549 "set port (port_id) mirror-rule (rule_id)" 550 " (pool-mirror-up|pool-mirror-down|vlan-mirror)" 551 " (poolmask|vlanid[,vlanid]*) dst-pool (pool_id) (on|off)\n" 552 " Set pool or vlan type mirror rule on a port.\n" 553 " e.g., 'set port 0 mirror-rule 0 vlan-mirror 0,1" 554 " dst-pool 0 on' enable mirror traffic with vlan 0,1" 555 " to pool 0.\n\n" 556 557 "set port (port_id) mirror-rule (rule_id)" 558 " (uplink-mirror|downlink-mirror) dst-pool" 559 " (pool_id) (on|off)\n" 560 " Set uplink or downlink type mirror rule on a port.\n" 561 " e.g., 'set port 0 mirror-rule 0 uplink-mirror dst-pool" 562 " 0 on' enable mirror income traffic to pool 0.\n\n" 563 564 "reset port (port_id) mirror-rule (rule_id)\n" 565 " Reset a mirror rule.\n\n" 566 567 "set flush_rx (on|off)\n" 568 " Flush (default) or don't flush RX streams before" 569 " forwarding. Mainly used with PCAP drivers.\n\n" 570 571 "set bypass mode (normal|bypass|isolate) (port_id)\n" 572 " Set the bypass mode for the lowest port on bypass enabled" 573 " NIC.\n\n" 574 575 "set bypass event (timeout|os_on|os_off|power_on|power_off) " 576 "mode (normal|bypass|isolate) (port_id)\n" 577 " Set the event required to initiate specified bypass mode for" 578 " the lowest port on a bypass enabled NIC where:\n" 579 " timeout = enable bypass after watchdog timeout.\n" 580 " os_on = enable bypass when OS/board is powered on.\n" 581 " os_off = enable bypass when OS/board is powered off.\n" 582 " power_on = enable bypass when power supply is turned on.\n" 583 " power_off = enable bypass when power supply is turned off." 584 "\n\n" 585 586 "set bypass timeout (0|1.5|2|3|4|8|16|32)\n" 587 " Set the bypass watchdog timeout to 'n' seconds" 588 " where 0 = instant.\n\n" 589 590 "show bypass config (port_id)\n" 591 " Show the bypass configuration for a bypass enabled NIC" 592 " using the lowest port on the NIC.\n\n" 593 594 #ifdef RTE_LIBRTE_PMD_BOND 595 "create bonded device (mode) (socket)\n" 596 " Create a new bonded device with specific bonding mode and socket.\n\n" 597 598 "add bonding slave (slave_id) (port_id)\n" 599 " Add a slave device to a bonded device.\n\n" 600 601 "remove bonding slave (slave_id) (port_id)\n" 602 " Remove a slave device from a bonded device.\n\n" 603 604 "set bonding mode (value) (port_id)\n" 605 " Set the bonding mode on a bonded device.\n\n" 606 607 "set bonding primary (slave_id) (port_id)\n" 608 " Set the primary slave for a bonded device.\n\n" 609 610 "show bonding config (port_id)\n" 611 " Show the bonding config for port_id.\n\n" 612 613 "set bonding mac_addr (port_id) (address)\n" 614 " Set the MAC address of a bonded device.\n\n" 615 616 "set bonding mode IEEE802.3AD aggregator policy (port_id) (agg_name)" 617 " Set Aggregation mode for IEEE802.3AD (mode 4)" 618 619 "set bonding xmit_balance_policy (port_id) (l2|l23|l34)\n" 620 " Set the transmit balance policy for bonded device running in balance mode.\n\n" 621 622 "set bonding mon_period (port_id) (value)\n" 623 " Set the bonding link status monitoring polling period in ms.\n\n" 624 625 "set bonding lacp dedicated_queues <port_id> (enable|disable)\n" 626 " Enable/disable dedicated queues for LACP control traffic.\n\n" 627 628 #endif 629 "set link-up port (port_id)\n" 630 " Set link up for a port.\n\n" 631 632 "set link-down port (port_id)\n" 633 " Set link down for a port.\n\n" 634 635 "E-tag set insertion on port-tag-id (value)" 636 " port (port_id) vf (vf_id)\n" 637 " Enable E-tag insertion for a VF on a port\n\n" 638 639 "E-tag set insertion off port (port_id) vf (vf_id)\n" 640 " Disable E-tag insertion for a VF on a port\n\n" 641 642 "E-tag set stripping (on|off) port (port_id)\n" 643 " Enable/disable E-tag stripping on a port\n\n" 644 645 "E-tag set forwarding (on|off) port (port_id)\n" 646 " Enable/disable E-tag based forwarding" 647 " on a port\n\n" 648 649 "E-tag set filter add e-tag-id (value) dst-pool" 650 " (pool_id) port (port_id)\n" 651 " Add an E-tag forwarding filter on a port\n\n" 652 653 "E-tag set filter del e-tag-id (value) port (port_id)\n" 654 " Delete an E-tag forwarding filter on a port\n\n" 655 656 "ddp add (port_id) (profile_path[,backup_profile_path])\n" 657 " Load a profile package on a port\n\n" 658 659 "ddp del (port_id) (backup_profile_path)\n" 660 " Delete a profile package from a port\n\n" 661 662 "ptype mapping get (port_id) (valid_only)\n" 663 " Get ptype mapping on a port\n\n" 664 665 "ptype mapping replace (port_id) (target) (mask) (pky_type)\n" 666 " Replace target with the pkt_type in ptype mapping\n\n" 667 668 "ptype mapping reset (port_id)\n" 669 " Reset ptype mapping on a port\n\n" 670 671 "ptype mapping update (port_id) (hw_ptype) (sw_ptype)\n" 672 " Update a ptype mapping item on a port\n\n" 673 674 "set port (port_id) ptype_mask (ptype_mask)\n" 675 " set packet types classification for a specific port\n\n" 676 677 "set port (port_id) queue-region region_id (value) " 678 "queue_start_index (value) queue_num (value)\n" 679 " Set a queue region on a port\n\n" 680 681 "set port (port_id) queue-region region_id (value) " 682 "flowtype (value)\n" 683 " Set a flowtype region index on a port\n\n" 684 685 "set port (port_id) queue-region UP (value) region_id (value)\n" 686 " Set the mapping of User Priority to " 687 "queue region on a port\n\n" 688 689 "set port (port_id) queue-region flush (on|off)\n" 690 " flush all queue region related configuration\n\n" 691 692 "show port meter cap (port_id)\n" 693 " Show port meter capability information\n\n" 694 695 "add port meter profile srtcm_rfc2697 (port_id) (profile_id) (cir) (cbs) (ebs)\n" 696 " meter profile add - srtcm rfc 2697\n\n" 697 698 "add port meter profile trtcm_rfc2698 (port_id) (profile_id) (cir) (pir) (cbs) (pbs)\n" 699 " meter profile add - trtcm rfc 2698\n\n" 700 701 "add port meter profile trtcm_rfc4115 (port_id) (profile_id) (cir) (eir) (cbs) (ebs)\n" 702 " meter profile add - trtcm rfc 4115\n\n" 703 704 "del port meter profile (port_id) (profile_id)\n" 705 " meter profile delete\n\n" 706 707 "create port meter (port_id) (mtr_id) (profile_id) (meter_enable)\n" 708 "(g_action) (y_action) (r_action) (stats_mask) (shared)\n" 709 "(use_pre_meter_color) [(dscp_tbl_entry0) (dscp_tbl_entry1)...\n" 710 "(dscp_tbl_entry63)]\n" 711 " meter create\n\n" 712 713 "enable port meter (port_id) (mtr_id)\n" 714 " meter enable\n\n" 715 716 "disable port meter (port_id) (mtr_id)\n" 717 " meter disable\n\n" 718 719 "del port meter (port_id) (mtr_id)\n" 720 " meter delete\n\n" 721 722 "set port meter profile (port_id) (mtr_id) (profile_id)\n" 723 " meter update meter profile\n\n" 724 725 "set port meter dscp table (port_id) (mtr_id) [(dscp_tbl_entry0)\n" 726 "(dscp_tbl_entry1)...(dscp_tbl_entry63)]\n" 727 " update meter dscp table entries\n\n" 728 729 "set port meter policer action (port_id) (mtr_id) (action_mask)\n" 730 "(action0) [(action1) (action2)]\n" 731 " meter update policer action\n\n" 732 733 "set port meter stats mask (port_id) (mtr_id) (stats_mask)\n" 734 " meter update stats\n\n" 735 736 "show port (port_id) queue-region\n" 737 " show all queue region related configuration info\n\n" 738 739 , list_pkt_forwarding_modes() 740 ); 741 } 742 743 if (show_all || !strcmp(res->section, "ports")) { 744 745 cmdline_printf( 746 cl, 747 "\n" 748 "Port Operations:\n" 749 "----------------\n\n" 750 751 "port start (port_id|all)\n" 752 " Start all ports or port_id.\n\n" 753 754 "port stop (port_id|all)\n" 755 " Stop all ports or port_id.\n\n" 756 757 "port close (port_id|all)\n" 758 " Close all ports or port_id.\n\n" 759 760 "port reset (port_id|all)\n" 761 " Reset all ports or port_id.\n\n" 762 763 "port attach (ident)\n" 764 " Attach physical or virtual dev by pci address or virtual device name\n\n" 765 766 "port detach (port_id)\n" 767 " Detach physical or virtual dev by port_id\n\n" 768 769 "port config (port_id|all)" 770 " speed (10|100|1000|10000|25000|40000|50000|100000|auto)" 771 " duplex (half|full|auto)\n" 772 " Set speed and duplex for all ports or port_id\n\n" 773 774 "port config (port_id|all) loopback (mode)\n" 775 " Set loopback mode for all ports or port_id\n\n" 776 777 "port config all (rxq|txq|rxd|txd) (value)\n" 778 " Set number for rxq/txq/rxd/txd.\n\n" 779 780 "port config all max-pkt-len (value)\n" 781 " Set the max packet length.\n\n" 782 783 "port config all max-lro-pkt-size (value)\n" 784 " Set the max LRO aggregated packet size.\n\n" 785 786 "port config all drop-en (on|off)\n" 787 " Enable or disable packet drop on all RX queues of all ports when no " 788 "receive buffers available.\n\n" 789 790 "port config all rss (all|default|ip|tcp|udp|sctp|" 791 "ether|port|vxlan|geneve|nvgre|vxlan-gpe|none|<flowtype_id>)\n" 792 " Set the RSS mode.\n\n" 793 794 "port config port-id rss reta (hash,queue)[,(hash,queue)]\n" 795 " Set the RSS redirection table.\n\n" 796 797 "port config (port_id) dcb vt (on|off) (traffic_class)" 798 " pfc (on|off)\n" 799 " Set the DCB mode.\n\n" 800 801 "port config all burst (value)\n" 802 " Set the number of packets per burst.\n\n" 803 804 "port config all (txpt|txht|txwt|rxpt|rxht|rxwt)" 805 " (value)\n" 806 " Set the ring prefetch/host/writeback threshold" 807 " for tx/rx queue.\n\n" 808 809 "port config all (txfreet|txrst|rxfreet) (value)\n" 810 " Set free threshold for rx/tx, or set" 811 " tx rs bit threshold.\n\n" 812 "port config mtu X value\n" 813 " Set the MTU of port X to a given value\n\n" 814 815 "port config (port_id) (rxq|txq) (queue_id) ring_size (value)\n" 816 " Set a rx/tx queue's ring size configuration, the new" 817 " value will take effect after command that (re-)start the port" 818 " or command that setup the specific queue\n\n" 819 820 "port (port_id) (rxq|txq) (queue_id) (start|stop)\n" 821 " Start/stop a rx/tx queue of port X. Only take effect" 822 " when port X is started\n\n" 823 824 "port (port_id) (rxq|txq) (queue_id) deferred_start (on|off)\n" 825 " Switch on/off a deferred start of port X rx/tx queue. Only" 826 " take effect when port X is stopped.\n\n" 827 828 "port (port_id) (rxq|txq) (queue_id) setup\n" 829 " Setup a rx/tx queue of port X.\n\n" 830 831 "port config (port_id|all) l2-tunnel E-tag ether-type" 832 " (value)\n" 833 " Set the value of E-tag ether-type.\n\n" 834 835 "port config (port_id|all) l2-tunnel E-tag" 836 " (enable|disable)\n" 837 " Enable/disable the E-tag support.\n\n" 838 839 "port config (port_id) pctype mapping reset\n" 840 " Reset flow type to pctype mapping on a port\n\n" 841 842 "port config (port_id) pctype mapping update" 843 " (pctype_id_0[,pctype_id_1]*) (flow_type_id)\n" 844 " Update a flow type to pctype mapping item on a port\n\n" 845 846 "port config (port_id) pctype (pctype_id) hash_inset|" 847 "fdir_inset|fdir_flx_inset get|set|clear field\n" 848 " (field_idx)\n" 849 " Configure RSS|FDIR|FDIR_FLX input set for some pctype\n\n" 850 851 "port config (port_id) pctype (pctype_id) hash_inset|" 852 "fdir_inset|fdir_flx_inset clear all" 853 " Clear RSS|FDIR|FDIR_FLX input set completely for some pctype\n\n" 854 855 "port config (port_id) udp_tunnel_port add|rm vxlan|geneve (udp_port)\n\n" 856 " Add/remove UDP tunnel port for tunneling offload\n\n" 857 858 "port config <port_id> rx_offload vlan_strip|" 859 "ipv4_cksum|udp_cksum|tcp_cksum|tcp_lro|qinq_strip|" 860 "outer_ipv4_cksum|macsec_strip|header_split|" 861 "vlan_filter|vlan_extend|jumbo_frame|" 862 "scatter|timestamp|security|keep_crc on|off\n" 863 " Enable or disable a per port Rx offloading" 864 " on all Rx queues of a port\n\n" 865 866 "port (port_id) rxq (queue_id) rx_offload vlan_strip|" 867 "ipv4_cksum|udp_cksum|tcp_cksum|tcp_lro|qinq_strip|" 868 "outer_ipv4_cksum|macsec_strip|header_split|" 869 "vlan_filter|vlan_extend|jumbo_frame|" 870 "scatter|timestamp|security|keep_crc on|off\n" 871 " Enable or disable a per queue Rx offloading" 872 " only on a specific Rx queue\n\n" 873 874 "port config (port_id) tx_offload vlan_insert|" 875 "ipv4_cksum|udp_cksum|tcp_cksum|sctp_cksum|tcp_tso|" 876 "udp_tso|outer_ipv4_cksum|qinq_insert|vxlan_tnl_tso|" 877 "gre_tnl_tso|ipip_tnl_tso|geneve_tnl_tso|" 878 "macsec_insert|mt_lockfree|multi_segs|mbuf_fast_free|" 879 "security|match_metadata on|off\n" 880 " Enable or disable a per port Tx offloading" 881 " on all Tx queues of a port\n\n" 882 883 "port (port_id) txq (queue_id) tx_offload vlan_insert|" 884 "ipv4_cksum|udp_cksum|tcp_cksum|sctp_cksum|tcp_tso|" 885 "udp_tso|outer_ipv4_cksum|qinq_insert|vxlan_tnl_tso|" 886 "gre_tnl_tso|ipip_tnl_tso|geneve_tnl_tso|macsec_insert" 887 "|mt_lockfree|multi_segs|mbuf_fast_free|security" 888 " on|off\n" 889 " Enable or disable a per queue Tx offloading" 890 " only on a specific Tx queue\n\n" 891 892 "bpf-load rx|tx (port) (queue) (J|M|B) (file_name)\n" 893 " Load an eBPF program as a callback" 894 " for particular RX/TX queue\n\n" 895 896 "bpf-unload rx|tx (port) (queue)\n" 897 " Unload previously loaded eBPF program" 898 " for particular RX/TX queue\n\n" 899 900 "port config (port_id) tx_metadata (value)\n" 901 " Set Tx metadata value per port. Testpmd will add this value" 902 " to any Tx packet sent from this port\n\n" 903 ); 904 } 905 906 if (show_all || !strcmp(res->section, "registers")) { 907 908 cmdline_printf( 909 cl, 910 "\n" 911 "Registers:\n" 912 "----------\n\n" 913 914 "read reg (port_id) (address)\n" 915 " Display value of a port register.\n\n" 916 917 "read regfield (port_id) (address) (bit_x) (bit_y)\n" 918 " Display a port register bit field.\n\n" 919 920 "read regbit (port_id) (address) (bit_x)\n" 921 " Display a single port register bit.\n\n" 922 923 "write reg (port_id) (address) (value)\n" 924 " Set value of a port register.\n\n" 925 926 "write regfield (port_id) (address) (bit_x) (bit_y)" 927 " (value)\n" 928 " Set bit field of a port register.\n\n" 929 930 "write regbit (port_id) (address) (bit_x) (value)\n" 931 " Set single bit value of a port register.\n\n" 932 ); 933 } 934 if (show_all || !strcmp(res->section, "filters")) { 935 936 cmdline_printf( 937 cl, 938 "\n" 939 "filters:\n" 940 "--------\n\n" 941 942 "ethertype_filter (port_id) (add|del)" 943 " (mac_addr|mac_ignr) (mac_address) ethertype" 944 " (ether_type) (drop|fwd) queue (queue_id)\n" 945 " Add/Del an ethertype filter.\n\n" 946 947 "2tuple_filter (port_id) (add|del)" 948 " dst_port (dst_port_value) protocol (protocol_value)" 949 " mask (mask_value) tcp_flags (tcp_flags_value)" 950 " priority (prio_value) queue (queue_id)\n" 951 " Add/Del a 2tuple filter.\n\n" 952 953 "5tuple_filter (port_id) (add|del)" 954 " dst_ip (dst_address) src_ip (src_address)" 955 " dst_port (dst_port_value) src_port (src_port_value)" 956 " protocol (protocol_value)" 957 " mask (mask_value) tcp_flags (tcp_flags_value)" 958 " priority (prio_value) queue (queue_id)\n" 959 " Add/Del a 5tuple filter.\n\n" 960 961 "syn_filter (port_id) (add|del) priority (high|low) queue (queue_id)" 962 " Add/Del syn filter.\n\n" 963 964 "flex_filter (port_id) (add|del) len (len_value)" 965 " bytes (bytes_value) mask (mask_value)" 966 " priority (prio_value) queue (queue_id)\n" 967 " Add/Del a flex filter.\n\n" 968 969 "flow_director_filter (port_id) mode IP (add|del|update)" 970 " flow (ipv4-other|ipv4-frag|ipv6-other|ipv6-frag)" 971 " src (src_ip_address) dst (dst_ip_address)" 972 " tos (tos_value) proto (proto_value) ttl (ttl_value)" 973 " vlan (vlan_value) flexbytes (flexbytes_value)" 974 " (drop|fwd) pf|vf(vf_id) queue (queue_id)" 975 " fd_id (fd_id_value)\n" 976 " Add/Del an IP type flow director filter.\n\n" 977 978 "flow_director_filter (port_id) mode IP (add|del|update)" 979 " flow (ipv4-tcp|ipv4-udp|ipv6-tcp|ipv6-udp)" 980 " src (src_ip_address) (src_port)" 981 " dst (dst_ip_address) (dst_port)" 982 " tos (tos_value) ttl (ttl_value)" 983 " vlan (vlan_value) flexbytes (flexbytes_value)" 984 " (drop|fwd) pf|vf(vf_id) queue (queue_id)" 985 " fd_id (fd_id_value)\n" 986 " Add/Del an UDP/TCP type flow director filter.\n\n" 987 988 "flow_director_filter (port_id) mode IP (add|del|update)" 989 " flow (ipv4-sctp|ipv6-sctp)" 990 " src (src_ip_address) (src_port)" 991 " dst (dst_ip_address) (dst_port)" 992 " tag (verification_tag) " 993 " tos (tos_value) ttl (ttl_value)" 994 " vlan (vlan_value)" 995 " flexbytes (flexbytes_value) (drop|fwd)" 996 " pf|vf(vf_id) queue (queue_id) fd_id (fd_id_value)\n" 997 " Add/Del a SCTP type flow director filter.\n\n" 998 999 "flow_director_filter (port_id) mode IP (add|del|update)" 1000 " flow l2_payload ether (ethertype)" 1001 " flexbytes (flexbytes_value) (drop|fwd)" 1002 " pf|vf(vf_id) queue (queue_id) fd_id (fd_id_value)\n" 1003 " Add/Del a l2 payload type flow director filter.\n\n" 1004 1005 "flow_director_filter (port_id) mode MAC-VLAN (add|del|update)" 1006 " mac (mac_address) vlan (vlan_value)" 1007 " flexbytes (flexbytes_value) (drop|fwd)" 1008 " queue (queue_id) fd_id (fd_id_value)\n" 1009 " Add/Del a MAC-VLAN flow director filter.\n\n" 1010 1011 "flow_director_filter (port_id) mode Tunnel (add|del|update)" 1012 " mac (mac_address) vlan (vlan_value)" 1013 " tunnel (NVGRE|VxLAN) tunnel-id (tunnel_id_value)" 1014 " flexbytes (flexbytes_value) (drop|fwd)" 1015 " queue (queue_id) fd_id (fd_id_value)\n" 1016 " Add/Del a Tunnel flow director filter.\n\n" 1017 1018 "flow_director_filter (port_id) mode raw (add|del|update)" 1019 " flow (flow_id) (drop|fwd) queue (queue_id)" 1020 " fd_id (fd_id_value) packet (packet file name)\n" 1021 " Add/Del a raw type flow director filter.\n\n" 1022 1023 "flush_flow_director (port_id)\n" 1024 " Flush all flow director entries of a device.\n\n" 1025 1026 "flow_director_mask (port_id) mode IP vlan (vlan_value)" 1027 " src_mask (ipv4_src) (ipv6_src) (src_port)" 1028 " dst_mask (ipv4_dst) (ipv6_dst) (dst_port)\n" 1029 " Set flow director IP mask.\n\n" 1030 1031 "flow_director_mask (port_id) mode MAC-VLAN" 1032 " vlan (vlan_value)\n" 1033 " Set flow director MAC-VLAN mask.\n\n" 1034 1035 "flow_director_mask (port_id) mode Tunnel" 1036 " vlan (vlan_value) mac (mac_value)" 1037 " tunnel-type (tunnel_type_value)" 1038 " tunnel-id (tunnel_id_value)\n" 1039 " Set flow director Tunnel mask.\n\n" 1040 1041 "flow_director_flex_mask (port_id)" 1042 " flow (none|ipv4-other|ipv4-frag|ipv4-tcp|ipv4-udp|ipv4-sctp|" 1043 "ipv6-other|ipv6-frag|ipv6-tcp|ipv6-udp|ipv6-sctp|l2_payload|all)" 1044 " (mask)\n" 1045 " Configure mask of flex payload.\n\n" 1046 1047 "flow_director_flex_payload (port_id)" 1048 " (raw|l2|l3|l4) (config)\n" 1049 " Configure flex payload selection.\n\n" 1050 1051 "get_sym_hash_ena_per_port (port_id)\n" 1052 " get symmetric hash enable configuration per port.\n\n" 1053 1054 "set_sym_hash_ena_per_port (port_id) (enable|disable)\n" 1055 " set symmetric hash enable configuration per port" 1056 " to enable or disable.\n\n" 1057 1058 "get_hash_global_config (port_id)\n" 1059 " Get the global configurations of hash filters.\n\n" 1060 1061 "set_hash_global_config (port_id) (toeplitz|simple_xor|symmetric_toeplitz|default)" 1062 " (ipv4|ipv4-frag|ipv4-tcp|ipv4-udp|ipv4-sctp|ipv4-other|ipv6|" 1063 "ipv6-frag|ipv6-tcp|ipv6-udp|ipv6-sctp|ipv6-other|l2_payload)" 1064 " (enable|disable)\n" 1065 " Set the global configurations of hash filters.\n\n" 1066 1067 "set_hash_input_set (port_id) (ipv4|ipv4-frag|" 1068 "ipv4-tcp|ipv4-udp|ipv4-sctp|ipv4-other|ipv6|" 1069 "ipv6-frag|ipv6-tcp|ipv6-udp|ipv6-sctp|ipv6-other|" 1070 "l2_payload|<flowtype_id>) (ovlan|ivlan|src-ipv4|dst-ipv4|" 1071 "src-ipv6|dst-ipv6|ipv4-tos|ipv4-proto|ipv6-tc|" 1072 "ipv6-next-header|udp-src-port|udp-dst-port|" 1073 "tcp-src-port|tcp-dst-port|sctp-src-port|" 1074 "sctp-dst-port|sctp-veri-tag|udp-key|gre-key|fld-1st|" 1075 "fld-2nd|fld-3rd|fld-4th|fld-5th|fld-6th|fld-7th|" 1076 "fld-8th|none) (select|add)\n" 1077 " Set the input set for hash.\n\n" 1078 1079 "set_fdir_input_set (port_id) " 1080 "(ipv4-frag|ipv4-tcp|ipv4-udp|ipv4-sctp|ipv4-other|" 1081 "ipv6-frag|ipv6-tcp|ipv6-udp|ipv6-sctp|ipv6-other|" 1082 "l2_payload) (ivlan|ethertype|src-ipv4|dst-ipv4|src-ipv6|" 1083 "dst-ipv6|ipv4-tos|ipv4-proto|ipv4-ttl|ipv6-tc|" 1084 "ipv6-next-header|ipv6-hop-limits|udp-src-port|" 1085 "udp-dst-port|tcp-src-port|tcp-dst-port|" 1086 "sctp-src-port|sctp-dst-port|sctp-veri-tag|none)" 1087 " (select|add)\n" 1088 " Set the input set for FDir.\n\n" 1089 1090 "flow validate {port_id}" 1091 " [group {group_id}] [priority {level}]" 1092 " [ingress] [egress]" 1093 " pattern {item} [/ {item} [...]] / end" 1094 " actions {action} [/ {action} [...]] / end\n" 1095 " Check whether a flow rule can be created.\n\n" 1096 1097 "flow create {port_id}" 1098 " [group {group_id}] [priority {level}]" 1099 " [ingress] [egress]" 1100 " pattern {item} [/ {item} [...]] / end" 1101 " actions {action} [/ {action} [...]] / end\n" 1102 " Create a flow rule.\n\n" 1103 1104 "flow destroy {port_id} rule {rule_id} [...]\n" 1105 " Destroy specific flow rules.\n\n" 1106 1107 "flow flush {port_id}\n" 1108 " Destroy all flow rules.\n\n" 1109 1110 "flow query {port_id} {rule_id} {action}\n" 1111 " Query an existing flow rule.\n\n" 1112 1113 "flow list {port_id} [group {group_id}] [...]\n" 1114 " List existing flow rules sorted by priority," 1115 " filtered by group identifiers.\n\n" 1116 1117 "flow isolate {port_id} {boolean}\n" 1118 " Restrict ingress traffic to the defined" 1119 " flow rules\n\n" 1120 1121 "set vxlan ip-version (ipv4|ipv6) vni (vni) udp-src" 1122 " (udp-src) udp-dst (udp-dst) ip-src (ip-src) ip-dst" 1123 " (ip-dst) eth-src (eth-src) eth-dst (eth-dst)\n" 1124 " Configure the VXLAN encapsulation for flows.\n\n" 1125 1126 "set vxlan-with-vlan ip-version (ipv4|ipv6) vni (vni)" 1127 " udp-src (udp-src) udp-dst (udp-dst) ip-src (ip-src)" 1128 " ip-dst (ip-dst) vlan-tci (vlan-tci) eth-src (eth-src)" 1129 " eth-dst (eth-dst)\n" 1130 " Configure the VXLAN encapsulation for flows.\n\n" 1131 1132 "set vxlan-tos-ttl ip-version (ipv4|ipv6) vni (vni) udp-src" 1133 " (udp-src) udp-dst (udp-dst) ip-tos (ip-tos) ip-ttl (ip-ttl)" 1134 " ip-src (ip-src) ip-dst (ip-dst) eth-src (eth-src)" 1135 " eth-dst (eth-dst)\n" 1136 " Configure the VXLAN encapsulation for flows.\n\n" 1137 1138 "set nvgre ip-version (ipv4|ipv6) tni (tni) ip-src" 1139 " (ip-src) ip-dst (ip-dst) eth-src (eth-src) eth-dst" 1140 " (eth-dst)\n" 1141 " Configure the NVGRE encapsulation for flows.\n\n" 1142 1143 "set nvgre-with-vlan ip-version (ipv4|ipv6) tni (tni)" 1144 " ip-src (ip-src) ip-dst (ip-dst) vlan-tci (vlan-tci)" 1145 " eth-src (eth-src) eth-dst (eth-dst)\n" 1146 " Configure the NVGRE encapsulation for flows.\n\n" 1147 1148 "set raw_encap {flow items}\n" 1149 " Configure the encapsulation with raw data.\n\n" 1150 1151 "set raw_decap {flow items}\n" 1152 " Configure the decapsulation with raw data.\n\n" 1153 1154 ); 1155 } 1156 1157 if (show_all || !strcmp(res->section, "traffic_management")) { 1158 cmdline_printf( 1159 cl, 1160 "\n" 1161 "Traffic Management:\n" 1162 "--------------\n" 1163 "show port tm cap (port_id)\n" 1164 " Display the port TM capability.\n\n" 1165 1166 "show port tm level cap (port_id) (level_id)\n" 1167 " Display the port TM hierarchical level capability.\n\n" 1168 1169 "show port tm node cap (port_id) (node_id)\n" 1170 " Display the port TM node capability.\n\n" 1171 1172 "show port tm node type (port_id) (node_id)\n" 1173 " Display the port TM node type.\n\n" 1174 1175 "show port tm node stats (port_id) (node_id) (clear)\n" 1176 " Display the port TM node stats.\n\n" 1177 1178 #if defined RTE_LIBRTE_PMD_SOFTNIC && defined RTE_LIBRTE_SCHED 1179 "set port tm hierarchy default (port_id)\n" 1180 " Set default traffic Management hierarchy on a port\n\n" 1181 #endif 1182 1183 "add port tm node shaper profile (port_id) (shaper_profile_id)" 1184 " (cmit_tb_rate) (cmit_tb_size) (peak_tb_rate) (peak_tb_size)" 1185 " (packet_length_adjust)\n" 1186 " Add port tm node private shaper profile.\n\n" 1187 1188 "del port tm node shaper profile (port_id) (shaper_profile_id)\n" 1189 " Delete port tm node private shaper profile.\n\n" 1190 1191 "add port tm node shared shaper (port_id) (shared_shaper_id)" 1192 " (shaper_profile_id)\n" 1193 " Add/update port tm node shared shaper.\n\n" 1194 1195 "del port tm node shared shaper (port_id) (shared_shaper_id)\n" 1196 " Delete port tm node shared shaper.\n\n" 1197 1198 "set port tm node shaper profile (port_id) (node_id)" 1199 " (shaper_profile_id)\n" 1200 " Set port tm node shaper profile.\n\n" 1201 1202 "add port tm node wred profile (port_id) (wred_profile_id)" 1203 " (color_g) (min_th_g) (max_th_g) (maxp_inv_g) (wq_log2_g)" 1204 " (color_y) (min_th_y) (max_th_y) (maxp_inv_y) (wq_log2_y)" 1205 " (color_r) (min_th_r) (max_th_r) (maxp_inv_r) (wq_log2_r)\n" 1206 " Add port tm node wred profile.\n\n" 1207 1208 "del port tm node wred profile (port_id) (wred_profile_id)\n" 1209 " Delete port tm node wred profile.\n\n" 1210 1211 "add port tm nonleaf node (port_id) (node_id) (parent_node_id)" 1212 " (priority) (weight) (level_id) (shaper_profile_id)" 1213 " (n_sp_priorities) (stats_mask) (n_shared_shapers)" 1214 " [(shared_shaper_id_0) (shared_shaper_id_1)...]\n" 1215 " Add port tm nonleaf node.\n\n" 1216 1217 "add port tm leaf node (port_id) (node_id) (parent_node_id)" 1218 " (priority) (weight) (level_id) (shaper_profile_id)" 1219 " (cman_mode) (wred_profile_id) (stats_mask) (n_shared_shapers)" 1220 " [(shared_shaper_id_0) (shared_shaper_id_1)...]\n" 1221 " Add port tm leaf node.\n\n" 1222 1223 "del port tm node (port_id) (node_id)\n" 1224 " Delete port tm node.\n\n" 1225 1226 "set port tm node parent (port_id) (node_id) (parent_node_id)" 1227 " (priority) (weight)\n" 1228 " Set port tm node parent.\n\n" 1229 1230 "suspend port tm node (port_id) (node_id)" 1231 " Suspend tm node.\n\n" 1232 1233 "resume port tm node (port_id) (node_id)" 1234 " Resume tm node.\n\n" 1235 1236 "port tm hierarchy commit (port_id) (clean_on_fail)\n" 1237 " Commit tm hierarchy.\n\n" 1238 1239 "set port tm mark ip_ecn (port) (green) (yellow)" 1240 " (red)\n" 1241 " Enables/Disables the traffic management marking" 1242 " for IP ECN (Explicit Congestion Notification)" 1243 " packets on a given port\n\n" 1244 1245 "set port tm mark ip_dscp (port) (green) (yellow)" 1246 " (red)\n" 1247 " Enables/Disables the traffic management marking" 1248 " on the port for IP dscp packets\n\n" 1249 1250 "set port tm mark vlan_dei (port) (green) (yellow)" 1251 " (red)\n" 1252 " Enables/Disables the traffic management marking" 1253 " on the port for VLAN packets with DEI enabled\n\n" 1254 ); 1255 } 1256 1257 if (show_all || !strcmp(res->section, "devices")) { 1258 cmdline_printf( 1259 cl, 1260 "\n" 1261 "Device Operations:\n" 1262 "--------------\n" 1263 "device detach (identifier)\n" 1264 " Detach device by identifier.\n\n" 1265 ); 1266 } 1267 1268 } 1269 1270 cmdline_parse_token_string_t cmd_help_long_help = 1271 TOKEN_STRING_INITIALIZER(struct cmd_help_long_result, help, "help"); 1272 1273 cmdline_parse_token_string_t cmd_help_long_section = 1274 TOKEN_STRING_INITIALIZER(struct cmd_help_long_result, section, 1275 "all#control#display#config#" 1276 "ports#registers#filters#traffic_management#devices"); 1277 1278 cmdline_parse_inst_t cmd_help_long = { 1279 .f = cmd_help_long_parsed, 1280 .data = NULL, 1281 .help_str = "help all|control|display|config|ports|register|" 1282 "filters|traffic_management|devices: " 1283 "Show help", 1284 .tokens = { 1285 (void *)&cmd_help_long_help, 1286 (void *)&cmd_help_long_section, 1287 NULL, 1288 }, 1289 }; 1290 1291 1292 /* *** start/stop/close all ports *** */ 1293 struct cmd_operate_port_result { 1294 cmdline_fixed_string_t keyword; 1295 cmdline_fixed_string_t name; 1296 cmdline_fixed_string_t value; 1297 }; 1298 1299 static void cmd_operate_port_parsed(void *parsed_result, 1300 __attribute__((unused)) struct cmdline *cl, 1301 __attribute__((unused)) void *data) 1302 { 1303 struct cmd_operate_port_result *res = parsed_result; 1304 1305 if (!strcmp(res->name, "start")) 1306 start_port(RTE_PORT_ALL); 1307 else if (!strcmp(res->name, "stop")) 1308 stop_port(RTE_PORT_ALL); 1309 else if (!strcmp(res->name, "close")) 1310 close_port(RTE_PORT_ALL); 1311 else if (!strcmp(res->name, "reset")) 1312 reset_port(RTE_PORT_ALL); 1313 else 1314 printf("Unknown parameter\n"); 1315 } 1316 1317 cmdline_parse_token_string_t cmd_operate_port_all_cmd = 1318 TOKEN_STRING_INITIALIZER(struct cmd_operate_port_result, keyword, 1319 "port"); 1320 cmdline_parse_token_string_t cmd_operate_port_all_port = 1321 TOKEN_STRING_INITIALIZER(struct cmd_operate_port_result, name, 1322 "start#stop#close#reset"); 1323 cmdline_parse_token_string_t cmd_operate_port_all_all = 1324 TOKEN_STRING_INITIALIZER(struct cmd_operate_port_result, value, "all"); 1325 1326 cmdline_parse_inst_t cmd_operate_port = { 1327 .f = cmd_operate_port_parsed, 1328 .data = NULL, 1329 .help_str = "port start|stop|close all: Start/Stop/Close/Reset all ports", 1330 .tokens = { 1331 (void *)&cmd_operate_port_all_cmd, 1332 (void *)&cmd_operate_port_all_port, 1333 (void *)&cmd_operate_port_all_all, 1334 NULL, 1335 }, 1336 }; 1337 1338 /* *** start/stop/close specific port *** */ 1339 struct cmd_operate_specific_port_result { 1340 cmdline_fixed_string_t keyword; 1341 cmdline_fixed_string_t name; 1342 uint8_t value; 1343 }; 1344 1345 static void cmd_operate_specific_port_parsed(void *parsed_result, 1346 __attribute__((unused)) struct cmdline *cl, 1347 __attribute__((unused)) void *data) 1348 { 1349 struct cmd_operate_specific_port_result *res = parsed_result; 1350 1351 if (!strcmp(res->name, "start")) 1352 start_port(res->value); 1353 else if (!strcmp(res->name, "stop")) 1354 stop_port(res->value); 1355 else if (!strcmp(res->name, "close")) 1356 close_port(res->value); 1357 else if (!strcmp(res->name, "reset")) 1358 reset_port(res->value); 1359 else 1360 printf("Unknown parameter\n"); 1361 } 1362 1363 cmdline_parse_token_string_t cmd_operate_specific_port_cmd = 1364 TOKEN_STRING_INITIALIZER(struct cmd_operate_specific_port_result, 1365 keyword, "port"); 1366 cmdline_parse_token_string_t cmd_operate_specific_port_port = 1367 TOKEN_STRING_INITIALIZER(struct cmd_operate_specific_port_result, 1368 name, "start#stop#close#reset"); 1369 cmdline_parse_token_num_t cmd_operate_specific_port_id = 1370 TOKEN_NUM_INITIALIZER(struct cmd_operate_specific_port_result, 1371 value, UINT8); 1372 1373 cmdline_parse_inst_t cmd_operate_specific_port = { 1374 .f = cmd_operate_specific_port_parsed, 1375 .data = NULL, 1376 .help_str = "port start|stop|close <port_id>: Start/Stop/Close/Reset port_id", 1377 .tokens = { 1378 (void *)&cmd_operate_specific_port_cmd, 1379 (void *)&cmd_operate_specific_port_port, 1380 (void *)&cmd_operate_specific_port_id, 1381 NULL, 1382 }, 1383 }; 1384 1385 /* *** enable port setup (after attach) via iterator or event *** */ 1386 struct cmd_set_port_setup_on_result { 1387 cmdline_fixed_string_t set; 1388 cmdline_fixed_string_t port; 1389 cmdline_fixed_string_t setup; 1390 cmdline_fixed_string_t on; 1391 cmdline_fixed_string_t mode; 1392 }; 1393 1394 static void cmd_set_port_setup_on_parsed(void *parsed_result, 1395 __attribute__((unused)) struct cmdline *cl, 1396 __attribute__((unused)) void *data) 1397 { 1398 struct cmd_set_port_setup_on_result *res = parsed_result; 1399 1400 if (strcmp(res->mode, "event") == 0) 1401 setup_on_probe_event = true; 1402 else if (strcmp(res->mode, "iterator") == 0) 1403 setup_on_probe_event = false; 1404 else 1405 printf("Unknown mode\n"); 1406 } 1407 1408 cmdline_parse_token_string_t cmd_set_port_setup_on_set = 1409 TOKEN_STRING_INITIALIZER(struct cmd_set_port_setup_on_result, 1410 set, "set"); 1411 cmdline_parse_token_string_t cmd_set_port_setup_on_port = 1412 TOKEN_STRING_INITIALIZER(struct cmd_set_port_setup_on_result, 1413 port, "port"); 1414 cmdline_parse_token_string_t cmd_set_port_setup_on_setup = 1415 TOKEN_STRING_INITIALIZER(struct cmd_set_port_setup_on_result, 1416 setup, "setup"); 1417 cmdline_parse_token_string_t cmd_set_port_setup_on_on = 1418 TOKEN_STRING_INITIALIZER(struct cmd_set_port_setup_on_result, 1419 on, "on"); 1420 cmdline_parse_token_string_t cmd_set_port_setup_on_mode = 1421 TOKEN_STRING_INITIALIZER(struct cmd_set_port_setup_on_result, 1422 mode, "iterator#event"); 1423 1424 cmdline_parse_inst_t cmd_set_port_setup_on = { 1425 .f = cmd_set_port_setup_on_parsed, 1426 .data = NULL, 1427 .help_str = "set port setup on iterator|event", 1428 .tokens = { 1429 (void *)&cmd_set_port_setup_on_set, 1430 (void *)&cmd_set_port_setup_on_port, 1431 (void *)&cmd_set_port_setup_on_setup, 1432 (void *)&cmd_set_port_setup_on_on, 1433 (void *)&cmd_set_port_setup_on_mode, 1434 NULL, 1435 }, 1436 }; 1437 1438 /* *** attach a specified port *** */ 1439 struct cmd_operate_attach_port_result { 1440 cmdline_fixed_string_t port; 1441 cmdline_fixed_string_t keyword; 1442 cmdline_fixed_string_t identifier; 1443 }; 1444 1445 static void cmd_operate_attach_port_parsed(void *parsed_result, 1446 __attribute__((unused)) struct cmdline *cl, 1447 __attribute__((unused)) void *data) 1448 { 1449 struct cmd_operate_attach_port_result *res = parsed_result; 1450 1451 if (!strcmp(res->keyword, "attach")) 1452 attach_port(res->identifier); 1453 else 1454 printf("Unknown parameter\n"); 1455 } 1456 1457 cmdline_parse_token_string_t cmd_operate_attach_port_port = 1458 TOKEN_STRING_INITIALIZER(struct cmd_operate_attach_port_result, 1459 port, "port"); 1460 cmdline_parse_token_string_t cmd_operate_attach_port_keyword = 1461 TOKEN_STRING_INITIALIZER(struct cmd_operate_attach_port_result, 1462 keyword, "attach"); 1463 cmdline_parse_token_string_t cmd_operate_attach_port_identifier = 1464 TOKEN_STRING_INITIALIZER(struct cmd_operate_attach_port_result, 1465 identifier, NULL); 1466 1467 cmdline_parse_inst_t cmd_operate_attach_port = { 1468 .f = cmd_operate_attach_port_parsed, 1469 .data = NULL, 1470 .help_str = "port attach <identifier>: " 1471 "(identifier: pci address or virtual dev name)", 1472 .tokens = { 1473 (void *)&cmd_operate_attach_port_port, 1474 (void *)&cmd_operate_attach_port_keyword, 1475 (void *)&cmd_operate_attach_port_identifier, 1476 NULL, 1477 }, 1478 }; 1479 1480 /* *** detach a specified port *** */ 1481 struct cmd_operate_detach_port_result { 1482 cmdline_fixed_string_t port; 1483 cmdline_fixed_string_t keyword; 1484 portid_t port_id; 1485 }; 1486 1487 static void cmd_operate_detach_port_parsed(void *parsed_result, 1488 __attribute__((unused)) struct cmdline *cl, 1489 __attribute__((unused)) void *data) 1490 { 1491 struct cmd_operate_detach_port_result *res = parsed_result; 1492 1493 if (!strcmp(res->keyword, "detach")) 1494 detach_port_device(res->port_id); 1495 else 1496 printf("Unknown parameter\n"); 1497 } 1498 1499 cmdline_parse_token_string_t cmd_operate_detach_port_port = 1500 TOKEN_STRING_INITIALIZER(struct cmd_operate_detach_port_result, 1501 port, "port"); 1502 cmdline_parse_token_string_t cmd_operate_detach_port_keyword = 1503 TOKEN_STRING_INITIALIZER(struct cmd_operate_detach_port_result, 1504 keyword, "detach"); 1505 cmdline_parse_token_num_t cmd_operate_detach_port_port_id = 1506 TOKEN_NUM_INITIALIZER(struct cmd_operate_detach_port_result, 1507 port_id, UINT16); 1508 1509 cmdline_parse_inst_t cmd_operate_detach_port = { 1510 .f = cmd_operate_detach_port_parsed, 1511 .data = NULL, 1512 .help_str = "port detach <port_id>", 1513 .tokens = { 1514 (void *)&cmd_operate_detach_port_port, 1515 (void *)&cmd_operate_detach_port_keyword, 1516 (void *)&cmd_operate_detach_port_port_id, 1517 NULL, 1518 }, 1519 }; 1520 1521 /* *** detach device by identifier *** */ 1522 struct cmd_operate_detach_device_result { 1523 cmdline_fixed_string_t device; 1524 cmdline_fixed_string_t keyword; 1525 cmdline_fixed_string_t identifier; 1526 }; 1527 1528 static void cmd_operate_detach_device_parsed(void *parsed_result, 1529 __attribute__((unused)) struct cmdline *cl, 1530 __attribute__((unused)) void *data) 1531 { 1532 struct cmd_operate_detach_device_result *res = parsed_result; 1533 1534 if (!strcmp(res->keyword, "detach")) 1535 detach_device(res->identifier); 1536 else 1537 printf("Unknown parameter\n"); 1538 } 1539 1540 cmdline_parse_token_string_t cmd_operate_detach_device_device = 1541 TOKEN_STRING_INITIALIZER(struct cmd_operate_detach_device_result, 1542 device, "device"); 1543 cmdline_parse_token_string_t cmd_operate_detach_device_keyword = 1544 TOKEN_STRING_INITIALIZER(struct cmd_operate_detach_device_result, 1545 keyword, "detach"); 1546 cmdline_parse_token_string_t cmd_operate_detach_device_identifier = 1547 TOKEN_STRING_INITIALIZER(struct cmd_operate_detach_device_result, 1548 identifier, NULL); 1549 1550 cmdline_parse_inst_t cmd_operate_detach_device = { 1551 .f = cmd_operate_detach_device_parsed, 1552 .data = NULL, 1553 .help_str = "device detach <identifier>:" 1554 "(identifier: pci address or virtual dev name)", 1555 .tokens = { 1556 (void *)&cmd_operate_detach_device_device, 1557 (void *)&cmd_operate_detach_device_keyword, 1558 (void *)&cmd_operate_detach_device_identifier, 1559 NULL, 1560 }, 1561 }; 1562 /* *** configure speed for all ports *** */ 1563 struct cmd_config_speed_all { 1564 cmdline_fixed_string_t port; 1565 cmdline_fixed_string_t keyword; 1566 cmdline_fixed_string_t all; 1567 cmdline_fixed_string_t item1; 1568 cmdline_fixed_string_t item2; 1569 cmdline_fixed_string_t value1; 1570 cmdline_fixed_string_t value2; 1571 }; 1572 1573 static int 1574 parse_and_check_speed_duplex(char *speedstr, char *duplexstr, uint32_t *speed) 1575 { 1576 1577 int duplex; 1578 1579 if (!strcmp(duplexstr, "half")) { 1580 duplex = ETH_LINK_HALF_DUPLEX; 1581 } else if (!strcmp(duplexstr, "full")) { 1582 duplex = ETH_LINK_FULL_DUPLEX; 1583 } else if (!strcmp(duplexstr, "auto")) { 1584 duplex = ETH_LINK_FULL_DUPLEX; 1585 } else { 1586 printf("Unknown duplex parameter\n"); 1587 return -1; 1588 } 1589 1590 if (!strcmp(speedstr, "10")) { 1591 *speed = (duplex == ETH_LINK_HALF_DUPLEX) ? 1592 ETH_LINK_SPEED_10M_HD : ETH_LINK_SPEED_10M; 1593 } else if (!strcmp(speedstr, "100")) { 1594 *speed = (duplex == ETH_LINK_HALF_DUPLEX) ? 1595 ETH_LINK_SPEED_100M_HD : ETH_LINK_SPEED_100M; 1596 } else { 1597 if (duplex != ETH_LINK_FULL_DUPLEX) { 1598 printf("Invalid speed/duplex parameters\n"); 1599 return -1; 1600 } 1601 if (!strcmp(speedstr, "1000")) { 1602 *speed = ETH_LINK_SPEED_1G; 1603 } else if (!strcmp(speedstr, "10000")) { 1604 *speed = ETH_LINK_SPEED_10G; 1605 } else if (!strcmp(speedstr, "25000")) { 1606 *speed = ETH_LINK_SPEED_25G; 1607 } else if (!strcmp(speedstr, "40000")) { 1608 *speed = ETH_LINK_SPEED_40G; 1609 } else if (!strcmp(speedstr, "50000")) { 1610 *speed = ETH_LINK_SPEED_50G; 1611 } else if (!strcmp(speedstr, "100000")) { 1612 *speed = ETH_LINK_SPEED_100G; 1613 } else if (!strcmp(speedstr, "auto")) { 1614 *speed = ETH_LINK_SPEED_AUTONEG; 1615 } else { 1616 printf("Unknown speed parameter\n"); 1617 return -1; 1618 } 1619 } 1620 1621 return 0; 1622 } 1623 1624 static void 1625 cmd_config_speed_all_parsed(void *parsed_result, 1626 __attribute__((unused)) struct cmdline *cl, 1627 __attribute__((unused)) void *data) 1628 { 1629 struct cmd_config_speed_all *res = parsed_result; 1630 uint32_t link_speed; 1631 portid_t pid; 1632 1633 if (!all_ports_stopped()) { 1634 printf("Please stop all ports first\n"); 1635 return; 1636 } 1637 1638 if (parse_and_check_speed_duplex(res->value1, res->value2, 1639 &link_speed) < 0) 1640 return; 1641 1642 RTE_ETH_FOREACH_DEV(pid) { 1643 ports[pid].dev_conf.link_speeds = link_speed; 1644 } 1645 1646 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1); 1647 } 1648 1649 cmdline_parse_token_string_t cmd_config_speed_all_port = 1650 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_all, port, "port"); 1651 cmdline_parse_token_string_t cmd_config_speed_all_keyword = 1652 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_all, keyword, 1653 "config"); 1654 cmdline_parse_token_string_t cmd_config_speed_all_all = 1655 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_all, all, "all"); 1656 cmdline_parse_token_string_t cmd_config_speed_all_item1 = 1657 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_all, item1, "speed"); 1658 cmdline_parse_token_string_t cmd_config_speed_all_value1 = 1659 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_all, value1, 1660 "10#100#1000#10000#25000#40000#50000#100000#auto"); 1661 cmdline_parse_token_string_t cmd_config_speed_all_item2 = 1662 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_all, item2, "duplex"); 1663 cmdline_parse_token_string_t cmd_config_speed_all_value2 = 1664 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_all, value2, 1665 "half#full#auto"); 1666 1667 cmdline_parse_inst_t cmd_config_speed_all = { 1668 .f = cmd_config_speed_all_parsed, 1669 .data = NULL, 1670 .help_str = "port config all speed " 1671 "10|100|1000|10000|25000|40000|50000|100000|auto duplex " 1672 "half|full|auto", 1673 .tokens = { 1674 (void *)&cmd_config_speed_all_port, 1675 (void *)&cmd_config_speed_all_keyword, 1676 (void *)&cmd_config_speed_all_all, 1677 (void *)&cmd_config_speed_all_item1, 1678 (void *)&cmd_config_speed_all_value1, 1679 (void *)&cmd_config_speed_all_item2, 1680 (void *)&cmd_config_speed_all_value2, 1681 NULL, 1682 }, 1683 }; 1684 1685 /* *** configure speed for specific port *** */ 1686 struct cmd_config_speed_specific { 1687 cmdline_fixed_string_t port; 1688 cmdline_fixed_string_t keyword; 1689 portid_t id; 1690 cmdline_fixed_string_t item1; 1691 cmdline_fixed_string_t item2; 1692 cmdline_fixed_string_t value1; 1693 cmdline_fixed_string_t value2; 1694 }; 1695 1696 static void 1697 cmd_config_speed_specific_parsed(void *parsed_result, 1698 __attribute__((unused)) struct cmdline *cl, 1699 __attribute__((unused)) void *data) 1700 { 1701 struct cmd_config_speed_specific *res = parsed_result; 1702 uint32_t link_speed; 1703 1704 if (!all_ports_stopped()) { 1705 printf("Please stop all ports first\n"); 1706 return; 1707 } 1708 1709 if (port_id_is_invalid(res->id, ENABLED_WARN)) 1710 return; 1711 1712 if (parse_and_check_speed_duplex(res->value1, res->value2, 1713 &link_speed) < 0) 1714 return; 1715 1716 ports[res->id].dev_conf.link_speeds = link_speed; 1717 1718 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1); 1719 } 1720 1721 1722 cmdline_parse_token_string_t cmd_config_speed_specific_port = 1723 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_specific, port, 1724 "port"); 1725 cmdline_parse_token_string_t cmd_config_speed_specific_keyword = 1726 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_specific, keyword, 1727 "config"); 1728 cmdline_parse_token_num_t cmd_config_speed_specific_id = 1729 TOKEN_NUM_INITIALIZER(struct cmd_config_speed_specific, id, UINT16); 1730 cmdline_parse_token_string_t cmd_config_speed_specific_item1 = 1731 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_specific, item1, 1732 "speed"); 1733 cmdline_parse_token_string_t cmd_config_speed_specific_value1 = 1734 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_specific, value1, 1735 "10#100#1000#10000#25000#40000#50000#100000#auto"); 1736 cmdline_parse_token_string_t cmd_config_speed_specific_item2 = 1737 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_specific, item2, 1738 "duplex"); 1739 cmdline_parse_token_string_t cmd_config_speed_specific_value2 = 1740 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_specific, value2, 1741 "half#full#auto"); 1742 1743 cmdline_parse_inst_t cmd_config_speed_specific = { 1744 .f = cmd_config_speed_specific_parsed, 1745 .data = NULL, 1746 .help_str = "port config <port_id> speed " 1747 "10|100|1000|10000|25000|40000|50000|100000|auto duplex " 1748 "half|full|auto", 1749 .tokens = { 1750 (void *)&cmd_config_speed_specific_port, 1751 (void *)&cmd_config_speed_specific_keyword, 1752 (void *)&cmd_config_speed_specific_id, 1753 (void *)&cmd_config_speed_specific_item1, 1754 (void *)&cmd_config_speed_specific_value1, 1755 (void *)&cmd_config_speed_specific_item2, 1756 (void *)&cmd_config_speed_specific_value2, 1757 NULL, 1758 }, 1759 }; 1760 1761 /* *** configure loopback for all ports *** */ 1762 struct cmd_config_loopback_all { 1763 cmdline_fixed_string_t port; 1764 cmdline_fixed_string_t keyword; 1765 cmdline_fixed_string_t all; 1766 cmdline_fixed_string_t item; 1767 uint32_t mode; 1768 }; 1769 1770 static void 1771 cmd_config_loopback_all_parsed(void *parsed_result, 1772 __attribute__((unused)) struct cmdline *cl, 1773 __attribute__((unused)) void *data) 1774 { 1775 struct cmd_config_loopback_all *res = parsed_result; 1776 portid_t pid; 1777 1778 if (!all_ports_stopped()) { 1779 printf("Please stop all ports first\n"); 1780 return; 1781 } 1782 1783 RTE_ETH_FOREACH_DEV(pid) { 1784 ports[pid].dev_conf.lpbk_mode = res->mode; 1785 } 1786 1787 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1); 1788 } 1789 1790 cmdline_parse_token_string_t cmd_config_loopback_all_port = 1791 TOKEN_STRING_INITIALIZER(struct cmd_config_loopback_all, port, "port"); 1792 cmdline_parse_token_string_t cmd_config_loopback_all_keyword = 1793 TOKEN_STRING_INITIALIZER(struct cmd_config_loopback_all, keyword, 1794 "config"); 1795 cmdline_parse_token_string_t cmd_config_loopback_all_all = 1796 TOKEN_STRING_INITIALIZER(struct cmd_config_loopback_all, all, "all"); 1797 cmdline_parse_token_string_t cmd_config_loopback_all_item = 1798 TOKEN_STRING_INITIALIZER(struct cmd_config_loopback_all, item, 1799 "loopback"); 1800 cmdline_parse_token_num_t cmd_config_loopback_all_mode = 1801 TOKEN_NUM_INITIALIZER(struct cmd_config_loopback_all, mode, UINT32); 1802 1803 cmdline_parse_inst_t cmd_config_loopback_all = { 1804 .f = cmd_config_loopback_all_parsed, 1805 .data = NULL, 1806 .help_str = "port config all loopback <mode>", 1807 .tokens = { 1808 (void *)&cmd_config_loopback_all_port, 1809 (void *)&cmd_config_loopback_all_keyword, 1810 (void *)&cmd_config_loopback_all_all, 1811 (void *)&cmd_config_loopback_all_item, 1812 (void *)&cmd_config_loopback_all_mode, 1813 NULL, 1814 }, 1815 }; 1816 1817 /* *** configure loopback for specific port *** */ 1818 struct cmd_config_loopback_specific { 1819 cmdline_fixed_string_t port; 1820 cmdline_fixed_string_t keyword; 1821 uint16_t port_id; 1822 cmdline_fixed_string_t item; 1823 uint32_t mode; 1824 }; 1825 1826 static void 1827 cmd_config_loopback_specific_parsed(void *parsed_result, 1828 __attribute__((unused)) struct cmdline *cl, 1829 __attribute__((unused)) void *data) 1830 { 1831 struct cmd_config_loopback_specific *res = parsed_result; 1832 1833 if (port_id_is_invalid(res->port_id, ENABLED_WARN)) 1834 return; 1835 1836 if (!port_is_stopped(res->port_id)) { 1837 printf("Please stop port %u first\n", res->port_id); 1838 return; 1839 } 1840 1841 ports[res->port_id].dev_conf.lpbk_mode = res->mode; 1842 1843 cmd_reconfig_device_queue(res->port_id, 1, 1); 1844 } 1845 1846 1847 cmdline_parse_token_string_t cmd_config_loopback_specific_port = 1848 TOKEN_STRING_INITIALIZER(struct cmd_config_loopback_specific, port, 1849 "port"); 1850 cmdline_parse_token_string_t cmd_config_loopback_specific_keyword = 1851 TOKEN_STRING_INITIALIZER(struct cmd_config_loopback_specific, keyword, 1852 "config"); 1853 cmdline_parse_token_num_t cmd_config_loopback_specific_id = 1854 TOKEN_NUM_INITIALIZER(struct cmd_config_loopback_specific, port_id, 1855 UINT16); 1856 cmdline_parse_token_string_t cmd_config_loopback_specific_item = 1857 TOKEN_STRING_INITIALIZER(struct cmd_config_loopback_specific, item, 1858 "loopback"); 1859 cmdline_parse_token_num_t cmd_config_loopback_specific_mode = 1860 TOKEN_NUM_INITIALIZER(struct cmd_config_loopback_specific, mode, 1861 UINT32); 1862 1863 cmdline_parse_inst_t cmd_config_loopback_specific = { 1864 .f = cmd_config_loopback_specific_parsed, 1865 .data = NULL, 1866 .help_str = "port config <port_id> loopback <mode>", 1867 .tokens = { 1868 (void *)&cmd_config_loopback_specific_port, 1869 (void *)&cmd_config_loopback_specific_keyword, 1870 (void *)&cmd_config_loopback_specific_id, 1871 (void *)&cmd_config_loopback_specific_item, 1872 (void *)&cmd_config_loopback_specific_mode, 1873 NULL, 1874 }, 1875 }; 1876 1877 /* *** configure txq/rxq, txd/rxd *** */ 1878 struct cmd_config_rx_tx { 1879 cmdline_fixed_string_t port; 1880 cmdline_fixed_string_t keyword; 1881 cmdline_fixed_string_t all; 1882 cmdline_fixed_string_t name; 1883 uint16_t value; 1884 }; 1885 1886 static void 1887 cmd_config_rx_tx_parsed(void *parsed_result, 1888 __attribute__((unused)) struct cmdline *cl, 1889 __attribute__((unused)) void *data) 1890 { 1891 struct cmd_config_rx_tx *res = parsed_result; 1892 1893 if (!all_ports_stopped()) { 1894 printf("Please stop all ports first\n"); 1895 return; 1896 } 1897 if (!strcmp(res->name, "rxq")) { 1898 if (!res->value && !nb_txq) { 1899 printf("Warning: Either rx or tx queues should be non zero\n"); 1900 return; 1901 } 1902 if (check_nb_rxq(res->value) != 0) 1903 return; 1904 nb_rxq = res->value; 1905 } 1906 else if (!strcmp(res->name, "txq")) { 1907 if (!res->value && !nb_rxq) { 1908 printf("Warning: Either rx or tx queues should be non zero\n"); 1909 return; 1910 } 1911 if (check_nb_txq(res->value) != 0) 1912 return; 1913 nb_txq = res->value; 1914 } 1915 else if (!strcmp(res->name, "rxd")) { 1916 if (res->value <= 0 || res->value > RTE_TEST_RX_DESC_MAX) { 1917 printf("rxd %d invalid - must be > 0 && <= %d\n", 1918 res->value, RTE_TEST_RX_DESC_MAX); 1919 return; 1920 } 1921 nb_rxd = res->value; 1922 } else if (!strcmp(res->name, "txd")) { 1923 if (res->value <= 0 || res->value > RTE_TEST_TX_DESC_MAX) { 1924 printf("txd %d invalid - must be > 0 && <= %d\n", 1925 res->value, RTE_TEST_TX_DESC_MAX); 1926 return; 1927 } 1928 nb_txd = res->value; 1929 } else { 1930 printf("Unknown parameter\n"); 1931 return; 1932 } 1933 1934 fwd_config_setup(); 1935 1936 init_port_config(); 1937 1938 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1); 1939 } 1940 1941 cmdline_parse_token_string_t cmd_config_rx_tx_port = 1942 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_tx, port, "port"); 1943 cmdline_parse_token_string_t cmd_config_rx_tx_keyword = 1944 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_tx, keyword, "config"); 1945 cmdline_parse_token_string_t cmd_config_rx_tx_all = 1946 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_tx, all, "all"); 1947 cmdline_parse_token_string_t cmd_config_rx_tx_name = 1948 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_tx, name, 1949 "rxq#txq#rxd#txd"); 1950 cmdline_parse_token_num_t cmd_config_rx_tx_value = 1951 TOKEN_NUM_INITIALIZER(struct cmd_config_rx_tx, value, UINT16); 1952 1953 cmdline_parse_inst_t cmd_config_rx_tx = { 1954 .f = cmd_config_rx_tx_parsed, 1955 .data = NULL, 1956 .help_str = "port config all rxq|txq|rxd|txd <value>", 1957 .tokens = { 1958 (void *)&cmd_config_rx_tx_port, 1959 (void *)&cmd_config_rx_tx_keyword, 1960 (void *)&cmd_config_rx_tx_all, 1961 (void *)&cmd_config_rx_tx_name, 1962 (void *)&cmd_config_rx_tx_value, 1963 NULL, 1964 }, 1965 }; 1966 1967 /* *** config max packet length *** */ 1968 struct cmd_config_max_pkt_len_result { 1969 cmdline_fixed_string_t port; 1970 cmdline_fixed_string_t keyword; 1971 cmdline_fixed_string_t all; 1972 cmdline_fixed_string_t name; 1973 uint32_t value; 1974 }; 1975 1976 static void 1977 cmd_config_max_pkt_len_parsed(void *parsed_result, 1978 __attribute__((unused)) struct cmdline *cl, 1979 __attribute__((unused)) void *data) 1980 { 1981 struct cmd_config_max_pkt_len_result *res = parsed_result; 1982 portid_t pid; 1983 1984 if (!all_ports_stopped()) { 1985 printf("Please stop all ports first\n"); 1986 return; 1987 } 1988 1989 RTE_ETH_FOREACH_DEV(pid) { 1990 struct rte_port *port = &ports[pid]; 1991 uint64_t rx_offloads = port->dev_conf.rxmode.offloads; 1992 1993 if (!strcmp(res->name, "max-pkt-len")) { 1994 if (res->value < RTE_ETHER_MIN_LEN) { 1995 printf("max-pkt-len can not be less than %d\n", 1996 RTE_ETHER_MIN_LEN); 1997 return; 1998 } 1999 if (res->value == port->dev_conf.rxmode.max_rx_pkt_len) 2000 return; 2001 2002 port->dev_conf.rxmode.max_rx_pkt_len = res->value; 2003 if (res->value > RTE_ETHER_MAX_LEN) 2004 rx_offloads |= DEV_RX_OFFLOAD_JUMBO_FRAME; 2005 else 2006 rx_offloads &= ~DEV_RX_OFFLOAD_JUMBO_FRAME; 2007 port->dev_conf.rxmode.offloads = rx_offloads; 2008 } else { 2009 printf("Unknown parameter\n"); 2010 return; 2011 } 2012 } 2013 2014 init_port_config(); 2015 2016 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1); 2017 } 2018 2019 cmdline_parse_token_string_t cmd_config_max_pkt_len_port = 2020 TOKEN_STRING_INITIALIZER(struct cmd_config_max_pkt_len_result, port, 2021 "port"); 2022 cmdline_parse_token_string_t cmd_config_max_pkt_len_keyword = 2023 TOKEN_STRING_INITIALIZER(struct cmd_config_max_pkt_len_result, keyword, 2024 "config"); 2025 cmdline_parse_token_string_t cmd_config_max_pkt_len_all = 2026 TOKEN_STRING_INITIALIZER(struct cmd_config_max_pkt_len_result, all, 2027 "all"); 2028 cmdline_parse_token_string_t cmd_config_max_pkt_len_name = 2029 TOKEN_STRING_INITIALIZER(struct cmd_config_max_pkt_len_result, name, 2030 "max-pkt-len"); 2031 cmdline_parse_token_num_t cmd_config_max_pkt_len_value = 2032 TOKEN_NUM_INITIALIZER(struct cmd_config_max_pkt_len_result, value, 2033 UINT32); 2034 2035 cmdline_parse_inst_t cmd_config_max_pkt_len = { 2036 .f = cmd_config_max_pkt_len_parsed, 2037 .data = NULL, 2038 .help_str = "port config all max-pkt-len <value>", 2039 .tokens = { 2040 (void *)&cmd_config_max_pkt_len_port, 2041 (void *)&cmd_config_max_pkt_len_keyword, 2042 (void *)&cmd_config_max_pkt_len_all, 2043 (void *)&cmd_config_max_pkt_len_name, 2044 (void *)&cmd_config_max_pkt_len_value, 2045 NULL, 2046 }, 2047 }; 2048 2049 /* *** config max LRO aggregated packet size *** */ 2050 struct cmd_config_max_lro_pkt_size_result { 2051 cmdline_fixed_string_t port; 2052 cmdline_fixed_string_t keyword; 2053 cmdline_fixed_string_t all; 2054 cmdline_fixed_string_t name; 2055 uint32_t value; 2056 }; 2057 2058 static void 2059 cmd_config_max_lro_pkt_size_parsed(void *parsed_result, 2060 __attribute__((unused)) struct cmdline *cl, 2061 __attribute__((unused)) void *data) 2062 { 2063 struct cmd_config_max_lro_pkt_size_result *res = parsed_result; 2064 portid_t pid; 2065 2066 if (!all_ports_stopped()) { 2067 printf("Please stop all ports first\n"); 2068 return; 2069 } 2070 2071 RTE_ETH_FOREACH_DEV(pid) { 2072 struct rte_port *port = &ports[pid]; 2073 2074 if (!strcmp(res->name, "max-lro-pkt-size")) { 2075 if (res->value == 2076 port->dev_conf.rxmode.max_lro_pkt_size) 2077 return; 2078 2079 port->dev_conf.rxmode.max_lro_pkt_size = res->value; 2080 } else { 2081 printf("Unknown parameter\n"); 2082 return; 2083 } 2084 } 2085 2086 init_port_config(); 2087 2088 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1); 2089 } 2090 2091 cmdline_parse_token_string_t cmd_config_max_lro_pkt_size_port = 2092 TOKEN_STRING_INITIALIZER(struct cmd_config_max_lro_pkt_size_result, 2093 port, "port"); 2094 cmdline_parse_token_string_t cmd_config_max_lro_pkt_size_keyword = 2095 TOKEN_STRING_INITIALIZER(struct cmd_config_max_lro_pkt_size_result, 2096 keyword, "config"); 2097 cmdline_parse_token_string_t cmd_config_max_lro_pkt_size_all = 2098 TOKEN_STRING_INITIALIZER(struct cmd_config_max_lro_pkt_size_result, 2099 all, "all"); 2100 cmdline_parse_token_string_t cmd_config_max_lro_pkt_size_name = 2101 TOKEN_STRING_INITIALIZER(struct cmd_config_max_lro_pkt_size_result, 2102 name, "max-lro-pkt-size"); 2103 cmdline_parse_token_num_t cmd_config_max_lro_pkt_size_value = 2104 TOKEN_NUM_INITIALIZER(struct cmd_config_max_lro_pkt_size_result, 2105 value, UINT32); 2106 2107 cmdline_parse_inst_t cmd_config_max_lro_pkt_size = { 2108 .f = cmd_config_max_lro_pkt_size_parsed, 2109 .data = NULL, 2110 .help_str = "port config all max-lro-pkt-size <value>", 2111 .tokens = { 2112 (void *)&cmd_config_max_lro_pkt_size_port, 2113 (void *)&cmd_config_max_lro_pkt_size_keyword, 2114 (void *)&cmd_config_max_lro_pkt_size_all, 2115 (void *)&cmd_config_max_lro_pkt_size_name, 2116 (void *)&cmd_config_max_lro_pkt_size_value, 2117 NULL, 2118 }, 2119 }; 2120 2121 /* *** configure port MTU *** */ 2122 struct cmd_config_mtu_result { 2123 cmdline_fixed_string_t port; 2124 cmdline_fixed_string_t keyword; 2125 cmdline_fixed_string_t mtu; 2126 portid_t port_id; 2127 uint16_t value; 2128 }; 2129 2130 static void 2131 cmd_config_mtu_parsed(void *parsed_result, 2132 __attribute__((unused)) struct cmdline *cl, 2133 __attribute__((unused)) void *data) 2134 { 2135 struct cmd_config_mtu_result *res = parsed_result; 2136 2137 if (res->value < RTE_ETHER_MIN_LEN) { 2138 printf("mtu cannot be less than %d\n", RTE_ETHER_MIN_LEN); 2139 return; 2140 } 2141 port_mtu_set(res->port_id, res->value); 2142 } 2143 2144 cmdline_parse_token_string_t cmd_config_mtu_port = 2145 TOKEN_STRING_INITIALIZER(struct cmd_config_mtu_result, port, 2146 "port"); 2147 cmdline_parse_token_string_t cmd_config_mtu_keyword = 2148 TOKEN_STRING_INITIALIZER(struct cmd_config_mtu_result, keyword, 2149 "config"); 2150 cmdline_parse_token_string_t cmd_config_mtu_mtu = 2151 TOKEN_STRING_INITIALIZER(struct cmd_config_mtu_result, keyword, 2152 "mtu"); 2153 cmdline_parse_token_num_t cmd_config_mtu_port_id = 2154 TOKEN_NUM_INITIALIZER(struct cmd_config_mtu_result, port_id, UINT16); 2155 cmdline_parse_token_num_t cmd_config_mtu_value = 2156 TOKEN_NUM_INITIALIZER(struct cmd_config_mtu_result, value, UINT16); 2157 2158 cmdline_parse_inst_t cmd_config_mtu = { 2159 .f = cmd_config_mtu_parsed, 2160 .data = NULL, 2161 .help_str = "port config mtu <port_id> <value>", 2162 .tokens = { 2163 (void *)&cmd_config_mtu_port, 2164 (void *)&cmd_config_mtu_keyword, 2165 (void *)&cmd_config_mtu_mtu, 2166 (void *)&cmd_config_mtu_port_id, 2167 (void *)&cmd_config_mtu_value, 2168 NULL, 2169 }, 2170 }; 2171 2172 /* *** configure rx mode *** */ 2173 struct cmd_config_rx_mode_flag { 2174 cmdline_fixed_string_t port; 2175 cmdline_fixed_string_t keyword; 2176 cmdline_fixed_string_t all; 2177 cmdline_fixed_string_t name; 2178 cmdline_fixed_string_t value; 2179 }; 2180 2181 static void 2182 cmd_config_rx_mode_flag_parsed(void *parsed_result, 2183 __attribute__((unused)) struct cmdline *cl, 2184 __attribute__((unused)) void *data) 2185 { 2186 struct cmd_config_rx_mode_flag *res = parsed_result; 2187 2188 if (!all_ports_stopped()) { 2189 printf("Please stop all ports first\n"); 2190 return; 2191 } 2192 2193 if (!strcmp(res->name, "drop-en")) { 2194 if (!strcmp(res->value, "on")) 2195 rx_drop_en = 1; 2196 else if (!strcmp(res->value, "off")) 2197 rx_drop_en = 0; 2198 else { 2199 printf("Unknown parameter\n"); 2200 return; 2201 } 2202 } else { 2203 printf("Unknown parameter\n"); 2204 return; 2205 } 2206 2207 init_port_config(); 2208 2209 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1); 2210 } 2211 2212 cmdline_parse_token_string_t cmd_config_rx_mode_flag_port = 2213 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_mode_flag, port, "port"); 2214 cmdline_parse_token_string_t cmd_config_rx_mode_flag_keyword = 2215 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_mode_flag, keyword, 2216 "config"); 2217 cmdline_parse_token_string_t cmd_config_rx_mode_flag_all = 2218 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_mode_flag, all, "all"); 2219 cmdline_parse_token_string_t cmd_config_rx_mode_flag_name = 2220 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_mode_flag, name, 2221 "drop-en"); 2222 cmdline_parse_token_string_t cmd_config_rx_mode_flag_value = 2223 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_mode_flag, value, 2224 "on#off"); 2225 2226 cmdline_parse_inst_t cmd_config_rx_mode_flag = { 2227 .f = cmd_config_rx_mode_flag_parsed, 2228 .data = NULL, 2229 .help_str = "port config all drop-en on|off", 2230 .tokens = { 2231 (void *)&cmd_config_rx_mode_flag_port, 2232 (void *)&cmd_config_rx_mode_flag_keyword, 2233 (void *)&cmd_config_rx_mode_flag_all, 2234 (void *)&cmd_config_rx_mode_flag_name, 2235 (void *)&cmd_config_rx_mode_flag_value, 2236 NULL, 2237 }, 2238 }; 2239 2240 /* *** configure rss *** */ 2241 struct cmd_config_rss { 2242 cmdline_fixed_string_t port; 2243 cmdline_fixed_string_t keyword; 2244 cmdline_fixed_string_t all; 2245 cmdline_fixed_string_t name; 2246 cmdline_fixed_string_t value; 2247 }; 2248 2249 static void 2250 cmd_config_rss_parsed(void *parsed_result, 2251 __attribute__((unused)) struct cmdline *cl, 2252 __attribute__((unused)) void *data) 2253 { 2254 struct cmd_config_rss *res = parsed_result; 2255 struct rte_eth_rss_conf rss_conf = { .rss_key_len = 0, }; 2256 struct rte_eth_dev_info dev_info = { .flow_type_rss_offloads = 0, }; 2257 int use_default = 0; 2258 int all_updated = 1; 2259 int diag; 2260 uint16_t i; 2261 int ret; 2262 2263 if (!strcmp(res->value, "all")) 2264 rss_conf.rss_hf = ETH_RSS_IP | ETH_RSS_TCP | 2265 ETH_RSS_UDP | ETH_RSS_SCTP | 2266 ETH_RSS_L2_PAYLOAD; 2267 else if (!strcmp(res->value, "ip")) 2268 rss_conf.rss_hf = ETH_RSS_IP; 2269 else if (!strcmp(res->value, "udp")) 2270 rss_conf.rss_hf = ETH_RSS_UDP; 2271 else if (!strcmp(res->value, "tcp")) 2272 rss_conf.rss_hf = ETH_RSS_TCP; 2273 else if (!strcmp(res->value, "sctp")) 2274 rss_conf.rss_hf = ETH_RSS_SCTP; 2275 else if (!strcmp(res->value, "ether")) 2276 rss_conf.rss_hf = ETH_RSS_L2_PAYLOAD; 2277 else if (!strcmp(res->value, "port")) 2278 rss_conf.rss_hf = ETH_RSS_PORT; 2279 else if (!strcmp(res->value, "vxlan")) 2280 rss_conf.rss_hf = ETH_RSS_VXLAN; 2281 else if (!strcmp(res->value, "geneve")) 2282 rss_conf.rss_hf = ETH_RSS_GENEVE; 2283 else if (!strcmp(res->value, "nvgre")) 2284 rss_conf.rss_hf = ETH_RSS_NVGRE; 2285 else if (!strcmp(res->value, "l3-src-only")) 2286 rss_conf.rss_hf = ETH_RSS_L3_SRC_ONLY; 2287 else if (!strcmp(res->value, "l3-dst-only")) 2288 rss_conf.rss_hf = ETH_RSS_L3_DST_ONLY; 2289 else if (!strcmp(res->value, "l4-src-only")) 2290 rss_conf.rss_hf = ETH_RSS_L4_SRC_ONLY; 2291 else if (!strcmp(res->value, "l4-dst-only")) 2292 rss_conf.rss_hf = ETH_RSS_L4_DST_ONLY; 2293 else if (!strcmp(res->value, "none")) 2294 rss_conf.rss_hf = 0; 2295 else if (!strcmp(res->value, "default")) 2296 use_default = 1; 2297 else if (isdigit(res->value[0]) && atoi(res->value) > 0 && 2298 atoi(res->value) < 64) 2299 rss_conf.rss_hf = 1ULL << atoi(res->value); 2300 else { 2301 printf("Unknown parameter\n"); 2302 return; 2303 } 2304 rss_conf.rss_key = NULL; 2305 /* Update global configuration for RSS types. */ 2306 RTE_ETH_FOREACH_DEV(i) { 2307 struct rte_eth_rss_conf local_rss_conf; 2308 2309 ret = eth_dev_info_get_print_err(i, &dev_info); 2310 if (ret != 0) 2311 return; 2312 2313 if (use_default) 2314 rss_conf.rss_hf = dev_info.flow_type_rss_offloads; 2315 2316 local_rss_conf = rss_conf; 2317 local_rss_conf.rss_hf = rss_conf.rss_hf & 2318 dev_info.flow_type_rss_offloads; 2319 if (local_rss_conf.rss_hf != rss_conf.rss_hf) { 2320 printf("Port %u modified RSS hash function based on hardware support," 2321 "requested:%#"PRIx64" configured:%#"PRIx64"\n", 2322 i, rss_conf.rss_hf, local_rss_conf.rss_hf); 2323 } 2324 diag = rte_eth_dev_rss_hash_update(i, &local_rss_conf); 2325 if (diag < 0) { 2326 all_updated = 0; 2327 printf("Configuration of RSS hash at ethernet port %d " 2328 "failed with error (%d): %s.\n", 2329 i, -diag, strerror(-diag)); 2330 } 2331 } 2332 if (all_updated && !use_default) 2333 rss_hf = rss_conf.rss_hf; 2334 } 2335 2336 cmdline_parse_token_string_t cmd_config_rss_port = 2337 TOKEN_STRING_INITIALIZER(struct cmd_config_rss, port, "port"); 2338 cmdline_parse_token_string_t cmd_config_rss_keyword = 2339 TOKEN_STRING_INITIALIZER(struct cmd_config_rss, keyword, "config"); 2340 cmdline_parse_token_string_t cmd_config_rss_all = 2341 TOKEN_STRING_INITIALIZER(struct cmd_config_rss, all, "all"); 2342 cmdline_parse_token_string_t cmd_config_rss_name = 2343 TOKEN_STRING_INITIALIZER(struct cmd_config_rss, name, "rss"); 2344 cmdline_parse_token_string_t cmd_config_rss_value = 2345 TOKEN_STRING_INITIALIZER(struct cmd_config_rss, value, NULL); 2346 2347 cmdline_parse_inst_t cmd_config_rss = { 2348 .f = cmd_config_rss_parsed, 2349 .data = NULL, 2350 .help_str = "port config all rss " 2351 "all|default|ip|tcp|udp|sctp|ether|port|vxlan|geneve|nvgre|vxlan-gpe|none|<flowtype_id>", 2352 .tokens = { 2353 (void *)&cmd_config_rss_port, 2354 (void *)&cmd_config_rss_keyword, 2355 (void *)&cmd_config_rss_all, 2356 (void *)&cmd_config_rss_name, 2357 (void *)&cmd_config_rss_value, 2358 NULL, 2359 }, 2360 }; 2361 2362 /* *** configure rss hash key *** */ 2363 struct cmd_config_rss_hash_key { 2364 cmdline_fixed_string_t port; 2365 cmdline_fixed_string_t config; 2366 portid_t port_id; 2367 cmdline_fixed_string_t rss_hash_key; 2368 cmdline_fixed_string_t rss_type; 2369 cmdline_fixed_string_t key; 2370 }; 2371 2372 static uint8_t 2373 hexa_digit_to_value(char hexa_digit) 2374 { 2375 if ((hexa_digit >= '0') && (hexa_digit <= '9')) 2376 return (uint8_t) (hexa_digit - '0'); 2377 if ((hexa_digit >= 'a') && (hexa_digit <= 'f')) 2378 return (uint8_t) ((hexa_digit - 'a') + 10); 2379 if ((hexa_digit >= 'A') && (hexa_digit <= 'F')) 2380 return (uint8_t) ((hexa_digit - 'A') + 10); 2381 /* Invalid hexa digit */ 2382 return 0xFF; 2383 } 2384 2385 static uint8_t 2386 parse_and_check_key_hexa_digit(char *key, int idx) 2387 { 2388 uint8_t hexa_v; 2389 2390 hexa_v = hexa_digit_to_value(key[idx]); 2391 if (hexa_v == 0xFF) 2392 printf("invalid key: character %c at position %d is not a " 2393 "valid hexa digit\n", key[idx], idx); 2394 return hexa_v; 2395 } 2396 2397 static void 2398 cmd_config_rss_hash_key_parsed(void *parsed_result, 2399 __attribute__((unused)) struct cmdline *cl, 2400 __attribute__((unused)) void *data) 2401 { 2402 struct cmd_config_rss_hash_key *res = parsed_result; 2403 uint8_t hash_key[RSS_HASH_KEY_LENGTH]; 2404 uint8_t xdgt0; 2405 uint8_t xdgt1; 2406 int i; 2407 struct rte_eth_dev_info dev_info; 2408 uint8_t hash_key_size; 2409 uint32_t key_len; 2410 int ret; 2411 2412 ret = eth_dev_info_get_print_err(res->port_id, &dev_info); 2413 if (ret != 0) 2414 return; 2415 2416 if (dev_info.hash_key_size > 0 && 2417 dev_info.hash_key_size <= sizeof(hash_key)) 2418 hash_key_size = dev_info.hash_key_size; 2419 else { 2420 printf("dev_info did not provide a valid hash key size\n"); 2421 return; 2422 } 2423 /* Check the length of the RSS hash key */ 2424 key_len = strlen(res->key); 2425 if (key_len != (hash_key_size * 2)) { 2426 printf("key length: %d invalid - key must be a string of %d" 2427 " hexa-decimal numbers\n", 2428 (int) key_len, hash_key_size * 2); 2429 return; 2430 } 2431 /* Translate RSS hash key into binary representation */ 2432 for (i = 0; i < hash_key_size; i++) { 2433 xdgt0 = parse_and_check_key_hexa_digit(res->key, (i * 2)); 2434 if (xdgt0 == 0xFF) 2435 return; 2436 xdgt1 = parse_and_check_key_hexa_digit(res->key, (i * 2) + 1); 2437 if (xdgt1 == 0xFF) 2438 return; 2439 hash_key[i] = (uint8_t) ((xdgt0 * 16) + xdgt1); 2440 } 2441 port_rss_hash_key_update(res->port_id, res->rss_type, hash_key, 2442 hash_key_size); 2443 } 2444 2445 cmdline_parse_token_string_t cmd_config_rss_hash_key_port = 2446 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_hash_key, port, "port"); 2447 cmdline_parse_token_string_t cmd_config_rss_hash_key_config = 2448 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_hash_key, config, 2449 "config"); 2450 cmdline_parse_token_num_t cmd_config_rss_hash_key_port_id = 2451 TOKEN_NUM_INITIALIZER(struct cmd_config_rss_hash_key, port_id, UINT16); 2452 cmdline_parse_token_string_t cmd_config_rss_hash_key_rss_hash_key = 2453 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_hash_key, 2454 rss_hash_key, "rss-hash-key"); 2455 cmdline_parse_token_string_t cmd_config_rss_hash_key_rss_type = 2456 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_hash_key, rss_type, 2457 "ipv4#ipv4-frag#ipv4-tcp#ipv4-udp#ipv4-sctp#" 2458 "ipv4-other#ipv6#ipv6-frag#ipv6-tcp#ipv6-udp#" 2459 "ipv6-sctp#ipv6-other#l2-payload#ipv6-ex#" 2460 "ipv6-tcp-ex#ipv6-udp-ex#" 2461 "l3-src-only#l3-dst-only#l4-src-only#l4-dst-only"); 2462 cmdline_parse_token_string_t cmd_config_rss_hash_key_value = 2463 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_hash_key, key, NULL); 2464 2465 cmdline_parse_inst_t cmd_config_rss_hash_key = { 2466 .f = cmd_config_rss_hash_key_parsed, 2467 .data = NULL, 2468 .help_str = "port config <port_id> rss-hash-key " 2469 "ipv4|ipv4-frag|ipv4-tcp|ipv4-udp|ipv4-sctp|ipv4-other|" 2470 "ipv6|ipv6-frag|ipv6-tcp|ipv6-udp|ipv6-sctp|ipv6-other|" 2471 "l2-payload|ipv6-ex|ipv6-tcp-ex|ipv6-udp-ex|" 2472 "l3-src-only|l3-dst-only|l4-src-only|l4-dst-only " 2473 "<string of hex digits (variable length, NIC dependent)>", 2474 .tokens = { 2475 (void *)&cmd_config_rss_hash_key_port, 2476 (void *)&cmd_config_rss_hash_key_config, 2477 (void *)&cmd_config_rss_hash_key_port_id, 2478 (void *)&cmd_config_rss_hash_key_rss_hash_key, 2479 (void *)&cmd_config_rss_hash_key_rss_type, 2480 (void *)&cmd_config_rss_hash_key_value, 2481 NULL, 2482 }, 2483 }; 2484 2485 /* *** configure port rxq/txq ring size *** */ 2486 struct cmd_config_rxtx_ring_size { 2487 cmdline_fixed_string_t port; 2488 cmdline_fixed_string_t config; 2489 portid_t portid; 2490 cmdline_fixed_string_t rxtxq; 2491 uint16_t qid; 2492 cmdline_fixed_string_t rsize; 2493 uint16_t size; 2494 }; 2495 2496 static void 2497 cmd_config_rxtx_ring_size_parsed(void *parsed_result, 2498 __attribute__((unused)) struct cmdline *cl, 2499 __attribute__((unused)) void *data) 2500 { 2501 struct cmd_config_rxtx_ring_size *res = parsed_result; 2502 struct rte_port *port; 2503 uint8_t isrx; 2504 2505 if (port_id_is_invalid(res->portid, ENABLED_WARN)) 2506 return; 2507 2508 if (res->portid == (portid_t)RTE_PORT_ALL) { 2509 printf("Invalid port id\n"); 2510 return; 2511 } 2512 2513 port = &ports[res->portid]; 2514 2515 if (!strcmp(res->rxtxq, "rxq")) 2516 isrx = 1; 2517 else if (!strcmp(res->rxtxq, "txq")) 2518 isrx = 0; 2519 else { 2520 printf("Unknown parameter\n"); 2521 return; 2522 } 2523 2524 if (isrx && rx_queue_id_is_invalid(res->qid)) 2525 return; 2526 else if (!isrx && tx_queue_id_is_invalid(res->qid)) 2527 return; 2528 2529 if (isrx && res->size != 0 && res->size <= rx_free_thresh) { 2530 printf("Invalid rx ring_size, must > rx_free_thresh: %d\n", 2531 rx_free_thresh); 2532 return; 2533 } 2534 2535 if (isrx) 2536 port->nb_rx_desc[res->qid] = res->size; 2537 else 2538 port->nb_tx_desc[res->qid] = res->size; 2539 2540 cmd_reconfig_device_queue(res->portid, 0, 1); 2541 } 2542 2543 cmdline_parse_token_string_t cmd_config_rxtx_ring_size_port = 2544 TOKEN_STRING_INITIALIZER(struct cmd_config_rxtx_ring_size, 2545 port, "port"); 2546 cmdline_parse_token_string_t cmd_config_rxtx_ring_size_config = 2547 TOKEN_STRING_INITIALIZER(struct cmd_config_rxtx_ring_size, 2548 config, "config"); 2549 cmdline_parse_token_num_t cmd_config_rxtx_ring_size_portid = 2550 TOKEN_NUM_INITIALIZER(struct cmd_config_rxtx_ring_size, 2551 portid, UINT16); 2552 cmdline_parse_token_string_t cmd_config_rxtx_ring_size_rxtxq = 2553 TOKEN_STRING_INITIALIZER(struct cmd_config_rxtx_ring_size, 2554 rxtxq, "rxq#txq"); 2555 cmdline_parse_token_num_t cmd_config_rxtx_ring_size_qid = 2556 TOKEN_NUM_INITIALIZER(struct cmd_config_rxtx_ring_size, 2557 qid, UINT16); 2558 cmdline_parse_token_string_t cmd_config_rxtx_ring_size_rsize = 2559 TOKEN_STRING_INITIALIZER(struct cmd_config_rxtx_ring_size, 2560 rsize, "ring_size"); 2561 cmdline_parse_token_num_t cmd_config_rxtx_ring_size_size = 2562 TOKEN_NUM_INITIALIZER(struct cmd_config_rxtx_ring_size, 2563 size, UINT16); 2564 2565 cmdline_parse_inst_t cmd_config_rxtx_ring_size = { 2566 .f = cmd_config_rxtx_ring_size_parsed, 2567 .data = NULL, 2568 .help_str = "port config <port_id> rxq|txq <queue_id> ring_size <value>", 2569 .tokens = { 2570 (void *)&cmd_config_rxtx_ring_size_port, 2571 (void *)&cmd_config_rxtx_ring_size_config, 2572 (void *)&cmd_config_rxtx_ring_size_portid, 2573 (void *)&cmd_config_rxtx_ring_size_rxtxq, 2574 (void *)&cmd_config_rxtx_ring_size_qid, 2575 (void *)&cmd_config_rxtx_ring_size_rsize, 2576 (void *)&cmd_config_rxtx_ring_size_size, 2577 NULL, 2578 }, 2579 }; 2580 2581 /* *** configure port rxq/txq start/stop *** */ 2582 struct cmd_config_rxtx_queue { 2583 cmdline_fixed_string_t port; 2584 portid_t portid; 2585 cmdline_fixed_string_t rxtxq; 2586 uint16_t qid; 2587 cmdline_fixed_string_t opname; 2588 }; 2589 2590 static void 2591 cmd_config_rxtx_queue_parsed(void *parsed_result, 2592 __attribute__((unused)) struct cmdline *cl, 2593 __attribute__((unused)) void *data) 2594 { 2595 struct cmd_config_rxtx_queue *res = parsed_result; 2596 uint8_t isrx; 2597 uint8_t isstart; 2598 int ret = 0; 2599 2600 if (test_done == 0) { 2601 printf("Please stop forwarding first\n"); 2602 return; 2603 } 2604 2605 if (port_id_is_invalid(res->portid, ENABLED_WARN)) 2606 return; 2607 2608 if (port_is_started(res->portid) != 1) { 2609 printf("Please start port %u first\n", res->portid); 2610 return; 2611 } 2612 2613 if (!strcmp(res->rxtxq, "rxq")) 2614 isrx = 1; 2615 else if (!strcmp(res->rxtxq, "txq")) 2616 isrx = 0; 2617 else { 2618 printf("Unknown parameter\n"); 2619 return; 2620 } 2621 2622 if (isrx && rx_queue_id_is_invalid(res->qid)) 2623 return; 2624 else if (!isrx && tx_queue_id_is_invalid(res->qid)) 2625 return; 2626 2627 if (!strcmp(res->opname, "start")) 2628 isstart = 1; 2629 else if (!strcmp(res->opname, "stop")) 2630 isstart = 0; 2631 else { 2632 printf("Unknown parameter\n"); 2633 return; 2634 } 2635 2636 if (isstart && isrx) 2637 ret = rte_eth_dev_rx_queue_start(res->portid, res->qid); 2638 else if (!isstart && isrx) 2639 ret = rte_eth_dev_rx_queue_stop(res->portid, res->qid); 2640 else if (isstart && !isrx) 2641 ret = rte_eth_dev_tx_queue_start(res->portid, res->qid); 2642 else 2643 ret = rte_eth_dev_tx_queue_stop(res->portid, res->qid); 2644 2645 if (ret == -ENOTSUP) 2646 printf("Function not supported in PMD driver\n"); 2647 } 2648 2649 cmdline_parse_token_string_t cmd_config_rxtx_queue_port = 2650 TOKEN_STRING_INITIALIZER(struct cmd_config_rxtx_queue, port, "port"); 2651 cmdline_parse_token_num_t cmd_config_rxtx_queue_portid = 2652 TOKEN_NUM_INITIALIZER(struct cmd_config_rxtx_queue, portid, UINT16); 2653 cmdline_parse_token_string_t cmd_config_rxtx_queue_rxtxq = 2654 TOKEN_STRING_INITIALIZER(struct cmd_config_rxtx_queue, rxtxq, "rxq#txq"); 2655 cmdline_parse_token_num_t cmd_config_rxtx_queue_qid = 2656 TOKEN_NUM_INITIALIZER(struct cmd_config_rxtx_queue, qid, UINT16); 2657 cmdline_parse_token_string_t cmd_config_rxtx_queue_opname = 2658 TOKEN_STRING_INITIALIZER(struct cmd_config_rxtx_queue, opname, 2659 "start#stop"); 2660 2661 cmdline_parse_inst_t cmd_config_rxtx_queue = { 2662 .f = cmd_config_rxtx_queue_parsed, 2663 .data = NULL, 2664 .help_str = "port <port_id> rxq|txq <queue_id> start|stop", 2665 .tokens = { 2666 (void *)&cmd_config_rxtx_queue_port, 2667 (void *)&cmd_config_rxtx_queue_portid, 2668 (void *)&cmd_config_rxtx_queue_rxtxq, 2669 (void *)&cmd_config_rxtx_queue_qid, 2670 (void *)&cmd_config_rxtx_queue_opname, 2671 NULL, 2672 }, 2673 }; 2674 2675 /* *** configure port rxq/txq deferred start on/off *** */ 2676 struct cmd_config_deferred_start_rxtx_queue { 2677 cmdline_fixed_string_t port; 2678 portid_t port_id; 2679 cmdline_fixed_string_t rxtxq; 2680 uint16_t qid; 2681 cmdline_fixed_string_t opname; 2682 cmdline_fixed_string_t state; 2683 }; 2684 2685 static void 2686 cmd_config_deferred_start_rxtx_queue_parsed(void *parsed_result, 2687 __attribute__((unused)) struct cmdline *cl, 2688 __attribute__((unused)) void *data) 2689 { 2690 struct cmd_config_deferred_start_rxtx_queue *res = parsed_result; 2691 struct rte_port *port; 2692 uint8_t isrx; 2693 uint8_t ison; 2694 uint8_t needreconfig = 0; 2695 2696 if (port_id_is_invalid(res->port_id, ENABLED_WARN)) 2697 return; 2698 2699 if (port_is_started(res->port_id) != 0) { 2700 printf("Please stop port %u first\n", res->port_id); 2701 return; 2702 } 2703 2704 port = &ports[res->port_id]; 2705 2706 isrx = !strcmp(res->rxtxq, "rxq"); 2707 2708 if (isrx && rx_queue_id_is_invalid(res->qid)) 2709 return; 2710 else if (!isrx && tx_queue_id_is_invalid(res->qid)) 2711 return; 2712 2713 ison = !strcmp(res->state, "on"); 2714 2715 if (isrx && port->rx_conf[res->qid].rx_deferred_start != ison) { 2716 port->rx_conf[res->qid].rx_deferred_start = ison; 2717 needreconfig = 1; 2718 } else if (!isrx && port->tx_conf[res->qid].tx_deferred_start != ison) { 2719 port->tx_conf[res->qid].tx_deferred_start = ison; 2720 needreconfig = 1; 2721 } 2722 2723 if (needreconfig) 2724 cmd_reconfig_device_queue(res->port_id, 0, 1); 2725 } 2726 2727 cmdline_parse_token_string_t cmd_config_deferred_start_rxtx_queue_port = 2728 TOKEN_STRING_INITIALIZER(struct cmd_config_deferred_start_rxtx_queue, 2729 port, "port"); 2730 cmdline_parse_token_num_t cmd_config_deferred_start_rxtx_queue_port_id = 2731 TOKEN_NUM_INITIALIZER(struct cmd_config_deferred_start_rxtx_queue, 2732 port_id, UINT16); 2733 cmdline_parse_token_string_t cmd_config_deferred_start_rxtx_queue_rxtxq = 2734 TOKEN_STRING_INITIALIZER(struct cmd_config_deferred_start_rxtx_queue, 2735 rxtxq, "rxq#txq"); 2736 cmdline_parse_token_num_t cmd_config_deferred_start_rxtx_queue_qid = 2737 TOKEN_NUM_INITIALIZER(struct cmd_config_deferred_start_rxtx_queue, 2738 qid, UINT16); 2739 cmdline_parse_token_string_t cmd_config_deferred_start_rxtx_queue_opname = 2740 TOKEN_STRING_INITIALIZER(struct cmd_config_deferred_start_rxtx_queue, 2741 opname, "deferred_start"); 2742 cmdline_parse_token_string_t cmd_config_deferred_start_rxtx_queue_state = 2743 TOKEN_STRING_INITIALIZER(struct cmd_config_deferred_start_rxtx_queue, 2744 state, "on#off"); 2745 2746 cmdline_parse_inst_t cmd_config_deferred_start_rxtx_queue = { 2747 .f = cmd_config_deferred_start_rxtx_queue_parsed, 2748 .data = NULL, 2749 .help_str = "port <port_id> rxq|txq <queue_id> deferred_start on|off", 2750 .tokens = { 2751 (void *)&cmd_config_deferred_start_rxtx_queue_port, 2752 (void *)&cmd_config_deferred_start_rxtx_queue_port_id, 2753 (void *)&cmd_config_deferred_start_rxtx_queue_rxtxq, 2754 (void *)&cmd_config_deferred_start_rxtx_queue_qid, 2755 (void *)&cmd_config_deferred_start_rxtx_queue_opname, 2756 (void *)&cmd_config_deferred_start_rxtx_queue_state, 2757 NULL, 2758 }, 2759 }; 2760 2761 /* *** configure port rxq/txq setup *** */ 2762 struct cmd_setup_rxtx_queue { 2763 cmdline_fixed_string_t port; 2764 portid_t portid; 2765 cmdline_fixed_string_t rxtxq; 2766 uint16_t qid; 2767 cmdline_fixed_string_t setup; 2768 }; 2769 2770 /* Common CLI fields for queue setup */ 2771 cmdline_parse_token_string_t cmd_setup_rxtx_queue_port = 2772 TOKEN_STRING_INITIALIZER(struct cmd_setup_rxtx_queue, port, "port"); 2773 cmdline_parse_token_num_t cmd_setup_rxtx_queue_portid = 2774 TOKEN_NUM_INITIALIZER(struct cmd_setup_rxtx_queue, portid, UINT16); 2775 cmdline_parse_token_string_t cmd_setup_rxtx_queue_rxtxq = 2776 TOKEN_STRING_INITIALIZER(struct cmd_setup_rxtx_queue, rxtxq, "rxq#txq"); 2777 cmdline_parse_token_num_t cmd_setup_rxtx_queue_qid = 2778 TOKEN_NUM_INITIALIZER(struct cmd_setup_rxtx_queue, qid, UINT16); 2779 cmdline_parse_token_string_t cmd_setup_rxtx_queue_setup = 2780 TOKEN_STRING_INITIALIZER(struct cmd_setup_rxtx_queue, setup, "setup"); 2781 2782 static void 2783 cmd_setup_rxtx_queue_parsed( 2784 void *parsed_result, 2785 __attribute__((unused)) struct cmdline *cl, 2786 __attribute__((unused)) void *data) 2787 { 2788 struct cmd_setup_rxtx_queue *res = parsed_result; 2789 struct rte_port *port; 2790 struct rte_mempool *mp; 2791 unsigned int socket_id; 2792 uint8_t isrx = 0; 2793 int ret; 2794 2795 if (port_id_is_invalid(res->portid, ENABLED_WARN)) 2796 return; 2797 2798 if (res->portid == (portid_t)RTE_PORT_ALL) { 2799 printf("Invalid port id\n"); 2800 return; 2801 } 2802 2803 if (!strcmp(res->rxtxq, "rxq")) 2804 isrx = 1; 2805 else if (!strcmp(res->rxtxq, "txq")) 2806 isrx = 0; 2807 else { 2808 printf("Unknown parameter\n"); 2809 return; 2810 } 2811 2812 if (isrx && rx_queue_id_is_invalid(res->qid)) { 2813 printf("Invalid rx queue\n"); 2814 return; 2815 } else if (!isrx && tx_queue_id_is_invalid(res->qid)) { 2816 printf("Invalid tx queue\n"); 2817 return; 2818 } 2819 2820 port = &ports[res->portid]; 2821 if (isrx) { 2822 socket_id = rxring_numa[res->portid]; 2823 if (!numa_support || socket_id == NUMA_NO_CONFIG) 2824 socket_id = port->socket_id; 2825 2826 mp = mbuf_pool_find(socket_id); 2827 if (mp == NULL) { 2828 printf("Failed to setup RX queue: " 2829 "No mempool allocation" 2830 " on the socket %d\n", 2831 rxring_numa[res->portid]); 2832 return; 2833 } 2834 ret = rte_eth_rx_queue_setup(res->portid, 2835 res->qid, 2836 port->nb_rx_desc[res->qid], 2837 socket_id, 2838 &port->rx_conf[res->qid], 2839 mp); 2840 if (ret) 2841 printf("Failed to setup RX queue\n"); 2842 } else { 2843 socket_id = txring_numa[res->portid]; 2844 if (!numa_support || socket_id == NUMA_NO_CONFIG) 2845 socket_id = port->socket_id; 2846 2847 ret = rte_eth_tx_queue_setup(res->portid, 2848 res->qid, 2849 port->nb_tx_desc[res->qid], 2850 socket_id, 2851 &port->tx_conf[res->qid]); 2852 if (ret) 2853 printf("Failed to setup TX queue\n"); 2854 } 2855 } 2856 2857 cmdline_parse_inst_t cmd_setup_rxtx_queue = { 2858 .f = cmd_setup_rxtx_queue_parsed, 2859 .data = NULL, 2860 .help_str = "port <port_id> rxq|txq <queue_idx> setup", 2861 .tokens = { 2862 (void *)&cmd_setup_rxtx_queue_port, 2863 (void *)&cmd_setup_rxtx_queue_portid, 2864 (void *)&cmd_setup_rxtx_queue_rxtxq, 2865 (void *)&cmd_setup_rxtx_queue_qid, 2866 (void *)&cmd_setup_rxtx_queue_setup, 2867 NULL, 2868 }, 2869 }; 2870 2871 2872 /* *** Configure RSS RETA *** */ 2873 struct cmd_config_rss_reta { 2874 cmdline_fixed_string_t port; 2875 cmdline_fixed_string_t keyword; 2876 portid_t port_id; 2877 cmdline_fixed_string_t name; 2878 cmdline_fixed_string_t list_name; 2879 cmdline_fixed_string_t list_of_items; 2880 }; 2881 2882 static int 2883 parse_reta_config(const char *str, 2884 struct rte_eth_rss_reta_entry64 *reta_conf, 2885 uint16_t nb_entries) 2886 { 2887 int i; 2888 unsigned size; 2889 uint16_t hash_index, idx, shift; 2890 uint16_t nb_queue; 2891 char s[256]; 2892 const char *p, *p0 = str; 2893 char *end; 2894 enum fieldnames { 2895 FLD_HASH_INDEX = 0, 2896 FLD_QUEUE, 2897 _NUM_FLD 2898 }; 2899 unsigned long int_fld[_NUM_FLD]; 2900 char *str_fld[_NUM_FLD]; 2901 2902 while ((p = strchr(p0,'(')) != NULL) { 2903 ++p; 2904 if((p0 = strchr(p,')')) == NULL) 2905 return -1; 2906 2907 size = p0 - p; 2908 if(size >= sizeof(s)) 2909 return -1; 2910 2911 snprintf(s, sizeof(s), "%.*s", size, p); 2912 if (rte_strsplit(s, sizeof(s), str_fld, _NUM_FLD, ',') != _NUM_FLD) 2913 return -1; 2914 for (i = 0; i < _NUM_FLD; i++) { 2915 errno = 0; 2916 int_fld[i] = strtoul(str_fld[i], &end, 0); 2917 if (errno != 0 || end == str_fld[i] || 2918 int_fld[i] > 65535) 2919 return -1; 2920 } 2921 2922 hash_index = (uint16_t)int_fld[FLD_HASH_INDEX]; 2923 nb_queue = (uint16_t)int_fld[FLD_QUEUE]; 2924 2925 if (hash_index >= nb_entries) { 2926 printf("Invalid RETA hash index=%d\n", hash_index); 2927 return -1; 2928 } 2929 2930 idx = hash_index / RTE_RETA_GROUP_SIZE; 2931 shift = hash_index % RTE_RETA_GROUP_SIZE; 2932 reta_conf[idx].mask |= (1ULL << shift); 2933 reta_conf[idx].reta[shift] = nb_queue; 2934 } 2935 2936 return 0; 2937 } 2938 2939 static void 2940 cmd_set_rss_reta_parsed(void *parsed_result, 2941 __attribute__((unused)) struct cmdline *cl, 2942 __attribute__((unused)) void *data) 2943 { 2944 int ret; 2945 struct rte_eth_dev_info dev_info; 2946 struct rte_eth_rss_reta_entry64 reta_conf[8]; 2947 struct cmd_config_rss_reta *res = parsed_result; 2948 2949 ret = eth_dev_info_get_print_err(res->port_id, &dev_info); 2950 if (ret != 0) 2951 return; 2952 2953 if (dev_info.reta_size == 0) { 2954 printf("Redirection table size is 0 which is " 2955 "invalid for RSS\n"); 2956 return; 2957 } else 2958 printf("The reta size of port %d is %u\n", 2959 res->port_id, dev_info.reta_size); 2960 if (dev_info.reta_size > ETH_RSS_RETA_SIZE_512) { 2961 printf("Currently do not support more than %u entries of " 2962 "redirection table\n", ETH_RSS_RETA_SIZE_512); 2963 return; 2964 } 2965 2966 memset(reta_conf, 0, sizeof(reta_conf)); 2967 if (!strcmp(res->list_name, "reta")) { 2968 if (parse_reta_config(res->list_of_items, reta_conf, 2969 dev_info.reta_size)) { 2970 printf("Invalid RSS Redirection Table " 2971 "config entered\n"); 2972 return; 2973 } 2974 ret = rte_eth_dev_rss_reta_update(res->port_id, 2975 reta_conf, dev_info.reta_size); 2976 if (ret != 0) 2977 printf("Bad redirection table parameter, " 2978 "return code = %d \n", ret); 2979 } 2980 } 2981 2982 cmdline_parse_token_string_t cmd_config_rss_reta_port = 2983 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_reta, port, "port"); 2984 cmdline_parse_token_string_t cmd_config_rss_reta_keyword = 2985 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_reta, keyword, "config"); 2986 cmdline_parse_token_num_t cmd_config_rss_reta_port_id = 2987 TOKEN_NUM_INITIALIZER(struct cmd_config_rss_reta, port_id, UINT16); 2988 cmdline_parse_token_string_t cmd_config_rss_reta_name = 2989 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_reta, name, "rss"); 2990 cmdline_parse_token_string_t cmd_config_rss_reta_list_name = 2991 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_reta, list_name, "reta"); 2992 cmdline_parse_token_string_t cmd_config_rss_reta_list_of_items = 2993 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_reta, list_of_items, 2994 NULL); 2995 cmdline_parse_inst_t cmd_config_rss_reta = { 2996 .f = cmd_set_rss_reta_parsed, 2997 .data = NULL, 2998 .help_str = "port config <port_id> rss reta <hash,queue[,hash,queue]*>", 2999 .tokens = { 3000 (void *)&cmd_config_rss_reta_port, 3001 (void *)&cmd_config_rss_reta_keyword, 3002 (void *)&cmd_config_rss_reta_port_id, 3003 (void *)&cmd_config_rss_reta_name, 3004 (void *)&cmd_config_rss_reta_list_name, 3005 (void *)&cmd_config_rss_reta_list_of_items, 3006 NULL, 3007 }, 3008 }; 3009 3010 /* *** SHOW PORT RETA INFO *** */ 3011 struct cmd_showport_reta { 3012 cmdline_fixed_string_t show; 3013 cmdline_fixed_string_t port; 3014 portid_t port_id; 3015 cmdline_fixed_string_t rss; 3016 cmdline_fixed_string_t reta; 3017 uint16_t size; 3018 cmdline_fixed_string_t list_of_items; 3019 }; 3020 3021 static int 3022 showport_parse_reta_config(struct rte_eth_rss_reta_entry64 *conf, 3023 uint16_t nb_entries, 3024 char *str) 3025 { 3026 uint32_t size; 3027 const char *p, *p0 = str; 3028 char s[256]; 3029 char *end; 3030 char *str_fld[8]; 3031 uint16_t i; 3032 uint16_t num = (nb_entries + RTE_RETA_GROUP_SIZE - 1) / 3033 RTE_RETA_GROUP_SIZE; 3034 int ret; 3035 3036 p = strchr(p0, '('); 3037 if (p == NULL) 3038 return -1; 3039 p++; 3040 p0 = strchr(p, ')'); 3041 if (p0 == NULL) 3042 return -1; 3043 size = p0 - p; 3044 if (size >= sizeof(s)) { 3045 printf("The string size exceeds the internal buffer size\n"); 3046 return -1; 3047 } 3048 snprintf(s, sizeof(s), "%.*s", size, p); 3049 ret = rte_strsplit(s, sizeof(s), str_fld, num, ','); 3050 if (ret <= 0 || ret != num) { 3051 printf("The bits of masks do not match the number of " 3052 "reta entries: %u\n", num); 3053 return -1; 3054 } 3055 for (i = 0; i < ret; i++) 3056 conf[i].mask = (uint64_t)strtoul(str_fld[i], &end, 0); 3057 3058 return 0; 3059 } 3060 3061 static void 3062 cmd_showport_reta_parsed(void *parsed_result, 3063 __attribute__((unused)) struct cmdline *cl, 3064 __attribute__((unused)) void *data) 3065 { 3066 struct cmd_showport_reta *res = parsed_result; 3067 struct rte_eth_rss_reta_entry64 reta_conf[8]; 3068 struct rte_eth_dev_info dev_info; 3069 uint16_t max_reta_size; 3070 int ret; 3071 3072 ret = eth_dev_info_get_print_err(res->port_id, &dev_info); 3073 if (ret != 0) 3074 return; 3075 3076 max_reta_size = RTE_MIN(dev_info.reta_size, ETH_RSS_RETA_SIZE_512); 3077 if (res->size == 0 || res->size > max_reta_size) { 3078 printf("Invalid redirection table size: %u (1-%u)\n", 3079 res->size, max_reta_size); 3080 return; 3081 } 3082 3083 memset(reta_conf, 0, sizeof(reta_conf)); 3084 if (showport_parse_reta_config(reta_conf, res->size, 3085 res->list_of_items) < 0) { 3086 printf("Invalid string: %s for reta masks\n", 3087 res->list_of_items); 3088 return; 3089 } 3090 port_rss_reta_info(res->port_id, reta_conf, res->size); 3091 } 3092 3093 cmdline_parse_token_string_t cmd_showport_reta_show = 3094 TOKEN_STRING_INITIALIZER(struct cmd_showport_reta, show, "show"); 3095 cmdline_parse_token_string_t cmd_showport_reta_port = 3096 TOKEN_STRING_INITIALIZER(struct cmd_showport_reta, port, "port"); 3097 cmdline_parse_token_num_t cmd_showport_reta_port_id = 3098 TOKEN_NUM_INITIALIZER(struct cmd_showport_reta, port_id, UINT16); 3099 cmdline_parse_token_string_t cmd_showport_reta_rss = 3100 TOKEN_STRING_INITIALIZER(struct cmd_showport_reta, rss, "rss"); 3101 cmdline_parse_token_string_t cmd_showport_reta_reta = 3102 TOKEN_STRING_INITIALIZER(struct cmd_showport_reta, reta, "reta"); 3103 cmdline_parse_token_num_t cmd_showport_reta_size = 3104 TOKEN_NUM_INITIALIZER(struct cmd_showport_reta, size, UINT16); 3105 cmdline_parse_token_string_t cmd_showport_reta_list_of_items = 3106 TOKEN_STRING_INITIALIZER(struct cmd_showport_reta, 3107 list_of_items, NULL); 3108 3109 cmdline_parse_inst_t cmd_showport_reta = { 3110 .f = cmd_showport_reta_parsed, 3111 .data = NULL, 3112 .help_str = "show port <port_id> rss reta <size> <mask0[,mask1]*>", 3113 .tokens = { 3114 (void *)&cmd_showport_reta_show, 3115 (void *)&cmd_showport_reta_port, 3116 (void *)&cmd_showport_reta_port_id, 3117 (void *)&cmd_showport_reta_rss, 3118 (void *)&cmd_showport_reta_reta, 3119 (void *)&cmd_showport_reta_size, 3120 (void *)&cmd_showport_reta_list_of_items, 3121 NULL, 3122 }, 3123 }; 3124 3125 /* *** Show RSS hash configuration *** */ 3126 struct cmd_showport_rss_hash { 3127 cmdline_fixed_string_t show; 3128 cmdline_fixed_string_t port; 3129 portid_t port_id; 3130 cmdline_fixed_string_t rss_hash; 3131 cmdline_fixed_string_t rss_type; 3132 cmdline_fixed_string_t key; /* optional argument */ 3133 }; 3134 3135 static void cmd_showport_rss_hash_parsed(void *parsed_result, 3136 __attribute__((unused)) struct cmdline *cl, 3137 void *show_rss_key) 3138 { 3139 struct cmd_showport_rss_hash *res = parsed_result; 3140 3141 port_rss_hash_conf_show(res->port_id, show_rss_key != NULL); 3142 } 3143 3144 cmdline_parse_token_string_t cmd_showport_rss_hash_show = 3145 TOKEN_STRING_INITIALIZER(struct cmd_showport_rss_hash, show, "show"); 3146 cmdline_parse_token_string_t cmd_showport_rss_hash_port = 3147 TOKEN_STRING_INITIALIZER(struct cmd_showport_rss_hash, port, "port"); 3148 cmdline_parse_token_num_t cmd_showport_rss_hash_port_id = 3149 TOKEN_NUM_INITIALIZER(struct cmd_showport_rss_hash, port_id, UINT16); 3150 cmdline_parse_token_string_t cmd_showport_rss_hash_rss_hash = 3151 TOKEN_STRING_INITIALIZER(struct cmd_showport_rss_hash, rss_hash, 3152 "rss-hash"); 3153 cmdline_parse_token_string_t cmd_showport_rss_hash_rss_key = 3154 TOKEN_STRING_INITIALIZER(struct cmd_showport_rss_hash, key, "key"); 3155 3156 cmdline_parse_inst_t cmd_showport_rss_hash = { 3157 .f = cmd_showport_rss_hash_parsed, 3158 .data = NULL, 3159 .help_str = "show port <port_id> rss-hash", 3160 .tokens = { 3161 (void *)&cmd_showport_rss_hash_show, 3162 (void *)&cmd_showport_rss_hash_port, 3163 (void *)&cmd_showport_rss_hash_port_id, 3164 (void *)&cmd_showport_rss_hash_rss_hash, 3165 NULL, 3166 }, 3167 }; 3168 3169 cmdline_parse_inst_t cmd_showport_rss_hash_key = { 3170 .f = cmd_showport_rss_hash_parsed, 3171 .data = (void *)1, 3172 .help_str = "show port <port_id> rss-hash key", 3173 .tokens = { 3174 (void *)&cmd_showport_rss_hash_show, 3175 (void *)&cmd_showport_rss_hash_port, 3176 (void *)&cmd_showport_rss_hash_port_id, 3177 (void *)&cmd_showport_rss_hash_rss_hash, 3178 (void *)&cmd_showport_rss_hash_rss_key, 3179 NULL, 3180 }, 3181 }; 3182 3183 /* *** Configure DCB *** */ 3184 struct cmd_config_dcb { 3185 cmdline_fixed_string_t port; 3186 cmdline_fixed_string_t config; 3187 portid_t port_id; 3188 cmdline_fixed_string_t dcb; 3189 cmdline_fixed_string_t vt; 3190 cmdline_fixed_string_t vt_en; 3191 uint8_t num_tcs; 3192 cmdline_fixed_string_t pfc; 3193 cmdline_fixed_string_t pfc_en; 3194 }; 3195 3196 static void 3197 cmd_config_dcb_parsed(void *parsed_result, 3198 __attribute__((unused)) struct cmdline *cl, 3199 __attribute__((unused)) void *data) 3200 { 3201 struct cmd_config_dcb *res = parsed_result; 3202 portid_t port_id = res->port_id; 3203 struct rte_port *port; 3204 uint8_t pfc_en; 3205 int ret; 3206 3207 port = &ports[port_id]; 3208 /** Check if the port is not started **/ 3209 if (port->port_status != RTE_PORT_STOPPED) { 3210 printf("Please stop port %d first\n", port_id); 3211 return; 3212 } 3213 3214 if ((res->num_tcs != ETH_4_TCS) && (res->num_tcs != ETH_8_TCS)) { 3215 printf("The invalid number of traffic class," 3216 " only 4 or 8 allowed.\n"); 3217 return; 3218 } 3219 3220 if (nb_fwd_lcores < res->num_tcs) { 3221 printf("nb_cores shouldn't be less than number of TCs.\n"); 3222 return; 3223 } 3224 if (!strncmp(res->pfc_en, "on", 2)) 3225 pfc_en = 1; 3226 else 3227 pfc_en = 0; 3228 3229 /* DCB in VT mode */ 3230 if (!strncmp(res->vt_en, "on", 2)) 3231 ret = init_port_dcb_config(port_id, DCB_VT_ENABLED, 3232 (enum rte_eth_nb_tcs)res->num_tcs, 3233 pfc_en); 3234 else 3235 ret = init_port_dcb_config(port_id, DCB_ENABLED, 3236 (enum rte_eth_nb_tcs)res->num_tcs, 3237 pfc_en); 3238 3239 3240 if (ret != 0) { 3241 printf("Cannot initialize network ports.\n"); 3242 return; 3243 } 3244 3245 cmd_reconfig_device_queue(port_id, 1, 1); 3246 } 3247 3248 cmdline_parse_token_string_t cmd_config_dcb_port = 3249 TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, port, "port"); 3250 cmdline_parse_token_string_t cmd_config_dcb_config = 3251 TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, config, "config"); 3252 cmdline_parse_token_num_t cmd_config_dcb_port_id = 3253 TOKEN_NUM_INITIALIZER(struct cmd_config_dcb, port_id, UINT16); 3254 cmdline_parse_token_string_t cmd_config_dcb_dcb = 3255 TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, dcb, "dcb"); 3256 cmdline_parse_token_string_t cmd_config_dcb_vt = 3257 TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, vt, "vt"); 3258 cmdline_parse_token_string_t cmd_config_dcb_vt_en = 3259 TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, vt_en, "on#off"); 3260 cmdline_parse_token_num_t cmd_config_dcb_num_tcs = 3261 TOKEN_NUM_INITIALIZER(struct cmd_config_dcb, num_tcs, UINT8); 3262 cmdline_parse_token_string_t cmd_config_dcb_pfc= 3263 TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, pfc, "pfc"); 3264 cmdline_parse_token_string_t cmd_config_dcb_pfc_en = 3265 TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, pfc_en, "on#off"); 3266 3267 cmdline_parse_inst_t cmd_config_dcb = { 3268 .f = cmd_config_dcb_parsed, 3269 .data = NULL, 3270 .help_str = "port config <port-id> dcb vt on|off <num_tcs> pfc on|off", 3271 .tokens = { 3272 (void *)&cmd_config_dcb_port, 3273 (void *)&cmd_config_dcb_config, 3274 (void *)&cmd_config_dcb_port_id, 3275 (void *)&cmd_config_dcb_dcb, 3276 (void *)&cmd_config_dcb_vt, 3277 (void *)&cmd_config_dcb_vt_en, 3278 (void *)&cmd_config_dcb_num_tcs, 3279 (void *)&cmd_config_dcb_pfc, 3280 (void *)&cmd_config_dcb_pfc_en, 3281 NULL, 3282 }, 3283 }; 3284 3285 /* *** configure number of packets per burst *** */ 3286 struct cmd_config_burst { 3287 cmdline_fixed_string_t port; 3288 cmdline_fixed_string_t keyword; 3289 cmdline_fixed_string_t all; 3290 cmdline_fixed_string_t name; 3291 uint16_t value; 3292 }; 3293 3294 static void 3295 cmd_config_burst_parsed(void *parsed_result, 3296 __attribute__((unused)) struct cmdline *cl, 3297 __attribute__((unused)) void *data) 3298 { 3299 struct cmd_config_burst *res = parsed_result; 3300 struct rte_eth_dev_info dev_info; 3301 uint16_t rec_nb_pkts; 3302 int ret; 3303 3304 if (!all_ports_stopped()) { 3305 printf("Please stop all ports first\n"); 3306 return; 3307 } 3308 3309 if (!strcmp(res->name, "burst")) { 3310 if (res->value == 0) { 3311 /* If user gives a value of zero, query the PMD for 3312 * its recommended Rx burst size. Testpmd uses a single 3313 * size for all ports, so assume all ports are the same 3314 * NIC model and use the values from Port 0. 3315 */ 3316 ret = eth_dev_info_get_print_err(0, &dev_info); 3317 if (ret != 0) 3318 return; 3319 3320 rec_nb_pkts = dev_info.default_rxportconf.burst_size; 3321 3322 if (rec_nb_pkts == 0) { 3323 printf("PMD does not recommend a burst size.\n" 3324 "User provided value must be between" 3325 " 1 and %d\n", MAX_PKT_BURST); 3326 return; 3327 } else if (rec_nb_pkts > MAX_PKT_BURST) { 3328 printf("PMD recommended burst size of %d" 3329 " exceeds maximum value of %d\n", 3330 rec_nb_pkts, MAX_PKT_BURST); 3331 return; 3332 } 3333 printf("Using PMD-provided burst value of %d\n", 3334 rec_nb_pkts); 3335 nb_pkt_per_burst = rec_nb_pkts; 3336 } else if (res->value > MAX_PKT_BURST) { 3337 printf("burst must be >= 1 && <= %d\n", MAX_PKT_BURST); 3338 return; 3339 } else 3340 nb_pkt_per_burst = res->value; 3341 } else { 3342 printf("Unknown parameter\n"); 3343 return; 3344 } 3345 3346 init_port_config(); 3347 3348 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1); 3349 } 3350 3351 cmdline_parse_token_string_t cmd_config_burst_port = 3352 TOKEN_STRING_INITIALIZER(struct cmd_config_burst, port, "port"); 3353 cmdline_parse_token_string_t cmd_config_burst_keyword = 3354 TOKEN_STRING_INITIALIZER(struct cmd_config_burst, keyword, "config"); 3355 cmdline_parse_token_string_t cmd_config_burst_all = 3356 TOKEN_STRING_INITIALIZER(struct cmd_config_burst, all, "all"); 3357 cmdline_parse_token_string_t cmd_config_burst_name = 3358 TOKEN_STRING_INITIALIZER(struct cmd_config_burst, name, "burst"); 3359 cmdline_parse_token_num_t cmd_config_burst_value = 3360 TOKEN_NUM_INITIALIZER(struct cmd_config_burst, value, UINT16); 3361 3362 cmdline_parse_inst_t cmd_config_burst = { 3363 .f = cmd_config_burst_parsed, 3364 .data = NULL, 3365 .help_str = "port config all burst <value>", 3366 .tokens = { 3367 (void *)&cmd_config_burst_port, 3368 (void *)&cmd_config_burst_keyword, 3369 (void *)&cmd_config_burst_all, 3370 (void *)&cmd_config_burst_name, 3371 (void *)&cmd_config_burst_value, 3372 NULL, 3373 }, 3374 }; 3375 3376 /* *** configure rx/tx queues *** */ 3377 struct cmd_config_thresh { 3378 cmdline_fixed_string_t port; 3379 cmdline_fixed_string_t keyword; 3380 cmdline_fixed_string_t all; 3381 cmdline_fixed_string_t name; 3382 uint8_t value; 3383 }; 3384 3385 static void 3386 cmd_config_thresh_parsed(void *parsed_result, 3387 __attribute__((unused)) struct cmdline *cl, 3388 __attribute__((unused)) void *data) 3389 { 3390 struct cmd_config_thresh *res = parsed_result; 3391 3392 if (!all_ports_stopped()) { 3393 printf("Please stop all ports first\n"); 3394 return; 3395 } 3396 3397 if (!strcmp(res->name, "txpt")) 3398 tx_pthresh = res->value; 3399 else if(!strcmp(res->name, "txht")) 3400 tx_hthresh = res->value; 3401 else if(!strcmp(res->name, "txwt")) 3402 tx_wthresh = res->value; 3403 else if(!strcmp(res->name, "rxpt")) 3404 rx_pthresh = res->value; 3405 else if(!strcmp(res->name, "rxht")) 3406 rx_hthresh = res->value; 3407 else if(!strcmp(res->name, "rxwt")) 3408 rx_wthresh = res->value; 3409 else { 3410 printf("Unknown parameter\n"); 3411 return; 3412 } 3413 3414 init_port_config(); 3415 3416 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1); 3417 } 3418 3419 cmdline_parse_token_string_t cmd_config_thresh_port = 3420 TOKEN_STRING_INITIALIZER(struct cmd_config_thresh, port, "port"); 3421 cmdline_parse_token_string_t cmd_config_thresh_keyword = 3422 TOKEN_STRING_INITIALIZER(struct cmd_config_thresh, keyword, "config"); 3423 cmdline_parse_token_string_t cmd_config_thresh_all = 3424 TOKEN_STRING_INITIALIZER(struct cmd_config_thresh, all, "all"); 3425 cmdline_parse_token_string_t cmd_config_thresh_name = 3426 TOKEN_STRING_INITIALIZER(struct cmd_config_thresh, name, 3427 "txpt#txht#txwt#rxpt#rxht#rxwt"); 3428 cmdline_parse_token_num_t cmd_config_thresh_value = 3429 TOKEN_NUM_INITIALIZER(struct cmd_config_thresh, value, UINT8); 3430 3431 cmdline_parse_inst_t cmd_config_thresh = { 3432 .f = cmd_config_thresh_parsed, 3433 .data = NULL, 3434 .help_str = "port config all txpt|txht|txwt|rxpt|rxht|rxwt <value>", 3435 .tokens = { 3436 (void *)&cmd_config_thresh_port, 3437 (void *)&cmd_config_thresh_keyword, 3438 (void *)&cmd_config_thresh_all, 3439 (void *)&cmd_config_thresh_name, 3440 (void *)&cmd_config_thresh_value, 3441 NULL, 3442 }, 3443 }; 3444 3445 /* *** configure free/rs threshold *** */ 3446 struct cmd_config_threshold { 3447 cmdline_fixed_string_t port; 3448 cmdline_fixed_string_t keyword; 3449 cmdline_fixed_string_t all; 3450 cmdline_fixed_string_t name; 3451 uint16_t value; 3452 }; 3453 3454 static void 3455 cmd_config_threshold_parsed(void *parsed_result, 3456 __attribute__((unused)) struct cmdline *cl, 3457 __attribute__((unused)) void *data) 3458 { 3459 struct cmd_config_threshold *res = parsed_result; 3460 3461 if (!all_ports_stopped()) { 3462 printf("Please stop all ports first\n"); 3463 return; 3464 } 3465 3466 if (!strcmp(res->name, "txfreet")) 3467 tx_free_thresh = res->value; 3468 else if (!strcmp(res->name, "txrst")) 3469 tx_rs_thresh = res->value; 3470 else if (!strcmp(res->name, "rxfreet")) 3471 rx_free_thresh = res->value; 3472 else { 3473 printf("Unknown parameter\n"); 3474 return; 3475 } 3476 3477 init_port_config(); 3478 3479 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1); 3480 } 3481 3482 cmdline_parse_token_string_t cmd_config_threshold_port = 3483 TOKEN_STRING_INITIALIZER(struct cmd_config_threshold, port, "port"); 3484 cmdline_parse_token_string_t cmd_config_threshold_keyword = 3485 TOKEN_STRING_INITIALIZER(struct cmd_config_threshold, keyword, 3486 "config"); 3487 cmdline_parse_token_string_t cmd_config_threshold_all = 3488 TOKEN_STRING_INITIALIZER(struct cmd_config_threshold, all, "all"); 3489 cmdline_parse_token_string_t cmd_config_threshold_name = 3490 TOKEN_STRING_INITIALIZER(struct cmd_config_threshold, name, 3491 "txfreet#txrst#rxfreet"); 3492 cmdline_parse_token_num_t cmd_config_threshold_value = 3493 TOKEN_NUM_INITIALIZER(struct cmd_config_threshold, value, UINT16); 3494 3495 cmdline_parse_inst_t cmd_config_threshold = { 3496 .f = cmd_config_threshold_parsed, 3497 .data = NULL, 3498 .help_str = "port config all txfreet|txrst|rxfreet <value>", 3499 .tokens = { 3500 (void *)&cmd_config_threshold_port, 3501 (void *)&cmd_config_threshold_keyword, 3502 (void *)&cmd_config_threshold_all, 3503 (void *)&cmd_config_threshold_name, 3504 (void *)&cmd_config_threshold_value, 3505 NULL, 3506 }, 3507 }; 3508 3509 /* *** stop *** */ 3510 struct cmd_stop_result { 3511 cmdline_fixed_string_t stop; 3512 }; 3513 3514 static void cmd_stop_parsed(__attribute__((unused)) void *parsed_result, 3515 __attribute__((unused)) struct cmdline *cl, 3516 __attribute__((unused)) void *data) 3517 { 3518 stop_packet_forwarding(); 3519 } 3520 3521 cmdline_parse_token_string_t cmd_stop_stop = 3522 TOKEN_STRING_INITIALIZER(struct cmd_stop_result, stop, "stop"); 3523 3524 cmdline_parse_inst_t cmd_stop = { 3525 .f = cmd_stop_parsed, 3526 .data = NULL, 3527 .help_str = "stop: Stop packet forwarding", 3528 .tokens = { 3529 (void *)&cmd_stop_stop, 3530 NULL, 3531 }, 3532 }; 3533 3534 /* *** SET CORELIST and PORTLIST CONFIGURATION *** */ 3535 3536 unsigned int 3537 parse_item_list(char* str, const char* item_name, unsigned int max_items, 3538 unsigned int *parsed_items, int check_unique_values) 3539 { 3540 unsigned int nb_item; 3541 unsigned int value; 3542 unsigned int i; 3543 unsigned int j; 3544 int value_ok; 3545 char c; 3546 3547 /* 3548 * First parse all items in the list and store their value. 3549 */ 3550 value = 0; 3551 nb_item = 0; 3552 value_ok = 0; 3553 for (i = 0; i < strnlen(str, STR_TOKEN_SIZE); i++) { 3554 c = str[i]; 3555 if ((c >= '0') && (c <= '9')) { 3556 value = (unsigned int) (value * 10 + (c - '0')); 3557 value_ok = 1; 3558 continue; 3559 } 3560 if (c != ',') { 3561 printf("character %c is not a decimal digit\n", c); 3562 return 0; 3563 } 3564 if (! value_ok) { 3565 printf("No valid value before comma\n"); 3566 return 0; 3567 } 3568 if (nb_item < max_items) { 3569 parsed_items[nb_item] = value; 3570 value_ok = 0; 3571 value = 0; 3572 } 3573 nb_item++; 3574 } 3575 if (nb_item >= max_items) { 3576 printf("Number of %s = %u > %u (maximum items)\n", 3577 item_name, nb_item + 1, max_items); 3578 return 0; 3579 } 3580 parsed_items[nb_item++] = value; 3581 if (! check_unique_values) 3582 return nb_item; 3583 3584 /* 3585 * Then, check that all values in the list are differents. 3586 * No optimization here... 3587 */ 3588 for (i = 0; i < nb_item; i++) { 3589 for (j = i + 1; j < nb_item; j++) { 3590 if (parsed_items[j] == parsed_items[i]) { 3591 printf("duplicated %s %u at index %u and %u\n", 3592 item_name, parsed_items[i], i, j); 3593 return 0; 3594 } 3595 } 3596 } 3597 return nb_item; 3598 } 3599 3600 struct cmd_set_list_result { 3601 cmdline_fixed_string_t cmd_keyword; 3602 cmdline_fixed_string_t list_name; 3603 cmdline_fixed_string_t list_of_items; 3604 }; 3605 3606 static void cmd_set_list_parsed(void *parsed_result, 3607 __attribute__((unused)) struct cmdline *cl, 3608 __attribute__((unused)) void *data) 3609 { 3610 struct cmd_set_list_result *res; 3611 union { 3612 unsigned int lcorelist[RTE_MAX_LCORE]; 3613 unsigned int portlist[RTE_MAX_ETHPORTS]; 3614 } parsed_items; 3615 unsigned int nb_item; 3616 3617 if (test_done == 0) { 3618 printf("Please stop forwarding first\n"); 3619 return; 3620 } 3621 3622 res = parsed_result; 3623 if (!strcmp(res->list_name, "corelist")) { 3624 nb_item = parse_item_list(res->list_of_items, "core", 3625 RTE_MAX_LCORE, 3626 parsed_items.lcorelist, 1); 3627 if (nb_item > 0) { 3628 set_fwd_lcores_list(parsed_items.lcorelist, nb_item); 3629 fwd_config_setup(); 3630 } 3631 return; 3632 } 3633 if (!strcmp(res->list_name, "portlist")) { 3634 nb_item = parse_item_list(res->list_of_items, "port", 3635 RTE_MAX_ETHPORTS, 3636 parsed_items.portlist, 1); 3637 if (nb_item > 0) { 3638 set_fwd_ports_list(parsed_items.portlist, nb_item); 3639 fwd_config_setup(); 3640 } 3641 } 3642 } 3643 3644 cmdline_parse_token_string_t cmd_set_list_keyword = 3645 TOKEN_STRING_INITIALIZER(struct cmd_set_list_result, cmd_keyword, 3646 "set"); 3647 cmdline_parse_token_string_t cmd_set_list_name = 3648 TOKEN_STRING_INITIALIZER(struct cmd_set_list_result, list_name, 3649 "corelist#portlist"); 3650 cmdline_parse_token_string_t cmd_set_list_of_items = 3651 TOKEN_STRING_INITIALIZER(struct cmd_set_list_result, list_of_items, 3652 NULL); 3653 3654 cmdline_parse_inst_t cmd_set_fwd_list = { 3655 .f = cmd_set_list_parsed, 3656 .data = NULL, 3657 .help_str = "set corelist|portlist <list0[,list1]*>", 3658 .tokens = { 3659 (void *)&cmd_set_list_keyword, 3660 (void *)&cmd_set_list_name, 3661 (void *)&cmd_set_list_of_items, 3662 NULL, 3663 }, 3664 }; 3665 3666 /* *** SET COREMASK and PORTMASK CONFIGURATION *** */ 3667 3668 struct cmd_setmask_result { 3669 cmdline_fixed_string_t set; 3670 cmdline_fixed_string_t mask; 3671 uint64_t hexavalue; 3672 }; 3673 3674 static void cmd_set_mask_parsed(void *parsed_result, 3675 __attribute__((unused)) struct cmdline *cl, 3676 __attribute__((unused)) void *data) 3677 { 3678 struct cmd_setmask_result *res = parsed_result; 3679 3680 if (test_done == 0) { 3681 printf("Please stop forwarding first\n"); 3682 return; 3683 } 3684 if (!strcmp(res->mask, "coremask")) { 3685 set_fwd_lcores_mask(res->hexavalue); 3686 fwd_config_setup(); 3687 } else if (!strcmp(res->mask, "portmask")) { 3688 set_fwd_ports_mask(res->hexavalue); 3689 fwd_config_setup(); 3690 } 3691 } 3692 3693 cmdline_parse_token_string_t cmd_setmask_set = 3694 TOKEN_STRING_INITIALIZER(struct cmd_setmask_result, set, "set"); 3695 cmdline_parse_token_string_t cmd_setmask_mask = 3696 TOKEN_STRING_INITIALIZER(struct cmd_setmask_result, mask, 3697 "coremask#portmask"); 3698 cmdline_parse_token_num_t cmd_setmask_value = 3699 TOKEN_NUM_INITIALIZER(struct cmd_setmask_result, hexavalue, UINT64); 3700 3701 cmdline_parse_inst_t cmd_set_fwd_mask = { 3702 .f = cmd_set_mask_parsed, 3703 .data = NULL, 3704 .help_str = "set coremask|portmask <hexadecimal value>", 3705 .tokens = { 3706 (void *)&cmd_setmask_set, 3707 (void *)&cmd_setmask_mask, 3708 (void *)&cmd_setmask_value, 3709 NULL, 3710 }, 3711 }; 3712 3713 /* 3714 * SET NBPORT, NBCORE, PACKET BURST, and VERBOSE LEVEL CONFIGURATION 3715 */ 3716 struct cmd_set_result { 3717 cmdline_fixed_string_t set; 3718 cmdline_fixed_string_t what; 3719 uint16_t value; 3720 }; 3721 3722 static void cmd_set_parsed(void *parsed_result, 3723 __attribute__((unused)) struct cmdline *cl, 3724 __attribute__((unused)) void *data) 3725 { 3726 struct cmd_set_result *res = parsed_result; 3727 if (!strcmp(res->what, "nbport")) { 3728 set_fwd_ports_number(res->value); 3729 fwd_config_setup(); 3730 } else if (!strcmp(res->what, "nbcore")) { 3731 set_fwd_lcores_number(res->value); 3732 fwd_config_setup(); 3733 } else if (!strcmp(res->what, "burst")) 3734 set_nb_pkt_per_burst(res->value); 3735 else if (!strcmp(res->what, "verbose")) 3736 set_verbose_level(res->value); 3737 } 3738 3739 cmdline_parse_token_string_t cmd_set_set = 3740 TOKEN_STRING_INITIALIZER(struct cmd_set_result, set, "set"); 3741 cmdline_parse_token_string_t cmd_set_what = 3742 TOKEN_STRING_INITIALIZER(struct cmd_set_result, what, 3743 "nbport#nbcore#burst#verbose"); 3744 cmdline_parse_token_num_t cmd_set_value = 3745 TOKEN_NUM_INITIALIZER(struct cmd_set_result, value, UINT16); 3746 3747 cmdline_parse_inst_t cmd_set_numbers = { 3748 .f = cmd_set_parsed, 3749 .data = NULL, 3750 .help_str = "set nbport|nbcore|burst|verbose <value>", 3751 .tokens = { 3752 (void *)&cmd_set_set, 3753 (void *)&cmd_set_what, 3754 (void *)&cmd_set_value, 3755 NULL, 3756 }, 3757 }; 3758 3759 /* *** SET LOG LEVEL CONFIGURATION *** */ 3760 3761 struct cmd_set_log_result { 3762 cmdline_fixed_string_t set; 3763 cmdline_fixed_string_t log; 3764 cmdline_fixed_string_t type; 3765 uint32_t level; 3766 }; 3767 3768 static void 3769 cmd_set_log_parsed(void *parsed_result, 3770 __attribute__((unused)) struct cmdline *cl, 3771 __attribute__((unused)) void *data) 3772 { 3773 struct cmd_set_log_result *res; 3774 int ret; 3775 3776 res = parsed_result; 3777 if (!strcmp(res->type, "global")) 3778 rte_log_set_global_level(res->level); 3779 else { 3780 ret = rte_log_set_level_regexp(res->type, res->level); 3781 if (ret < 0) 3782 printf("Unable to set log level\n"); 3783 } 3784 } 3785 3786 cmdline_parse_token_string_t cmd_set_log_set = 3787 TOKEN_STRING_INITIALIZER(struct cmd_set_log_result, set, "set"); 3788 cmdline_parse_token_string_t cmd_set_log_log = 3789 TOKEN_STRING_INITIALIZER(struct cmd_set_log_result, log, "log"); 3790 cmdline_parse_token_string_t cmd_set_log_type = 3791 TOKEN_STRING_INITIALIZER(struct cmd_set_log_result, type, NULL); 3792 cmdline_parse_token_num_t cmd_set_log_level = 3793 TOKEN_NUM_INITIALIZER(struct cmd_set_log_result, level, UINT32); 3794 3795 cmdline_parse_inst_t cmd_set_log = { 3796 .f = cmd_set_log_parsed, 3797 .data = NULL, 3798 .help_str = "set log global|<type> <level>", 3799 .tokens = { 3800 (void *)&cmd_set_log_set, 3801 (void *)&cmd_set_log_log, 3802 (void *)&cmd_set_log_type, 3803 (void *)&cmd_set_log_level, 3804 NULL, 3805 }, 3806 }; 3807 3808 /* *** SET SEGMENT LENGTHS OF TXONLY PACKETS *** */ 3809 3810 struct cmd_set_txpkts_result { 3811 cmdline_fixed_string_t cmd_keyword; 3812 cmdline_fixed_string_t txpkts; 3813 cmdline_fixed_string_t seg_lengths; 3814 }; 3815 3816 static void 3817 cmd_set_txpkts_parsed(void *parsed_result, 3818 __attribute__((unused)) struct cmdline *cl, 3819 __attribute__((unused)) void *data) 3820 { 3821 struct cmd_set_txpkts_result *res; 3822 unsigned seg_lengths[RTE_MAX_SEGS_PER_PKT]; 3823 unsigned int nb_segs; 3824 3825 res = parsed_result; 3826 nb_segs = parse_item_list(res->seg_lengths, "segment lengths", 3827 RTE_MAX_SEGS_PER_PKT, seg_lengths, 0); 3828 if (nb_segs > 0) 3829 set_tx_pkt_segments(seg_lengths, nb_segs); 3830 } 3831 3832 cmdline_parse_token_string_t cmd_set_txpkts_keyword = 3833 TOKEN_STRING_INITIALIZER(struct cmd_set_txpkts_result, 3834 cmd_keyword, "set"); 3835 cmdline_parse_token_string_t cmd_set_txpkts_name = 3836 TOKEN_STRING_INITIALIZER(struct cmd_set_txpkts_result, 3837 txpkts, "txpkts"); 3838 cmdline_parse_token_string_t cmd_set_txpkts_lengths = 3839 TOKEN_STRING_INITIALIZER(struct cmd_set_txpkts_result, 3840 seg_lengths, NULL); 3841 3842 cmdline_parse_inst_t cmd_set_txpkts = { 3843 .f = cmd_set_txpkts_parsed, 3844 .data = NULL, 3845 .help_str = "set txpkts <len0[,len1]*>", 3846 .tokens = { 3847 (void *)&cmd_set_txpkts_keyword, 3848 (void *)&cmd_set_txpkts_name, 3849 (void *)&cmd_set_txpkts_lengths, 3850 NULL, 3851 }, 3852 }; 3853 3854 /* *** SET COPY AND SPLIT POLICY ON TX PACKETS *** */ 3855 3856 struct cmd_set_txsplit_result { 3857 cmdline_fixed_string_t cmd_keyword; 3858 cmdline_fixed_string_t txsplit; 3859 cmdline_fixed_string_t mode; 3860 }; 3861 3862 static void 3863 cmd_set_txsplit_parsed(void *parsed_result, 3864 __attribute__((unused)) struct cmdline *cl, 3865 __attribute__((unused)) void *data) 3866 { 3867 struct cmd_set_txsplit_result *res; 3868 3869 res = parsed_result; 3870 set_tx_pkt_split(res->mode); 3871 } 3872 3873 cmdline_parse_token_string_t cmd_set_txsplit_keyword = 3874 TOKEN_STRING_INITIALIZER(struct cmd_set_txsplit_result, 3875 cmd_keyword, "set"); 3876 cmdline_parse_token_string_t cmd_set_txsplit_name = 3877 TOKEN_STRING_INITIALIZER(struct cmd_set_txsplit_result, 3878 txsplit, "txsplit"); 3879 cmdline_parse_token_string_t cmd_set_txsplit_mode = 3880 TOKEN_STRING_INITIALIZER(struct cmd_set_txsplit_result, 3881 mode, NULL); 3882 3883 cmdline_parse_inst_t cmd_set_txsplit = { 3884 .f = cmd_set_txsplit_parsed, 3885 .data = NULL, 3886 .help_str = "set txsplit on|off|rand", 3887 .tokens = { 3888 (void *)&cmd_set_txsplit_keyword, 3889 (void *)&cmd_set_txsplit_name, 3890 (void *)&cmd_set_txsplit_mode, 3891 NULL, 3892 }, 3893 }; 3894 3895 /* *** ADD/REMOVE ALL VLAN IDENTIFIERS TO/FROM A PORT VLAN RX FILTER *** */ 3896 struct cmd_rx_vlan_filter_all_result { 3897 cmdline_fixed_string_t rx_vlan; 3898 cmdline_fixed_string_t what; 3899 cmdline_fixed_string_t all; 3900 portid_t port_id; 3901 }; 3902 3903 static void 3904 cmd_rx_vlan_filter_all_parsed(void *parsed_result, 3905 __attribute__((unused)) struct cmdline *cl, 3906 __attribute__((unused)) void *data) 3907 { 3908 struct cmd_rx_vlan_filter_all_result *res = parsed_result; 3909 3910 if (!strcmp(res->what, "add")) 3911 rx_vlan_all_filter_set(res->port_id, 1); 3912 else 3913 rx_vlan_all_filter_set(res->port_id, 0); 3914 } 3915 3916 cmdline_parse_token_string_t cmd_rx_vlan_filter_all_rx_vlan = 3917 TOKEN_STRING_INITIALIZER(struct cmd_rx_vlan_filter_all_result, 3918 rx_vlan, "rx_vlan"); 3919 cmdline_parse_token_string_t cmd_rx_vlan_filter_all_what = 3920 TOKEN_STRING_INITIALIZER(struct cmd_rx_vlan_filter_all_result, 3921 what, "add#rm"); 3922 cmdline_parse_token_string_t cmd_rx_vlan_filter_all_all = 3923 TOKEN_STRING_INITIALIZER(struct cmd_rx_vlan_filter_all_result, 3924 all, "all"); 3925 cmdline_parse_token_num_t cmd_rx_vlan_filter_all_portid = 3926 TOKEN_NUM_INITIALIZER(struct cmd_rx_vlan_filter_all_result, 3927 port_id, UINT16); 3928 3929 cmdline_parse_inst_t cmd_rx_vlan_filter_all = { 3930 .f = cmd_rx_vlan_filter_all_parsed, 3931 .data = NULL, 3932 .help_str = "rx_vlan add|rm all <port_id>: " 3933 "Add/Remove all identifiers to/from the set of VLAN " 3934 "identifiers filtered by a port", 3935 .tokens = { 3936 (void *)&cmd_rx_vlan_filter_all_rx_vlan, 3937 (void *)&cmd_rx_vlan_filter_all_what, 3938 (void *)&cmd_rx_vlan_filter_all_all, 3939 (void *)&cmd_rx_vlan_filter_all_portid, 3940 NULL, 3941 }, 3942 }; 3943 3944 /* *** VLAN OFFLOAD SET ON A PORT *** */ 3945 struct cmd_vlan_offload_result { 3946 cmdline_fixed_string_t vlan; 3947 cmdline_fixed_string_t set; 3948 cmdline_fixed_string_t vlan_type; 3949 cmdline_fixed_string_t what; 3950 cmdline_fixed_string_t on; 3951 cmdline_fixed_string_t port_id; 3952 }; 3953 3954 static void 3955 cmd_vlan_offload_parsed(void *parsed_result, 3956 __attribute__((unused)) struct cmdline *cl, 3957 __attribute__((unused)) void *data) 3958 { 3959 int on; 3960 struct cmd_vlan_offload_result *res = parsed_result; 3961 char *str; 3962 int i, len = 0; 3963 portid_t port_id = 0; 3964 unsigned int tmp; 3965 3966 str = res->port_id; 3967 len = strnlen(str, STR_TOKEN_SIZE); 3968 i = 0; 3969 /* Get port_id first */ 3970 while(i < len){ 3971 if(str[i] == ',') 3972 break; 3973 3974 i++; 3975 } 3976 str[i]='\0'; 3977 tmp = strtoul(str, NULL, 0); 3978 /* If port_id greater that what portid_t can represent, return */ 3979 if(tmp >= RTE_MAX_ETHPORTS) 3980 return; 3981 port_id = (portid_t)tmp; 3982 3983 if (!strcmp(res->on, "on")) 3984 on = 1; 3985 else 3986 on = 0; 3987 3988 if (!strcmp(res->what, "strip")) 3989 rx_vlan_strip_set(port_id, on); 3990 else if(!strcmp(res->what, "stripq")){ 3991 uint16_t queue_id = 0; 3992 3993 /* No queue_id, return */ 3994 if(i + 1 >= len) { 3995 printf("must specify (port,queue_id)\n"); 3996 return; 3997 } 3998 tmp = strtoul(str + i + 1, NULL, 0); 3999 /* If queue_id greater that what 16-bits can represent, return */ 4000 if(tmp > 0xffff) 4001 return; 4002 4003 queue_id = (uint16_t)tmp; 4004 rx_vlan_strip_set_on_queue(port_id, queue_id, on); 4005 } 4006 else if (!strcmp(res->what, "filter")) 4007 rx_vlan_filter_set(port_id, on); 4008 else if (!strcmp(res->what, "qinq_strip")) 4009 rx_vlan_qinq_strip_set(port_id, on); 4010 else 4011 vlan_extend_set(port_id, on); 4012 4013 return; 4014 } 4015 4016 cmdline_parse_token_string_t cmd_vlan_offload_vlan = 4017 TOKEN_STRING_INITIALIZER(struct cmd_vlan_offload_result, 4018 vlan, "vlan"); 4019 cmdline_parse_token_string_t cmd_vlan_offload_set = 4020 TOKEN_STRING_INITIALIZER(struct cmd_vlan_offload_result, 4021 set, "set"); 4022 cmdline_parse_token_string_t cmd_vlan_offload_what = 4023 TOKEN_STRING_INITIALIZER(struct cmd_vlan_offload_result, 4024 what, "strip#filter#qinq_strip#extend#stripq"); 4025 cmdline_parse_token_string_t cmd_vlan_offload_on = 4026 TOKEN_STRING_INITIALIZER(struct cmd_vlan_offload_result, 4027 on, "on#off"); 4028 cmdline_parse_token_string_t cmd_vlan_offload_portid = 4029 TOKEN_STRING_INITIALIZER(struct cmd_vlan_offload_result, 4030 port_id, NULL); 4031 4032 cmdline_parse_inst_t cmd_vlan_offload = { 4033 .f = cmd_vlan_offload_parsed, 4034 .data = NULL, 4035 .help_str = "vlan set strip|filter|qinq_strip|extend|stripq on|off " 4036 "<port_id[,queue_id]>: " 4037 "Strip/Filter/QinQ for rx side Extend for both rx/tx sides", 4038 .tokens = { 4039 (void *)&cmd_vlan_offload_vlan, 4040 (void *)&cmd_vlan_offload_set, 4041 (void *)&cmd_vlan_offload_what, 4042 (void *)&cmd_vlan_offload_on, 4043 (void *)&cmd_vlan_offload_portid, 4044 NULL, 4045 }, 4046 }; 4047 4048 /* *** VLAN TPID SET ON A PORT *** */ 4049 struct cmd_vlan_tpid_result { 4050 cmdline_fixed_string_t vlan; 4051 cmdline_fixed_string_t set; 4052 cmdline_fixed_string_t vlan_type; 4053 cmdline_fixed_string_t what; 4054 uint16_t tp_id; 4055 portid_t port_id; 4056 }; 4057 4058 static void 4059 cmd_vlan_tpid_parsed(void *parsed_result, 4060 __attribute__((unused)) struct cmdline *cl, 4061 __attribute__((unused)) void *data) 4062 { 4063 struct cmd_vlan_tpid_result *res = parsed_result; 4064 enum rte_vlan_type vlan_type; 4065 4066 if (!strcmp(res->vlan_type, "inner")) 4067 vlan_type = ETH_VLAN_TYPE_INNER; 4068 else if (!strcmp(res->vlan_type, "outer")) 4069 vlan_type = ETH_VLAN_TYPE_OUTER; 4070 else { 4071 printf("Unknown vlan type\n"); 4072 return; 4073 } 4074 vlan_tpid_set(res->port_id, vlan_type, res->tp_id); 4075 } 4076 4077 cmdline_parse_token_string_t cmd_vlan_tpid_vlan = 4078 TOKEN_STRING_INITIALIZER(struct cmd_vlan_tpid_result, 4079 vlan, "vlan"); 4080 cmdline_parse_token_string_t cmd_vlan_tpid_set = 4081 TOKEN_STRING_INITIALIZER(struct cmd_vlan_tpid_result, 4082 set, "set"); 4083 cmdline_parse_token_string_t cmd_vlan_type = 4084 TOKEN_STRING_INITIALIZER(struct cmd_vlan_tpid_result, 4085 vlan_type, "inner#outer"); 4086 cmdline_parse_token_string_t cmd_vlan_tpid_what = 4087 TOKEN_STRING_INITIALIZER(struct cmd_vlan_tpid_result, 4088 what, "tpid"); 4089 cmdline_parse_token_num_t cmd_vlan_tpid_tpid = 4090 TOKEN_NUM_INITIALIZER(struct cmd_vlan_tpid_result, 4091 tp_id, UINT16); 4092 cmdline_parse_token_num_t cmd_vlan_tpid_portid = 4093 TOKEN_NUM_INITIALIZER(struct cmd_vlan_tpid_result, 4094 port_id, UINT16); 4095 4096 cmdline_parse_inst_t cmd_vlan_tpid = { 4097 .f = cmd_vlan_tpid_parsed, 4098 .data = NULL, 4099 .help_str = "vlan set inner|outer tpid <tp_id> <port_id>: " 4100 "Set the VLAN Ether type", 4101 .tokens = { 4102 (void *)&cmd_vlan_tpid_vlan, 4103 (void *)&cmd_vlan_tpid_set, 4104 (void *)&cmd_vlan_type, 4105 (void *)&cmd_vlan_tpid_what, 4106 (void *)&cmd_vlan_tpid_tpid, 4107 (void *)&cmd_vlan_tpid_portid, 4108 NULL, 4109 }, 4110 }; 4111 4112 /* *** ADD/REMOVE A VLAN IDENTIFIER TO/FROM A PORT VLAN RX FILTER *** */ 4113 struct cmd_rx_vlan_filter_result { 4114 cmdline_fixed_string_t rx_vlan; 4115 cmdline_fixed_string_t what; 4116 uint16_t vlan_id; 4117 portid_t port_id; 4118 }; 4119 4120 static void 4121 cmd_rx_vlan_filter_parsed(void *parsed_result, 4122 __attribute__((unused)) struct cmdline *cl, 4123 __attribute__((unused)) void *data) 4124 { 4125 struct cmd_rx_vlan_filter_result *res = parsed_result; 4126 4127 if (!strcmp(res->what, "add")) 4128 rx_vft_set(res->port_id, res->vlan_id, 1); 4129 else 4130 rx_vft_set(res->port_id, res->vlan_id, 0); 4131 } 4132 4133 cmdline_parse_token_string_t cmd_rx_vlan_filter_rx_vlan = 4134 TOKEN_STRING_INITIALIZER(struct cmd_rx_vlan_filter_result, 4135 rx_vlan, "rx_vlan"); 4136 cmdline_parse_token_string_t cmd_rx_vlan_filter_what = 4137 TOKEN_STRING_INITIALIZER(struct cmd_rx_vlan_filter_result, 4138 what, "add#rm"); 4139 cmdline_parse_token_num_t cmd_rx_vlan_filter_vlanid = 4140 TOKEN_NUM_INITIALIZER(struct cmd_rx_vlan_filter_result, 4141 vlan_id, UINT16); 4142 cmdline_parse_token_num_t cmd_rx_vlan_filter_portid = 4143 TOKEN_NUM_INITIALIZER(struct cmd_rx_vlan_filter_result, 4144 port_id, UINT16); 4145 4146 cmdline_parse_inst_t cmd_rx_vlan_filter = { 4147 .f = cmd_rx_vlan_filter_parsed, 4148 .data = NULL, 4149 .help_str = "rx_vlan add|rm <vlan_id> <port_id>: " 4150 "Add/Remove a VLAN identifier to/from the set of VLAN " 4151 "identifiers filtered by a port", 4152 .tokens = { 4153 (void *)&cmd_rx_vlan_filter_rx_vlan, 4154 (void *)&cmd_rx_vlan_filter_what, 4155 (void *)&cmd_rx_vlan_filter_vlanid, 4156 (void *)&cmd_rx_vlan_filter_portid, 4157 NULL, 4158 }, 4159 }; 4160 4161 /* *** ENABLE HARDWARE INSERTION OF VLAN HEADER IN TX PACKETS *** */ 4162 struct cmd_tx_vlan_set_result { 4163 cmdline_fixed_string_t tx_vlan; 4164 cmdline_fixed_string_t set; 4165 portid_t port_id; 4166 uint16_t vlan_id; 4167 }; 4168 4169 static void 4170 cmd_tx_vlan_set_parsed(void *parsed_result, 4171 __attribute__((unused)) struct cmdline *cl, 4172 __attribute__((unused)) void *data) 4173 { 4174 struct cmd_tx_vlan_set_result *res = parsed_result; 4175 4176 if (!port_is_stopped(res->port_id)) { 4177 printf("Please stop port %d first\n", res->port_id); 4178 return; 4179 } 4180 4181 tx_vlan_set(res->port_id, res->vlan_id); 4182 4183 cmd_reconfig_device_queue(res->port_id, 1, 1); 4184 } 4185 4186 cmdline_parse_token_string_t cmd_tx_vlan_set_tx_vlan = 4187 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_result, 4188 tx_vlan, "tx_vlan"); 4189 cmdline_parse_token_string_t cmd_tx_vlan_set_set = 4190 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_result, 4191 set, "set"); 4192 cmdline_parse_token_num_t cmd_tx_vlan_set_portid = 4193 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_result, 4194 port_id, UINT16); 4195 cmdline_parse_token_num_t cmd_tx_vlan_set_vlanid = 4196 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_result, 4197 vlan_id, UINT16); 4198 4199 cmdline_parse_inst_t cmd_tx_vlan_set = { 4200 .f = cmd_tx_vlan_set_parsed, 4201 .data = NULL, 4202 .help_str = "tx_vlan set <port_id> <vlan_id>: " 4203 "Enable hardware insertion of a single VLAN header " 4204 "with a given TAG Identifier in packets sent on a port", 4205 .tokens = { 4206 (void *)&cmd_tx_vlan_set_tx_vlan, 4207 (void *)&cmd_tx_vlan_set_set, 4208 (void *)&cmd_tx_vlan_set_portid, 4209 (void *)&cmd_tx_vlan_set_vlanid, 4210 NULL, 4211 }, 4212 }; 4213 4214 /* *** ENABLE HARDWARE INSERTION OF Double VLAN HEADER IN TX PACKETS *** */ 4215 struct cmd_tx_vlan_set_qinq_result { 4216 cmdline_fixed_string_t tx_vlan; 4217 cmdline_fixed_string_t set; 4218 portid_t port_id; 4219 uint16_t vlan_id; 4220 uint16_t vlan_id_outer; 4221 }; 4222 4223 static void 4224 cmd_tx_vlan_set_qinq_parsed(void *parsed_result, 4225 __attribute__((unused)) struct cmdline *cl, 4226 __attribute__((unused)) void *data) 4227 { 4228 struct cmd_tx_vlan_set_qinq_result *res = parsed_result; 4229 4230 if (!port_is_stopped(res->port_id)) { 4231 printf("Please stop port %d first\n", res->port_id); 4232 return; 4233 } 4234 4235 tx_qinq_set(res->port_id, res->vlan_id, res->vlan_id_outer); 4236 4237 cmd_reconfig_device_queue(res->port_id, 1, 1); 4238 } 4239 4240 cmdline_parse_token_string_t cmd_tx_vlan_set_qinq_tx_vlan = 4241 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_qinq_result, 4242 tx_vlan, "tx_vlan"); 4243 cmdline_parse_token_string_t cmd_tx_vlan_set_qinq_set = 4244 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_qinq_result, 4245 set, "set"); 4246 cmdline_parse_token_num_t cmd_tx_vlan_set_qinq_portid = 4247 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_qinq_result, 4248 port_id, UINT16); 4249 cmdline_parse_token_num_t cmd_tx_vlan_set_qinq_vlanid = 4250 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_qinq_result, 4251 vlan_id, UINT16); 4252 cmdline_parse_token_num_t cmd_tx_vlan_set_qinq_vlanid_outer = 4253 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_qinq_result, 4254 vlan_id_outer, UINT16); 4255 4256 cmdline_parse_inst_t cmd_tx_vlan_set_qinq = { 4257 .f = cmd_tx_vlan_set_qinq_parsed, 4258 .data = NULL, 4259 .help_str = "tx_vlan set <port_id> <vlan_id> <outer_vlan_id>: " 4260 "Enable hardware insertion of double VLAN header " 4261 "with given TAG Identifiers in packets sent on a port", 4262 .tokens = { 4263 (void *)&cmd_tx_vlan_set_qinq_tx_vlan, 4264 (void *)&cmd_tx_vlan_set_qinq_set, 4265 (void *)&cmd_tx_vlan_set_qinq_portid, 4266 (void *)&cmd_tx_vlan_set_qinq_vlanid, 4267 (void *)&cmd_tx_vlan_set_qinq_vlanid_outer, 4268 NULL, 4269 }, 4270 }; 4271 4272 /* *** ENABLE/DISABLE PORT BASED TX VLAN INSERTION *** */ 4273 struct cmd_tx_vlan_set_pvid_result { 4274 cmdline_fixed_string_t tx_vlan; 4275 cmdline_fixed_string_t set; 4276 cmdline_fixed_string_t pvid; 4277 portid_t port_id; 4278 uint16_t vlan_id; 4279 cmdline_fixed_string_t mode; 4280 }; 4281 4282 static void 4283 cmd_tx_vlan_set_pvid_parsed(void *parsed_result, 4284 __attribute__((unused)) struct cmdline *cl, 4285 __attribute__((unused)) void *data) 4286 { 4287 struct cmd_tx_vlan_set_pvid_result *res = parsed_result; 4288 4289 if (strcmp(res->mode, "on") == 0) 4290 tx_vlan_pvid_set(res->port_id, res->vlan_id, 1); 4291 else 4292 tx_vlan_pvid_set(res->port_id, res->vlan_id, 0); 4293 } 4294 4295 cmdline_parse_token_string_t cmd_tx_vlan_set_pvid_tx_vlan = 4296 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_pvid_result, 4297 tx_vlan, "tx_vlan"); 4298 cmdline_parse_token_string_t cmd_tx_vlan_set_pvid_set = 4299 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_pvid_result, 4300 set, "set"); 4301 cmdline_parse_token_string_t cmd_tx_vlan_set_pvid_pvid = 4302 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_pvid_result, 4303 pvid, "pvid"); 4304 cmdline_parse_token_num_t cmd_tx_vlan_set_pvid_port_id = 4305 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_pvid_result, 4306 port_id, UINT16); 4307 cmdline_parse_token_num_t cmd_tx_vlan_set_pvid_vlan_id = 4308 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_pvid_result, 4309 vlan_id, UINT16); 4310 cmdline_parse_token_string_t cmd_tx_vlan_set_pvid_mode = 4311 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_pvid_result, 4312 mode, "on#off"); 4313 4314 cmdline_parse_inst_t cmd_tx_vlan_set_pvid = { 4315 .f = cmd_tx_vlan_set_pvid_parsed, 4316 .data = NULL, 4317 .help_str = "tx_vlan set pvid <port_id> <vlan_id> on|off", 4318 .tokens = { 4319 (void *)&cmd_tx_vlan_set_pvid_tx_vlan, 4320 (void *)&cmd_tx_vlan_set_pvid_set, 4321 (void *)&cmd_tx_vlan_set_pvid_pvid, 4322 (void *)&cmd_tx_vlan_set_pvid_port_id, 4323 (void *)&cmd_tx_vlan_set_pvid_vlan_id, 4324 (void *)&cmd_tx_vlan_set_pvid_mode, 4325 NULL, 4326 }, 4327 }; 4328 4329 /* *** DISABLE HARDWARE INSERTION OF VLAN HEADER IN TX PACKETS *** */ 4330 struct cmd_tx_vlan_reset_result { 4331 cmdline_fixed_string_t tx_vlan; 4332 cmdline_fixed_string_t reset; 4333 portid_t port_id; 4334 }; 4335 4336 static void 4337 cmd_tx_vlan_reset_parsed(void *parsed_result, 4338 __attribute__((unused)) struct cmdline *cl, 4339 __attribute__((unused)) void *data) 4340 { 4341 struct cmd_tx_vlan_reset_result *res = parsed_result; 4342 4343 if (!port_is_stopped(res->port_id)) { 4344 printf("Please stop port %d first\n", res->port_id); 4345 return; 4346 } 4347 4348 tx_vlan_reset(res->port_id); 4349 4350 cmd_reconfig_device_queue(res->port_id, 1, 1); 4351 } 4352 4353 cmdline_parse_token_string_t cmd_tx_vlan_reset_tx_vlan = 4354 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_reset_result, 4355 tx_vlan, "tx_vlan"); 4356 cmdline_parse_token_string_t cmd_tx_vlan_reset_reset = 4357 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_reset_result, 4358 reset, "reset"); 4359 cmdline_parse_token_num_t cmd_tx_vlan_reset_portid = 4360 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_reset_result, 4361 port_id, UINT16); 4362 4363 cmdline_parse_inst_t cmd_tx_vlan_reset = { 4364 .f = cmd_tx_vlan_reset_parsed, 4365 .data = NULL, 4366 .help_str = "tx_vlan reset <port_id>: Disable hardware insertion of a " 4367 "VLAN header in packets sent on a port", 4368 .tokens = { 4369 (void *)&cmd_tx_vlan_reset_tx_vlan, 4370 (void *)&cmd_tx_vlan_reset_reset, 4371 (void *)&cmd_tx_vlan_reset_portid, 4372 NULL, 4373 }, 4374 }; 4375 4376 4377 /* *** ENABLE HARDWARE INSERTION OF CHECKSUM IN TX PACKETS *** */ 4378 struct cmd_csum_result { 4379 cmdline_fixed_string_t csum; 4380 cmdline_fixed_string_t mode; 4381 cmdline_fixed_string_t proto; 4382 cmdline_fixed_string_t hwsw; 4383 portid_t port_id; 4384 }; 4385 4386 static void 4387 csum_show(int port_id) 4388 { 4389 struct rte_eth_dev_info dev_info; 4390 uint64_t tx_offloads; 4391 int ret; 4392 4393 tx_offloads = ports[port_id].dev_conf.txmode.offloads; 4394 printf("Parse tunnel is %s\n", 4395 (ports[port_id].parse_tunnel) ? "on" : "off"); 4396 printf("IP checksum offload is %s\n", 4397 (tx_offloads & DEV_TX_OFFLOAD_IPV4_CKSUM) ? "hw" : "sw"); 4398 printf("UDP checksum offload is %s\n", 4399 (tx_offloads & DEV_TX_OFFLOAD_UDP_CKSUM) ? "hw" : "sw"); 4400 printf("TCP checksum offload is %s\n", 4401 (tx_offloads & DEV_TX_OFFLOAD_TCP_CKSUM) ? "hw" : "sw"); 4402 printf("SCTP checksum offload is %s\n", 4403 (tx_offloads & DEV_TX_OFFLOAD_SCTP_CKSUM) ? "hw" : "sw"); 4404 printf("Outer-Ip checksum offload is %s\n", 4405 (tx_offloads & DEV_TX_OFFLOAD_OUTER_IPV4_CKSUM) ? "hw" : "sw"); 4406 printf("Outer-Udp checksum offload is %s\n", 4407 (tx_offloads & DEV_TX_OFFLOAD_OUTER_UDP_CKSUM) ? "hw" : "sw"); 4408 4409 /* display warnings if configuration is not supported by the NIC */ 4410 ret = eth_dev_info_get_print_err(port_id, &dev_info); 4411 if (ret != 0) 4412 return; 4413 4414 if ((tx_offloads & DEV_TX_OFFLOAD_IPV4_CKSUM) && 4415 (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_IPV4_CKSUM) == 0) { 4416 printf("Warning: hardware IP checksum enabled but not " 4417 "supported by port %d\n", port_id); 4418 } 4419 if ((tx_offloads & DEV_TX_OFFLOAD_UDP_CKSUM) && 4420 (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_UDP_CKSUM) == 0) { 4421 printf("Warning: hardware UDP checksum enabled but not " 4422 "supported by port %d\n", port_id); 4423 } 4424 if ((tx_offloads & DEV_TX_OFFLOAD_TCP_CKSUM) && 4425 (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_TCP_CKSUM) == 0) { 4426 printf("Warning: hardware TCP checksum enabled but not " 4427 "supported by port %d\n", port_id); 4428 } 4429 if ((tx_offloads & DEV_TX_OFFLOAD_SCTP_CKSUM) && 4430 (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_SCTP_CKSUM) == 0) { 4431 printf("Warning: hardware SCTP checksum enabled but not " 4432 "supported by port %d\n", port_id); 4433 } 4434 if ((tx_offloads & DEV_TX_OFFLOAD_OUTER_IPV4_CKSUM) && 4435 (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_OUTER_IPV4_CKSUM) == 0) { 4436 printf("Warning: hardware outer IP checksum enabled but not " 4437 "supported by port %d\n", port_id); 4438 } 4439 if ((tx_offloads & DEV_TX_OFFLOAD_OUTER_UDP_CKSUM) && 4440 (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_OUTER_UDP_CKSUM) 4441 == 0) { 4442 printf("Warning: hardware outer UDP checksum enabled but not " 4443 "supported by port %d\n", port_id); 4444 } 4445 } 4446 4447 static void 4448 cmd_config_queue_tx_offloads(struct rte_port *port) 4449 { 4450 int k; 4451 4452 /* Apply queue tx offloads configuration */ 4453 for (k = 0; k < port->dev_info.max_rx_queues; k++) 4454 port->tx_conf[k].offloads = 4455 port->dev_conf.txmode.offloads; 4456 } 4457 4458 static void 4459 cmd_csum_parsed(void *parsed_result, 4460 __attribute__((unused)) struct cmdline *cl, 4461 __attribute__((unused)) void *data) 4462 { 4463 struct cmd_csum_result *res = parsed_result; 4464 int hw = 0; 4465 uint64_t csum_offloads = 0; 4466 struct rte_eth_dev_info dev_info; 4467 int ret; 4468 4469 if (port_id_is_invalid(res->port_id, ENABLED_WARN)) { 4470 printf("invalid port %d\n", res->port_id); 4471 return; 4472 } 4473 if (!port_is_stopped(res->port_id)) { 4474 printf("Please stop port %d first\n", res->port_id); 4475 return; 4476 } 4477 4478 ret = eth_dev_info_get_print_err(res->port_id, &dev_info); 4479 if (ret != 0) 4480 return; 4481 4482 if (!strcmp(res->mode, "set")) { 4483 4484 if (!strcmp(res->hwsw, "hw")) 4485 hw = 1; 4486 4487 if (!strcmp(res->proto, "ip")) { 4488 if (hw == 0 || (dev_info.tx_offload_capa & 4489 DEV_TX_OFFLOAD_IPV4_CKSUM)) { 4490 csum_offloads |= DEV_TX_OFFLOAD_IPV4_CKSUM; 4491 } else { 4492 printf("IP checksum offload is not supported " 4493 "by port %u\n", res->port_id); 4494 } 4495 } else if (!strcmp(res->proto, "udp")) { 4496 if (hw == 0 || (dev_info.tx_offload_capa & 4497 DEV_TX_OFFLOAD_UDP_CKSUM)) { 4498 csum_offloads |= DEV_TX_OFFLOAD_UDP_CKSUM; 4499 } else { 4500 printf("UDP checksum offload is not supported " 4501 "by port %u\n", res->port_id); 4502 } 4503 } else if (!strcmp(res->proto, "tcp")) { 4504 if (hw == 0 || (dev_info.tx_offload_capa & 4505 DEV_TX_OFFLOAD_TCP_CKSUM)) { 4506 csum_offloads |= DEV_TX_OFFLOAD_TCP_CKSUM; 4507 } else { 4508 printf("TCP checksum offload is not supported " 4509 "by port %u\n", res->port_id); 4510 } 4511 } else if (!strcmp(res->proto, "sctp")) { 4512 if (hw == 0 || (dev_info.tx_offload_capa & 4513 DEV_TX_OFFLOAD_SCTP_CKSUM)) { 4514 csum_offloads |= DEV_TX_OFFLOAD_SCTP_CKSUM; 4515 } else { 4516 printf("SCTP checksum offload is not supported " 4517 "by port %u\n", res->port_id); 4518 } 4519 } else if (!strcmp(res->proto, "outer-ip")) { 4520 if (hw == 0 || (dev_info.tx_offload_capa & 4521 DEV_TX_OFFLOAD_OUTER_IPV4_CKSUM)) { 4522 csum_offloads |= 4523 DEV_TX_OFFLOAD_OUTER_IPV4_CKSUM; 4524 } else { 4525 printf("Outer IP checksum offload is not " 4526 "supported by port %u\n", res->port_id); 4527 } 4528 } else if (!strcmp(res->proto, "outer-udp")) { 4529 if (hw == 0 || (dev_info.tx_offload_capa & 4530 DEV_TX_OFFLOAD_OUTER_UDP_CKSUM)) { 4531 csum_offloads |= 4532 DEV_TX_OFFLOAD_OUTER_UDP_CKSUM; 4533 } else { 4534 printf("Outer UDP checksum offload is not " 4535 "supported by port %u\n", res->port_id); 4536 } 4537 } 4538 4539 if (hw) { 4540 ports[res->port_id].dev_conf.txmode.offloads |= 4541 csum_offloads; 4542 } else { 4543 ports[res->port_id].dev_conf.txmode.offloads &= 4544 (~csum_offloads); 4545 } 4546 cmd_config_queue_tx_offloads(&ports[res->port_id]); 4547 } 4548 csum_show(res->port_id); 4549 4550 cmd_reconfig_device_queue(res->port_id, 1, 1); 4551 } 4552 4553 cmdline_parse_token_string_t cmd_csum_csum = 4554 TOKEN_STRING_INITIALIZER(struct cmd_csum_result, 4555 csum, "csum"); 4556 cmdline_parse_token_string_t cmd_csum_mode = 4557 TOKEN_STRING_INITIALIZER(struct cmd_csum_result, 4558 mode, "set"); 4559 cmdline_parse_token_string_t cmd_csum_proto = 4560 TOKEN_STRING_INITIALIZER(struct cmd_csum_result, 4561 proto, "ip#tcp#udp#sctp#outer-ip#outer-udp"); 4562 cmdline_parse_token_string_t cmd_csum_hwsw = 4563 TOKEN_STRING_INITIALIZER(struct cmd_csum_result, 4564 hwsw, "hw#sw"); 4565 cmdline_parse_token_num_t cmd_csum_portid = 4566 TOKEN_NUM_INITIALIZER(struct cmd_csum_result, 4567 port_id, UINT16); 4568 4569 cmdline_parse_inst_t cmd_csum_set = { 4570 .f = cmd_csum_parsed, 4571 .data = NULL, 4572 .help_str = "csum set ip|tcp|udp|sctp|outer-ip|outer-udp hw|sw <port_id>: " 4573 "Enable/Disable hardware calculation of L3/L4 checksum when " 4574 "using csum forward engine", 4575 .tokens = { 4576 (void *)&cmd_csum_csum, 4577 (void *)&cmd_csum_mode, 4578 (void *)&cmd_csum_proto, 4579 (void *)&cmd_csum_hwsw, 4580 (void *)&cmd_csum_portid, 4581 NULL, 4582 }, 4583 }; 4584 4585 cmdline_parse_token_string_t cmd_csum_mode_show = 4586 TOKEN_STRING_INITIALIZER(struct cmd_csum_result, 4587 mode, "show"); 4588 4589 cmdline_parse_inst_t cmd_csum_show = { 4590 .f = cmd_csum_parsed, 4591 .data = NULL, 4592 .help_str = "csum show <port_id>: Show checksum offload configuration", 4593 .tokens = { 4594 (void *)&cmd_csum_csum, 4595 (void *)&cmd_csum_mode_show, 4596 (void *)&cmd_csum_portid, 4597 NULL, 4598 }, 4599 }; 4600 4601 /* Enable/disable tunnel parsing */ 4602 struct cmd_csum_tunnel_result { 4603 cmdline_fixed_string_t csum; 4604 cmdline_fixed_string_t parse; 4605 cmdline_fixed_string_t onoff; 4606 portid_t port_id; 4607 }; 4608 4609 static void 4610 cmd_csum_tunnel_parsed(void *parsed_result, 4611 __attribute__((unused)) struct cmdline *cl, 4612 __attribute__((unused)) void *data) 4613 { 4614 struct cmd_csum_tunnel_result *res = parsed_result; 4615 4616 if (port_id_is_invalid(res->port_id, ENABLED_WARN)) 4617 return; 4618 4619 if (!strcmp(res->onoff, "on")) 4620 ports[res->port_id].parse_tunnel = 1; 4621 else 4622 ports[res->port_id].parse_tunnel = 0; 4623 4624 csum_show(res->port_id); 4625 } 4626 4627 cmdline_parse_token_string_t cmd_csum_tunnel_csum = 4628 TOKEN_STRING_INITIALIZER(struct cmd_csum_tunnel_result, 4629 csum, "csum"); 4630 cmdline_parse_token_string_t cmd_csum_tunnel_parse = 4631 TOKEN_STRING_INITIALIZER(struct cmd_csum_tunnel_result, 4632 parse, "parse-tunnel"); 4633 cmdline_parse_token_string_t cmd_csum_tunnel_onoff = 4634 TOKEN_STRING_INITIALIZER(struct cmd_csum_tunnel_result, 4635 onoff, "on#off"); 4636 cmdline_parse_token_num_t cmd_csum_tunnel_portid = 4637 TOKEN_NUM_INITIALIZER(struct cmd_csum_tunnel_result, 4638 port_id, UINT16); 4639 4640 cmdline_parse_inst_t cmd_csum_tunnel = { 4641 .f = cmd_csum_tunnel_parsed, 4642 .data = NULL, 4643 .help_str = "csum parse-tunnel on|off <port_id>: " 4644 "Enable/Disable parsing of tunnels for csum engine", 4645 .tokens = { 4646 (void *)&cmd_csum_tunnel_csum, 4647 (void *)&cmd_csum_tunnel_parse, 4648 (void *)&cmd_csum_tunnel_onoff, 4649 (void *)&cmd_csum_tunnel_portid, 4650 NULL, 4651 }, 4652 }; 4653 4654 /* *** ENABLE HARDWARE SEGMENTATION IN TX NON-TUNNELED PACKETS *** */ 4655 struct cmd_tso_set_result { 4656 cmdline_fixed_string_t tso; 4657 cmdline_fixed_string_t mode; 4658 uint16_t tso_segsz; 4659 portid_t port_id; 4660 }; 4661 4662 static void 4663 cmd_tso_set_parsed(void *parsed_result, 4664 __attribute__((unused)) struct cmdline *cl, 4665 __attribute__((unused)) void *data) 4666 { 4667 struct cmd_tso_set_result *res = parsed_result; 4668 struct rte_eth_dev_info dev_info; 4669 int ret; 4670 4671 if (port_id_is_invalid(res->port_id, ENABLED_WARN)) 4672 return; 4673 if (!port_is_stopped(res->port_id)) { 4674 printf("Please stop port %d first\n", res->port_id); 4675 return; 4676 } 4677 4678 if (!strcmp(res->mode, "set")) 4679 ports[res->port_id].tso_segsz = res->tso_segsz; 4680 4681 ret = eth_dev_info_get_print_err(res->port_id, &dev_info); 4682 if (ret != 0) 4683 return; 4684 4685 if ((ports[res->port_id].tso_segsz != 0) && 4686 (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_TCP_TSO) == 0) { 4687 printf("Error: TSO is not supported by port %d\n", 4688 res->port_id); 4689 return; 4690 } 4691 4692 if (ports[res->port_id].tso_segsz == 0) { 4693 ports[res->port_id].dev_conf.txmode.offloads &= 4694 ~DEV_TX_OFFLOAD_TCP_TSO; 4695 printf("TSO for non-tunneled packets is disabled\n"); 4696 } else { 4697 ports[res->port_id].dev_conf.txmode.offloads |= 4698 DEV_TX_OFFLOAD_TCP_TSO; 4699 printf("TSO segment size for non-tunneled packets is %d\n", 4700 ports[res->port_id].tso_segsz); 4701 } 4702 cmd_config_queue_tx_offloads(&ports[res->port_id]); 4703 4704 /* display warnings if configuration is not supported by the NIC */ 4705 ret = eth_dev_info_get_print_err(res->port_id, &dev_info); 4706 if (ret != 0) 4707 return; 4708 4709 if ((ports[res->port_id].tso_segsz != 0) && 4710 (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_TCP_TSO) == 0) { 4711 printf("Warning: TSO enabled but not " 4712 "supported by port %d\n", res->port_id); 4713 } 4714 4715 cmd_reconfig_device_queue(res->port_id, 1, 1); 4716 } 4717 4718 cmdline_parse_token_string_t cmd_tso_set_tso = 4719 TOKEN_STRING_INITIALIZER(struct cmd_tso_set_result, 4720 tso, "tso"); 4721 cmdline_parse_token_string_t cmd_tso_set_mode = 4722 TOKEN_STRING_INITIALIZER(struct cmd_tso_set_result, 4723 mode, "set"); 4724 cmdline_parse_token_num_t cmd_tso_set_tso_segsz = 4725 TOKEN_NUM_INITIALIZER(struct cmd_tso_set_result, 4726 tso_segsz, UINT16); 4727 cmdline_parse_token_num_t cmd_tso_set_portid = 4728 TOKEN_NUM_INITIALIZER(struct cmd_tso_set_result, 4729 port_id, UINT16); 4730 4731 cmdline_parse_inst_t cmd_tso_set = { 4732 .f = cmd_tso_set_parsed, 4733 .data = NULL, 4734 .help_str = "tso set <tso_segsz> <port_id>: " 4735 "Set TSO segment size of non-tunneled packets for csum engine " 4736 "(0 to disable)", 4737 .tokens = { 4738 (void *)&cmd_tso_set_tso, 4739 (void *)&cmd_tso_set_mode, 4740 (void *)&cmd_tso_set_tso_segsz, 4741 (void *)&cmd_tso_set_portid, 4742 NULL, 4743 }, 4744 }; 4745 4746 cmdline_parse_token_string_t cmd_tso_show_mode = 4747 TOKEN_STRING_INITIALIZER(struct cmd_tso_set_result, 4748 mode, "show"); 4749 4750 4751 cmdline_parse_inst_t cmd_tso_show = { 4752 .f = cmd_tso_set_parsed, 4753 .data = NULL, 4754 .help_str = "tso show <port_id>: " 4755 "Show TSO segment size of non-tunneled packets for csum engine", 4756 .tokens = { 4757 (void *)&cmd_tso_set_tso, 4758 (void *)&cmd_tso_show_mode, 4759 (void *)&cmd_tso_set_portid, 4760 NULL, 4761 }, 4762 }; 4763 4764 /* *** ENABLE HARDWARE SEGMENTATION IN TX TUNNELED PACKETS *** */ 4765 struct cmd_tunnel_tso_set_result { 4766 cmdline_fixed_string_t tso; 4767 cmdline_fixed_string_t mode; 4768 uint16_t tso_segsz; 4769 portid_t port_id; 4770 }; 4771 4772 static struct rte_eth_dev_info 4773 check_tunnel_tso_nic_support(portid_t port_id) 4774 { 4775 struct rte_eth_dev_info dev_info; 4776 4777 if (eth_dev_info_get_print_err(port_id, &dev_info) != 0) 4778 return dev_info; 4779 4780 if (!(dev_info.tx_offload_capa & DEV_TX_OFFLOAD_VXLAN_TNL_TSO)) 4781 printf("Warning: VXLAN TUNNEL TSO not supported therefore " 4782 "not enabled for port %d\n", port_id); 4783 if (!(dev_info.tx_offload_capa & DEV_TX_OFFLOAD_GRE_TNL_TSO)) 4784 printf("Warning: GRE TUNNEL TSO not supported therefore " 4785 "not enabled for port %d\n", port_id); 4786 if (!(dev_info.tx_offload_capa & DEV_TX_OFFLOAD_IPIP_TNL_TSO)) 4787 printf("Warning: IPIP TUNNEL TSO not supported therefore " 4788 "not enabled for port %d\n", port_id); 4789 if (!(dev_info.tx_offload_capa & DEV_TX_OFFLOAD_GENEVE_TNL_TSO)) 4790 printf("Warning: GENEVE TUNNEL TSO not supported therefore " 4791 "not enabled for port %d\n", port_id); 4792 if (!(dev_info.tx_offload_capa & DEV_TX_OFFLOAD_IP_TNL_TSO)) 4793 printf("Warning: IP TUNNEL TSO not supported therefore " 4794 "not enabled for port %d\n", port_id); 4795 if (!(dev_info.tx_offload_capa & DEV_TX_OFFLOAD_UDP_TNL_TSO)) 4796 printf("Warning: UDP TUNNEL TSO not supported therefore " 4797 "not enabled for port %d\n", port_id); 4798 return dev_info; 4799 } 4800 4801 static void 4802 cmd_tunnel_tso_set_parsed(void *parsed_result, 4803 __attribute__((unused)) struct cmdline *cl, 4804 __attribute__((unused)) void *data) 4805 { 4806 struct cmd_tunnel_tso_set_result *res = parsed_result; 4807 struct rte_eth_dev_info dev_info; 4808 4809 if (port_id_is_invalid(res->port_id, ENABLED_WARN)) 4810 return; 4811 if (!port_is_stopped(res->port_id)) { 4812 printf("Please stop port %d first\n", res->port_id); 4813 return; 4814 } 4815 4816 if (!strcmp(res->mode, "set")) 4817 ports[res->port_id].tunnel_tso_segsz = res->tso_segsz; 4818 4819 dev_info = check_tunnel_tso_nic_support(res->port_id); 4820 if (ports[res->port_id].tunnel_tso_segsz == 0) { 4821 ports[res->port_id].dev_conf.txmode.offloads &= 4822 ~(DEV_TX_OFFLOAD_VXLAN_TNL_TSO | 4823 DEV_TX_OFFLOAD_GRE_TNL_TSO | 4824 DEV_TX_OFFLOAD_IPIP_TNL_TSO | 4825 DEV_TX_OFFLOAD_GENEVE_TNL_TSO | 4826 DEV_TX_OFFLOAD_IP_TNL_TSO | 4827 DEV_TX_OFFLOAD_UDP_TNL_TSO); 4828 printf("TSO for tunneled packets is disabled\n"); 4829 } else { 4830 uint64_t tso_offloads = (DEV_TX_OFFLOAD_VXLAN_TNL_TSO | 4831 DEV_TX_OFFLOAD_GRE_TNL_TSO | 4832 DEV_TX_OFFLOAD_IPIP_TNL_TSO | 4833 DEV_TX_OFFLOAD_GENEVE_TNL_TSO | 4834 DEV_TX_OFFLOAD_IP_TNL_TSO | 4835 DEV_TX_OFFLOAD_UDP_TNL_TSO); 4836 4837 ports[res->port_id].dev_conf.txmode.offloads |= 4838 (tso_offloads & dev_info.tx_offload_capa); 4839 printf("TSO segment size for tunneled packets is %d\n", 4840 ports[res->port_id].tunnel_tso_segsz); 4841 4842 /* Below conditions are needed to make it work: 4843 * (1) tunnel TSO is supported by the NIC; 4844 * (2) "csum parse_tunnel" must be set so that tunneled pkts 4845 * are recognized; 4846 * (3) for tunneled pkts with outer L3 of IPv4, 4847 * "csum set outer-ip" must be set to hw, because after tso, 4848 * total_len of outer IP header is changed, and the checksum 4849 * of outer IP header calculated by sw should be wrong; that 4850 * is not necessary for IPv6 tunneled pkts because there's no 4851 * checksum in IP header anymore. 4852 */ 4853 4854 if (!ports[res->port_id].parse_tunnel) 4855 printf("Warning: csum parse_tunnel must be set " 4856 "so that tunneled packets are recognized\n"); 4857 if (!(ports[res->port_id].dev_conf.txmode.offloads & 4858 DEV_TX_OFFLOAD_OUTER_IPV4_CKSUM)) 4859 printf("Warning: csum set outer-ip must be set to hw " 4860 "if outer L3 is IPv4; not necessary for IPv6\n"); 4861 } 4862 4863 cmd_config_queue_tx_offloads(&ports[res->port_id]); 4864 cmd_reconfig_device_queue(res->port_id, 1, 1); 4865 } 4866 4867 cmdline_parse_token_string_t cmd_tunnel_tso_set_tso = 4868 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_tso_set_result, 4869 tso, "tunnel_tso"); 4870 cmdline_parse_token_string_t cmd_tunnel_tso_set_mode = 4871 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_tso_set_result, 4872 mode, "set"); 4873 cmdline_parse_token_num_t cmd_tunnel_tso_set_tso_segsz = 4874 TOKEN_NUM_INITIALIZER(struct cmd_tunnel_tso_set_result, 4875 tso_segsz, UINT16); 4876 cmdline_parse_token_num_t cmd_tunnel_tso_set_portid = 4877 TOKEN_NUM_INITIALIZER(struct cmd_tunnel_tso_set_result, 4878 port_id, UINT16); 4879 4880 cmdline_parse_inst_t cmd_tunnel_tso_set = { 4881 .f = cmd_tunnel_tso_set_parsed, 4882 .data = NULL, 4883 .help_str = "tunnel_tso set <tso_segsz> <port_id>: " 4884 "Set TSO segment size of tunneled packets for csum engine " 4885 "(0 to disable)", 4886 .tokens = { 4887 (void *)&cmd_tunnel_tso_set_tso, 4888 (void *)&cmd_tunnel_tso_set_mode, 4889 (void *)&cmd_tunnel_tso_set_tso_segsz, 4890 (void *)&cmd_tunnel_tso_set_portid, 4891 NULL, 4892 }, 4893 }; 4894 4895 cmdline_parse_token_string_t cmd_tunnel_tso_show_mode = 4896 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_tso_set_result, 4897 mode, "show"); 4898 4899 4900 cmdline_parse_inst_t cmd_tunnel_tso_show = { 4901 .f = cmd_tunnel_tso_set_parsed, 4902 .data = NULL, 4903 .help_str = "tunnel_tso show <port_id> " 4904 "Show TSO segment size of tunneled packets for csum engine", 4905 .tokens = { 4906 (void *)&cmd_tunnel_tso_set_tso, 4907 (void *)&cmd_tunnel_tso_show_mode, 4908 (void *)&cmd_tunnel_tso_set_portid, 4909 NULL, 4910 }, 4911 }; 4912 4913 /* *** SET GRO FOR A PORT *** */ 4914 struct cmd_gro_enable_result { 4915 cmdline_fixed_string_t cmd_set; 4916 cmdline_fixed_string_t cmd_port; 4917 cmdline_fixed_string_t cmd_keyword; 4918 cmdline_fixed_string_t cmd_onoff; 4919 portid_t cmd_pid; 4920 }; 4921 4922 static void 4923 cmd_gro_enable_parsed(void *parsed_result, 4924 __attribute__((unused)) struct cmdline *cl, 4925 __attribute__((unused)) void *data) 4926 { 4927 struct cmd_gro_enable_result *res; 4928 4929 res = parsed_result; 4930 if (!strcmp(res->cmd_keyword, "gro")) 4931 setup_gro(res->cmd_onoff, res->cmd_pid); 4932 } 4933 4934 cmdline_parse_token_string_t cmd_gro_enable_set = 4935 TOKEN_STRING_INITIALIZER(struct cmd_gro_enable_result, 4936 cmd_set, "set"); 4937 cmdline_parse_token_string_t cmd_gro_enable_port = 4938 TOKEN_STRING_INITIALIZER(struct cmd_gro_enable_result, 4939 cmd_keyword, "port"); 4940 cmdline_parse_token_num_t cmd_gro_enable_pid = 4941 TOKEN_NUM_INITIALIZER(struct cmd_gro_enable_result, 4942 cmd_pid, UINT16); 4943 cmdline_parse_token_string_t cmd_gro_enable_keyword = 4944 TOKEN_STRING_INITIALIZER(struct cmd_gro_enable_result, 4945 cmd_keyword, "gro"); 4946 cmdline_parse_token_string_t cmd_gro_enable_onoff = 4947 TOKEN_STRING_INITIALIZER(struct cmd_gro_enable_result, 4948 cmd_onoff, "on#off"); 4949 4950 cmdline_parse_inst_t cmd_gro_enable = { 4951 .f = cmd_gro_enable_parsed, 4952 .data = NULL, 4953 .help_str = "set port <port_id> gro on|off", 4954 .tokens = { 4955 (void *)&cmd_gro_enable_set, 4956 (void *)&cmd_gro_enable_port, 4957 (void *)&cmd_gro_enable_pid, 4958 (void *)&cmd_gro_enable_keyword, 4959 (void *)&cmd_gro_enable_onoff, 4960 NULL, 4961 }, 4962 }; 4963 4964 /* *** DISPLAY GRO CONFIGURATION *** */ 4965 struct cmd_gro_show_result { 4966 cmdline_fixed_string_t cmd_show; 4967 cmdline_fixed_string_t cmd_port; 4968 cmdline_fixed_string_t cmd_keyword; 4969 portid_t cmd_pid; 4970 }; 4971 4972 static void 4973 cmd_gro_show_parsed(void *parsed_result, 4974 __attribute__((unused)) struct cmdline *cl, 4975 __attribute__((unused)) void *data) 4976 { 4977 struct cmd_gro_show_result *res; 4978 4979 res = parsed_result; 4980 if (!strcmp(res->cmd_keyword, "gro")) 4981 show_gro(res->cmd_pid); 4982 } 4983 4984 cmdline_parse_token_string_t cmd_gro_show_show = 4985 TOKEN_STRING_INITIALIZER(struct cmd_gro_show_result, 4986 cmd_show, "show"); 4987 cmdline_parse_token_string_t cmd_gro_show_port = 4988 TOKEN_STRING_INITIALIZER(struct cmd_gro_show_result, 4989 cmd_port, "port"); 4990 cmdline_parse_token_num_t cmd_gro_show_pid = 4991 TOKEN_NUM_INITIALIZER(struct cmd_gro_show_result, 4992 cmd_pid, UINT16); 4993 cmdline_parse_token_string_t cmd_gro_show_keyword = 4994 TOKEN_STRING_INITIALIZER(struct cmd_gro_show_result, 4995 cmd_keyword, "gro"); 4996 4997 cmdline_parse_inst_t cmd_gro_show = { 4998 .f = cmd_gro_show_parsed, 4999 .data = NULL, 5000 .help_str = "show port <port_id> gro", 5001 .tokens = { 5002 (void *)&cmd_gro_show_show, 5003 (void *)&cmd_gro_show_port, 5004 (void *)&cmd_gro_show_pid, 5005 (void *)&cmd_gro_show_keyword, 5006 NULL, 5007 }, 5008 }; 5009 5010 /* *** SET FLUSH CYCLES FOR GRO *** */ 5011 struct cmd_gro_flush_result { 5012 cmdline_fixed_string_t cmd_set; 5013 cmdline_fixed_string_t cmd_keyword; 5014 cmdline_fixed_string_t cmd_flush; 5015 uint8_t cmd_cycles; 5016 }; 5017 5018 static void 5019 cmd_gro_flush_parsed(void *parsed_result, 5020 __attribute__((unused)) struct cmdline *cl, 5021 __attribute__((unused)) void *data) 5022 { 5023 struct cmd_gro_flush_result *res; 5024 5025 res = parsed_result; 5026 if ((!strcmp(res->cmd_keyword, "gro")) && 5027 (!strcmp(res->cmd_flush, "flush"))) 5028 setup_gro_flush_cycles(res->cmd_cycles); 5029 } 5030 5031 cmdline_parse_token_string_t cmd_gro_flush_set = 5032 TOKEN_STRING_INITIALIZER(struct cmd_gro_flush_result, 5033 cmd_set, "set"); 5034 cmdline_parse_token_string_t cmd_gro_flush_keyword = 5035 TOKEN_STRING_INITIALIZER(struct cmd_gro_flush_result, 5036 cmd_keyword, "gro"); 5037 cmdline_parse_token_string_t cmd_gro_flush_flush = 5038 TOKEN_STRING_INITIALIZER(struct cmd_gro_flush_result, 5039 cmd_flush, "flush"); 5040 cmdline_parse_token_num_t cmd_gro_flush_cycles = 5041 TOKEN_NUM_INITIALIZER(struct cmd_gro_flush_result, 5042 cmd_cycles, UINT8); 5043 5044 cmdline_parse_inst_t cmd_gro_flush = { 5045 .f = cmd_gro_flush_parsed, 5046 .data = NULL, 5047 .help_str = "set gro flush <cycles>", 5048 .tokens = { 5049 (void *)&cmd_gro_flush_set, 5050 (void *)&cmd_gro_flush_keyword, 5051 (void *)&cmd_gro_flush_flush, 5052 (void *)&cmd_gro_flush_cycles, 5053 NULL, 5054 }, 5055 }; 5056 5057 /* *** ENABLE/DISABLE GSO *** */ 5058 struct cmd_gso_enable_result { 5059 cmdline_fixed_string_t cmd_set; 5060 cmdline_fixed_string_t cmd_port; 5061 cmdline_fixed_string_t cmd_keyword; 5062 cmdline_fixed_string_t cmd_mode; 5063 portid_t cmd_pid; 5064 }; 5065 5066 static void 5067 cmd_gso_enable_parsed(void *parsed_result, 5068 __attribute__((unused)) struct cmdline *cl, 5069 __attribute__((unused)) void *data) 5070 { 5071 struct cmd_gso_enable_result *res; 5072 5073 res = parsed_result; 5074 if (!strcmp(res->cmd_keyword, "gso")) 5075 setup_gso(res->cmd_mode, res->cmd_pid); 5076 } 5077 5078 cmdline_parse_token_string_t cmd_gso_enable_set = 5079 TOKEN_STRING_INITIALIZER(struct cmd_gso_enable_result, 5080 cmd_set, "set"); 5081 cmdline_parse_token_string_t cmd_gso_enable_port = 5082 TOKEN_STRING_INITIALIZER(struct cmd_gso_enable_result, 5083 cmd_port, "port"); 5084 cmdline_parse_token_string_t cmd_gso_enable_keyword = 5085 TOKEN_STRING_INITIALIZER(struct cmd_gso_enable_result, 5086 cmd_keyword, "gso"); 5087 cmdline_parse_token_string_t cmd_gso_enable_mode = 5088 TOKEN_STRING_INITIALIZER(struct cmd_gso_enable_result, 5089 cmd_mode, "on#off"); 5090 cmdline_parse_token_num_t cmd_gso_enable_pid = 5091 TOKEN_NUM_INITIALIZER(struct cmd_gso_enable_result, 5092 cmd_pid, UINT16); 5093 5094 cmdline_parse_inst_t cmd_gso_enable = { 5095 .f = cmd_gso_enable_parsed, 5096 .data = NULL, 5097 .help_str = "set port <port_id> gso on|off", 5098 .tokens = { 5099 (void *)&cmd_gso_enable_set, 5100 (void *)&cmd_gso_enable_port, 5101 (void *)&cmd_gso_enable_pid, 5102 (void *)&cmd_gso_enable_keyword, 5103 (void *)&cmd_gso_enable_mode, 5104 NULL, 5105 }, 5106 }; 5107 5108 /* *** SET MAX PACKET LENGTH FOR GSO SEGMENTS *** */ 5109 struct cmd_gso_size_result { 5110 cmdline_fixed_string_t cmd_set; 5111 cmdline_fixed_string_t cmd_keyword; 5112 cmdline_fixed_string_t cmd_segsz; 5113 uint16_t cmd_size; 5114 }; 5115 5116 static void 5117 cmd_gso_size_parsed(void *parsed_result, 5118 __attribute__((unused)) struct cmdline *cl, 5119 __attribute__((unused)) void *data) 5120 { 5121 struct cmd_gso_size_result *res = parsed_result; 5122 5123 if (test_done == 0) { 5124 printf("Before setting GSO segsz, please first" 5125 " stop fowarding\n"); 5126 return; 5127 } 5128 5129 if (!strcmp(res->cmd_keyword, "gso") && 5130 !strcmp(res->cmd_segsz, "segsz")) { 5131 if (res->cmd_size < RTE_GSO_SEG_SIZE_MIN) 5132 printf("gso_size should be larger than %zu." 5133 " Please input a legal value\n", 5134 RTE_GSO_SEG_SIZE_MIN); 5135 else 5136 gso_max_segment_size = res->cmd_size; 5137 } 5138 } 5139 5140 cmdline_parse_token_string_t cmd_gso_size_set = 5141 TOKEN_STRING_INITIALIZER(struct cmd_gso_size_result, 5142 cmd_set, "set"); 5143 cmdline_parse_token_string_t cmd_gso_size_keyword = 5144 TOKEN_STRING_INITIALIZER(struct cmd_gso_size_result, 5145 cmd_keyword, "gso"); 5146 cmdline_parse_token_string_t cmd_gso_size_segsz = 5147 TOKEN_STRING_INITIALIZER(struct cmd_gso_size_result, 5148 cmd_segsz, "segsz"); 5149 cmdline_parse_token_num_t cmd_gso_size_size = 5150 TOKEN_NUM_INITIALIZER(struct cmd_gso_size_result, 5151 cmd_size, UINT16); 5152 5153 cmdline_parse_inst_t cmd_gso_size = { 5154 .f = cmd_gso_size_parsed, 5155 .data = NULL, 5156 .help_str = "set gso segsz <length>", 5157 .tokens = { 5158 (void *)&cmd_gso_size_set, 5159 (void *)&cmd_gso_size_keyword, 5160 (void *)&cmd_gso_size_segsz, 5161 (void *)&cmd_gso_size_size, 5162 NULL, 5163 }, 5164 }; 5165 5166 /* *** SHOW GSO CONFIGURATION *** */ 5167 struct cmd_gso_show_result { 5168 cmdline_fixed_string_t cmd_show; 5169 cmdline_fixed_string_t cmd_port; 5170 cmdline_fixed_string_t cmd_keyword; 5171 portid_t cmd_pid; 5172 }; 5173 5174 static void 5175 cmd_gso_show_parsed(void *parsed_result, 5176 __attribute__((unused)) struct cmdline *cl, 5177 __attribute__((unused)) void *data) 5178 { 5179 struct cmd_gso_show_result *res = parsed_result; 5180 5181 if (!rte_eth_dev_is_valid_port(res->cmd_pid)) { 5182 printf("invalid port id %u\n", res->cmd_pid); 5183 return; 5184 } 5185 if (!strcmp(res->cmd_keyword, "gso")) { 5186 if (gso_ports[res->cmd_pid].enable) { 5187 printf("Max GSO'd packet size: %uB\n" 5188 "Supported GSO types: TCP/IPv4, " 5189 "UDP/IPv4, VxLAN with inner " 5190 "TCP/IPv4 packet, GRE with inner " 5191 "TCP/IPv4 packet\n", 5192 gso_max_segment_size); 5193 } else 5194 printf("GSO is not enabled on Port %u\n", res->cmd_pid); 5195 } 5196 } 5197 5198 cmdline_parse_token_string_t cmd_gso_show_show = 5199 TOKEN_STRING_INITIALIZER(struct cmd_gso_show_result, 5200 cmd_show, "show"); 5201 cmdline_parse_token_string_t cmd_gso_show_port = 5202 TOKEN_STRING_INITIALIZER(struct cmd_gso_show_result, 5203 cmd_port, "port"); 5204 cmdline_parse_token_string_t cmd_gso_show_keyword = 5205 TOKEN_STRING_INITIALIZER(struct cmd_gso_show_result, 5206 cmd_keyword, "gso"); 5207 cmdline_parse_token_num_t cmd_gso_show_pid = 5208 TOKEN_NUM_INITIALIZER(struct cmd_gso_show_result, 5209 cmd_pid, UINT16); 5210 5211 cmdline_parse_inst_t cmd_gso_show = { 5212 .f = cmd_gso_show_parsed, 5213 .data = NULL, 5214 .help_str = "show port <port_id> gso", 5215 .tokens = { 5216 (void *)&cmd_gso_show_show, 5217 (void *)&cmd_gso_show_port, 5218 (void *)&cmd_gso_show_pid, 5219 (void *)&cmd_gso_show_keyword, 5220 NULL, 5221 }, 5222 }; 5223 5224 /* *** ENABLE/DISABLE FLUSH ON RX STREAMS *** */ 5225 struct cmd_set_flush_rx { 5226 cmdline_fixed_string_t set; 5227 cmdline_fixed_string_t flush_rx; 5228 cmdline_fixed_string_t mode; 5229 }; 5230 5231 static void 5232 cmd_set_flush_rx_parsed(void *parsed_result, 5233 __attribute__((unused)) struct cmdline *cl, 5234 __attribute__((unused)) void *data) 5235 { 5236 struct cmd_set_flush_rx *res = parsed_result; 5237 no_flush_rx = (uint8_t)((strcmp(res->mode, "on") == 0) ? 0 : 1); 5238 } 5239 5240 cmdline_parse_token_string_t cmd_setflushrx_set = 5241 TOKEN_STRING_INITIALIZER(struct cmd_set_flush_rx, 5242 set, "set"); 5243 cmdline_parse_token_string_t cmd_setflushrx_flush_rx = 5244 TOKEN_STRING_INITIALIZER(struct cmd_set_flush_rx, 5245 flush_rx, "flush_rx"); 5246 cmdline_parse_token_string_t cmd_setflushrx_mode = 5247 TOKEN_STRING_INITIALIZER(struct cmd_set_flush_rx, 5248 mode, "on#off"); 5249 5250 5251 cmdline_parse_inst_t cmd_set_flush_rx = { 5252 .f = cmd_set_flush_rx_parsed, 5253 .help_str = "set flush_rx on|off: Enable/Disable flush on rx streams", 5254 .data = NULL, 5255 .tokens = { 5256 (void *)&cmd_setflushrx_set, 5257 (void *)&cmd_setflushrx_flush_rx, 5258 (void *)&cmd_setflushrx_mode, 5259 NULL, 5260 }, 5261 }; 5262 5263 /* *** ENABLE/DISABLE LINK STATUS CHECK *** */ 5264 struct cmd_set_link_check { 5265 cmdline_fixed_string_t set; 5266 cmdline_fixed_string_t link_check; 5267 cmdline_fixed_string_t mode; 5268 }; 5269 5270 static void 5271 cmd_set_link_check_parsed(void *parsed_result, 5272 __attribute__((unused)) struct cmdline *cl, 5273 __attribute__((unused)) void *data) 5274 { 5275 struct cmd_set_link_check *res = parsed_result; 5276 no_link_check = (uint8_t)((strcmp(res->mode, "on") == 0) ? 0 : 1); 5277 } 5278 5279 cmdline_parse_token_string_t cmd_setlinkcheck_set = 5280 TOKEN_STRING_INITIALIZER(struct cmd_set_link_check, 5281 set, "set"); 5282 cmdline_parse_token_string_t cmd_setlinkcheck_link_check = 5283 TOKEN_STRING_INITIALIZER(struct cmd_set_link_check, 5284 link_check, "link_check"); 5285 cmdline_parse_token_string_t cmd_setlinkcheck_mode = 5286 TOKEN_STRING_INITIALIZER(struct cmd_set_link_check, 5287 mode, "on#off"); 5288 5289 5290 cmdline_parse_inst_t cmd_set_link_check = { 5291 .f = cmd_set_link_check_parsed, 5292 .help_str = "set link_check on|off: Enable/Disable link status check " 5293 "when starting/stopping a port", 5294 .data = NULL, 5295 .tokens = { 5296 (void *)&cmd_setlinkcheck_set, 5297 (void *)&cmd_setlinkcheck_link_check, 5298 (void *)&cmd_setlinkcheck_mode, 5299 NULL, 5300 }, 5301 }; 5302 5303 /* *** SET NIC BYPASS MODE *** */ 5304 struct cmd_set_bypass_mode_result { 5305 cmdline_fixed_string_t set; 5306 cmdline_fixed_string_t bypass; 5307 cmdline_fixed_string_t mode; 5308 cmdline_fixed_string_t value; 5309 portid_t port_id; 5310 }; 5311 5312 static void 5313 cmd_set_bypass_mode_parsed(void *parsed_result, 5314 __attribute__((unused)) struct cmdline *cl, 5315 __attribute__((unused)) void *data) 5316 { 5317 struct cmd_set_bypass_mode_result *res = parsed_result; 5318 portid_t port_id = res->port_id; 5319 int32_t rc = -EINVAL; 5320 5321 #if defined RTE_LIBRTE_IXGBE_PMD && defined RTE_LIBRTE_IXGBE_BYPASS 5322 uint32_t bypass_mode = RTE_PMD_IXGBE_BYPASS_MODE_NORMAL; 5323 5324 if (!strcmp(res->value, "bypass")) 5325 bypass_mode = RTE_PMD_IXGBE_BYPASS_MODE_BYPASS; 5326 else if (!strcmp(res->value, "isolate")) 5327 bypass_mode = RTE_PMD_IXGBE_BYPASS_MODE_ISOLATE; 5328 else 5329 bypass_mode = RTE_PMD_IXGBE_BYPASS_MODE_NORMAL; 5330 5331 /* Set the bypass mode for the relevant port. */ 5332 rc = rte_pmd_ixgbe_bypass_state_set(port_id, &bypass_mode); 5333 #endif 5334 if (rc != 0) 5335 printf("\t Failed to set bypass mode for port = %d.\n", port_id); 5336 } 5337 5338 cmdline_parse_token_string_t cmd_setbypass_mode_set = 5339 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_mode_result, 5340 set, "set"); 5341 cmdline_parse_token_string_t cmd_setbypass_mode_bypass = 5342 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_mode_result, 5343 bypass, "bypass"); 5344 cmdline_parse_token_string_t cmd_setbypass_mode_mode = 5345 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_mode_result, 5346 mode, "mode"); 5347 cmdline_parse_token_string_t cmd_setbypass_mode_value = 5348 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_mode_result, 5349 value, "normal#bypass#isolate"); 5350 cmdline_parse_token_num_t cmd_setbypass_mode_port = 5351 TOKEN_NUM_INITIALIZER(struct cmd_set_bypass_mode_result, 5352 port_id, UINT16); 5353 5354 cmdline_parse_inst_t cmd_set_bypass_mode = { 5355 .f = cmd_set_bypass_mode_parsed, 5356 .help_str = "set bypass mode normal|bypass|isolate <port_id>: " 5357 "Set the NIC bypass mode for port_id", 5358 .data = NULL, 5359 .tokens = { 5360 (void *)&cmd_setbypass_mode_set, 5361 (void *)&cmd_setbypass_mode_bypass, 5362 (void *)&cmd_setbypass_mode_mode, 5363 (void *)&cmd_setbypass_mode_value, 5364 (void *)&cmd_setbypass_mode_port, 5365 NULL, 5366 }, 5367 }; 5368 5369 /* *** SET NIC BYPASS EVENT *** */ 5370 struct cmd_set_bypass_event_result { 5371 cmdline_fixed_string_t set; 5372 cmdline_fixed_string_t bypass; 5373 cmdline_fixed_string_t event; 5374 cmdline_fixed_string_t event_value; 5375 cmdline_fixed_string_t mode; 5376 cmdline_fixed_string_t mode_value; 5377 portid_t port_id; 5378 }; 5379 5380 static void 5381 cmd_set_bypass_event_parsed(void *parsed_result, 5382 __attribute__((unused)) struct cmdline *cl, 5383 __attribute__((unused)) void *data) 5384 { 5385 int32_t rc = -EINVAL; 5386 struct cmd_set_bypass_event_result *res = parsed_result; 5387 portid_t port_id = res->port_id; 5388 5389 #if defined RTE_LIBRTE_IXGBE_PMD && defined RTE_LIBRTE_IXGBE_BYPASS 5390 uint32_t bypass_event = RTE_PMD_IXGBE_BYPASS_EVENT_NONE; 5391 uint32_t bypass_mode = RTE_PMD_IXGBE_BYPASS_MODE_NORMAL; 5392 5393 if (!strcmp(res->event_value, "timeout")) 5394 bypass_event = RTE_PMD_IXGBE_BYPASS_EVENT_TIMEOUT; 5395 else if (!strcmp(res->event_value, "os_on")) 5396 bypass_event = RTE_PMD_IXGBE_BYPASS_EVENT_OS_ON; 5397 else if (!strcmp(res->event_value, "os_off")) 5398 bypass_event = RTE_PMD_IXGBE_BYPASS_EVENT_OS_OFF; 5399 else if (!strcmp(res->event_value, "power_on")) 5400 bypass_event = RTE_PMD_IXGBE_BYPASS_EVENT_POWER_ON; 5401 else if (!strcmp(res->event_value, "power_off")) 5402 bypass_event = RTE_PMD_IXGBE_BYPASS_EVENT_POWER_OFF; 5403 else 5404 bypass_event = RTE_PMD_IXGBE_BYPASS_EVENT_NONE; 5405 5406 if (!strcmp(res->mode_value, "bypass")) 5407 bypass_mode = RTE_PMD_IXGBE_BYPASS_MODE_BYPASS; 5408 else if (!strcmp(res->mode_value, "isolate")) 5409 bypass_mode = RTE_PMD_IXGBE_BYPASS_MODE_ISOLATE; 5410 else 5411 bypass_mode = RTE_PMD_IXGBE_BYPASS_MODE_NORMAL; 5412 5413 /* Set the watchdog timeout. */ 5414 if (bypass_event == RTE_PMD_IXGBE_BYPASS_EVENT_TIMEOUT) { 5415 5416 rc = -EINVAL; 5417 if (RTE_PMD_IXGBE_BYPASS_TMT_VALID(bypass_timeout)) { 5418 rc = rte_pmd_ixgbe_bypass_wd_timeout_store(port_id, 5419 bypass_timeout); 5420 } 5421 if (rc != 0) { 5422 printf("Failed to set timeout value %u " 5423 "for port %d, errto code: %d.\n", 5424 bypass_timeout, port_id, rc); 5425 } 5426 } 5427 5428 /* Set the bypass event to transition to bypass mode. */ 5429 rc = rte_pmd_ixgbe_bypass_event_store(port_id, bypass_event, 5430 bypass_mode); 5431 #endif 5432 5433 if (rc != 0) 5434 printf("\t Failed to set bypass event for port = %d.\n", 5435 port_id); 5436 } 5437 5438 cmdline_parse_token_string_t cmd_setbypass_event_set = 5439 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_event_result, 5440 set, "set"); 5441 cmdline_parse_token_string_t cmd_setbypass_event_bypass = 5442 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_event_result, 5443 bypass, "bypass"); 5444 cmdline_parse_token_string_t cmd_setbypass_event_event = 5445 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_event_result, 5446 event, "event"); 5447 cmdline_parse_token_string_t cmd_setbypass_event_event_value = 5448 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_event_result, 5449 event_value, "none#timeout#os_off#os_on#power_on#power_off"); 5450 cmdline_parse_token_string_t cmd_setbypass_event_mode = 5451 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_event_result, 5452 mode, "mode"); 5453 cmdline_parse_token_string_t cmd_setbypass_event_mode_value = 5454 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_event_result, 5455 mode_value, "normal#bypass#isolate"); 5456 cmdline_parse_token_num_t cmd_setbypass_event_port = 5457 TOKEN_NUM_INITIALIZER(struct cmd_set_bypass_event_result, 5458 port_id, UINT16); 5459 5460 cmdline_parse_inst_t cmd_set_bypass_event = { 5461 .f = cmd_set_bypass_event_parsed, 5462 .help_str = "set bypass event none|timeout|os_on|os_off|power_on|" 5463 "power_off mode normal|bypass|isolate <port_id>: " 5464 "Set the NIC bypass event mode for port_id", 5465 .data = NULL, 5466 .tokens = { 5467 (void *)&cmd_setbypass_event_set, 5468 (void *)&cmd_setbypass_event_bypass, 5469 (void *)&cmd_setbypass_event_event, 5470 (void *)&cmd_setbypass_event_event_value, 5471 (void *)&cmd_setbypass_event_mode, 5472 (void *)&cmd_setbypass_event_mode_value, 5473 (void *)&cmd_setbypass_event_port, 5474 NULL, 5475 }, 5476 }; 5477 5478 5479 /* *** SET NIC BYPASS TIMEOUT *** */ 5480 struct cmd_set_bypass_timeout_result { 5481 cmdline_fixed_string_t set; 5482 cmdline_fixed_string_t bypass; 5483 cmdline_fixed_string_t timeout; 5484 cmdline_fixed_string_t value; 5485 }; 5486 5487 static void 5488 cmd_set_bypass_timeout_parsed(void *parsed_result, 5489 __attribute__((unused)) struct cmdline *cl, 5490 __attribute__((unused)) void *data) 5491 { 5492 __rte_unused struct cmd_set_bypass_timeout_result *res = parsed_result; 5493 5494 #if defined RTE_LIBRTE_IXGBE_PMD && defined RTE_LIBRTE_IXGBE_BYPASS 5495 if (!strcmp(res->value, "1.5")) 5496 bypass_timeout = RTE_PMD_IXGBE_BYPASS_TMT_1_5_SEC; 5497 else if (!strcmp(res->value, "2")) 5498 bypass_timeout = RTE_PMD_IXGBE_BYPASS_TMT_2_SEC; 5499 else if (!strcmp(res->value, "3")) 5500 bypass_timeout = RTE_PMD_IXGBE_BYPASS_TMT_3_SEC; 5501 else if (!strcmp(res->value, "4")) 5502 bypass_timeout = RTE_PMD_IXGBE_BYPASS_TMT_4_SEC; 5503 else if (!strcmp(res->value, "8")) 5504 bypass_timeout = RTE_PMD_IXGBE_BYPASS_TMT_8_SEC; 5505 else if (!strcmp(res->value, "16")) 5506 bypass_timeout = RTE_PMD_IXGBE_BYPASS_TMT_16_SEC; 5507 else if (!strcmp(res->value, "32")) 5508 bypass_timeout = RTE_PMD_IXGBE_BYPASS_TMT_32_SEC; 5509 else 5510 bypass_timeout = RTE_PMD_IXGBE_BYPASS_TMT_OFF; 5511 #endif 5512 } 5513 5514 cmdline_parse_token_string_t cmd_setbypass_timeout_set = 5515 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_timeout_result, 5516 set, "set"); 5517 cmdline_parse_token_string_t cmd_setbypass_timeout_bypass = 5518 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_timeout_result, 5519 bypass, "bypass"); 5520 cmdline_parse_token_string_t cmd_setbypass_timeout_timeout = 5521 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_timeout_result, 5522 timeout, "timeout"); 5523 cmdline_parse_token_string_t cmd_setbypass_timeout_value = 5524 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_timeout_result, 5525 value, "0#1.5#2#3#4#8#16#32"); 5526 5527 cmdline_parse_inst_t cmd_set_bypass_timeout = { 5528 .f = cmd_set_bypass_timeout_parsed, 5529 .help_str = "set bypass timeout 0|1.5|2|3|4|8|16|32: " 5530 "Set the NIC bypass watchdog timeout in seconds", 5531 .data = NULL, 5532 .tokens = { 5533 (void *)&cmd_setbypass_timeout_set, 5534 (void *)&cmd_setbypass_timeout_bypass, 5535 (void *)&cmd_setbypass_timeout_timeout, 5536 (void *)&cmd_setbypass_timeout_value, 5537 NULL, 5538 }, 5539 }; 5540 5541 /* *** SHOW NIC BYPASS MODE *** */ 5542 struct cmd_show_bypass_config_result { 5543 cmdline_fixed_string_t show; 5544 cmdline_fixed_string_t bypass; 5545 cmdline_fixed_string_t config; 5546 portid_t port_id; 5547 }; 5548 5549 static void 5550 cmd_show_bypass_config_parsed(void *parsed_result, 5551 __attribute__((unused)) struct cmdline *cl, 5552 __attribute__((unused)) void *data) 5553 { 5554 struct cmd_show_bypass_config_result *res = parsed_result; 5555 portid_t port_id = res->port_id; 5556 int rc = -EINVAL; 5557 #if defined RTE_LIBRTE_IXGBE_PMD && defined RTE_LIBRTE_IXGBE_BYPASS 5558 uint32_t event_mode; 5559 uint32_t bypass_mode; 5560 uint32_t timeout = bypass_timeout; 5561 int i; 5562 5563 static const char * const timeouts[RTE_PMD_IXGBE_BYPASS_TMT_NUM] = 5564 {"off", "1.5", "2", "3", "4", "8", "16", "32"}; 5565 static const char * const modes[RTE_PMD_IXGBE_BYPASS_MODE_NUM] = 5566 {"UNKNOWN", "normal", "bypass", "isolate"}; 5567 static const char * const events[RTE_PMD_IXGBE_BYPASS_EVENT_NUM] = { 5568 "NONE", 5569 "OS/board on", 5570 "power supply on", 5571 "OS/board off", 5572 "power supply off", 5573 "timeout"}; 5574 int num_events = (sizeof events) / (sizeof events[0]); 5575 5576 /* Display the bypass mode.*/ 5577 if (rte_pmd_ixgbe_bypass_state_show(port_id, &bypass_mode) != 0) { 5578 printf("\tFailed to get bypass mode for port = %d\n", port_id); 5579 return; 5580 } 5581 else { 5582 if (!RTE_PMD_IXGBE_BYPASS_MODE_VALID(bypass_mode)) 5583 bypass_mode = RTE_PMD_IXGBE_BYPASS_MODE_NONE; 5584 5585 printf("\tbypass mode = %s\n", modes[bypass_mode]); 5586 } 5587 5588 /* Display the bypass timeout.*/ 5589 if (!RTE_PMD_IXGBE_BYPASS_TMT_VALID(timeout)) 5590 timeout = RTE_PMD_IXGBE_BYPASS_TMT_OFF; 5591 5592 printf("\tbypass timeout = %s\n", timeouts[timeout]); 5593 5594 /* Display the bypass events and associated modes. */ 5595 for (i = RTE_PMD_IXGBE_BYPASS_EVENT_START; i < num_events; i++) { 5596 5597 if (rte_pmd_ixgbe_bypass_event_show(port_id, i, &event_mode)) { 5598 printf("\tFailed to get bypass mode for event = %s\n", 5599 events[i]); 5600 } else { 5601 if (!RTE_PMD_IXGBE_BYPASS_MODE_VALID(event_mode)) 5602 event_mode = RTE_PMD_IXGBE_BYPASS_MODE_NONE; 5603 5604 printf("\tbypass event: %-16s = %s\n", events[i], 5605 modes[event_mode]); 5606 } 5607 } 5608 #endif 5609 if (rc != 0) 5610 printf("\tFailed to get bypass configuration for port = %d\n", 5611 port_id); 5612 } 5613 5614 cmdline_parse_token_string_t cmd_showbypass_config_show = 5615 TOKEN_STRING_INITIALIZER(struct cmd_show_bypass_config_result, 5616 show, "show"); 5617 cmdline_parse_token_string_t cmd_showbypass_config_bypass = 5618 TOKEN_STRING_INITIALIZER(struct cmd_show_bypass_config_result, 5619 bypass, "bypass"); 5620 cmdline_parse_token_string_t cmd_showbypass_config_config = 5621 TOKEN_STRING_INITIALIZER(struct cmd_show_bypass_config_result, 5622 config, "config"); 5623 cmdline_parse_token_num_t cmd_showbypass_config_port = 5624 TOKEN_NUM_INITIALIZER(struct cmd_show_bypass_config_result, 5625 port_id, UINT16); 5626 5627 cmdline_parse_inst_t cmd_show_bypass_config = { 5628 .f = cmd_show_bypass_config_parsed, 5629 .help_str = "show bypass config <port_id>: " 5630 "Show the NIC bypass config for port_id", 5631 .data = NULL, 5632 .tokens = { 5633 (void *)&cmd_showbypass_config_show, 5634 (void *)&cmd_showbypass_config_bypass, 5635 (void *)&cmd_showbypass_config_config, 5636 (void *)&cmd_showbypass_config_port, 5637 NULL, 5638 }, 5639 }; 5640 5641 #ifdef RTE_LIBRTE_PMD_BOND 5642 /* *** SET BONDING MODE *** */ 5643 struct cmd_set_bonding_mode_result { 5644 cmdline_fixed_string_t set; 5645 cmdline_fixed_string_t bonding; 5646 cmdline_fixed_string_t mode; 5647 uint8_t value; 5648 portid_t port_id; 5649 }; 5650 5651 static void cmd_set_bonding_mode_parsed(void *parsed_result, 5652 __attribute__((unused)) struct cmdline *cl, 5653 __attribute__((unused)) void *data) 5654 { 5655 struct cmd_set_bonding_mode_result *res = parsed_result; 5656 portid_t port_id = res->port_id; 5657 5658 /* Set the bonding mode for the relevant port. */ 5659 if (0 != rte_eth_bond_mode_set(port_id, res->value)) 5660 printf("\t Failed to set bonding mode for port = %d.\n", port_id); 5661 } 5662 5663 cmdline_parse_token_string_t cmd_setbonding_mode_set = 5664 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_mode_result, 5665 set, "set"); 5666 cmdline_parse_token_string_t cmd_setbonding_mode_bonding = 5667 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_mode_result, 5668 bonding, "bonding"); 5669 cmdline_parse_token_string_t cmd_setbonding_mode_mode = 5670 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_mode_result, 5671 mode, "mode"); 5672 cmdline_parse_token_num_t cmd_setbonding_mode_value = 5673 TOKEN_NUM_INITIALIZER(struct cmd_set_bonding_mode_result, 5674 value, UINT8); 5675 cmdline_parse_token_num_t cmd_setbonding_mode_port = 5676 TOKEN_NUM_INITIALIZER(struct cmd_set_bonding_mode_result, 5677 port_id, UINT16); 5678 5679 cmdline_parse_inst_t cmd_set_bonding_mode = { 5680 .f = cmd_set_bonding_mode_parsed, 5681 .help_str = "set bonding mode <mode_value> <port_id>: " 5682 "Set the bonding mode for port_id", 5683 .data = NULL, 5684 .tokens = { 5685 (void *) &cmd_setbonding_mode_set, 5686 (void *) &cmd_setbonding_mode_bonding, 5687 (void *) &cmd_setbonding_mode_mode, 5688 (void *) &cmd_setbonding_mode_value, 5689 (void *) &cmd_setbonding_mode_port, 5690 NULL 5691 } 5692 }; 5693 5694 /* *** SET BONDING SLOW_QUEUE SW/HW *** */ 5695 struct cmd_set_bonding_lacp_dedicated_queues_result { 5696 cmdline_fixed_string_t set; 5697 cmdline_fixed_string_t bonding; 5698 cmdline_fixed_string_t lacp; 5699 cmdline_fixed_string_t dedicated_queues; 5700 portid_t port_id; 5701 cmdline_fixed_string_t mode; 5702 }; 5703 5704 static void cmd_set_bonding_lacp_dedicated_queues_parsed(void *parsed_result, 5705 __attribute__((unused)) struct cmdline *cl, 5706 __attribute__((unused)) void *data) 5707 { 5708 struct cmd_set_bonding_lacp_dedicated_queues_result *res = parsed_result; 5709 portid_t port_id = res->port_id; 5710 struct rte_port *port; 5711 5712 port = &ports[port_id]; 5713 5714 /** Check if the port is not started **/ 5715 if (port->port_status != RTE_PORT_STOPPED) { 5716 printf("Please stop port %d first\n", port_id); 5717 return; 5718 } 5719 5720 if (!strcmp(res->mode, "enable")) { 5721 if (rte_eth_bond_8023ad_dedicated_queues_enable(port_id) == 0) 5722 printf("Dedicate queues for LACP control packets" 5723 " enabled\n"); 5724 else 5725 printf("Enabling dedicate queues for LACP control " 5726 "packets on port %d failed\n", port_id); 5727 } else if (!strcmp(res->mode, "disable")) { 5728 if (rte_eth_bond_8023ad_dedicated_queues_disable(port_id) == 0) 5729 printf("Dedicated queues for LACP control packets " 5730 "disabled\n"); 5731 else 5732 printf("Disabling dedicated queues for LACP control " 5733 "traffic on port %d failed\n", port_id); 5734 } 5735 } 5736 5737 cmdline_parse_token_string_t cmd_setbonding_lacp_dedicated_queues_set = 5738 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_lacp_dedicated_queues_result, 5739 set, "set"); 5740 cmdline_parse_token_string_t cmd_setbonding_lacp_dedicated_queues_bonding = 5741 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_lacp_dedicated_queues_result, 5742 bonding, "bonding"); 5743 cmdline_parse_token_string_t cmd_setbonding_lacp_dedicated_queues_lacp = 5744 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_lacp_dedicated_queues_result, 5745 lacp, "lacp"); 5746 cmdline_parse_token_string_t cmd_setbonding_lacp_dedicated_queues_dedicated_queues = 5747 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_lacp_dedicated_queues_result, 5748 dedicated_queues, "dedicated_queues"); 5749 cmdline_parse_token_num_t cmd_setbonding_lacp_dedicated_queues_port_id = 5750 TOKEN_NUM_INITIALIZER(struct cmd_set_bonding_lacp_dedicated_queues_result, 5751 port_id, UINT16); 5752 cmdline_parse_token_string_t cmd_setbonding_lacp_dedicated_queues_mode = 5753 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_lacp_dedicated_queues_result, 5754 mode, "enable#disable"); 5755 5756 cmdline_parse_inst_t cmd_set_lacp_dedicated_queues = { 5757 .f = cmd_set_bonding_lacp_dedicated_queues_parsed, 5758 .help_str = "set bonding lacp dedicated_queues <port_id> " 5759 "enable|disable: " 5760 "Enable/disable dedicated queues for LACP control traffic for port_id", 5761 .data = NULL, 5762 .tokens = { 5763 (void *)&cmd_setbonding_lacp_dedicated_queues_set, 5764 (void *)&cmd_setbonding_lacp_dedicated_queues_bonding, 5765 (void *)&cmd_setbonding_lacp_dedicated_queues_lacp, 5766 (void *)&cmd_setbonding_lacp_dedicated_queues_dedicated_queues, 5767 (void *)&cmd_setbonding_lacp_dedicated_queues_port_id, 5768 (void *)&cmd_setbonding_lacp_dedicated_queues_mode, 5769 NULL 5770 } 5771 }; 5772 5773 /* *** SET BALANCE XMIT POLICY *** */ 5774 struct cmd_set_bonding_balance_xmit_policy_result { 5775 cmdline_fixed_string_t set; 5776 cmdline_fixed_string_t bonding; 5777 cmdline_fixed_string_t balance_xmit_policy; 5778 portid_t port_id; 5779 cmdline_fixed_string_t policy; 5780 }; 5781 5782 static void cmd_set_bonding_balance_xmit_policy_parsed(void *parsed_result, 5783 __attribute__((unused)) struct cmdline *cl, 5784 __attribute__((unused)) void *data) 5785 { 5786 struct cmd_set_bonding_balance_xmit_policy_result *res = parsed_result; 5787 portid_t port_id = res->port_id; 5788 uint8_t policy; 5789 5790 if (!strcmp(res->policy, "l2")) { 5791 policy = BALANCE_XMIT_POLICY_LAYER2; 5792 } else if (!strcmp(res->policy, "l23")) { 5793 policy = BALANCE_XMIT_POLICY_LAYER23; 5794 } else if (!strcmp(res->policy, "l34")) { 5795 policy = BALANCE_XMIT_POLICY_LAYER34; 5796 } else { 5797 printf("\t Invalid xmit policy selection"); 5798 return; 5799 } 5800 5801 /* Set the bonding mode for the relevant port. */ 5802 if (0 != rte_eth_bond_xmit_policy_set(port_id, policy)) { 5803 printf("\t Failed to set bonding balance xmit policy for port = %d.\n", 5804 port_id); 5805 } 5806 } 5807 5808 cmdline_parse_token_string_t cmd_setbonding_balance_xmit_policy_set = 5809 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_balance_xmit_policy_result, 5810 set, "set"); 5811 cmdline_parse_token_string_t cmd_setbonding_balance_xmit_policy_bonding = 5812 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_balance_xmit_policy_result, 5813 bonding, "bonding"); 5814 cmdline_parse_token_string_t cmd_setbonding_balance_xmit_policy_balance_xmit_policy = 5815 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_balance_xmit_policy_result, 5816 balance_xmit_policy, "balance_xmit_policy"); 5817 cmdline_parse_token_num_t cmd_setbonding_balance_xmit_policy_port = 5818 TOKEN_NUM_INITIALIZER(struct cmd_set_bonding_balance_xmit_policy_result, 5819 port_id, UINT16); 5820 cmdline_parse_token_string_t cmd_setbonding_balance_xmit_policy_policy = 5821 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_balance_xmit_policy_result, 5822 policy, "l2#l23#l34"); 5823 5824 cmdline_parse_inst_t cmd_set_balance_xmit_policy = { 5825 .f = cmd_set_bonding_balance_xmit_policy_parsed, 5826 .help_str = "set bonding balance_xmit_policy <port_id> " 5827 "l2|l23|l34: " 5828 "Set the bonding balance_xmit_policy for port_id", 5829 .data = NULL, 5830 .tokens = { 5831 (void *)&cmd_setbonding_balance_xmit_policy_set, 5832 (void *)&cmd_setbonding_balance_xmit_policy_bonding, 5833 (void *)&cmd_setbonding_balance_xmit_policy_balance_xmit_policy, 5834 (void *)&cmd_setbonding_balance_xmit_policy_port, 5835 (void *)&cmd_setbonding_balance_xmit_policy_policy, 5836 NULL 5837 } 5838 }; 5839 5840 /* *** SHOW NIC BONDING CONFIGURATION *** */ 5841 struct cmd_show_bonding_config_result { 5842 cmdline_fixed_string_t show; 5843 cmdline_fixed_string_t bonding; 5844 cmdline_fixed_string_t config; 5845 portid_t port_id; 5846 }; 5847 5848 static void cmd_show_bonding_config_parsed(void *parsed_result, 5849 __attribute__((unused)) struct cmdline *cl, 5850 __attribute__((unused)) void *data) 5851 { 5852 struct cmd_show_bonding_config_result *res = parsed_result; 5853 int bonding_mode, agg_mode; 5854 portid_t slaves[RTE_MAX_ETHPORTS]; 5855 int num_slaves, num_active_slaves; 5856 int primary_id; 5857 int i; 5858 portid_t port_id = res->port_id; 5859 5860 /* Display the bonding mode.*/ 5861 bonding_mode = rte_eth_bond_mode_get(port_id); 5862 if (bonding_mode < 0) { 5863 printf("\tFailed to get bonding mode for port = %d\n", port_id); 5864 return; 5865 } else 5866 printf("\tBonding mode: %d\n", bonding_mode); 5867 5868 if (bonding_mode == BONDING_MODE_BALANCE) { 5869 int balance_xmit_policy; 5870 5871 balance_xmit_policy = rte_eth_bond_xmit_policy_get(port_id); 5872 if (balance_xmit_policy < 0) { 5873 printf("\tFailed to get balance xmit policy for port = %d\n", 5874 port_id); 5875 return; 5876 } else { 5877 printf("\tBalance Xmit Policy: "); 5878 5879 switch (balance_xmit_policy) { 5880 case BALANCE_XMIT_POLICY_LAYER2: 5881 printf("BALANCE_XMIT_POLICY_LAYER2"); 5882 break; 5883 case BALANCE_XMIT_POLICY_LAYER23: 5884 printf("BALANCE_XMIT_POLICY_LAYER23"); 5885 break; 5886 case BALANCE_XMIT_POLICY_LAYER34: 5887 printf("BALANCE_XMIT_POLICY_LAYER34"); 5888 break; 5889 } 5890 printf("\n"); 5891 } 5892 } 5893 5894 if (bonding_mode == BONDING_MODE_8023AD) { 5895 agg_mode = rte_eth_bond_8023ad_agg_selection_get(port_id); 5896 printf("\tIEEE802.3AD Aggregator Mode: "); 5897 switch (agg_mode) { 5898 case AGG_BANDWIDTH: 5899 printf("bandwidth"); 5900 break; 5901 case AGG_STABLE: 5902 printf("stable"); 5903 break; 5904 case AGG_COUNT: 5905 printf("count"); 5906 break; 5907 } 5908 printf("\n"); 5909 } 5910 5911 num_slaves = rte_eth_bond_slaves_get(port_id, slaves, RTE_MAX_ETHPORTS); 5912 5913 if (num_slaves < 0) { 5914 printf("\tFailed to get slave list for port = %d\n", port_id); 5915 return; 5916 } 5917 if (num_slaves > 0) { 5918 printf("\tSlaves (%d): [", num_slaves); 5919 for (i = 0; i < num_slaves - 1; i++) 5920 printf("%d ", slaves[i]); 5921 5922 printf("%d]\n", slaves[num_slaves - 1]); 5923 } else { 5924 printf("\tSlaves: []\n"); 5925 5926 } 5927 5928 num_active_slaves = rte_eth_bond_active_slaves_get(port_id, slaves, 5929 RTE_MAX_ETHPORTS); 5930 5931 if (num_active_slaves < 0) { 5932 printf("\tFailed to get active slave list for port = %d\n", port_id); 5933 return; 5934 } 5935 if (num_active_slaves > 0) { 5936 printf("\tActive Slaves (%d): [", num_active_slaves); 5937 for (i = 0; i < num_active_slaves - 1; i++) 5938 printf("%d ", slaves[i]); 5939 5940 printf("%d]\n", slaves[num_active_slaves - 1]); 5941 5942 } else { 5943 printf("\tActive Slaves: []\n"); 5944 5945 } 5946 5947 primary_id = rte_eth_bond_primary_get(port_id); 5948 if (primary_id < 0) { 5949 printf("\tFailed to get primary slave for port = %d\n", port_id); 5950 return; 5951 } else 5952 printf("\tPrimary: [%d]\n", primary_id); 5953 5954 } 5955 5956 cmdline_parse_token_string_t cmd_showbonding_config_show = 5957 TOKEN_STRING_INITIALIZER(struct cmd_show_bonding_config_result, 5958 show, "show"); 5959 cmdline_parse_token_string_t cmd_showbonding_config_bonding = 5960 TOKEN_STRING_INITIALIZER(struct cmd_show_bonding_config_result, 5961 bonding, "bonding"); 5962 cmdline_parse_token_string_t cmd_showbonding_config_config = 5963 TOKEN_STRING_INITIALIZER(struct cmd_show_bonding_config_result, 5964 config, "config"); 5965 cmdline_parse_token_num_t cmd_showbonding_config_port = 5966 TOKEN_NUM_INITIALIZER(struct cmd_show_bonding_config_result, 5967 port_id, UINT16); 5968 5969 cmdline_parse_inst_t cmd_show_bonding_config = { 5970 .f = cmd_show_bonding_config_parsed, 5971 .help_str = "show bonding config <port_id>: " 5972 "Show the bonding config for port_id", 5973 .data = NULL, 5974 .tokens = { 5975 (void *)&cmd_showbonding_config_show, 5976 (void *)&cmd_showbonding_config_bonding, 5977 (void *)&cmd_showbonding_config_config, 5978 (void *)&cmd_showbonding_config_port, 5979 NULL 5980 } 5981 }; 5982 5983 /* *** SET BONDING PRIMARY *** */ 5984 struct cmd_set_bonding_primary_result { 5985 cmdline_fixed_string_t set; 5986 cmdline_fixed_string_t bonding; 5987 cmdline_fixed_string_t primary; 5988 portid_t slave_id; 5989 portid_t port_id; 5990 }; 5991 5992 static void cmd_set_bonding_primary_parsed(void *parsed_result, 5993 __attribute__((unused)) struct cmdline *cl, 5994 __attribute__((unused)) void *data) 5995 { 5996 struct cmd_set_bonding_primary_result *res = parsed_result; 5997 portid_t master_port_id = res->port_id; 5998 portid_t slave_port_id = res->slave_id; 5999 6000 /* Set the primary slave for a bonded device. */ 6001 if (0 != rte_eth_bond_primary_set(master_port_id, slave_port_id)) { 6002 printf("\t Failed to set primary slave for port = %d.\n", 6003 master_port_id); 6004 return; 6005 } 6006 init_port_config(); 6007 } 6008 6009 cmdline_parse_token_string_t cmd_setbonding_primary_set = 6010 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_primary_result, 6011 set, "set"); 6012 cmdline_parse_token_string_t cmd_setbonding_primary_bonding = 6013 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_primary_result, 6014 bonding, "bonding"); 6015 cmdline_parse_token_string_t cmd_setbonding_primary_primary = 6016 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_primary_result, 6017 primary, "primary"); 6018 cmdline_parse_token_num_t cmd_setbonding_primary_slave = 6019 TOKEN_NUM_INITIALIZER(struct cmd_set_bonding_primary_result, 6020 slave_id, UINT16); 6021 cmdline_parse_token_num_t cmd_setbonding_primary_port = 6022 TOKEN_NUM_INITIALIZER(struct cmd_set_bonding_primary_result, 6023 port_id, UINT16); 6024 6025 cmdline_parse_inst_t cmd_set_bonding_primary = { 6026 .f = cmd_set_bonding_primary_parsed, 6027 .help_str = "set bonding primary <slave_id> <port_id>: " 6028 "Set the primary slave for port_id", 6029 .data = NULL, 6030 .tokens = { 6031 (void *)&cmd_setbonding_primary_set, 6032 (void *)&cmd_setbonding_primary_bonding, 6033 (void *)&cmd_setbonding_primary_primary, 6034 (void *)&cmd_setbonding_primary_slave, 6035 (void *)&cmd_setbonding_primary_port, 6036 NULL 6037 } 6038 }; 6039 6040 /* *** ADD SLAVE *** */ 6041 struct cmd_add_bonding_slave_result { 6042 cmdline_fixed_string_t add; 6043 cmdline_fixed_string_t bonding; 6044 cmdline_fixed_string_t slave; 6045 portid_t slave_id; 6046 portid_t port_id; 6047 }; 6048 6049 static void cmd_add_bonding_slave_parsed(void *parsed_result, 6050 __attribute__((unused)) struct cmdline *cl, 6051 __attribute__((unused)) void *data) 6052 { 6053 struct cmd_add_bonding_slave_result *res = parsed_result; 6054 portid_t master_port_id = res->port_id; 6055 portid_t slave_port_id = res->slave_id; 6056 6057 /* add the slave for a bonded device. */ 6058 if (0 != rte_eth_bond_slave_add(master_port_id, slave_port_id)) { 6059 printf("\t Failed to add slave %d to master port = %d.\n", 6060 slave_port_id, master_port_id); 6061 return; 6062 } 6063 init_port_config(); 6064 set_port_slave_flag(slave_port_id); 6065 } 6066 6067 cmdline_parse_token_string_t cmd_addbonding_slave_add = 6068 TOKEN_STRING_INITIALIZER(struct cmd_add_bonding_slave_result, 6069 add, "add"); 6070 cmdline_parse_token_string_t cmd_addbonding_slave_bonding = 6071 TOKEN_STRING_INITIALIZER(struct cmd_add_bonding_slave_result, 6072 bonding, "bonding"); 6073 cmdline_parse_token_string_t cmd_addbonding_slave_slave = 6074 TOKEN_STRING_INITIALIZER(struct cmd_add_bonding_slave_result, 6075 slave, "slave"); 6076 cmdline_parse_token_num_t cmd_addbonding_slave_slaveid = 6077 TOKEN_NUM_INITIALIZER(struct cmd_add_bonding_slave_result, 6078 slave_id, UINT16); 6079 cmdline_parse_token_num_t cmd_addbonding_slave_port = 6080 TOKEN_NUM_INITIALIZER(struct cmd_add_bonding_slave_result, 6081 port_id, UINT16); 6082 6083 cmdline_parse_inst_t cmd_add_bonding_slave = { 6084 .f = cmd_add_bonding_slave_parsed, 6085 .help_str = "add bonding slave <slave_id> <port_id>: " 6086 "Add a slave device to a bonded device", 6087 .data = NULL, 6088 .tokens = { 6089 (void *)&cmd_addbonding_slave_add, 6090 (void *)&cmd_addbonding_slave_bonding, 6091 (void *)&cmd_addbonding_slave_slave, 6092 (void *)&cmd_addbonding_slave_slaveid, 6093 (void *)&cmd_addbonding_slave_port, 6094 NULL 6095 } 6096 }; 6097 6098 /* *** REMOVE SLAVE *** */ 6099 struct cmd_remove_bonding_slave_result { 6100 cmdline_fixed_string_t remove; 6101 cmdline_fixed_string_t bonding; 6102 cmdline_fixed_string_t slave; 6103 portid_t slave_id; 6104 portid_t port_id; 6105 }; 6106 6107 static void cmd_remove_bonding_slave_parsed(void *parsed_result, 6108 __attribute__((unused)) struct cmdline *cl, 6109 __attribute__((unused)) void *data) 6110 { 6111 struct cmd_remove_bonding_slave_result *res = parsed_result; 6112 portid_t master_port_id = res->port_id; 6113 portid_t slave_port_id = res->slave_id; 6114 6115 /* remove the slave from a bonded device. */ 6116 if (0 != rte_eth_bond_slave_remove(master_port_id, slave_port_id)) { 6117 printf("\t Failed to remove slave %d from master port = %d.\n", 6118 slave_port_id, master_port_id); 6119 return; 6120 } 6121 init_port_config(); 6122 clear_port_slave_flag(slave_port_id); 6123 } 6124 6125 cmdline_parse_token_string_t cmd_removebonding_slave_remove = 6126 TOKEN_STRING_INITIALIZER(struct cmd_remove_bonding_slave_result, 6127 remove, "remove"); 6128 cmdline_parse_token_string_t cmd_removebonding_slave_bonding = 6129 TOKEN_STRING_INITIALIZER(struct cmd_remove_bonding_slave_result, 6130 bonding, "bonding"); 6131 cmdline_parse_token_string_t cmd_removebonding_slave_slave = 6132 TOKEN_STRING_INITIALIZER(struct cmd_remove_bonding_slave_result, 6133 slave, "slave"); 6134 cmdline_parse_token_num_t cmd_removebonding_slave_slaveid = 6135 TOKEN_NUM_INITIALIZER(struct cmd_remove_bonding_slave_result, 6136 slave_id, UINT16); 6137 cmdline_parse_token_num_t cmd_removebonding_slave_port = 6138 TOKEN_NUM_INITIALIZER(struct cmd_remove_bonding_slave_result, 6139 port_id, UINT16); 6140 6141 cmdline_parse_inst_t cmd_remove_bonding_slave = { 6142 .f = cmd_remove_bonding_slave_parsed, 6143 .help_str = "remove bonding slave <slave_id> <port_id>: " 6144 "Remove a slave device from a bonded device", 6145 .data = NULL, 6146 .tokens = { 6147 (void *)&cmd_removebonding_slave_remove, 6148 (void *)&cmd_removebonding_slave_bonding, 6149 (void *)&cmd_removebonding_slave_slave, 6150 (void *)&cmd_removebonding_slave_slaveid, 6151 (void *)&cmd_removebonding_slave_port, 6152 NULL 6153 } 6154 }; 6155 6156 /* *** CREATE BONDED DEVICE *** */ 6157 struct cmd_create_bonded_device_result { 6158 cmdline_fixed_string_t create; 6159 cmdline_fixed_string_t bonded; 6160 cmdline_fixed_string_t device; 6161 uint8_t mode; 6162 uint8_t socket; 6163 }; 6164 6165 static int bond_dev_num = 0; 6166 6167 static void cmd_create_bonded_device_parsed(void *parsed_result, 6168 __attribute__((unused)) struct cmdline *cl, 6169 __attribute__((unused)) void *data) 6170 { 6171 struct cmd_create_bonded_device_result *res = parsed_result; 6172 char ethdev_name[RTE_ETH_NAME_MAX_LEN]; 6173 int port_id; 6174 int ret; 6175 6176 if (test_done == 0) { 6177 printf("Please stop forwarding first\n"); 6178 return; 6179 } 6180 6181 snprintf(ethdev_name, RTE_ETH_NAME_MAX_LEN, "net_bonding_testpmd_%d", 6182 bond_dev_num++); 6183 6184 /* Create a new bonded device. */ 6185 port_id = rte_eth_bond_create(ethdev_name, res->mode, res->socket); 6186 if (port_id < 0) { 6187 printf("\t Failed to create bonded device.\n"); 6188 return; 6189 } else { 6190 printf("Created new bonded device %s on (port %d).\n", ethdev_name, 6191 port_id); 6192 6193 /* Update number of ports */ 6194 nb_ports = rte_eth_dev_count_avail(); 6195 reconfig(port_id, res->socket); 6196 ret = rte_eth_promiscuous_enable(port_id); 6197 if (ret != 0) 6198 printf("Failed to enable promiscuous mode for port %u: %s - ignore\n", 6199 port_id, rte_strerror(-ret)); 6200 6201 ports[port_id].need_setup = 0; 6202 ports[port_id].port_status = RTE_PORT_STOPPED; 6203 } 6204 6205 } 6206 6207 cmdline_parse_token_string_t cmd_createbonded_device_create = 6208 TOKEN_STRING_INITIALIZER(struct cmd_create_bonded_device_result, 6209 create, "create"); 6210 cmdline_parse_token_string_t cmd_createbonded_device_bonded = 6211 TOKEN_STRING_INITIALIZER(struct cmd_create_bonded_device_result, 6212 bonded, "bonded"); 6213 cmdline_parse_token_string_t cmd_createbonded_device_device = 6214 TOKEN_STRING_INITIALIZER(struct cmd_create_bonded_device_result, 6215 device, "device"); 6216 cmdline_parse_token_num_t cmd_createbonded_device_mode = 6217 TOKEN_NUM_INITIALIZER(struct cmd_create_bonded_device_result, 6218 mode, UINT8); 6219 cmdline_parse_token_num_t cmd_createbonded_device_socket = 6220 TOKEN_NUM_INITIALIZER(struct cmd_create_bonded_device_result, 6221 socket, UINT8); 6222 6223 cmdline_parse_inst_t cmd_create_bonded_device = { 6224 .f = cmd_create_bonded_device_parsed, 6225 .help_str = "create bonded device <mode> <socket>: " 6226 "Create a new bonded device with specific bonding mode and socket", 6227 .data = NULL, 6228 .tokens = { 6229 (void *)&cmd_createbonded_device_create, 6230 (void *)&cmd_createbonded_device_bonded, 6231 (void *)&cmd_createbonded_device_device, 6232 (void *)&cmd_createbonded_device_mode, 6233 (void *)&cmd_createbonded_device_socket, 6234 NULL 6235 } 6236 }; 6237 6238 /* *** SET MAC ADDRESS IN BONDED DEVICE *** */ 6239 struct cmd_set_bond_mac_addr_result { 6240 cmdline_fixed_string_t set; 6241 cmdline_fixed_string_t bonding; 6242 cmdline_fixed_string_t mac_addr; 6243 uint16_t port_num; 6244 struct rte_ether_addr address; 6245 }; 6246 6247 static void cmd_set_bond_mac_addr_parsed(void *parsed_result, 6248 __attribute__((unused)) struct cmdline *cl, 6249 __attribute__((unused)) void *data) 6250 { 6251 struct cmd_set_bond_mac_addr_result *res = parsed_result; 6252 int ret; 6253 6254 if (port_id_is_invalid(res->port_num, ENABLED_WARN)) 6255 return; 6256 6257 ret = rte_eth_bond_mac_address_set(res->port_num, &res->address); 6258 6259 /* check the return value and print it if is < 0 */ 6260 if (ret < 0) 6261 printf("set_bond_mac_addr error: (%s)\n", strerror(-ret)); 6262 } 6263 6264 cmdline_parse_token_string_t cmd_set_bond_mac_addr_set = 6265 TOKEN_STRING_INITIALIZER(struct cmd_set_bond_mac_addr_result, set, "set"); 6266 cmdline_parse_token_string_t cmd_set_bond_mac_addr_bonding = 6267 TOKEN_STRING_INITIALIZER(struct cmd_set_bond_mac_addr_result, bonding, 6268 "bonding"); 6269 cmdline_parse_token_string_t cmd_set_bond_mac_addr_mac = 6270 TOKEN_STRING_INITIALIZER(struct cmd_set_bond_mac_addr_result, mac_addr, 6271 "mac_addr"); 6272 cmdline_parse_token_num_t cmd_set_bond_mac_addr_portnum = 6273 TOKEN_NUM_INITIALIZER(struct cmd_set_bond_mac_addr_result, 6274 port_num, UINT16); 6275 cmdline_parse_token_etheraddr_t cmd_set_bond_mac_addr_addr = 6276 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_bond_mac_addr_result, address); 6277 6278 cmdline_parse_inst_t cmd_set_bond_mac_addr = { 6279 .f = cmd_set_bond_mac_addr_parsed, 6280 .data = (void *) 0, 6281 .help_str = "set bonding mac_addr <port_id> <mac_addr>", 6282 .tokens = { 6283 (void *)&cmd_set_bond_mac_addr_set, 6284 (void *)&cmd_set_bond_mac_addr_bonding, 6285 (void *)&cmd_set_bond_mac_addr_mac, 6286 (void *)&cmd_set_bond_mac_addr_portnum, 6287 (void *)&cmd_set_bond_mac_addr_addr, 6288 NULL 6289 } 6290 }; 6291 6292 6293 /* *** SET LINK STATUS MONITORING POLLING PERIOD ON BONDED DEVICE *** */ 6294 struct cmd_set_bond_mon_period_result { 6295 cmdline_fixed_string_t set; 6296 cmdline_fixed_string_t bonding; 6297 cmdline_fixed_string_t mon_period; 6298 uint16_t port_num; 6299 uint32_t period_ms; 6300 }; 6301 6302 static void cmd_set_bond_mon_period_parsed(void *parsed_result, 6303 __attribute__((unused)) struct cmdline *cl, 6304 __attribute__((unused)) void *data) 6305 { 6306 struct cmd_set_bond_mon_period_result *res = parsed_result; 6307 int ret; 6308 6309 ret = rte_eth_bond_link_monitoring_set(res->port_num, res->period_ms); 6310 6311 /* check the return value and print it if is < 0 */ 6312 if (ret < 0) 6313 printf("set_bond_mac_addr error: (%s)\n", strerror(-ret)); 6314 } 6315 6316 cmdline_parse_token_string_t cmd_set_bond_mon_period_set = 6317 TOKEN_STRING_INITIALIZER(struct cmd_set_bond_mon_period_result, 6318 set, "set"); 6319 cmdline_parse_token_string_t cmd_set_bond_mon_period_bonding = 6320 TOKEN_STRING_INITIALIZER(struct cmd_set_bond_mon_period_result, 6321 bonding, "bonding"); 6322 cmdline_parse_token_string_t cmd_set_bond_mon_period_mon_period = 6323 TOKEN_STRING_INITIALIZER(struct cmd_set_bond_mon_period_result, 6324 mon_period, "mon_period"); 6325 cmdline_parse_token_num_t cmd_set_bond_mon_period_portnum = 6326 TOKEN_NUM_INITIALIZER(struct cmd_set_bond_mon_period_result, 6327 port_num, UINT16); 6328 cmdline_parse_token_num_t cmd_set_bond_mon_period_period_ms = 6329 TOKEN_NUM_INITIALIZER(struct cmd_set_bond_mon_period_result, 6330 period_ms, UINT32); 6331 6332 cmdline_parse_inst_t cmd_set_bond_mon_period = { 6333 .f = cmd_set_bond_mon_period_parsed, 6334 .data = (void *) 0, 6335 .help_str = "set bonding mon_period <port_id> <period_ms>", 6336 .tokens = { 6337 (void *)&cmd_set_bond_mon_period_set, 6338 (void *)&cmd_set_bond_mon_period_bonding, 6339 (void *)&cmd_set_bond_mon_period_mon_period, 6340 (void *)&cmd_set_bond_mon_period_portnum, 6341 (void *)&cmd_set_bond_mon_period_period_ms, 6342 NULL 6343 } 6344 }; 6345 6346 6347 6348 struct cmd_set_bonding_agg_mode_policy_result { 6349 cmdline_fixed_string_t set; 6350 cmdline_fixed_string_t bonding; 6351 cmdline_fixed_string_t agg_mode; 6352 uint16_t port_num; 6353 cmdline_fixed_string_t policy; 6354 }; 6355 6356 6357 static void 6358 cmd_set_bonding_agg_mode(void *parsed_result, 6359 __attribute__((unused)) struct cmdline *cl, 6360 __attribute__((unused)) void *data) 6361 { 6362 struct cmd_set_bonding_agg_mode_policy_result *res = parsed_result; 6363 uint8_t policy = AGG_BANDWIDTH; 6364 6365 if (!strcmp(res->policy, "bandwidth")) 6366 policy = AGG_BANDWIDTH; 6367 else if (!strcmp(res->policy, "stable")) 6368 policy = AGG_STABLE; 6369 else if (!strcmp(res->policy, "count")) 6370 policy = AGG_COUNT; 6371 6372 rte_eth_bond_8023ad_agg_selection_set(res->port_num, policy); 6373 } 6374 6375 6376 cmdline_parse_token_string_t cmd_set_bonding_agg_mode_set = 6377 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_agg_mode_policy_result, 6378 set, "set"); 6379 cmdline_parse_token_string_t cmd_set_bonding_agg_mode_bonding = 6380 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_agg_mode_policy_result, 6381 bonding, "bonding"); 6382 6383 cmdline_parse_token_string_t cmd_set_bonding_agg_mode_agg_mode = 6384 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_agg_mode_policy_result, 6385 agg_mode, "agg_mode"); 6386 6387 cmdline_parse_token_num_t cmd_set_bonding_agg_mode_portnum = 6388 TOKEN_NUM_INITIALIZER(struct cmd_set_bonding_agg_mode_policy_result, 6389 port_num, UINT16); 6390 6391 cmdline_parse_token_string_t cmd_set_bonding_agg_mode_policy_string = 6392 TOKEN_STRING_INITIALIZER( 6393 struct cmd_set_bonding_balance_xmit_policy_result, 6394 policy, "stable#bandwidth#count"); 6395 6396 cmdline_parse_inst_t cmd_set_bonding_agg_mode_policy = { 6397 .f = cmd_set_bonding_agg_mode, 6398 .data = (void *) 0, 6399 .help_str = "set bonding mode IEEE802.3AD aggregator policy <port_id> <agg_name>", 6400 .tokens = { 6401 (void *)&cmd_set_bonding_agg_mode_set, 6402 (void *)&cmd_set_bonding_agg_mode_bonding, 6403 (void *)&cmd_set_bonding_agg_mode_agg_mode, 6404 (void *)&cmd_set_bonding_agg_mode_portnum, 6405 (void *)&cmd_set_bonding_agg_mode_policy_string, 6406 NULL 6407 } 6408 }; 6409 6410 6411 #endif /* RTE_LIBRTE_PMD_BOND */ 6412 6413 /* *** SET FORWARDING MODE *** */ 6414 struct cmd_set_fwd_mode_result { 6415 cmdline_fixed_string_t set; 6416 cmdline_fixed_string_t fwd; 6417 cmdline_fixed_string_t mode; 6418 }; 6419 6420 static void cmd_set_fwd_mode_parsed(void *parsed_result, 6421 __attribute__((unused)) struct cmdline *cl, 6422 __attribute__((unused)) void *data) 6423 { 6424 struct cmd_set_fwd_mode_result *res = parsed_result; 6425 6426 retry_enabled = 0; 6427 set_pkt_forwarding_mode(res->mode); 6428 } 6429 6430 cmdline_parse_token_string_t cmd_setfwd_set = 6431 TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_mode_result, set, "set"); 6432 cmdline_parse_token_string_t cmd_setfwd_fwd = 6433 TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_mode_result, fwd, "fwd"); 6434 cmdline_parse_token_string_t cmd_setfwd_mode = 6435 TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_mode_result, mode, 6436 "" /* defined at init */); 6437 6438 cmdline_parse_inst_t cmd_set_fwd_mode = { 6439 .f = cmd_set_fwd_mode_parsed, 6440 .data = NULL, 6441 .help_str = NULL, /* defined at init */ 6442 .tokens = { 6443 (void *)&cmd_setfwd_set, 6444 (void *)&cmd_setfwd_fwd, 6445 (void *)&cmd_setfwd_mode, 6446 NULL, 6447 }, 6448 }; 6449 6450 static void cmd_set_fwd_mode_init(void) 6451 { 6452 char *modes, *c; 6453 static char token[128]; 6454 static char help[256]; 6455 cmdline_parse_token_string_t *token_struct; 6456 6457 modes = list_pkt_forwarding_modes(); 6458 snprintf(help, sizeof(help), "set fwd %s: " 6459 "Set packet forwarding mode", modes); 6460 cmd_set_fwd_mode.help_str = help; 6461 6462 /* string token separator is # */ 6463 for (c = token; *modes != '\0'; modes++) 6464 if (*modes == '|') 6465 *c++ = '#'; 6466 else 6467 *c++ = *modes; 6468 token_struct = (cmdline_parse_token_string_t*)cmd_set_fwd_mode.tokens[2]; 6469 token_struct->string_data.str = token; 6470 } 6471 6472 /* *** SET RETRY FORWARDING MODE *** */ 6473 struct cmd_set_fwd_retry_mode_result { 6474 cmdline_fixed_string_t set; 6475 cmdline_fixed_string_t fwd; 6476 cmdline_fixed_string_t mode; 6477 cmdline_fixed_string_t retry; 6478 }; 6479 6480 static void cmd_set_fwd_retry_mode_parsed(void *parsed_result, 6481 __attribute__((unused)) struct cmdline *cl, 6482 __attribute__((unused)) void *data) 6483 { 6484 struct cmd_set_fwd_retry_mode_result *res = parsed_result; 6485 6486 retry_enabled = 1; 6487 set_pkt_forwarding_mode(res->mode); 6488 } 6489 6490 cmdline_parse_token_string_t cmd_setfwd_retry_set = 6491 TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_retry_mode_result, 6492 set, "set"); 6493 cmdline_parse_token_string_t cmd_setfwd_retry_fwd = 6494 TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_retry_mode_result, 6495 fwd, "fwd"); 6496 cmdline_parse_token_string_t cmd_setfwd_retry_mode = 6497 TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_retry_mode_result, 6498 mode, 6499 "" /* defined at init */); 6500 cmdline_parse_token_string_t cmd_setfwd_retry_retry = 6501 TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_retry_mode_result, 6502 retry, "retry"); 6503 6504 cmdline_parse_inst_t cmd_set_fwd_retry_mode = { 6505 .f = cmd_set_fwd_retry_mode_parsed, 6506 .data = NULL, 6507 .help_str = NULL, /* defined at init */ 6508 .tokens = { 6509 (void *)&cmd_setfwd_retry_set, 6510 (void *)&cmd_setfwd_retry_fwd, 6511 (void *)&cmd_setfwd_retry_mode, 6512 (void *)&cmd_setfwd_retry_retry, 6513 NULL, 6514 }, 6515 }; 6516 6517 static void cmd_set_fwd_retry_mode_init(void) 6518 { 6519 char *modes, *c; 6520 static char token[128]; 6521 static char help[256]; 6522 cmdline_parse_token_string_t *token_struct; 6523 6524 modes = list_pkt_forwarding_retry_modes(); 6525 snprintf(help, sizeof(help), "set fwd %s retry: " 6526 "Set packet forwarding mode with retry", modes); 6527 cmd_set_fwd_retry_mode.help_str = help; 6528 6529 /* string token separator is # */ 6530 for (c = token; *modes != '\0'; modes++) 6531 if (*modes == '|') 6532 *c++ = '#'; 6533 else 6534 *c++ = *modes; 6535 token_struct = (cmdline_parse_token_string_t *) 6536 cmd_set_fwd_retry_mode.tokens[2]; 6537 token_struct->string_data.str = token; 6538 } 6539 6540 /* *** SET BURST TX DELAY TIME RETRY NUMBER *** */ 6541 struct cmd_set_burst_tx_retry_result { 6542 cmdline_fixed_string_t set; 6543 cmdline_fixed_string_t burst; 6544 cmdline_fixed_string_t tx; 6545 cmdline_fixed_string_t delay; 6546 uint32_t time; 6547 cmdline_fixed_string_t retry; 6548 uint32_t retry_num; 6549 }; 6550 6551 static void cmd_set_burst_tx_retry_parsed(void *parsed_result, 6552 __attribute__((unused)) struct cmdline *cl, 6553 __attribute__((unused)) void *data) 6554 { 6555 struct cmd_set_burst_tx_retry_result *res = parsed_result; 6556 6557 if (!strcmp(res->set, "set") && !strcmp(res->burst, "burst") 6558 && !strcmp(res->tx, "tx")) { 6559 if (!strcmp(res->delay, "delay")) 6560 burst_tx_delay_time = res->time; 6561 if (!strcmp(res->retry, "retry")) 6562 burst_tx_retry_num = res->retry_num; 6563 } 6564 6565 } 6566 6567 cmdline_parse_token_string_t cmd_set_burst_tx_retry_set = 6568 TOKEN_STRING_INITIALIZER(struct cmd_set_burst_tx_retry_result, set, "set"); 6569 cmdline_parse_token_string_t cmd_set_burst_tx_retry_burst = 6570 TOKEN_STRING_INITIALIZER(struct cmd_set_burst_tx_retry_result, burst, 6571 "burst"); 6572 cmdline_parse_token_string_t cmd_set_burst_tx_retry_tx = 6573 TOKEN_STRING_INITIALIZER(struct cmd_set_burst_tx_retry_result, tx, "tx"); 6574 cmdline_parse_token_string_t cmd_set_burst_tx_retry_delay = 6575 TOKEN_STRING_INITIALIZER(struct cmd_set_burst_tx_retry_result, delay, "delay"); 6576 cmdline_parse_token_num_t cmd_set_burst_tx_retry_time = 6577 TOKEN_NUM_INITIALIZER(struct cmd_set_burst_tx_retry_result, time, UINT32); 6578 cmdline_parse_token_string_t cmd_set_burst_tx_retry_retry = 6579 TOKEN_STRING_INITIALIZER(struct cmd_set_burst_tx_retry_result, retry, "retry"); 6580 cmdline_parse_token_num_t cmd_set_burst_tx_retry_retry_num = 6581 TOKEN_NUM_INITIALIZER(struct cmd_set_burst_tx_retry_result, retry_num, UINT32); 6582 6583 cmdline_parse_inst_t cmd_set_burst_tx_retry = { 6584 .f = cmd_set_burst_tx_retry_parsed, 6585 .help_str = "set burst tx delay <delay_usec> retry <num_retry>", 6586 .tokens = { 6587 (void *)&cmd_set_burst_tx_retry_set, 6588 (void *)&cmd_set_burst_tx_retry_burst, 6589 (void *)&cmd_set_burst_tx_retry_tx, 6590 (void *)&cmd_set_burst_tx_retry_delay, 6591 (void *)&cmd_set_burst_tx_retry_time, 6592 (void *)&cmd_set_burst_tx_retry_retry, 6593 (void *)&cmd_set_burst_tx_retry_retry_num, 6594 NULL, 6595 }, 6596 }; 6597 6598 /* *** SET PROMISC MODE *** */ 6599 struct cmd_set_promisc_mode_result { 6600 cmdline_fixed_string_t set; 6601 cmdline_fixed_string_t promisc; 6602 cmdline_fixed_string_t port_all; /* valid if "allports" argument == 1 */ 6603 uint16_t port_num; /* valid if "allports" argument == 0 */ 6604 cmdline_fixed_string_t mode; 6605 }; 6606 6607 static void cmd_set_promisc_mode_parsed(void *parsed_result, 6608 __attribute__((unused)) struct cmdline *cl, 6609 void *allports) 6610 { 6611 struct cmd_set_promisc_mode_result *res = parsed_result; 6612 int enable; 6613 portid_t i; 6614 6615 if (!strcmp(res->mode, "on")) 6616 enable = 1; 6617 else 6618 enable = 0; 6619 6620 /* all ports */ 6621 if (allports) { 6622 RTE_ETH_FOREACH_DEV(i) 6623 eth_set_promisc_mode(i, enable); 6624 } else { 6625 eth_set_promisc_mode(res->port_num, enable); 6626 } 6627 } 6628 6629 cmdline_parse_token_string_t cmd_setpromisc_set = 6630 TOKEN_STRING_INITIALIZER(struct cmd_set_promisc_mode_result, set, "set"); 6631 cmdline_parse_token_string_t cmd_setpromisc_promisc = 6632 TOKEN_STRING_INITIALIZER(struct cmd_set_promisc_mode_result, promisc, 6633 "promisc"); 6634 cmdline_parse_token_string_t cmd_setpromisc_portall = 6635 TOKEN_STRING_INITIALIZER(struct cmd_set_promisc_mode_result, port_all, 6636 "all"); 6637 cmdline_parse_token_num_t cmd_setpromisc_portnum = 6638 TOKEN_NUM_INITIALIZER(struct cmd_set_promisc_mode_result, port_num, 6639 UINT16); 6640 cmdline_parse_token_string_t cmd_setpromisc_mode = 6641 TOKEN_STRING_INITIALIZER(struct cmd_set_promisc_mode_result, mode, 6642 "on#off"); 6643 6644 cmdline_parse_inst_t cmd_set_promisc_mode_all = { 6645 .f = cmd_set_promisc_mode_parsed, 6646 .data = (void *)1, 6647 .help_str = "set promisc all on|off: Set promisc mode for all ports", 6648 .tokens = { 6649 (void *)&cmd_setpromisc_set, 6650 (void *)&cmd_setpromisc_promisc, 6651 (void *)&cmd_setpromisc_portall, 6652 (void *)&cmd_setpromisc_mode, 6653 NULL, 6654 }, 6655 }; 6656 6657 cmdline_parse_inst_t cmd_set_promisc_mode_one = { 6658 .f = cmd_set_promisc_mode_parsed, 6659 .data = (void *)0, 6660 .help_str = "set promisc <port_id> on|off: Set promisc mode on port_id", 6661 .tokens = { 6662 (void *)&cmd_setpromisc_set, 6663 (void *)&cmd_setpromisc_promisc, 6664 (void *)&cmd_setpromisc_portnum, 6665 (void *)&cmd_setpromisc_mode, 6666 NULL, 6667 }, 6668 }; 6669 6670 /* *** SET ALLMULTI MODE *** */ 6671 struct cmd_set_allmulti_mode_result { 6672 cmdline_fixed_string_t set; 6673 cmdline_fixed_string_t allmulti; 6674 cmdline_fixed_string_t port_all; /* valid if "allports" argument == 1 */ 6675 uint16_t port_num; /* valid if "allports" argument == 0 */ 6676 cmdline_fixed_string_t mode; 6677 }; 6678 6679 static void cmd_set_allmulti_mode_parsed(void *parsed_result, 6680 __attribute__((unused)) struct cmdline *cl, 6681 void *allports) 6682 { 6683 struct cmd_set_allmulti_mode_result *res = parsed_result; 6684 int enable; 6685 portid_t i; 6686 6687 if (!strcmp(res->mode, "on")) 6688 enable = 1; 6689 else 6690 enable = 0; 6691 6692 /* all ports */ 6693 if (allports) { 6694 RTE_ETH_FOREACH_DEV(i) { 6695 eth_set_allmulticast_mode(i, enable); 6696 } 6697 } 6698 else { 6699 eth_set_allmulticast_mode(res->port_num, enable); 6700 } 6701 } 6702 6703 cmdline_parse_token_string_t cmd_setallmulti_set = 6704 TOKEN_STRING_INITIALIZER(struct cmd_set_allmulti_mode_result, set, "set"); 6705 cmdline_parse_token_string_t cmd_setallmulti_allmulti = 6706 TOKEN_STRING_INITIALIZER(struct cmd_set_allmulti_mode_result, allmulti, 6707 "allmulti"); 6708 cmdline_parse_token_string_t cmd_setallmulti_portall = 6709 TOKEN_STRING_INITIALIZER(struct cmd_set_allmulti_mode_result, port_all, 6710 "all"); 6711 cmdline_parse_token_num_t cmd_setallmulti_portnum = 6712 TOKEN_NUM_INITIALIZER(struct cmd_set_allmulti_mode_result, port_num, 6713 UINT16); 6714 cmdline_parse_token_string_t cmd_setallmulti_mode = 6715 TOKEN_STRING_INITIALIZER(struct cmd_set_allmulti_mode_result, mode, 6716 "on#off"); 6717 6718 cmdline_parse_inst_t cmd_set_allmulti_mode_all = { 6719 .f = cmd_set_allmulti_mode_parsed, 6720 .data = (void *)1, 6721 .help_str = "set allmulti all on|off: Set allmulti mode for all ports", 6722 .tokens = { 6723 (void *)&cmd_setallmulti_set, 6724 (void *)&cmd_setallmulti_allmulti, 6725 (void *)&cmd_setallmulti_portall, 6726 (void *)&cmd_setallmulti_mode, 6727 NULL, 6728 }, 6729 }; 6730 6731 cmdline_parse_inst_t cmd_set_allmulti_mode_one = { 6732 .f = cmd_set_allmulti_mode_parsed, 6733 .data = (void *)0, 6734 .help_str = "set allmulti <port_id> on|off: " 6735 "Set allmulti mode on port_id", 6736 .tokens = { 6737 (void *)&cmd_setallmulti_set, 6738 (void *)&cmd_setallmulti_allmulti, 6739 (void *)&cmd_setallmulti_portnum, 6740 (void *)&cmd_setallmulti_mode, 6741 NULL, 6742 }, 6743 }; 6744 6745 /* *** SETUP ETHERNET LINK FLOW CONTROL *** */ 6746 struct cmd_link_flow_ctrl_set_result { 6747 cmdline_fixed_string_t set; 6748 cmdline_fixed_string_t flow_ctrl; 6749 cmdline_fixed_string_t rx; 6750 cmdline_fixed_string_t rx_lfc_mode; 6751 cmdline_fixed_string_t tx; 6752 cmdline_fixed_string_t tx_lfc_mode; 6753 cmdline_fixed_string_t mac_ctrl_frame_fwd; 6754 cmdline_fixed_string_t mac_ctrl_frame_fwd_mode; 6755 cmdline_fixed_string_t autoneg_str; 6756 cmdline_fixed_string_t autoneg; 6757 cmdline_fixed_string_t hw_str; 6758 uint32_t high_water; 6759 cmdline_fixed_string_t lw_str; 6760 uint32_t low_water; 6761 cmdline_fixed_string_t pt_str; 6762 uint16_t pause_time; 6763 cmdline_fixed_string_t xon_str; 6764 uint16_t send_xon; 6765 portid_t port_id; 6766 }; 6767 6768 cmdline_parse_token_string_t cmd_lfc_set_set = 6769 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result, 6770 set, "set"); 6771 cmdline_parse_token_string_t cmd_lfc_set_flow_ctrl = 6772 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result, 6773 flow_ctrl, "flow_ctrl"); 6774 cmdline_parse_token_string_t cmd_lfc_set_rx = 6775 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result, 6776 rx, "rx"); 6777 cmdline_parse_token_string_t cmd_lfc_set_rx_mode = 6778 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result, 6779 rx_lfc_mode, "on#off"); 6780 cmdline_parse_token_string_t cmd_lfc_set_tx = 6781 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result, 6782 tx, "tx"); 6783 cmdline_parse_token_string_t cmd_lfc_set_tx_mode = 6784 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result, 6785 tx_lfc_mode, "on#off"); 6786 cmdline_parse_token_string_t cmd_lfc_set_high_water_str = 6787 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result, 6788 hw_str, "high_water"); 6789 cmdline_parse_token_num_t cmd_lfc_set_high_water = 6790 TOKEN_NUM_INITIALIZER(struct cmd_link_flow_ctrl_set_result, 6791 high_water, UINT32); 6792 cmdline_parse_token_string_t cmd_lfc_set_low_water_str = 6793 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result, 6794 lw_str, "low_water"); 6795 cmdline_parse_token_num_t cmd_lfc_set_low_water = 6796 TOKEN_NUM_INITIALIZER(struct cmd_link_flow_ctrl_set_result, 6797 low_water, UINT32); 6798 cmdline_parse_token_string_t cmd_lfc_set_pause_time_str = 6799 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result, 6800 pt_str, "pause_time"); 6801 cmdline_parse_token_num_t cmd_lfc_set_pause_time = 6802 TOKEN_NUM_INITIALIZER(struct cmd_link_flow_ctrl_set_result, 6803 pause_time, UINT16); 6804 cmdline_parse_token_string_t cmd_lfc_set_send_xon_str = 6805 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result, 6806 xon_str, "send_xon"); 6807 cmdline_parse_token_num_t cmd_lfc_set_send_xon = 6808 TOKEN_NUM_INITIALIZER(struct cmd_link_flow_ctrl_set_result, 6809 send_xon, UINT16); 6810 cmdline_parse_token_string_t cmd_lfc_set_mac_ctrl_frame_fwd_mode = 6811 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result, 6812 mac_ctrl_frame_fwd, "mac_ctrl_frame_fwd"); 6813 cmdline_parse_token_string_t cmd_lfc_set_mac_ctrl_frame_fwd = 6814 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result, 6815 mac_ctrl_frame_fwd_mode, "on#off"); 6816 cmdline_parse_token_string_t cmd_lfc_set_autoneg_str = 6817 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result, 6818 autoneg_str, "autoneg"); 6819 cmdline_parse_token_string_t cmd_lfc_set_autoneg = 6820 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result, 6821 autoneg, "on#off"); 6822 cmdline_parse_token_num_t cmd_lfc_set_portid = 6823 TOKEN_NUM_INITIALIZER(struct cmd_link_flow_ctrl_set_result, 6824 port_id, UINT16); 6825 6826 /* forward declaration */ 6827 static void 6828 cmd_link_flow_ctrl_set_parsed(void *parsed_result, struct cmdline *cl, 6829 void *data); 6830 6831 cmdline_parse_inst_t cmd_link_flow_control_set = { 6832 .f = cmd_link_flow_ctrl_set_parsed, 6833 .data = NULL, 6834 .help_str = "set flow_ctrl rx on|off tx on|off <high_water> " 6835 "<low_water> <pause_time> <send_xon> mac_ctrl_frame_fwd on|off " 6836 "autoneg on|off <port_id>: Configure the Ethernet flow control", 6837 .tokens = { 6838 (void *)&cmd_lfc_set_set, 6839 (void *)&cmd_lfc_set_flow_ctrl, 6840 (void *)&cmd_lfc_set_rx, 6841 (void *)&cmd_lfc_set_rx_mode, 6842 (void *)&cmd_lfc_set_tx, 6843 (void *)&cmd_lfc_set_tx_mode, 6844 (void *)&cmd_lfc_set_high_water, 6845 (void *)&cmd_lfc_set_low_water, 6846 (void *)&cmd_lfc_set_pause_time, 6847 (void *)&cmd_lfc_set_send_xon, 6848 (void *)&cmd_lfc_set_mac_ctrl_frame_fwd_mode, 6849 (void *)&cmd_lfc_set_mac_ctrl_frame_fwd, 6850 (void *)&cmd_lfc_set_autoneg_str, 6851 (void *)&cmd_lfc_set_autoneg, 6852 (void *)&cmd_lfc_set_portid, 6853 NULL, 6854 }, 6855 }; 6856 6857 cmdline_parse_inst_t cmd_link_flow_control_set_rx = { 6858 .f = cmd_link_flow_ctrl_set_parsed, 6859 .data = (void *)&cmd_link_flow_control_set_rx, 6860 .help_str = "set flow_ctrl rx on|off <port_id>: " 6861 "Change rx flow control parameter", 6862 .tokens = { 6863 (void *)&cmd_lfc_set_set, 6864 (void *)&cmd_lfc_set_flow_ctrl, 6865 (void *)&cmd_lfc_set_rx, 6866 (void *)&cmd_lfc_set_rx_mode, 6867 (void *)&cmd_lfc_set_portid, 6868 NULL, 6869 }, 6870 }; 6871 6872 cmdline_parse_inst_t cmd_link_flow_control_set_tx = { 6873 .f = cmd_link_flow_ctrl_set_parsed, 6874 .data = (void *)&cmd_link_flow_control_set_tx, 6875 .help_str = "set flow_ctrl tx on|off <port_id>: " 6876 "Change tx flow control parameter", 6877 .tokens = { 6878 (void *)&cmd_lfc_set_set, 6879 (void *)&cmd_lfc_set_flow_ctrl, 6880 (void *)&cmd_lfc_set_tx, 6881 (void *)&cmd_lfc_set_tx_mode, 6882 (void *)&cmd_lfc_set_portid, 6883 NULL, 6884 }, 6885 }; 6886 6887 cmdline_parse_inst_t cmd_link_flow_control_set_hw = { 6888 .f = cmd_link_flow_ctrl_set_parsed, 6889 .data = (void *)&cmd_link_flow_control_set_hw, 6890 .help_str = "set flow_ctrl high_water <value> <port_id>: " 6891 "Change high water flow control parameter", 6892 .tokens = { 6893 (void *)&cmd_lfc_set_set, 6894 (void *)&cmd_lfc_set_flow_ctrl, 6895 (void *)&cmd_lfc_set_high_water_str, 6896 (void *)&cmd_lfc_set_high_water, 6897 (void *)&cmd_lfc_set_portid, 6898 NULL, 6899 }, 6900 }; 6901 6902 cmdline_parse_inst_t cmd_link_flow_control_set_lw = { 6903 .f = cmd_link_flow_ctrl_set_parsed, 6904 .data = (void *)&cmd_link_flow_control_set_lw, 6905 .help_str = "set flow_ctrl low_water <value> <port_id>: " 6906 "Change low water flow control parameter", 6907 .tokens = { 6908 (void *)&cmd_lfc_set_set, 6909 (void *)&cmd_lfc_set_flow_ctrl, 6910 (void *)&cmd_lfc_set_low_water_str, 6911 (void *)&cmd_lfc_set_low_water, 6912 (void *)&cmd_lfc_set_portid, 6913 NULL, 6914 }, 6915 }; 6916 6917 cmdline_parse_inst_t cmd_link_flow_control_set_pt = { 6918 .f = cmd_link_flow_ctrl_set_parsed, 6919 .data = (void *)&cmd_link_flow_control_set_pt, 6920 .help_str = "set flow_ctrl pause_time <value> <port_id>: " 6921 "Change pause time flow control parameter", 6922 .tokens = { 6923 (void *)&cmd_lfc_set_set, 6924 (void *)&cmd_lfc_set_flow_ctrl, 6925 (void *)&cmd_lfc_set_pause_time_str, 6926 (void *)&cmd_lfc_set_pause_time, 6927 (void *)&cmd_lfc_set_portid, 6928 NULL, 6929 }, 6930 }; 6931 6932 cmdline_parse_inst_t cmd_link_flow_control_set_xon = { 6933 .f = cmd_link_flow_ctrl_set_parsed, 6934 .data = (void *)&cmd_link_flow_control_set_xon, 6935 .help_str = "set flow_ctrl send_xon <value> <port_id>: " 6936 "Change send_xon flow control parameter", 6937 .tokens = { 6938 (void *)&cmd_lfc_set_set, 6939 (void *)&cmd_lfc_set_flow_ctrl, 6940 (void *)&cmd_lfc_set_send_xon_str, 6941 (void *)&cmd_lfc_set_send_xon, 6942 (void *)&cmd_lfc_set_portid, 6943 NULL, 6944 }, 6945 }; 6946 6947 cmdline_parse_inst_t cmd_link_flow_control_set_macfwd = { 6948 .f = cmd_link_flow_ctrl_set_parsed, 6949 .data = (void *)&cmd_link_flow_control_set_macfwd, 6950 .help_str = "set flow_ctrl mac_ctrl_frame_fwd on|off <port_id>: " 6951 "Change mac ctrl fwd flow control parameter", 6952 .tokens = { 6953 (void *)&cmd_lfc_set_set, 6954 (void *)&cmd_lfc_set_flow_ctrl, 6955 (void *)&cmd_lfc_set_mac_ctrl_frame_fwd_mode, 6956 (void *)&cmd_lfc_set_mac_ctrl_frame_fwd, 6957 (void *)&cmd_lfc_set_portid, 6958 NULL, 6959 }, 6960 }; 6961 6962 cmdline_parse_inst_t cmd_link_flow_control_set_autoneg = { 6963 .f = cmd_link_flow_ctrl_set_parsed, 6964 .data = (void *)&cmd_link_flow_control_set_autoneg, 6965 .help_str = "set flow_ctrl autoneg on|off <port_id>: " 6966 "Change autoneg flow control parameter", 6967 .tokens = { 6968 (void *)&cmd_lfc_set_set, 6969 (void *)&cmd_lfc_set_flow_ctrl, 6970 (void *)&cmd_lfc_set_autoneg_str, 6971 (void *)&cmd_lfc_set_autoneg, 6972 (void *)&cmd_lfc_set_portid, 6973 NULL, 6974 }, 6975 }; 6976 6977 static void 6978 cmd_link_flow_ctrl_set_parsed(void *parsed_result, 6979 __attribute__((unused)) struct cmdline *cl, 6980 void *data) 6981 { 6982 struct cmd_link_flow_ctrl_set_result *res = parsed_result; 6983 cmdline_parse_inst_t *cmd = data; 6984 struct rte_eth_fc_conf fc_conf; 6985 int rx_fc_en = 0; 6986 int tx_fc_en = 0; 6987 int ret; 6988 6989 /* 6990 * Rx on/off, flow control is enabled/disabled on RX side. This can indicate 6991 * the RTE_FC_TX_PAUSE, Transmit pause frame at the Rx side. 6992 * Tx on/off, flow control is enabled/disabled on TX side. This can indicate 6993 * the RTE_FC_RX_PAUSE, Respond to the pause frame at the Tx side. 6994 */ 6995 static enum rte_eth_fc_mode rx_tx_onoff_2_lfc_mode[2][2] = { 6996 {RTE_FC_NONE, RTE_FC_TX_PAUSE}, {RTE_FC_RX_PAUSE, RTE_FC_FULL} 6997 }; 6998 6999 /* Partial command line, retrieve current configuration */ 7000 if (cmd) { 7001 ret = rte_eth_dev_flow_ctrl_get(res->port_id, &fc_conf); 7002 if (ret != 0) { 7003 printf("cannot get current flow ctrl parameters, return" 7004 "code = %d\n", ret); 7005 return; 7006 } 7007 7008 if ((fc_conf.mode == RTE_FC_RX_PAUSE) || 7009 (fc_conf.mode == RTE_FC_FULL)) 7010 rx_fc_en = 1; 7011 if ((fc_conf.mode == RTE_FC_TX_PAUSE) || 7012 (fc_conf.mode == RTE_FC_FULL)) 7013 tx_fc_en = 1; 7014 } 7015 7016 if (!cmd || cmd == &cmd_link_flow_control_set_rx) 7017 rx_fc_en = (!strcmp(res->rx_lfc_mode, "on")) ? 1 : 0; 7018 7019 if (!cmd || cmd == &cmd_link_flow_control_set_tx) 7020 tx_fc_en = (!strcmp(res->tx_lfc_mode, "on")) ? 1 : 0; 7021 7022 fc_conf.mode = rx_tx_onoff_2_lfc_mode[rx_fc_en][tx_fc_en]; 7023 7024 if (!cmd || cmd == &cmd_link_flow_control_set_hw) 7025 fc_conf.high_water = res->high_water; 7026 7027 if (!cmd || cmd == &cmd_link_flow_control_set_lw) 7028 fc_conf.low_water = res->low_water; 7029 7030 if (!cmd || cmd == &cmd_link_flow_control_set_pt) 7031 fc_conf.pause_time = res->pause_time; 7032 7033 if (!cmd || cmd == &cmd_link_flow_control_set_xon) 7034 fc_conf.send_xon = res->send_xon; 7035 7036 if (!cmd || cmd == &cmd_link_flow_control_set_macfwd) { 7037 if (!strcmp(res->mac_ctrl_frame_fwd_mode, "on")) 7038 fc_conf.mac_ctrl_frame_fwd = 1; 7039 else 7040 fc_conf.mac_ctrl_frame_fwd = 0; 7041 } 7042 7043 if (!cmd || cmd == &cmd_link_flow_control_set_autoneg) 7044 fc_conf.autoneg = (!strcmp(res->autoneg, "on")) ? 1 : 0; 7045 7046 ret = rte_eth_dev_flow_ctrl_set(res->port_id, &fc_conf); 7047 if (ret != 0) 7048 printf("bad flow contrl parameter, return code = %d \n", ret); 7049 } 7050 7051 /* *** SETUP ETHERNET PRIORITY FLOW CONTROL *** */ 7052 struct cmd_priority_flow_ctrl_set_result { 7053 cmdline_fixed_string_t set; 7054 cmdline_fixed_string_t pfc_ctrl; 7055 cmdline_fixed_string_t rx; 7056 cmdline_fixed_string_t rx_pfc_mode; 7057 cmdline_fixed_string_t tx; 7058 cmdline_fixed_string_t tx_pfc_mode; 7059 uint32_t high_water; 7060 uint32_t low_water; 7061 uint16_t pause_time; 7062 uint8_t priority; 7063 portid_t port_id; 7064 }; 7065 7066 static void 7067 cmd_priority_flow_ctrl_set_parsed(void *parsed_result, 7068 __attribute__((unused)) struct cmdline *cl, 7069 __attribute__((unused)) void *data) 7070 { 7071 struct cmd_priority_flow_ctrl_set_result *res = parsed_result; 7072 struct rte_eth_pfc_conf pfc_conf; 7073 int rx_fc_enable, tx_fc_enable; 7074 int ret; 7075 7076 /* 7077 * Rx on/off, flow control is enabled/disabled on RX side. This can indicate 7078 * the RTE_FC_TX_PAUSE, Transmit pause frame at the Rx side. 7079 * Tx on/off, flow control is enabled/disabled on TX side. This can indicate 7080 * the RTE_FC_RX_PAUSE, Respond to the pause frame at the Tx side. 7081 */ 7082 static enum rte_eth_fc_mode rx_tx_onoff_2_pfc_mode[2][2] = { 7083 {RTE_FC_NONE, RTE_FC_RX_PAUSE}, {RTE_FC_TX_PAUSE, RTE_FC_FULL} 7084 }; 7085 7086 rx_fc_enable = (!strncmp(res->rx_pfc_mode, "on",2)) ? 1 : 0; 7087 tx_fc_enable = (!strncmp(res->tx_pfc_mode, "on",2)) ? 1 : 0; 7088 pfc_conf.fc.mode = rx_tx_onoff_2_pfc_mode[rx_fc_enable][tx_fc_enable]; 7089 pfc_conf.fc.high_water = res->high_water; 7090 pfc_conf.fc.low_water = res->low_water; 7091 pfc_conf.fc.pause_time = res->pause_time; 7092 pfc_conf.priority = res->priority; 7093 7094 ret = rte_eth_dev_priority_flow_ctrl_set(res->port_id, &pfc_conf); 7095 if (ret != 0) 7096 printf("bad priority flow contrl parameter, return code = %d \n", ret); 7097 } 7098 7099 cmdline_parse_token_string_t cmd_pfc_set_set = 7100 TOKEN_STRING_INITIALIZER(struct cmd_priority_flow_ctrl_set_result, 7101 set, "set"); 7102 cmdline_parse_token_string_t cmd_pfc_set_flow_ctrl = 7103 TOKEN_STRING_INITIALIZER(struct cmd_priority_flow_ctrl_set_result, 7104 pfc_ctrl, "pfc_ctrl"); 7105 cmdline_parse_token_string_t cmd_pfc_set_rx = 7106 TOKEN_STRING_INITIALIZER(struct cmd_priority_flow_ctrl_set_result, 7107 rx, "rx"); 7108 cmdline_parse_token_string_t cmd_pfc_set_rx_mode = 7109 TOKEN_STRING_INITIALIZER(struct cmd_priority_flow_ctrl_set_result, 7110 rx_pfc_mode, "on#off"); 7111 cmdline_parse_token_string_t cmd_pfc_set_tx = 7112 TOKEN_STRING_INITIALIZER(struct cmd_priority_flow_ctrl_set_result, 7113 tx, "tx"); 7114 cmdline_parse_token_string_t cmd_pfc_set_tx_mode = 7115 TOKEN_STRING_INITIALIZER(struct cmd_priority_flow_ctrl_set_result, 7116 tx_pfc_mode, "on#off"); 7117 cmdline_parse_token_num_t cmd_pfc_set_high_water = 7118 TOKEN_NUM_INITIALIZER(struct cmd_priority_flow_ctrl_set_result, 7119 high_water, UINT32); 7120 cmdline_parse_token_num_t cmd_pfc_set_low_water = 7121 TOKEN_NUM_INITIALIZER(struct cmd_priority_flow_ctrl_set_result, 7122 low_water, UINT32); 7123 cmdline_parse_token_num_t cmd_pfc_set_pause_time = 7124 TOKEN_NUM_INITIALIZER(struct cmd_priority_flow_ctrl_set_result, 7125 pause_time, UINT16); 7126 cmdline_parse_token_num_t cmd_pfc_set_priority = 7127 TOKEN_NUM_INITIALIZER(struct cmd_priority_flow_ctrl_set_result, 7128 priority, UINT8); 7129 cmdline_parse_token_num_t cmd_pfc_set_portid = 7130 TOKEN_NUM_INITIALIZER(struct cmd_priority_flow_ctrl_set_result, 7131 port_id, UINT16); 7132 7133 cmdline_parse_inst_t cmd_priority_flow_control_set = { 7134 .f = cmd_priority_flow_ctrl_set_parsed, 7135 .data = NULL, 7136 .help_str = "set pfc_ctrl rx on|off tx on|off <high_water> <low_water> " 7137 "<pause_time> <priority> <port_id>: " 7138 "Configure the Ethernet priority flow control", 7139 .tokens = { 7140 (void *)&cmd_pfc_set_set, 7141 (void *)&cmd_pfc_set_flow_ctrl, 7142 (void *)&cmd_pfc_set_rx, 7143 (void *)&cmd_pfc_set_rx_mode, 7144 (void *)&cmd_pfc_set_tx, 7145 (void *)&cmd_pfc_set_tx_mode, 7146 (void *)&cmd_pfc_set_high_water, 7147 (void *)&cmd_pfc_set_low_water, 7148 (void *)&cmd_pfc_set_pause_time, 7149 (void *)&cmd_pfc_set_priority, 7150 (void *)&cmd_pfc_set_portid, 7151 NULL, 7152 }, 7153 }; 7154 7155 /* *** RESET CONFIGURATION *** */ 7156 struct cmd_reset_result { 7157 cmdline_fixed_string_t reset; 7158 cmdline_fixed_string_t def; 7159 }; 7160 7161 static void cmd_reset_parsed(__attribute__((unused)) void *parsed_result, 7162 struct cmdline *cl, 7163 __attribute__((unused)) void *data) 7164 { 7165 cmdline_printf(cl, "Reset to default forwarding configuration...\n"); 7166 set_def_fwd_config(); 7167 } 7168 7169 cmdline_parse_token_string_t cmd_reset_set = 7170 TOKEN_STRING_INITIALIZER(struct cmd_reset_result, reset, "set"); 7171 cmdline_parse_token_string_t cmd_reset_def = 7172 TOKEN_STRING_INITIALIZER(struct cmd_reset_result, def, 7173 "default"); 7174 7175 cmdline_parse_inst_t cmd_reset = { 7176 .f = cmd_reset_parsed, 7177 .data = NULL, 7178 .help_str = "set default: Reset default forwarding configuration", 7179 .tokens = { 7180 (void *)&cmd_reset_set, 7181 (void *)&cmd_reset_def, 7182 NULL, 7183 }, 7184 }; 7185 7186 /* *** START FORWARDING *** */ 7187 struct cmd_start_result { 7188 cmdline_fixed_string_t start; 7189 }; 7190 7191 cmdline_parse_token_string_t cmd_start_start = 7192 TOKEN_STRING_INITIALIZER(struct cmd_start_result, start, "start"); 7193 7194 static void cmd_start_parsed(__attribute__((unused)) void *parsed_result, 7195 __attribute__((unused)) struct cmdline *cl, 7196 __attribute__((unused)) void *data) 7197 { 7198 start_packet_forwarding(0); 7199 } 7200 7201 cmdline_parse_inst_t cmd_start = { 7202 .f = cmd_start_parsed, 7203 .data = NULL, 7204 .help_str = "start: Start packet forwarding", 7205 .tokens = { 7206 (void *)&cmd_start_start, 7207 NULL, 7208 }, 7209 }; 7210 7211 /* *** START FORWARDING WITH ONE TX BURST FIRST *** */ 7212 struct cmd_start_tx_first_result { 7213 cmdline_fixed_string_t start; 7214 cmdline_fixed_string_t tx_first; 7215 }; 7216 7217 static void 7218 cmd_start_tx_first_parsed(__attribute__((unused)) void *parsed_result, 7219 __attribute__((unused)) struct cmdline *cl, 7220 __attribute__((unused)) void *data) 7221 { 7222 start_packet_forwarding(1); 7223 } 7224 7225 cmdline_parse_token_string_t cmd_start_tx_first_start = 7226 TOKEN_STRING_INITIALIZER(struct cmd_start_tx_first_result, start, 7227 "start"); 7228 cmdline_parse_token_string_t cmd_start_tx_first_tx_first = 7229 TOKEN_STRING_INITIALIZER(struct cmd_start_tx_first_result, 7230 tx_first, "tx_first"); 7231 7232 cmdline_parse_inst_t cmd_start_tx_first = { 7233 .f = cmd_start_tx_first_parsed, 7234 .data = NULL, 7235 .help_str = "start tx_first: Start packet forwarding, " 7236 "after sending 1 burst of packets", 7237 .tokens = { 7238 (void *)&cmd_start_tx_first_start, 7239 (void *)&cmd_start_tx_first_tx_first, 7240 NULL, 7241 }, 7242 }; 7243 7244 /* *** START FORWARDING WITH N TX BURST FIRST *** */ 7245 struct cmd_start_tx_first_n_result { 7246 cmdline_fixed_string_t start; 7247 cmdline_fixed_string_t tx_first; 7248 uint32_t tx_num; 7249 }; 7250 7251 static void 7252 cmd_start_tx_first_n_parsed(void *parsed_result, 7253 __attribute__((unused)) struct cmdline *cl, 7254 __attribute__((unused)) void *data) 7255 { 7256 struct cmd_start_tx_first_n_result *res = parsed_result; 7257 7258 start_packet_forwarding(res->tx_num); 7259 } 7260 7261 cmdline_parse_token_string_t cmd_start_tx_first_n_start = 7262 TOKEN_STRING_INITIALIZER(struct cmd_start_tx_first_n_result, 7263 start, "start"); 7264 cmdline_parse_token_string_t cmd_start_tx_first_n_tx_first = 7265 TOKEN_STRING_INITIALIZER(struct cmd_start_tx_first_n_result, 7266 tx_first, "tx_first"); 7267 cmdline_parse_token_num_t cmd_start_tx_first_n_tx_num = 7268 TOKEN_NUM_INITIALIZER(struct cmd_start_tx_first_n_result, 7269 tx_num, UINT32); 7270 7271 cmdline_parse_inst_t cmd_start_tx_first_n = { 7272 .f = cmd_start_tx_first_n_parsed, 7273 .data = NULL, 7274 .help_str = "start tx_first <num>: " 7275 "packet forwarding, after sending <num> bursts of packets", 7276 .tokens = { 7277 (void *)&cmd_start_tx_first_n_start, 7278 (void *)&cmd_start_tx_first_n_tx_first, 7279 (void *)&cmd_start_tx_first_n_tx_num, 7280 NULL, 7281 }, 7282 }; 7283 7284 /* *** SET LINK UP *** */ 7285 struct cmd_set_link_up_result { 7286 cmdline_fixed_string_t set; 7287 cmdline_fixed_string_t link_up; 7288 cmdline_fixed_string_t port; 7289 portid_t port_id; 7290 }; 7291 7292 cmdline_parse_token_string_t cmd_set_link_up_set = 7293 TOKEN_STRING_INITIALIZER(struct cmd_set_link_up_result, set, "set"); 7294 cmdline_parse_token_string_t cmd_set_link_up_link_up = 7295 TOKEN_STRING_INITIALIZER(struct cmd_set_link_up_result, link_up, 7296 "link-up"); 7297 cmdline_parse_token_string_t cmd_set_link_up_port = 7298 TOKEN_STRING_INITIALIZER(struct cmd_set_link_up_result, port, "port"); 7299 cmdline_parse_token_num_t cmd_set_link_up_port_id = 7300 TOKEN_NUM_INITIALIZER(struct cmd_set_link_up_result, port_id, UINT16); 7301 7302 static void cmd_set_link_up_parsed(__attribute__((unused)) void *parsed_result, 7303 __attribute__((unused)) struct cmdline *cl, 7304 __attribute__((unused)) void *data) 7305 { 7306 struct cmd_set_link_up_result *res = parsed_result; 7307 dev_set_link_up(res->port_id); 7308 } 7309 7310 cmdline_parse_inst_t cmd_set_link_up = { 7311 .f = cmd_set_link_up_parsed, 7312 .data = NULL, 7313 .help_str = "set link-up port <port id>", 7314 .tokens = { 7315 (void *)&cmd_set_link_up_set, 7316 (void *)&cmd_set_link_up_link_up, 7317 (void *)&cmd_set_link_up_port, 7318 (void *)&cmd_set_link_up_port_id, 7319 NULL, 7320 }, 7321 }; 7322 7323 /* *** SET LINK DOWN *** */ 7324 struct cmd_set_link_down_result { 7325 cmdline_fixed_string_t set; 7326 cmdline_fixed_string_t link_down; 7327 cmdline_fixed_string_t port; 7328 portid_t port_id; 7329 }; 7330 7331 cmdline_parse_token_string_t cmd_set_link_down_set = 7332 TOKEN_STRING_INITIALIZER(struct cmd_set_link_down_result, set, "set"); 7333 cmdline_parse_token_string_t cmd_set_link_down_link_down = 7334 TOKEN_STRING_INITIALIZER(struct cmd_set_link_down_result, link_down, 7335 "link-down"); 7336 cmdline_parse_token_string_t cmd_set_link_down_port = 7337 TOKEN_STRING_INITIALIZER(struct cmd_set_link_down_result, port, "port"); 7338 cmdline_parse_token_num_t cmd_set_link_down_port_id = 7339 TOKEN_NUM_INITIALIZER(struct cmd_set_link_down_result, port_id, UINT16); 7340 7341 static void cmd_set_link_down_parsed( 7342 __attribute__((unused)) void *parsed_result, 7343 __attribute__((unused)) struct cmdline *cl, 7344 __attribute__((unused)) void *data) 7345 { 7346 struct cmd_set_link_down_result *res = parsed_result; 7347 dev_set_link_down(res->port_id); 7348 } 7349 7350 cmdline_parse_inst_t cmd_set_link_down = { 7351 .f = cmd_set_link_down_parsed, 7352 .data = NULL, 7353 .help_str = "set link-down port <port id>", 7354 .tokens = { 7355 (void *)&cmd_set_link_down_set, 7356 (void *)&cmd_set_link_down_link_down, 7357 (void *)&cmd_set_link_down_port, 7358 (void *)&cmd_set_link_down_port_id, 7359 NULL, 7360 }, 7361 }; 7362 7363 /* *** SHOW CFG *** */ 7364 struct cmd_showcfg_result { 7365 cmdline_fixed_string_t show; 7366 cmdline_fixed_string_t cfg; 7367 cmdline_fixed_string_t what; 7368 }; 7369 7370 static void cmd_showcfg_parsed(void *parsed_result, 7371 __attribute__((unused)) struct cmdline *cl, 7372 __attribute__((unused)) void *data) 7373 { 7374 struct cmd_showcfg_result *res = parsed_result; 7375 if (!strcmp(res->what, "rxtx")) 7376 rxtx_config_display(); 7377 else if (!strcmp(res->what, "cores")) 7378 fwd_lcores_config_display(); 7379 else if (!strcmp(res->what, "fwd")) 7380 pkt_fwd_config_display(&cur_fwd_config); 7381 else if (!strcmp(res->what, "txpkts")) 7382 show_tx_pkt_segments(); 7383 } 7384 7385 cmdline_parse_token_string_t cmd_showcfg_show = 7386 TOKEN_STRING_INITIALIZER(struct cmd_showcfg_result, show, "show"); 7387 cmdline_parse_token_string_t cmd_showcfg_port = 7388 TOKEN_STRING_INITIALIZER(struct cmd_showcfg_result, cfg, "config"); 7389 cmdline_parse_token_string_t cmd_showcfg_what = 7390 TOKEN_STRING_INITIALIZER(struct cmd_showcfg_result, what, 7391 "rxtx#cores#fwd#txpkts"); 7392 7393 cmdline_parse_inst_t cmd_showcfg = { 7394 .f = cmd_showcfg_parsed, 7395 .data = NULL, 7396 .help_str = "show config rxtx|cores|fwd|txpkts", 7397 .tokens = { 7398 (void *)&cmd_showcfg_show, 7399 (void *)&cmd_showcfg_port, 7400 (void *)&cmd_showcfg_what, 7401 NULL, 7402 }, 7403 }; 7404 7405 /* *** SHOW ALL PORT INFO *** */ 7406 struct cmd_showportall_result { 7407 cmdline_fixed_string_t show; 7408 cmdline_fixed_string_t port; 7409 cmdline_fixed_string_t what; 7410 cmdline_fixed_string_t all; 7411 }; 7412 7413 static void cmd_showportall_parsed(void *parsed_result, 7414 __attribute__((unused)) struct cmdline *cl, 7415 __attribute__((unused)) void *data) 7416 { 7417 portid_t i; 7418 7419 struct cmd_showportall_result *res = parsed_result; 7420 if (!strcmp(res->show, "clear")) { 7421 if (!strcmp(res->what, "stats")) 7422 RTE_ETH_FOREACH_DEV(i) 7423 nic_stats_clear(i); 7424 else if (!strcmp(res->what, "xstats")) 7425 RTE_ETH_FOREACH_DEV(i) 7426 nic_xstats_clear(i); 7427 } else if (!strcmp(res->what, "info")) 7428 RTE_ETH_FOREACH_DEV(i) 7429 port_infos_display(i); 7430 else if (!strcmp(res->what, "summary")) { 7431 port_summary_header_display(); 7432 RTE_ETH_FOREACH_DEV(i) 7433 port_summary_display(i); 7434 } 7435 else if (!strcmp(res->what, "stats")) 7436 RTE_ETH_FOREACH_DEV(i) 7437 nic_stats_display(i); 7438 else if (!strcmp(res->what, "xstats")) 7439 RTE_ETH_FOREACH_DEV(i) 7440 nic_xstats_display(i); 7441 else if (!strcmp(res->what, "fdir")) 7442 RTE_ETH_FOREACH_DEV(i) 7443 fdir_get_infos(i); 7444 else if (!strcmp(res->what, "stat_qmap")) 7445 RTE_ETH_FOREACH_DEV(i) 7446 nic_stats_mapping_display(i); 7447 else if (!strcmp(res->what, "dcb_tc")) 7448 RTE_ETH_FOREACH_DEV(i) 7449 port_dcb_info_display(i); 7450 else if (!strcmp(res->what, "cap")) 7451 RTE_ETH_FOREACH_DEV(i) 7452 port_offload_cap_display(i); 7453 } 7454 7455 cmdline_parse_token_string_t cmd_showportall_show = 7456 TOKEN_STRING_INITIALIZER(struct cmd_showportall_result, show, 7457 "show#clear"); 7458 cmdline_parse_token_string_t cmd_showportall_port = 7459 TOKEN_STRING_INITIALIZER(struct cmd_showportall_result, port, "port"); 7460 cmdline_parse_token_string_t cmd_showportall_what = 7461 TOKEN_STRING_INITIALIZER(struct cmd_showportall_result, what, 7462 "info#summary#stats#xstats#fdir#stat_qmap#dcb_tc#cap"); 7463 cmdline_parse_token_string_t cmd_showportall_all = 7464 TOKEN_STRING_INITIALIZER(struct cmd_showportall_result, all, "all"); 7465 cmdline_parse_inst_t cmd_showportall = { 7466 .f = cmd_showportall_parsed, 7467 .data = NULL, 7468 .help_str = "show|clear port " 7469 "info|summary|stats|xstats|fdir|stat_qmap|dcb_tc|cap all", 7470 .tokens = { 7471 (void *)&cmd_showportall_show, 7472 (void *)&cmd_showportall_port, 7473 (void *)&cmd_showportall_what, 7474 (void *)&cmd_showportall_all, 7475 NULL, 7476 }, 7477 }; 7478 7479 /* *** SHOW PORT INFO *** */ 7480 struct cmd_showport_result { 7481 cmdline_fixed_string_t show; 7482 cmdline_fixed_string_t port; 7483 cmdline_fixed_string_t what; 7484 uint16_t portnum; 7485 }; 7486 7487 static void cmd_showport_parsed(void *parsed_result, 7488 __attribute__((unused)) struct cmdline *cl, 7489 __attribute__((unused)) void *data) 7490 { 7491 struct cmd_showport_result *res = parsed_result; 7492 if (!strcmp(res->show, "clear")) { 7493 if (!strcmp(res->what, "stats")) 7494 nic_stats_clear(res->portnum); 7495 else if (!strcmp(res->what, "xstats")) 7496 nic_xstats_clear(res->portnum); 7497 } else if (!strcmp(res->what, "info")) 7498 port_infos_display(res->portnum); 7499 else if (!strcmp(res->what, "summary")) { 7500 port_summary_header_display(); 7501 port_summary_display(res->portnum); 7502 } 7503 else if (!strcmp(res->what, "stats")) 7504 nic_stats_display(res->portnum); 7505 else if (!strcmp(res->what, "xstats")) 7506 nic_xstats_display(res->portnum); 7507 else if (!strcmp(res->what, "fdir")) 7508 fdir_get_infos(res->portnum); 7509 else if (!strcmp(res->what, "stat_qmap")) 7510 nic_stats_mapping_display(res->portnum); 7511 else if (!strcmp(res->what, "dcb_tc")) 7512 port_dcb_info_display(res->portnum); 7513 else if (!strcmp(res->what, "cap")) 7514 port_offload_cap_display(res->portnum); 7515 } 7516 7517 cmdline_parse_token_string_t cmd_showport_show = 7518 TOKEN_STRING_INITIALIZER(struct cmd_showport_result, show, 7519 "show#clear"); 7520 cmdline_parse_token_string_t cmd_showport_port = 7521 TOKEN_STRING_INITIALIZER(struct cmd_showport_result, port, "port"); 7522 cmdline_parse_token_string_t cmd_showport_what = 7523 TOKEN_STRING_INITIALIZER(struct cmd_showport_result, what, 7524 "info#summary#stats#xstats#fdir#stat_qmap#dcb_tc#cap"); 7525 cmdline_parse_token_num_t cmd_showport_portnum = 7526 TOKEN_NUM_INITIALIZER(struct cmd_showport_result, portnum, UINT16); 7527 7528 cmdline_parse_inst_t cmd_showport = { 7529 .f = cmd_showport_parsed, 7530 .data = NULL, 7531 .help_str = "show|clear port " 7532 "info|summary|stats|xstats|fdir|stat_qmap|dcb_tc|cap " 7533 "<port_id>", 7534 .tokens = { 7535 (void *)&cmd_showport_show, 7536 (void *)&cmd_showport_port, 7537 (void *)&cmd_showport_what, 7538 (void *)&cmd_showport_portnum, 7539 NULL, 7540 }, 7541 }; 7542 7543 /* *** SHOW DEVICE INFO *** */ 7544 struct cmd_showdevice_result { 7545 cmdline_fixed_string_t show; 7546 cmdline_fixed_string_t device; 7547 cmdline_fixed_string_t what; 7548 cmdline_fixed_string_t identifier; 7549 }; 7550 7551 static void cmd_showdevice_parsed(void *parsed_result, 7552 __attribute__((unused)) struct cmdline *cl, 7553 __attribute__((unused)) void *data) 7554 { 7555 struct cmd_showdevice_result *res = parsed_result; 7556 if (!strcmp(res->what, "info")) { 7557 if (!strcmp(res->identifier, "all")) 7558 device_infos_display(NULL); 7559 else 7560 device_infos_display(res->identifier); 7561 } 7562 } 7563 7564 cmdline_parse_token_string_t cmd_showdevice_show = 7565 TOKEN_STRING_INITIALIZER(struct cmd_showdevice_result, show, 7566 "show"); 7567 cmdline_parse_token_string_t cmd_showdevice_device = 7568 TOKEN_STRING_INITIALIZER(struct cmd_showdevice_result, device, "device"); 7569 cmdline_parse_token_string_t cmd_showdevice_what = 7570 TOKEN_STRING_INITIALIZER(struct cmd_showdevice_result, what, 7571 "info"); 7572 cmdline_parse_token_string_t cmd_showdevice_identifier = 7573 TOKEN_STRING_INITIALIZER(struct cmd_showdevice_result, 7574 identifier, NULL); 7575 7576 cmdline_parse_inst_t cmd_showdevice = { 7577 .f = cmd_showdevice_parsed, 7578 .data = NULL, 7579 .help_str = "show device info <identifier>|all", 7580 .tokens = { 7581 (void *)&cmd_showdevice_show, 7582 (void *)&cmd_showdevice_device, 7583 (void *)&cmd_showdevice_what, 7584 (void *)&cmd_showdevice_identifier, 7585 NULL, 7586 }, 7587 }; 7588 /* *** SHOW QUEUE INFO *** */ 7589 struct cmd_showqueue_result { 7590 cmdline_fixed_string_t show; 7591 cmdline_fixed_string_t type; 7592 cmdline_fixed_string_t what; 7593 uint16_t portnum; 7594 uint16_t queuenum; 7595 }; 7596 7597 static void 7598 cmd_showqueue_parsed(void *parsed_result, 7599 __attribute__((unused)) struct cmdline *cl, 7600 __attribute__((unused)) void *data) 7601 { 7602 struct cmd_showqueue_result *res = parsed_result; 7603 7604 if (!strcmp(res->type, "rxq")) 7605 rx_queue_infos_display(res->portnum, res->queuenum); 7606 else if (!strcmp(res->type, "txq")) 7607 tx_queue_infos_display(res->portnum, res->queuenum); 7608 } 7609 7610 cmdline_parse_token_string_t cmd_showqueue_show = 7611 TOKEN_STRING_INITIALIZER(struct cmd_showqueue_result, show, "show"); 7612 cmdline_parse_token_string_t cmd_showqueue_type = 7613 TOKEN_STRING_INITIALIZER(struct cmd_showqueue_result, type, "rxq#txq"); 7614 cmdline_parse_token_string_t cmd_showqueue_what = 7615 TOKEN_STRING_INITIALIZER(struct cmd_showqueue_result, what, "info"); 7616 cmdline_parse_token_num_t cmd_showqueue_portnum = 7617 TOKEN_NUM_INITIALIZER(struct cmd_showqueue_result, portnum, UINT16); 7618 cmdline_parse_token_num_t cmd_showqueue_queuenum = 7619 TOKEN_NUM_INITIALIZER(struct cmd_showqueue_result, queuenum, UINT16); 7620 7621 cmdline_parse_inst_t cmd_showqueue = { 7622 .f = cmd_showqueue_parsed, 7623 .data = NULL, 7624 .help_str = "show rxq|txq info <port_id> <queue_id>", 7625 .tokens = { 7626 (void *)&cmd_showqueue_show, 7627 (void *)&cmd_showqueue_type, 7628 (void *)&cmd_showqueue_what, 7629 (void *)&cmd_showqueue_portnum, 7630 (void *)&cmd_showqueue_queuenum, 7631 NULL, 7632 }, 7633 }; 7634 7635 /* show/clear fwd engine statistics */ 7636 struct fwd_result { 7637 cmdline_fixed_string_t action; 7638 cmdline_fixed_string_t fwd; 7639 cmdline_fixed_string_t stats; 7640 cmdline_fixed_string_t all; 7641 }; 7642 7643 cmdline_parse_token_string_t cmd_fwd_action = 7644 TOKEN_STRING_INITIALIZER(struct fwd_result, action, "show#clear"); 7645 cmdline_parse_token_string_t cmd_fwd_fwd = 7646 TOKEN_STRING_INITIALIZER(struct fwd_result, fwd, "fwd"); 7647 cmdline_parse_token_string_t cmd_fwd_stats = 7648 TOKEN_STRING_INITIALIZER(struct fwd_result, stats, "stats"); 7649 cmdline_parse_token_string_t cmd_fwd_all = 7650 TOKEN_STRING_INITIALIZER(struct fwd_result, all, "all"); 7651 7652 static void 7653 cmd_showfwdall_parsed(void *parsed_result, 7654 __rte_unused struct cmdline *cl, 7655 __rte_unused void *data) 7656 { 7657 struct fwd_result *res = parsed_result; 7658 7659 if (!strcmp(res->action, "show")) 7660 fwd_stats_display(); 7661 else 7662 fwd_stats_reset(); 7663 } 7664 7665 static cmdline_parse_inst_t cmd_showfwdall = { 7666 .f = cmd_showfwdall_parsed, 7667 .data = NULL, 7668 .help_str = "show|clear fwd stats all", 7669 .tokens = { 7670 (void *)&cmd_fwd_action, 7671 (void *)&cmd_fwd_fwd, 7672 (void *)&cmd_fwd_stats, 7673 (void *)&cmd_fwd_all, 7674 NULL, 7675 }, 7676 }; 7677 7678 /* *** READ PORT REGISTER *** */ 7679 struct cmd_read_reg_result { 7680 cmdline_fixed_string_t read; 7681 cmdline_fixed_string_t reg; 7682 portid_t port_id; 7683 uint32_t reg_off; 7684 }; 7685 7686 static void 7687 cmd_read_reg_parsed(void *parsed_result, 7688 __attribute__((unused)) struct cmdline *cl, 7689 __attribute__((unused)) void *data) 7690 { 7691 struct cmd_read_reg_result *res = parsed_result; 7692 port_reg_display(res->port_id, res->reg_off); 7693 } 7694 7695 cmdline_parse_token_string_t cmd_read_reg_read = 7696 TOKEN_STRING_INITIALIZER(struct cmd_read_reg_result, read, "read"); 7697 cmdline_parse_token_string_t cmd_read_reg_reg = 7698 TOKEN_STRING_INITIALIZER(struct cmd_read_reg_result, reg, "reg"); 7699 cmdline_parse_token_num_t cmd_read_reg_port_id = 7700 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_result, port_id, UINT16); 7701 cmdline_parse_token_num_t cmd_read_reg_reg_off = 7702 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_result, reg_off, UINT32); 7703 7704 cmdline_parse_inst_t cmd_read_reg = { 7705 .f = cmd_read_reg_parsed, 7706 .data = NULL, 7707 .help_str = "read reg <port_id> <reg_off>", 7708 .tokens = { 7709 (void *)&cmd_read_reg_read, 7710 (void *)&cmd_read_reg_reg, 7711 (void *)&cmd_read_reg_port_id, 7712 (void *)&cmd_read_reg_reg_off, 7713 NULL, 7714 }, 7715 }; 7716 7717 /* *** READ PORT REGISTER BIT FIELD *** */ 7718 struct cmd_read_reg_bit_field_result { 7719 cmdline_fixed_string_t read; 7720 cmdline_fixed_string_t regfield; 7721 portid_t port_id; 7722 uint32_t reg_off; 7723 uint8_t bit1_pos; 7724 uint8_t bit2_pos; 7725 }; 7726 7727 static void 7728 cmd_read_reg_bit_field_parsed(void *parsed_result, 7729 __attribute__((unused)) struct cmdline *cl, 7730 __attribute__((unused)) void *data) 7731 { 7732 struct cmd_read_reg_bit_field_result *res = parsed_result; 7733 port_reg_bit_field_display(res->port_id, res->reg_off, 7734 res->bit1_pos, res->bit2_pos); 7735 } 7736 7737 cmdline_parse_token_string_t cmd_read_reg_bit_field_read = 7738 TOKEN_STRING_INITIALIZER(struct cmd_read_reg_bit_field_result, read, 7739 "read"); 7740 cmdline_parse_token_string_t cmd_read_reg_bit_field_regfield = 7741 TOKEN_STRING_INITIALIZER(struct cmd_read_reg_bit_field_result, 7742 regfield, "regfield"); 7743 cmdline_parse_token_num_t cmd_read_reg_bit_field_port_id = 7744 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_field_result, port_id, 7745 UINT16); 7746 cmdline_parse_token_num_t cmd_read_reg_bit_field_reg_off = 7747 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_field_result, reg_off, 7748 UINT32); 7749 cmdline_parse_token_num_t cmd_read_reg_bit_field_bit1_pos = 7750 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_field_result, bit1_pos, 7751 UINT8); 7752 cmdline_parse_token_num_t cmd_read_reg_bit_field_bit2_pos = 7753 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_field_result, bit2_pos, 7754 UINT8); 7755 7756 cmdline_parse_inst_t cmd_read_reg_bit_field = { 7757 .f = cmd_read_reg_bit_field_parsed, 7758 .data = NULL, 7759 .help_str = "read regfield <port_id> <reg_off> <bit_x> <bit_y>: " 7760 "Read register bit field between bit_x and bit_y included", 7761 .tokens = { 7762 (void *)&cmd_read_reg_bit_field_read, 7763 (void *)&cmd_read_reg_bit_field_regfield, 7764 (void *)&cmd_read_reg_bit_field_port_id, 7765 (void *)&cmd_read_reg_bit_field_reg_off, 7766 (void *)&cmd_read_reg_bit_field_bit1_pos, 7767 (void *)&cmd_read_reg_bit_field_bit2_pos, 7768 NULL, 7769 }, 7770 }; 7771 7772 /* *** READ PORT REGISTER BIT *** */ 7773 struct cmd_read_reg_bit_result { 7774 cmdline_fixed_string_t read; 7775 cmdline_fixed_string_t regbit; 7776 portid_t port_id; 7777 uint32_t reg_off; 7778 uint8_t bit_pos; 7779 }; 7780 7781 static void 7782 cmd_read_reg_bit_parsed(void *parsed_result, 7783 __attribute__((unused)) struct cmdline *cl, 7784 __attribute__((unused)) void *data) 7785 { 7786 struct cmd_read_reg_bit_result *res = parsed_result; 7787 port_reg_bit_display(res->port_id, res->reg_off, res->bit_pos); 7788 } 7789 7790 cmdline_parse_token_string_t cmd_read_reg_bit_read = 7791 TOKEN_STRING_INITIALIZER(struct cmd_read_reg_bit_result, read, "read"); 7792 cmdline_parse_token_string_t cmd_read_reg_bit_regbit = 7793 TOKEN_STRING_INITIALIZER(struct cmd_read_reg_bit_result, 7794 regbit, "regbit"); 7795 cmdline_parse_token_num_t cmd_read_reg_bit_port_id = 7796 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_result, port_id, UINT16); 7797 cmdline_parse_token_num_t cmd_read_reg_bit_reg_off = 7798 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_result, reg_off, UINT32); 7799 cmdline_parse_token_num_t cmd_read_reg_bit_bit_pos = 7800 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_result, bit_pos, UINT8); 7801 7802 cmdline_parse_inst_t cmd_read_reg_bit = { 7803 .f = cmd_read_reg_bit_parsed, 7804 .data = NULL, 7805 .help_str = "read regbit <port_id> <reg_off> <bit_x>: 0 <= bit_x <= 31", 7806 .tokens = { 7807 (void *)&cmd_read_reg_bit_read, 7808 (void *)&cmd_read_reg_bit_regbit, 7809 (void *)&cmd_read_reg_bit_port_id, 7810 (void *)&cmd_read_reg_bit_reg_off, 7811 (void *)&cmd_read_reg_bit_bit_pos, 7812 NULL, 7813 }, 7814 }; 7815 7816 /* *** WRITE PORT REGISTER *** */ 7817 struct cmd_write_reg_result { 7818 cmdline_fixed_string_t write; 7819 cmdline_fixed_string_t reg; 7820 portid_t port_id; 7821 uint32_t reg_off; 7822 uint32_t value; 7823 }; 7824 7825 static void 7826 cmd_write_reg_parsed(void *parsed_result, 7827 __attribute__((unused)) struct cmdline *cl, 7828 __attribute__((unused)) void *data) 7829 { 7830 struct cmd_write_reg_result *res = parsed_result; 7831 port_reg_set(res->port_id, res->reg_off, res->value); 7832 } 7833 7834 cmdline_parse_token_string_t cmd_write_reg_write = 7835 TOKEN_STRING_INITIALIZER(struct cmd_write_reg_result, write, "write"); 7836 cmdline_parse_token_string_t cmd_write_reg_reg = 7837 TOKEN_STRING_INITIALIZER(struct cmd_write_reg_result, reg, "reg"); 7838 cmdline_parse_token_num_t cmd_write_reg_port_id = 7839 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_result, port_id, UINT16); 7840 cmdline_parse_token_num_t cmd_write_reg_reg_off = 7841 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_result, reg_off, UINT32); 7842 cmdline_parse_token_num_t cmd_write_reg_value = 7843 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_result, value, UINT32); 7844 7845 cmdline_parse_inst_t cmd_write_reg = { 7846 .f = cmd_write_reg_parsed, 7847 .data = NULL, 7848 .help_str = "write reg <port_id> <reg_off> <reg_value>", 7849 .tokens = { 7850 (void *)&cmd_write_reg_write, 7851 (void *)&cmd_write_reg_reg, 7852 (void *)&cmd_write_reg_port_id, 7853 (void *)&cmd_write_reg_reg_off, 7854 (void *)&cmd_write_reg_value, 7855 NULL, 7856 }, 7857 }; 7858 7859 /* *** WRITE PORT REGISTER BIT FIELD *** */ 7860 struct cmd_write_reg_bit_field_result { 7861 cmdline_fixed_string_t write; 7862 cmdline_fixed_string_t regfield; 7863 portid_t port_id; 7864 uint32_t reg_off; 7865 uint8_t bit1_pos; 7866 uint8_t bit2_pos; 7867 uint32_t value; 7868 }; 7869 7870 static void 7871 cmd_write_reg_bit_field_parsed(void *parsed_result, 7872 __attribute__((unused)) struct cmdline *cl, 7873 __attribute__((unused)) void *data) 7874 { 7875 struct cmd_write_reg_bit_field_result *res = parsed_result; 7876 port_reg_bit_field_set(res->port_id, res->reg_off, 7877 res->bit1_pos, res->bit2_pos, res->value); 7878 } 7879 7880 cmdline_parse_token_string_t cmd_write_reg_bit_field_write = 7881 TOKEN_STRING_INITIALIZER(struct cmd_write_reg_bit_field_result, write, 7882 "write"); 7883 cmdline_parse_token_string_t cmd_write_reg_bit_field_regfield = 7884 TOKEN_STRING_INITIALIZER(struct cmd_write_reg_bit_field_result, 7885 regfield, "regfield"); 7886 cmdline_parse_token_num_t cmd_write_reg_bit_field_port_id = 7887 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_field_result, port_id, 7888 UINT16); 7889 cmdline_parse_token_num_t cmd_write_reg_bit_field_reg_off = 7890 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_field_result, reg_off, 7891 UINT32); 7892 cmdline_parse_token_num_t cmd_write_reg_bit_field_bit1_pos = 7893 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_field_result, bit1_pos, 7894 UINT8); 7895 cmdline_parse_token_num_t cmd_write_reg_bit_field_bit2_pos = 7896 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_field_result, bit2_pos, 7897 UINT8); 7898 cmdline_parse_token_num_t cmd_write_reg_bit_field_value = 7899 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_field_result, value, 7900 UINT32); 7901 7902 cmdline_parse_inst_t cmd_write_reg_bit_field = { 7903 .f = cmd_write_reg_bit_field_parsed, 7904 .data = NULL, 7905 .help_str = "write regfield <port_id> <reg_off> <bit_x> <bit_y> " 7906 "<reg_value>: " 7907 "Set register bit field between bit_x and bit_y included", 7908 .tokens = { 7909 (void *)&cmd_write_reg_bit_field_write, 7910 (void *)&cmd_write_reg_bit_field_regfield, 7911 (void *)&cmd_write_reg_bit_field_port_id, 7912 (void *)&cmd_write_reg_bit_field_reg_off, 7913 (void *)&cmd_write_reg_bit_field_bit1_pos, 7914 (void *)&cmd_write_reg_bit_field_bit2_pos, 7915 (void *)&cmd_write_reg_bit_field_value, 7916 NULL, 7917 }, 7918 }; 7919 7920 /* *** WRITE PORT REGISTER BIT *** */ 7921 struct cmd_write_reg_bit_result { 7922 cmdline_fixed_string_t write; 7923 cmdline_fixed_string_t regbit; 7924 portid_t port_id; 7925 uint32_t reg_off; 7926 uint8_t bit_pos; 7927 uint8_t value; 7928 }; 7929 7930 static void 7931 cmd_write_reg_bit_parsed(void *parsed_result, 7932 __attribute__((unused)) struct cmdline *cl, 7933 __attribute__((unused)) void *data) 7934 { 7935 struct cmd_write_reg_bit_result *res = parsed_result; 7936 port_reg_bit_set(res->port_id, res->reg_off, res->bit_pos, res->value); 7937 } 7938 7939 cmdline_parse_token_string_t cmd_write_reg_bit_write = 7940 TOKEN_STRING_INITIALIZER(struct cmd_write_reg_bit_result, write, 7941 "write"); 7942 cmdline_parse_token_string_t cmd_write_reg_bit_regbit = 7943 TOKEN_STRING_INITIALIZER(struct cmd_write_reg_bit_result, 7944 regbit, "regbit"); 7945 cmdline_parse_token_num_t cmd_write_reg_bit_port_id = 7946 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_result, port_id, UINT16); 7947 cmdline_parse_token_num_t cmd_write_reg_bit_reg_off = 7948 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_result, reg_off, UINT32); 7949 cmdline_parse_token_num_t cmd_write_reg_bit_bit_pos = 7950 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_result, bit_pos, UINT8); 7951 cmdline_parse_token_num_t cmd_write_reg_bit_value = 7952 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_result, value, UINT8); 7953 7954 cmdline_parse_inst_t cmd_write_reg_bit = { 7955 .f = cmd_write_reg_bit_parsed, 7956 .data = NULL, 7957 .help_str = "write regbit <port_id> <reg_off> <bit_x> 0|1: " 7958 "0 <= bit_x <= 31", 7959 .tokens = { 7960 (void *)&cmd_write_reg_bit_write, 7961 (void *)&cmd_write_reg_bit_regbit, 7962 (void *)&cmd_write_reg_bit_port_id, 7963 (void *)&cmd_write_reg_bit_reg_off, 7964 (void *)&cmd_write_reg_bit_bit_pos, 7965 (void *)&cmd_write_reg_bit_value, 7966 NULL, 7967 }, 7968 }; 7969 7970 /* *** READ A RING DESCRIPTOR OF A PORT RX/TX QUEUE *** */ 7971 struct cmd_read_rxd_txd_result { 7972 cmdline_fixed_string_t read; 7973 cmdline_fixed_string_t rxd_txd; 7974 portid_t port_id; 7975 uint16_t queue_id; 7976 uint16_t desc_id; 7977 }; 7978 7979 static void 7980 cmd_read_rxd_txd_parsed(void *parsed_result, 7981 __attribute__((unused)) struct cmdline *cl, 7982 __attribute__((unused)) void *data) 7983 { 7984 struct cmd_read_rxd_txd_result *res = parsed_result; 7985 7986 if (!strcmp(res->rxd_txd, "rxd")) 7987 rx_ring_desc_display(res->port_id, res->queue_id, res->desc_id); 7988 else if (!strcmp(res->rxd_txd, "txd")) 7989 tx_ring_desc_display(res->port_id, res->queue_id, res->desc_id); 7990 } 7991 7992 cmdline_parse_token_string_t cmd_read_rxd_txd_read = 7993 TOKEN_STRING_INITIALIZER(struct cmd_read_rxd_txd_result, read, "read"); 7994 cmdline_parse_token_string_t cmd_read_rxd_txd_rxd_txd = 7995 TOKEN_STRING_INITIALIZER(struct cmd_read_rxd_txd_result, rxd_txd, 7996 "rxd#txd"); 7997 cmdline_parse_token_num_t cmd_read_rxd_txd_port_id = 7998 TOKEN_NUM_INITIALIZER(struct cmd_read_rxd_txd_result, port_id, UINT16); 7999 cmdline_parse_token_num_t cmd_read_rxd_txd_queue_id = 8000 TOKEN_NUM_INITIALIZER(struct cmd_read_rxd_txd_result, queue_id, UINT16); 8001 cmdline_parse_token_num_t cmd_read_rxd_txd_desc_id = 8002 TOKEN_NUM_INITIALIZER(struct cmd_read_rxd_txd_result, desc_id, UINT16); 8003 8004 cmdline_parse_inst_t cmd_read_rxd_txd = { 8005 .f = cmd_read_rxd_txd_parsed, 8006 .data = NULL, 8007 .help_str = "read rxd|txd <port_id> <queue_id> <desc_id>", 8008 .tokens = { 8009 (void *)&cmd_read_rxd_txd_read, 8010 (void *)&cmd_read_rxd_txd_rxd_txd, 8011 (void *)&cmd_read_rxd_txd_port_id, 8012 (void *)&cmd_read_rxd_txd_queue_id, 8013 (void *)&cmd_read_rxd_txd_desc_id, 8014 NULL, 8015 }, 8016 }; 8017 8018 /* *** QUIT *** */ 8019 struct cmd_quit_result { 8020 cmdline_fixed_string_t quit; 8021 }; 8022 8023 static void cmd_quit_parsed(__attribute__((unused)) void *parsed_result, 8024 struct cmdline *cl, 8025 __attribute__((unused)) void *data) 8026 { 8027 cmdline_quit(cl); 8028 } 8029 8030 cmdline_parse_token_string_t cmd_quit_quit = 8031 TOKEN_STRING_INITIALIZER(struct cmd_quit_result, quit, "quit"); 8032 8033 cmdline_parse_inst_t cmd_quit = { 8034 .f = cmd_quit_parsed, 8035 .data = NULL, 8036 .help_str = "quit: Exit application", 8037 .tokens = { 8038 (void *)&cmd_quit_quit, 8039 NULL, 8040 }, 8041 }; 8042 8043 /* *** ADD/REMOVE MAC ADDRESS FROM A PORT *** */ 8044 struct cmd_mac_addr_result { 8045 cmdline_fixed_string_t mac_addr_cmd; 8046 cmdline_fixed_string_t what; 8047 uint16_t port_num; 8048 struct rte_ether_addr address; 8049 }; 8050 8051 static void cmd_mac_addr_parsed(void *parsed_result, 8052 __attribute__((unused)) struct cmdline *cl, 8053 __attribute__((unused)) void *data) 8054 { 8055 struct cmd_mac_addr_result *res = parsed_result; 8056 int ret; 8057 8058 if (strcmp(res->what, "add") == 0) 8059 ret = rte_eth_dev_mac_addr_add(res->port_num, &res->address, 0); 8060 else if (strcmp(res->what, "set") == 0) 8061 ret = rte_eth_dev_default_mac_addr_set(res->port_num, 8062 &res->address); 8063 else 8064 ret = rte_eth_dev_mac_addr_remove(res->port_num, &res->address); 8065 8066 /* check the return value and print it if is < 0 */ 8067 if(ret < 0) 8068 printf("mac_addr_cmd error: (%s)\n", strerror(-ret)); 8069 8070 } 8071 8072 cmdline_parse_token_string_t cmd_mac_addr_cmd = 8073 TOKEN_STRING_INITIALIZER(struct cmd_mac_addr_result, mac_addr_cmd, 8074 "mac_addr"); 8075 cmdline_parse_token_string_t cmd_mac_addr_what = 8076 TOKEN_STRING_INITIALIZER(struct cmd_mac_addr_result, what, 8077 "add#remove#set"); 8078 cmdline_parse_token_num_t cmd_mac_addr_portnum = 8079 TOKEN_NUM_INITIALIZER(struct cmd_mac_addr_result, port_num, 8080 UINT16); 8081 cmdline_parse_token_etheraddr_t cmd_mac_addr_addr = 8082 TOKEN_ETHERADDR_INITIALIZER(struct cmd_mac_addr_result, address); 8083 8084 cmdline_parse_inst_t cmd_mac_addr = { 8085 .f = cmd_mac_addr_parsed, 8086 .data = (void *)0, 8087 .help_str = "mac_addr add|remove|set <port_id> <mac_addr>: " 8088 "Add/Remove/Set MAC address on port_id", 8089 .tokens = { 8090 (void *)&cmd_mac_addr_cmd, 8091 (void *)&cmd_mac_addr_what, 8092 (void *)&cmd_mac_addr_portnum, 8093 (void *)&cmd_mac_addr_addr, 8094 NULL, 8095 }, 8096 }; 8097 8098 /* *** SET THE PEER ADDRESS FOR CERTAIN PORT *** */ 8099 struct cmd_eth_peer_result { 8100 cmdline_fixed_string_t set; 8101 cmdline_fixed_string_t eth_peer; 8102 portid_t port_id; 8103 cmdline_fixed_string_t peer_addr; 8104 }; 8105 8106 static void cmd_set_eth_peer_parsed(void *parsed_result, 8107 __attribute__((unused)) struct cmdline *cl, 8108 __attribute__((unused)) void *data) 8109 { 8110 struct cmd_eth_peer_result *res = parsed_result; 8111 8112 if (test_done == 0) { 8113 printf("Please stop forwarding first\n"); 8114 return; 8115 } 8116 if (!strcmp(res->eth_peer, "eth-peer")) { 8117 set_fwd_eth_peer(res->port_id, res->peer_addr); 8118 fwd_config_setup(); 8119 } 8120 } 8121 cmdline_parse_token_string_t cmd_eth_peer_set = 8122 TOKEN_STRING_INITIALIZER(struct cmd_eth_peer_result, set, "set"); 8123 cmdline_parse_token_string_t cmd_eth_peer = 8124 TOKEN_STRING_INITIALIZER(struct cmd_eth_peer_result, eth_peer, "eth-peer"); 8125 cmdline_parse_token_num_t cmd_eth_peer_port_id = 8126 TOKEN_NUM_INITIALIZER(struct cmd_eth_peer_result, port_id, UINT16); 8127 cmdline_parse_token_string_t cmd_eth_peer_addr = 8128 TOKEN_STRING_INITIALIZER(struct cmd_eth_peer_result, peer_addr, NULL); 8129 8130 cmdline_parse_inst_t cmd_set_fwd_eth_peer = { 8131 .f = cmd_set_eth_peer_parsed, 8132 .data = NULL, 8133 .help_str = "set eth-peer <port_id> <peer_mac>", 8134 .tokens = { 8135 (void *)&cmd_eth_peer_set, 8136 (void *)&cmd_eth_peer, 8137 (void *)&cmd_eth_peer_port_id, 8138 (void *)&cmd_eth_peer_addr, 8139 NULL, 8140 }, 8141 }; 8142 8143 /* *** CONFIGURE QUEUE STATS COUNTER MAPPINGS *** */ 8144 struct cmd_set_qmap_result { 8145 cmdline_fixed_string_t set; 8146 cmdline_fixed_string_t qmap; 8147 cmdline_fixed_string_t what; 8148 portid_t port_id; 8149 uint16_t queue_id; 8150 uint8_t map_value; 8151 }; 8152 8153 static void 8154 cmd_set_qmap_parsed(void *parsed_result, 8155 __attribute__((unused)) struct cmdline *cl, 8156 __attribute__((unused)) void *data) 8157 { 8158 struct cmd_set_qmap_result *res = parsed_result; 8159 int is_rx = (strcmp(res->what, "tx") == 0) ? 0 : 1; 8160 8161 set_qmap(res->port_id, (uint8_t)is_rx, res->queue_id, res->map_value); 8162 } 8163 8164 cmdline_parse_token_string_t cmd_setqmap_set = 8165 TOKEN_STRING_INITIALIZER(struct cmd_set_qmap_result, 8166 set, "set"); 8167 cmdline_parse_token_string_t cmd_setqmap_qmap = 8168 TOKEN_STRING_INITIALIZER(struct cmd_set_qmap_result, 8169 qmap, "stat_qmap"); 8170 cmdline_parse_token_string_t cmd_setqmap_what = 8171 TOKEN_STRING_INITIALIZER(struct cmd_set_qmap_result, 8172 what, "tx#rx"); 8173 cmdline_parse_token_num_t cmd_setqmap_portid = 8174 TOKEN_NUM_INITIALIZER(struct cmd_set_qmap_result, 8175 port_id, UINT16); 8176 cmdline_parse_token_num_t cmd_setqmap_queueid = 8177 TOKEN_NUM_INITIALIZER(struct cmd_set_qmap_result, 8178 queue_id, UINT16); 8179 cmdline_parse_token_num_t cmd_setqmap_mapvalue = 8180 TOKEN_NUM_INITIALIZER(struct cmd_set_qmap_result, 8181 map_value, UINT8); 8182 8183 cmdline_parse_inst_t cmd_set_qmap = { 8184 .f = cmd_set_qmap_parsed, 8185 .data = NULL, 8186 .help_str = "set stat_qmap rx|tx <port_id> <queue_id> <map_value>: " 8187 "Set statistics mapping value on tx|rx queue_id of port_id", 8188 .tokens = { 8189 (void *)&cmd_setqmap_set, 8190 (void *)&cmd_setqmap_qmap, 8191 (void *)&cmd_setqmap_what, 8192 (void *)&cmd_setqmap_portid, 8193 (void *)&cmd_setqmap_queueid, 8194 (void *)&cmd_setqmap_mapvalue, 8195 NULL, 8196 }, 8197 }; 8198 8199 /* *** SET OPTION TO HIDE ZERO VALUES FOR XSTATS DISPLAY *** */ 8200 struct cmd_set_xstats_hide_zero_result { 8201 cmdline_fixed_string_t keyword; 8202 cmdline_fixed_string_t name; 8203 cmdline_fixed_string_t on_off; 8204 }; 8205 8206 static void 8207 cmd_set_xstats_hide_zero_parsed(void *parsed_result, 8208 __attribute__((unused)) struct cmdline *cl, 8209 __attribute__((unused)) void *data) 8210 { 8211 struct cmd_set_xstats_hide_zero_result *res; 8212 uint16_t on_off = 0; 8213 8214 res = parsed_result; 8215 on_off = !strcmp(res->on_off, "on") ? 1 : 0; 8216 set_xstats_hide_zero(on_off); 8217 } 8218 8219 cmdline_parse_token_string_t cmd_set_xstats_hide_zero_keyword = 8220 TOKEN_STRING_INITIALIZER(struct cmd_set_xstats_hide_zero_result, 8221 keyword, "set"); 8222 cmdline_parse_token_string_t cmd_set_xstats_hide_zero_name = 8223 TOKEN_STRING_INITIALIZER(struct cmd_set_xstats_hide_zero_result, 8224 name, "xstats-hide-zero"); 8225 cmdline_parse_token_string_t cmd_set_xstats_hide_zero_on_off = 8226 TOKEN_STRING_INITIALIZER(struct cmd_set_xstats_hide_zero_result, 8227 on_off, "on#off"); 8228 8229 cmdline_parse_inst_t cmd_set_xstats_hide_zero = { 8230 .f = cmd_set_xstats_hide_zero_parsed, 8231 .data = NULL, 8232 .help_str = "set xstats-hide-zero on|off", 8233 .tokens = { 8234 (void *)&cmd_set_xstats_hide_zero_keyword, 8235 (void *)&cmd_set_xstats_hide_zero_name, 8236 (void *)&cmd_set_xstats_hide_zero_on_off, 8237 NULL, 8238 }, 8239 }; 8240 8241 /* *** CONFIGURE UNICAST HASH TABLE *** */ 8242 struct cmd_set_uc_hash_table { 8243 cmdline_fixed_string_t set; 8244 cmdline_fixed_string_t port; 8245 portid_t port_id; 8246 cmdline_fixed_string_t what; 8247 struct rte_ether_addr address; 8248 cmdline_fixed_string_t mode; 8249 }; 8250 8251 static void 8252 cmd_set_uc_hash_parsed(void *parsed_result, 8253 __attribute__((unused)) struct cmdline *cl, 8254 __attribute__((unused)) void *data) 8255 { 8256 int ret=0; 8257 struct cmd_set_uc_hash_table *res = parsed_result; 8258 8259 int is_on = (strcmp(res->mode, "on") == 0) ? 1 : 0; 8260 8261 if (strcmp(res->what, "uta") == 0) 8262 ret = rte_eth_dev_uc_hash_table_set(res->port_id, 8263 &res->address,(uint8_t)is_on); 8264 if (ret < 0) 8265 printf("bad unicast hash table parameter, return code = %d \n", ret); 8266 8267 } 8268 8269 cmdline_parse_token_string_t cmd_set_uc_hash_set = 8270 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_hash_table, 8271 set, "set"); 8272 cmdline_parse_token_string_t cmd_set_uc_hash_port = 8273 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_hash_table, 8274 port, "port"); 8275 cmdline_parse_token_num_t cmd_set_uc_hash_portid = 8276 TOKEN_NUM_INITIALIZER(struct cmd_set_uc_hash_table, 8277 port_id, UINT16); 8278 cmdline_parse_token_string_t cmd_set_uc_hash_what = 8279 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_hash_table, 8280 what, "uta"); 8281 cmdline_parse_token_etheraddr_t cmd_set_uc_hash_mac = 8282 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_uc_hash_table, 8283 address); 8284 cmdline_parse_token_string_t cmd_set_uc_hash_mode = 8285 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_hash_table, 8286 mode, "on#off"); 8287 8288 cmdline_parse_inst_t cmd_set_uc_hash_filter = { 8289 .f = cmd_set_uc_hash_parsed, 8290 .data = NULL, 8291 .help_str = "set port <port_id> uta <mac_addr> on|off)", 8292 .tokens = { 8293 (void *)&cmd_set_uc_hash_set, 8294 (void *)&cmd_set_uc_hash_port, 8295 (void *)&cmd_set_uc_hash_portid, 8296 (void *)&cmd_set_uc_hash_what, 8297 (void *)&cmd_set_uc_hash_mac, 8298 (void *)&cmd_set_uc_hash_mode, 8299 NULL, 8300 }, 8301 }; 8302 8303 struct cmd_set_uc_all_hash_table { 8304 cmdline_fixed_string_t set; 8305 cmdline_fixed_string_t port; 8306 portid_t port_id; 8307 cmdline_fixed_string_t what; 8308 cmdline_fixed_string_t value; 8309 cmdline_fixed_string_t mode; 8310 }; 8311 8312 static void 8313 cmd_set_uc_all_hash_parsed(void *parsed_result, 8314 __attribute__((unused)) struct cmdline *cl, 8315 __attribute__((unused)) void *data) 8316 { 8317 int ret=0; 8318 struct cmd_set_uc_all_hash_table *res = parsed_result; 8319 8320 int is_on = (strcmp(res->mode, "on") == 0) ? 1 : 0; 8321 8322 if ((strcmp(res->what, "uta") == 0) && 8323 (strcmp(res->value, "all") == 0)) 8324 ret = rte_eth_dev_uc_all_hash_table_set(res->port_id,(uint8_t) is_on); 8325 if (ret < 0) 8326 printf("bad unicast hash table parameter," 8327 "return code = %d \n", ret); 8328 } 8329 8330 cmdline_parse_token_string_t cmd_set_uc_all_hash_set = 8331 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_all_hash_table, 8332 set, "set"); 8333 cmdline_parse_token_string_t cmd_set_uc_all_hash_port = 8334 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_all_hash_table, 8335 port, "port"); 8336 cmdline_parse_token_num_t cmd_set_uc_all_hash_portid = 8337 TOKEN_NUM_INITIALIZER(struct cmd_set_uc_all_hash_table, 8338 port_id, UINT16); 8339 cmdline_parse_token_string_t cmd_set_uc_all_hash_what = 8340 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_all_hash_table, 8341 what, "uta"); 8342 cmdline_parse_token_string_t cmd_set_uc_all_hash_value = 8343 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_all_hash_table, 8344 value,"all"); 8345 cmdline_parse_token_string_t cmd_set_uc_all_hash_mode = 8346 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_all_hash_table, 8347 mode, "on#off"); 8348 8349 cmdline_parse_inst_t cmd_set_uc_all_hash_filter = { 8350 .f = cmd_set_uc_all_hash_parsed, 8351 .data = NULL, 8352 .help_str = "set port <port_id> uta all on|off", 8353 .tokens = { 8354 (void *)&cmd_set_uc_all_hash_set, 8355 (void *)&cmd_set_uc_all_hash_port, 8356 (void *)&cmd_set_uc_all_hash_portid, 8357 (void *)&cmd_set_uc_all_hash_what, 8358 (void *)&cmd_set_uc_all_hash_value, 8359 (void *)&cmd_set_uc_all_hash_mode, 8360 NULL, 8361 }, 8362 }; 8363 8364 /* *** CONFIGURE MACVLAN FILTER FOR VF(s) *** */ 8365 struct cmd_set_vf_macvlan_filter { 8366 cmdline_fixed_string_t set; 8367 cmdline_fixed_string_t port; 8368 portid_t port_id; 8369 cmdline_fixed_string_t vf; 8370 uint8_t vf_id; 8371 struct rte_ether_addr address; 8372 cmdline_fixed_string_t filter_type; 8373 cmdline_fixed_string_t mode; 8374 }; 8375 8376 static void 8377 cmd_set_vf_macvlan_parsed(void *parsed_result, 8378 __attribute__((unused)) struct cmdline *cl, 8379 __attribute__((unused)) void *data) 8380 { 8381 int is_on, ret = 0; 8382 struct cmd_set_vf_macvlan_filter *res = parsed_result; 8383 struct rte_eth_mac_filter filter; 8384 8385 memset(&filter, 0, sizeof(struct rte_eth_mac_filter)); 8386 8387 rte_memcpy(&filter.mac_addr, &res->address, RTE_ETHER_ADDR_LEN); 8388 8389 /* set VF MAC filter */ 8390 filter.is_vf = 1; 8391 8392 /* set VF ID */ 8393 filter.dst_id = res->vf_id; 8394 8395 if (!strcmp(res->filter_type, "exact-mac")) 8396 filter.filter_type = RTE_MAC_PERFECT_MATCH; 8397 else if (!strcmp(res->filter_type, "exact-mac-vlan")) 8398 filter.filter_type = RTE_MACVLAN_PERFECT_MATCH; 8399 else if (!strcmp(res->filter_type, "hashmac")) 8400 filter.filter_type = RTE_MAC_HASH_MATCH; 8401 else if (!strcmp(res->filter_type, "hashmac-vlan")) 8402 filter.filter_type = RTE_MACVLAN_HASH_MATCH; 8403 8404 is_on = (strcmp(res->mode, "on") == 0) ? 1 : 0; 8405 8406 if (is_on) 8407 ret = rte_eth_dev_filter_ctrl(res->port_id, 8408 RTE_ETH_FILTER_MACVLAN, 8409 RTE_ETH_FILTER_ADD, 8410 &filter); 8411 else 8412 ret = rte_eth_dev_filter_ctrl(res->port_id, 8413 RTE_ETH_FILTER_MACVLAN, 8414 RTE_ETH_FILTER_DELETE, 8415 &filter); 8416 8417 if (ret < 0) 8418 printf("bad set MAC hash parameter, return code = %d\n", ret); 8419 8420 } 8421 8422 cmdline_parse_token_string_t cmd_set_vf_macvlan_set = 8423 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_macvlan_filter, 8424 set, "set"); 8425 cmdline_parse_token_string_t cmd_set_vf_macvlan_port = 8426 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_macvlan_filter, 8427 port, "port"); 8428 cmdline_parse_token_num_t cmd_set_vf_macvlan_portid = 8429 TOKEN_NUM_INITIALIZER(struct cmd_set_vf_macvlan_filter, 8430 port_id, UINT16); 8431 cmdline_parse_token_string_t cmd_set_vf_macvlan_vf = 8432 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_macvlan_filter, 8433 vf, "vf"); 8434 cmdline_parse_token_num_t cmd_set_vf_macvlan_vf_id = 8435 TOKEN_NUM_INITIALIZER(struct cmd_set_vf_macvlan_filter, 8436 vf_id, UINT8); 8437 cmdline_parse_token_etheraddr_t cmd_set_vf_macvlan_mac = 8438 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_vf_macvlan_filter, 8439 address); 8440 cmdline_parse_token_string_t cmd_set_vf_macvlan_filter_type = 8441 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_macvlan_filter, 8442 filter_type, "exact-mac#exact-mac-vlan" 8443 "#hashmac#hashmac-vlan"); 8444 cmdline_parse_token_string_t cmd_set_vf_macvlan_mode = 8445 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_macvlan_filter, 8446 mode, "on#off"); 8447 8448 cmdline_parse_inst_t cmd_set_vf_macvlan_filter = { 8449 .f = cmd_set_vf_macvlan_parsed, 8450 .data = NULL, 8451 .help_str = "set port <port_id> vf <vf_id> <mac_addr> " 8452 "exact-mac|exact-mac-vlan|hashmac|hashmac-vlan on|off: " 8453 "Exact match rule: exact match of MAC or MAC and VLAN; " 8454 "hash match rule: hash match of MAC and exact match of VLAN", 8455 .tokens = { 8456 (void *)&cmd_set_vf_macvlan_set, 8457 (void *)&cmd_set_vf_macvlan_port, 8458 (void *)&cmd_set_vf_macvlan_portid, 8459 (void *)&cmd_set_vf_macvlan_vf, 8460 (void *)&cmd_set_vf_macvlan_vf_id, 8461 (void *)&cmd_set_vf_macvlan_mac, 8462 (void *)&cmd_set_vf_macvlan_filter_type, 8463 (void *)&cmd_set_vf_macvlan_mode, 8464 NULL, 8465 }, 8466 }; 8467 8468 /* *** CONFIGURE VF TRAFFIC CONTROL *** */ 8469 struct cmd_set_vf_traffic { 8470 cmdline_fixed_string_t set; 8471 cmdline_fixed_string_t port; 8472 portid_t port_id; 8473 cmdline_fixed_string_t vf; 8474 uint8_t vf_id; 8475 cmdline_fixed_string_t what; 8476 cmdline_fixed_string_t mode; 8477 }; 8478 8479 static void 8480 cmd_set_vf_traffic_parsed(void *parsed_result, 8481 __attribute__((unused)) struct cmdline *cl, 8482 __attribute__((unused)) void *data) 8483 { 8484 struct cmd_set_vf_traffic *res = parsed_result; 8485 int is_rx = (strcmp(res->what, "rx") == 0) ? 1 : 0; 8486 int is_on = (strcmp(res->mode, "on") == 0) ? 1 : 0; 8487 8488 set_vf_traffic(res->port_id, (uint8_t)is_rx, res->vf_id,(uint8_t) is_on); 8489 } 8490 8491 cmdline_parse_token_string_t cmd_setvf_traffic_set = 8492 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_traffic, 8493 set, "set"); 8494 cmdline_parse_token_string_t cmd_setvf_traffic_port = 8495 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_traffic, 8496 port, "port"); 8497 cmdline_parse_token_num_t cmd_setvf_traffic_portid = 8498 TOKEN_NUM_INITIALIZER(struct cmd_set_vf_traffic, 8499 port_id, UINT16); 8500 cmdline_parse_token_string_t cmd_setvf_traffic_vf = 8501 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_traffic, 8502 vf, "vf"); 8503 cmdline_parse_token_num_t cmd_setvf_traffic_vfid = 8504 TOKEN_NUM_INITIALIZER(struct cmd_set_vf_traffic, 8505 vf_id, UINT8); 8506 cmdline_parse_token_string_t cmd_setvf_traffic_what = 8507 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_traffic, 8508 what, "tx#rx"); 8509 cmdline_parse_token_string_t cmd_setvf_traffic_mode = 8510 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_traffic, 8511 mode, "on#off"); 8512 8513 cmdline_parse_inst_t cmd_set_vf_traffic = { 8514 .f = cmd_set_vf_traffic_parsed, 8515 .data = NULL, 8516 .help_str = "set port <port_id> vf <vf_id> rx|tx on|off", 8517 .tokens = { 8518 (void *)&cmd_setvf_traffic_set, 8519 (void *)&cmd_setvf_traffic_port, 8520 (void *)&cmd_setvf_traffic_portid, 8521 (void *)&cmd_setvf_traffic_vf, 8522 (void *)&cmd_setvf_traffic_vfid, 8523 (void *)&cmd_setvf_traffic_what, 8524 (void *)&cmd_setvf_traffic_mode, 8525 NULL, 8526 }, 8527 }; 8528 8529 /* *** CONFIGURE VF RECEIVE MODE *** */ 8530 struct cmd_set_vf_rxmode { 8531 cmdline_fixed_string_t set; 8532 cmdline_fixed_string_t port; 8533 portid_t port_id; 8534 cmdline_fixed_string_t vf; 8535 uint8_t vf_id; 8536 cmdline_fixed_string_t what; 8537 cmdline_fixed_string_t mode; 8538 cmdline_fixed_string_t on; 8539 }; 8540 8541 static void 8542 cmd_set_vf_rxmode_parsed(void *parsed_result, 8543 __attribute__((unused)) struct cmdline *cl, 8544 __attribute__((unused)) void *data) 8545 { 8546 int ret = -ENOTSUP; 8547 uint16_t vf_rxmode = 0; 8548 struct cmd_set_vf_rxmode *res = parsed_result; 8549 8550 int is_on = (strcmp(res->on, "on") == 0) ? 1 : 0; 8551 if (!strcmp(res->what,"rxmode")) { 8552 if (!strcmp(res->mode, "AUPE")) 8553 vf_rxmode |= ETH_VMDQ_ACCEPT_UNTAG; 8554 else if (!strcmp(res->mode, "ROPE")) 8555 vf_rxmode |= ETH_VMDQ_ACCEPT_HASH_UC; 8556 else if (!strcmp(res->mode, "BAM")) 8557 vf_rxmode |= ETH_VMDQ_ACCEPT_BROADCAST; 8558 else if (!strncmp(res->mode, "MPE",3)) 8559 vf_rxmode |= ETH_VMDQ_ACCEPT_MULTICAST; 8560 } 8561 8562 RTE_SET_USED(is_on); 8563 8564 #ifdef RTE_LIBRTE_IXGBE_PMD 8565 if (ret == -ENOTSUP) 8566 ret = rte_pmd_ixgbe_set_vf_rxmode(res->port_id, res->vf_id, 8567 vf_rxmode, (uint8_t)is_on); 8568 #endif 8569 #ifdef RTE_LIBRTE_BNXT_PMD 8570 if (ret == -ENOTSUP) 8571 ret = rte_pmd_bnxt_set_vf_rxmode(res->port_id, res->vf_id, 8572 vf_rxmode, (uint8_t)is_on); 8573 #endif 8574 if (ret < 0) 8575 printf("bad VF receive mode parameter, return code = %d \n", 8576 ret); 8577 } 8578 8579 cmdline_parse_token_string_t cmd_set_vf_rxmode_set = 8580 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_rxmode, 8581 set, "set"); 8582 cmdline_parse_token_string_t cmd_set_vf_rxmode_port = 8583 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_rxmode, 8584 port, "port"); 8585 cmdline_parse_token_num_t cmd_set_vf_rxmode_portid = 8586 TOKEN_NUM_INITIALIZER(struct cmd_set_vf_rxmode, 8587 port_id, UINT16); 8588 cmdline_parse_token_string_t cmd_set_vf_rxmode_vf = 8589 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_rxmode, 8590 vf, "vf"); 8591 cmdline_parse_token_num_t cmd_set_vf_rxmode_vfid = 8592 TOKEN_NUM_INITIALIZER(struct cmd_set_vf_rxmode, 8593 vf_id, UINT8); 8594 cmdline_parse_token_string_t cmd_set_vf_rxmode_what = 8595 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_rxmode, 8596 what, "rxmode"); 8597 cmdline_parse_token_string_t cmd_set_vf_rxmode_mode = 8598 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_rxmode, 8599 mode, "AUPE#ROPE#BAM#MPE"); 8600 cmdline_parse_token_string_t cmd_set_vf_rxmode_on = 8601 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_rxmode, 8602 on, "on#off"); 8603 8604 cmdline_parse_inst_t cmd_set_vf_rxmode = { 8605 .f = cmd_set_vf_rxmode_parsed, 8606 .data = NULL, 8607 .help_str = "set port <port_id> vf <vf_id> rxmode " 8608 "AUPE|ROPE|BAM|MPE on|off", 8609 .tokens = { 8610 (void *)&cmd_set_vf_rxmode_set, 8611 (void *)&cmd_set_vf_rxmode_port, 8612 (void *)&cmd_set_vf_rxmode_portid, 8613 (void *)&cmd_set_vf_rxmode_vf, 8614 (void *)&cmd_set_vf_rxmode_vfid, 8615 (void *)&cmd_set_vf_rxmode_what, 8616 (void *)&cmd_set_vf_rxmode_mode, 8617 (void *)&cmd_set_vf_rxmode_on, 8618 NULL, 8619 }, 8620 }; 8621 8622 /* *** ADD MAC ADDRESS FILTER FOR A VF OF A PORT *** */ 8623 struct cmd_vf_mac_addr_result { 8624 cmdline_fixed_string_t mac_addr_cmd; 8625 cmdline_fixed_string_t what; 8626 cmdline_fixed_string_t port; 8627 uint16_t port_num; 8628 cmdline_fixed_string_t vf; 8629 uint8_t vf_num; 8630 struct rte_ether_addr address; 8631 }; 8632 8633 static void cmd_vf_mac_addr_parsed(void *parsed_result, 8634 __attribute__((unused)) struct cmdline *cl, 8635 __attribute__((unused)) void *data) 8636 { 8637 struct cmd_vf_mac_addr_result *res = parsed_result; 8638 int ret = -ENOTSUP; 8639 8640 if (strcmp(res->what, "add") != 0) 8641 return; 8642 8643 #ifdef RTE_LIBRTE_I40E_PMD 8644 if (ret == -ENOTSUP) 8645 ret = rte_pmd_i40e_add_vf_mac_addr(res->port_num, res->vf_num, 8646 &res->address); 8647 #endif 8648 #ifdef RTE_LIBRTE_BNXT_PMD 8649 if (ret == -ENOTSUP) 8650 ret = rte_pmd_bnxt_mac_addr_add(res->port_num, &res->address, 8651 res->vf_num); 8652 #endif 8653 8654 if(ret < 0) 8655 printf("vf_mac_addr_cmd error: (%s)\n", strerror(-ret)); 8656 8657 } 8658 8659 cmdline_parse_token_string_t cmd_vf_mac_addr_cmd = 8660 TOKEN_STRING_INITIALIZER(struct cmd_vf_mac_addr_result, 8661 mac_addr_cmd,"mac_addr"); 8662 cmdline_parse_token_string_t cmd_vf_mac_addr_what = 8663 TOKEN_STRING_INITIALIZER(struct cmd_vf_mac_addr_result, 8664 what,"add"); 8665 cmdline_parse_token_string_t cmd_vf_mac_addr_port = 8666 TOKEN_STRING_INITIALIZER(struct cmd_vf_mac_addr_result, 8667 port,"port"); 8668 cmdline_parse_token_num_t cmd_vf_mac_addr_portnum = 8669 TOKEN_NUM_INITIALIZER(struct cmd_vf_mac_addr_result, 8670 port_num, UINT16); 8671 cmdline_parse_token_string_t cmd_vf_mac_addr_vf = 8672 TOKEN_STRING_INITIALIZER(struct cmd_vf_mac_addr_result, 8673 vf,"vf"); 8674 cmdline_parse_token_num_t cmd_vf_mac_addr_vfnum = 8675 TOKEN_NUM_INITIALIZER(struct cmd_vf_mac_addr_result, 8676 vf_num, UINT8); 8677 cmdline_parse_token_etheraddr_t cmd_vf_mac_addr_addr = 8678 TOKEN_ETHERADDR_INITIALIZER(struct cmd_vf_mac_addr_result, 8679 address); 8680 8681 cmdline_parse_inst_t cmd_vf_mac_addr_filter = { 8682 .f = cmd_vf_mac_addr_parsed, 8683 .data = (void *)0, 8684 .help_str = "mac_addr add port <port_id> vf <vf_id> <mac_addr>: " 8685 "Add MAC address filtering for a VF on port_id", 8686 .tokens = { 8687 (void *)&cmd_vf_mac_addr_cmd, 8688 (void *)&cmd_vf_mac_addr_what, 8689 (void *)&cmd_vf_mac_addr_port, 8690 (void *)&cmd_vf_mac_addr_portnum, 8691 (void *)&cmd_vf_mac_addr_vf, 8692 (void *)&cmd_vf_mac_addr_vfnum, 8693 (void *)&cmd_vf_mac_addr_addr, 8694 NULL, 8695 }, 8696 }; 8697 8698 /* *** ADD/REMOVE A VLAN IDENTIFIER TO/FROM A PORT VLAN RX FILTER *** */ 8699 struct cmd_vf_rx_vlan_filter { 8700 cmdline_fixed_string_t rx_vlan; 8701 cmdline_fixed_string_t what; 8702 uint16_t vlan_id; 8703 cmdline_fixed_string_t port; 8704 portid_t port_id; 8705 cmdline_fixed_string_t vf; 8706 uint64_t vf_mask; 8707 }; 8708 8709 static void 8710 cmd_vf_rx_vlan_filter_parsed(void *parsed_result, 8711 __attribute__((unused)) struct cmdline *cl, 8712 __attribute__((unused)) void *data) 8713 { 8714 struct cmd_vf_rx_vlan_filter *res = parsed_result; 8715 int ret = -ENOTSUP; 8716 8717 __rte_unused int is_add = (strcmp(res->what, "add") == 0) ? 1 : 0; 8718 8719 #ifdef RTE_LIBRTE_IXGBE_PMD 8720 if (ret == -ENOTSUP) 8721 ret = rte_pmd_ixgbe_set_vf_vlan_filter(res->port_id, 8722 res->vlan_id, res->vf_mask, is_add); 8723 #endif 8724 #ifdef RTE_LIBRTE_I40E_PMD 8725 if (ret == -ENOTSUP) 8726 ret = rte_pmd_i40e_set_vf_vlan_filter(res->port_id, 8727 res->vlan_id, res->vf_mask, is_add); 8728 #endif 8729 #ifdef RTE_LIBRTE_BNXT_PMD 8730 if (ret == -ENOTSUP) 8731 ret = rte_pmd_bnxt_set_vf_vlan_filter(res->port_id, 8732 res->vlan_id, res->vf_mask, is_add); 8733 #endif 8734 8735 switch (ret) { 8736 case 0: 8737 break; 8738 case -EINVAL: 8739 printf("invalid vlan_id %d or vf_mask %"PRIu64"\n", 8740 res->vlan_id, res->vf_mask); 8741 break; 8742 case -ENODEV: 8743 printf("invalid port_id %d\n", res->port_id); 8744 break; 8745 case -ENOTSUP: 8746 printf("function not implemented or supported\n"); 8747 break; 8748 default: 8749 printf("programming error: (%s)\n", strerror(-ret)); 8750 } 8751 } 8752 8753 cmdline_parse_token_string_t cmd_vf_rx_vlan_filter_rx_vlan = 8754 TOKEN_STRING_INITIALIZER(struct cmd_vf_rx_vlan_filter, 8755 rx_vlan, "rx_vlan"); 8756 cmdline_parse_token_string_t cmd_vf_rx_vlan_filter_what = 8757 TOKEN_STRING_INITIALIZER(struct cmd_vf_rx_vlan_filter, 8758 what, "add#rm"); 8759 cmdline_parse_token_num_t cmd_vf_rx_vlan_filter_vlanid = 8760 TOKEN_NUM_INITIALIZER(struct cmd_vf_rx_vlan_filter, 8761 vlan_id, UINT16); 8762 cmdline_parse_token_string_t cmd_vf_rx_vlan_filter_port = 8763 TOKEN_STRING_INITIALIZER(struct cmd_vf_rx_vlan_filter, 8764 port, "port"); 8765 cmdline_parse_token_num_t cmd_vf_rx_vlan_filter_portid = 8766 TOKEN_NUM_INITIALIZER(struct cmd_vf_rx_vlan_filter, 8767 port_id, UINT16); 8768 cmdline_parse_token_string_t cmd_vf_rx_vlan_filter_vf = 8769 TOKEN_STRING_INITIALIZER(struct cmd_vf_rx_vlan_filter, 8770 vf, "vf"); 8771 cmdline_parse_token_num_t cmd_vf_rx_vlan_filter_vf_mask = 8772 TOKEN_NUM_INITIALIZER(struct cmd_vf_rx_vlan_filter, 8773 vf_mask, UINT64); 8774 8775 cmdline_parse_inst_t cmd_vf_rxvlan_filter = { 8776 .f = cmd_vf_rx_vlan_filter_parsed, 8777 .data = NULL, 8778 .help_str = "rx_vlan add|rm <vlan_id> port <port_id> vf <vf_mask>: " 8779 "(vf_mask = hexadecimal VF mask)", 8780 .tokens = { 8781 (void *)&cmd_vf_rx_vlan_filter_rx_vlan, 8782 (void *)&cmd_vf_rx_vlan_filter_what, 8783 (void *)&cmd_vf_rx_vlan_filter_vlanid, 8784 (void *)&cmd_vf_rx_vlan_filter_port, 8785 (void *)&cmd_vf_rx_vlan_filter_portid, 8786 (void *)&cmd_vf_rx_vlan_filter_vf, 8787 (void *)&cmd_vf_rx_vlan_filter_vf_mask, 8788 NULL, 8789 }, 8790 }; 8791 8792 /* *** SET RATE LIMIT FOR A QUEUE OF A PORT *** */ 8793 struct cmd_queue_rate_limit_result { 8794 cmdline_fixed_string_t set; 8795 cmdline_fixed_string_t port; 8796 uint16_t port_num; 8797 cmdline_fixed_string_t queue; 8798 uint8_t queue_num; 8799 cmdline_fixed_string_t rate; 8800 uint16_t rate_num; 8801 }; 8802 8803 static void cmd_queue_rate_limit_parsed(void *parsed_result, 8804 __attribute__((unused)) struct cmdline *cl, 8805 __attribute__((unused)) void *data) 8806 { 8807 struct cmd_queue_rate_limit_result *res = parsed_result; 8808 int ret = 0; 8809 8810 if ((strcmp(res->set, "set") == 0) && (strcmp(res->port, "port") == 0) 8811 && (strcmp(res->queue, "queue") == 0) 8812 && (strcmp(res->rate, "rate") == 0)) 8813 ret = set_queue_rate_limit(res->port_num, res->queue_num, 8814 res->rate_num); 8815 if (ret < 0) 8816 printf("queue_rate_limit_cmd error: (%s)\n", strerror(-ret)); 8817 8818 } 8819 8820 cmdline_parse_token_string_t cmd_queue_rate_limit_set = 8821 TOKEN_STRING_INITIALIZER(struct cmd_queue_rate_limit_result, 8822 set, "set"); 8823 cmdline_parse_token_string_t cmd_queue_rate_limit_port = 8824 TOKEN_STRING_INITIALIZER(struct cmd_queue_rate_limit_result, 8825 port, "port"); 8826 cmdline_parse_token_num_t cmd_queue_rate_limit_portnum = 8827 TOKEN_NUM_INITIALIZER(struct cmd_queue_rate_limit_result, 8828 port_num, UINT16); 8829 cmdline_parse_token_string_t cmd_queue_rate_limit_queue = 8830 TOKEN_STRING_INITIALIZER(struct cmd_queue_rate_limit_result, 8831 queue, "queue"); 8832 cmdline_parse_token_num_t cmd_queue_rate_limit_queuenum = 8833 TOKEN_NUM_INITIALIZER(struct cmd_queue_rate_limit_result, 8834 queue_num, UINT8); 8835 cmdline_parse_token_string_t cmd_queue_rate_limit_rate = 8836 TOKEN_STRING_INITIALIZER(struct cmd_queue_rate_limit_result, 8837 rate, "rate"); 8838 cmdline_parse_token_num_t cmd_queue_rate_limit_ratenum = 8839 TOKEN_NUM_INITIALIZER(struct cmd_queue_rate_limit_result, 8840 rate_num, UINT16); 8841 8842 cmdline_parse_inst_t cmd_queue_rate_limit = { 8843 .f = cmd_queue_rate_limit_parsed, 8844 .data = (void *)0, 8845 .help_str = "set port <port_id> queue <queue_id> rate <rate_value>: " 8846 "Set rate limit for a queue on port_id", 8847 .tokens = { 8848 (void *)&cmd_queue_rate_limit_set, 8849 (void *)&cmd_queue_rate_limit_port, 8850 (void *)&cmd_queue_rate_limit_portnum, 8851 (void *)&cmd_queue_rate_limit_queue, 8852 (void *)&cmd_queue_rate_limit_queuenum, 8853 (void *)&cmd_queue_rate_limit_rate, 8854 (void *)&cmd_queue_rate_limit_ratenum, 8855 NULL, 8856 }, 8857 }; 8858 8859 /* *** SET RATE LIMIT FOR A VF OF A PORT *** */ 8860 struct cmd_vf_rate_limit_result { 8861 cmdline_fixed_string_t set; 8862 cmdline_fixed_string_t port; 8863 uint16_t port_num; 8864 cmdline_fixed_string_t vf; 8865 uint8_t vf_num; 8866 cmdline_fixed_string_t rate; 8867 uint16_t rate_num; 8868 cmdline_fixed_string_t q_msk; 8869 uint64_t q_msk_val; 8870 }; 8871 8872 static void cmd_vf_rate_limit_parsed(void *parsed_result, 8873 __attribute__((unused)) struct cmdline *cl, 8874 __attribute__((unused)) void *data) 8875 { 8876 struct cmd_vf_rate_limit_result *res = parsed_result; 8877 int ret = 0; 8878 8879 if ((strcmp(res->set, "set") == 0) && (strcmp(res->port, "port") == 0) 8880 && (strcmp(res->vf, "vf") == 0) 8881 && (strcmp(res->rate, "rate") == 0) 8882 && (strcmp(res->q_msk, "queue_mask") == 0)) 8883 ret = set_vf_rate_limit(res->port_num, res->vf_num, 8884 res->rate_num, res->q_msk_val); 8885 if (ret < 0) 8886 printf("vf_rate_limit_cmd error: (%s)\n", strerror(-ret)); 8887 8888 } 8889 8890 cmdline_parse_token_string_t cmd_vf_rate_limit_set = 8891 TOKEN_STRING_INITIALIZER(struct cmd_vf_rate_limit_result, 8892 set, "set"); 8893 cmdline_parse_token_string_t cmd_vf_rate_limit_port = 8894 TOKEN_STRING_INITIALIZER(struct cmd_vf_rate_limit_result, 8895 port, "port"); 8896 cmdline_parse_token_num_t cmd_vf_rate_limit_portnum = 8897 TOKEN_NUM_INITIALIZER(struct cmd_vf_rate_limit_result, 8898 port_num, UINT16); 8899 cmdline_parse_token_string_t cmd_vf_rate_limit_vf = 8900 TOKEN_STRING_INITIALIZER(struct cmd_vf_rate_limit_result, 8901 vf, "vf"); 8902 cmdline_parse_token_num_t cmd_vf_rate_limit_vfnum = 8903 TOKEN_NUM_INITIALIZER(struct cmd_vf_rate_limit_result, 8904 vf_num, UINT8); 8905 cmdline_parse_token_string_t cmd_vf_rate_limit_rate = 8906 TOKEN_STRING_INITIALIZER(struct cmd_vf_rate_limit_result, 8907 rate, "rate"); 8908 cmdline_parse_token_num_t cmd_vf_rate_limit_ratenum = 8909 TOKEN_NUM_INITIALIZER(struct cmd_vf_rate_limit_result, 8910 rate_num, UINT16); 8911 cmdline_parse_token_string_t cmd_vf_rate_limit_q_msk = 8912 TOKEN_STRING_INITIALIZER(struct cmd_vf_rate_limit_result, 8913 q_msk, "queue_mask"); 8914 cmdline_parse_token_num_t cmd_vf_rate_limit_q_msk_val = 8915 TOKEN_NUM_INITIALIZER(struct cmd_vf_rate_limit_result, 8916 q_msk_val, UINT64); 8917 8918 cmdline_parse_inst_t cmd_vf_rate_limit = { 8919 .f = cmd_vf_rate_limit_parsed, 8920 .data = (void *)0, 8921 .help_str = "set port <port_id> vf <vf_id> rate <rate_value> " 8922 "queue_mask <queue_mask_value>: " 8923 "Set rate limit for queues of VF on port_id", 8924 .tokens = { 8925 (void *)&cmd_vf_rate_limit_set, 8926 (void *)&cmd_vf_rate_limit_port, 8927 (void *)&cmd_vf_rate_limit_portnum, 8928 (void *)&cmd_vf_rate_limit_vf, 8929 (void *)&cmd_vf_rate_limit_vfnum, 8930 (void *)&cmd_vf_rate_limit_rate, 8931 (void *)&cmd_vf_rate_limit_ratenum, 8932 (void *)&cmd_vf_rate_limit_q_msk, 8933 (void *)&cmd_vf_rate_limit_q_msk_val, 8934 NULL, 8935 }, 8936 }; 8937 8938 /* *** ADD TUNNEL FILTER OF A PORT *** */ 8939 struct cmd_tunnel_filter_result { 8940 cmdline_fixed_string_t cmd; 8941 cmdline_fixed_string_t what; 8942 portid_t port_id; 8943 struct rte_ether_addr outer_mac; 8944 struct rte_ether_addr inner_mac; 8945 cmdline_ipaddr_t ip_value; 8946 uint16_t inner_vlan; 8947 cmdline_fixed_string_t tunnel_type; 8948 cmdline_fixed_string_t filter_type; 8949 uint32_t tenant_id; 8950 uint16_t queue_num; 8951 }; 8952 8953 static void 8954 cmd_tunnel_filter_parsed(void *parsed_result, 8955 __attribute__((unused)) struct cmdline *cl, 8956 __attribute__((unused)) void *data) 8957 { 8958 struct cmd_tunnel_filter_result *res = parsed_result; 8959 struct rte_eth_tunnel_filter_conf tunnel_filter_conf; 8960 int ret = 0; 8961 8962 memset(&tunnel_filter_conf, 0, sizeof(tunnel_filter_conf)); 8963 8964 rte_ether_addr_copy(&res->outer_mac, &tunnel_filter_conf.outer_mac); 8965 rte_ether_addr_copy(&res->inner_mac, &tunnel_filter_conf.inner_mac); 8966 tunnel_filter_conf.inner_vlan = res->inner_vlan; 8967 8968 if (res->ip_value.family == AF_INET) { 8969 tunnel_filter_conf.ip_addr.ipv4_addr = 8970 res->ip_value.addr.ipv4.s_addr; 8971 tunnel_filter_conf.ip_type = RTE_TUNNEL_IPTYPE_IPV4; 8972 } else { 8973 memcpy(&(tunnel_filter_conf.ip_addr.ipv6_addr), 8974 &(res->ip_value.addr.ipv6), 8975 sizeof(struct in6_addr)); 8976 tunnel_filter_conf.ip_type = RTE_TUNNEL_IPTYPE_IPV6; 8977 } 8978 8979 if (!strcmp(res->filter_type, "imac-ivlan")) 8980 tunnel_filter_conf.filter_type = RTE_TUNNEL_FILTER_IMAC_IVLAN; 8981 else if (!strcmp(res->filter_type, "imac-ivlan-tenid")) 8982 tunnel_filter_conf.filter_type = 8983 RTE_TUNNEL_FILTER_IMAC_IVLAN_TENID; 8984 else if (!strcmp(res->filter_type, "imac-tenid")) 8985 tunnel_filter_conf.filter_type = RTE_TUNNEL_FILTER_IMAC_TENID; 8986 else if (!strcmp(res->filter_type, "imac")) 8987 tunnel_filter_conf.filter_type = ETH_TUNNEL_FILTER_IMAC; 8988 else if (!strcmp(res->filter_type, "omac-imac-tenid")) 8989 tunnel_filter_conf.filter_type = 8990 RTE_TUNNEL_FILTER_OMAC_TENID_IMAC; 8991 else if (!strcmp(res->filter_type, "oip")) 8992 tunnel_filter_conf.filter_type = ETH_TUNNEL_FILTER_OIP; 8993 else if (!strcmp(res->filter_type, "iip")) 8994 tunnel_filter_conf.filter_type = ETH_TUNNEL_FILTER_IIP; 8995 else { 8996 printf("The filter type is not supported"); 8997 return; 8998 } 8999 9000 if (!strcmp(res->tunnel_type, "vxlan")) 9001 tunnel_filter_conf.tunnel_type = RTE_TUNNEL_TYPE_VXLAN; 9002 else if (!strcmp(res->tunnel_type, "vxlan-gpe")) 9003 tunnel_filter_conf.tunnel_type = RTE_TUNNEL_TYPE_VXLAN_GPE; 9004 else if (!strcmp(res->tunnel_type, "nvgre")) 9005 tunnel_filter_conf.tunnel_type = RTE_TUNNEL_TYPE_NVGRE; 9006 else if (!strcmp(res->tunnel_type, "ipingre")) 9007 tunnel_filter_conf.tunnel_type = RTE_TUNNEL_TYPE_IP_IN_GRE; 9008 else { 9009 printf("The tunnel type %s not supported.\n", res->tunnel_type); 9010 return; 9011 } 9012 9013 tunnel_filter_conf.tenant_id = res->tenant_id; 9014 tunnel_filter_conf.queue_id = res->queue_num; 9015 if (!strcmp(res->what, "add")) 9016 ret = rte_eth_dev_filter_ctrl(res->port_id, 9017 RTE_ETH_FILTER_TUNNEL, 9018 RTE_ETH_FILTER_ADD, 9019 &tunnel_filter_conf); 9020 else 9021 ret = rte_eth_dev_filter_ctrl(res->port_id, 9022 RTE_ETH_FILTER_TUNNEL, 9023 RTE_ETH_FILTER_DELETE, 9024 &tunnel_filter_conf); 9025 if (ret < 0) 9026 printf("cmd_tunnel_filter_parsed error: (%s)\n", 9027 strerror(-ret)); 9028 9029 } 9030 cmdline_parse_token_string_t cmd_tunnel_filter_cmd = 9031 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_filter_result, 9032 cmd, "tunnel_filter"); 9033 cmdline_parse_token_string_t cmd_tunnel_filter_what = 9034 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_filter_result, 9035 what, "add#rm"); 9036 cmdline_parse_token_num_t cmd_tunnel_filter_port_id = 9037 TOKEN_NUM_INITIALIZER(struct cmd_tunnel_filter_result, 9038 port_id, UINT16); 9039 cmdline_parse_token_etheraddr_t cmd_tunnel_filter_outer_mac = 9040 TOKEN_ETHERADDR_INITIALIZER(struct cmd_tunnel_filter_result, 9041 outer_mac); 9042 cmdline_parse_token_etheraddr_t cmd_tunnel_filter_inner_mac = 9043 TOKEN_ETHERADDR_INITIALIZER(struct cmd_tunnel_filter_result, 9044 inner_mac); 9045 cmdline_parse_token_num_t cmd_tunnel_filter_innner_vlan = 9046 TOKEN_NUM_INITIALIZER(struct cmd_tunnel_filter_result, 9047 inner_vlan, UINT16); 9048 cmdline_parse_token_ipaddr_t cmd_tunnel_filter_ip_value = 9049 TOKEN_IPADDR_INITIALIZER(struct cmd_tunnel_filter_result, 9050 ip_value); 9051 cmdline_parse_token_string_t cmd_tunnel_filter_tunnel_type = 9052 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_filter_result, 9053 tunnel_type, "vxlan#nvgre#ipingre#vxlan-gpe"); 9054 9055 cmdline_parse_token_string_t cmd_tunnel_filter_filter_type = 9056 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_filter_result, 9057 filter_type, "oip#iip#imac-ivlan#imac-ivlan-tenid#imac-tenid#" 9058 "imac#omac-imac-tenid"); 9059 cmdline_parse_token_num_t cmd_tunnel_filter_tenant_id = 9060 TOKEN_NUM_INITIALIZER(struct cmd_tunnel_filter_result, 9061 tenant_id, UINT32); 9062 cmdline_parse_token_num_t cmd_tunnel_filter_queue_num = 9063 TOKEN_NUM_INITIALIZER(struct cmd_tunnel_filter_result, 9064 queue_num, UINT16); 9065 9066 cmdline_parse_inst_t cmd_tunnel_filter = { 9067 .f = cmd_tunnel_filter_parsed, 9068 .data = (void *)0, 9069 .help_str = "tunnel_filter add|rm <port_id> <outer_mac> <inner_mac> " 9070 "<ip> <inner_vlan> vxlan|nvgre|ipingre oip|iip|imac-ivlan|" 9071 "imac-ivlan-tenid|imac-tenid|imac|omac-imac-tenid <tenant_id> " 9072 "<queue_id>: Add/Rm tunnel filter of a port", 9073 .tokens = { 9074 (void *)&cmd_tunnel_filter_cmd, 9075 (void *)&cmd_tunnel_filter_what, 9076 (void *)&cmd_tunnel_filter_port_id, 9077 (void *)&cmd_tunnel_filter_outer_mac, 9078 (void *)&cmd_tunnel_filter_inner_mac, 9079 (void *)&cmd_tunnel_filter_ip_value, 9080 (void *)&cmd_tunnel_filter_innner_vlan, 9081 (void *)&cmd_tunnel_filter_tunnel_type, 9082 (void *)&cmd_tunnel_filter_filter_type, 9083 (void *)&cmd_tunnel_filter_tenant_id, 9084 (void *)&cmd_tunnel_filter_queue_num, 9085 NULL, 9086 }, 9087 }; 9088 9089 /* *** CONFIGURE TUNNEL UDP PORT *** */ 9090 struct cmd_tunnel_udp_config { 9091 cmdline_fixed_string_t cmd; 9092 cmdline_fixed_string_t what; 9093 uint16_t udp_port; 9094 portid_t port_id; 9095 }; 9096 9097 static void 9098 cmd_tunnel_udp_config_parsed(void *parsed_result, 9099 __attribute__((unused)) struct cmdline *cl, 9100 __attribute__((unused)) void *data) 9101 { 9102 struct cmd_tunnel_udp_config *res = parsed_result; 9103 struct rte_eth_udp_tunnel tunnel_udp; 9104 int ret; 9105 9106 tunnel_udp.udp_port = res->udp_port; 9107 9108 if (!strcmp(res->cmd, "rx_vxlan_port")) 9109 tunnel_udp.prot_type = RTE_TUNNEL_TYPE_VXLAN; 9110 9111 if (!strcmp(res->what, "add")) 9112 ret = rte_eth_dev_udp_tunnel_port_add(res->port_id, 9113 &tunnel_udp); 9114 else 9115 ret = rte_eth_dev_udp_tunnel_port_delete(res->port_id, 9116 &tunnel_udp); 9117 9118 if (ret < 0) 9119 printf("udp tunneling add error: (%s)\n", strerror(-ret)); 9120 } 9121 9122 cmdline_parse_token_string_t cmd_tunnel_udp_config_cmd = 9123 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_udp_config, 9124 cmd, "rx_vxlan_port"); 9125 cmdline_parse_token_string_t cmd_tunnel_udp_config_what = 9126 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_udp_config, 9127 what, "add#rm"); 9128 cmdline_parse_token_num_t cmd_tunnel_udp_config_udp_port = 9129 TOKEN_NUM_INITIALIZER(struct cmd_tunnel_udp_config, 9130 udp_port, UINT16); 9131 cmdline_parse_token_num_t cmd_tunnel_udp_config_port_id = 9132 TOKEN_NUM_INITIALIZER(struct cmd_tunnel_udp_config, 9133 port_id, UINT16); 9134 9135 cmdline_parse_inst_t cmd_tunnel_udp_config = { 9136 .f = cmd_tunnel_udp_config_parsed, 9137 .data = (void *)0, 9138 .help_str = "rx_vxlan_port add|rm <udp_port> <port_id>: " 9139 "Add/Remove a tunneling UDP port filter", 9140 .tokens = { 9141 (void *)&cmd_tunnel_udp_config_cmd, 9142 (void *)&cmd_tunnel_udp_config_what, 9143 (void *)&cmd_tunnel_udp_config_udp_port, 9144 (void *)&cmd_tunnel_udp_config_port_id, 9145 NULL, 9146 }, 9147 }; 9148 9149 struct cmd_config_tunnel_udp_port { 9150 cmdline_fixed_string_t port; 9151 cmdline_fixed_string_t config; 9152 portid_t port_id; 9153 cmdline_fixed_string_t udp_tunnel_port; 9154 cmdline_fixed_string_t action; 9155 cmdline_fixed_string_t tunnel_type; 9156 uint16_t udp_port; 9157 }; 9158 9159 static void 9160 cmd_cfg_tunnel_udp_port_parsed(void *parsed_result, 9161 __attribute__((unused)) struct cmdline *cl, 9162 __attribute__((unused)) void *data) 9163 { 9164 struct cmd_config_tunnel_udp_port *res = parsed_result; 9165 struct rte_eth_udp_tunnel tunnel_udp; 9166 int ret = 0; 9167 9168 if (port_id_is_invalid(res->port_id, ENABLED_WARN)) 9169 return; 9170 9171 tunnel_udp.udp_port = res->udp_port; 9172 9173 if (!strcmp(res->tunnel_type, "vxlan")) { 9174 tunnel_udp.prot_type = RTE_TUNNEL_TYPE_VXLAN; 9175 } else if (!strcmp(res->tunnel_type, "geneve")) { 9176 tunnel_udp.prot_type = RTE_TUNNEL_TYPE_GENEVE; 9177 } else if (!strcmp(res->tunnel_type, "vxlan-gpe")) { 9178 tunnel_udp.prot_type = RTE_TUNNEL_TYPE_VXLAN_GPE; 9179 } else { 9180 printf("Invalid tunnel type\n"); 9181 return; 9182 } 9183 9184 if (!strcmp(res->action, "add")) 9185 ret = rte_eth_dev_udp_tunnel_port_add(res->port_id, 9186 &tunnel_udp); 9187 else 9188 ret = rte_eth_dev_udp_tunnel_port_delete(res->port_id, 9189 &tunnel_udp); 9190 9191 if (ret < 0) 9192 printf("udp tunneling port add error: (%s)\n", strerror(-ret)); 9193 } 9194 9195 cmdline_parse_token_string_t cmd_config_tunnel_udp_port_port = 9196 TOKEN_STRING_INITIALIZER(struct cmd_config_tunnel_udp_port, port, 9197 "port"); 9198 cmdline_parse_token_string_t cmd_config_tunnel_udp_port_config = 9199 TOKEN_STRING_INITIALIZER(struct cmd_config_tunnel_udp_port, config, 9200 "config"); 9201 cmdline_parse_token_num_t cmd_config_tunnel_udp_port_port_id = 9202 TOKEN_NUM_INITIALIZER(struct cmd_config_tunnel_udp_port, port_id, 9203 UINT16); 9204 cmdline_parse_token_string_t cmd_config_tunnel_udp_port_tunnel_port = 9205 TOKEN_STRING_INITIALIZER(struct cmd_config_tunnel_udp_port, 9206 udp_tunnel_port, 9207 "udp_tunnel_port"); 9208 cmdline_parse_token_string_t cmd_config_tunnel_udp_port_action = 9209 TOKEN_STRING_INITIALIZER(struct cmd_config_tunnel_udp_port, action, 9210 "add#rm"); 9211 cmdline_parse_token_string_t cmd_config_tunnel_udp_port_tunnel_type = 9212 TOKEN_STRING_INITIALIZER(struct cmd_config_tunnel_udp_port, tunnel_type, 9213 "vxlan#geneve#vxlan-gpe"); 9214 cmdline_parse_token_num_t cmd_config_tunnel_udp_port_value = 9215 TOKEN_NUM_INITIALIZER(struct cmd_config_tunnel_udp_port, udp_port, 9216 UINT16); 9217 9218 cmdline_parse_inst_t cmd_cfg_tunnel_udp_port = { 9219 .f = cmd_cfg_tunnel_udp_port_parsed, 9220 .data = NULL, 9221 .help_str = "port config <port_id> udp_tunnel_port add|rm vxlan|geneve|vxlan-gpe <udp_port>", 9222 .tokens = { 9223 (void *)&cmd_config_tunnel_udp_port_port, 9224 (void *)&cmd_config_tunnel_udp_port_config, 9225 (void *)&cmd_config_tunnel_udp_port_port_id, 9226 (void *)&cmd_config_tunnel_udp_port_tunnel_port, 9227 (void *)&cmd_config_tunnel_udp_port_action, 9228 (void *)&cmd_config_tunnel_udp_port_tunnel_type, 9229 (void *)&cmd_config_tunnel_udp_port_value, 9230 NULL, 9231 }, 9232 }; 9233 9234 /* *** GLOBAL CONFIG *** */ 9235 struct cmd_global_config_result { 9236 cmdline_fixed_string_t cmd; 9237 portid_t port_id; 9238 cmdline_fixed_string_t cfg_type; 9239 uint8_t len; 9240 }; 9241 9242 static void 9243 cmd_global_config_parsed(void *parsed_result, 9244 __attribute__((unused)) struct cmdline *cl, 9245 __attribute__((unused)) void *data) 9246 { 9247 struct cmd_global_config_result *res = parsed_result; 9248 struct rte_eth_global_cfg conf; 9249 int ret; 9250 9251 memset(&conf, 0, sizeof(conf)); 9252 conf.cfg_type = RTE_ETH_GLOBAL_CFG_TYPE_GRE_KEY_LEN; 9253 conf.cfg.gre_key_len = res->len; 9254 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_NONE, 9255 RTE_ETH_FILTER_SET, &conf); 9256 if (ret != 0) 9257 printf("Global config error\n"); 9258 } 9259 9260 cmdline_parse_token_string_t cmd_global_config_cmd = 9261 TOKEN_STRING_INITIALIZER(struct cmd_global_config_result, cmd, 9262 "global_config"); 9263 cmdline_parse_token_num_t cmd_global_config_port_id = 9264 TOKEN_NUM_INITIALIZER(struct cmd_global_config_result, port_id, 9265 UINT16); 9266 cmdline_parse_token_string_t cmd_global_config_type = 9267 TOKEN_STRING_INITIALIZER(struct cmd_global_config_result, 9268 cfg_type, "gre-key-len"); 9269 cmdline_parse_token_num_t cmd_global_config_gre_key_len = 9270 TOKEN_NUM_INITIALIZER(struct cmd_global_config_result, 9271 len, UINT8); 9272 9273 cmdline_parse_inst_t cmd_global_config = { 9274 .f = cmd_global_config_parsed, 9275 .data = (void *)NULL, 9276 .help_str = "global_config <port_id> gre-key-len <key_len>", 9277 .tokens = { 9278 (void *)&cmd_global_config_cmd, 9279 (void *)&cmd_global_config_port_id, 9280 (void *)&cmd_global_config_type, 9281 (void *)&cmd_global_config_gre_key_len, 9282 NULL, 9283 }, 9284 }; 9285 9286 /* *** CONFIGURE VM MIRROR VLAN/POOL RULE *** */ 9287 struct cmd_set_mirror_mask_result { 9288 cmdline_fixed_string_t set; 9289 cmdline_fixed_string_t port; 9290 portid_t port_id; 9291 cmdline_fixed_string_t mirror; 9292 uint8_t rule_id; 9293 cmdline_fixed_string_t what; 9294 cmdline_fixed_string_t value; 9295 cmdline_fixed_string_t dstpool; 9296 uint8_t dstpool_id; 9297 cmdline_fixed_string_t on; 9298 }; 9299 9300 cmdline_parse_token_string_t cmd_mirror_mask_set = 9301 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result, 9302 set, "set"); 9303 cmdline_parse_token_string_t cmd_mirror_mask_port = 9304 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result, 9305 port, "port"); 9306 cmdline_parse_token_num_t cmd_mirror_mask_portid = 9307 TOKEN_NUM_INITIALIZER(struct cmd_set_mirror_mask_result, 9308 port_id, UINT16); 9309 cmdline_parse_token_string_t cmd_mirror_mask_mirror = 9310 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result, 9311 mirror, "mirror-rule"); 9312 cmdline_parse_token_num_t cmd_mirror_mask_ruleid = 9313 TOKEN_NUM_INITIALIZER(struct cmd_set_mirror_mask_result, 9314 rule_id, UINT8); 9315 cmdline_parse_token_string_t cmd_mirror_mask_what = 9316 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result, 9317 what, "pool-mirror-up#pool-mirror-down" 9318 "#vlan-mirror"); 9319 cmdline_parse_token_string_t cmd_mirror_mask_value = 9320 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result, 9321 value, NULL); 9322 cmdline_parse_token_string_t cmd_mirror_mask_dstpool = 9323 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result, 9324 dstpool, "dst-pool"); 9325 cmdline_parse_token_num_t cmd_mirror_mask_poolid = 9326 TOKEN_NUM_INITIALIZER(struct cmd_set_mirror_mask_result, 9327 dstpool_id, UINT8); 9328 cmdline_parse_token_string_t cmd_mirror_mask_on = 9329 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result, 9330 on, "on#off"); 9331 9332 static void 9333 cmd_set_mirror_mask_parsed(void *parsed_result, 9334 __attribute__((unused)) struct cmdline *cl, 9335 __attribute__((unused)) void *data) 9336 { 9337 int ret,nb_item,i; 9338 struct cmd_set_mirror_mask_result *res = parsed_result; 9339 struct rte_eth_mirror_conf mr_conf; 9340 9341 memset(&mr_conf, 0, sizeof(struct rte_eth_mirror_conf)); 9342 9343 unsigned int vlan_list[ETH_MIRROR_MAX_VLANS]; 9344 9345 mr_conf.dst_pool = res->dstpool_id; 9346 9347 if (!strcmp(res->what, "pool-mirror-up")) { 9348 mr_conf.pool_mask = strtoull(res->value, NULL, 16); 9349 mr_conf.rule_type = ETH_MIRROR_VIRTUAL_POOL_UP; 9350 } else if (!strcmp(res->what, "pool-mirror-down")) { 9351 mr_conf.pool_mask = strtoull(res->value, NULL, 16); 9352 mr_conf.rule_type = ETH_MIRROR_VIRTUAL_POOL_DOWN; 9353 } else if (!strcmp(res->what, "vlan-mirror")) { 9354 mr_conf.rule_type = ETH_MIRROR_VLAN; 9355 nb_item = parse_item_list(res->value, "vlan", 9356 ETH_MIRROR_MAX_VLANS, vlan_list, 1); 9357 if (nb_item <= 0) 9358 return; 9359 9360 for (i = 0; i < nb_item; i++) { 9361 if (vlan_list[i] > RTE_ETHER_MAX_VLAN_ID) { 9362 printf("Invalid vlan_id: must be < 4096\n"); 9363 return; 9364 } 9365 9366 mr_conf.vlan.vlan_id[i] = (uint16_t)vlan_list[i]; 9367 mr_conf.vlan.vlan_mask |= 1ULL << i; 9368 } 9369 } 9370 9371 if (!strcmp(res->on, "on")) 9372 ret = rte_eth_mirror_rule_set(res->port_id, &mr_conf, 9373 res->rule_id, 1); 9374 else 9375 ret = rte_eth_mirror_rule_set(res->port_id, &mr_conf, 9376 res->rule_id, 0); 9377 if (ret < 0) 9378 printf("mirror rule add error: (%s)\n", strerror(-ret)); 9379 } 9380 9381 cmdline_parse_inst_t cmd_set_mirror_mask = { 9382 .f = cmd_set_mirror_mask_parsed, 9383 .data = NULL, 9384 .help_str = "set port <port_id> mirror-rule <rule_id> " 9385 "pool-mirror-up|pool-mirror-down|vlan-mirror " 9386 "<pool_mask|vlan_id[,vlan_id]*> dst-pool <pool_id> on|off", 9387 .tokens = { 9388 (void *)&cmd_mirror_mask_set, 9389 (void *)&cmd_mirror_mask_port, 9390 (void *)&cmd_mirror_mask_portid, 9391 (void *)&cmd_mirror_mask_mirror, 9392 (void *)&cmd_mirror_mask_ruleid, 9393 (void *)&cmd_mirror_mask_what, 9394 (void *)&cmd_mirror_mask_value, 9395 (void *)&cmd_mirror_mask_dstpool, 9396 (void *)&cmd_mirror_mask_poolid, 9397 (void *)&cmd_mirror_mask_on, 9398 NULL, 9399 }, 9400 }; 9401 9402 /* *** CONFIGURE VM MIRROR UPLINK/DOWNLINK RULE *** */ 9403 struct cmd_set_mirror_link_result { 9404 cmdline_fixed_string_t set; 9405 cmdline_fixed_string_t port; 9406 portid_t port_id; 9407 cmdline_fixed_string_t mirror; 9408 uint8_t rule_id; 9409 cmdline_fixed_string_t what; 9410 cmdline_fixed_string_t dstpool; 9411 uint8_t dstpool_id; 9412 cmdline_fixed_string_t on; 9413 }; 9414 9415 cmdline_parse_token_string_t cmd_mirror_link_set = 9416 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_link_result, 9417 set, "set"); 9418 cmdline_parse_token_string_t cmd_mirror_link_port = 9419 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_link_result, 9420 port, "port"); 9421 cmdline_parse_token_num_t cmd_mirror_link_portid = 9422 TOKEN_NUM_INITIALIZER(struct cmd_set_mirror_link_result, 9423 port_id, UINT16); 9424 cmdline_parse_token_string_t cmd_mirror_link_mirror = 9425 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_link_result, 9426 mirror, "mirror-rule"); 9427 cmdline_parse_token_num_t cmd_mirror_link_ruleid = 9428 TOKEN_NUM_INITIALIZER(struct cmd_set_mirror_link_result, 9429 rule_id, UINT8); 9430 cmdline_parse_token_string_t cmd_mirror_link_what = 9431 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_link_result, 9432 what, "uplink-mirror#downlink-mirror"); 9433 cmdline_parse_token_string_t cmd_mirror_link_dstpool = 9434 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_link_result, 9435 dstpool, "dst-pool"); 9436 cmdline_parse_token_num_t cmd_mirror_link_poolid = 9437 TOKEN_NUM_INITIALIZER(struct cmd_set_mirror_link_result, 9438 dstpool_id, UINT8); 9439 cmdline_parse_token_string_t cmd_mirror_link_on = 9440 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_link_result, 9441 on, "on#off"); 9442 9443 static void 9444 cmd_set_mirror_link_parsed(void *parsed_result, 9445 __attribute__((unused)) struct cmdline *cl, 9446 __attribute__((unused)) void *data) 9447 { 9448 int ret; 9449 struct cmd_set_mirror_link_result *res = parsed_result; 9450 struct rte_eth_mirror_conf mr_conf; 9451 9452 memset(&mr_conf, 0, sizeof(struct rte_eth_mirror_conf)); 9453 if (!strcmp(res->what, "uplink-mirror")) 9454 mr_conf.rule_type = ETH_MIRROR_UPLINK_PORT; 9455 else 9456 mr_conf.rule_type = ETH_MIRROR_DOWNLINK_PORT; 9457 9458 mr_conf.dst_pool = res->dstpool_id; 9459 9460 if (!strcmp(res->on, "on")) 9461 ret = rte_eth_mirror_rule_set(res->port_id, &mr_conf, 9462 res->rule_id, 1); 9463 else 9464 ret = rte_eth_mirror_rule_set(res->port_id, &mr_conf, 9465 res->rule_id, 0); 9466 9467 /* check the return value and print it if is < 0 */ 9468 if (ret < 0) 9469 printf("mirror rule add error: (%s)\n", strerror(-ret)); 9470 9471 } 9472 9473 cmdline_parse_inst_t cmd_set_mirror_link = { 9474 .f = cmd_set_mirror_link_parsed, 9475 .data = NULL, 9476 .help_str = "set port <port_id> mirror-rule <rule_id> " 9477 "uplink-mirror|downlink-mirror dst-pool <pool_id> on|off", 9478 .tokens = { 9479 (void *)&cmd_mirror_link_set, 9480 (void *)&cmd_mirror_link_port, 9481 (void *)&cmd_mirror_link_portid, 9482 (void *)&cmd_mirror_link_mirror, 9483 (void *)&cmd_mirror_link_ruleid, 9484 (void *)&cmd_mirror_link_what, 9485 (void *)&cmd_mirror_link_dstpool, 9486 (void *)&cmd_mirror_link_poolid, 9487 (void *)&cmd_mirror_link_on, 9488 NULL, 9489 }, 9490 }; 9491 9492 /* *** RESET VM MIRROR RULE *** */ 9493 struct cmd_rm_mirror_rule_result { 9494 cmdline_fixed_string_t reset; 9495 cmdline_fixed_string_t port; 9496 portid_t port_id; 9497 cmdline_fixed_string_t mirror; 9498 uint8_t rule_id; 9499 }; 9500 9501 cmdline_parse_token_string_t cmd_rm_mirror_rule_reset = 9502 TOKEN_STRING_INITIALIZER(struct cmd_rm_mirror_rule_result, 9503 reset, "reset"); 9504 cmdline_parse_token_string_t cmd_rm_mirror_rule_port = 9505 TOKEN_STRING_INITIALIZER(struct cmd_rm_mirror_rule_result, 9506 port, "port"); 9507 cmdline_parse_token_num_t cmd_rm_mirror_rule_portid = 9508 TOKEN_NUM_INITIALIZER(struct cmd_rm_mirror_rule_result, 9509 port_id, UINT16); 9510 cmdline_parse_token_string_t cmd_rm_mirror_rule_mirror = 9511 TOKEN_STRING_INITIALIZER(struct cmd_rm_mirror_rule_result, 9512 mirror, "mirror-rule"); 9513 cmdline_parse_token_num_t cmd_rm_mirror_rule_ruleid = 9514 TOKEN_NUM_INITIALIZER(struct cmd_rm_mirror_rule_result, 9515 rule_id, UINT8); 9516 9517 static void 9518 cmd_reset_mirror_rule_parsed(void *parsed_result, 9519 __attribute__((unused)) struct cmdline *cl, 9520 __attribute__((unused)) void *data) 9521 { 9522 int ret; 9523 struct cmd_set_mirror_link_result *res = parsed_result; 9524 /* check rule_id */ 9525 ret = rte_eth_mirror_rule_reset(res->port_id,res->rule_id); 9526 if(ret < 0) 9527 printf("mirror rule remove error: (%s)\n", strerror(-ret)); 9528 } 9529 9530 cmdline_parse_inst_t cmd_reset_mirror_rule = { 9531 .f = cmd_reset_mirror_rule_parsed, 9532 .data = NULL, 9533 .help_str = "reset port <port_id> mirror-rule <rule_id>", 9534 .tokens = { 9535 (void *)&cmd_rm_mirror_rule_reset, 9536 (void *)&cmd_rm_mirror_rule_port, 9537 (void *)&cmd_rm_mirror_rule_portid, 9538 (void *)&cmd_rm_mirror_rule_mirror, 9539 (void *)&cmd_rm_mirror_rule_ruleid, 9540 NULL, 9541 }, 9542 }; 9543 9544 /* ******************************************************************************** */ 9545 9546 struct cmd_dump_result { 9547 cmdline_fixed_string_t dump; 9548 }; 9549 9550 static void 9551 dump_struct_sizes(void) 9552 { 9553 #define DUMP_SIZE(t) printf("sizeof(" #t ") = %u\n", (unsigned)sizeof(t)); 9554 DUMP_SIZE(struct rte_mbuf); 9555 DUMP_SIZE(struct rte_mempool); 9556 DUMP_SIZE(struct rte_ring); 9557 #undef DUMP_SIZE 9558 } 9559 9560 static void cmd_dump_parsed(void *parsed_result, 9561 __attribute__((unused)) struct cmdline *cl, 9562 __attribute__((unused)) void *data) 9563 { 9564 struct cmd_dump_result *res = parsed_result; 9565 9566 if (!strcmp(res->dump, "dump_physmem")) 9567 rte_dump_physmem_layout(stdout); 9568 else if (!strcmp(res->dump, "dump_memzone")) 9569 rte_memzone_dump(stdout); 9570 else if (!strcmp(res->dump, "dump_struct_sizes")) 9571 dump_struct_sizes(); 9572 else if (!strcmp(res->dump, "dump_ring")) 9573 rte_ring_list_dump(stdout); 9574 else if (!strcmp(res->dump, "dump_mempool")) 9575 rte_mempool_list_dump(stdout); 9576 else if (!strcmp(res->dump, "dump_devargs")) 9577 rte_devargs_dump(stdout); 9578 else if (!strcmp(res->dump, "dump_log_types")) 9579 rte_log_dump(stdout); 9580 } 9581 9582 cmdline_parse_token_string_t cmd_dump_dump = 9583 TOKEN_STRING_INITIALIZER(struct cmd_dump_result, dump, 9584 "dump_physmem#" 9585 "dump_memzone#" 9586 "dump_struct_sizes#" 9587 "dump_ring#" 9588 "dump_mempool#" 9589 "dump_devargs#" 9590 "dump_log_types"); 9591 9592 cmdline_parse_inst_t cmd_dump = { 9593 .f = cmd_dump_parsed, /* function to call */ 9594 .data = NULL, /* 2nd arg of func */ 9595 .help_str = "Dump status", 9596 .tokens = { /* token list, NULL terminated */ 9597 (void *)&cmd_dump_dump, 9598 NULL, 9599 }, 9600 }; 9601 9602 /* ******************************************************************************** */ 9603 9604 struct cmd_dump_one_result { 9605 cmdline_fixed_string_t dump; 9606 cmdline_fixed_string_t name; 9607 }; 9608 9609 static void cmd_dump_one_parsed(void *parsed_result, struct cmdline *cl, 9610 __attribute__((unused)) void *data) 9611 { 9612 struct cmd_dump_one_result *res = parsed_result; 9613 9614 if (!strcmp(res->dump, "dump_ring")) { 9615 struct rte_ring *r; 9616 r = rte_ring_lookup(res->name); 9617 if (r == NULL) { 9618 cmdline_printf(cl, "Cannot find ring\n"); 9619 return; 9620 } 9621 rte_ring_dump(stdout, r); 9622 } else if (!strcmp(res->dump, "dump_mempool")) { 9623 struct rte_mempool *mp; 9624 mp = rte_mempool_lookup(res->name); 9625 if (mp == NULL) { 9626 cmdline_printf(cl, "Cannot find mempool\n"); 9627 return; 9628 } 9629 rte_mempool_dump(stdout, mp); 9630 } 9631 } 9632 9633 cmdline_parse_token_string_t cmd_dump_one_dump = 9634 TOKEN_STRING_INITIALIZER(struct cmd_dump_one_result, dump, 9635 "dump_ring#dump_mempool"); 9636 9637 cmdline_parse_token_string_t cmd_dump_one_name = 9638 TOKEN_STRING_INITIALIZER(struct cmd_dump_one_result, name, NULL); 9639 9640 cmdline_parse_inst_t cmd_dump_one = { 9641 .f = cmd_dump_one_parsed, /* function to call */ 9642 .data = NULL, /* 2nd arg of func */ 9643 .help_str = "dump_ring|dump_mempool <name>: Dump one ring/mempool", 9644 .tokens = { /* token list, NULL terminated */ 9645 (void *)&cmd_dump_one_dump, 9646 (void *)&cmd_dump_one_name, 9647 NULL, 9648 }, 9649 }; 9650 9651 /* *** Add/Del syn filter *** */ 9652 struct cmd_syn_filter_result { 9653 cmdline_fixed_string_t filter; 9654 portid_t port_id; 9655 cmdline_fixed_string_t ops; 9656 cmdline_fixed_string_t priority; 9657 cmdline_fixed_string_t high; 9658 cmdline_fixed_string_t queue; 9659 uint16_t queue_id; 9660 }; 9661 9662 static void 9663 cmd_syn_filter_parsed(void *parsed_result, 9664 __attribute__((unused)) struct cmdline *cl, 9665 __attribute__((unused)) void *data) 9666 { 9667 struct cmd_syn_filter_result *res = parsed_result; 9668 struct rte_eth_syn_filter syn_filter; 9669 int ret = 0; 9670 9671 ret = rte_eth_dev_filter_supported(res->port_id, 9672 RTE_ETH_FILTER_SYN); 9673 if (ret < 0) { 9674 printf("syn filter is not supported on port %u.\n", 9675 res->port_id); 9676 return; 9677 } 9678 9679 memset(&syn_filter, 0, sizeof(syn_filter)); 9680 9681 if (!strcmp(res->ops, "add")) { 9682 if (!strcmp(res->high, "high")) 9683 syn_filter.hig_pri = 1; 9684 else 9685 syn_filter.hig_pri = 0; 9686 9687 syn_filter.queue = res->queue_id; 9688 ret = rte_eth_dev_filter_ctrl(res->port_id, 9689 RTE_ETH_FILTER_SYN, 9690 RTE_ETH_FILTER_ADD, 9691 &syn_filter); 9692 } else 9693 ret = rte_eth_dev_filter_ctrl(res->port_id, 9694 RTE_ETH_FILTER_SYN, 9695 RTE_ETH_FILTER_DELETE, 9696 &syn_filter); 9697 9698 if (ret < 0) 9699 printf("syn filter programming error: (%s)\n", 9700 strerror(-ret)); 9701 } 9702 9703 cmdline_parse_token_string_t cmd_syn_filter_filter = 9704 TOKEN_STRING_INITIALIZER(struct cmd_syn_filter_result, 9705 filter, "syn_filter"); 9706 cmdline_parse_token_num_t cmd_syn_filter_port_id = 9707 TOKEN_NUM_INITIALIZER(struct cmd_syn_filter_result, 9708 port_id, UINT16); 9709 cmdline_parse_token_string_t cmd_syn_filter_ops = 9710 TOKEN_STRING_INITIALIZER(struct cmd_syn_filter_result, 9711 ops, "add#del"); 9712 cmdline_parse_token_string_t cmd_syn_filter_priority = 9713 TOKEN_STRING_INITIALIZER(struct cmd_syn_filter_result, 9714 priority, "priority"); 9715 cmdline_parse_token_string_t cmd_syn_filter_high = 9716 TOKEN_STRING_INITIALIZER(struct cmd_syn_filter_result, 9717 high, "high#low"); 9718 cmdline_parse_token_string_t cmd_syn_filter_queue = 9719 TOKEN_STRING_INITIALIZER(struct cmd_syn_filter_result, 9720 queue, "queue"); 9721 cmdline_parse_token_num_t cmd_syn_filter_queue_id = 9722 TOKEN_NUM_INITIALIZER(struct cmd_syn_filter_result, 9723 queue_id, UINT16); 9724 9725 cmdline_parse_inst_t cmd_syn_filter = { 9726 .f = cmd_syn_filter_parsed, 9727 .data = NULL, 9728 .help_str = "syn_filter <port_id> add|del priority high|low queue " 9729 "<queue_id>: Add/Delete syn filter", 9730 .tokens = { 9731 (void *)&cmd_syn_filter_filter, 9732 (void *)&cmd_syn_filter_port_id, 9733 (void *)&cmd_syn_filter_ops, 9734 (void *)&cmd_syn_filter_priority, 9735 (void *)&cmd_syn_filter_high, 9736 (void *)&cmd_syn_filter_queue, 9737 (void *)&cmd_syn_filter_queue_id, 9738 NULL, 9739 }, 9740 }; 9741 9742 /* *** queue region set *** */ 9743 struct cmd_queue_region_result { 9744 cmdline_fixed_string_t set; 9745 cmdline_fixed_string_t port; 9746 portid_t port_id; 9747 cmdline_fixed_string_t cmd; 9748 cmdline_fixed_string_t region; 9749 uint8_t region_id; 9750 cmdline_fixed_string_t queue_start_index; 9751 uint8_t queue_id; 9752 cmdline_fixed_string_t queue_num; 9753 uint8_t queue_num_value; 9754 }; 9755 9756 static void 9757 cmd_queue_region_parsed(void *parsed_result, 9758 __attribute__((unused)) struct cmdline *cl, 9759 __attribute__((unused)) void *data) 9760 { 9761 struct cmd_queue_region_result *res = parsed_result; 9762 int ret = -ENOTSUP; 9763 #ifdef RTE_LIBRTE_I40E_PMD 9764 struct rte_pmd_i40e_queue_region_conf region_conf; 9765 enum rte_pmd_i40e_queue_region_op op_type; 9766 #endif 9767 9768 if (port_id_is_invalid(res->port_id, ENABLED_WARN)) 9769 return; 9770 9771 #ifdef RTE_LIBRTE_I40E_PMD 9772 memset(®ion_conf, 0, sizeof(region_conf)); 9773 op_type = RTE_PMD_I40E_RSS_QUEUE_REGION_SET; 9774 region_conf.region_id = res->region_id; 9775 region_conf.queue_num = res->queue_num_value; 9776 region_conf.queue_start_index = res->queue_id; 9777 9778 ret = rte_pmd_i40e_rss_queue_region_conf(res->port_id, 9779 op_type, ®ion_conf); 9780 #endif 9781 9782 switch (ret) { 9783 case 0: 9784 break; 9785 case -ENOTSUP: 9786 printf("function not implemented or supported\n"); 9787 break; 9788 default: 9789 printf("queue region config error: (%s)\n", strerror(-ret)); 9790 } 9791 } 9792 9793 cmdline_parse_token_string_t cmd_queue_region_set = 9794 TOKEN_STRING_INITIALIZER(struct cmd_queue_region_result, 9795 set, "set"); 9796 cmdline_parse_token_string_t cmd_queue_region_port = 9797 TOKEN_STRING_INITIALIZER(struct cmd_queue_region_result, port, "port"); 9798 cmdline_parse_token_num_t cmd_queue_region_port_id = 9799 TOKEN_NUM_INITIALIZER(struct cmd_queue_region_result, 9800 port_id, UINT16); 9801 cmdline_parse_token_string_t cmd_queue_region_cmd = 9802 TOKEN_STRING_INITIALIZER(struct cmd_queue_region_result, 9803 cmd, "queue-region"); 9804 cmdline_parse_token_string_t cmd_queue_region_id = 9805 TOKEN_STRING_INITIALIZER(struct cmd_queue_region_result, 9806 region, "region_id"); 9807 cmdline_parse_token_num_t cmd_queue_region_index = 9808 TOKEN_NUM_INITIALIZER(struct cmd_queue_region_result, 9809 region_id, UINT8); 9810 cmdline_parse_token_string_t cmd_queue_region_queue_start_index = 9811 TOKEN_STRING_INITIALIZER(struct cmd_queue_region_result, 9812 queue_start_index, "queue_start_index"); 9813 cmdline_parse_token_num_t cmd_queue_region_queue_id = 9814 TOKEN_NUM_INITIALIZER(struct cmd_queue_region_result, 9815 queue_id, UINT8); 9816 cmdline_parse_token_string_t cmd_queue_region_queue_num = 9817 TOKEN_STRING_INITIALIZER(struct cmd_queue_region_result, 9818 queue_num, "queue_num"); 9819 cmdline_parse_token_num_t cmd_queue_region_queue_num_value = 9820 TOKEN_NUM_INITIALIZER(struct cmd_queue_region_result, 9821 queue_num_value, UINT8); 9822 9823 cmdline_parse_inst_t cmd_queue_region = { 9824 .f = cmd_queue_region_parsed, 9825 .data = NULL, 9826 .help_str = "set port <port_id> queue-region region_id <value> " 9827 "queue_start_index <value> queue_num <value>: Set a queue region", 9828 .tokens = { 9829 (void *)&cmd_queue_region_set, 9830 (void *)&cmd_queue_region_port, 9831 (void *)&cmd_queue_region_port_id, 9832 (void *)&cmd_queue_region_cmd, 9833 (void *)&cmd_queue_region_id, 9834 (void *)&cmd_queue_region_index, 9835 (void *)&cmd_queue_region_queue_start_index, 9836 (void *)&cmd_queue_region_queue_id, 9837 (void *)&cmd_queue_region_queue_num, 9838 (void *)&cmd_queue_region_queue_num_value, 9839 NULL, 9840 }, 9841 }; 9842 9843 /* *** queue region and flowtype set *** */ 9844 struct cmd_region_flowtype_result { 9845 cmdline_fixed_string_t set; 9846 cmdline_fixed_string_t port; 9847 portid_t port_id; 9848 cmdline_fixed_string_t cmd; 9849 cmdline_fixed_string_t region; 9850 uint8_t region_id; 9851 cmdline_fixed_string_t flowtype; 9852 uint8_t flowtype_id; 9853 }; 9854 9855 static void 9856 cmd_region_flowtype_parsed(void *parsed_result, 9857 __attribute__((unused)) struct cmdline *cl, 9858 __attribute__((unused)) void *data) 9859 { 9860 struct cmd_region_flowtype_result *res = parsed_result; 9861 int ret = -ENOTSUP; 9862 #ifdef RTE_LIBRTE_I40E_PMD 9863 struct rte_pmd_i40e_queue_region_conf region_conf; 9864 enum rte_pmd_i40e_queue_region_op op_type; 9865 #endif 9866 9867 if (port_id_is_invalid(res->port_id, ENABLED_WARN)) 9868 return; 9869 9870 #ifdef RTE_LIBRTE_I40E_PMD 9871 memset(®ion_conf, 0, sizeof(region_conf)); 9872 9873 op_type = RTE_PMD_I40E_RSS_QUEUE_REGION_FLOWTYPE_SET; 9874 region_conf.region_id = res->region_id; 9875 region_conf.hw_flowtype = res->flowtype_id; 9876 9877 ret = rte_pmd_i40e_rss_queue_region_conf(res->port_id, 9878 op_type, ®ion_conf); 9879 #endif 9880 9881 switch (ret) { 9882 case 0: 9883 break; 9884 case -ENOTSUP: 9885 printf("function not implemented or supported\n"); 9886 break; 9887 default: 9888 printf("region flowtype config error: (%s)\n", strerror(-ret)); 9889 } 9890 } 9891 9892 cmdline_parse_token_string_t cmd_region_flowtype_set = 9893 TOKEN_STRING_INITIALIZER(struct cmd_region_flowtype_result, 9894 set, "set"); 9895 cmdline_parse_token_string_t cmd_region_flowtype_port = 9896 TOKEN_STRING_INITIALIZER(struct cmd_region_flowtype_result, 9897 port, "port"); 9898 cmdline_parse_token_num_t cmd_region_flowtype_port_index = 9899 TOKEN_NUM_INITIALIZER(struct cmd_region_flowtype_result, 9900 port_id, UINT16); 9901 cmdline_parse_token_string_t cmd_region_flowtype_cmd = 9902 TOKEN_STRING_INITIALIZER(struct cmd_region_flowtype_result, 9903 cmd, "queue-region"); 9904 cmdline_parse_token_string_t cmd_region_flowtype_index = 9905 TOKEN_STRING_INITIALIZER(struct cmd_region_flowtype_result, 9906 region, "region_id"); 9907 cmdline_parse_token_num_t cmd_region_flowtype_id = 9908 TOKEN_NUM_INITIALIZER(struct cmd_region_flowtype_result, 9909 region_id, UINT8); 9910 cmdline_parse_token_string_t cmd_region_flowtype_flow_index = 9911 TOKEN_STRING_INITIALIZER(struct cmd_region_flowtype_result, 9912 flowtype, "flowtype"); 9913 cmdline_parse_token_num_t cmd_region_flowtype_flow_id = 9914 TOKEN_NUM_INITIALIZER(struct cmd_region_flowtype_result, 9915 flowtype_id, UINT8); 9916 cmdline_parse_inst_t cmd_region_flowtype = { 9917 .f = cmd_region_flowtype_parsed, 9918 .data = NULL, 9919 .help_str = "set port <port_id> queue-region region_id <value> " 9920 "flowtype <value>: Set a flowtype region index", 9921 .tokens = { 9922 (void *)&cmd_region_flowtype_set, 9923 (void *)&cmd_region_flowtype_port, 9924 (void *)&cmd_region_flowtype_port_index, 9925 (void *)&cmd_region_flowtype_cmd, 9926 (void *)&cmd_region_flowtype_index, 9927 (void *)&cmd_region_flowtype_id, 9928 (void *)&cmd_region_flowtype_flow_index, 9929 (void *)&cmd_region_flowtype_flow_id, 9930 NULL, 9931 }, 9932 }; 9933 9934 /* *** User Priority (UP) to queue region (region_id) set *** */ 9935 struct cmd_user_priority_region_result { 9936 cmdline_fixed_string_t set; 9937 cmdline_fixed_string_t port; 9938 portid_t port_id; 9939 cmdline_fixed_string_t cmd; 9940 cmdline_fixed_string_t user_priority; 9941 uint8_t user_priority_id; 9942 cmdline_fixed_string_t region; 9943 uint8_t region_id; 9944 }; 9945 9946 static void 9947 cmd_user_priority_region_parsed(void *parsed_result, 9948 __attribute__((unused)) struct cmdline *cl, 9949 __attribute__((unused)) void *data) 9950 { 9951 struct cmd_user_priority_region_result *res = parsed_result; 9952 int ret = -ENOTSUP; 9953 #ifdef RTE_LIBRTE_I40E_PMD 9954 struct rte_pmd_i40e_queue_region_conf region_conf; 9955 enum rte_pmd_i40e_queue_region_op op_type; 9956 #endif 9957 9958 if (port_id_is_invalid(res->port_id, ENABLED_WARN)) 9959 return; 9960 9961 #ifdef RTE_LIBRTE_I40E_PMD 9962 memset(®ion_conf, 0, sizeof(region_conf)); 9963 op_type = RTE_PMD_I40E_RSS_QUEUE_REGION_USER_PRIORITY_SET; 9964 region_conf.user_priority = res->user_priority_id; 9965 region_conf.region_id = res->region_id; 9966 9967 ret = rte_pmd_i40e_rss_queue_region_conf(res->port_id, 9968 op_type, ®ion_conf); 9969 #endif 9970 9971 switch (ret) { 9972 case 0: 9973 break; 9974 case -ENOTSUP: 9975 printf("function not implemented or supported\n"); 9976 break; 9977 default: 9978 printf("user_priority region config error: (%s)\n", 9979 strerror(-ret)); 9980 } 9981 } 9982 9983 cmdline_parse_token_string_t cmd_user_priority_region_set = 9984 TOKEN_STRING_INITIALIZER(struct cmd_user_priority_region_result, 9985 set, "set"); 9986 cmdline_parse_token_string_t cmd_user_priority_region_port = 9987 TOKEN_STRING_INITIALIZER(struct cmd_user_priority_region_result, 9988 port, "port"); 9989 cmdline_parse_token_num_t cmd_user_priority_region_port_index = 9990 TOKEN_NUM_INITIALIZER(struct cmd_user_priority_region_result, 9991 port_id, UINT16); 9992 cmdline_parse_token_string_t cmd_user_priority_region_cmd = 9993 TOKEN_STRING_INITIALIZER(struct cmd_user_priority_region_result, 9994 cmd, "queue-region"); 9995 cmdline_parse_token_string_t cmd_user_priority_region_UP = 9996 TOKEN_STRING_INITIALIZER(struct cmd_user_priority_region_result, 9997 user_priority, "UP"); 9998 cmdline_parse_token_num_t cmd_user_priority_region_UP_id = 9999 TOKEN_NUM_INITIALIZER(struct cmd_user_priority_region_result, 10000 user_priority_id, UINT8); 10001 cmdline_parse_token_string_t cmd_user_priority_region_region = 10002 TOKEN_STRING_INITIALIZER(struct cmd_user_priority_region_result, 10003 region, "region_id"); 10004 cmdline_parse_token_num_t cmd_user_priority_region_region_id = 10005 TOKEN_NUM_INITIALIZER(struct cmd_user_priority_region_result, 10006 region_id, UINT8); 10007 10008 cmdline_parse_inst_t cmd_user_priority_region = { 10009 .f = cmd_user_priority_region_parsed, 10010 .data = NULL, 10011 .help_str = "set port <port_id> queue-region UP <value> " 10012 "region_id <value>: Set the mapping of User Priority (UP) " 10013 "to queue region (region_id) ", 10014 .tokens = { 10015 (void *)&cmd_user_priority_region_set, 10016 (void *)&cmd_user_priority_region_port, 10017 (void *)&cmd_user_priority_region_port_index, 10018 (void *)&cmd_user_priority_region_cmd, 10019 (void *)&cmd_user_priority_region_UP, 10020 (void *)&cmd_user_priority_region_UP_id, 10021 (void *)&cmd_user_priority_region_region, 10022 (void *)&cmd_user_priority_region_region_id, 10023 NULL, 10024 }, 10025 }; 10026 10027 /* *** flush all queue region related configuration *** */ 10028 struct cmd_flush_queue_region_result { 10029 cmdline_fixed_string_t set; 10030 cmdline_fixed_string_t port; 10031 portid_t port_id; 10032 cmdline_fixed_string_t cmd; 10033 cmdline_fixed_string_t flush; 10034 cmdline_fixed_string_t what; 10035 }; 10036 10037 static void 10038 cmd_flush_queue_region_parsed(void *parsed_result, 10039 __attribute__((unused)) struct cmdline *cl, 10040 __attribute__((unused)) void *data) 10041 { 10042 struct cmd_flush_queue_region_result *res = parsed_result; 10043 int ret = -ENOTSUP; 10044 #ifdef RTE_LIBRTE_I40E_PMD 10045 struct rte_pmd_i40e_queue_region_conf region_conf; 10046 enum rte_pmd_i40e_queue_region_op op_type; 10047 #endif 10048 10049 if (port_id_is_invalid(res->port_id, ENABLED_WARN)) 10050 return; 10051 10052 #ifdef RTE_LIBRTE_I40E_PMD 10053 memset(®ion_conf, 0, sizeof(region_conf)); 10054 10055 if (strcmp(res->what, "on") == 0) 10056 op_type = RTE_PMD_I40E_RSS_QUEUE_REGION_ALL_FLUSH_ON; 10057 else 10058 op_type = RTE_PMD_I40E_RSS_QUEUE_REGION_ALL_FLUSH_OFF; 10059 10060 ret = rte_pmd_i40e_rss_queue_region_conf(res->port_id, 10061 op_type, ®ion_conf); 10062 #endif 10063 10064 switch (ret) { 10065 case 0: 10066 break; 10067 case -ENOTSUP: 10068 printf("function not implemented or supported\n"); 10069 break; 10070 default: 10071 printf("queue region config flush error: (%s)\n", 10072 strerror(-ret)); 10073 } 10074 } 10075 10076 cmdline_parse_token_string_t cmd_flush_queue_region_set = 10077 TOKEN_STRING_INITIALIZER(struct cmd_flush_queue_region_result, 10078 set, "set"); 10079 cmdline_parse_token_string_t cmd_flush_queue_region_port = 10080 TOKEN_STRING_INITIALIZER(struct cmd_flush_queue_region_result, 10081 port, "port"); 10082 cmdline_parse_token_num_t cmd_flush_queue_region_port_index = 10083 TOKEN_NUM_INITIALIZER(struct cmd_flush_queue_region_result, 10084 port_id, UINT16); 10085 cmdline_parse_token_string_t cmd_flush_queue_region_cmd = 10086 TOKEN_STRING_INITIALIZER(struct cmd_flush_queue_region_result, 10087 cmd, "queue-region"); 10088 cmdline_parse_token_string_t cmd_flush_queue_region_flush = 10089 TOKEN_STRING_INITIALIZER(struct cmd_flush_queue_region_result, 10090 flush, "flush"); 10091 cmdline_parse_token_string_t cmd_flush_queue_region_what = 10092 TOKEN_STRING_INITIALIZER(struct cmd_flush_queue_region_result, 10093 what, "on#off"); 10094 10095 cmdline_parse_inst_t cmd_flush_queue_region = { 10096 .f = cmd_flush_queue_region_parsed, 10097 .data = NULL, 10098 .help_str = "set port <port_id> queue-region flush on|off" 10099 ": flush all queue region related configuration", 10100 .tokens = { 10101 (void *)&cmd_flush_queue_region_set, 10102 (void *)&cmd_flush_queue_region_port, 10103 (void *)&cmd_flush_queue_region_port_index, 10104 (void *)&cmd_flush_queue_region_cmd, 10105 (void *)&cmd_flush_queue_region_flush, 10106 (void *)&cmd_flush_queue_region_what, 10107 NULL, 10108 }, 10109 }; 10110 10111 /* *** get all queue region related configuration info *** */ 10112 struct cmd_show_queue_region_info { 10113 cmdline_fixed_string_t show; 10114 cmdline_fixed_string_t port; 10115 portid_t port_id; 10116 cmdline_fixed_string_t cmd; 10117 }; 10118 10119 static void 10120 cmd_show_queue_region_info_parsed(void *parsed_result, 10121 __attribute__((unused)) struct cmdline *cl, 10122 __attribute__((unused)) void *data) 10123 { 10124 struct cmd_show_queue_region_info *res = parsed_result; 10125 int ret = -ENOTSUP; 10126 #ifdef RTE_LIBRTE_I40E_PMD 10127 struct rte_pmd_i40e_queue_regions rte_pmd_regions; 10128 enum rte_pmd_i40e_queue_region_op op_type; 10129 #endif 10130 10131 if (port_id_is_invalid(res->port_id, ENABLED_WARN)) 10132 return; 10133 10134 #ifdef RTE_LIBRTE_I40E_PMD 10135 memset(&rte_pmd_regions, 0, sizeof(rte_pmd_regions)); 10136 10137 op_type = RTE_PMD_I40E_RSS_QUEUE_REGION_INFO_GET; 10138 10139 ret = rte_pmd_i40e_rss_queue_region_conf(res->port_id, 10140 op_type, &rte_pmd_regions); 10141 10142 port_queue_region_info_display(res->port_id, &rte_pmd_regions); 10143 #endif 10144 10145 switch (ret) { 10146 case 0: 10147 break; 10148 case -ENOTSUP: 10149 printf("function not implemented or supported\n"); 10150 break; 10151 default: 10152 printf("queue region config info show error: (%s)\n", 10153 strerror(-ret)); 10154 } 10155 } 10156 10157 cmdline_parse_token_string_t cmd_show_queue_region_info_get = 10158 TOKEN_STRING_INITIALIZER(struct cmd_show_queue_region_info, 10159 show, "show"); 10160 cmdline_parse_token_string_t cmd_show_queue_region_info_port = 10161 TOKEN_STRING_INITIALIZER(struct cmd_show_queue_region_info, 10162 port, "port"); 10163 cmdline_parse_token_num_t cmd_show_queue_region_info_port_index = 10164 TOKEN_NUM_INITIALIZER(struct cmd_show_queue_region_info, 10165 port_id, UINT16); 10166 cmdline_parse_token_string_t cmd_show_queue_region_info_cmd = 10167 TOKEN_STRING_INITIALIZER(struct cmd_show_queue_region_info, 10168 cmd, "queue-region"); 10169 10170 cmdline_parse_inst_t cmd_show_queue_region_info_all = { 10171 .f = cmd_show_queue_region_info_parsed, 10172 .data = NULL, 10173 .help_str = "show port <port_id> queue-region" 10174 ": show all queue region related configuration info", 10175 .tokens = { 10176 (void *)&cmd_show_queue_region_info_get, 10177 (void *)&cmd_show_queue_region_info_port, 10178 (void *)&cmd_show_queue_region_info_port_index, 10179 (void *)&cmd_show_queue_region_info_cmd, 10180 NULL, 10181 }, 10182 }; 10183 10184 /* *** ADD/REMOVE A 2tuple FILTER *** */ 10185 struct cmd_2tuple_filter_result { 10186 cmdline_fixed_string_t filter; 10187 portid_t port_id; 10188 cmdline_fixed_string_t ops; 10189 cmdline_fixed_string_t dst_port; 10190 uint16_t dst_port_value; 10191 cmdline_fixed_string_t protocol; 10192 uint8_t protocol_value; 10193 cmdline_fixed_string_t mask; 10194 uint8_t mask_value; 10195 cmdline_fixed_string_t tcp_flags; 10196 uint8_t tcp_flags_value; 10197 cmdline_fixed_string_t priority; 10198 uint8_t priority_value; 10199 cmdline_fixed_string_t queue; 10200 uint16_t queue_id; 10201 }; 10202 10203 static void 10204 cmd_2tuple_filter_parsed(void *parsed_result, 10205 __attribute__((unused)) struct cmdline *cl, 10206 __attribute__((unused)) void *data) 10207 { 10208 struct rte_eth_ntuple_filter filter; 10209 struct cmd_2tuple_filter_result *res = parsed_result; 10210 int ret = 0; 10211 10212 ret = rte_eth_dev_filter_supported(res->port_id, RTE_ETH_FILTER_NTUPLE); 10213 if (ret < 0) { 10214 printf("ntuple filter is not supported on port %u.\n", 10215 res->port_id); 10216 return; 10217 } 10218 10219 memset(&filter, 0, sizeof(struct rte_eth_ntuple_filter)); 10220 10221 filter.flags = RTE_2TUPLE_FLAGS; 10222 filter.dst_port_mask = (res->mask_value & 0x02) ? UINT16_MAX : 0; 10223 filter.proto_mask = (res->mask_value & 0x01) ? UINT8_MAX : 0; 10224 filter.proto = res->protocol_value; 10225 filter.priority = res->priority_value; 10226 if (res->tcp_flags_value != 0 && filter.proto != IPPROTO_TCP) { 10227 printf("nonzero tcp_flags is only meaningful" 10228 " when protocol is TCP.\n"); 10229 return; 10230 } 10231 if (res->tcp_flags_value > RTE_NTUPLE_TCP_FLAGS_MASK) { 10232 printf("invalid TCP flags.\n"); 10233 return; 10234 } 10235 10236 if (res->tcp_flags_value != 0) { 10237 filter.flags |= RTE_NTUPLE_FLAGS_TCP_FLAG; 10238 filter.tcp_flags = res->tcp_flags_value; 10239 } 10240 10241 /* need convert to big endian. */ 10242 filter.dst_port = rte_cpu_to_be_16(res->dst_port_value); 10243 filter.queue = res->queue_id; 10244 10245 if (!strcmp(res->ops, "add")) 10246 ret = rte_eth_dev_filter_ctrl(res->port_id, 10247 RTE_ETH_FILTER_NTUPLE, 10248 RTE_ETH_FILTER_ADD, 10249 &filter); 10250 else 10251 ret = rte_eth_dev_filter_ctrl(res->port_id, 10252 RTE_ETH_FILTER_NTUPLE, 10253 RTE_ETH_FILTER_DELETE, 10254 &filter); 10255 if (ret < 0) 10256 printf("2tuple filter programming error: (%s)\n", 10257 strerror(-ret)); 10258 10259 } 10260 10261 cmdline_parse_token_string_t cmd_2tuple_filter_filter = 10262 TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result, 10263 filter, "2tuple_filter"); 10264 cmdline_parse_token_num_t cmd_2tuple_filter_port_id = 10265 TOKEN_NUM_INITIALIZER(struct cmd_2tuple_filter_result, 10266 port_id, UINT16); 10267 cmdline_parse_token_string_t cmd_2tuple_filter_ops = 10268 TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result, 10269 ops, "add#del"); 10270 cmdline_parse_token_string_t cmd_2tuple_filter_dst_port = 10271 TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result, 10272 dst_port, "dst_port"); 10273 cmdline_parse_token_num_t cmd_2tuple_filter_dst_port_value = 10274 TOKEN_NUM_INITIALIZER(struct cmd_2tuple_filter_result, 10275 dst_port_value, UINT16); 10276 cmdline_parse_token_string_t cmd_2tuple_filter_protocol = 10277 TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result, 10278 protocol, "protocol"); 10279 cmdline_parse_token_num_t cmd_2tuple_filter_protocol_value = 10280 TOKEN_NUM_INITIALIZER(struct cmd_2tuple_filter_result, 10281 protocol_value, UINT8); 10282 cmdline_parse_token_string_t cmd_2tuple_filter_mask = 10283 TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result, 10284 mask, "mask"); 10285 cmdline_parse_token_num_t cmd_2tuple_filter_mask_value = 10286 TOKEN_NUM_INITIALIZER(struct cmd_2tuple_filter_result, 10287 mask_value, INT8); 10288 cmdline_parse_token_string_t cmd_2tuple_filter_tcp_flags = 10289 TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result, 10290 tcp_flags, "tcp_flags"); 10291 cmdline_parse_token_num_t cmd_2tuple_filter_tcp_flags_value = 10292 TOKEN_NUM_INITIALIZER(struct cmd_2tuple_filter_result, 10293 tcp_flags_value, UINT8); 10294 cmdline_parse_token_string_t cmd_2tuple_filter_priority = 10295 TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result, 10296 priority, "priority"); 10297 cmdline_parse_token_num_t cmd_2tuple_filter_priority_value = 10298 TOKEN_NUM_INITIALIZER(struct cmd_2tuple_filter_result, 10299 priority_value, UINT8); 10300 cmdline_parse_token_string_t cmd_2tuple_filter_queue = 10301 TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result, 10302 queue, "queue"); 10303 cmdline_parse_token_num_t cmd_2tuple_filter_queue_id = 10304 TOKEN_NUM_INITIALIZER(struct cmd_2tuple_filter_result, 10305 queue_id, UINT16); 10306 10307 cmdline_parse_inst_t cmd_2tuple_filter = { 10308 .f = cmd_2tuple_filter_parsed, 10309 .data = NULL, 10310 .help_str = "2tuple_filter <port_id> add|del dst_port <value> protocol " 10311 "<value> mask <value> tcp_flags <value> priority <value> queue " 10312 "<queue_id>: Add a 2tuple filter", 10313 .tokens = { 10314 (void *)&cmd_2tuple_filter_filter, 10315 (void *)&cmd_2tuple_filter_port_id, 10316 (void *)&cmd_2tuple_filter_ops, 10317 (void *)&cmd_2tuple_filter_dst_port, 10318 (void *)&cmd_2tuple_filter_dst_port_value, 10319 (void *)&cmd_2tuple_filter_protocol, 10320 (void *)&cmd_2tuple_filter_protocol_value, 10321 (void *)&cmd_2tuple_filter_mask, 10322 (void *)&cmd_2tuple_filter_mask_value, 10323 (void *)&cmd_2tuple_filter_tcp_flags, 10324 (void *)&cmd_2tuple_filter_tcp_flags_value, 10325 (void *)&cmd_2tuple_filter_priority, 10326 (void *)&cmd_2tuple_filter_priority_value, 10327 (void *)&cmd_2tuple_filter_queue, 10328 (void *)&cmd_2tuple_filter_queue_id, 10329 NULL, 10330 }, 10331 }; 10332 10333 /* *** ADD/REMOVE A 5tuple FILTER *** */ 10334 struct cmd_5tuple_filter_result { 10335 cmdline_fixed_string_t filter; 10336 portid_t port_id; 10337 cmdline_fixed_string_t ops; 10338 cmdline_fixed_string_t dst_ip; 10339 cmdline_ipaddr_t dst_ip_value; 10340 cmdline_fixed_string_t src_ip; 10341 cmdline_ipaddr_t src_ip_value; 10342 cmdline_fixed_string_t dst_port; 10343 uint16_t dst_port_value; 10344 cmdline_fixed_string_t src_port; 10345 uint16_t src_port_value; 10346 cmdline_fixed_string_t protocol; 10347 uint8_t protocol_value; 10348 cmdline_fixed_string_t mask; 10349 uint8_t mask_value; 10350 cmdline_fixed_string_t tcp_flags; 10351 uint8_t tcp_flags_value; 10352 cmdline_fixed_string_t priority; 10353 uint8_t priority_value; 10354 cmdline_fixed_string_t queue; 10355 uint16_t queue_id; 10356 }; 10357 10358 static void 10359 cmd_5tuple_filter_parsed(void *parsed_result, 10360 __attribute__((unused)) struct cmdline *cl, 10361 __attribute__((unused)) void *data) 10362 { 10363 struct rte_eth_ntuple_filter filter; 10364 struct cmd_5tuple_filter_result *res = parsed_result; 10365 int ret = 0; 10366 10367 ret = rte_eth_dev_filter_supported(res->port_id, RTE_ETH_FILTER_NTUPLE); 10368 if (ret < 0) { 10369 printf("ntuple filter is not supported on port %u.\n", 10370 res->port_id); 10371 return; 10372 } 10373 10374 memset(&filter, 0, sizeof(struct rte_eth_ntuple_filter)); 10375 10376 filter.flags = RTE_5TUPLE_FLAGS; 10377 filter.dst_ip_mask = (res->mask_value & 0x10) ? UINT32_MAX : 0; 10378 filter.src_ip_mask = (res->mask_value & 0x08) ? UINT32_MAX : 0; 10379 filter.dst_port_mask = (res->mask_value & 0x04) ? UINT16_MAX : 0; 10380 filter.src_port_mask = (res->mask_value & 0x02) ? UINT16_MAX : 0; 10381 filter.proto_mask = (res->mask_value & 0x01) ? UINT8_MAX : 0; 10382 filter.proto = res->protocol_value; 10383 filter.priority = res->priority_value; 10384 if (res->tcp_flags_value != 0 && filter.proto != IPPROTO_TCP) { 10385 printf("nonzero tcp_flags is only meaningful" 10386 " when protocol is TCP.\n"); 10387 return; 10388 } 10389 if (res->tcp_flags_value > RTE_NTUPLE_TCP_FLAGS_MASK) { 10390 printf("invalid TCP flags.\n"); 10391 return; 10392 } 10393 10394 if (res->tcp_flags_value != 0) { 10395 filter.flags |= RTE_NTUPLE_FLAGS_TCP_FLAG; 10396 filter.tcp_flags = res->tcp_flags_value; 10397 } 10398 10399 if (res->dst_ip_value.family == AF_INET) 10400 /* no need to convert, already big endian. */ 10401 filter.dst_ip = res->dst_ip_value.addr.ipv4.s_addr; 10402 else { 10403 if (filter.dst_ip_mask == 0) { 10404 printf("can not support ipv6 involved compare.\n"); 10405 return; 10406 } 10407 filter.dst_ip = 0; 10408 } 10409 10410 if (res->src_ip_value.family == AF_INET) 10411 /* no need to convert, already big endian. */ 10412 filter.src_ip = res->src_ip_value.addr.ipv4.s_addr; 10413 else { 10414 if (filter.src_ip_mask == 0) { 10415 printf("can not support ipv6 involved compare.\n"); 10416 return; 10417 } 10418 filter.src_ip = 0; 10419 } 10420 /* need convert to big endian. */ 10421 filter.dst_port = rte_cpu_to_be_16(res->dst_port_value); 10422 filter.src_port = rte_cpu_to_be_16(res->src_port_value); 10423 filter.queue = res->queue_id; 10424 10425 if (!strcmp(res->ops, "add")) 10426 ret = rte_eth_dev_filter_ctrl(res->port_id, 10427 RTE_ETH_FILTER_NTUPLE, 10428 RTE_ETH_FILTER_ADD, 10429 &filter); 10430 else 10431 ret = rte_eth_dev_filter_ctrl(res->port_id, 10432 RTE_ETH_FILTER_NTUPLE, 10433 RTE_ETH_FILTER_DELETE, 10434 &filter); 10435 if (ret < 0) 10436 printf("5tuple filter programming error: (%s)\n", 10437 strerror(-ret)); 10438 } 10439 10440 cmdline_parse_token_string_t cmd_5tuple_filter_filter = 10441 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result, 10442 filter, "5tuple_filter"); 10443 cmdline_parse_token_num_t cmd_5tuple_filter_port_id = 10444 TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result, 10445 port_id, UINT16); 10446 cmdline_parse_token_string_t cmd_5tuple_filter_ops = 10447 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result, 10448 ops, "add#del"); 10449 cmdline_parse_token_string_t cmd_5tuple_filter_dst_ip = 10450 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result, 10451 dst_ip, "dst_ip"); 10452 cmdline_parse_token_ipaddr_t cmd_5tuple_filter_dst_ip_value = 10453 TOKEN_IPADDR_INITIALIZER(struct cmd_5tuple_filter_result, 10454 dst_ip_value); 10455 cmdline_parse_token_string_t cmd_5tuple_filter_src_ip = 10456 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result, 10457 src_ip, "src_ip"); 10458 cmdline_parse_token_ipaddr_t cmd_5tuple_filter_src_ip_value = 10459 TOKEN_IPADDR_INITIALIZER(struct cmd_5tuple_filter_result, 10460 src_ip_value); 10461 cmdline_parse_token_string_t cmd_5tuple_filter_dst_port = 10462 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result, 10463 dst_port, "dst_port"); 10464 cmdline_parse_token_num_t cmd_5tuple_filter_dst_port_value = 10465 TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result, 10466 dst_port_value, UINT16); 10467 cmdline_parse_token_string_t cmd_5tuple_filter_src_port = 10468 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result, 10469 src_port, "src_port"); 10470 cmdline_parse_token_num_t cmd_5tuple_filter_src_port_value = 10471 TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result, 10472 src_port_value, UINT16); 10473 cmdline_parse_token_string_t cmd_5tuple_filter_protocol = 10474 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result, 10475 protocol, "protocol"); 10476 cmdline_parse_token_num_t cmd_5tuple_filter_protocol_value = 10477 TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result, 10478 protocol_value, UINT8); 10479 cmdline_parse_token_string_t cmd_5tuple_filter_mask = 10480 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result, 10481 mask, "mask"); 10482 cmdline_parse_token_num_t cmd_5tuple_filter_mask_value = 10483 TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result, 10484 mask_value, INT8); 10485 cmdline_parse_token_string_t cmd_5tuple_filter_tcp_flags = 10486 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result, 10487 tcp_flags, "tcp_flags"); 10488 cmdline_parse_token_num_t cmd_5tuple_filter_tcp_flags_value = 10489 TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result, 10490 tcp_flags_value, UINT8); 10491 cmdline_parse_token_string_t cmd_5tuple_filter_priority = 10492 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result, 10493 priority, "priority"); 10494 cmdline_parse_token_num_t cmd_5tuple_filter_priority_value = 10495 TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result, 10496 priority_value, UINT8); 10497 cmdline_parse_token_string_t cmd_5tuple_filter_queue = 10498 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result, 10499 queue, "queue"); 10500 cmdline_parse_token_num_t cmd_5tuple_filter_queue_id = 10501 TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result, 10502 queue_id, UINT16); 10503 10504 cmdline_parse_inst_t cmd_5tuple_filter = { 10505 .f = cmd_5tuple_filter_parsed, 10506 .data = NULL, 10507 .help_str = "5tuple_filter <port_id> add|del dst_ip <value> " 10508 "src_ip <value> dst_port <value> src_port <value> " 10509 "protocol <value> mask <value> tcp_flags <value> " 10510 "priority <value> queue <queue_id>: Add/Del a 5tuple filter", 10511 .tokens = { 10512 (void *)&cmd_5tuple_filter_filter, 10513 (void *)&cmd_5tuple_filter_port_id, 10514 (void *)&cmd_5tuple_filter_ops, 10515 (void *)&cmd_5tuple_filter_dst_ip, 10516 (void *)&cmd_5tuple_filter_dst_ip_value, 10517 (void *)&cmd_5tuple_filter_src_ip, 10518 (void *)&cmd_5tuple_filter_src_ip_value, 10519 (void *)&cmd_5tuple_filter_dst_port, 10520 (void *)&cmd_5tuple_filter_dst_port_value, 10521 (void *)&cmd_5tuple_filter_src_port, 10522 (void *)&cmd_5tuple_filter_src_port_value, 10523 (void *)&cmd_5tuple_filter_protocol, 10524 (void *)&cmd_5tuple_filter_protocol_value, 10525 (void *)&cmd_5tuple_filter_mask, 10526 (void *)&cmd_5tuple_filter_mask_value, 10527 (void *)&cmd_5tuple_filter_tcp_flags, 10528 (void *)&cmd_5tuple_filter_tcp_flags_value, 10529 (void *)&cmd_5tuple_filter_priority, 10530 (void *)&cmd_5tuple_filter_priority_value, 10531 (void *)&cmd_5tuple_filter_queue, 10532 (void *)&cmd_5tuple_filter_queue_id, 10533 NULL, 10534 }, 10535 }; 10536 10537 /* *** ADD/REMOVE A flex FILTER *** */ 10538 struct cmd_flex_filter_result { 10539 cmdline_fixed_string_t filter; 10540 cmdline_fixed_string_t ops; 10541 portid_t port_id; 10542 cmdline_fixed_string_t len; 10543 uint8_t len_value; 10544 cmdline_fixed_string_t bytes; 10545 cmdline_fixed_string_t bytes_value; 10546 cmdline_fixed_string_t mask; 10547 cmdline_fixed_string_t mask_value; 10548 cmdline_fixed_string_t priority; 10549 uint8_t priority_value; 10550 cmdline_fixed_string_t queue; 10551 uint16_t queue_id; 10552 }; 10553 10554 static int xdigit2val(unsigned char c) 10555 { 10556 int val; 10557 if (isdigit(c)) 10558 val = c - '0'; 10559 else if (isupper(c)) 10560 val = c - 'A' + 10; 10561 else 10562 val = c - 'a' + 10; 10563 return val; 10564 } 10565 10566 static void 10567 cmd_flex_filter_parsed(void *parsed_result, 10568 __attribute__((unused)) struct cmdline *cl, 10569 __attribute__((unused)) void *data) 10570 { 10571 int ret = 0; 10572 struct rte_eth_flex_filter filter; 10573 struct cmd_flex_filter_result *res = parsed_result; 10574 char *bytes_ptr, *mask_ptr; 10575 uint16_t len, i, j = 0; 10576 char c; 10577 int val; 10578 uint8_t byte = 0; 10579 10580 if (res->len_value > RTE_FLEX_FILTER_MAXLEN) { 10581 printf("the len exceed the max length 128\n"); 10582 return; 10583 } 10584 memset(&filter, 0, sizeof(struct rte_eth_flex_filter)); 10585 filter.len = res->len_value; 10586 filter.priority = res->priority_value; 10587 filter.queue = res->queue_id; 10588 bytes_ptr = res->bytes_value; 10589 mask_ptr = res->mask_value; 10590 10591 /* translate bytes string to array. */ 10592 if (bytes_ptr[0] == '0' && ((bytes_ptr[1] == 'x') || 10593 (bytes_ptr[1] == 'X'))) 10594 bytes_ptr += 2; 10595 len = strnlen(bytes_ptr, res->len_value * 2); 10596 if (len == 0 || (len % 8 != 0)) { 10597 printf("please check len and bytes input\n"); 10598 return; 10599 } 10600 for (i = 0; i < len; i++) { 10601 c = bytes_ptr[i]; 10602 if (isxdigit(c) == 0) { 10603 /* invalid characters. */ 10604 printf("invalid input\n"); 10605 return; 10606 } 10607 val = xdigit2val(c); 10608 if (i % 2) { 10609 byte |= val; 10610 filter.bytes[j] = byte; 10611 printf("bytes[%d]:%02x ", j, filter.bytes[j]); 10612 j++; 10613 byte = 0; 10614 } else 10615 byte |= val << 4; 10616 } 10617 printf("\n"); 10618 /* translate mask string to uint8_t array. */ 10619 if (mask_ptr[0] == '0' && ((mask_ptr[1] == 'x') || 10620 (mask_ptr[1] == 'X'))) 10621 mask_ptr += 2; 10622 len = strnlen(mask_ptr, (res->len_value + 3) / 4); 10623 if (len == 0) { 10624 printf("invalid input\n"); 10625 return; 10626 } 10627 j = 0; 10628 byte = 0; 10629 for (i = 0; i < len; i++) { 10630 c = mask_ptr[i]; 10631 if (isxdigit(c) == 0) { 10632 /* invalid characters. */ 10633 printf("invalid input\n"); 10634 return; 10635 } 10636 val = xdigit2val(c); 10637 if (i % 2) { 10638 byte |= val; 10639 filter.mask[j] = byte; 10640 printf("mask[%d]:%02x ", j, filter.mask[j]); 10641 j++; 10642 byte = 0; 10643 } else 10644 byte |= val << 4; 10645 } 10646 printf("\n"); 10647 10648 if (!strcmp(res->ops, "add")) 10649 ret = rte_eth_dev_filter_ctrl(res->port_id, 10650 RTE_ETH_FILTER_FLEXIBLE, 10651 RTE_ETH_FILTER_ADD, 10652 &filter); 10653 else 10654 ret = rte_eth_dev_filter_ctrl(res->port_id, 10655 RTE_ETH_FILTER_FLEXIBLE, 10656 RTE_ETH_FILTER_DELETE, 10657 &filter); 10658 10659 if (ret < 0) 10660 printf("flex filter setting error: (%s)\n", strerror(-ret)); 10661 } 10662 10663 cmdline_parse_token_string_t cmd_flex_filter_filter = 10664 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result, 10665 filter, "flex_filter"); 10666 cmdline_parse_token_num_t cmd_flex_filter_port_id = 10667 TOKEN_NUM_INITIALIZER(struct cmd_flex_filter_result, 10668 port_id, UINT16); 10669 cmdline_parse_token_string_t cmd_flex_filter_ops = 10670 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result, 10671 ops, "add#del"); 10672 cmdline_parse_token_string_t cmd_flex_filter_len = 10673 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result, 10674 len, "len"); 10675 cmdline_parse_token_num_t cmd_flex_filter_len_value = 10676 TOKEN_NUM_INITIALIZER(struct cmd_flex_filter_result, 10677 len_value, UINT8); 10678 cmdline_parse_token_string_t cmd_flex_filter_bytes = 10679 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result, 10680 bytes, "bytes"); 10681 cmdline_parse_token_string_t cmd_flex_filter_bytes_value = 10682 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result, 10683 bytes_value, NULL); 10684 cmdline_parse_token_string_t cmd_flex_filter_mask = 10685 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result, 10686 mask, "mask"); 10687 cmdline_parse_token_string_t cmd_flex_filter_mask_value = 10688 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result, 10689 mask_value, NULL); 10690 cmdline_parse_token_string_t cmd_flex_filter_priority = 10691 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result, 10692 priority, "priority"); 10693 cmdline_parse_token_num_t cmd_flex_filter_priority_value = 10694 TOKEN_NUM_INITIALIZER(struct cmd_flex_filter_result, 10695 priority_value, UINT8); 10696 cmdline_parse_token_string_t cmd_flex_filter_queue = 10697 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result, 10698 queue, "queue"); 10699 cmdline_parse_token_num_t cmd_flex_filter_queue_id = 10700 TOKEN_NUM_INITIALIZER(struct cmd_flex_filter_result, 10701 queue_id, UINT16); 10702 cmdline_parse_inst_t cmd_flex_filter = { 10703 .f = cmd_flex_filter_parsed, 10704 .data = NULL, 10705 .help_str = "flex_filter <port_id> add|del len <value> bytes " 10706 "<value> mask <value> priority <value> queue <queue_id>: " 10707 "Add/Del a flex filter", 10708 .tokens = { 10709 (void *)&cmd_flex_filter_filter, 10710 (void *)&cmd_flex_filter_port_id, 10711 (void *)&cmd_flex_filter_ops, 10712 (void *)&cmd_flex_filter_len, 10713 (void *)&cmd_flex_filter_len_value, 10714 (void *)&cmd_flex_filter_bytes, 10715 (void *)&cmd_flex_filter_bytes_value, 10716 (void *)&cmd_flex_filter_mask, 10717 (void *)&cmd_flex_filter_mask_value, 10718 (void *)&cmd_flex_filter_priority, 10719 (void *)&cmd_flex_filter_priority_value, 10720 (void *)&cmd_flex_filter_queue, 10721 (void *)&cmd_flex_filter_queue_id, 10722 NULL, 10723 }, 10724 }; 10725 10726 /* *** Filters Control *** */ 10727 10728 /* *** deal with ethertype filter *** */ 10729 struct cmd_ethertype_filter_result { 10730 cmdline_fixed_string_t filter; 10731 portid_t port_id; 10732 cmdline_fixed_string_t ops; 10733 cmdline_fixed_string_t mac; 10734 struct rte_ether_addr mac_addr; 10735 cmdline_fixed_string_t ethertype; 10736 uint16_t ethertype_value; 10737 cmdline_fixed_string_t drop; 10738 cmdline_fixed_string_t queue; 10739 uint16_t queue_id; 10740 }; 10741 10742 cmdline_parse_token_string_t cmd_ethertype_filter_filter = 10743 TOKEN_STRING_INITIALIZER(struct cmd_ethertype_filter_result, 10744 filter, "ethertype_filter"); 10745 cmdline_parse_token_num_t cmd_ethertype_filter_port_id = 10746 TOKEN_NUM_INITIALIZER(struct cmd_ethertype_filter_result, 10747 port_id, UINT16); 10748 cmdline_parse_token_string_t cmd_ethertype_filter_ops = 10749 TOKEN_STRING_INITIALIZER(struct cmd_ethertype_filter_result, 10750 ops, "add#del"); 10751 cmdline_parse_token_string_t cmd_ethertype_filter_mac = 10752 TOKEN_STRING_INITIALIZER(struct cmd_ethertype_filter_result, 10753 mac, "mac_addr#mac_ignr"); 10754 cmdline_parse_token_etheraddr_t cmd_ethertype_filter_mac_addr = 10755 TOKEN_ETHERADDR_INITIALIZER(struct cmd_ethertype_filter_result, 10756 mac_addr); 10757 cmdline_parse_token_string_t cmd_ethertype_filter_ethertype = 10758 TOKEN_STRING_INITIALIZER(struct cmd_ethertype_filter_result, 10759 ethertype, "ethertype"); 10760 cmdline_parse_token_num_t cmd_ethertype_filter_ethertype_value = 10761 TOKEN_NUM_INITIALIZER(struct cmd_ethertype_filter_result, 10762 ethertype_value, UINT16); 10763 cmdline_parse_token_string_t cmd_ethertype_filter_drop = 10764 TOKEN_STRING_INITIALIZER(struct cmd_ethertype_filter_result, 10765 drop, "drop#fwd"); 10766 cmdline_parse_token_string_t cmd_ethertype_filter_queue = 10767 TOKEN_STRING_INITIALIZER(struct cmd_ethertype_filter_result, 10768 queue, "queue"); 10769 cmdline_parse_token_num_t cmd_ethertype_filter_queue_id = 10770 TOKEN_NUM_INITIALIZER(struct cmd_ethertype_filter_result, 10771 queue_id, UINT16); 10772 10773 static void 10774 cmd_ethertype_filter_parsed(void *parsed_result, 10775 __attribute__((unused)) struct cmdline *cl, 10776 __attribute__((unused)) void *data) 10777 { 10778 struct cmd_ethertype_filter_result *res = parsed_result; 10779 struct rte_eth_ethertype_filter filter; 10780 int ret = 0; 10781 10782 ret = rte_eth_dev_filter_supported(res->port_id, 10783 RTE_ETH_FILTER_ETHERTYPE); 10784 if (ret < 0) { 10785 printf("ethertype filter is not supported on port %u.\n", 10786 res->port_id); 10787 return; 10788 } 10789 10790 memset(&filter, 0, sizeof(filter)); 10791 if (!strcmp(res->mac, "mac_addr")) { 10792 filter.flags |= RTE_ETHTYPE_FLAGS_MAC; 10793 rte_memcpy(&filter.mac_addr, &res->mac_addr, 10794 sizeof(struct rte_ether_addr)); 10795 } 10796 if (!strcmp(res->drop, "drop")) 10797 filter.flags |= RTE_ETHTYPE_FLAGS_DROP; 10798 filter.ether_type = res->ethertype_value; 10799 filter.queue = res->queue_id; 10800 10801 if (!strcmp(res->ops, "add")) 10802 ret = rte_eth_dev_filter_ctrl(res->port_id, 10803 RTE_ETH_FILTER_ETHERTYPE, 10804 RTE_ETH_FILTER_ADD, 10805 &filter); 10806 else 10807 ret = rte_eth_dev_filter_ctrl(res->port_id, 10808 RTE_ETH_FILTER_ETHERTYPE, 10809 RTE_ETH_FILTER_DELETE, 10810 &filter); 10811 if (ret < 0) 10812 printf("ethertype filter programming error: (%s)\n", 10813 strerror(-ret)); 10814 } 10815 10816 cmdline_parse_inst_t cmd_ethertype_filter = { 10817 .f = cmd_ethertype_filter_parsed, 10818 .data = NULL, 10819 .help_str = "ethertype_filter <port_id> add|del mac_addr|mac_ignr " 10820 "<mac_addr> ethertype <value> drop|fw queue <queue_id>: " 10821 "Add or delete an ethertype filter entry", 10822 .tokens = { 10823 (void *)&cmd_ethertype_filter_filter, 10824 (void *)&cmd_ethertype_filter_port_id, 10825 (void *)&cmd_ethertype_filter_ops, 10826 (void *)&cmd_ethertype_filter_mac, 10827 (void *)&cmd_ethertype_filter_mac_addr, 10828 (void *)&cmd_ethertype_filter_ethertype, 10829 (void *)&cmd_ethertype_filter_ethertype_value, 10830 (void *)&cmd_ethertype_filter_drop, 10831 (void *)&cmd_ethertype_filter_queue, 10832 (void *)&cmd_ethertype_filter_queue_id, 10833 NULL, 10834 }, 10835 }; 10836 10837 /* *** deal with flow director filter *** */ 10838 struct cmd_flow_director_result { 10839 cmdline_fixed_string_t flow_director_filter; 10840 portid_t port_id; 10841 cmdline_fixed_string_t mode; 10842 cmdline_fixed_string_t mode_value; 10843 cmdline_fixed_string_t ops; 10844 cmdline_fixed_string_t flow; 10845 cmdline_fixed_string_t flow_type; 10846 cmdline_fixed_string_t ether; 10847 uint16_t ether_type; 10848 cmdline_fixed_string_t src; 10849 cmdline_ipaddr_t ip_src; 10850 uint16_t port_src; 10851 cmdline_fixed_string_t dst; 10852 cmdline_ipaddr_t ip_dst; 10853 uint16_t port_dst; 10854 cmdline_fixed_string_t verify_tag; 10855 uint32_t verify_tag_value; 10856 cmdline_fixed_string_t tos; 10857 uint8_t tos_value; 10858 cmdline_fixed_string_t proto; 10859 uint8_t proto_value; 10860 cmdline_fixed_string_t ttl; 10861 uint8_t ttl_value; 10862 cmdline_fixed_string_t vlan; 10863 uint16_t vlan_value; 10864 cmdline_fixed_string_t flexbytes; 10865 cmdline_fixed_string_t flexbytes_value; 10866 cmdline_fixed_string_t pf_vf; 10867 cmdline_fixed_string_t drop; 10868 cmdline_fixed_string_t queue; 10869 uint16_t queue_id; 10870 cmdline_fixed_string_t fd_id; 10871 uint32_t fd_id_value; 10872 cmdline_fixed_string_t mac; 10873 struct rte_ether_addr mac_addr; 10874 cmdline_fixed_string_t tunnel; 10875 cmdline_fixed_string_t tunnel_type; 10876 cmdline_fixed_string_t tunnel_id; 10877 uint32_t tunnel_id_value; 10878 cmdline_fixed_string_t packet; 10879 char filepath[]; 10880 }; 10881 10882 static inline int 10883 parse_flexbytes(const char *q_arg, uint8_t *flexbytes, uint16_t max_num) 10884 { 10885 char s[256]; 10886 const char *p, *p0 = q_arg; 10887 char *end; 10888 unsigned long int_fld; 10889 char *str_fld[max_num]; 10890 int i; 10891 unsigned size; 10892 int ret = -1; 10893 10894 p = strchr(p0, '('); 10895 if (p == NULL) 10896 return -1; 10897 ++p; 10898 p0 = strchr(p, ')'); 10899 if (p0 == NULL) 10900 return -1; 10901 10902 size = p0 - p; 10903 if (size >= sizeof(s)) 10904 return -1; 10905 10906 snprintf(s, sizeof(s), "%.*s", size, p); 10907 ret = rte_strsplit(s, sizeof(s), str_fld, max_num, ','); 10908 if (ret < 0 || ret > max_num) 10909 return -1; 10910 for (i = 0; i < ret; i++) { 10911 errno = 0; 10912 int_fld = strtoul(str_fld[i], &end, 0); 10913 if (errno != 0 || *end != '\0' || int_fld > UINT8_MAX) 10914 return -1; 10915 flexbytes[i] = (uint8_t)int_fld; 10916 } 10917 return ret; 10918 } 10919 10920 static uint16_t 10921 str2flowtype(char *string) 10922 { 10923 uint8_t i = 0; 10924 static const struct { 10925 char str[32]; 10926 uint16_t type; 10927 } flowtype_str[] = { 10928 {"raw", RTE_ETH_FLOW_RAW}, 10929 {"ipv4", RTE_ETH_FLOW_IPV4}, 10930 {"ipv4-frag", RTE_ETH_FLOW_FRAG_IPV4}, 10931 {"ipv4-tcp", RTE_ETH_FLOW_NONFRAG_IPV4_TCP}, 10932 {"ipv4-udp", RTE_ETH_FLOW_NONFRAG_IPV4_UDP}, 10933 {"ipv4-sctp", RTE_ETH_FLOW_NONFRAG_IPV4_SCTP}, 10934 {"ipv4-other", RTE_ETH_FLOW_NONFRAG_IPV4_OTHER}, 10935 {"ipv6", RTE_ETH_FLOW_IPV6}, 10936 {"ipv6-frag", RTE_ETH_FLOW_FRAG_IPV6}, 10937 {"ipv6-tcp", RTE_ETH_FLOW_NONFRAG_IPV6_TCP}, 10938 {"ipv6-udp", RTE_ETH_FLOW_NONFRAG_IPV6_UDP}, 10939 {"ipv6-sctp", RTE_ETH_FLOW_NONFRAG_IPV6_SCTP}, 10940 {"ipv6-other", RTE_ETH_FLOW_NONFRAG_IPV6_OTHER}, 10941 {"l2_payload", RTE_ETH_FLOW_L2_PAYLOAD}, 10942 }; 10943 10944 for (i = 0; i < RTE_DIM(flowtype_str); i++) { 10945 if (!strcmp(flowtype_str[i].str, string)) 10946 return flowtype_str[i].type; 10947 } 10948 10949 if (isdigit(string[0]) && atoi(string) > 0 && atoi(string) < 64) 10950 return (uint16_t)atoi(string); 10951 10952 return RTE_ETH_FLOW_UNKNOWN; 10953 } 10954 10955 static enum rte_eth_fdir_tunnel_type 10956 str2fdir_tunneltype(char *string) 10957 { 10958 uint8_t i = 0; 10959 10960 static const struct { 10961 char str[32]; 10962 enum rte_eth_fdir_tunnel_type type; 10963 } tunneltype_str[] = { 10964 {"NVGRE", RTE_FDIR_TUNNEL_TYPE_NVGRE}, 10965 {"VxLAN", RTE_FDIR_TUNNEL_TYPE_VXLAN}, 10966 }; 10967 10968 for (i = 0; i < RTE_DIM(tunneltype_str); i++) { 10969 if (!strcmp(tunneltype_str[i].str, string)) 10970 return tunneltype_str[i].type; 10971 } 10972 return RTE_FDIR_TUNNEL_TYPE_UNKNOWN; 10973 } 10974 10975 #define IPV4_ADDR_TO_UINT(ip_addr, ip) \ 10976 do { \ 10977 if ((ip_addr).family == AF_INET) \ 10978 (ip) = (ip_addr).addr.ipv4.s_addr; \ 10979 else { \ 10980 printf("invalid parameter.\n"); \ 10981 return; \ 10982 } \ 10983 } while (0) 10984 10985 #define IPV6_ADDR_TO_ARRAY(ip_addr, ip) \ 10986 do { \ 10987 if ((ip_addr).family == AF_INET6) \ 10988 rte_memcpy(&(ip), \ 10989 &((ip_addr).addr.ipv6), \ 10990 sizeof(struct in6_addr)); \ 10991 else { \ 10992 printf("invalid parameter.\n"); \ 10993 return; \ 10994 } \ 10995 } while (0) 10996 10997 static void 10998 cmd_flow_director_filter_parsed(void *parsed_result, 10999 __attribute__((unused)) struct cmdline *cl, 11000 __attribute__((unused)) void *data) 11001 { 11002 struct cmd_flow_director_result *res = parsed_result; 11003 struct rte_eth_fdir_filter entry; 11004 uint8_t flexbytes[RTE_ETH_FDIR_MAX_FLEXLEN]; 11005 char *end; 11006 unsigned long vf_id; 11007 int ret = 0; 11008 11009 ret = rte_eth_dev_filter_supported(res->port_id, RTE_ETH_FILTER_FDIR); 11010 if (ret < 0) { 11011 printf("flow director is not supported on port %u.\n", 11012 res->port_id); 11013 return; 11014 } 11015 memset(flexbytes, 0, sizeof(flexbytes)); 11016 memset(&entry, 0, sizeof(struct rte_eth_fdir_filter)); 11017 11018 if (fdir_conf.mode == RTE_FDIR_MODE_PERFECT_MAC_VLAN) { 11019 if (strcmp(res->mode_value, "MAC-VLAN")) { 11020 printf("Please set mode to MAC-VLAN.\n"); 11021 return; 11022 } 11023 } else if (fdir_conf.mode == RTE_FDIR_MODE_PERFECT_TUNNEL) { 11024 if (strcmp(res->mode_value, "Tunnel")) { 11025 printf("Please set mode to Tunnel.\n"); 11026 return; 11027 } 11028 } else { 11029 if (!strcmp(res->mode_value, "raw")) { 11030 #ifdef RTE_LIBRTE_I40E_PMD 11031 struct rte_pmd_i40e_flow_type_mapping 11032 mapping[RTE_PMD_I40E_FLOW_TYPE_MAX]; 11033 struct rte_pmd_i40e_pkt_template_conf conf; 11034 uint16_t flow_type = str2flowtype(res->flow_type); 11035 uint16_t i, port = res->port_id; 11036 uint8_t add; 11037 11038 memset(&conf, 0, sizeof(conf)); 11039 11040 if (flow_type == RTE_ETH_FLOW_UNKNOWN) { 11041 printf("Invalid flow type specified.\n"); 11042 return; 11043 } 11044 ret = rte_pmd_i40e_flow_type_mapping_get(res->port_id, 11045 mapping); 11046 if (ret) 11047 return; 11048 if (mapping[flow_type].pctype == 0ULL) { 11049 printf("Invalid flow type specified.\n"); 11050 return; 11051 } 11052 for (i = 0; i < RTE_PMD_I40E_PCTYPE_MAX; i++) { 11053 if (mapping[flow_type].pctype & (1ULL << i)) { 11054 conf.input.pctype = i; 11055 break; 11056 } 11057 } 11058 11059 conf.input.packet = open_file(res->filepath, 11060 &conf.input.length); 11061 if (!conf.input.packet) 11062 return; 11063 if (!strcmp(res->drop, "drop")) 11064 conf.action.behavior = 11065 RTE_PMD_I40E_PKT_TEMPLATE_REJECT; 11066 else 11067 conf.action.behavior = 11068 RTE_PMD_I40E_PKT_TEMPLATE_ACCEPT; 11069 conf.action.report_status = 11070 RTE_PMD_I40E_PKT_TEMPLATE_REPORT_ID; 11071 conf.action.rx_queue = res->queue_id; 11072 conf.soft_id = res->fd_id_value; 11073 add = strcmp(res->ops, "del") ? 1 : 0; 11074 ret = rte_pmd_i40e_flow_add_del_packet_template(port, 11075 &conf, 11076 add); 11077 if (ret < 0) 11078 printf("flow director config error: (%s)\n", 11079 strerror(-ret)); 11080 close_file(conf.input.packet); 11081 #endif 11082 return; 11083 } else if (strcmp(res->mode_value, "IP")) { 11084 printf("Please set mode to IP or raw.\n"); 11085 return; 11086 } 11087 entry.input.flow_type = str2flowtype(res->flow_type); 11088 } 11089 11090 ret = parse_flexbytes(res->flexbytes_value, 11091 flexbytes, 11092 RTE_ETH_FDIR_MAX_FLEXLEN); 11093 if (ret < 0) { 11094 printf("error: Cannot parse flexbytes input.\n"); 11095 return; 11096 } 11097 11098 switch (entry.input.flow_type) { 11099 case RTE_ETH_FLOW_FRAG_IPV4: 11100 case RTE_ETH_FLOW_NONFRAG_IPV4_OTHER: 11101 entry.input.flow.ip4_flow.proto = res->proto_value; 11102 /* fall-through */ 11103 case RTE_ETH_FLOW_NONFRAG_IPV4_UDP: 11104 case RTE_ETH_FLOW_NONFRAG_IPV4_TCP: 11105 IPV4_ADDR_TO_UINT(res->ip_dst, 11106 entry.input.flow.ip4_flow.dst_ip); 11107 IPV4_ADDR_TO_UINT(res->ip_src, 11108 entry.input.flow.ip4_flow.src_ip); 11109 entry.input.flow.ip4_flow.tos = res->tos_value; 11110 entry.input.flow.ip4_flow.ttl = res->ttl_value; 11111 /* need convert to big endian. */ 11112 entry.input.flow.udp4_flow.dst_port = 11113 rte_cpu_to_be_16(res->port_dst); 11114 entry.input.flow.udp4_flow.src_port = 11115 rte_cpu_to_be_16(res->port_src); 11116 break; 11117 case RTE_ETH_FLOW_NONFRAG_IPV4_SCTP: 11118 IPV4_ADDR_TO_UINT(res->ip_dst, 11119 entry.input.flow.sctp4_flow.ip.dst_ip); 11120 IPV4_ADDR_TO_UINT(res->ip_src, 11121 entry.input.flow.sctp4_flow.ip.src_ip); 11122 entry.input.flow.ip4_flow.tos = res->tos_value; 11123 entry.input.flow.ip4_flow.ttl = res->ttl_value; 11124 /* need convert to big endian. */ 11125 entry.input.flow.sctp4_flow.dst_port = 11126 rte_cpu_to_be_16(res->port_dst); 11127 entry.input.flow.sctp4_flow.src_port = 11128 rte_cpu_to_be_16(res->port_src); 11129 entry.input.flow.sctp4_flow.verify_tag = 11130 rte_cpu_to_be_32(res->verify_tag_value); 11131 break; 11132 case RTE_ETH_FLOW_FRAG_IPV6: 11133 case RTE_ETH_FLOW_NONFRAG_IPV6_OTHER: 11134 entry.input.flow.ipv6_flow.proto = res->proto_value; 11135 /* fall-through */ 11136 case RTE_ETH_FLOW_NONFRAG_IPV6_UDP: 11137 case RTE_ETH_FLOW_NONFRAG_IPV6_TCP: 11138 IPV6_ADDR_TO_ARRAY(res->ip_dst, 11139 entry.input.flow.ipv6_flow.dst_ip); 11140 IPV6_ADDR_TO_ARRAY(res->ip_src, 11141 entry.input.flow.ipv6_flow.src_ip); 11142 entry.input.flow.ipv6_flow.tc = res->tos_value; 11143 entry.input.flow.ipv6_flow.hop_limits = res->ttl_value; 11144 /* need convert to big endian. */ 11145 entry.input.flow.udp6_flow.dst_port = 11146 rte_cpu_to_be_16(res->port_dst); 11147 entry.input.flow.udp6_flow.src_port = 11148 rte_cpu_to_be_16(res->port_src); 11149 break; 11150 case RTE_ETH_FLOW_NONFRAG_IPV6_SCTP: 11151 IPV6_ADDR_TO_ARRAY(res->ip_dst, 11152 entry.input.flow.sctp6_flow.ip.dst_ip); 11153 IPV6_ADDR_TO_ARRAY(res->ip_src, 11154 entry.input.flow.sctp6_flow.ip.src_ip); 11155 entry.input.flow.ipv6_flow.tc = res->tos_value; 11156 entry.input.flow.ipv6_flow.hop_limits = res->ttl_value; 11157 /* need convert to big endian. */ 11158 entry.input.flow.sctp6_flow.dst_port = 11159 rte_cpu_to_be_16(res->port_dst); 11160 entry.input.flow.sctp6_flow.src_port = 11161 rte_cpu_to_be_16(res->port_src); 11162 entry.input.flow.sctp6_flow.verify_tag = 11163 rte_cpu_to_be_32(res->verify_tag_value); 11164 break; 11165 case RTE_ETH_FLOW_L2_PAYLOAD: 11166 entry.input.flow.l2_flow.ether_type = 11167 rte_cpu_to_be_16(res->ether_type); 11168 break; 11169 default: 11170 break; 11171 } 11172 11173 if (fdir_conf.mode == RTE_FDIR_MODE_PERFECT_MAC_VLAN) 11174 rte_memcpy(&entry.input.flow.mac_vlan_flow.mac_addr, 11175 &res->mac_addr, 11176 sizeof(struct rte_ether_addr)); 11177 11178 if (fdir_conf.mode == RTE_FDIR_MODE_PERFECT_TUNNEL) { 11179 rte_memcpy(&entry.input.flow.tunnel_flow.mac_addr, 11180 &res->mac_addr, 11181 sizeof(struct rte_ether_addr)); 11182 entry.input.flow.tunnel_flow.tunnel_type = 11183 str2fdir_tunneltype(res->tunnel_type); 11184 entry.input.flow.tunnel_flow.tunnel_id = 11185 rte_cpu_to_be_32(res->tunnel_id_value); 11186 } 11187 11188 rte_memcpy(entry.input.flow_ext.flexbytes, 11189 flexbytes, 11190 RTE_ETH_FDIR_MAX_FLEXLEN); 11191 11192 entry.input.flow_ext.vlan_tci = rte_cpu_to_be_16(res->vlan_value); 11193 11194 entry.action.flex_off = 0; /*use 0 by default */ 11195 if (!strcmp(res->drop, "drop")) 11196 entry.action.behavior = RTE_ETH_FDIR_REJECT; 11197 else 11198 entry.action.behavior = RTE_ETH_FDIR_ACCEPT; 11199 11200 if (fdir_conf.mode != RTE_FDIR_MODE_PERFECT_MAC_VLAN && 11201 fdir_conf.mode != RTE_FDIR_MODE_PERFECT_TUNNEL) { 11202 if (!strcmp(res->pf_vf, "pf")) 11203 entry.input.flow_ext.is_vf = 0; 11204 else if (!strncmp(res->pf_vf, "vf", 2)) { 11205 struct rte_eth_dev_info dev_info; 11206 11207 ret = eth_dev_info_get_print_err(res->port_id, 11208 &dev_info); 11209 if (ret != 0) 11210 return; 11211 11212 errno = 0; 11213 vf_id = strtoul(res->pf_vf + 2, &end, 10); 11214 if (errno != 0 || *end != '\0' || 11215 vf_id >= dev_info.max_vfs) { 11216 printf("invalid parameter %s.\n", res->pf_vf); 11217 return; 11218 } 11219 entry.input.flow_ext.is_vf = 1; 11220 entry.input.flow_ext.dst_id = (uint16_t)vf_id; 11221 } else { 11222 printf("invalid parameter %s.\n", res->pf_vf); 11223 return; 11224 } 11225 } 11226 11227 /* set to report FD ID by default */ 11228 entry.action.report_status = RTE_ETH_FDIR_REPORT_ID; 11229 entry.action.rx_queue = res->queue_id; 11230 entry.soft_id = res->fd_id_value; 11231 if (!strcmp(res->ops, "add")) 11232 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_FDIR, 11233 RTE_ETH_FILTER_ADD, &entry); 11234 else if (!strcmp(res->ops, "del")) 11235 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_FDIR, 11236 RTE_ETH_FILTER_DELETE, &entry); 11237 else 11238 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_FDIR, 11239 RTE_ETH_FILTER_UPDATE, &entry); 11240 if (ret < 0) 11241 printf("flow director programming error: (%s)\n", 11242 strerror(-ret)); 11243 } 11244 11245 cmdline_parse_token_string_t cmd_flow_director_filter = 11246 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result, 11247 flow_director_filter, "flow_director_filter"); 11248 cmdline_parse_token_num_t cmd_flow_director_port_id = 11249 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result, 11250 port_id, UINT16); 11251 cmdline_parse_token_string_t cmd_flow_director_ops = 11252 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result, 11253 ops, "add#del#update"); 11254 cmdline_parse_token_string_t cmd_flow_director_flow = 11255 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result, 11256 flow, "flow"); 11257 cmdline_parse_token_string_t cmd_flow_director_flow_type = 11258 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result, 11259 flow_type, NULL); 11260 cmdline_parse_token_string_t cmd_flow_director_ether = 11261 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result, 11262 ether, "ether"); 11263 cmdline_parse_token_num_t cmd_flow_director_ether_type = 11264 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result, 11265 ether_type, UINT16); 11266 cmdline_parse_token_string_t cmd_flow_director_src = 11267 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result, 11268 src, "src"); 11269 cmdline_parse_token_ipaddr_t cmd_flow_director_ip_src = 11270 TOKEN_IPADDR_INITIALIZER(struct cmd_flow_director_result, 11271 ip_src); 11272 cmdline_parse_token_num_t cmd_flow_director_port_src = 11273 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result, 11274 port_src, UINT16); 11275 cmdline_parse_token_string_t cmd_flow_director_dst = 11276 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result, 11277 dst, "dst"); 11278 cmdline_parse_token_ipaddr_t cmd_flow_director_ip_dst = 11279 TOKEN_IPADDR_INITIALIZER(struct cmd_flow_director_result, 11280 ip_dst); 11281 cmdline_parse_token_num_t cmd_flow_director_port_dst = 11282 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result, 11283 port_dst, UINT16); 11284 cmdline_parse_token_string_t cmd_flow_director_verify_tag = 11285 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result, 11286 verify_tag, "verify_tag"); 11287 cmdline_parse_token_num_t cmd_flow_director_verify_tag_value = 11288 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result, 11289 verify_tag_value, UINT32); 11290 cmdline_parse_token_string_t cmd_flow_director_tos = 11291 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result, 11292 tos, "tos"); 11293 cmdline_parse_token_num_t cmd_flow_director_tos_value = 11294 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result, 11295 tos_value, UINT8); 11296 cmdline_parse_token_string_t cmd_flow_director_proto = 11297 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result, 11298 proto, "proto"); 11299 cmdline_parse_token_num_t cmd_flow_director_proto_value = 11300 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result, 11301 proto_value, UINT8); 11302 cmdline_parse_token_string_t cmd_flow_director_ttl = 11303 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result, 11304 ttl, "ttl"); 11305 cmdline_parse_token_num_t cmd_flow_director_ttl_value = 11306 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result, 11307 ttl_value, UINT8); 11308 cmdline_parse_token_string_t cmd_flow_director_vlan = 11309 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result, 11310 vlan, "vlan"); 11311 cmdline_parse_token_num_t cmd_flow_director_vlan_value = 11312 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result, 11313 vlan_value, UINT16); 11314 cmdline_parse_token_string_t cmd_flow_director_flexbytes = 11315 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result, 11316 flexbytes, "flexbytes"); 11317 cmdline_parse_token_string_t cmd_flow_director_flexbytes_value = 11318 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result, 11319 flexbytes_value, NULL); 11320 cmdline_parse_token_string_t cmd_flow_director_drop = 11321 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result, 11322 drop, "drop#fwd"); 11323 cmdline_parse_token_string_t cmd_flow_director_pf_vf = 11324 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result, 11325 pf_vf, NULL); 11326 cmdline_parse_token_string_t cmd_flow_director_queue = 11327 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result, 11328 queue, "queue"); 11329 cmdline_parse_token_num_t cmd_flow_director_queue_id = 11330 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result, 11331 queue_id, UINT16); 11332 cmdline_parse_token_string_t cmd_flow_director_fd_id = 11333 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result, 11334 fd_id, "fd_id"); 11335 cmdline_parse_token_num_t cmd_flow_director_fd_id_value = 11336 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result, 11337 fd_id_value, UINT32); 11338 11339 cmdline_parse_token_string_t cmd_flow_director_mode = 11340 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result, 11341 mode, "mode"); 11342 cmdline_parse_token_string_t cmd_flow_director_mode_ip = 11343 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result, 11344 mode_value, "IP"); 11345 cmdline_parse_token_string_t cmd_flow_director_mode_mac_vlan = 11346 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result, 11347 mode_value, "MAC-VLAN"); 11348 cmdline_parse_token_string_t cmd_flow_director_mode_tunnel = 11349 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result, 11350 mode_value, "Tunnel"); 11351 cmdline_parse_token_string_t cmd_flow_director_mode_raw = 11352 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result, 11353 mode_value, "raw"); 11354 cmdline_parse_token_string_t cmd_flow_director_mac = 11355 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result, 11356 mac, "mac"); 11357 cmdline_parse_token_etheraddr_t cmd_flow_director_mac_addr = 11358 TOKEN_ETHERADDR_INITIALIZER(struct cmd_flow_director_result, 11359 mac_addr); 11360 cmdline_parse_token_string_t cmd_flow_director_tunnel = 11361 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result, 11362 tunnel, "tunnel"); 11363 cmdline_parse_token_string_t cmd_flow_director_tunnel_type = 11364 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result, 11365 tunnel_type, "NVGRE#VxLAN"); 11366 cmdline_parse_token_string_t cmd_flow_director_tunnel_id = 11367 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result, 11368 tunnel_id, "tunnel-id"); 11369 cmdline_parse_token_num_t cmd_flow_director_tunnel_id_value = 11370 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result, 11371 tunnel_id_value, UINT32); 11372 cmdline_parse_token_string_t cmd_flow_director_packet = 11373 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result, 11374 packet, "packet"); 11375 cmdline_parse_token_string_t cmd_flow_director_filepath = 11376 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result, 11377 filepath, NULL); 11378 11379 cmdline_parse_inst_t cmd_add_del_ip_flow_director = { 11380 .f = cmd_flow_director_filter_parsed, 11381 .data = NULL, 11382 .help_str = "flow_director_filter <port_id> mode IP add|del|update flow" 11383 " ipv4-other|ipv4-frag|ipv4-tcp|ipv4-udp|ipv4-sctp|" 11384 "ipv6-other|ipv6-frag|ipv6-tcp|ipv6-udp|ipv6-sctp|" 11385 "l2_payload src <src_ip> dst <dst_ip> tos <tos_value> " 11386 "proto <proto_value> ttl <ttl_value> vlan <vlan_value> " 11387 "flexbytes <flexbyte_values> drop|fw <pf_vf> queue <queue_id> " 11388 "fd_id <fd_id_value>: " 11389 "Add or delete an ip flow director entry on NIC", 11390 .tokens = { 11391 (void *)&cmd_flow_director_filter, 11392 (void *)&cmd_flow_director_port_id, 11393 (void *)&cmd_flow_director_mode, 11394 (void *)&cmd_flow_director_mode_ip, 11395 (void *)&cmd_flow_director_ops, 11396 (void *)&cmd_flow_director_flow, 11397 (void *)&cmd_flow_director_flow_type, 11398 (void *)&cmd_flow_director_src, 11399 (void *)&cmd_flow_director_ip_src, 11400 (void *)&cmd_flow_director_dst, 11401 (void *)&cmd_flow_director_ip_dst, 11402 (void *)&cmd_flow_director_tos, 11403 (void *)&cmd_flow_director_tos_value, 11404 (void *)&cmd_flow_director_proto, 11405 (void *)&cmd_flow_director_proto_value, 11406 (void *)&cmd_flow_director_ttl, 11407 (void *)&cmd_flow_director_ttl_value, 11408 (void *)&cmd_flow_director_vlan, 11409 (void *)&cmd_flow_director_vlan_value, 11410 (void *)&cmd_flow_director_flexbytes, 11411 (void *)&cmd_flow_director_flexbytes_value, 11412 (void *)&cmd_flow_director_drop, 11413 (void *)&cmd_flow_director_pf_vf, 11414 (void *)&cmd_flow_director_queue, 11415 (void *)&cmd_flow_director_queue_id, 11416 (void *)&cmd_flow_director_fd_id, 11417 (void *)&cmd_flow_director_fd_id_value, 11418 NULL, 11419 }, 11420 }; 11421 11422 cmdline_parse_inst_t cmd_add_del_udp_flow_director = { 11423 .f = cmd_flow_director_filter_parsed, 11424 .data = NULL, 11425 .help_str = "flow_director_filter ... : Add or delete an udp/tcp flow " 11426 "director entry on NIC", 11427 .tokens = { 11428 (void *)&cmd_flow_director_filter, 11429 (void *)&cmd_flow_director_port_id, 11430 (void *)&cmd_flow_director_mode, 11431 (void *)&cmd_flow_director_mode_ip, 11432 (void *)&cmd_flow_director_ops, 11433 (void *)&cmd_flow_director_flow, 11434 (void *)&cmd_flow_director_flow_type, 11435 (void *)&cmd_flow_director_src, 11436 (void *)&cmd_flow_director_ip_src, 11437 (void *)&cmd_flow_director_port_src, 11438 (void *)&cmd_flow_director_dst, 11439 (void *)&cmd_flow_director_ip_dst, 11440 (void *)&cmd_flow_director_port_dst, 11441 (void *)&cmd_flow_director_tos, 11442 (void *)&cmd_flow_director_tos_value, 11443 (void *)&cmd_flow_director_ttl, 11444 (void *)&cmd_flow_director_ttl_value, 11445 (void *)&cmd_flow_director_vlan, 11446 (void *)&cmd_flow_director_vlan_value, 11447 (void *)&cmd_flow_director_flexbytes, 11448 (void *)&cmd_flow_director_flexbytes_value, 11449 (void *)&cmd_flow_director_drop, 11450 (void *)&cmd_flow_director_pf_vf, 11451 (void *)&cmd_flow_director_queue, 11452 (void *)&cmd_flow_director_queue_id, 11453 (void *)&cmd_flow_director_fd_id, 11454 (void *)&cmd_flow_director_fd_id_value, 11455 NULL, 11456 }, 11457 }; 11458 11459 cmdline_parse_inst_t cmd_add_del_sctp_flow_director = { 11460 .f = cmd_flow_director_filter_parsed, 11461 .data = NULL, 11462 .help_str = "flow_director_filter ... : Add or delete a sctp flow " 11463 "director entry on NIC", 11464 .tokens = { 11465 (void *)&cmd_flow_director_filter, 11466 (void *)&cmd_flow_director_port_id, 11467 (void *)&cmd_flow_director_mode, 11468 (void *)&cmd_flow_director_mode_ip, 11469 (void *)&cmd_flow_director_ops, 11470 (void *)&cmd_flow_director_flow, 11471 (void *)&cmd_flow_director_flow_type, 11472 (void *)&cmd_flow_director_src, 11473 (void *)&cmd_flow_director_ip_src, 11474 (void *)&cmd_flow_director_port_src, 11475 (void *)&cmd_flow_director_dst, 11476 (void *)&cmd_flow_director_ip_dst, 11477 (void *)&cmd_flow_director_port_dst, 11478 (void *)&cmd_flow_director_verify_tag, 11479 (void *)&cmd_flow_director_verify_tag_value, 11480 (void *)&cmd_flow_director_tos, 11481 (void *)&cmd_flow_director_tos_value, 11482 (void *)&cmd_flow_director_ttl, 11483 (void *)&cmd_flow_director_ttl_value, 11484 (void *)&cmd_flow_director_vlan, 11485 (void *)&cmd_flow_director_vlan_value, 11486 (void *)&cmd_flow_director_flexbytes, 11487 (void *)&cmd_flow_director_flexbytes_value, 11488 (void *)&cmd_flow_director_drop, 11489 (void *)&cmd_flow_director_pf_vf, 11490 (void *)&cmd_flow_director_queue, 11491 (void *)&cmd_flow_director_queue_id, 11492 (void *)&cmd_flow_director_fd_id, 11493 (void *)&cmd_flow_director_fd_id_value, 11494 NULL, 11495 }, 11496 }; 11497 11498 cmdline_parse_inst_t cmd_add_del_l2_flow_director = { 11499 .f = cmd_flow_director_filter_parsed, 11500 .data = NULL, 11501 .help_str = "flow_director_filter ... : Add or delete a L2 flow " 11502 "director entry on NIC", 11503 .tokens = { 11504 (void *)&cmd_flow_director_filter, 11505 (void *)&cmd_flow_director_port_id, 11506 (void *)&cmd_flow_director_mode, 11507 (void *)&cmd_flow_director_mode_ip, 11508 (void *)&cmd_flow_director_ops, 11509 (void *)&cmd_flow_director_flow, 11510 (void *)&cmd_flow_director_flow_type, 11511 (void *)&cmd_flow_director_ether, 11512 (void *)&cmd_flow_director_ether_type, 11513 (void *)&cmd_flow_director_flexbytes, 11514 (void *)&cmd_flow_director_flexbytes_value, 11515 (void *)&cmd_flow_director_drop, 11516 (void *)&cmd_flow_director_pf_vf, 11517 (void *)&cmd_flow_director_queue, 11518 (void *)&cmd_flow_director_queue_id, 11519 (void *)&cmd_flow_director_fd_id, 11520 (void *)&cmd_flow_director_fd_id_value, 11521 NULL, 11522 }, 11523 }; 11524 11525 cmdline_parse_inst_t cmd_add_del_mac_vlan_flow_director = { 11526 .f = cmd_flow_director_filter_parsed, 11527 .data = NULL, 11528 .help_str = "flow_director_filter ... : Add or delete a MAC VLAN flow " 11529 "director entry on NIC", 11530 .tokens = { 11531 (void *)&cmd_flow_director_filter, 11532 (void *)&cmd_flow_director_port_id, 11533 (void *)&cmd_flow_director_mode, 11534 (void *)&cmd_flow_director_mode_mac_vlan, 11535 (void *)&cmd_flow_director_ops, 11536 (void *)&cmd_flow_director_mac, 11537 (void *)&cmd_flow_director_mac_addr, 11538 (void *)&cmd_flow_director_vlan, 11539 (void *)&cmd_flow_director_vlan_value, 11540 (void *)&cmd_flow_director_flexbytes, 11541 (void *)&cmd_flow_director_flexbytes_value, 11542 (void *)&cmd_flow_director_drop, 11543 (void *)&cmd_flow_director_queue, 11544 (void *)&cmd_flow_director_queue_id, 11545 (void *)&cmd_flow_director_fd_id, 11546 (void *)&cmd_flow_director_fd_id_value, 11547 NULL, 11548 }, 11549 }; 11550 11551 cmdline_parse_inst_t cmd_add_del_tunnel_flow_director = { 11552 .f = cmd_flow_director_filter_parsed, 11553 .data = NULL, 11554 .help_str = "flow_director_filter ... : Add or delete a tunnel flow " 11555 "director entry on NIC", 11556 .tokens = { 11557 (void *)&cmd_flow_director_filter, 11558 (void *)&cmd_flow_director_port_id, 11559 (void *)&cmd_flow_director_mode, 11560 (void *)&cmd_flow_director_mode_tunnel, 11561 (void *)&cmd_flow_director_ops, 11562 (void *)&cmd_flow_director_mac, 11563 (void *)&cmd_flow_director_mac_addr, 11564 (void *)&cmd_flow_director_vlan, 11565 (void *)&cmd_flow_director_vlan_value, 11566 (void *)&cmd_flow_director_tunnel, 11567 (void *)&cmd_flow_director_tunnel_type, 11568 (void *)&cmd_flow_director_tunnel_id, 11569 (void *)&cmd_flow_director_tunnel_id_value, 11570 (void *)&cmd_flow_director_flexbytes, 11571 (void *)&cmd_flow_director_flexbytes_value, 11572 (void *)&cmd_flow_director_drop, 11573 (void *)&cmd_flow_director_queue, 11574 (void *)&cmd_flow_director_queue_id, 11575 (void *)&cmd_flow_director_fd_id, 11576 (void *)&cmd_flow_director_fd_id_value, 11577 NULL, 11578 }, 11579 }; 11580 11581 cmdline_parse_inst_t cmd_add_del_raw_flow_director = { 11582 .f = cmd_flow_director_filter_parsed, 11583 .data = NULL, 11584 .help_str = "flow_director_filter ... : Add or delete a raw flow " 11585 "director entry on NIC", 11586 .tokens = { 11587 (void *)&cmd_flow_director_filter, 11588 (void *)&cmd_flow_director_port_id, 11589 (void *)&cmd_flow_director_mode, 11590 (void *)&cmd_flow_director_mode_raw, 11591 (void *)&cmd_flow_director_ops, 11592 (void *)&cmd_flow_director_flow, 11593 (void *)&cmd_flow_director_flow_type, 11594 (void *)&cmd_flow_director_drop, 11595 (void *)&cmd_flow_director_queue, 11596 (void *)&cmd_flow_director_queue_id, 11597 (void *)&cmd_flow_director_fd_id, 11598 (void *)&cmd_flow_director_fd_id_value, 11599 (void *)&cmd_flow_director_packet, 11600 (void *)&cmd_flow_director_filepath, 11601 NULL, 11602 }, 11603 }; 11604 11605 struct cmd_flush_flow_director_result { 11606 cmdline_fixed_string_t flush_flow_director; 11607 portid_t port_id; 11608 }; 11609 11610 cmdline_parse_token_string_t cmd_flush_flow_director_flush = 11611 TOKEN_STRING_INITIALIZER(struct cmd_flush_flow_director_result, 11612 flush_flow_director, "flush_flow_director"); 11613 cmdline_parse_token_num_t cmd_flush_flow_director_port_id = 11614 TOKEN_NUM_INITIALIZER(struct cmd_flush_flow_director_result, 11615 port_id, UINT16); 11616 11617 static void 11618 cmd_flush_flow_director_parsed(void *parsed_result, 11619 __attribute__((unused)) struct cmdline *cl, 11620 __attribute__((unused)) void *data) 11621 { 11622 struct cmd_flow_director_result *res = parsed_result; 11623 int ret = 0; 11624 11625 ret = rte_eth_dev_filter_supported(res->port_id, RTE_ETH_FILTER_FDIR); 11626 if (ret < 0) { 11627 printf("flow director is not supported on port %u.\n", 11628 res->port_id); 11629 return; 11630 } 11631 11632 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_FDIR, 11633 RTE_ETH_FILTER_FLUSH, NULL); 11634 if (ret < 0) 11635 printf("flow director table flushing error: (%s)\n", 11636 strerror(-ret)); 11637 } 11638 11639 cmdline_parse_inst_t cmd_flush_flow_director = { 11640 .f = cmd_flush_flow_director_parsed, 11641 .data = NULL, 11642 .help_str = "flush_flow_director <port_id>: " 11643 "Flush all flow director entries of a device on NIC", 11644 .tokens = { 11645 (void *)&cmd_flush_flow_director_flush, 11646 (void *)&cmd_flush_flow_director_port_id, 11647 NULL, 11648 }, 11649 }; 11650 11651 /* *** deal with flow director mask *** */ 11652 struct cmd_flow_director_mask_result { 11653 cmdline_fixed_string_t flow_director_mask; 11654 portid_t port_id; 11655 cmdline_fixed_string_t mode; 11656 cmdline_fixed_string_t mode_value; 11657 cmdline_fixed_string_t vlan; 11658 uint16_t vlan_mask; 11659 cmdline_fixed_string_t src_mask; 11660 cmdline_ipaddr_t ipv4_src; 11661 cmdline_ipaddr_t ipv6_src; 11662 uint16_t port_src; 11663 cmdline_fixed_string_t dst_mask; 11664 cmdline_ipaddr_t ipv4_dst; 11665 cmdline_ipaddr_t ipv6_dst; 11666 uint16_t port_dst; 11667 cmdline_fixed_string_t mac; 11668 uint8_t mac_addr_byte_mask; 11669 cmdline_fixed_string_t tunnel_id; 11670 uint32_t tunnel_id_mask; 11671 cmdline_fixed_string_t tunnel_type; 11672 uint8_t tunnel_type_mask; 11673 }; 11674 11675 static void 11676 cmd_flow_director_mask_parsed(void *parsed_result, 11677 __attribute__((unused)) struct cmdline *cl, 11678 __attribute__((unused)) void *data) 11679 { 11680 struct cmd_flow_director_mask_result *res = parsed_result; 11681 struct rte_eth_fdir_masks *mask; 11682 struct rte_port *port; 11683 11684 port = &ports[res->port_id]; 11685 /** Check if the port is not started **/ 11686 if (port->port_status != RTE_PORT_STOPPED) { 11687 printf("Please stop port %d first\n", res->port_id); 11688 return; 11689 } 11690 11691 mask = &port->dev_conf.fdir_conf.mask; 11692 11693 if (fdir_conf.mode == RTE_FDIR_MODE_PERFECT_MAC_VLAN) { 11694 if (strcmp(res->mode_value, "MAC-VLAN")) { 11695 printf("Please set mode to MAC-VLAN.\n"); 11696 return; 11697 } 11698 11699 mask->vlan_tci_mask = rte_cpu_to_be_16(res->vlan_mask); 11700 } else if (fdir_conf.mode == RTE_FDIR_MODE_PERFECT_TUNNEL) { 11701 if (strcmp(res->mode_value, "Tunnel")) { 11702 printf("Please set mode to Tunnel.\n"); 11703 return; 11704 } 11705 11706 mask->vlan_tci_mask = rte_cpu_to_be_16(res->vlan_mask); 11707 mask->mac_addr_byte_mask = res->mac_addr_byte_mask; 11708 mask->tunnel_id_mask = rte_cpu_to_be_32(res->tunnel_id_mask); 11709 mask->tunnel_type_mask = res->tunnel_type_mask; 11710 } else { 11711 if (strcmp(res->mode_value, "IP")) { 11712 printf("Please set mode to IP.\n"); 11713 return; 11714 } 11715 11716 mask->vlan_tci_mask = rte_cpu_to_be_16(res->vlan_mask); 11717 IPV4_ADDR_TO_UINT(res->ipv4_src, mask->ipv4_mask.src_ip); 11718 IPV4_ADDR_TO_UINT(res->ipv4_dst, mask->ipv4_mask.dst_ip); 11719 IPV6_ADDR_TO_ARRAY(res->ipv6_src, mask->ipv6_mask.src_ip); 11720 IPV6_ADDR_TO_ARRAY(res->ipv6_dst, mask->ipv6_mask.dst_ip); 11721 mask->src_port_mask = rte_cpu_to_be_16(res->port_src); 11722 mask->dst_port_mask = rte_cpu_to_be_16(res->port_dst); 11723 } 11724 11725 cmd_reconfig_device_queue(res->port_id, 1, 1); 11726 } 11727 11728 cmdline_parse_token_string_t cmd_flow_director_mask = 11729 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result, 11730 flow_director_mask, "flow_director_mask"); 11731 cmdline_parse_token_num_t cmd_flow_director_mask_port_id = 11732 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_mask_result, 11733 port_id, UINT16); 11734 cmdline_parse_token_string_t cmd_flow_director_mask_vlan = 11735 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result, 11736 vlan, "vlan"); 11737 cmdline_parse_token_num_t cmd_flow_director_mask_vlan_value = 11738 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_mask_result, 11739 vlan_mask, UINT16); 11740 cmdline_parse_token_string_t cmd_flow_director_mask_src = 11741 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result, 11742 src_mask, "src_mask"); 11743 cmdline_parse_token_ipaddr_t cmd_flow_director_mask_ipv4_src = 11744 TOKEN_IPADDR_INITIALIZER(struct cmd_flow_director_mask_result, 11745 ipv4_src); 11746 cmdline_parse_token_ipaddr_t cmd_flow_director_mask_ipv6_src = 11747 TOKEN_IPADDR_INITIALIZER(struct cmd_flow_director_mask_result, 11748 ipv6_src); 11749 cmdline_parse_token_num_t cmd_flow_director_mask_port_src = 11750 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_mask_result, 11751 port_src, UINT16); 11752 cmdline_parse_token_string_t cmd_flow_director_mask_dst = 11753 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result, 11754 dst_mask, "dst_mask"); 11755 cmdline_parse_token_ipaddr_t cmd_flow_director_mask_ipv4_dst = 11756 TOKEN_IPADDR_INITIALIZER(struct cmd_flow_director_mask_result, 11757 ipv4_dst); 11758 cmdline_parse_token_ipaddr_t cmd_flow_director_mask_ipv6_dst = 11759 TOKEN_IPADDR_INITIALIZER(struct cmd_flow_director_mask_result, 11760 ipv6_dst); 11761 cmdline_parse_token_num_t cmd_flow_director_mask_port_dst = 11762 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_mask_result, 11763 port_dst, UINT16); 11764 11765 cmdline_parse_token_string_t cmd_flow_director_mask_mode = 11766 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result, 11767 mode, "mode"); 11768 cmdline_parse_token_string_t cmd_flow_director_mask_mode_ip = 11769 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result, 11770 mode_value, "IP"); 11771 cmdline_parse_token_string_t cmd_flow_director_mask_mode_mac_vlan = 11772 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result, 11773 mode_value, "MAC-VLAN"); 11774 cmdline_parse_token_string_t cmd_flow_director_mask_mode_tunnel = 11775 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result, 11776 mode_value, "Tunnel"); 11777 cmdline_parse_token_string_t cmd_flow_director_mask_mac = 11778 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result, 11779 mac, "mac"); 11780 cmdline_parse_token_num_t cmd_flow_director_mask_mac_value = 11781 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_mask_result, 11782 mac_addr_byte_mask, UINT8); 11783 cmdline_parse_token_string_t cmd_flow_director_mask_tunnel_type = 11784 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result, 11785 tunnel_type, "tunnel-type"); 11786 cmdline_parse_token_num_t cmd_flow_director_mask_tunnel_type_value = 11787 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_mask_result, 11788 tunnel_type_mask, UINT8); 11789 cmdline_parse_token_string_t cmd_flow_director_mask_tunnel_id = 11790 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result, 11791 tunnel_id, "tunnel-id"); 11792 cmdline_parse_token_num_t cmd_flow_director_mask_tunnel_id_value = 11793 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_mask_result, 11794 tunnel_id_mask, UINT32); 11795 11796 cmdline_parse_inst_t cmd_set_flow_director_ip_mask = { 11797 .f = cmd_flow_director_mask_parsed, 11798 .data = NULL, 11799 .help_str = "flow_director_mask ... : " 11800 "Set IP mode flow director's mask on NIC", 11801 .tokens = { 11802 (void *)&cmd_flow_director_mask, 11803 (void *)&cmd_flow_director_mask_port_id, 11804 (void *)&cmd_flow_director_mask_mode, 11805 (void *)&cmd_flow_director_mask_mode_ip, 11806 (void *)&cmd_flow_director_mask_vlan, 11807 (void *)&cmd_flow_director_mask_vlan_value, 11808 (void *)&cmd_flow_director_mask_src, 11809 (void *)&cmd_flow_director_mask_ipv4_src, 11810 (void *)&cmd_flow_director_mask_ipv6_src, 11811 (void *)&cmd_flow_director_mask_port_src, 11812 (void *)&cmd_flow_director_mask_dst, 11813 (void *)&cmd_flow_director_mask_ipv4_dst, 11814 (void *)&cmd_flow_director_mask_ipv6_dst, 11815 (void *)&cmd_flow_director_mask_port_dst, 11816 NULL, 11817 }, 11818 }; 11819 11820 cmdline_parse_inst_t cmd_set_flow_director_mac_vlan_mask = { 11821 .f = cmd_flow_director_mask_parsed, 11822 .data = NULL, 11823 .help_str = "flow_director_mask ... : Set MAC VLAN mode " 11824 "flow director's mask on NIC", 11825 .tokens = { 11826 (void *)&cmd_flow_director_mask, 11827 (void *)&cmd_flow_director_mask_port_id, 11828 (void *)&cmd_flow_director_mask_mode, 11829 (void *)&cmd_flow_director_mask_mode_mac_vlan, 11830 (void *)&cmd_flow_director_mask_vlan, 11831 (void *)&cmd_flow_director_mask_vlan_value, 11832 NULL, 11833 }, 11834 }; 11835 11836 cmdline_parse_inst_t cmd_set_flow_director_tunnel_mask = { 11837 .f = cmd_flow_director_mask_parsed, 11838 .data = NULL, 11839 .help_str = "flow_director_mask ... : Set tunnel mode " 11840 "flow director's mask on NIC", 11841 .tokens = { 11842 (void *)&cmd_flow_director_mask, 11843 (void *)&cmd_flow_director_mask_port_id, 11844 (void *)&cmd_flow_director_mask_mode, 11845 (void *)&cmd_flow_director_mask_mode_tunnel, 11846 (void *)&cmd_flow_director_mask_vlan, 11847 (void *)&cmd_flow_director_mask_vlan_value, 11848 (void *)&cmd_flow_director_mask_mac, 11849 (void *)&cmd_flow_director_mask_mac_value, 11850 (void *)&cmd_flow_director_mask_tunnel_type, 11851 (void *)&cmd_flow_director_mask_tunnel_type_value, 11852 (void *)&cmd_flow_director_mask_tunnel_id, 11853 (void *)&cmd_flow_director_mask_tunnel_id_value, 11854 NULL, 11855 }, 11856 }; 11857 11858 /* *** deal with flow director mask on flexible payload *** */ 11859 struct cmd_flow_director_flex_mask_result { 11860 cmdline_fixed_string_t flow_director_flexmask; 11861 portid_t port_id; 11862 cmdline_fixed_string_t flow; 11863 cmdline_fixed_string_t flow_type; 11864 cmdline_fixed_string_t mask; 11865 }; 11866 11867 static void 11868 cmd_flow_director_flex_mask_parsed(void *parsed_result, 11869 __attribute__((unused)) struct cmdline *cl, 11870 __attribute__((unused)) void *data) 11871 { 11872 struct cmd_flow_director_flex_mask_result *res = parsed_result; 11873 struct rte_eth_fdir_info fdir_info; 11874 struct rte_eth_fdir_flex_mask flex_mask; 11875 struct rte_port *port; 11876 uint64_t flow_type_mask; 11877 uint16_t i; 11878 int ret; 11879 11880 port = &ports[res->port_id]; 11881 /** Check if the port is not started **/ 11882 if (port->port_status != RTE_PORT_STOPPED) { 11883 printf("Please stop port %d first\n", res->port_id); 11884 return; 11885 } 11886 11887 memset(&flex_mask, 0, sizeof(struct rte_eth_fdir_flex_mask)); 11888 ret = parse_flexbytes(res->mask, 11889 flex_mask.mask, 11890 RTE_ETH_FDIR_MAX_FLEXLEN); 11891 if (ret < 0) { 11892 printf("error: Cannot parse mask input.\n"); 11893 return; 11894 } 11895 11896 memset(&fdir_info, 0, sizeof(fdir_info)); 11897 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_FDIR, 11898 RTE_ETH_FILTER_INFO, &fdir_info); 11899 if (ret < 0) { 11900 printf("Cannot get FDir filter info\n"); 11901 return; 11902 } 11903 11904 if (!strcmp(res->flow_type, "none")) { 11905 /* means don't specify the flow type */ 11906 flex_mask.flow_type = RTE_ETH_FLOW_UNKNOWN; 11907 for (i = 0; i < RTE_ETH_FLOW_MAX; i++) 11908 memset(&port->dev_conf.fdir_conf.flex_conf.flex_mask[i], 11909 0, sizeof(struct rte_eth_fdir_flex_mask)); 11910 port->dev_conf.fdir_conf.flex_conf.nb_flexmasks = 1; 11911 rte_memcpy(&port->dev_conf.fdir_conf.flex_conf.flex_mask[0], 11912 &flex_mask, 11913 sizeof(struct rte_eth_fdir_flex_mask)); 11914 cmd_reconfig_device_queue(res->port_id, 1, 1); 11915 return; 11916 } 11917 flow_type_mask = fdir_info.flow_types_mask[0]; 11918 if (!strcmp(res->flow_type, "all")) { 11919 if (!flow_type_mask) { 11920 printf("No flow type supported\n"); 11921 return; 11922 } 11923 for (i = RTE_ETH_FLOW_UNKNOWN; i < RTE_ETH_FLOW_MAX; i++) { 11924 if (flow_type_mask & (1ULL << i)) { 11925 flex_mask.flow_type = i; 11926 fdir_set_flex_mask(res->port_id, &flex_mask); 11927 } 11928 } 11929 cmd_reconfig_device_queue(res->port_id, 1, 1); 11930 return; 11931 } 11932 flex_mask.flow_type = str2flowtype(res->flow_type); 11933 if (!(flow_type_mask & (1ULL << flex_mask.flow_type))) { 11934 printf("Flow type %s not supported on port %d\n", 11935 res->flow_type, res->port_id); 11936 return; 11937 } 11938 fdir_set_flex_mask(res->port_id, &flex_mask); 11939 cmd_reconfig_device_queue(res->port_id, 1, 1); 11940 } 11941 11942 cmdline_parse_token_string_t cmd_flow_director_flexmask = 11943 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_flex_mask_result, 11944 flow_director_flexmask, 11945 "flow_director_flex_mask"); 11946 cmdline_parse_token_num_t cmd_flow_director_flexmask_port_id = 11947 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_flex_mask_result, 11948 port_id, UINT16); 11949 cmdline_parse_token_string_t cmd_flow_director_flexmask_flow = 11950 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_flex_mask_result, 11951 flow, "flow"); 11952 cmdline_parse_token_string_t cmd_flow_director_flexmask_flow_type = 11953 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_flex_mask_result, 11954 flow_type, "none#ipv4-other#ipv4-frag#ipv4-tcp#ipv4-udp#ipv4-sctp#" 11955 "ipv6-other#ipv6-frag#ipv6-tcp#ipv6-udp#ipv6-sctp#l2_payload#all"); 11956 cmdline_parse_token_string_t cmd_flow_director_flexmask_mask = 11957 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_flex_mask_result, 11958 mask, NULL); 11959 11960 cmdline_parse_inst_t cmd_set_flow_director_flex_mask = { 11961 .f = cmd_flow_director_flex_mask_parsed, 11962 .data = NULL, 11963 .help_str = "flow_director_flex_mask ... : " 11964 "Set flow director's flex mask on NIC", 11965 .tokens = { 11966 (void *)&cmd_flow_director_flexmask, 11967 (void *)&cmd_flow_director_flexmask_port_id, 11968 (void *)&cmd_flow_director_flexmask_flow, 11969 (void *)&cmd_flow_director_flexmask_flow_type, 11970 (void *)&cmd_flow_director_flexmask_mask, 11971 NULL, 11972 }, 11973 }; 11974 11975 /* *** deal with flow director flexible payload configuration *** */ 11976 struct cmd_flow_director_flexpayload_result { 11977 cmdline_fixed_string_t flow_director_flexpayload; 11978 portid_t port_id; 11979 cmdline_fixed_string_t payload_layer; 11980 cmdline_fixed_string_t payload_cfg; 11981 }; 11982 11983 static inline int 11984 parse_offsets(const char *q_arg, uint16_t *offsets, uint16_t max_num) 11985 { 11986 char s[256]; 11987 const char *p, *p0 = q_arg; 11988 char *end; 11989 unsigned long int_fld; 11990 char *str_fld[max_num]; 11991 int i; 11992 unsigned size; 11993 int ret = -1; 11994 11995 p = strchr(p0, '('); 11996 if (p == NULL) 11997 return -1; 11998 ++p; 11999 p0 = strchr(p, ')'); 12000 if (p0 == NULL) 12001 return -1; 12002 12003 size = p0 - p; 12004 if (size >= sizeof(s)) 12005 return -1; 12006 12007 snprintf(s, sizeof(s), "%.*s", size, p); 12008 ret = rte_strsplit(s, sizeof(s), str_fld, max_num, ','); 12009 if (ret < 0 || ret > max_num) 12010 return -1; 12011 for (i = 0; i < ret; i++) { 12012 errno = 0; 12013 int_fld = strtoul(str_fld[i], &end, 0); 12014 if (errno != 0 || *end != '\0' || int_fld > UINT16_MAX) 12015 return -1; 12016 offsets[i] = (uint16_t)int_fld; 12017 } 12018 return ret; 12019 } 12020 12021 static void 12022 cmd_flow_director_flxpld_parsed(void *parsed_result, 12023 __attribute__((unused)) struct cmdline *cl, 12024 __attribute__((unused)) void *data) 12025 { 12026 struct cmd_flow_director_flexpayload_result *res = parsed_result; 12027 struct rte_eth_flex_payload_cfg flex_cfg; 12028 struct rte_port *port; 12029 int ret = 0; 12030 12031 port = &ports[res->port_id]; 12032 /** Check if the port is not started **/ 12033 if (port->port_status != RTE_PORT_STOPPED) { 12034 printf("Please stop port %d first\n", res->port_id); 12035 return; 12036 } 12037 12038 memset(&flex_cfg, 0, sizeof(struct rte_eth_flex_payload_cfg)); 12039 12040 if (!strcmp(res->payload_layer, "raw")) 12041 flex_cfg.type = RTE_ETH_RAW_PAYLOAD; 12042 else if (!strcmp(res->payload_layer, "l2")) 12043 flex_cfg.type = RTE_ETH_L2_PAYLOAD; 12044 else if (!strcmp(res->payload_layer, "l3")) 12045 flex_cfg.type = RTE_ETH_L3_PAYLOAD; 12046 else if (!strcmp(res->payload_layer, "l4")) 12047 flex_cfg.type = RTE_ETH_L4_PAYLOAD; 12048 12049 ret = parse_offsets(res->payload_cfg, flex_cfg.src_offset, 12050 RTE_ETH_FDIR_MAX_FLEXLEN); 12051 if (ret < 0) { 12052 printf("error: Cannot parse flex payload input.\n"); 12053 return; 12054 } 12055 12056 fdir_set_flex_payload(res->port_id, &flex_cfg); 12057 cmd_reconfig_device_queue(res->port_id, 1, 1); 12058 } 12059 12060 cmdline_parse_token_string_t cmd_flow_director_flexpayload = 12061 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_flexpayload_result, 12062 flow_director_flexpayload, 12063 "flow_director_flex_payload"); 12064 cmdline_parse_token_num_t cmd_flow_director_flexpayload_port_id = 12065 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_flexpayload_result, 12066 port_id, UINT16); 12067 cmdline_parse_token_string_t cmd_flow_director_flexpayload_payload_layer = 12068 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_flexpayload_result, 12069 payload_layer, "raw#l2#l3#l4"); 12070 cmdline_parse_token_string_t cmd_flow_director_flexpayload_payload_cfg = 12071 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_flexpayload_result, 12072 payload_cfg, NULL); 12073 12074 cmdline_parse_inst_t cmd_set_flow_director_flex_payload = { 12075 .f = cmd_flow_director_flxpld_parsed, 12076 .data = NULL, 12077 .help_str = "flow_director_flexpayload ... : " 12078 "Set flow director's flex payload on NIC", 12079 .tokens = { 12080 (void *)&cmd_flow_director_flexpayload, 12081 (void *)&cmd_flow_director_flexpayload_port_id, 12082 (void *)&cmd_flow_director_flexpayload_payload_layer, 12083 (void *)&cmd_flow_director_flexpayload_payload_cfg, 12084 NULL, 12085 }, 12086 }; 12087 12088 /* Generic flow interface command. */ 12089 extern cmdline_parse_inst_t cmd_flow; 12090 12091 /* *** Classification Filters Control *** */ 12092 /* *** Get symmetric hash enable per port *** */ 12093 struct cmd_get_sym_hash_ena_per_port_result { 12094 cmdline_fixed_string_t get_sym_hash_ena_per_port; 12095 portid_t port_id; 12096 }; 12097 12098 static void 12099 cmd_get_sym_hash_per_port_parsed(void *parsed_result, 12100 __rte_unused struct cmdline *cl, 12101 __rte_unused void *data) 12102 { 12103 struct cmd_get_sym_hash_ena_per_port_result *res = parsed_result; 12104 struct rte_eth_hash_filter_info info; 12105 int ret; 12106 12107 if (rte_eth_dev_filter_supported(res->port_id, 12108 RTE_ETH_FILTER_HASH) < 0) { 12109 printf("RTE_ETH_FILTER_HASH not supported on port: %d\n", 12110 res->port_id); 12111 return; 12112 } 12113 12114 memset(&info, 0, sizeof(info)); 12115 info.info_type = RTE_ETH_HASH_FILTER_SYM_HASH_ENA_PER_PORT; 12116 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_HASH, 12117 RTE_ETH_FILTER_GET, &info); 12118 12119 if (ret < 0) { 12120 printf("Cannot get symmetric hash enable per port " 12121 "on port %u\n", res->port_id); 12122 return; 12123 } 12124 12125 printf("Symmetric hash is %s on port %u\n", info.info.enable ? 12126 "enabled" : "disabled", res->port_id); 12127 } 12128 12129 cmdline_parse_token_string_t cmd_get_sym_hash_ena_per_port_all = 12130 TOKEN_STRING_INITIALIZER(struct cmd_get_sym_hash_ena_per_port_result, 12131 get_sym_hash_ena_per_port, "get_sym_hash_ena_per_port"); 12132 cmdline_parse_token_num_t cmd_get_sym_hash_ena_per_port_port_id = 12133 TOKEN_NUM_INITIALIZER(struct cmd_get_sym_hash_ena_per_port_result, 12134 port_id, UINT16); 12135 12136 cmdline_parse_inst_t cmd_get_sym_hash_ena_per_port = { 12137 .f = cmd_get_sym_hash_per_port_parsed, 12138 .data = NULL, 12139 .help_str = "get_sym_hash_ena_per_port <port_id>", 12140 .tokens = { 12141 (void *)&cmd_get_sym_hash_ena_per_port_all, 12142 (void *)&cmd_get_sym_hash_ena_per_port_port_id, 12143 NULL, 12144 }, 12145 }; 12146 12147 /* *** Set symmetric hash enable per port *** */ 12148 struct cmd_set_sym_hash_ena_per_port_result { 12149 cmdline_fixed_string_t set_sym_hash_ena_per_port; 12150 cmdline_fixed_string_t enable; 12151 portid_t port_id; 12152 }; 12153 12154 static void 12155 cmd_set_sym_hash_per_port_parsed(void *parsed_result, 12156 __rte_unused struct cmdline *cl, 12157 __rte_unused void *data) 12158 { 12159 struct cmd_set_sym_hash_ena_per_port_result *res = parsed_result; 12160 struct rte_eth_hash_filter_info info; 12161 int ret; 12162 12163 if (rte_eth_dev_filter_supported(res->port_id, 12164 RTE_ETH_FILTER_HASH) < 0) { 12165 printf("RTE_ETH_FILTER_HASH not supported on port: %d\n", 12166 res->port_id); 12167 return; 12168 } 12169 12170 memset(&info, 0, sizeof(info)); 12171 info.info_type = RTE_ETH_HASH_FILTER_SYM_HASH_ENA_PER_PORT; 12172 if (!strcmp(res->enable, "enable")) 12173 info.info.enable = 1; 12174 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_HASH, 12175 RTE_ETH_FILTER_SET, &info); 12176 if (ret < 0) { 12177 printf("Cannot set symmetric hash enable per port on " 12178 "port %u\n", res->port_id); 12179 return; 12180 } 12181 printf("Symmetric hash has been set to %s on port %u\n", 12182 res->enable, res->port_id); 12183 } 12184 12185 cmdline_parse_token_string_t cmd_set_sym_hash_ena_per_port_all = 12186 TOKEN_STRING_INITIALIZER(struct cmd_set_sym_hash_ena_per_port_result, 12187 set_sym_hash_ena_per_port, "set_sym_hash_ena_per_port"); 12188 cmdline_parse_token_num_t cmd_set_sym_hash_ena_per_port_port_id = 12189 TOKEN_NUM_INITIALIZER(struct cmd_set_sym_hash_ena_per_port_result, 12190 port_id, UINT16); 12191 cmdline_parse_token_string_t cmd_set_sym_hash_ena_per_port_enable = 12192 TOKEN_STRING_INITIALIZER(struct cmd_set_sym_hash_ena_per_port_result, 12193 enable, "enable#disable"); 12194 12195 cmdline_parse_inst_t cmd_set_sym_hash_ena_per_port = { 12196 .f = cmd_set_sym_hash_per_port_parsed, 12197 .data = NULL, 12198 .help_str = "set_sym_hash_ena_per_port <port_id> enable|disable", 12199 .tokens = { 12200 (void *)&cmd_set_sym_hash_ena_per_port_all, 12201 (void *)&cmd_set_sym_hash_ena_per_port_port_id, 12202 (void *)&cmd_set_sym_hash_ena_per_port_enable, 12203 NULL, 12204 }, 12205 }; 12206 12207 /* Get global config of hash function */ 12208 struct cmd_get_hash_global_config_result { 12209 cmdline_fixed_string_t get_hash_global_config; 12210 portid_t port_id; 12211 }; 12212 12213 static char * 12214 flowtype_to_str(uint16_t ftype) 12215 { 12216 uint16_t i; 12217 static struct { 12218 char str[16]; 12219 uint16_t ftype; 12220 } ftype_table[] = { 12221 {"ipv4", RTE_ETH_FLOW_IPV4}, 12222 {"ipv4-frag", RTE_ETH_FLOW_FRAG_IPV4}, 12223 {"ipv4-tcp", RTE_ETH_FLOW_NONFRAG_IPV4_TCP}, 12224 {"ipv4-udp", RTE_ETH_FLOW_NONFRAG_IPV4_UDP}, 12225 {"ipv4-sctp", RTE_ETH_FLOW_NONFRAG_IPV4_SCTP}, 12226 {"ipv4-other", RTE_ETH_FLOW_NONFRAG_IPV4_OTHER}, 12227 {"ipv6", RTE_ETH_FLOW_IPV6}, 12228 {"ipv6-frag", RTE_ETH_FLOW_FRAG_IPV6}, 12229 {"ipv6-tcp", RTE_ETH_FLOW_NONFRAG_IPV6_TCP}, 12230 {"ipv6-udp", RTE_ETH_FLOW_NONFRAG_IPV6_UDP}, 12231 {"ipv6-sctp", RTE_ETH_FLOW_NONFRAG_IPV6_SCTP}, 12232 {"ipv6-other", RTE_ETH_FLOW_NONFRAG_IPV6_OTHER}, 12233 {"l2_payload", RTE_ETH_FLOW_L2_PAYLOAD}, 12234 {"port", RTE_ETH_FLOW_PORT}, 12235 {"vxlan", RTE_ETH_FLOW_VXLAN}, 12236 {"geneve", RTE_ETH_FLOW_GENEVE}, 12237 {"nvgre", RTE_ETH_FLOW_NVGRE}, 12238 {"vxlan-gpe", RTE_ETH_FLOW_VXLAN_GPE}, 12239 }; 12240 12241 for (i = 0; i < RTE_DIM(ftype_table); i++) { 12242 if (ftype_table[i].ftype == ftype) 12243 return ftype_table[i].str; 12244 } 12245 12246 return NULL; 12247 } 12248 12249 static void 12250 cmd_get_hash_global_config_parsed(void *parsed_result, 12251 __rte_unused struct cmdline *cl, 12252 __rte_unused void *data) 12253 { 12254 struct cmd_get_hash_global_config_result *res = parsed_result; 12255 struct rte_eth_hash_filter_info info; 12256 uint32_t idx, offset; 12257 uint16_t i; 12258 char *str; 12259 int ret; 12260 12261 if (rte_eth_dev_filter_supported(res->port_id, 12262 RTE_ETH_FILTER_HASH) < 0) { 12263 printf("RTE_ETH_FILTER_HASH not supported on port %d\n", 12264 res->port_id); 12265 return; 12266 } 12267 12268 memset(&info, 0, sizeof(info)); 12269 info.info_type = RTE_ETH_HASH_FILTER_GLOBAL_CONFIG; 12270 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_HASH, 12271 RTE_ETH_FILTER_GET, &info); 12272 if (ret < 0) { 12273 printf("Cannot get hash global configurations by port %d\n", 12274 res->port_id); 12275 return; 12276 } 12277 12278 switch (info.info.global_conf.hash_func) { 12279 case RTE_ETH_HASH_FUNCTION_TOEPLITZ: 12280 printf("Hash function is Toeplitz\n"); 12281 break; 12282 case RTE_ETH_HASH_FUNCTION_SIMPLE_XOR: 12283 printf("Hash function is Simple XOR\n"); 12284 break; 12285 case RTE_ETH_HASH_FUNCTION_SYMMETRIC_TOEPLITZ: 12286 printf("Hash function is Symmetric Toeplitz\n"); 12287 break; 12288 default: 12289 printf("Unknown hash function\n"); 12290 break; 12291 } 12292 12293 for (i = 0; i < RTE_ETH_FLOW_MAX; i++) { 12294 idx = i / UINT64_BIT; 12295 offset = i % UINT64_BIT; 12296 if (!(info.info.global_conf.valid_bit_mask[idx] & 12297 (1ULL << offset))) 12298 continue; 12299 str = flowtype_to_str(i); 12300 if (!str) 12301 continue; 12302 printf("Symmetric hash is %s globally for flow type %s " 12303 "by port %d\n", 12304 ((info.info.global_conf.sym_hash_enable_mask[idx] & 12305 (1ULL << offset)) ? "enabled" : "disabled"), str, 12306 res->port_id); 12307 } 12308 } 12309 12310 cmdline_parse_token_string_t cmd_get_hash_global_config_all = 12311 TOKEN_STRING_INITIALIZER(struct cmd_get_hash_global_config_result, 12312 get_hash_global_config, "get_hash_global_config"); 12313 cmdline_parse_token_num_t cmd_get_hash_global_config_port_id = 12314 TOKEN_NUM_INITIALIZER(struct cmd_get_hash_global_config_result, 12315 port_id, UINT16); 12316 12317 cmdline_parse_inst_t cmd_get_hash_global_config = { 12318 .f = cmd_get_hash_global_config_parsed, 12319 .data = NULL, 12320 .help_str = "get_hash_global_config <port_id>", 12321 .tokens = { 12322 (void *)&cmd_get_hash_global_config_all, 12323 (void *)&cmd_get_hash_global_config_port_id, 12324 NULL, 12325 }, 12326 }; 12327 12328 /* Set global config of hash function */ 12329 struct cmd_set_hash_global_config_result { 12330 cmdline_fixed_string_t set_hash_global_config; 12331 portid_t port_id; 12332 cmdline_fixed_string_t hash_func; 12333 cmdline_fixed_string_t flow_type; 12334 cmdline_fixed_string_t enable; 12335 }; 12336 12337 static void 12338 cmd_set_hash_global_config_parsed(void *parsed_result, 12339 __rte_unused struct cmdline *cl, 12340 __rte_unused void *data) 12341 { 12342 struct cmd_set_hash_global_config_result *res = parsed_result; 12343 struct rte_eth_hash_filter_info info; 12344 uint32_t ftype, idx, offset; 12345 int ret; 12346 12347 if (rte_eth_dev_filter_supported(res->port_id, 12348 RTE_ETH_FILTER_HASH) < 0) { 12349 printf("RTE_ETH_FILTER_HASH not supported on port %d\n", 12350 res->port_id); 12351 return; 12352 } 12353 memset(&info, 0, sizeof(info)); 12354 info.info_type = RTE_ETH_HASH_FILTER_GLOBAL_CONFIG; 12355 if (!strcmp(res->hash_func, "toeplitz")) 12356 info.info.global_conf.hash_func = 12357 RTE_ETH_HASH_FUNCTION_TOEPLITZ; 12358 else if (!strcmp(res->hash_func, "simple_xor")) 12359 info.info.global_conf.hash_func = 12360 RTE_ETH_HASH_FUNCTION_SIMPLE_XOR; 12361 else if (!strcmp(res->hash_func, "symmetric_toeplitz")) 12362 info.info.global_conf.hash_func = 12363 RTE_ETH_HASH_FUNCTION_SYMMETRIC_TOEPLITZ; 12364 else if (!strcmp(res->hash_func, "default")) 12365 info.info.global_conf.hash_func = 12366 RTE_ETH_HASH_FUNCTION_DEFAULT; 12367 12368 ftype = str2flowtype(res->flow_type); 12369 idx = ftype / UINT64_BIT; 12370 offset = ftype % UINT64_BIT; 12371 info.info.global_conf.valid_bit_mask[idx] |= (1ULL << offset); 12372 if (!strcmp(res->enable, "enable")) 12373 info.info.global_conf.sym_hash_enable_mask[idx] |= 12374 (1ULL << offset); 12375 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_HASH, 12376 RTE_ETH_FILTER_SET, &info); 12377 if (ret < 0) 12378 printf("Cannot set global hash configurations by port %d\n", 12379 res->port_id); 12380 else 12381 printf("Global hash configurations have been set " 12382 "successfully by port %d\n", res->port_id); 12383 } 12384 12385 cmdline_parse_token_string_t cmd_set_hash_global_config_all = 12386 TOKEN_STRING_INITIALIZER(struct cmd_set_hash_global_config_result, 12387 set_hash_global_config, "set_hash_global_config"); 12388 cmdline_parse_token_num_t cmd_set_hash_global_config_port_id = 12389 TOKEN_NUM_INITIALIZER(struct cmd_set_hash_global_config_result, 12390 port_id, UINT16); 12391 cmdline_parse_token_string_t cmd_set_hash_global_config_hash_func = 12392 TOKEN_STRING_INITIALIZER(struct cmd_set_hash_global_config_result, 12393 hash_func, "toeplitz#simple_xor#symmetric_toeplitz#default"); 12394 cmdline_parse_token_string_t cmd_set_hash_global_config_flow_type = 12395 TOKEN_STRING_INITIALIZER(struct cmd_set_hash_global_config_result, 12396 flow_type, 12397 "ipv4#ipv4-frag#ipv4-tcp#ipv4-udp#ipv4-sctp#ipv4-other#ipv6#" 12398 "ipv6-frag#ipv6-tcp#ipv6-udp#ipv6-sctp#ipv6-other#l2_payload"); 12399 cmdline_parse_token_string_t cmd_set_hash_global_config_enable = 12400 TOKEN_STRING_INITIALIZER(struct cmd_set_hash_global_config_result, 12401 enable, "enable#disable"); 12402 12403 cmdline_parse_inst_t cmd_set_hash_global_config = { 12404 .f = cmd_set_hash_global_config_parsed, 12405 .data = NULL, 12406 .help_str = "set_hash_global_config <port_id> " 12407 "toeplitz|simple_xor|symmetric_toeplitz|default " 12408 "ipv4|ipv4-frag|ipv4-tcp|ipv4-udp|ipv4-sctp|ipv4-other|" 12409 "ipv6|ipv6-frag|ipv6-tcp|ipv6-udp|ipv6-sctp|ipv6-other|" 12410 "l2_payload enable|disable", 12411 .tokens = { 12412 (void *)&cmd_set_hash_global_config_all, 12413 (void *)&cmd_set_hash_global_config_port_id, 12414 (void *)&cmd_set_hash_global_config_hash_func, 12415 (void *)&cmd_set_hash_global_config_flow_type, 12416 (void *)&cmd_set_hash_global_config_enable, 12417 NULL, 12418 }, 12419 }; 12420 12421 /* Set hash input set */ 12422 struct cmd_set_hash_input_set_result { 12423 cmdline_fixed_string_t set_hash_input_set; 12424 portid_t port_id; 12425 cmdline_fixed_string_t flow_type; 12426 cmdline_fixed_string_t inset_field; 12427 cmdline_fixed_string_t select; 12428 }; 12429 12430 static enum rte_eth_input_set_field 12431 str2inset(char *string) 12432 { 12433 uint16_t i; 12434 12435 static const struct { 12436 char str[32]; 12437 enum rte_eth_input_set_field inset; 12438 } inset_table[] = { 12439 {"ethertype", RTE_ETH_INPUT_SET_L2_ETHERTYPE}, 12440 {"ovlan", RTE_ETH_INPUT_SET_L2_OUTER_VLAN}, 12441 {"ivlan", RTE_ETH_INPUT_SET_L2_INNER_VLAN}, 12442 {"src-ipv4", RTE_ETH_INPUT_SET_L3_SRC_IP4}, 12443 {"dst-ipv4", RTE_ETH_INPUT_SET_L3_DST_IP4}, 12444 {"ipv4-tos", RTE_ETH_INPUT_SET_L3_IP4_TOS}, 12445 {"ipv4-proto", RTE_ETH_INPUT_SET_L3_IP4_PROTO}, 12446 {"ipv4-ttl", RTE_ETH_INPUT_SET_L3_IP4_TTL}, 12447 {"src-ipv6", RTE_ETH_INPUT_SET_L3_SRC_IP6}, 12448 {"dst-ipv6", RTE_ETH_INPUT_SET_L3_DST_IP6}, 12449 {"ipv6-tc", RTE_ETH_INPUT_SET_L3_IP6_TC}, 12450 {"ipv6-next-header", RTE_ETH_INPUT_SET_L3_IP6_NEXT_HEADER}, 12451 {"ipv6-hop-limits", RTE_ETH_INPUT_SET_L3_IP6_HOP_LIMITS}, 12452 {"udp-src-port", RTE_ETH_INPUT_SET_L4_UDP_SRC_PORT}, 12453 {"udp-dst-port", RTE_ETH_INPUT_SET_L4_UDP_DST_PORT}, 12454 {"tcp-src-port", RTE_ETH_INPUT_SET_L4_TCP_SRC_PORT}, 12455 {"tcp-dst-port", RTE_ETH_INPUT_SET_L4_TCP_DST_PORT}, 12456 {"sctp-src-port", RTE_ETH_INPUT_SET_L4_SCTP_SRC_PORT}, 12457 {"sctp-dst-port", RTE_ETH_INPUT_SET_L4_SCTP_DST_PORT}, 12458 {"sctp-veri-tag", RTE_ETH_INPUT_SET_L4_SCTP_VERIFICATION_TAG}, 12459 {"udp-key", RTE_ETH_INPUT_SET_TUNNEL_L4_UDP_KEY}, 12460 {"gre-key", RTE_ETH_INPUT_SET_TUNNEL_GRE_KEY}, 12461 {"fld-1st", RTE_ETH_INPUT_SET_FLEX_PAYLOAD_1ST_WORD}, 12462 {"fld-2nd", RTE_ETH_INPUT_SET_FLEX_PAYLOAD_2ND_WORD}, 12463 {"fld-3rd", RTE_ETH_INPUT_SET_FLEX_PAYLOAD_3RD_WORD}, 12464 {"fld-4th", RTE_ETH_INPUT_SET_FLEX_PAYLOAD_4TH_WORD}, 12465 {"fld-5th", RTE_ETH_INPUT_SET_FLEX_PAYLOAD_5TH_WORD}, 12466 {"fld-6th", RTE_ETH_INPUT_SET_FLEX_PAYLOAD_6TH_WORD}, 12467 {"fld-7th", RTE_ETH_INPUT_SET_FLEX_PAYLOAD_7TH_WORD}, 12468 {"fld-8th", RTE_ETH_INPUT_SET_FLEX_PAYLOAD_8TH_WORD}, 12469 {"none", RTE_ETH_INPUT_SET_NONE}, 12470 }; 12471 12472 for (i = 0; i < RTE_DIM(inset_table); i++) { 12473 if (!strcmp(string, inset_table[i].str)) 12474 return inset_table[i].inset; 12475 } 12476 12477 return RTE_ETH_INPUT_SET_UNKNOWN; 12478 } 12479 12480 static void 12481 cmd_set_hash_input_set_parsed(void *parsed_result, 12482 __rte_unused struct cmdline *cl, 12483 __rte_unused void *data) 12484 { 12485 struct cmd_set_hash_input_set_result *res = parsed_result; 12486 struct rte_eth_hash_filter_info info; 12487 12488 memset(&info, 0, sizeof(info)); 12489 info.info_type = RTE_ETH_HASH_FILTER_INPUT_SET_SELECT; 12490 info.info.input_set_conf.flow_type = str2flowtype(res->flow_type); 12491 info.info.input_set_conf.field[0] = str2inset(res->inset_field); 12492 info.info.input_set_conf.inset_size = 1; 12493 if (!strcmp(res->select, "select")) 12494 info.info.input_set_conf.op = RTE_ETH_INPUT_SET_SELECT; 12495 else if (!strcmp(res->select, "add")) 12496 info.info.input_set_conf.op = RTE_ETH_INPUT_SET_ADD; 12497 rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_HASH, 12498 RTE_ETH_FILTER_SET, &info); 12499 } 12500 12501 cmdline_parse_token_string_t cmd_set_hash_input_set_cmd = 12502 TOKEN_STRING_INITIALIZER(struct cmd_set_hash_input_set_result, 12503 set_hash_input_set, "set_hash_input_set"); 12504 cmdline_parse_token_num_t cmd_set_hash_input_set_port_id = 12505 TOKEN_NUM_INITIALIZER(struct cmd_set_hash_input_set_result, 12506 port_id, UINT16); 12507 cmdline_parse_token_string_t cmd_set_hash_input_set_flow_type = 12508 TOKEN_STRING_INITIALIZER(struct cmd_set_hash_input_set_result, 12509 flow_type, NULL); 12510 cmdline_parse_token_string_t cmd_set_hash_input_set_field = 12511 TOKEN_STRING_INITIALIZER(struct cmd_set_hash_input_set_result, 12512 inset_field, 12513 "ovlan#ivlan#src-ipv4#dst-ipv4#src-ipv6#dst-ipv6#" 12514 "ipv4-tos#ipv4-proto#ipv6-tc#ipv6-next-header#udp-src-port#" 12515 "udp-dst-port#tcp-src-port#tcp-dst-port#sctp-src-port#" 12516 "sctp-dst-port#sctp-veri-tag#udp-key#gre-key#fld-1st#" 12517 "fld-2nd#fld-3rd#fld-4th#fld-5th#fld-6th#fld-7th#" 12518 "fld-8th#none"); 12519 cmdline_parse_token_string_t cmd_set_hash_input_set_select = 12520 TOKEN_STRING_INITIALIZER(struct cmd_set_hash_input_set_result, 12521 select, "select#add"); 12522 12523 cmdline_parse_inst_t cmd_set_hash_input_set = { 12524 .f = cmd_set_hash_input_set_parsed, 12525 .data = NULL, 12526 .help_str = "set_hash_input_set <port_id> " 12527 "ipv4-frag|ipv4-tcp|ipv4-udp|ipv4-sctp|ipv4-other|" 12528 "ipv6-frag|ipv6-tcp|ipv6-udp|ipv6-sctp|ipv6-other|l2_payload|<flowtype_id> " 12529 "ovlan|ivlan|src-ipv4|dst-ipv4|src-ipv6|dst-ipv6|ipv4-tos|ipv4-proto|" 12530 "ipv6-tc|ipv6-next-header|udp-src-port|udp-dst-port|tcp-src-port|" 12531 "tcp-dst-port|sctp-src-port|sctp-dst-port|sctp-veri-tag|udp-key|" 12532 "gre-key|fld-1st|fld-2nd|fld-3rd|fld-4th|fld-5th|fld-6th|" 12533 "fld-7th|fld-8th|none select|add", 12534 .tokens = { 12535 (void *)&cmd_set_hash_input_set_cmd, 12536 (void *)&cmd_set_hash_input_set_port_id, 12537 (void *)&cmd_set_hash_input_set_flow_type, 12538 (void *)&cmd_set_hash_input_set_field, 12539 (void *)&cmd_set_hash_input_set_select, 12540 NULL, 12541 }, 12542 }; 12543 12544 /* Set flow director input set */ 12545 struct cmd_set_fdir_input_set_result { 12546 cmdline_fixed_string_t set_fdir_input_set; 12547 portid_t port_id; 12548 cmdline_fixed_string_t flow_type; 12549 cmdline_fixed_string_t inset_field; 12550 cmdline_fixed_string_t select; 12551 }; 12552 12553 static void 12554 cmd_set_fdir_input_set_parsed(void *parsed_result, 12555 __rte_unused struct cmdline *cl, 12556 __rte_unused void *data) 12557 { 12558 struct cmd_set_fdir_input_set_result *res = parsed_result; 12559 struct rte_eth_fdir_filter_info info; 12560 12561 memset(&info, 0, sizeof(info)); 12562 info.info_type = RTE_ETH_FDIR_FILTER_INPUT_SET_SELECT; 12563 info.info.input_set_conf.flow_type = str2flowtype(res->flow_type); 12564 info.info.input_set_conf.field[0] = str2inset(res->inset_field); 12565 info.info.input_set_conf.inset_size = 1; 12566 if (!strcmp(res->select, "select")) 12567 info.info.input_set_conf.op = RTE_ETH_INPUT_SET_SELECT; 12568 else if (!strcmp(res->select, "add")) 12569 info.info.input_set_conf.op = RTE_ETH_INPUT_SET_ADD; 12570 rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_FDIR, 12571 RTE_ETH_FILTER_SET, &info); 12572 } 12573 12574 cmdline_parse_token_string_t cmd_set_fdir_input_set_cmd = 12575 TOKEN_STRING_INITIALIZER(struct cmd_set_fdir_input_set_result, 12576 set_fdir_input_set, "set_fdir_input_set"); 12577 cmdline_parse_token_num_t cmd_set_fdir_input_set_port_id = 12578 TOKEN_NUM_INITIALIZER(struct cmd_set_fdir_input_set_result, 12579 port_id, UINT16); 12580 cmdline_parse_token_string_t cmd_set_fdir_input_set_flow_type = 12581 TOKEN_STRING_INITIALIZER(struct cmd_set_fdir_input_set_result, 12582 flow_type, 12583 "ipv4-frag#ipv4-tcp#ipv4-udp#ipv4-sctp#ipv4-other#" 12584 "ipv6-frag#ipv6-tcp#ipv6-udp#ipv6-sctp#ipv6-other#l2_payload"); 12585 cmdline_parse_token_string_t cmd_set_fdir_input_set_field = 12586 TOKEN_STRING_INITIALIZER(struct cmd_set_fdir_input_set_result, 12587 inset_field, 12588 "ivlan#ethertype#src-ipv4#dst-ipv4#src-ipv6#dst-ipv6#" 12589 "ipv4-tos#ipv4-proto#ipv4-ttl#ipv6-tc#ipv6-next-header#" 12590 "ipv6-hop-limits#udp-src-port#udp-dst-port#" 12591 "tcp-src-port#tcp-dst-port#sctp-src-port#sctp-dst-port#" 12592 "sctp-veri-tag#none"); 12593 cmdline_parse_token_string_t cmd_set_fdir_input_set_select = 12594 TOKEN_STRING_INITIALIZER(struct cmd_set_fdir_input_set_result, 12595 select, "select#add"); 12596 12597 cmdline_parse_inst_t cmd_set_fdir_input_set = { 12598 .f = cmd_set_fdir_input_set_parsed, 12599 .data = NULL, 12600 .help_str = "set_fdir_input_set <port_id> " 12601 "ipv4-frag|ipv4-tcp|ipv4-udp|ipv4-sctp|ipv4-other|" 12602 "ipv6-frag|ipv6-tcp|ipv6-udp|ipv6-sctp|ipv6-other|l2_payload " 12603 "ivlan|ethertype|src-ipv4|dst-ipv4|src-ipv6|dst-ipv6|" 12604 "ipv4-tos|ipv4-proto|ipv4-ttl|ipv6-tc|ipv6-next-header|" 12605 "ipv6-hop-limits|udp-src-port|udp-dst-port|" 12606 "tcp-src-port|tcp-dst-port|sctp-src-port|sctp-dst-port|" 12607 "sctp-veri-tag|none select|add", 12608 .tokens = { 12609 (void *)&cmd_set_fdir_input_set_cmd, 12610 (void *)&cmd_set_fdir_input_set_port_id, 12611 (void *)&cmd_set_fdir_input_set_flow_type, 12612 (void *)&cmd_set_fdir_input_set_field, 12613 (void *)&cmd_set_fdir_input_set_select, 12614 NULL, 12615 }, 12616 }; 12617 12618 /* *** ADD/REMOVE A MULTICAST MAC ADDRESS TO/FROM A PORT *** */ 12619 struct cmd_mcast_addr_result { 12620 cmdline_fixed_string_t mcast_addr_cmd; 12621 cmdline_fixed_string_t what; 12622 uint16_t port_num; 12623 struct rte_ether_addr mc_addr; 12624 }; 12625 12626 static void cmd_mcast_addr_parsed(void *parsed_result, 12627 __attribute__((unused)) struct cmdline *cl, 12628 __attribute__((unused)) void *data) 12629 { 12630 struct cmd_mcast_addr_result *res = parsed_result; 12631 12632 if (!rte_is_multicast_ether_addr(&res->mc_addr)) { 12633 printf("Invalid multicast addr %02X:%02X:%02X:%02X:%02X:%02X\n", 12634 res->mc_addr.addr_bytes[0], res->mc_addr.addr_bytes[1], 12635 res->mc_addr.addr_bytes[2], res->mc_addr.addr_bytes[3], 12636 res->mc_addr.addr_bytes[4], res->mc_addr.addr_bytes[5]); 12637 return; 12638 } 12639 if (strcmp(res->what, "add") == 0) 12640 mcast_addr_add(res->port_num, &res->mc_addr); 12641 else 12642 mcast_addr_remove(res->port_num, &res->mc_addr); 12643 } 12644 12645 cmdline_parse_token_string_t cmd_mcast_addr_cmd = 12646 TOKEN_STRING_INITIALIZER(struct cmd_mcast_addr_result, 12647 mcast_addr_cmd, "mcast_addr"); 12648 cmdline_parse_token_string_t cmd_mcast_addr_what = 12649 TOKEN_STRING_INITIALIZER(struct cmd_mcast_addr_result, what, 12650 "add#remove"); 12651 cmdline_parse_token_num_t cmd_mcast_addr_portnum = 12652 TOKEN_NUM_INITIALIZER(struct cmd_mcast_addr_result, port_num, UINT16); 12653 cmdline_parse_token_etheraddr_t cmd_mcast_addr_addr = 12654 TOKEN_ETHERADDR_INITIALIZER(struct cmd_mac_addr_result, address); 12655 12656 cmdline_parse_inst_t cmd_mcast_addr = { 12657 .f = cmd_mcast_addr_parsed, 12658 .data = (void *)0, 12659 .help_str = "mcast_addr add|remove <port_id> <mcast_addr>: " 12660 "Add/Remove multicast MAC address on port_id", 12661 .tokens = { 12662 (void *)&cmd_mcast_addr_cmd, 12663 (void *)&cmd_mcast_addr_what, 12664 (void *)&cmd_mcast_addr_portnum, 12665 (void *)&cmd_mcast_addr_addr, 12666 NULL, 12667 }, 12668 }; 12669 12670 /* l2 tunnel config 12671 * only support E-tag now. 12672 */ 12673 12674 /* Ether type config */ 12675 struct cmd_config_l2_tunnel_eth_type_result { 12676 cmdline_fixed_string_t port; 12677 cmdline_fixed_string_t config; 12678 cmdline_fixed_string_t all; 12679 portid_t id; 12680 cmdline_fixed_string_t l2_tunnel; 12681 cmdline_fixed_string_t l2_tunnel_type; 12682 cmdline_fixed_string_t eth_type; 12683 uint16_t eth_type_val; 12684 }; 12685 12686 cmdline_parse_token_string_t cmd_config_l2_tunnel_eth_type_port = 12687 TOKEN_STRING_INITIALIZER 12688 (struct cmd_config_l2_tunnel_eth_type_result, 12689 port, "port"); 12690 cmdline_parse_token_string_t cmd_config_l2_tunnel_eth_type_config = 12691 TOKEN_STRING_INITIALIZER 12692 (struct cmd_config_l2_tunnel_eth_type_result, 12693 config, "config"); 12694 cmdline_parse_token_string_t cmd_config_l2_tunnel_eth_type_all_str = 12695 TOKEN_STRING_INITIALIZER 12696 (struct cmd_config_l2_tunnel_eth_type_result, 12697 all, "all"); 12698 cmdline_parse_token_num_t cmd_config_l2_tunnel_eth_type_id = 12699 TOKEN_NUM_INITIALIZER 12700 (struct cmd_config_l2_tunnel_eth_type_result, 12701 id, UINT16); 12702 cmdline_parse_token_string_t cmd_config_l2_tunnel_eth_type_l2_tunnel = 12703 TOKEN_STRING_INITIALIZER 12704 (struct cmd_config_l2_tunnel_eth_type_result, 12705 l2_tunnel, "l2-tunnel"); 12706 cmdline_parse_token_string_t cmd_config_l2_tunnel_eth_type_l2_tunnel_type = 12707 TOKEN_STRING_INITIALIZER 12708 (struct cmd_config_l2_tunnel_eth_type_result, 12709 l2_tunnel_type, "E-tag"); 12710 cmdline_parse_token_string_t cmd_config_l2_tunnel_eth_type_eth_type = 12711 TOKEN_STRING_INITIALIZER 12712 (struct cmd_config_l2_tunnel_eth_type_result, 12713 eth_type, "ether-type"); 12714 cmdline_parse_token_num_t cmd_config_l2_tunnel_eth_type_eth_type_val = 12715 TOKEN_NUM_INITIALIZER 12716 (struct cmd_config_l2_tunnel_eth_type_result, 12717 eth_type_val, UINT16); 12718 12719 static enum rte_eth_tunnel_type 12720 str2fdir_l2_tunnel_type(char *string) 12721 { 12722 uint32_t i = 0; 12723 12724 static const struct { 12725 char str[32]; 12726 enum rte_eth_tunnel_type type; 12727 } l2_tunnel_type_str[] = { 12728 {"E-tag", RTE_L2_TUNNEL_TYPE_E_TAG}, 12729 }; 12730 12731 for (i = 0; i < RTE_DIM(l2_tunnel_type_str); i++) { 12732 if (!strcmp(l2_tunnel_type_str[i].str, string)) 12733 return l2_tunnel_type_str[i].type; 12734 } 12735 return RTE_TUNNEL_TYPE_NONE; 12736 } 12737 12738 /* ether type config for all ports */ 12739 static void 12740 cmd_config_l2_tunnel_eth_type_all_parsed 12741 (void *parsed_result, 12742 __attribute__((unused)) struct cmdline *cl, 12743 __attribute__((unused)) void *data) 12744 { 12745 struct cmd_config_l2_tunnel_eth_type_result *res = parsed_result; 12746 struct rte_eth_l2_tunnel_conf entry; 12747 portid_t pid; 12748 12749 entry.l2_tunnel_type = str2fdir_l2_tunnel_type(res->l2_tunnel_type); 12750 entry.ether_type = res->eth_type_val; 12751 12752 RTE_ETH_FOREACH_DEV(pid) { 12753 rte_eth_dev_l2_tunnel_eth_type_conf(pid, &entry); 12754 } 12755 } 12756 12757 cmdline_parse_inst_t cmd_config_l2_tunnel_eth_type_all = { 12758 .f = cmd_config_l2_tunnel_eth_type_all_parsed, 12759 .data = NULL, 12760 .help_str = "port config all l2-tunnel E-tag ether-type <value>", 12761 .tokens = { 12762 (void *)&cmd_config_l2_tunnel_eth_type_port, 12763 (void *)&cmd_config_l2_tunnel_eth_type_config, 12764 (void *)&cmd_config_l2_tunnel_eth_type_all_str, 12765 (void *)&cmd_config_l2_tunnel_eth_type_l2_tunnel, 12766 (void *)&cmd_config_l2_tunnel_eth_type_l2_tunnel_type, 12767 (void *)&cmd_config_l2_tunnel_eth_type_eth_type, 12768 (void *)&cmd_config_l2_tunnel_eth_type_eth_type_val, 12769 NULL, 12770 }, 12771 }; 12772 12773 /* ether type config for a specific port */ 12774 static void 12775 cmd_config_l2_tunnel_eth_type_specific_parsed( 12776 void *parsed_result, 12777 __attribute__((unused)) struct cmdline *cl, 12778 __attribute__((unused)) void *data) 12779 { 12780 struct cmd_config_l2_tunnel_eth_type_result *res = 12781 parsed_result; 12782 struct rte_eth_l2_tunnel_conf entry; 12783 12784 if (port_id_is_invalid(res->id, ENABLED_WARN)) 12785 return; 12786 12787 entry.l2_tunnel_type = str2fdir_l2_tunnel_type(res->l2_tunnel_type); 12788 entry.ether_type = res->eth_type_val; 12789 12790 rte_eth_dev_l2_tunnel_eth_type_conf(res->id, &entry); 12791 } 12792 12793 cmdline_parse_inst_t cmd_config_l2_tunnel_eth_type_specific = { 12794 .f = cmd_config_l2_tunnel_eth_type_specific_parsed, 12795 .data = NULL, 12796 .help_str = "port config <port_id> l2-tunnel E-tag ether-type <value>", 12797 .tokens = { 12798 (void *)&cmd_config_l2_tunnel_eth_type_port, 12799 (void *)&cmd_config_l2_tunnel_eth_type_config, 12800 (void *)&cmd_config_l2_tunnel_eth_type_id, 12801 (void *)&cmd_config_l2_tunnel_eth_type_l2_tunnel, 12802 (void *)&cmd_config_l2_tunnel_eth_type_l2_tunnel_type, 12803 (void *)&cmd_config_l2_tunnel_eth_type_eth_type, 12804 (void *)&cmd_config_l2_tunnel_eth_type_eth_type_val, 12805 NULL, 12806 }, 12807 }; 12808 12809 /* Enable/disable l2 tunnel */ 12810 struct cmd_config_l2_tunnel_en_dis_result { 12811 cmdline_fixed_string_t port; 12812 cmdline_fixed_string_t config; 12813 cmdline_fixed_string_t all; 12814 portid_t id; 12815 cmdline_fixed_string_t l2_tunnel; 12816 cmdline_fixed_string_t l2_tunnel_type; 12817 cmdline_fixed_string_t en_dis; 12818 }; 12819 12820 cmdline_parse_token_string_t cmd_config_l2_tunnel_en_dis_port = 12821 TOKEN_STRING_INITIALIZER 12822 (struct cmd_config_l2_tunnel_en_dis_result, 12823 port, "port"); 12824 cmdline_parse_token_string_t cmd_config_l2_tunnel_en_dis_config = 12825 TOKEN_STRING_INITIALIZER 12826 (struct cmd_config_l2_tunnel_en_dis_result, 12827 config, "config"); 12828 cmdline_parse_token_string_t cmd_config_l2_tunnel_en_dis_all_str = 12829 TOKEN_STRING_INITIALIZER 12830 (struct cmd_config_l2_tunnel_en_dis_result, 12831 all, "all"); 12832 cmdline_parse_token_num_t cmd_config_l2_tunnel_en_dis_id = 12833 TOKEN_NUM_INITIALIZER 12834 (struct cmd_config_l2_tunnel_en_dis_result, 12835 id, UINT16); 12836 cmdline_parse_token_string_t cmd_config_l2_tunnel_en_dis_l2_tunnel = 12837 TOKEN_STRING_INITIALIZER 12838 (struct cmd_config_l2_tunnel_en_dis_result, 12839 l2_tunnel, "l2-tunnel"); 12840 cmdline_parse_token_string_t cmd_config_l2_tunnel_en_dis_l2_tunnel_type = 12841 TOKEN_STRING_INITIALIZER 12842 (struct cmd_config_l2_tunnel_en_dis_result, 12843 l2_tunnel_type, "E-tag"); 12844 cmdline_parse_token_string_t cmd_config_l2_tunnel_en_dis_en_dis = 12845 TOKEN_STRING_INITIALIZER 12846 (struct cmd_config_l2_tunnel_en_dis_result, 12847 en_dis, "enable#disable"); 12848 12849 /* enable/disable l2 tunnel for all ports */ 12850 static void 12851 cmd_config_l2_tunnel_en_dis_all_parsed( 12852 void *parsed_result, 12853 __attribute__((unused)) struct cmdline *cl, 12854 __attribute__((unused)) void *data) 12855 { 12856 struct cmd_config_l2_tunnel_en_dis_result *res = parsed_result; 12857 struct rte_eth_l2_tunnel_conf entry; 12858 portid_t pid; 12859 uint8_t en; 12860 12861 entry.l2_tunnel_type = str2fdir_l2_tunnel_type(res->l2_tunnel_type); 12862 12863 if (!strcmp("enable", res->en_dis)) 12864 en = 1; 12865 else 12866 en = 0; 12867 12868 RTE_ETH_FOREACH_DEV(pid) { 12869 rte_eth_dev_l2_tunnel_offload_set(pid, 12870 &entry, 12871 ETH_L2_TUNNEL_ENABLE_MASK, 12872 en); 12873 } 12874 } 12875 12876 cmdline_parse_inst_t cmd_config_l2_tunnel_en_dis_all = { 12877 .f = cmd_config_l2_tunnel_en_dis_all_parsed, 12878 .data = NULL, 12879 .help_str = "port config all l2-tunnel E-tag enable|disable", 12880 .tokens = { 12881 (void *)&cmd_config_l2_tunnel_en_dis_port, 12882 (void *)&cmd_config_l2_tunnel_en_dis_config, 12883 (void *)&cmd_config_l2_tunnel_en_dis_all_str, 12884 (void *)&cmd_config_l2_tunnel_en_dis_l2_tunnel, 12885 (void *)&cmd_config_l2_tunnel_en_dis_l2_tunnel_type, 12886 (void *)&cmd_config_l2_tunnel_en_dis_en_dis, 12887 NULL, 12888 }, 12889 }; 12890 12891 /* enable/disable l2 tunnel for a port */ 12892 static void 12893 cmd_config_l2_tunnel_en_dis_specific_parsed( 12894 void *parsed_result, 12895 __attribute__((unused)) struct cmdline *cl, 12896 __attribute__((unused)) void *data) 12897 { 12898 struct cmd_config_l2_tunnel_en_dis_result *res = 12899 parsed_result; 12900 struct rte_eth_l2_tunnel_conf entry; 12901 12902 if (port_id_is_invalid(res->id, ENABLED_WARN)) 12903 return; 12904 12905 entry.l2_tunnel_type = str2fdir_l2_tunnel_type(res->l2_tunnel_type); 12906 12907 if (!strcmp("enable", res->en_dis)) 12908 rte_eth_dev_l2_tunnel_offload_set(res->id, 12909 &entry, 12910 ETH_L2_TUNNEL_ENABLE_MASK, 12911 1); 12912 else 12913 rte_eth_dev_l2_tunnel_offload_set(res->id, 12914 &entry, 12915 ETH_L2_TUNNEL_ENABLE_MASK, 12916 0); 12917 } 12918 12919 cmdline_parse_inst_t cmd_config_l2_tunnel_en_dis_specific = { 12920 .f = cmd_config_l2_tunnel_en_dis_specific_parsed, 12921 .data = NULL, 12922 .help_str = "port config <port_id> l2-tunnel E-tag enable|disable", 12923 .tokens = { 12924 (void *)&cmd_config_l2_tunnel_en_dis_port, 12925 (void *)&cmd_config_l2_tunnel_en_dis_config, 12926 (void *)&cmd_config_l2_tunnel_en_dis_id, 12927 (void *)&cmd_config_l2_tunnel_en_dis_l2_tunnel, 12928 (void *)&cmd_config_l2_tunnel_en_dis_l2_tunnel_type, 12929 (void *)&cmd_config_l2_tunnel_en_dis_en_dis, 12930 NULL, 12931 }, 12932 }; 12933 12934 /* E-tag configuration */ 12935 12936 /* Common result structure for all E-tag configuration */ 12937 struct cmd_config_e_tag_result { 12938 cmdline_fixed_string_t e_tag; 12939 cmdline_fixed_string_t set; 12940 cmdline_fixed_string_t insertion; 12941 cmdline_fixed_string_t stripping; 12942 cmdline_fixed_string_t forwarding; 12943 cmdline_fixed_string_t filter; 12944 cmdline_fixed_string_t add; 12945 cmdline_fixed_string_t del; 12946 cmdline_fixed_string_t on; 12947 cmdline_fixed_string_t off; 12948 cmdline_fixed_string_t on_off; 12949 cmdline_fixed_string_t port_tag_id; 12950 uint32_t port_tag_id_val; 12951 cmdline_fixed_string_t e_tag_id; 12952 uint16_t e_tag_id_val; 12953 cmdline_fixed_string_t dst_pool; 12954 uint8_t dst_pool_val; 12955 cmdline_fixed_string_t port; 12956 portid_t port_id; 12957 cmdline_fixed_string_t vf; 12958 uint8_t vf_id; 12959 }; 12960 12961 /* Common CLI fields for all E-tag configuration */ 12962 cmdline_parse_token_string_t cmd_config_e_tag_e_tag = 12963 TOKEN_STRING_INITIALIZER 12964 (struct cmd_config_e_tag_result, 12965 e_tag, "E-tag"); 12966 cmdline_parse_token_string_t cmd_config_e_tag_set = 12967 TOKEN_STRING_INITIALIZER 12968 (struct cmd_config_e_tag_result, 12969 set, "set"); 12970 cmdline_parse_token_string_t cmd_config_e_tag_insertion = 12971 TOKEN_STRING_INITIALIZER 12972 (struct cmd_config_e_tag_result, 12973 insertion, "insertion"); 12974 cmdline_parse_token_string_t cmd_config_e_tag_stripping = 12975 TOKEN_STRING_INITIALIZER 12976 (struct cmd_config_e_tag_result, 12977 stripping, "stripping"); 12978 cmdline_parse_token_string_t cmd_config_e_tag_forwarding = 12979 TOKEN_STRING_INITIALIZER 12980 (struct cmd_config_e_tag_result, 12981 forwarding, "forwarding"); 12982 cmdline_parse_token_string_t cmd_config_e_tag_filter = 12983 TOKEN_STRING_INITIALIZER 12984 (struct cmd_config_e_tag_result, 12985 filter, "filter"); 12986 cmdline_parse_token_string_t cmd_config_e_tag_add = 12987 TOKEN_STRING_INITIALIZER 12988 (struct cmd_config_e_tag_result, 12989 add, "add"); 12990 cmdline_parse_token_string_t cmd_config_e_tag_del = 12991 TOKEN_STRING_INITIALIZER 12992 (struct cmd_config_e_tag_result, 12993 del, "del"); 12994 cmdline_parse_token_string_t cmd_config_e_tag_on = 12995 TOKEN_STRING_INITIALIZER 12996 (struct cmd_config_e_tag_result, 12997 on, "on"); 12998 cmdline_parse_token_string_t cmd_config_e_tag_off = 12999 TOKEN_STRING_INITIALIZER 13000 (struct cmd_config_e_tag_result, 13001 off, "off"); 13002 cmdline_parse_token_string_t cmd_config_e_tag_on_off = 13003 TOKEN_STRING_INITIALIZER 13004 (struct cmd_config_e_tag_result, 13005 on_off, "on#off"); 13006 cmdline_parse_token_string_t cmd_config_e_tag_port_tag_id = 13007 TOKEN_STRING_INITIALIZER 13008 (struct cmd_config_e_tag_result, 13009 port_tag_id, "port-tag-id"); 13010 cmdline_parse_token_num_t cmd_config_e_tag_port_tag_id_val = 13011 TOKEN_NUM_INITIALIZER 13012 (struct cmd_config_e_tag_result, 13013 port_tag_id_val, UINT32); 13014 cmdline_parse_token_string_t cmd_config_e_tag_e_tag_id = 13015 TOKEN_STRING_INITIALIZER 13016 (struct cmd_config_e_tag_result, 13017 e_tag_id, "e-tag-id"); 13018 cmdline_parse_token_num_t cmd_config_e_tag_e_tag_id_val = 13019 TOKEN_NUM_INITIALIZER 13020 (struct cmd_config_e_tag_result, 13021 e_tag_id_val, UINT16); 13022 cmdline_parse_token_string_t cmd_config_e_tag_dst_pool = 13023 TOKEN_STRING_INITIALIZER 13024 (struct cmd_config_e_tag_result, 13025 dst_pool, "dst-pool"); 13026 cmdline_parse_token_num_t cmd_config_e_tag_dst_pool_val = 13027 TOKEN_NUM_INITIALIZER 13028 (struct cmd_config_e_tag_result, 13029 dst_pool_val, UINT8); 13030 cmdline_parse_token_string_t cmd_config_e_tag_port = 13031 TOKEN_STRING_INITIALIZER 13032 (struct cmd_config_e_tag_result, 13033 port, "port"); 13034 cmdline_parse_token_num_t cmd_config_e_tag_port_id = 13035 TOKEN_NUM_INITIALIZER 13036 (struct cmd_config_e_tag_result, 13037 port_id, UINT16); 13038 cmdline_parse_token_string_t cmd_config_e_tag_vf = 13039 TOKEN_STRING_INITIALIZER 13040 (struct cmd_config_e_tag_result, 13041 vf, "vf"); 13042 cmdline_parse_token_num_t cmd_config_e_tag_vf_id = 13043 TOKEN_NUM_INITIALIZER 13044 (struct cmd_config_e_tag_result, 13045 vf_id, UINT8); 13046 13047 /* E-tag insertion configuration */ 13048 static void 13049 cmd_config_e_tag_insertion_en_parsed( 13050 void *parsed_result, 13051 __attribute__((unused)) struct cmdline *cl, 13052 __attribute__((unused)) void *data) 13053 { 13054 struct cmd_config_e_tag_result *res = 13055 parsed_result; 13056 struct rte_eth_l2_tunnel_conf entry; 13057 13058 if (port_id_is_invalid(res->port_id, ENABLED_WARN)) 13059 return; 13060 13061 entry.l2_tunnel_type = RTE_L2_TUNNEL_TYPE_E_TAG; 13062 entry.tunnel_id = res->port_tag_id_val; 13063 entry.vf_id = res->vf_id; 13064 rte_eth_dev_l2_tunnel_offload_set(res->port_id, 13065 &entry, 13066 ETH_L2_TUNNEL_INSERTION_MASK, 13067 1); 13068 } 13069 13070 static void 13071 cmd_config_e_tag_insertion_dis_parsed( 13072 void *parsed_result, 13073 __attribute__((unused)) struct cmdline *cl, 13074 __attribute__((unused)) void *data) 13075 { 13076 struct cmd_config_e_tag_result *res = 13077 parsed_result; 13078 struct rte_eth_l2_tunnel_conf entry; 13079 13080 if (port_id_is_invalid(res->port_id, ENABLED_WARN)) 13081 return; 13082 13083 entry.l2_tunnel_type = RTE_L2_TUNNEL_TYPE_E_TAG; 13084 entry.vf_id = res->vf_id; 13085 13086 rte_eth_dev_l2_tunnel_offload_set(res->port_id, 13087 &entry, 13088 ETH_L2_TUNNEL_INSERTION_MASK, 13089 0); 13090 } 13091 13092 cmdline_parse_inst_t cmd_config_e_tag_insertion_en = { 13093 .f = cmd_config_e_tag_insertion_en_parsed, 13094 .data = NULL, 13095 .help_str = "E-tag ... : E-tag insertion enable", 13096 .tokens = { 13097 (void *)&cmd_config_e_tag_e_tag, 13098 (void *)&cmd_config_e_tag_set, 13099 (void *)&cmd_config_e_tag_insertion, 13100 (void *)&cmd_config_e_tag_on, 13101 (void *)&cmd_config_e_tag_port_tag_id, 13102 (void *)&cmd_config_e_tag_port_tag_id_val, 13103 (void *)&cmd_config_e_tag_port, 13104 (void *)&cmd_config_e_tag_port_id, 13105 (void *)&cmd_config_e_tag_vf, 13106 (void *)&cmd_config_e_tag_vf_id, 13107 NULL, 13108 }, 13109 }; 13110 13111 cmdline_parse_inst_t cmd_config_e_tag_insertion_dis = { 13112 .f = cmd_config_e_tag_insertion_dis_parsed, 13113 .data = NULL, 13114 .help_str = "E-tag ... : E-tag insertion disable", 13115 .tokens = { 13116 (void *)&cmd_config_e_tag_e_tag, 13117 (void *)&cmd_config_e_tag_set, 13118 (void *)&cmd_config_e_tag_insertion, 13119 (void *)&cmd_config_e_tag_off, 13120 (void *)&cmd_config_e_tag_port, 13121 (void *)&cmd_config_e_tag_port_id, 13122 (void *)&cmd_config_e_tag_vf, 13123 (void *)&cmd_config_e_tag_vf_id, 13124 NULL, 13125 }, 13126 }; 13127 13128 /* E-tag stripping configuration */ 13129 static void 13130 cmd_config_e_tag_stripping_parsed( 13131 void *parsed_result, 13132 __attribute__((unused)) struct cmdline *cl, 13133 __attribute__((unused)) void *data) 13134 { 13135 struct cmd_config_e_tag_result *res = 13136 parsed_result; 13137 struct rte_eth_l2_tunnel_conf entry; 13138 13139 if (port_id_is_invalid(res->port_id, ENABLED_WARN)) 13140 return; 13141 13142 entry.l2_tunnel_type = RTE_L2_TUNNEL_TYPE_E_TAG; 13143 13144 if (!strcmp(res->on_off, "on")) 13145 rte_eth_dev_l2_tunnel_offload_set 13146 (res->port_id, 13147 &entry, 13148 ETH_L2_TUNNEL_STRIPPING_MASK, 13149 1); 13150 else 13151 rte_eth_dev_l2_tunnel_offload_set 13152 (res->port_id, 13153 &entry, 13154 ETH_L2_TUNNEL_STRIPPING_MASK, 13155 0); 13156 } 13157 13158 cmdline_parse_inst_t cmd_config_e_tag_stripping_en_dis = { 13159 .f = cmd_config_e_tag_stripping_parsed, 13160 .data = NULL, 13161 .help_str = "E-tag ... : E-tag stripping enable/disable", 13162 .tokens = { 13163 (void *)&cmd_config_e_tag_e_tag, 13164 (void *)&cmd_config_e_tag_set, 13165 (void *)&cmd_config_e_tag_stripping, 13166 (void *)&cmd_config_e_tag_on_off, 13167 (void *)&cmd_config_e_tag_port, 13168 (void *)&cmd_config_e_tag_port_id, 13169 NULL, 13170 }, 13171 }; 13172 13173 /* E-tag forwarding configuration */ 13174 static void 13175 cmd_config_e_tag_forwarding_parsed( 13176 void *parsed_result, 13177 __attribute__((unused)) struct cmdline *cl, 13178 __attribute__((unused)) void *data) 13179 { 13180 struct cmd_config_e_tag_result *res = parsed_result; 13181 struct rte_eth_l2_tunnel_conf entry; 13182 13183 if (port_id_is_invalid(res->port_id, ENABLED_WARN)) 13184 return; 13185 13186 entry.l2_tunnel_type = RTE_L2_TUNNEL_TYPE_E_TAG; 13187 13188 if (!strcmp(res->on_off, "on")) 13189 rte_eth_dev_l2_tunnel_offload_set 13190 (res->port_id, 13191 &entry, 13192 ETH_L2_TUNNEL_FORWARDING_MASK, 13193 1); 13194 else 13195 rte_eth_dev_l2_tunnel_offload_set 13196 (res->port_id, 13197 &entry, 13198 ETH_L2_TUNNEL_FORWARDING_MASK, 13199 0); 13200 } 13201 13202 cmdline_parse_inst_t cmd_config_e_tag_forwarding_en_dis = { 13203 .f = cmd_config_e_tag_forwarding_parsed, 13204 .data = NULL, 13205 .help_str = "E-tag ... : E-tag forwarding enable/disable", 13206 .tokens = { 13207 (void *)&cmd_config_e_tag_e_tag, 13208 (void *)&cmd_config_e_tag_set, 13209 (void *)&cmd_config_e_tag_forwarding, 13210 (void *)&cmd_config_e_tag_on_off, 13211 (void *)&cmd_config_e_tag_port, 13212 (void *)&cmd_config_e_tag_port_id, 13213 NULL, 13214 }, 13215 }; 13216 13217 /* E-tag filter configuration */ 13218 static void 13219 cmd_config_e_tag_filter_add_parsed( 13220 void *parsed_result, 13221 __attribute__((unused)) struct cmdline *cl, 13222 __attribute__((unused)) void *data) 13223 { 13224 struct cmd_config_e_tag_result *res = parsed_result; 13225 struct rte_eth_l2_tunnel_conf entry; 13226 int ret = 0; 13227 13228 if (port_id_is_invalid(res->port_id, ENABLED_WARN)) 13229 return; 13230 13231 if (res->e_tag_id_val > 0x3fff) { 13232 printf("e-tag-id must be equal or less than 0x3fff.\n"); 13233 return; 13234 } 13235 13236 ret = rte_eth_dev_filter_supported(res->port_id, 13237 RTE_ETH_FILTER_L2_TUNNEL); 13238 if (ret < 0) { 13239 printf("E-tag filter is not supported on port %u.\n", 13240 res->port_id); 13241 return; 13242 } 13243 13244 entry.l2_tunnel_type = RTE_L2_TUNNEL_TYPE_E_TAG; 13245 entry.tunnel_id = res->e_tag_id_val; 13246 entry.pool = res->dst_pool_val; 13247 13248 ret = rte_eth_dev_filter_ctrl(res->port_id, 13249 RTE_ETH_FILTER_L2_TUNNEL, 13250 RTE_ETH_FILTER_ADD, 13251 &entry); 13252 if (ret < 0) 13253 printf("E-tag filter programming error: (%s)\n", 13254 strerror(-ret)); 13255 } 13256 13257 cmdline_parse_inst_t cmd_config_e_tag_filter_add = { 13258 .f = cmd_config_e_tag_filter_add_parsed, 13259 .data = NULL, 13260 .help_str = "E-tag ... : E-tag filter add", 13261 .tokens = { 13262 (void *)&cmd_config_e_tag_e_tag, 13263 (void *)&cmd_config_e_tag_set, 13264 (void *)&cmd_config_e_tag_filter, 13265 (void *)&cmd_config_e_tag_add, 13266 (void *)&cmd_config_e_tag_e_tag_id, 13267 (void *)&cmd_config_e_tag_e_tag_id_val, 13268 (void *)&cmd_config_e_tag_dst_pool, 13269 (void *)&cmd_config_e_tag_dst_pool_val, 13270 (void *)&cmd_config_e_tag_port, 13271 (void *)&cmd_config_e_tag_port_id, 13272 NULL, 13273 }, 13274 }; 13275 13276 static void 13277 cmd_config_e_tag_filter_del_parsed( 13278 void *parsed_result, 13279 __attribute__((unused)) struct cmdline *cl, 13280 __attribute__((unused)) void *data) 13281 { 13282 struct cmd_config_e_tag_result *res = parsed_result; 13283 struct rte_eth_l2_tunnel_conf entry; 13284 int ret = 0; 13285 13286 if (port_id_is_invalid(res->port_id, ENABLED_WARN)) 13287 return; 13288 13289 if (res->e_tag_id_val > 0x3fff) { 13290 printf("e-tag-id must be less than 0x3fff.\n"); 13291 return; 13292 } 13293 13294 ret = rte_eth_dev_filter_supported(res->port_id, 13295 RTE_ETH_FILTER_L2_TUNNEL); 13296 if (ret < 0) { 13297 printf("E-tag filter is not supported on port %u.\n", 13298 res->port_id); 13299 return; 13300 } 13301 13302 entry.l2_tunnel_type = RTE_L2_TUNNEL_TYPE_E_TAG; 13303 entry.tunnel_id = res->e_tag_id_val; 13304 13305 ret = rte_eth_dev_filter_ctrl(res->port_id, 13306 RTE_ETH_FILTER_L2_TUNNEL, 13307 RTE_ETH_FILTER_DELETE, 13308 &entry); 13309 if (ret < 0) 13310 printf("E-tag filter programming error: (%s)\n", 13311 strerror(-ret)); 13312 } 13313 13314 cmdline_parse_inst_t cmd_config_e_tag_filter_del = { 13315 .f = cmd_config_e_tag_filter_del_parsed, 13316 .data = NULL, 13317 .help_str = "E-tag ... : E-tag filter delete", 13318 .tokens = { 13319 (void *)&cmd_config_e_tag_e_tag, 13320 (void *)&cmd_config_e_tag_set, 13321 (void *)&cmd_config_e_tag_filter, 13322 (void *)&cmd_config_e_tag_del, 13323 (void *)&cmd_config_e_tag_e_tag_id, 13324 (void *)&cmd_config_e_tag_e_tag_id_val, 13325 (void *)&cmd_config_e_tag_port, 13326 (void *)&cmd_config_e_tag_port_id, 13327 NULL, 13328 }, 13329 }; 13330 13331 /* vf vlan anti spoof configuration */ 13332 13333 /* Common result structure for vf vlan anti spoof */ 13334 struct cmd_vf_vlan_anti_spoof_result { 13335 cmdline_fixed_string_t set; 13336 cmdline_fixed_string_t vf; 13337 cmdline_fixed_string_t vlan; 13338 cmdline_fixed_string_t antispoof; 13339 portid_t port_id; 13340 uint32_t vf_id; 13341 cmdline_fixed_string_t on_off; 13342 }; 13343 13344 /* Common CLI fields for vf vlan anti spoof enable disable */ 13345 cmdline_parse_token_string_t cmd_vf_vlan_anti_spoof_set = 13346 TOKEN_STRING_INITIALIZER 13347 (struct cmd_vf_vlan_anti_spoof_result, 13348 set, "set"); 13349 cmdline_parse_token_string_t cmd_vf_vlan_anti_spoof_vf = 13350 TOKEN_STRING_INITIALIZER 13351 (struct cmd_vf_vlan_anti_spoof_result, 13352 vf, "vf"); 13353 cmdline_parse_token_string_t cmd_vf_vlan_anti_spoof_vlan = 13354 TOKEN_STRING_INITIALIZER 13355 (struct cmd_vf_vlan_anti_spoof_result, 13356 vlan, "vlan"); 13357 cmdline_parse_token_string_t cmd_vf_vlan_anti_spoof_antispoof = 13358 TOKEN_STRING_INITIALIZER 13359 (struct cmd_vf_vlan_anti_spoof_result, 13360 antispoof, "antispoof"); 13361 cmdline_parse_token_num_t cmd_vf_vlan_anti_spoof_port_id = 13362 TOKEN_NUM_INITIALIZER 13363 (struct cmd_vf_vlan_anti_spoof_result, 13364 port_id, UINT16); 13365 cmdline_parse_token_num_t cmd_vf_vlan_anti_spoof_vf_id = 13366 TOKEN_NUM_INITIALIZER 13367 (struct cmd_vf_vlan_anti_spoof_result, 13368 vf_id, UINT32); 13369 cmdline_parse_token_string_t cmd_vf_vlan_anti_spoof_on_off = 13370 TOKEN_STRING_INITIALIZER 13371 (struct cmd_vf_vlan_anti_spoof_result, 13372 on_off, "on#off"); 13373 13374 static void 13375 cmd_set_vf_vlan_anti_spoof_parsed( 13376 void *parsed_result, 13377 __attribute__((unused)) struct cmdline *cl, 13378 __attribute__((unused)) void *data) 13379 { 13380 struct cmd_vf_vlan_anti_spoof_result *res = parsed_result; 13381 int ret = -ENOTSUP; 13382 13383 __rte_unused int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0; 13384 13385 if (port_id_is_invalid(res->port_id, ENABLED_WARN)) 13386 return; 13387 13388 #ifdef RTE_LIBRTE_IXGBE_PMD 13389 if (ret == -ENOTSUP) 13390 ret = rte_pmd_ixgbe_set_vf_vlan_anti_spoof(res->port_id, 13391 res->vf_id, is_on); 13392 #endif 13393 #ifdef RTE_LIBRTE_I40E_PMD 13394 if (ret == -ENOTSUP) 13395 ret = rte_pmd_i40e_set_vf_vlan_anti_spoof(res->port_id, 13396 res->vf_id, is_on); 13397 #endif 13398 #ifdef RTE_LIBRTE_BNXT_PMD 13399 if (ret == -ENOTSUP) 13400 ret = rte_pmd_bnxt_set_vf_vlan_anti_spoof(res->port_id, 13401 res->vf_id, is_on); 13402 #endif 13403 13404 switch (ret) { 13405 case 0: 13406 break; 13407 case -EINVAL: 13408 printf("invalid vf_id %d\n", res->vf_id); 13409 break; 13410 case -ENODEV: 13411 printf("invalid port_id %d\n", res->port_id); 13412 break; 13413 case -ENOTSUP: 13414 printf("function not implemented\n"); 13415 break; 13416 default: 13417 printf("programming error: (%s)\n", strerror(-ret)); 13418 } 13419 } 13420 13421 cmdline_parse_inst_t cmd_set_vf_vlan_anti_spoof = { 13422 .f = cmd_set_vf_vlan_anti_spoof_parsed, 13423 .data = NULL, 13424 .help_str = "set vf vlan antispoof <port_id> <vf_id> on|off", 13425 .tokens = { 13426 (void *)&cmd_vf_vlan_anti_spoof_set, 13427 (void *)&cmd_vf_vlan_anti_spoof_vf, 13428 (void *)&cmd_vf_vlan_anti_spoof_vlan, 13429 (void *)&cmd_vf_vlan_anti_spoof_antispoof, 13430 (void *)&cmd_vf_vlan_anti_spoof_port_id, 13431 (void *)&cmd_vf_vlan_anti_spoof_vf_id, 13432 (void *)&cmd_vf_vlan_anti_spoof_on_off, 13433 NULL, 13434 }, 13435 }; 13436 13437 /* vf mac anti spoof configuration */ 13438 13439 /* Common result structure for vf mac anti spoof */ 13440 struct cmd_vf_mac_anti_spoof_result { 13441 cmdline_fixed_string_t set; 13442 cmdline_fixed_string_t vf; 13443 cmdline_fixed_string_t mac; 13444 cmdline_fixed_string_t antispoof; 13445 portid_t port_id; 13446 uint32_t vf_id; 13447 cmdline_fixed_string_t on_off; 13448 }; 13449 13450 /* Common CLI fields for vf mac anti spoof enable disable */ 13451 cmdline_parse_token_string_t cmd_vf_mac_anti_spoof_set = 13452 TOKEN_STRING_INITIALIZER 13453 (struct cmd_vf_mac_anti_spoof_result, 13454 set, "set"); 13455 cmdline_parse_token_string_t cmd_vf_mac_anti_spoof_vf = 13456 TOKEN_STRING_INITIALIZER 13457 (struct cmd_vf_mac_anti_spoof_result, 13458 vf, "vf"); 13459 cmdline_parse_token_string_t cmd_vf_mac_anti_spoof_mac = 13460 TOKEN_STRING_INITIALIZER 13461 (struct cmd_vf_mac_anti_spoof_result, 13462 mac, "mac"); 13463 cmdline_parse_token_string_t cmd_vf_mac_anti_spoof_antispoof = 13464 TOKEN_STRING_INITIALIZER 13465 (struct cmd_vf_mac_anti_spoof_result, 13466 antispoof, "antispoof"); 13467 cmdline_parse_token_num_t cmd_vf_mac_anti_spoof_port_id = 13468 TOKEN_NUM_INITIALIZER 13469 (struct cmd_vf_mac_anti_spoof_result, 13470 port_id, UINT16); 13471 cmdline_parse_token_num_t cmd_vf_mac_anti_spoof_vf_id = 13472 TOKEN_NUM_INITIALIZER 13473 (struct cmd_vf_mac_anti_spoof_result, 13474 vf_id, UINT32); 13475 cmdline_parse_token_string_t cmd_vf_mac_anti_spoof_on_off = 13476 TOKEN_STRING_INITIALIZER 13477 (struct cmd_vf_mac_anti_spoof_result, 13478 on_off, "on#off"); 13479 13480 static void 13481 cmd_set_vf_mac_anti_spoof_parsed( 13482 void *parsed_result, 13483 __attribute__((unused)) struct cmdline *cl, 13484 __attribute__((unused)) void *data) 13485 { 13486 struct cmd_vf_mac_anti_spoof_result *res = parsed_result; 13487 int ret = -ENOTSUP; 13488 13489 __rte_unused int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0; 13490 13491 if (port_id_is_invalid(res->port_id, ENABLED_WARN)) 13492 return; 13493 13494 #ifdef RTE_LIBRTE_IXGBE_PMD 13495 if (ret == -ENOTSUP) 13496 ret = rte_pmd_ixgbe_set_vf_mac_anti_spoof(res->port_id, 13497 res->vf_id, is_on); 13498 #endif 13499 #ifdef RTE_LIBRTE_I40E_PMD 13500 if (ret == -ENOTSUP) 13501 ret = rte_pmd_i40e_set_vf_mac_anti_spoof(res->port_id, 13502 res->vf_id, is_on); 13503 #endif 13504 #ifdef RTE_LIBRTE_BNXT_PMD 13505 if (ret == -ENOTSUP) 13506 ret = rte_pmd_bnxt_set_vf_mac_anti_spoof(res->port_id, 13507 res->vf_id, is_on); 13508 #endif 13509 13510 switch (ret) { 13511 case 0: 13512 break; 13513 case -EINVAL: 13514 printf("invalid vf_id %d or is_on %d\n", res->vf_id, is_on); 13515 break; 13516 case -ENODEV: 13517 printf("invalid port_id %d\n", res->port_id); 13518 break; 13519 case -ENOTSUP: 13520 printf("function not implemented\n"); 13521 break; 13522 default: 13523 printf("programming error: (%s)\n", strerror(-ret)); 13524 } 13525 } 13526 13527 cmdline_parse_inst_t cmd_set_vf_mac_anti_spoof = { 13528 .f = cmd_set_vf_mac_anti_spoof_parsed, 13529 .data = NULL, 13530 .help_str = "set vf mac antispoof <port_id> <vf_id> on|off", 13531 .tokens = { 13532 (void *)&cmd_vf_mac_anti_spoof_set, 13533 (void *)&cmd_vf_mac_anti_spoof_vf, 13534 (void *)&cmd_vf_mac_anti_spoof_mac, 13535 (void *)&cmd_vf_mac_anti_spoof_antispoof, 13536 (void *)&cmd_vf_mac_anti_spoof_port_id, 13537 (void *)&cmd_vf_mac_anti_spoof_vf_id, 13538 (void *)&cmd_vf_mac_anti_spoof_on_off, 13539 NULL, 13540 }, 13541 }; 13542 13543 /* vf vlan strip queue configuration */ 13544 13545 /* Common result structure for vf mac anti spoof */ 13546 struct cmd_vf_vlan_stripq_result { 13547 cmdline_fixed_string_t set; 13548 cmdline_fixed_string_t vf; 13549 cmdline_fixed_string_t vlan; 13550 cmdline_fixed_string_t stripq; 13551 portid_t port_id; 13552 uint16_t vf_id; 13553 cmdline_fixed_string_t on_off; 13554 }; 13555 13556 /* Common CLI fields for vf vlan strip enable disable */ 13557 cmdline_parse_token_string_t cmd_vf_vlan_stripq_set = 13558 TOKEN_STRING_INITIALIZER 13559 (struct cmd_vf_vlan_stripq_result, 13560 set, "set"); 13561 cmdline_parse_token_string_t cmd_vf_vlan_stripq_vf = 13562 TOKEN_STRING_INITIALIZER 13563 (struct cmd_vf_vlan_stripq_result, 13564 vf, "vf"); 13565 cmdline_parse_token_string_t cmd_vf_vlan_stripq_vlan = 13566 TOKEN_STRING_INITIALIZER 13567 (struct cmd_vf_vlan_stripq_result, 13568 vlan, "vlan"); 13569 cmdline_parse_token_string_t cmd_vf_vlan_stripq_stripq = 13570 TOKEN_STRING_INITIALIZER 13571 (struct cmd_vf_vlan_stripq_result, 13572 stripq, "stripq"); 13573 cmdline_parse_token_num_t cmd_vf_vlan_stripq_port_id = 13574 TOKEN_NUM_INITIALIZER 13575 (struct cmd_vf_vlan_stripq_result, 13576 port_id, UINT16); 13577 cmdline_parse_token_num_t cmd_vf_vlan_stripq_vf_id = 13578 TOKEN_NUM_INITIALIZER 13579 (struct cmd_vf_vlan_stripq_result, 13580 vf_id, UINT16); 13581 cmdline_parse_token_string_t cmd_vf_vlan_stripq_on_off = 13582 TOKEN_STRING_INITIALIZER 13583 (struct cmd_vf_vlan_stripq_result, 13584 on_off, "on#off"); 13585 13586 static void 13587 cmd_set_vf_vlan_stripq_parsed( 13588 void *parsed_result, 13589 __attribute__((unused)) struct cmdline *cl, 13590 __attribute__((unused)) void *data) 13591 { 13592 struct cmd_vf_vlan_stripq_result *res = parsed_result; 13593 int ret = -ENOTSUP; 13594 13595 __rte_unused int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0; 13596 13597 if (port_id_is_invalid(res->port_id, ENABLED_WARN)) 13598 return; 13599 13600 #ifdef RTE_LIBRTE_IXGBE_PMD 13601 if (ret == -ENOTSUP) 13602 ret = rte_pmd_ixgbe_set_vf_vlan_stripq(res->port_id, 13603 res->vf_id, is_on); 13604 #endif 13605 #ifdef RTE_LIBRTE_I40E_PMD 13606 if (ret == -ENOTSUP) 13607 ret = rte_pmd_i40e_set_vf_vlan_stripq(res->port_id, 13608 res->vf_id, is_on); 13609 #endif 13610 #ifdef RTE_LIBRTE_BNXT_PMD 13611 if (ret == -ENOTSUP) 13612 ret = rte_pmd_bnxt_set_vf_vlan_stripq(res->port_id, 13613 res->vf_id, is_on); 13614 #endif 13615 13616 switch (ret) { 13617 case 0: 13618 break; 13619 case -EINVAL: 13620 printf("invalid vf_id %d or is_on %d\n", res->vf_id, is_on); 13621 break; 13622 case -ENODEV: 13623 printf("invalid port_id %d\n", res->port_id); 13624 break; 13625 case -ENOTSUP: 13626 printf("function not implemented\n"); 13627 break; 13628 default: 13629 printf("programming error: (%s)\n", strerror(-ret)); 13630 } 13631 } 13632 13633 cmdline_parse_inst_t cmd_set_vf_vlan_stripq = { 13634 .f = cmd_set_vf_vlan_stripq_parsed, 13635 .data = NULL, 13636 .help_str = "set vf vlan stripq <port_id> <vf_id> on|off", 13637 .tokens = { 13638 (void *)&cmd_vf_vlan_stripq_set, 13639 (void *)&cmd_vf_vlan_stripq_vf, 13640 (void *)&cmd_vf_vlan_stripq_vlan, 13641 (void *)&cmd_vf_vlan_stripq_stripq, 13642 (void *)&cmd_vf_vlan_stripq_port_id, 13643 (void *)&cmd_vf_vlan_stripq_vf_id, 13644 (void *)&cmd_vf_vlan_stripq_on_off, 13645 NULL, 13646 }, 13647 }; 13648 13649 /* vf vlan insert configuration */ 13650 13651 /* Common result structure for vf vlan insert */ 13652 struct cmd_vf_vlan_insert_result { 13653 cmdline_fixed_string_t set; 13654 cmdline_fixed_string_t vf; 13655 cmdline_fixed_string_t vlan; 13656 cmdline_fixed_string_t insert; 13657 portid_t port_id; 13658 uint16_t vf_id; 13659 uint16_t vlan_id; 13660 }; 13661 13662 /* Common CLI fields for vf vlan insert enable disable */ 13663 cmdline_parse_token_string_t cmd_vf_vlan_insert_set = 13664 TOKEN_STRING_INITIALIZER 13665 (struct cmd_vf_vlan_insert_result, 13666 set, "set"); 13667 cmdline_parse_token_string_t cmd_vf_vlan_insert_vf = 13668 TOKEN_STRING_INITIALIZER 13669 (struct cmd_vf_vlan_insert_result, 13670 vf, "vf"); 13671 cmdline_parse_token_string_t cmd_vf_vlan_insert_vlan = 13672 TOKEN_STRING_INITIALIZER 13673 (struct cmd_vf_vlan_insert_result, 13674 vlan, "vlan"); 13675 cmdline_parse_token_string_t cmd_vf_vlan_insert_insert = 13676 TOKEN_STRING_INITIALIZER 13677 (struct cmd_vf_vlan_insert_result, 13678 insert, "insert"); 13679 cmdline_parse_token_num_t cmd_vf_vlan_insert_port_id = 13680 TOKEN_NUM_INITIALIZER 13681 (struct cmd_vf_vlan_insert_result, 13682 port_id, UINT16); 13683 cmdline_parse_token_num_t cmd_vf_vlan_insert_vf_id = 13684 TOKEN_NUM_INITIALIZER 13685 (struct cmd_vf_vlan_insert_result, 13686 vf_id, UINT16); 13687 cmdline_parse_token_num_t cmd_vf_vlan_insert_vlan_id = 13688 TOKEN_NUM_INITIALIZER 13689 (struct cmd_vf_vlan_insert_result, 13690 vlan_id, UINT16); 13691 13692 static void 13693 cmd_set_vf_vlan_insert_parsed( 13694 void *parsed_result, 13695 __attribute__((unused)) struct cmdline *cl, 13696 __attribute__((unused)) void *data) 13697 { 13698 struct cmd_vf_vlan_insert_result *res = parsed_result; 13699 int ret = -ENOTSUP; 13700 13701 if (port_id_is_invalid(res->port_id, ENABLED_WARN)) 13702 return; 13703 13704 #ifdef RTE_LIBRTE_IXGBE_PMD 13705 if (ret == -ENOTSUP) 13706 ret = rte_pmd_ixgbe_set_vf_vlan_insert(res->port_id, res->vf_id, 13707 res->vlan_id); 13708 #endif 13709 #ifdef RTE_LIBRTE_I40E_PMD 13710 if (ret == -ENOTSUP) 13711 ret = rte_pmd_i40e_set_vf_vlan_insert(res->port_id, res->vf_id, 13712 res->vlan_id); 13713 #endif 13714 #ifdef RTE_LIBRTE_BNXT_PMD 13715 if (ret == -ENOTSUP) 13716 ret = rte_pmd_bnxt_set_vf_vlan_insert(res->port_id, res->vf_id, 13717 res->vlan_id); 13718 #endif 13719 13720 switch (ret) { 13721 case 0: 13722 break; 13723 case -EINVAL: 13724 printf("invalid vf_id %d or vlan_id %d\n", res->vf_id, res->vlan_id); 13725 break; 13726 case -ENODEV: 13727 printf("invalid port_id %d\n", res->port_id); 13728 break; 13729 case -ENOTSUP: 13730 printf("function not implemented\n"); 13731 break; 13732 default: 13733 printf("programming error: (%s)\n", strerror(-ret)); 13734 } 13735 } 13736 13737 cmdline_parse_inst_t cmd_set_vf_vlan_insert = { 13738 .f = cmd_set_vf_vlan_insert_parsed, 13739 .data = NULL, 13740 .help_str = "set vf vlan insert <port_id> <vf_id> <vlan_id>", 13741 .tokens = { 13742 (void *)&cmd_vf_vlan_insert_set, 13743 (void *)&cmd_vf_vlan_insert_vf, 13744 (void *)&cmd_vf_vlan_insert_vlan, 13745 (void *)&cmd_vf_vlan_insert_insert, 13746 (void *)&cmd_vf_vlan_insert_port_id, 13747 (void *)&cmd_vf_vlan_insert_vf_id, 13748 (void *)&cmd_vf_vlan_insert_vlan_id, 13749 NULL, 13750 }, 13751 }; 13752 13753 /* tx loopback configuration */ 13754 13755 /* Common result structure for tx loopback */ 13756 struct cmd_tx_loopback_result { 13757 cmdline_fixed_string_t set; 13758 cmdline_fixed_string_t tx; 13759 cmdline_fixed_string_t loopback; 13760 portid_t port_id; 13761 cmdline_fixed_string_t on_off; 13762 }; 13763 13764 /* Common CLI fields for tx loopback enable disable */ 13765 cmdline_parse_token_string_t cmd_tx_loopback_set = 13766 TOKEN_STRING_INITIALIZER 13767 (struct cmd_tx_loopback_result, 13768 set, "set"); 13769 cmdline_parse_token_string_t cmd_tx_loopback_tx = 13770 TOKEN_STRING_INITIALIZER 13771 (struct cmd_tx_loopback_result, 13772 tx, "tx"); 13773 cmdline_parse_token_string_t cmd_tx_loopback_loopback = 13774 TOKEN_STRING_INITIALIZER 13775 (struct cmd_tx_loopback_result, 13776 loopback, "loopback"); 13777 cmdline_parse_token_num_t cmd_tx_loopback_port_id = 13778 TOKEN_NUM_INITIALIZER 13779 (struct cmd_tx_loopback_result, 13780 port_id, UINT16); 13781 cmdline_parse_token_string_t cmd_tx_loopback_on_off = 13782 TOKEN_STRING_INITIALIZER 13783 (struct cmd_tx_loopback_result, 13784 on_off, "on#off"); 13785 13786 static void 13787 cmd_set_tx_loopback_parsed( 13788 void *parsed_result, 13789 __attribute__((unused)) struct cmdline *cl, 13790 __attribute__((unused)) void *data) 13791 { 13792 struct cmd_tx_loopback_result *res = parsed_result; 13793 int ret = -ENOTSUP; 13794 13795 __rte_unused int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0; 13796 13797 if (port_id_is_invalid(res->port_id, ENABLED_WARN)) 13798 return; 13799 13800 #ifdef RTE_LIBRTE_IXGBE_PMD 13801 if (ret == -ENOTSUP) 13802 ret = rte_pmd_ixgbe_set_tx_loopback(res->port_id, is_on); 13803 #endif 13804 #ifdef RTE_LIBRTE_I40E_PMD 13805 if (ret == -ENOTSUP) 13806 ret = rte_pmd_i40e_set_tx_loopback(res->port_id, is_on); 13807 #endif 13808 #ifdef RTE_LIBRTE_BNXT_PMD 13809 if (ret == -ENOTSUP) 13810 ret = rte_pmd_bnxt_set_tx_loopback(res->port_id, is_on); 13811 #endif 13812 #if defined RTE_LIBRTE_DPAA_BUS && defined RTE_LIBRTE_DPAA_PMD 13813 if (ret == -ENOTSUP) 13814 ret = rte_pmd_dpaa_set_tx_loopback(res->port_id, is_on); 13815 #endif 13816 13817 switch (ret) { 13818 case 0: 13819 break; 13820 case -EINVAL: 13821 printf("invalid is_on %d\n", is_on); 13822 break; 13823 case -ENODEV: 13824 printf("invalid port_id %d\n", res->port_id); 13825 break; 13826 case -ENOTSUP: 13827 printf("function not implemented\n"); 13828 break; 13829 default: 13830 printf("programming error: (%s)\n", strerror(-ret)); 13831 } 13832 } 13833 13834 cmdline_parse_inst_t cmd_set_tx_loopback = { 13835 .f = cmd_set_tx_loopback_parsed, 13836 .data = NULL, 13837 .help_str = "set tx loopback <port_id> on|off", 13838 .tokens = { 13839 (void *)&cmd_tx_loopback_set, 13840 (void *)&cmd_tx_loopback_tx, 13841 (void *)&cmd_tx_loopback_loopback, 13842 (void *)&cmd_tx_loopback_port_id, 13843 (void *)&cmd_tx_loopback_on_off, 13844 NULL, 13845 }, 13846 }; 13847 13848 /* all queues drop enable configuration */ 13849 13850 /* Common result structure for all queues drop enable */ 13851 struct cmd_all_queues_drop_en_result { 13852 cmdline_fixed_string_t set; 13853 cmdline_fixed_string_t all; 13854 cmdline_fixed_string_t queues; 13855 cmdline_fixed_string_t drop; 13856 portid_t port_id; 13857 cmdline_fixed_string_t on_off; 13858 }; 13859 13860 /* Common CLI fields for tx loopback enable disable */ 13861 cmdline_parse_token_string_t cmd_all_queues_drop_en_set = 13862 TOKEN_STRING_INITIALIZER 13863 (struct cmd_all_queues_drop_en_result, 13864 set, "set"); 13865 cmdline_parse_token_string_t cmd_all_queues_drop_en_all = 13866 TOKEN_STRING_INITIALIZER 13867 (struct cmd_all_queues_drop_en_result, 13868 all, "all"); 13869 cmdline_parse_token_string_t cmd_all_queues_drop_en_queues = 13870 TOKEN_STRING_INITIALIZER 13871 (struct cmd_all_queues_drop_en_result, 13872 queues, "queues"); 13873 cmdline_parse_token_string_t cmd_all_queues_drop_en_drop = 13874 TOKEN_STRING_INITIALIZER 13875 (struct cmd_all_queues_drop_en_result, 13876 drop, "drop"); 13877 cmdline_parse_token_num_t cmd_all_queues_drop_en_port_id = 13878 TOKEN_NUM_INITIALIZER 13879 (struct cmd_all_queues_drop_en_result, 13880 port_id, UINT16); 13881 cmdline_parse_token_string_t cmd_all_queues_drop_en_on_off = 13882 TOKEN_STRING_INITIALIZER 13883 (struct cmd_all_queues_drop_en_result, 13884 on_off, "on#off"); 13885 13886 static void 13887 cmd_set_all_queues_drop_en_parsed( 13888 void *parsed_result, 13889 __attribute__((unused)) struct cmdline *cl, 13890 __attribute__((unused)) void *data) 13891 { 13892 struct cmd_all_queues_drop_en_result *res = parsed_result; 13893 int ret = -ENOTSUP; 13894 int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0; 13895 13896 if (port_id_is_invalid(res->port_id, ENABLED_WARN)) 13897 return; 13898 13899 #ifdef RTE_LIBRTE_IXGBE_PMD 13900 if (ret == -ENOTSUP) 13901 ret = rte_pmd_ixgbe_set_all_queues_drop_en(res->port_id, is_on); 13902 #endif 13903 #ifdef RTE_LIBRTE_BNXT_PMD 13904 if (ret == -ENOTSUP) 13905 ret = rte_pmd_bnxt_set_all_queues_drop_en(res->port_id, is_on); 13906 #endif 13907 switch (ret) { 13908 case 0: 13909 break; 13910 case -EINVAL: 13911 printf("invalid is_on %d\n", is_on); 13912 break; 13913 case -ENODEV: 13914 printf("invalid port_id %d\n", res->port_id); 13915 break; 13916 case -ENOTSUP: 13917 printf("function not implemented\n"); 13918 break; 13919 default: 13920 printf("programming error: (%s)\n", strerror(-ret)); 13921 } 13922 } 13923 13924 cmdline_parse_inst_t cmd_set_all_queues_drop_en = { 13925 .f = cmd_set_all_queues_drop_en_parsed, 13926 .data = NULL, 13927 .help_str = "set all queues drop <port_id> on|off", 13928 .tokens = { 13929 (void *)&cmd_all_queues_drop_en_set, 13930 (void *)&cmd_all_queues_drop_en_all, 13931 (void *)&cmd_all_queues_drop_en_queues, 13932 (void *)&cmd_all_queues_drop_en_drop, 13933 (void *)&cmd_all_queues_drop_en_port_id, 13934 (void *)&cmd_all_queues_drop_en_on_off, 13935 NULL, 13936 }, 13937 }; 13938 13939 /* vf split drop enable configuration */ 13940 13941 /* Common result structure for vf split drop enable */ 13942 struct cmd_vf_split_drop_en_result { 13943 cmdline_fixed_string_t set; 13944 cmdline_fixed_string_t vf; 13945 cmdline_fixed_string_t split; 13946 cmdline_fixed_string_t drop; 13947 portid_t port_id; 13948 uint16_t vf_id; 13949 cmdline_fixed_string_t on_off; 13950 }; 13951 13952 /* Common CLI fields for vf split drop enable disable */ 13953 cmdline_parse_token_string_t cmd_vf_split_drop_en_set = 13954 TOKEN_STRING_INITIALIZER 13955 (struct cmd_vf_split_drop_en_result, 13956 set, "set"); 13957 cmdline_parse_token_string_t cmd_vf_split_drop_en_vf = 13958 TOKEN_STRING_INITIALIZER 13959 (struct cmd_vf_split_drop_en_result, 13960 vf, "vf"); 13961 cmdline_parse_token_string_t cmd_vf_split_drop_en_split = 13962 TOKEN_STRING_INITIALIZER 13963 (struct cmd_vf_split_drop_en_result, 13964 split, "split"); 13965 cmdline_parse_token_string_t cmd_vf_split_drop_en_drop = 13966 TOKEN_STRING_INITIALIZER 13967 (struct cmd_vf_split_drop_en_result, 13968 drop, "drop"); 13969 cmdline_parse_token_num_t cmd_vf_split_drop_en_port_id = 13970 TOKEN_NUM_INITIALIZER 13971 (struct cmd_vf_split_drop_en_result, 13972 port_id, UINT16); 13973 cmdline_parse_token_num_t cmd_vf_split_drop_en_vf_id = 13974 TOKEN_NUM_INITIALIZER 13975 (struct cmd_vf_split_drop_en_result, 13976 vf_id, UINT16); 13977 cmdline_parse_token_string_t cmd_vf_split_drop_en_on_off = 13978 TOKEN_STRING_INITIALIZER 13979 (struct cmd_vf_split_drop_en_result, 13980 on_off, "on#off"); 13981 13982 static void 13983 cmd_set_vf_split_drop_en_parsed( 13984 void *parsed_result, 13985 __attribute__((unused)) struct cmdline *cl, 13986 __attribute__((unused)) void *data) 13987 { 13988 struct cmd_vf_split_drop_en_result *res = parsed_result; 13989 int ret = -ENOTSUP; 13990 int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0; 13991 13992 if (port_id_is_invalid(res->port_id, ENABLED_WARN)) 13993 return; 13994 13995 #ifdef RTE_LIBRTE_IXGBE_PMD 13996 ret = rte_pmd_ixgbe_set_vf_split_drop_en(res->port_id, res->vf_id, 13997 is_on); 13998 #endif 13999 switch (ret) { 14000 case 0: 14001 break; 14002 case -EINVAL: 14003 printf("invalid vf_id %d or is_on %d\n", res->vf_id, is_on); 14004 break; 14005 case -ENODEV: 14006 printf("invalid port_id %d\n", res->port_id); 14007 break; 14008 case -ENOTSUP: 14009 printf("not supported on port %d\n", res->port_id); 14010 break; 14011 default: 14012 printf("programming error: (%s)\n", strerror(-ret)); 14013 } 14014 } 14015 14016 cmdline_parse_inst_t cmd_set_vf_split_drop_en = { 14017 .f = cmd_set_vf_split_drop_en_parsed, 14018 .data = NULL, 14019 .help_str = "set vf split drop <port_id> <vf_id> on|off", 14020 .tokens = { 14021 (void *)&cmd_vf_split_drop_en_set, 14022 (void *)&cmd_vf_split_drop_en_vf, 14023 (void *)&cmd_vf_split_drop_en_split, 14024 (void *)&cmd_vf_split_drop_en_drop, 14025 (void *)&cmd_vf_split_drop_en_port_id, 14026 (void *)&cmd_vf_split_drop_en_vf_id, 14027 (void *)&cmd_vf_split_drop_en_on_off, 14028 NULL, 14029 }, 14030 }; 14031 14032 /* vf mac address configuration */ 14033 14034 /* Common result structure for vf mac address */ 14035 struct cmd_set_vf_mac_addr_result { 14036 cmdline_fixed_string_t set; 14037 cmdline_fixed_string_t vf; 14038 cmdline_fixed_string_t mac; 14039 cmdline_fixed_string_t addr; 14040 portid_t port_id; 14041 uint16_t vf_id; 14042 struct rte_ether_addr mac_addr; 14043 14044 }; 14045 14046 /* Common CLI fields for vf split drop enable disable */ 14047 cmdline_parse_token_string_t cmd_set_vf_mac_addr_set = 14048 TOKEN_STRING_INITIALIZER 14049 (struct cmd_set_vf_mac_addr_result, 14050 set, "set"); 14051 cmdline_parse_token_string_t cmd_set_vf_mac_addr_vf = 14052 TOKEN_STRING_INITIALIZER 14053 (struct cmd_set_vf_mac_addr_result, 14054 vf, "vf"); 14055 cmdline_parse_token_string_t cmd_set_vf_mac_addr_mac = 14056 TOKEN_STRING_INITIALIZER 14057 (struct cmd_set_vf_mac_addr_result, 14058 mac, "mac"); 14059 cmdline_parse_token_string_t cmd_set_vf_mac_addr_addr = 14060 TOKEN_STRING_INITIALIZER 14061 (struct cmd_set_vf_mac_addr_result, 14062 addr, "addr"); 14063 cmdline_parse_token_num_t cmd_set_vf_mac_addr_port_id = 14064 TOKEN_NUM_INITIALIZER 14065 (struct cmd_set_vf_mac_addr_result, 14066 port_id, UINT16); 14067 cmdline_parse_token_num_t cmd_set_vf_mac_addr_vf_id = 14068 TOKEN_NUM_INITIALIZER 14069 (struct cmd_set_vf_mac_addr_result, 14070 vf_id, UINT16); 14071 cmdline_parse_token_etheraddr_t cmd_set_vf_mac_addr_mac_addr = 14072 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_vf_mac_addr_result, 14073 mac_addr); 14074 14075 static void 14076 cmd_set_vf_mac_addr_parsed( 14077 void *parsed_result, 14078 __attribute__((unused)) struct cmdline *cl, 14079 __attribute__((unused)) void *data) 14080 { 14081 struct cmd_set_vf_mac_addr_result *res = parsed_result; 14082 int ret = -ENOTSUP; 14083 14084 if (port_id_is_invalid(res->port_id, ENABLED_WARN)) 14085 return; 14086 14087 #ifdef RTE_LIBRTE_IXGBE_PMD 14088 if (ret == -ENOTSUP) 14089 ret = rte_pmd_ixgbe_set_vf_mac_addr(res->port_id, res->vf_id, 14090 &res->mac_addr); 14091 #endif 14092 #ifdef RTE_LIBRTE_I40E_PMD 14093 if (ret == -ENOTSUP) 14094 ret = rte_pmd_i40e_set_vf_mac_addr(res->port_id, res->vf_id, 14095 &res->mac_addr); 14096 #endif 14097 #ifdef RTE_LIBRTE_BNXT_PMD 14098 if (ret == -ENOTSUP) 14099 ret = rte_pmd_bnxt_set_vf_mac_addr(res->port_id, res->vf_id, 14100 &res->mac_addr); 14101 #endif 14102 14103 switch (ret) { 14104 case 0: 14105 break; 14106 case -EINVAL: 14107 printf("invalid vf_id %d or mac_addr\n", res->vf_id); 14108 break; 14109 case -ENODEV: 14110 printf("invalid port_id %d\n", res->port_id); 14111 break; 14112 case -ENOTSUP: 14113 printf("function not implemented\n"); 14114 break; 14115 default: 14116 printf("programming error: (%s)\n", strerror(-ret)); 14117 } 14118 } 14119 14120 cmdline_parse_inst_t cmd_set_vf_mac_addr = { 14121 .f = cmd_set_vf_mac_addr_parsed, 14122 .data = NULL, 14123 .help_str = "set vf mac addr <port_id> <vf_id> <mac_addr>", 14124 .tokens = { 14125 (void *)&cmd_set_vf_mac_addr_set, 14126 (void *)&cmd_set_vf_mac_addr_vf, 14127 (void *)&cmd_set_vf_mac_addr_mac, 14128 (void *)&cmd_set_vf_mac_addr_addr, 14129 (void *)&cmd_set_vf_mac_addr_port_id, 14130 (void *)&cmd_set_vf_mac_addr_vf_id, 14131 (void *)&cmd_set_vf_mac_addr_mac_addr, 14132 NULL, 14133 }, 14134 }; 14135 14136 /* MACsec configuration */ 14137 14138 /* Common result structure for MACsec offload enable */ 14139 struct cmd_macsec_offload_on_result { 14140 cmdline_fixed_string_t set; 14141 cmdline_fixed_string_t macsec; 14142 cmdline_fixed_string_t offload; 14143 portid_t port_id; 14144 cmdline_fixed_string_t on; 14145 cmdline_fixed_string_t encrypt; 14146 cmdline_fixed_string_t en_on_off; 14147 cmdline_fixed_string_t replay_protect; 14148 cmdline_fixed_string_t rp_on_off; 14149 }; 14150 14151 /* Common CLI fields for MACsec offload disable */ 14152 cmdline_parse_token_string_t cmd_macsec_offload_on_set = 14153 TOKEN_STRING_INITIALIZER 14154 (struct cmd_macsec_offload_on_result, 14155 set, "set"); 14156 cmdline_parse_token_string_t cmd_macsec_offload_on_macsec = 14157 TOKEN_STRING_INITIALIZER 14158 (struct cmd_macsec_offload_on_result, 14159 macsec, "macsec"); 14160 cmdline_parse_token_string_t cmd_macsec_offload_on_offload = 14161 TOKEN_STRING_INITIALIZER 14162 (struct cmd_macsec_offload_on_result, 14163 offload, "offload"); 14164 cmdline_parse_token_num_t cmd_macsec_offload_on_port_id = 14165 TOKEN_NUM_INITIALIZER 14166 (struct cmd_macsec_offload_on_result, 14167 port_id, UINT16); 14168 cmdline_parse_token_string_t cmd_macsec_offload_on_on = 14169 TOKEN_STRING_INITIALIZER 14170 (struct cmd_macsec_offload_on_result, 14171 on, "on"); 14172 cmdline_parse_token_string_t cmd_macsec_offload_on_encrypt = 14173 TOKEN_STRING_INITIALIZER 14174 (struct cmd_macsec_offload_on_result, 14175 encrypt, "encrypt"); 14176 cmdline_parse_token_string_t cmd_macsec_offload_on_en_on_off = 14177 TOKEN_STRING_INITIALIZER 14178 (struct cmd_macsec_offload_on_result, 14179 en_on_off, "on#off"); 14180 cmdline_parse_token_string_t cmd_macsec_offload_on_replay_protect = 14181 TOKEN_STRING_INITIALIZER 14182 (struct cmd_macsec_offload_on_result, 14183 replay_protect, "replay-protect"); 14184 cmdline_parse_token_string_t cmd_macsec_offload_on_rp_on_off = 14185 TOKEN_STRING_INITIALIZER 14186 (struct cmd_macsec_offload_on_result, 14187 rp_on_off, "on#off"); 14188 14189 static void 14190 cmd_set_macsec_offload_on_parsed( 14191 void *parsed_result, 14192 __attribute__((unused)) struct cmdline *cl, 14193 __attribute__((unused)) void *data) 14194 { 14195 struct cmd_macsec_offload_on_result *res = parsed_result; 14196 int ret = -ENOTSUP; 14197 portid_t port_id = res->port_id; 14198 int en = (strcmp(res->en_on_off, "on") == 0) ? 1 : 0; 14199 int rp = (strcmp(res->rp_on_off, "on") == 0) ? 1 : 0; 14200 struct rte_eth_dev_info dev_info; 14201 14202 if (port_id_is_invalid(port_id, ENABLED_WARN)) 14203 return; 14204 if (!port_is_stopped(port_id)) { 14205 printf("Please stop port %d first\n", port_id); 14206 return; 14207 } 14208 14209 ret = eth_dev_info_get_print_err(port_id, &dev_info); 14210 if (ret != 0) 14211 return; 14212 14213 if (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_MACSEC_INSERT) { 14214 #ifdef RTE_LIBRTE_IXGBE_PMD 14215 ret = rte_pmd_ixgbe_macsec_enable(port_id, en, rp); 14216 #endif 14217 } 14218 RTE_SET_USED(en); 14219 RTE_SET_USED(rp); 14220 14221 switch (ret) { 14222 case 0: 14223 ports[port_id].dev_conf.txmode.offloads |= 14224 DEV_TX_OFFLOAD_MACSEC_INSERT; 14225 cmd_reconfig_device_queue(port_id, 1, 1); 14226 break; 14227 case -ENODEV: 14228 printf("invalid port_id %d\n", port_id); 14229 break; 14230 case -ENOTSUP: 14231 printf("not supported on port %d\n", port_id); 14232 break; 14233 default: 14234 printf("programming error: (%s)\n", strerror(-ret)); 14235 } 14236 } 14237 14238 cmdline_parse_inst_t cmd_set_macsec_offload_on = { 14239 .f = cmd_set_macsec_offload_on_parsed, 14240 .data = NULL, 14241 .help_str = "set macsec offload <port_id> on " 14242 "encrypt on|off replay-protect on|off", 14243 .tokens = { 14244 (void *)&cmd_macsec_offload_on_set, 14245 (void *)&cmd_macsec_offload_on_macsec, 14246 (void *)&cmd_macsec_offload_on_offload, 14247 (void *)&cmd_macsec_offload_on_port_id, 14248 (void *)&cmd_macsec_offload_on_on, 14249 (void *)&cmd_macsec_offload_on_encrypt, 14250 (void *)&cmd_macsec_offload_on_en_on_off, 14251 (void *)&cmd_macsec_offload_on_replay_protect, 14252 (void *)&cmd_macsec_offload_on_rp_on_off, 14253 NULL, 14254 }, 14255 }; 14256 14257 /* Common result structure for MACsec offload disable */ 14258 struct cmd_macsec_offload_off_result { 14259 cmdline_fixed_string_t set; 14260 cmdline_fixed_string_t macsec; 14261 cmdline_fixed_string_t offload; 14262 portid_t port_id; 14263 cmdline_fixed_string_t off; 14264 }; 14265 14266 /* Common CLI fields for MACsec offload disable */ 14267 cmdline_parse_token_string_t cmd_macsec_offload_off_set = 14268 TOKEN_STRING_INITIALIZER 14269 (struct cmd_macsec_offload_off_result, 14270 set, "set"); 14271 cmdline_parse_token_string_t cmd_macsec_offload_off_macsec = 14272 TOKEN_STRING_INITIALIZER 14273 (struct cmd_macsec_offload_off_result, 14274 macsec, "macsec"); 14275 cmdline_parse_token_string_t cmd_macsec_offload_off_offload = 14276 TOKEN_STRING_INITIALIZER 14277 (struct cmd_macsec_offload_off_result, 14278 offload, "offload"); 14279 cmdline_parse_token_num_t cmd_macsec_offload_off_port_id = 14280 TOKEN_NUM_INITIALIZER 14281 (struct cmd_macsec_offload_off_result, 14282 port_id, UINT16); 14283 cmdline_parse_token_string_t cmd_macsec_offload_off_off = 14284 TOKEN_STRING_INITIALIZER 14285 (struct cmd_macsec_offload_off_result, 14286 off, "off"); 14287 14288 static void 14289 cmd_set_macsec_offload_off_parsed( 14290 void *parsed_result, 14291 __attribute__((unused)) struct cmdline *cl, 14292 __attribute__((unused)) void *data) 14293 { 14294 struct cmd_macsec_offload_off_result *res = parsed_result; 14295 int ret = -ENOTSUP; 14296 struct rte_eth_dev_info dev_info; 14297 portid_t port_id = res->port_id; 14298 14299 if (port_id_is_invalid(port_id, ENABLED_WARN)) 14300 return; 14301 if (!port_is_stopped(port_id)) { 14302 printf("Please stop port %d first\n", port_id); 14303 return; 14304 } 14305 14306 ret = eth_dev_info_get_print_err(port_id, &dev_info); 14307 if (ret != 0) 14308 return; 14309 14310 if (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_MACSEC_INSERT) { 14311 #ifdef RTE_LIBRTE_IXGBE_PMD 14312 ret = rte_pmd_ixgbe_macsec_disable(port_id); 14313 #endif 14314 } 14315 switch (ret) { 14316 case 0: 14317 ports[port_id].dev_conf.txmode.offloads &= 14318 ~DEV_TX_OFFLOAD_MACSEC_INSERT; 14319 cmd_reconfig_device_queue(port_id, 1, 1); 14320 break; 14321 case -ENODEV: 14322 printf("invalid port_id %d\n", port_id); 14323 break; 14324 case -ENOTSUP: 14325 printf("not supported on port %d\n", port_id); 14326 break; 14327 default: 14328 printf("programming error: (%s)\n", strerror(-ret)); 14329 } 14330 } 14331 14332 cmdline_parse_inst_t cmd_set_macsec_offload_off = { 14333 .f = cmd_set_macsec_offload_off_parsed, 14334 .data = NULL, 14335 .help_str = "set macsec offload <port_id> off", 14336 .tokens = { 14337 (void *)&cmd_macsec_offload_off_set, 14338 (void *)&cmd_macsec_offload_off_macsec, 14339 (void *)&cmd_macsec_offload_off_offload, 14340 (void *)&cmd_macsec_offload_off_port_id, 14341 (void *)&cmd_macsec_offload_off_off, 14342 NULL, 14343 }, 14344 }; 14345 14346 /* Common result structure for MACsec secure connection configure */ 14347 struct cmd_macsec_sc_result { 14348 cmdline_fixed_string_t set; 14349 cmdline_fixed_string_t macsec; 14350 cmdline_fixed_string_t sc; 14351 cmdline_fixed_string_t tx_rx; 14352 portid_t port_id; 14353 struct rte_ether_addr mac; 14354 uint16_t pi; 14355 }; 14356 14357 /* Common CLI fields for MACsec secure connection configure */ 14358 cmdline_parse_token_string_t cmd_macsec_sc_set = 14359 TOKEN_STRING_INITIALIZER 14360 (struct cmd_macsec_sc_result, 14361 set, "set"); 14362 cmdline_parse_token_string_t cmd_macsec_sc_macsec = 14363 TOKEN_STRING_INITIALIZER 14364 (struct cmd_macsec_sc_result, 14365 macsec, "macsec"); 14366 cmdline_parse_token_string_t cmd_macsec_sc_sc = 14367 TOKEN_STRING_INITIALIZER 14368 (struct cmd_macsec_sc_result, 14369 sc, "sc"); 14370 cmdline_parse_token_string_t cmd_macsec_sc_tx_rx = 14371 TOKEN_STRING_INITIALIZER 14372 (struct cmd_macsec_sc_result, 14373 tx_rx, "tx#rx"); 14374 cmdline_parse_token_num_t cmd_macsec_sc_port_id = 14375 TOKEN_NUM_INITIALIZER 14376 (struct cmd_macsec_sc_result, 14377 port_id, UINT16); 14378 cmdline_parse_token_etheraddr_t cmd_macsec_sc_mac = 14379 TOKEN_ETHERADDR_INITIALIZER 14380 (struct cmd_macsec_sc_result, 14381 mac); 14382 cmdline_parse_token_num_t cmd_macsec_sc_pi = 14383 TOKEN_NUM_INITIALIZER 14384 (struct cmd_macsec_sc_result, 14385 pi, UINT16); 14386 14387 static void 14388 cmd_set_macsec_sc_parsed( 14389 void *parsed_result, 14390 __attribute__((unused)) struct cmdline *cl, 14391 __attribute__((unused)) void *data) 14392 { 14393 struct cmd_macsec_sc_result *res = parsed_result; 14394 int ret = -ENOTSUP; 14395 int is_tx = (strcmp(res->tx_rx, "tx") == 0) ? 1 : 0; 14396 14397 #ifdef RTE_LIBRTE_IXGBE_PMD 14398 ret = is_tx ? 14399 rte_pmd_ixgbe_macsec_config_txsc(res->port_id, 14400 res->mac.addr_bytes) : 14401 rte_pmd_ixgbe_macsec_config_rxsc(res->port_id, 14402 res->mac.addr_bytes, res->pi); 14403 #endif 14404 RTE_SET_USED(is_tx); 14405 14406 switch (ret) { 14407 case 0: 14408 break; 14409 case -ENODEV: 14410 printf("invalid port_id %d\n", res->port_id); 14411 break; 14412 case -ENOTSUP: 14413 printf("not supported on port %d\n", res->port_id); 14414 break; 14415 default: 14416 printf("programming error: (%s)\n", strerror(-ret)); 14417 } 14418 } 14419 14420 cmdline_parse_inst_t cmd_set_macsec_sc = { 14421 .f = cmd_set_macsec_sc_parsed, 14422 .data = NULL, 14423 .help_str = "set macsec sc tx|rx <port_id> <mac> <pi>", 14424 .tokens = { 14425 (void *)&cmd_macsec_sc_set, 14426 (void *)&cmd_macsec_sc_macsec, 14427 (void *)&cmd_macsec_sc_sc, 14428 (void *)&cmd_macsec_sc_tx_rx, 14429 (void *)&cmd_macsec_sc_port_id, 14430 (void *)&cmd_macsec_sc_mac, 14431 (void *)&cmd_macsec_sc_pi, 14432 NULL, 14433 }, 14434 }; 14435 14436 /* Common result structure for MACsec secure connection configure */ 14437 struct cmd_macsec_sa_result { 14438 cmdline_fixed_string_t set; 14439 cmdline_fixed_string_t macsec; 14440 cmdline_fixed_string_t sa; 14441 cmdline_fixed_string_t tx_rx; 14442 portid_t port_id; 14443 uint8_t idx; 14444 uint8_t an; 14445 uint32_t pn; 14446 cmdline_fixed_string_t key; 14447 }; 14448 14449 /* Common CLI fields for MACsec secure connection configure */ 14450 cmdline_parse_token_string_t cmd_macsec_sa_set = 14451 TOKEN_STRING_INITIALIZER 14452 (struct cmd_macsec_sa_result, 14453 set, "set"); 14454 cmdline_parse_token_string_t cmd_macsec_sa_macsec = 14455 TOKEN_STRING_INITIALIZER 14456 (struct cmd_macsec_sa_result, 14457 macsec, "macsec"); 14458 cmdline_parse_token_string_t cmd_macsec_sa_sa = 14459 TOKEN_STRING_INITIALIZER 14460 (struct cmd_macsec_sa_result, 14461 sa, "sa"); 14462 cmdline_parse_token_string_t cmd_macsec_sa_tx_rx = 14463 TOKEN_STRING_INITIALIZER 14464 (struct cmd_macsec_sa_result, 14465 tx_rx, "tx#rx"); 14466 cmdline_parse_token_num_t cmd_macsec_sa_port_id = 14467 TOKEN_NUM_INITIALIZER 14468 (struct cmd_macsec_sa_result, 14469 port_id, UINT16); 14470 cmdline_parse_token_num_t cmd_macsec_sa_idx = 14471 TOKEN_NUM_INITIALIZER 14472 (struct cmd_macsec_sa_result, 14473 idx, UINT8); 14474 cmdline_parse_token_num_t cmd_macsec_sa_an = 14475 TOKEN_NUM_INITIALIZER 14476 (struct cmd_macsec_sa_result, 14477 an, UINT8); 14478 cmdline_parse_token_num_t cmd_macsec_sa_pn = 14479 TOKEN_NUM_INITIALIZER 14480 (struct cmd_macsec_sa_result, 14481 pn, UINT32); 14482 cmdline_parse_token_string_t cmd_macsec_sa_key = 14483 TOKEN_STRING_INITIALIZER 14484 (struct cmd_macsec_sa_result, 14485 key, NULL); 14486 14487 static void 14488 cmd_set_macsec_sa_parsed( 14489 void *parsed_result, 14490 __attribute__((unused)) struct cmdline *cl, 14491 __attribute__((unused)) void *data) 14492 { 14493 struct cmd_macsec_sa_result *res = parsed_result; 14494 int ret = -ENOTSUP; 14495 int is_tx = (strcmp(res->tx_rx, "tx") == 0) ? 1 : 0; 14496 uint8_t key[16] = { 0 }; 14497 uint8_t xdgt0; 14498 uint8_t xdgt1; 14499 int key_len; 14500 int i; 14501 14502 key_len = strlen(res->key) / 2; 14503 if (key_len > 16) 14504 key_len = 16; 14505 14506 for (i = 0; i < key_len; i++) { 14507 xdgt0 = parse_and_check_key_hexa_digit(res->key, (i * 2)); 14508 if (xdgt0 == 0xFF) 14509 return; 14510 xdgt1 = parse_and_check_key_hexa_digit(res->key, (i * 2) + 1); 14511 if (xdgt1 == 0xFF) 14512 return; 14513 key[i] = (uint8_t) ((xdgt0 * 16) + xdgt1); 14514 } 14515 14516 #ifdef RTE_LIBRTE_IXGBE_PMD 14517 ret = is_tx ? 14518 rte_pmd_ixgbe_macsec_select_txsa(res->port_id, 14519 res->idx, res->an, res->pn, key) : 14520 rte_pmd_ixgbe_macsec_select_rxsa(res->port_id, 14521 res->idx, res->an, res->pn, key); 14522 #endif 14523 RTE_SET_USED(is_tx); 14524 RTE_SET_USED(key); 14525 14526 switch (ret) { 14527 case 0: 14528 break; 14529 case -EINVAL: 14530 printf("invalid idx %d or an %d\n", res->idx, res->an); 14531 break; 14532 case -ENODEV: 14533 printf("invalid port_id %d\n", res->port_id); 14534 break; 14535 case -ENOTSUP: 14536 printf("not supported on port %d\n", res->port_id); 14537 break; 14538 default: 14539 printf("programming error: (%s)\n", strerror(-ret)); 14540 } 14541 } 14542 14543 cmdline_parse_inst_t cmd_set_macsec_sa = { 14544 .f = cmd_set_macsec_sa_parsed, 14545 .data = NULL, 14546 .help_str = "set macsec sa tx|rx <port_id> <idx> <an> <pn> <key>", 14547 .tokens = { 14548 (void *)&cmd_macsec_sa_set, 14549 (void *)&cmd_macsec_sa_macsec, 14550 (void *)&cmd_macsec_sa_sa, 14551 (void *)&cmd_macsec_sa_tx_rx, 14552 (void *)&cmd_macsec_sa_port_id, 14553 (void *)&cmd_macsec_sa_idx, 14554 (void *)&cmd_macsec_sa_an, 14555 (void *)&cmd_macsec_sa_pn, 14556 (void *)&cmd_macsec_sa_key, 14557 NULL, 14558 }, 14559 }; 14560 14561 /* VF unicast promiscuous mode configuration */ 14562 14563 /* Common result structure for VF unicast promiscuous mode */ 14564 struct cmd_vf_promisc_result { 14565 cmdline_fixed_string_t set; 14566 cmdline_fixed_string_t vf; 14567 cmdline_fixed_string_t promisc; 14568 portid_t port_id; 14569 uint32_t vf_id; 14570 cmdline_fixed_string_t on_off; 14571 }; 14572 14573 /* Common CLI fields for VF unicast promiscuous mode enable disable */ 14574 cmdline_parse_token_string_t cmd_vf_promisc_set = 14575 TOKEN_STRING_INITIALIZER 14576 (struct cmd_vf_promisc_result, 14577 set, "set"); 14578 cmdline_parse_token_string_t cmd_vf_promisc_vf = 14579 TOKEN_STRING_INITIALIZER 14580 (struct cmd_vf_promisc_result, 14581 vf, "vf"); 14582 cmdline_parse_token_string_t cmd_vf_promisc_promisc = 14583 TOKEN_STRING_INITIALIZER 14584 (struct cmd_vf_promisc_result, 14585 promisc, "promisc"); 14586 cmdline_parse_token_num_t cmd_vf_promisc_port_id = 14587 TOKEN_NUM_INITIALIZER 14588 (struct cmd_vf_promisc_result, 14589 port_id, UINT16); 14590 cmdline_parse_token_num_t cmd_vf_promisc_vf_id = 14591 TOKEN_NUM_INITIALIZER 14592 (struct cmd_vf_promisc_result, 14593 vf_id, UINT32); 14594 cmdline_parse_token_string_t cmd_vf_promisc_on_off = 14595 TOKEN_STRING_INITIALIZER 14596 (struct cmd_vf_promisc_result, 14597 on_off, "on#off"); 14598 14599 static void 14600 cmd_set_vf_promisc_parsed( 14601 void *parsed_result, 14602 __attribute__((unused)) struct cmdline *cl, 14603 __attribute__((unused)) void *data) 14604 { 14605 struct cmd_vf_promisc_result *res = parsed_result; 14606 int ret = -ENOTSUP; 14607 14608 __rte_unused int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0; 14609 14610 if (port_id_is_invalid(res->port_id, ENABLED_WARN)) 14611 return; 14612 14613 #ifdef RTE_LIBRTE_I40E_PMD 14614 ret = rte_pmd_i40e_set_vf_unicast_promisc(res->port_id, 14615 res->vf_id, is_on); 14616 #endif 14617 14618 switch (ret) { 14619 case 0: 14620 break; 14621 case -EINVAL: 14622 printf("invalid vf_id %d\n", res->vf_id); 14623 break; 14624 case -ENODEV: 14625 printf("invalid port_id %d\n", res->port_id); 14626 break; 14627 case -ENOTSUP: 14628 printf("function not implemented\n"); 14629 break; 14630 default: 14631 printf("programming error: (%s)\n", strerror(-ret)); 14632 } 14633 } 14634 14635 cmdline_parse_inst_t cmd_set_vf_promisc = { 14636 .f = cmd_set_vf_promisc_parsed, 14637 .data = NULL, 14638 .help_str = "set vf promisc <port_id> <vf_id> on|off: " 14639 "Set unicast promiscuous mode for a VF from the PF", 14640 .tokens = { 14641 (void *)&cmd_vf_promisc_set, 14642 (void *)&cmd_vf_promisc_vf, 14643 (void *)&cmd_vf_promisc_promisc, 14644 (void *)&cmd_vf_promisc_port_id, 14645 (void *)&cmd_vf_promisc_vf_id, 14646 (void *)&cmd_vf_promisc_on_off, 14647 NULL, 14648 }, 14649 }; 14650 14651 /* VF multicast promiscuous mode configuration */ 14652 14653 /* Common result structure for VF multicast promiscuous mode */ 14654 struct cmd_vf_allmulti_result { 14655 cmdline_fixed_string_t set; 14656 cmdline_fixed_string_t vf; 14657 cmdline_fixed_string_t allmulti; 14658 portid_t port_id; 14659 uint32_t vf_id; 14660 cmdline_fixed_string_t on_off; 14661 }; 14662 14663 /* Common CLI fields for VF multicast promiscuous mode enable disable */ 14664 cmdline_parse_token_string_t cmd_vf_allmulti_set = 14665 TOKEN_STRING_INITIALIZER 14666 (struct cmd_vf_allmulti_result, 14667 set, "set"); 14668 cmdline_parse_token_string_t cmd_vf_allmulti_vf = 14669 TOKEN_STRING_INITIALIZER 14670 (struct cmd_vf_allmulti_result, 14671 vf, "vf"); 14672 cmdline_parse_token_string_t cmd_vf_allmulti_allmulti = 14673 TOKEN_STRING_INITIALIZER 14674 (struct cmd_vf_allmulti_result, 14675 allmulti, "allmulti"); 14676 cmdline_parse_token_num_t cmd_vf_allmulti_port_id = 14677 TOKEN_NUM_INITIALIZER 14678 (struct cmd_vf_allmulti_result, 14679 port_id, UINT16); 14680 cmdline_parse_token_num_t cmd_vf_allmulti_vf_id = 14681 TOKEN_NUM_INITIALIZER 14682 (struct cmd_vf_allmulti_result, 14683 vf_id, UINT32); 14684 cmdline_parse_token_string_t cmd_vf_allmulti_on_off = 14685 TOKEN_STRING_INITIALIZER 14686 (struct cmd_vf_allmulti_result, 14687 on_off, "on#off"); 14688 14689 static void 14690 cmd_set_vf_allmulti_parsed( 14691 void *parsed_result, 14692 __attribute__((unused)) struct cmdline *cl, 14693 __attribute__((unused)) void *data) 14694 { 14695 struct cmd_vf_allmulti_result *res = parsed_result; 14696 int ret = -ENOTSUP; 14697 14698 __rte_unused int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0; 14699 14700 if (port_id_is_invalid(res->port_id, ENABLED_WARN)) 14701 return; 14702 14703 #ifdef RTE_LIBRTE_I40E_PMD 14704 ret = rte_pmd_i40e_set_vf_multicast_promisc(res->port_id, 14705 res->vf_id, is_on); 14706 #endif 14707 14708 switch (ret) { 14709 case 0: 14710 break; 14711 case -EINVAL: 14712 printf("invalid vf_id %d\n", res->vf_id); 14713 break; 14714 case -ENODEV: 14715 printf("invalid port_id %d\n", res->port_id); 14716 break; 14717 case -ENOTSUP: 14718 printf("function not implemented\n"); 14719 break; 14720 default: 14721 printf("programming error: (%s)\n", strerror(-ret)); 14722 } 14723 } 14724 14725 cmdline_parse_inst_t cmd_set_vf_allmulti = { 14726 .f = cmd_set_vf_allmulti_parsed, 14727 .data = NULL, 14728 .help_str = "set vf allmulti <port_id> <vf_id> on|off: " 14729 "Set multicast promiscuous mode for a VF from the PF", 14730 .tokens = { 14731 (void *)&cmd_vf_allmulti_set, 14732 (void *)&cmd_vf_allmulti_vf, 14733 (void *)&cmd_vf_allmulti_allmulti, 14734 (void *)&cmd_vf_allmulti_port_id, 14735 (void *)&cmd_vf_allmulti_vf_id, 14736 (void *)&cmd_vf_allmulti_on_off, 14737 NULL, 14738 }, 14739 }; 14740 14741 /* vf broadcast mode configuration */ 14742 14743 /* Common result structure for vf broadcast */ 14744 struct cmd_set_vf_broadcast_result { 14745 cmdline_fixed_string_t set; 14746 cmdline_fixed_string_t vf; 14747 cmdline_fixed_string_t broadcast; 14748 portid_t port_id; 14749 uint16_t vf_id; 14750 cmdline_fixed_string_t on_off; 14751 }; 14752 14753 /* Common CLI fields for vf broadcast enable disable */ 14754 cmdline_parse_token_string_t cmd_set_vf_broadcast_set = 14755 TOKEN_STRING_INITIALIZER 14756 (struct cmd_set_vf_broadcast_result, 14757 set, "set"); 14758 cmdline_parse_token_string_t cmd_set_vf_broadcast_vf = 14759 TOKEN_STRING_INITIALIZER 14760 (struct cmd_set_vf_broadcast_result, 14761 vf, "vf"); 14762 cmdline_parse_token_string_t cmd_set_vf_broadcast_broadcast = 14763 TOKEN_STRING_INITIALIZER 14764 (struct cmd_set_vf_broadcast_result, 14765 broadcast, "broadcast"); 14766 cmdline_parse_token_num_t cmd_set_vf_broadcast_port_id = 14767 TOKEN_NUM_INITIALIZER 14768 (struct cmd_set_vf_broadcast_result, 14769 port_id, UINT16); 14770 cmdline_parse_token_num_t cmd_set_vf_broadcast_vf_id = 14771 TOKEN_NUM_INITIALIZER 14772 (struct cmd_set_vf_broadcast_result, 14773 vf_id, UINT16); 14774 cmdline_parse_token_string_t cmd_set_vf_broadcast_on_off = 14775 TOKEN_STRING_INITIALIZER 14776 (struct cmd_set_vf_broadcast_result, 14777 on_off, "on#off"); 14778 14779 static void 14780 cmd_set_vf_broadcast_parsed( 14781 void *parsed_result, 14782 __attribute__((unused)) struct cmdline *cl, 14783 __attribute__((unused)) void *data) 14784 { 14785 struct cmd_set_vf_broadcast_result *res = parsed_result; 14786 int ret = -ENOTSUP; 14787 14788 __rte_unused int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0; 14789 14790 if (port_id_is_invalid(res->port_id, ENABLED_WARN)) 14791 return; 14792 14793 #ifdef RTE_LIBRTE_I40E_PMD 14794 ret = rte_pmd_i40e_set_vf_broadcast(res->port_id, 14795 res->vf_id, is_on); 14796 #endif 14797 14798 switch (ret) { 14799 case 0: 14800 break; 14801 case -EINVAL: 14802 printf("invalid vf_id %d or is_on %d\n", res->vf_id, is_on); 14803 break; 14804 case -ENODEV: 14805 printf("invalid port_id %d\n", res->port_id); 14806 break; 14807 case -ENOTSUP: 14808 printf("function not implemented\n"); 14809 break; 14810 default: 14811 printf("programming error: (%s)\n", strerror(-ret)); 14812 } 14813 } 14814 14815 cmdline_parse_inst_t cmd_set_vf_broadcast = { 14816 .f = cmd_set_vf_broadcast_parsed, 14817 .data = NULL, 14818 .help_str = "set vf broadcast <port_id> <vf_id> on|off", 14819 .tokens = { 14820 (void *)&cmd_set_vf_broadcast_set, 14821 (void *)&cmd_set_vf_broadcast_vf, 14822 (void *)&cmd_set_vf_broadcast_broadcast, 14823 (void *)&cmd_set_vf_broadcast_port_id, 14824 (void *)&cmd_set_vf_broadcast_vf_id, 14825 (void *)&cmd_set_vf_broadcast_on_off, 14826 NULL, 14827 }, 14828 }; 14829 14830 /* vf vlan tag configuration */ 14831 14832 /* Common result structure for vf vlan tag */ 14833 struct cmd_set_vf_vlan_tag_result { 14834 cmdline_fixed_string_t set; 14835 cmdline_fixed_string_t vf; 14836 cmdline_fixed_string_t vlan; 14837 cmdline_fixed_string_t tag; 14838 portid_t port_id; 14839 uint16_t vf_id; 14840 cmdline_fixed_string_t on_off; 14841 }; 14842 14843 /* Common CLI fields for vf vlan tag enable disable */ 14844 cmdline_parse_token_string_t cmd_set_vf_vlan_tag_set = 14845 TOKEN_STRING_INITIALIZER 14846 (struct cmd_set_vf_vlan_tag_result, 14847 set, "set"); 14848 cmdline_parse_token_string_t cmd_set_vf_vlan_tag_vf = 14849 TOKEN_STRING_INITIALIZER 14850 (struct cmd_set_vf_vlan_tag_result, 14851 vf, "vf"); 14852 cmdline_parse_token_string_t cmd_set_vf_vlan_tag_vlan = 14853 TOKEN_STRING_INITIALIZER 14854 (struct cmd_set_vf_vlan_tag_result, 14855 vlan, "vlan"); 14856 cmdline_parse_token_string_t cmd_set_vf_vlan_tag_tag = 14857 TOKEN_STRING_INITIALIZER 14858 (struct cmd_set_vf_vlan_tag_result, 14859 tag, "tag"); 14860 cmdline_parse_token_num_t cmd_set_vf_vlan_tag_port_id = 14861 TOKEN_NUM_INITIALIZER 14862 (struct cmd_set_vf_vlan_tag_result, 14863 port_id, UINT16); 14864 cmdline_parse_token_num_t cmd_set_vf_vlan_tag_vf_id = 14865 TOKEN_NUM_INITIALIZER 14866 (struct cmd_set_vf_vlan_tag_result, 14867 vf_id, UINT16); 14868 cmdline_parse_token_string_t cmd_set_vf_vlan_tag_on_off = 14869 TOKEN_STRING_INITIALIZER 14870 (struct cmd_set_vf_vlan_tag_result, 14871 on_off, "on#off"); 14872 14873 static void 14874 cmd_set_vf_vlan_tag_parsed( 14875 void *parsed_result, 14876 __attribute__((unused)) struct cmdline *cl, 14877 __attribute__((unused)) void *data) 14878 { 14879 struct cmd_set_vf_vlan_tag_result *res = parsed_result; 14880 int ret = -ENOTSUP; 14881 14882 __rte_unused int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0; 14883 14884 if (port_id_is_invalid(res->port_id, ENABLED_WARN)) 14885 return; 14886 14887 #ifdef RTE_LIBRTE_I40E_PMD 14888 ret = rte_pmd_i40e_set_vf_vlan_tag(res->port_id, 14889 res->vf_id, is_on); 14890 #endif 14891 14892 switch (ret) { 14893 case 0: 14894 break; 14895 case -EINVAL: 14896 printf("invalid vf_id %d or is_on %d\n", res->vf_id, is_on); 14897 break; 14898 case -ENODEV: 14899 printf("invalid port_id %d\n", res->port_id); 14900 break; 14901 case -ENOTSUP: 14902 printf("function not implemented\n"); 14903 break; 14904 default: 14905 printf("programming error: (%s)\n", strerror(-ret)); 14906 } 14907 } 14908 14909 cmdline_parse_inst_t cmd_set_vf_vlan_tag = { 14910 .f = cmd_set_vf_vlan_tag_parsed, 14911 .data = NULL, 14912 .help_str = "set vf vlan tag <port_id> <vf_id> on|off", 14913 .tokens = { 14914 (void *)&cmd_set_vf_vlan_tag_set, 14915 (void *)&cmd_set_vf_vlan_tag_vf, 14916 (void *)&cmd_set_vf_vlan_tag_vlan, 14917 (void *)&cmd_set_vf_vlan_tag_tag, 14918 (void *)&cmd_set_vf_vlan_tag_port_id, 14919 (void *)&cmd_set_vf_vlan_tag_vf_id, 14920 (void *)&cmd_set_vf_vlan_tag_on_off, 14921 NULL, 14922 }, 14923 }; 14924 14925 /* Common definition of VF and TC TX bandwidth configuration */ 14926 struct cmd_vf_tc_bw_result { 14927 cmdline_fixed_string_t set; 14928 cmdline_fixed_string_t vf; 14929 cmdline_fixed_string_t tc; 14930 cmdline_fixed_string_t tx; 14931 cmdline_fixed_string_t min_bw; 14932 cmdline_fixed_string_t max_bw; 14933 cmdline_fixed_string_t strict_link_prio; 14934 portid_t port_id; 14935 uint16_t vf_id; 14936 uint8_t tc_no; 14937 uint32_t bw; 14938 cmdline_fixed_string_t bw_list; 14939 uint8_t tc_map; 14940 }; 14941 14942 cmdline_parse_token_string_t cmd_vf_tc_bw_set = 14943 TOKEN_STRING_INITIALIZER 14944 (struct cmd_vf_tc_bw_result, 14945 set, "set"); 14946 cmdline_parse_token_string_t cmd_vf_tc_bw_vf = 14947 TOKEN_STRING_INITIALIZER 14948 (struct cmd_vf_tc_bw_result, 14949 vf, "vf"); 14950 cmdline_parse_token_string_t cmd_vf_tc_bw_tc = 14951 TOKEN_STRING_INITIALIZER 14952 (struct cmd_vf_tc_bw_result, 14953 tc, "tc"); 14954 cmdline_parse_token_string_t cmd_vf_tc_bw_tx = 14955 TOKEN_STRING_INITIALIZER 14956 (struct cmd_vf_tc_bw_result, 14957 tx, "tx"); 14958 cmdline_parse_token_string_t cmd_vf_tc_bw_strict_link_prio = 14959 TOKEN_STRING_INITIALIZER 14960 (struct cmd_vf_tc_bw_result, 14961 strict_link_prio, "strict-link-priority"); 14962 cmdline_parse_token_string_t cmd_vf_tc_bw_min_bw = 14963 TOKEN_STRING_INITIALIZER 14964 (struct cmd_vf_tc_bw_result, 14965 min_bw, "min-bandwidth"); 14966 cmdline_parse_token_string_t cmd_vf_tc_bw_max_bw = 14967 TOKEN_STRING_INITIALIZER 14968 (struct cmd_vf_tc_bw_result, 14969 max_bw, "max-bandwidth"); 14970 cmdline_parse_token_num_t cmd_vf_tc_bw_port_id = 14971 TOKEN_NUM_INITIALIZER 14972 (struct cmd_vf_tc_bw_result, 14973 port_id, UINT16); 14974 cmdline_parse_token_num_t cmd_vf_tc_bw_vf_id = 14975 TOKEN_NUM_INITIALIZER 14976 (struct cmd_vf_tc_bw_result, 14977 vf_id, UINT16); 14978 cmdline_parse_token_num_t cmd_vf_tc_bw_tc_no = 14979 TOKEN_NUM_INITIALIZER 14980 (struct cmd_vf_tc_bw_result, 14981 tc_no, UINT8); 14982 cmdline_parse_token_num_t cmd_vf_tc_bw_bw = 14983 TOKEN_NUM_INITIALIZER 14984 (struct cmd_vf_tc_bw_result, 14985 bw, UINT32); 14986 cmdline_parse_token_string_t cmd_vf_tc_bw_bw_list = 14987 TOKEN_STRING_INITIALIZER 14988 (struct cmd_vf_tc_bw_result, 14989 bw_list, NULL); 14990 cmdline_parse_token_num_t cmd_vf_tc_bw_tc_map = 14991 TOKEN_NUM_INITIALIZER 14992 (struct cmd_vf_tc_bw_result, 14993 tc_map, UINT8); 14994 14995 /* VF max bandwidth setting */ 14996 static void 14997 cmd_vf_max_bw_parsed( 14998 void *parsed_result, 14999 __attribute__((unused)) struct cmdline *cl, 15000 __attribute__((unused)) void *data) 15001 { 15002 struct cmd_vf_tc_bw_result *res = parsed_result; 15003 int ret = -ENOTSUP; 15004 15005 if (port_id_is_invalid(res->port_id, ENABLED_WARN)) 15006 return; 15007 15008 #ifdef RTE_LIBRTE_I40E_PMD 15009 ret = rte_pmd_i40e_set_vf_max_bw(res->port_id, 15010 res->vf_id, res->bw); 15011 #endif 15012 15013 switch (ret) { 15014 case 0: 15015 break; 15016 case -EINVAL: 15017 printf("invalid vf_id %d or bandwidth %d\n", 15018 res->vf_id, res->bw); 15019 break; 15020 case -ENODEV: 15021 printf("invalid port_id %d\n", res->port_id); 15022 break; 15023 case -ENOTSUP: 15024 printf("function not implemented\n"); 15025 break; 15026 default: 15027 printf("programming error: (%s)\n", strerror(-ret)); 15028 } 15029 } 15030 15031 cmdline_parse_inst_t cmd_vf_max_bw = { 15032 .f = cmd_vf_max_bw_parsed, 15033 .data = NULL, 15034 .help_str = "set vf tx max-bandwidth <port_id> <vf_id> <bandwidth>", 15035 .tokens = { 15036 (void *)&cmd_vf_tc_bw_set, 15037 (void *)&cmd_vf_tc_bw_vf, 15038 (void *)&cmd_vf_tc_bw_tx, 15039 (void *)&cmd_vf_tc_bw_max_bw, 15040 (void *)&cmd_vf_tc_bw_port_id, 15041 (void *)&cmd_vf_tc_bw_vf_id, 15042 (void *)&cmd_vf_tc_bw_bw, 15043 NULL, 15044 }, 15045 }; 15046 15047 static int 15048 vf_tc_min_bw_parse_bw_list(uint8_t *bw_list, 15049 uint8_t *tc_num, 15050 char *str) 15051 { 15052 uint32_t size; 15053 const char *p, *p0 = str; 15054 char s[256]; 15055 char *end; 15056 char *str_fld[16]; 15057 uint16_t i; 15058 int ret; 15059 15060 p = strchr(p0, '('); 15061 if (p == NULL) { 15062 printf("The bandwidth-list should be '(bw1, bw2, ...)'\n"); 15063 return -1; 15064 } 15065 p++; 15066 p0 = strchr(p, ')'); 15067 if (p0 == NULL) { 15068 printf("The bandwidth-list should be '(bw1, bw2, ...)'\n"); 15069 return -1; 15070 } 15071 size = p0 - p; 15072 if (size >= sizeof(s)) { 15073 printf("The string size exceeds the internal buffer size\n"); 15074 return -1; 15075 } 15076 snprintf(s, sizeof(s), "%.*s", size, p); 15077 ret = rte_strsplit(s, sizeof(s), str_fld, 16, ','); 15078 if (ret <= 0) { 15079 printf("Failed to get the bandwidth list. "); 15080 return -1; 15081 } 15082 *tc_num = ret; 15083 for (i = 0; i < ret; i++) 15084 bw_list[i] = (uint8_t)strtoul(str_fld[i], &end, 0); 15085 15086 return 0; 15087 } 15088 15089 /* TC min bandwidth setting */ 15090 static void 15091 cmd_vf_tc_min_bw_parsed( 15092 void *parsed_result, 15093 __attribute__((unused)) struct cmdline *cl, 15094 __attribute__((unused)) void *data) 15095 { 15096 struct cmd_vf_tc_bw_result *res = parsed_result; 15097 uint8_t tc_num; 15098 uint8_t bw[16]; 15099 int ret = -ENOTSUP; 15100 15101 if (port_id_is_invalid(res->port_id, ENABLED_WARN)) 15102 return; 15103 15104 ret = vf_tc_min_bw_parse_bw_list(bw, &tc_num, res->bw_list); 15105 if (ret) 15106 return; 15107 15108 #ifdef RTE_LIBRTE_I40E_PMD 15109 ret = rte_pmd_i40e_set_vf_tc_bw_alloc(res->port_id, res->vf_id, 15110 tc_num, bw); 15111 #endif 15112 15113 switch (ret) { 15114 case 0: 15115 break; 15116 case -EINVAL: 15117 printf("invalid vf_id %d or bandwidth\n", res->vf_id); 15118 break; 15119 case -ENODEV: 15120 printf("invalid port_id %d\n", res->port_id); 15121 break; 15122 case -ENOTSUP: 15123 printf("function not implemented\n"); 15124 break; 15125 default: 15126 printf("programming error: (%s)\n", strerror(-ret)); 15127 } 15128 } 15129 15130 cmdline_parse_inst_t cmd_vf_tc_min_bw = { 15131 .f = cmd_vf_tc_min_bw_parsed, 15132 .data = NULL, 15133 .help_str = "set vf tc tx min-bandwidth <port_id> <vf_id>" 15134 " <bw1, bw2, ...>", 15135 .tokens = { 15136 (void *)&cmd_vf_tc_bw_set, 15137 (void *)&cmd_vf_tc_bw_vf, 15138 (void *)&cmd_vf_tc_bw_tc, 15139 (void *)&cmd_vf_tc_bw_tx, 15140 (void *)&cmd_vf_tc_bw_min_bw, 15141 (void *)&cmd_vf_tc_bw_port_id, 15142 (void *)&cmd_vf_tc_bw_vf_id, 15143 (void *)&cmd_vf_tc_bw_bw_list, 15144 NULL, 15145 }, 15146 }; 15147 15148 static void 15149 cmd_tc_min_bw_parsed( 15150 void *parsed_result, 15151 __attribute__((unused)) struct cmdline *cl, 15152 __attribute__((unused)) void *data) 15153 { 15154 struct cmd_vf_tc_bw_result *res = parsed_result; 15155 struct rte_port *port; 15156 uint8_t tc_num; 15157 uint8_t bw[16]; 15158 int ret = -ENOTSUP; 15159 15160 if (port_id_is_invalid(res->port_id, ENABLED_WARN)) 15161 return; 15162 15163 port = &ports[res->port_id]; 15164 /** Check if the port is not started **/ 15165 if (port->port_status != RTE_PORT_STOPPED) { 15166 printf("Please stop port %d first\n", res->port_id); 15167 return; 15168 } 15169 15170 ret = vf_tc_min_bw_parse_bw_list(bw, &tc_num, res->bw_list); 15171 if (ret) 15172 return; 15173 15174 #ifdef RTE_LIBRTE_IXGBE_PMD 15175 ret = rte_pmd_ixgbe_set_tc_bw_alloc(res->port_id, tc_num, bw); 15176 #endif 15177 15178 switch (ret) { 15179 case 0: 15180 break; 15181 case -EINVAL: 15182 printf("invalid bandwidth\n"); 15183 break; 15184 case -ENODEV: 15185 printf("invalid port_id %d\n", res->port_id); 15186 break; 15187 case -ENOTSUP: 15188 printf("function not implemented\n"); 15189 break; 15190 default: 15191 printf("programming error: (%s)\n", strerror(-ret)); 15192 } 15193 } 15194 15195 cmdline_parse_inst_t cmd_tc_min_bw = { 15196 .f = cmd_tc_min_bw_parsed, 15197 .data = NULL, 15198 .help_str = "set tc tx min-bandwidth <port_id> <bw1, bw2, ...>", 15199 .tokens = { 15200 (void *)&cmd_vf_tc_bw_set, 15201 (void *)&cmd_vf_tc_bw_tc, 15202 (void *)&cmd_vf_tc_bw_tx, 15203 (void *)&cmd_vf_tc_bw_min_bw, 15204 (void *)&cmd_vf_tc_bw_port_id, 15205 (void *)&cmd_vf_tc_bw_bw_list, 15206 NULL, 15207 }, 15208 }; 15209 15210 /* TC max bandwidth setting */ 15211 static void 15212 cmd_vf_tc_max_bw_parsed( 15213 void *parsed_result, 15214 __attribute__((unused)) struct cmdline *cl, 15215 __attribute__((unused)) void *data) 15216 { 15217 struct cmd_vf_tc_bw_result *res = parsed_result; 15218 int ret = -ENOTSUP; 15219 15220 if (port_id_is_invalid(res->port_id, ENABLED_WARN)) 15221 return; 15222 15223 #ifdef RTE_LIBRTE_I40E_PMD 15224 ret = rte_pmd_i40e_set_vf_tc_max_bw(res->port_id, res->vf_id, 15225 res->tc_no, res->bw); 15226 #endif 15227 15228 switch (ret) { 15229 case 0: 15230 break; 15231 case -EINVAL: 15232 printf("invalid vf_id %d, tc_no %d or bandwidth %d\n", 15233 res->vf_id, res->tc_no, res->bw); 15234 break; 15235 case -ENODEV: 15236 printf("invalid port_id %d\n", res->port_id); 15237 break; 15238 case -ENOTSUP: 15239 printf("function not implemented\n"); 15240 break; 15241 default: 15242 printf("programming error: (%s)\n", strerror(-ret)); 15243 } 15244 } 15245 15246 cmdline_parse_inst_t cmd_vf_tc_max_bw = { 15247 .f = cmd_vf_tc_max_bw_parsed, 15248 .data = NULL, 15249 .help_str = "set vf tc tx max-bandwidth <port_id> <vf_id> <tc_no>" 15250 " <bandwidth>", 15251 .tokens = { 15252 (void *)&cmd_vf_tc_bw_set, 15253 (void *)&cmd_vf_tc_bw_vf, 15254 (void *)&cmd_vf_tc_bw_tc, 15255 (void *)&cmd_vf_tc_bw_tx, 15256 (void *)&cmd_vf_tc_bw_max_bw, 15257 (void *)&cmd_vf_tc_bw_port_id, 15258 (void *)&cmd_vf_tc_bw_vf_id, 15259 (void *)&cmd_vf_tc_bw_tc_no, 15260 (void *)&cmd_vf_tc_bw_bw, 15261 NULL, 15262 }, 15263 }; 15264 15265 15266 #if defined RTE_LIBRTE_PMD_SOFTNIC && defined RTE_LIBRTE_SCHED 15267 15268 /* *** Set Port default Traffic Management Hierarchy *** */ 15269 struct cmd_set_port_tm_hierarchy_default_result { 15270 cmdline_fixed_string_t set; 15271 cmdline_fixed_string_t port; 15272 cmdline_fixed_string_t tm; 15273 cmdline_fixed_string_t hierarchy; 15274 cmdline_fixed_string_t def; 15275 portid_t port_id; 15276 }; 15277 15278 cmdline_parse_token_string_t cmd_set_port_tm_hierarchy_default_set = 15279 TOKEN_STRING_INITIALIZER( 15280 struct cmd_set_port_tm_hierarchy_default_result, set, "set"); 15281 cmdline_parse_token_string_t cmd_set_port_tm_hierarchy_default_port = 15282 TOKEN_STRING_INITIALIZER( 15283 struct cmd_set_port_tm_hierarchy_default_result, port, "port"); 15284 cmdline_parse_token_string_t cmd_set_port_tm_hierarchy_default_tm = 15285 TOKEN_STRING_INITIALIZER( 15286 struct cmd_set_port_tm_hierarchy_default_result, tm, "tm"); 15287 cmdline_parse_token_string_t cmd_set_port_tm_hierarchy_default_hierarchy = 15288 TOKEN_STRING_INITIALIZER( 15289 struct cmd_set_port_tm_hierarchy_default_result, 15290 hierarchy, "hierarchy"); 15291 cmdline_parse_token_string_t cmd_set_port_tm_hierarchy_default_default = 15292 TOKEN_STRING_INITIALIZER( 15293 struct cmd_set_port_tm_hierarchy_default_result, 15294 def, "default"); 15295 cmdline_parse_token_num_t cmd_set_port_tm_hierarchy_default_port_id = 15296 TOKEN_NUM_INITIALIZER( 15297 struct cmd_set_port_tm_hierarchy_default_result, 15298 port_id, UINT16); 15299 15300 static void cmd_set_port_tm_hierarchy_default_parsed(void *parsed_result, 15301 __attribute__((unused)) struct cmdline *cl, 15302 __attribute__((unused)) void *data) 15303 { 15304 struct cmd_set_port_tm_hierarchy_default_result *res = parsed_result; 15305 struct rte_port *p; 15306 portid_t port_id = res->port_id; 15307 15308 if (port_id_is_invalid(port_id, ENABLED_WARN)) 15309 return; 15310 15311 p = &ports[port_id]; 15312 15313 /* Forward mode: tm */ 15314 if (strcmp(cur_fwd_config.fwd_eng->fwd_mode_name, "softnic")) { 15315 printf(" softnicfwd mode not enabled(error)\n"); 15316 return; 15317 } 15318 15319 /* Set the default tm hierarchy */ 15320 p->softport.default_tm_hierarchy_enable = 1; 15321 } 15322 15323 cmdline_parse_inst_t cmd_set_port_tm_hierarchy_default = { 15324 .f = cmd_set_port_tm_hierarchy_default_parsed, 15325 .data = NULL, 15326 .help_str = "set port tm hierarchy default <port_id>", 15327 .tokens = { 15328 (void *)&cmd_set_port_tm_hierarchy_default_set, 15329 (void *)&cmd_set_port_tm_hierarchy_default_port, 15330 (void *)&cmd_set_port_tm_hierarchy_default_tm, 15331 (void *)&cmd_set_port_tm_hierarchy_default_hierarchy, 15332 (void *)&cmd_set_port_tm_hierarchy_default_default, 15333 (void *)&cmd_set_port_tm_hierarchy_default_port_id, 15334 NULL, 15335 }, 15336 }; 15337 #endif 15338 15339 /** Set VXLAN encapsulation details */ 15340 struct cmd_set_vxlan_result { 15341 cmdline_fixed_string_t set; 15342 cmdline_fixed_string_t vxlan; 15343 cmdline_fixed_string_t pos_token; 15344 cmdline_fixed_string_t ip_version; 15345 uint32_t vlan_present:1; 15346 uint32_t vni; 15347 uint16_t udp_src; 15348 uint16_t udp_dst; 15349 cmdline_ipaddr_t ip_src; 15350 cmdline_ipaddr_t ip_dst; 15351 uint16_t tci; 15352 uint8_t tos; 15353 uint8_t ttl; 15354 struct rte_ether_addr eth_src; 15355 struct rte_ether_addr eth_dst; 15356 }; 15357 15358 cmdline_parse_token_string_t cmd_set_vxlan_set = 15359 TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, set, "set"); 15360 cmdline_parse_token_string_t cmd_set_vxlan_vxlan = 15361 TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, vxlan, "vxlan"); 15362 cmdline_parse_token_string_t cmd_set_vxlan_vxlan_tos_ttl = 15363 TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, vxlan, 15364 "vxlan-tos-ttl"); 15365 cmdline_parse_token_string_t cmd_set_vxlan_vxlan_with_vlan = 15366 TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, vxlan, 15367 "vxlan-with-vlan"); 15368 cmdline_parse_token_string_t cmd_set_vxlan_ip_version = 15369 TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, pos_token, 15370 "ip-version"); 15371 cmdline_parse_token_string_t cmd_set_vxlan_ip_version_value = 15372 TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, ip_version, 15373 "ipv4#ipv6"); 15374 cmdline_parse_token_string_t cmd_set_vxlan_vni = 15375 TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, pos_token, 15376 "vni"); 15377 cmdline_parse_token_num_t cmd_set_vxlan_vni_value = 15378 TOKEN_NUM_INITIALIZER(struct cmd_set_vxlan_result, vni, UINT32); 15379 cmdline_parse_token_string_t cmd_set_vxlan_udp_src = 15380 TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, pos_token, 15381 "udp-src"); 15382 cmdline_parse_token_num_t cmd_set_vxlan_udp_src_value = 15383 TOKEN_NUM_INITIALIZER(struct cmd_set_vxlan_result, udp_src, UINT16); 15384 cmdline_parse_token_string_t cmd_set_vxlan_udp_dst = 15385 TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, pos_token, 15386 "udp-dst"); 15387 cmdline_parse_token_num_t cmd_set_vxlan_udp_dst_value = 15388 TOKEN_NUM_INITIALIZER(struct cmd_set_vxlan_result, udp_dst, UINT16); 15389 cmdline_parse_token_string_t cmd_set_vxlan_ip_tos = 15390 TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, pos_token, 15391 "ip-tos"); 15392 cmdline_parse_token_num_t cmd_set_vxlan_ip_tos_value = 15393 TOKEN_NUM_INITIALIZER(struct cmd_set_vxlan_result, tos, UINT8); 15394 cmdline_parse_token_string_t cmd_set_vxlan_ip_ttl = 15395 TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, pos_token, 15396 "ip-ttl"); 15397 cmdline_parse_token_num_t cmd_set_vxlan_ip_ttl_value = 15398 TOKEN_NUM_INITIALIZER(struct cmd_set_vxlan_result, ttl, UINT8); 15399 cmdline_parse_token_string_t cmd_set_vxlan_ip_src = 15400 TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, pos_token, 15401 "ip-src"); 15402 cmdline_parse_token_ipaddr_t cmd_set_vxlan_ip_src_value = 15403 TOKEN_IPADDR_INITIALIZER(struct cmd_set_vxlan_result, ip_src); 15404 cmdline_parse_token_string_t cmd_set_vxlan_ip_dst = 15405 TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, pos_token, 15406 "ip-dst"); 15407 cmdline_parse_token_ipaddr_t cmd_set_vxlan_ip_dst_value = 15408 TOKEN_IPADDR_INITIALIZER(struct cmd_set_vxlan_result, ip_dst); 15409 cmdline_parse_token_string_t cmd_set_vxlan_vlan = 15410 TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, pos_token, 15411 "vlan-tci"); 15412 cmdline_parse_token_num_t cmd_set_vxlan_vlan_value = 15413 TOKEN_NUM_INITIALIZER(struct cmd_set_vxlan_result, tci, UINT16); 15414 cmdline_parse_token_string_t cmd_set_vxlan_eth_src = 15415 TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, pos_token, 15416 "eth-src"); 15417 cmdline_parse_token_etheraddr_t cmd_set_vxlan_eth_src_value = 15418 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_vxlan_result, eth_src); 15419 cmdline_parse_token_string_t cmd_set_vxlan_eth_dst = 15420 TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, pos_token, 15421 "eth-dst"); 15422 cmdline_parse_token_etheraddr_t cmd_set_vxlan_eth_dst_value = 15423 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_vxlan_result, eth_dst); 15424 15425 static void cmd_set_vxlan_parsed(void *parsed_result, 15426 __attribute__((unused)) struct cmdline *cl, 15427 __attribute__((unused)) void *data) 15428 { 15429 struct cmd_set_vxlan_result *res = parsed_result; 15430 union { 15431 uint32_t vxlan_id; 15432 uint8_t vni[4]; 15433 } id = { 15434 .vxlan_id = rte_cpu_to_be_32(res->vni) & RTE_BE32(0x00ffffff), 15435 }; 15436 15437 vxlan_encap_conf.select_tos_ttl = 0; 15438 if (strcmp(res->vxlan, "vxlan") == 0) 15439 vxlan_encap_conf.select_vlan = 0; 15440 else if (strcmp(res->vxlan, "vxlan-with-vlan") == 0) 15441 vxlan_encap_conf.select_vlan = 1; 15442 else if (strcmp(res->vxlan, "vxlan-tos-ttl") == 0) { 15443 vxlan_encap_conf.select_vlan = 0; 15444 vxlan_encap_conf.select_tos_ttl = 1; 15445 } 15446 if (strcmp(res->ip_version, "ipv4") == 0) 15447 vxlan_encap_conf.select_ipv4 = 1; 15448 else if (strcmp(res->ip_version, "ipv6") == 0) 15449 vxlan_encap_conf.select_ipv4 = 0; 15450 else 15451 return; 15452 rte_memcpy(vxlan_encap_conf.vni, &id.vni[1], 3); 15453 vxlan_encap_conf.udp_src = rte_cpu_to_be_16(res->udp_src); 15454 vxlan_encap_conf.udp_dst = rte_cpu_to_be_16(res->udp_dst); 15455 vxlan_encap_conf.ip_tos = res->tos; 15456 vxlan_encap_conf.ip_ttl = res->ttl; 15457 if (vxlan_encap_conf.select_ipv4) { 15458 IPV4_ADDR_TO_UINT(res->ip_src, vxlan_encap_conf.ipv4_src); 15459 IPV4_ADDR_TO_UINT(res->ip_dst, vxlan_encap_conf.ipv4_dst); 15460 } else { 15461 IPV6_ADDR_TO_ARRAY(res->ip_src, vxlan_encap_conf.ipv6_src); 15462 IPV6_ADDR_TO_ARRAY(res->ip_dst, vxlan_encap_conf.ipv6_dst); 15463 } 15464 if (vxlan_encap_conf.select_vlan) 15465 vxlan_encap_conf.vlan_tci = rte_cpu_to_be_16(res->tci); 15466 rte_memcpy(vxlan_encap_conf.eth_src, res->eth_src.addr_bytes, 15467 RTE_ETHER_ADDR_LEN); 15468 rte_memcpy(vxlan_encap_conf.eth_dst, res->eth_dst.addr_bytes, 15469 RTE_ETHER_ADDR_LEN); 15470 } 15471 15472 cmdline_parse_inst_t cmd_set_vxlan = { 15473 .f = cmd_set_vxlan_parsed, 15474 .data = NULL, 15475 .help_str = "set vxlan ip-version ipv4|ipv6 vni <vni> udp-src" 15476 " <udp-src> udp-dst <udp-dst> ip-src <ip-src> ip-dst <ip-dst>" 15477 " eth-src <eth-src> eth-dst <eth-dst>", 15478 .tokens = { 15479 (void *)&cmd_set_vxlan_set, 15480 (void *)&cmd_set_vxlan_vxlan, 15481 (void *)&cmd_set_vxlan_ip_version, 15482 (void *)&cmd_set_vxlan_ip_version_value, 15483 (void *)&cmd_set_vxlan_vni, 15484 (void *)&cmd_set_vxlan_vni_value, 15485 (void *)&cmd_set_vxlan_udp_src, 15486 (void *)&cmd_set_vxlan_udp_src_value, 15487 (void *)&cmd_set_vxlan_udp_dst, 15488 (void *)&cmd_set_vxlan_udp_dst_value, 15489 (void *)&cmd_set_vxlan_ip_src, 15490 (void *)&cmd_set_vxlan_ip_src_value, 15491 (void *)&cmd_set_vxlan_ip_dst, 15492 (void *)&cmd_set_vxlan_ip_dst_value, 15493 (void *)&cmd_set_vxlan_eth_src, 15494 (void *)&cmd_set_vxlan_eth_src_value, 15495 (void *)&cmd_set_vxlan_eth_dst, 15496 (void *)&cmd_set_vxlan_eth_dst_value, 15497 NULL, 15498 }, 15499 }; 15500 15501 cmdline_parse_inst_t cmd_set_vxlan_tos_ttl = { 15502 .f = cmd_set_vxlan_parsed, 15503 .data = NULL, 15504 .help_str = "set vxlan-tos-ttl ip-version ipv4|ipv6 vni <vni> udp-src" 15505 " <udp-src> udp-dst <udp-dst> ip-tos <ip-tos> ip-ttl <ip-ttl>" 15506 " ip-src <ip-src> ip-dst <ip-dst> eth-src <eth-src>" 15507 " eth-dst <eth-dst>", 15508 .tokens = { 15509 (void *)&cmd_set_vxlan_set, 15510 (void *)&cmd_set_vxlan_vxlan_tos_ttl, 15511 (void *)&cmd_set_vxlan_ip_version, 15512 (void *)&cmd_set_vxlan_ip_version_value, 15513 (void *)&cmd_set_vxlan_vni, 15514 (void *)&cmd_set_vxlan_vni_value, 15515 (void *)&cmd_set_vxlan_udp_src, 15516 (void *)&cmd_set_vxlan_udp_src_value, 15517 (void *)&cmd_set_vxlan_udp_dst, 15518 (void *)&cmd_set_vxlan_udp_dst_value, 15519 (void *)&cmd_set_vxlan_ip_tos, 15520 (void *)&cmd_set_vxlan_ip_tos_value, 15521 (void *)&cmd_set_vxlan_ip_ttl, 15522 (void *)&cmd_set_vxlan_ip_ttl_value, 15523 (void *)&cmd_set_vxlan_ip_src, 15524 (void *)&cmd_set_vxlan_ip_src_value, 15525 (void *)&cmd_set_vxlan_ip_dst, 15526 (void *)&cmd_set_vxlan_ip_dst_value, 15527 (void *)&cmd_set_vxlan_eth_src, 15528 (void *)&cmd_set_vxlan_eth_src_value, 15529 (void *)&cmd_set_vxlan_eth_dst, 15530 (void *)&cmd_set_vxlan_eth_dst_value, 15531 NULL, 15532 }, 15533 }; 15534 15535 cmdline_parse_inst_t cmd_set_vxlan_with_vlan = { 15536 .f = cmd_set_vxlan_parsed, 15537 .data = NULL, 15538 .help_str = "set vxlan-with-vlan ip-version ipv4|ipv6 vni <vni>" 15539 " udp-src <udp-src> udp-dst <udp-dst> ip-src <ip-src> ip-dst" 15540 " <ip-dst> vlan-tci <vlan-tci> eth-src <eth-src> eth-dst" 15541 " <eth-dst>", 15542 .tokens = { 15543 (void *)&cmd_set_vxlan_set, 15544 (void *)&cmd_set_vxlan_vxlan_with_vlan, 15545 (void *)&cmd_set_vxlan_ip_version, 15546 (void *)&cmd_set_vxlan_ip_version_value, 15547 (void *)&cmd_set_vxlan_vni, 15548 (void *)&cmd_set_vxlan_vni_value, 15549 (void *)&cmd_set_vxlan_udp_src, 15550 (void *)&cmd_set_vxlan_udp_src_value, 15551 (void *)&cmd_set_vxlan_udp_dst, 15552 (void *)&cmd_set_vxlan_udp_dst_value, 15553 (void *)&cmd_set_vxlan_ip_src, 15554 (void *)&cmd_set_vxlan_ip_src_value, 15555 (void *)&cmd_set_vxlan_ip_dst, 15556 (void *)&cmd_set_vxlan_ip_dst_value, 15557 (void *)&cmd_set_vxlan_vlan, 15558 (void *)&cmd_set_vxlan_vlan_value, 15559 (void *)&cmd_set_vxlan_eth_src, 15560 (void *)&cmd_set_vxlan_eth_src_value, 15561 (void *)&cmd_set_vxlan_eth_dst, 15562 (void *)&cmd_set_vxlan_eth_dst_value, 15563 NULL, 15564 }, 15565 }; 15566 15567 /** Set NVGRE encapsulation details */ 15568 struct cmd_set_nvgre_result { 15569 cmdline_fixed_string_t set; 15570 cmdline_fixed_string_t nvgre; 15571 cmdline_fixed_string_t pos_token; 15572 cmdline_fixed_string_t ip_version; 15573 uint32_t tni; 15574 cmdline_ipaddr_t ip_src; 15575 cmdline_ipaddr_t ip_dst; 15576 uint16_t tci; 15577 struct rte_ether_addr eth_src; 15578 struct rte_ether_addr eth_dst; 15579 }; 15580 15581 cmdline_parse_token_string_t cmd_set_nvgre_set = 15582 TOKEN_STRING_INITIALIZER(struct cmd_set_nvgre_result, set, "set"); 15583 cmdline_parse_token_string_t cmd_set_nvgre_nvgre = 15584 TOKEN_STRING_INITIALIZER(struct cmd_set_nvgre_result, nvgre, "nvgre"); 15585 cmdline_parse_token_string_t cmd_set_nvgre_nvgre_with_vlan = 15586 TOKEN_STRING_INITIALIZER(struct cmd_set_nvgre_result, nvgre, 15587 "nvgre-with-vlan"); 15588 cmdline_parse_token_string_t cmd_set_nvgre_ip_version = 15589 TOKEN_STRING_INITIALIZER(struct cmd_set_nvgre_result, pos_token, 15590 "ip-version"); 15591 cmdline_parse_token_string_t cmd_set_nvgre_ip_version_value = 15592 TOKEN_STRING_INITIALIZER(struct cmd_set_nvgre_result, ip_version, 15593 "ipv4#ipv6"); 15594 cmdline_parse_token_string_t cmd_set_nvgre_tni = 15595 TOKEN_STRING_INITIALIZER(struct cmd_set_nvgre_result, pos_token, 15596 "tni"); 15597 cmdline_parse_token_num_t cmd_set_nvgre_tni_value = 15598 TOKEN_NUM_INITIALIZER(struct cmd_set_nvgre_result, tni, UINT32); 15599 cmdline_parse_token_string_t cmd_set_nvgre_ip_src = 15600 TOKEN_STRING_INITIALIZER(struct cmd_set_nvgre_result, pos_token, 15601 "ip-src"); 15602 cmdline_parse_token_num_t cmd_set_nvgre_ip_src_value = 15603 TOKEN_IPADDR_INITIALIZER(struct cmd_set_nvgre_result, ip_src); 15604 cmdline_parse_token_string_t cmd_set_nvgre_ip_dst = 15605 TOKEN_STRING_INITIALIZER(struct cmd_set_nvgre_result, pos_token, 15606 "ip-dst"); 15607 cmdline_parse_token_ipaddr_t cmd_set_nvgre_ip_dst_value = 15608 TOKEN_IPADDR_INITIALIZER(struct cmd_set_nvgre_result, ip_dst); 15609 cmdline_parse_token_string_t cmd_set_nvgre_vlan = 15610 TOKEN_STRING_INITIALIZER(struct cmd_set_nvgre_result, pos_token, 15611 "vlan-tci"); 15612 cmdline_parse_token_num_t cmd_set_nvgre_vlan_value = 15613 TOKEN_NUM_INITIALIZER(struct cmd_set_nvgre_result, tci, UINT16); 15614 cmdline_parse_token_string_t cmd_set_nvgre_eth_src = 15615 TOKEN_STRING_INITIALIZER(struct cmd_set_nvgre_result, pos_token, 15616 "eth-src"); 15617 cmdline_parse_token_etheraddr_t cmd_set_nvgre_eth_src_value = 15618 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_nvgre_result, eth_src); 15619 cmdline_parse_token_string_t cmd_set_nvgre_eth_dst = 15620 TOKEN_STRING_INITIALIZER(struct cmd_set_nvgre_result, pos_token, 15621 "eth-dst"); 15622 cmdline_parse_token_etheraddr_t cmd_set_nvgre_eth_dst_value = 15623 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_nvgre_result, eth_dst); 15624 15625 static void cmd_set_nvgre_parsed(void *parsed_result, 15626 __attribute__((unused)) struct cmdline *cl, 15627 __attribute__((unused)) void *data) 15628 { 15629 struct cmd_set_nvgre_result *res = parsed_result; 15630 union { 15631 uint32_t nvgre_tni; 15632 uint8_t tni[4]; 15633 } id = { 15634 .nvgre_tni = rte_cpu_to_be_32(res->tni) & RTE_BE32(0x00ffffff), 15635 }; 15636 15637 if (strcmp(res->nvgre, "nvgre") == 0) 15638 nvgre_encap_conf.select_vlan = 0; 15639 else if (strcmp(res->nvgre, "nvgre-with-vlan") == 0) 15640 nvgre_encap_conf.select_vlan = 1; 15641 if (strcmp(res->ip_version, "ipv4") == 0) 15642 nvgre_encap_conf.select_ipv4 = 1; 15643 else if (strcmp(res->ip_version, "ipv6") == 0) 15644 nvgre_encap_conf.select_ipv4 = 0; 15645 else 15646 return; 15647 rte_memcpy(nvgre_encap_conf.tni, &id.tni[1], 3); 15648 if (nvgre_encap_conf.select_ipv4) { 15649 IPV4_ADDR_TO_UINT(res->ip_src, nvgre_encap_conf.ipv4_src); 15650 IPV4_ADDR_TO_UINT(res->ip_dst, nvgre_encap_conf.ipv4_dst); 15651 } else { 15652 IPV6_ADDR_TO_ARRAY(res->ip_src, nvgre_encap_conf.ipv6_src); 15653 IPV6_ADDR_TO_ARRAY(res->ip_dst, nvgre_encap_conf.ipv6_dst); 15654 } 15655 if (nvgre_encap_conf.select_vlan) 15656 nvgre_encap_conf.vlan_tci = rte_cpu_to_be_16(res->tci); 15657 rte_memcpy(nvgre_encap_conf.eth_src, res->eth_src.addr_bytes, 15658 RTE_ETHER_ADDR_LEN); 15659 rte_memcpy(nvgre_encap_conf.eth_dst, res->eth_dst.addr_bytes, 15660 RTE_ETHER_ADDR_LEN); 15661 } 15662 15663 cmdline_parse_inst_t cmd_set_nvgre = { 15664 .f = cmd_set_nvgre_parsed, 15665 .data = NULL, 15666 .help_str = "set nvgre ip-version <ipv4|ipv6> tni <tni> ip-src" 15667 " <ip-src> ip-dst <ip-dst> eth-src <eth-src>" 15668 " eth-dst <eth-dst>", 15669 .tokens = { 15670 (void *)&cmd_set_nvgre_set, 15671 (void *)&cmd_set_nvgre_nvgre, 15672 (void *)&cmd_set_nvgre_ip_version, 15673 (void *)&cmd_set_nvgre_ip_version_value, 15674 (void *)&cmd_set_nvgre_tni, 15675 (void *)&cmd_set_nvgre_tni_value, 15676 (void *)&cmd_set_nvgre_ip_src, 15677 (void *)&cmd_set_nvgre_ip_src_value, 15678 (void *)&cmd_set_nvgre_ip_dst, 15679 (void *)&cmd_set_nvgre_ip_dst_value, 15680 (void *)&cmd_set_nvgre_eth_src, 15681 (void *)&cmd_set_nvgre_eth_src_value, 15682 (void *)&cmd_set_nvgre_eth_dst, 15683 (void *)&cmd_set_nvgre_eth_dst_value, 15684 NULL, 15685 }, 15686 }; 15687 15688 cmdline_parse_inst_t cmd_set_nvgre_with_vlan = { 15689 .f = cmd_set_nvgre_parsed, 15690 .data = NULL, 15691 .help_str = "set nvgre-with-vlan ip-version <ipv4|ipv6> tni <tni>" 15692 " ip-src <ip-src> ip-dst <ip-dst> vlan-tci <vlan-tci>" 15693 " eth-src <eth-src> eth-dst <eth-dst>", 15694 .tokens = { 15695 (void *)&cmd_set_nvgre_set, 15696 (void *)&cmd_set_nvgre_nvgre_with_vlan, 15697 (void *)&cmd_set_nvgre_ip_version, 15698 (void *)&cmd_set_nvgre_ip_version_value, 15699 (void *)&cmd_set_nvgre_tni, 15700 (void *)&cmd_set_nvgre_tni_value, 15701 (void *)&cmd_set_nvgre_ip_src, 15702 (void *)&cmd_set_nvgre_ip_src_value, 15703 (void *)&cmd_set_nvgre_ip_dst, 15704 (void *)&cmd_set_nvgre_ip_dst_value, 15705 (void *)&cmd_set_nvgre_vlan, 15706 (void *)&cmd_set_nvgre_vlan_value, 15707 (void *)&cmd_set_nvgre_eth_src, 15708 (void *)&cmd_set_nvgre_eth_src_value, 15709 (void *)&cmd_set_nvgre_eth_dst, 15710 (void *)&cmd_set_nvgre_eth_dst_value, 15711 NULL, 15712 }, 15713 }; 15714 15715 /** Set L2 encapsulation details */ 15716 struct cmd_set_l2_encap_result { 15717 cmdline_fixed_string_t set; 15718 cmdline_fixed_string_t l2_encap; 15719 cmdline_fixed_string_t pos_token; 15720 cmdline_fixed_string_t ip_version; 15721 uint32_t vlan_present:1; 15722 uint16_t tci; 15723 struct rte_ether_addr eth_src; 15724 struct rte_ether_addr eth_dst; 15725 }; 15726 15727 cmdline_parse_token_string_t cmd_set_l2_encap_set = 15728 TOKEN_STRING_INITIALIZER(struct cmd_set_l2_encap_result, set, "set"); 15729 cmdline_parse_token_string_t cmd_set_l2_encap_l2_encap = 15730 TOKEN_STRING_INITIALIZER(struct cmd_set_l2_encap_result, l2_encap, "l2_encap"); 15731 cmdline_parse_token_string_t cmd_set_l2_encap_l2_encap_with_vlan = 15732 TOKEN_STRING_INITIALIZER(struct cmd_set_l2_encap_result, l2_encap, 15733 "l2_encap-with-vlan"); 15734 cmdline_parse_token_string_t cmd_set_l2_encap_ip_version = 15735 TOKEN_STRING_INITIALIZER(struct cmd_set_l2_encap_result, pos_token, 15736 "ip-version"); 15737 cmdline_parse_token_string_t cmd_set_l2_encap_ip_version_value = 15738 TOKEN_STRING_INITIALIZER(struct cmd_set_l2_encap_result, ip_version, 15739 "ipv4#ipv6"); 15740 cmdline_parse_token_string_t cmd_set_l2_encap_vlan = 15741 TOKEN_STRING_INITIALIZER(struct cmd_set_l2_encap_result, pos_token, 15742 "vlan-tci"); 15743 cmdline_parse_token_num_t cmd_set_l2_encap_vlan_value = 15744 TOKEN_NUM_INITIALIZER(struct cmd_set_l2_encap_result, tci, UINT16); 15745 cmdline_parse_token_string_t cmd_set_l2_encap_eth_src = 15746 TOKEN_STRING_INITIALIZER(struct cmd_set_l2_encap_result, pos_token, 15747 "eth-src"); 15748 cmdline_parse_token_etheraddr_t cmd_set_l2_encap_eth_src_value = 15749 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_l2_encap_result, eth_src); 15750 cmdline_parse_token_string_t cmd_set_l2_encap_eth_dst = 15751 TOKEN_STRING_INITIALIZER(struct cmd_set_l2_encap_result, pos_token, 15752 "eth-dst"); 15753 cmdline_parse_token_etheraddr_t cmd_set_l2_encap_eth_dst_value = 15754 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_l2_encap_result, eth_dst); 15755 15756 static void cmd_set_l2_encap_parsed(void *parsed_result, 15757 __attribute__((unused)) struct cmdline *cl, 15758 __attribute__((unused)) void *data) 15759 { 15760 struct cmd_set_l2_encap_result *res = parsed_result; 15761 15762 if (strcmp(res->l2_encap, "l2_encap") == 0) 15763 l2_encap_conf.select_vlan = 0; 15764 else if (strcmp(res->l2_encap, "l2_encap-with-vlan") == 0) 15765 l2_encap_conf.select_vlan = 1; 15766 if (strcmp(res->ip_version, "ipv4") == 0) 15767 l2_encap_conf.select_ipv4 = 1; 15768 else if (strcmp(res->ip_version, "ipv6") == 0) 15769 l2_encap_conf.select_ipv4 = 0; 15770 else 15771 return; 15772 if (l2_encap_conf.select_vlan) 15773 l2_encap_conf.vlan_tci = rte_cpu_to_be_16(res->tci); 15774 rte_memcpy(l2_encap_conf.eth_src, res->eth_src.addr_bytes, 15775 RTE_ETHER_ADDR_LEN); 15776 rte_memcpy(l2_encap_conf.eth_dst, res->eth_dst.addr_bytes, 15777 RTE_ETHER_ADDR_LEN); 15778 } 15779 15780 cmdline_parse_inst_t cmd_set_l2_encap = { 15781 .f = cmd_set_l2_encap_parsed, 15782 .data = NULL, 15783 .help_str = "set l2_encap ip-version ipv4|ipv6" 15784 " eth-src <eth-src> eth-dst <eth-dst>", 15785 .tokens = { 15786 (void *)&cmd_set_l2_encap_set, 15787 (void *)&cmd_set_l2_encap_l2_encap, 15788 (void *)&cmd_set_l2_encap_ip_version, 15789 (void *)&cmd_set_l2_encap_ip_version_value, 15790 (void *)&cmd_set_l2_encap_eth_src, 15791 (void *)&cmd_set_l2_encap_eth_src_value, 15792 (void *)&cmd_set_l2_encap_eth_dst, 15793 (void *)&cmd_set_l2_encap_eth_dst_value, 15794 NULL, 15795 }, 15796 }; 15797 15798 cmdline_parse_inst_t cmd_set_l2_encap_with_vlan = { 15799 .f = cmd_set_l2_encap_parsed, 15800 .data = NULL, 15801 .help_str = "set l2_encap-with-vlan ip-version ipv4|ipv6" 15802 " vlan-tci <vlan-tci> eth-src <eth-src> eth-dst <eth-dst>", 15803 .tokens = { 15804 (void *)&cmd_set_l2_encap_set, 15805 (void *)&cmd_set_l2_encap_l2_encap_with_vlan, 15806 (void *)&cmd_set_l2_encap_ip_version, 15807 (void *)&cmd_set_l2_encap_ip_version_value, 15808 (void *)&cmd_set_l2_encap_vlan, 15809 (void *)&cmd_set_l2_encap_vlan_value, 15810 (void *)&cmd_set_l2_encap_eth_src, 15811 (void *)&cmd_set_l2_encap_eth_src_value, 15812 (void *)&cmd_set_l2_encap_eth_dst, 15813 (void *)&cmd_set_l2_encap_eth_dst_value, 15814 NULL, 15815 }, 15816 }; 15817 15818 /** Set L2 decapsulation details */ 15819 struct cmd_set_l2_decap_result { 15820 cmdline_fixed_string_t set; 15821 cmdline_fixed_string_t l2_decap; 15822 cmdline_fixed_string_t pos_token; 15823 uint32_t vlan_present:1; 15824 }; 15825 15826 cmdline_parse_token_string_t cmd_set_l2_decap_set = 15827 TOKEN_STRING_INITIALIZER(struct cmd_set_l2_decap_result, set, "set"); 15828 cmdline_parse_token_string_t cmd_set_l2_decap_l2_decap = 15829 TOKEN_STRING_INITIALIZER(struct cmd_set_l2_decap_result, l2_decap, 15830 "l2_decap"); 15831 cmdline_parse_token_string_t cmd_set_l2_decap_l2_decap_with_vlan = 15832 TOKEN_STRING_INITIALIZER(struct cmd_set_l2_decap_result, l2_decap, 15833 "l2_decap-with-vlan"); 15834 15835 static void cmd_set_l2_decap_parsed(void *parsed_result, 15836 __attribute__((unused)) struct cmdline *cl, 15837 __attribute__((unused)) void *data) 15838 { 15839 struct cmd_set_l2_decap_result *res = parsed_result; 15840 15841 if (strcmp(res->l2_decap, "l2_decap") == 0) 15842 l2_decap_conf.select_vlan = 0; 15843 else if (strcmp(res->l2_decap, "l2_decap-with-vlan") == 0) 15844 l2_decap_conf.select_vlan = 1; 15845 } 15846 15847 cmdline_parse_inst_t cmd_set_l2_decap = { 15848 .f = cmd_set_l2_decap_parsed, 15849 .data = NULL, 15850 .help_str = "set l2_decap", 15851 .tokens = { 15852 (void *)&cmd_set_l2_decap_set, 15853 (void *)&cmd_set_l2_decap_l2_decap, 15854 NULL, 15855 }, 15856 }; 15857 15858 cmdline_parse_inst_t cmd_set_l2_decap_with_vlan = { 15859 .f = cmd_set_l2_decap_parsed, 15860 .data = NULL, 15861 .help_str = "set l2_decap-with-vlan", 15862 .tokens = { 15863 (void *)&cmd_set_l2_decap_set, 15864 (void *)&cmd_set_l2_decap_l2_decap_with_vlan, 15865 NULL, 15866 }, 15867 }; 15868 15869 /** Set MPLSoGRE encapsulation details */ 15870 struct cmd_set_mplsogre_encap_result { 15871 cmdline_fixed_string_t set; 15872 cmdline_fixed_string_t mplsogre; 15873 cmdline_fixed_string_t pos_token; 15874 cmdline_fixed_string_t ip_version; 15875 uint32_t vlan_present:1; 15876 uint32_t label; 15877 cmdline_ipaddr_t ip_src; 15878 cmdline_ipaddr_t ip_dst; 15879 uint16_t tci; 15880 struct rte_ether_addr eth_src; 15881 struct rte_ether_addr eth_dst; 15882 }; 15883 15884 cmdline_parse_token_string_t cmd_set_mplsogre_encap_set = 15885 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_encap_result, set, 15886 "set"); 15887 cmdline_parse_token_string_t cmd_set_mplsogre_encap_mplsogre_encap = 15888 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_encap_result, mplsogre, 15889 "mplsogre_encap"); 15890 cmdline_parse_token_string_t cmd_set_mplsogre_encap_mplsogre_encap_with_vlan = 15891 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_encap_result, 15892 mplsogre, "mplsogre_encap-with-vlan"); 15893 cmdline_parse_token_string_t cmd_set_mplsogre_encap_ip_version = 15894 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_encap_result, 15895 pos_token, "ip-version"); 15896 cmdline_parse_token_string_t cmd_set_mplsogre_encap_ip_version_value = 15897 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_encap_result, 15898 ip_version, "ipv4#ipv6"); 15899 cmdline_parse_token_string_t cmd_set_mplsogre_encap_label = 15900 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_encap_result, 15901 pos_token, "label"); 15902 cmdline_parse_token_num_t cmd_set_mplsogre_encap_label_value = 15903 TOKEN_NUM_INITIALIZER(struct cmd_set_mplsogre_encap_result, label, 15904 UINT32); 15905 cmdline_parse_token_string_t cmd_set_mplsogre_encap_ip_src = 15906 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_encap_result, 15907 pos_token, "ip-src"); 15908 cmdline_parse_token_ipaddr_t cmd_set_mplsogre_encap_ip_src_value = 15909 TOKEN_IPADDR_INITIALIZER(struct cmd_set_mplsogre_encap_result, ip_src); 15910 cmdline_parse_token_string_t cmd_set_mplsogre_encap_ip_dst = 15911 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_encap_result, 15912 pos_token, "ip-dst"); 15913 cmdline_parse_token_ipaddr_t cmd_set_mplsogre_encap_ip_dst_value = 15914 TOKEN_IPADDR_INITIALIZER(struct cmd_set_mplsogre_encap_result, ip_dst); 15915 cmdline_parse_token_string_t cmd_set_mplsogre_encap_vlan = 15916 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_encap_result, 15917 pos_token, "vlan-tci"); 15918 cmdline_parse_token_num_t cmd_set_mplsogre_encap_vlan_value = 15919 TOKEN_NUM_INITIALIZER(struct cmd_set_mplsogre_encap_result, tci, 15920 UINT16); 15921 cmdline_parse_token_string_t cmd_set_mplsogre_encap_eth_src = 15922 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_encap_result, 15923 pos_token, "eth-src"); 15924 cmdline_parse_token_etheraddr_t cmd_set_mplsogre_encap_eth_src_value = 15925 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_mplsogre_encap_result, 15926 eth_src); 15927 cmdline_parse_token_string_t cmd_set_mplsogre_encap_eth_dst = 15928 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_encap_result, 15929 pos_token, "eth-dst"); 15930 cmdline_parse_token_etheraddr_t cmd_set_mplsogre_encap_eth_dst_value = 15931 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_mplsogre_encap_result, 15932 eth_dst); 15933 15934 static void cmd_set_mplsogre_encap_parsed(void *parsed_result, 15935 __attribute__((unused)) struct cmdline *cl, 15936 __attribute__((unused)) void *data) 15937 { 15938 struct cmd_set_mplsogre_encap_result *res = parsed_result; 15939 union { 15940 uint32_t mplsogre_label; 15941 uint8_t label[4]; 15942 } id = { 15943 .mplsogre_label = rte_cpu_to_be_32(res->label<<12), 15944 }; 15945 15946 if (strcmp(res->mplsogre, "mplsogre_encap") == 0) 15947 mplsogre_encap_conf.select_vlan = 0; 15948 else if (strcmp(res->mplsogre, "mplsogre_encap-with-vlan") == 0) 15949 mplsogre_encap_conf.select_vlan = 1; 15950 if (strcmp(res->ip_version, "ipv4") == 0) 15951 mplsogre_encap_conf.select_ipv4 = 1; 15952 else if (strcmp(res->ip_version, "ipv6") == 0) 15953 mplsogre_encap_conf.select_ipv4 = 0; 15954 else 15955 return; 15956 rte_memcpy(mplsogre_encap_conf.label, &id.label, 3); 15957 if (mplsogre_encap_conf.select_ipv4) { 15958 IPV4_ADDR_TO_UINT(res->ip_src, mplsogre_encap_conf.ipv4_src); 15959 IPV4_ADDR_TO_UINT(res->ip_dst, mplsogre_encap_conf.ipv4_dst); 15960 } else { 15961 IPV6_ADDR_TO_ARRAY(res->ip_src, mplsogre_encap_conf.ipv6_src); 15962 IPV6_ADDR_TO_ARRAY(res->ip_dst, mplsogre_encap_conf.ipv6_dst); 15963 } 15964 if (mplsogre_encap_conf.select_vlan) 15965 mplsogre_encap_conf.vlan_tci = rte_cpu_to_be_16(res->tci); 15966 rte_memcpy(mplsogre_encap_conf.eth_src, res->eth_src.addr_bytes, 15967 RTE_ETHER_ADDR_LEN); 15968 rte_memcpy(mplsogre_encap_conf.eth_dst, res->eth_dst.addr_bytes, 15969 RTE_ETHER_ADDR_LEN); 15970 } 15971 15972 cmdline_parse_inst_t cmd_set_mplsogre_encap = { 15973 .f = cmd_set_mplsogre_encap_parsed, 15974 .data = NULL, 15975 .help_str = "set mplsogre_encap ip-version ipv4|ipv6 label <label>" 15976 " ip-src <ip-src> ip-dst <ip-dst> eth-src <eth-src>" 15977 " eth-dst <eth-dst>", 15978 .tokens = { 15979 (void *)&cmd_set_mplsogre_encap_set, 15980 (void *)&cmd_set_mplsogre_encap_mplsogre_encap, 15981 (void *)&cmd_set_mplsogre_encap_ip_version, 15982 (void *)&cmd_set_mplsogre_encap_ip_version_value, 15983 (void *)&cmd_set_mplsogre_encap_label, 15984 (void *)&cmd_set_mplsogre_encap_label_value, 15985 (void *)&cmd_set_mplsogre_encap_ip_src, 15986 (void *)&cmd_set_mplsogre_encap_ip_src_value, 15987 (void *)&cmd_set_mplsogre_encap_ip_dst, 15988 (void *)&cmd_set_mplsogre_encap_ip_dst_value, 15989 (void *)&cmd_set_mplsogre_encap_eth_src, 15990 (void *)&cmd_set_mplsogre_encap_eth_src_value, 15991 (void *)&cmd_set_mplsogre_encap_eth_dst, 15992 (void *)&cmd_set_mplsogre_encap_eth_dst_value, 15993 NULL, 15994 }, 15995 }; 15996 15997 cmdline_parse_inst_t cmd_set_mplsogre_encap_with_vlan = { 15998 .f = cmd_set_mplsogre_encap_parsed, 15999 .data = NULL, 16000 .help_str = "set mplsogre_encap-with-vlan ip-version ipv4|ipv6" 16001 " label <label> ip-src <ip-src> ip-dst <ip-dst>" 16002 " vlan-tci <vlan-tci> eth-src <eth-src> eth-dst <eth-dst>", 16003 .tokens = { 16004 (void *)&cmd_set_mplsogre_encap_set, 16005 (void *)&cmd_set_mplsogre_encap_mplsogre_encap_with_vlan, 16006 (void *)&cmd_set_mplsogre_encap_ip_version, 16007 (void *)&cmd_set_mplsogre_encap_ip_version_value, 16008 (void *)&cmd_set_mplsogre_encap_label, 16009 (void *)&cmd_set_mplsogre_encap_label_value, 16010 (void *)&cmd_set_mplsogre_encap_ip_src, 16011 (void *)&cmd_set_mplsogre_encap_ip_src_value, 16012 (void *)&cmd_set_mplsogre_encap_ip_dst, 16013 (void *)&cmd_set_mplsogre_encap_ip_dst_value, 16014 (void *)&cmd_set_mplsogre_encap_vlan, 16015 (void *)&cmd_set_mplsogre_encap_vlan_value, 16016 (void *)&cmd_set_mplsogre_encap_eth_src, 16017 (void *)&cmd_set_mplsogre_encap_eth_src_value, 16018 (void *)&cmd_set_mplsogre_encap_eth_dst, 16019 (void *)&cmd_set_mplsogre_encap_eth_dst_value, 16020 NULL, 16021 }, 16022 }; 16023 16024 /** Set MPLSoGRE decapsulation details */ 16025 struct cmd_set_mplsogre_decap_result { 16026 cmdline_fixed_string_t set; 16027 cmdline_fixed_string_t mplsogre; 16028 cmdline_fixed_string_t pos_token; 16029 cmdline_fixed_string_t ip_version; 16030 uint32_t vlan_present:1; 16031 }; 16032 16033 cmdline_parse_token_string_t cmd_set_mplsogre_decap_set = 16034 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_decap_result, set, 16035 "set"); 16036 cmdline_parse_token_string_t cmd_set_mplsogre_decap_mplsogre_decap = 16037 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_decap_result, mplsogre, 16038 "mplsogre_decap"); 16039 cmdline_parse_token_string_t cmd_set_mplsogre_decap_mplsogre_decap_with_vlan = 16040 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_decap_result, 16041 mplsogre, "mplsogre_decap-with-vlan"); 16042 cmdline_parse_token_string_t cmd_set_mplsogre_decap_ip_version = 16043 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_decap_result, 16044 pos_token, "ip-version"); 16045 cmdline_parse_token_string_t cmd_set_mplsogre_decap_ip_version_value = 16046 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_decap_result, 16047 ip_version, "ipv4#ipv6"); 16048 16049 static void cmd_set_mplsogre_decap_parsed(void *parsed_result, 16050 __attribute__((unused)) struct cmdline *cl, 16051 __attribute__((unused)) void *data) 16052 { 16053 struct cmd_set_mplsogre_decap_result *res = parsed_result; 16054 16055 if (strcmp(res->mplsogre, "mplsogre_decap") == 0) 16056 mplsogre_decap_conf.select_vlan = 0; 16057 else if (strcmp(res->mplsogre, "mplsogre_decap-with-vlan") == 0) 16058 mplsogre_decap_conf.select_vlan = 1; 16059 if (strcmp(res->ip_version, "ipv4") == 0) 16060 mplsogre_decap_conf.select_ipv4 = 1; 16061 else if (strcmp(res->ip_version, "ipv6") == 0) 16062 mplsogre_decap_conf.select_ipv4 = 0; 16063 } 16064 16065 cmdline_parse_inst_t cmd_set_mplsogre_decap = { 16066 .f = cmd_set_mplsogre_decap_parsed, 16067 .data = NULL, 16068 .help_str = "set mplsogre_decap ip-version ipv4|ipv6", 16069 .tokens = { 16070 (void *)&cmd_set_mplsogre_decap_set, 16071 (void *)&cmd_set_mplsogre_decap_mplsogre_decap, 16072 (void *)&cmd_set_mplsogre_decap_ip_version, 16073 (void *)&cmd_set_mplsogre_decap_ip_version_value, 16074 NULL, 16075 }, 16076 }; 16077 16078 cmdline_parse_inst_t cmd_set_mplsogre_decap_with_vlan = { 16079 .f = cmd_set_mplsogre_decap_parsed, 16080 .data = NULL, 16081 .help_str = "set mplsogre_decap-with-vlan ip-version ipv4|ipv6", 16082 .tokens = { 16083 (void *)&cmd_set_mplsogre_decap_set, 16084 (void *)&cmd_set_mplsogre_decap_mplsogre_decap_with_vlan, 16085 (void *)&cmd_set_mplsogre_decap_ip_version, 16086 (void *)&cmd_set_mplsogre_decap_ip_version_value, 16087 NULL, 16088 }, 16089 }; 16090 16091 /** Set MPLSoUDP encapsulation details */ 16092 struct cmd_set_mplsoudp_encap_result { 16093 cmdline_fixed_string_t set; 16094 cmdline_fixed_string_t mplsoudp; 16095 cmdline_fixed_string_t pos_token; 16096 cmdline_fixed_string_t ip_version; 16097 uint32_t vlan_present:1; 16098 uint32_t label; 16099 uint16_t udp_src; 16100 uint16_t udp_dst; 16101 cmdline_ipaddr_t ip_src; 16102 cmdline_ipaddr_t ip_dst; 16103 uint16_t tci; 16104 struct rte_ether_addr eth_src; 16105 struct rte_ether_addr eth_dst; 16106 }; 16107 16108 cmdline_parse_token_string_t cmd_set_mplsoudp_encap_set = 16109 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_encap_result, set, 16110 "set"); 16111 cmdline_parse_token_string_t cmd_set_mplsoudp_encap_mplsoudp_encap = 16112 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_encap_result, mplsoudp, 16113 "mplsoudp_encap"); 16114 cmdline_parse_token_string_t cmd_set_mplsoudp_encap_mplsoudp_encap_with_vlan = 16115 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_encap_result, 16116 mplsoudp, "mplsoudp_encap-with-vlan"); 16117 cmdline_parse_token_string_t cmd_set_mplsoudp_encap_ip_version = 16118 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_encap_result, 16119 pos_token, "ip-version"); 16120 cmdline_parse_token_string_t cmd_set_mplsoudp_encap_ip_version_value = 16121 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_encap_result, 16122 ip_version, "ipv4#ipv6"); 16123 cmdline_parse_token_string_t cmd_set_mplsoudp_encap_label = 16124 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_encap_result, 16125 pos_token, "label"); 16126 cmdline_parse_token_num_t cmd_set_mplsoudp_encap_label_value = 16127 TOKEN_NUM_INITIALIZER(struct cmd_set_mplsoudp_encap_result, label, 16128 UINT32); 16129 cmdline_parse_token_string_t cmd_set_mplsoudp_encap_udp_src = 16130 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_encap_result, 16131 pos_token, "udp-src"); 16132 cmdline_parse_token_num_t cmd_set_mplsoudp_encap_udp_src_value = 16133 TOKEN_NUM_INITIALIZER(struct cmd_set_mplsoudp_encap_result, udp_src, 16134 UINT16); 16135 cmdline_parse_token_string_t cmd_set_mplsoudp_encap_udp_dst = 16136 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_encap_result, 16137 pos_token, "udp-dst"); 16138 cmdline_parse_token_num_t cmd_set_mplsoudp_encap_udp_dst_value = 16139 TOKEN_NUM_INITIALIZER(struct cmd_set_mplsoudp_encap_result, udp_dst, 16140 UINT16); 16141 cmdline_parse_token_string_t cmd_set_mplsoudp_encap_ip_src = 16142 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_encap_result, 16143 pos_token, "ip-src"); 16144 cmdline_parse_token_ipaddr_t cmd_set_mplsoudp_encap_ip_src_value = 16145 TOKEN_IPADDR_INITIALIZER(struct cmd_set_mplsoudp_encap_result, ip_src); 16146 cmdline_parse_token_string_t cmd_set_mplsoudp_encap_ip_dst = 16147 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_encap_result, 16148 pos_token, "ip-dst"); 16149 cmdline_parse_token_ipaddr_t cmd_set_mplsoudp_encap_ip_dst_value = 16150 TOKEN_IPADDR_INITIALIZER(struct cmd_set_mplsoudp_encap_result, ip_dst); 16151 cmdline_parse_token_string_t cmd_set_mplsoudp_encap_vlan = 16152 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_encap_result, 16153 pos_token, "vlan-tci"); 16154 cmdline_parse_token_num_t cmd_set_mplsoudp_encap_vlan_value = 16155 TOKEN_NUM_INITIALIZER(struct cmd_set_mplsoudp_encap_result, tci, 16156 UINT16); 16157 cmdline_parse_token_string_t cmd_set_mplsoudp_encap_eth_src = 16158 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_encap_result, 16159 pos_token, "eth-src"); 16160 cmdline_parse_token_etheraddr_t cmd_set_mplsoudp_encap_eth_src_value = 16161 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_mplsoudp_encap_result, 16162 eth_src); 16163 cmdline_parse_token_string_t cmd_set_mplsoudp_encap_eth_dst = 16164 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_encap_result, 16165 pos_token, "eth-dst"); 16166 cmdline_parse_token_etheraddr_t cmd_set_mplsoudp_encap_eth_dst_value = 16167 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_mplsoudp_encap_result, 16168 eth_dst); 16169 16170 static void cmd_set_mplsoudp_encap_parsed(void *parsed_result, 16171 __attribute__((unused)) struct cmdline *cl, 16172 __attribute__((unused)) void *data) 16173 { 16174 struct cmd_set_mplsoudp_encap_result *res = parsed_result; 16175 union { 16176 uint32_t mplsoudp_label; 16177 uint8_t label[4]; 16178 } id = { 16179 .mplsoudp_label = rte_cpu_to_be_32(res->label<<12), 16180 }; 16181 16182 if (strcmp(res->mplsoudp, "mplsoudp_encap") == 0) 16183 mplsoudp_encap_conf.select_vlan = 0; 16184 else if (strcmp(res->mplsoudp, "mplsoudp_encap-with-vlan") == 0) 16185 mplsoudp_encap_conf.select_vlan = 1; 16186 if (strcmp(res->ip_version, "ipv4") == 0) 16187 mplsoudp_encap_conf.select_ipv4 = 1; 16188 else if (strcmp(res->ip_version, "ipv6") == 0) 16189 mplsoudp_encap_conf.select_ipv4 = 0; 16190 else 16191 return; 16192 rte_memcpy(mplsoudp_encap_conf.label, &id.label, 3); 16193 mplsoudp_encap_conf.udp_src = rte_cpu_to_be_16(res->udp_src); 16194 mplsoudp_encap_conf.udp_dst = rte_cpu_to_be_16(res->udp_dst); 16195 if (mplsoudp_encap_conf.select_ipv4) { 16196 IPV4_ADDR_TO_UINT(res->ip_src, mplsoudp_encap_conf.ipv4_src); 16197 IPV4_ADDR_TO_UINT(res->ip_dst, mplsoudp_encap_conf.ipv4_dst); 16198 } else { 16199 IPV6_ADDR_TO_ARRAY(res->ip_src, mplsoudp_encap_conf.ipv6_src); 16200 IPV6_ADDR_TO_ARRAY(res->ip_dst, mplsoudp_encap_conf.ipv6_dst); 16201 } 16202 if (mplsoudp_encap_conf.select_vlan) 16203 mplsoudp_encap_conf.vlan_tci = rte_cpu_to_be_16(res->tci); 16204 rte_memcpy(mplsoudp_encap_conf.eth_src, res->eth_src.addr_bytes, 16205 RTE_ETHER_ADDR_LEN); 16206 rte_memcpy(mplsoudp_encap_conf.eth_dst, res->eth_dst.addr_bytes, 16207 RTE_ETHER_ADDR_LEN); 16208 } 16209 16210 cmdline_parse_inst_t cmd_set_mplsoudp_encap = { 16211 .f = cmd_set_mplsoudp_encap_parsed, 16212 .data = NULL, 16213 .help_str = "set mplsoudp_encap ip-version ipv4|ipv6 label <label>" 16214 " udp-src <udp-src> udp-dst <udp-dst> ip-src <ip-src>" 16215 " ip-dst <ip-dst> eth-src <eth-src> eth-dst <eth-dst>", 16216 .tokens = { 16217 (void *)&cmd_set_mplsoudp_encap_set, 16218 (void *)&cmd_set_mplsoudp_encap_mplsoudp_encap, 16219 (void *)&cmd_set_mplsoudp_encap_ip_version, 16220 (void *)&cmd_set_mplsoudp_encap_ip_version_value, 16221 (void *)&cmd_set_mplsoudp_encap_label, 16222 (void *)&cmd_set_mplsoudp_encap_label_value, 16223 (void *)&cmd_set_mplsoudp_encap_udp_src, 16224 (void *)&cmd_set_mplsoudp_encap_udp_src_value, 16225 (void *)&cmd_set_mplsoudp_encap_udp_dst, 16226 (void *)&cmd_set_mplsoudp_encap_udp_dst_value, 16227 (void *)&cmd_set_mplsoudp_encap_ip_src, 16228 (void *)&cmd_set_mplsoudp_encap_ip_src_value, 16229 (void *)&cmd_set_mplsoudp_encap_ip_dst, 16230 (void *)&cmd_set_mplsoudp_encap_ip_dst_value, 16231 (void *)&cmd_set_mplsoudp_encap_eth_src, 16232 (void *)&cmd_set_mplsoudp_encap_eth_src_value, 16233 (void *)&cmd_set_mplsoudp_encap_eth_dst, 16234 (void *)&cmd_set_mplsoudp_encap_eth_dst_value, 16235 NULL, 16236 }, 16237 }; 16238 16239 cmdline_parse_inst_t cmd_set_mplsoudp_encap_with_vlan = { 16240 .f = cmd_set_mplsoudp_encap_parsed, 16241 .data = NULL, 16242 .help_str = "set mplsoudp_encap-with-vlan ip-version ipv4|ipv6" 16243 " label <label> udp-src <udp-src> udp-dst <udp-dst>" 16244 " ip-src <ip-src> ip-dst <ip-dst> vlan-tci <vlan-tci>" 16245 " eth-src <eth-src> eth-dst <eth-dst>", 16246 .tokens = { 16247 (void *)&cmd_set_mplsoudp_encap_set, 16248 (void *)&cmd_set_mplsoudp_encap_mplsoudp_encap_with_vlan, 16249 (void *)&cmd_set_mplsoudp_encap_ip_version, 16250 (void *)&cmd_set_mplsoudp_encap_ip_version_value, 16251 (void *)&cmd_set_mplsoudp_encap_label, 16252 (void *)&cmd_set_mplsoudp_encap_label_value, 16253 (void *)&cmd_set_mplsoudp_encap_udp_src, 16254 (void *)&cmd_set_mplsoudp_encap_udp_src_value, 16255 (void *)&cmd_set_mplsoudp_encap_udp_dst, 16256 (void *)&cmd_set_mplsoudp_encap_udp_dst_value, 16257 (void *)&cmd_set_mplsoudp_encap_ip_src, 16258 (void *)&cmd_set_mplsoudp_encap_ip_src_value, 16259 (void *)&cmd_set_mplsoudp_encap_ip_dst, 16260 (void *)&cmd_set_mplsoudp_encap_ip_dst_value, 16261 (void *)&cmd_set_mplsoudp_encap_vlan, 16262 (void *)&cmd_set_mplsoudp_encap_vlan_value, 16263 (void *)&cmd_set_mplsoudp_encap_eth_src, 16264 (void *)&cmd_set_mplsoudp_encap_eth_src_value, 16265 (void *)&cmd_set_mplsoudp_encap_eth_dst, 16266 (void *)&cmd_set_mplsoudp_encap_eth_dst_value, 16267 NULL, 16268 }, 16269 }; 16270 16271 /** Set MPLSoUDP decapsulation details */ 16272 struct cmd_set_mplsoudp_decap_result { 16273 cmdline_fixed_string_t set; 16274 cmdline_fixed_string_t mplsoudp; 16275 cmdline_fixed_string_t pos_token; 16276 cmdline_fixed_string_t ip_version; 16277 uint32_t vlan_present:1; 16278 }; 16279 16280 cmdline_parse_token_string_t cmd_set_mplsoudp_decap_set = 16281 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_decap_result, set, 16282 "set"); 16283 cmdline_parse_token_string_t cmd_set_mplsoudp_decap_mplsoudp_decap = 16284 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_decap_result, mplsoudp, 16285 "mplsoudp_decap"); 16286 cmdline_parse_token_string_t cmd_set_mplsoudp_decap_mplsoudp_decap_with_vlan = 16287 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_decap_result, 16288 mplsoudp, "mplsoudp_decap-with-vlan"); 16289 cmdline_parse_token_string_t cmd_set_mplsoudp_decap_ip_version = 16290 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_decap_result, 16291 pos_token, "ip-version"); 16292 cmdline_parse_token_string_t cmd_set_mplsoudp_decap_ip_version_value = 16293 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_decap_result, 16294 ip_version, "ipv4#ipv6"); 16295 16296 static void cmd_set_mplsoudp_decap_parsed(void *parsed_result, 16297 __attribute__((unused)) struct cmdline *cl, 16298 __attribute__((unused)) void *data) 16299 { 16300 struct cmd_set_mplsoudp_decap_result *res = parsed_result; 16301 16302 if (strcmp(res->mplsoudp, "mplsoudp_decap") == 0) 16303 mplsoudp_decap_conf.select_vlan = 0; 16304 else if (strcmp(res->mplsoudp, "mplsoudp_decap-with-vlan") == 0) 16305 mplsoudp_decap_conf.select_vlan = 1; 16306 if (strcmp(res->ip_version, "ipv4") == 0) 16307 mplsoudp_decap_conf.select_ipv4 = 1; 16308 else if (strcmp(res->ip_version, "ipv6") == 0) 16309 mplsoudp_decap_conf.select_ipv4 = 0; 16310 } 16311 16312 cmdline_parse_inst_t cmd_set_mplsoudp_decap = { 16313 .f = cmd_set_mplsoudp_decap_parsed, 16314 .data = NULL, 16315 .help_str = "set mplsoudp_decap ip-version ipv4|ipv6", 16316 .tokens = { 16317 (void *)&cmd_set_mplsoudp_decap_set, 16318 (void *)&cmd_set_mplsoudp_decap_mplsoudp_decap, 16319 (void *)&cmd_set_mplsoudp_decap_ip_version, 16320 (void *)&cmd_set_mplsoudp_decap_ip_version_value, 16321 NULL, 16322 }, 16323 }; 16324 16325 cmdline_parse_inst_t cmd_set_mplsoudp_decap_with_vlan = { 16326 .f = cmd_set_mplsoudp_decap_parsed, 16327 .data = NULL, 16328 .help_str = "set mplsoudp_decap-with-vlan ip-version ipv4|ipv6", 16329 .tokens = { 16330 (void *)&cmd_set_mplsoudp_decap_set, 16331 (void *)&cmd_set_mplsoudp_decap_mplsoudp_decap_with_vlan, 16332 (void *)&cmd_set_mplsoudp_decap_ip_version, 16333 (void *)&cmd_set_mplsoudp_decap_ip_version_value, 16334 NULL, 16335 }, 16336 }; 16337 16338 /* Strict link priority scheduling mode setting */ 16339 static void 16340 cmd_strict_link_prio_parsed( 16341 void *parsed_result, 16342 __attribute__((unused)) struct cmdline *cl, 16343 __attribute__((unused)) void *data) 16344 { 16345 struct cmd_vf_tc_bw_result *res = parsed_result; 16346 int ret = -ENOTSUP; 16347 16348 if (port_id_is_invalid(res->port_id, ENABLED_WARN)) 16349 return; 16350 16351 #ifdef RTE_LIBRTE_I40E_PMD 16352 ret = rte_pmd_i40e_set_tc_strict_prio(res->port_id, res->tc_map); 16353 #endif 16354 16355 switch (ret) { 16356 case 0: 16357 break; 16358 case -EINVAL: 16359 printf("invalid tc_bitmap 0x%x\n", res->tc_map); 16360 break; 16361 case -ENODEV: 16362 printf("invalid port_id %d\n", res->port_id); 16363 break; 16364 case -ENOTSUP: 16365 printf("function not implemented\n"); 16366 break; 16367 default: 16368 printf("programming error: (%s)\n", strerror(-ret)); 16369 } 16370 } 16371 16372 cmdline_parse_inst_t cmd_strict_link_prio = { 16373 .f = cmd_strict_link_prio_parsed, 16374 .data = NULL, 16375 .help_str = "set tx strict-link-priority <port_id> <tc_bitmap>", 16376 .tokens = { 16377 (void *)&cmd_vf_tc_bw_set, 16378 (void *)&cmd_vf_tc_bw_tx, 16379 (void *)&cmd_vf_tc_bw_strict_link_prio, 16380 (void *)&cmd_vf_tc_bw_port_id, 16381 (void *)&cmd_vf_tc_bw_tc_map, 16382 NULL, 16383 }, 16384 }; 16385 16386 /* Load dynamic device personalization*/ 16387 struct cmd_ddp_add_result { 16388 cmdline_fixed_string_t ddp; 16389 cmdline_fixed_string_t add; 16390 portid_t port_id; 16391 char filepath[]; 16392 }; 16393 16394 cmdline_parse_token_string_t cmd_ddp_add_ddp = 16395 TOKEN_STRING_INITIALIZER(struct cmd_ddp_add_result, ddp, "ddp"); 16396 cmdline_parse_token_string_t cmd_ddp_add_add = 16397 TOKEN_STRING_INITIALIZER(struct cmd_ddp_add_result, add, "add"); 16398 cmdline_parse_token_num_t cmd_ddp_add_port_id = 16399 TOKEN_NUM_INITIALIZER(struct cmd_ddp_add_result, port_id, UINT16); 16400 cmdline_parse_token_string_t cmd_ddp_add_filepath = 16401 TOKEN_STRING_INITIALIZER(struct cmd_ddp_add_result, filepath, NULL); 16402 16403 static void 16404 cmd_ddp_add_parsed( 16405 void *parsed_result, 16406 __attribute__((unused)) struct cmdline *cl, 16407 __attribute__((unused)) void *data) 16408 { 16409 struct cmd_ddp_add_result *res = parsed_result; 16410 uint8_t *buff; 16411 uint32_t size; 16412 char *filepath; 16413 char *file_fld[2]; 16414 int file_num; 16415 int ret = -ENOTSUP; 16416 16417 if (!all_ports_stopped()) { 16418 printf("Please stop all ports first\n"); 16419 return; 16420 } 16421 16422 filepath = strdup(res->filepath); 16423 if (filepath == NULL) { 16424 printf("Failed to allocate memory\n"); 16425 return; 16426 } 16427 file_num = rte_strsplit(filepath, strlen(filepath), file_fld, 2, ','); 16428 16429 buff = open_file(file_fld[0], &size); 16430 if (!buff) { 16431 free((void *)filepath); 16432 return; 16433 } 16434 16435 #ifdef RTE_LIBRTE_I40E_PMD 16436 if (ret == -ENOTSUP) 16437 ret = rte_pmd_i40e_process_ddp_package(res->port_id, 16438 buff, size, 16439 RTE_PMD_I40E_PKG_OP_WR_ADD); 16440 #endif 16441 16442 if (ret == -EEXIST) 16443 printf("Profile has already existed.\n"); 16444 else if (ret < 0) 16445 printf("Failed to load profile.\n"); 16446 else if (file_num == 2) 16447 save_file(file_fld[1], buff, size); 16448 16449 close_file(buff); 16450 free((void *)filepath); 16451 } 16452 16453 cmdline_parse_inst_t cmd_ddp_add = { 16454 .f = cmd_ddp_add_parsed, 16455 .data = NULL, 16456 .help_str = "ddp add <port_id> <profile_path[,backup_profile_path]>", 16457 .tokens = { 16458 (void *)&cmd_ddp_add_ddp, 16459 (void *)&cmd_ddp_add_add, 16460 (void *)&cmd_ddp_add_port_id, 16461 (void *)&cmd_ddp_add_filepath, 16462 NULL, 16463 }, 16464 }; 16465 16466 /* Delete dynamic device personalization*/ 16467 struct cmd_ddp_del_result { 16468 cmdline_fixed_string_t ddp; 16469 cmdline_fixed_string_t del; 16470 portid_t port_id; 16471 char filepath[]; 16472 }; 16473 16474 cmdline_parse_token_string_t cmd_ddp_del_ddp = 16475 TOKEN_STRING_INITIALIZER(struct cmd_ddp_del_result, ddp, "ddp"); 16476 cmdline_parse_token_string_t cmd_ddp_del_del = 16477 TOKEN_STRING_INITIALIZER(struct cmd_ddp_del_result, del, "del"); 16478 cmdline_parse_token_num_t cmd_ddp_del_port_id = 16479 TOKEN_NUM_INITIALIZER(struct cmd_ddp_del_result, port_id, UINT16); 16480 cmdline_parse_token_string_t cmd_ddp_del_filepath = 16481 TOKEN_STRING_INITIALIZER(struct cmd_ddp_del_result, filepath, NULL); 16482 16483 static void 16484 cmd_ddp_del_parsed( 16485 void *parsed_result, 16486 __attribute__((unused)) struct cmdline *cl, 16487 __attribute__((unused)) void *data) 16488 { 16489 struct cmd_ddp_del_result *res = parsed_result; 16490 uint8_t *buff; 16491 uint32_t size; 16492 int ret = -ENOTSUP; 16493 16494 if (!all_ports_stopped()) { 16495 printf("Please stop all ports first\n"); 16496 return; 16497 } 16498 16499 buff = open_file(res->filepath, &size); 16500 if (!buff) 16501 return; 16502 16503 #ifdef RTE_LIBRTE_I40E_PMD 16504 if (ret == -ENOTSUP) 16505 ret = rte_pmd_i40e_process_ddp_package(res->port_id, 16506 buff, size, 16507 RTE_PMD_I40E_PKG_OP_WR_DEL); 16508 #endif 16509 16510 if (ret == -EACCES) 16511 printf("Profile does not exist.\n"); 16512 else if (ret < 0) 16513 printf("Failed to delete profile.\n"); 16514 16515 close_file(buff); 16516 } 16517 16518 cmdline_parse_inst_t cmd_ddp_del = { 16519 .f = cmd_ddp_del_parsed, 16520 .data = NULL, 16521 .help_str = "ddp del <port_id> <backup_profile_path>", 16522 .tokens = { 16523 (void *)&cmd_ddp_del_ddp, 16524 (void *)&cmd_ddp_del_del, 16525 (void *)&cmd_ddp_del_port_id, 16526 (void *)&cmd_ddp_del_filepath, 16527 NULL, 16528 }, 16529 }; 16530 16531 /* Get dynamic device personalization profile info */ 16532 struct cmd_ddp_info_result { 16533 cmdline_fixed_string_t ddp; 16534 cmdline_fixed_string_t get; 16535 cmdline_fixed_string_t info; 16536 char filepath[]; 16537 }; 16538 16539 cmdline_parse_token_string_t cmd_ddp_info_ddp = 16540 TOKEN_STRING_INITIALIZER(struct cmd_ddp_info_result, ddp, "ddp"); 16541 cmdline_parse_token_string_t cmd_ddp_info_get = 16542 TOKEN_STRING_INITIALIZER(struct cmd_ddp_info_result, get, "get"); 16543 cmdline_parse_token_string_t cmd_ddp_info_info = 16544 TOKEN_STRING_INITIALIZER(struct cmd_ddp_info_result, info, "info"); 16545 cmdline_parse_token_string_t cmd_ddp_info_filepath = 16546 TOKEN_STRING_INITIALIZER(struct cmd_ddp_info_result, filepath, NULL); 16547 16548 static void 16549 cmd_ddp_info_parsed( 16550 void *parsed_result, 16551 __attribute__((unused)) struct cmdline *cl, 16552 __attribute__((unused)) void *data) 16553 { 16554 struct cmd_ddp_info_result *res = parsed_result; 16555 uint8_t *pkg; 16556 uint32_t pkg_size; 16557 int ret = -ENOTSUP; 16558 #ifdef RTE_LIBRTE_I40E_PMD 16559 uint32_t i, j, n; 16560 uint8_t *buff; 16561 uint32_t buff_size = 0; 16562 struct rte_pmd_i40e_profile_info info; 16563 uint32_t dev_num = 0; 16564 struct rte_pmd_i40e_ddp_device_id *devs; 16565 uint32_t proto_num = 0; 16566 struct rte_pmd_i40e_proto_info *proto = NULL; 16567 uint32_t pctype_num = 0; 16568 struct rte_pmd_i40e_ptype_info *pctype; 16569 uint32_t ptype_num = 0; 16570 struct rte_pmd_i40e_ptype_info *ptype; 16571 uint8_t proto_id; 16572 16573 #endif 16574 16575 pkg = open_file(res->filepath, &pkg_size); 16576 if (!pkg) 16577 return; 16578 16579 #ifdef RTE_LIBRTE_I40E_PMD 16580 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size, 16581 (uint8_t *)&info, sizeof(info), 16582 RTE_PMD_I40E_PKG_INFO_GLOBAL_HEADER); 16583 if (!ret) { 16584 printf("Global Track id: 0x%x\n", info.track_id); 16585 printf("Global Version: %d.%d.%d.%d\n", 16586 info.version.major, 16587 info.version.minor, 16588 info.version.update, 16589 info.version.draft); 16590 printf("Global Package name: %s\n\n", info.name); 16591 } 16592 16593 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size, 16594 (uint8_t *)&info, sizeof(info), 16595 RTE_PMD_I40E_PKG_INFO_HEADER); 16596 if (!ret) { 16597 printf("i40e Profile Track id: 0x%x\n", info.track_id); 16598 printf("i40e Profile Version: %d.%d.%d.%d\n", 16599 info.version.major, 16600 info.version.minor, 16601 info.version.update, 16602 info.version.draft); 16603 printf("i40e Profile name: %s\n\n", info.name); 16604 } 16605 16606 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size, 16607 (uint8_t *)&buff_size, sizeof(buff_size), 16608 RTE_PMD_I40E_PKG_INFO_GLOBAL_NOTES_SIZE); 16609 if (!ret && buff_size) { 16610 buff = (uint8_t *)malloc(buff_size); 16611 if (buff) { 16612 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size, 16613 buff, buff_size, 16614 RTE_PMD_I40E_PKG_INFO_GLOBAL_NOTES); 16615 if (!ret) 16616 printf("Package Notes:\n%s\n\n", buff); 16617 free(buff); 16618 } 16619 } 16620 16621 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size, 16622 (uint8_t *)&dev_num, sizeof(dev_num), 16623 RTE_PMD_I40E_PKG_INFO_DEVID_NUM); 16624 if (!ret && dev_num) { 16625 buff_size = dev_num * sizeof(struct rte_pmd_i40e_ddp_device_id); 16626 devs = (struct rte_pmd_i40e_ddp_device_id *)malloc(buff_size); 16627 if (devs) { 16628 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size, 16629 (uint8_t *)devs, buff_size, 16630 RTE_PMD_I40E_PKG_INFO_DEVID_LIST); 16631 if (!ret) { 16632 printf("List of supported devices:\n"); 16633 for (i = 0; i < dev_num; i++) { 16634 printf(" %04X:%04X %04X:%04X\n", 16635 devs[i].vendor_dev_id >> 16, 16636 devs[i].vendor_dev_id & 0xFFFF, 16637 devs[i].sub_vendor_dev_id >> 16, 16638 devs[i].sub_vendor_dev_id & 0xFFFF); 16639 } 16640 printf("\n"); 16641 } 16642 free(devs); 16643 } 16644 } 16645 16646 /* get information about protocols and packet types */ 16647 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size, 16648 (uint8_t *)&proto_num, sizeof(proto_num), 16649 RTE_PMD_I40E_PKG_INFO_PROTOCOL_NUM); 16650 if (ret || !proto_num) 16651 goto no_print_return; 16652 16653 buff_size = proto_num * sizeof(struct rte_pmd_i40e_proto_info); 16654 proto = (struct rte_pmd_i40e_proto_info *)malloc(buff_size); 16655 if (!proto) 16656 goto no_print_return; 16657 16658 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size, (uint8_t *)proto, 16659 buff_size, 16660 RTE_PMD_I40E_PKG_INFO_PROTOCOL_LIST); 16661 if (!ret) { 16662 printf("List of used protocols:\n"); 16663 for (i = 0; i < proto_num; i++) 16664 printf(" %2u: %s\n", proto[i].proto_id, 16665 proto[i].name); 16666 printf("\n"); 16667 } 16668 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size, 16669 (uint8_t *)&pctype_num, sizeof(pctype_num), 16670 RTE_PMD_I40E_PKG_INFO_PCTYPE_NUM); 16671 if (ret || !pctype_num) 16672 goto no_print_pctypes; 16673 16674 buff_size = pctype_num * sizeof(struct rte_pmd_i40e_ptype_info); 16675 pctype = (struct rte_pmd_i40e_ptype_info *)malloc(buff_size); 16676 if (!pctype) 16677 goto no_print_pctypes; 16678 16679 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size, (uint8_t *)pctype, 16680 buff_size, 16681 RTE_PMD_I40E_PKG_INFO_PCTYPE_LIST); 16682 if (ret) { 16683 free(pctype); 16684 goto no_print_pctypes; 16685 } 16686 16687 printf("List of defined packet classification types:\n"); 16688 for (i = 0; i < pctype_num; i++) { 16689 printf(" %2u:", pctype[i].ptype_id); 16690 for (j = 0; j < RTE_PMD_I40E_PROTO_NUM; j++) { 16691 proto_id = pctype[i].protocols[j]; 16692 if (proto_id != RTE_PMD_I40E_PROTO_UNUSED) { 16693 for (n = 0; n < proto_num; n++) { 16694 if (proto[n].proto_id == proto_id) { 16695 printf(" %s", proto[n].name); 16696 break; 16697 } 16698 } 16699 } 16700 } 16701 printf("\n"); 16702 } 16703 printf("\n"); 16704 free(pctype); 16705 16706 no_print_pctypes: 16707 16708 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size, (uint8_t *)&ptype_num, 16709 sizeof(ptype_num), 16710 RTE_PMD_I40E_PKG_INFO_PTYPE_NUM); 16711 if (ret || !ptype_num) 16712 goto no_print_return; 16713 16714 buff_size = ptype_num * sizeof(struct rte_pmd_i40e_ptype_info); 16715 ptype = (struct rte_pmd_i40e_ptype_info *)malloc(buff_size); 16716 if (!ptype) 16717 goto no_print_return; 16718 16719 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size, (uint8_t *)ptype, 16720 buff_size, 16721 RTE_PMD_I40E_PKG_INFO_PTYPE_LIST); 16722 if (ret) { 16723 free(ptype); 16724 goto no_print_return; 16725 } 16726 printf("List of defined packet types:\n"); 16727 for (i = 0; i < ptype_num; i++) { 16728 printf(" %2u:", ptype[i].ptype_id); 16729 for (j = 0; j < RTE_PMD_I40E_PROTO_NUM; j++) { 16730 proto_id = ptype[i].protocols[j]; 16731 if (proto_id != RTE_PMD_I40E_PROTO_UNUSED) { 16732 for (n = 0; n < proto_num; n++) { 16733 if (proto[n].proto_id == proto_id) { 16734 printf(" %s", proto[n].name); 16735 break; 16736 } 16737 } 16738 } 16739 } 16740 printf("\n"); 16741 } 16742 free(ptype); 16743 printf("\n"); 16744 16745 ret = 0; 16746 no_print_return: 16747 if (proto) 16748 free(proto); 16749 #endif 16750 if (ret == -ENOTSUP) 16751 printf("Function not supported in PMD driver\n"); 16752 close_file(pkg); 16753 } 16754 16755 cmdline_parse_inst_t cmd_ddp_get_info = { 16756 .f = cmd_ddp_info_parsed, 16757 .data = NULL, 16758 .help_str = "ddp get info <profile_path>", 16759 .tokens = { 16760 (void *)&cmd_ddp_info_ddp, 16761 (void *)&cmd_ddp_info_get, 16762 (void *)&cmd_ddp_info_info, 16763 (void *)&cmd_ddp_info_filepath, 16764 NULL, 16765 }, 16766 }; 16767 16768 /* Get dynamic device personalization profile info list*/ 16769 #define PROFILE_INFO_SIZE 48 16770 #define MAX_PROFILE_NUM 16 16771 16772 struct cmd_ddp_get_list_result { 16773 cmdline_fixed_string_t ddp; 16774 cmdline_fixed_string_t get; 16775 cmdline_fixed_string_t list; 16776 portid_t port_id; 16777 }; 16778 16779 cmdline_parse_token_string_t cmd_ddp_get_list_ddp = 16780 TOKEN_STRING_INITIALIZER(struct cmd_ddp_get_list_result, ddp, "ddp"); 16781 cmdline_parse_token_string_t cmd_ddp_get_list_get = 16782 TOKEN_STRING_INITIALIZER(struct cmd_ddp_get_list_result, get, "get"); 16783 cmdline_parse_token_string_t cmd_ddp_get_list_list = 16784 TOKEN_STRING_INITIALIZER(struct cmd_ddp_get_list_result, list, "list"); 16785 cmdline_parse_token_num_t cmd_ddp_get_list_port_id = 16786 TOKEN_NUM_INITIALIZER(struct cmd_ddp_get_list_result, port_id, UINT16); 16787 16788 static void 16789 cmd_ddp_get_list_parsed( 16790 __attribute__((unused)) void *parsed_result, 16791 __attribute__((unused)) struct cmdline *cl, 16792 __attribute__((unused)) void *data) 16793 { 16794 #ifdef RTE_LIBRTE_I40E_PMD 16795 struct cmd_ddp_get_list_result *res = parsed_result; 16796 struct rte_pmd_i40e_profile_list *p_list; 16797 struct rte_pmd_i40e_profile_info *p_info; 16798 uint32_t p_num; 16799 uint32_t size; 16800 uint32_t i; 16801 #endif 16802 int ret = -ENOTSUP; 16803 16804 #ifdef RTE_LIBRTE_I40E_PMD 16805 size = PROFILE_INFO_SIZE * MAX_PROFILE_NUM + 4; 16806 p_list = (struct rte_pmd_i40e_profile_list *)malloc(size); 16807 if (!p_list) 16808 printf("%s: Failed to malloc buffer\n", __func__); 16809 16810 if (ret == -ENOTSUP) 16811 ret = rte_pmd_i40e_get_ddp_list(res->port_id, 16812 (uint8_t *)p_list, size); 16813 16814 if (!ret) { 16815 p_num = p_list->p_count; 16816 printf("Profile number is: %d\n\n", p_num); 16817 16818 for (i = 0; i < p_num; i++) { 16819 p_info = &p_list->p_info[i]; 16820 printf("Profile %d:\n", i); 16821 printf("Track id: 0x%x\n", p_info->track_id); 16822 printf("Version: %d.%d.%d.%d\n", 16823 p_info->version.major, 16824 p_info->version.minor, 16825 p_info->version.update, 16826 p_info->version.draft); 16827 printf("Profile name: %s\n\n", p_info->name); 16828 } 16829 } 16830 16831 free(p_list); 16832 #endif 16833 16834 if (ret < 0) 16835 printf("Failed to get ddp list\n"); 16836 } 16837 16838 cmdline_parse_inst_t cmd_ddp_get_list = { 16839 .f = cmd_ddp_get_list_parsed, 16840 .data = NULL, 16841 .help_str = "ddp get list <port_id>", 16842 .tokens = { 16843 (void *)&cmd_ddp_get_list_ddp, 16844 (void *)&cmd_ddp_get_list_get, 16845 (void *)&cmd_ddp_get_list_list, 16846 (void *)&cmd_ddp_get_list_port_id, 16847 NULL, 16848 }, 16849 }; 16850 16851 /* Configure input set */ 16852 struct cmd_cfg_input_set_result { 16853 cmdline_fixed_string_t port; 16854 cmdline_fixed_string_t cfg; 16855 portid_t port_id; 16856 cmdline_fixed_string_t pctype; 16857 uint8_t pctype_id; 16858 cmdline_fixed_string_t inset_type; 16859 cmdline_fixed_string_t opt; 16860 cmdline_fixed_string_t field; 16861 uint8_t field_idx; 16862 }; 16863 16864 static void 16865 cmd_cfg_input_set_parsed( 16866 __attribute__((unused)) void *parsed_result, 16867 __attribute__((unused)) struct cmdline *cl, 16868 __attribute__((unused)) void *data) 16869 { 16870 #ifdef RTE_LIBRTE_I40E_PMD 16871 struct cmd_cfg_input_set_result *res = parsed_result; 16872 enum rte_pmd_i40e_inset_type inset_type = INSET_NONE; 16873 struct rte_pmd_i40e_inset inset; 16874 #endif 16875 int ret = -ENOTSUP; 16876 16877 if (!all_ports_stopped()) { 16878 printf("Please stop all ports first\n"); 16879 return; 16880 } 16881 16882 #ifdef RTE_LIBRTE_I40E_PMD 16883 if (!strcmp(res->inset_type, "hash_inset")) 16884 inset_type = INSET_HASH; 16885 else if (!strcmp(res->inset_type, "fdir_inset")) 16886 inset_type = INSET_FDIR; 16887 else if (!strcmp(res->inset_type, "fdir_flx_inset")) 16888 inset_type = INSET_FDIR_FLX; 16889 ret = rte_pmd_i40e_inset_get(res->port_id, res->pctype_id, 16890 &inset, inset_type); 16891 if (ret) { 16892 printf("Failed to get input set.\n"); 16893 return; 16894 } 16895 16896 if (!strcmp(res->opt, "get")) { 16897 ret = rte_pmd_i40e_inset_field_get(inset.inset, 16898 res->field_idx); 16899 if (ret) 16900 printf("Field index %d is enabled.\n", res->field_idx); 16901 else 16902 printf("Field index %d is disabled.\n", res->field_idx); 16903 return; 16904 } else if (!strcmp(res->opt, "set")) 16905 ret = rte_pmd_i40e_inset_field_set(&inset.inset, 16906 res->field_idx); 16907 else if (!strcmp(res->opt, "clear")) 16908 ret = rte_pmd_i40e_inset_field_clear(&inset.inset, 16909 res->field_idx); 16910 if (ret) { 16911 printf("Failed to configure input set field.\n"); 16912 return; 16913 } 16914 16915 ret = rte_pmd_i40e_inset_set(res->port_id, res->pctype_id, 16916 &inset, inset_type); 16917 if (ret) { 16918 printf("Failed to set input set.\n"); 16919 return; 16920 } 16921 #endif 16922 16923 if (ret == -ENOTSUP) 16924 printf("Function not supported\n"); 16925 } 16926 16927 cmdline_parse_token_string_t cmd_cfg_input_set_port = 16928 TOKEN_STRING_INITIALIZER(struct cmd_cfg_input_set_result, 16929 port, "port"); 16930 cmdline_parse_token_string_t cmd_cfg_input_set_cfg = 16931 TOKEN_STRING_INITIALIZER(struct cmd_cfg_input_set_result, 16932 cfg, "config"); 16933 cmdline_parse_token_num_t cmd_cfg_input_set_port_id = 16934 TOKEN_NUM_INITIALIZER(struct cmd_cfg_input_set_result, 16935 port_id, UINT16); 16936 cmdline_parse_token_string_t cmd_cfg_input_set_pctype = 16937 TOKEN_STRING_INITIALIZER(struct cmd_cfg_input_set_result, 16938 pctype, "pctype"); 16939 cmdline_parse_token_num_t cmd_cfg_input_set_pctype_id = 16940 TOKEN_NUM_INITIALIZER(struct cmd_cfg_input_set_result, 16941 pctype_id, UINT8); 16942 cmdline_parse_token_string_t cmd_cfg_input_set_inset_type = 16943 TOKEN_STRING_INITIALIZER(struct cmd_cfg_input_set_result, 16944 inset_type, 16945 "hash_inset#fdir_inset#fdir_flx_inset"); 16946 cmdline_parse_token_string_t cmd_cfg_input_set_opt = 16947 TOKEN_STRING_INITIALIZER(struct cmd_cfg_input_set_result, 16948 opt, "get#set#clear"); 16949 cmdline_parse_token_string_t cmd_cfg_input_set_field = 16950 TOKEN_STRING_INITIALIZER(struct cmd_cfg_input_set_result, 16951 field, "field"); 16952 cmdline_parse_token_num_t cmd_cfg_input_set_field_idx = 16953 TOKEN_NUM_INITIALIZER(struct cmd_cfg_input_set_result, 16954 field_idx, UINT8); 16955 16956 cmdline_parse_inst_t cmd_cfg_input_set = { 16957 .f = cmd_cfg_input_set_parsed, 16958 .data = NULL, 16959 .help_str = "port config <port_id> pctype <pctype_id> hash_inset|" 16960 "fdir_inset|fdir_flx_inset get|set|clear field <field_idx>", 16961 .tokens = { 16962 (void *)&cmd_cfg_input_set_port, 16963 (void *)&cmd_cfg_input_set_cfg, 16964 (void *)&cmd_cfg_input_set_port_id, 16965 (void *)&cmd_cfg_input_set_pctype, 16966 (void *)&cmd_cfg_input_set_pctype_id, 16967 (void *)&cmd_cfg_input_set_inset_type, 16968 (void *)&cmd_cfg_input_set_opt, 16969 (void *)&cmd_cfg_input_set_field, 16970 (void *)&cmd_cfg_input_set_field_idx, 16971 NULL, 16972 }, 16973 }; 16974 16975 /* Clear input set */ 16976 struct cmd_clear_input_set_result { 16977 cmdline_fixed_string_t port; 16978 cmdline_fixed_string_t cfg; 16979 portid_t port_id; 16980 cmdline_fixed_string_t pctype; 16981 uint8_t pctype_id; 16982 cmdline_fixed_string_t inset_type; 16983 cmdline_fixed_string_t clear; 16984 cmdline_fixed_string_t all; 16985 }; 16986 16987 static void 16988 cmd_clear_input_set_parsed( 16989 __attribute__((unused)) void *parsed_result, 16990 __attribute__((unused)) struct cmdline *cl, 16991 __attribute__((unused)) void *data) 16992 { 16993 #ifdef RTE_LIBRTE_I40E_PMD 16994 struct cmd_clear_input_set_result *res = parsed_result; 16995 enum rte_pmd_i40e_inset_type inset_type = INSET_NONE; 16996 struct rte_pmd_i40e_inset inset; 16997 #endif 16998 int ret = -ENOTSUP; 16999 17000 if (!all_ports_stopped()) { 17001 printf("Please stop all ports first\n"); 17002 return; 17003 } 17004 17005 #ifdef RTE_LIBRTE_I40E_PMD 17006 if (!strcmp(res->inset_type, "hash_inset")) 17007 inset_type = INSET_HASH; 17008 else if (!strcmp(res->inset_type, "fdir_inset")) 17009 inset_type = INSET_FDIR; 17010 else if (!strcmp(res->inset_type, "fdir_flx_inset")) 17011 inset_type = INSET_FDIR_FLX; 17012 17013 memset(&inset, 0, sizeof(inset)); 17014 17015 ret = rte_pmd_i40e_inset_set(res->port_id, res->pctype_id, 17016 &inset, inset_type); 17017 if (ret) { 17018 printf("Failed to clear input set.\n"); 17019 return; 17020 } 17021 17022 #endif 17023 17024 if (ret == -ENOTSUP) 17025 printf("Function not supported\n"); 17026 } 17027 17028 cmdline_parse_token_string_t cmd_clear_input_set_port = 17029 TOKEN_STRING_INITIALIZER(struct cmd_clear_input_set_result, 17030 port, "port"); 17031 cmdline_parse_token_string_t cmd_clear_input_set_cfg = 17032 TOKEN_STRING_INITIALIZER(struct cmd_clear_input_set_result, 17033 cfg, "config"); 17034 cmdline_parse_token_num_t cmd_clear_input_set_port_id = 17035 TOKEN_NUM_INITIALIZER(struct cmd_clear_input_set_result, 17036 port_id, UINT16); 17037 cmdline_parse_token_string_t cmd_clear_input_set_pctype = 17038 TOKEN_STRING_INITIALIZER(struct cmd_clear_input_set_result, 17039 pctype, "pctype"); 17040 cmdline_parse_token_num_t cmd_clear_input_set_pctype_id = 17041 TOKEN_NUM_INITIALIZER(struct cmd_clear_input_set_result, 17042 pctype_id, UINT8); 17043 cmdline_parse_token_string_t cmd_clear_input_set_inset_type = 17044 TOKEN_STRING_INITIALIZER(struct cmd_clear_input_set_result, 17045 inset_type, 17046 "hash_inset#fdir_inset#fdir_flx_inset"); 17047 cmdline_parse_token_string_t cmd_clear_input_set_clear = 17048 TOKEN_STRING_INITIALIZER(struct cmd_clear_input_set_result, 17049 clear, "clear"); 17050 cmdline_parse_token_string_t cmd_clear_input_set_all = 17051 TOKEN_STRING_INITIALIZER(struct cmd_clear_input_set_result, 17052 all, "all"); 17053 17054 cmdline_parse_inst_t cmd_clear_input_set = { 17055 .f = cmd_clear_input_set_parsed, 17056 .data = NULL, 17057 .help_str = "port config <port_id> pctype <pctype_id> hash_inset|" 17058 "fdir_inset|fdir_flx_inset clear all", 17059 .tokens = { 17060 (void *)&cmd_clear_input_set_port, 17061 (void *)&cmd_clear_input_set_cfg, 17062 (void *)&cmd_clear_input_set_port_id, 17063 (void *)&cmd_clear_input_set_pctype, 17064 (void *)&cmd_clear_input_set_pctype_id, 17065 (void *)&cmd_clear_input_set_inset_type, 17066 (void *)&cmd_clear_input_set_clear, 17067 (void *)&cmd_clear_input_set_all, 17068 NULL, 17069 }, 17070 }; 17071 17072 /* show vf stats */ 17073 17074 /* Common result structure for show vf stats */ 17075 struct cmd_show_vf_stats_result { 17076 cmdline_fixed_string_t show; 17077 cmdline_fixed_string_t vf; 17078 cmdline_fixed_string_t stats; 17079 portid_t port_id; 17080 uint16_t vf_id; 17081 }; 17082 17083 /* Common CLI fields show vf stats*/ 17084 cmdline_parse_token_string_t cmd_show_vf_stats_show = 17085 TOKEN_STRING_INITIALIZER 17086 (struct cmd_show_vf_stats_result, 17087 show, "show"); 17088 cmdline_parse_token_string_t cmd_show_vf_stats_vf = 17089 TOKEN_STRING_INITIALIZER 17090 (struct cmd_show_vf_stats_result, 17091 vf, "vf"); 17092 cmdline_parse_token_string_t cmd_show_vf_stats_stats = 17093 TOKEN_STRING_INITIALIZER 17094 (struct cmd_show_vf_stats_result, 17095 stats, "stats"); 17096 cmdline_parse_token_num_t cmd_show_vf_stats_port_id = 17097 TOKEN_NUM_INITIALIZER 17098 (struct cmd_show_vf_stats_result, 17099 port_id, UINT16); 17100 cmdline_parse_token_num_t cmd_show_vf_stats_vf_id = 17101 TOKEN_NUM_INITIALIZER 17102 (struct cmd_show_vf_stats_result, 17103 vf_id, UINT16); 17104 17105 static void 17106 cmd_show_vf_stats_parsed( 17107 void *parsed_result, 17108 __attribute__((unused)) struct cmdline *cl, 17109 __attribute__((unused)) void *data) 17110 { 17111 struct cmd_show_vf_stats_result *res = parsed_result; 17112 struct rte_eth_stats stats; 17113 int ret = -ENOTSUP; 17114 static const char *nic_stats_border = "########################"; 17115 17116 if (port_id_is_invalid(res->port_id, ENABLED_WARN)) 17117 return; 17118 17119 memset(&stats, 0, sizeof(stats)); 17120 17121 #ifdef RTE_LIBRTE_I40E_PMD 17122 if (ret == -ENOTSUP) 17123 ret = rte_pmd_i40e_get_vf_stats(res->port_id, 17124 res->vf_id, 17125 &stats); 17126 #endif 17127 #ifdef RTE_LIBRTE_BNXT_PMD 17128 if (ret == -ENOTSUP) 17129 ret = rte_pmd_bnxt_get_vf_stats(res->port_id, 17130 res->vf_id, 17131 &stats); 17132 #endif 17133 17134 switch (ret) { 17135 case 0: 17136 break; 17137 case -EINVAL: 17138 printf("invalid vf_id %d\n", res->vf_id); 17139 break; 17140 case -ENODEV: 17141 printf("invalid port_id %d\n", res->port_id); 17142 break; 17143 case -ENOTSUP: 17144 printf("function not implemented\n"); 17145 break; 17146 default: 17147 printf("programming error: (%s)\n", strerror(-ret)); 17148 } 17149 17150 printf("\n %s NIC statistics for port %-2d vf %-2d %s\n", 17151 nic_stats_border, res->port_id, res->vf_id, nic_stats_border); 17152 17153 printf(" RX-packets: %-10"PRIu64" RX-missed: %-10"PRIu64" RX-bytes: " 17154 "%-"PRIu64"\n", 17155 stats.ipackets, stats.imissed, stats.ibytes); 17156 printf(" RX-errors: %-"PRIu64"\n", stats.ierrors); 17157 printf(" RX-nombuf: %-10"PRIu64"\n", 17158 stats.rx_nombuf); 17159 printf(" TX-packets: %-10"PRIu64" TX-errors: %-10"PRIu64" TX-bytes: " 17160 "%-"PRIu64"\n", 17161 stats.opackets, stats.oerrors, stats.obytes); 17162 17163 printf(" %s############################%s\n", 17164 nic_stats_border, nic_stats_border); 17165 } 17166 17167 cmdline_parse_inst_t cmd_show_vf_stats = { 17168 .f = cmd_show_vf_stats_parsed, 17169 .data = NULL, 17170 .help_str = "show vf stats <port_id> <vf_id>", 17171 .tokens = { 17172 (void *)&cmd_show_vf_stats_show, 17173 (void *)&cmd_show_vf_stats_vf, 17174 (void *)&cmd_show_vf_stats_stats, 17175 (void *)&cmd_show_vf_stats_port_id, 17176 (void *)&cmd_show_vf_stats_vf_id, 17177 NULL, 17178 }, 17179 }; 17180 17181 /* clear vf stats */ 17182 17183 /* Common result structure for clear vf stats */ 17184 struct cmd_clear_vf_stats_result { 17185 cmdline_fixed_string_t clear; 17186 cmdline_fixed_string_t vf; 17187 cmdline_fixed_string_t stats; 17188 portid_t port_id; 17189 uint16_t vf_id; 17190 }; 17191 17192 /* Common CLI fields clear vf stats*/ 17193 cmdline_parse_token_string_t cmd_clear_vf_stats_clear = 17194 TOKEN_STRING_INITIALIZER 17195 (struct cmd_clear_vf_stats_result, 17196 clear, "clear"); 17197 cmdline_parse_token_string_t cmd_clear_vf_stats_vf = 17198 TOKEN_STRING_INITIALIZER 17199 (struct cmd_clear_vf_stats_result, 17200 vf, "vf"); 17201 cmdline_parse_token_string_t cmd_clear_vf_stats_stats = 17202 TOKEN_STRING_INITIALIZER 17203 (struct cmd_clear_vf_stats_result, 17204 stats, "stats"); 17205 cmdline_parse_token_num_t cmd_clear_vf_stats_port_id = 17206 TOKEN_NUM_INITIALIZER 17207 (struct cmd_clear_vf_stats_result, 17208 port_id, UINT16); 17209 cmdline_parse_token_num_t cmd_clear_vf_stats_vf_id = 17210 TOKEN_NUM_INITIALIZER 17211 (struct cmd_clear_vf_stats_result, 17212 vf_id, UINT16); 17213 17214 static void 17215 cmd_clear_vf_stats_parsed( 17216 void *parsed_result, 17217 __attribute__((unused)) struct cmdline *cl, 17218 __attribute__((unused)) void *data) 17219 { 17220 struct cmd_clear_vf_stats_result *res = parsed_result; 17221 int ret = -ENOTSUP; 17222 17223 if (port_id_is_invalid(res->port_id, ENABLED_WARN)) 17224 return; 17225 17226 #ifdef RTE_LIBRTE_I40E_PMD 17227 if (ret == -ENOTSUP) 17228 ret = rte_pmd_i40e_reset_vf_stats(res->port_id, 17229 res->vf_id); 17230 #endif 17231 #ifdef RTE_LIBRTE_BNXT_PMD 17232 if (ret == -ENOTSUP) 17233 ret = rte_pmd_bnxt_reset_vf_stats(res->port_id, 17234 res->vf_id); 17235 #endif 17236 17237 switch (ret) { 17238 case 0: 17239 break; 17240 case -EINVAL: 17241 printf("invalid vf_id %d\n", res->vf_id); 17242 break; 17243 case -ENODEV: 17244 printf("invalid port_id %d\n", res->port_id); 17245 break; 17246 case -ENOTSUP: 17247 printf("function not implemented\n"); 17248 break; 17249 default: 17250 printf("programming error: (%s)\n", strerror(-ret)); 17251 } 17252 } 17253 17254 cmdline_parse_inst_t cmd_clear_vf_stats = { 17255 .f = cmd_clear_vf_stats_parsed, 17256 .data = NULL, 17257 .help_str = "clear vf stats <port_id> <vf_id>", 17258 .tokens = { 17259 (void *)&cmd_clear_vf_stats_clear, 17260 (void *)&cmd_clear_vf_stats_vf, 17261 (void *)&cmd_clear_vf_stats_stats, 17262 (void *)&cmd_clear_vf_stats_port_id, 17263 (void *)&cmd_clear_vf_stats_vf_id, 17264 NULL, 17265 }, 17266 }; 17267 17268 /* port config pctype mapping reset */ 17269 17270 /* Common result structure for port config pctype mapping reset */ 17271 struct cmd_pctype_mapping_reset_result { 17272 cmdline_fixed_string_t port; 17273 cmdline_fixed_string_t config; 17274 portid_t port_id; 17275 cmdline_fixed_string_t pctype; 17276 cmdline_fixed_string_t mapping; 17277 cmdline_fixed_string_t reset; 17278 }; 17279 17280 /* Common CLI fields for port config pctype mapping reset*/ 17281 cmdline_parse_token_string_t cmd_pctype_mapping_reset_port = 17282 TOKEN_STRING_INITIALIZER 17283 (struct cmd_pctype_mapping_reset_result, 17284 port, "port"); 17285 cmdline_parse_token_string_t cmd_pctype_mapping_reset_config = 17286 TOKEN_STRING_INITIALIZER 17287 (struct cmd_pctype_mapping_reset_result, 17288 config, "config"); 17289 cmdline_parse_token_num_t cmd_pctype_mapping_reset_port_id = 17290 TOKEN_NUM_INITIALIZER 17291 (struct cmd_pctype_mapping_reset_result, 17292 port_id, UINT16); 17293 cmdline_parse_token_string_t cmd_pctype_mapping_reset_pctype = 17294 TOKEN_STRING_INITIALIZER 17295 (struct cmd_pctype_mapping_reset_result, 17296 pctype, "pctype"); 17297 cmdline_parse_token_string_t cmd_pctype_mapping_reset_mapping = 17298 TOKEN_STRING_INITIALIZER 17299 (struct cmd_pctype_mapping_reset_result, 17300 mapping, "mapping"); 17301 cmdline_parse_token_string_t cmd_pctype_mapping_reset_reset = 17302 TOKEN_STRING_INITIALIZER 17303 (struct cmd_pctype_mapping_reset_result, 17304 reset, "reset"); 17305 17306 static void 17307 cmd_pctype_mapping_reset_parsed( 17308 void *parsed_result, 17309 __attribute__((unused)) struct cmdline *cl, 17310 __attribute__((unused)) void *data) 17311 { 17312 struct cmd_pctype_mapping_reset_result *res = parsed_result; 17313 int ret = -ENOTSUP; 17314 17315 if (port_id_is_invalid(res->port_id, ENABLED_WARN)) 17316 return; 17317 17318 #ifdef RTE_LIBRTE_I40E_PMD 17319 ret = rte_pmd_i40e_flow_type_mapping_reset(res->port_id); 17320 #endif 17321 17322 switch (ret) { 17323 case 0: 17324 break; 17325 case -ENODEV: 17326 printf("invalid port_id %d\n", res->port_id); 17327 break; 17328 case -ENOTSUP: 17329 printf("function not implemented\n"); 17330 break; 17331 default: 17332 printf("programming error: (%s)\n", strerror(-ret)); 17333 } 17334 } 17335 17336 cmdline_parse_inst_t cmd_pctype_mapping_reset = { 17337 .f = cmd_pctype_mapping_reset_parsed, 17338 .data = NULL, 17339 .help_str = "port config <port_id> pctype mapping reset", 17340 .tokens = { 17341 (void *)&cmd_pctype_mapping_reset_port, 17342 (void *)&cmd_pctype_mapping_reset_config, 17343 (void *)&cmd_pctype_mapping_reset_port_id, 17344 (void *)&cmd_pctype_mapping_reset_pctype, 17345 (void *)&cmd_pctype_mapping_reset_mapping, 17346 (void *)&cmd_pctype_mapping_reset_reset, 17347 NULL, 17348 }, 17349 }; 17350 17351 /* show port pctype mapping */ 17352 17353 /* Common result structure for show port pctype mapping */ 17354 struct cmd_pctype_mapping_get_result { 17355 cmdline_fixed_string_t show; 17356 cmdline_fixed_string_t port; 17357 portid_t port_id; 17358 cmdline_fixed_string_t pctype; 17359 cmdline_fixed_string_t mapping; 17360 }; 17361 17362 /* Common CLI fields for pctype mapping get */ 17363 cmdline_parse_token_string_t cmd_pctype_mapping_get_show = 17364 TOKEN_STRING_INITIALIZER 17365 (struct cmd_pctype_mapping_get_result, 17366 show, "show"); 17367 cmdline_parse_token_string_t cmd_pctype_mapping_get_port = 17368 TOKEN_STRING_INITIALIZER 17369 (struct cmd_pctype_mapping_get_result, 17370 port, "port"); 17371 cmdline_parse_token_num_t cmd_pctype_mapping_get_port_id = 17372 TOKEN_NUM_INITIALIZER 17373 (struct cmd_pctype_mapping_get_result, 17374 port_id, UINT16); 17375 cmdline_parse_token_string_t cmd_pctype_mapping_get_pctype = 17376 TOKEN_STRING_INITIALIZER 17377 (struct cmd_pctype_mapping_get_result, 17378 pctype, "pctype"); 17379 cmdline_parse_token_string_t cmd_pctype_mapping_get_mapping = 17380 TOKEN_STRING_INITIALIZER 17381 (struct cmd_pctype_mapping_get_result, 17382 mapping, "mapping"); 17383 17384 static void 17385 cmd_pctype_mapping_get_parsed( 17386 void *parsed_result, 17387 __attribute__((unused)) struct cmdline *cl, 17388 __attribute__((unused)) void *data) 17389 { 17390 struct cmd_pctype_mapping_get_result *res = parsed_result; 17391 int ret = -ENOTSUP; 17392 #ifdef RTE_LIBRTE_I40E_PMD 17393 struct rte_pmd_i40e_flow_type_mapping 17394 mapping[RTE_PMD_I40E_FLOW_TYPE_MAX]; 17395 int i, j, first_pctype; 17396 #endif 17397 17398 if (port_id_is_invalid(res->port_id, ENABLED_WARN)) 17399 return; 17400 17401 #ifdef RTE_LIBRTE_I40E_PMD 17402 ret = rte_pmd_i40e_flow_type_mapping_get(res->port_id, mapping); 17403 #endif 17404 17405 switch (ret) { 17406 case 0: 17407 break; 17408 case -ENODEV: 17409 printf("invalid port_id %d\n", res->port_id); 17410 return; 17411 case -ENOTSUP: 17412 printf("function not implemented\n"); 17413 return; 17414 default: 17415 printf("programming error: (%s)\n", strerror(-ret)); 17416 return; 17417 } 17418 17419 #ifdef RTE_LIBRTE_I40E_PMD 17420 for (i = 0; i < RTE_PMD_I40E_FLOW_TYPE_MAX; i++) { 17421 if (mapping[i].pctype != 0ULL) { 17422 first_pctype = 1; 17423 17424 printf("pctype: "); 17425 for (j = 0; j < RTE_PMD_I40E_PCTYPE_MAX; j++) { 17426 if (mapping[i].pctype & (1ULL << j)) { 17427 printf(first_pctype ? 17428 "%02d" : ",%02d", j); 17429 first_pctype = 0; 17430 } 17431 } 17432 printf(" -> flowtype: %02d\n", mapping[i].flow_type); 17433 } 17434 } 17435 #endif 17436 } 17437 17438 cmdline_parse_inst_t cmd_pctype_mapping_get = { 17439 .f = cmd_pctype_mapping_get_parsed, 17440 .data = NULL, 17441 .help_str = "show port <port_id> pctype mapping", 17442 .tokens = { 17443 (void *)&cmd_pctype_mapping_get_show, 17444 (void *)&cmd_pctype_mapping_get_port, 17445 (void *)&cmd_pctype_mapping_get_port_id, 17446 (void *)&cmd_pctype_mapping_get_pctype, 17447 (void *)&cmd_pctype_mapping_get_mapping, 17448 NULL, 17449 }, 17450 }; 17451 17452 /* port config pctype mapping update */ 17453 17454 /* Common result structure for port config pctype mapping update */ 17455 struct cmd_pctype_mapping_update_result { 17456 cmdline_fixed_string_t port; 17457 cmdline_fixed_string_t config; 17458 portid_t port_id; 17459 cmdline_fixed_string_t pctype; 17460 cmdline_fixed_string_t mapping; 17461 cmdline_fixed_string_t update; 17462 cmdline_fixed_string_t pctype_list; 17463 uint16_t flow_type; 17464 }; 17465 17466 /* Common CLI fields for pctype mapping update*/ 17467 cmdline_parse_token_string_t cmd_pctype_mapping_update_port = 17468 TOKEN_STRING_INITIALIZER 17469 (struct cmd_pctype_mapping_update_result, 17470 port, "port"); 17471 cmdline_parse_token_string_t cmd_pctype_mapping_update_config = 17472 TOKEN_STRING_INITIALIZER 17473 (struct cmd_pctype_mapping_update_result, 17474 config, "config"); 17475 cmdline_parse_token_num_t cmd_pctype_mapping_update_port_id = 17476 TOKEN_NUM_INITIALIZER 17477 (struct cmd_pctype_mapping_update_result, 17478 port_id, UINT16); 17479 cmdline_parse_token_string_t cmd_pctype_mapping_update_pctype = 17480 TOKEN_STRING_INITIALIZER 17481 (struct cmd_pctype_mapping_update_result, 17482 pctype, "pctype"); 17483 cmdline_parse_token_string_t cmd_pctype_mapping_update_mapping = 17484 TOKEN_STRING_INITIALIZER 17485 (struct cmd_pctype_mapping_update_result, 17486 mapping, "mapping"); 17487 cmdline_parse_token_string_t cmd_pctype_mapping_update_update = 17488 TOKEN_STRING_INITIALIZER 17489 (struct cmd_pctype_mapping_update_result, 17490 update, "update"); 17491 cmdline_parse_token_string_t cmd_pctype_mapping_update_pc_type = 17492 TOKEN_STRING_INITIALIZER 17493 (struct cmd_pctype_mapping_update_result, 17494 pctype_list, NULL); 17495 cmdline_parse_token_num_t cmd_pctype_mapping_update_flow_type = 17496 TOKEN_NUM_INITIALIZER 17497 (struct cmd_pctype_mapping_update_result, 17498 flow_type, UINT16); 17499 17500 static void 17501 cmd_pctype_mapping_update_parsed( 17502 void *parsed_result, 17503 __attribute__((unused)) struct cmdline *cl, 17504 __attribute__((unused)) void *data) 17505 { 17506 struct cmd_pctype_mapping_update_result *res = parsed_result; 17507 int ret = -ENOTSUP; 17508 #ifdef RTE_LIBRTE_I40E_PMD 17509 struct rte_pmd_i40e_flow_type_mapping mapping; 17510 unsigned int i; 17511 unsigned int nb_item; 17512 unsigned int pctype_list[RTE_PMD_I40E_PCTYPE_MAX]; 17513 #endif 17514 17515 if (port_id_is_invalid(res->port_id, ENABLED_WARN)) 17516 return; 17517 17518 #ifdef RTE_LIBRTE_I40E_PMD 17519 nb_item = parse_item_list(res->pctype_list, "pctypes", 17520 RTE_PMD_I40E_PCTYPE_MAX, pctype_list, 1); 17521 mapping.flow_type = res->flow_type; 17522 for (i = 0, mapping.pctype = 0ULL; i < nb_item; i++) 17523 mapping.pctype |= (1ULL << pctype_list[i]); 17524 ret = rte_pmd_i40e_flow_type_mapping_update(res->port_id, 17525 &mapping, 17526 1, 17527 0); 17528 #endif 17529 17530 switch (ret) { 17531 case 0: 17532 break; 17533 case -EINVAL: 17534 printf("invalid pctype or flow type\n"); 17535 break; 17536 case -ENODEV: 17537 printf("invalid port_id %d\n", res->port_id); 17538 break; 17539 case -ENOTSUP: 17540 printf("function not implemented\n"); 17541 break; 17542 default: 17543 printf("programming error: (%s)\n", strerror(-ret)); 17544 } 17545 } 17546 17547 cmdline_parse_inst_t cmd_pctype_mapping_update = { 17548 .f = cmd_pctype_mapping_update_parsed, 17549 .data = NULL, 17550 .help_str = "port config <port_id> pctype mapping update" 17551 " <pctype_id_0,[pctype_id_1]*> <flowtype_id>", 17552 .tokens = { 17553 (void *)&cmd_pctype_mapping_update_port, 17554 (void *)&cmd_pctype_mapping_update_config, 17555 (void *)&cmd_pctype_mapping_update_port_id, 17556 (void *)&cmd_pctype_mapping_update_pctype, 17557 (void *)&cmd_pctype_mapping_update_mapping, 17558 (void *)&cmd_pctype_mapping_update_update, 17559 (void *)&cmd_pctype_mapping_update_pc_type, 17560 (void *)&cmd_pctype_mapping_update_flow_type, 17561 NULL, 17562 }, 17563 }; 17564 17565 /* ptype mapping get */ 17566 17567 /* Common result structure for ptype mapping get */ 17568 struct cmd_ptype_mapping_get_result { 17569 cmdline_fixed_string_t ptype; 17570 cmdline_fixed_string_t mapping; 17571 cmdline_fixed_string_t get; 17572 portid_t port_id; 17573 uint8_t valid_only; 17574 }; 17575 17576 /* Common CLI fields for ptype mapping get */ 17577 cmdline_parse_token_string_t cmd_ptype_mapping_get_ptype = 17578 TOKEN_STRING_INITIALIZER 17579 (struct cmd_ptype_mapping_get_result, 17580 ptype, "ptype"); 17581 cmdline_parse_token_string_t cmd_ptype_mapping_get_mapping = 17582 TOKEN_STRING_INITIALIZER 17583 (struct cmd_ptype_mapping_get_result, 17584 mapping, "mapping"); 17585 cmdline_parse_token_string_t cmd_ptype_mapping_get_get = 17586 TOKEN_STRING_INITIALIZER 17587 (struct cmd_ptype_mapping_get_result, 17588 get, "get"); 17589 cmdline_parse_token_num_t cmd_ptype_mapping_get_port_id = 17590 TOKEN_NUM_INITIALIZER 17591 (struct cmd_ptype_mapping_get_result, 17592 port_id, UINT16); 17593 cmdline_parse_token_num_t cmd_ptype_mapping_get_valid_only = 17594 TOKEN_NUM_INITIALIZER 17595 (struct cmd_ptype_mapping_get_result, 17596 valid_only, UINT8); 17597 17598 static void 17599 cmd_ptype_mapping_get_parsed( 17600 void *parsed_result, 17601 __attribute__((unused)) struct cmdline *cl, 17602 __attribute__((unused)) void *data) 17603 { 17604 struct cmd_ptype_mapping_get_result *res = parsed_result; 17605 int ret = -ENOTSUP; 17606 #ifdef RTE_LIBRTE_I40E_PMD 17607 int max_ptype_num = 256; 17608 struct rte_pmd_i40e_ptype_mapping mapping[max_ptype_num]; 17609 uint16_t count; 17610 int i; 17611 #endif 17612 17613 if (port_id_is_invalid(res->port_id, ENABLED_WARN)) 17614 return; 17615 17616 #ifdef RTE_LIBRTE_I40E_PMD 17617 ret = rte_pmd_i40e_ptype_mapping_get(res->port_id, 17618 mapping, 17619 max_ptype_num, 17620 &count, 17621 res->valid_only); 17622 #endif 17623 17624 switch (ret) { 17625 case 0: 17626 break; 17627 case -ENODEV: 17628 printf("invalid port_id %d\n", res->port_id); 17629 break; 17630 case -ENOTSUP: 17631 printf("function not implemented\n"); 17632 break; 17633 default: 17634 printf("programming error: (%s)\n", strerror(-ret)); 17635 } 17636 17637 #ifdef RTE_LIBRTE_I40E_PMD 17638 if (!ret) { 17639 for (i = 0; i < count; i++) 17640 printf("%3d\t0x%08x\n", 17641 mapping[i].hw_ptype, mapping[i].sw_ptype); 17642 } 17643 #endif 17644 } 17645 17646 cmdline_parse_inst_t cmd_ptype_mapping_get = { 17647 .f = cmd_ptype_mapping_get_parsed, 17648 .data = NULL, 17649 .help_str = "ptype mapping get <port_id> <valid_only>", 17650 .tokens = { 17651 (void *)&cmd_ptype_mapping_get_ptype, 17652 (void *)&cmd_ptype_mapping_get_mapping, 17653 (void *)&cmd_ptype_mapping_get_get, 17654 (void *)&cmd_ptype_mapping_get_port_id, 17655 (void *)&cmd_ptype_mapping_get_valid_only, 17656 NULL, 17657 }, 17658 }; 17659 17660 /* ptype mapping replace */ 17661 17662 /* Common result structure for ptype mapping replace */ 17663 struct cmd_ptype_mapping_replace_result { 17664 cmdline_fixed_string_t ptype; 17665 cmdline_fixed_string_t mapping; 17666 cmdline_fixed_string_t replace; 17667 portid_t port_id; 17668 uint32_t target; 17669 uint8_t mask; 17670 uint32_t pkt_type; 17671 }; 17672 17673 /* Common CLI fields for ptype mapping replace */ 17674 cmdline_parse_token_string_t cmd_ptype_mapping_replace_ptype = 17675 TOKEN_STRING_INITIALIZER 17676 (struct cmd_ptype_mapping_replace_result, 17677 ptype, "ptype"); 17678 cmdline_parse_token_string_t cmd_ptype_mapping_replace_mapping = 17679 TOKEN_STRING_INITIALIZER 17680 (struct cmd_ptype_mapping_replace_result, 17681 mapping, "mapping"); 17682 cmdline_parse_token_string_t cmd_ptype_mapping_replace_replace = 17683 TOKEN_STRING_INITIALIZER 17684 (struct cmd_ptype_mapping_replace_result, 17685 replace, "replace"); 17686 cmdline_parse_token_num_t cmd_ptype_mapping_replace_port_id = 17687 TOKEN_NUM_INITIALIZER 17688 (struct cmd_ptype_mapping_replace_result, 17689 port_id, UINT16); 17690 cmdline_parse_token_num_t cmd_ptype_mapping_replace_target = 17691 TOKEN_NUM_INITIALIZER 17692 (struct cmd_ptype_mapping_replace_result, 17693 target, UINT32); 17694 cmdline_parse_token_num_t cmd_ptype_mapping_replace_mask = 17695 TOKEN_NUM_INITIALIZER 17696 (struct cmd_ptype_mapping_replace_result, 17697 mask, UINT8); 17698 cmdline_parse_token_num_t cmd_ptype_mapping_replace_pkt_type = 17699 TOKEN_NUM_INITIALIZER 17700 (struct cmd_ptype_mapping_replace_result, 17701 pkt_type, UINT32); 17702 17703 static void 17704 cmd_ptype_mapping_replace_parsed( 17705 void *parsed_result, 17706 __attribute__((unused)) struct cmdline *cl, 17707 __attribute__((unused)) void *data) 17708 { 17709 struct cmd_ptype_mapping_replace_result *res = parsed_result; 17710 int ret = -ENOTSUP; 17711 17712 if (port_id_is_invalid(res->port_id, ENABLED_WARN)) 17713 return; 17714 17715 #ifdef RTE_LIBRTE_I40E_PMD 17716 ret = rte_pmd_i40e_ptype_mapping_replace(res->port_id, 17717 res->target, 17718 res->mask, 17719 res->pkt_type); 17720 #endif 17721 17722 switch (ret) { 17723 case 0: 17724 break; 17725 case -EINVAL: 17726 printf("invalid ptype 0x%8x or 0x%8x\n", 17727 res->target, res->pkt_type); 17728 break; 17729 case -ENODEV: 17730 printf("invalid port_id %d\n", res->port_id); 17731 break; 17732 case -ENOTSUP: 17733 printf("function not implemented\n"); 17734 break; 17735 default: 17736 printf("programming error: (%s)\n", strerror(-ret)); 17737 } 17738 } 17739 17740 cmdline_parse_inst_t cmd_ptype_mapping_replace = { 17741 .f = cmd_ptype_mapping_replace_parsed, 17742 .data = NULL, 17743 .help_str = 17744 "ptype mapping replace <port_id> <target> <mask> <pkt_type>", 17745 .tokens = { 17746 (void *)&cmd_ptype_mapping_replace_ptype, 17747 (void *)&cmd_ptype_mapping_replace_mapping, 17748 (void *)&cmd_ptype_mapping_replace_replace, 17749 (void *)&cmd_ptype_mapping_replace_port_id, 17750 (void *)&cmd_ptype_mapping_replace_target, 17751 (void *)&cmd_ptype_mapping_replace_mask, 17752 (void *)&cmd_ptype_mapping_replace_pkt_type, 17753 NULL, 17754 }, 17755 }; 17756 17757 /* ptype mapping reset */ 17758 17759 /* Common result structure for ptype mapping reset */ 17760 struct cmd_ptype_mapping_reset_result { 17761 cmdline_fixed_string_t ptype; 17762 cmdline_fixed_string_t mapping; 17763 cmdline_fixed_string_t reset; 17764 portid_t port_id; 17765 }; 17766 17767 /* Common CLI fields for ptype mapping reset*/ 17768 cmdline_parse_token_string_t cmd_ptype_mapping_reset_ptype = 17769 TOKEN_STRING_INITIALIZER 17770 (struct cmd_ptype_mapping_reset_result, 17771 ptype, "ptype"); 17772 cmdline_parse_token_string_t cmd_ptype_mapping_reset_mapping = 17773 TOKEN_STRING_INITIALIZER 17774 (struct cmd_ptype_mapping_reset_result, 17775 mapping, "mapping"); 17776 cmdline_parse_token_string_t cmd_ptype_mapping_reset_reset = 17777 TOKEN_STRING_INITIALIZER 17778 (struct cmd_ptype_mapping_reset_result, 17779 reset, "reset"); 17780 cmdline_parse_token_num_t cmd_ptype_mapping_reset_port_id = 17781 TOKEN_NUM_INITIALIZER 17782 (struct cmd_ptype_mapping_reset_result, 17783 port_id, UINT16); 17784 17785 static void 17786 cmd_ptype_mapping_reset_parsed( 17787 void *parsed_result, 17788 __attribute__((unused)) struct cmdline *cl, 17789 __attribute__((unused)) void *data) 17790 { 17791 struct cmd_ptype_mapping_reset_result *res = parsed_result; 17792 int ret = -ENOTSUP; 17793 17794 if (port_id_is_invalid(res->port_id, ENABLED_WARN)) 17795 return; 17796 17797 #ifdef RTE_LIBRTE_I40E_PMD 17798 ret = rte_pmd_i40e_ptype_mapping_reset(res->port_id); 17799 #endif 17800 17801 switch (ret) { 17802 case 0: 17803 break; 17804 case -ENODEV: 17805 printf("invalid port_id %d\n", res->port_id); 17806 break; 17807 case -ENOTSUP: 17808 printf("function not implemented\n"); 17809 break; 17810 default: 17811 printf("programming error: (%s)\n", strerror(-ret)); 17812 } 17813 } 17814 17815 cmdline_parse_inst_t cmd_ptype_mapping_reset = { 17816 .f = cmd_ptype_mapping_reset_parsed, 17817 .data = NULL, 17818 .help_str = "ptype mapping reset <port_id>", 17819 .tokens = { 17820 (void *)&cmd_ptype_mapping_reset_ptype, 17821 (void *)&cmd_ptype_mapping_reset_mapping, 17822 (void *)&cmd_ptype_mapping_reset_reset, 17823 (void *)&cmd_ptype_mapping_reset_port_id, 17824 NULL, 17825 }, 17826 }; 17827 17828 /* ptype mapping update */ 17829 17830 /* Common result structure for ptype mapping update */ 17831 struct cmd_ptype_mapping_update_result { 17832 cmdline_fixed_string_t ptype; 17833 cmdline_fixed_string_t mapping; 17834 cmdline_fixed_string_t reset; 17835 portid_t port_id; 17836 uint8_t hw_ptype; 17837 uint32_t sw_ptype; 17838 }; 17839 17840 /* Common CLI fields for ptype mapping update*/ 17841 cmdline_parse_token_string_t cmd_ptype_mapping_update_ptype = 17842 TOKEN_STRING_INITIALIZER 17843 (struct cmd_ptype_mapping_update_result, 17844 ptype, "ptype"); 17845 cmdline_parse_token_string_t cmd_ptype_mapping_update_mapping = 17846 TOKEN_STRING_INITIALIZER 17847 (struct cmd_ptype_mapping_update_result, 17848 mapping, "mapping"); 17849 cmdline_parse_token_string_t cmd_ptype_mapping_update_update = 17850 TOKEN_STRING_INITIALIZER 17851 (struct cmd_ptype_mapping_update_result, 17852 reset, "update"); 17853 cmdline_parse_token_num_t cmd_ptype_mapping_update_port_id = 17854 TOKEN_NUM_INITIALIZER 17855 (struct cmd_ptype_mapping_update_result, 17856 port_id, UINT16); 17857 cmdline_parse_token_num_t cmd_ptype_mapping_update_hw_ptype = 17858 TOKEN_NUM_INITIALIZER 17859 (struct cmd_ptype_mapping_update_result, 17860 hw_ptype, UINT8); 17861 cmdline_parse_token_num_t cmd_ptype_mapping_update_sw_ptype = 17862 TOKEN_NUM_INITIALIZER 17863 (struct cmd_ptype_mapping_update_result, 17864 sw_ptype, UINT32); 17865 17866 static void 17867 cmd_ptype_mapping_update_parsed( 17868 void *parsed_result, 17869 __attribute__((unused)) struct cmdline *cl, 17870 __attribute__((unused)) void *data) 17871 { 17872 struct cmd_ptype_mapping_update_result *res = parsed_result; 17873 int ret = -ENOTSUP; 17874 #ifdef RTE_LIBRTE_I40E_PMD 17875 struct rte_pmd_i40e_ptype_mapping mapping; 17876 #endif 17877 if (port_id_is_invalid(res->port_id, ENABLED_WARN)) 17878 return; 17879 17880 #ifdef RTE_LIBRTE_I40E_PMD 17881 mapping.hw_ptype = res->hw_ptype; 17882 mapping.sw_ptype = res->sw_ptype; 17883 ret = rte_pmd_i40e_ptype_mapping_update(res->port_id, 17884 &mapping, 17885 1, 17886 0); 17887 #endif 17888 17889 switch (ret) { 17890 case 0: 17891 break; 17892 case -EINVAL: 17893 printf("invalid ptype 0x%8x\n", res->sw_ptype); 17894 break; 17895 case -ENODEV: 17896 printf("invalid port_id %d\n", res->port_id); 17897 break; 17898 case -ENOTSUP: 17899 printf("function not implemented\n"); 17900 break; 17901 default: 17902 printf("programming error: (%s)\n", strerror(-ret)); 17903 } 17904 } 17905 17906 cmdline_parse_inst_t cmd_ptype_mapping_update = { 17907 .f = cmd_ptype_mapping_update_parsed, 17908 .data = NULL, 17909 .help_str = "ptype mapping update <port_id> <hw_ptype> <sw_ptype>", 17910 .tokens = { 17911 (void *)&cmd_ptype_mapping_update_ptype, 17912 (void *)&cmd_ptype_mapping_update_mapping, 17913 (void *)&cmd_ptype_mapping_update_update, 17914 (void *)&cmd_ptype_mapping_update_port_id, 17915 (void *)&cmd_ptype_mapping_update_hw_ptype, 17916 (void *)&cmd_ptype_mapping_update_sw_ptype, 17917 NULL, 17918 }, 17919 }; 17920 17921 /* Common result structure for file commands */ 17922 struct cmd_cmdfile_result { 17923 cmdline_fixed_string_t load; 17924 cmdline_fixed_string_t filename; 17925 }; 17926 17927 /* Common CLI fields for file commands */ 17928 cmdline_parse_token_string_t cmd_load_cmdfile = 17929 TOKEN_STRING_INITIALIZER(struct cmd_cmdfile_result, load, "load"); 17930 cmdline_parse_token_string_t cmd_load_cmdfile_filename = 17931 TOKEN_STRING_INITIALIZER(struct cmd_cmdfile_result, filename, NULL); 17932 17933 static void 17934 cmd_load_from_file_parsed( 17935 void *parsed_result, 17936 __attribute__((unused)) struct cmdline *cl, 17937 __attribute__((unused)) void *data) 17938 { 17939 struct cmd_cmdfile_result *res = parsed_result; 17940 17941 cmdline_read_from_file(res->filename); 17942 } 17943 17944 cmdline_parse_inst_t cmd_load_from_file = { 17945 .f = cmd_load_from_file_parsed, 17946 .data = NULL, 17947 .help_str = "load <filename>", 17948 .tokens = { 17949 (void *)&cmd_load_cmdfile, 17950 (void *)&cmd_load_cmdfile_filename, 17951 NULL, 17952 }, 17953 }; 17954 17955 /* Get Rx offloads capabilities */ 17956 struct cmd_rx_offload_get_capa_result { 17957 cmdline_fixed_string_t show; 17958 cmdline_fixed_string_t port; 17959 portid_t port_id; 17960 cmdline_fixed_string_t rx_offload; 17961 cmdline_fixed_string_t capabilities; 17962 }; 17963 17964 cmdline_parse_token_string_t cmd_rx_offload_get_capa_show = 17965 TOKEN_STRING_INITIALIZER 17966 (struct cmd_rx_offload_get_capa_result, 17967 show, "show"); 17968 cmdline_parse_token_string_t cmd_rx_offload_get_capa_port = 17969 TOKEN_STRING_INITIALIZER 17970 (struct cmd_rx_offload_get_capa_result, 17971 port, "port"); 17972 cmdline_parse_token_num_t cmd_rx_offload_get_capa_port_id = 17973 TOKEN_NUM_INITIALIZER 17974 (struct cmd_rx_offload_get_capa_result, 17975 port_id, UINT16); 17976 cmdline_parse_token_string_t cmd_rx_offload_get_capa_rx_offload = 17977 TOKEN_STRING_INITIALIZER 17978 (struct cmd_rx_offload_get_capa_result, 17979 rx_offload, "rx_offload"); 17980 cmdline_parse_token_string_t cmd_rx_offload_get_capa_capabilities = 17981 TOKEN_STRING_INITIALIZER 17982 (struct cmd_rx_offload_get_capa_result, 17983 capabilities, "capabilities"); 17984 17985 static void 17986 print_rx_offloads(uint64_t offloads) 17987 { 17988 uint64_t single_offload; 17989 int begin; 17990 int end; 17991 int bit; 17992 17993 if (offloads == 0) 17994 return; 17995 17996 begin = __builtin_ctzll(offloads); 17997 end = sizeof(offloads) * CHAR_BIT - __builtin_clzll(offloads); 17998 17999 single_offload = 1ULL << begin; 18000 for (bit = begin; bit < end; bit++) { 18001 if (offloads & single_offload) 18002 printf(" %s", 18003 rte_eth_dev_rx_offload_name(single_offload)); 18004 single_offload <<= 1; 18005 } 18006 } 18007 18008 static void 18009 cmd_rx_offload_get_capa_parsed( 18010 void *parsed_result, 18011 __attribute__((unused)) struct cmdline *cl, 18012 __attribute__((unused)) void *data) 18013 { 18014 struct cmd_rx_offload_get_capa_result *res = parsed_result; 18015 struct rte_eth_dev_info dev_info; 18016 portid_t port_id = res->port_id; 18017 uint64_t queue_offloads; 18018 uint64_t port_offloads; 18019 int ret; 18020 18021 ret = eth_dev_info_get_print_err(port_id, &dev_info); 18022 if (ret != 0) 18023 return; 18024 18025 queue_offloads = dev_info.rx_queue_offload_capa; 18026 port_offloads = dev_info.rx_offload_capa ^ queue_offloads; 18027 18028 printf("Rx Offloading Capabilities of port %d :\n", port_id); 18029 printf(" Per Queue :"); 18030 print_rx_offloads(queue_offloads); 18031 18032 printf("\n"); 18033 printf(" Per Port :"); 18034 print_rx_offloads(port_offloads); 18035 printf("\n\n"); 18036 } 18037 18038 cmdline_parse_inst_t cmd_rx_offload_get_capa = { 18039 .f = cmd_rx_offload_get_capa_parsed, 18040 .data = NULL, 18041 .help_str = "show port <port_id> rx_offload capabilities", 18042 .tokens = { 18043 (void *)&cmd_rx_offload_get_capa_show, 18044 (void *)&cmd_rx_offload_get_capa_port, 18045 (void *)&cmd_rx_offload_get_capa_port_id, 18046 (void *)&cmd_rx_offload_get_capa_rx_offload, 18047 (void *)&cmd_rx_offload_get_capa_capabilities, 18048 NULL, 18049 } 18050 }; 18051 18052 /* Get Rx offloads configuration */ 18053 struct cmd_rx_offload_get_configuration_result { 18054 cmdline_fixed_string_t show; 18055 cmdline_fixed_string_t port; 18056 portid_t port_id; 18057 cmdline_fixed_string_t rx_offload; 18058 cmdline_fixed_string_t configuration; 18059 }; 18060 18061 cmdline_parse_token_string_t cmd_rx_offload_get_configuration_show = 18062 TOKEN_STRING_INITIALIZER 18063 (struct cmd_rx_offload_get_configuration_result, 18064 show, "show"); 18065 cmdline_parse_token_string_t cmd_rx_offload_get_configuration_port = 18066 TOKEN_STRING_INITIALIZER 18067 (struct cmd_rx_offload_get_configuration_result, 18068 port, "port"); 18069 cmdline_parse_token_num_t cmd_rx_offload_get_configuration_port_id = 18070 TOKEN_NUM_INITIALIZER 18071 (struct cmd_rx_offload_get_configuration_result, 18072 port_id, UINT16); 18073 cmdline_parse_token_string_t cmd_rx_offload_get_configuration_rx_offload = 18074 TOKEN_STRING_INITIALIZER 18075 (struct cmd_rx_offload_get_configuration_result, 18076 rx_offload, "rx_offload"); 18077 cmdline_parse_token_string_t cmd_rx_offload_get_configuration_configuration = 18078 TOKEN_STRING_INITIALIZER 18079 (struct cmd_rx_offload_get_configuration_result, 18080 configuration, "configuration"); 18081 18082 static void 18083 cmd_rx_offload_get_configuration_parsed( 18084 void *parsed_result, 18085 __attribute__((unused)) struct cmdline *cl, 18086 __attribute__((unused)) void *data) 18087 { 18088 struct cmd_rx_offload_get_configuration_result *res = parsed_result; 18089 struct rte_eth_dev_info dev_info; 18090 portid_t port_id = res->port_id; 18091 struct rte_port *port = &ports[port_id]; 18092 uint64_t port_offloads; 18093 uint64_t queue_offloads; 18094 uint16_t nb_rx_queues; 18095 int q; 18096 int ret; 18097 18098 printf("Rx Offloading Configuration of port %d :\n", port_id); 18099 18100 port_offloads = port->dev_conf.rxmode.offloads; 18101 printf(" Port :"); 18102 print_rx_offloads(port_offloads); 18103 printf("\n"); 18104 18105 ret = eth_dev_info_get_print_err(port_id, &dev_info); 18106 if (ret != 0) 18107 return; 18108 18109 nb_rx_queues = dev_info.nb_rx_queues; 18110 for (q = 0; q < nb_rx_queues; q++) { 18111 queue_offloads = port->rx_conf[q].offloads; 18112 printf(" Queue[%2d] :", q); 18113 print_rx_offloads(queue_offloads); 18114 printf("\n"); 18115 } 18116 printf("\n"); 18117 } 18118 18119 cmdline_parse_inst_t cmd_rx_offload_get_configuration = { 18120 .f = cmd_rx_offload_get_configuration_parsed, 18121 .data = NULL, 18122 .help_str = "show port <port_id> rx_offload configuration", 18123 .tokens = { 18124 (void *)&cmd_rx_offload_get_configuration_show, 18125 (void *)&cmd_rx_offload_get_configuration_port, 18126 (void *)&cmd_rx_offload_get_configuration_port_id, 18127 (void *)&cmd_rx_offload_get_configuration_rx_offload, 18128 (void *)&cmd_rx_offload_get_configuration_configuration, 18129 NULL, 18130 } 18131 }; 18132 18133 /* Enable/Disable a per port offloading */ 18134 struct cmd_config_per_port_rx_offload_result { 18135 cmdline_fixed_string_t port; 18136 cmdline_fixed_string_t config; 18137 portid_t port_id; 18138 cmdline_fixed_string_t rx_offload; 18139 cmdline_fixed_string_t offload; 18140 cmdline_fixed_string_t on_off; 18141 }; 18142 18143 cmdline_parse_token_string_t cmd_config_per_port_rx_offload_result_port = 18144 TOKEN_STRING_INITIALIZER 18145 (struct cmd_config_per_port_rx_offload_result, 18146 port, "port"); 18147 cmdline_parse_token_string_t cmd_config_per_port_rx_offload_result_config = 18148 TOKEN_STRING_INITIALIZER 18149 (struct cmd_config_per_port_rx_offload_result, 18150 config, "config"); 18151 cmdline_parse_token_num_t cmd_config_per_port_rx_offload_result_port_id = 18152 TOKEN_NUM_INITIALIZER 18153 (struct cmd_config_per_port_rx_offload_result, 18154 port_id, UINT16); 18155 cmdline_parse_token_string_t cmd_config_per_port_rx_offload_result_rx_offload = 18156 TOKEN_STRING_INITIALIZER 18157 (struct cmd_config_per_port_rx_offload_result, 18158 rx_offload, "rx_offload"); 18159 cmdline_parse_token_string_t cmd_config_per_port_rx_offload_result_offload = 18160 TOKEN_STRING_INITIALIZER 18161 (struct cmd_config_per_port_rx_offload_result, 18162 offload, "vlan_strip#ipv4_cksum#udp_cksum#tcp_cksum#tcp_lro#" 18163 "qinq_strip#outer_ipv4_cksum#macsec_strip#" 18164 "header_split#vlan_filter#vlan_extend#jumbo_frame#" 18165 "scatter#timestamp#security#keep_crc#rss_hash"); 18166 cmdline_parse_token_string_t cmd_config_per_port_rx_offload_result_on_off = 18167 TOKEN_STRING_INITIALIZER 18168 (struct cmd_config_per_port_rx_offload_result, 18169 on_off, "on#off"); 18170 18171 static uint64_t 18172 search_rx_offload(const char *name) 18173 { 18174 uint64_t single_offload; 18175 const char *single_name; 18176 int found = 0; 18177 unsigned int bit; 18178 18179 single_offload = 1; 18180 for (bit = 0; bit < sizeof(single_offload) * CHAR_BIT; bit++) { 18181 single_name = rte_eth_dev_rx_offload_name(single_offload); 18182 if (!strcasecmp(single_name, name)) { 18183 found = 1; 18184 break; 18185 } 18186 single_offload <<= 1; 18187 } 18188 18189 if (found) 18190 return single_offload; 18191 18192 return 0; 18193 } 18194 18195 static void 18196 cmd_config_per_port_rx_offload_parsed(void *parsed_result, 18197 __attribute__((unused)) struct cmdline *cl, 18198 __attribute__((unused)) void *data) 18199 { 18200 struct cmd_config_per_port_rx_offload_result *res = parsed_result; 18201 portid_t port_id = res->port_id; 18202 struct rte_eth_dev_info dev_info; 18203 struct rte_port *port = &ports[port_id]; 18204 uint64_t single_offload; 18205 uint16_t nb_rx_queues; 18206 int q; 18207 int ret; 18208 18209 if (port->port_status != RTE_PORT_STOPPED) { 18210 printf("Error: Can't config offload when Port %d " 18211 "is not stopped\n", port_id); 18212 return; 18213 } 18214 18215 single_offload = search_rx_offload(res->offload); 18216 if (single_offload == 0) { 18217 printf("Unknown offload name: %s\n", res->offload); 18218 return; 18219 } 18220 18221 ret = eth_dev_info_get_print_err(port_id, &dev_info); 18222 if (ret != 0) 18223 return; 18224 18225 nb_rx_queues = dev_info.nb_rx_queues; 18226 if (!strcmp(res->on_off, "on")) { 18227 port->dev_conf.rxmode.offloads |= single_offload; 18228 for (q = 0; q < nb_rx_queues; q++) 18229 port->rx_conf[q].offloads |= single_offload; 18230 } else { 18231 port->dev_conf.rxmode.offloads &= ~single_offload; 18232 for (q = 0; q < nb_rx_queues; q++) 18233 port->rx_conf[q].offloads &= ~single_offload; 18234 } 18235 18236 cmd_reconfig_device_queue(port_id, 1, 1); 18237 } 18238 18239 cmdline_parse_inst_t cmd_config_per_port_rx_offload = { 18240 .f = cmd_config_per_port_rx_offload_parsed, 18241 .data = NULL, 18242 .help_str = "port config <port_id> rx_offload vlan_strip|ipv4_cksum|" 18243 "udp_cksum|tcp_cksum|tcp_lro|qinq_strip|outer_ipv4_cksum|" 18244 "macsec_strip|header_split|vlan_filter|vlan_extend|" 18245 "jumbo_frame|scatter|timestamp|security|keep_crc|rss_hash " 18246 "on|off", 18247 .tokens = { 18248 (void *)&cmd_config_per_port_rx_offload_result_port, 18249 (void *)&cmd_config_per_port_rx_offload_result_config, 18250 (void *)&cmd_config_per_port_rx_offload_result_port_id, 18251 (void *)&cmd_config_per_port_rx_offload_result_rx_offload, 18252 (void *)&cmd_config_per_port_rx_offload_result_offload, 18253 (void *)&cmd_config_per_port_rx_offload_result_on_off, 18254 NULL, 18255 } 18256 }; 18257 18258 /* Enable/Disable a per queue offloading */ 18259 struct cmd_config_per_queue_rx_offload_result { 18260 cmdline_fixed_string_t port; 18261 portid_t port_id; 18262 cmdline_fixed_string_t rxq; 18263 uint16_t queue_id; 18264 cmdline_fixed_string_t rx_offload; 18265 cmdline_fixed_string_t offload; 18266 cmdline_fixed_string_t on_off; 18267 }; 18268 18269 cmdline_parse_token_string_t cmd_config_per_queue_rx_offload_result_port = 18270 TOKEN_STRING_INITIALIZER 18271 (struct cmd_config_per_queue_rx_offload_result, 18272 port, "port"); 18273 cmdline_parse_token_num_t cmd_config_per_queue_rx_offload_result_port_id = 18274 TOKEN_NUM_INITIALIZER 18275 (struct cmd_config_per_queue_rx_offload_result, 18276 port_id, UINT16); 18277 cmdline_parse_token_string_t cmd_config_per_queue_rx_offload_result_rxq = 18278 TOKEN_STRING_INITIALIZER 18279 (struct cmd_config_per_queue_rx_offload_result, 18280 rxq, "rxq"); 18281 cmdline_parse_token_num_t cmd_config_per_queue_rx_offload_result_queue_id = 18282 TOKEN_NUM_INITIALIZER 18283 (struct cmd_config_per_queue_rx_offload_result, 18284 queue_id, UINT16); 18285 cmdline_parse_token_string_t cmd_config_per_queue_rx_offload_result_rxoffload = 18286 TOKEN_STRING_INITIALIZER 18287 (struct cmd_config_per_queue_rx_offload_result, 18288 rx_offload, "rx_offload"); 18289 cmdline_parse_token_string_t cmd_config_per_queue_rx_offload_result_offload = 18290 TOKEN_STRING_INITIALIZER 18291 (struct cmd_config_per_queue_rx_offload_result, 18292 offload, "vlan_strip#ipv4_cksum#udp_cksum#tcp_cksum#tcp_lro#" 18293 "qinq_strip#outer_ipv4_cksum#macsec_strip#" 18294 "header_split#vlan_filter#vlan_extend#jumbo_frame#" 18295 "scatter#timestamp#security#keep_crc"); 18296 cmdline_parse_token_string_t cmd_config_per_queue_rx_offload_result_on_off = 18297 TOKEN_STRING_INITIALIZER 18298 (struct cmd_config_per_queue_rx_offload_result, 18299 on_off, "on#off"); 18300 18301 static void 18302 cmd_config_per_queue_rx_offload_parsed(void *parsed_result, 18303 __attribute__((unused)) struct cmdline *cl, 18304 __attribute__((unused)) void *data) 18305 { 18306 struct cmd_config_per_queue_rx_offload_result *res = parsed_result; 18307 struct rte_eth_dev_info dev_info; 18308 portid_t port_id = res->port_id; 18309 uint16_t queue_id = res->queue_id; 18310 struct rte_port *port = &ports[port_id]; 18311 uint64_t single_offload; 18312 int ret; 18313 18314 if (port->port_status != RTE_PORT_STOPPED) { 18315 printf("Error: Can't config offload when Port %d " 18316 "is not stopped\n", port_id); 18317 return; 18318 } 18319 18320 ret = eth_dev_info_get_print_err(port_id, &dev_info); 18321 if (ret != 0) 18322 return; 18323 18324 if (queue_id >= dev_info.nb_rx_queues) { 18325 printf("Error: input queue_id should be 0 ... " 18326 "%d\n", dev_info.nb_rx_queues - 1); 18327 return; 18328 } 18329 18330 single_offload = search_rx_offload(res->offload); 18331 if (single_offload == 0) { 18332 printf("Unknown offload name: %s\n", res->offload); 18333 return; 18334 } 18335 18336 if (!strcmp(res->on_off, "on")) 18337 port->rx_conf[queue_id].offloads |= single_offload; 18338 else 18339 port->rx_conf[queue_id].offloads &= ~single_offload; 18340 18341 cmd_reconfig_device_queue(port_id, 1, 1); 18342 } 18343 18344 cmdline_parse_inst_t cmd_config_per_queue_rx_offload = { 18345 .f = cmd_config_per_queue_rx_offload_parsed, 18346 .data = NULL, 18347 .help_str = "port <port_id> rxq <queue_id> rx_offload " 18348 "vlan_strip|ipv4_cksum|" 18349 "udp_cksum|tcp_cksum|tcp_lro|qinq_strip|outer_ipv4_cksum|" 18350 "macsec_strip|header_split|vlan_filter|vlan_extend|" 18351 "jumbo_frame|scatter|timestamp|security|keep_crc " 18352 "on|off", 18353 .tokens = { 18354 (void *)&cmd_config_per_queue_rx_offload_result_port, 18355 (void *)&cmd_config_per_queue_rx_offload_result_port_id, 18356 (void *)&cmd_config_per_queue_rx_offload_result_rxq, 18357 (void *)&cmd_config_per_queue_rx_offload_result_queue_id, 18358 (void *)&cmd_config_per_queue_rx_offload_result_rxoffload, 18359 (void *)&cmd_config_per_queue_rx_offload_result_offload, 18360 (void *)&cmd_config_per_queue_rx_offload_result_on_off, 18361 NULL, 18362 } 18363 }; 18364 18365 /* Get Tx offloads capabilities */ 18366 struct cmd_tx_offload_get_capa_result { 18367 cmdline_fixed_string_t show; 18368 cmdline_fixed_string_t port; 18369 portid_t port_id; 18370 cmdline_fixed_string_t tx_offload; 18371 cmdline_fixed_string_t capabilities; 18372 }; 18373 18374 cmdline_parse_token_string_t cmd_tx_offload_get_capa_show = 18375 TOKEN_STRING_INITIALIZER 18376 (struct cmd_tx_offload_get_capa_result, 18377 show, "show"); 18378 cmdline_parse_token_string_t cmd_tx_offload_get_capa_port = 18379 TOKEN_STRING_INITIALIZER 18380 (struct cmd_tx_offload_get_capa_result, 18381 port, "port"); 18382 cmdline_parse_token_num_t cmd_tx_offload_get_capa_port_id = 18383 TOKEN_NUM_INITIALIZER 18384 (struct cmd_tx_offload_get_capa_result, 18385 port_id, UINT16); 18386 cmdline_parse_token_string_t cmd_tx_offload_get_capa_tx_offload = 18387 TOKEN_STRING_INITIALIZER 18388 (struct cmd_tx_offload_get_capa_result, 18389 tx_offload, "tx_offload"); 18390 cmdline_parse_token_string_t cmd_tx_offload_get_capa_capabilities = 18391 TOKEN_STRING_INITIALIZER 18392 (struct cmd_tx_offload_get_capa_result, 18393 capabilities, "capabilities"); 18394 18395 static void 18396 print_tx_offloads(uint64_t offloads) 18397 { 18398 uint64_t single_offload; 18399 int begin; 18400 int end; 18401 int bit; 18402 18403 if (offloads == 0) 18404 return; 18405 18406 begin = __builtin_ctzll(offloads); 18407 end = sizeof(offloads) * CHAR_BIT - __builtin_clzll(offloads); 18408 18409 single_offload = 1ULL << begin; 18410 for (bit = begin; bit < end; bit++) { 18411 if (offloads & single_offload) 18412 printf(" %s", 18413 rte_eth_dev_tx_offload_name(single_offload)); 18414 single_offload <<= 1; 18415 } 18416 } 18417 18418 static void 18419 cmd_tx_offload_get_capa_parsed( 18420 void *parsed_result, 18421 __attribute__((unused)) struct cmdline *cl, 18422 __attribute__((unused)) void *data) 18423 { 18424 struct cmd_tx_offload_get_capa_result *res = parsed_result; 18425 struct rte_eth_dev_info dev_info; 18426 portid_t port_id = res->port_id; 18427 uint64_t queue_offloads; 18428 uint64_t port_offloads; 18429 int ret; 18430 18431 ret = eth_dev_info_get_print_err(port_id, &dev_info); 18432 if (ret != 0) 18433 return; 18434 18435 queue_offloads = dev_info.tx_queue_offload_capa; 18436 port_offloads = dev_info.tx_offload_capa ^ queue_offloads; 18437 18438 printf("Tx Offloading Capabilities of port %d :\n", port_id); 18439 printf(" Per Queue :"); 18440 print_tx_offloads(queue_offloads); 18441 18442 printf("\n"); 18443 printf(" Per Port :"); 18444 print_tx_offloads(port_offloads); 18445 printf("\n\n"); 18446 } 18447 18448 cmdline_parse_inst_t cmd_tx_offload_get_capa = { 18449 .f = cmd_tx_offload_get_capa_parsed, 18450 .data = NULL, 18451 .help_str = "show port <port_id> tx_offload capabilities", 18452 .tokens = { 18453 (void *)&cmd_tx_offload_get_capa_show, 18454 (void *)&cmd_tx_offload_get_capa_port, 18455 (void *)&cmd_tx_offload_get_capa_port_id, 18456 (void *)&cmd_tx_offload_get_capa_tx_offload, 18457 (void *)&cmd_tx_offload_get_capa_capabilities, 18458 NULL, 18459 } 18460 }; 18461 18462 /* Get Tx offloads configuration */ 18463 struct cmd_tx_offload_get_configuration_result { 18464 cmdline_fixed_string_t show; 18465 cmdline_fixed_string_t port; 18466 portid_t port_id; 18467 cmdline_fixed_string_t tx_offload; 18468 cmdline_fixed_string_t configuration; 18469 }; 18470 18471 cmdline_parse_token_string_t cmd_tx_offload_get_configuration_show = 18472 TOKEN_STRING_INITIALIZER 18473 (struct cmd_tx_offload_get_configuration_result, 18474 show, "show"); 18475 cmdline_parse_token_string_t cmd_tx_offload_get_configuration_port = 18476 TOKEN_STRING_INITIALIZER 18477 (struct cmd_tx_offload_get_configuration_result, 18478 port, "port"); 18479 cmdline_parse_token_num_t cmd_tx_offload_get_configuration_port_id = 18480 TOKEN_NUM_INITIALIZER 18481 (struct cmd_tx_offload_get_configuration_result, 18482 port_id, UINT16); 18483 cmdline_parse_token_string_t cmd_tx_offload_get_configuration_tx_offload = 18484 TOKEN_STRING_INITIALIZER 18485 (struct cmd_tx_offload_get_configuration_result, 18486 tx_offload, "tx_offload"); 18487 cmdline_parse_token_string_t cmd_tx_offload_get_configuration_configuration = 18488 TOKEN_STRING_INITIALIZER 18489 (struct cmd_tx_offload_get_configuration_result, 18490 configuration, "configuration"); 18491 18492 static void 18493 cmd_tx_offload_get_configuration_parsed( 18494 void *parsed_result, 18495 __attribute__((unused)) struct cmdline *cl, 18496 __attribute__((unused)) void *data) 18497 { 18498 struct cmd_tx_offload_get_configuration_result *res = parsed_result; 18499 struct rte_eth_dev_info dev_info; 18500 portid_t port_id = res->port_id; 18501 struct rte_port *port = &ports[port_id]; 18502 uint64_t port_offloads; 18503 uint64_t queue_offloads; 18504 uint16_t nb_tx_queues; 18505 int q; 18506 int ret; 18507 18508 printf("Tx Offloading Configuration of port %d :\n", port_id); 18509 18510 port_offloads = port->dev_conf.txmode.offloads; 18511 printf(" Port :"); 18512 print_tx_offloads(port_offloads); 18513 printf("\n"); 18514 18515 ret = eth_dev_info_get_print_err(port_id, &dev_info); 18516 if (ret != 0) 18517 return; 18518 18519 nb_tx_queues = dev_info.nb_tx_queues; 18520 for (q = 0; q < nb_tx_queues; q++) { 18521 queue_offloads = port->tx_conf[q].offloads; 18522 printf(" Queue[%2d] :", q); 18523 print_tx_offloads(queue_offloads); 18524 printf("\n"); 18525 } 18526 printf("\n"); 18527 } 18528 18529 cmdline_parse_inst_t cmd_tx_offload_get_configuration = { 18530 .f = cmd_tx_offload_get_configuration_parsed, 18531 .data = NULL, 18532 .help_str = "show port <port_id> tx_offload configuration", 18533 .tokens = { 18534 (void *)&cmd_tx_offload_get_configuration_show, 18535 (void *)&cmd_tx_offload_get_configuration_port, 18536 (void *)&cmd_tx_offload_get_configuration_port_id, 18537 (void *)&cmd_tx_offload_get_configuration_tx_offload, 18538 (void *)&cmd_tx_offload_get_configuration_configuration, 18539 NULL, 18540 } 18541 }; 18542 18543 /* Enable/Disable a per port offloading */ 18544 struct cmd_config_per_port_tx_offload_result { 18545 cmdline_fixed_string_t port; 18546 cmdline_fixed_string_t config; 18547 portid_t port_id; 18548 cmdline_fixed_string_t tx_offload; 18549 cmdline_fixed_string_t offload; 18550 cmdline_fixed_string_t on_off; 18551 }; 18552 18553 cmdline_parse_token_string_t cmd_config_per_port_tx_offload_result_port = 18554 TOKEN_STRING_INITIALIZER 18555 (struct cmd_config_per_port_tx_offload_result, 18556 port, "port"); 18557 cmdline_parse_token_string_t cmd_config_per_port_tx_offload_result_config = 18558 TOKEN_STRING_INITIALIZER 18559 (struct cmd_config_per_port_tx_offload_result, 18560 config, "config"); 18561 cmdline_parse_token_num_t cmd_config_per_port_tx_offload_result_port_id = 18562 TOKEN_NUM_INITIALIZER 18563 (struct cmd_config_per_port_tx_offload_result, 18564 port_id, UINT16); 18565 cmdline_parse_token_string_t cmd_config_per_port_tx_offload_result_tx_offload = 18566 TOKEN_STRING_INITIALIZER 18567 (struct cmd_config_per_port_tx_offload_result, 18568 tx_offload, "tx_offload"); 18569 cmdline_parse_token_string_t cmd_config_per_port_tx_offload_result_offload = 18570 TOKEN_STRING_INITIALIZER 18571 (struct cmd_config_per_port_tx_offload_result, 18572 offload, "vlan_insert#ipv4_cksum#udp_cksum#tcp_cksum#" 18573 "sctp_cksum#tcp_tso#udp_tso#outer_ipv4_cksum#" 18574 "qinq_insert#vxlan_tnl_tso#gre_tnl_tso#" 18575 "ipip_tnl_tso#geneve_tnl_tso#macsec_insert#" 18576 "mt_lockfree#multi_segs#mbuf_fast_free#security#" 18577 "match_metadata"); 18578 cmdline_parse_token_string_t cmd_config_per_port_tx_offload_result_on_off = 18579 TOKEN_STRING_INITIALIZER 18580 (struct cmd_config_per_port_tx_offload_result, 18581 on_off, "on#off"); 18582 18583 static uint64_t 18584 search_tx_offload(const char *name) 18585 { 18586 uint64_t single_offload; 18587 const char *single_name; 18588 int found = 0; 18589 unsigned int bit; 18590 18591 single_offload = 1; 18592 for (bit = 0; bit < sizeof(single_offload) * CHAR_BIT; bit++) { 18593 single_name = rte_eth_dev_tx_offload_name(single_offload); 18594 if (single_name == NULL) 18595 break; 18596 if (!strcasecmp(single_name, name)) { 18597 found = 1; 18598 break; 18599 } else if (!strcasecmp(single_name, "UNKNOWN")) 18600 break; 18601 single_offload <<= 1; 18602 } 18603 18604 if (found) 18605 return single_offload; 18606 18607 return 0; 18608 } 18609 18610 static void 18611 cmd_config_per_port_tx_offload_parsed(void *parsed_result, 18612 __attribute__((unused)) struct cmdline *cl, 18613 __attribute__((unused)) void *data) 18614 { 18615 struct cmd_config_per_port_tx_offload_result *res = parsed_result; 18616 portid_t port_id = res->port_id; 18617 struct rte_eth_dev_info dev_info; 18618 struct rte_port *port = &ports[port_id]; 18619 uint64_t single_offload; 18620 uint16_t nb_tx_queues; 18621 int q; 18622 int ret; 18623 18624 if (port->port_status != RTE_PORT_STOPPED) { 18625 printf("Error: Can't config offload when Port %d " 18626 "is not stopped\n", port_id); 18627 return; 18628 } 18629 18630 single_offload = search_tx_offload(res->offload); 18631 if (single_offload == 0) { 18632 printf("Unknown offload name: %s\n", res->offload); 18633 return; 18634 } 18635 18636 ret = eth_dev_info_get_print_err(port_id, &dev_info); 18637 if (ret != 0) 18638 return; 18639 18640 nb_tx_queues = dev_info.nb_tx_queues; 18641 if (!strcmp(res->on_off, "on")) { 18642 port->dev_conf.txmode.offloads |= single_offload; 18643 for (q = 0; q < nb_tx_queues; q++) 18644 port->tx_conf[q].offloads |= single_offload; 18645 } else { 18646 port->dev_conf.txmode.offloads &= ~single_offload; 18647 for (q = 0; q < nb_tx_queues; q++) 18648 port->tx_conf[q].offloads &= ~single_offload; 18649 } 18650 18651 cmd_reconfig_device_queue(port_id, 1, 1); 18652 } 18653 18654 cmdline_parse_inst_t cmd_config_per_port_tx_offload = { 18655 .f = cmd_config_per_port_tx_offload_parsed, 18656 .data = NULL, 18657 .help_str = "port config <port_id> tx_offload " 18658 "vlan_insert|ipv4_cksum|udp_cksum|tcp_cksum|" 18659 "sctp_cksum|tcp_tso|udp_tso|outer_ipv4_cksum|" 18660 "qinq_insert|vxlan_tnl_tso|gre_tnl_tso|" 18661 "ipip_tnl_tso|geneve_tnl_tso|macsec_insert|" 18662 "mt_lockfree|multi_segs|mbuf_fast_free|security|" 18663 "match_metadata on|off", 18664 .tokens = { 18665 (void *)&cmd_config_per_port_tx_offload_result_port, 18666 (void *)&cmd_config_per_port_tx_offload_result_config, 18667 (void *)&cmd_config_per_port_tx_offload_result_port_id, 18668 (void *)&cmd_config_per_port_tx_offload_result_tx_offload, 18669 (void *)&cmd_config_per_port_tx_offload_result_offload, 18670 (void *)&cmd_config_per_port_tx_offload_result_on_off, 18671 NULL, 18672 } 18673 }; 18674 18675 /* Enable/Disable a per queue offloading */ 18676 struct cmd_config_per_queue_tx_offload_result { 18677 cmdline_fixed_string_t port; 18678 portid_t port_id; 18679 cmdline_fixed_string_t txq; 18680 uint16_t queue_id; 18681 cmdline_fixed_string_t tx_offload; 18682 cmdline_fixed_string_t offload; 18683 cmdline_fixed_string_t on_off; 18684 }; 18685 18686 cmdline_parse_token_string_t cmd_config_per_queue_tx_offload_result_port = 18687 TOKEN_STRING_INITIALIZER 18688 (struct cmd_config_per_queue_tx_offload_result, 18689 port, "port"); 18690 cmdline_parse_token_num_t cmd_config_per_queue_tx_offload_result_port_id = 18691 TOKEN_NUM_INITIALIZER 18692 (struct cmd_config_per_queue_tx_offload_result, 18693 port_id, UINT16); 18694 cmdline_parse_token_string_t cmd_config_per_queue_tx_offload_result_txq = 18695 TOKEN_STRING_INITIALIZER 18696 (struct cmd_config_per_queue_tx_offload_result, 18697 txq, "txq"); 18698 cmdline_parse_token_num_t cmd_config_per_queue_tx_offload_result_queue_id = 18699 TOKEN_NUM_INITIALIZER 18700 (struct cmd_config_per_queue_tx_offload_result, 18701 queue_id, UINT16); 18702 cmdline_parse_token_string_t cmd_config_per_queue_tx_offload_result_txoffload = 18703 TOKEN_STRING_INITIALIZER 18704 (struct cmd_config_per_queue_tx_offload_result, 18705 tx_offload, "tx_offload"); 18706 cmdline_parse_token_string_t cmd_config_per_queue_tx_offload_result_offload = 18707 TOKEN_STRING_INITIALIZER 18708 (struct cmd_config_per_queue_tx_offload_result, 18709 offload, "vlan_insert#ipv4_cksum#udp_cksum#tcp_cksum#" 18710 "sctp_cksum#tcp_tso#udp_tso#outer_ipv4_cksum#" 18711 "qinq_insert#vxlan_tnl_tso#gre_tnl_tso#" 18712 "ipip_tnl_tso#geneve_tnl_tso#macsec_insert#" 18713 "mt_lockfree#multi_segs#mbuf_fast_free#security"); 18714 cmdline_parse_token_string_t cmd_config_per_queue_tx_offload_result_on_off = 18715 TOKEN_STRING_INITIALIZER 18716 (struct cmd_config_per_queue_tx_offload_result, 18717 on_off, "on#off"); 18718 18719 static void 18720 cmd_config_per_queue_tx_offload_parsed(void *parsed_result, 18721 __attribute__((unused)) struct cmdline *cl, 18722 __attribute__((unused)) void *data) 18723 { 18724 struct cmd_config_per_queue_tx_offload_result *res = parsed_result; 18725 struct rte_eth_dev_info dev_info; 18726 portid_t port_id = res->port_id; 18727 uint16_t queue_id = res->queue_id; 18728 struct rte_port *port = &ports[port_id]; 18729 uint64_t single_offload; 18730 int ret; 18731 18732 if (port->port_status != RTE_PORT_STOPPED) { 18733 printf("Error: Can't config offload when Port %d " 18734 "is not stopped\n", port_id); 18735 return; 18736 } 18737 18738 ret = eth_dev_info_get_print_err(port_id, &dev_info); 18739 if (ret != 0) 18740 return; 18741 18742 if (queue_id >= dev_info.nb_tx_queues) { 18743 printf("Error: input queue_id should be 0 ... " 18744 "%d\n", dev_info.nb_tx_queues - 1); 18745 return; 18746 } 18747 18748 single_offload = search_tx_offload(res->offload); 18749 if (single_offload == 0) { 18750 printf("Unknown offload name: %s\n", res->offload); 18751 return; 18752 } 18753 18754 if (!strcmp(res->on_off, "on")) 18755 port->tx_conf[queue_id].offloads |= single_offload; 18756 else 18757 port->tx_conf[queue_id].offloads &= ~single_offload; 18758 18759 cmd_reconfig_device_queue(port_id, 1, 1); 18760 } 18761 18762 cmdline_parse_inst_t cmd_config_per_queue_tx_offload = { 18763 .f = cmd_config_per_queue_tx_offload_parsed, 18764 .data = NULL, 18765 .help_str = "port <port_id> txq <queue_id> tx_offload " 18766 "vlan_insert|ipv4_cksum|udp_cksum|tcp_cksum|" 18767 "sctp_cksum|tcp_tso|udp_tso|outer_ipv4_cksum|" 18768 "qinq_insert|vxlan_tnl_tso|gre_tnl_tso|" 18769 "ipip_tnl_tso|geneve_tnl_tso|macsec_insert|" 18770 "mt_lockfree|multi_segs|mbuf_fast_free|security " 18771 "on|off", 18772 .tokens = { 18773 (void *)&cmd_config_per_queue_tx_offload_result_port, 18774 (void *)&cmd_config_per_queue_tx_offload_result_port_id, 18775 (void *)&cmd_config_per_queue_tx_offload_result_txq, 18776 (void *)&cmd_config_per_queue_tx_offload_result_queue_id, 18777 (void *)&cmd_config_per_queue_tx_offload_result_txoffload, 18778 (void *)&cmd_config_per_queue_tx_offload_result_offload, 18779 (void *)&cmd_config_per_queue_tx_offload_result_on_off, 18780 NULL, 18781 } 18782 }; 18783 18784 /* *** configure tx_metadata for specific port *** */ 18785 struct cmd_config_tx_metadata_specific_result { 18786 cmdline_fixed_string_t port; 18787 cmdline_fixed_string_t keyword; 18788 uint16_t port_id; 18789 cmdline_fixed_string_t item; 18790 uint32_t value; 18791 }; 18792 18793 static void 18794 cmd_config_tx_metadata_specific_parsed(void *parsed_result, 18795 __attribute__((unused)) struct cmdline *cl, 18796 __attribute__((unused)) void *data) 18797 { 18798 struct cmd_config_tx_metadata_specific_result *res = parsed_result; 18799 18800 if (port_id_is_invalid(res->port_id, ENABLED_WARN)) 18801 return; 18802 ports[res->port_id].tx_metadata = res->value; 18803 /* Add/remove callback to insert valid metadata in every Tx packet. */ 18804 if (ports[res->port_id].tx_metadata) 18805 add_tx_md_callback(res->port_id); 18806 else 18807 remove_tx_md_callback(res->port_id); 18808 rte_flow_dynf_metadata_register(); 18809 } 18810 18811 cmdline_parse_token_string_t cmd_config_tx_metadata_specific_port = 18812 TOKEN_STRING_INITIALIZER(struct cmd_config_tx_metadata_specific_result, 18813 port, "port"); 18814 cmdline_parse_token_string_t cmd_config_tx_metadata_specific_keyword = 18815 TOKEN_STRING_INITIALIZER(struct cmd_config_tx_metadata_specific_result, 18816 keyword, "config"); 18817 cmdline_parse_token_num_t cmd_config_tx_metadata_specific_id = 18818 TOKEN_NUM_INITIALIZER(struct cmd_config_tx_metadata_specific_result, 18819 port_id, UINT16); 18820 cmdline_parse_token_string_t cmd_config_tx_metadata_specific_item = 18821 TOKEN_STRING_INITIALIZER(struct cmd_config_tx_metadata_specific_result, 18822 item, "tx_metadata"); 18823 cmdline_parse_token_num_t cmd_config_tx_metadata_specific_value = 18824 TOKEN_NUM_INITIALIZER(struct cmd_config_tx_metadata_specific_result, 18825 value, UINT32); 18826 18827 cmdline_parse_inst_t cmd_config_tx_metadata_specific = { 18828 .f = cmd_config_tx_metadata_specific_parsed, 18829 .data = NULL, 18830 .help_str = "port config <port_id> tx_metadata <value>", 18831 .tokens = { 18832 (void *)&cmd_config_tx_metadata_specific_port, 18833 (void *)&cmd_config_tx_metadata_specific_keyword, 18834 (void *)&cmd_config_tx_metadata_specific_id, 18835 (void *)&cmd_config_tx_metadata_specific_item, 18836 (void *)&cmd_config_tx_metadata_specific_value, 18837 NULL, 18838 }, 18839 }; 18840 18841 /* *** display tx_metadata per port configuration *** */ 18842 struct cmd_show_tx_metadata_result { 18843 cmdline_fixed_string_t cmd_show; 18844 cmdline_fixed_string_t cmd_port; 18845 cmdline_fixed_string_t cmd_keyword; 18846 portid_t cmd_pid; 18847 }; 18848 18849 static void 18850 cmd_show_tx_metadata_parsed(void *parsed_result, 18851 __attribute__((unused)) struct cmdline *cl, 18852 __attribute__((unused)) void *data) 18853 { 18854 struct cmd_show_tx_metadata_result *res = parsed_result; 18855 18856 if (!rte_eth_dev_is_valid_port(res->cmd_pid)) { 18857 printf("invalid port id %u\n", res->cmd_pid); 18858 return; 18859 } 18860 if (!strcmp(res->cmd_keyword, "tx_metadata")) { 18861 printf("Port %u tx_metadata: %u\n", res->cmd_pid, 18862 rte_be_to_cpu_32(ports[res->cmd_pid].tx_metadata)); 18863 } 18864 } 18865 18866 cmdline_parse_token_string_t cmd_show_tx_metadata_show = 18867 TOKEN_STRING_INITIALIZER(struct cmd_show_tx_metadata_result, 18868 cmd_show, "show"); 18869 cmdline_parse_token_string_t cmd_show_tx_metadata_port = 18870 TOKEN_STRING_INITIALIZER(struct cmd_show_tx_metadata_result, 18871 cmd_port, "port"); 18872 cmdline_parse_token_num_t cmd_show_tx_metadata_pid = 18873 TOKEN_NUM_INITIALIZER(struct cmd_show_tx_metadata_result, 18874 cmd_pid, UINT16); 18875 cmdline_parse_token_string_t cmd_show_tx_metadata_keyword = 18876 TOKEN_STRING_INITIALIZER(struct cmd_show_tx_metadata_result, 18877 cmd_keyword, "tx_metadata"); 18878 18879 cmdline_parse_inst_t cmd_show_tx_metadata = { 18880 .f = cmd_show_tx_metadata_parsed, 18881 .data = NULL, 18882 .help_str = "show port <port_id> tx_metadata", 18883 .tokens = { 18884 (void *)&cmd_show_tx_metadata_show, 18885 (void *)&cmd_show_tx_metadata_port, 18886 (void *)&cmd_show_tx_metadata_pid, 18887 (void *)&cmd_show_tx_metadata_keyword, 18888 NULL, 18889 }, 18890 }; 18891 18892 /* show port supported ptypes */ 18893 18894 /* Common result structure for show port ptypes */ 18895 struct cmd_show_port_supported_ptypes_result { 18896 cmdline_fixed_string_t show; 18897 cmdline_fixed_string_t port; 18898 portid_t port_id; 18899 cmdline_fixed_string_t ptypes; 18900 }; 18901 18902 /* Common CLI fields for show port ptypes */ 18903 cmdline_parse_token_string_t cmd_show_port_supported_ptypes_show = 18904 TOKEN_STRING_INITIALIZER 18905 (struct cmd_show_port_supported_ptypes_result, 18906 show, "show"); 18907 cmdline_parse_token_string_t cmd_show_port_supported_ptypes_port = 18908 TOKEN_STRING_INITIALIZER 18909 (struct cmd_show_port_supported_ptypes_result, 18910 port, "port"); 18911 cmdline_parse_token_num_t cmd_show_port_supported_ptypes_port_id = 18912 TOKEN_NUM_INITIALIZER 18913 (struct cmd_show_port_supported_ptypes_result, 18914 port_id, UINT16); 18915 cmdline_parse_token_string_t cmd_show_port_supported_ptypes_ptypes = 18916 TOKEN_STRING_INITIALIZER 18917 (struct cmd_show_port_supported_ptypes_result, 18918 ptypes, "ptypes"); 18919 18920 static void 18921 cmd_show_port_supported_ptypes_parsed( 18922 void *parsed_result, 18923 __attribute__((unused)) struct cmdline *cl, 18924 __attribute__((unused)) void *data) 18925 { 18926 #define RSVD_PTYPE_MASK 0xf0000000 18927 #define MAX_PTYPES_PER_LAYER 16 18928 #define LTYPE_NAMESIZE 32 18929 #define PTYPE_NAMESIZE 256 18930 struct cmd_show_port_supported_ptypes_result *res = parsed_result; 18931 char buf[PTYPE_NAMESIZE], ltype[LTYPE_NAMESIZE]; 18932 uint32_t ptype_mask = RTE_PTYPE_L2_MASK; 18933 uint32_t ptypes[MAX_PTYPES_PER_LAYER]; 18934 uint16_t port_id = res->port_id; 18935 int ret, i; 18936 18937 ret = rte_eth_dev_get_supported_ptypes(port_id, ptype_mask, NULL, 0); 18938 if (ret < 0) 18939 return; 18940 18941 while (ptype_mask != RSVD_PTYPE_MASK) { 18942 18943 switch (ptype_mask) { 18944 case RTE_PTYPE_L2_MASK: 18945 strlcpy(ltype, "L2", sizeof(ltype)); 18946 break; 18947 case RTE_PTYPE_L3_MASK: 18948 strlcpy(ltype, "L3", sizeof(ltype)); 18949 break; 18950 case RTE_PTYPE_L4_MASK: 18951 strlcpy(ltype, "L4", sizeof(ltype)); 18952 break; 18953 case RTE_PTYPE_TUNNEL_MASK: 18954 strlcpy(ltype, "Tunnel", sizeof(ltype)); 18955 break; 18956 case RTE_PTYPE_INNER_L2_MASK: 18957 strlcpy(ltype, "Inner L2", sizeof(ltype)); 18958 break; 18959 case RTE_PTYPE_INNER_L3_MASK: 18960 strlcpy(ltype, "Inner L3", sizeof(ltype)); 18961 break; 18962 case RTE_PTYPE_INNER_L4_MASK: 18963 strlcpy(ltype, "Inner L4", sizeof(ltype)); 18964 break; 18965 default: 18966 return; 18967 } 18968 18969 ret = rte_eth_dev_get_supported_ptypes(res->port_id, 18970 ptype_mask, ptypes, 18971 MAX_PTYPES_PER_LAYER); 18972 18973 if (ret > 0) 18974 printf("Supported %s ptypes:\n", ltype); 18975 else 18976 printf("%s ptypes unsupported\n", ltype); 18977 18978 for (i = 0; i < ret; ++i) { 18979 rte_get_ptype_name(ptypes[i], buf, sizeof(buf)); 18980 printf("%s\n", buf); 18981 } 18982 18983 ptype_mask <<= 4; 18984 } 18985 } 18986 18987 cmdline_parse_inst_t cmd_show_port_supported_ptypes = { 18988 .f = cmd_show_port_supported_ptypes_parsed, 18989 .data = NULL, 18990 .help_str = "show port <port_id> ptypes", 18991 .tokens = { 18992 (void *)&cmd_show_port_supported_ptypes_show, 18993 (void *)&cmd_show_port_supported_ptypes_port, 18994 (void *)&cmd_show_port_supported_ptypes_port_id, 18995 (void *)&cmd_show_port_supported_ptypes_ptypes, 18996 NULL, 18997 }, 18998 }; 18999 19000 /* *** display rx/tx descriptor status *** */ 19001 struct cmd_show_rx_tx_desc_status_result { 19002 cmdline_fixed_string_t cmd_show; 19003 cmdline_fixed_string_t cmd_port; 19004 cmdline_fixed_string_t cmd_keyword; 19005 cmdline_fixed_string_t cmd_desc; 19006 cmdline_fixed_string_t cmd_status; 19007 portid_t cmd_pid; 19008 portid_t cmd_qid; 19009 portid_t cmd_did; 19010 }; 19011 19012 static void 19013 cmd_show_rx_tx_desc_status_parsed(void *parsed_result, 19014 __attribute__((unused)) struct cmdline *cl, 19015 __attribute__((unused)) void *data) 19016 { 19017 struct cmd_show_rx_tx_desc_status_result *res = parsed_result; 19018 int rc; 19019 19020 if (!rte_eth_dev_is_valid_port(res->cmd_pid)) { 19021 printf("invalid port id %u\n", res->cmd_pid); 19022 return; 19023 } 19024 19025 if (!strcmp(res->cmd_keyword, "rxq")) { 19026 rc = rte_eth_rx_descriptor_status(res->cmd_pid, res->cmd_qid, 19027 res->cmd_did); 19028 if (rc < 0) { 19029 printf("Invalid queueid = %d\n", res->cmd_qid); 19030 return; 19031 } 19032 if (rc == RTE_ETH_RX_DESC_AVAIL) 19033 printf("Desc status = AVAILABLE\n"); 19034 else if (rc == RTE_ETH_RX_DESC_DONE) 19035 printf("Desc status = DONE\n"); 19036 else 19037 printf("Desc status = UNAVAILABLE\n"); 19038 } else if (!strcmp(res->cmd_keyword, "txq")) { 19039 rc = rte_eth_tx_descriptor_status(res->cmd_pid, res->cmd_qid, 19040 res->cmd_did); 19041 if (rc < 0) { 19042 printf("Invalid queueid = %d\n", res->cmd_qid); 19043 return; 19044 } 19045 if (rc == RTE_ETH_TX_DESC_FULL) 19046 printf("Desc status = FULL\n"); 19047 else if (rc == RTE_ETH_TX_DESC_DONE) 19048 printf("Desc status = DONE\n"); 19049 else 19050 printf("Desc status = UNAVAILABLE\n"); 19051 } 19052 } 19053 19054 cmdline_parse_token_string_t cmd_show_rx_tx_desc_status_show = 19055 TOKEN_STRING_INITIALIZER(struct cmd_show_rx_tx_desc_status_result, 19056 cmd_show, "show"); 19057 cmdline_parse_token_string_t cmd_show_rx_tx_desc_status_port = 19058 TOKEN_STRING_INITIALIZER(struct cmd_show_rx_tx_desc_status_result, 19059 cmd_port, "port"); 19060 cmdline_parse_token_num_t cmd_show_rx_tx_desc_status_pid = 19061 TOKEN_NUM_INITIALIZER(struct cmd_show_rx_tx_desc_status_result, 19062 cmd_pid, UINT16); 19063 cmdline_parse_token_string_t cmd_show_rx_tx_desc_status_keyword = 19064 TOKEN_STRING_INITIALIZER(struct cmd_show_rx_tx_desc_status_result, 19065 cmd_keyword, "rxq#txq"); 19066 cmdline_parse_token_num_t cmd_show_rx_tx_desc_status_qid = 19067 TOKEN_NUM_INITIALIZER(struct cmd_show_rx_tx_desc_status_result, 19068 cmd_qid, UINT16); 19069 cmdline_parse_token_string_t cmd_show_rx_tx_desc_status_desc = 19070 TOKEN_STRING_INITIALIZER(struct cmd_show_rx_tx_desc_status_result, 19071 cmd_desc, "desc"); 19072 cmdline_parse_token_num_t cmd_show_rx_tx_desc_status_did = 19073 TOKEN_NUM_INITIALIZER(struct cmd_show_rx_tx_desc_status_result, 19074 cmd_did, UINT16); 19075 cmdline_parse_token_string_t cmd_show_rx_tx_desc_status_status = 19076 TOKEN_STRING_INITIALIZER(struct cmd_show_rx_tx_desc_status_result, 19077 cmd_status, "status"); 19078 cmdline_parse_inst_t cmd_show_rx_tx_desc_status = { 19079 .f = cmd_show_rx_tx_desc_status_parsed, 19080 .data = NULL, 19081 .help_str = "show port <port_id> rxq|txq <queue_id> desc <desc_id> " 19082 "status", 19083 .tokens = { 19084 (void *)&cmd_show_rx_tx_desc_status_show, 19085 (void *)&cmd_show_rx_tx_desc_status_port, 19086 (void *)&cmd_show_rx_tx_desc_status_pid, 19087 (void *)&cmd_show_rx_tx_desc_status_keyword, 19088 (void *)&cmd_show_rx_tx_desc_status_qid, 19089 (void *)&cmd_show_rx_tx_desc_status_desc, 19090 (void *)&cmd_show_rx_tx_desc_status_did, 19091 (void *)&cmd_show_rx_tx_desc_status_status, 19092 NULL, 19093 }, 19094 }; 19095 19096 /* Common result structure for set port ptypes */ 19097 struct cmd_set_port_ptypes_result { 19098 cmdline_fixed_string_t set; 19099 cmdline_fixed_string_t port; 19100 portid_t port_id; 19101 cmdline_fixed_string_t ptype_mask; 19102 uint32_t mask; 19103 }; 19104 19105 /* Common CLI fields for set port ptypes */ 19106 cmdline_parse_token_string_t cmd_set_port_ptypes_set = 19107 TOKEN_STRING_INITIALIZER 19108 (struct cmd_set_port_ptypes_result, 19109 set, "set"); 19110 cmdline_parse_token_string_t cmd_set_port_ptypes_port = 19111 TOKEN_STRING_INITIALIZER 19112 (struct cmd_set_port_ptypes_result, 19113 port, "port"); 19114 cmdline_parse_token_num_t cmd_set_port_ptypes_port_id = 19115 TOKEN_NUM_INITIALIZER 19116 (struct cmd_set_port_ptypes_result, 19117 port_id, UINT16); 19118 cmdline_parse_token_string_t cmd_set_port_ptypes_mask_str = 19119 TOKEN_STRING_INITIALIZER 19120 (struct cmd_set_port_ptypes_result, 19121 ptype_mask, "ptype_mask"); 19122 cmdline_parse_token_num_t cmd_set_port_ptypes_mask_u32 = 19123 TOKEN_NUM_INITIALIZER 19124 (struct cmd_set_port_ptypes_result, 19125 mask, UINT32); 19126 19127 static void 19128 cmd_set_port_ptypes_parsed( 19129 void *parsed_result, 19130 __attribute__((unused)) struct cmdline *cl, 19131 __attribute__((unused)) void *data) 19132 { 19133 struct cmd_set_port_ptypes_result *res = parsed_result; 19134 #define PTYPE_NAMESIZE 256 19135 char ptype_name[PTYPE_NAMESIZE]; 19136 uint16_t port_id = res->port_id; 19137 uint32_t ptype_mask = res->mask; 19138 int ret, i; 19139 19140 ret = rte_eth_dev_get_supported_ptypes(port_id, RTE_PTYPE_ALL_MASK, 19141 NULL, 0); 19142 if (ret <= 0) { 19143 printf("Port %d doesn't support any ptypes.\n", port_id); 19144 return; 19145 } 19146 19147 uint32_t ptypes[ret]; 19148 19149 ret = rte_eth_dev_set_ptypes(port_id, ptype_mask, ptypes, ret); 19150 if (ret < 0) { 19151 printf("Unable to set requested ptypes for Port %d\n", port_id); 19152 return; 19153 } 19154 19155 printf("Successfully set following ptypes for Port %d\n", port_id); 19156 for (i = 0; i < ret && ptypes[i] != RTE_PTYPE_UNKNOWN; i++) { 19157 rte_get_ptype_name(ptypes[i], ptype_name, sizeof(ptype_name)); 19158 printf("%s\n", ptype_name); 19159 } 19160 19161 clear_ptypes = false; 19162 } 19163 19164 cmdline_parse_inst_t cmd_set_port_ptypes = { 19165 .f = cmd_set_port_ptypes_parsed, 19166 .data = NULL, 19167 .help_str = "set port <port_id> ptype_mask <mask>", 19168 .tokens = { 19169 (void *)&cmd_set_port_ptypes_set, 19170 (void *)&cmd_set_port_ptypes_port, 19171 (void *)&cmd_set_port_ptypes_port_id, 19172 (void *)&cmd_set_port_ptypes_mask_str, 19173 (void *)&cmd_set_port_ptypes_mask_u32, 19174 NULL, 19175 }, 19176 }; 19177 19178 /* ******************************************************************************** */ 19179 19180 /* list of instructions */ 19181 cmdline_parse_ctx_t main_ctx[] = { 19182 (cmdline_parse_inst_t *)&cmd_help_brief, 19183 (cmdline_parse_inst_t *)&cmd_help_long, 19184 (cmdline_parse_inst_t *)&cmd_quit, 19185 (cmdline_parse_inst_t *)&cmd_load_from_file, 19186 (cmdline_parse_inst_t *)&cmd_showport, 19187 (cmdline_parse_inst_t *)&cmd_showqueue, 19188 (cmdline_parse_inst_t *)&cmd_showportall, 19189 (cmdline_parse_inst_t *)&cmd_showdevice, 19190 (cmdline_parse_inst_t *)&cmd_showcfg, 19191 (cmdline_parse_inst_t *)&cmd_showfwdall, 19192 (cmdline_parse_inst_t *)&cmd_start, 19193 (cmdline_parse_inst_t *)&cmd_start_tx_first, 19194 (cmdline_parse_inst_t *)&cmd_start_tx_first_n, 19195 (cmdline_parse_inst_t *)&cmd_set_link_up, 19196 (cmdline_parse_inst_t *)&cmd_set_link_down, 19197 (cmdline_parse_inst_t *)&cmd_reset, 19198 (cmdline_parse_inst_t *)&cmd_set_numbers, 19199 (cmdline_parse_inst_t *)&cmd_set_log, 19200 (cmdline_parse_inst_t *)&cmd_set_txpkts, 19201 (cmdline_parse_inst_t *)&cmd_set_txsplit, 19202 (cmdline_parse_inst_t *)&cmd_set_fwd_list, 19203 (cmdline_parse_inst_t *)&cmd_set_fwd_mask, 19204 (cmdline_parse_inst_t *)&cmd_set_fwd_mode, 19205 (cmdline_parse_inst_t *)&cmd_set_fwd_retry_mode, 19206 (cmdline_parse_inst_t *)&cmd_set_burst_tx_retry, 19207 (cmdline_parse_inst_t *)&cmd_set_promisc_mode_one, 19208 (cmdline_parse_inst_t *)&cmd_set_promisc_mode_all, 19209 (cmdline_parse_inst_t *)&cmd_set_allmulti_mode_one, 19210 (cmdline_parse_inst_t *)&cmd_set_allmulti_mode_all, 19211 (cmdline_parse_inst_t *)&cmd_set_flush_rx, 19212 (cmdline_parse_inst_t *)&cmd_set_link_check, 19213 (cmdline_parse_inst_t *)&cmd_set_bypass_mode, 19214 (cmdline_parse_inst_t *)&cmd_set_bypass_event, 19215 (cmdline_parse_inst_t *)&cmd_set_bypass_timeout, 19216 (cmdline_parse_inst_t *)&cmd_show_bypass_config, 19217 #ifdef RTE_LIBRTE_PMD_BOND 19218 (cmdline_parse_inst_t *) &cmd_set_bonding_mode, 19219 (cmdline_parse_inst_t *) &cmd_show_bonding_config, 19220 (cmdline_parse_inst_t *) &cmd_set_bonding_primary, 19221 (cmdline_parse_inst_t *) &cmd_add_bonding_slave, 19222 (cmdline_parse_inst_t *) &cmd_remove_bonding_slave, 19223 (cmdline_parse_inst_t *) &cmd_create_bonded_device, 19224 (cmdline_parse_inst_t *) &cmd_set_bond_mac_addr, 19225 (cmdline_parse_inst_t *) &cmd_set_balance_xmit_policy, 19226 (cmdline_parse_inst_t *) &cmd_set_bond_mon_period, 19227 (cmdline_parse_inst_t *) &cmd_set_lacp_dedicated_queues, 19228 (cmdline_parse_inst_t *) &cmd_set_bonding_agg_mode_policy, 19229 #endif 19230 (cmdline_parse_inst_t *)&cmd_vlan_offload, 19231 (cmdline_parse_inst_t *)&cmd_vlan_tpid, 19232 (cmdline_parse_inst_t *)&cmd_rx_vlan_filter_all, 19233 (cmdline_parse_inst_t *)&cmd_rx_vlan_filter, 19234 (cmdline_parse_inst_t *)&cmd_tx_vlan_set, 19235 (cmdline_parse_inst_t *)&cmd_tx_vlan_set_qinq, 19236 (cmdline_parse_inst_t *)&cmd_tx_vlan_reset, 19237 (cmdline_parse_inst_t *)&cmd_tx_vlan_set_pvid, 19238 (cmdline_parse_inst_t *)&cmd_csum_set, 19239 (cmdline_parse_inst_t *)&cmd_csum_show, 19240 (cmdline_parse_inst_t *)&cmd_csum_tunnel, 19241 (cmdline_parse_inst_t *)&cmd_tso_set, 19242 (cmdline_parse_inst_t *)&cmd_tso_show, 19243 (cmdline_parse_inst_t *)&cmd_tunnel_tso_set, 19244 (cmdline_parse_inst_t *)&cmd_tunnel_tso_show, 19245 (cmdline_parse_inst_t *)&cmd_gro_enable, 19246 (cmdline_parse_inst_t *)&cmd_gro_flush, 19247 (cmdline_parse_inst_t *)&cmd_gro_show, 19248 (cmdline_parse_inst_t *)&cmd_gso_enable, 19249 (cmdline_parse_inst_t *)&cmd_gso_size, 19250 (cmdline_parse_inst_t *)&cmd_gso_show, 19251 (cmdline_parse_inst_t *)&cmd_link_flow_control_set, 19252 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_rx, 19253 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_tx, 19254 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_hw, 19255 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_lw, 19256 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_pt, 19257 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_xon, 19258 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_macfwd, 19259 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_autoneg, 19260 (cmdline_parse_inst_t *)&cmd_priority_flow_control_set, 19261 (cmdline_parse_inst_t *)&cmd_config_dcb, 19262 (cmdline_parse_inst_t *)&cmd_read_reg, 19263 (cmdline_parse_inst_t *)&cmd_read_reg_bit_field, 19264 (cmdline_parse_inst_t *)&cmd_read_reg_bit, 19265 (cmdline_parse_inst_t *)&cmd_write_reg, 19266 (cmdline_parse_inst_t *)&cmd_write_reg_bit_field, 19267 (cmdline_parse_inst_t *)&cmd_write_reg_bit, 19268 (cmdline_parse_inst_t *)&cmd_read_rxd_txd, 19269 (cmdline_parse_inst_t *)&cmd_stop, 19270 (cmdline_parse_inst_t *)&cmd_mac_addr, 19271 (cmdline_parse_inst_t *)&cmd_set_fwd_eth_peer, 19272 (cmdline_parse_inst_t *)&cmd_set_qmap, 19273 (cmdline_parse_inst_t *)&cmd_set_xstats_hide_zero, 19274 (cmdline_parse_inst_t *)&cmd_operate_port, 19275 (cmdline_parse_inst_t *)&cmd_operate_specific_port, 19276 (cmdline_parse_inst_t *)&cmd_operate_attach_port, 19277 (cmdline_parse_inst_t *)&cmd_operate_detach_port, 19278 (cmdline_parse_inst_t *)&cmd_operate_detach_device, 19279 (cmdline_parse_inst_t *)&cmd_set_port_setup_on, 19280 (cmdline_parse_inst_t *)&cmd_config_speed_all, 19281 (cmdline_parse_inst_t *)&cmd_config_speed_specific, 19282 (cmdline_parse_inst_t *)&cmd_config_loopback_all, 19283 (cmdline_parse_inst_t *)&cmd_config_loopback_specific, 19284 (cmdline_parse_inst_t *)&cmd_config_rx_tx, 19285 (cmdline_parse_inst_t *)&cmd_config_mtu, 19286 (cmdline_parse_inst_t *)&cmd_config_max_pkt_len, 19287 (cmdline_parse_inst_t *)&cmd_config_max_lro_pkt_size, 19288 (cmdline_parse_inst_t *)&cmd_config_rx_mode_flag, 19289 (cmdline_parse_inst_t *)&cmd_config_rss, 19290 (cmdline_parse_inst_t *)&cmd_config_rxtx_ring_size, 19291 (cmdline_parse_inst_t *)&cmd_config_rxtx_queue, 19292 (cmdline_parse_inst_t *)&cmd_config_deferred_start_rxtx_queue, 19293 (cmdline_parse_inst_t *)&cmd_setup_rxtx_queue, 19294 (cmdline_parse_inst_t *)&cmd_config_rss_reta, 19295 (cmdline_parse_inst_t *)&cmd_showport_reta, 19296 (cmdline_parse_inst_t *)&cmd_config_burst, 19297 (cmdline_parse_inst_t *)&cmd_config_thresh, 19298 (cmdline_parse_inst_t *)&cmd_config_threshold, 19299 (cmdline_parse_inst_t *)&cmd_set_uc_hash_filter, 19300 (cmdline_parse_inst_t *)&cmd_set_uc_all_hash_filter, 19301 (cmdline_parse_inst_t *)&cmd_vf_mac_addr_filter, 19302 (cmdline_parse_inst_t *)&cmd_set_vf_macvlan_filter, 19303 (cmdline_parse_inst_t *)&cmd_queue_rate_limit, 19304 (cmdline_parse_inst_t *)&cmd_tunnel_filter, 19305 (cmdline_parse_inst_t *)&cmd_tunnel_udp_config, 19306 (cmdline_parse_inst_t *)&cmd_global_config, 19307 (cmdline_parse_inst_t *)&cmd_set_mirror_mask, 19308 (cmdline_parse_inst_t *)&cmd_set_mirror_link, 19309 (cmdline_parse_inst_t *)&cmd_reset_mirror_rule, 19310 (cmdline_parse_inst_t *)&cmd_showport_rss_hash, 19311 (cmdline_parse_inst_t *)&cmd_showport_rss_hash_key, 19312 (cmdline_parse_inst_t *)&cmd_config_rss_hash_key, 19313 (cmdline_parse_inst_t *)&cmd_dump, 19314 (cmdline_parse_inst_t *)&cmd_dump_one, 19315 (cmdline_parse_inst_t *)&cmd_ethertype_filter, 19316 (cmdline_parse_inst_t *)&cmd_syn_filter, 19317 (cmdline_parse_inst_t *)&cmd_2tuple_filter, 19318 (cmdline_parse_inst_t *)&cmd_5tuple_filter, 19319 (cmdline_parse_inst_t *)&cmd_flex_filter, 19320 (cmdline_parse_inst_t *)&cmd_add_del_ip_flow_director, 19321 (cmdline_parse_inst_t *)&cmd_add_del_udp_flow_director, 19322 (cmdline_parse_inst_t *)&cmd_add_del_sctp_flow_director, 19323 (cmdline_parse_inst_t *)&cmd_add_del_l2_flow_director, 19324 (cmdline_parse_inst_t *)&cmd_add_del_mac_vlan_flow_director, 19325 (cmdline_parse_inst_t *)&cmd_add_del_tunnel_flow_director, 19326 (cmdline_parse_inst_t *)&cmd_add_del_raw_flow_director, 19327 (cmdline_parse_inst_t *)&cmd_flush_flow_director, 19328 (cmdline_parse_inst_t *)&cmd_set_flow_director_ip_mask, 19329 (cmdline_parse_inst_t *)&cmd_set_flow_director_mac_vlan_mask, 19330 (cmdline_parse_inst_t *)&cmd_set_flow_director_tunnel_mask, 19331 (cmdline_parse_inst_t *)&cmd_set_flow_director_flex_mask, 19332 (cmdline_parse_inst_t *)&cmd_set_flow_director_flex_payload, 19333 (cmdline_parse_inst_t *)&cmd_get_sym_hash_ena_per_port, 19334 (cmdline_parse_inst_t *)&cmd_set_sym_hash_ena_per_port, 19335 (cmdline_parse_inst_t *)&cmd_get_hash_global_config, 19336 (cmdline_parse_inst_t *)&cmd_set_hash_global_config, 19337 (cmdline_parse_inst_t *)&cmd_set_hash_input_set, 19338 (cmdline_parse_inst_t *)&cmd_set_fdir_input_set, 19339 (cmdline_parse_inst_t *)&cmd_flow, 19340 (cmdline_parse_inst_t *)&cmd_show_port_meter_cap, 19341 (cmdline_parse_inst_t *)&cmd_add_port_meter_profile_srtcm, 19342 (cmdline_parse_inst_t *)&cmd_add_port_meter_profile_trtcm, 19343 (cmdline_parse_inst_t *)&cmd_del_port_meter_profile, 19344 (cmdline_parse_inst_t *)&cmd_create_port_meter, 19345 (cmdline_parse_inst_t *)&cmd_enable_port_meter, 19346 (cmdline_parse_inst_t *)&cmd_disable_port_meter, 19347 (cmdline_parse_inst_t *)&cmd_del_port_meter, 19348 (cmdline_parse_inst_t *)&cmd_set_port_meter_profile, 19349 (cmdline_parse_inst_t *)&cmd_set_port_meter_dscp_table, 19350 (cmdline_parse_inst_t *)&cmd_set_port_meter_policer_action, 19351 (cmdline_parse_inst_t *)&cmd_set_port_meter_stats_mask, 19352 (cmdline_parse_inst_t *)&cmd_show_port_meter_stats, 19353 (cmdline_parse_inst_t *)&cmd_mcast_addr, 19354 (cmdline_parse_inst_t *)&cmd_config_l2_tunnel_eth_type_all, 19355 (cmdline_parse_inst_t *)&cmd_config_l2_tunnel_eth_type_specific, 19356 (cmdline_parse_inst_t *)&cmd_config_l2_tunnel_en_dis_all, 19357 (cmdline_parse_inst_t *)&cmd_config_l2_tunnel_en_dis_specific, 19358 (cmdline_parse_inst_t *)&cmd_config_e_tag_insertion_en, 19359 (cmdline_parse_inst_t *)&cmd_config_e_tag_insertion_dis, 19360 (cmdline_parse_inst_t *)&cmd_config_e_tag_stripping_en_dis, 19361 (cmdline_parse_inst_t *)&cmd_config_e_tag_forwarding_en_dis, 19362 (cmdline_parse_inst_t *)&cmd_config_e_tag_filter_add, 19363 (cmdline_parse_inst_t *)&cmd_config_e_tag_filter_del, 19364 (cmdline_parse_inst_t *)&cmd_set_vf_vlan_anti_spoof, 19365 (cmdline_parse_inst_t *)&cmd_set_vf_mac_anti_spoof, 19366 (cmdline_parse_inst_t *)&cmd_set_vf_vlan_stripq, 19367 (cmdline_parse_inst_t *)&cmd_set_vf_vlan_insert, 19368 (cmdline_parse_inst_t *)&cmd_set_tx_loopback, 19369 (cmdline_parse_inst_t *)&cmd_set_all_queues_drop_en, 19370 (cmdline_parse_inst_t *)&cmd_set_vf_split_drop_en, 19371 (cmdline_parse_inst_t *)&cmd_set_macsec_offload_on, 19372 (cmdline_parse_inst_t *)&cmd_set_macsec_offload_off, 19373 (cmdline_parse_inst_t *)&cmd_set_macsec_sc, 19374 (cmdline_parse_inst_t *)&cmd_set_macsec_sa, 19375 (cmdline_parse_inst_t *)&cmd_set_vf_traffic, 19376 (cmdline_parse_inst_t *)&cmd_set_vf_rxmode, 19377 (cmdline_parse_inst_t *)&cmd_vf_rate_limit, 19378 (cmdline_parse_inst_t *)&cmd_vf_rxvlan_filter, 19379 (cmdline_parse_inst_t *)&cmd_set_vf_mac_addr, 19380 (cmdline_parse_inst_t *)&cmd_set_vf_promisc, 19381 (cmdline_parse_inst_t *)&cmd_set_vf_allmulti, 19382 (cmdline_parse_inst_t *)&cmd_set_vf_broadcast, 19383 (cmdline_parse_inst_t *)&cmd_set_vf_vlan_tag, 19384 (cmdline_parse_inst_t *)&cmd_vf_max_bw, 19385 (cmdline_parse_inst_t *)&cmd_vf_tc_min_bw, 19386 (cmdline_parse_inst_t *)&cmd_vf_tc_max_bw, 19387 (cmdline_parse_inst_t *)&cmd_strict_link_prio, 19388 (cmdline_parse_inst_t *)&cmd_tc_min_bw, 19389 #if defined RTE_LIBRTE_PMD_SOFTNIC && defined RTE_LIBRTE_SCHED 19390 (cmdline_parse_inst_t *)&cmd_set_port_tm_hierarchy_default, 19391 #endif 19392 (cmdline_parse_inst_t *)&cmd_set_vxlan, 19393 (cmdline_parse_inst_t *)&cmd_set_vxlan_tos_ttl, 19394 (cmdline_parse_inst_t *)&cmd_set_vxlan_with_vlan, 19395 (cmdline_parse_inst_t *)&cmd_set_nvgre, 19396 (cmdline_parse_inst_t *)&cmd_set_nvgre_with_vlan, 19397 (cmdline_parse_inst_t *)&cmd_set_l2_encap, 19398 (cmdline_parse_inst_t *)&cmd_set_l2_encap_with_vlan, 19399 (cmdline_parse_inst_t *)&cmd_set_l2_decap, 19400 (cmdline_parse_inst_t *)&cmd_set_l2_decap_with_vlan, 19401 (cmdline_parse_inst_t *)&cmd_set_mplsogre_encap, 19402 (cmdline_parse_inst_t *)&cmd_set_mplsogre_encap_with_vlan, 19403 (cmdline_parse_inst_t *)&cmd_set_mplsogre_decap, 19404 (cmdline_parse_inst_t *)&cmd_set_mplsogre_decap_with_vlan, 19405 (cmdline_parse_inst_t *)&cmd_set_mplsoudp_encap, 19406 (cmdline_parse_inst_t *)&cmd_set_mplsoudp_encap_with_vlan, 19407 (cmdline_parse_inst_t *)&cmd_set_mplsoudp_decap, 19408 (cmdline_parse_inst_t *)&cmd_set_mplsoudp_decap_with_vlan, 19409 (cmdline_parse_inst_t *)&cmd_ddp_add, 19410 (cmdline_parse_inst_t *)&cmd_ddp_del, 19411 (cmdline_parse_inst_t *)&cmd_ddp_get_list, 19412 (cmdline_parse_inst_t *)&cmd_ddp_get_info, 19413 (cmdline_parse_inst_t *)&cmd_cfg_input_set, 19414 (cmdline_parse_inst_t *)&cmd_clear_input_set, 19415 (cmdline_parse_inst_t *)&cmd_show_vf_stats, 19416 (cmdline_parse_inst_t *)&cmd_clear_vf_stats, 19417 (cmdline_parse_inst_t *)&cmd_show_port_supported_ptypes, 19418 (cmdline_parse_inst_t *)&cmd_set_port_ptypes, 19419 (cmdline_parse_inst_t *)&cmd_ptype_mapping_get, 19420 (cmdline_parse_inst_t *)&cmd_ptype_mapping_replace, 19421 (cmdline_parse_inst_t *)&cmd_ptype_mapping_reset, 19422 (cmdline_parse_inst_t *)&cmd_ptype_mapping_update, 19423 19424 (cmdline_parse_inst_t *)&cmd_pctype_mapping_get, 19425 (cmdline_parse_inst_t *)&cmd_pctype_mapping_reset, 19426 (cmdline_parse_inst_t *)&cmd_pctype_mapping_update, 19427 (cmdline_parse_inst_t *)&cmd_queue_region, 19428 (cmdline_parse_inst_t *)&cmd_region_flowtype, 19429 (cmdline_parse_inst_t *)&cmd_user_priority_region, 19430 (cmdline_parse_inst_t *)&cmd_flush_queue_region, 19431 (cmdline_parse_inst_t *)&cmd_show_queue_region_info_all, 19432 (cmdline_parse_inst_t *)&cmd_show_port_tm_cap, 19433 (cmdline_parse_inst_t *)&cmd_show_port_tm_level_cap, 19434 (cmdline_parse_inst_t *)&cmd_show_port_tm_node_cap, 19435 (cmdline_parse_inst_t *)&cmd_show_port_tm_node_type, 19436 (cmdline_parse_inst_t *)&cmd_show_port_tm_node_stats, 19437 (cmdline_parse_inst_t *)&cmd_add_port_tm_node_shaper_profile, 19438 (cmdline_parse_inst_t *)&cmd_del_port_tm_node_shaper_profile, 19439 (cmdline_parse_inst_t *)&cmd_add_port_tm_node_shared_shaper, 19440 (cmdline_parse_inst_t *)&cmd_del_port_tm_node_shared_shaper, 19441 (cmdline_parse_inst_t *)&cmd_add_port_tm_node_wred_profile, 19442 (cmdline_parse_inst_t *)&cmd_del_port_tm_node_wred_profile, 19443 (cmdline_parse_inst_t *)&cmd_set_port_tm_node_shaper_profile, 19444 (cmdline_parse_inst_t *)&cmd_add_port_tm_nonleaf_node, 19445 (cmdline_parse_inst_t *)&cmd_add_port_tm_leaf_node, 19446 (cmdline_parse_inst_t *)&cmd_del_port_tm_node, 19447 (cmdline_parse_inst_t *)&cmd_set_port_tm_node_parent, 19448 (cmdline_parse_inst_t *)&cmd_suspend_port_tm_node, 19449 (cmdline_parse_inst_t *)&cmd_resume_port_tm_node, 19450 (cmdline_parse_inst_t *)&cmd_port_tm_hierarchy_commit, 19451 (cmdline_parse_inst_t *)&cmd_port_tm_mark_ip_ecn, 19452 (cmdline_parse_inst_t *)&cmd_port_tm_mark_ip_dscp, 19453 (cmdline_parse_inst_t *)&cmd_port_tm_mark_vlan_dei, 19454 (cmdline_parse_inst_t *)&cmd_cfg_tunnel_udp_port, 19455 (cmdline_parse_inst_t *)&cmd_rx_offload_get_capa, 19456 (cmdline_parse_inst_t *)&cmd_rx_offload_get_configuration, 19457 (cmdline_parse_inst_t *)&cmd_config_per_port_rx_offload, 19458 (cmdline_parse_inst_t *)&cmd_config_per_queue_rx_offload, 19459 (cmdline_parse_inst_t *)&cmd_tx_offload_get_capa, 19460 (cmdline_parse_inst_t *)&cmd_tx_offload_get_configuration, 19461 (cmdline_parse_inst_t *)&cmd_config_per_port_tx_offload, 19462 (cmdline_parse_inst_t *)&cmd_config_per_queue_tx_offload, 19463 #ifdef RTE_LIBRTE_BPF 19464 (cmdline_parse_inst_t *)&cmd_operate_bpf_ld_parse, 19465 (cmdline_parse_inst_t *)&cmd_operate_bpf_unld_parse, 19466 #endif 19467 (cmdline_parse_inst_t *)&cmd_config_tx_metadata_specific, 19468 (cmdline_parse_inst_t *)&cmd_show_tx_metadata, 19469 (cmdline_parse_inst_t *)&cmd_show_rx_tx_desc_status, 19470 (cmdline_parse_inst_t *)&cmd_set_raw, 19471 (cmdline_parse_inst_t *)&cmd_show_set_raw, 19472 (cmdline_parse_inst_t *)&cmd_show_set_raw_all, 19473 NULL, 19474 }; 19475 19476 /* read cmdline commands from file */ 19477 void 19478 cmdline_read_from_file(const char *filename) 19479 { 19480 struct cmdline *cl; 19481 19482 cl = cmdline_file_new(main_ctx, "testpmd> ", filename); 19483 if (cl == NULL) { 19484 printf("Failed to create file based cmdline context: %s\n", 19485 filename); 19486 return; 19487 } 19488 19489 cmdline_interact(cl); 19490 cmdline_quit(cl); 19491 19492 cmdline_free(cl); 19493 19494 printf("Read CLI commands from %s\n", filename); 19495 } 19496 19497 /* prompt function, called from main on MASTER lcore */ 19498 void 19499 prompt(void) 19500 { 19501 /* initialize non-constant commands */ 19502 cmd_set_fwd_mode_init(); 19503 cmd_set_fwd_retry_mode_init(); 19504 19505 testpmd_cl = cmdline_stdin_new(main_ctx, "testpmd> "); 19506 if (testpmd_cl == NULL) 19507 return; 19508 cmdline_interact(testpmd_cl); 19509 cmdline_stdin_exit(testpmd_cl); 19510 } 19511 19512 void 19513 prompt_exit(void) 19514 { 19515 if (testpmd_cl != NULL) 19516 cmdline_quit(testpmd_cl); 19517 } 19518 19519 static void 19520 cmd_reconfig_device_queue(portid_t id, uint8_t dev, uint8_t queue) 19521 { 19522 if (id == (portid_t)RTE_PORT_ALL) { 19523 portid_t pid; 19524 19525 RTE_ETH_FOREACH_DEV(pid) { 19526 /* check if need_reconfig has been set to 1 */ 19527 if (ports[pid].need_reconfig == 0) 19528 ports[pid].need_reconfig = dev; 19529 /* check if need_reconfig_queues has been set to 1 */ 19530 if (ports[pid].need_reconfig_queues == 0) 19531 ports[pid].need_reconfig_queues = queue; 19532 } 19533 } else if (!port_id_is_invalid(id, DISABLED_WARN)) { 19534 /* check if need_reconfig has been set to 1 */ 19535 if (ports[id].need_reconfig == 0) 19536 ports[id].need_reconfig = dev; 19537 /* check if need_reconfig_queues has been set to 1 */ 19538 if (ports[id].need_reconfig_queues == 0) 19539 ports[id].need_reconfig_queues = queue; 19540 } 19541 } 19542