1 /* SPDX-License-Identifier: BSD-3-Clause 2 * Copyright(c) 2010-2016 Intel Corporation. 3 * Copyright(c) 2014 6WIND S.A. 4 */ 5 6 #include <stdarg.h> 7 #include <errno.h> 8 #include <stdio.h> 9 #include <stdint.h> 10 #include <string.h> 11 #include <termios.h> 12 #include <unistd.h> 13 #include <inttypes.h> 14 #include <sys/socket.h> 15 #include <netinet/in.h> 16 17 #include <sys/queue.h> 18 19 #include <rte_common.h> 20 #include <rte_byteorder.h> 21 #include <rte_log.h> 22 #include <rte_debug.h> 23 #include <rte_cycles.h> 24 #include <rte_memory.h> 25 #include <rte_memzone.h> 26 #include <rte_malloc.h> 27 #include <rte_launch.h> 28 #include <rte_eal.h> 29 #include <rte_per_lcore.h> 30 #include <rte_lcore.h> 31 #include <rte_atomic.h> 32 #include <rte_branch_prediction.h> 33 #include <rte_ring.h> 34 #include <rte_mempool.h> 35 #include <rte_interrupts.h> 36 #include <rte_pci.h> 37 #include <rte_ether.h> 38 #include <rte_ethdev.h> 39 #include <rte_string_fns.h> 40 #include <rte_devargs.h> 41 #include <rte_flow.h> 42 #include <rte_gro.h> 43 44 #include <cmdline_rdline.h> 45 #include <cmdline_parse.h> 46 #include <cmdline_parse_num.h> 47 #include <cmdline_parse_string.h> 48 #include <cmdline_parse_ipaddr.h> 49 #include <cmdline_parse_etheraddr.h> 50 #include <cmdline_socket.h> 51 #include <cmdline.h> 52 #ifdef RTE_LIBRTE_PMD_BOND 53 #include <rte_eth_bond.h> 54 #include <rte_eth_bond_8023ad.h> 55 #endif 56 #if defined RTE_LIBRTE_DPAA_BUS && defined RTE_LIBRTE_DPAA_PMD 57 #include <rte_pmd_dpaa.h> 58 #endif 59 #ifdef RTE_LIBRTE_IXGBE_PMD 60 #include <rte_pmd_ixgbe.h> 61 #endif 62 #ifdef RTE_LIBRTE_I40E_PMD 63 #include <rte_pmd_i40e.h> 64 #endif 65 #ifdef RTE_LIBRTE_BNXT_PMD 66 #include <rte_pmd_bnxt.h> 67 #endif 68 #include "testpmd.h" 69 #include "cmdline_mtr.h" 70 #include "cmdline_tm.h" 71 #include "bpf_cmd.h" 72 73 static struct cmdline *testpmd_cl; 74 75 static void cmd_reconfig_device_queue(portid_t id, uint8_t dev, uint8_t queue); 76 77 /* *** Help command with introduction. *** */ 78 struct cmd_help_brief_result { 79 cmdline_fixed_string_t help; 80 }; 81 82 static void cmd_help_brief_parsed(__attribute__((unused)) void *parsed_result, 83 struct cmdline *cl, 84 __attribute__((unused)) void *data) 85 { 86 cmdline_printf( 87 cl, 88 "\n" 89 "Help is available for the following sections:\n\n" 90 " help control : Start and stop forwarding.\n" 91 " help display : Displaying port, stats and config " 92 "information.\n" 93 " help config : Configuration information.\n" 94 " help ports : Configuring ports.\n" 95 " help registers : Reading and setting port registers.\n" 96 " help filters : Filters configuration help.\n" 97 " help traffic_management : Traffic Management commmands.\n" 98 " help devices : Device related cmds.\n" 99 " help all : All of the above sections.\n\n" 100 ); 101 102 } 103 104 cmdline_parse_token_string_t cmd_help_brief_help = 105 TOKEN_STRING_INITIALIZER(struct cmd_help_brief_result, help, "help"); 106 107 cmdline_parse_inst_t cmd_help_brief = { 108 .f = cmd_help_brief_parsed, 109 .data = NULL, 110 .help_str = "help: Show help", 111 .tokens = { 112 (void *)&cmd_help_brief_help, 113 NULL, 114 }, 115 }; 116 117 /* *** Help command with help sections. *** */ 118 struct cmd_help_long_result { 119 cmdline_fixed_string_t help; 120 cmdline_fixed_string_t section; 121 }; 122 123 static void cmd_help_long_parsed(void *parsed_result, 124 struct cmdline *cl, 125 __attribute__((unused)) void *data) 126 { 127 int show_all = 0; 128 struct cmd_help_long_result *res = parsed_result; 129 130 if (!strcmp(res->section, "all")) 131 show_all = 1; 132 133 if (show_all || !strcmp(res->section, "control")) { 134 135 cmdline_printf( 136 cl, 137 "\n" 138 "Control forwarding:\n" 139 "-------------------\n\n" 140 141 "start\n" 142 " Start packet forwarding with current configuration.\n\n" 143 144 "start tx_first\n" 145 " Start packet forwarding with current config" 146 " after sending one burst of packets.\n\n" 147 148 "stop\n" 149 " Stop packet forwarding, and display accumulated" 150 " statistics.\n\n" 151 152 "quit\n" 153 " Quit to prompt.\n\n" 154 ); 155 } 156 157 if (show_all || !strcmp(res->section, "display")) { 158 159 cmdline_printf( 160 cl, 161 "\n" 162 "Display:\n" 163 "--------\n\n" 164 165 "show port (info|stats|summary|xstats|fdir|stat_qmap|dcb_tc|cap) (port_id|all)\n" 166 " Display information for port_id, or all.\n\n" 167 168 "show port X rss reta (size) (mask0,mask1,...)\n" 169 " Display the rss redirection table entry indicated" 170 " by masks on port X. size is used to indicate the" 171 " hardware supported reta size\n\n" 172 173 "show port (port_id) rss-hash [key]\n" 174 " Display the RSS hash functions and RSS hash key of port\n\n" 175 176 "clear port (info|stats|xstats|fdir|stat_qmap) (port_id|all)\n" 177 " Clear information for port_id, or all.\n\n" 178 179 "show (rxq|txq) info (port_id) (queue_id)\n" 180 " Display information for configured RX/TX queue.\n\n" 181 182 "show config (rxtx|cores|fwd|txpkts)\n" 183 " Display the given configuration.\n\n" 184 185 "read rxd (port_id) (queue_id) (rxd_id)\n" 186 " Display an RX descriptor of a port RX queue.\n\n" 187 188 "read txd (port_id) (queue_id) (txd_id)\n" 189 " Display a TX descriptor of a port TX queue.\n\n" 190 191 "ddp get list (port_id)\n" 192 " Get ddp profile info list\n\n" 193 194 "ddp get info (profile_path)\n" 195 " Get ddp profile information.\n\n" 196 197 "show vf stats (port_id) (vf_id)\n" 198 " Display a VF's statistics.\n\n" 199 200 "clear vf stats (port_id) (vf_id)\n" 201 " Reset a VF's statistics.\n\n" 202 203 "show port (port_id) pctype mapping\n" 204 " Get flow ptype to pctype mapping on a port\n\n" 205 206 "show port meter stats (port_id) (meter_id) (clear)\n" 207 " Get meter stats on a port\n\n" 208 209 "show fwd stats all\n" 210 " Display statistics for all fwd engines.\n\n" 211 212 "clear fwd stats all\n" 213 " Clear statistics for all fwd engines.\n\n" 214 215 "show port (port_id) rx_offload capabilities\n" 216 " List all per queue and per port Rx offloading" 217 " capabilities of a port\n\n" 218 219 "show port (port_id) rx_offload configuration\n" 220 " List port level and all queue level" 221 " Rx offloading configuration\n\n" 222 223 "show port (port_id) tx_offload capabilities\n" 224 " List all per queue and per port" 225 " Tx offloading capabilities of a port\n\n" 226 227 "show port (port_id) tx_offload configuration\n" 228 " List port level and all queue level" 229 " Tx offloading configuration\n\n" 230 231 "show port (port_id) tx_metadata\n" 232 " Show Tx metadata value set" 233 " for a specific port\n\n" 234 235 "show port (port_id) ptypes\n" 236 " Show port supported ptypes" 237 " for a specific port\n\n" 238 239 "show device info (<identifier>|all)" 240 " Show general information about devices probed.\n\n" 241 242 "show port (port_id) rxq|txq (queue_id) desc (desc_id) status" 243 " Show status of rx|tx descriptor.\n\n" 244 ); 245 } 246 247 if (show_all || !strcmp(res->section, "config")) { 248 cmdline_printf( 249 cl, 250 "\n" 251 "Configuration:\n" 252 "--------------\n" 253 "Configuration changes only become active when" 254 " forwarding is started/restarted.\n\n" 255 256 "set default\n" 257 " Reset forwarding to the default configuration.\n\n" 258 259 "set verbose (level)\n" 260 " Set the debug verbosity level X.\n\n" 261 262 "set log global|(type) (level)\n" 263 " Set the log level.\n\n" 264 265 "set nbport (num)\n" 266 " Set number of ports.\n\n" 267 268 "set nbcore (num)\n" 269 " Set number of cores.\n\n" 270 271 "set coremask (mask)\n" 272 " Set the forwarding cores hexadecimal mask.\n\n" 273 274 "set portmask (mask)\n" 275 " Set the forwarding ports hexadecimal mask.\n\n" 276 277 "set burst (num)\n" 278 " Set number of packets per burst.\n\n" 279 280 "set burst tx delay (microseconds) retry (num)\n" 281 " Set the transmit delay time and number of retries," 282 " effective when retry is enabled.\n\n" 283 284 "set txpkts (x[,y]*)\n" 285 " Set the length of each segment of TXONLY" 286 " and optionally CSUM packets.\n\n" 287 288 "set txsplit (off|on|rand)\n" 289 " Set the split policy for the TX packets." 290 " Right now only applicable for CSUM and TXONLY" 291 " modes\n\n" 292 293 "set corelist (x[,y]*)\n" 294 " Set the list of forwarding cores.\n\n" 295 296 "set portlist (x[,y]*)\n" 297 " Set the list of forwarding ports.\n\n" 298 299 "set port setup on (iterator|event)\n" 300 " Select how attached port is retrieved for setup.\n\n" 301 302 "set tx loopback (port_id) (on|off)\n" 303 " Enable or disable tx loopback.\n\n" 304 305 "set all queues drop (port_id) (on|off)\n" 306 " Set drop enable bit for all queues.\n\n" 307 308 "set vf split drop (port_id) (vf_id) (on|off)\n" 309 " Set split drop enable bit for a VF from the PF.\n\n" 310 311 "set vf mac antispoof (port_id) (vf_id) (on|off).\n" 312 " Set MAC antispoof for a VF from the PF.\n\n" 313 314 "set macsec offload (port_id) on encrypt (on|off) replay-protect (on|off)\n" 315 " Enable MACsec offload.\n\n" 316 317 "set macsec offload (port_id) off\n" 318 " Disable MACsec offload.\n\n" 319 320 "set macsec sc (tx|rx) (port_id) (mac) (pi)\n" 321 " Configure MACsec secure connection (SC).\n\n" 322 323 "set macsec sa (tx|rx) (port_id) (idx) (an) (pn) (key)\n" 324 " Configure MACsec secure association (SA).\n\n" 325 326 "set vf broadcast (port_id) (vf_id) (on|off)\n" 327 " Set VF broadcast for a VF from the PF.\n\n" 328 329 "vlan set stripq (on|off) (port_id,queue_id)\n" 330 " Set the VLAN strip for a queue on a port.\n\n" 331 332 "set vf vlan stripq (port_id) (vf_id) (on|off)\n" 333 " Set the VLAN strip for all queues in a pool for a VF from the PF.\n\n" 334 335 "set vf vlan insert (port_id) (vf_id) (vlan_id)\n" 336 " Set VLAN insert for a VF from the PF.\n\n" 337 338 "set vf vlan antispoof (port_id) (vf_id) (on|off)\n" 339 " Set VLAN antispoof for a VF from the PF.\n\n" 340 341 "set vf vlan tag (port_id) (vf_id) (on|off)\n" 342 " Set VLAN tag for a VF from the PF.\n\n" 343 344 "set vf tx max-bandwidth (port_id) (vf_id) (bandwidth)\n" 345 " Set a VF's max bandwidth(Mbps).\n\n" 346 347 "set vf tc tx min-bandwidth (port_id) (vf_id) (bw1, bw2, ...)\n" 348 " Set all TCs' min bandwidth(%%) on a VF.\n\n" 349 350 "set vf tc tx max-bandwidth (port_id) (vf_id) (tc_no) (bandwidth)\n" 351 " Set a TC's max bandwidth(Mbps) on a VF.\n\n" 352 353 "set tx strict-link-priority (port_id) (tc_bitmap)\n" 354 " Set some TCs' strict link priority mode on a physical port.\n\n" 355 356 "set tc tx min-bandwidth (port_id) (bw1, bw2, ...)\n" 357 " Set all TCs' min bandwidth(%%) for all PF and VFs.\n\n" 358 359 "vlan set (strip|filter|qinq_strip|extend) (on|off) (port_id)\n" 360 " Set the VLAN strip or filter or qinq strip or extend\n\n" 361 362 "vlan set (inner|outer) tpid (value) (port_id)\n" 363 " Set the VLAN TPID for Packet Filtering on" 364 " a port\n\n" 365 366 "rx_vlan add (vlan_id|all) (port_id)\n" 367 " Add a vlan_id, or all identifiers, to the set" 368 " of VLAN identifiers filtered by port_id.\n\n" 369 370 "rx_vlan rm (vlan_id|all) (port_id)\n" 371 " Remove a vlan_id, or all identifiers, from the set" 372 " of VLAN identifiers filtered by port_id.\n\n" 373 374 "rx_vlan add (vlan_id) port (port_id) vf (vf_mask)\n" 375 " Add a vlan_id, to the set of VLAN identifiers" 376 "filtered for VF(s) from port_id.\n\n" 377 378 "rx_vlan rm (vlan_id) port (port_id) vf (vf_mask)\n" 379 " Remove a vlan_id, to the set of VLAN identifiers" 380 "filtered for VF(s) from port_id.\n\n" 381 382 "tunnel_filter add (port_id) (outer_mac) (inner_mac) (ip_addr) " 383 "(inner_vlan) (vxlan|nvgre|ipingre|vxlan-gpe) (imac-ivlan|imac-ivlan-tenid|" 384 "imac-tenid|imac|omac-imac-tenid|oip|iip) (tenant_id) (queue_id)\n" 385 " add a tunnel filter of a port.\n\n" 386 387 "tunnel_filter rm (port_id) (outer_mac) (inner_mac) (ip_addr) " 388 "(inner_vlan) (vxlan|nvgre|ipingre|vxlan-gpe) (imac-ivlan|imac-ivlan-tenid|" 389 "imac-tenid|imac|omac-imac-tenid|oip|iip) (tenant_id) (queue_id)\n" 390 " remove a tunnel filter of a port.\n\n" 391 392 "rx_vxlan_port add (udp_port) (port_id)\n" 393 " Add an UDP port for VXLAN packet filter on a port\n\n" 394 395 "rx_vxlan_port rm (udp_port) (port_id)\n" 396 " Remove an UDP port for VXLAN packet filter on a port\n\n" 397 398 "tx_vlan set (port_id) vlan_id[, vlan_id_outer]\n" 399 " Set hardware insertion of VLAN IDs (single or double VLAN " 400 "depends on the number of VLAN IDs) in packets sent on a port.\n\n" 401 402 "tx_vlan set pvid port_id vlan_id (on|off)\n" 403 " Set port based TX VLAN insertion.\n\n" 404 405 "tx_vlan reset (port_id)\n" 406 " Disable hardware insertion of a VLAN header in" 407 " packets sent on a port.\n\n" 408 409 "csum set (ip|udp|tcp|sctp|outer-ip|outer-udp) (hw|sw) (port_id)\n" 410 " Select hardware or software calculation of the" 411 " checksum when transmitting a packet using the" 412 " csum forward engine.\n" 413 " ip|udp|tcp|sctp always concern the inner layer.\n" 414 " outer-ip concerns the outer IP layer in" 415 " outer-udp concerns the outer UDP layer in" 416 " case the packet is recognized as a tunnel packet by" 417 " the forward engine (vxlan, gre and ipip are supported)\n" 418 " Please check the NIC datasheet for HW limits.\n\n" 419 420 "csum parse-tunnel (on|off) (tx_port_id)\n" 421 " If disabled, treat tunnel packets as non-tunneled" 422 " packets (treat inner headers as payload). The port\n" 423 " argument is the port used for TX in csum forward" 424 " engine.\n\n" 425 426 "csum show (port_id)\n" 427 " Display tx checksum offload configuration\n\n" 428 429 "tso set (segsize) (portid)\n" 430 " Enable TCP Segmentation Offload in csum forward" 431 " engine.\n" 432 " Please check the NIC datasheet for HW limits.\n\n" 433 434 "tso show (portid)" 435 " Display the status of TCP Segmentation Offload.\n\n" 436 437 "set port (port_id) gro on|off\n" 438 " Enable or disable Generic Receive Offload in" 439 " csum forwarding engine.\n\n" 440 441 "show port (port_id) gro\n" 442 " Display GRO configuration.\n\n" 443 444 "set gro flush (cycles)\n" 445 " Set the cycle to flush GROed packets from" 446 " reassembly tables.\n\n" 447 448 "set port (port_id) gso (on|off)" 449 " Enable or disable Generic Segmentation Offload in" 450 " csum forwarding engine.\n\n" 451 452 "set gso segsz (length)\n" 453 " Set max packet length for output GSO segments," 454 " including packet header and payload.\n\n" 455 456 "show port (port_id) gso\n" 457 " Show GSO configuration.\n\n" 458 459 "set fwd (%s)\n" 460 " Set packet forwarding mode.\n\n" 461 462 "mac_addr add (port_id) (XX:XX:XX:XX:XX:XX)\n" 463 " Add a MAC address on port_id.\n\n" 464 465 "mac_addr remove (port_id) (XX:XX:XX:XX:XX:XX)\n" 466 " Remove a MAC address from port_id.\n\n" 467 468 "mac_addr set (port_id) (XX:XX:XX:XX:XX:XX)\n" 469 " Set the default MAC address for port_id.\n\n" 470 471 "mac_addr add port (port_id) vf (vf_id) (mac_address)\n" 472 " Add a MAC address for a VF on the port.\n\n" 473 474 "set vf mac addr (port_id) (vf_id) (XX:XX:XX:XX:XX:XX)\n" 475 " Set the MAC address for a VF from the PF.\n\n" 476 477 "set eth-peer (port_id) (peer_addr)\n" 478 " set the peer address for certain port.\n\n" 479 480 "set port (port_id) uta (mac_address|all) (on|off)\n" 481 " Add/Remove a or all unicast hash filter(s)" 482 "from port X.\n\n" 483 484 "set promisc (port_id|all) (on|off)\n" 485 " Set the promiscuous mode on port_id, or all.\n\n" 486 487 "set allmulti (port_id|all) (on|off)\n" 488 " Set the allmulti mode on port_id, or all.\n\n" 489 490 "set vf promisc (port_id) (vf_id) (on|off)\n" 491 " Set unicast promiscuous mode for a VF from the PF.\n\n" 492 493 "set vf allmulti (port_id) (vf_id) (on|off)\n" 494 " Set multicast promiscuous mode for a VF from the PF.\n\n" 495 496 "set flow_ctrl rx (on|off) tx (on|off) (high_water)" 497 " (low_water) (pause_time) (send_xon) mac_ctrl_frame_fwd" 498 " (on|off) autoneg (on|off) (port_id)\n" 499 "set flow_ctrl rx (on|off) (portid)\n" 500 "set flow_ctrl tx (on|off) (portid)\n" 501 "set flow_ctrl high_water (high_water) (portid)\n" 502 "set flow_ctrl low_water (low_water) (portid)\n" 503 "set flow_ctrl pause_time (pause_time) (portid)\n" 504 "set flow_ctrl send_xon (send_xon) (portid)\n" 505 "set flow_ctrl mac_ctrl_frame_fwd (on|off) (portid)\n" 506 "set flow_ctrl autoneg (on|off) (port_id)\n" 507 " Set the link flow control parameter on a port.\n\n" 508 509 "set pfc_ctrl rx (on|off) tx (on|off) (high_water)" 510 " (low_water) (pause_time) (priority) (port_id)\n" 511 " Set the priority flow control parameter on a" 512 " port.\n\n" 513 514 "set stat_qmap (tx|rx) (port_id) (queue_id) (qmapping)\n" 515 " Set statistics mapping (qmapping 0..15) for RX/TX" 516 " queue on port.\n" 517 " e.g., 'set stat_qmap rx 0 2 5' sets rx queue 2" 518 " on port 0 to mapping 5.\n\n" 519 520 "set xstats-hide-zero on|off\n" 521 " Set the option to hide the zero values" 522 " for xstats display.\n" 523 524 "set port (port_id) vf (vf_id) rx|tx on|off\n" 525 " Enable/Disable a VF receive/tranmit from a port\n\n" 526 527 "set port (port_id) vf (vf_id) (mac_addr)" 528 " (exact-mac#exact-mac-vlan#hashmac|hashmac-vlan) on|off\n" 529 " Add/Remove unicast or multicast MAC addr filter" 530 " for a VF.\n\n" 531 532 "set port (port_id) vf (vf_id) rxmode (AUPE|ROPE|BAM" 533 "|MPE) (on|off)\n" 534 " AUPE:accepts untagged VLAN;" 535 "ROPE:accept unicast hash\n\n" 536 " BAM:accepts broadcast packets;" 537 "MPE:accepts all multicast packets\n\n" 538 " Enable/Disable a VF receive mode of a port\n\n" 539 540 "set port (port_id) queue (queue_id) rate (rate_num)\n" 541 " Set rate limit for a queue of a port\n\n" 542 543 "set port (port_id) vf (vf_id) rate (rate_num) " 544 "queue_mask (queue_mask_value)\n" 545 " Set rate limit for queues in VF of a port\n\n" 546 547 "set port (port_id) mirror-rule (rule_id)" 548 " (pool-mirror-up|pool-mirror-down|vlan-mirror)" 549 " (poolmask|vlanid[,vlanid]*) dst-pool (pool_id) (on|off)\n" 550 " Set pool or vlan type mirror rule on a port.\n" 551 " e.g., 'set port 0 mirror-rule 0 vlan-mirror 0,1" 552 " dst-pool 0 on' enable mirror traffic with vlan 0,1" 553 " to pool 0.\n\n" 554 555 "set port (port_id) mirror-rule (rule_id)" 556 " (uplink-mirror|downlink-mirror) dst-pool" 557 " (pool_id) (on|off)\n" 558 " Set uplink or downlink type mirror rule on a port.\n" 559 " e.g., 'set port 0 mirror-rule 0 uplink-mirror dst-pool" 560 " 0 on' enable mirror income traffic to pool 0.\n\n" 561 562 "reset port (port_id) mirror-rule (rule_id)\n" 563 " Reset a mirror rule.\n\n" 564 565 "set flush_rx (on|off)\n" 566 " Flush (default) or don't flush RX streams before" 567 " forwarding. Mainly used with PCAP drivers.\n\n" 568 569 "set bypass mode (normal|bypass|isolate) (port_id)\n" 570 " Set the bypass mode for the lowest port on bypass enabled" 571 " NIC.\n\n" 572 573 "set bypass event (timeout|os_on|os_off|power_on|power_off) " 574 "mode (normal|bypass|isolate) (port_id)\n" 575 " Set the event required to initiate specified bypass mode for" 576 " the lowest port on a bypass enabled NIC where:\n" 577 " timeout = enable bypass after watchdog timeout.\n" 578 " os_on = enable bypass when OS/board is powered on.\n" 579 " os_off = enable bypass when OS/board is powered off.\n" 580 " power_on = enable bypass when power supply is turned on.\n" 581 " power_off = enable bypass when power supply is turned off." 582 "\n\n" 583 584 "set bypass timeout (0|1.5|2|3|4|8|16|32)\n" 585 " Set the bypass watchdog timeout to 'n' seconds" 586 " where 0 = instant.\n\n" 587 588 "show bypass config (port_id)\n" 589 " Show the bypass configuration for a bypass enabled NIC" 590 " using the lowest port on the NIC.\n\n" 591 592 #ifdef RTE_LIBRTE_PMD_BOND 593 "create bonded device (mode) (socket)\n" 594 " Create a new bonded device with specific bonding mode and socket.\n\n" 595 596 "add bonding slave (slave_id) (port_id)\n" 597 " Add a slave device to a bonded device.\n\n" 598 599 "remove bonding slave (slave_id) (port_id)\n" 600 " Remove a slave device from a bonded device.\n\n" 601 602 "set bonding mode (value) (port_id)\n" 603 " Set the bonding mode on a bonded device.\n\n" 604 605 "set bonding primary (slave_id) (port_id)\n" 606 " Set the primary slave for a bonded device.\n\n" 607 608 "show bonding config (port_id)\n" 609 " Show the bonding config for port_id.\n\n" 610 611 "set bonding mac_addr (port_id) (address)\n" 612 " Set the MAC address of a bonded device.\n\n" 613 614 "set bonding mode IEEE802.3AD aggregator policy (port_id) (agg_name)" 615 " Set Aggregation mode for IEEE802.3AD (mode 4)" 616 617 "set bonding xmit_balance_policy (port_id) (l2|l23|l34)\n" 618 " Set the transmit balance policy for bonded device running in balance mode.\n\n" 619 620 "set bonding mon_period (port_id) (value)\n" 621 " Set the bonding link status monitoring polling period in ms.\n\n" 622 623 "set bonding lacp dedicated_queues <port_id> (enable|disable)\n" 624 " Enable/disable dedicated queues for LACP control traffic.\n\n" 625 626 #endif 627 "set link-up port (port_id)\n" 628 " Set link up for a port.\n\n" 629 630 "set link-down port (port_id)\n" 631 " Set link down for a port.\n\n" 632 633 "E-tag set insertion on port-tag-id (value)" 634 " port (port_id) vf (vf_id)\n" 635 " Enable E-tag insertion for a VF on a port\n\n" 636 637 "E-tag set insertion off port (port_id) vf (vf_id)\n" 638 " Disable E-tag insertion for a VF on a port\n\n" 639 640 "E-tag set stripping (on|off) port (port_id)\n" 641 " Enable/disable E-tag stripping on a port\n\n" 642 643 "E-tag set forwarding (on|off) port (port_id)\n" 644 " Enable/disable E-tag based forwarding" 645 " on a port\n\n" 646 647 "E-tag set filter add e-tag-id (value) dst-pool" 648 " (pool_id) port (port_id)\n" 649 " Add an E-tag forwarding filter on a port\n\n" 650 651 "E-tag set filter del e-tag-id (value) port (port_id)\n" 652 " Delete an E-tag forwarding filter on a port\n\n" 653 654 "ddp add (port_id) (profile_path[,backup_profile_path])\n" 655 " Load a profile package on a port\n\n" 656 657 "ddp del (port_id) (backup_profile_path)\n" 658 " Delete a profile package from a port\n\n" 659 660 "ptype mapping get (port_id) (valid_only)\n" 661 " Get ptype mapping on a port\n\n" 662 663 "ptype mapping replace (port_id) (target) (mask) (pky_type)\n" 664 " Replace target with the pkt_type in ptype mapping\n\n" 665 666 "ptype mapping reset (port_id)\n" 667 " Reset ptype mapping on a port\n\n" 668 669 "ptype mapping update (port_id) (hw_ptype) (sw_ptype)\n" 670 " Update a ptype mapping item on a port\n\n" 671 672 "set port (port_id) ptype_mask (ptype_mask)\n" 673 " set packet types classification for a specific port\n\n" 674 675 "set port (port_id) queue-region region_id (value) " 676 "queue_start_index (value) queue_num (value)\n" 677 " Set a queue region on a port\n\n" 678 679 "set port (port_id) queue-region region_id (value) " 680 "flowtype (value)\n" 681 " Set a flowtype region index on a port\n\n" 682 683 "set port (port_id) queue-region UP (value) region_id (value)\n" 684 " Set the mapping of User Priority to " 685 "queue region on a port\n\n" 686 687 "set port (port_id) queue-region flush (on|off)\n" 688 " flush all queue region related configuration\n\n" 689 690 "show port meter cap (port_id)\n" 691 " Show port meter capability information\n\n" 692 693 "add port meter profile srtcm_rfc2697 (port_id) (profile_id) (cir) (cbs) (ebs)\n" 694 " meter profile add - srtcm rfc 2697\n\n" 695 696 "add port meter profile trtcm_rfc2698 (port_id) (profile_id) (cir) (pir) (cbs) (pbs)\n" 697 " meter profile add - trtcm rfc 2698\n\n" 698 699 "add port meter profile trtcm_rfc4115 (port_id) (profile_id) (cir) (eir) (cbs) (ebs)\n" 700 " meter profile add - trtcm rfc 4115\n\n" 701 702 "del port meter profile (port_id) (profile_id)\n" 703 " meter profile delete\n\n" 704 705 "create port meter (port_id) (mtr_id) (profile_id) (meter_enable)\n" 706 "(g_action) (y_action) (r_action) (stats_mask) (shared)\n" 707 "(use_pre_meter_color) [(dscp_tbl_entry0) (dscp_tbl_entry1)...\n" 708 "(dscp_tbl_entry63)]\n" 709 " meter create\n\n" 710 711 "enable port meter (port_id) (mtr_id)\n" 712 " meter enable\n\n" 713 714 "disable port meter (port_id) (mtr_id)\n" 715 " meter disable\n\n" 716 717 "del port meter (port_id) (mtr_id)\n" 718 " meter delete\n\n" 719 720 "set port meter profile (port_id) (mtr_id) (profile_id)\n" 721 " meter update meter profile\n\n" 722 723 "set port meter dscp table (port_id) (mtr_id) [(dscp_tbl_entry0)\n" 724 "(dscp_tbl_entry1)...(dscp_tbl_entry63)]\n" 725 " update meter dscp table entries\n\n" 726 727 "set port meter policer action (port_id) (mtr_id) (action_mask)\n" 728 "(action0) [(action1) (action2)]\n" 729 " meter update policer action\n\n" 730 731 "set port meter stats mask (port_id) (mtr_id) (stats_mask)\n" 732 " meter update stats\n\n" 733 734 "show port (port_id) queue-region\n" 735 " show all queue region related configuration info\n\n" 736 737 , list_pkt_forwarding_modes() 738 ); 739 } 740 741 if (show_all || !strcmp(res->section, "ports")) { 742 743 cmdline_printf( 744 cl, 745 "\n" 746 "Port Operations:\n" 747 "----------------\n\n" 748 749 "port start (port_id|all)\n" 750 " Start all ports or port_id.\n\n" 751 752 "port stop (port_id|all)\n" 753 " Stop all ports or port_id.\n\n" 754 755 "port close (port_id|all)\n" 756 " Close all ports or port_id.\n\n" 757 758 "port reset (port_id|all)\n" 759 " Reset all ports or port_id.\n\n" 760 761 "port attach (ident)\n" 762 " Attach physical or virtual dev by pci address or virtual device name\n\n" 763 764 "port detach (port_id)\n" 765 " Detach physical or virtual dev by port_id\n\n" 766 767 "port config (port_id|all)" 768 " speed (10|100|1000|10000|25000|40000|50000|100000|auto)" 769 " duplex (half|full|auto)\n" 770 " Set speed and duplex for all ports or port_id\n\n" 771 772 "port config (port_id|all) loopback (mode)\n" 773 " Set loopback mode for all ports or port_id\n\n" 774 775 "port config all (rxq|txq|rxd|txd) (value)\n" 776 " Set number for rxq/txq/rxd/txd.\n\n" 777 778 "port config all max-pkt-len (value)\n" 779 " Set the max packet length.\n\n" 780 781 "port config all max-lro-pkt-size (value)\n" 782 " Set the max LRO aggregated packet size.\n\n" 783 784 "port config all drop-en (on|off)\n" 785 " Enable or disable packet drop on all RX queues of all ports when no " 786 "receive buffers available.\n\n" 787 788 "port config all rss (all|default|ip|tcp|udp|sctp|" 789 "ether|port|vxlan|geneve|nvgre|vxlan-gpe|none|<flowtype_id>)\n" 790 " Set the RSS mode.\n\n" 791 792 "port config port-id rss reta (hash,queue)[,(hash,queue)]\n" 793 " Set the RSS redirection table.\n\n" 794 795 "port config (port_id) dcb vt (on|off) (traffic_class)" 796 " pfc (on|off)\n" 797 " Set the DCB mode.\n\n" 798 799 "port config all burst (value)\n" 800 " Set the number of packets per burst.\n\n" 801 802 "port config all (txpt|txht|txwt|rxpt|rxht|rxwt)" 803 " (value)\n" 804 " Set the ring prefetch/host/writeback threshold" 805 " for tx/rx queue.\n\n" 806 807 "port config all (txfreet|txrst|rxfreet) (value)\n" 808 " Set free threshold for rx/tx, or set" 809 " tx rs bit threshold.\n\n" 810 "port config mtu X value\n" 811 " Set the MTU of port X to a given value\n\n" 812 813 "port config (port_id) (rxq|txq) (queue_id) ring_size (value)\n" 814 " Set a rx/tx queue's ring size configuration, the new" 815 " value will take effect after command that (re-)start the port" 816 " or command that setup the specific queue\n\n" 817 818 "port (port_id) (rxq|txq) (queue_id) (start|stop)\n" 819 " Start/stop a rx/tx queue of port X. Only take effect" 820 " when port X is started\n\n" 821 822 "port (port_id) (rxq|txq) (queue_id) deferred_start (on|off)\n" 823 " Switch on/off a deferred start of port X rx/tx queue. Only" 824 " take effect when port X is stopped.\n\n" 825 826 "port (port_id) (rxq|txq) (queue_id) setup\n" 827 " Setup a rx/tx queue of port X.\n\n" 828 829 "port config (port_id|all) l2-tunnel E-tag ether-type" 830 " (value)\n" 831 " Set the value of E-tag ether-type.\n\n" 832 833 "port config (port_id|all) l2-tunnel E-tag" 834 " (enable|disable)\n" 835 " Enable/disable the E-tag support.\n\n" 836 837 "port config (port_id) pctype mapping reset\n" 838 " Reset flow type to pctype mapping on a port\n\n" 839 840 "port config (port_id) pctype mapping update" 841 " (pctype_id_0[,pctype_id_1]*) (flow_type_id)\n" 842 " Update a flow type to pctype mapping item on a port\n\n" 843 844 "port config (port_id) pctype (pctype_id) hash_inset|" 845 "fdir_inset|fdir_flx_inset get|set|clear field\n" 846 " (field_idx)\n" 847 " Configure RSS|FDIR|FDIR_FLX input set for some pctype\n\n" 848 849 "port config (port_id) pctype (pctype_id) hash_inset|" 850 "fdir_inset|fdir_flx_inset clear all" 851 " Clear RSS|FDIR|FDIR_FLX input set completely for some pctype\n\n" 852 853 "port config (port_id) udp_tunnel_port add|rm vxlan|geneve (udp_port)\n\n" 854 " Add/remove UDP tunnel port for tunneling offload\n\n" 855 856 "port config <port_id> rx_offload vlan_strip|" 857 "ipv4_cksum|udp_cksum|tcp_cksum|tcp_lro|qinq_strip|" 858 "outer_ipv4_cksum|macsec_strip|header_split|" 859 "vlan_filter|vlan_extend|jumbo_frame|" 860 "scatter|timestamp|security|keep_crc on|off\n" 861 " Enable or disable a per port Rx offloading" 862 " on all Rx queues of a port\n\n" 863 864 "port (port_id) rxq (queue_id) rx_offload vlan_strip|" 865 "ipv4_cksum|udp_cksum|tcp_cksum|tcp_lro|qinq_strip|" 866 "outer_ipv4_cksum|macsec_strip|header_split|" 867 "vlan_filter|vlan_extend|jumbo_frame|" 868 "scatter|timestamp|security|keep_crc on|off\n" 869 " Enable or disable a per queue Rx offloading" 870 " only on a specific Rx queue\n\n" 871 872 "port config (port_id) tx_offload vlan_insert|" 873 "ipv4_cksum|udp_cksum|tcp_cksum|sctp_cksum|tcp_tso|" 874 "udp_tso|outer_ipv4_cksum|qinq_insert|vxlan_tnl_tso|" 875 "gre_tnl_tso|ipip_tnl_tso|geneve_tnl_tso|" 876 "macsec_insert|mt_lockfree|multi_segs|mbuf_fast_free|" 877 "security on|off\n" 878 " Enable or disable a per port Tx offloading" 879 " on all Tx queues of a port\n\n" 880 881 "port (port_id) txq (queue_id) tx_offload vlan_insert|" 882 "ipv4_cksum|udp_cksum|tcp_cksum|sctp_cksum|tcp_tso|" 883 "udp_tso|outer_ipv4_cksum|qinq_insert|vxlan_tnl_tso|" 884 "gre_tnl_tso|ipip_tnl_tso|geneve_tnl_tso|macsec_insert" 885 "|mt_lockfree|multi_segs|mbuf_fast_free|security" 886 " on|off\n" 887 " Enable or disable a per queue Tx offloading" 888 " only on a specific Tx queue\n\n" 889 890 "bpf-load rx|tx (port) (queue) (J|M|B) (file_name)\n" 891 " Load an eBPF program as a callback" 892 " for particular RX/TX queue\n\n" 893 894 "bpf-unload rx|tx (port) (queue)\n" 895 " Unload previously loaded eBPF program" 896 " for particular RX/TX queue\n\n" 897 898 "port config (port_id) tx_metadata (value)\n" 899 " Set Tx metadata value per port. Testpmd will add this value" 900 " to any Tx packet sent from this port\n\n" 901 ); 902 } 903 904 if (show_all || !strcmp(res->section, "registers")) { 905 906 cmdline_printf( 907 cl, 908 "\n" 909 "Registers:\n" 910 "----------\n\n" 911 912 "read reg (port_id) (address)\n" 913 " Display value of a port register.\n\n" 914 915 "read regfield (port_id) (address) (bit_x) (bit_y)\n" 916 " Display a port register bit field.\n\n" 917 918 "read regbit (port_id) (address) (bit_x)\n" 919 " Display a single port register bit.\n\n" 920 921 "write reg (port_id) (address) (value)\n" 922 " Set value of a port register.\n\n" 923 924 "write regfield (port_id) (address) (bit_x) (bit_y)" 925 " (value)\n" 926 " Set bit field of a port register.\n\n" 927 928 "write regbit (port_id) (address) (bit_x) (value)\n" 929 " Set single bit value of a port register.\n\n" 930 ); 931 } 932 if (show_all || !strcmp(res->section, "filters")) { 933 934 cmdline_printf( 935 cl, 936 "\n" 937 "filters:\n" 938 "--------\n\n" 939 940 "ethertype_filter (port_id) (add|del)" 941 " (mac_addr|mac_ignr) (mac_address) ethertype" 942 " (ether_type) (drop|fwd) queue (queue_id)\n" 943 " Add/Del an ethertype filter.\n\n" 944 945 "2tuple_filter (port_id) (add|del)" 946 " dst_port (dst_port_value) protocol (protocol_value)" 947 " mask (mask_value) tcp_flags (tcp_flags_value)" 948 " priority (prio_value) queue (queue_id)\n" 949 " Add/Del a 2tuple filter.\n\n" 950 951 "5tuple_filter (port_id) (add|del)" 952 " dst_ip (dst_address) src_ip (src_address)" 953 " dst_port (dst_port_value) src_port (src_port_value)" 954 " protocol (protocol_value)" 955 " mask (mask_value) tcp_flags (tcp_flags_value)" 956 " priority (prio_value) queue (queue_id)\n" 957 " Add/Del a 5tuple filter.\n\n" 958 959 "syn_filter (port_id) (add|del) priority (high|low) queue (queue_id)" 960 " Add/Del syn filter.\n\n" 961 962 "flex_filter (port_id) (add|del) len (len_value)" 963 " bytes (bytes_value) mask (mask_value)" 964 " priority (prio_value) queue (queue_id)\n" 965 " Add/Del a flex filter.\n\n" 966 967 "flow_director_filter (port_id) mode IP (add|del|update)" 968 " flow (ipv4-other|ipv4-frag|ipv6-other|ipv6-frag)" 969 " src (src_ip_address) dst (dst_ip_address)" 970 " tos (tos_value) proto (proto_value) ttl (ttl_value)" 971 " vlan (vlan_value) flexbytes (flexbytes_value)" 972 " (drop|fwd) pf|vf(vf_id) queue (queue_id)" 973 " fd_id (fd_id_value)\n" 974 " Add/Del an IP type flow director filter.\n\n" 975 976 "flow_director_filter (port_id) mode IP (add|del|update)" 977 " flow (ipv4-tcp|ipv4-udp|ipv6-tcp|ipv6-udp)" 978 " src (src_ip_address) (src_port)" 979 " dst (dst_ip_address) (dst_port)" 980 " tos (tos_value) ttl (ttl_value)" 981 " vlan (vlan_value) flexbytes (flexbytes_value)" 982 " (drop|fwd) pf|vf(vf_id) queue (queue_id)" 983 " fd_id (fd_id_value)\n" 984 " Add/Del an UDP/TCP type flow director filter.\n\n" 985 986 "flow_director_filter (port_id) mode IP (add|del|update)" 987 " flow (ipv4-sctp|ipv6-sctp)" 988 " src (src_ip_address) (src_port)" 989 " dst (dst_ip_address) (dst_port)" 990 " tag (verification_tag) " 991 " tos (tos_value) ttl (ttl_value)" 992 " vlan (vlan_value)" 993 " flexbytes (flexbytes_value) (drop|fwd)" 994 " pf|vf(vf_id) queue (queue_id) fd_id (fd_id_value)\n" 995 " Add/Del a SCTP type flow director filter.\n\n" 996 997 "flow_director_filter (port_id) mode IP (add|del|update)" 998 " flow l2_payload ether (ethertype)" 999 " flexbytes (flexbytes_value) (drop|fwd)" 1000 " pf|vf(vf_id) queue (queue_id) fd_id (fd_id_value)\n" 1001 " Add/Del a l2 payload type flow director filter.\n\n" 1002 1003 "flow_director_filter (port_id) mode MAC-VLAN (add|del|update)" 1004 " mac (mac_address) vlan (vlan_value)" 1005 " flexbytes (flexbytes_value) (drop|fwd)" 1006 " queue (queue_id) fd_id (fd_id_value)\n" 1007 " Add/Del a MAC-VLAN flow director filter.\n\n" 1008 1009 "flow_director_filter (port_id) mode Tunnel (add|del|update)" 1010 " mac (mac_address) vlan (vlan_value)" 1011 " tunnel (NVGRE|VxLAN) tunnel-id (tunnel_id_value)" 1012 " flexbytes (flexbytes_value) (drop|fwd)" 1013 " queue (queue_id) fd_id (fd_id_value)\n" 1014 " Add/Del a Tunnel flow director filter.\n\n" 1015 1016 "flow_director_filter (port_id) mode raw (add|del|update)" 1017 " flow (flow_id) (drop|fwd) queue (queue_id)" 1018 " fd_id (fd_id_value) packet (packet file name)\n" 1019 " Add/Del a raw type flow director filter.\n\n" 1020 1021 "flush_flow_director (port_id)\n" 1022 " Flush all flow director entries of a device.\n\n" 1023 1024 "flow_director_mask (port_id) mode IP vlan (vlan_value)" 1025 " src_mask (ipv4_src) (ipv6_src) (src_port)" 1026 " dst_mask (ipv4_dst) (ipv6_dst) (dst_port)\n" 1027 " Set flow director IP mask.\n\n" 1028 1029 "flow_director_mask (port_id) mode MAC-VLAN" 1030 " vlan (vlan_value)\n" 1031 " Set flow director MAC-VLAN mask.\n\n" 1032 1033 "flow_director_mask (port_id) mode Tunnel" 1034 " vlan (vlan_value) mac (mac_value)" 1035 " tunnel-type (tunnel_type_value)" 1036 " tunnel-id (tunnel_id_value)\n" 1037 " Set flow director Tunnel mask.\n\n" 1038 1039 "flow_director_flex_mask (port_id)" 1040 " flow (none|ipv4-other|ipv4-frag|ipv4-tcp|ipv4-udp|ipv4-sctp|" 1041 "ipv6-other|ipv6-frag|ipv6-tcp|ipv6-udp|ipv6-sctp|l2_payload|all)" 1042 " (mask)\n" 1043 " Configure mask of flex payload.\n\n" 1044 1045 "flow_director_flex_payload (port_id)" 1046 " (raw|l2|l3|l4) (config)\n" 1047 " Configure flex payload selection.\n\n" 1048 1049 "get_sym_hash_ena_per_port (port_id)\n" 1050 " get symmetric hash enable configuration per port.\n\n" 1051 1052 "set_sym_hash_ena_per_port (port_id) (enable|disable)\n" 1053 " set symmetric hash enable configuration per port" 1054 " to enable or disable.\n\n" 1055 1056 "get_hash_global_config (port_id)\n" 1057 " Get the global configurations of hash filters.\n\n" 1058 1059 "set_hash_global_config (port_id) (toeplitz|simple_xor|symmetric_toeplitz|default)" 1060 " (ipv4|ipv4-frag|ipv4-tcp|ipv4-udp|ipv4-sctp|ipv4-other|ipv6|" 1061 "ipv6-frag|ipv6-tcp|ipv6-udp|ipv6-sctp|ipv6-other|l2_payload)" 1062 " (enable|disable)\n" 1063 " Set the global configurations of hash filters.\n\n" 1064 1065 "set_hash_input_set (port_id) (ipv4|ipv4-frag|" 1066 "ipv4-tcp|ipv4-udp|ipv4-sctp|ipv4-other|ipv6|" 1067 "ipv6-frag|ipv6-tcp|ipv6-udp|ipv6-sctp|ipv6-other|" 1068 "l2_payload|<flowtype_id>) (ovlan|ivlan|src-ipv4|dst-ipv4|" 1069 "src-ipv6|dst-ipv6|ipv4-tos|ipv4-proto|ipv6-tc|" 1070 "ipv6-next-header|udp-src-port|udp-dst-port|" 1071 "tcp-src-port|tcp-dst-port|sctp-src-port|" 1072 "sctp-dst-port|sctp-veri-tag|udp-key|gre-key|fld-1st|" 1073 "fld-2nd|fld-3rd|fld-4th|fld-5th|fld-6th|fld-7th|" 1074 "fld-8th|none) (select|add)\n" 1075 " Set the input set for hash.\n\n" 1076 1077 "set_fdir_input_set (port_id) " 1078 "(ipv4-frag|ipv4-tcp|ipv4-udp|ipv4-sctp|ipv4-other|" 1079 "ipv6-frag|ipv6-tcp|ipv6-udp|ipv6-sctp|ipv6-other|" 1080 "l2_payload) (ivlan|ethertype|src-ipv4|dst-ipv4|src-ipv6|" 1081 "dst-ipv6|ipv4-tos|ipv4-proto|ipv4-ttl|ipv6-tc|" 1082 "ipv6-next-header|ipv6-hop-limits|udp-src-port|" 1083 "udp-dst-port|tcp-src-port|tcp-dst-port|" 1084 "sctp-src-port|sctp-dst-port|sctp-veri-tag|none)" 1085 " (select|add)\n" 1086 " Set the input set for FDir.\n\n" 1087 1088 "flow validate {port_id}" 1089 " [group {group_id}] [priority {level}]" 1090 " [ingress] [egress]" 1091 " pattern {item} [/ {item} [...]] / end" 1092 " actions {action} [/ {action} [...]] / end\n" 1093 " Check whether a flow rule can be created.\n\n" 1094 1095 "flow create {port_id}" 1096 " [group {group_id}] [priority {level}]" 1097 " [ingress] [egress]" 1098 " pattern {item} [/ {item} [...]] / end" 1099 " actions {action} [/ {action} [...]] / end\n" 1100 " Create a flow rule.\n\n" 1101 1102 "flow destroy {port_id} rule {rule_id} [...]\n" 1103 " Destroy specific flow rules.\n\n" 1104 1105 "flow flush {port_id}\n" 1106 " Destroy all flow rules.\n\n" 1107 1108 "flow query {port_id} {rule_id} {action}\n" 1109 " Query an existing flow rule.\n\n" 1110 1111 "flow list {port_id} [group {group_id}] [...]\n" 1112 " List existing flow rules sorted by priority," 1113 " filtered by group identifiers.\n\n" 1114 1115 "flow isolate {port_id} {boolean}\n" 1116 " Restrict ingress traffic to the defined" 1117 " flow rules\n\n" 1118 1119 "set vxlan ip-version (ipv4|ipv6) vni (vni) udp-src" 1120 " (udp-src) udp-dst (udp-dst) ip-src (ip-src) ip-dst" 1121 " (ip-dst) eth-src (eth-src) eth-dst (eth-dst)\n" 1122 " Configure the VXLAN encapsulation for flows.\n\n" 1123 1124 "set vxlan-with-vlan ip-version (ipv4|ipv6) vni (vni)" 1125 " udp-src (udp-src) udp-dst (udp-dst) ip-src (ip-src)" 1126 " ip-dst (ip-dst) vlan-tci (vlan-tci) eth-src (eth-src)" 1127 " eth-dst (eth-dst)\n" 1128 " Configure the VXLAN encapsulation for flows.\n\n" 1129 1130 "set vxlan-tos-ttl ip-version (ipv4|ipv6) vni (vni) udp-src" 1131 " (udp-src) udp-dst (udp-dst) ip-tos (ip-tos) ip-ttl (ip-ttl)" 1132 " ip-src (ip-src) ip-dst (ip-dst) eth-src (eth-src)" 1133 " eth-dst (eth-dst)\n" 1134 " Configure the VXLAN encapsulation for flows.\n\n" 1135 1136 "set nvgre ip-version (ipv4|ipv6) tni (tni) ip-src" 1137 " (ip-src) ip-dst (ip-dst) eth-src (eth-src) eth-dst" 1138 " (eth-dst)\n" 1139 " Configure the NVGRE encapsulation for flows.\n\n" 1140 1141 "set nvgre-with-vlan ip-version (ipv4|ipv6) tni (tni)" 1142 " ip-src (ip-src) ip-dst (ip-dst) vlan-tci (vlan-tci)" 1143 " eth-src (eth-src) eth-dst (eth-dst)\n" 1144 " Configure the NVGRE encapsulation for flows.\n\n" 1145 1146 "set raw_encap {flow items}\n" 1147 " Configure the encapsulation with raw data.\n\n" 1148 1149 "set raw_decap {flow items}\n" 1150 " Configure the decapsulation with raw data.\n\n" 1151 1152 ); 1153 } 1154 1155 if (show_all || !strcmp(res->section, "traffic_management")) { 1156 cmdline_printf( 1157 cl, 1158 "\n" 1159 "Traffic Management:\n" 1160 "--------------\n" 1161 "show port tm cap (port_id)\n" 1162 " Display the port TM capability.\n\n" 1163 1164 "show port tm level cap (port_id) (level_id)\n" 1165 " Display the port TM hierarchical level capability.\n\n" 1166 1167 "show port tm node cap (port_id) (node_id)\n" 1168 " Display the port TM node capability.\n\n" 1169 1170 "show port tm node type (port_id) (node_id)\n" 1171 " Display the port TM node type.\n\n" 1172 1173 "show port tm node stats (port_id) (node_id) (clear)\n" 1174 " Display the port TM node stats.\n\n" 1175 1176 #if defined RTE_LIBRTE_PMD_SOFTNIC && defined RTE_LIBRTE_SCHED 1177 "set port tm hierarchy default (port_id)\n" 1178 " Set default traffic Management hierarchy on a port\n\n" 1179 #endif 1180 1181 "add port tm node shaper profile (port_id) (shaper_profile_id)" 1182 " (cmit_tb_rate) (cmit_tb_size) (peak_tb_rate) (peak_tb_size)" 1183 " (packet_length_adjust)\n" 1184 " Add port tm node private shaper profile.\n\n" 1185 1186 "del port tm node shaper profile (port_id) (shaper_profile_id)\n" 1187 " Delete port tm node private shaper profile.\n\n" 1188 1189 "add port tm node shared shaper (port_id) (shared_shaper_id)" 1190 " (shaper_profile_id)\n" 1191 " Add/update port tm node shared shaper.\n\n" 1192 1193 "del port tm node shared shaper (port_id) (shared_shaper_id)\n" 1194 " Delete port tm node shared shaper.\n\n" 1195 1196 "set port tm node shaper profile (port_id) (node_id)" 1197 " (shaper_profile_id)\n" 1198 " Set port tm node shaper profile.\n\n" 1199 1200 "add port tm node wred profile (port_id) (wred_profile_id)" 1201 " (color_g) (min_th_g) (max_th_g) (maxp_inv_g) (wq_log2_g)" 1202 " (color_y) (min_th_y) (max_th_y) (maxp_inv_y) (wq_log2_y)" 1203 " (color_r) (min_th_r) (max_th_r) (maxp_inv_r) (wq_log2_r)\n" 1204 " Add port tm node wred profile.\n\n" 1205 1206 "del port tm node wred profile (port_id) (wred_profile_id)\n" 1207 " Delete port tm node wred profile.\n\n" 1208 1209 "add port tm nonleaf node (port_id) (node_id) (parent_node_id)" 1210 " (priority) (weight) (level_id) (shaper_profile_id)" 1211 " (n_sp_priorities) (stats_mask) (n_shared_shapers)" 1212 " [(shared_shaper_id_0) (shared_shaper_id_1)...]\n" 1213 " Add port tm nonleaf node.\n\n" 1214 1215 "add port tm leaf node (port_id) (node_id) (parent_node_id)" 1216 " (priority) (weight) (level_id) (shaper_profile_id)" 1217 " (cman_mode) (wred_profile_id) (stats_mask) (n_shared_shapers)" 1218 " [(shared_shaper_id_0) (shared_shaper_id_1)...]\n" 1219 " Add port tm leaf node.\n\n" 1220 1221 "del port tm node (port_id) (node_id)\n" 1222 " Delete port tm node.\n\n" 1223 1224 "set port tm node parent (port_id) (node_id) (parent_node_id)" 1225 " (priority) (weight)\n" 1226 " Set port tm node parent.\n\n" 1227 1228 "suspend port tm node (port_id) (node_id)" 1229 " Suspend tm node.\n\n" 1230 1231 "resume port tm node (port_id) (node_id)" 1232 " Resume tm node.\n\n" 1233 1234 "port tm hierarchy commit (port_id) (clean_on_fail)\n" 1235 " Commit tm hierarchy.\n\n" 1236 1237 "set port tm mark ip_ecn (port) (green) (yellow)" 1238 " (red)\n" 1239 " Enables/Disables the traffic management marking" 1240 " for IP ECN (Explicit Congestion Notification)" 1241 " packets on a given port\n\n" 1242 1243 "set port tm mark ip_dscp (port) (green) (yellow)" 1244 " (red)\n" 1245 " Enables/Disables the traffic management marking" 1246 " on the port for IP dscp packets\n\n" 1247 1248 "set port tm mark vlan_dei (port) (green) (yellow)" 1249 " (red)\n" 1250 " Enables/Disables the traffic management marking" 1251 " on the port for VLAN packets with DEI enabled\n\n" 1252 ); 1253 } 1254 1255 if (show_all || !strcmp(res->section, "devices")) { 1256 cmdline_printf( 1257 cl, 1258 "\n" 1259 "Device Operations:\n" 1260 "--------------\n" 1261 "device detach (identifier)\n" 1262 " Detach device by identifier.\n\n" 1263 ); 1264 } 1265 1266 } 1267 1268 cmdline_parse_token_string_t cmd_help_long_help = 1269 TOKEN_STRING_INITIALIZER(struct cmd_help_long_result, help, "help"); 1270 1271 cmdline_parse_token_string_t cmd_help_long_section = 1272 TOKEN_STRING_INITIALIZER(struct cmd_help_long_result, section, 1273 "all#control#display#config#" 1274 "ports#registers#filters#traffic_management#devices"); 1275 1276 cmdline_parse_inst_t cmd_help_long = { 1277 .f = cmd_help_long_parsed, 1278 .data = NULL, 1279 .help_str = "help all|control|display|config|ports|register|" 1280 "filters|traffic_management|devices: " 1281 "Show help", 1282 .tokens = { 1283 (void *)&cmd_help_long_help, 1284 (void *)&cmd_help_long_section, 1285 NULL, 1286 }, 1287 }; 1288 1289 1290 /* *** start/stop/close all ports *** */ 1291 struct cmd_operate_port_result { 1292 cmdline_fixed_string_t keyword; 1293 cmdline_fixed_string_t name; 1294 cmdline_fixed_string_t value; 1295 }; 1296 1297 static void cmd_operate_port_parsed(void *parsed_result, 1298 __attribute__((unused)) struct cmdline *cl, 1299 __attribute__((unused)) void *data) 1300 { 1301 struct cmd_operate_port_result *res = parsed_result; 1302 1303 if (!strcmp(res->name, "start")) 1304 start_port(RTE_PORT_ALL); 1305 else if (!strcmp(res->name, "stop")) 1306 stop_port(RTE_PORT_ALL); 1307 else if (!strcmp(res->name, "close")) 1308 close_port(RTE_PORT_ALL); 1309 else if (!strcmp(res->name, "reset")) 1310 reset_port(RTE_PORT_ALL); 1311 else 1312 printf("Unknown parameter\n"); 1313 } 1314 1315 cmdline_parse_token_string_t cmd_operate_port_all_cmd = 1316 TOKEN_STRING_INITIALIZER(struct cmd_operate_port_result, keyword, 1317 "port"); 1318 cmdline_parse_token_string_t cmd_operate_port_all_port = 1319 TOKEN_STRING_INITIALIZER(struct cmd_operate_port_result, name, 1320 "start#stop#close#reset"); 1321 cmdline_parse_token_string_t cmd_operate_port_all_all = 1322 TOKEN_STRING_INITIALIZER(struct cmd_operate_port_result, value, "all"); 1323 1324 cmdline_parse_inst_t cmd_operate_port = { 1325 .f = cmd_operate_port_parsed, 1326 .data = NULL, 1327 .help_str = "port start|stop|close all: Start/Stop/Close/Reset all ports", 1328 .tokens = { 1329 (void *)&cmd_operate_port_all_cmd, 1330 (void *)&cmd_operate_port_all_port, 1331 (void *)&cmd_operate_port_all_all, 1332 NULL, 1333 }, 1334 }; 1335 1336 /* *** start/stop/close specific port *** */ 1337 struct cmd_operate_specific_port_result { 1338 cmdline_fixed_string_t keyword; 1339 cmdline_fixed_string_t name; 1340 uint8_t value; 1341 }; 1342 1343 static void cmd_operate_specific_port_parsed(void *parsed_result, 1344 __attribute__((unused)) struct cmdline *cl, 1345 __attribute__((unused)) void *data) 1346 { 1347 struct cmd_operate_specific_port_result *res = parsed_result; 1348 1349 if (!strcmp(res->name, "start")) 1350 start_port(res->value); 1351 else if (!strcmp(res->name, "stop")) 1352 stop_port(res->value); 1353 else if (!strcmp(res->name, "close")) 1354 close_port(res->value); 1355 else if (!strcmp(res->name, "reset")) 1356 reset_port(res->value); 1357 else 1358 printf("Unknown parameter\n"); 1359 } 1360 1361 cmdline_parse_token_string_t cmd_operate_specific_port_cmd = 1362 TOKEN_STRING_INITIALIZER(struct cmd_operate_specific_port_result, 1363 keyword, "port"); 1364 cmdline_parse_token_string_t cmd_operate_specific_port_port = 1365 TOKEN_STRING_INITIALIZER(struct cmd_operate_specific_port_result, 1366 name, "start#stop#close#reset"); 1367 cmdline_parse_token_num_t cmd_operate_specific_port_id = 1368 TOKEN_NUM_INITIALIZER(struct cmd_operate_specific_port_result, 1369 value, UINT8); 1370 1371 cmdline_parse_inst_t cmd_operate_specific_port = { 1372 .f = cmd_operate_specific_port_parsed, 1373 .data = NULL, 1374 .help_str = "port start|stop|close <port_id>: Start/Stop/Close/Reset port_id", 1375 .tokens = { 1376 (void *)&cmd_operate_specific_port_cmd, 1377 (void *)&cmd_operate_specific_port_port, 1378 (void *)&cmd_operate_specific_port_id, 1379 NULL, 1380 }, 1381 }; 1382 1383 /* *** enable port setup (after attach) via iterator or event *** */ 1384 struct cmd_set_port_setup_on_result { 1385 cmdline_fixed_string_t set; 1386 cmdline_fixed_string_t port; 1387 cmdline_fixed_string_t setup; 1388 cmdline_fixed_string_t on; 1389 cmdline_fixed_string_t mode; 1390 }; 1391 1392 static void cmd_set_port_setup_on_parsed(void *parsed_result, 1393 __attribute__((unused)) struct cmdline *cl, 1394 __attribute__((unused)) void *data) 1395 { 1396 struct cmd_set_port_setup_on_result *res = parsed_result; 1397 1398 if (strcmp(res->mode, "event") == 0) 1399 setup_on_probe_event = true; 1400 else if (strcmp(res->mode, "iterator") == 0) 1401 setup_on_probe_event = false; 1402 else 1403 printf("Unknown mode\n"); 1404 } 1405 1406 cmdline_parse_token_string_t cmd_set_port_setup_on_set = 1407 TOKEN_STRING_INITIALIZER(struct cmd_set_port_setup_on_result, 1408 set, "set"); 1409 cmdline_parse_token_string_t cmd_set_port_setup_on_port = 1410 TOKEN_STRING_INITIALIZER(struct cmd_set_port_setup_on_result, 1411 port, "port"); 1412 cmdline_parse_token_string_t cmd_set_port_setup_on_setup = 1413 TOKEN_STRING_INITIALIZER(struct cmd_set_port_setup_on_result, 1414 setup, "setup"); 1415 cmdline_parse_token_string_t cmd_set_port_setup_on_on = 1416 TOKEN_STRING_INITIALIZER(struct cmd_set_port_setup_on_result, 1417 on, "on"); 1418 cmdline_parse_token_string_t cmd_set_port_setup_on_mode = 1419 TOKEN_STRING_INITIALIZER(struct cmd_set_port_setup_on_result, 1420 mode, "iterator#event"); 1421 1422 cmdline_parse_inst_t cmd_set_port_setup_on = { 1423 .f = cmd_set_port_setup_on_parsed, 1424 .data = NULL, 1425 .help_str = "set port setup on iterator|event", 1426 .tokens = { 1427 (void *)&cmd_set_port_setup_on_set, 1428 (void *)&cmd_set_port_setup_on_port, 1429 (void *)&cmd_set_port_setup_on_setup, 1430 (void *)&cmd_set_port_setup_on_on, 1431 (void *)&cmd_set_port_setup_on_mode, 1432 NULL, 1433 }, 1434 }; 1435 1436 /* *** attach a specified port *** */ 1437 struct cmd_operate_attach_port_result { 1438 cmdline_fixed_string_t port; 1439 cmdline_fixed_string_t keyword; 1440 cmdline_multi_string_t identifier; 1441 }; 1442 1443 static void cmd_operate_attach_port_parsed(void *parsed_result, 1444 __attribute__((unused)) struct cmdline *cl, 1445 __attribute__((unused)) void *data) 1446 { 1447 struct cmd_operate_attach_port_result *res = parsed_result; 1448 1449 if (!strcmp(res->keyword, "attach")) 1450 attach_port(res->identifier); 1451 else 1452 printf("Unknown parameter\n"); 1453 } 1454 1455 cmdline_parse_token_string_t cmd_operate_attach_port_port = 1456 TOKEN_STRING_INITIALIZER(struct cmd_operate_attach_port_result, 1457 port, "port"); 1458 cmdline_parse_token_string_t cmd_operate_attach_port_keyword = 1459 TOKEN_STRING_INITIALIZER(struct cmd_operate_attach_port_result, 1460 keyword, "attach"); 1461 cmdline_parse_token_string_t cmd_operate_attach_port_identifier = 1462 TOKEN_STRING_INITIALIZER(struct cmd_operate_attach_port_result, 1463 identifier, TOKEN_STRING_MULTI); 1464 1465 cmdline_parse_inst_t cmd_operate_attach_port = { 1466 .f = cmd_operate_attach_port_parsed, 1467 .data = NULL, 1468 .help_str = "port attach <identifier>: " 1469 "(identifier: pci address or virtual dev name)", 1470 .tokens = { 1471 (void *)&cmd_operate_attach_port_port, 1472 (void *)&cmd_operate_attach_port_keyword, 1473 (void *)&cmd_operate_attach_port_identifier, 1474 NULL, 1475 }, 1476 }; 1477 1478 /* *** detach a specified port *** */ 1479 struct cmd_operate_detach_port_result { 1480 cmdline_fixed_string_t port; 1481 cmdline_fixed_string_t keyword; 1482 portid_t port_id; 1483 }; 1484 1485 static void cmd_operate_detach_port_parsed(void *parsed_result, 1486 __attribute__((unused)) struct cmdline *cl, 1487 __attribute__((unused)) void *data) 1488 { 1489 struct cmd_operate_detach_port_result *res = parsed_result; 1490 1491 if (!strcmp(res->keyword, "detach")) { 1492 RTE_ETH_VALID_PORTID_OR_RET(res->port_id); 1493 detach_port_device(res->port_id); 1494 } else { 1495 printf("Unknown parameter\n"); 1496 } 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_devargs(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_TX_PAUSE}, {RTE_FC_RX_PAUSE, RTE_FC_FULL} 7084 }; 7085 7086 memset(&pfc_conf, 0, sizeof(struct rte_eth_pfc_conf)); 7087 rx_fc_enable = (!strncmp(res->rx_pfc_mode, "on",2)) ? 1 : 0; 7088 tx_fc_enable = (!strncmp(res->tx_pfc_mode, "on",2)) ? 1 : 0; 7089 pfc_conf.fc.mode = rx_tx_onoff_2_pfc_mode[rx_fc_enable][tx_fc_enable]; 7090 pfc_conf.fc.high_water = res->high_water; 7091 pfc_conf.fc.low_water = res->low_water; 7092 pfc_conf.fc.pause_time = res->pause_time; 7093 pfc_conf.priority = res->priority; 7094 7095 ret = rte_eth_dev_priority_flow_ctrl_set(res->port_id, &pfc_conf); 7096 if (ret != 0) 7097 printf("bad priority flow contrl parameter, return code = %d \n", ret); 7098 } 7099 7100 cmdline_parse_token_string_t cmd_pfc_set_set = 7101 TOKEN_STRING_INITIALIZER(struct cmd_priority_flow_ctrl_set_result, 7102 set, "set"); 7103 cmdline_parse_token_string_t cmd_pfc_set_flow_ctrl = 7104 TOKEN_STRING_INITIALIZER(struct cmd_priority_flow_ctrl_set_result, 7105 pfc_ctrl, "pfc_ctrl"); 7106 cmdline_parse_token_string_t cmd_pfc_set_rx = 7107 TOKEN_STRING_INITIALIZER(struct cmd_priority_flow_ctrl_set_result, 7108 rx, "rx"); 7109 cmdline_parse_token_string_t cmd_pfc_set_rx_mode = 7110 TOKEN_STRING_INITIALIZER(struct cmd_priority_flow_ctrl_set_result, 7111 rx_pfc_mode, "on#off"); 7112 cmdline_parse_token_string_t cmd_pfc_set_tx = 7113 TOKEN_STRING_INITIALIZER(struct cmd_priority_flow_ctrl_set_result, 7114 tx, "tx"); 7115 cmdline_parse_token_string_t cmd_pfc_set_tx_mode = 7116 TOKEN_STRING_INITIALIZER(struct cmd_priority_flow_ctrl_set_result, 7117 tx_pfc_mode, "on#off"); 7118 cmdline_parse_token_num_t cmd_pfc_set_high_water = 7119 TOKEN_NUM_INITIALIZER(struct cmd_priority_flow_ctrl_set_result, 7120 high_water, UINT32); 7121 cmdline_parse_token_num_t cmd_pfc_set_low_water = 7122 TOKEN_NUM_INITIALIZER(struct cmd_priority_flow_ctrl_set_result, 7123 low_water, UINT32); 7124 cmdline_parse_token_num_t cmd_pfc_set_pause_time = 7125 TOKEN_NUM_INITIALIZER(struct cmd_priority_flow_ctrl_set_result, 7126 pause_time, UINT16); 7127 cmdline_parse_token_num_t cmd_pfc_set_priority = 7128 TOKEN_NUM_INITIALIZER(struct cmd_priority_flow_ctrl_set_result, 7129 priority, UINT8); 7130 cmdline_parse_token_num_t cmd_pfc_set_portid = 7131 TOKEN_NUM_INITIALIZER(struct cmd_priority_flow_ctrl_set_result, 7132 port_id, UINT16); 7133 7134 cmdline_parse_inst_t cmd_priority_flow_control_set = { 7135 .f = cmd_priority_flow_ctrl_set_parsed, 7136 .data = NULL, 7137 .help_str = "set pfc_ctrl rx on|off tx on|off <high_water> <low_water> " 7138 "<pause_time> <priority> <port_id>: " 7139 "Configure the Ethernet priority flow control", 7140 .tokens = { 7141 (void *)&cmd_pfc_set_set, 7142 (void *)&cmd_pfc_set_flow_ctrl, 7143 (void *)&cmd_pfc_set_rx, 7144 (void *)&cmd_pfc_set_rx_mode, 7145 (void *)&cmd_pfc_set_tx, 7146 (void *)&cmd_pfc_set_tx_mode, 7147 (void *)&cmd_pfc_set_high_water, 7148 (void *)&cmd_pfc_set_low_water, 7149 (void *)&cmd_pfc_set_pause_time, 7150 (void *)&cmd_pfc_set_priority, 7151 (void *)&cmd_pfc_set_portid, 7152 NULL, 7153 }, 7154 }; 7155 7156 /* *** RESET CONFIGURATION *** */ 7157 struct cmd_reset_result { 7158 cmdline_fixed_string_t reset; 7159 cmdline_fixed_string_t def; 7160 }; 7161 7162 static void cmd_reset_parsed(__attribute__((unused)) void *parsed_result, 7163 struct cmdline *cl, 7164 __attribute__((unused)) void *data) 7165 { 7166 cmdline_printf(cl, "Reset to default forwarding configuration...\n"); 7167 set_def_fwd_config(); 7168 } 7169 7170 cmdline_parse_token_string_t cmd_reset_set = 7171 TOKEN_STRING_INITIALIZER(struct cmd_reset_result, reset, "set"); 7172 cmdline_parse_token_string_t cmd_reset_def = 7173 TOKEN_STRING_INITIALIZER(struct cmd_reset_result, def, 7174 "default"); 7175 7176 cmdline_parse_inst_t cmd_reset = { 7177 .f = cmd_reset_parsed, 7178 .data = NULL, 7179 .help_str = "set default: Reset default forwarding configuration", 7180 .tokens = { 7181 (void *)&cmd_reset_set, 7182 (void *)&cmd_reset_def, 7183 NULL, 7184 }, 7185 }; 7186 7187 /* *** START FORWARDING *** */ 7188 struct cmd_start_result { 7189 cmdline_fixed_string_t start; 7190 }; 7191 7192 cmdline_parse_token_string_t cmd_start_start = 7193 TOKEN_STRING_INITIALIZER(struct cmd_start_result, start, "start"); 7194 7195 static void cmd_start_parsed(__attribute__((unused)) void *parsed_result, 7196 __attribute__((unused)) struct cmdline *cl, 7197 __attribute__((unused)) void *data) 7198 { 7199 start_packet_forwarding(0); 7200 } 7201 7202 cmdline_parse_inst_t cmd_start = { 7203 .f = cmd_start_parsed, 7204 .data = NULL, 7205 .help_str = "start: Start packet forwarding", 7206 .tokens = { 7207 (void *)&cmd_start_start, 7208 NULL, 7209 }, 7210 }; 7211 7212 /* *** START FORWARDING WITH ONE TX BURST FIRST *** */ 7213 struct cmd_start_tx_first_result { 7214 cmdline_fixed_string_t start; 7215 cmdline_fixed_string_t tx_first; 7216 }; 7217 7218 static void 7219 cmd_start_tx_first_parsed(__attribute__((unused)) void *parsed_result, 7220 __attribute__((unused)) struct cmdline *cl, 7221 __attribute__((unused)) void *data) 7222 { 7223 start_packet_forwarding(1); 7224 } 7225 7226 cmdline_parse_token_string_t cmd_start_tx_first_start = 7227 TOKEN_STRING_INITIALIZER(struct cmd_start_tx_first_result, start, 7228 "start"); 7229 cmdline_parse_token_string_t cmd_start_tx_first_tx_first = 7230 TOKEN_STRING_INITIALIZER(struct cmd_start_tx_first_result, 7231 tx_first, "tx_first"); 7232 7233 cmdline_parse_inst_t cmd_start_tx_first = { 7234 .f = cmd_start_tx_first_parsed, 7235 .data = NULL, 7236 .help_str = "start tx_first: Start packet forwarding, " 7237 "after sending 1 burst of packets", 7238 .tokens = { 7239 (void *)&cmd_start_tx_first_start, 7240 (void *)&cmd_start_tx_first_tx_first, 7241 NULL, 7242 }, 7243 }; 7244 7245 /* *** START FORWARDING WITH N TX BURST FIRST *** */ 7246 struct cmd_start_tx_first_n_result { 7247 cmdline_fixed_string_t start; 7248 cmdline_fixed_string_t tx_first; 7249 uint32_t tx_num; 7250 }; 7251 7252 static void 7253 cmd_start_tx_first_n_parsed(void *parsed_result, 7254 __attribute__((unused)) struct cmdline *cl, 7255 __attribute__((unused)) void *data) 7256 { 7257 struct cmd_start_tx_first_n_result *res = parsed_result; 7258 7259 start_packet_forwarding(res->tx_num); 7260 } 7261 7262 cmdline_parse_token_string_t cmd_start_tx_first_n_start = 7263 TOKEN_STRING_INITIALIZER(struct cmd_start_tx_first_n_result, 7264 start, "start"); 7265 cmdline_parse_token_string_t cmd_start_tx_first_n_tx_first = 7266 TOKEN_STRING_INITIALIZER(struct cmd_start_tx_first_n_result, 7267 tx_first, "tx_first"); 7268 cmdline_parse_token_num_t cmd_start_tx_first_n_tx_num = 7269 TOKEN_NUM_INITIALIZER(struct cmd_start_tx_first_n_result, 7270 tx_num, UINT32); 7271 7272 cmdline_parse_inst_t cmd_start_tx_first_n = { 7273 .f = cmd_start_tx_first_n_parsed, 7274 .data = NULL, 7275 .help_str = "start tx_first <num>: " 7276 "packet forwarding, after sending <num> bursts of packets", 7277 .tokens = { 7278 (void *)&cmd_start_tx_first_n_start, 7279 (void *)&cmd_start_tx_first_n_tx_first, 7280 (void *)&cmd_start_tx_first_n_tx_num, 7281 NULL, 7282 }, 7283 }; 7284 7285 /* *** SET LINK UP *** */ 7286 struct cmd_set_link_up_result { 7287 cmdline_fixed_string_t set; 7288 cmdline_fixed_string_t link_up; 7289 cmdline_fixed_string_t port; 7290 portid_t port_id; 7291 }; 7292 7293 cmdline_parse_token_string_t cmd_set_link_up_set = 7294 TOKEN_STRING_INITIALIZER(struct cmd_set_link_up_result, set, "set"); 7295 cmdline_parse_token_string_t cmd_set_link_up_link_up = 7296 TOKEN_STRING_INITIALIZER(struct cmd_set_link_up_result, link_up, 7297 "link-up"); 7298 cmdline_parse_token_string_t cmd_set_link_up_port = 7299 TOKEN_STRING_INITIALIZER(struct cmd_set_link_up_result, port, "port"); 7300 cmdline_parse_token_num_t cmd_set_link_up_port_id = 7301 TOKEN_NUM_INITIALIZER(struct cmd_set_link_up_result, port_id, UINT16); 7302 7303 static void cmd_set_link_up_parsed(__attribute__((unused)) void *parsed_result, 7304 __attribute__((unused)) struct cmdline *cl, 7305 __attribute__((unused)) void *data) 7306 { 7307 struct cmd_set_link_up_result *res = parsed_result; 7308 dev_set_link_up(res->port_id); 7309 } 7310 7311 cmdline_parse_inst_t cmd_set_link_up = { 7312 .f = cmd_set_link_up_parsed, 7313 .data = NULL, 7314 .help_str = "set link-up port <port id>", 7315 .tokens = { 7316 (void *)&cmd_set_link_up_set, 7317 (void *)&cmd_set_link_up_link_up, 7318 (void *)&cmd_set_link_up_port, 7319 (void *)&cmd_set_link_up_port_id, 7320 NULL, 7321 }, 7322 }; 7323 7324 /* *** SET LINK DOWN *** */ 7325 struct cmd_set_link_down_result { 7326 cmdline_fixed_string_t set; 7327 cmdline_fixed_string_t link_down; 7328 cmdline_fixed_string_t port; 7329 portid_t port_id; 7330 }; 7331 7332 cmdline_parse_token_string_t cmd_set_link_down_set = 7333 TOKEN_STRING_INITIALIZER(struct cmd_set_link_down_result, set, "set"); 7334 cmdline_parse_token_string_t cmd_set_link_down_link_down = 7335 TOKEN_STRING_INITIALIZER(struct cmd_set_link_down_result, link_down, 7336 "link-down"); 7337 cmdline_parse_token_string_t cmd_set_link_down_port = 7338 TOKEN_STRING_INITIALIZER(struct cmd_set_link_down_result, port, "port"); 7339 cmdline_parse_token_num_t cmd_set_link_down_port_id = 7340 TOKEN_NUM_INITIALIZER(struct cmd_set_link_down_result, port_id, UINT16); 7341 7342 static void cmd_set_link_down_parsed( 7343 __attribute__((unused)) void *parsed_result, 7344 __attribute__((unused)) struct cmdline *cl, 7345 __attribute__((unused)) void *data) 7346 { 7347 struct cmd_set_link_down_result *res = parsed_result; 7348 dev_set_link_down(res->port_id); 7349 } 7350 7351 cmdline_parse_inst_t cmd_set_link_down = { 7352 .f = cmd_set_link_down_parsed, 7353 .data = NULL, 7354 .help_str = "set link-down port <port id>", 7355 .tokens = { 7356 (void *)&cmd_set_link_down_set, 7357 (void *)&cmd_set_link_down_link_down, 7358 (void *)&cmd_set_link_down_port, 7359 (void *)&cmd_set_link_down_port_id, 7360 NULL, 7361 }, 7362 }; 7363 7364 /* *** SHOW CFG *** */ 7365 struct cmd_showcfg_result { 7366 cmdline_fixed_string_t show; 7367 cmdline_fixed_string_t cfg; 7368 cmdline_fixed_string_t what; 7369 }; 7370 7371 static void cmd_showcfg_parsed(void *parsed_result, 7372 __attribute__((unused)) struct cmdline *cl, 7373 __attribute__((unused)) void *data) 7374 { 7375 struct cmd_showcfg_result *res = parsed_result; 7376 if (!strcmp(res->what, "rxtx")) 7377 rxtx_config_display(); 7378 else if (!strcmp(res->what, "cores")) 7379 fwd_lcores_config_display(); 7380 else if (!strcmp(res->what, "fwd")) 7381 pkt_fwd_config_display(&cur_fwd_config); 7382 else if (!strcmp(res->what, "txpkts")) 7383 show_tx_pkt_segments(); 7384 } 7385 7386 cmdline_parse_token_string_t cmd_showcfg_show = 7387 TOKEN_STRING_INITIALIZER(struct cmd_showcfg_result, show, "show"); 7388 cmdline_parse_token_string_t cmd_showcfg_port = 7389 TOKEN_STRING_INITIALIZER(struct cmd_showcfg_result, cfg, "config"); 7390 cmdline_parse_token_string_t cmd_showcfg_what = 7391 TOKEN_STRING_INITIALIZER(struct cmd_showcfg_result, what, 7392 "rxtx#cores#fwd#txpkts"); 7393 7394 cmdline_parse_inst_t cmd_showcfg = { 7395 .f = cmd_showcfg_parsed, 7396 .data = NULL, 7397 .help_str = "show config rxtx|cores|fwd|txpkts", 7398 .tokens = { 7399 (void *)&cmd_showcfg_show, 7400 (void *)&cmd_showcfg_port, 7401 (void *)&cmd_showcfg_what, 7402 NULL, 7403 }, 7404 }; 7405 7406 /* *** SHOW ALL PORT INFO *** */ 7407 struct cmd_showportall_result { 7408 cmdline_fixed_string_t show; 7409 cmdline_fixed_string_t port; 7410 cmdline_fixed_string_t what; 7411 cmdline_fixed_string_t all; 7412 }; 7413 7414 static void cmd_showportall_parsed(void *parsed_result, 7415 __attribute__((unused)) struct cmdline *cl, 7416 __attribute__((unused)) void *data) 7417 { 7418 portid_t i; 7419 7420 struct cmd_showportall_result *res = parsed_result; 7421 if (!strcmp(res->show, "clear")) { 7422 if (!strcmp(res->what, "stats")) 7423 RTE_ETH_FOREACH_DEV(i) 7424 nic_stats_clear(i); 7425 else if (!strcmp(res->what, "xstats")) 7426 RTE_ETH_FOREACH_DEV(i) 7427 nic_xstats_clear(i); 7428 } else if (!strcmp(res->what, "info")) 7429 RTE_ETH_FOREACH_DEV(i) 7430 port_infos_display(i); 7431 else if (!strcmp(res->what, "summary")) { 7432 port_summary_header_display(); 7433 RTE_ETH_FOREACH_DEV(i) 7434 port_summary_display(i); 7435 } 7436 else if (!strcmp(res->what, "stats")) 7437 RTE_ETH_FOREACH_DEV(i) 7438 nic_stats_display(i); 7439 else if (!strcmp(res->what, "xstats")) 7440 RTE_ETH_FOREACH_DEV(i) 7441 nic_xstats_display(i); 7442 else if (!strcmp(res->what, "fdir")) 7443 RTE_ETH_FOREACH_DEV(i) 7444 fdir_get_infos(i); 7445 else if (!strcmp(res->what, "stat_qmap")) 7446 RTE_ETH_FOREACH_DEV(i) 7447 nic_stats_mapping_display(i); 7448 else if (!strcmp(res->what, "dcb_tc")) 7449 RTE_ETH_FOREACH_DEV(i) 7450 port_dcb_info_display(i); 7451 else if (!strcmp(res->what, "cap")) 7452 RTE_ETH_FOREACH_DEV(i) 7453 port_offload_cap_display(i); 7454 } 7455 7456 cmdline_parse_token_string_t cmd_showportall_show = 7457 TOKEN_STRING_INITIALIZER(struct cmd_showportall_result, show, 7458 "show#clear"); 7459 cmdline_parse_token_string_t cmd_showportall_port = 7460 TOKEN_STRING_INITIALIZER(struct cmd_showportall_result, port, "port"); 7461 cmdline_parse_token_string_t cmd_showportall_what = 7462 TOKEN_STRING_INITIALIZER(struct cmd_showportall_result, what, 7463 "info#summary#stats#xstats#fdir#stat_qmap#dcb_tc#cap"); 7464 cmdline_parse_token_string_t cmd_showportall_all = 7465 TOKEN_STRING_INITIALIZER(struct cmd_showportall_result, all, "all"); 7466 cmdline_parse_inst_t cmd_showportall = { 7467 .f = cmd_showportall_parsed, 7468 .data = NULL, 7469 .help_str = "show|clear port " 7470 "info|summary|stats|xstats|fdir|stat_qmap|dcb_tc|cap all", 7471 .tokens = { 7472 (void *)&cmd_showportall_show, 7473 (void *)&cmd_showportall_port, 7474 (void *)&cmd_showportall_what, 7475 (void *)&cmd_showportall_all, 7476 NULL, 7477 }, 7478 }; 7479 7480 /* *** SHOW PORT INFO *** */ 7481 struct cmd_showport_result { 7482 cmdline_fixed_string_t show; 7483 cmdline_fixed_string_t port; 7484 cmdline_fixed_string_t what; 7485 uint16_t portnum; 7486 }; 7487 7488 static void cmd_showport_parsed(void *parsed_result, 7489 __attribute__((unused)) struct cmdline *cl, 7490 __attribute__((unused)) void *data) 7491 { 7492 struct cmd_showport_result *res = parsed_result; 7493 if (!strcmp(res->show, "clear")) { 7494 if (!strcmp(res->what, "stats")) 7495 nic_stats_clear(res->portnum); 7496 else if (!strcmp(res->what, "xstats")) 7497 nic_xstats_clear(res->portnum); 7498 } else if (!strcmp(res->what, "info")) 7499 port_infos_display(res->portnum); 7500 else if (!strcmp(res->what, "summary")) { 7501 port_summary_header_display(); 7502 port_summary_display(res->portnum); 7503 } 7504 else if (!strcmp(res->what, "stats")) 7505 nic_stats_display(res->portnum); 7506 else if (!strcmp(res->what, "xstats")) 7507 nic_xstats_display(res->portnum); 7508 else if (!strcmp(res->what, "fdir")) 7509 fdir_get_infos(res->portnum); 7510 else if (!strcmp(res->what, "stat_qmap")) 7511 nic_stats_mapping_display(res->portnum); 7512 else if (!strcmp(res->what, "dcb_tc")) 7513 port_dcb_info_display(res->portnum); 7514 else if (!strcmp(res->what, "cap")) 7515 port_offload_cap_display(res->portnum); 7516 } 7517 7518 cmdline_parse_token_string_t cmd_showport_show = 7519 TOKEN_STRING_INITIALIZER(struct cmd_showport_result, show, 7520 "show#clear"); 7521 cmdline_parse_token_string_t cmd_showport_port = 7522 TOKEN_STRING_INITIALIZER(struct cmd_showport_result, port, "port"); 7523 cmdline_parse_token_string_t cmd_showport_what = 7524 TOKEN_STRING_INITIALIZER(struct cmd_showport_result, what, 7525 "info#summary#stats#xstats#fdir#stat_qmap#dcb_tc#cap"); 7526 cmdline_parse_token_num_t cmd_showport_portnum = 7527 TOKEN_NUM_INITIALIZER(struct cmd_showport_result, portnum, UINT16); 7528 7529 cmdline_parse_inst_t cmd_showport = { 7530 .f = cmd_showport_parsed, 7531 .data = NULL, 7532 .help_str = "show|clear port " 7533 "info|summary|stats|xstats|fdir|stat_qmap|dcb_tc|cap " 7534 "<port_id>", 7535 .tokens = { 7536 (void *)&cmd_showport_show, 7537 (void *)&cmd_showport_port, 7538 (void *)&cmd_showport_what, 7539 (void *)&cmd_showport_portnum, 7540 NULL, 7541 }, 7542 }; 7543 7544 /* *** SHOW DEVICE INFO *** */ 7545 struct cmd_showdevice_result { 7546 cmdline_fixed_string_t show; 7547 cmdline_fixed_string_t device; 7548 cmdline_fixed_string_t what; 7549 cmdline_fixed_string_t identifier; 7550 }; 7551 7552 static void cmd_showdevice_parsed(void *parsed_result, 7553 __attribute__((unused)) struct cmdline *cl, 7554 __attribute__((unused)) void *data) 7555 { 7556 struct cmd_showdevice_result *res = parsed_result; 7557 if (!strcmp(res->what, "info")) { 7558 if (!strcmp(res->identifier, "all")) 7559 device_infos_display(NULL); 7560 else 7561 device_infos_display(res->identifier); 7562 } 7563 } 7564 7565 cmdline_parse_token_string_t cmd_showdevice_show = 7566 TOKEN_STRING_INITIALIZER(struct cmd_showdevice_result, show, 7567 "show"); 7568 cmdline_parse_token_string_t cmd_showdevice_device = 7569 TOKEN_STRING_INITIALIZER(struct cmd_showdevice_result, device, "device"); 7570 cmdline_parse_token_string_t cmd_showdevice_what = 7571 TOKEN_STRING_INITIALIZER(struct cmd_showdevice_result, what, 7572 "info"); 7573 cmdline_parse_token_string_t cmd_showdevice_identifier = 7574 TOKEN_STRING_INITIALIZER(struct cmd_showdevice_result, 7575 identifier, NULL); 7576 7577 cmdline_parse_inst_t cmd_showdevice = { 7578 .f = cmd_showdevice_parsed, 7579 .data = NULL, 7580 .help_str = "show device info <identifier>|all", 7581 .tokens = { 7582 (void *)&cmd_showdevice_show, 7583 (void *)&cmd_showdevice_device, 7584 (void *)&cmd_showdevice_what, 7585 (void *)&cmd_showdevice_identifier, 7586 NULL, 7587 }, 7588 }; 7589 /* *** SHOW QUEUE INFO *** */ 7590 struct cmd_showqueue_result { 7591 cmdline_fixed_string_t show; 7592 cmdline_fixed_string_t type; 7593 cmdline_fixed_string_t what; 7594 uint16_t portnum; 7595 uint16_t queuenum; 7596 }; 7597 7598 static void 7599 cmd_showqueue_parsed(void *parsed_result, 7600 __attribute__((unused)) struct cmdline *cl, 7601 __attribute__((unused)) void *data) 7602 { 7603 struct cmd_showqueue_result *res = parsed_result; 7604 7605 if (!strcmp(res->type, "rxq")) 7606 rx_queue_infos_display(res->portnum, res->queuenum); 7607 else if (!strcmp(res->type, "txq")) 7608 tx_queue_infos_display(res->portnum, res->queuenum); 7609 } 7610 7611 cmdline_parse_token_string_t cmd_showqueue_show = 7612 TOKEN_STRING_INITIALIZER(struct cmd_showqueue_result, show, "show"); 7613 cmdline_parse_token_string_t cmd_showqueue_type = 7614 TOKEN_STRING_INITIALIZER(struct cmd_showqueue_result, type, "rxq#txq"); 7615 cmdline_parse_token_string_t cmd_showqueue_what = 7616 TOKEN_STRING_INITIALIZER(struct cmd_showqueue_result, what, "info"); 7617 cmdline_parse_token_num_t cmd_showqueue_portnum = 7618 TOKEN_NUM_INITIALIZER(struct cmd_showqueue_result, portnum, UINT16); 7619 cmdline_parse_token_num_t cmd_showqueue_queuenum = 7620 TOKEN_NUM_INITIALIZER(struct cmd_showqueue_result, queuenum, UINT16); 7621 7622 cmdline_parse_inst_t cmd_showqueue = { 7623 .f = cmd_showqueue_parsed, 7624 .data = NULL, 7625 .help_str = "show rxq|txq info <port_id> <queue_id>", 7626 .tokens = { 7627 (void *)&cmd_showqueue_show, 7628 (void *)&cmd_showqueue_type, 7629 (void *)&cmd_showqueue_what, 7630 (void *)&cmd_showqueue_portnum, 7631 (void *)&cmd_showqueue_queuenum, 7632 NULL, 7633 }, 7634 }; 7635 7636 /* show/clear fwd engine statistics */ 7637 struct fwd_result { 7638 cmdline_fixed_string_t action; 7639 cmdline_fixed_string_t fwd; 7640 cmdline_fixed_string_t stats; 7641 cmdline_fixed_string_t all; 7642 }; 7643 7644 cmdline_parse_token_string_t cmd_fwd_action = 7645 TOKEN_STRING_INITIALIZER(struct fwd_result, action, "show#clear"); 7646 cmdline_parse_token_string_t cmd_fwd_fwd = 7647 TOKEN_STRING_INITIALIZER(struct fwd_result, fwd, "fwd"); 7648 cmdline_parse_token_string_t cmd_fwd_stats = 7649 TOKEN_STRING_INITIALIZER(struct fwd_result, stats, "stats"); 7650 cmdline_parse_token_string_t cmd_fwd_all = 7651 TOKEN_STRING_INITIALIZER(struct fwd_result, all, "all"); 7652 7653 static void 7654 cmd_showfwdall_parsed(void *parsed_result, 7655 __rte_unused struct cmdline *cl, 7656 __rte_unused void *data) 7657 { 7658 struct fwd_result *res = parsed_result; 7659 7660 if (!strcmp(res->action, "show")) 7661 fwd_stats_display(); 7662 else 7663 fwd_stats_reset(); 7664 } 7665 7666 static cmdline_parse_inst_t cmd_showfwdall = { 7667 .f = cmd_showfwdall_parsed, 7668 .data = NULL, 7669 .help_str = "show|clear fwd stats all", 7670 .tokens = { 7671 (void *)&cmd_fwd_action, 7672 (void *)&cmd_fwd_fwd, 7673 (void *)&cmd_fwd_stats, 7674 (void *)&cmd_fwd_all, 7675 NULL, 7676 }, 7677 }; 7678 7679 /* *** READ PORT REGISTER *** */ 7680 struct cmd_read_reg_result { 7681 cmdline_fixed_string_t read; 7682 cmdline_fixed_string_t reg; 7683 portid_t port_id; 7684 uint32_t reg_off; 7685 }; 7686 7687 static void 7688 cmd_read_reg_parsed(void *parsed_result, 7689 __attribute__((unused)) struct cmdline *cl, 7690 __attribute__((unused)) void *data) 7691 { 7692 struct cmd_read_reg_result *res = parsed_result; 7693 port_reg_display(res->port_id, res->reg_off); 7694 } 7695 7696 cmdline_parse_token_string_t cmd_read_reg_read = 7697 TOKEN_STRING_INITIALIZER(struct cmd_read_reg_result, read, "read"); 7698 cmdline_parse_token_string_t cmd_read_reg_reg = 7699 TOKEN_STRING_INITIALIZER(struct cmd_read_reg_result, reg, "reg"); 7700 cmdline_parse_token_num_t cmd_read_reg_port_id = 7701 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_result, port_id, UINT16); 7702 cmdline_parse_token_num_t cmd_read_reg_reg_off = 7703 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_result, reg_off, UINT32); 7704 7705 cmdline_parse_inst_t cmd_read_reg = { 7706 .f = cmd_read_reg_parsed, 7707 .data = NULL, 7708 .help_str = "read reg <port_id> <reg_off>", 7709 .tokens = { 7710 (void *)&cmd_read_reg_read, 7711 (void *)&cmd_read_reg_reg, 7712 (void *)&cmd_read_reg_port_id, 7713 (void *)&cmd_read_reg_reg_off, 7714 NULL, 7715 }, 7716 }; 7717 7718 /* *** READ PORT REGISTER BIT FIELD *** */ 7719 struct cmd_read_reg_bit_field_result { 7720 cmdline_fixed_string_t read; 7721 cmdline_fixed_string_t regfield; 7722 portid_t port_id; 7723 uint32_t reg_off; 7724 uint8_t bit1_pos; 7725 uint8_t bit2_pos; 7726 }; 7727 7728 static void 7729 cmd_read_reg_bit_field_parsed(void *parsed_result, 7730 __attribute__((unused)) struct cmdline *cl, 7731 __attribute__((unused)) void *data) 7732 { 7733 struct cmd_read_reg_bit_field_result *res = parsed_result; 7734 port_reg_bit_field_display(res->port_id, res->reg_off, 7735 res->bit1_pos, res->bit2_pos); 7736 } 7737 7738 cmdline_parse_token_string_t cmd_read_reg_bit_field_read = 7739 TOKEN_STRING_INITIALIZER(struct cmd_read_reg_bit_field_result, read, 7740 "read"); 7741 cmdline_parse_token_string_t cmd_read_reg_bit_field_regfield = 7742 TOKEN_STRING_INITIALIZER(struct cmd_read_reg_bit_field_result, 7743 regfield, "regfield"); 7744 cmdline_parse_token_num_t cmd_read_reg_bit_field_port_id = 7745 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_field_result, port_id, 7746 UINT16); 7747 cmdline_parse_token_num_t cmd_read_reg_bit_field_reg_off = 7748 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_field_result, reg_off, 7749 UINT32); 7750 cmdline_parse_token_num_t cmd_read_reg_bit_field_bit1_pos = 7751 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_field_result, bit1_pos, 7752 UINT8); 7753 cmdline_parse_token_num_t cmd_read_reg_bit_field_bit2_pos = 7754 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_field_result, bit2_pos, 7755 UINT8); 7756 7757 cmdline_parse_inst_t cmd_read_reg_bit_field = { 7758 .f = cmd_read_reg_bit_field_parsed, 7759 .data = NULL, 7760 .help_str = "read regfield <port_id> <reg_off> <bit_x> <bit_y>: " 7761 "Read register bit field between bit_x and bit_y included", 7762 .tokens = { 7763 (void *)&cmd_read_reg_bit_field_read, 7764 (void *)&cmd_read_reg_bit_field_regfield, 7765 (void *)&cmd_read_reg_bit_field_port_id, 7766 (void *)&cmd_read_reg_bit_field_reg_off, 7767 (void *)&cmd_read_reg_bit_field_bit1_pos, 7768 (void *)&cmd_read_reg_bit_field_bit2_pos, 7769 NULL, 7770 }, 7771 }; 7772 7773 /* *** READ PORT REGISTER BIT *** */ 7774 struct cmd_read_reg_bit_result { 7775 cmdline_fixed_string_t read; 7776 cmdline_fixed_string_t regbit; 7777 portid_t port_id; 7778 uint32_t reg_off; 7779 uint8_t bit_pos; 7780 }; 7781 7782 static void 7783 cmd_read_reg_bit_parsed(void *parsed_result, 7784 __attribute__((unused)) struct cmdline *cl, 7785 __attribute__((unused)) void *data) 7786 { 7787 struct cmd_read_reg_bit_result *res = parsed_result; 7788 port_reg_bit_display(res->port_id, res->reg_off, res->bit_pos); 7789 } 7790 7791 cmdline_parse_token_string_t cmd_read_reg_bit_read = 7792 TOKEN_STRING_INITIALIZER(struct cmd_read_reg_bit_result, read, "read"); 7793 cmdline_parse_token_string_t cmd_read_reg_bit_regbit = 7794 TOKEN_STRING_INITIALIZER(struct cmd_read_reg_bit_result, 7795 regbit, "regbit"); 7796 cmdline_parse_token_num_t cmd_read_reg_bit_port_id = 7797 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_result, port_id, UINT16); 7798 cmdline_parse_token_num_t cmd_read_reg_bit_reg_off = 7799 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_result, reg_off, UINT32); 7800 cmdline_parse_token_num_t cmd_read_reg_bit_bit_pos = 7801 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_result, bit_pos, UINT8); 7802 7803 cmdline_parse_inst_t cmd_read_reg_bit = { 7804 .f = cmd_read_reg_bit_parsed, 7805 .data = NULL, 7806 .help_str = "read regbit <port_id> <reg_off> <bit_x>: 0 <= bit_x <= 31", 7807 .tokens = { 7808 (void *)&cmd_read_reg_bit_read, 7809 (void *)&cmd_read_reg_bit_regbit, 7810 (void *)&cmd_read_reg_bit_port_id, 7811 (void *)&cmd_read_reg_bit_reg_off, 7812 (void *)&cmd_read_reg_bit_bit_pos, 7813 NULL, 7814 }, 7815 }; 7816 7817 /* *** WRITE PORT REGISTER *** */ 7818 struct cmd_write_reg_result { 7819 cmdline_fixed_string_t write; 7820 cmdline_fixed_string_t reg; 7821 portid_t port_id; 7822 uint32_t reg_off; 7823 uint32_t value; 7824 }; 7825 7826 static void 7827 cmd_write_reg_parsed(void *parsed_result, 7828 __attribute__((unused)) struct cmdline *cl, 7829 __attribute__((unused)) void *data) 7830 { 7831 struct cmd_write_reg_result *res = parsed_result; 7832 port_reg_set(res->port_id, res->reg_off, res->value); 7833 } 7834 7835 cmdline_parse_token_string_t cmd_write_reg_write = 7836 TOKEN_STRING_INITIALIZER(struct cmd_write_reg_result, write, "write"); 7837 cmdline_parse_token_string_t cmd_write_reg_reg = 7838 TOKEN_STRING_INITIALIZER(struct cmd_write_reg_result, reg, "reg"); 7839 cmdline_parse_token_num_t cmd_write_reg_port_id = 7840 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_result, port_id, UINT16); 7841 cmdline_parse_token_num_t cmd_write_reg_reg_off = 7842 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_result, reg_off, UINT32); 7843 cmdline_parse_token_num_t cmd_write_reg_value = 7844 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_result, value, UINT32); 7845 7846 cmdline_parse_inst_t cmd_write_reg = { 7847 .f = cmd_write_reg_parsed, 7848 .data = NULL, 7849 .help_str = "write reg <port_id> <reg_off> <reg_value>", 7850 .tokens = { 7851 (void *)&cmd_write_reg_write, 7852 (void *)&cmd_write_reg_reg, 7853 (void *)&cmd_write_reg_port_id, 7854 (void *)&cmd_write_reg_reg_off, 7855 (void *)&cmd_write_reg_value, 7856 NULL, 7857 }, 7858 }; 7859 7860 /* *** WRITE PORT REGISTER BIT FIELD *** */ 7861 struct cmd_write_reg_bit_field_result { 7862 cmdline_fixed_string_t write; 7863 cmdline_fixed_string_t regfield; 7864 portid_t port_id; 7865 uint32_t reg_off; 7866 uint8_t bit1_pos; 7867 uint8_t bit2_pos; 7868 uint32_t value; 7869 }; 7870 7871 static void 7872 cmd_write_reg_bit_field_parsed(void *parsed_result, 7873 __attribute__((unused)) struct cmdline *cl, 7874 __attribute__((unused)) void *data) 7875 { 7876 struct cmd_write_reg_bit_field_result *res = parsed_result; 7877 port_reg_bit_field_set(res->port_id, res->reg_off, 7878 res->bit1_pos, res->bit2_pos, res->value); 7879 } 7880 7881 cmdline_parse_token_string_t cmd_write_reg_bit_field_write = 7882 TOKEN_STRING_INITIALIZER(struct cmd_write_reg_bit_field_result, write, 7883 "write"); 7884 cmdline_parse_token_string_t cmd_write_reg_bit_field_regfield = 7885 TOKEN_STRING_INITIALIZER(struct cmd_write_reg_bit_field_result, 7886 regfield, "regfield"); 7887 cmdline_parse_token_num_t cmd_write_reg_bit_field_port_id = 7888 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_field_result, port_id, 7889 UINT16); 7890 cmdline_parse_token_num_t cmd_write_reg_bit_field_reg_off = 7891 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_field_result, reg_off, 7892 UINT32); 7893 cmdline_parse_token_num_t cmd_write_reg_bit_field_bit1_pos = 7894 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_field_result, bit1_pos, 7895 UINT8); 7896 cmdline_parse_token_num_t cmd_write_reg_bit_field_bit2_pos = 7897 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_field_result, bit2_pos, 7898 UINT8); 7899 cmdline_parse_token_num_t cmd_write_reg_bit_field_value = 7900 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_field_result, value, 7901 UINT32); 7902 7903 cmdline_parse_inst_t cmd_write_reg_bit_field = { 7904 .f = cmd_write_reg_bit_field_parsed, 7905 .data = NULL, 7906 .help_str = "write regfield <port_id> <reg_off> <bit_x> <bit_y> " 7907 "<reg_value>: " 7908 "Set register bit field between bit_x and bit_y included", 7909 .tokens = { 7910 (void *)&cmd_write_reg_bit_field_write, 7911 (void *)&cmd_write_reg_bit_field_regfield, 7912 (void *)&cmd_write_reg_bit_field_port_id, 7913 (void *)&cmd_write_reg_bit_field_reg_off, 7914 (void *)&cmd_write_reg_bit_field_bit1_pos, 7915 (void *)&cmd_write_reg_bit_field_bit2_pos, 7916 (void *)&cmd_write_reg_bit_field_value, 7917 NULL, 7918 }, 7919 }; 7920 7921 /* *** WRITE PORT REGISTER BIT *** */ 7922 struct cmd_write_reg_bit_result { 7923 cmdline_fixed_string_t write; 7924 cmdline_fixed_string_t regbit; 7925 portid_t port_id; 7926 uint32_t reg_off; 7927 uint8_t bit_pos; 7928 uint8_t value; 7929 }; 7930 7931 static void 7932 cmd_write_reg_bit_parsed(void *parsed_result, 7933 __attribute__((unused)) struct cmdline *cl, 7934 __attribute__((unused)) void *data) 7935 { 7936 struct cmd_write_reg_bit_result *res = parsed_result; 7937 port_reg_bit_set(res->port_id, res->reg_off, res->bit_pos, res->value); 7938 } 7939 7940 cmdline_parse_token_string_t cmd_write_reg_bit_write = 7941 TOKEN_STRING_INITIALIZER(struct cmd_write_reg_bit_result, write, 7942 "write"); 7943 cmdline_parse_token_string_t cmd_write_reg_bit_regbit = 7944 TOKEN_STRING_INITIALIZER(struct cmd_write_reg_bit_result, 7945 regbit, "regbit"); 7946 cmdline_parse_token_num_t cmd_write_reg_bit_port_id = 7947 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_result, port_id, UINT16); 7948 cmdline_parse_token_num_t cmd_write_reg_bit_reg_off = 7949 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_result, reg_off, UINT32); 7950 cmdline_parse_token_num_t cmd_write_reg_bit_bit_pos = 7951 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_result, bit_pos, UINT8); 7952 cmdline_parse_token_num_t cmd_write_reg_bit_value = 7953 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_result, value, UINT8); 7954 7955 cmdline_parse_inst_t cmd_write_reg_bit = { 7956 .f = cmd_write_reg_bit_parsed, 7957 .data = NULL, 7958 .help_str = "write regbit <port_id> <reg_off> <bit_x> 0|1: " 7959 "0 <= bit_x <= 31", 7960 .tokens = { 7961 (void *)&cmd_write_reg_bit_write, 7962 (void *)&cmd_write_reg_bit_regbit, 7963 (void *)&cmd_write_reg_bit_port_id, 7964 (void *)&cmd_write_reg_bit_reg_off, 7965 (void *)&cmd_write_reg_bit_bit_pos, 7966 (void *)&cmd_write_reg_bit_value, 7967 NULL, 7968 }, 7969 }; 7970 7971 /* *** READ A RING DESCRIPTOR OF A PORT RX/TX QUEUE *** */ 7972 struct cmd_read_rxd_txd_result { 7973 cmdline_fixed_string_t read; 7974 cmdline_fixed_string_t rxd_txd; 7975 portid_t port_id; 7976 uint16_t queue_id; 7977 uint16_t desc_id; 7978 }; 7979 7980 static void 7981 cmd_read_rxd_txd_parsed(void *parsed_result, 7982 __attribute__((unused)) struct cmdline *cl, 7983 __attribute__((unused)) void *data) 7984 { 7985 struct cmd_read_rxd_txd_result *res = parsed_result; 7986 7987 if (!strcmp(res->rxd_txd, "rxd")) 7988 rx_ring_desc_display(res->port_id, res->queue_id, res->desc_id); 7989 else if (!strcmp(res->rxd_txd, "txd")) 7990 tx_ring_desc_display(res->port_id, res->queue_id, res->desc_id); 7991 } 7992 7993 cmdline_parse_token_string_t cmd_read_rxd_txd_read = 7994 TOKEN_STRING_INITIALIZER(struct cmd_read_rxd_txd_result, read, "read"); 7995 cmdline_parse_token_string_t cmd_read_rxd_txd_rxd_txd = 7996 TOKEN_STRING_INITIALIZER(struct cmd_read_rxd_txd_result, rxd_txd, 7997 "rxd#txd"); 7998 cmdline_parse_token_num_t cmd_read_rxd_txd_port_id = 7999 TOKEN_NUM_INITIALIZER(struct cmd_read_rxd_txd_result, port_id, UINT16); 8000 cmdline_parse_token_num_t cmd_read_rxd_txd_queue_id = 8001 TOKEN_NUM_INITIALIZER(struct cmd_read_rxd_txd_result, queue_id, UINT16); 8002 cmdline_parse_token_num_t cmd_read_rxd_txd_desc_id = 8003 TOKEN_NUM_INITIALIZER(struct cmd_read_rxd_txd_result, desc_id, UINT16); 8004 8005 cmdline_parse_inst_t cmd_read_rxd_txd = { 8006 .f = cmd_read_rxd_txd_parsed, 8007 .data = NULL, 8008 .help_str = "read rxd|txd <port_id> <queue_id> <desc_id>", 8009 .tokens = { 8010 (void *)&cmd_read_rxd_txd_read, 8011 (void *)&cmd_read_rxd_txd_rxd_txd, 8012 (void *)&cmd_read_rxd_txd_port_id, 8013 (void *)&cmd_read_rxd_txd_queue_id, 8014 (void *)&cmd_read_rxd_txd_desc_id, 8015 NULL, 8016 }, 8017 }; 8018 8019 /* *** QUIT *** */ 8020 struct cmd_quit_result { 8021 cmdline_fixed_string_t quit; 8022 }; 8023 8024 static void cmd_quit_parsed(__attribute__((unused)) void *parsed_result, 8025 struct cmdline *cl, 8026 __attribute__((unused)) void *data) 8027 { 8028 cmdline_quit(cl); 8029 } 8030 8031 cmdline_parse_token_string_t cmd_quit_quit = 8032 TOKEN_STRING_INITIALIZER(struct cmd_quit_result, quit, "quit"); 8033 8034 cmdline_parse_inst_t cmd_quit = { 8035 .f = cmd_quit_parsed, 8036 .data = NULL, 8037 .help_str = "quit: Exit application", 8038 .tokens = { 8039 (void *)&cmd_quit_quit, 8040 NULL, 8041 }, 8042 }; 8043 8044 /* *** ADD/REMOVE MAC ADDRESS FROM A PORT *** */ 8045 struct cmd_mac_addr_result { 8046 cmdline_fixed_string_t mac_addr_cmd; 8047 cmdline_fixed_string_t what; 8048 uint16_t port_num; 8049 struct rte_ether_addr address; 8050 }; 8051 8052 static void cmd_mac_addr_parsed(void *parsed_result, 8053 __attribute__((unused)) struct cmdline *cl, 8054 __attribute__((unused)) void *data) 8055 { 8056 struct cmd_mac_addr_result *res = parsed_result; 8057 int ret; 8058 8059 if (strcmp(res->what, "add") == 0) 8060 ret = rte_eth_dev_mac_addr_add(res->port_num, &res->address, 0); 8061 else if (strcmp(res->what, "set") == 0) 8062 ret = rte_eth_dev_default_mac_addr_set(res->port_num, 8063 &res->address); 8064 else 8065 ret = rte_eth_dev_mac_addr_remove(res->port_num, &res->address); 8066 8067 /* check the return value and print it if is < 0 */ 8068 if(ret < 0) 8069 printf("mac_addr_cmd error: (%s)\n", strerror(-ret)); 8070 8071 } 8072 8073 cmdline_parse_token_string_t cmd_mac_addr_cmd = 8074 TOKEN_STRING_INITIALIZER(struct cmd_mac_addr_result, mac_addr_cmd, 8075 "mac_addr"); 8076 cmdline_parse_token_string_t cmd_mac_addr_what = 8077 TOKEN_STRING_INITIALIZER(struct cmd_mac_addr_result, what, 8078 "add#remove#set"); 8079 cmdline_parse_token_num_t cmd_mac_addr_portnum = 8080 TOKEN_NUM_INITIALIZER(struct cmd_mac_addr_result, port_num, 8081 UINT16); 8082 cmdline_parse_token_etheraddr_t cmd_mac_addr_addr = 8083 TOKEN_ETHERADDR_INITIALIZER(struct cmd_mac_addr_result, address); 8084 8085 cmdline_parse_inst_t cmd_mac_addr = { 8086 .f = cmd_mac_addr_parsed, 8087 .data = (void *)0, 8088 .help_str = "mac_addr add|remove|set <port_id> <mac_addr>: " 8089 "Add/Remove/Set MAC address on port_id", 8090 .tokens = { 8091 (void *)&cmd_mac_addr_cmd, 8092 (void *)&cmd_mac_addr_what, 8093 (void *)&cmd_mac_addr_portnum, 8094 (void *)&cmd_mac_addr_addr, 8095 NULL, 8096 }, 8097 }; 8098 8099 /* *** SET THE PEER ADDRESS FOR CERTAIN PORT *** */ 8100 struct cmd_eth_peer_result { 8101 cmdline_fixed_string_t set; 8102 cmdline_fixed_string_t eth_peer; 8103 portid_t port_id; 8104 cmdline_fixed_string_t peer_addr; 8105 }; 8106 8107 static void cmd_set_eth_peer_parsed(void *parsed_result, 8108 __attribute__((unused)) struct cmdline *cl, 8109 __attribute__((unused)) void *data) 8110 { 8111 struct cmd_eth_peer_result *res = parsed_result; 8112 8113 if (test_done == 0) { 8114 printf("Please stop forwarding first\n"); 8115 return; 8116 } 8117 if (!strcmp(res->eth_peer, "eth-peer")) { 8118 set_fwd_eth_peer(res->port_id, res->peer_addr); 8119 fwd_config_setup(); 8120 } 8121 } 8122 cmdline_parse_token_string_t cmd_eth_peer_set = 8123 TOKEN_STRING_INITIALIZER(struct cmd_eth_peer_result, set, "set"); 8124 cmdline_parse_token_string_t cmd_eth_peer = 8125 TOKEN_STRING_INITIALIZER(struct cmd_eth_peer_result, eth_peer, "eth-peer"); 8126 cmdline_parse_token_num_t cmd_eth_peer_port_id = 8127 TOKEN_NUM_INITIALIZER(struct cmd_eth_peer_result, port_id, UINT16); 8128 cmdline_parse_token_string_t cmd_eth_peer_addr = 8129 TOKEN_STRING_INITIALIZER(struct cmd_eth_peer_result, peer_addr, NULL); 8130 8131 cmdline_parse_inst_t cmd_set_fwd_eth_peer = { 8132 .f = cmd_set_eth_peer_parsed, 8133 .data = NULL, 8134 .help_str = "set eth-peer <port_id> <peer_mac>", 8135 .tokens = { 8136 (void *)&cmd_eth_peer_set, 8137 (void *)&cmd_eth_peer, 8138 (void *)&cmd_eth_peer_port_id, 8139 (void *)&cmd_eth_peer_addr, 8140 NULL, 8141 }, 8142 }; 8143 8144 /* *** CONFIGURE QUEUE STATS COUNTER MAPPINGS *** */ 8145 struct cmd_set_qmap_result { 8146 cmdline_fixed_string_t set; 8147 cmdline_fixed_string_t qmap; 8148 cmdline_fixed_string_t what; 8149 portid_t port_id; 8150 uint16_t queue_id; 8151 uint8_t map_value; 8152 }; 8153 8154 static void 8155 cmd_set_qmap_parsed(void *parsed_result, 8156 __attribute__((unused)) struct cmdline *cl, 8157 __attribute__((unused)) void *data) 8158 { 8159 struct cmd_set_qmap_result *res = parsed_result; 8160 int is_rx = (strcmp(res->what, "tx") == 0) ? 0 : 1; 8161 8162 set_qmap(res->port_id, (uint8_t)is_rx, res->queue_id, res->map_value); 8163 } 8164 8165 cmdline_parse_token_string_t cmd_setqmap_set = 8166 TOKEN_STRING_INITIALIZER(struct cmd_set_qmap_result, 8167 set, "set"); 8168 cmdline_parse_token_string_t cmd_setqmap_qmap = 8169 TOKEN_STRING_INITIALIZER(struct cmd_set_qmap_result, 8170 qmap, "stat_qmap"); 8171 cmdline_parse_token_string_t cmd_setqmap_what = 8172 TOKEN_STRING_INITIALIZER(struct cmd_set_qmap_result, 8173 what, "tx#rx"); 8174 cmdline_parse_token_num_t cmd_setqmap_portid = 8175 TOKEN_NUM_INITIALIZER(struct cmd_set_qmap_result, 8176 port_id, UINT16); 8177 cmdline_parse_token_num_t cmd_setqmap_queueid = 8178 TOKEN_NUM_INITIALIZER(struct cmd_set_qmap_result, 8179 queue_id, UINT16); 8180 cmdline_parse_token_num_t cmd_setqmap_mapvalue = 8181 TOKEN_NUM_INITIALIZER(struct cmd_set_qmap_result, 8182 map_value, UINT8); 8183 8184 cmdline_parse_inst_t cmd_set_qmap = { 8185 .f = cmd_set_qmap_parsed, 8186 .data = NULL, 8187 .help_str = "set stat_qmap rx|tx <port_id> <queue_id> <map_value>: " 8188 "Set statistics mapping value on tx|rx queue_id of port_id", 8189 .tokens = { 8190 (void *)&cmd_setqmap_set, 8191 (void *)&cmd_setqmap_qmap, 8192 (void *)&cmd_setqmap_what, 8193 (void *)&cmd_setqmap_portid, 8194 (void *)&cmd_setqmap_queueid, 8195 (void *)&cmd_setqmap_mapvalue, 8196 NULL, 8197 }, 8198 }; 8199 8200 /* *** SET OPTION TO HIDE ZERO VALUES FOR XSTATS DISPLAY *** */ 8201 struct cmd_set_xstats_hide_zero_result { 8202 cmdline_fixed_string_t keyword; 8203 cmdline_fixed_string_t name; 8204 cmdline_fixed_string_t on_off; 8205 }; 8206 8207 static void 8208 cmd_set_xstats_hide_zero_parsed(void *parsed_result, 8209 __attribute__((unused)) struct cmdline *cl, 8210 __attribute__((unused)) void *data) 8211 { 8212 struct cmd_set_xstats_hide_zero_result *res; 8213 uint16_t on_off = 0; 8214 8215 res = parsed_result; 8216 on_off = !strcmp(res->on_off, "on") ? 1 : 0; 8217 set_xstats_hide_zero(on_off); 8218 } 8219 8220 cmdline_parse_token_string_t cmd_set_xstats_hide_zero_keyword = 8221 TOKEN_STRING_INITIALIZER(struct cmd_set_xstats_hide_zero_result, 8222 keyword, "set"); 8223 cmdline_parse_token_string_t cmd_set_xstats_hide_zero_name = 8224 TOKEN_STRING_INITIALIZER(struct cmd_set_xstats_hide_zero_result, 8225 name, "xstats-hide-zero"); 8226 cmdline_parse_token_string_t cmd_set_xstats_hide_zero_on_off = 8227 TOKEN_STRING_INITIALIZER(struct cmd_set_xstats_hide_zero_result, 8228 on_off, "on#off"); 8229 8230 cmdline_parse_inst_t cmd_set_xstats_hide_zero = { 8231 .f = cmd_set_xstats_hide_zero_parsed, 8232 .data = NULL, 8233 .help_str = "set xstats-hide-zero on|off", 8234 .tokens = { 8235 (void *)&cmd_set_xstats_hide_zero_keyword, 8236 (void *)&cmd_set_xstats_hide_zero_name, 8237 (void *)&cmd_set_xstats_hide_zero_on_off, 8238 NULL, 8239 }, 8240 }; 8241 8242 /* *** CONFIGURE UNICAST HASH TABLE *** */ 8243 struct cmd_set_uc_hash_table { 8244 cmdline_fixed_string_t set; 8245 cmdline_fixed_string_t port; 8246 portid_t port_id; 8247 cmdline_fixed_string_t what; 8248 struct rte_ether_addr address; 8249 cmdline_fixed_string_t mode; 8250 }; 8251 8252 static void 8253 cmd_set_uc_hash_parsed(void *parsed_result, 8254 __attribute__((unused)) struct cmdline *cl, 8255 __attribute__((unused)) void *data) 8256 { 8257 int ret=0; 8258 struct cmd_set_uc_hash_table *res = parsed_result; 8259 8260 int is_on = (strcmp(res->mode, "on") == 0) ? 1 : 0; 8261 8262 if (strcmp(res->what, "uta") == 0) 8263 ret = rte_eth_dev_uc_hash_table_set(res->port_id, 8264 &res->address,(uint8_t)is_on); 8265 if (ret < 0) 8266 printf("bad unicast hash table parameter, return code = %d \n", ret); 8267 8268 } 8269 8270 cmdline_parse_token_string_t cmd_set_uc_hash_set = 8271 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_hash_table, 8272 set, "set"); 8273 cmdline_parse_token_string_t cmd_set_uc_hash_port = 8274 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_hash_table, 8275 port, "port"); 8276 cmdline_parse_token_num_t cmd_set_uc_hash_portid = 8277 TOKEN_NUM_INITIALIZER(struct cmd_set_uc_hash_table, 8278 port_id, UINT16); 8279 cmdline_parse_token_string_t cmd_set_uc_hash_what = 8280 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_hash_table, 8281 what, "uta"); 8282 cmdline_parse_token_etheraddr_t cmd_set_uc_hash_mac = 8283 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_uc_hash_table, 8284 address); 8285 cmdline_parse_token_string_t cmd_set_uc_hash_mode = 8286 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_hash_table, 8287 mode, "on#off"); 8288 8289 cmdline_parse_inst_t cmd_set_uc_hash_filter = { 8290 .f = cmd_set_uc_hash_parsed, 8291 .data = NULL, 8292 .help_str = "set port <port_id> uta <mac_addr> on|off)", 8293 .tokens = { 8294 (void *)&cmd_set_uc_hash_set, 8295 (void *)&cmd_set_uc_hash_port, 8296 (void *)&cmd_set_uc_hash_portid, 8297 (void *)&cmd_set_uc_hash_what, 8298 (void *)&cmd_set_uc_hash_mac, 8299 (void *)&cmd_set_uc_hash_mode, 8300 NULL, 8301 }, 8302 }; 8303 8304 struct cmd_set_uc_all_hash_table { 8305 cmdline_fixed_string_t set; 8306 cmdline_fixed_string_t port; 8307 portid_t port_id; 8308 cmdline_fixed_string_t what; 8309 cmdline_fixed_string_t value; 8310 cmdline_fixed_string_t mode; 8311 }; 8312 8313 static void 8314 cmd_set_uc_all_hash_parsed(void *parsed_result, 8315 __attribute__((unused)) struct cmdline *cl, 8316 __attribute__((unused)) void *data) 8317 { 8318 int ret=0; 8319 struct cmd_set_uc_all_hash_table *res = parsed_result; 8320 8321 int is_on = (strcmp(res->mode, "on") == 0) ? 1 : 0; 8322 8323 if ((strcmp(res->what, "uta") == 0) && 8324 (strcmp(res->value, "all") == 0)) 8325 ret = rte_eth_dev_uc_all_hash_table_set(res->port_id,(uint8_t) is_on); 8326 if (ret < 0) 8327 printf("bad unicast hash table parameter," 8328 "return code = %d \n", ret); 8329 } 8330 8331 cmdline_parse_token_string_t cmd_set_uc_all_hash_set = 8332 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_all_hash_table, 8333 set, "set"); 8334 cmdline_parse_token_string_t cmd_set_uc_all_hash_port = 8335 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_all_hash_table, 8336 port, "port"); 8337 cmdline_parse_token_num_t cmd_set_uc_all_hash_portid = 8338 TOKEN_NUM_INITIALIZER(struct cmd_set_uc_all_hash_table, 8339 port_id, UINT16); 8340 cmdline_parse_token_string_t cmd_set_uc_all_hash_what = 8341 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_all_hash_table, 8342 what, "uta"); 8343 cmdline_parse_token_string_t cmd_set_uc_all_hash_value = 8344 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_all_hash_table, 8345 value,"all"); 8346 cmdline_parse_token_string_t cmd_set_uc_all_hash_mode = 8347 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_all_hash_table, 8348 mode, "on#off"); 8349 8350 cmdline_parse_inst_t cmd_set_uc_all_hash_filter = { 8351 .f = cmd_set_uc_all_hash_parsed, 8352 .data = NULL, 8353 .help_str = "set port <port_id> uta all on|off", 8354 .tokens = { 8355 (void *)&cmd_set_uc_all_hash_set, 8356 (void *)&cmd_set_uc_all_hash_port, 8357 (void *)&cmd_set_uc_all_hash_portid, 8358 (void *)&cmd_set_uc_all_hash_what, 8359 (void *)&cmd_set_uc_all_hash_value, 8360 (void *)&cmd_set_uc_all_hash_mode, 8361 NULL, 8362 }, 8363 }; 8364 8365 /* *** CONFIGURE MACVLAN FILTER FOR VF(s) *** */ 8366 struct cmd_set_vf_macvlan_filter { 8367 cmdline_fixed_string_t set; 8368 cmdline_fixed_string_t port; 8369 portid_t port_id; 8370 cmdline_fixed_string_t vf; 8371 uint8_t vf_id; 8372 struct rte_ether_addr address; 8373 cmdline_fixed_string_t filter_type; 8374 cmdline_fixed_string_t mode; 8375 }; 8376 8377 static void 8378 cmd_set_vf_macvlan_parsed(void *parsed_result, 8379 __attribute__((unused)) struct cmdline *cl, 8380 __attribute__((unused)) void *data) 8381 { 8382 int is_on, ret = 0; 8383 struct cmd_set_vf_macvlan_filter *res = parsed_result; 8384 struct rte_eth_mac_filter filter; 8385 8386 memset(&filter, 0, sizeof(struct rte_eth_mac_filter)); 8387 8388 rte_memcpy(&filter.mac_addr, &res->address, RTE_ETHER_ADDR_LEN); 8389 8390 /* set VF MAC filter */ 8391 filter.is_vf = 1; 8392 8393 /* set VF ID */ 8394 filter.dst_id = res->vf_id; 8395 8396 if (!strcmp(res->filter_type, "exact-mac")) 8397 filter.filter_type = RTE_MAC_PERFECT_MATCH; 8398 else if (!strcmp(res->filter_type, "exact-mac-vlan")) 8399 filter.filter_type = RTE_MACVLAN_PERFECT_MATCH; 8400 else if (!strcmp(res->filter_type, "hashmac")) 8401 filter.filter_type = RTE_MAC_HASH_MATCH; 8402 else if (!strcmp(res->filter_type, "hashmac-vlan")) 8403 filter.filter_type = RTE_MACVLAN_HASH_MATCH; 8404 8405 is_on = (strcmp(res->mode, "on") == 0) ? 1 : 0; 8406 8407 if (is_on) 8408 ret = rte_eth_dev_filter_ctrl(res->port_id, 8409 RTE_ETH_FILTER_MACVLAN, 8410 RTE_ETH_FILTER_ADD, 8411 &filter); 8412 else 8413 ret = rte_eth_dev_filter_ctrl(res->port_id, 8414 RTE_ETH_FILTER_MACVLAN, 8415 RTE_ETH_FILTER_DELETE, 8416 &filter); 8417 8418 if (ret < 0) 8419 printf("bad set MAC hash parameter, return code = %d\n", ret); 8420 8421 } 8422 8423 cmdline_parse_token_string_t cmd_set_vf_macvlan_set = 8424 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_macvlan_filter, 8425 set, "set"); 8426 cmdline_parse_token_string_t cmd_set_vf_macvlan_port = 8427 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_macvlan_filter, 8428 port, "port"); 8429 cmdline_parse_token_num_t cmd_set_vf_macvlan_portid = 8430 TOKEN_NUM_INITIALIZER(struct cmd_set_vf_macvlan_filter, 8431 port_id, UINT16); 8432 cmdline_parse_token_string_t cmd_set_vf_macvlan_vf = 8433 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_macvlan_filter, 8434 vf, "vf"); 8435 cmdline_parse_token_num_t cmd_set_vf_macvlan_vf_id = 8436 TOKEN_NUM_INITIALIZER(struct cmd_set_vf_macvlan_filter, 8437 vf_id, UINT8); 8438 cmdline_parse_token_etheraddr_t cmd_set_vf_macvlan_mac = 8439 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_vf_macvlan_filter, 8440 address); 8441 cmdline_parse_token_string_t cmd_set_vf_macvlan_filter_type = 8442 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_macvlan_filter, 8443 filter_type, "exact-mac#exact-mac-vlan" 8444 "#hashmac#hashmac-vlan"); 8445 cmdline_parse_token_string_t cmd_set_vf_macvlan_mode = 8446 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_macvlan_filter, 8447 mode, "on#off"); 8448 8449 cmdline_parse_inst_t cmd_set_vf_macvlan_filter = { 8450 .f = cmd_set_vf_macvlan_parsed, 8451 .data = NULL, 8452 .help_str = "set port <port_id> vf <vf_id> <mac_addr> " 8453 "exact-mac|exact-mac-vlan|hashmac|hashmac-vlan on|off: " 8454 "Exact match rule: exact match of MAC or MAC and VLAN; " 8455 "hash match rule: hash match of MAC and exact match of VLAN", 8456 .tokens = { 8457 (void *)&cmd_set_vf_macvlan_set, 8458 (void *)&cmd_set_vf_macvlan_port, 8459 (void *)&cmd_set_vf_macvlan_portid, 8460 (void *)&cmd_set_vf_macvlan_vf, 8461 (void *)&cmd_set_vf_macvlan_vf_id, 8462 (void *)&cmd_set_vf_macvlan_mac, 8463 (void *)&cmd_set_vf_macvlan_filter_type, 8464 (void *)&cmd_set_vf_macvlan_mode, 8465 NULL, 8466 }, 8467 }; 8468 8469 /* *** CONFIGURE VF TRAFFIC CONTROL *** */ 8470 struct cmd_set_vf_traffic { 8471 cmdline_fixed_string_t set; 8472 cmdline_fixed_string_t port; 8473 portid_t port_id; 8474 cmdline_fixed_string_t vf; 8475 uint8_t vf_id; 8476 cmdline_fixed_string_t what; 8477 cmdline_fixed_string_t mode; 8478 }; 8479 8480 static void 8481 cmd_set_vf_traffic_parsed(void *parsed_result, 8482 __attribute__((unused)) struct cmdline *cl, 8483 __attribute__((unused)) void *data) 8484 { 8485 struct cmd_set_vf_traffic *res = parsed_result; 8486 int is_rx = (strcmp(res->what, "rx") == 0) ? 1 : 0; 8487 int is_on = (strcmp(res->mode, "on") == 0) ? 1 : 0; 8488 8489 set_vf_traffic(res->port_id, (uint8_t)is_rx, res->vf_id,(uint8_t) is_on); 8490 } 8491 8492 cmdline_parse_token_string_t cmd_setvf_traffic_set = 8493 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_traffic, 8494 set, "set"); 8495 cmdline_parse_token_string_t cmd_setvf_traffic_port = 8496 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_traffic, 8497 port, "port"); 8498 cmdline_parse_token_num_t cmd_setvf_traffic_portid = 8499 TOKEN_NUM_INITIALIZER(struct cmd_set_vf_traffic, 8500 port_id, UINT16); 8501 cmdline_parse_token_string_t cmd_setvf_traffic_vf = 8502 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_traffic, 8503 vf, "vf"); 8504 cmdline_parse_token_num_t cmd_setvf_traffic_vfid = 8505 TOKEN_NUM_INITIALIZER(struct cmd_set_vf_traffic, 8506 vf_id, UINT8); 8507 cmdline_parse_token_string_t cmd_setvf_traffic_what = 8508 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_traffic, 8509 what, "tx#rx"); 8510 cmdline_parse_token_string_t cmd_setvf_traffic_mode = 8511 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_traffic, 8512 mode, "on#off"); 8513 8514 cmdline_parse_inst_t cmd_set_vf_traffic = { 8515 .f = cmd_set_vf_traffic_parsed, 8516 .data = NULL, 8517 .help_str = "set port <port_id> vf <vf_id> rx|tx on|off", 8518 .tokens = { 8519 (void *)&cmd_setvf_traffic_set, 8520 (void *)&cmd_setvf_traffic_port, 8521 (void *)&cmd_setvf_traffic_portid, 8522 (void *)&cmd_setvf_traffic_vf, 8523 (void *)&cmd_setvf_traffic_vfid, 8524 (void *)&cmd_setvf_traffic_what, 8525 (void *)&cmd_setvf_traffic_mode, 8526 NULL, 8527 }, 8528 }; 8529 8530 /* *** CONFIGURE VF RECEIVE MODE *** */ 8531 struct cmd_set_vf_rxmode { 8532 cmdline_fixed_string_t set; 8533 cmdline_fixed_string_t port; 8534 portid_t port_id; 8535 cmdline_fixed_string_t vf; 8536 uint8_t vf_id; 8537 cmdline_fixed_string_t what; 8538 cmdline_fixed_string_t mode; 8539 cmdline_fixed_string_t on; 8540 }; 8541 8542 static void 8543 cmd_set_vf_rxmode_parsed(void *parsed_result, 8544 __attribute__((unused)) struct cmdline *cl, 8545 __attribute__((unused)) void *data) 8546 { 8547 int ret = -ENOTSUP; 8548 uint16_t vf_rxmode = 0; 8549 struct cmd_set_vf_rxmode *res = parsed_result; 8550 8551 int is_on = (strcmp(res->on, "on") == 0) ? 1 : 0; 8552 if (!strcmp(res->what,"rxmode")) { 8553 if (!strcmp(res->mode, "AUPE")) 8554 vf_rxmode |= ETH_VMDQ_ACCEPT_UNTAG; 8555 else if (!strcmp(res->mode, "ROPE")) 8556 vf_rxmode |= ETH_VMDQ_ACCEPT_HASH_UC; 8557 else if (!strcmp(res->mode, "BAM")) 8558 vf_rxmode |= ETH_VMDQ_ACCEPT_BROADCAST; 8559 else if (!strncmp(res->mode, "MPE",3)) 8560 vf_rxmode |= ETH_VMDQ_ACCEPT_MULTICAST; 8561 } 8562 8563 RTE_SET_USED(is_on); 8564 8565 #ifdef RTE_LIBRTE_IXGBE_PMD 8566 if (ret == -ENOTSUP) 8567 ret = rte_pmd_ixgbe_set_vf_rxmode(res->port_id, res->vf_id, 8568 vf_rxmode, (uint8_t)is_on); 8569 #endif 8570 #ifdef RTE_LIBRTE_BNXT_PMD 8571 if (ret == -ENOTSUP) 8572 ret = rte_pmd_bnxt_set_vf_rxmode(res->port_id, res->vf_id, 8573 vf_rxmode, (uint8_t)is_on); 8574 #endif 8575 if (ret < 0) 8576 printf("bad VF receive mode parameter, return code = %d \n", 8577 ret); 8578 } 8579 8580 cmdline_parse_token_string_t cmd_set_vf_rxmode_set = 8581 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_rxmode, 8582 set, "set"); 8583 cmdline_parse_token_string_t cmd_set_vf_rxmode_port = 8584 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_rxmode, 8585 port, "port"); 8586 cmdline_parse_token_num_t cmd_set_vf_rxmode_portid = 8587 TOKEN_NUM_INITIALIZER(struct cmd_set_vf_rxmode, 8588 port_id, UINT16); 8589 cmdline_parse_token_string_t cmd_set_vf_rxmode_vf = 8590 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_rxmode, 8591 vf, "vf"); 8592 cmdline_parse_token_num_t cmd_set_vf_rxmode_vfid = 8593 TOKEN_NUM_INITIALIZER(struct cmd_set_vf_rxmode, 8594 vf_id, UINT8); 8595 cmdline_parse_token_string_t cmd_set_vf_rxmode_what = 8596 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_rxmode, 8597 what, "rxmode"); 8598 cmdline_parse_token_string_t cmd_set_vf_rxmode_mode = 8599 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_rxmode, 8600 mode, "AUPE#ROPE#BAM#MPE"); 8601 cmdline_parse_token_string_t cmd_set_vf_rxmode_on = 8602 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_rxmode, 8603 on, "on#off"); 8604 8605 cmdline_parse_inst_t cmd_set_vf_rxmode = { 8606 .f = cmd_set_vf_rxmode_parsed, 8607 .data = NULL, 8608 .help_str = "set port <port_id> vf <vf_id> rxmode " 8609 "AUPE|ROPE|BAM|MPE on|off", 8610 .tokens = { 8611 (void *)&cmd_set_vf_rxmode_set, 8612 (void *)&cmd_set_vf_rxmode_port, 8613 (void *)&cmd_set_vf_rxmode_portid, 8614 (void *)&cmd_set_vf_rxmode_vf, 8615 (void *)&cmd_set_vf_rxmode_vfid, 8616 (void *)&cmd_set_vf_rxmode_what, 8617 (void *)&cmd_set_vf_rxmode_mode, 8618 (void *)&cmd_set_vf_rxmode_on, 8619 NULL, 8620 }, 8621 }; 8622 8623 /* *** ADD MAC ADDRESS FILTER FOR A VF OF A PORT *** */ 8624 struct cmd_vf_mac_addr_result { 8625 cmdline_fixed_string_t mac_addr_cmd; 8626 cmdline_fixed_string_t what; 8627 cmdline_fixed_string_t port; 8628 uint16_t port_num; 8629 cmdline_fixed_string_t vf; 8630 uint8_t vf_num; 8631 struct rte_ether_addr address; 8632 }; 8633 8634 static void cmd_vf_mac_addr_parsed(void *parsed_result, 8635 __attribute__((unused)) struct cmdline *cl, 8636 __attribute__((unused)) void *data) 8637 { 8638 struct cmd_vf_mac_addr_result *res = parsed_result; 8639 int ret = -ENOTSUP; 8640 8641 if (strcmp(res->what, "add") != 0) 8642 return; 8643 8644 #ifdef RTE_LIBRTE_I40E_PMD 8645 if (ret == -ENOTSUP) 8646 ret = rte_pmd_i40e_add_vf_mac_addr(res->port_num, res->vf_num, 8647 &res->address); 8648 #endif 8649 #ifdef RTE_LIBRTE_BNXT_PMD 8650 if (ret == -ENOTSUP) 8651 ret = rte_pmd_bnxt_mac_addr_add(res->port_num, &res->address, 8652 res->vf_num); 8653 #endif 8654 8655 if(ret < 0) 8656 printf("vf_mac_addr_cmd error: (%s)\n", strerror(-ret)); 8657 8658 } 8659 8660 cmdline_parse_token_string_t cmd_vf_mac_addr_cmd = 8661 TOKEN_STRING_INITIALIZER(struct cmd_vf_mac_addr_result, 8662 mac_addr_cmd,"mac_addr"); 8663 cmdline_parse_token_string_t cmd_vf_mac_addr_what = 8664 TOKEN_STRING_INITIALIZER(struct cmd_vf_mac_addr_result, 8665 what,"add"); 8666 cmdline_parse_token_string_t cmd_vf_mac_addr_port = 8667 TOKEN_STRING_INITIALIZER(struct cmd_vf_mac_addr_result, 8668 port,"port"); 8669 cmdline_parse_token_num_t cmd_vf_mac_addr_portnum = 8670 TOKEN_NUM_INITIALIZER(struct cmd_vf_mac_addr_result, 8671 port_num, UINT16); 8672 cmdline_parse_token_string_t cmd_vf_mac_addr_vf = 8673 TOKEN_STRING_INITIALIZER(struct cmd_vf_mac_addr_result, 8674 vf,"vf"); 8675 cmdline_parse_token_num_t cmd_vf_mac_addr_vfnum = 8676 TOKEN_NUM_INITIALIZER(struct cmd_vf_mac_addr_result, 8677 vf_num, UINT8); 8678 cmdline_parse_token_etheraddr_t cmd_vf_mac_addr_addr = 8679 TOKEN_ETHERADDR_INITIALIZER(struct cmd_vf_mac_addr_result, 8680 address); 8681 8682 cmdline_parse_inst_t cmd_vf_mac_addr_filter = { 8683 .f = cmd_vf_mac_addr_parsed, 8684 .data = (void *)0, 8685 .help_str = "mac_addr add port <port_id> vf <vf_id> <mac_addr>: " 8686 "Add MAC address filtering for a VF on port_id", 8687 .tokens = { 8688 (void *)&cmd_vf_mac_addr_cmd, 8689 (void *)&cmd_vf_mac_addr_what, 8690 (void *)&cmd_vf_mac_addr_port, 8691 (void *)&cmd_vf_mac_addr_portnum, 8692 (void *)&cmd_vf_mac_addr_vf, 8693 (void *)&cmd_vf_mac_addr_vfnum, 8694 (void *)&cmd_vf_mac_addr_addr, 8695 NULL, 8696 }, 8697 }; 8698 8699 /* *** ADD/REMOVE A VLAN IDENTIFIER TO/FROM A PORT VLAN RX FILTER *** */ 8700 struct cmd_vf_rx_vlan_filter { 8701 cmdline_fixed_string_t rx_vlan; 8702 cmdline_fixed_string_t what; 8703 uint16_t vlan_id; 8704 cmdline_fixed_string_t port; 8705 portid_t port_id; 8706 cmdline_fixed_string_t vf; 8707 uint64_t vf_mask; 8708 }; 8709 8710 static void 8711 cmd_vf_rx_vlan_filter_parsed(void *parsed_result, 8712 __attribute__((unused)) struct cmdline *cl, 8713 __attribute__((unused)) void *data) 8714 { 8715 struct cmd_vf_rx_vlan_filter *res = parsed_result; 8716 int ret = -ENOTSUP; 8717 8718 __rte_unused int is_add = (strcmp(res->what, "add") == 0) ? 1 : 0; 8719 8720 #ifdef RTE_LIBRTE_IXGBE_PMD 8721 if (ret == -ENOTSUP) 8722 ret = rte_pmd_ixgbe_set_vf_vlan_filter(res->port_id, 8723 res->vlan_id, res->vf_mask, is_add); 8724 #endif 8725 #ifdef RTE_LIBRTE_I40E_PMD 8726 if (ret == -ENOTSUP) 8727 ret = rte_pmd_i40e_set_vf_vlan_filter(res->port_id, 8728 res->vlan_id, res->vf_mask, is_add); 8729 #endif 8730 #ifdef RTE_LIBRTE_BNXT_PMD 8731 if (ret == -ENOTSUP) 8732 ret = rte_pmd_bnxt_set_vf_vlan_filter(res->port_id, 8733 res->vlan_id, res->vf_mask, is_add); 8734 #endif 8735 8736 switch (ret) { 8737 case 0: 8738 break; 8739 case -EINVAL: 8740 printf("invalid vlan_id %d or vf_mask %"PRIu64"\n", 8741 res->vlan_id, res->vf_mask); 8742 break; 8743 case -ENODEV: 8744 printf("invalid port_id %d\n", res->port_id); 8745 break; 8746 case -ENOTSUP: 8747 printf("function not implemented or supported\n"); 8748 break; 8749 default: 8750 printf("programming error: (%s)\n", strerror(-ret)); 8751 } 8752 } 8753 8754 cmdline_parse_token_string_t cmd_vf_rx_vlan_filter_rx_vlan = 8755 TOKEN_STRING_INITIALIZER(struct cmd_vf_rx_vlan_filter, 8756 rx_vlan, "rx_vlan"); 8757 cmdline_parse_token_string_t cmd_vf_rx_vlan_filter_what = 8758 TOKEN_STRING_INITIALIZER(struct cmd_vf_rx_vlan_filter, 8759 what, "add#rm"); 8760 cmdline_parse_token_num_t cmd_vf_rx_vlan_filter_vlanid = 8761 TOKEN_NUM_INITIALIZER(struct cmd_vf_rx_vlan_filter, 8762 vlan_id, UINT16); 8763 cmdline_parse_token_string_t cmd_vf_rx_vlan_filter_port = 8764 TOKEN_STRING_INITIALIZER(struct cmd_vf_rx_vlan_filter, 8765 port, "port"); 8766 cmdline_parse_token_num_t cmd_vf_rx_vlan_filter_portid = 8767 TOKEN_NUM_INITIALIZER(struct cmd_vf_rx_vlan_filter, 8768 port_id, UINT16); 8769 cmdline_parse_token_string_t cmd_vf_rx_vlan_filter_vf = 8770 TOKEN_STRING_INITIALIZER(struct cmd_vf_rx_vlan_filter, 8771 vf, "vf"); 8772 cmdline_parse_token_num_t cmd_vf_rx_vlan_filter_vf_mask = 8773 TOKEN_NUM_INITIALIZER(struct cmd_vf_rx_vlan_filter, 8774 vf_mask, UINT64); 8775 8776 cmdline_parse_inst_t cmd_vf_rxvlan_filter = { 8777 .f = cmd_vf_rx_vlan_filter_parsed, 8778 .data = NULL, 8779 .help_str = "rx_vlan add|rm <vlan_id> port <port_id> vf <vf_mask>: " 8780 "(vf_mask = hexadecimal VF mask)", 8781 .tokens = { 8782 (void *)&cmd_vf_rx_vlan_filter_rx_vlan, 8783 (void *)&cmd_vf_rx_vlan_filter_what, 8784 (void *)&cmd_vf_rx_vlan_filter_vlanid, 8785 (void *)&cmd_vf_rx_vlan_filter_port, 8786 (void *)&cmd_vf_rx_vlan_filter_portid, 8787 (void *)&cmd_vf_rx_vlan_filter_vf, 8788 (void *)&cmd_vf_rx_vlan_filter_vf_mask, 8789 NULL, 8790 }, 8791 }; 8792 8793 /* *** SET RATE LIMIT FOR A QUEUE OF A PORT *** */ 8794 struct cmd_queue_rate_limit_result { 8795 cmdline_fixed_string_t set; 8796 cmdline_fixed_string_t port; 8797 uint16_t port_num; 8798 cmdline_fixed_string_t queue; 8799 uint8_t queue_num; 8800 cmdline_fixed_string_t rate; 8801 uint16_t rate_num; 8802 }; 8803 8804 static void cmd_queue_rate_limit_parsed(void *parsed_result, 8805 __attribute__((unused)) struct cmdline *cl, 8806 __attribute__((unused)) void *data) 8807 { 8808 struct cmd_queue_rate_limit_result *res = parsed_result; 8809 int ret = 0; 8810 8811 if ((strcmp(res->set, "set") == 0) && (strcmp(res->port, "port") == 0) 8812 && (strcmp(res->queue, "queue") == 0) 8813 && (strcmp(res->rate, "rate") == 0)) 8814 ret = set_queue_rate_limit(res->port_num, res->queue_num, 8815 res->rate_num); 8816 if (ret < 0) 8817 printf("queue_rate_limit_cmd error: (%s)\n", strerror(-ret)); 8818 8819 } 8820 8821 cmdline_parse_token_string_t cmd_queue_rate_limit_set = 8822 TOKEN_STRING_INITIALIZER(struct cmd_queue_rate_limit_result, 8823 set, "set"); 8824 cmdline_parse_token_string_t cmd_queue_rate_limit_port = 8825 TOKEN_STRING_INITIALIZER(struct cmd_queue_rate_limit_result, 8826 port, "port"); 8827 cmdline_parse_token_num_t cmd_queue_rate_limit_portnum = 8828 TOKEN_NUM_INITIALIZER(struct cmd_queue_rate_limit_result, 8829 port_num, UINT16); 8830 cmdline_parse_token_string_t cmd_queue_rate_limit_queue = 8831 TOKEN_STRING_INITIALIZER(struct cmd_queue_rate_limit_result, 8832 queue, "queue"); 8833 cmdline_parse_token_num_t cmd_queue_rate_limit_queuenum = 8834 TOKEN_NUM_INITIALIZER(struct cmd_queue_rate_limit_result, 8835 queue_num, UINT8); 8836 cmdline_parse_token_string_t cmd_queue_rate_limit_rate = 8837 TOKEN_STRING_INITIALIZER(struct cmd_queue_rate_limit_result, 8838 rate, "rate"); 8839 cmdline_parse_token_num_t cmd_queue_rate_limit_ratenum = 8840 TOKEN_NUM_INITIALIZER(struct cmd_queue_rate_limit_result, 8841 rate_num, UINT16); 8842 8843 cmdline_parse_inst_t cmd_queue_rate_limit = { 8844 .f = cmd_queue_rate_limit_parsed, 8845 .data = (void *)0, 8846 .help_str = "set port <port_id> queue <queue_id> rate <rate_value>: " 8847 "Set rate limit for a queue on port_id", 8848 .tokens = { 8849 (void *)&cmd_queue_rate_limit_set, 8850 (void *)&cmd_queue_rate_limit_port, 8851 (void *)&cmd_queue_rate_limit_portnum, 8852 (void *)&cmd_queue_rate_limit_queue, 8853 (void *)&cmd_queue_rate_limit_queuenum, 8854 (void *)&cmd_queue_rate_limit_rate, 8855 (void *)&cmd_queue_rate_limit_ratenum, 8856 NULL, 8857 }, 8858 }; 8859 8860 /* *** SET RATE LIMIT FOR A VF OF A PORT *** */ 8861 struct cmd_vf_rate_limit_result { 8862 cmdline_fixed_string_t set; 8863 cmdline_fixed_string_t port; 8864 uint16_t port_num; 8865 cmdline_fixed_string_t vf; 8866 uint8_t vf_num; 8867 cmdline_fixed_string_t rate; 8868 uint16_t rate_num; 8869 cmdline_fixed_string_t q_msk; 8870 uint64_t q_msk_val; 8871 }; 8872 8873 static void cmd_vf_rate_limit_parsed(void *parsed_result, 8874 __attribute__((unused)) struct cmdline *cl, 8875 __attribute__((unused)) void *data) 8876 { 8877 struct cmd_vf_rate_limit_result *res = parsed_result; 8878 int ret = 0; 8879 8880 if ((strcmp(res->set, "set") == 0) && (strcmp(res->port, "port") == 0) 8881 && (strcmp(res->vf, "vf") == 0) 8882 && (strcmp(res->rate, "rate") == 0) 8883 && (strcmp(res->q_msk, "queue_mask") == 0)) 8884 ret = set_vf_rate_limit(res->port_num, res->vf_num, 8885 res->rate_num, res->q_msk_val); 8886 if (ret < 0) 8887 printf("vf_rate_limit_cmd error: (%s)\n", strerror(-ret)); 8888 8889 } 8890 8891 cmdline_parse_token_string_t cmd_vf_rate_limit_set = 8892 TOKEN_STRING_INITIALIZER(struct cmd_vf_rate_limit_result, 8893 set, "set"); 8894 cmdline_parse_token_string_t cmd_vf_rate_limit_port = 8895 TOKEN_STRING_INITIALIZER(struct cmd_vf_rate_limit_result, 8896 port, "port"); 8897 cmdline_parse_token_num_t cmd_vf_rate_limit_portnum = 8898 TOKEN_NUM_INITIALIZER(struct cmd_vf_rate_limit_result, 8899 port_num, UINT16); 8900 cmdline_parse_token_string_t cmd_vf_rate_limit_vf = 8901 TOKEN_STRING_INITIALIZER(struct cmd_vf_rate_limit_result, 8902 vf, "vf"); 8903 cmdline_parse_token_num_t cmd_vf_rate_limit_vfnum = 8904 TOKEN_NUM_INITIALIZER(struct cmd_vf_rate_limit_result, 8905 vf_num, UINT8); 8906 cmdline_parse_token_string_t cmd_vf_rate_limit_rate = 8907 TOKEN_STRING_INITIALIZER(struct cmd_vf_rate_limit_result, 8908 rate, "rate"); 8909 cmdline_parse_token_num_t cmd_vf_rate_limit_ratenum = 8910 TOKEN_NUM_INITIALIZER(struct cmd_vf_rate_limit_result, 8911 rate_num, UINT16); 8912 cmdline_parse_token_string_t cmd_vf_rate_limit_q_msk = 8913 TOKEN_STRING_INITIALIZER(struct cmd_vf_rate_limit_result, 8914 q_msk, "queue_mask"); 8915 cmdline_parse_token_num_t cmd_vf_rate_limit_q_msk_val = 8916 TOKEN_NUM_INITIALIZER(struct cmd_vf_rate_limit_result, 8917 q_msk_val, UINT64); 8918 8919 cmdline_parse_inst_t cmd_vf_rate_limit = { 8920 .f = cmd_vf_rate_limit_parsed, 8921 .data = (void *)0, 8922 .help_str = "set port <port_id> vf <vf_id> rate <rate_value> " 8923 "queue_mask <queue_mask_value>: " 8924 "Set rate limit for queues of VF on port_id", 8925 .tokens = { 8926 (void *)&cmd_vf_rate_limit_set, 8927 (void *)&cmd_vf_rate_limit_port, 8928 (void *)&cmd_vf_rate_limit_portnum, 8929 (void *)&cmd_vf_rate_limit_vf, 8930 (void *)&cmd_vf_rate_limit_vfnum, 8931 (void *)&cmd_vf_rate_limit_rate, 8932 (void *)&cmd_vf_rate_limit_ratenum, 8933 (void *)&cmd_vf_rate_limit_q_msk, 8934 (void *)&cmd_vf_rate_limit_q_msk_val, 8935 NULL, 8936 }, 8937 }; 8938 8939 /* *** ADD TUNNEL FILTER OF A PORT *** */ 8940 struct cmd_tunnel_filter_result { 8941 cmdline_fixed_string_t cmd; 8942 cmdline_fixed_string_t what; 8943 portid_t port_id; 8944 struct rte_ether_addr outer_mac; 8945 struct rte_ether_addr inner_mac; 8946 cmdline_ipaddr_t ip_value; 8947 uint16_t inner_vlan; 8948 cmdline_fixed_string_t tunnel_type; 8949 cmdline_fixed_string_t filter_type; 8950 uint32_t tenant_id; 8951 uint16_t queue_num; 8952 }; 8953 8954 static void 8955 cmd_tunnel_filter_parsed(void *parsed_result, 8956 __attribute__((unused)) struct cmdline *cl, 8957 __attribute__((unused)) void *data) 8958 { 8959 struct cmd_tunnel_filter_result *res = parsed_result; 8960 struct rte_eth_tunnel_filter_conf tunnel_filter_conf; 8961 int ret = 0; 8962 8963 memset(&tunnel_filter_conf, 0, sizeof(tunnel_filter_conf)); 8964 8965 rte_ether_addr_copy(&res->outer_mac, &tunnel_filter_conf.outer_mac); 8966 rte_ether_addr_copy(&res->inner_mac, &tunnel_filter_conf.inner_mac); 8967 tunnel_filter_conf.inner_vlan = res->inner_vlan; 8968 8969 if (res->ip_value.family == AF_INET) { 8970 tunnel_filter_conf.ip_addr.ipv4_addr = 8971 res->ip_value.addr.ipv4.s_addr; 8972 tunnel_filter_conf.ip_type = RTE_TUNNEL_IPTYPE_IPV4; 8973 } else { 8974 memcpy(&(tunnel_filter_conf.ip_addr.ipv6_addr), 8975 &(res->ip_value.addr.ipv6), 8976 sizeof(struct in6_addr)); 8977 tunnel_filter_conf.ip_type = RTE_TUNNEL_IPTYPE_IPV6; 8978 } 8979 8980 if (!strcmp(res->filter_type, "imac-ivlan")) 8981 tunnel_filter_conf.filter_type = RTE_TUNNEL_FILTER_IMAC_IVLAN; 8982 else if (!strcmp(res->filter_type, "imac-ivlan-tenid")) 8983 tunnel_filter_conf.filter_type = 8984 RTE_TUNNEL_FILTER_IMAC_IVLAN_TENID; 8985 else if (!strcmp(res->filter_type, "imac-tenid")) 8986 tunnel_filter_conf.filter_type = RTE_TUNNEL_FILTER_IMAC_TENID; 8987 else if (!strcmp(res->filter_type, "imac")) 8988 tunnel_filter_conf.filter_type = ETH_TUNNEL_FILTER_IMAC; 8989 else if (!strcmp(res->filter_type, "omac-imac-tenid")) 8990 tunnel_filter_conf.filter_type = 8991 RTE_TUNNEL_FILTER_OMAC_TENID_IMAC; 8992 else if (!strcmp(res->filter_type, "oip")) 8993 tunnel_filter_conf.filter_type = ETH_TUNNEL_FILTER_OIP; 8994 else if (!strcmp(res->filter_type, "iip")) 8995 tunnel_filter_conf.filter_type = ETH_TUNNEL_FILTER_IIP; 8996 else { 8997 printf("The filter type is not supported"); 8998 return; 8999 } 9000 9001 if (!strcmp(res->tunnel_type, "vxlan")) 9002 tunnel_filter_conf.tunnel_type = RTE_TUNNEL_TYPE_VXLAN; 9003 else if (!strcmp(res->tunnel_type, "vxlan-gpe")) 9004 tunnel_filter_conf.tunnel_type = RTE_TUNNEL_TYPE_VXLAN_GPE; 9005 else if (!strcmp(res->tunnel_type, "nvgre")) 9006 tunnel_filter_conf.tunnel_type = RTE_TUNNEL_TYPE_NVGRE; 9007 else if (!strcmp(res->tunnel_type, "ipingre")) 9008 tunnel_filter_conf.tunnel_type = RTE_TUNNEL_TYPE_IP_IN_GRE; 9009 else { 9010 printf("The tunnel type %s not supported.\n", res->tunnel_type); 9011 return; 9012 } 9013 9014 tunnel_filter_conf.tenant_id = res->tenant_id; 9015 tunnel_filter_conf.queue_id = res->queue_num; 9016 if (!strcmp(res->what, "add")) 9017 ret = rte_eth_dev_filter_ctrl(res->port_id, 9018 RTE_ETH_FILTER_TUNNEL, 9019 RTE_ETH_FILTER_ADD, 9020 &tunnel_filter_conf); 9021 else 9022 ret = rte_eth_dev_filter_ctrl(res->port_id, 9023 RTE_ETH_FILTER_TUNNEL, 9024 RTE_ETH_FILTER_DELETE, 9025 &tunnel_filter_conf); 9026 if (ret < 0) 9027 printf("cmd_tunnel_filter_parsed error: (%s)\n", 9028 strerror(-ret)); 9029 9030 } 9031 cmdline_parse_token_string_t cmd_tunnel_filter_cmd = 9032 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_filter_result, 9033 cmd, "tunnel_filter"); 9034 cmdline_parse_token_string_t cmd_tunnel_filter_what = 9035 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_filter_result, 9036 what, "add#rm"); 9037 cmdline_parse_token_num_t cmd_tunnel_filter_port_id = 9038 TOKEN_NUM_INITIALIZER(struct cmd_tunnel_filter_result, 9039 port_id, UINT16); 9040 cmdline_parse_token_etheraddr_t cmd_tunnel_filter_outer_mac = 9041 TOKEN_ETHERADDR_INITIALIZER(struct cmd_tunnel_filter_result, 9042 outer_mac); 9043 cmdline_parse_token_etheraddr_t cmd_tunnel_filter_inner_mac = 9044 TOKEN_ETHERADDR_INITIALIZER(struct cmd_tunnel_filter_result, 9045 inner_mac); 9046 cmdline_parse_token_num_t cmd_tunnel_filter_innner_vlan = 9047 TOKEN_NUM_INITIALIZER(struct cmd_tunnel_filter_result, 9048 inner_vlan, UINT16); 9049 cmdline_parse_token_ipaddr_t cmd_tunnel_filter_ip_value = 9050 TOKEN_IPADDR_INITIALIZER(struct cmd_tunnel_filter_result, 9051 ip_value); 9052 cmdline_parse_token_string_t cmd_tunnel_filter_tunnel_type = 9053 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_filter_result, 9054 tunnel_type, "vxlan#nvgre#ipingre#vxlan-gpe"); 9055 9056 cmdline_parse_token_string_t cmd_tunnel_filter_filter_type = 9057 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_filter_result, 9058 filter_type, "oip#iip#imac-ivlan#imac-ivlan-tenid#imac-tenid#" 9059 "imac#omac-imac-tenid"); 9060 cmdline_parse_token_num_t cmd_tunnel_filter_tenant_id = 9061 TOKEN_NUM_INITIALIZER(struct cmd_tunnel_filter_result, 9062 tenant_id, UINT32); 9063 cmdline_parse_token_num_t cmd_tunnel_filter_queue_num = 9064 TOKEN_NUM_INITIALIZER(struct cmd_tunnel_filter_result, 9065 queue_num, UINT16); 9066 9067 cmdline_parse_inst_t cmd_tunnel_filter = { 9068 .f = cmd_tunnel_filter_parsed, 9069 .data = (void *)0, 9070 .help_str = "tunnel_filter add|rm <port_id> <outer_mac> <inner_mac> " 9071 "<ip> <inner_vlan> vxlan|nvgre|ipingre oip|iip|imac-ivlan|" 9072 "imac-ivlan-tenid|imac-tenid|imac|omac-imac-tenid <tenant_id> " 9073 "<queue_id>: Add/Rm tunnel filter of a port", 9074 .tokens = { 9075 (void *)&cmd_tunnel_filter_cmd, 9076 (void *)&cmd_tunnel_filter_what, 9077 (void *)&cmd_tunnel_filter_port_id, 9078 (void *)&cmd_tunnel_filter_outer_mac, 9079 (void *)&cmd_tunnel_filter_inner_mac, 9080 (void *)&cmd_tunnel_filter_ip_value, 9081 (void *)&cmd_tunnel_filter_innner_vlan, 9082 (void *)&cmd_tunnel_filter_tunnel_type, 9083 (void *)&cmd_tunnel_filter_filter_type, 9084 (void *)&cmd_tunnel_filter_tenant_id, 9085 (void *)&cmd_tunnel_filter_queue_num, 9086 NULL, 9087 }, 9088 }; 9089 9090 /* *** CONFIGURE TUNNEL UDP PORT *** */ 9091 struct cmd_tunnel_udp_config { 9092 cmdline_fixed_string_t cmd; 9093 cmdline_fixed_string_t what; 9094 uint16_t udp_port; 9095 portid_t port_id; 9096 }; 9097 9098 static void 9099 cmd_tunnel_udp_config_parsed(void *parsed_result, 9100 __attribute__((unused)) struct cmdline *cl, 9101 __attribute__((unused)) void *data) 9102 { 9103 struct cmd_tunnel_udp_config *res = parsed_result; 9104 struct rte_eth_udp_tunnel tunnel_udp; 9105 int ret; 9106 9107 tunnel_udp.udp_port = res->udp_port; 9108 9109 if (!strcmp(res->cmd, "rx_vxlan_port")) 9110 tunnel_udp.prot_type = RTE_TUNNEL_TYPE_VXLAN; 9111 9112 if (!strcmp(res->what, "add")) 9113 ret = rte_eth_dev_udp_tunnel_port_add(res->port_id, 9114 &tunnel_udp); 9115 else 9116 ret = rte_eth_dev_udp_tunnel_port_delete(res->port_id, 9117 &tunnel_udp); 9118 9119 if (ret < 0) 9120 printf("udp tunneling add error: (%s)\n", strerror(-ret)); 9121 } 9122 9123 cmdline_parse_token_string_t cmd_tunnel_udp_config_cmd = 9124 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_udp_config, 9125 cmd, "rx_vxlan_port"); 9126 cmdline_parse_token_string_t cmd_tunnel_udp_config_what = 9127 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_udp_config, 9128 what, "add#rm"); 9129 cmdline_parse_token_num_t cmd_tunnel_udp_config_udp_port = 9130 TOKEN_NUM_INITIALIZER(struct cmd_tunnel_udp_config, 9131 udp_port, UINT16); 9132 cmdline_parse_token_num_t cmd_tunnel_udp_config_port_id = 9133 TOKEN_NUM_INITIALIZER(struct cmd_tunnel_udp_config, 9134 port_id, UINT16); 9135 9136 cmdline_parse_inst_t cmd_tunnel_udp_config = { 9137 .f = cmd_tunnel_udp_config_parsed, 9138 .data = (void *)0, 9139 .help_str = "rx_vxlan_port add|rm <udp_port> <port_id>: " 9140 "Add/Remove a tunneling UDP port filter", 9141 .tokens = { 9142 (void *)&cmd_tunnel_udp_config_cmd, 9143 (void *)&cmd_tunnel_udp_config_what, 9144 (void *)&cmd_tunnel_udp_config_udp_port, 9145 (void *)&cmd_tunnel_udp_config_port_id, 9146 NULL, 9147 }, 9148 }; 9149 9150 struct cmd_config_tunnel_udp_port { 9151 cmdline_fixed_string_t port; 9152 cmdline_fixed_string_t config; 9153 portid_t port_id; 9154 cmdline_fixed_string_t udp_tunnel_port; 9155 cmdline_fixed_string_t action; 9156 cmdline_fixed_string_t tunnel_type; 9157 uint16_t udp_port; 9158 }; 9159 9160 static void 9161 cmd_cfg_tunnel_udp_port_parsed(void *parsed_result, 9162 __attribute__((unused)) struct cmdline *cl, 9163 __attribute__((unused)) void *data) 9164 { 9165 struct cmd_config_tunnel_udp_port *res = parsed_result; 9166 struct rte_eth_udp_tunnel tunnel_udp; 9167 int ret = 0; 9168 9169 if (port_id_is_invalid(res->port_id, ENABLED_WARN)) 9170 return; 9171 9172 tunnel_udp.udp_port = res->udp_port; 9173 9174 if (!strcmp(res->tunnel_type, "vxlan")) { 9175 tunnel_udp.prot_type = RTE_TUNNEL_TYPE_VXLAN; 9176 } else if (!strcmp(res->tunnel_type, "geneve")) { 9177 tunnel_udp.prot_type = RTE_TUNNEL_TYPE_GENEVE; 9178 } else if (!strcmp(res->tunnel_type, "vxlan-gpe")) { 9179 tunnel_udp.prot_type = RTE_TUNNEL_TYPE_VXLAN_GPE; 9180 } else { 9181 printf("Invalid tunnel type\n"); 9182 return; 9183 } 9184 9185 if (!strcmp(res->action, "add")) 9186 ret = rte_eth_dev_udp_tunnel_port_add(res->port_id, 9187 &tunnel_udp); 9188 else 9189 ret = rte_eth_dev_udp_tunnel_port_delete(res->port_id, 9190 &tunnel_udp); 9191 9192 if (ret < 0) 9193 printf("udp tunneling port add error: (%s)\n", strerror(-ret)); 9194 } 9195 9196 cmdline_parse_token_string_t cmd_config_tunnel_udp_port_port = 9197 TOKEN_STRING_INITIALIZER(struct cmd_config_tunnel_udp_port, port, 9198 "port"); 9199 cmdline_parse_token_string_t cmd_config_tunnel_udp_port_config = 9200 TOKEN_STRING_INITIALIZER(struct cmd_config_tunnel_udp_port, config, 9201 "config"); 9202 cmdline_parse_token_num_t cmd_config_tunnel_udp_port_port_id = 9203 TOKEN_NUM_INITIALIZER(struct cmd_config_tunnel_udp_port, port_id, 9204 UINT16); 9205 cmdline_parse_token_string_t cmd_config_tunnel_udp_port_tunnel_port = 9206 TOKEN_STRING_INITIALIZER(struct cmd_config_tunnel_udp_port, 9207 udp_tunnel_port, 9208 "udp_tunnel_port"); 9209 cmdline_parse_token_string_t cmd_config_tunnel_udp_port_action = 9210 TOKEN_STRING_INITIALIZER(struct cmd_config_tunnel_udp_port, action, 9211 "add#rm"); 9212 cmdline_parse_token_string_t cmd_config_tunnel_udp_port_tunnel_type = 9213 TOKEN_STRING_INITIALIZER(struct cmd_config_tunnel_udp_port, tunnel_type, 9214 "vxlan#geneve#vxlan-gpe"); 9215 cmdline_parse_token_num_t cmd_config_tunnel_udp_port_value = 9216 TOKEN_NUM_INITIALIZER(struct cmd_config_tunnel_udp_port, udp_port, 9217 UINT16); 9218 9219 cmdline_parse_inst_t cmd_cfg_tunnel_udp_port = { 9220 .f = cmd_cfg_tunnel_udp_port_parsed, 9221 .data = NULL, 9222 .help_str = "port config <port_id> udp_tunnel_port add|rm vxlan|geneve|vxlan-gpe <udp_port>", 9223 .tokens = { 9224 (void *)&cmd_config_tunnel_udp_port_port, 9225 (void *)&cmd_config_tunnel_udp_port_config, 9226 (void *)&cmd_config_tunnel_udp_port_port_id, 9227 (void *)&cmd_config_tunnel_udp_port_tunnel_port, 9228 (void *)&cmd_config_tunnel_udp_port_action, 9229 (void *)&cmd_config_tunnel_udp_port_tunnel_type, 9230 (void *)&cmd_config_tunnel_udp_port_value, 9231 NULL, 9232 }, 9233 }; 9234 9235 /* *** GLOBAL CONFIG *** */ 9236 struct cmd_global_config_result { 9237 cmdline_fixed_string_t cmd; 9238 portid_t port_id; 9239 cmdline_fixed_string_t cfg_type; 9240 uint8_t len; 9241 }; 9242 9243 static void 9244 cmd_global_config_parsed(void *parsed_result, 9245 __attribute__((unused)) struct cmdline *cl, 9246 __attribute__((unused)) void *data) 9247 { 9248 struct cmd_global_config_result *res = parsed_result; 9249 struct rte_eth_global_cfg conf; 9250 int ret; 9251 9252 memset(&conf, 0, sizeof(conf)); 9253 conf.cfg_type = RTE_ETH_GLOBAL_CFG_TYPE_GRE_KEY_LEN; 9254 conf.cfg.gre_key_len = res->len; 9255 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_NONE, 9256 RTE_ETH_FILTER_SET, &conf); 9257 if (ret != 0) 9258 printf("Global config error\n"); 9259 } 9260 9261 cmdline_parse_token_string_t cmd_global_config_cmd = 9262 TOKEN_STRING_INITIALIZER(struct cmd_global_config_result, cmd, 9263 "global_config"); 9264 cmdline_parse_token_num_t cmd_global_config_port_id = 9265 TOKEN_NUM_INITIALIZER(struct cmd_global_config_result, port_id, 9266 UINT16); 9267 cmdline_parse_token_string_t cmd_global_config_type = 9268 TOKEN_STRING_INITIALIZER(struct cmd_global_config_result, 9269 cfg_type, "gre-key-len"); 9270 cmdline_parse_token_num_t cmd_global_config_gre_key_len = 9271 TOKEN_NUM_INITIALIZER(struct cmd_global_config_result, 9272 len, UINT8); 9273 9274 cmdline_parse_inst_t cmd_global_config = { 9275 .f = cmd_global_config_parsed, 9276 .data = (void *)NULL, 9277 .help_str = "global_config <port_id> gre-key-len <key_len>", 9278 .tokens = { 9279 (void *)&cmd_global_config_cmd, 9280 (void *)&cmd_global_config_port_id, 9281 (void *)&cmd_global_config_type, 9282 (void *)&cmd_global_config_gre_key_len, 9283 NULL, 9284 }, 9285 }; 9286 9287 /* *** CONFIGURE VM MIRROR VLAN/POOL RULE *** */ 9288 struct cmd_set_mirror_mask_result { 9289 cmdline_fixed_string_t set; 9290 cmdline_fixed_string_t port; 9291 portid_t port_id; 9292 cmdline_fixed_string_t mirror; 9293 uint8_t rule_id; 9294 cmdline_fixed_string_t what; 9295 cmdline_fixed_string_t value; 9296 cmdline_fixed_string_t dstpool; 9297 uint8_t dstpool_id; 9298 cmdline_fixed_string_t on; 9299 }; 9300 9301 cmdline_parse_token_string_t cmd_mirror_mask_set = 9302 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result, 9303 set, "set"); 9304 cmdline_parse_token_string_t cmd_mirror_mask_port = 9305 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result, 9306 port, "port"); 9307 cmdline_parse_token_num_t cmd_mirror_mask_portid = 9308 TOKEN_NUM_INITIALIZER(struct cmd_set_mirror_mask_result, 9309 port_id, UINT16); 9310 cmdline_parse_token_string_t cmd_mirror_mask_mirror = 9311 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result, 9312 mirror, "mirror-rule"); 9313 cmdline_parse_token_num_t cmd_mirror_mask_ruleid = 9314 TOKEN_NUM_INITIALIZER(struct cmd_set_mirror_mask_result, 9315 rule_id, UINT8); 9316 cmdline_parse_token_string_t cmd_mirror_mask_what = 9317 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result, 9318 what, "pool-mirror-up#pool-mirror-down" 9319 "#vlan-mirror"); 9320 cmdline_parse_token_string_t cmd_mirror_mask_value = 9321 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result, 9322 value, NULL); 9323 cmdline_parse_token_string_t cmd_mirror_mask_dstpool = 9324 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result, 9325 dstpool, "dst-pool"); 9326 cmdline_parse_token_num_t cmd_mirror_mask_poolid = 9327 TOKEN_NUM_INITIALIZER(struct cmd_set_mirror_mask_result, 9328 dstpool_id, UINT8); 9329 cmdline_parse_token_string_t cmd_mirror_mask_on = 9330 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result, 9331 on, "on#off"); 9332 9333 static void 9334 cmd_set_mirror_mask_parsed(void *parsed_result, 9335 __attribute__((unused)) struct cmdline *cl, 9336 __attribute__((unused)) void *data) 9337 { 9338 int ret,nb_item,i; 9339 struct cmd_set_mirror_mask_result *res = parsed_result; 9340 struct rte_eth_mirror_conf mr_conf; 9341 9342 memset(&mr_conf, 0, sizeof(struct rte_eth_mirror_conf)); 9343 9344 unsigned int vlan_list[ETH_MIRROR_MAX_VLANS]; 9345 9346 mr_conf.dst_pool = res->dstpool_id; 9347 9348 if (!strcmp(res->what, "pool-mirror-up")) { 9349 mr_conf.pool_mask = strtoull(res->value, NULL, 16); 9350 mr_conf.rule_type = ETH_MIRROR_VIRTUAL_POOL_UP; 9351 } else if (!strcmp(res->what, "pool-mirror-down")) { 9352 mr_conf.pool_mask = strtoull(res->value, NULL, 16); 9353 mr_conf.rule_type = ETH_MIRROR_VIRTUAL_POOL_DOWN; 9354 } else if (!strcmp(res->what, "vlan-mirror")) { 9355 mr_conf.rule_type = ETH_MIRROR_VLAN; 9356 nb_item = parse_item_list(res->value, "vlan", 9357 ETH_MIRROR_MAX_VLANS, vlan_list, 1); 9358 if (nb_item <= 0) 9359 return; 9360 9361 for (i = 0; i < nb_item; i++) { 9362 if (vlan_list[i] > RTE_ETHER_MAX_VLAN_ID) { 9363 printf("Invalid vlan_id: must be < 4096\n"); 9364 return; 9365 } 9366 9367 mr_conf.vlan.vlan_id[i] = (uint16_t)vlan_list[i]; 9368 mr_conf.vlan.vlan_mask |= 1ULL << i; 9369 } 9370 } 9371 9372 if (!strcmp(res->on, "on")) 9373 ret = rte_eth_mirror_rule_set(res->port_id, &mr_conf, 9374 res->rule_id, 1); 9375 else 9376 ret = rte_eth_mirror_rule_set(res->port_id, &mr_conf, 9377 res->rule_id, 0); 9378 if (ret < 0) 9379 printf("mirror rule add error: (%s)\n", strerror(-ret)); 9380 } 9381 9382 cmdline_parse_inst_t cmd_set_mirror_mask = { 9383 .f = cmd_set_mirror_mask_parsed, 9384 .data = NULL, 9385 .help_str = "set port <port_id> mirror-rule <rule_id> " 9386 "pool-mirror-up|pool-mirror-down|vlan-mirror " 9387 "<pool_mask|vlan_id[,vlan_id]*> dst-pool <pool_id> on|off", 9388 .tokens = { 9389 (void *)&cmd_mirror_mask_set, 9390 (void *)&cmd_mirror_mask_port, 9391 (void *)&cmd_mirror_mask_portid, 9392 (void *)&cmd_mirror_mask_mirror, 9393 (void *)&cmd_mirror_mask_ruleid, 9394 (void *)&cmd_mirror_mask_what, 9395 (void *)&cmd_mirror_mask_value, 9396 (void *)&cmd_mirror_mask_dstpool, 9397 (void *)&cmd_mirror_mask_poolid, 9398 (void *)&cmd_mirror_mask_on, 9399 NULL, 9400 }, 9401 }; 9402 9403 /* *** CONFIGURE VM MIRROR UPLINK/DOWNLINK RULE *** */ 9404 struct cmd_set_mirror_link_result { 9405 cmdline_fixed_string_t set; 9406 cmdline_fixed_string_t port; 9407 portid_t port_id; 9408 cmdline_fixed_string_t mirror; 9409 uint8_t rule_id; 9410 cmdline_fixed_string_t what; 9411 cmdline_fixed_string_t dstpool; 9412 uint8_t dstpool_id; 9413 cmdline_fixed_string_t on; 9414 }; 9415 9416 cmdline_parse_token_string_t cmd_mirror_link_set = 9417 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_link_result, 9418 set, "set"); 9419 cmdline_parse_token_string_t cmd_mirror_link_port = 9420 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_link_result, 9421 port, "port"); 9422 cmdline_parse_token_num_t cmd_mirror_link_portid = 9423 TOKEN_NUM_INITIALIZER(struct cmd_set_mirror_link_result, 9424 port_id, UINT16); 9425 cmdline_parse_token_string_t cmd_mirror_link_mirror = 9426 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_link_result, 9427 mirror, "mirror-rule"); 9428 cmdline_parse_token_num_t cmd_mirror_link_ruleid = 9429 TOKEN_NUM_INITIALIZER(struct cmd_set_mirror_link_result, 9430 rule_id, UINT8); 9431 cmdline_parse_token_string_t cmd_mirror_link_what = 9432 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_link_result, 9433 what, "uplink-mirror#downlink-mirror"); 9434 cmdline_parse_token_string_t cmd_mirror_link_dstpool = 9435 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_link_result, 9436 dstpool, "dst-pool"); 9437 cmdline_parse_token_num_t cmd_mirror_link_poolid = 9438 TOKEN_NUM_INITIALIZER(struct cmd_set_mirror_link_result, 9439 dstpool_id, UINT8); 9440 cmdline_parse_token_string_t cmd_mirror_link_on = 9441 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_link_result, 9442 on, "on#off"); 9443 9444 static void 9445 cmd_set_mirror_link_parsed(void *parsed_result, 9446 __attribute__((unused)) struct cmdline *cl, 9447 __attribute__((unused)) void *data) 9448 { 9449 int ret; 9450 struct cmd_set_mirror_link_result *res = parsed_result; 9451 struct rte_eth_mirror_conf mr_conf; 9452 9453 memset(&mr_conf, 0, sizeof(struct rte_eth_mirror_conf)); 9454 if (!strcmp(res->what, "uplink-mirror")) 9455 mr_conf.rule_type = ETH_MIRROR_UPLINK_PORT; 9456 else 9457 mr_conf.rule_type = ETH_MIRROR_DOWNLINK_PORT; 9458 9459 mr_conf.dst_pool = res->dstpool_id; 9460 9461 if (!strcmp(res->on, "on")) 9462 ret = rte_eth_mirror_rule_set(res->port_id, &mr_conf, 9463 res->rule_id, 1); 9464 else 9465 ret = rte_eth_mirror_rule_set(res->port_id, &mr_conf, 9466 res->rule_id, 0); 9467 9468 /* check the return value and print it if is < 0 */ 9469 if (ret < 0) 9470 printf("mirror rule add error: (%s)\n", strerror(-ret)); 9471 9472 } 9473 9474 cmdline_parse_inst_t cmd_set_mirror_link = { 9475 .f = cmd_set_mirror_link_parsed, 9476 .data = NULL, 9477 .help_str = "set port <port_id> mirror-rule <rule_id> " 9478 "uplink-mirror|downlink-mirror dst-pool <pool_id> on|off", 9479 .tokens = { 9480 (void *)&cmd_mirror_link_set, 9481 (void *)&cmd_mirror_link_port, 9482 (void *)&cmd_mirror_link_portid, 9483 (void *)&cmd_mirror_link_mirror, 9484 (void *)&cmd_mirror_link_ruleid, 9485 (void *)&cmd_mirror_link_what, 9486 (void *)&cmd_mirror_link_dstpool, 9487 (void *)&cmd_mirror_link_poolid, 9488 (void *)&cmd_mirror_link_on, 9489 NULL, 9490 }, 9491 }; 9492 9493 /* *** RESET VM MIRROR RULE *** */ 9494 struct cmd_rm_mirror_rule_result { 9495 cmdline_fixed_string_t reset; 9496 cmdline_fixed_string_t port; 9497 portid_t port_id; 9498 cmdline_fixed_string_t mirror; 9499 uint8_t rule_id; 9500 }; 9501 9502 cmdline_parse_token_string_t cmd_rm_mirror_rule_reset = 9503 TOKEN_STRING_INITIALIZER(struct cmd_rm_mirror_rule_result, 9504 reset, "reset"); 9505 cmdline_parse_token_string_t cmd_rm_mirror_rule_port = 9506 TOKEN_STRING_INITIALIZER(struct cmd_rm_mirror_rule_result, 9507 port, "port"); 9508 cmdline_parse_token_num_t cmd_rm_mirror_rule_portid = 9509 TOKEN_NUM_INITIALIZER(struct cmd_rm_mirror_rule_result, 9510 port_id, UINT16); 9511 cmdline_parse_token_string_t cmd_rm_mirror_rule_mirror = 9512 TOKEN_STRING_INITIALIZER(struct cmd_rm_mirror_rule_result, 9513 mirror, "mirror-rule"); 9514 cmdline_parse_token_num_t cmd_rm_mirror_rule_ruleid = 9515 TOKEN_NUM_INITIALIZER(struct cmd_rm_mirror_rule_result, 9516 rule_id, UINT8); 9517 9518 static void 9519 cmd_reset_mirror_rule_parsed(void *parsed_result, 9520 __attribute__((unused)) struct cmdline *cl, 9521 __attribute__((unused)) void *data) 9522 { 9523 int ret; 9524 struct cmd_set_mirror_link_result *res = parsed_result; 9525 /* check rule_id */ 9526 ret = rte_eth_mirror_rule_reset(res->port_id,res->rule_id); 9527 if(ret < 0) 9528 printf("mirror rule remove error: (%s)\n", strerror(-ret)); 9529 } 9530 9531 cmdline_parse_inst_t cmd_reset_mirror_rule = { 9532 .f = cmd_reset_mirror_rule_parsed, 9533 .data = NULL, 9534 .help_str = "reset port <port_id> mirror-rule <rule_id>", 9535 .tokens = { 9536 (void *)&cmd_rm_mirror_rule_reset, 9537 (void *)&cmd_rm_mirror_rule_port, 9538 (void *)&cmd_rm_mirror_rule_portid, 9539 (void *)&cmd_rm_mirror_rule_mirror, 9540 (void *)&cmd_rm_mirror_rule_ruleid, 9541 NULL, 9542 }, 9543 }; 9544 9545 /* ******************************************************************************** */ 9546 9547 struct cmd_dump_result { 9548 cmdline_fixed_string_t dump; 9549 }; 9550 9551 static void 9552 dump_struct_sizes(void) 9553 { 9554 #define DUMP_SIZE(t) printf("sizeof(" #t ") = %u\n", (unsigned)sizeof(t)); 9555 DUMP_SIZE(struct rte_mbuf); 9556 DUMP_SIZE(struct rte_mempool); 9557 DUMP_SIZE(struct rte_ring); 9558 #undef DUMP_SIZE 9559 } 9560 9561 static void cmd_dump_parsed(void *parsed_result, 9562 __attribute__((unused)) struct cmdline *cl, 9563 __attribute__((unused)) void *data) 9564 { 9565 struct cmd_dump_result *res = parsed_result; 9566 9567 if (!strcmp(res->dump, "dump_physmem")) 9568 rte_dump_physmem_layout(stdout); 9569 else if (!strcmp(res->dump, "dump_memzone")) 9570 rte_memzone_dump(stdout); 9571 else if (!strcmp(res->dump, "dump_struct_sizes")) 9572 dump_struct_sizes(); 9573 else if (!strcmp(res->dump, "dump_ring")) 9574 rte_ring_list_dump(stdout); 9575 else if (!strcmp(res->dump, "dump_mempool")) 9576 rte_mempool_list_dump(stdout); 9577 else if (!strcmp(res->dump, "dump_devargs")) 9578 rte_devargs_dump(stdout); 9579 else if (!strcmp(res->dump, "dump_log_types")) 9580 rte_log_dump(stdout); 9581 } 9582 9583 cmdline_parse_token_string_t cmd_dump_dump = 9584 TOKEN_STRING_INITIALIZER(struct cmd_dump_result, dump, 9585 "dump_physmem#" 9586 "dump_memzone#" 9587 "dump_struct_sizes#" 9588 "dump_ring#" 9589 "dump_mempool#" 9590 "dump_devargs#" 9591 "dump_log_types"); 9592 9593 cmdline_parse_inst_t cmd_dump = { 9594 .f = cmd_dump_parsed, /* function to call */ 9595 .data = NULL, /* 2nd arg of func */ 9596 .help_str = "Dump status", 9597 .tokens = { /* token list, NULL terminated */ 9598 (void *)&cmd_dump_dump, 9599 NULL, 9600 }, 9601 }; 9602 9603 /* ******************************************************************************** */ 9604 9605 struct cmd_dump_one_result { 9606 cmdline_fixed_string_t dump; 9607 cmdline_fixed_string_t name; 9608 }; 9609 9610 static void cmd_dump_one_parsed(void *parsed_result, struct cmdline *cl, 9611 __attribute__((unused)) void *data) 9612 { 9613 struct cmd_dump_one_result *res = parsed_result; 9614 9615 if (!strcmp(res->dump, "dump_ring")) { 9616 struct rte_ring *r; 9617 r = rte_ring_lookup(res->name); 9618 if (r == NULL) { 9619 cmdline_printf(cl, "Cannot find ring\n"); 9620 return; 9621 } 9622 rte_ring_dump(stdout, r); 9623 } else if (!strcmp(res->dump, "dump_mempool")) { 9624 struct rte_mempool *mp; 9625 mp = rte_mempool_lookup(res->name); 9626 if (mp == NULL) { 9627 cmdline_printf(cl, "Cannot find mempool\n"); 9628 return; 9629 } 9630 rte_mempool_dump(stdout, mp); 9631 } 9632 } 9633 9634 cmdline_parse_token_string_t cmd_dump_one_dump = 9635 TOKEN_STRING_INITIALIZER(struct cmd_dump_one_result, dump, 9636 "dump_ring#dump_mempool"); 9637 9638 cmdline_parse_token_string_t cmd_dump_one_name = 9639 TOKEN_STRING_INITIALIZER(struct cmd_dump_one_result, name, NULL); 9640 9641 cmdline_parse_inst_t cmd_dump_one = { 9642 .f = cmd_dump_one_parsed, /* function to call */ 9643 .data = NULL, /* 2nd arg of func */ 9644 .help_str = "dump_ring|dump_mempool <name>: Dump one ring/mempool", 9645 .tokens = { /* token list, NULL terminated */ 9646 (void *)&cmd_dump_one_dump, 9647 (void *)&cmd_dump_one_name, 9648 NULL, 9649 }, 9650 }; 9651 9652 /* *** Add/Del syn filter *** */ 9653 struct cmd_syn_filter_result { 9654 cmdline_fixed_string_t filter; 9655 portid_t port_id; 9656 cmdline_fixed_string_t ops; 9657 cmdline_fixed_string_t priority; 9658 cmdline_fixed_string_t high; 9659 cmdline_fixed_string_t queue; 9660 uint16_t queue_id; 9661 }; 9662 9663 static void 9664 cmd_syn_filter_parsed(void *parsed_result, 9665 __attribute__((unused)) struct cmdline *cl, 9666 __attribute__((unused)) void *data) 9667 { 9668 struct cmd_syn_filter_result *res = parsed_result; 9669 struct rte_eth_syn_filter syn_filter; 9670 int ret = 0; 9671 9672 ret = rte_eth_dev_filter_supported(res->port_id, 9673 RTE_ETH_FILTER_SYN); 9674 if (ret < 0) { 9675 printf("syn filter is not supported on port %u.\n", 9676 res->port_id); 9677 return; 9678 } 9679 9680 memset(&syn_filter, 0, sizeof(syn_filter)); 9681 9682 if (!strcmp(res->ops, "add")) { 9683 if (!strcmp(res->high, "high")) 9684 syn_filter.hig_pri = 1; 9685 else 9686 syn_filter.hig_pri = 0; 9687 9688 syn_filter.queue = res->queue_id; 9689 ret = rte_eth_dev_filter_ctrl(res->port_id, 9690 RTE_ETH_FILTER_SYN, 9691 RTE_ETH_FILTER_ADD, 9692 &syn_filter); 9693 } else 9694 ret = rte_eth_dev_filter_ctrl(res->port_id, 9695 RTE_ETH_FILTER_SYN, 9696 RTE_ETH_FILTER_DELETE, 9697 &syn_filter); 9698 9699 if (ret < 0) 9700 printf("syn filter programming error: (%s)\n", 9701 strerror(-ret)); 9702 } 9703 9704 cmdline_parse_token_string_t cmd_syn_filter_filter = 9705 TOKEN_STRING_INITIALIZER(struct cmd_syn_filter_result, 9706 filter, "syn_filter"); 9707 cmdline_parse_token_num_t cmd_syn_filter_port_id = 9708 TOKEN_NUM_INITIALIZER(struct cmd_syn_filter_result, 9709 port_id, UINT16); 9710 cmdline_parse_token_string_t cmd_syn_filter_ops = 9711 TOKEN_STRING_INITIALIZER(struct cmd_syn_filter_result, 9712 ops, "add#del"); 9713 cmdline_parse_token_string_t cmd_syn_filter_priority = 9714 TOKEN_STRING_INITIALIZER(struct cmd_syn_filter_result, 9715 priority, "priority"); 9716 cmdline_parse_token_string_t cmd_syn_filter_high = 9717 TOKEN_STRING_INITIALIZER(struct cmd_syn_filter_result, 9718 high, "high#low"); 9719 cmdline_parse_token_string_t cmd_syn_filter_queue = 9720 TOKEN_STRING_INITIALIZER(struct cmd_syn_filter_result, 9721 queue, "queue"); 9722 cmdline_parse_token_num_t cmd_syn_filter_queue_id = 9723 TOKEN_NUM_INITIALIZER(struct cmd_syn_filter_result, 9724 queue_id, UINT16); 9725 9726 cmdline_parse_inst_t cmd_syn_filter = { 9727 .f = cmd_syn_filter_parsed, 9728 .data = NULL, 9729 .help_str = "syn_filter <port_id> add|del priority high|low queue " 9730 "<queue_id>: Add/Delete syn filter", 9731 .tokens = { 9732 (void *)&cmd_syn_filter_filter, 9733 (void *)&cmd_syn_filter_port_id, 9734 (void *)&cmd_syn_filter_ops, 9735 (void *)&cmd_syn_filter_priority, 9736 (void *)&cmd_syn_filter_high, 9737 (void *)&cmd_syn_filter_queue, 9738 (void *)&cmd_syn_filter_queue_id, 9739 NULL, 9740 }, 9741 }; 9742 9743 /* *** queue region set *** */ 9744 struct cmd_queue_region_result { 9745 cmdline_fixed_string_t set; 9746 cmdline_fixed_string_t port; 9747 portid_t port_id; 9748 cmdline_fixed_string_t cmd; 9749 cmdline_fixed_string_t region; 9750 uint8_t region_id; 9751 cmdline_fixed_string_t queue_start_index; 9752 uint8_t queue_id; 9753 cmdline_fixed_string_t queue_num; 9754 uint8_t queue_num_value; 9755 }; 9756 9757 static void 9758 cmd_queue_region_parsed(void *parsed_result, 9759 __attribute__((unused)) struct cmdline *cl, 9760 __attribute__((unused)) void *data) 9761 { 9762 struct cmd_queue_region_result *res = parsed_result; 9763 int ret = -ENOTSUP; 9764 #ifdef RTE_LIBRTE_I40E_PMD 9765 struct rte_pmd_i40e_queue_region_conf region_conf; 9766 enum rte_pmd_i40e_queue_region_op op_type; 9767 #endif 9768 9769 if (port_id_is_invalid(res->port_id, ENABLED_WARN)) 9770 return; 9771 9772 #ifdef RTE_LIBRTE_I40E_PMD 9773 memset(®ion_conf, 0, sizeof(region_conf)); 9774 op_type = RTE_PMD_I40E_RSS_QUEUE_REGION_SET; 9775 region_conf.region_id = res->region_id; 9776 region_conf.queue_num = res->queue_num_value; 9777 region_conf.queue_start_index = res->queue_id; 9778 9779 ret = rte_pmd_i40e_rss_queue_region_conf(res->port_id, 9780 op_type, ®ion_conf); 9781 #endif 9782 9783 switch (ret) { 9784 case 0: 9785 break; 9786 case -ENOTSUP: 9787 printf("function not implemented or supported\n"); 9788 break; 9789 default: 9790 printf("queue region config error: (%s)\n", strerror(-ret)); 9791 } 9792 } 9793 9794 cmdline_parse_token_string_t cmd_queue_region_set = 9795 TOKEN_STRING_INITIALIZER(struct cmd_queue_region_result, 9796 set, "set"); 9797 cmdline_parse_token_string_t cmd_queue_region_port = 9798 TOKEN_STRING_INITIALIZER(struct cmd_queue_region_result, port, "port"); 9799 cmdline_parse_token_num_t cmd_queue_region_port_id = 9800 TOKEN_NUM_INITIALIZER(struct cmd_queue_region_result, 9801 port_id, UINT16); 9802 cmdline_parse_token_string_t cmd_queue_region_cmd = 9803 TOKEN_STRING_INITIALIZER(struct cmd_queue_region_result, 9804 cmd, "queue-region"); 9805 cmdline_parse_token_string_t cmd_queue_region_id = 9806 TOKEN_STRING_INITIALIZER(struct cmd_queue_region_result, 9807 region, "region_id"); 9808 cmdline_parse_token_num_t cmd_queue_region_index = 9809 TOKEN_NUM_INITIALIZER(struct cmd_queue_region_result, 9810 region_id, UINT8); 9811 cmdline_parse_token_string_t cmd_queue_region_queue_start_index = 9812 TOKEN_STRING_INITIALIZER(struct cmd_queue_region_result, 9813 queue_start_index, "queue_start_index"); 9814 cmdline_parse_token_num_t cmd_queue_region_queue_id = 9815 TOKEN_NUM_INITIALIZER(struct cmd_queue_region_result, 9816 queue_id, UINT8); 9817 cmdline_parse_token_string_t cmd_queue_region_queue_num = 9818 TOKEN_STRING_INITIALIZER(struct cmd_queue_region_result, 9819 queue_num, "queue_num"); 9820 cmdline_parse_token_num_t cmd_queue_region_queue_num_value = 9821 TOKEN_NUM_INITIALIZER(struct cmd_queue_region_result, 9822 queue_num_value, UINT8); 9823 9824 cmdline_parse_inst_t cmd_queue_region = { 9825 .f = cmd_queue_region_parsed, 9826 .data = NULL, 9827 .help_str = "set port <port_id> queue-region region_id <value> " 9828 "queue_start_index <value> queue_num <value>: Set a queue region", 9829 .tokens = { 9830 (void *)&cmd_queue_region_set, 9831 (void *)&cmd_queue_region_port, 9832 (void *)&cmd_queue_region_port_id, 9833 (void *)&cmd_queue_region_cmd, 9834 (void *)&cmd_queue_region_id, 9835 (void *)&cmd_queue_region_index, 9836 (void *)&cmd_queue_region_queue_start_index, 9837 (void *)&cmd_queue_region_queue_id, 9838 (void *)&cmd_queue_region_queue_num, 9839 (void *)&cmd_queue_region_queue_num_value, 9840 NULL, 9841 }, 9842 }; 9843 9844 /* *** queue region and flowtype set *** */ 9845 struct cmd_region_flowtype_result { 9846 cmdline_fixed_string_t set; 9847 cmdline_fixed_string_t port; 9848 portid_t port_id; 9849 cmdline_fixed_string_t cmd; 9850 cmdline_fixed_string_t region; 9851 uint8_t region_id; 9852 cmdline_fixed_string_t flowtype; 9853 uint8_t flowtype_id; 9854 }; 9855 9856 static void 9857 cmd_region_flowtype_parsed(void *parsed_result, 9858 __attribute__((unused)) struct cmdline *cl, 9859 __attribute__((unused)) void *data) 9860 { 9861 struct cmd_region_flowtype_result *res = parsed_result; 9862 int ret = -ENOTSUP; 9863 #ifdef RTE_LIBRTE_I40E_PMD 9864 struct rte_pmd_i40e_queue_region_conf region_conf; 9865 enum rte_pmd_i40e_queue_region_op op_type; 9866 #endif 9867 9868 if (port_id_is_invalid(res->port_id, ENABLED_WARN)) 9869 return; 9870 9871 #ifdef RTE_LIBRTE_I40E_PMD 9872 memset(®ion_conf, 0, sizeof(region_conf)); 9873 9874 op_type = RTE_PMD_I40E_RSS_QUEUE_REGION_FLOWTYPE_SET; 9875 region_conf.region_id = res->region_id; 9876 region_conf.hw_flowtype = res->flowtype_id; 9877 9878 ret = rte_pmd_i40e_rss_queue_region_conf(res->port_id, 9879 op_type, ®ion_conf); 9880 #endif 9881 9882 switch (ret) { 9883 case 0: 9884 break; 9885 case -ENOTSUP: 9886 printf("function not implemented or supported\n"); 9887 break; 9888 default: 9889 printf("region flowtype config error: (%s)\n", strerror(-ret)); 9890 } 9891 } 9892 9893 cmdline_parse_token_string_t cmd_region_flowtype_set = 9894 TOKEN_STRING_INITIALIZER(struct cmd_region_flowtype_result, 9895 set, "set"); 9896 cmdline_parse_token_string_t cmd_region_flowtype_port = 9897 TOKEN_STRING_INITIALIZER(struct cmd_region_flowtype_result, 9898 port, "port"); 9899 cmdline_parse_token_num_t cmd_region_flowtype_port_index = 9900 TOKEN_NUM_INITIALIZER(struct cmd_region_flowtype_result, 9901 port_id, UINT16); 9902 cmdline_parse_token_string_t cmd_region_flowtype_cmd = 9903 TOKEN_STRING_INITIALIZER(struct cmd_region_flowtype_result, 9904 cmd, "queue-region"); 9905 cmdline_parse_token_string_t cmd_region_flowtype_index = 9906 TOKEN_STRING_INITIALIZER(struct cmd_region_flowtype_result, 9907 region, "region_id"); 9908 cmdline_parse_token_num_t cmd_region_flowtype_id = 9909 TOKEN_NUM_INITIALIZER(struct cmd_region_flowtype_result, 9910 region_id, UINT8); 9911 cmdline_parse_token_string_t cmd_region_flowtype_flow_index = 9912 TOKEN_STRING_INITIALIZER(struct cmd_region_flowtype_result, 9913 flowtype, "flowtype"); 9914 cmdline_parse_token_num_t cmd_region_flowtype_flow_id = 9915 TOKEN_NUM_INITIALIZER(struct cmd_region_flowtype_result, 9916 flowtype_id, UINT8); 9917 cmdline_parse_inst_t cmd_region_flowtype = { 9918 .f = cmd_region_flowtype_parsed, 9919 .data = NULL, 9920 .help_str = "set port <port_id> queue-region region_id <value> " 9921 "flowtype <value>: Set a flowtype region index", 9922 .tokens = { 9923 (void *)&cmd_region_flowtype_set, 9924 (void *)&cmd_region_flowtype_port, 9925 (void *)&cmd_region_flowtype_port_index, 9926 (void *)&cmd_region_flowtype_cmd, 9927 (void *)&cmd_region_flowtype_index, 9928 (void *)&cmd_region_flowtype_id, 9929 (void *)&cmd_region_flowtype_flow_index, 9930 (void *)&cmd_region_flowtype_flow_id, 9931 NULL, 9932 }, 9933 }; 9934 9935 /* *** User Priority (UP) to queue region (region_id) set *** */ 9936 struct cmd_user_priority_region_result { 9937 cmdline_fixed_string_t set; 9938 cmdline_fixed_string_t port; 9939 portid_t port_id; 9940 cmdline_fixed_string_t cmd; 9941 cmdline_fixed_string_t user_priority; 9942 uint8_t user_priority_id; 9943 cmdline_fixed_string_t region; 9944 uint8_t region_id; 9945 }; 9946 9947 static void 9948 cmd_user_priority_region_parsed(void *parsed_result, 9949 __attribute__((unused)) struct cmdline *cl, 9950 __attribute__((unused)) void *data) 9951 { 9952 struct cmd_user_priority_region_result *res = parsed_result; 9953 int ret = -ENOTSUP; 9954 #ifdef RTE_LIBRTE_I40E_PMD 9955 struct rte_pmd_i40e_queue_region_conf region_conf; 9956 enum rte_pmd_i40e_queue_region_op op_type; 9957 #endif 9958 9959 if (port_id_is_invalid(res->port_id, ENABLED_WARN)) 9960 return; 9961 9962 #ifdef RTE_LIBRTE_I40E_PMD 9963 memset(®ion_conf, 0, sizeof(region_conf)); 9964 op_type = RTE_PMD_I40E_RSS_QUEUE_REGION_USER_PRIORITY_SET; 9965 region_conf.user_priority = res->user_priority_id; 9966 region_conf.region_id = res->region_id; 9967 9968 ret = rte_pmd_i40e_rss_queue_region_conf(res->port_id, 9969 op_type, ®ion_conf); 9970 #endif 9971 9972 switch (ret) { 9973 case 0: 9974 break; 9975 case -ENOTSUP: 9976 printf("function not implemented or supported\n"); 9977 break; 9978 default: 9979 printf("user_priority region config error: (%s)\n", 9980 strerror(-ret)); 9981 } 9982 } 9983 9984 cmdline_parse_token_string_t cmd_user_priority_region_set = 9985 TOKEN_STRING_INITIALIZER(struct cmd_user_priority_region_result, 9986 set, "set"); 9987 cmdline_parse_token_string_t cmd_user_priority_region_port = 9988 TOKEN_STRING_INITIALIZER(struct cmd_user_priority_region_result, 9989 port, "port"); 9990 cmdline_parse_token_num_t cmd_user_priority_region_port_index = 9991 TOKEN_NUM_INITIALIZER(struct cmd_user_priority_region_result, 9992 port_id, UINT16); 9993 cmdline_parse_token_string_t cmd_user_priority_region_cmd = 9994 TOKEN_STRING_INITIALIZER(struct cmd_user_priority_region_result, 9995 cmd, "queue-region"); 9996 cmdline_parse_token_string_t cmd_user_priority_region_UP = 9997 TOKEN_STRING_INITIALIZER(struct cmd_user_priority_region_result, 9998 user_priority, "UP"); 9999 cmdline_parse_token_num_t cmd_user_priority_region_UP_id = 10000 TOKEN_NUM_INITIALIZER(struct cmd_user_priority_region_result, 10001 user_priority_id, UINT8); 10002 cmdline_parse_token_string_t cmd_user_priority_region_region = 10003 TOKEN_STRING_INITIALIZER(struct cmd_user_priority_region_result, 10004 region, "region_id"); 10005 cmdline_parse_token_num_t cmd_user_priority_region_region_id = 10006 TOKEN_NUM_INITIALIZER(struct cmd_user_priority_region_result, 10007 region_id, UINT8); 10008 10009 cmdline_parse_inst_t cmd_user_priority_region = { 10010 .f = cmd_user_priority_region_parsed, 10011 .data = NULL, 10012 .help_str = "set port <port_id> queue-region UP <value> " 10013 "region_id <value>: Set the mapping of User Priority (UP) " 10014 "to queue region (region_id) ", 10015 .tokens = { 10016 (void *)&cmd_user_priority_region_set, 10017 (void *)&cmd_user_priority_region_port, 10018 (void *)&cmd_user_priority_region_port_index, 10019 (void *)&cmd_user_priority_region_cmd, 10020 (void *)&cmd_user_priority_region_UP, 10021 (void *)&cmd_user_priority_region_UP_id, 10022 (void *)&cmd_user_priority_region_region, 10023 (void *)&cmd_user_priority_region_region_id, 10024 NULL, 10025 }, 10026 }; 10027 10028 /* *** flush all queue region related configuration *** */ 10029 struct cmd_flush_queue_region_result { 10030 cmdline_fixed_string_t set; 10031 cmdline_fixed_string_t port; 10032 portid_t port_id; 10033 cmdline_fixed_string_t cmd; 10034 cmdline_fixed_string_t flush; 10035 cmdline_fixed_string_t what; 10036 }; 10037 10038 static void 10039 cmd_flush_queue_region_parsed(void *parsed_result, 10040 __attribute__((unused)) struct cmdline *cl, 10041 __attribute__((unused)) void *data) 10042 { 10043 struct cmd_flush_queue_region_result *res = parsed_result; 10044 int ret = -ENOTSUP; 10045 #ifdef RTE_LIBRTE_I40E_PMD 10046 struct rte_pmd_i40e_queue_region_conf region_conf; 10047 enum rte_pmd_i40e_queue_region_op op_type; 10048 #endif 10049 10050 if (port_id_is_invalid(res->port_id, ENABLED_WARN)) 10051 return; 10052 10053 #ifdef RTE_LIBRTE_I40E_PMD 10054 memset(®ion_conf, 0, sizeof(region_conf)); 10055 10056 if (strcmp(res->what, "on") == 0) 10057 op_type = RTE_PMD_I40E_RSS_QUEUE_REGION_ALL_FLUSH_ON; 10058 else 10059 op_type = RTE_PMD_I40E_RSS_QUEUE_REGION_ALL_FLUSH_OFF; 10060 10061 ret = rte_pmd_i40e_rss_queue_region_conf(res->port_id, 10062 op_type, ®ion_conf); 10063 #endif 10064 10065 switch (ret) { 10066 case 0: 10067 break; 10068 case -ENOTSUP: 10069 printf("function not implemented or supported\n"); 10070 break; 10071 default: 10072 printf("queue region config flush error: (%s)\n", 10073 strerror(-ret)); 10074 } 10075 } 10076 10077 cmdline_parse_token_string_t cmd_flush_queue_region_set = 10078 TOKEN_STRING_INITIALIZER(struct cmd_flush_queue_region_result, 10079 set, "set"); 10080 cmdline_parse_token_string_t cmd_flush_queue_region_port = 10081 TOKEN_STRING_INITIALIZER(struct cmd_flush_queue_region_result, 10082 port, "port"); 10083 cmdline_parse_token_num_t cmd_flush_queue_region_port_index = 10084 TOKEN_NUM_INITIALIZER(struct cmd_flush_queue_region_result, 10085 port_id, UINT16); 10086 cmdline_parse_token_string_t cmd_flush_queue_region_cmd = 10087 TOKEN_STRING_INITIALIZER(struct cmd_flush_queue_region_result, 10088 cmd, "queue-region"); 10089 cmdline_parse_token_string_t cmd_flush_queue_region_flush = 10090 TOKEN_STRING_INITIALIZER(struct cmd_flush_queue_region_result, 10091 flush, "flush"); 10092 cmdline_parse_token_string_t cmd_flush_queue_region_what = 10093 TOKEN_STRING_INITIALIZER(struct cmd_flush_queue_region_result, 10094 what, "on#off"); 10095 10096 cmdline_parse_inst_t cmd_flush_queue_region = { 10097 .f = cmd_flush_queue_region_parsed, 10098 .data = NULL, 10099 .help_str = "set port <port_id> queue-region flush on|off" 10100 ": flush all queue region related configuration", 10101 .tokens = { 10102 (void *)&cmd_flush_queue_region_set, 10103 (void *)&cmd_flush_queue_region_port, 10104 (void *)&cmd_flush_queue_region_port_index, 10105 (void *)&cmd_flush_queue_region_cmd, 10106 (void *)&cmd_flush_queue_region_flush, 10107 (void *)&cmd_flush_queue_region_what, 10108 NULL, 10109 }, 10110 }; 10111 10112 /* *** get all queue region related configuration info *** */ 10113 struct cmd_show_queue_region_info { 10114 cmdline_fixed_string_t show; 10115 cmdline_fixed_string_t port; 10116 portid_t port_id; 10117 cmdline_fixed_string_t cmd; 10118 }; 10119 10120 static void 10121 cmd_show_queue_region_info_parsed(void *parsed_result, 10122 __attribute__((unused)) struct cmdline *cl, 10123 __attribute__((unused)) void *data) 10124 { 10125 struct cmd_show_queue_region_info *res = parsed_result; 10126 int ret = -ENOTSUP; 10127 #ifdef RTE_LIBRTE_I40E_PMD 10128 struct rte_pmd_i40e_queue_regions rte_pmd_regions; 10129 enum rte_pmd_i40e_queue_region_op op_type; 10130 #endif 10131 10132 if (port_id_is_invalid(res->port_id, ENABLED_WARN)) 10133 return; 10134 10135 #ifdef RTE_LIBRTE_I40E_PMD 10136 memset(&rte_pmd_regions, 0, sizeof(rte_pmd_regions)); 10137 10138 op_type = RTE_PMD_I40E_RSS_QUEUE_REGION_INFO_GET; 10139 10140 ret = rte_pmd_i40e_rss_queue_region_conf(res->port_id, 10141 op_type, &rte_pmd_regions); 10142 10143 port_queue_region_info_display(res->port_id, &rte_pmd_regions); 10144 #endif 10145 10146 switch (ret) { 10147 case 0: 10148 break; 10149 case -ENOTSUP: 10150 printf("function not implemented or supported\n"); 10151 break; 10152 default: 10153 printf("queue region config info show error: (%s)\n", 10154 strerror(-ret)); 10155 } 10156 } 10157 10158 cmdline_parse_token_string_t cmd_show_queue_region_info_get = 10159 TOKEN_STRING_INITIALIZER(struct cmd_show_queue_region_info, 10160 show, "show"); 10161 cmdline_parse_token_string_t cmd_show_queue_region_info_port = 10162 TOKEN_STRING_INITIALIZER(struct cmd_show_queue_region_info, 10163 port, "port"); 10164 cmdline_parse_token_num_t cmd_show_queue_region_info_port_index = 10165 TOKEN_NUM_INITIALIZER(struct cmd_show_queue_region_info, 10166 port_id, UINT16); 10167 cmdline_parse_token_string_t cmd_show_queue_region_info_cmd = 10168 TOKEN_STRING_INITIALIZER(struct cmd_show_queue_region_info, 10169 cmd, "queue-region"); 10170 10171 cmdline_parse_inst_t cmd_show_queue_region_info_all = { 10172 .f = cmd_show_queue_region_info_parsed, 10173 .data = NULL, 10174 .help_str = "show port <port_id> queue-region" 10175 ": show all queue region related configuration info", 10176 .tokens = { 10177 (void *)&cmd_show_queue_region_info_get, 10178 (void *)&cmd_show_queue_region_info_port, 10179 (void *)&cmd_show_queue_region_info_port_index, 10180 (void *)&cmd_show_queue_region_info_cmd, 10181 NULL, 10182 }, 10183 }; 10184 10185 /* *** ADD/REMOVE A 2tuple FILTER *** */ 10186 struct cmd_2tuple_filter_result { 10187 cmdline_fixed_string_t filter; 10188 portid_t port_id; 10189 cmdline_fixed_string_t ops; 10190 cmdline_fixed_string_t dst_port; 10191 uint16_t dst_port_value; 10192 cmdline_fixed_string_t protocol; 10193 uint8_t protocol_value; 10194 cmdline_fixed_string_t mask; 10195 uint8_t mask_value; 10196 cmdline_fixed_string_t tcp_flags; 10197 uint8_t tcp_flags_value; 10198 cmdline_fixed_string_t priority; 10199 uint8_t priority_value; 10200 cmdline_fixed_string_t queue; 10201 uint16_t queue_id; 10202 }; 10203 10204 static void 10205 cmd_2tuple_filter_parsed(void *parsed_result, 10206 __attribute__((unused)) struct cmdline *cl, 10207 __attribute__((unused)) void *data) 10208 { 10209 struct rte_eth_ntuple_filter filter; 10210 struct cmd_2tuple_filter_result *res = parsed_result; 10211 int ret = 0; 10212 10213 ret = rte_eth_dev_filter_supported(res->port_id, RTE_ETH_FILTER_NTUPLE); 10214 if (ret < 0) { 10215 printf("ntuple filter is not supported on port %u.\n", 10216 res->port_id); 10217 return; 10218 } 10219 10220 memset(&filter, 0, sizeof(struct rte_eth_ntuple_filter)); 10221 10222 filter.flags = RTE_2TUPLE_FLAGS; 10223 filter.dst_port_mask = (res->mask_value & 0x02) ? UINT16_MAX : 0; 10224 filter.proto_mask = (res->mask_value & 0x01) ? UINT8_MAX : 0; 10225 filter.proto = res->protocol_value; 10226 filter.priority = res->priority_value; 10227 if (res->tcp_flags_value != 0 && filter.proto != IPPROTO_TCP) { 10228 printf("nonzero tcp_flags is only meaningful" 10229 " when protocol is TCP.\n"); 10230 return; 10231 } 10232 if (res->tcp_flags_value > RTE_NTUPLE_TCP_FLAGS_MASK) { 10233 printf("invalid TCP flags.\n"); 10234 return; 10235 } 10236 10237 if (res->tcp_flags_value != 0) { 10238 filter.flags |= RTE_NTUPLE_FLAGS_TCP_FLAG; 10239 filter.tcp_flags = res->tcp_flags_value; 10240 } 10241 10242 /* need convert to big endian. */ 10243 filter.dst_port = rte_cpu_to_be_16(res->dst_port_value); 10244 filter.queue = res->queue_id; 10245 10246 if (!strcmp(res->ops, "add")) 10247 ret = rte_eth_dev_filter_ctrl(res->port_id, 10248 RTE_ETH_FILTER_NTUPLE, 10249 RTE_ETH_FILTER_ADD, 10250 &filter); 10251 else 10252 ret = rte_eth_dev_filter_ctrl(res->port_id, 10253 RTE_ETH_FILTER_NTUPLE, 10254 RTE_ETH_FILTER_DELETE, 10255 &filter); 10256 if (ret < 0) 10257 printf("2tuple filter programming error: (%s)\n", 10258 strerror(-ret)); 10259 10260 } 10261 10262 cmdline_parse_token_string_t cmd_2tuple_filter_filter = 10263 TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result, 10264 filter, "2tuple_filter"); 10265 cmdline_parse_token_num_t cmd_2tuple_filter_port_id = 10266 TOKEN_NUM_INITIALIZER(struct cmd_2tuple_filter_result, 10267 port_id, UINT16); 10268 cmdline_parse_token_string_t cmd_2tuple_filter_ops = 10269 TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result, 10270 ops, "add#del"); 10271 cmdline_parse_token_string_t cmd_2tuple_filter_dst_port = 10272 TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result, 10273 dst_port, "dst_port"); 10274 cmdline_parse_token_num_t cmd_2tuple_filter_dst_port_value = 10275 TOKEN_NUM_INITIALIZER(struct cmd_2tuple_filter_result, 10276 dst_port_value, UINT16); 10277 cmdline_parse_token_string_t cmd_2tuple_filter_protocol = 10278 TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result, 10279 protocol, "protocol"); 10280 cmdline_parse_token_num_t cmd_2tuple_filter_protocol_value = 10281 TOKEN_NUM_INITIALIZER(struct cmd_2tuple_filter_result, 10282 protocol_value, UINT8); 10283 cmdline_parse_token_string_t cmd_2tuple_filter_mask = 10284 TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result, 10285 mask, "mask"); 10286 cmdline_parse_token_num_t cmd_2tuple_filter_mask_value = 10287 TOKEN_NUM_INITIALIZER(struct cmd_2tuple_filter_result, 10288 mask_value, INT8); 10289 cmdline_parse_token_string_t cmd_2tuple_filter_tcp_flags = 10290 TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result, 10291 tcp_flags, "tcp_flags"); 10292 cmdline_parse_token_num_t cmd_2tuple_filter_tcp_flags_value = 10293 TOKEN_NUM_INITIALIZER(struct cmd_2tuple_filter_result, 10294 tcp_flags_value, UINT8); 10295 cmdline_parse_token_string_t cmd_2tuple_filter_priority = 10296 TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result, 10297 priority, "priority"); 10298 cmdline_parse_token_num_t cmd_2tuple_filter_priority_value = 10299 TOKEN_NUM_INITIALIZER(struct cmd_2tuple_filter_result, 10300 priority_value, UINT8); 10301 cmdline_parse_token_string_t cmd_2tuple_filter_queue = 10302 TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result, 10303 queue, "queue"); 10304 cmdline_parse_token_num_t cmd_2tuple_filter_queue_id = 10305 TOKEN_NUM_INITIALIZER(struct cmd_2tuple_filter_result, 10306 queue_id, UINT16); 10307 10308 cmdline_parse_inst_t cmd_2tuple_filter = { 10309 .f = cmd_2tuple_filter_parsed, 10310 .data = NULL, 10311 .help_str = "2tuple_filter <port_id> add|del dst_port <value> protocol " 10312 "<value> mask <value> tcp_flags <value> priority <value> queue " 10313 "<queue_id>: Add a 2tuple filter", 10314 .tokens = { 10315 (void *)&cmd_2tuple_filter_filter, 10316 (void *)&cmd_2tuple_filter_port_id, 10317 (void *)&cmd_2tuple_filter_ops, 10318 (void *)&cmd_2tuple_filter_dst_port, 10319 (void *)&cmd_2tuple_filter_dst_port_value, 10320 (void *)&cmd_2tuple_filter_protocol, 10321 (void *)&cmd_2tuple_filter_protocol_value, 10322 (void *)&cmd_2tuple_filter_mask, 10323 (void *)&cmd_2tuple_filter_mask_value, 10324 (void *)&cmd_2tuple_filter_tcp_flags, 10325 (void *)&cmd_2tuple_filter_tcp_flags_value, 10326 (void *)&cmd_2tuple_filter_priority, 10327 (void *)&cmd_2tuple_filter_priority_value, 10328 (void *)&cmd_2tuple_filter_queue, 10329 (void *)&cmd_2tuple_filter_queue_id, 10330 NULL, 10331 }, 10332 }; 10333 10334 /* *** ADD/REMOVE A 5tuple FILTER *** */ 10335 struct cmd_5tuple_filter_result { 10336 cmdline_fixed_string_t filter; 10337 portid_t port_id; 10338 cmdline_fixed_string_t ops; 10339 cmdline_fixed_string_t dst_ip; 10340 cmdline_ipaddr_t dst_ip_value; 10341 cmdline_fixed_string_t src_ip; 10342 cmdline_ipaddr_t src_ip_value; 10343 cmdline_fixed_string_t dst_port; 10344 uint16_t dst_port_value; 10345 cmdline_fixed_string_t src_port; 10346 uint16_t src_port_value; 10347 cmdline_fixed_string_t protocol; 10348 uint8_t protocol_value; 10349 cmdline_fixed_string_t mask; 10350 uint8_t mask_value; 10351 cmdline_fixed_string_t tcp_flags; 10352 uint8_t tcp_flags_value; 10353 cmdline_fixed_string_t priority; 10354 uint8_t priority_value; 10355 cmdline_fixed_string_t queue; 10356 uint16_t queue_id; 10357 }; 10358 10359 static void 10360 cmd_5tuple_filter_parsed(void *parsed_result, 10361 __attribute__((unused)) struct cmdline *cl, 10362 __attribute__((unused)) void *data) 10363 { 10364 struct rte_eth_ntuple_filter filter; 10365 struct cmd_5tuple_filter_result *res = parsed_result; 10366 int ret = 0; 10367 10368 ret = rte_eth_dev_filter_supported(res->port_id, RTE_ETH_FILTER_NTUPLE); 10369 if (ret < 0) { 10370 printf("ntuple filter is not supported on port %u.\n", 10371 res->port_id); 10372 return; 10373 } 10374 10375 memset(&filter, 0, sizeof(struct rte_eth_ntuple_filter)); 10376 10377 filter.flags = RTE_5TUPLE_FLAGS; 10378 filter.dst_ip_mask = (res->mask_value & 0x10) ? UINT32_MAX : 0; 10379 filter.src_ip_mask = (res->mask_value & 0x08) ? UINT32_MAX : 0; 10380 filter.dst_port_mask = (res->mask_value & 0x04) ? UINT16_MAX : 0; 10381 filter.src_port_mask = (res->mask_value & 0x02) ? UINT16_MAX : 0; 10382 filter.proto_mask = (res->mask_value & 0x01) ? UINT8_MAX : 0; 10383 filter.proto = res->protocol_value; 10384 filter.priority = res->priority_value; 10385 if (res->tcp_flags_value != 0 && filter.proto != IPPROTO_TCP) { 10386 printf("nonzero tcp_flags is only meaningful" 10387 " when protocol is TCP.\n"); 10388 return; 10389 } 10390 if (res->tcp_flags_value > RTE_NTUPLE_TCP_FLAGS_MASK) { 10391 printf("invalid TCP flags.\n"); 10392 return; 10393 } 10394 10395 if (res->tcp_flags_value != 0) { 10396 filter.flags |= RTE_NTUPLE_FLAGS_TCP_FLAG; 10397 filter.tcp_flags = res->tcp_flags_value; 10398 } 10399 10400 if (res->dst_ip_value.family == AF_INET) 10401 /* no need to convert, already big endian. */ 10402 filter.dst_ip = res->dst_ip_value.addr.ipv4.s_addr; 10403 else { 10404 if (filter.dst_ip_mask == 0) { 10405 printf("can not support ipv6 involved compare.\n"); 10406 return; 10407 } 10408 filter.dst_ip = 0; 10409 } 10410 10411 if (res->src_ip_value.family == AF_INET) 10412 /* no need to convert, already big endian. */ 10413 filter.src_ip = res->src_ip_value.addr.ipv4.s_addr; 10414 else { 10415 if (filter.src_ip_mask == 0) { 10416 printf("can not support ipv6 involved compare.\n"); 10417 return; 10418 } 10419 filter.src_ip = 0; 10420 } 10421 /* need convert to big endian. */ 10422 filter.dst_port = rte_cpu_to_be_16(res->dst_port_value); 10423 filter.src_port = rte_cpu_to_be_16(res->src_port_value); 10424 filter.queue = res->queue_id; 10425 10426 if (!strcmp(res->ops, "add")) 10427 ret = rte_eth_dev_filter_ctrl(res->port_id, 10428 RTE_ETH_FILTER_NTUPLE, 10429 RTE_ETH_FILTER_ADD, 10430 &filter); 10431 else 10432 ret = rte_eth_dev_filter_ctrl(res->port_id, 10433 RTE_ETH_FILTER_NTUPLE, 10434 RTE_ETH_FILTER_DELETE, 10435 &filter); 10436 if (ret < 0) 10437 printf("5tuple filter programming error: (%s)\n", 10438 strerror(-ret)); 10439 } 10440 10441 cmdline_parse_token_string_t cmd_5tuple_filter_filter = 10442 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result, 10443 filter, "5tuple_filter"); 10444 cmdline_parse_token_num_t cmd_5tuple_filter_port_id = 10445 TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result, 10446 port_id, UINT16); 10447 cmdline_parse_token_string_t cmd_5tuple_filter_ops = 10448 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result, 10449 ops, "add#del"); 10450 cmdline_parse_token_string_t cmd_5tuple_filter_dst_ip = 10451 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result, 10452 dst_ip, "dst_ip"); 10453 cmdline_parse_token_ipaddr_t cmd_5tuple_filter_dst_ip_value = 10454 TOKEN_IPADDR_INITIALIZER(struct cmd_5tuple_filter_result, 10455 dst_ip_value); 10456 cmdline_parse_token_string_t cmd_5tuple_filter_src_ip = 10457 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result, 10458 src_ip, "src_ip"); 10459 cmdline_parse_token_ipaddr_t cmd_5tuple_filter_src_ip_value = 10460 TOKEN_IPADDR_INITIALIZER(struct cmd_5tuple_filter_result, 10461 src_ip_value); 10462 cmdline_parse_token_string_t cmd_5tuple_filter_dst_port = 10463 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result, 10464 dst_port, "dst_port"); 10465 cmdline_parse_token_num_t cmd_5tuple_filter_dst_port_value = 10466 TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result, 10467 dst_port_value, UINT16); 10468 cmdline_parse_token_string_t cmd_5tuple_filter_src_port = 10469 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result, 10470 src_port, "src_port"); 10471 cmdline_parse_token_num_t cmd_5tuple_filter_src_port_value = 10472 TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result, 10473 src_port_value, UINT16); 10474 cmdline_parse_token_string_t cmd_5tuple_filter_protocol = 10475 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result, 10476 protocol, "protocol"); 10477 cmdline_parse_token_num_t cmd_5tuple_filter_protocol_value = 10478 TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result, 10479 protocol_value, UINT8); 10480 cmdline_parse_token_string_t cmd_5tuple_filter_mask = 10481 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result, 10482 mask, "mask"); 10483 cmdline_parse_token_num_t cmd_5tuple_filter_mask_value = 10484 TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result, 10485 mask_value, INT8); 10486 cmdline_parse_token_string_t cmd_5tuple_filter_tcp_flags = 10487 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result, 10488 tcp_flags, "tcp_flags"); 10489 cmdline_parse_token_num_t cmd_5tuple_filter_tcp_flags_value = 10490 TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result, 10491 tcp_flags_value, UINT8); 10492 cmdline_parse_token_string_t cmd_5tuple_filter_priority = 10493 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result, 10494 priority, "priority"); 10495 cmdline_parse_token_num_t cmd_5tuple_filter_priority_value = 10496 TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result, 10497 priority_value, UINT8); 10498 cmdline_parse_token_string_t cmd_5tuple_filter_queue = 10499 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result, 10500 queue, "queue"); 10501 cmdline_parse_token_num_t cmd_5tuple_filter_queue_id = 10502 TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result, 10503 queue_id, UINT16); 10504 10505 cmdline_parse_inst_t cmd_5tuple_filter = { 10506 .f = cmd_5tuple_filter_parsed, 10507 .data = NULL, 10508 .help_str = "5tuple_filter <port_id> add|del dst_ip <value> " 10509 "src_ip <value> dst_port <value> src_port <value> " 10510 "protocol <value> mask <value> tcp_flags <value> " 10511 "priority <value> queue <queue_id>: Add/Del a 5tuple filter", 10512 .tokens = { 10513 (void *)&cmd_5tuple_filter_filter, 10514 (void *)&cmd_5tuple_filter_port_id, 10515 (void *)&cmd_5tuple_filter_ops, 10516 (void *)&cmd_5tuple_filter_dst_ip, 10517 (void *)&cmd_5tuple_filter_dst_ip_value, 10518 (void *)&cmd_5tuple_filter_src_ip, 10519 (void *)&cmd_5tuple_filter_src_ip_value, 10520 (void *)&cmd_5tuple_filter_dst_port, 10521 (void *)&cmd_5tuple_filter_dst_port_value, 10522 (void *)&cmd_5tuple_filter_src_port, 10523 (void *)&cmd_5tuple_filter_src_port_value, 10524 (void *)&cmd_5tuple_filter_protocol, 10525 (void *)&cmd_5tuple_filter_protocol_value, 10526 (void *)&cmd_5tuple_filter_mask, 10527 (void *)&cmd_5tuple_filter_mask_value, 10528 (void *)&cmd_5tuple_filter_tcp_flags, 10529 (void *)&cmd_5tuple_filter_tcp_flags_value, 10530 (void *)&cmd_5tuple_filter_priority, 10531 (void *)&cmd_5tuple_filter_priority_value, 10532 (void *)&cmd_5tuple_filter_queue, 10533 (void *)&cmd_5tuple_filter_queue_id, 10534 NULL, 10535 }, 10536 }; 10537 10538 /* *** ADD/REMOVE A flex FILTER *** */ 10539 struct cmd_flex_filter_result { 10540 cmdline_fixed_string_t filter; 10541 cmdline_fixed_string_t ops; 10542 portid_t port_id; 10543 cmdline_fixed_string_t len; 10544 uint8_t len_value; 10545 cmdline_fixed_string_t bytes; 10546 cmdline_fixed_string_t bytes_value; 10547 cmdline_fixed_string_t mask; 10548 cmdline_fixed_string_t mask_value; 10549 cmdline_fixed_string_t priority; 10550 uint8_t priority_value; 10551 cmdline_fixed_string_t queue; 10552 uint16_t queue_id; 10553 }; 10554 10555 static int xdigit2val(unsigned char c) 10556 { 10557 int val; 10558 if (isdigit(c)) 10559 val = c - '0'; 10560 else if (isupper(c)) 10561 val = c - 'A' + 10; 10562 else 10563 val = c - 'a' + 10; 10564 return val; 10565 } 10566 10567 static void 10568 cmd_flex_filter_parsed(void *parsed_result, 10569 __attribute__((unused)) struct cmdline *cl, 10570 __attribute__((unused)) void *data) 10571 { 10572 int ret = 0; 10573 struct rte_eth_flex_filter filter; 10574 struct cmd_flex_filter_result *res = parsed_result; 10575 char *bytes_ptr, *mask_ptr; 10576 uint16_t len, i, j = 0; 10577 char c; 10578 int val; 10579 uint8_t byte = 0; 10580 10581 if (res->len_value > RTE_FLEX_FILTER_MAXLEN) { 10582 printf("the len exceed the max length 128\n"); 10583 return; 10584 } 10585 memset(&filter, 0, sizeof(struct rte_eth_flex_filter)); 10586 filter.len = res->len_value; 10587 filter.priority = res->priority_value; 10588 filter.queue = res->queue_id; 10589 bytes_ptr = res->bytes_value; 10590 mask_ptr = res->mask_value; 10591 10592 /* translate bytes string to array. */ 10593 if (bytes_ptr[0] == '0' && ((bytes_ptr[1] == 'x') || 10594 (bytes_ptr[1] == 'X'))) 10595 bytes_ptr += 2; 10596 len = strnlen(bytes_ptr, res->len_value * 2); 10597 if (len == 0 || (len % 8 != 0)) { 10598 printf("please check len and bytes input\n"); 10599 return; 10600 } 10601 for (i = 0; i < len; i++) { 10602 c = bytes_ptr[i]; 10603 if (isxdigit(c) == 0) { 10604 /* invalid characters. */ 10605 printf("invalid input\n"); 10606 return; 10607 } 10608 val = xdigit2val(c); 10609 if (i % 2) { 10610 byte |= val; 10611 filter.bytes[j] = byte; 10612 printf("bytes[%d]:%02x ", j, filter.bytes[j]); 10613 j++; 10614 byte = 0; 10615 } else 10616 byte |= val << 4; 10617 } 10618 printf("\n"); 10619 /* translate mask string to uint8_t array. */ 10620 if (mask_ptr[0] == '0' && ((mask_ptr[1] == 'x') || 10621 (mask_ptr[1] == 'X'))) 10622 mask_ptr += 2; 10623 len = strnlen(mask_ptr, (res->len_value + 3) / 4); 10624 if (len == 0) { 10625 printf("invalid input\n"); 10626 return; 10627 } 10628 j = 0; 10629 byte = 0; 10630 for (i = 0; i < len; i++) { 10631 c = mask_ptr[i]; 10632 if (isxdigit(c) == 0) { 10633 /* invalid characters. */ 10634 printf("invalid input\n"); 10635 return; 10636 } 10637 val = xdigit2val(c); 10638 if (i % 2) { 10639 byte |= val; 10640 filter.mask[j] = byte; 10641 printf("mask[%d]:%02x ", j, filter.mask[j]); 10642 j++; 10643 byte = 0; 10644 } else 10645 byte |= val << 4; 10646 } 10647 printf("\n"); 10648 10649 if (!strcmp(res->ops, "add")) 10650 ret = rte_eth_dev_filter_ctrl(res->port_id, 10651 RTE_ETH_FILTER_FLEXIBLE, 10652 RTE_ETH_FILTER_ADD, 10653 &filter); 10654 else 10655 ret = rte_eth_dev_filter_ctrl(res->port_id, 10656 RTE_ETH_FILTER_FLEXIBLE, 10657 RTE_ETH_FILTER_DELETE, 10658 &filter); 10659 10660 if (ret < 0) 10661 printf("flex filter setting error: (%s)\n", strerror(-ret)); 10662 } 10663 10664 cmdline_parse_token_string_t cmd_flex_filter_filter = 10665 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result, 10666 filter, "flex_filter"); 10667 cmdline_parse_token_num_t cmd_flex_filter_port_id = 10668 TOKEN_NUM_INITIALIZER(struct cmd_flex_filter_result, 10669 port_id, UINT16); 10670 cmdline_parse_token_string_t cmd_flex_filter_ops = 10671 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result, 10672 ops, "add#del"); 10673 cmdline_parse_token_string_t cmd_flex_filter_len = 10674 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result, 10675 len, "len"); 10676 cmdline_parse_token_num_t cmd_flex_filter_len_value = 10677 TOKEN_NUM_INITIALIZER(struct cmd_flex_filter_result, 10678 len_value, UINT8); 10679 cmdline_parse_token_string_t cmd_flex_filter_bytes = 10680 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result, 10681 bytes, "bytes"); 10682 cmdline_parse_token_string_t cmd_flex_filter_bytes_value = 10683 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result, 10684 bytes_value, NULL); 10685 cmdline_parse_token_string_t cmd_flex_filter_mask = 10686 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result, 10687 mask, "mask"); 10688 cmdline_parse_token_string_t cmd_flex_filter_mask_value = 10689 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result, 10690 mask_value, NULL); 10691 cmdline_parse_token_string_t cmd_flex_filter_priority = 10692 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result, 10693 priority, "priority"); 10694 cmdline_parse_token_num_t cmd_flex_filter_priority_value = 10695 TOKEN_NUM_INITIALIZER(struct cmd_flex_filter_result, 10696 priority_value, UINT8); 10697 cmdline_parse_token_string_t cmd_flex_filter_queue = 10698 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result, 10699 queue, "queue"); 10700 cmdline_parse_token_num_t cmd_flex_filter_queue_id = 10701 TOKEN_NUM_INITIALIZER(struct cmd_flex_filter_result, 10702 queue_id, UINT16); 10703 cmdline_parse_inst_t cmd_flex_filter = { 10704 .f = cmd_flex_filter_parsed, 10705 .data = NULL, 10706 .help_str = "flex_filter <port_id> add|del len <value> bytes " 10707 "<value> mask <value> priority <value> queue <queue_id>: " 10708 "Add/Del a flex filter", 10709 .tokens = { 10710 (void *)&cmd_flex_filter_filter, 10711 (void *)&cmd_flex_filter_port_id, 10712 (void *)&cmd_flex_filter_ops, 10713 (void *)&cmd_flex_filter_len, 10714 (void *)&cmd_flex_filter_len_value, 10715 (void *)&cmd_flex_filter_bytes, 10716 (void *)&cmd_flex_filter_bytes_value, 10717 (void *)&cmd_flex_filter_mask, 10718 (void *)&cmd_flex_filter_mask_value, 10719 (void *)&cmd_flex_filter_priority, 10720 (void *)&cmd_flex_filter_priority_value, 10721 (void *)&cmd_flex_filter_queue, 10722 (void *)&cmd_flex_filter_queue_id, 10723 NULL, 10724 }, 10725 }; 10726 10727 /* *** Filters Control *** */ 10728 10729 /* *** deal with ethertype filter *** */ 10730 struct cmd_ethertype_filter_result { 10731 cmdline_fixed_string_t filter; 10732 portid_t port_id; 10733 cmdline_fixed_string_t ops; 10734 cmdline_fixed_string_t mac; 10735 struct rte_ether_addr mac_addr; 10736 cmdline_fixed_string_t ethertype; 10737 uint16_t ethertype_value; 10738 cmdline_fixed_string_t drop; 10739 cmdline_fixed_string_t queue; 10740 uint16_t queue_id; 10741 }; 10742 10743 cmdline_parse_token_string_t cmd_ethertype_filter_filter = 10744 TOKEN_STRING_INITIALIZER(struct cmd_ethertype_filter_result, 10745 filter, "ethertype_filter"); 10746 cmdline_parse_token_num_t cmd_ethertype_filter_port_id = 10747 TOKEN_NUM_INITIALIZER(struct cmd_ethertype_filter_result, 10748 port_id, UINT16); 10749 cmdline_parse_token_string_t cmd_ethertype_filter_ops = 10750 TOKEN_STRING_INITIALIZER(struct cmd_ethertype_filter_result, 10751 ops, "add#del"); 10752 cmdline_parse_token_string_t cmd_ethertype_filter_mac = 10753 TOKEN_STRING_INITIALIZER(struct cmd_ethertype_filter_result, 10754 mac, "mac_addr#mac_ignr"); 10755 cmdline_parse_token_etheraddr_t cmd_ethertype_filter_mac_addr = 10756 TOKEN_ETHERADDR_INITIALIZER(struct cmd_ethertype_filter_result, 10757 mac_addr); 10758 cmdline_parse_token_string_t cmd_ethertype_filter_ethertype = 10759 TOKEN_STRING_INITIALIZER(struct cmd_ethertype_filter_result, 10760 ethertype, "ethertype"); 10761 cmdline_parse_token_num_t cmd_ethertype_filter_ethertype_value = 10762 TOKEN_NUM_INITIALIZER(struct cmd_ethertype_filter_result, 10763 ethertype_value, UINT16); 10764 cmdline_parse_token_string_t cmd_ethertype_filter_drop = 10765 TOKEN_STRING_INITIALIZER(struct cmd_ethertype_filter_result, 10766 drop, "drop#fwd"); 10767 cmdline_parse_token_string_t cmd_ethertype_filter_queue = 10768 TOKEN_STRING_INITIALIZER(struct cmd_ethertype_filter_result, 10769 queue, "queue"); 10770 cmdline_parse_token_num_t cmd_ethertype_filter_queue_id = 10771 TOKEN_NUM_INITIALIZER(struct cmd_ethertype_filter_result, 10772 queue_id, UINT16); 10773 10774 static void 10775 cmd_ethertype_filter_parsed(void *parsed_result, 10776 __attribute__((unused)) struct cmdline *cl, 10777 __attribute__((unused)) void *data) 10778 { 10779 struct cmd_ethertype_filter_result *res = parsed_result; 10780 struct rte_eth_ethertype_filter filter; 10781 int ret = 0; 10782 10783 ret = rte_eth_dev_filter_supported(res->port_id, 10784 RTE_ETH_FILTER_ETHERTYPE); 10785 if (ret < 0) { 10786 printf("ethertype filter is not supported on port %u.\n", 10787 res->port_id); 10788 return; 10789 } 10790 10791 memset(&filter, 0, sizeof(filter)); 10792 if (!strcmp(res->mac, "mac_addr")) { 10793 filter.flags |= RTE_ETHTYPE_FLAGS_MAC; 10794 rte_memcpy(&filter.mac_addr, &res->mac_addr, 10795 sizeof(struct rte_ether_addr)); 10796 } 10797 if (!strcmp(res->drop, "drop")) 10798 filter.flags |= RTE_ETHTYPE_FLAGS_DROP; 10799 filter.ether_type = res->ethertype_value; 10800 filter.queue = res->queue_id; 10801 10802 if (!strcmp(res->ops, "add")) 10803 ret = rte_eth_dev_filter_ctrl(res->port_id, 10804 RTE_ETH_FILTER_ETHERTYPE, 10805 RTE_ETH_FILTER_ADD, 10806 &filter); 10807 else 10808 ret = rte_eth_dev_filter_ctrl(res->port_id, 10809 RTE_ETH_FILTER_ETHERTYPE, 10810 RTE_ETH_FILTER_DELETE, 10811 &filter); 10812 if (ret < 0) 10813 printf("ethertype filter programming error: (%s)\n", 10814 strerror(-ret)); 10815 } 10816 10817 cmdline_parse_inst_t cmd_ethertype_filter = { 10818 .f = cmd_ethertype_filter_parsed, 10819 .data = NULL, 10820 .help_str = "ethertype_filter <port_id> add|del mac_addr|mac_ignr " 10821 "<mac_addr> ethertype <value> drop|fw queue <queue_id>: " 10822 "Add or delete an ethertype filter entry", 10823 .tokens = { 10824 (void *)&cmd_ethertype_filter_filter, 10825 (void *)&cmd_ethertype_filter_port_id, 10826 (void *)&cmd_ethertype_filter_ops, 10827 (void *)&cmd_ethertype_filter_mac, 10828 (void *)&cmd_ethertype_filter_mac_addr, 10829 (void *)&cmd_ethertype_filter_ethertype, 10830 (void *)&cmd_ethertype_filter_ethertype_value, 10831 (void *)&cmd_ethertype_filter_drop, 10832 (void *)&cmd_ethertype_filter_queue, 10833 (void *)&cmd_ethertype_filter_queue_id, 10834 NULL, 10835 }, 10836 }; 10837 10838 /* *** deal with flow director filter *** */ 10839 struct cmd_flow_director_result { 10840 cmdline_fixed_string_t flow_director_filter; 10841 portid_t port_id; 10842 cmdline_fixed_string_t mode; 10843 cmdline_fixed_string_t mode_value; 10844 cmdline_fixed_string_t ops; 10845 cmdline_fixed_string_t flow; 10846 cmdline_fixed_string_t flow_type; 10847 cmdline_fixed_string_t ether; 10848 uint16_t ether_type; 10849 cmdline_fixed_string_t src; 10850 cmdline_ipaddr_t ip_src; 10851 uint16_t port_src; 10852 cmdline_fixed_string_t dst; 10853 cmdline_ipaddr_t ip_dst; 10854 uint16_t port_dst; 10855 cmdline_fixed_string_t verify_tag; 10856 uint32_t verify_tag_value; 10857 cmdline_fixed_string_t tos; 10858 uint8_t tos_value; 10859 cmdline_fixed_string_t proto; 10860 uint8_t proto_value; 10861 cmdline_fixed_string_t ttl; 10862 uint8_t ttl_value; 10863 cmdline_fixed_string_t vlan; 10864 uint16_t vlan_value; 10865 cmdline_fixed_string_t flexbytes; 10866 cmdline_fixed_string_t flexbytes_value; 10867 cmdline_fixed_string_t pf_vf; 10868 cmdline_fixed_string_t drop; 10869 cmdline_fixed_string_t queue; 10870 uint16_t queue_id; 10871 cmdline_fixed_string_t fd_id; 10872 uint32_t fd_id_value; 10873 cmdline_fixed_string_t mac; 10874 struct rte_ether_addr mac_addr; 10875 cmdline_fixed_string_t tunnel; 10876 cmdline_fixed_string_t tunnel_type; 10877 cmdline_fixed_string_t tunnel_id; 10878 uint32_t tunnel_id_value; 10879 cmdline_fixed_string_t packet; 10880 char filepath[]; 10881 }; 10882 10883 static inline int 10884 parse_flexbytes(const char *q_arg, uint8_t *flexbytes, uint16_t max_num) 10885 { 10886 char s[256]; 10887 const char *p, *p0 = q_arg; 10888 char *end; 10889 unsigned long int_fld; 10890 char *str_fld[max_num]; 10891 int i; 10892 unsigned size; 10893 int ret = -1; 10894 10895 p = strchr(p0, '('); 10896 if (p == NULL) 10897 return -1; 10898 ++p; 10899 p0 = strchr(p, ')'); 10900 if (p0 == NULL) 10901 return -1; 10902 10903 size = p0 - p; 10904 if (size >= sizeof(s)) 10905 return -1; 10906 10907 snprintf(s, sizeof(s), "%.*s", size, p); 10908 ret = rte_strsplit(s, sizeof(s), str_fld, max_num, ','); 10909 if (ret < 0 || ret > max_num) 10910 return -1; 10911 for (i = 0; i < ret; i++) { 10912 errno = 0; 10913 int_fld = strtoul(str_fld[i], &end, 0); 10914 if (errno != 0 || *end != '\0' || int_fld > UINT8_MAX) 10915 return -1; 10916 flexbytes[i] = (uint8_t)int_fld; 10917 } 10918 return ret; 10919 } 10920 10921 static uint16_t 10922 str2flowtype(char *string) 10923 { 10924 uint8_t i = 0; 10925 static const struct { 10926 char str[32]; 10927 uint16_t type; 10928 } flowtype_str[] = { 10929 {"raw", RTE_ETH_FLOW_RAW}, 10930 {"ipv4", RTE_ETH_FLOW_IPV4}, 10931 {"ipv4-frag", RTE_ETH_FLOW_FRAG_IPV4}, 10932 {"ipv4-tcp", RTE_ETH_FLOW_NONFRAG_IPV4_TCP}, 10933 {"ipv4-udp", RTE_ETH_FLOW_NONFRAG_IPV4_UDP}, 10934 {"ipv4-sctp", RTE_ETH_FLOW_NONFRAG_IPV4_SCTP}, 10935 {"ipv4-other", RTE_ETH_FLOW_NONFRAG_IPV4_OTHER}, 10936 {"ipv6", RTE_ETH_FLOW_IPV6}, 10937 {"ipv6-frag", RTE_ETH_FLOW_FRAG_IPV6}, 10938 {"ipv6-tcp", RTE_ETH_FLOW_NONFRAG_IPV6_TCP}, 10939 {"ipv6-udp", RTE_ETH_FLOW_NONFRAG_IPV6_UDP}, 10940 {"ipv6-sctp", RTE_ETH_FLOW_NONFRAG_IPV6_SCTP}, 10941 {"ipv6-other", RTE_ETH_FLOW_NONFRAG_IPV6_OTHER}, 10942 {"l2_payload", RTE_ETH_FLOW_L2_PAYLOAD}, 10943 }; 10944 10945 for (i = 0; i < RTE_DIM(flowtype_str); i++) { 10946 if (!strcmp(flowtype_str[i].str, string)) 10947 return flowtype_str[i].type; 10948 } 10949 10950 if (isdigit(string[0]) && atoi(string) > 0 && atoi(string) < 64) 10951 return (uint16_t)atoi(string); 10952 10953 return RTE_ETH_FLOW_UNKNOWN; 10954 } 10955 10956 static enum rte_eth_fdir_tunnel_type 10957 str2fdir_tunneltype(char *string) 10958 { 10959 uint8_t i = 0; 10960 10961 static const struct { 10962 char str[32]; 10963 enum rte_eth_fdir_tunnel_type type; 10964 } tunneltype_str[] = { 10965 {"NVGRE", RTE_FDIR_TUNNEL_TYPE_NVGRE}, 10966 {"VxLAN", RTE_FDIR_TUNNEL_TYPE_VXLAN}, 10967 }; 10968 10969 for (i = 0; i < RTE_DIM(tunneltype_str); i++) { 10970 if (!strcmp(tunneltype_str[i].str, string)) 10971 return tunneltype_str[i].type; 10972 } 10973 return RTE_FDIR_TUNNEL_TYPE_UNKNOWN; 10974 } 10975 10976 #define IPV4_ADDR_TO_UINT(ip_addr, ip) \ 10977 do { \ 10978 if ((ip_addr).family == AF_INET) \ 10979 (ip) = (ip_addr).addr.ipv4.s_addr; \ 10980 else { \ 10981 printf("invalid parameter.\n"); \ 10982 return; \ 10983 } \ 10984 } while (0) 10985 10986 #define IPV6_ADDR_TO_ARRAY(ip_addr, ip) \ 10987 do { \ 10988 if ((ip_addr).family == AF_INET6) \ 10989 rte_memcpy(&(ip), \ 10990 &((ip_addr).addr.ipv6), \ 10991 sizeof(struct in6_addr)); \ 10992 else { \ 10993 printf("invalid parameter.\n"); \ 10994 return; \ 10995 } \ 10996 } while (0) 10997 10998 static void 10999 cmd_flow_director_filter_parsed(void *parsed_result, 11000 __attribute__((unused)) struct cmdline *cl, 11001 __attribute__((unused)) void *data) 11002 { 11003 struct cmd_flow_director_result *res = parsed_result; 11004 struct rte_eth_fdir_filter entry; 11005 uint8_t flexbytes[RTE_ETH_FDIR_MAX_FLEXLEN]; 11006 char *end; 11007 unsigned long vf_id; 11008 int ret = 0; 11009 11010 ret = rte_eth_dev_filter_supported(res->port_id, RTE_ETH_FILTER_FDIR); 11011 if (ret < 0) { 11012 printf("flow director is not supported on port %u.\n", 11013 res->port_id); 11014 return; 11015 } 11016 memset(flexbytes, 0, sizeof(flexbytes)); 11017 memset(&entry, 0, sizeof(struct rte_eth_fdir_filter)); 11018 11019 if (fdir_conf.mode == RTE_FDIR_MODE_PERFECT_MAC_VLAN) { 11020 if (strcmp(res->mode_value, "MAC-VLAN")) { 11021 printf("Please set mode to MAC-VLAN.\n"); 11022 return; 11023 } 11024 } else if (fdir_conf.mode == RTE_FDIR_MODE_PERFECT_TUNNEL) { 11025 if (strcmp(res->mode_value, "Tunnel")) { 11026 printf("Please set mode to Tunnel.\n"); 11027 return; 11028 } 11029 } else { 11030 if (!strcmp(res->mode_value, "raw")) { 11031 #ifdef RTE_LIBRTE_I40E_PMD 11032 struct rte_pmd_i40e_flow_type_mapping 11033 mapping[RTE_PMD_I40E_FLOW_TYPE_MAX]; 11034 struct rte_pmd_i40e_pkt_template_conf conf; 11035 uint16_t flow_type = str2flowtype(res->flow_type); 11036 uint16_t i, port = res->port_id; 11037 uint8_t add; 11038 11039 memset(&conf, 0, sizeof(conf)); 11040 11041 if (flow_type == RTE_ETH_FLOW_UNKNOWN) { 11042 printf("Invalid flow type specified.\n"); 11043 return; 11044 } 11045 ret = rte_pmd_i40e_flow_type_mapping_get(res->port_id, 11046 mapping); 11047 if (ret) 11048 return; 11049 if (mapping[flow_type].pctype == 0ULL) { 11050 printf("Invalid flow type specified.\n"); 11051 return; 11052 } 11053 for (i = 0; i < RTE_PMD_I40E_PCTYPE_MAX; i++) { 11054 if (mapping[flow_type].pctype & (1ULL << i)) { 11055 conf.input.pctype = i; 11056 break; 11057 } 11058 } 11059 11060 conf.input.packet = open_file(res->filepath, 11061 &conf.input.length); 11062 if (!conf.input.packet) 11063 return; 11064 if (!strcmp(res->drop, "drop")) 11065 conf.action.behavior = 11066 RTE_PMD_I40E_PKT_TEMPLATE_REJECT; 11067 else 11068 conf.action.behavior = 11069 RTE_PMD_I40E_PKT_TEMPLATE_ACCEPT; 11070 conf.action.report_status = 11071 RTE_PMD_I40E_PKT_TEMPLATE_REPORT_ID; 11072 conf.action.rx_queue = res->queue_id; 11073 conf.soft_id = res->fd_id_value; 11074 add = strcmp(res->ops, "del") ? 1 : 0; 11075 ret = rte_pmd_i40e_flow_add_del_packet_template(port, 11076 &conf, 11077 add); 11078 if (ret < 0) 11079 printf("flow director config error: (%s)\n", 11080 strerror(-ret)); 11081 close_file(conf.input.packet); 11082 #endif 11083 return; 11084 } else if (strcmp(res->mode_value, "IP")) { 11085 printf("Please set mode to IP or raw.\n"); 11086 return; 11087 } 11088 entry.input.flow_type = str2flowtype(res->flow_type); 11089 } 11090 11091 ret = parse_flexbytes(res->flexbytes_value, 11092 flexbytes, 11093 RTE_ETH_FDIR_MAX_FLEXLEN); 11094 if (ret < 0) { 11095 printf("error: Cannot parse flexbytes input.\n"); 11096 return; 11097 } 11098 11099 switch (entry.input.flow_type) { 11100 case RTE_ETH_FLOW_FRAG_IPV4: 11101 case RTE_ETH_FLOW_NONFRAG_IPV4_OTHER: 11102 entry.input.flow.ip4_flow.proto = res->proto_value; 11103 /* fall-through */ 11104 case RTE_ETH_FLOW_NONFRAG_IPV4_UDP: 11105 case RTE_ETH_FLOW_NONFRAG_IPV4_TCP: 11106 IPV4_ADDR_TO_UINT(res->ip_dst, 11107 entry.input.flow.ip4_flow.dst_ip); 11108 IPV4_ADDR_TO_UINT(res->ip_src, 11109 entry.input.flow.ip4_flow.src_ip); 11110 entry.input.flow.ip4_flow.tos = res->tos_value; 11111 entry.input.flow.ip4_flow.ttl = res->ttl_value; 11112 /* need convert to big endian. */ 11113 entry.input.flow.udp4_flow.dst_port = 11114 rte_cpu_to_be_16(res->port_dst); 11115 entry.input.flow.udp4_flow.src_port = 11116 rte_cpu_to_be_16(res->port_src); 11117 break; 11118 case RTE_ETH_FLOW_NONFRAG_IPV4_SCTP: 11119 IPV4_ADDR_TO_UINT(res->ip_dst, 11120 entry.input.flow.sctp4_flow.ip.dst_ip); 11121 IPV4_ADDR_TO_UINT(res->ip_src, 11122 entry.input.flow.sctp4_flow.ip.src_ip); 11123 entry.input.flow.ip4_flow.tos = res->tos_value; 11124 entry.input.flow.ip4_flow.ttl = res->ttl_value; 11125 /* need convert to big endian. */ 11126 entry.input.flow.sctp4_flow.dst_port = 11127 rte_cpu_to_be_16(res->port_dst); 11128 entry.input.flow.sctp4_flow.src_port = 11129 rte_cpu_to_be_16(res->port_src); 11130 entry.input.flow.sctp4_flow.verify_tag = 11131 rte_cpu_to_be_32(res->verify_tag_value); 11132 break; 11133 case RTE_ETH_FLOW_FRAG_IPV6: 11134 case RTE_ETH_FLOW_NONFRAG_IPV6_OTHER: 11135 entry.input.flow.ipv6_flow.proto = res->proto_value; 11136 /* fall-through */ 11137 case RTE_ETH_FLOW_NONFRAG_IPV6_UDP: 11138 case RTE_ETH_FLOW_NONFRAG_IPV6_TCP: 11139 IPV6_ADDR_TO_ARRAY(res->ip_dst, 11140 entry.input.flow.ipv6_flow.dst_ip); 11141 IPV6_ADDR_TO_ARRAY(res->ip_src, 11142 entry.input.flow.ipv6_flow.src_ip); 11143 entry.input.flow.ipv6_flow.tc = res->tos_value; 11144 entry.input.flow.ipv6_flow.hop_limits = res->ttl_value; 11145 /* need convert to big endian. */ 11146 entry.input.flow.udp6_flow.dst_port = 11147 rte_cpu_to_be_16(res->port_dst); 11148 entry.input.flow.udp6_flow.src_port = 11149 rte_cpu_to_be_16(res->port_src); 11150 break; 11151 case RTE_ETH_FLOW_NONFRAG_IPV6_SCTP: 11152 IPV6_ADDR_TO_ARRAY(res->ip_dst, 11153 entry.input.flow.sctp6_flow.ip.dst_ip); 11154 IPV6_ADDR_TO_ARRAY(res->ip_src, 11155 entry.input.flow.sctp6_flow.ip.src_ip); 11156 entry.input.flow.ipv6_flow.tc = res->tos_value; 11157 entry.input.flow.ipv6_flow.hop_limits = res->ttl_value; 11158 /* need convert to big endian. */ 11159 entry.input.flow.sctp6_flow.dst_port = 11160 rte_cpu_to_be_16(res->port_dst); 11161 entry.input.flow.sctp6_flow.src_port = 11162 rte_cpu_to_be_16(res->port_src); 11163 entry.input.flow.sctp6_flow.verify_tag = 11164 rte_cpu_to_be_32(res->verify_tag_value); 11165 break; 11166 case RTE_ETH_FLOW_L2_PAYLOAD: 11167 entry.input.flow.l2_flow.ether_type = 11168 rte_cpu_to_be_16(res->ether_type); 11169 break; 11170 default: 11171 break; 11172 } 11173 11174 if (fdir_conf.mode == RTE_FDIR_MODE_PERFECT_MAC_VLAN) 11175 rte_memcpy(&entry.input.flow.mac_vlan_flow.mac_addr, 11176 &res->mac_addr, 11177 sizeof(struct rte_ether_addr)); 11178 11179 if (fdir_conf.mode == RTE_FDIR_MODE_PERFECT_TUNNEL) { 11180 rte_memcpy(&entry.input.flow.tunnel_flow.mac_addr, 11181 &res->mac_addr, 11182 sizeof(struct rte_ether_addr)); 11183 entry.input.flow.tunnel_flow.tunnel_type = 11184 str2fdir_tunneltype(res->tunnel_type); 11185 entry.input.flow.tunnel_flow.tunnel_id = 11186 rte_cpu_to_be_32(res->tunnel_id_value); 11187 } 11188 11189 rte_memcpy(entry.input.flow_ext.flexbytes, 11190 flexbytes, 11191 RTE_ETH_FDIR_MAX_FLEXLEN); 11192 11193 entry.input.flow_ext.vlan_tci = rte_cpu_to_be_16(res->vlan_value); 11194 11195 entry.action.flex_off = 0; /*use 0 by default */ 11196 if (!strcmp(res->drop, "drop")) 11197 entry.action.behavior = RTE_ETH_FDIR_REJECT; 11198 else 11199 entry.action.behavior = RTE_ETH_FDIR_ACCEPT; 11200 11201 if (fdir_conf.mode != RTE_FDIR_MODE_PERFECT_MAC_VLAN && 11202 fdir_conf.mode != RTE_FDIR_MODE_PERFECT_TUNNEL) { 11203 if (!strcmp(res->pf_vf, "pf")) 11204 entry.input.flow_ext.is_vf = 0; 11205 else if (!strncmp(res->pf_vf, "vf", 2)) { 11206 struct rte_eth_dev_info dev_info; 11207 11208 ret = eth_dev_info_get_print_err(res->port_id, 11209 &dev_info); 11210 if (ret != 0) 11211 return; 11212 11213 errno = 0; 11214 vf_id = strtoul(res->pf_vf + 2, &end, 10); 11215 if (errno != 0 || *end != '\0' || 11216 vf_id >= dev_info.max_vfs) { 11217 printf("invalid parameter %s.\n", res->pf_vf); 11218 return; 11219 } 11220 entry.input.flow_ext.is_vf = 1; 11221 entry.input.flow_ext.dst_id = (uint16_t)vf_id; 11222 } else { 11223 printf("invalid parameter %s.\n", res->pf_vf); 11224 return; 11225 } 11226 } 11227 11228 /* set to report FD ID by default */ 11229 entry.action.report_status = RTE_ETH_FDIR_REPORT_ID; 11230 entry.action.rx_queue = res->queue_id; 11231 entry.soft_id = res->fd_id_value; 11232 if (!strcmp(res->ops, "add")) 11233 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_FDIR, 11234 RTE_ETH_FILTER_ADD, &entry); 11235 else if (!strcmp(res->ops, "del")) 11236 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_FDIR, 11237 RTE_ETH_FILTER_DELETE, &entry); 11238 else 11239 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_FDIR, 11240 RTE_ETH_FILTER_UPDATE, &entry); 11241 if (ret < 0) 11242 printf("flow director programming error: (%s)\n", 11243 strerror(-ret)); 11244 } 11245 11246 cmdline_parse_token_string_t cmd_flow_director_filter = 11247 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result, 11248 flow_director_filter, "flow_director_filter"); 11249 cmdline_parse_token_num_t cmd_flow_director_port_id = 11250 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result, 11251 port_id, UINT16); 11252 cmdline_parse_token_string_t cmd_flow_director_ops = 11253 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result, 11254 ops, "add#del#update"); 11255 cmdline_parse_token_string_t cmd_flow_director_flow = 11256 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result, 11257 flow, "flow"); 11258 cmdline_parse_token_string_t cmd_flow_director_flow_type = 11259 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result, 11260 flow_type, NULL); 11261 cmdline_parse_token_string_t cmd_flow_director_ether = 11262 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result, 11263 ether, "ether"); 11264 cmdline_parse_token_num_t cmd_flow_director_ether_type = 11265 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result, 11266 ether_type, UINT16); 11267 cmdline_parse_token_string_t cmd_flow_director_src = 11268 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result, 11269 src, "src"); 11270 cmdline_parse_token_ipaddr_t cmd_flow_director_ip_src = 11271 TOKEN_IPADDR_INITIALIZER(struct cmd_flow_director_result, 11272 ip_src); 11273 cmdline_parse_token_num_t cmd_flow_director_port_src = 11274 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result, 11275 port_src, UINT16); 11276 cmdline_parse_token_string_t cmd_flow_director_dst = 11277 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result, 11278 dst, "dst"); 11279 cmdline_parse_token_ipaddr_t cmd_flow_director_ip_dst = 11280 TOKEN_IPADDR_INITIALIZER(struct cmd_flow_director_result, 11281 ip_dst); 11282 cmdline_parse_token_num_t cmd_flow_director_port_dst = 11283 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result, 11284 port_dst, UINT16); 11285 cmdline_parse_token_string_t cmd_flow_director_verify_tag = 11286 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result, 11287 verify_tag, "verify_tag"); 11288 cmdline_parse_token_num_t cmd_flow_director_verify_tag_value = 11289 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result, 11290 verify_tag_value, UINT32); 11291 cmdline_parse_token_string_t cmd_flow_director_tos = 11292 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result, 11293 tos, "tos"); 11294 cmdline_parse_token_num_t cmd_flow_director_tos_value = 11295 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result, 11296 tos_value, UINT8); 11297 cmdline_parse_token_string_t cmd_flow_director_proto = 11298 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result, 11299 proto, "proto"); 11300 cmdline_parse_token_num_t cmd_flow_director_proto_value = 11301 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result, 11302 proto_value, UINT8); 11303 cmdline_parse_token_string_t cmd_flow_director_ttl = 11304 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result, 11305 ttl, "ttl"); 11306 cmdline_parse_token_num_t cmd_flow_director_ttl_value = 11307 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result, 11308 ttl_value, UINT8); 11309 cmdline_parse_token_string_t cmd_flow_director_vlan = 11310 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result, 11311 vlan, "vlan"); 11312 cmdline_parse_token_num_t cmd_flow_director_vlan_value = 11313 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result, 11314 vlan_value, UINT16); 11315 cmdline_parse_token_string_t cmd_flow_director_flexbytes = 11316 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result, 11317 flexbytes, "flexbytes"); 11318 cmdline_parse_token_string_t cmd_flow_director_flexbytes_value = 11319 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result, 11320 flexbytes_value, NULL); 11321 cmdline_parse_token_string_t cmd_flow_director_drop = 11322 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result, 11323 drop, "drop#fwd"); 11324 cmdline_parse_token_string_t cmd_flow_director_pf_vf = 11325 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result, 11326 pf_vf, NULL); 11327 cmdline_parse_token_string_t cmd_flow_director_queue = 11328 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result, 11329 queue, "queue"); 11330 cmdline_parse_token_num_t cmd_flow_director_queue_id = 11331 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result, 11332 queue_id, UINT16); 11333 cmdline_parse_token_string_t cmd_flow_director_fd_id = 11334 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result, 11335 fd_id, "fd_id"); 11336 cmdline_parse_token_num_t cmd_flow_director_fd_id_value = 11337 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result, 11338 fd_id_value, UINT32); 11339 11340 cmdline_parse_token_string_t cmd_flow_director_mode = 11341 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result, 11342 mode, "mode"); 11343 cmdline_parse_token_string_t cmd_flow_director_mode_ip = 11344 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result, 11345 mode_value, "IP"); 11346 cmdline_parse_token_string_t cmd_flow_director_mode_mac_vlan = 11347 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result, 11348 mode_value, "MAC-VLAN"); 11349 cmdline_parse_token_string_t cmd_flow_director_mode_tunnel = 11350 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result, 11351 mode_value, "Tunnel"); 11352 cmdline_parse_token_string_t cmd_flow_director_mode_raw = 11353 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result, 11354 mode_value, "raw"); 11355 cmdline_parse_token_string_t cmd_flow_director_mac = 11356 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result, 11357 mac, "mac"); 11358 cmdline_parse_token_etheraddr_t cmd_flow_director_mac_addr = 11359 TOKEN_ETHERADDR_INITIALIZER(struct cmd_flow_director_result, 11360 mac_addr); 11361 cmdline_parse_token_string_t cmd_flow_director_tunnel = 11362 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result, 11363 tunnel, "tunnel"); 11364 cmdline_parse_token_string_t cmd_flow_director_tunnel_type = 11365 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result, 11366 tunnel_type, "NVGRE#VxLAN"); 11367 cmdline_parse_token_string_t cmd_flow_director_tunnel_id = 11368 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result, 11369 tunnel_id, "tunnel-id"); 11370 cmdline_parse_token_num_t cmd_flow_director_tunnel_id_value = 11371 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result, 11372 tunnel_id_value, UINT32); 11373 cmdline_parse_token_string_t cmd_flow_director_packet = 11374 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result, 11375 packet, "packet"); 11376 cmdline_parse_token_string_t cmd_flow_director_filepath = 11377 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result, 11378 filepath, NULL); 11379 11380 cmdline_parse_inst_t cmd_add_del_ip_flow_director = { 11381 .f = cmd_flow_director_filter_parsed, 11382 .data = NULL, 11383 .help_str = "flow_director_filter <port_id> mode IP add|del|update flow" 11384 " ipv4-other|ipv4-frag|ipv4-tcp|ipv4-udp|ipv4-sctp|" 11385 "ipv6-other|ipv6-frag|ipv6-tcp|ipv6-udp|ipv6-sctp|" 11386 "l2_payload src <src_ip> dst <dst_ip> tos <tos_value> " 11387 "proto <proto_value> ttl <ttl_value> vlan <vlan_value> " 11388 "flexbytes <flexbyte_values> drop|fw <pf_vf> queue <queue_id> " 11389 "fd_id <fd_id_value>: " 11390 "Add or delete an ip flow director entry on NIC", 11391 .tokens = { 11392 (void *)&cmd_flow_director_filter, 11393 (void *)&cmd_flow_director_port_id, 11394 (void *)&cmd_flow_director_mode, 11395 (void *)&cmd_flow_director_mode_ip, 11396 (void *)&cmd_flow_director_ops, 11397 (void *)&cmd_flow_director_flow, 11398 (void *)&cmd_flow_director_flow_type, 11399 (void *)&cmd_flow_director_src, 11400 (void *)&cmd_flow_director_ip_src, 11401 (void *)&cmd_flow_director_dst, 11402 (void *)&cmd_flow_director_ip_dst, 11403 (void *)&cmd_flow_director_tos, 11404 (void *)&cmd_flow_director_tos_value, 11405 (void *)&cmd_flow_director_proto, 11406 (void *)&cmd_flow_director_proto_value, 11407 (void *)&cmd_flow_director_ttl, 11408 (void *)&cmd_flow_director_ttl_value, 11409 (void *)&cmd_flow_director_vlan, 11410 (void *)&cmd_flow_director_vlan_value, 11411 (void *)&cmd_flow_director_flexbytes, 11412 (void *)&cmd_flow_director_flexbytes_value, 11413 (void *)&cmd_flow_director_drop, 11414 (void *)&cmd_flow_director_pf_vf, 11415 (void *)&cmd_flow_director_queue, 11416 (void *)&cmd_flow_director_queue_id, 11417 (void *)&cmd_flow_director_fd_id, 11418 (void *)&cmd_flow_director_fd_id_value, 11419 NULL, 11420 }, 11421 }; 11422 11423 cmdline_parse_inst_t cmd_add_del_udp_flow_director = { 11424 .f = cmd_flow_director_filter_parsed, 11425 .data = NULL, 11426 .help_str = "flow_director_filter ... : Add or delete an udp/tcp flow " 11427 "director entry on NIC", 11428 .tokens = { 11429 (void *)&cmd_flow_director_filter, 11430 (void *)&cmd_flow_director_port_id, 11431 (void *)&cmd_flow_director_mode, 11432 (void *)&cmd_flow_director_mode_ip, 11433 (void *)&cmd_flow_director_ops, 11434 (void *)&cmd_flow_director_flow, 11435 (void *)&cmd_flow_director_flow_type, 11436 (void *)&cmd_flow_director_src, 11437 (void *)&cmd_flow_director_ip_src, 11438 (void *)&cmd_flow_director_port_src, 11439 (void *)&cmd_flow_director_dst, 11440 (void *)&cmd_flow_director_ip_dst, 11441 (void *)&cmd_flow_director_port_dst, 11442 (void *)&cmd_flow_director_tos, 11443 (void *)&cmd_flow_director_tos_value, 11444 (void *)&cmd_flow_director_ttl, 11445 (void *)&cmd_flow_director_ttl_value, 11446 (void *)&cmd_flow_director_vlan, 11447 (void *)&cmd_flow_director_vlan_value, 11448 (void *)&cmd_flow_director_flexbytes, 11449 (void *)&cmd_flow_director_flexbytes_value, 11450 (void *)&cmd_flow_director_drop, 11451 (void *)&cmd_flow_director_pf_vf, 11452 (void *)&cmd_flow_director_queue, 11453 (void *)&cmd_flow_director_queue_id, 11454 (void *)&cmd_flow_director_fd_id, 11455 (void *)&cmd_flow_director_fd_id_value, 11456 NULL, 11457 }, 11458 }; 11459 11460 cmdline_parse_inst_t cmd_add_del_sctp_flow_director = { 11461 .f = cmd_flow_director_filter_parsed, 11462 .data = NULL, 11463 .help_str = "flow_director_filter ... : Add or delete a sctp flow " 11464 "director entry on NIC", 11465 .tokens = { 11466 (void *)&cmd_flow_director_filter, 11467 (void *)&cmd_flow_director_port_id, 11468 (void *)&cmd_flow_director_mode, 11469 (void *)&cmd_flow_director_mode_ip, 11470 (void *)&cmd_flow_director_ops, 11471 (void *)&cmd_flow_director_flow, 11472 (void *)&cmd_flow_director_flow_type, 11473 (void *)&cmd_flow_director_src, 11474 (void *)&cmd_flow_director_ip_src, 11475 (void *)&cmd_flow_director_port_src, 11476 (void *)&cmd_flow_director_dst, 11477 (void *)&cmd_flow_director_ip_dst, 11478 (void *)&cmd_flow_director_port_dst, 11479 (void *)&cmd_flow_director_verify_tag, 11480 (void *)&cmd_flow_director_verify_tag_value, 11481 (void *)&cmd_flow_director_tos, 11482 (void *)&cmd_flow_director_tos_value, 11483 (void *)&cmd_flow_director_ttl, 11484 (void *)&cmd_flow_director_ttl_value, 11485 (void *)&cmd_flow_director_vlan, 11486 (void *)&cmd_flow_director_vlan_value, 11487 (void *)&cmd_flow_director_flexbytes, 11488 (void *)&cmd_flow_director_flexbytes_value, 11489 (void *)&cmd_flow_director_drop, 11490 (void *)&cmd_flow_director_pf_vf, 11491 (void *)&cmd_flow_director_queue, 11492 (void *)&cmd_flow_director_queue_id, 11493 (void *)&cmd_flow_director_fd_id, 11494 (void *)&cmd_flow_director_fd_id_value, 11495 NULL, 11496 }, 11497 }; 11498 11499 cmdline_parse_inst_t cmd_add_del_l2_flow_director = { 11500 .f = cmd_flow_director_filter_parsed, 11501 .data = NULL, 11502 .help_str = "flow_director_filter ... : Add or delete a L2 flow " 11503 "director entry on NIC", 11504 .tokens = { 11505 (void *)&cmd_flow_director_filter, 11506 (void *)&cmd_flow_director_port_id, 11507 (void *)&cmd_flow_director_mode, 11508 (void *)&cmd_flow_director_mode_ip, 11509 (void *)&cmd_flow_director_ops, 11510 (void *)&cmd_flow_director_flow, 11511 (void *)&cmd_flow_director_flow_type, 11512 (void *)&cmd_flow_director_ether, 11513 (void *)&cmd_flow_director_ether_type, 11514 (void *)&cmd_flow_director_flexbytes, 11515 (void *)&cmd_flow_director_flexbytes_value, 11516 (void *)&cmd_flow_director_drop, 11517 (void *)&cmd_flow_director_pf_vf, 11518 (void *)&cmd_flow_director_queue, 11519 (void *)&cmd_flow_director_queue_id, 11520 (void *)&cmd_flow_director_fd_id, 11521 (void *)&cmd_flow_director_fd_id_value, 11522 NULL, 11523 }, 11524 }; 11525 11526 cmdline_parse_inst_t cmd_add_del_mac_vlan_flow_director = { 11527 .f = cmd_flow_director_filter_parsed, 11528 .data = NULL, 11529 .help_str = "flow_director_filter ... : Add or delete a MAC VLAN flow " 11530 "director entry on NIC", 11531 .tokens = { 11532 (void *)&cmd_flow_director_filter, 11533 (void *)&cmd_flow_director_port_id, 11534 (void *)&cmd_flow_director_mode, 11535 (void *)&cmd_flow_director_mode_mac_vlan, 11536 (void *)&cmd_flow_director_ops, 11537 (void *)&cmd_flow_director_mac, 11538 (void *)&cmd_flow_director_mac_addr, 11539 (void *)&cmd_flow_director_vlan, 11540 (void *)&cmd_flow_director_vlan_value, 11541 (void *)&cmd_flow_director_flexbytes, 11542 (void *)&cmd_flow_director_flexbytes_value, 11543 (void *)&cmd_flow_director_drop, 11544 (void *)&cmd_flow_director_queue, 11545 (void *)&cmd_flow_director_queue_id, 11546 (void *)&cmd_flow_director_fd_id, 11547 (void *)&cmd_flow_director_fd_id_value, 11548 NULL, 11549 }, 11550 }; 11551 11552 cmdline_parse_inst_t cmd_add_del_tunnel_flow_director = { 11553 .f = cmd_flow_director_filter_parsed, 11554 .data = NULL, 11555 .help_str = "flow_director_filter ... : Add or delete a tunnel flow " 11556 "director entry on NIC", 11557 .tokens = { 11558 (void *)&cmd_flow_director_filter, 11559 (void *)&cmd_flow_director_port_id, 11560 (void *)&cmd_flow_director_mode, 11561 (void *)&cmd_flow_director_mode_tunnel, 11562 (void *)&cmd_flow_director_ops, 11563 (void *)&cmd_flow_director_mac, 11564 (void *)&cmd_flow_director_mac_addr, 11565 (void *)&cmd_flow_director_vlan, 11566 (void *)&cmd_flow_director_vlan_value, 11567 (void *)&cmd_flow_director_tunnel, 11568 (void *)&cmd_flow_director_tunnel_type, 11569 (void *)&cmd_flow_director_tunnel_id, 11570 (void *)&cmd_flow_director_tunnel_id_value, 11571 (void *)&cmd_flow_director_flexbytes, 11572 (void *)&cmd_flow_director_flexbytes_value, 11573 (void *)&cmd_flow_director_drop, 11574 (void *)&cmd_flow_director_queue, 11575 (void *)&cmd_flow_director_queue_id, 11576 (void *)&cmd_flow_director_fd_id, 11577 (void *)&cmd_flow_director_fd_id_value, 11578 NULL, 11579 }, 11580 }; 11581 11582 cmdline_parse_inst_t cmd_add_del_raw_flow_director = { 11583 .f = cmd_flow_director_filter_parsed, 11584 .data = NULL, 11585 .help_str = "flow_director_filter ... : Add or delete a raw flow " 11586 "director entry on NIC", 11587 .tokens = { 11588 (void *)&cmd_flow_director_filter, 11589 (void *)&cmd_flow_director_port_id, 11590 (void *)&cmd_flow_director_mode, 11591 (void *)&cmd_flow_director_mode_raw, 11592 (void *)&cmd_flow_director_ops, 11593 (void *)&cmd_flow_director_flow, 11594 (void *)&cmd_flow_director_flow_type, 11595 (void *)&cmd_flow_director_drop, 11596 (void *)&cmd_flow_director_queue, 11597 (void *)&cmd_flow_director_queue_id, 11598 (void *)&cmd_flow_director_fd_id, 11599 (void *)&cmd_flow_director_fd_id_value, 11600 (void *)&cmd_flow_director_packet, 11601 (void *)&cmd_flow_director_filepath, 11602 NULL, 11603 }, 11604 }; 11605 11606 struct cmd_flush_flow_director_result { 11607 cmdline_fixed_string_t flush_flow_director; 11608 portid_t port_id; 11609 }; 11610 11611 cmdline_parse_token_string_t cmd_flush_flow_director_flush = 11612 TOKEN_STRING_INITIALIZER(struct cmd_flush_flow_director_result, 11613 flush_flow_director, "flush_flow_director"); 11614 cmdline_parse_token_num_t cmd_flush_flow_director_port_id = 11615 TOKEN_NUM_INITIALIZER(struct cmd_flush_flow_director_result, 11616 port_id, UINT16); 11617 11618 static void 11619 cmd_flush_flow_director_parsed(void *parsed_result, 11620 __attribute__((unused)) struct cmdline *cl, 11621 __attribute__((unused)) void *data) 11622 { 11623 struct cmd_flow_director_result *res = parsed_result; 11624 int ret = 0; 11625 11626 ret = rte_eth_dev_filter_supported(res->port_id, RTE_ETH_FILTER_FDIR); 11627 if (ret < 0) { 11628 printf("flow director is not supported on port %u.\n", 11629 res->port_id); 11630 return; 11631 } 11632 11633 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_FDIR, 11634 RTE_ETH_FILTER_FLUSH, NULL); 11635 if (ret < 0) 11636 printf("flow director table flushing error: (%s)\n", 11637 strerror(-ret)); 11638 } 11639 11640 cmdline_parse_inst_t cmd_flush_flow_director = { 11641 .f = cmd_flush_flow_director_parsed, 11642 .data = NULL, 11643 .help_str = "flush_flow_director <port_id>: " 11644 "Flush all flow director entries of a device on NIC", 11645 .tokens = { 11646 (void *)&cmd_flush_flow_director_flush, 11647 (void *)&cmd_flush_flow_director_port_id, 11648 NULL, 11649 }, 11650 }; 11651 11652 /* *** deal with flow director mask *** */ 11653 struct cmd_flow_director_mask_result { 11654 cmdline_fixed_string_t flow_director_mask; 11655 portid_t port_id; 11656 cmdline_fixed_string_t mode; 11657 cmdline_fixed_string_t mode_value; 11658 cmdline_fixed_string_t vlan; 11659 uint16_t vlan_mask; 11660 cmdline_fixed_string_t src_mask; 11661 cmdline_ipaddr_t ipv4_src; 11662 cmdline_ipaddr_t ipv6_src; 11663 uint16_t port_src; 11664 cmdline_fixed_string_t dst_mask; 11665 cmdline_ipaddr_t ipv4_dst; 11666 cmdline_ipaddr_t ipv6_dst; 11667 uint16_t port_dst; 11668 cmdline_fixed_string_t mac; 11669 uint8_t mac_addr_byte_mask; 11670 cmdline_fixed_string_t tunnel_id; 11671 uint32_t tunnel_id_mask; 11672 cmdline_fixed_string_t tunnel_type; 11673 uint8_t tunnel_type_mask; 11674 }; 11675 11676 static void 11677 cmd_flow_director_mask_parsed(void *parsed_result, 11678 __attribute__((unused)) struct cmdline *cl, 11679 __attribute__((unused)) void *data) 11680 { 11681 struct cmd_flow_director_mask_result *res = parsed_result; 11682 struct rte_eth_fdir_masks *mask; 11683 struct rte_port *port; 11684 11685 port = &ports[res->port_id]; 11686 /** Check if the port is not started **/ 11687 if (port->port_status != RTE_PORT_STOPPED) { 11688 printf("Please stop port %d first\n", res->port_id); 11689 return; 11690 } 11691 11692 mask = &port->dev_conf.fdir_conf.mask; 11693 11694 if (fdir_conf.mode == RTE_FDIR_MODE_PERFECT_MAC_VLAN) { 11695 if (strcmp(res->mode_value, "MAC-VLAN")) { 11696 printf("Please set mode to MAC-VLAN.\n"); 11697 return; 11698 } 11699 11700 mask->vlan_tci_mask = rte_cpu_to_be_16(res->vlan_mask); 11701 } else if (fdir_conf.mode == RTE_FDIR_MODE_PERFECT_TUNNEL) { 11702 if (strcmp(res->mode_value, "Tunnel")) { 11703 printf("Please set mode to Tunnel.\n"); 11704 return; 11705 } 11706 11707 mask->vlan_tci_mask = rte_cpu_to_be_16(res->vlan_mask); 11708 mask->mac_addr_byte_mask = res->mac_addr_byte_mask; 11709 mask->tunnel_id_mask = rte_cpu_to_be_32(res->tunnel_id_mask); 11710 mask->tunnel_type_mask = res->tunnel_type_mask; 11711 } else { 11712 if (strcmp(res->mode_value, "IP")) { 11713 printf("Please set mode to IP.\n"); 11714 return; 11715 } 11716 11717 mask->vlan_tci_mask = rte_cpu_to_be_16(res->vlan_mask); 11718 IPV4_ADDR_TO_UINT(res->ipv4_src, mask->ipv4_mask.src_ip); 11719 IPV4_ADDR_TO_UINT(res->ipv4_dst, mask->ipv4_mask.dst_ip); 11720 IPV6_ADDR_TO_ARRAY(res->ipv6_src, mask->ipv6_mask.src_ip); 11721 IPV6_ADDR_TO_ARRAY(res->ipv6_dst, mask->ipv6_mask.dst_ip); 11722 mask->src_port_mask = rte_cpu_to_be_16(res->port_src); 11723 mask->dst_port_mask = rte_cpu_to_be_16(res->port_dst); 11724 } 11725 11726 cmd_reconfig_device_queue(res->port_id, 1, 1); 11727 } 11728 11729 cmdline_parse_token_string_t cmd_flow_director_mask = 11730 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result, 11731 flow_director_mask, "flow_director_mask"); 11732 cmdline_parse_token_num_t cmd_flow_director_mask_port_id = 11733 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_mask_result, 11734 port_id, UINT16); 11735 cmdline_parse_token_string_t cmd_flow_director_mask_vlan = 11736 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result, 11737 vlan, "vlan"); 11738 cmdline_parse_token_num_t cmd_flow_director_mask_vlan_value = 11739 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_mask_result, 11740 vlan_mask, UINT16); 11741 cmdline_parse_token_string_t cmd_flow_director_mask_src = 11742 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result, 11743 src_mask, "src_mask"); 11744 cmdline_parse_token_ipaddr_t cmd_flow_director_mask_ipv4_src = 11745 TOKEN_IPADDR_INITIALIZER(struct cmd_flow_director_mask_result, 11746 ipv4_src); 11747 cmdline_parse_token_ipaddr_t cmd_flow_director_mask_ipv6_src = 11748 TOKEN_IPADDR_INITIALIZER(struct cmd_flow_director_mask_result, 11749 ipv6_src); 11750 cmdline_parse_token_num_t cmd_flow_director_mask_port_src = 11751 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_mask_result, 11752 port_src, UINT16); 11753 cmdline_parse_token_string_t cmd_flow_director_mask_dst = 11754 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result, 11755 dst_mask, "dst_mask"); 11756 cmdline_parse_token_ipaddr_t cmd_flow_director_mask_ipv4_dst = 11757 TOKEN_IPADDR_INITIALIZER(struct cmd_flow_director_mask_result, 11758 ipv4_dst); 11759 cmdline_parse_token_ipaddr_t cmd_flow_director_mask_ipv6_dst = 11760 TOKEN_IPADDR_INITIALIZER(struct cmd_flow_director_mask_result, 11761 ipv6_dst); 11762 cmdline_parse_token_num_t cmd_flow_director_mask_port_dst = 11763 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_mask_result, 11764 port_dst, UINT16); 11765 11766 cmdline_parse_token_string_t cmd_flow_director_mask_mode = 11767 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result, 11768 mode, "mode"); 11769 cmdline_parse_token_string_t cmd_flow_director_mask_mode_ip = 11770 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result, 11771 mode_value, "IP"); 11772 cmdline_parse_token_string_t cmd_flow_director_mask_mode_mac_vlan = 11773 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result, 11774 mode_value, "MAC-VLAN"); 11775 cmdline_parse_token_string_t cmd_flow_director_mask_mode_tunnel = 11776 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result, 11777 mode_value, "Tunnel"); 11778 cmdline_parse_token_string_t cmd_flow_director_mask_mac = 11779 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result, 11780 mac, "mac"); 11781 cmdline_parse_token_num_t cmd_flow_director_mask_mac_value = 11782 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_mask_result, 11783 mac_addr_byte_mask, UINT8); 11784 cmdline_parse_token_string_t cmd_flow_director_mask_tunnel_type = 11785 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result, 11786 tunnel_type, "tunnel-type"); 11787 cmdline_parse_token_num_t cmd_flow_director_mask_tunnel_type_value = 11788 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_mask_result, 11789 tunnel_type_mask, UINT8); 11790 cmdline_parse_token_string_t cmd_flow_director_mask_tunnel_id = 11791 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result, 11792 tunnel_id, "tunnel-id"); 11793 cmdline_parse_token_num_t cmd_flow_director_mask_tunnel_id_value = 11794 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_mask_result, 11795 tunnel_id_mask, UINT32); 11796 11797 cmdline_parse_inst_t cmd_set_flow_director_ip_mask = { 11798 .f = cmd_flow_director_mask_parsed, 11799 .data = NULL, 11800 .help_str = "flow_director_mask ... : " 11801 "Set IP mode flow director's mask on NIC", 11802 .tokens = { 11803 (void *)&cmd_flow_director_mask, 11804 (void *)&cmd_flow_director_mask_port_id, 11805 (void *)&cmd_flow_director_mask_mode, 11806 (void *)&cmd_flow_director_mask_mode_ip, 11807 (void *)&cmd_flow_director_mask_vlan, 11808 (void *)&cmd_flow_director_mask_vlan_value, 11809 (void *)&cmd_flow_director_mask_src, 11810 (void *)&cmd_flow_director_mask_ipv4_src, 11811 (void *)&cmd_flow_director_mask_ipv6_src, 11812 (void *)&cmd_flow_director_mask_port_src, 11813 (void *)&cmd_flow_director_mask_dst, 11814 (void *)&cmd_flow_director_mask_ipv4_dst, 11815 (void *)&cmd_flow_director_mask_ipv6_dst, 11816 (void *)&cmd_flow_director_mask_port_dst, 11817 NULL, 11818 }, 11819 }; 11820 11821 cmdline_parse_inst_t cmd_set_flow_director_mac_vlan_mask = { 11822 .f = cmd_flow_director_mask_parsed, 11823 .data = NULL, 11824 .help_str = "flow_director_mask ... : Set MAC VLAN mode " 11825 "flow director's mask on NIC", 11826 .tokens = { 11827 (void *)&cmd_flow_director_mask, 11828 (void *)&cmd_flow_director_mask_port_id, 11829 (void *)&cmd_flow_director_mask_mode, 11830 (void *)&cmd_flow_director_mask_mode_mac_vlan, 11831 (void *)&cmd_flow_director_mask_vlan, 11832 (void *)&cmd_flow_director_mask_vlan_value, 11833 NULL, 11834 }, 11835 }; 11836 11837 cmdline_parse_inst_t cmd_set_flow_director_tunnel_mask = { 11838 .f = cmd_flow_director_mask_parsed, 11839 .data = NULL, 11840 .help_str = "flow_director_mask ... : Set tunnel mode " 11841 "flow director's mask on NIC", 11842 .tokens = { 11843 (void *)&cmd_flow_director_mask, 11844 (void *)&cmd_flow_director_mask_port_id, 11845 (void *)&cmd_flow_director_mask_mode, 11846 (void *)&cmd_flow_director_mask_mode_tunnel, 11847 (void *)&cmd_flow_director_mask_vlan, 11848 (void *)&cmd_flow_director_mask_vlan_value, 11849 (void *)&cmd_flow_director_mask_mac, 11850 (void *)&cmd_flow_director_mask_mac_value, 11851 (void *)&cmd_flow_director_mask_tunnel_type, 11852 (void *)&cmd_flow_director_mask_tunnel_type_value, 11853 (void *)&cmd_flow_director_mask_tunnel_id, 11854 (void *)&cmd_flow_director_mask_tunnel_id_value, 11855 NULL, 11856 }, 11857 }; 11858 11859 /* *** deal with flow director mask on flexible payload *** */ 11860 struct cmd_flow_director_flex_mask_result { 11861 cmdline_fixed_string_t flow_director_flexmask; 11862 portid_t port_id; 11863 cmdline_fixed_string_t flow; 11864 cmdline_fixed_string_t flow_type; 11865 cmdline_fixed_string_t mask; 11866 }; 11867 11868 static void 11869 cmd_flow_director_flex_mask_parsed(void *parsed_result, 11870 __attribute__((unused)) struct cmdline *cl, 11871 __attribute__((unused)) void *data) 11872 { 11873 struct cmd_flow_director_flex_mask_result *res = parsed_result; 11874 struct rte_eth_fdir_info fdir_info; 11875 struct rte_eth_fdir_flex_mask flex_mask; 11876 struct rte_port *port; 11877 uint64_t flow_type_mask; 11878 uint16_t i; 11879 int ret; 11880 11881 port = &ports[res->port_id]; 11882 /** Check if the port is not started **/ 11883 if (port->port_status != RTE_PORT_STOPPED) { 11884 printf("Please stop port %d first\n", res->port_id); 11885 return; 11886 } 11887 11888 memset(&flex_mask, 0, sizeof(struct rte_eth_fdir_flex_mask)); 11889 ret = parse_flexbytes(res->mask, 11890 flex_mask.mask, 11891 RTE_ETH_FDIR_MAX_FLEXLEN); 11892 if (ret < 0) { 11893 printf("error: Cannot parse mask input.\n"); 11894 return; 11895 } 11896 11897 memset(&fdir_info, 0, sizeof(fdir_info)); 11898 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_FDIR, 11899 RTE_ETH_FILTER_INFO, &fdir_info); 11900 if (ret < 0) { 11901 printf("Cannot get FDir filter info\n"); 11902 return; 11903 } 11904 11905 if (!strcmp(res->flow_type, "none")) { 11906 /* means don't specify the flow type */ 11907 flex_mask.flow_type = RTE_ETH_FLOW_UNKNOWN; 11908 for (i = 0; i < RTE_ETH_FLOW_MAX; i++) 11909 memset(&port->dev_conf.fdir_conf.flex_conf.flex_mask[i], 11910 0, sizeof(struct rte_eth_fdir_flex_mask)); 11911 port->dev_conf.fdir_conf.flex_conf.nb_flexmasks = 1; 11912 rte_memcpy(&port->dev_conf.fdir_conf.flex_conf.flex_mask[0], 11913 &flex_mask, 11914 sizeof(struct rte_eth_fdir_flex_mask)); 11915 cmd_reconfig_device_queue(res->port_id, 1, 1); 11916 return; 11917 } 11918 flow_type_mask = fdir_info.flow_types_mask[0]; 11919 if (!strcmp(res->flow_type, "all")) { 11920 if (!flow_type_mask) { 11921 printf("No flow type supported\n"); 11922 return; 11923 } 11924 for (i = RTE_ETH_FLOW_UNKNOWN; i < RTE_ETH_FLOW_MAX; i++) { 11925 if (flow_type_mask & (1ULL << i)) { 11926 flex_mask.flow_type = i; 11927 fdir_set_flex_mask(res->port_id, &flex_mask); 11928 } 11929 } 11930 cmd_reconfig_device_queue(res->port_id, 1, 1); 11931 return; 11932 } 11933 flex_mask.flow_type = str2flowtype(res->flow_type); 11934 if (!(flow_type_mask & (1ULL << flex_mask.flow_type))) { 11935 printf("Flow type %s not supported on port %d\n", 11936 res->flow_type, res->port_id); 11937 return; 11938 } 11939 fdir_set_flex_mask(res->port_id, &flex_mask); 11940 cmd_reconfig_device_queue(res->port_id, 1, 1); 11941 } 11942 11943 cmdline_parse_token_string_t cmd_flow_director_flexmask = 11944 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_flex_mask_result, 11945 flow_director_flexmask, 11946 "flow_director_flex_mask"); 11947 cmdline_parse_token_num_t cmd_flow_director_flexmask_port_id = 11948 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_flex_mask_result, 11949 port_id, UINT16); 11950 cmdline_parse_token_string_t cmd_flow_director_flexmask_flow = 11951 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_flex_mask_result, 11952 flow, "flow"); 11953 cmdline_parse_token_string_t cmd_flow_director_flexmask_flow_type = 11954 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_flex_mask_result, 11955 flow_type, "none#ipv4-other#ipv4-frag#ipv4-tcp#ipv4-udp#ipv4-sctp#" 11956 "ipv6-other#ipv6-frag#ipv6-tcp#ipv6-udp#ipv6-sctp#l2_payload#all"); 11957 cmdline_parse_token_string_t cmd_flow_director_flexmask_mask = 11958 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_flex_mask_result, 11959 mask, NULL); 11960 11961 cmdline_parse_inst_t cmd_set_flow_director_flex_mask = { 11962 .f = cmd_flow_director_flex_mask_parsed, 11963 .data = NULL, 11964 .help_str = "flow_director_flex_mask ... : " 11965 "Set flow director's flex mask on NIC", 11966 .tokens = { 11967 (void *)&cmd_flow_director_flexmask, 11968 (void *)&cmd_flow_director_flexmask_port_id, 11969 (void *)&cmd_flow_director_flexmask_flow, 11970 (void *)&cmd_flow_director_flexmask_flow_type, 11971 (void *)&cmd_flow_director_flexmask_mask, 11972 NULL, 11973 }, 11974 }; 11975 11976 /* *** deal with flow director flexible payload configuration *** */ 11977 struct cmd_flow_director_flexpayload_result { 11978 cmdline_fixed_string_t flow_director_flexpayload; 11979 portid_t port_id; 11980 cmdline_fixed_string_t payload_layer; 11981 cmdline_fixed_string_t payload_cfg; 11982 }; 11983 11984 static inline int 11985 parse_offsets(const char *q_arg, uint16_t *offsets, uint16_t max_num) 11986 { 11987 char s[256]; 11988 const char *p, *p0 = q_arg; 11989 char *end; 11990 unsigned long int_fld; 11991 char *str_fld[max_num]; 11992 int i; 11993 unsigned size; 11994 int ret = -1; 11995 11996 p = strchr(p0, '('); 11997 if (p == NULL) 11998 return -1; 11999 ++p; 12000 p0 = strchr(p, ')'); 12001 if (p0 == NULL) 12002 return -1; 12003 12004 size = p0 - p; 12005 if (size >= sizeof(s)) 12006 return -1; 12007 12008 snprintf(s, sizeof(s), "%.*s", size, p); 12009 ret = rte_strsplit(s, sizeof(s), str_fld, max_num, ','); 12010 if (ret < 0 || ret > max_num) 12011 return -1; 12012 for (i = 0; i < ret; i++) { 12013 errno = 0; 12014 int_fld = strtoul(str_fld[i], &end, 0); 12015 if (errno != 0 || *end != '\0' || int_fld > UINT16_MAX) 12016 return -1; 12017 offsets[i] = (uint16_t)int_fld; 12018 } 12019 return ret; 12020 } 12021 12022 static void 12023 cmd_flow_director_flxpld_parsed(void *parsed_result, 12024 __attribute__((unused)) struct cmdline *cl, 12025 __attribute__((unused)) void *data) 12026 { 12027 struct cmd_flow_director_flexpayload_result *res = parsed_result; 12028 struct rte_eth_flex_payload_cfg flex_cfg; 12029 struct rte_port *port; 12030 int ret = 0; 12031 12032 port = &ports[res->port_id]; 12033 /** Check if the port is not started **/ 12034 if (port->port_status != RTE_PORT_STOPPED) { 12035 printf("Please stop port %d first\n", res->port_id); 12036 return; 12037 } 12038 12039 memset(&flex_cfg, 0, sizeof(struct rte_eth_flex_payload_cfg)); 12040 12041 if (!strcmp(res->payload_layer, "raw")) 12042 flex_cfg.type = RTE_ETH_RAW_PAYLOAD; 12043 else if (!strcmp(res->payload_layer, "l2")) 12044 flex_cfg.type = RTE_ETH_L2_PAYLOAD; 12045 else if (!strcmp(res->payload_layer, "l3")) 12046 flex_cfg.type = RTE_ETH_L3_PAYLOAD; 12047 else if (!strcmp(res->payload_layer, "l4")) 12048 flex_cfg.type = RTE_ETH_L4_PAYLOAD; 12049 12050 ret = parse_offsets(res->payload_cfg, flex_cfg.src_offset, 12051 RTE_ETH_FDIR_MAX_FLEXLEN); 12052 if (ret < 0) { 12053 printf("error: Cannot parse flex payload input.\n"); 12054 return; 12055 } 12056 12057 fdir_set_flex_payload(res->port_id, &flex_cfg); 12058 cmd_reconfig_device_queue(res->port_id, 1, 1); 12059 } 12060 12061 cmdline_parse_token_string_t cmd_flow_director_flexpayload = 12062 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_flexpayload_result, 12063 flow_director_flexpayload, 12064 "flow_director_flex_payload"); 12065 cmdline_parse_token_num_t cmd_flow_director_flexpayload_port_id = 12066 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_flexpayload_result, 12067 port_id, UINT16); 12068 cmdline_parse_token_string_t cmd_flow_director_flexpayload_payload_layer = 12069 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_flexpayload_result, 12070 payload_layer, "raw#l2#l3#l4"); 12071 cmdline_parse_token_string_t cmd_flow_director_flexpayload_payload_cfg = 12072 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_flexpayload_result, 12073 payload_cfg, NULL); 12074 12075 cmdline_parse_inst_t cmd_set_flow_director_flex_payload = { 12076 .f = cmd_flow_director_flxpld_parsed, 12077 .data = NULL, 12078 .help_str = "flow_director_flexpayload ... : " 12079 "Set flow director's flex payload on NIC", 12080 .tokens = { 12081 (void *)&cmd_flow_director_flexpayload, 12082 (void *)&cmd_flow_director_flexpayload_port_id, 12083 (void *)&cmd_flow_director_flexpayload_payload_layer, 12084 (void *)&cmd_flow_director_flexpayload_payload_cfg, 12085 NULL, 12086 }, 12087 }; 12088 12089 /* Generic flow interface command. */ 12090 extern cmdline_parse_inst_t cmd_flow; 12091 12092 /* *** Classification Filters Control *** */ 12093 /* *** Get symmetric hash enable per port *** */ 12094 struct cmd_get_sym_hash_ena_per_port_result { 12095 cmdline_fixed_string_t get_sym_hash_ena_per_port; 12096 portid_t port_id; 12097 }; 12098 12099 static void 12100 cmd_get_sym_hash_per_port_parsed(void *parsed_result, 12101 __rte_unused struct cmdline *cl, 12102 __rte_unused void *data) 12103 { 12104 struct cmd_get_sym_hash_ena_per_port_result *res = parsed_result; 12105 struct rte_eth_hash_filter_info info; 12106 int ret; 12107 12108 if (rte_eth_dev_filter_supported(res->port_id, 12109 RTE_ETH_FILTER_HASH) < 0) { 12110 printf("RTE_ETH_FILTER_HASH not supported on port: %d\n", 12111 res->port_id); 12112 return; 12113 } 12114 12115 memset(&info, 0, sizeof(info)); 12116 info.info_type = RTE_ETH_HASH_FILTER_SYM_HASH_ENA_PER_PORT; 12117 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_HASH, 12118 RTE_ETH_FILTER_GET, &info); 12119 12120 if (ret < 0) { 12121 printf("Cannot get symmetric hash enable per port " 12122 "on port %u\n", res->port_id); 12123 return; 12124 } 12125 12126 printf("Symmetric hash is %s on port %u\n", info.info.enable ? 12127 "enabled" : "disabled", res->port_id); 12128 } 12129 12130 cmdline_parse_token_string_t cmd_get_sym_hash_ena_per_port_all = 12131 TOKEN_STRING_INITIALIZER(struct cmd_get_sym_hash_ena_per_port_result, 12132 get_sym_hash_ena_per_port, "get_sym_hash_ena_per_port"); 12133 cmdline_parse_token_num_t cmd_get_sym_hash_ena_per_port_port_id = 12134 TOKEN_NUM_INITIALIZER(struct cmd_get_sym_hash_ena_per_port_result, 12135 port_id, UINT16); 12136 12137 cmdline_parse_inst_t cmd_get_sym_hash_ena_per_port = { 12138 .f = cmd_get_sym_hash_per_port_parsed, 12139 .data = NULL, 12140 .help_str = "get_sym_hash_ena_per_port <port_id>", 12141 .tokens = { 12142 (void *)&cmd_get_sym_hash_ena_per_port_all, 12143 (void *)&cmd_get_sym_hash_ena_per_port_port_id, 12144 NULL, 12145 }, 12146 }; 12147 12148 /* *** Set symmetric hash enable per port *** */ 12149 struct cmd_set_sym_hash_ena_per_port_result { 12150 cmdline_fixed_string_t set_sym_hash_ena_per_port; 12151 cmdline_fixed_string_t enable; 12152 portid_t port_id; 12153 }; 12154 12155 static void 12156 cmd_set_sym_hash_per_port_parsed(void *parsed_result, 12157 __rte_unused struct cmdline *cl, 12158 __rte_unused void *data) 12159 { 12160 struct cmd_set_sym_hash_ena_per_port_result *res = parsed_result; 12161 struct rte_eth_hash_filter_info info; 12162 int ret; 12163 12164 if (rte_eth_dev_filter_supported(res->port_id, 12165 RTE_ETH_FILTER_HASH) < 0) { 12166 printf("RTE_ETH_FILTER_HASH not supported on port: %d\n", 12167 res->port_id); 12168 return; 12169 } 12170 12171 memset(&info, 0, sizeof(info)); 12172 info.info_type = RTE_ETH_HASH_FILTER_SYM_HASH_ENA_PER_PORT; 12173 if (!strcmp(res->enable, "enable")) 12174 info.info.enable = 1; 12175 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_HASH, 12176 RTE_ETH_FILTER_SET, &info); 12177 if (ret < 0) { 12178 printf("Cannot set symmetric hash enable per port on " 12179 "port %u\n", res->port_id); 12180 return; 12181 } 12182 printf("Symmetric hash has been set to %s on port %u\n", 12183 res->enable, res->port_id); 12184 } 12185 12186 cmdline_parse_token_string_t cmd_set_sym_hash_ena_per_port_all = 12187 TOKEN_STRING_INITIALIZER(struct cmd_set_sym_hash_ena_per_port_result, 12188 set_sym_hash_ena_per_port, "set_sym_hash_ena_per_port"); 12189 cmdline_parse_token_num_t cmd_set_sym_hash_ena_per_port_port_id = 12190 TOKEN_NUM_INITIALIZER(struct cmd_set_sym_hash_ena_per_port_result, 12191 port_id, UINT16); 12192 cmdline_parse_token_string_t cmd_set_sym_hash_ena_per_port_enable = 12193 TOKEN_STRING_INITIALIZER(struct cmd_set_sym_hash_ena_per_port_result, 12194 enable, "enable#disable"); 12195 12196 cmdline_parse_inst_t cmd_set_sym_hash_ena_per_port = { 12197 .f = cmd_set_sym_hash_per_port_parsed, 12198 .data = NULL, 12199 .help_str = "set_sym_hash_ena_per_port <port_id> enable|disable", 12200 .tokens = { 12201 (void *)&cmd_set_sym_hash_ena_per_port_all, 12202 (void *)&cmd_set_sym_hash_ena_per_port_port_id, 12203 (void *)&cmd_set_sym_hash_ena_per_port_enable, 12204 NULL, 12205 }, 12206 }; 12207 12208 /* Get global config of hash function */ 12209 struct cmd_get_hash_global_config_result { 12210 cmdline_fixed_string_t get_hash_global_config; 12211 portid_t port_id; 12212 }; 12213 12214 static char * 12215 flowtype_to_str(uint16_t ftype) 12216 { 12217 uint16_t i; 12218 static struct { 12219 char str[16]; 12220 uint16_t ftype; 12221 } ftype_table[] = { 12222 {"ipv4", RTE_ETH_FLOW_IPV4}, 12223 {"ipv4-frag", RTE_ETH_FLOW_FRAG_IPV4}, 12224 {"ipv4-tcp", RTE_ETH_FLOW_NONFRAG_IPV4_TCP}, 12225 {"ipv4-udp", RTE_ETH_FLOW_NONFRAG_IPV4_UDP}, 12226 {"ipv4-sctp", RTE_ETH_FLOW_NONFRAG_IPV4_SCTP}, 12227 {"ipv4-other", RTE_ETH_FLOW_NONFRAG_IPV4_OTHER}, 12228 {"ipv6", RTE_ETH_FLOW_IPV6}, 12229 {"ipv6-frag", RTE_ETH_FLOW_FRAG_IPV6}, 12230 {"ipv6-tcp", RTE_ETH_FLOW_NONFRAG_IPV6_TCP}, 12231 {"ipv6-udp", RTE_ETH_FLOW_NONFRAG_IPV6_UDP}, 12232 {"ipv6-sctp", RTE_ETH_FLOW_NONFRAG_IPV6_SCTP}, 12233 {"ipv6-other", RTE_ETH_FLOW_NONFRAG_IPV6_OTHER}, 12234 {"l2_payload", RTE_ETH_FLOW_L2_PAYLOAD}, 12235 {"port", RTE_ETH_FLOW_PORT}, 12236 {"vxlan", RTE_ETH_FLOW_VXLAN}, 12237 {"geneve", RTE_ETH_FLOW_GENEVE}, 12238 {"nvgre", RTE_ETH_FLOW_NVGRE}, 12239 {"vxlan-gpe", RTE_ETH_FLOW_VXLAN_GPE}, 12240 }; 12241 12242 for (i = 0; i < RTE_DIM(ftype_table); i++) { 12243 if (ftype_table[i].ftype == ftype) 12244 return ftype_table[i].str; 12245 } 12246 12247 return NULL; 12248 } 12249 12250 static void 12251 cmd_get_hash_global_config_parsed(void *parsed_result, 12252 __rte_unused struct cmdline *cl, 12253 __rte_unused void *data) 12254 { 12255 struct cmd_get_hash_global_config_result *res = parsed_result; 12256 struct rte_eth_hash_filter_info info; 12257 uint32_t idx, offset; 12258 uint16_t i; 12259 char *str; 12260 int ret; 12261 12262 if (rte_eth_dev_filter_supported(res->port_id, 12263 RTE_ETH_FILTER_HASH) < 0) { 12264 printf("RTE_ETH_FILTER_HASH not supported on port %d\n", 12265 res->port_id); 12266 return; 12267 } 12268 12269 memset(&info, 0, sizeof(info)); 12270 info.info_type = RTE_ETH_HASH_FILTER_GLOBAL_CONFIG; 12271 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_HASH, 12272 RTE_ETH_FILTER_GET, &info); 12273 if (ret < 0) { 12274 printf("Cannot get hash global configurations by port %d\n", 12275 res->port_id); 12276 return; 12277 } 12278 12279 switch (info.info.global_conf.hash_func) { 12280 case RTE_ETH_HASH_FUNCTION_TOEPLITZ: 12281 printf("Hash function is Toeplitz\n"); 12282 break; 12283 case RTE_ETH_HASH_FUNCTION_SIMPLE_XOR: 12284 printf("Hash function is Simple XOR\n"); 12285 break; 12286 case RTE_ETH_HASH_FUNCTION_SYMMETRIC_TOEPLITZ: 12287 printf("Hash function is Symmetric Toeplitz\n"); 12288 break; 12289 default: 12290 printf("Unknown hash function\n"); 12291 break; 12292 } 12293 12294 for (i = 0; i < RTE_ETH_FLOW_MAX; i++) { 12295 idx = i / UINT64_BIT; 12296 offset = i % UINT64_BIT; 12297 if (!(info.info.global_conf.valid_bit_mask[idx] & 12298 (1ULL << offset))) 12299 continue; 12300 str = flowtype_to_str(i); 12301 if (!str) 12302 continue; 12303 printf("Symmetric hash is %s globally for flow type %s " 12304 "by port %d\n", 12305 ((info.info.global_conf.sym_hash_enable_mask[idx] & 12306 (1ULL << offset)) ? "enabled" : "disabled"), str, 12307 res->port_id); 12308 } 12309 } 12310 12311 cmdline_parse_token_string_t cmd_get_hash_global_config_all = 12312 TOKEN_STRING_INITIALIZER(struct cmd_get_hash_global_config_result, 12313 get_hash_global_config, "get_hash_global_config"); 12314 cmdline_parse_token_num_t cmd_get_hash_global_config_port_id = 12315 TOKEN_NUM_INITIALIZER(struct cmd_get_hash_global_config_result, 12316 port_id, UINT16); 12317 12318 cmdline_parse_inst_t cmd_get_hash_global_config = { 12319 .f = cmd_get_hash_global_config_parsed, 12320 .data = NULL, 12321 .help_str = "get_hash_global_config <port_id>", 12322 .tokens = { 12323 (void *)&cmd_get_hash_global_config_all, 12324 (void *)&cmd_get_hash_global_config_port_id, 12325 NULL, 12326 }, 12327 }; 12328 12329 /* Set global config of hash function */ 12330 struct cmd_set_hash_global_config_result { 12331 cmdline_fixed_string_t set_hash_global_config; 12332 portid_t port_id; 12333 cmdline_fixed_string_t hash_func; 12334 cmdline_fixed_string_t flow_type; 12335 cmdline_fixed_string_t enable; 12336 }; 12337 12338 static void 12339 cmd_set_hash_global_config_parsed(void *parsed_result, 12340 __rte_unused struct cmdline *cl, 12341 __rte_unused void *data) 12342 { 12343 struct cmd_set_hash_global_config_result *res = parsed_result; 12344 struct rte_eth_hash_filter_info info; 12345 uint32_t ftype, idx, offset; 12346 int ret; 12347 12348 if (rte_eth_dev_filter_supported(res->port_id, 12349 RTE_ETH_FILTER_HASH) < 0) { 12350 printf("RTE_ETH_FILTER_HASH not supported on port %d\n", 12351 res->port_id); 12352 return; 12353 } 12354 memset(&info, 0, sizeof(info)); 12355 info.info_type = RTE_ETH_HASH_FILTER_GLOBAL_CONFIG; 12356 if (!strcmp(res->hash_func, "toeplitz")) 12357 info.info.global_conf.hash_func = 12358 RTE_ETH_HASH_FUNCTION_TOEPLITZ; 12359 else if (!strcmp(res->hash_func, "simple_xor")) 12360 info.info.global_conf.hash_func = 12361 RTE_ETH_HASH_FUNCTION_SIMPLE_XOR; 12362 else if (!strcmp(res->hash_func, "symmetric_toeplitz")) 12363 info.info.global_conf.hash_func = 12364 RTE_ETH_HASH_FUNCTION_SYMMETRIC_TOEPLITZ; 12365 else if (!strcmp(res->hash_func, "default")) 12366 info.info.global_conf.hash_func = 12367 RTE_ETH_HASH_FUNCTION_DEFAULT; 12368 12369 ftype = str2flowtype(res->flow_type); 12370 idx = ftype / UINT64_BIT; 12371 offset = ftype % UINT64_BIT; 12372 info.info.global_conf.valid_bit_mask[idx] |= (1ULL << offset); 12373 if (!strcmp(res->enable, "enable")) 12374 info.info.global_conf.sym_hash_enable_mask[idx] |= 12375 (1ULL << offset); 12376 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_HASH, 12377 RTE_ETH_FILTER_SET, &info); 12378 if (ret < 0) 12379 printf("Cannot set global hash configurations by port %d\n", 12380 res->port_id); 12381 else 12382 printf("Global hash configurations have been set " 12383 "successfully by port %d\n", res->port_id); 12384 } 12385 12386 cmdline_parse_token_string_t cmd_set_hash_global_config_all = 12387 TOKEN_STRING_INITIALIZER(struct cmd_set_hash_global_config_result, 12388 set_hash_global_config, "set_hash_global_config"); 12389 cmdline_parse_token_num_t cmd_set_hash_global_config_port_id = 12390 TOKEN_NUM_INITIALIZER(struct cmd_set_hash_global_config_result, 12391 port_id, UINT16); 12392 cmdline_parse_token_string_t cmd_set_hash_global_config_hash_func = 12393 TOKEN_STRING_INITIALIZER(struct cmd_set_hash_global_config_result, 12394 hash_func, "toeplitz#simple_xor#symmetric_toeplitz#default"); 12395 cmdline_parse_token_string_t cmd_set_hash_global_config_flow_type = 12396 TOKEN_STRING_INITIALIZER(struct cmd_set_hash_global_config_result, 12397 flow_type, 12398 "ipv4#ipv4-frag#ipv4-tcp#ipv4-udp#ipv4-sctp#ipv4-other#ipv6#" 12399 "ipv6-frag#ipv6-tcp#ipv6-udp#ipv6-sctp#ipv6-other#l2_payload"); 12400 cmdline_parse_token_string_t cmd_set_hash_global_config_enable = 12401 TOKEN_STRING_INITIALIZER(struct cmd_set_hash_global_config_result, 12402 enable, "enable#disable"); 12403 12404 cmdline_parse_inst_t cmd_set_hash_global_config = { 12405 .f = cmd_set_hash_global_config_parsed, 12406 .data = NULL, 12407 .help_str = "set_hash_global_config <port_id> " 12408 "toeplitz|simple_xor|symmetric_toeplitz|default " 12409 "ipv4|ipv4-frag|ipv4-tcp|ipv4-udp|ipv4-sctp|ipv4-other|" 12410 "ipv6|ipv6-frag|ipv6-tcp|ipv6-udp|ipv6-sctp|ipv6-other|" 12411 "l2_payload enable|disable", 12412 .tokens = { 12413 (void *)&cmd_set_hash_global_config_all, 12414 (void *)&cmd_set_hash_global_config_port_id, 12415 (void *)&cmd_set_hash_global_config_hash_func, 12416 (void *)&cmd_set_hash_global_config_flow_type, 12417 (void *)&cmd_set_hash_global_config_enable, 12418 NULL, 12419 }, 12420 }; 12421 12422 /* Set hash input set */ 12423 struct cmd_set_hash_input_set_result { 12424 cmdline_fixed_string_t set_hash_input_set; 12425 portid_t port_id; 12426 cmdline_fixed_string_t flow_type; 12427 cmdline_fixed_string_t inset_field; 12428 cmdline_fixed_string_t select; 12429 }; 12430 12431 static enum rte_eth_input_set_field 12432 str2inset(char *string) 12433 { 12434 uint16_t i; 12435 12436 static const struct { 12437 char str[32]; 12438 enum rte_eth_input_set_field inset; 12439 } inset_table[] = { 12440 {"ethertype", RTE_ETH_INPUT_SET_L2_ETHERTYPE}, 12441 {"ovlan", RTE_ETH_INPUT_SET_L2_OUTER_VLAN}, 12442 {"ivlan", RTE_ETH_INPUT_SET_L2_INNER_VLAN}, 12443 {"src-ipv4", RTE_ETH_INPUT_SET_L3_SRC_IP4}, 12444 {"dst-ipv4", RTE_ETH_INPUT_SET_L3_DST_IP4}, 12445 {"ipv4-tos", RTE_ETH_INPUT_SET_L3_IP4_TOS}, 12446 {"ipv4-proto", RTE_ETH_INPUT_SET_L3_IP4_PROTO}, 12447 {"ipv4-ttl", RTE_ETH_INPUT_SET_L3_IP4_TTL}, 12448 {"src-ipv6", RTE_ETH_INPUT_SET_L3_SRC_IP6}, 12449 {"dst-ipv6", RTE_ETH_INPUT_SET_L3_DST_IP6}, 12450 {"ipv6-tc", RTE_ETH_INPUT_SET_L3_IP6_TC}, 12451 {"ipv6-next-header", RTE_ETH_INPUT_SET_L3_IP6_NEXT_HEADER}, 12452 {"ipv6-hop-limits", RTE_ETH_INPUT_SET_L3_IP6_HOP_LIMITS}, 12453 {"udp-src-port", RTE_ETH_INPUT_SET_L4_UDP_SRC_PORT}, 12454 {"udp-dst-port", RTE_ETH_INPUT_SET_L4_UDP_DST_PORT}, 12455 {"tcp-src-port", RTE_ETH_INPUT_SET_L4_TCP_SRC_PORT}, 12456 {"tcp-dst-port", RTE_ETH_INPUT_SET_L4_TCP_DST_PORT}, 12457 {"sctp-src-port", RTE_ETH_INPUT_SET_L4_SCTP_SRC_PORT}, 12458 {"sctp-dst-port", RTE_ETH_INPUT_SET_L4_SCTP_DST_PORT}, 12459 {"sctp-veri-tag", RTE_ETH_INPUT_SET_L4_SCTP_VERIFICATION_TAG}, 12460 {"udp-key", RTE_ETH_INPUT_SET_TUNNEL_L4_UDP_KEY}, 12461 {"gre-key", RTE_ETH_INPUT_SET_TUNNEL_GRE_KEY}, 12462 {"fld-1st", RTE_ETH_INPUT_SET_FLEX_PAYLOAD_1ST_WORD}, 12463 {"fld-2nd", RTE_ETH_INPUT_SET_FLEX_PAYLOAD_2ND_WORD}, 12464 {"fld-3rd", RTE_ETH_INPUT_SET_FLEX_PAYLOAD_3RD_WORD}, 12465 {"fld-4th", RTE_ETH_INPUT_SET_FLEX_PAYLOAD_4TH_WORD}, 12466 {"fld-5th", RTE_ETH_INPUT_SET_FLEX_PAYLOAD_5TH_WORD}, 12467 {"fld-6th", RTE_ETH_INPUT_SET_FLEX_PAYLOAD_6TH_WORD}, 12468 {"fld-7th", RTE_ETH_INPUT_SET_FLEX_PAYLOAD_7TH_WORD}, 12469 {"fld-8th", RTE_ETH_INPUT_SET_FLEX_PAYLOAD_8TH_WORD}, 12470 {"none", RTE_ETH_INPUT_SET_NONE}, 12471 }; 12472 12473 for (i = 0; i < RTE_DIM(inset_table); i++) { 12474 if (!strcmp(string, inset_table[i].str)) 12475 return inset_table[i].inset; 12476 } 12477 12478 return RTE_ETH_INPUT_SET_UNKNOWN; 12479 } 12480 12481 static void 12482 cmd_set_hash_input_set_parsed(void *parsed_result, 12483 __rte_unused struct cmdline *cl, 12484 __rte_unused void *data) 12485 { 12486 struct cmd_set_hash_input_set_result *res = parsed_result; 12487 struct rte_eth_hash_filter_info info; 12488 12489 memset(&info, 0, sizeof(info)); 12490 info.info_type = RTE_ETH_HASH_FILTER_INPUT_SET_SELECT; 12491 info.info.input_set_conf.flow_type = str2flowtype(res->flow_type); 12492 info.info.input_set_conf.field[0] = str2inset(res->inset_field); 12493 info.info.input_set_conf.inset_size = 1; 12494 if (!strcmp(res->select, "select")) 12495 info.info.input_set_conf.op = RTE_ETH_INPUT_SET_SELECT; 12496 else if (!strcmp(res->select, "add")) 12497 info.info.input_set_conf.op = RTE_ETH_INPUT_SET_ADD; 12498 rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_HASH, 12499 RTE_ETH_FILTER_SET, &info); 12500 } 12501 12502 cmdline_parse_token_string_t cmd_set_hash_input_set_cmd = 12503 TOKEN_STRING_INITIALIZER(struct cmd_set_hash_input_set_result, 12504 set_hash_input_set, "set_hash_input_set"); 12505 cmdline_parse_token_num_t cmd_set_hash_input_set_port_id = 12506 TOKEN_NUM_INITIALIZER(struct cmd_set_hash_input_set_result, 12507 port_id, UINT16); 12508 cmdline_parse_token_string_t cmd_set_hash_input_set_flow_type = 12509 TOKEN_STRING_INITIALIZER(struct cmd_set_hash_input_set_result, 12510 flow_type, NULL); 12511 cmdline_parse_token_string_t cmd_set_hash_input_set_field = 12512 TOKEN_STRING_INITIALIZER(struct cmd_set_hash_input_set_result, 12513 inset_field, 12514 "ovlan#ivlan#src-ipv4#dst-ipv4#src-ipv6#dst-ipv6#" 12515 "ipv4-tos#ipv4-proto#ipv6-tc#ipv6-next-header#udp-src-port#" 12516 "udp-dst-port#tcp-src-port#tcp-dst-port#sctp-src-port#" 12517 "sctp-dst-port#sctp-veri-tag#udp-key#gre-key#fld-1st#" 12518 "fld-2nd#fld-3rd#fld-4th#fld-5th#fld-6th#fld-7th#" 12519 "fld-8th#none"); 12520 cmdline_parse_token_string_t cmd_set_hash_input_set_select = 12521 TOKEN_STRING_INITIALIZER(struct cmd_set_hash_input_set_result, 12522 select, "select#add"); 12523 12524 cmdline_parse_inst_t cmd_set_hash_input_set = { 12525 .f = cmd_set_hash_input_set_parsed, 12526 .data = NULL, 12527 .help_str = "set_hash_input_set <port_id> " 12528 "ipv4-frag|ipv4-tcp|ipv4-udp|ipv4-sctp|ipv4-other|" 12529 "ipv6-frag|ipv6-tcp|ipv6-udp|ipv6-sctp|ipv6-other|l2_payload|<flowtype_id> " 12530 "ovlan|ivlan|src-ipv4|dst-ipv4|src-ipv6|dst-ipv6|ipv4-tos|ipv4-proto|" 12531 "ipv6-tc|ipv6-next-header|udp-src-port|udp-dst-port|tcp-src-port|" 12532 "tcp-dst-port|sctp-src-port|sctp-dst-port|sctp-veri-tag|udp-key|" 12533 "gre-key|fld-1st|fld-2nd|fld-3rd|fld-4th|fld-5th|fld-6th|" 12534 "fld-7th|fld-8th|none select|add", 12535 .tokens = { 12536 (void *)&cmd_set_hash_input_set_cmd, 12537 (void *)&cmd_set_hash_input_set_port_id, 12538 (void *)&cmd_set_hash_input_set_flow_type, 12539 (void *)&cmd_set_hash_input_set_field, 12540 (void *)&cmd_set_hash_input_set_select, 12541 NULL, 12542 }, 12543 }; 12544 12545 /* Set flow director input set */ 12546 struct cmd_set_fdir_input_set_result { 12547 cmdline_fixed_string_t set_fdir_input_set; 12548 portid_t port_id; 12549 cmdline_fixed_string_t flow_type; 12550 cmdline_fixed_string_t inset_field; 12551 cmdline_fixed_string_t select; 12552 }; 12553 12554 static void 12555 cmd_set_fdir_input_set_parsed(void *parsed_result, 12556 __rte_unused struct cmdline *cl, 12557 __rte_unused void *data) 12558 { 12559 struct cmd_set_fdir_input_set_result *res = parsed_result; 12560 struct rte_eth_fdir_filter_info info; 12561 12562 memset(&info, 0, sizeof(info)); 12563 info.info_type = RTE_ETH_FDIR_FILTER_INPUT_SET_SELECT; 12564 info.info.input_set_conf.flow_type = str2flowtype(res->flow_type); 12565 info.info.input_set_conf.field[0] = str2inset(res->inset_field); 12566 info.info.input_set_conf.inset_size = 1; 12567 if (!strcmp(res->select, "select")) 12568 info.info.input_set_conf.op = RTE_ETH_INPUT_SET_SELECT; 12569 else if (!strcmp(res->select, "add")) 12570 info.info.input_set_conf.op = RTE_ETH_INPUT_SET_ADD; 12571 rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_FDIR, 12572 RTE_ETH_FILTER_SET, &info); 12573 } 12574 12575 cmdline_parse_token_string_t cmd_set_fdir_input_set_cmd = 12576 TOKEN_STRING_INITIALIZER(struct cmd_set_fdir_input_set_result, 12577 set_fdir_input_set, "set_fdir_input_set"); 12578 cmdline_parse_token_num_t cmd_set_fdir_input_set_port_id = 12579 TOKEN_NUM_INITIALIZER(struct cmd_set_fdir_input_set_result, 12580 port_id, UINT16); 12581 cmdline_parse_token_string_t cmd_set_fdir_input_set_flow_type = 12582 TOKEN_STRING_INITIALIZER(struct cmd_set_fdir_input_set_result, 12583 flow_type, 12584 "ipv4-frag#ipv4-tcp#ipv4-udp#ipv4-sctp#ipv4-other#" 12585 "ipv6-frag#ipv6-tcp#ipv6-udp#ipv6-sctp#ipv6-other#l2_payload"); 12586 cmdline_parse_token_string_t cmd_set_fdir_input_set_field = 12587 TOKEN_STRING_INITIALIZER(struct cmd_set_fdir_input_set_result, 12588 inset_field, 12589 "ivlan#ethertype#src-ipv4#dst-ipv4#src-ipv6#dst-ipv6#" 12590 "ipv4-tos#ipv4-proto#ipv4-ttl#ipv6-tc#ipv6-next-header#" 12591 "ipv6-hop-limits#udp-src-port#udp-dst-port#" 12592 "tcp-src-port#tcp-dst-port#sctp-src-port#sctp-dst-port#" 12593 "sctp-veri-tag#none"); 12594 cmdline_parse_token_string_t cmd_set_fdir_input_set_select = 12595 TOKEN_STRING_INITIALIZER(struct cmd_set_fdir_input_set_result, 12596 select, "select#add"); 12597 12598 cmdline_parse_inst_t cmd_set_fdir_input_set = { 12599 .f = cmd_set_fdir_input_set_parsed, 12600 .data = NULL, 12601 .help_str = "set_fdir_input_set <port_id> " 12602 "ipv4-frag|ipv4-tcp|ipv4-udp|ipv4-sctp|ipv4-other|" 12603 "ipv6-frag|ipv6-tcp|ipv6-udp|ipv6-sctp|ipv6-other|l2_payload " 12604 "ivlan|ethertype|src-ipv4|dst-ipv4|src-ipv6|dst-ipv6|" 12605 "ipv4-tos|ipv4-proto|ipv4-ttl|ipv6-tc|ipv6-next-header|" 12606 "ipv6-hop-limits|udp-src-port|udp-dst-port|" 12607 "tcp-src-port|tcp-dst-port|sctp-src-port|sctp-dst-port|" 12608 "sctp-veri-tag|none select|add", 12609 .tokens = { 12610 (void *)&cmd_set_fdir_input_set_cmd, 12611 (void *)&cmd_set_fdir_input_set_port_id, 12612 (void *)&cmd_set_fdir_input_set_flow_type, 12613 (void *)&cmd_set_fdir_input_set_field, 12614 (void *)&cmd_set_fdir_input_set_select, 12615 NULL, 12616 }, 12617 }; 12618 12619 /* *** ADD/REMOVE A MULTICAST MAC ADDRESS TO/FROM A PORT *** */ 12620 struct cmd_mcast_addr_result { 12621 cmdline_fixed_string_t mcast_addr_cmd; 12622 cmdline_fixed_string_t what; 12623 uint16_t port_num; 12624 struct rte_ether_addr mc_addr; 12625 }; 12626 12627 static void cmd_mcast_addr_parsed(void *parsed_result, 12628 __attribute__((unused)) struct cmdline *cl, 12629 __attribute__((unused)) void *data) 12630 { 12631 struct cmd_mcast_addr_result *res = parsed_result; 12632 12633 if (!rte_is_multicast_ether_addr(&res->mc_addr)) { 12634 printf("Invalid multicast addr %02X:%02X:%02X:%02X:%02X:%02X\n", 12635 res->mc_addr.addr_bytes[0], res->mc_addr.addr_bytes[1], 12636 res->mc_addr.addr_bytes[2], res->mc_addr.addr_bytes[3], 12637 res->mc_addr.addr_bytes[4], res->mc_addr.addr_bytes[5]); 12638 return; 12639 } 12640 if (strcmp(res->what, "add") == 0) 12641 mcast_addr_add(res->port_num, &res->mc_addr); 12642 else 12643 mcast_addr_remove(res->port_num, &res->mc_addr); 12644 } 12645 12646 cmdline_parse_token_string_t cmd_mcast_addr_cmd = 12647 TOKEN_STRING_INITIALIZER(struct cmd_mcast_addr_result, 12648 mcast_addr_cmd, "mcast_addr"); 12649 cmdline_parse_token_string_t cmd_mcast_addr_what = 12650 TOKEN_STRING_INITIALIZER(struct cmd_mcast_addr_result, what, 12651 "add#remove"); 12652 cmdline_parse_token_num_t cmd_mcast_addr_portnum = 12653 TOKEN_NUM_INITIALIZER(struct cmd_mcast_addr_result, port_num, UINT16); 12654 cmdline_parse_token_etheraddr_t cmd_mcast_addr_addr = 12655 TOKEN_ETHERADDR_INITIALIZER(struct cmd_mac_addr_result, address); 12656 12657 cmdline_parse_inst_t cmd_mcast_addr = { 12658 .f = cmd_mcast_addr_parsed, 12659 .data = (void *)0, 12660 .help_str = "mcast_addr add|remove <port_id> <mcast_addr>: " 12661 "Add/Remove multicast MAC address on port_id", 12662 .tokens = { 12663 (void *)&cmd_mcast_addr_cmd, 12664 (void *)&cmd_mcast_addr_what, 12665 (void *)&cmd_mcast_addr_portnum, 12666 (void *)&cmd_mcast_addr_addr, 12667 NULL, 12668 }, 12669 }; 12670 12671 /* l2 tunnel config 12672 * only support E-tag now. 12673 */ 12674 12675 /* Ether type config */ 12676 struct cmd_config_l2_tunnel_eth_type_result { 12677 cmdline_fixed_string_t port; 12678 cmdline_fixed_string_t config; 12679 cmdline_fixed_string_t all; 12680 portid_t id; 12681 cmdline_fixed_string_t l2_tunnel; 12682 cmdline_fixed_string_t l2_tunnel_type; 12683 cmdline_fixed_string_t eth_type; 12684 uint16_t eth_type_val; 12685 }; 12686 12687 cmdline_parse_token_string_t cmd_config_l2_tunnel_eth_type_port = 12688 TOKEN_STRING_INITIALIZER 12689 (struct cmd_config_l2_tunnel_eth_type_result, 12690 port, "port"); 12691 cmdline_parse_token_string_t cmd_config_l2_tunnel_eth_type_config = 12692 TOKEN_STRING_INITIALIZER 12693 (struct cmd_config_l2_tunnel_eth_type_result, 12694 config, "config"); 12695 cmdline_parse_token_string_t cmd_config_l2_tunnel_eth_type_all_str = 12696 TOKEN_STRING_INITIALIZER 12697 (struct cmd_config_l2_tunnel_eth_type_result, 12698 all, "all"); 12699 cmdline_parse_token_num_t cmd_config_l2_tunnel_eth_type_id = 12700 TOKEN_NUM_INITIALIZER 12701 (struct cmd_config_l2_tunnel_eth_type_result, 12702 id, UINT16); 12703 cmdline_parse_token_string_t cmd_config_l2_tunnel_eth_type_l2_tunnel = 12704 TOKEN_STRING_INITIALIZER 12705 (struct cmd_config_l2_tunnel_eth_type_result, 12706 l2_tunnel, "l2-tunnel"); 12707 cmdline_parse_token_string_t cmd_config_l2_tunnel_eth_type_l2_tunnel_type = 12708 TOKEN_STRING_INITIALIZER 12709 (struct cmd_config_l2_tunnel_eth_type_result, 12710 l2_tunnel_type, "E-tag"); 12711 cmdline_parse_token_string_t cmd_config_l2_tunnel_eth_type_eth_type = 12712 TOKEN_STRING_INITIALIZER 12713 (struct cmd_config_l2_tunnel_eth_type_result, 12714 eth_type, "ether-type"); 12715 cmdline_parse_token_num_t cmd_config_l2_tunnel_eth_type_eth_type_val = 12716 TOKEN_NUM_INITIALIZER 12717 (struct cmd_config_l2_tunnel_eth_type_result, 12718 eth_type_val, UINT16); 12719 12720 static enum rte_eth_tunnel_type 12721 str2fdir_l2_tunnel_type(char *string) 12722 { 12723 uint32_t i = 0; 12724 12725 static const struct { 12726 char str[32]; 12727 enum rte_eth_tunnel_type type; 12728 } l2_tunnel_type_str[] = { 12729 {"E-tag", RTE_L2_TUNNEL_TYPE_E_TAG}, 12730 }; 12731 12732 for (i = 0; i < RTE_DIM(l2_tunnel_type_str); i++) { 12733 if (!strcmp(l2_tunnel_type_str[i].str, string)) 12734 return l2_tunnel_type_str[i].type; 12735 } 12736 return RTE_TUNNEL_TYPE_NONE; 12737 } 12738 12739 /* ether type config for all ports */ 12740 static void 12741 cmd_config_l2_tunnel_eth_type_all_parsed 12742 (void *parsed_result, 12743 __attribute__((unused)) struct cmdline *cl, 12744 __attribute__((unused)) void *data) 12745 { 12746 struct cmd_config_l2_tunnel_eth_type_result *res = parsed_result; 12747 struct rte_eth_l2_tunnel_conf entry; 12748 portid_t pid; 12749 12750 entry.l2_tunnel_type = str2fdir_l2_tunnel_type(res->l2_tunnel_type); 12751 entry.ether_type = res->eth_type_val; 12752 12753 RTE_ETH_FOREACH_DEV(pid) { 12754 rte_eth_dev_l2_tunnel_eth_type_conf(pid, &entry); 12755 } 12756 } 12757 12758 cmdline_parse_inst_t cmd_config_l2_tunnel_eth_type_all = { 12759 .f = cmd_config_l2_tunnel_eth_type_all_parsed, 12760 .data = NULL, 12761 .help_str = "port config all l2-tunnel E-tag ether-type <value>", 12762 .tokens = { 12763 (void *)&cmd_config_l2_tunnel_eth_type_port, 12764 (void *)&cmd_config_l2_tunnel_eth_type_config, 12765 (void *)&cmd_config_l2_tunnel_eth_type_all_str, 12766 (void *)&cmd_config_l2_tunnel_eth_type_l2_tunnel, 12767 (void *)&cmd_config_l2_tunnel_eth_type_l2_tunnel_type, 12768 (void *)&cmd_config_l2_tunnel_eth_type_eth_type, 12769 (void *)&cmd_config_l2_tunnel_eth_type_eth_type_val, 12770 NULL, 12771 }, 12772 }; 12773 12774 /* ether type config for a specific port */ 12775 static void 12776 cmd_config_l2_tunnel_eth_type_specific_parsed( 12777 void *parsed_result, 12778 __attribute__((unused)) struct cmdline *cl, 12779 __attribute__((unused)) void *data) 12780 { 12781 struct cmd_config_l2_tunnel_eth_type_result *res = 12782 parsed_result; 12783 struct rte_eth_l2_tunnel_conf entry; 12784 12785 if (port_id_is_invalid(res->id, ENABLED_WARN)) 12786 return; 12787 12788 entry.l2_tunnel_type = str2fdir_l2_tunnel_type(res->l2_tunnel_type); 12789 entry.ether_type = res->eth_type_val; 12790 12791 rte_eth_dev_l2_tunnel_eth_type_conf(res->id, &entry); 12792 } 12793 12794 cmdline_parse_inst_t cmd_config_l2_tunnel_eth_type_specific = { 12795 .f = cmd_config_l2_tunnel_eth_type_specific_parsed, 12796 .data = NULL, 12797 .help_str = "port config <port_id> l2-tunnel E-tag ether-type <value>", 12798 .tokens = { 12799 (void *)&cmd_config_l2_tunnel_eth_type_port, 12800 (void *)&cmd_config_l2_tunnel_eth_type_config, 12801 (void *)&cmd_config_l2_tunnel_eth_type_id, 12802 (void *)&cmd_config_l2_tunnel_eth_type_l2_tunnel, 12803 (void *)&cmd_config_l2_tunnel_eth_type_l2_tunnel_type, 12804 (void *)&cmd_config_l2_tunnel_eth_type_eth_type, 12805 (void *)&cmd_config_l2_tunnel_eth_type_eth_type_val, 12806 NULL, 12807 }, 12808 }; 12809 12810 /* Enable/disable l2 tunnel */ 12811 struct cmd_config_l2_tunnel_en_dis_result { 12812 cmdline_fixed_string_t port; 12813 cmdline_fixed_string_t config; 12814 cmdline_fixed_string_t all; 12815 portid_t id; 12816 cmdline_fixed_string_t l2_tunnel; 12817 cmdline_fixed_string_t l2_tunnel_type; 12818 cmdline_fixed_string_t en_dis; 12819 }; 12820 12821 cmdline_parse_token_string_t cmd_config_l2_tunnel_en_dis_port = 12822 TOKEN_STRING_INITIALIZER 12823 (struct cmd_config_l2_tunnel_en_dis_result, 12824 port, "port"); 12825 cmdline_parse_token_string_t cmd_config_l2_tunnel_en_dis_config = 12826 TOKEN_STRING_INITIALIZER 12827 (struct cmd_config_l2_tunnel_en_dis_result, 12828 config, "config"); 12829 cmdline_parse_token_string_t cmd_config_l2_tunnel_en_dis_all_str = 12830 TOKEN_STRING_INITIALIZER 12831 (struct cmd_config_l2_tunnel_en_dis_result, 12832 all, "all"); 12833 cmdline_parse_token_num_t cmd_config_l2_tunnel_en_dis_id = 12834 TOKEN_NUM_INITIALIZER 12835 (struct cmd_config_l2_tunnel_en_dis_result, 12836 id, UINT16); 12837 cmdline_parse_token_string_t cmd_config_l2_tunnel_en_dis_l2_tunnel = 12838 TOKEN_STRING_INITIALIZER 12839 (struct cmd_config_l2_tunnel_en_dis_result, 12840 l2_tunnel, "l2-tunnel"); 12841 cmdline_parse_token_string_t cmd_config_l2_tunnel_en_dis_l2_tunnel_type = 12842 TOKEN_STRING_INITIALIZER 12843 (struct cmd_config_l2_tunnel_en_dis_result, 12844 l2_tunnel_type, "E-tag"); 12845 cmdline_parse_token_string_t cmd_config_l2_tunnel_en_dis_en_dis = 12846 TOKEN_STRING_INITIALIZER 12847 (struct cmd_config_l2_tunnel_en_dis_result, 12848 en_dis, "enable#disable"); 12849 12850 /* enable/disable l2 tunnel for all ports */ 12851 static void 12852 cmd_config_l2_tunnel_en_dis_all_parsed( 12853 void *parsed_result, 12854 __attribute__((unused)) struct cmdline *cl, 12855 __attribute__((unused)) void *data) 12856 { 12857 struct cmd_config_l2_tunnel_en_dis_result *res = parsed_result; 12858 struct rte_eth_l2_tunnel_conf entry; 12859 portid_t pid; 12860 uint8_t en; 12861 12862 entry.l2_tunnel_type = str2fdir_l2_tunnel_type(res->l2_tunnel_type); 12863 12864 if (!strcmp("enable", res->en_dis)) 12865 en = 1; 12866 else 12867 en = 0; 12868 12869 RTE_ETH_FOREACH_DEV(pid) { 12870 rte_eth_dev_l2_tunnel_offload_set(pid, 12871 &entry, 12872 ETH_L2_TUNNEL_ENABLE_MASK, 12873 en); 12874 } 12875 } 12876 12877 cmdline_parse_inst_t cmd_config_l2_tunnel_en_dis_all = { 12878 .f = cmd_config_l2_tunnel_en_dis_all_parsed, 12879 .data = NULL, 12880 .help_str = "port config all l2-tunnel E-tag enable|disable", 12881 .tokens = { 12882 (void *)&cmd_config_l2_tunnel_en_dis_port, 12883 (void *)&cmd_config_l2_tunnel_en_dis_config, 12884 (void *)&cmd_config_l2_tunnel_en_dis_all_str, 12885 (void *)&cmd_config_l2_tunnel_en_dis_l2_tunnel, 12886 (void *)&cmd_config_l2_tunnel_en_dis_l2_tunnel_type, 12887 (void *)&cmd_config_l2_tunnel_en_dis_en_dis, 12888 NULL, 12889 }, 12890 }; 12891 12892 /* enable/disable l2 tunnel for a port */ 12893 static void 12894 cmd_config_l2_tunnel_en_dis_specific_parsed( 12895 void *parsed_result, 12896 __attribute__((unused)) struct cmdline *cl, 12897 __attribute__((unused)) void *data) 12898 { 12899 struct cmd_config_l2_tunnel_en_dis_result *res = 12900 parsed_result; 12901 struct rte_eth_l2_tunnel_conf entry; 12902 12903 if (port_id_is_invalid(res->id, ENABLED_WARN)) 12904 return; 12905 12906 entry.l2_tunnel_type = str2fdir_l2_tunnel_type(res->l2_tunnel_type); 12907 12908 if (!strcmp("enable", res->en_dis)) 12909 rte_eth_dev_l2_tunnel_offload_set(res->id, 12910 &entry, 12911 ETH_L2_TUNNEL_ENABLE_MASK, 12912 1); 12913 else 12914 rte_eth_dev_l2_tunnel_offload_set(res->id, 12915 &entry, 12916 ETH_L2_TUNNEL_ENABLE_MASK, 12917 0); 12918 } 12919 12920 cmdline_parse_inst_t cmd_config_l2_tunnel_en_dis_specific = { 12921 .f = cmd_config_l2_tunnel_en_dis_specific_parsed, 12922 .data = NULL, 12923 .help_str = "port config <port_id> l2-tunnel E-tag enable|disable", 12924 .tokens = { 12925 (void *)&cmd_config_l2_tunnel_en_dis_port, 12926 (void *)&cmd_config_l2_tunnel_en_dis_config, 12927 (void *)&cmd_config_l2_tunnel_en_dis_id, 12928 (void *)&cmd_config_l2_tunnel_en_dis_l2_tunnel, 12929 (void *)&cmd_config_l2_tunnel_en_dis_l2_tunnel_type, 12930 (void *)&cmd_config_l2_tunnel_en_dis_en_dis, 12931 NULL, 12932 }, 12933 }; 12934 12935 /* E-tag configuration */ 12936 12937 /* Common result structure for all E-tag configuration */ 12938 struct cmd_config_e_tag_result { 12939 cmdline_fixed_string_t e_tag; 12940 cmdline_fixed_string_t set; 12941 cmdline_fixed_string_t insertion; 12942 cmdline_fixed_string_t stripping; 12943 cmdline_fixed_string_t forwarding; 12944 cmdline_fixed_string_t filter; 12945 cmdline_fixed_string_t add; 12946 cmdline_fixed_string_t del; 12947 cmdline_fixed_string_t on; 12948 cmdline_fixed_string_t off; 12949 cmdline_fixed_string_t on_off; 12950 cmdline_fixed_string_t port_tag_id; 12951 uint32_t port_tag_id_val; 12952 cmdline_fixed_string_t e_tag_id; 12953 uint16_t e_tag_id_val; 12954 cmdline_fixed_string_t dst_pool; 12955 uint8_t dst_pool_val; 12956 cmdline_fixed_string_t port; 12957 portid_t port_id; 12958 cmdline_fixed_string_t vf; 12959 uint8_t vf_id; 12960 }; 12961 12962 /* Common CLI fields for all E-tag configuration */ 12963 cmdline_parse_token_string_t cmd_config_e_tag_e_tag = 12964 TOKEN_STRING_INITIALIZER 12965 (struct cmd_config_e_tag_result, 12966 e_tag, "E-tag"); 12967 cmdline_parse_token_string_t cmd_config_e_tag_set = 12968 TOKEN_STRING_INITIALIZER 12969 (struct cmd_config_e_tag_result, 12970 set, "set"); 12971 cmdline_parse_token_string_t cmd_config_e_tag_insertion = 12972 TOKEN_STRING_INITIALIZER 12973 (struct cmd_config_e_tag_result, 12974 insertion, "insertion"); 12975 cmdline_parse_token_string_t cmd_config_e_tag_stripping = 12976 TOKEN_STRING_INITIALIZER 12977 (struct cmd_config_e_tag_result, 12978 stripping, "stripping"); 12979 cmdline_parse_token_string_t cmd_config_e_tag_forwarding = 12980 TOKEN_STRING_INITIALIZER 12981 (struct cmd_config_e_tag_result, 12982 forwarding, "forwarding"); 12983 cmdline_parse_token_string_t cmd_config_e_tag_filter = 12984 TOKEN_STRING_INITIALIZER 12985 (struct cmd_config_e_tag_result, 12986 filter, "filter"); 12987 cmdline_parse_token_string_t cmd_config_e_tag_add = 12988 TOKEN_STRING_INITIALIZER 12989 (struct cmd_config_e_tag_result, 12990 add, "add"); 12991 cmdline_parse_token_string_t cmd_config_e_tag_del = 12992 TOKEN_STRING_INITIALIZER 12993 (struct cmd_config_e_tag_result, 12994 del, "del"); 12995 cmdline_parse_token_string_t cmd_config_e_tag_on = 12996 TOKEN_STRING_INITIALIZER 12997 (struct cmd_config_e_tag_result, 12998 on, "on"); 12999 cmdline_parse_token_string_t cmd_config_e_tag_off = 13000 TOKEN_STRING_INITIALIZER 13001 (struct cmd_config_e_tag_result, 13002 off, "off"); 13003 cmdline_parse_token_string_t cmd_config_e_tag_on_off = 13004 TOKEN_STRING_INITIALIZER 13005 (struct cmd_config_e_tag_result, 13006 on_off, "on#off"); 13007 cmdline_parse_token_string_t cmd_config_e_tag_port_tag_id = 13008 TOKEN_STRING_INITIALIZER 13009 (struct cmd_config_e_tag_result, 13010 port_tag_id, "port-tag-id"); 13011 cmdline_parse_token_num_t cmd_config_e_tag_port_tag_id_val = 13012 TOKEN_NUM_INITIALIZER 13013 (struct cmd_config_e_tag_result, 13014 port_tag_id_val, UINT32); 13015 cmdline_parse_token_string_t cmd_config_e_tag_e_tag_id = 13016 TOKEN_STRING_INITIALIZER 13017 (struct cmd_config_e_tag_result, 13018 e_tag_id, "e-tag-id"); 13019 cmdline_parse_token_num_t cmd_config_e_tag_e_tag_id_val = 13020 TOKEN_NUM_INITIALIZER 13021 (struct cmd_config_e_tag_result, 13022 e_tag_id_val, UINT16); 13023 cmdline_parse_token_string_t cmd_config_e_tag_dst_pool = 13024 TOKEN_STRING_INITIALIZER 13025 (struct cmd_config_e_tag_result, 13026 dst_pool, "dst-pool"); 13027 cmdline_parse_token_num_t cmd_config_e_tag_dst_pool_val = 13028 TOKEN_NUM_INITIALIZER 13029 (struct cmd_config_e_tag_result, 13030 dst_pool_val, UINT8); 13031 cmdline_parse_token_string_t cmd_config_e_tag_port = 13032 TOKEN_STRING_INITIALIZER 13033 (struct cmd_config_e_tag_result, 13034 port, "port"); 13035 cmdline_parse_token_num_t cmd_config_e_tag_port_id = 13036 TOKEN_NUM_INITIALIZER 13037 (struct cmd_config_e_tag_result, 13038 port_id, UINT16); 13039 cmdline_parse_token_string_t cmd_config_e_tag_vf = 13040 TOKEN_STRING_INITIALIZER 13041 (struct cmd_config_e_tag_result, 13042 vf, "vf"); 13043 cmdline_parse_token_num_t cmd_config_e_tag_vf_id = 13044 TOKEN_NUM_INITIALIZER 13045 (struct cmd_config_e_tag_result, 13046 vf_id, UINT8); 13047 13048 /* E-tag insertion configuration */ 13049 static void 13050 cmd_config_e_tag_insertion_en_parsed( 13051 void *parsed_result, 13052 __attribute__((unused)) struct cmdline *cl, 13053 __attribute__((unused)) void *data) 13054 { 13055 struct cmd_config_e_tag_result *res = 13056 parsed_result; 13057 struct rte_eth_l2_tunnel_conf entry; 13058 13059 if (port_id_is_invalid(res->port_id, ENABLED_WARN)) 13060 return; 13061 13062 entry.l2_tunnel_type = RTE_L2_TUNNEL_TYPE_E_TAG; 13063 entry.tunnel_id = res->port_tag_id_val; 13064 entry.vf_id = res->vf_id; 13065 rte_eth_dev_l2_tunnel_offload_set(res->port_id, 13066 &entry, 13067 ETH_L2_TUNNEL_INSERTION_MASK, 13068 1); 13069 } 13070 13071 static void 13072 cmd_config_e_tag_insertion_dis_parsed( 13073 void *parsed_result, 13074 __attribute__((unused)) struct cmdline *cl, 13075 __attribute__((unused)) void *data) 13076 { 13077 struct cmd_config_e_tag_result *res = 13078 parsed_result; 13079 struct rte_eth_l2_tunnel_conf entry; 13080 13081 if (port_id_is_invalid(res->port_id, ENABLED_WARN)) 13082 return; 13083 13084 entry.l2_tunnel_type = RTE_L2_TUNNEL_TYPE_E_TAG; 13085 entry.vf_id = res->vf_id; 13086 13087 rte_eth_dev_l2_tunnel_offload_set(res->port_id, 13088 &entry, 13089 ETH_L2_TUNNEL_INSERTION_MASK, 13090 0); 13091 } 13092 13093 cmdline_parse_inst_t cmd_config_e_tag_insertion_en = { 13094 .f = cmd_config_e_tag_insertion_en_parsed, 13095 .data = NULL, 13096 .help_str = "E-tag ... : E-tag insertion enable", 13097 .tokens = { 13098 (void *)&cmd_config_e_tag_e_tag, 13099 (void *)&cmd_config_e_tag_set, 13100 (void *)&cmd_config_e_tag_insertion, 13101 (void *)&cmd_config_e_tag_on, 13102 (void *)&cmd_config_e_tag_port_tag_id, 13103 (void *)&cmd_config_e_tag_port_tag_id_val, 13104 (void *)&cmd_config_e_tag_port, 13105 (void *)&cmd_config_e_tag_port_id, 13106 (void *)&cmd_config_e_tag_vf, 13107 (void *)&cmd_config_e_tag_vf_id, 13108 NULL, 13109 }, 13110 }; 13111 13112 cmdline_parse_inst_t cmd_config_e_tag_insertion_dis = { 13113 .f = cmd_config_e_tag_insertion_dis_parsed, 13114 .data = NULL, 13115 .help_str = "E-tag ... : E-tag insertion disable", 13116 .tokens = { 13117 (void *)&cmd_config_e_tag_e_tag, 13118 (void *)&cmd_config_e_tag_set, 13119 (void *)&cmd_config_e_tag_insertion, 13120 (void *)&cmd_config_e_tag_off, 13121 (void *)&cmd_config_e_tag_port, 13122 (void *)&cmd_config_e_tag_port_id, 13123 (void *)&cmd_config_e_tag_vf, 13124 (void *)&cmd_config_e_tag_vf_id, 13125 NULL, 13126 }, 13127 }; 13128 13129 /* E-tag stripping configuration */ 13130 static void 13131 cmd_config_e_tag_stripping_parsed( 13132 void *parsed_result, 13133 __attribute__((unused)) struct cmdline *cl, 13134 __attribute__((unused)) void *data) 13135 { 13136 struct cmd_config_e_tag_result *res = 13137 parsed_result; 13138 struct rte_eth_l2_tunnel_conf entry; 13139 13140 if (port_id_is_invalid(res->port_id, ENABLED_WARN)) 13141 return; 13142 13143 entry.l2_tunnel_type = RTE_L2_TUNNEL_TYPE_E_TAG; 13144 13145 if (!strcmp(res->on_off, "on")) 13146 rte_eth_dev_l2_tunnel_offload_set 13147 (res->port_id, 13148 &entry, 13149 ETH_L2_TUNNEL_STRIPPING_MASK, 13150 1); 13151 else 13152 rte_eth_dev_l2_tunnel_offload_set 13153 (res->port_id, 13154 &entry, 13155 ETH_L2_TUNNEL_STRIPPING_MASK, 13156 0); 13157 } 13158 13159 cmdline_parse_inst_t cmd_config_e_tag_stripping_en_dis = { 13160 .f = cmd_config_e_tag_stripping_parsed, 13161 .data = NULL, 13162 .help_str = "E-tag ... : E-tag stripping enable/disable", 13163 .tokens = { 13164 (void *)&cmd_config_e_tag_e_tag, 13165 (void *)&cmd_config_e_tag_set, 13166 (void *)&cmd_config_e_tag_stripping, 13167 (void *)&cmd_config_e_tag_on_off, 13168 (void *)&cmd_config_e_tag_port, 13169 (void *)&cmd_config_e_tag_port_id, 13170 NULL, 13171 }, 13172 }; 13173 13174 /* E-tag forwarding configuration */ 13175 static void 13176 cmd_config_e_tag_forwarding_parsed( 13177 void *parsed_result, 13178 __attribute__((unused)) struct cmdline *cl, 13179 __attribute__((unused)) void *data) 13180 { 13181 struct cmd_config_e_tag_result *res = parsed_result; 13182 struct rte_eth_l2_tunnel_conf entry; 13183 13184 if (port_id_is_invalid(res->port_id, ENABLED_WARN)) 13185 return; 13186 13187 entry.l2_tunnel_type = RTE_L2_TUNNEL_TYPE_E_TAG; 13188 13189 if (!strcmp(res->on_off, "on")) 13190 rte_eth_dev_l2_tunnel_offload_set 13191 (res->port_id, 13192 &entry, 13193 ETH_L2_TUNNEL_FORWARDING_MASK, 13194 1); 13195 else 13196 rte_eth_dev_l2_tunnel_offload_set 13197 (res->port_id, 13198 &entry, 13199 ETH_L2_TUNNEL_FORWARDING_MASK, 13200 0); 13201 } 13202 13203 cmdline_parse_inst_t cmd_config_e_tag_forwarding_en_dis = { 13204 .f = cmd_config_e_tag_forwarding_parsed, 13205 .data = NULL, 13206 .help_str = "E-tag ... : E-tag forwarding enable/disable", 13207 .tokens = { 13208 (void *)&cmd_config_e_tag_e_tag, 13209 (void *)&cmd_config_e_tag_set, 13210 (void *)&cmd_config_e_tag_forwarding, 13211 (void *)&cmd_config_e_tag_on_off, 13212 (void *)&cmd_config_e_tag_port, 13213 (void *)&cmd_config_e_tag_port_id, 13214 NULL, 13215 }, 13216 }; 13217 13218 /* E-tag filter configuration */ 13219 static void 13220 cmd_config_e_tag_filter_add_parsed( 13221 void *parsed_result, 13222 __attribute__((unused)) struct cmdline *cl, 13223 __attribute__((unused)) void *data) 13224 { 13225 struct cmd_config_e_tag_result *res = parsed_result; 13226 struct rte_eth_l2_tunnel_conf entry; 13227 int ret = 0; 13228 13229 if (port_id_is_invalid(res->port_id, ENABLED_WARN)) 13230 return; 13231 13232 if (res->e_tag_id_val > 0x3fff) { 13233 printf("e-tag-id must be equal or less than 0x3fff.\n"); 13234 return; 13235 } 13236 13237 ret = rte_eth_dev_filter_supported(res->port_id, 13238 RTE_ETH_FILTER_L2_TUNNEL); 13239 if (ret < 0) { 13240 printf("E-tag filter is not supported on port %u.\n", 13241 res->port_id); 13242 return; 13243 } 13244 13245 entry.l2_tunnel_type = RTE_L2_TUNNEL_TYPE_E_TAG; 13246 entry.tunnel_id = res->e_tag_id_val; 13247 entry.pool = res->dst_pool_val; 13248 13249 ret = rte_eth_dev_filter_ctrl(res->port_id, 13250 RTE_ETH_FILTER_L2_TUNNEL, 13251 RTE_ETH_FILTER_ADD, 13252 &entry); 13253 if (ret < 0) 13254 printf("E-tag filter programming error: (%s)\n", 13255 strerror(-ret)); 13256 } 13257 13258 cmdline_parse_inst_t cmd_config_e_tag_filter_add = { 13259 .f = cmd_config_e_tag_filter_add_parsed, 13260 .data = NULL, 13261 .help_str = "E-tag ... : E-tag filter add", 13262 .tokens = { 13263 (void *)&cmd_config_e_tag_e_tag, 13264 (void *)&cmd_config_e_tag_set, 13265 (void *)&cmd_config_e_tag_filter, 13266 (void *)&cmd_config_e_tag_add, 13267 (void *)&cmd_config_e_tag_e_tag_id, 13268 (void *)&cmd_config_e_tag_e_tag_id_val, 13269 (void *)&cmd_config_e_tag_dst_pool, 13270 (void *)&cmd_config_e_tag_dst_pool_val, 13271 (void *)&cmd_config_e_tag_port, 13272 (void *)&cmd_config_e_tag_port_id, 13273 NULL, 13274 }, 13275 }; 13276 13277 static void 13278 cmd_config_e_tag_filter_del_parsed( 13279 void *parsed_result, 13280 __attribute__((unused)) struct cmdline *cl, 13281 __attribute__((unused)) void *data) 13282 { 13283 struct cmd_config_e_tag_result *res = parsed_result; 13284 struct rte_eth_l2_tunnel_conf entry; 13285 int ret = 0; 13286 13287 if (port_id_is_invalid(res->port_id, ENABLED_WARN)) 13288 return; 13289 13290 if (res->e_tag_id_val > 0x3fff) { 13291 printf("e-tag-id must be less than 0x3fff.\n"); 13292 return; 13293 } 13294 13295 ret = rte_eth_dev_filter_supported(res->port_id, 13296 RTE_ETH_FILTER_L2_TUNNEL); 13297 if (ret < 0) { 13298 printf("E-tag filter is not supported on port %u.\n", 13299 res->port_id); 13300 return; 13301 } 13302 13303 entry.l2_tunnel_type = RTE_L2_TUNNEL_TYPE_E_TAG; 13304 entry.tunnel_id = res->e_tag_id_val; 13305 13306 ret = rte_eth_dev_filter_ctrl(res->port_id, 13307 RTE_ETH_FILTER_L2_TUNNEL, 13308 RTE_ETH_FILTER_DELETE, 13309 &entry); 13310 if (ret < 0) 13311 printf("E-tag filter programming error: (%s)\n", 13312 strerror(-ret)); 13313 } 13314 13315 cmdline_parse_inst_t cmd_config_e_tag_filter_del = { 13316 .f = cmd_config_e_tag_filter_del_parsed, 13317 .data = NULL, 13318 .help_str = "E-tag ... : E-tag filter delete", 13319 .tokens = { 13320 (void *)&cmd_config_e_tag_e_tag, 13321 (void *)&cmd_config_e_tag_set, 13322 (void *)&cmd_config_e_tag_filter, 13323 (void *)&cmd_config_e_tag_del, 13324 (void *)&cmd_config_e_tag_e_tag_id, 13325 (void *)&cmd_config_e_tag_e_tag_id_val, 13326 (void *)&cmd_config_e_tag_port, 13327 (void *)&cmd_config_e_tag_port_id, 13328 NULL, 13329 }, 13330 }; 13331 13332 /* vf vlan anti spoof configuration */ 13333 13334 /* Common result structure for vf vlan anti spoof */ 13335 struct cmd_vf_vlan_anti_spoof_result { 13336 cmdline_fixed_string_t set; 13337 cmdline_fixed_string_t vf; 13338 cmdline_fixed_string_t vlan; 13339 cmdline_fixed_string_t antispoof; 13340 portid_t port_id; 13341 uint32_t vf_id; 13342 cmdline_fixed_string_t on_off; 13343 }; 13344 13345 /* Common CLI fields for vf vlan anti spoof enable disable */ 13346 cmdline_parse_token_string_t cmd_vf_vlan_anti_spoof_set = 13347 TOKEN_STRING_INITIALIZER 13348 (struct cmd_vf_vlan_anti_spoof_result, 13349 set, "set"); 13350 cmdline_parse_token_string_t cmd_vf_vlan_anti_spoof_vf = 13351 TOKEN_STRING_INITIALIZER 13352 (struct cmd_vf_vlan_anti_spoof_result, 13353 vf, "vf"); 13354 cmdline_parse_token_string_t cmd_vf_vlan_anti_spoof_vlan = 13355 TOKEN_STRING_INITIALIZER 13356 (struct cmd_vf_vlan_anti_spoof_result, 13357 vlan, "vlan"); 13358 cmdline_parse_token_string_t cmd_vf_vlan_anti_spoof_antispoof = 13359 TOKEN_STRING_INITIALIZER 13360 (struct cmd_vf_vlan_anti_spoof_result, 13361 antispoof, "antispoof"); 13362 cmdline_parse_token_num_t cmd_vf_vlan_anti_spoof_port_id = 13363 TOKEN_NUM_INITIALIZER 13364 (struct cmd_vf_vlan_anti_spoof_result, 13365 port_id, UINT16); 13366 cmdline_parse_token_num_t cmd_vf_vlan_anti_spoof_vf_id = 13367 TOKEN_NUM_INITIALIZER 13368 (struct cmd_vf_vlan_anti_spoof_result, 13369 vf_id, UINT32); 13370 cmdline_parse_token_string_t cmd_vf_vlan_anti_spoof_on_off = 13371 TOKEN_STRING_INITIALIZER 13372 (struct cmd_vf_vlan_anti_spoof_result, 13373 on_off, "on#off"); 13374 13375 static void 13376 cmd_set_vf_vlan_anti_spoof_parsed( 13377 void *parsed_result, 13378 __attribute__((unused)) struct cmdline *cl, 13379 __attribute__((unused)) void *data) 13380 { 13381 struct cmd_vf_vlan_anti_spoof_result *res = parsed_result; 13382 int ret = -ENOTSUP; 13383 13384 __rte_unused int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0; 13385 13386 if (port_id_is_invalid(res->port_id, ENABLED_WARN)) 13387 return; 13388 13389 #ifdef RTE_LIBRTE_IXGBE_PMD 13390 if (ret == -ENOTSUP) 13391 ret = rte_pmd_ixgbe_set_vf_vlan_anti_spoof(res->port_id, 13392 res->vf_id, is_on); 13393 #endif 13394 #ifdef RTE_LIBRTE_I40E_PMD 13395 if (ret == -ENOTSUP) 13396 ret = rte_pmd_i40e_set_vf_vlan_anti_spoof(res->port_id, 13397 res->vf_id, is_on); 13398 #endif 13399 #ifdef RTE_LIBRTE_BNXT_PMD 13400 if (ret == -ENOTSUP) 13401 ret = rte_pmd_bnxt_set_vf_vlan_anti_spoof(res->port_id, 13402 res->vf_id, is_on); 13403 #endif 13404 13405 switch (ret) { 13406 case 0: 13407 break; 13408 case -EINVAL: 13409 printf("invalid vf_id %d\n", res->vf_id); 13410 break; 13411 case -ENODEV: 13412 printf("invalid port_id %d\n", res->port_id); 13413 break; 13414 case -ENOTSUP: 13415 printf("function not implemented\n"); 13416 break; 13417 default: 13418 printf("programming error: (%s)\n", strerror(-ret)); 13419 } 13420 } 13421 13422 cmdline_parse_inst_t cmd_set_vf_vlan_anti_spoof = { 13423 .f = cmd_set_vf_vlan_anti_spoof_parsed, 13424 .data = NULL, 13425 .help_str = "set vf vlan antispoof <port_id> <vf_id> on|off", 13426 .tokens = { 13427 (void *)&cmd_vf_vlan_anti_spoof_set, 13428 (void *)&cmd_vf_vlan_anti_spoof_vf, 13429 (void *)&cmd_vf_vlan_anti_spoof_vlan, 13430 (void *)&cmd_vf_vlan_anti_spoof_antispoof, 13431 (void *)&cmd_vf_vlan_anti_spoof_port_id, 13432 (void *)&cmd_vf_vlan_anti_spoof_vf_id, 13433 (void *)&cmd_vf_vlan_anti_spoof_on_off, 13434 NULL, 13435 }, 13436 }; 13437 13438 /* vf mac anti spoof configuration */ 13439 13440 /* Common result structure for vf mac anti spoof */ 13441 struct cmd_vf_mac_anti_spoof_result { 13442 cmdline_fixed_string_t set; 13443 cmdline_fixed_string_t vf; 13444 cmdline_fixed_string_t mac; 13445 cmdline_fixed_string_t antispoof; 13446 portid_t port_id; 13447 uint32_t vf_id; 13448 cmdline_fixed_string_t on_off; 13449 }; 13450 13451 /* Common CLI fields for vf mac anti spoof enable disable */ 13452 cmdline_parse_token_string_t cmd_vf_mac_anti_spoof_set = 13453 TOKEN_STRING_INITIALIZER 13454 (struct cmd_vf_mac_anti_spoof_result, 13455 set, "set"); 13456 cmdline_parse_token_string_t cmd_vf_mac_anti_spoof_vf = 13457 TOKEN_STRING_INITIALIZER 13458 (struct cmd_vf_mac_anti_spoof_result, 13459 vf, "vf"); 13460 cmdline_parse_token_string_t cmd_vf_mac_anti_spoof_mac = 13461 TOKEN_STRING_INITIALIZER 13462 (struct cmd_vf_mac_anti_spoof_result, 13463 mac, "mac"); 13464 cmdline_parse_token_string_t cmd_vf_mac_anti_spoof_antispoof = 13465 TOKEN_STRING_INITIALIZER 13466 (struct cmd_vf_mac_anti_spoof_result, 13467 antispoof, "antispoof"); 13468 cmdline_parse_token_num_t cmd_vf_mac_anti_spoof_port_id = 13469 TOKEN_NUM_INITIALIZER 13470 (struct cmd_vf_mac_anti_spoof_result, 13471 port_id, UINT16); 13472 cmdline_parse_token_num_t cmd_vf_mac_anti_spoof_vf_id = 13473 TOKEN_NUM_INITIALIZER 13474 (struct cmd_vf_mac_anti_spoof_result, 13475 vf_id, UINT32); 13476 cmdline_parse_token_string_t cmd_vf_mac_anti_spoof_on_off = 13477 TOKEN_STRING_INITIALIZER 13478 (struct cmd_vf_mac_anti_spoof_result, 13479 on_off, "on#off"); 13480 13481 static void 13482 cmd_set_vf_mac_anti_spoof_parsed( 13483 void *parsed_result, 13484 __attribute__((unused)) struct cmdline *cl, 13485 __attribute__((unused)) void *data) 13486 { 13487 struct cmd_vf_mac_anti_spoof_result *res = parsed_result; 13488 int ret = -ENOTSUP; 13489 13490 __rte_unused int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0; 13491 13492 if (port_id_is_invalid(res->port_id, ENABLED_WARN)) 13493 return; 13494 13495 #ifdef RTE_LIBRTE_IXGBE_PMD 13496 if (ret == -ENOTSUP) 13497 ret = rte_pmd_ixgbe_set_vf_mac_anti_spoof(res->port_id, 13498 res->vf_id, is_on); 13499 #endif 13500 #ifdef RTE_LIBRTE_I40E_PMD 13501 if (ret == -ENOTSUP) 13502 ret = rte_pmd_i40e_set_vf_mac_anti_spoof(res->port_id, 13503 res->vf_id, is_on); 13504 #endif 13505 #ifdef RTE_LIBRTE_BNXT_PMD 13506 if (ret == -ENOTSUP) 13507 ret = rte_pmd_bnxt_set_vf_mac_anti_spoof(res->port_id, 13508 res->vf_id, is_on); 13509 #endif 13510 13511 switch (ret) { 13512 case 0: 13513 break; 13514 case -EINVAL: 13515 printf("invalid vf_id %d or is_on %d\n", res->vf_id, is_on); 13516 break; 13517 case -ENODEV: 13518 printf("invalid port_id %d\n", res->port_id); 13519 break; 13520 case -ENOTSUP: 13521 printf("function not implemented\n"); 13522 break; 13523 default: 13524 printf("programming error: (%s)\n", strerror(-ret)); 13525 } 13526 } 13527 13528 cmdline_parse_inst_t cmd_set_vf_mac_anti_spoof = { 13529 .f = cmd_set_vf_mac_anti_spoof_parsed, 13530 .data = NULL, 13531 .help_str = "set vf mac antispoof <port_id> <vf_id> on|off", 13532 .tokens = { 13533 (void *)&cmd_vf_mac_anti_spoof_set, 13534 (void *)&cmd_vf_mac_anti_spoof_vf, 13535 (void *)&cmd_vf_mac_anti_spoof_mac, 13536 (void *)&cmd_vf_mac_anti_spoof_antispoof, 13537 (void *)&cmd_vf_mac_anti_spoof_port_id, 13538 (void *)&cmd_vf_mac_anti_spoof_vf_id, 13539 (void *)&cmd_vf_mac_anti_spoof_on_off, 13540 NULL, 13541 }, 13542 }; 13543 13544 /* vf vlan strip queue configuration */ 13545 13546 /* Common result structure for vf mac anti spoof */ 13547 struct cmd_vf_vlan_stripq_result { 13548 cmdline_fixed_string_t set; 13549 cmdline_fixed_string_t vf; 13550 cmdline_fixed_string_t vlan; 13551 cmdline_fixed_string_t stripq; 13552 portid_t port_id; 13553 uint16_t vf_id; 13554 cmdline_fixed_string_t on_off; 13555 }; 13556 13557 /* Common CLI fields for vf vlan strip enable disable */ 13558 cmdline_parse_token_string_t cmd_vf_vlan_stripq_set = 13559 TOKEN_STRING_INITIALIZER 13560 (struct cmd_vf_vlan_stripq_result, 13561 set, "set"); 13562 cmdline_parse_token_string_t cmd_vf_vlan_stripq_vf = 13563 TOKEN_STRING_INITIALIZER 13564 (struct cmd_vf_vlan_stripq_result, 13565 vf, "vf"); 13566 cmdline_parse_token_string_t cmd_vf_vlan_stripq_vlan = 13567 TOKEN_STRING_INITIALIZER 13568 (struct cmd_vf_vlan_stripq_result, 13569 vlan, "vlan"); 13570 cmdline_parse_token_string_t cmd_vf_vlan_stripq_stripq = 13571 TOKEN_STRING_INITIALIZER 13572 (struct cmd_vf_vlan_stripq_result, 13573 stripq, "stripq"); 13574 cmdline_parse_token_num_t cmd_vf_vlan_stripq_port_id = 13575 TOKEN_NUM_INITIALIZER 13576 (struct cmd_vf_vlan_stripq_result, 13577 port_id, UINT16); 13578 cmdline_parse_token_num_t cmd_vf_vlan_stripq_vf_id = 13579 TOKEN_NUM_INITIALIZER 13580 (struct cmd_vf_vlan_stripq_result, 13581 vf_id, UINT16); 13582 cmdline_parse_token_string_t cmd_vf_vlan_stripq_on_off = 13583 TOKEN_STRING_INITIALIZER 13584 (struct cmd_vf_vlan_stripq_result, 13585 on_off, "on#off"); 13586 13587 static void 13588 cmd_set_vf_vlan_stripq_parsed( 13589 void *parsed_result, 13590 __attribute__((unused)) struct cmdline *cl, 13591 __attribute__((unused)) void *data) 13592 { 13593 struct cmd_vf_vlan_stripq_result *res = parsed_result; 13594 int ret = -ENOTSUP; 13595 13596 __rte_unused int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0; 13597 13598 if (port_id_is_invalid(res->port_id, ENABLED_WARN)) 13599 return; 13600 13601 #ifdef RTE_LIBRTE_IXGBE_PMD 13602 if (ret == -ENOTSUP) 13603 ret = rte_pmd_ixgbe_set_vf_vlan_stripq(res->port_id, 13604 res->vf_id, is_on); 13605 #endif 13606 #ifdef RTE_LIBRTE_I40E_PMD 13607 if (ret == -ENOTSUP) 13608 ret = rte_pmd_i40e_set_vf_vlan_stripq(res->port_id, 13609 res->vf_id, is_on); 13610 #endif 13611 #ifdef RTE_LIBRTE_BNXT_PMD 13612 if (ret == -ENOTSUP) 13613 ret = rte_pmd_bnxt_set_vf_vlan_stripq(res->port_id, 13614 res->vf_id, is_on); 13615 #endif 13616 13617 switch (ret) { 13618 case 0: 13619 break; 13620 case -EINVAL: 13621 printf("invalid vf_id %d or is_on %d\n", res->vf_id, is_on); 13622 break; 13623 case -ENODEV: 13624 printf("invalid port_id %d\n", res->port_id); 13625 break; 13626 case -ENOTSUP: 13627 printf("function not implemented\n"); 13628 break; 13629 default: 13630 printf("programming error: (%s)\n", strerror(-ret)); 13631 } 13632 } 13633 13634 cmdline_parse_inst_t cmd_set_vf_vlan_stripq = { 13635 .f = cmd_set_vf_vlan_stripq_parsed, 13636 .data = NULL, 13637 .help_str = "set vf vlan stripq <port_id> <vf_id> on|off", 13638 .tokens = { 13639 (void *)&cmd_vf_vlan_stripq_set, 13640 (void *)&cmd_vf_vlan_stripq_vf, 13641 (void *)&cmd_vf_vlan_stripq_vlan, 13642 (void *)&cmd_vf_vlan_stripq_stripq, 13643 (void *)&cmd_vf_vlan_stripq_port_id, 13644 (void *)&cmd_vf_vlan_stripq_vf_id, 13645 (void *)&cmd_vf_vlan_stripq_on_off, 13646 NULL, 13647 }, 13648 }; 13649 13650 /* vf vlan insert configuration */ 13651 13652 /* Common result structure for vf vlan insert */ 13653 struct cmd_vf_vlan_insert_result { 13654 cmdline_fixed_string_t set; 13655 cmdline_fixed_string_t vf; 13656 cmdline_fixed_string_t vlan; 13657 cmdline_fixed_string_t insert; 13658 portid_t port_id; 13659 uint16_t vf_id; 13660 uint16_t vlan_id; 13661 }; 13662 13663 /* Common CLI fields for vf vlan insert enable disable */ 13664 cmdline_parse_token_string_t cmd_vf_vlan_insert_set = 13665 TOKEN_STRING_INITIALIZER 13666 (struct cmd_vf_vlan_insert_result, 13667 set, "set"); 13668 cmdline_parse_token_string_t cmd_vf_vlan_insert_vf = 13669 TOKEN_STRING_INITIALIZER 13670 (struct cmd_vf_vlan_insert_result, 13671 vf, "vf"); 13672 cmdline_parse_token_string_t cmd_vf_vlan_insert_vlan = 13673 TOKEN_STRING_INITIALIZER 13674 (struct cmd_vf_vlan_insert_result, 13675 vlan, "vlan"); 13676 cmdline_parse_token_string_t cmd_vf_vlan_insert_insert = 13677 TOKEN_STRING_INITIALIZER 13678 (struct cmd_vf_vlan_insert_result, 13679 insert, "insert"); 13680 cmdline_parse_token_num_t cmd_vf_vlan_insert_port_id = 13681 TOKEN_NUM_INITIALIZER 13682 (struct cmd_vf_vlan_insert_result, 13683 port_id, UINT16); 13684 cmdline_parse_token_num_t cmd_vf_vlan_insert_vf_id = 13685 TOKEN_NUM_INITIALIZER 13686 (struct cmd_vf_vlan_insert_result, 13687 vf_id, UINT16); 13688 cmdline_parse_token_num_t cmd_vf_vlan_insert_vlan_id = 13689 TOKEN_NUM_INITIALIZER 13690 (struct cmd_vf_vlan_insert_result, 13691 vlan_id, UINT16); 13692 13693 static void 13694 cmd_set_vf_vlan_insert_parsed( 13695 void *parsed_result, 13696 __attribute__((unused)) struct cmdline *cl, 13697 __attribute__((unused)) void *data) 13698 { 13699 struct cmd_vf_vlan_insert_result *res = parsed_result; 13700 int ret = -ENOTSUP; 13701 13702 if (port_id_is_invalid(res->port_id, ENABLED_WARN)) 13703 return; 13704 13705 #ifdef RTE_LIBRTE_IXGBE_PMD 13706 if (ret == -ENOTSUP) 13707 ret = rte_pmd_ixgbe_set_vf_vlan_insert(res->port_id, res->vf_id, 13708 res->vlan_id); 13709 #endif 13710 #ifdef RTE_LIBRTE_I40E_PMD 13711 if (ret == -ENOTSUP) 13712 ret = rte_pmd_i40e_set_vf_vlan_insert(res->port_id, res->vf_id, 13713 res->vlan_id); 13714 #endif 13715 #ifdef RTE_LIBRTE_BNXT_PMD 13716 if (ret == -ENOTSUP) 13717 ret = rte_pmd_bnxt_set_vf_vlan_insert(res->port_id, res->vf_id, 13718 res->vlan_id); 13719 #endif 13720 13721 switch (ret) { 13722 case 0: 13723 break; 13724 case -EINVAL: 13725 printf("invalid vf_id %d or vlan_id %d\n", res->vf_id, res->vlan_id); 13726 break; 13727 case -ENODEV: 13728 printf("invalid port_id %d\n", res->port_id); 13729 break; 13730 case -ENOTSUP: 13731 printf("function not implemented\n"); 13732 break; 13733 default: 13734 printf("programming error: (%s)\n", strerror(-ret)); 13735 } 13736 } 13737 13738 cmdline_parse_inst_t cmd_set_vf_vlan_insert = { 13739 .f = cmd_set_vf_vlan_insert_parsed, 13740 .data = NULL, 13741 .help_str = "set vf vlan insert <port_id> <vf_id> <vlan_id>", 13742 .tokens = { 13743 (void *)&cmd_vf_vlan_insert_set, 13744 (void *)&cmd_vf_vlan_insert_vf, 13745 (void *)&cmd_vf_vlan_insert_vlan, 13746 (void *)&cmd_vf_vlan_insert_insert, 13747 (void *)&cmd_vf_vlan_insert_port_id, 13748 (void *)&cmd_vf_vlan_insert_vf_id, 13749 (void *)&cmd_vf_vlan_insert_vlan_id, 13750 NULL, 13751 }, 13752 }; 13753 13754 /* tx loopback configuration */ 13755 13756 /* Common result structure for tx loopback */ 13757 struct cmd_tx_loopback_result { 13758 cmdline_fixed_string_t set; 13759 cmdline_fixed_string_t tx; 13760 cmdline_fixed_string_t loopback; 13761 portid_t port_id; 13762 cmdline_fixed_string_t on_off; 13763 }; 13764 13765 /* Common CLI fields for tx loopback enable disable */ 13766 cmdline_parse_token_string_t cmd_tx_loopback_set = 13767 TOKEN_STRING_INITIALIZER 13768 (struct cmd_tx_loopback_result, 13769 set, "set"); 13770 cmdline_parse_token_string_t cmd_tx_loopback_tx = 13771 TOKEN_STRING_INITIALIZER 13772 (struct cmd_tx_loopback_result, 13773 tx, "tx"); 13774 cmdline_parse_token_string_t cmd_tx_loopback_loopback = 13775 TOKEN_STRING_INITIALIZER 13776 (struct cmd_tx_loopback_result, 13777 loopback, "loopback"); 13778 cmdline_parse_token_num_t cmd_tx_loopback_port_id = 13779 TOKEN_NUM_INITIALIZER 13780 (struct cmd_tx_loopback_result, 13781 port_id, UINT16); 13782 cmdline_parse_token_string_t cmd_tx_loopback_on_off = 13783 TOKEN_STRING_INITIALIZER 13784 (struct cmd_tx_loopback_result, 13785 on_off, "on#off"); 13786 13787 static void 13788 cmd_set_tx_loopback_parsed( 13789 void *parsed_result, 13790 __attribute__((unused)) struct cmdline *cl, 13791 __attribute__((unused)) void *data) 13792 { 13793 struct cmd_tx_loopback_result *res = parsed_result; 13794 int ret = -ENOTSUP; 13795 13796 __rte_unused int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0; 13797 13798 if (port_id_is_invalid(res->port_id, ENABLED_WARN)) 13799 return; 13800 13801 #ifdef RTE_LIBRTE_IXGBE_PMD 13802 if (ret == -ENOTSUP) 13803 ret = rte_pmd_ixgbe_set_tx_loopback(res->port_id, is_on); 13804 #endif 13805 #ifdef RTE_LIBRTE_I40E_PMD 13806 if (ret == -ENOTSUP) 13807 ret = rte_pmd_i40e_set_tx_loopback(res->port_id, is_on); 13808 #endif 13809 #ifdef RTE_LIBRTE_BNXT_PMD 13810 if (ret == -ENOTSUP) 13811 ret = rte_pmd_bnxt_set_tx_loopback(res->port_id, is_on); 13812 #endif 13813 #if defined RTE_LIBRTE_DPAA_BUS && defined RTE_LIBRTE_DPAA_PMD 13814 if (ret == -ENOTSUP) 13815 ret = rte_pmd_dpaa_set_tx_loopback(res->port_id, is_on); 13816 #endif 13817 13818 switch (ret) { 13819 case 0: 13820 break; 13821 case -EINVAL: 13822 printf("invalid is_on %d\n", is_on); 13823 break; 13824 case -ENODEV: 13825 printf("invalid port_id %d\n", res->port_id); 13826 break; 13827 case -ENOTSUP: 13828 printf("function not implemented\n"); 13829 break; 13830 default: 13831 printf("programming error: (%s)\n", strerror(-ret)); 13832 } 13833 } 13834 13835 cmdline_parse_inst_t cmd_set_tx_loopback = { 13836 .f = cmd_set_tx_loopback_parsed, 13837 .data = NULL, 13838 .help_str = "set tx loopback <port_id> on|off", 13839 .tokens = { 13840 (void *)&cmd_tx_loopback_set, 13841 (void *)&cmd_tx_loopback_tx, 13842 (void *)&cmd_tx_loopback_loopback, 13843 (void *)&cmd_tx_loopback_port_id, 13844 (void *)&cmd_tx_loopback_on_off, 13845 NULL, 13846 }, 13847 }; 13848 13849 /* all queues drop enable configuration */ 13850 13851 /* Common result structure for all queues drop enable */ 13852 struct cmd_all_queues_drop_en_result { 13853 cmdline_fixed_string_t set; 13854 cmdline_fixed_string_t all; 13855 cmdline_fixed_string_t queues; 13856 cmdline_fixed_string_t drop; 13857 portid_t port_id; 13858 cmdline_fixed_string_t on_off; 13859 }; 13860 13861 /* Common CLI fields for tx loopback enable disable */ 13862 cmdline_parse_token_string_t cmd_all_queues_drop_en_set = 13863 TOKEN_STRING_INITIALIZER 13864 (struct cmd_all_queues_drop_en_result, 13865 set, "set"); 13866 cmdline_parse_token_string_t cmd_all_queues_drop_en_all = 13867 TOKEN_STRING_INITIALIZER 13868 (struct cmd_all_queues_drop_en_result, 13869 all, "all"); 13870 cmdline_parse_token_string_t cmd_all_queues_drop_en_queues = 13871 TOKEN_STRING_INITIALIZER 13872 (struct cmd_all_queues_drop_en_result, 13873 queues, "queues"); 13874 cmdline_parse_token_string_t cmd_all_queues_drop_en_drop = 13875 TOKEN_STRING_INITIALIZER 13876 (struct cmd_all_queues_drop_en_result, 13877 drop, "drop"); 13878 cmdline_parse_token_num_t cmd_all_queues_drop_en_port_id = 13879 TOKEN_NUM_INITIALIZER 13880 (struct cmd_all_queues_drop_en_result, 13881 port_id, UINT16); 13882 cmdline_parse_token_string_t cmd_all_queues_drop_en_on_off = 13883 TOKEN_STRING_INITIALIZER 13884 (struct cmd_all_queues_drop_en_result, 13885 on_off, "on#off"); 13886 13887 static void 13888 cmd_set_all_queues_drop_en_parsed( 13889 void *parsed_result, 13890 __attribute__((unused)) struct cmdline *cl, 13891 __attribute__((unused)) void *data) 13892 { 13893 struct cmd_all_queues_drop_en_result *res = parsed_result; 13894 int ret = -ENOTSUP; 13895 int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0; 13896 13897 if (port_id_is_invalid(res->port_id, ENABLED_WARN)) 13898 return; 13899 13900 #ifdef RTE_LIBRTE_IXGBE_PMD 13901 if (ret == -ENOTSUP) 13902 ret = rte_pmd_ixgbe_set_all_queues_drop_en(res->port_id, is_on); 13903 #endif 13904 #ifdef RTE_LIBRTE_BNXT_PMD 13905 if (ret == -ENOTSUP) 13906 ret = rte_pmd_bnxt_set_all_queues_drop_en(res->port_id, is_on); 13907 #endif 13908 switch (ret) { 13909 case 0: 13910 break; 13911 case -EINVAL: 13912 printf("invalid is_on %d\n", is_on); 13913 break; 13914 case -ENODEV: 13915 printf("invalid port_id %d\n", res->port_id); 13916 break; 13917 case -ENOTSUP: 13918 printf("function not implemented\n"); 13919 break; 13920 default: 13921 printf("programming error: (%s)\n", strerror(-ret)); 13922 } 13923 } 13924 13925 cmdline_parse_inst_t cmd_set_all_queues_drop_en = { 13926 .f = cmd_set_all_queues_drop_en_parsed, 13927 .data = NULL, 13928 .help_str = "set all queues drop <port_id> on|off", 13929 .tokens = { 13930 (void *)&cmd_all_queues_drop_en_set, 13931 (void *)&cmd_all_queues_drop_en_all, 13932 (void *)&cmd_all_queues_drop_en_queues, 13933 (void *)&cmd_all_queues_drop_en_drop, 13934 (void *)&cmd_all_queues_drop_en_port_id, 13935 (void *)&cmd_all_queues_drop_en_on_off, 13936 NULL, 13937 }, 13938 }; 13939 13940 /* vf split drop enable configuration */ 13941 13942 /* Common result structure for vf split drop enable */ 13943 struct cmd_vf_split_drop_en_result { 13944 cmdline_fixed_string_t set; 13945 cmdline_fixed_string_t vf; 13946 cmdline_fixed_string_t split; 13947 cmdline_fixed_string_t drop; 13948 portid_t port_id; 13949 uint16_t vf_id; 13950 cmdline_fixed_string_t on_off; 13951 }; 13952 13953 /* Common CLI fields for vf split drop enable disable */ 13954 cmdline_parse_token_string_t cmd_vf_split_drop_en_set = 13955 TOKEN_STRING_INITIALIZER 13956 (struct cmd_vf_split_drop_en_result, 13957 set, "set"); 13958 cmdline_parse_token_string_t cmd_vf_split_drop_en_vf = 13959 TOKEN_STRING_INITIALIZER 13960 (struct cmd_vf_split_drop_en_result, 13961 vf, "vf"); 13962 cmdline_parse_token_string_t cmd_vf_split_drop_en_split = 13963 TOKEN_STRING_INITIALIZER 13964 (struct cmd_vf_split_drop_en_result, 13965 split, "split"); 13966 cmdline_parse_token_string_t cmd_vf_split_drop_en_drop = 13967 TOKEN_STRING_INITIALIZER 13968 (struct cmd_vf_split_drop_en_result, 13969 drop, "drop"); 13970 cmdline_parse_token_num_t cmd_vf_split_drop_en_port_id = 13971 TOKEN_NUM_INITIALIZER 13972 (struct cmd_vf_split_drop_en_result, 13973 port_id, UINT16); 13974 cmdline_parse_token_num_t cmd_vf_split_drop_en_vf_id = 13975 TOKEN_NUM_INITIALIZER 13976 (struct cmd_vf_split_drop_en_result, 13977 vf_id, UINT16); 13978 cmdline_parse_token_string_t cmd_vf_split_drop_en_on_off = 13979 TOKEN_STRING_INITIALIZER 13980 (struct cmd_vf_split_drop_en_result, 13981 on_off, "on#off"); 13982 13983 static void 13984 cmd_set_vf_split_drop_en_parsed( 13985 void *parsed_result, 13986 __attribute__((unused)) struct cmdline *cl, 13987 __attribute__((unused)) void *data) 13988 { 13989 struct cmd_vf_split_drop_en_result *res = parsed_result; 13990 int ret = -ENOTSUP; 13991 int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0; 13992 13993 if (port_id_is_invalid(res->port_id, ENABLED_WARN)) 13994 return; 13995 13996 #ifdef RTE_LIBRTE_IXGBE_PMD 13997 ret = rte_pmd_ixgbe_set_vf_split_drop_en(res->port_id, res->vf_id, 13998 is_on); 13999 #endif 14000 switch (ret) { 14001 case 0: 14002 break; 14003 case -EINVAL: 14004 printf("invalid vf_id %d or is_on %d\n", res->vf_id, is_on); 14005 break; 14006 case -ENODEV: 14007 printf("invalid port_id %d\n", res->port_id); 14008 break; 14009 case -ENOTSUP: 14010 printf("not supported on port %d\n", res->port_id); 14011 break; 14012 default: 14013 printf("programming error: (%s)\n", strerror(-ret)); 14014 } 14015 } 14016 14017 cmdline_parse_inst_t cmd_set_vf_split_drop_en = { 14018 .f = cmd_set_vf_split_drop_en_parsed, 14019 .data = NULL, 14020 .help_str = "set vf split drop <port_id> <vf_id> on|off", 14021 .tokens = { 14022 (void *)&cmd_vf_split_drop_en_set, 14023 (void *)&cmd_vf_split_drop_en_vf, 14024 (void *)&cmd_vf_split_drop_en_split, 14025 (void *)&cmd_vf_split_drop_en_drop, 14026 (void *)&cmd_vf_split_drop_en_port_id, 14027 (void *)&cmd_vf_split_drop_en_vf_id, 14028 (void *)&cmd_vf_split_drop_en_on_off, 14029 NULL, 14030 }, 14031 }; 14032 14033 /* vf mac address configuration */ 14034 14035 /* Common result structure for vf mac address */ 14036 struct cmd_set_vf_mac_addr_result { 14037 cmdline_fixed_string_t set; 14038 cmdline_fixed_string_t vf; 14039 cmdline_fixed_string_t mac; 14040 cmdline_fixed_string_t addr; 14041 portid_t port_id; 14042 uint16_t vf_id; 14043 struct rte_ether_addr mac_addr; 14044 14045 }; 14046 14047 /* Common CLI fields for vf split drop enable disable */ 14048 cmdline_parse_token_string_t cmd_set_vf_mac_addr_set = 14049 TOKEN_STRING_INITIALIZER 14050 (struct cmd_set_vf_mac_addr_result, 14051 set, "set"); 14052 cmdline_parse_token_string_t cmd_set_vf_mac_addr_vf = 14053 TOKEN_STRING_INITIALIZER 14054 (struct cmd_set_vf_mac_addr_result, 14055 vf, "vf"); 14056 cmdline_parse_token_string_t cmd_set_vf_mac_addr_mac = 14057 TOKEN_STRING_INITIALIZER 14058 (struct cmd_set_vf_mac_addr_result, 14059 mac, "mac"); 14060 cmdline_parse_token_string_t cmd_set_vf_mac_addr_addr = 14061 TOKEN_STRING_INITIALIZER 14062 (struct cmd_set_vf_mac_addr_result, 14063 addr, "addr"); 14064 cmdline_parse_token_num_t cmd_set_vf_mac_addr_port_id = 14065 TOKEN_NUM_INITIALIZER 14066 (struct cmd_set_vf_mac_addr_result, 14067 port_id, UINT16); 14068 cmdline_parse_token_num_t cmd_set_vf_mac_addr_vf_id = 14069 TOKEN_NUM_INITIALIZER 14070 (struct cmd_set_vf_mac_addr_result, 14071 vf_id, UINT16); 14072 cmdline_parse_token_etheraddr_t cmd_set_vf_mac_addr_mac_addr = 14073 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_vf_mac_addr_result, 14074 mac_addr); 14075 14076 static void 14077 cmd_set_vf_mac_addr_parsed( 14078 void *parsed_result, 14079 __attribute__((unused)) struct cmdline *cl, 14080 __attribute__((unused)) void *data) 14081 { 14082 struct cmd_set_vf_mac_addr_result *res = parsed_result; 14083 int ret = -ENOTSUP; 14084 14085 if (port_id_is_invalid(res->port_id, ENABLED_WARN)) 14086 return; 14087 14088 #ifdef RTE_LIBRTE_IXGBE_PMD 14089 if (ret == -ENOTSUP) 14090 ret = rte_pmd_ixgbe_set_vf_mac_addr(res->port_id, res->vf_id, 14091 &res->mac_addr); 14092 #endif 14093 #ifdef RTE_LIBRTE_I40E_PMD 14094 if (ret == -ENOTSUP) 14095 ret = rte_pmd_i40e_set_vf_mac_addr(res->port_id, res->vf_id, 14096 &res->mac_addr); 14097 #endif 14098 #ifdef RTE_LIBRTE_BNXT_PMD 14099 if (ret == -ENOTSUP) 14100 ret = rte_pmd_bnxt_set_vf_mac_addr(res->port_id, res->vf_id, 14101 &res->mac_addr); 14102 #endif 14103 14104 switch (ret) { 14105 case 0: 14106 break; 14107 case -EINVAL: 14108 printf("invalid vf_id %d or mac_addr\n", res->vf_id); 14109 break; 14110 case -ENODEV: 14111 printf("invalid port_id %d\n", res->port_id); 14112 break; 14113 case -ENOTSUP: 14114 printf("function not implemented\n"); 14115 break; 14116 default: 14117 printf("programming error: (%s)\n", strerror(-ret)); 14118 } 14119 } 14120 14121 cmdline_parse_inst_t cmd_set_vf_mac_addr = { 14122 .f = cmd_set_vf_mac_addr_parsed, 14123 .data = NULL, 14124 .help_str = "set vf mac addr <port_id> <vf_id> <mac_addr>", 14125 .tokens = { 14126 (void *)&cmd_set_vf_mac_addr_set, 14127 (void *)&cmd_set_vf_mac_addr_vf, 14128 (void *)&cmd_set_vf_mac_addr_mac, 14129 (void *)&cmd_set_vf_mac_addr_addr, 14130 (void *)&cmd_set_vf_mac_addr_port_id, 14131 (void *)&cmd_set_vf_mac_addr_vf_id, 14132 (void *)&cmd_set_vf_mac_addr_mac_addr, 14133 NULL, 14134 }, 14135 }; 14136 14137 /* MACsec configuration */ 14138 14139 /* Common result structure for MACsec offload enable */ 14140 struct cmd_macsec_offload_on_result { 14141 cmdline_fixed_string_t set; 14142 cmdline_fixed_string_t macsec; 14143 cmdline_fixed_string_t offload; 14144 portid_t port_id; 14145 cmdline_fixed_string_t on; 14146 cmdline_fixed_string_t encrypt; 14147 cmdline_fixed_string_t en_on_off; 14148 cmdline_fixed_string_t replay_protect; 14149 cmdline_fixed_string_t rp_on_off; 14150 }; 14151 14152 /* Common CLI fields for MACsec offload disable */ 14153 cmdline_parse_token_string_t cmd_macsec_offload_on_set = 14154 TOKEN_STRING_INITIALIZER 14155 (struct cmd_macsec_offload_on_result, 14156 set, "set"); 14157 cmdline_parse_token_string_t cmd_macsec_offload_on_macsec = 14158 TOKEN_STRING_INITIALIZER 14159 (struct cmd_macsec_offload_on_result, 14160 macsec, "macsec"); 14161 cmdline_parse_token_string_t cmd_macsec_offload_on_offload = 14162 TOKEN_STRING_INITIALIZER 14163 (struct cmd_macsec_offload_on_result, 14164 offload, "offload"); 14165 cmdline_parse_token_num_t cmd_macsec_offload_on_port_id = 14166 TOKEN_NUM_INITIALIZER 14167 (struct cmd_macsec_offload_on_result, 14168 port_id, UINT16); 14169 cmdline_parse_token_string_t cmd_macsec_offload_on_on = 14170 TOKEN_STRING_INITIALIZER 14171 (struct cmd_macsec_offload_on_result, 14172 on, "on"); 14173 cmdline_parse_token_string_t cmd_macsec_offload_on_encrypt = 14174 TOKEN_STRING_INITIALIZER 14175 (struct cmd_macsec_offload_on_result, 14176 encrypt, "encrypt"); 14177 cmdline_parse_token_string_t cmd_macsec_offload_on_en_on_off = 14178 TOKEN_STRING_INITIALIZER 14179 (struct cmd_macsec_offload_on_result, 14180 en_on_off, "on#off"); 14181 cmdline_parse_token_string_t cmd_macsec_offload_on_replay_protect = 14182 TOKEN_STRING_INITIALIZER 14183 (struct cmd_macsec_offload_on_result, 14184 replay_protect, "replay-protect"); 14185 cmdline_parse_token_string_t cmd_macsec_offload_on_rp_on_off = 14186 TOKEN_STRING_INITIALIZER 14187 (struct cmd_macsec_offload_on_result, 14188 rp_on_off, "on#off"); 14189 14190 static void 14191 cmd_set_macsec_offload_on_parsed( 14192 void *parsed_result, 14193 __attribute__((unused)) struct cmdline *cl, 14194 __attribute__((unused)) void *data) 14195 { 14196 struct cmd_macsec_offload_on_result *res = parsed_result; 14197 int ret = -ENOTSUP; 14198 portid_t port_id = res->port_id; 14199 int en = (strcmp(res->en_on_off, "on") == 0) ? 1 : 0; 14200 int rp = (strcmp(res->rp_on_off, "on") == 0) ? 1 : 0; 14201 struct rte_eth_dev_info dev_info; 14202 14203 if (port_id_is_invalid(port_id, ENABLED_WARN)) 14204 return; 14205 if (!port_is_stopped(port_id)) { 14206 printf("Please stop port %d first\n", port_id); 14207 return; 14208 } 14209 14210 ret = eth_dev_info_get_print_err(port_id, &dev_info); 14211 if (ret != 0) 14212 return; 14213 14214 if (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_MACSEC_INSERT) { 14215 #ifdef RTE_LIBRTE_IXGBE_PMD 14216 ret = rte_pmd_ixgbe_macsec_enable(port_id, en, rp); 14217 #endif 14218 } 14219 RTE_SET_USED(en); 14220 RTE_SET_USED(rp); 14221 14222 switch (ret) { 14223 case 0: 14224 ports[port_id].dev_conf.txmode.offloads |= 14225 DEV_TX_OFFLOAD_MACSEC_INSERT; 14226 cmd_reconfig_device_queue(port_id, 1, 1); 14227 break; 14228 case -ENODEV: 14229 printf("invalid port_id %d\n", port_id); 14230 break; 14231 case -ENOTSUP: 14232 printf("not supported on port %d\n", port_id); 14233 break; 14234 default: 14235 printf("programming error: (%s)\n", strerror(-ret)); 14236 } 14237 } 14238 14239 cmdline_parse_inst_t cmd_set_macsec_offload_on = { 14240 .f = cmd_set_macsec_offload_on_parsed, 14241 .data = NULL, 14242 .help_str = "set macsec offload <port_id> on " 14243 "encrypt on|off replay-protect on|off", 14244 .tokens = { 14245 (void *)&cmd_macsec_offload_on_set, 14246 (void *)&cmd_macsec_offload_on_macsec, 14247 (void *)&cmd_macsec_offload_on_offload, 14248 (void *)&cmd_macsec_offload_on_port_id, 14249 (void *)&cmd_macsec_offload_on_on, 14250 (void *)&cmd_macsec_offload_on_encrypt, 14251 (void *)&cmd_macsec_offload_on_en_on_off, 14252 (void *)&cmd_macsec_offload_on_replay_protect, 14253 (void *)&cmd_macsec_offload_on_rp_on_off, 14254 NULL, 14255 }, 14256 }; 14257 14258 /* Common result structure for MACsec offload disable */ 14259 struct cmd_macsec_offload_off_result { 14260 cmdline_fixed_string_t set; 14261 cmdline_fixed_string_t macsec; 14262 cmdline_fixed_string_t offload; 14263 portid_t port_id; 14264 cmdline_fixed_string_t off; 14265 }; 14266 14267 /* Common CLI fields for MACsec offload disable */ 14268 cmdline_parse_token_string_t cmd_macsec_offload_off_set = 14269 TOKEN_STRING_INITIALIZER 14270 (struct cmd_macsec_offload_off_result, 14271 set, "set"); 14272 cmdline_parse_token_string_t cmd_macsec_offload_off_macsec = 14273 TOKEN_STRING_INITIALIZER 14274 (struct cmd_macsec_offload_off_result, 14275 macsec, "macsec"); 14276 cmdline_parse_token_string_t cmd_macsec_offload_off_offload = 14277 TOKEN_STRING_INITIALIZER 14278 (struct cmd_macsec_offload_off_result, 14279 offload, "offload"); 14280 cmdline_parse_token_num_t cmd_macsec_offload_off_port_id = 14281 TOKEN_NUM_INITIALIZER 14282 (struct cmd_macsec_offload_off_result, 14283 port_id, UINT16); 14284 cmdline_parse_token_string_t cmd_macsec_offload_off_off = 14285 TOKEN_STRING_INITIALIZER 14286 (struct cmd_macsec_offload_off_result, 14287 off, "off"); 14288 14289 static void 14290 cmd_set_macsec_offload_off_parsed( 14291 void *parsed_result, 14292 __attribute__((unused)) struct cmdline *cl, 14293 __attribute__((unused)) void *data) 14294 { 14295 struct cmd_macsec_offload_off_result *res = parsed_result; 14296 int ret = -ENOTSUP; 14297 struct rte_eth_dev_info dev_info; 14298 portid_t port_id = res->port_id; 14299 14300 if (port_id_is_invalid(port_id, ENABLED_WARN)) 14301 return; 14302 if (!port_is_stopped(port_id)) { 14303 printf("Please stop port %d first\n", port_id); 14304 return; 14305 } 14306 14307 ret = eth_dev_info_get_print_err(port_id, &dev_info); 14308 if (ret != 0) 14309 return; 14310 14311 if (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_MACSEC_INSERT) { 14312 #ifdef RTE_LIBRTE_IXGBE_PMD 14313 ret = rte_pmd_ixgbe_macsec_disable(port_id); 14314 #endif 14315 } 14316 switch (ret) { 14317 case 0: 14318 ports[port_id].dev_conf.txmode.offloads &= 14319 ~DEV_TX_OFFLOAD_MACSEC_INSERT; 14320 cmd_reconfig_device_queue(port_id, 1, 1); 14321 break; 14322 case -ENODEV: 14323 printf("invalid port_id %d\n", port_id); 14324 break; 14325 case -ENOTSUP: 14326 printf("not supported on port %d\n", port_id); 14327 break; 14328 default: 14329 printf("programming error: (%s)\n", strerror(-ret)); 14330 } 14331 } 14332 14333 cmdline_parse_inst_t cmd_set_macsec_offload_off = { 14334 .f = cmd_set_macsec_offload_off_parsed, 14335 .data = NULL, 14336 .help_str = "set macsec offload <port_id> off", 14337 .tokens = { 14338 (void *)&cmd_macsec_offload_off_set, 14339 (void *)&cmd_macsec_offload_off_macsec, 14340 (void *)&cmd_macsec_offload_off_offload, 14341 (void *)&cmd_macsec_offload_off_port_id, 14342 (void *)&cmd_macsec_offload_off_off, 14343 NULL, 14344 }, 14345 }; 14346 14347 /* Common result structure for MACsec secure connection configure */ 14348 struct cmd_macsec_sc_result { 14349 cmdline_fixed_string_t set; 14350 cmdline_fixed_string_t macsec; 14351 cmdline_fixed_string_t sc; 14352 cmdline_fixed_string_t tx_rx; 14353 portid_t port_id; 14354 struct rte_ether_addr mac; 14355 uint16_t pi; 14356 }; 14357 14358 /* Common CLI fields for MACsec secure connection configure */ 14359 cmdline_parse_token_string_t cmd_macsec_sc_set = 14360 TOKEN_STRING_INITIALIZER 14361 (struct cmd_macsec_sc_result, 14362 set, "set"); 14363 cmdline_parse_token_string_t cmd_macsec_sc_macsec = 14364 TOKEN_STRING_INITIALIZER 14365 (struct cmd_macsec_sc_result, 14366 macsec, "macsec"); 14367 cmdline_parse_token_string_t cmd_macsec_sc_sc = 14368 TOKEN_STRING_INITIALIZER 14369 (struct cmd_macsec_sc_result, 14370 sc, "sc"); 14371 cmdline_parse_token_string_t cmd_macsec_sc_tx_rx = 14372 TOKEN_STRING_INITIALIZER 14373 (struct cmd_macsec_sc_result, 14374 tx_rx, "tx#rx"); 14375 cmdline_parse_token_num_t cmd_macsec_sc_port_id = 14376 TOKEN_NUM_INITIALIZER 14377 (struct cmd_macsec_sc_result, 14378 port_id, UINT16); 14379 cmdline_parse_token_etheraddr_t cmd_macsec_sc_mac = 14380 TOKEN_ETHERADDR_INITIALIZER 14381 (struct cmd_macsec_sc_result, 14382 mac); 14383 cmdline_parse_token_num_t cmd_macsec_sc_pi = 14384 TOKEN_NUM_INITIALIZER 14385 (struct cmd_macsec_sc_result, 14386 pi, UINT16); 14387 14388 static void 14389 cmd_set_macsec_sc_parsed( 14390 void *parsed_result, 14391 __attribute__((unused)) struct cmdline *cl, 14392 __attribute__((unused)) void *data) 14393 { 14394 struct cmd_macsec_sc_result *res = parsed_result; 14395 int ret = -ENOTSUP; 14396 int is_tx = (strcmp(res->tx_rx, "tx") == 0) ? 1 : 0; 14397 14398 #ifdef RTE_LIBRTE_IXGBE_PMD 14399 ret = is_tx ? 14400 rte_pmd_ixgbe_macsec_config_txsc(res->port_id, 14401 res->mac.addr_bytes) : 14402 rte_pmd_ixgbe_macsec_config_rxsc(res->port_id, 14403 res->mac.addr_bytes, res->pi); 14404 #endif 14405 RTE_SET_USED(is_tx); 14406 14407 switch (ret) { 14408 case 0: 14409 break; 14410 case -ENODEV: 14411 printf("invalid port_id %d\n", res->port_id); 14412 break; 14413 case -ENOTSUP: 14414 printf("not supported on port %d\n", res->port_id); 14415 break; 14416 default: 14417 printf("programming error: (%s)\n", strerror(-ret)); 14418 } 14419 } 14420 14421 cmdline_parse_inst_t cmd_set_macsec_sc = { 14422 .f = cmd_set_macsec_sc_parsed, 14423 .data = NULL, 14424 .help_str = "set macsec sc tx|rx <port_id> <mac> <pi>", 14425 .tokens = { 14426 (void *)&cmd_macsec_sc_set, 14427 (void *)&cmd_macsec_sc_macsec, 14428 (void *)&cmd_macsec_sc_sc, 14429 (void *)&cmd_macsec_sc_tx_rx, 14430 (void *)&cmd_macsec_sc_port_id, 14431 (void *)&cmd_macsec_sc_mac, 14432 (void *)&cmd_macsec_sc_pi, 14433 NULL, 14434 }, 14435 }; 14436 14437 /* Common result structure for MACsec secure connection configure */ 14438 struct cmd_macsec_sa_result { 14439 cmdline_fixed_string_t set; 14440 cmdline_fixed_string_t macsec; 14441 cmdline_fixed_string_t sa; 14442 cmdline_fixed_string_t tx_rx; 14443 portid_t port_id; 14444 uint8_t idx; 14445 uint8_t an; 14446 uint32_t pn; 14447 cmdline_fixed_string_t key; 14448 }; 14449 14450 /* Common CLI fields for MACsec secure connection configure */ 14451 cmdline_parse_token_string_t cmd_macsec_sa_set = 14452 TOKEN_STRING_INITIALIZER 14453 (struct cmd_macsec_sa_result, 14454 set, "set"); 14455 cmdline_parse_token_string_t cmd_macsec_sa_macsec = 14456 TOKEN_STRING_INITIALIZER 14457 (struct cmd_macsec_sa_result, 14458 macsec, "macsec"); 14459 cmdline_parse_token_string_t cmd_macsec_sa_sa = 14460 TOKEN_STRING_INITIALIZER 14461 (struct cmd_macsec_sa_result, 14462 sa, "sa"); 14463 cmdline_parse_token_string_t cmd_macsec_sa_tx_rx = 14464 TOKEN_STRING_INITIALIZER 14465 (struct cmd_macsec_sa_result, 14466 tx_rx, "tx#rx"); 14467 cmdline_parse_token_num_t cmd_macsec_sa_port_id = 14468 TOKEN_NUM_INITIALIZER 14469 (struct cmd_macsec_sa_result, 14470 port_id, UINT16); 14471 cmdline_parse_token_num_t cmd_macsec_sa_idx = 14472 TOKEN_NUM_INITIALIZER 14473 (struct cmd_macsec_sa_result, 14474 idx, UINT8); 14475 cmdline_parse_token_num_t cmd_macsec_sa_an = 14476 TOKEN_NUM_INITIALIZER 14477 (struct cmd_macsec_sa_result, 14478 an, UINT8); 14479 cmdline_parse_token_num_t cmd_macsec_sa_pn = 14480 TOKEN_NUM_INITIALIZER 14481 (struct cmd_macsec_sa_result, 14482 pn, UINT32); 14483 cmdline_parse_token_string_t cmd_macsec_sa_key = 14484 TOKEN_STRING_INITIALIZER 14485 (struct cmd_macsec_sa_result, 14486 key, NULL); 14487 14488 static void 14489 cmd_set_macsec_sa_parsed( 14490 void *parsed_result, 14491 __attribute__((unused)) struct cmdline *cl, 14492 __attribute__((unused)) void *data) 14493 { 14494 struct cmd_macsec_sa_result *res = parsed_result; 14495 int ret = -ENOTSUP; 14496 int is_tx = (strcmp(res->tx_rx, "tx") == 0) ? 1 : 0; 14497 uint8_t key[16] = { 0 }; 14498 uint8_t xdgt0; 14499 uint8_t xdgt1; 14500 int key_len; 14501 int i; 14502 14503 key_len = strlen(res->key) / 2; 14504 if (key_len > 16) 14505 key_len = 16; 14506 14507 for (i = 0; i < key_len; i++) { 14508 xdgt0 = parse_and_check_key_hexa_digit(res->key, (i * 2)); 14509 if (xdgt0 == 0xFF) 14510 return; 14511 xdgt1 = parse_and_check_key_hexa_digit(res->key, (i * 2) + 1); 14512 if (xdgt1 == 0xFF) 14513 return; 14514 key[i] = (uint8_t) ((xdgt0 * 16) + xdgt1); 14515 } 14516 14517 #ifdef RTE_LIBRTE_IXGBE_PMD 14518 ret = is_tx ? 14519 rte_pmd_ixgbe_macsec_select_txsa(res->port_id, 14520 res->idx, res->an, res->pn, key) : 14521 rte_pmd_ixgbe_macsec_select_rxsa(res->port_id, 14522 res->idx, res->an, res->pn, key); 14523 #endif 14524 RTE_SET_USED(is_tx); 14525 RTE_SET_USED(key); 14526 14527 switch (ret) { 14528 case 0: 14529 break; 14530 case -EINVAL: 14531 printf("invalid idx %d or an %d\n", res->idx, res->an); 14532 break; 14533 case -ENODEV: 14534 printf("invalid port_id %d\n", res->port_id); 14535 break; 14536 case -ENOTSUP: 14537 printf("not supported on port %d\n", res->port_id); 14538 break; 14539 default: 14540 printf("programming error: (%s)\n", strerror(-ret)); 14541 } 14542 } 14543 14544 cmdline_parse_inst_t cmd_set_macsec_sa = { 14545 .f = cmd_set_macsec_sa_parsed, 14546 .data = NULL, 14547 .help_str = "set macsec sa tx|rx <port_id> <idx> <an> <pn> <key>", 14548 .tokens = { 14549 (void *)&cmd_macsec_sa_set, 14550 (void *)&cmd_macsec_sa_macsec, 14551 (void *)&cmd_macsec_sa_sa, 14552 (void *)&cmd_macsec_sa_tx_rx, 14553 (void *)&cmd_macsec_sa_port_id, 14554 (void *)&cmd_macsec_sa_idx, 14555 (void *)&cmd_macsec_sa_an, 14556 (void *)&cmd_macsec_sa_pn, 14557 (void *)&cmd_macsec_sa_key, 14558 NULL, 14559 }, 14560 }; 14561 14562 /* VF unicast promiscuous mode configuration */ 14563 14564 /* Common result structure for VF unicast promiscuous mode */ 14565 struct cmd_vf_promisc_result { 14566 cmdline_fixed_string_t set; 14567 cmdline_fixed_string_t vf; 14568 cmdline_fixed_string_t promisc; 14569 portid_t port_id; 14570 uint32_t vf_id; 14571 cmdline_fixed_string_t on_off; 14572 }; 14573 14574 /* Common CLI fields for VF unicast promiscuous mode enable disable */ 14575 cmdline_parse_token_string_t cmd_vf_promisc_set = 14576 TOKEN_STRING_INITIALIZER 14577 (struct cmd_vf_promisc_result, 14578 set, "set"); 14579 cmdline_parse_token_string_t cmd_vf_promisc_vf = 14580 TOKEN_STRING_INITIALIZER 14581 (struct cmd_vf_promisc_result, 14582 vf, "vf"); 14583 cmdline_parse_token_string_t cmd_vf_promisc_promisc = 14584 TOKEN_STRING_INITIALIZER 14585 (struct cmd_vf_promisc_result, 14586 promisc, "promisc"); 14587 cmdline_parse_token_num_t cmd_vf_promisc_port_id = 14588 TOKEN_NUM_INITIALIZER 14589 (struct cmd_vf_promisc_result, 14590 port_id, UINT16); 14591 cmdline_parse_token_num_t cmd_vf_promisc_vf_id = 14592 TOKEN_NUM_INITIALIZER 14593 (struct cmd_vf_promisc_result, 14594 vf_id, UINT32); 14595 cmdline_parse_token_string_t cmd_vf_promisc_on_off = 14596 TOKEN_STRING_INITIALIZER 14597 (struct cmd_vf_promisc_result, 14598 on_off, "on#off"); 14599 14600 static void 14601 cmd_set_vf_promisc_parsed( 14602 void *parsed_result, 14603 __attribute__((unused)) struct cmdline *cl, 14604 __attribute__((unused)) void *data) 14605 { 14606 struct cmd_vf_promisc_result *res = parsed_result; 14607 int ret = -ENOTSUP; 14608 14609 __rte_unused int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0; 14610 14611 if (port_id_is_invalid(res->port_id, ENABLED_WARN)) 14612 return; 14613 14614 #ifdef RTE_LIBRTE_I40E_PMD 14615 ret = rte_pmd_i40e_set_vf_unicast_promisc(res->port_id, 14616 res->vf_id, is_on); 14617 #endif 14618 14619 switch (ret) { 14620 case 0: 14621 break; 14622 case -EINVAL: 14623 printf("invalid vf_id %d\n", res->vf_id); 14624 break; 14625 case -ENODEV: 14626 printf("invalid port_id %d\n", res->port_id); 14627 break; 14628 case -ENOTSUP: 14629 printf("function not implemented\n"); 14630 break; 14631 default: 14632 printf("programming error: (%s)\n", strerror(-ret)); 14633 } 14634 } 14635 14636 cmdline_parse_inst_t cmd_set_vf_promisc = { 14637 .f = cmd_set_vf_promisc_parsed, 14638 .data = NULL, 14639 .help_str = "set vf promisc <port_id> <vf_id> on|off: " 14640 "Set unicast promiscuous mode for a VF from the PF", 14641 .tokens = { 14642 (void *)&cmd_vf_promisc_set, 14643 (void *)&cmd_vf_promisc_vf, 14644 (void *)&cmd_vf_promisc_promisc, 14645 (void *)&cmd_vf_promisc_port_id, 14646 (void *)&cmd_vf_promisc_vf_id, 14647 (void *)&cmd_vf_promisc_on_off, 14648 NULL, 14649 }, 14650 }; 14651 14652 /* VF multicast promiscuous mode configuration */ 14653 14654 /* Common result structure for VF multicast promiscuous mode */ 14655 struct cmd_vf_allmulti_result { 14656 cmdline_fixed_string_t set; 14657 cmdline_fixed_string_t vf; 14658 cmdline_fixed_string_t allmulti; 14659 portid_t port_id; 14660 uint32_t vf_id; 14661 cmdline_fixed_string_t on_off; 14662 }; 14663 14664 /* Common CLI fields for VF multicast promiscuous mode enable disable */ 14665 cmdline_parse_token_string_t cmd_vf_allmulti_set = 14666 TOKEN_STRING_INITIALIZER 14667 (struct cmd_vf_allmulti_result, 14668 set, "set"); 14669 cmdline_parse_token_string_t cmd_vf_allmulti_vf = 14670 TOKEN_STRING_INITIALIZER 14671 (struct cmd_vf_allmulti_result, 14672 vf, "vf"); 14673 cmdline_parse_token_string_t cmd_vf_allmulti_allmulti = 14674 TOKEN_STRING_INITIALIZER 14675 (struct cmd_vf_allmulti_result, 14676 allmulti, "allmulti"); 14677 cmdline_parse_token_num_t cmd_vf_allmulti_port_id = 14678 TOKEN_NUM_INITIALIZER 14679 (struct cmd_vf_allmulti_result, 14680 port_id, UINT16); 14681 cmdline_parse_token_num_t cmd_vf_allmulti_vf_id = 14682 TOKEN_NUM_INITIALIZER 14683 (struct cmd_vf_allmulti_result, 14684 vf_id, UINT32); 14685 cmdline_parse_token_string_t cmd_vf_allmulti_on_off = 14686 TOKEN_STRING_INITIALIZER 14687 (struct cmd_vf_allmulti_result, 14688 on_off, "on#off"); 14689 14690 static void 14691 cmd_set_vf_allmulti_parsed( 14692 void *parsed_result, 14693 __attribute__((unused)) struct cmdline *cl, 14694 __attribute__((unused)) void *data) 14695 { 14696 struct cmd_vf_allmulti_result *res = parsed_result; 14697 int ret = -ENOTSUP; 14698 14699 __rte_unused int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0; 14700 14701 if (port_id_is_invalid(res->port_id, ENABLED_WARN)) 14702 return; 14703 14704 #ifdef RTE_LIBRTE_I40E_PMD 14705 ret = rte_pmd_i40e_set_vf_multicast_promisc(res->port_id, 14706 res->vf_id, is_on); 14707 #endif 14708 14709 switch (ret) { 14710 case 0: 14711 break; 14712 case -EINVAL: 14713 printf("invalid vf_id %d\n", res->vf_id); 14714 break; 14715 case -ENODEV: 14716 printf("invalid port_id %d\n", res->port_id); 14717 break; 14718 case -ENOTSUP: 14719 printf("function not implemented\n"); 14720 break; 14721 default: 14722 printf("programming error: (%s)\n", strerror(-ret)); 14723 } 14724 } 14725 14726 cmdline_parse_inst_t cmd_set_vf_allmulti = { 14727 .f = cmd_set_vf_allmulti_parsed, 14728 .data = NULL, 14729 .help_str = "set vf allmulti <port_id> <vf_id> on|off: " 14730 "Set multicast promiscuous mode for a VF from the PF", 14731 .tokens = { 14732 (void *)&cmd_vf_allmulti_set, 14733 (void *)&cmd_vf_allmulti_vf, 14734 (void *)&cmd_vf_allmulti_allmulti, 14735 (void *)&cmd_vf_allmulti_port_id, 14736 (void *)&cmd_vf_allmulti_vf_id, 14737 (void *)&cmd_vf_allmulti_on_off, 14738 NULL, 14739 }, 14740 }; 14741 14742 /* vf broadcast mode configuration */ 14743 14744 /* Common result structure for vf broadcast */ 14745 struct cmd_set_vf_broadcast_result { 14746 cmdline_fixed_string_t set; 14747 cmdline_fixed_string_t vf; 14748 cmdline_fixed_string_t broadcast; 14749 portid_t port_id; 14750 uint16_t vf_id; 14751 cmdline_fixed_string_t on_off; 14752 }; 14753 14754 /* Common CLI fields for vf broadcast enable disable */ 14755 cmdline_parse_token_string_t cmd_set_vf_broadcast_set = 14756 TOKEN_STRING_INITIALIZER 14757 (struct cmd_set_vf_broadcast_result, 14758 set, "set"); 14759 cmdline_parse_token_string_t cmd_set_vf_broadcast_vf = 14760 TOKEN_STRING_INITIALIZER 14761 (struct cmd_set_vf_broadcast_result, 14762 vf, "vf"); 14763 cmdline_parse_token_string_t cmd_set_vf_broadcast_broadcast = 14764 TOKEN_STRING_INITIALIZER 14765 (struct cmd_set_vf_broadcast_result, 14766 broadcast, "broadcast"); 14767 cmdline_parse_token_num_t cmd_set_vf_broadcast_port_id = 14768 TOKEN_NUM_INITIALIZER 14769 (struct cmd_set_vf_broadcast_result, 14770 port_id, UINT16); 14771 cmdline_parse_token_num_t cmd_set_vf_broadcast_vf_id = 14772 TOKEN_NUM_INITIALIZER 14773 (struct cmd_set_vf_broadcast_result, 14774 vf_id, UINT16); 14775 cmdline_parse_token_string_t cmd_set_vf_broadcast_on_off = 14776 TOKEN_STRING_INITIALIZER 14777 (struct cmd_set_vf_broadcast_result, 14778 on_off, "on#off"); 14779 14780 static void 14781 cmd_set_vf_broadcast_parsed( 14782 void *parsed_result, 14783 __attribute__((unused)) struct cmdline *cl, 14784 __attribute__((unused)) void *data) 14785 { 14786 struct cmd_set_vf_broadcast_result *res = parsed_result; 14787 int ret = -ENOTSUP; 14788 14789 __rte_unused int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0; 14790 14791 if (port_id_is_invalid(res->port_id, ENABLED_WARN)) 14792 return; 14793 14794 #ifdef RTE_LIBRTE_I40E_PMD 14795 ret = rte_pmd_i40e_set_vf_broadcast(res->port_id, 14796 res->vf_id, is_on); 14797 #endif 14798 14799 switch (ret) { 14800 case 0: 14801 break; 14802 case -EINVAL: 14803 printf("invalid vf_id %d or is_on %d\n", res->vf_id, is_on); 14804 break; 14805 case -ENODEV: 14806 printf("invalid port_id %d\n", res->port_id); 14807 break; 14808 case -ENOTSUP: 14809 printf("function not implemented\n"); 14810 break; 14811 default: 14812 printf("programming error: (%s)\n", strerror(-ret)); 14813 } 14814 } 14815 14816 cmdline_parse_inst_t cmd_set_vf_broadcast = { 14817 .f = cmd_set_vf_broadcast_parsed, 14818 .data = NULL, 14819 .help_str = "set vf broadcast <port_id> <vf_id> on|off", 14820 .tokens = { 14821 (void *)&cmd_set_vf_broadcast_set, 14822 (void *)&cmd_set_vf_broadcast_vf, 14823 (void *)&cmd_set_vf_broadcast_broadcast, 14824 (void *)&cmd_set_vf_broadcast_port_id, 14825 (void *)&cmd_set_vf_broadcast_vf_id, 14826 (void *)&cmd_set_vf_broadcast_on_off, 14827 NULL, 14828 }, 14829 }; 14830 14831 /* vf vlan tag configuration */ 14832 14833 /* Common result structure for vf vlan tag */ 14834 struct cmd_set_vf_vlan_tag_result { 14835 cmdline_fixed_string_t set; 14836 cmdline_fixed_string_t vf; 14837 cmdline_fixed_string_t vlan; 14838 cmdline_fixed_string_t tag; 14839 portid_t port_id; 14840 uint16_t vf_id; 14841 cmdline_fixed_string_t on_off; 14842 }; 14843 14844 /* Common CLI fields for vf vlan tag enable disable */ 14845 cmdline_parse_token_string_t cmd_set_vf_vlan_tag_set = 14846 TOKEN_STRING_INITIALIZER 14847 (struct cmd_set_vf_vlan_tag_result, 14848 set, "set"); 14849 cmdline_parse_token_string_t cmd_set_vf_vlan_tag_vf = 14850 TOKEN_STRING_INITIALIZER 14851 (struct cmd_set_vf_vlan_tag_result, 14852 vf, "vf"); 14853 cmdline_parse_token_string_t cmd_set_vf_vlan_tag_vlan = 14854 TOKEN_STRING_INITIALIZER 14855 (struct cmd_set_vf_vlan_tag_result, 14856 vlan, "vlan"); 14857 cmdline_parse_token_string_t cmd_set_vf_vlan_tag_tag = 14858 TOKEN_STRING_INITIALIZER 14859 (struct cmd_set_vf_vlan_tag_result, 14860 tag, "tag"); 14861 cmdline_parse_token_num_t cmd_set_vf_vlan_tag_port_id = 14862 TOKEN_NUM_INITIALIZER 14863 (struct cmd_set_vf_vlan_tag_result, 14864 port_id, UINT16); 14865 cmdline_parse_token_num_t cmd_set_vf_vlan_tag_vf_id = 14866 TOKEN_NUM_INITIALIZER 14867 (struct cmd_set_vf_vlan_tag_result, 14868 vf_id, UINT16); 14869 cmdline_parse_token_string_t cmd_set_vf_vlan_tag_on_off = 14870 TOKEN_STRING_INITIALIZER 14871 (struct cmd_set_vf_vlan_tag_result, 14872 on_off, "on#off"); 14873 14874 static void 14875 cmd_set_vf_vlan_tag_parsed( 14876 void *parsed_result, 14877 __attribute__((unused)) struct cmdline *cl, 14878 __attribute__((unused)) void *data) 14879 { 14880 struct cmd_set_vf_vlan_tag_result *res = parsed_result; 14881 int ret = -ENOTSUP; 14882 14883 __rte_unused int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0; 14884 14885 if (port_id_is_invalid(res->port_id, ENABLED_WARN)) 14886 return; 14887 14888 #ifdef RTE_LIBRTE_I40E_PMD 14889 ret = rte_pmd_i40e_set_vf_vlan_tag(res->port_id, 14890 res->vf_id, is_on); 14891 #endif 14892 14893 switch (ret) { 14894 case 0: 14895 break; 14896 case -EINVAL: 14897 printf("invalid vf_id %d or is_on %d\n", res->vf_id, is_on); 14898 break; 14899 case -ENODEV: 14900 printf("invalid port_id %d\n", res->port_id); 14901 break; 14902 case -ENOTSUP: 14903 printf("function not implemented\n"); 14904 break; 14905 default: 14906 printf("programming error: (%s)\n", strerror(-ret)); 14907 } 14908 } 14909 14910 cmdline_parse_inst_t cmd_set_vf_vlan_tag = { 14911 .f = cmd_set_vf_vlan_tag_parsed, 14912 .data = NULL, 14913 .help_str = "set vf vlan tag <port_id> <vf_id> on|off", 14914 .tokens = { 14915 (void *)&cmd_set_vf_vlan_tag_set, 14916 (void *)&cmd_set_vf_vlan_tag_vf, 14917 (void *)&cmd_set_vf_vlan_tag_vlan, 14918 (void *)&cmd_set_vf_vlan_tag_tag, 14919 (void *)&cmd_set_vf_vlan_tag_port_id, 14920 (void *)&cmd_set_vf_vlan_tag_vf_id, 14921 (void *)&cmd_set_vf_vlan_tag_on_off, 14922 NULL, 14923 }, 14924 }; 14925 14926 /* Common definition of VF and TC TX bandwidth configuration */ 14927 struct cmd_vf_tc_bw_result { 14928 cmdline_fixed_string_t set; 14929 cmdline_fixed_string_t vf; 14930 cmdline_fixed_string_t tc; 14931 cmdline_fixed_string_t tx; 14932 cmdline_fixed_string_t min_bw; 14933 cmdline_fixed_string_t max_bw; 14934 cmdline_fixed_string_t strict_link_prio; 14935 portid_t port_id; 14936 uint16_t vf_id; 14937 uint8_t tc_no; 14938 uint32_t bw; 14939 cmdline_fixed_string_t bw_list; 14940 uint8_t tc_map; 14941 }; 14942 14943 cmdline_parse_token_string_t cmd_vf_tc_bw_set = 14944 TOKEN_STRING_INITIALIZER 14945 (struct cmd_vf_tc_bw_result, 14946 set, "set"); 14947 cmdline_parse_token_string_t cmd_vf_tc_bw_vf = 14948 TOKEN_STRING_INITIALIZER 14949 (struct cmd_vf_tc_bw_result, 14950 vf, "vf"); 14951 cmdline_parse_token_string_t cmd_vf_tc_bw_tc = 14952 TOKEN_STRING_INITIALIZER 14953 (struct cmd_vf_tc_bw_result, 14954 tc, "tc"); 14955 cmdline_parse_token_string_t cmd_vf_tc_bw_tx = 14956 TOKEN_STRING_INITIALIZER 14957 (struct cmd_vf_tc_bw_result, 14958 tx, "tx"); 14959 cmdline_parse_token_string_t cmd_vf_tc_bw_strict_link_prio = 14960 TOKEN_STRING_INITIALIZER 14961 (struct cmd_vf_tc_bw_result, 14962 strict_link_prio, "strict-link-priority"); 14963 cmdline_parse_token_string_t cmd_vf_tc_bw_min_bw = 14964 TOKEN_STRING_INITIALIZER 14965 (struct cmd_vf_tc_bw_result, 14966 min_bw, "min-bandwidth"); 14967 cmdline_parse_token_string_t cmd_vf_tc_bw_max_bw = 14968 TOKEN_STRING_INITIALIZER 14969 (struct cmd_vf_tc_bw_result, 14970 max_bw, "max-bandwidth"); 14971 cmdline_parse_token_num_t cmd_vf_tc_bw_port_id = 14972 TOKEN_NUM_INITIALIZER 14973 (struct cmd_vf_tc_bw_result, 14974 port_id, UINT16); 14975 cmdline_parse_token_num_t cmd_vf_tc_bw_vf_id = 14976 TOKEN_NUM_INITIALIZER 14977 (struct cmd_vf_tc_bw_result, 14978 vf_id, UINT16); 14979 cmdline_parse_token_num_t cmd_vf_tc_bw_tc_no = 14980 TOKEN_NUM_INITIALIZER 14981 (struct cmd_vf_tc_bw_result, 14982 tc_no, UINT8); 14983 cmdline_parse_token_num_t cmd_vf_tc_bw_bw = 14984 TOKEN_NUM_INITIALIZER 14985 (struct cmd_vf_tc_bw_result, 14986 bw, UINT32); 14987 cmdline_parse_token_string_t cmd_vf_tc_bw_bw_list = 14988 TOKEN_STRING_INITIALIZER 14989 (struct cmd_vf_tc_bw_result, 14990 bw_list, NULL); 14991 cmdline_parse_token_num_t cmd_vf_tc_bw_tc_map = 14992 TOKEN_NUM_INITIALIZER 14993 (struct cmd_vf_tc_bw_result, 14994 tc_map, UINT8); 14995 14996 /* VF max bandwidth setting */ 14997 static void 14998 cmd_vf_max_bw_parsed( 14999 void *parsed_result, 15000 __attribute__((unused)) struct cmdline *cl, 15001 __attribute__((unused)) void *data) 15002 { 15003 struct cmd_vf_tc_bw_result *res = parsed_result; 15004 int ret = -ENOTSUP; 15005 15006 if (port_id_is_invalid(res->port_id, ENABLED_WARN)) 15007 return; 15008 15009 #ifdef RTE_LIBRTE_I40E_PMD 15010 ret = rte_pmd_i40e_set_vf_max_bw(res->port_id, 15011 res->vf_id, res->bw); 15012 #endif 15013 15014 switch (ret) { 15015 case 0: 15016 break; 15017 case -EINVAL: 15018 printf("invalid vf_id %d or bandwidth %d\n", 15019 res->vf_id, res->bw); 15020 break; 15021 case -ENODEV: 15022 printf("invalid port_id %d\n", res->port_id); 15023 break; 15024 case -ENOTSUP: 15025 printf("function not implemented\n"); 15026 break; 15027 default: 15028 printf("programming error: (%s)\n", strerror(-ret)); 15029 } 15030 } 15031 15032 cmdline_parse_inst_t cmd_vf_max_bw = { 15033 .f = cmd_vf_max_bw_parsed, 15034 .data = NULL, 15035 .help_str = "set vf tx max-bandwidth <port_id> <vf_id> <bandwidth>", 15036 .tokens = { 15037 (void *)&cmd_vf_tc_bw_set, 15038 (void *)&cmd_vf_tc_bw_vf, 15039 (void *)&cmd_vf_tc_bw_tx, 15040 (void *)&cmd_vf_tc_bw_max_bw, 15041 (void *)&cmd_vf_tc_bw_port_id, 15042 (void *)&cmd_vf_tc_bw_vf_id, 15043 (void *)&cmd_vf_tc_bw_bw, 15044 NULL, 15045 }, 15046 }; 15047 15048 static int 15049 vf_tc_min_bw_parse_bw_list(uint8_t *bw_list, 15050 uint8_t *tc_num, 15051 char *str) 15052 { 15053 uint32_t size; 15054 const char *p, *p0 = str; 15055 char s[256]; 15056 char *end; 15057 char *str_fld[16]; 15058 uint16_t i; 15059 int ret; 15060 15061 p = strchr(p0, '('); 15062 if (p == NULL) { 15063 printf("The bandwidth-list should be '(bw1, bw2, ...)'\n"); 15064 return -1; 15065 } 15066 p++; 15067 p0 = strchr(p, ')'); 15068 if (p0 == NULL) { 15069 printf("The bandwidth-list should be '(bw1, bw2, ...)'\n"); 15070 return -1; 15071 } 15072 size = p0 - p; 15073 if (size >= sizeof(s)) { 15074 printf("The string size exceeds the internal buffer size\n"); 15075 return -1; 15076 } 15077 snprintf(s, sizeof(s), "%.*s", size, p); 15078 ret = rte_strsplit(s, sizeof(s), str_fld, 16, ','); 15079 if (ret <= 0) { 15080 printf("Failed to get the bandwidth list. "); 15081 return -1; 15082 } 15083 *tc_num = ret; 15084 for (i = 0; i < ret; i++) 15085 bw_list[i] = (uint8_t)strtoul(str_fld[i], &end, 0); 15086 15087 return 0; 15088 } 15089 15090 /* TC min bandwidth setting */ 15091 static void 15092 cmd_vf_tc_min_bw_parsed( 15093 void *parsed_result, 15094 __attribute__((unused)) struct cmdline *cl, 15095 __attribute__((unused)) void *data) 15096 { 15097 struct cmd_vf_tc_bw_result *res = parsed_result; 15098 uint8_t tc_num; 15099 uint8_t bw[16]; 15100 int ret = -ENOTSUP; 15101 15102 if (port_id_is_invalid(res->port_id, ENABLED_WARN)) 15103 return; 15104 15105 ret = vf_tc_min_bw_parse_bw_list(bw, &tc_num, res->bw_list); 15106 if (ret) 15107 return; 15108 15109 #ifdef RTE_LIBRTE_I40E_PMD 15110 ret = rte_pmd_i40e_set_vf_tc_bw_alloc(res->port_id, res->vf_id, 15111 tc_num, bw); 15112 #endif 15113 15114 switch (ret) { 15115 case 0: 15116 break; 15117 case -EINVAL: 15118 printf("invalid vf_id %d or bandwidth\n", res->vf_id); 15119 break; 15120 case -ENODEV: 15121 printf("invalid port_id %d\n", res->port_id); 15122 break; 15123 case -ENOTSUP: 15124 printf("function not implemented\n"); 15125 break; 15126 default: 15127 printf("programming error: (%s)\n", strerror(-ret)); 15128 } 15129 } 15130 15131 cmdline_parse_inst_t cmd_vf_tc_min_bw = { 15132 .f = cmd_vf_tc_min_bw_parsed, 15133 .data = NULL, 15134 .help_str = "set vf tc tx min-bandwidth <port_id> <vf_id>" 15135 " <bw1, bw2, ...>", 15136 .tokens = { 15137 (void *)&cmd_vf_tc_bw_set, 15138 (void *)&cmd_vf_tc_bw_vf, 15139 (void *)&cmd_vf_tc_bw_tc, 15140 (void *)&cmd_vf_tc_bw_tx, 15141 (void *)&cmd_vf_tc_bw_min_bw, 15142 (void *)&cmd_vf_tc_bw_port_id, 15143 (void *)&cmd_vf_tc_bw_vf_id, 15144 (void *)&cmd_vf_tc_bw_bw_list, 15145 NULL, 15146 }, 15147 }; 15148 15149 static void 15150 cmd_tc_min_bw_parsed( 15151 void *parsed_result, 15152 __attribute__((unused)) struct cmdline *cl, 15153 __attribute__((unused)) void *data) 15154 { 15155 struct cmd_vf_tc_bw_result *res = parsed_result; 15156 struct rte_port *port; 15157 uint8_t tc_num; 15158 uint8_t bw[16]; 15159 int ret = -ENOTSUP; 15160 15161 if (port_id_is_invalid(res->port_id, ENABLED_WARN)) 15162 return; 15163 15164 port = &ports[res->port_id]; 15165 /** Check if the port is not started **/ 15166 if (port->port_status != RTE_PORT_STOPPED) { 15167 printf("Please stop port %d first\n", res->port_id); 15168 return; 15169 } 15170 15171 ret = vf_tc_min_bw_parse_bw_list(bw, &tc_num, res->bw_list); 15172 if (ret) 15173 return; 15174 15175 #ifdef RTE_LIBRTE_IXGBE_PMD 15176 ret = rte_pmd_ixgbe_set_tc_bw_alloc(res->port_id, tc_num, bw); 15177 #endif 15178 15179 switch (ret) { 15180 case 0: 15181 break; 15182 case -EINVAL: 15183 printf("invalid bandwidth\n"); 15184 break; 15185 case -ENODEV: 15186 printf("invalid port_id %d\n", res->port_id); 15187 break; 15188 case -ENOTSUP: 15189 printf("function not implemented\n"); 15190 break; 15191 default: 15192 printf("programming error: (%s)\n", strerror(-ret)); 15193 } 15194 } 15195 15196 cmdline_parse_inst_t cmd_tc_min_bw = { 15197 .f = cmd_tc_min_bw_parsed, 15198 .data = NULL, 15199 .help_str = "set tc tx min-bandwidth <port_id> <bw1, bw2, ...>", 15200 .tokens = { 15201 (void *)&cmd_vf_tc_bw_set, 15202 (void *)&cmd_vf_tc_bw_tc, 15203 (void *)&cmd_vf_tc_bw_tx, 15204 (void *)&cmd_vf_tc_bw_min_bw, 15205 (void *)&cmd_vf_tc_bw_port_id, 15206 (void *)&cmd_vf_tc_bw_bw_list, 15207 NULL, 15208 }, 15209 }; 15210 15211 /* TC max bandwidth setting */ 15212 static void 15213 cmd_vf_tc_max_bw_parsed( 15214 void *parsed_result, 15215 __attribute__((unused)) struct cmdline *cl, 15216 __attribute__((unused)) void *data) 15217 { 15218 struct cmd_vf_tc_bw_result *res = parsed_result; 15219 int ret = -ENOTSUP; 15220 15221 if (port_id_is_invalid(res->port_id, ENABLED_WARN)) 15222 return; 15223 15224 #ifdef RTE_LIBRTE_I40E_PMD 15225 ret = rte_pmd_i40e_set_vf_tc_max_bw(res->port_id, res->vf_id, 15226 res->tc_no, res->bw); 15227 #endif 15228 15229 switch (ret) { 15230 case 0: 15231 break; 15232 case -EINVAL: 15233 printf("invalid vf_id %d, tc_no %d or bandwidth %d\n", 15234 res->vf_id, res->tc_no, res->bw); 15235 break; 15236 case -ENODEV: 15237 printf("invalid port_id %d\n", res->port_id); 15238 break; 15239 case -ENOTSUP: 15240 printf("function not implemented\n"); 15241 break; 15242 default: 15243 printf("programming error: (%s)\n", strerror(-ret)); 15244 } 15245 } 15246 15247 cmdline_parse_inst_t cmd_vf_tc_max_bw = { 15248 .f = cmd_vf_tc_max_bw_parsed, 15249 .data = NULL, 15250 .help_str = "set vf tc tx max-bandwidth <port_id> <vf_id> <tc_no>" 15251 " <bandwidth>", 15252 .tokens = { 15253 (void *)&cmd_vf_tc_bw_set, 15254 (void *)&cmd_vf_tc_bw_vf, 15255 (void *)&cmd_vf_tc_bw_tc, 15256 (void *)&cmd_vf_tc_bw_tx, 15257 (void *)&cmd_vf_tc_bw_max_bw, 15258 (void *)&cmd_vf_tc_bw_port_id, 15259 (void *)&cmd_vf_tc_bw_vf_id, 15260 (void *)&cmd_vf_tc_bw_tc_no, 15261 (void *)&cmd_vf_tc_bw_bw, 15262 NULL, 15263 }, 15264 }; 15265 15266 15267 #if defined RTE_LIBRTE_PMD_SOFTNIC && defined RTE_LIBRTE_SCHED 15268 15269 /* *** Set Port default Traffic Management Hierarchy *** */ 15270 struct cmd_set_port_tm_hierarchy_default_result { 15271 cmdline_fixed_string_t set; 15272 cmdline_fixed_string_t port; 15273 cmdline_fixed_string_t tm; 15274 cmdline_fixed_string_t hierarchy; 15275 cmdline_fixed_string_t def; 15276 portid_t port_id; 15277 }; 15278 15279 cmdline_parse_token_string_t cmd_set_port_tm_hierarchy_default_set = 15280 TOKEN_STRING_INITIALIZER( 15281 struct cmd_set_port_tm_hierarchy_default_result, set, "set"); 15282 cmdline_parse_token_string_t cmd_set_port_tm_hierarchy_default_port = 15283 TOKEN_STRING_INITIALIZER( 15284 struct cmd_set_port_tm_hierarchy_default_result, port, "port"); 15285 cmdline_parse_token_string_t cmd_set_port_tm_hierarchy_default_tm = 15286 TOKEN_STRING_INITIALIZER( 15287 struct cmd_set_port_tm_hierarchy_default_result, tm, "tm"); 15288 cmdline_parse_token_string_t cmd_set_port_tm_hierarchy_default_hierarchy = 15289 TOKEN_STRING_INITIALIZER( 15290 struct cmd_set_port_tm_hierarchy_default_result, 15291 hierarchy, "hierarchy"); 15292 cmdline_parse_token_string_t cmd_set_port_tm_hierarchy_default_default = 15293 TOKEN_STRING_INITIALIZER( 15294 struct cmd_set_port_tm_hierarchy_default_result, 15295 def, "default"); 15296 cmdline_parse_token_num_t cmd_set_port_tm_hierarchy_default_port_id = 15297 TOKEN_NUM_INITIALIZER( 15298 struct cmd_set_port_tm_hierarchy_default_result, 15299 port_id, UINT16); 15300 15301 static void cmd_set_port_tm_hierarchy_default_parsed(void *parsed_result, 15302 __attribute__((unused)) struct cmdline *cl, 15303 __attribute__((unused)) void *data) 15304 { 15305 struct cmd_set_port_tm_hierarchy_default_result *res = parsed_result; 15306 struct rte_port *p; 15307 portid_t port_id = res->port_id; 15308 15309 if (port_id_is_invalid(port_id, ENABLED_WARN)) 15310 return; 15311 15312 p = &ports[port_id]; 15313 15314 /* Forward mode: tm */ 15315 if (strcmp(cur_fwd_config.fwd_eng->fwd_mode_name, "softnic")) { 15316 printf(" softnicfwd mode not enabled(error)\n"); 15317 return; 15318 } 15319 15320 /* Set the default tm hierarchy */ 15321 p->softport.default_tm_hierarchy_enable = 1; 15322 } 15323 15324 cmdline_parse_inst_t cmd_set_port_tm_hierarchy_default = { 15325 .f = cmd_set_port_tm_hierarchy_default_parsed, 15326 .data = NULL, 15327 .help_str = "set port tm hierarchy default <port_id>", 15328 .tokens = { 15329 (void *)&cmd_set_port_tm_hierarchy_default_set, 15330 (void *)&cmd_set_port_tm_hierarchy_default_port, 15331 (void *)&cmd_set_port_tm_hierarchy_default_tm, 15332 (void *)&cmd_set_port_tm_hierarchy_default_hierarchy, 15333 (void *)&cmd_set_port_tm_hierarchy_default_default, 15334 (void *)&cmd_set_port_tm_hierarchy_default_port_id, 15335 NULL, 15336 }, 15337 }; 15338 #endif 15339 15340 /** Set VXLAN encapsulation details */ 15341 struct cmd_set_vxlan_result { 15342 cmdline_fixed_string_t set; 15343 cmdline_fixed_string_t vxlan; 15344 cmdline_fixed_string_t pos_token; 15345 cmdline_fixed_string_t ip_version; 15346 uint32_t vlan_present:1; 15347 uint32_t vni; 15348 uint16_t udp_src; 15349 uint16_t udp_dst; 15350 cmdline_ipaddr_t ip_src; 15351 cmdline_ipaddr_t ip_dst; 15352 uint16_t tci; 15353 uint8_t tos; 15354 uint8_t ttl; 15355 struct rte_ether_addr eth_src; 15356 struct rte_ether_addr eth_dst; 15357 }; 15358 15359 cmdline_parse_token_string_t cmd_set_vxlan_set = 15360 TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, set, "set"); 15361 cmdline_parse_token_string_t cmd_set_vxlan_vxlan = 15362 TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, vxlan, "vxlan"); 15363 cmdline_parse_token_string_t cmd_set_vxlan_vxlan_tos_ttl = 15364 TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, vxlan, 15365 "vxlan-tos-ttl"); 15366 cmdline_parse_token_string_t cmd_set_vxlan_vxlan_with_vlan = 15367 TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, vxlan, 15368 "vxlan-with-vlan"); 15369 cmdline_parse_token_string_t cmd_set_vxlan_ip_version = 15370 TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, pos_token, 15371 "ip-version"); 15372 cmdline_parse_token_string_t cmd_set_vxlan_ip_version_value = 15373 TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, ip_version, 15374 "ipv4#ipv6"); 15375 cmdline_parse_token_string_t cmd_set_vxlan_vni = 15376 TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, pos_token, 15377 "vni"); 15378 cmdline_parse_token_num_t cmd_set_vxlan_vni_value = 15379 TOKEN_NUM_INITIALIZER(struct cmd_set_vxlan_result, vni, UINT32); 15380 cmdline_parse_token_string_t cmd_set_vxlan_udp_src = 15381 TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, pos_token, 15382 "udp-src"); 15383 cmdline_parse_token_num_t cmd_set_vxlan_udp_src_value = 15384 TOKEN_NUM_INITIALIZER(struct cmd_set_vxlan_result, udp_src, UINT16); 15385 cmdline_parse_token_string_t cmd_set_vxlan_udp_dst = 15386 TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, pos_token, 15387 "udp-dst"); 15388 cmdline_parse_token_num_t cmd_set_vxlan_udp_dst_value = 15389 TOKEN_NUM_INITIALIZER(struct cmd_set_vxlan_result, udp_dst, UINT16); 15390 cmdline_parse_token_string_t cmd_set_vxlan_ip_tos = 15391 TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, pos_token, 15392 "ip-tos"); 15393 cmdline_parse_token_num_t cmd_set_vxlan_ip_tos_value = 15394 TOKEN_NUM_INITIALIZER(struct cmd_set_vxlan_result, tos, UINT8); 15395 cmdline_parse_token_string_t cmd_set_vxlan_ip_ttl = 15396 TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, pos_token, 15397 "ip-ttl"); 15398 cmdline_parse_token_num_t cmd_set_vxlan_ip_ttl_value = 15399 TOKEN_NUM_INITIALIZER(struct cmd_set_vxlan_result, ttl, UINT8); 15400 cmdline_parse_token_string_t cmd_set_vxlan_ip_src = 15401 TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, pos_token, 15402 "ip-src"); 15403 cmdline_parse_token_ipaddr_t cmd_set_vxlan_ip_src_value = 15404 TOKEN_IPADDR_INITIALIZER(struct cmd_set_vxlan_result, ip_src); 15405 cmdline_parse_token_string_t cmd_set_vxlan_ip_dst = 15406 TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, pos_token, 15407 "ip-dst"); 15408 cmdline_parse_token_ipaddr_t cmd_set_vxlan_ip_dst_value = 15409 TOKEN_IPADDR_INITIALIZER(struct cmd_set_vxlan_result, ip_dst); 15410 cmdline_parse_token_string_t cmd_set_vxlan_vlan = 15411 TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, pos_token, 15412 "vlan-tci"); 15413 cmdline_parse_token_num_t cmd_set_vxlan_vlan_value = 15414 TOKEN_NUM_INITIALIZER(struct cmd_set_vxlan_result, tci, UINT16); 15415 cmdline_parse_token_string_t cmd_set_vxlan_eth_src = 15416 TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, pos_token, 15417 "eth-src"); 15418 cmdline_parse_token_etheraddr_t cmd_set_vxlan_eth_src_value = 15419 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_vxlan_result, eth_src); 15420 cmdline_parse_token_string_t cmd_set_vxlan_eth_dst = 15421 TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, pos_token, 15422 "eth-dst"); 15423 cmdline_parse_token_etheraddr_t cmd_set_vxlan_eth_dst_value = 15424 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_vxlan_result, eth_dst); 15425 15426 static void cmd_set_vxlan_parsed(void *parsed_result, 15427 __attribute__((unused)) struct cmdline *cl, 15428 __attribute__((unused)) void *data) 15429 { 15430 struct cmd_set_vxlan_result *res = parsed_result; 15431 union { 15432 uint32_t vxlan_id; 15433 uint8_t vni[4]; 15434 } id = { 15435 .vxlan_id = rte_cpu_to_be_32(res->vni) & RTE_BE32(0x00ffffff), 15436 }; 15437 15438 vxlan_encap_conf.select_tos_ttl = 0; 15439 if (strcmp(res->vxlan, "vxlan") == 0) 15440 vxlan_encap_conf.select_vlan = 0; 15441 else if (strcmp(res->vxlan, "vxlan-with-vlan") == 0) 15442 vxlan_encap_conf.select_vlan = 1; 15443 else if (strcmp(res->vxlan, "vxlan-tos-ttl") == 0) { 15444 vxlan_encap_conf.select_vlan = 0; 15445 vxlan_encap_conf.select_tos_ttl = 1; 15446 } 15447 if (strcmp(res->ip_version, "ipv4") == 0) 15448 vxlan_encap_conf.select_ipv4 = 1; 15449 else if (strcmp(res->ip_version, "ipv6") == 0) 15450 vxlan_encap_conf.select_ipv4 = 0; 15451 else 15452 return; 15453 rte_memcpy(vxlan_encap_conf.vni, &id.vni[1], 3); 15454 vxlan_encap_conf.udp_src = rte_cpu_to_be_16(res->udp_src); 15455 vxlan_encap_conf.udp_dst = rte_cpu_to_be_16(res->udp_dst); 15456 vxlan_encap_conf.ip_tos = res->tos; 15457 vxlan_encap_conf.ip_ttl = res->ttl; 15458 if (vxlan_encap_conf.select_ipv4) { 15459 IPV4_ADDR_TO_UINT(res->ip_src, vxlan_encap_conf.ipv4_src); 15460 IPV4_ADDR_TO_UINT(res->ip_dst, vxlan_encap_conf.ipv4_dst); 15461 } else { 15462 IPV6_ADDR_TO_ARRAY(res->ip_src, vxlan_encap_conf.ipv6_src); 15463 IPV6_ADDR_TO_ARRAY(res->ip_dst, vxlan_encap_conf.ipv6_dst); 15464 } 15465 if (vxlan_encap_conf.select_vlan) 15466 vxlan_encap_conf.vlan_tci = rte_cpu_to_be_16(res->tci); 15467 rte_memcpy(vxlan_encap_conf.eth_src, res->eth_src.addr_bytes, 15468 RTE_ETHER_ADDR_LEN); 15469 rte_memcpy(vxlan_encap_conf.eth_dst, res->eth_dst.addr_bytes, 15470 RTE_ETHER_ADDR_LEN); 15471 } 15472 15473 cmdline_parse_inst_t cmd_set_vxlan = { 15474 .f = cmd_set_vxlan_parsed, 15475 .data = NULL, 15476 .help_str = "set vxlan ip-version ipv4|ipv6 vni <vni> udp-src" 15477 " <udp-src> udp-dst <udp-dst> ip-src <ip-src> ip-dst <ip-dst>" 15478 " eth-src <eth-src> eth-dst <eth-dst>", 15479 .tokens = { 15480 (void *)&cmd_set_vxlan_set, 15481 (void *)&cmd_set_vxlan_vxlan, 15482 (void *)&cmd_set_vxlan_ip_version, 15483 (void *)&cmd_set_vxlan_ip_version_value, 15484 (void *)&cmd_set_vxlan_vni, 15485 (void *)&cmd_set_vxlan_vni_value, 15486 (void *)&cmd_set_vxlan_udp_src, 15487 (void *)&cmd_set_vxlan_udp_src_value, 15488 (void *)&cmd_set_vxlan_udp_dst, 15489 (void *)&cmd_set_vxlan_udp_dst_value, 15490 (void *)&cmd_set_vxlan_ip_src, 15491 (void *)&cmd_set_vxlan_ip_src_value, 15492 (void *)&cmd_set_vxlan_ip_dst, 15493 (void *)&cmd_set_vxlan_ip_dst_value, 15494 (void *)&cmd_set_vxlan_eth_src, 15495 (void *)&cmd_set_vxlan_eth_src_value, 15496 (void *)&cmd_set_vxlan_eth_dst, 15497 (void *)&cmd_set_vxlan_eth_dst_value, 15498 NULL, 15499 }, 15500 }; 15501 15502 cmdline_parse_inst_t cmd_set_vxlan_tos_ttl = { 15503 .f = cmd_set_vxlan_parsed, 15504 .data = NULL, 15505 .help_str = "set vxlan-tos-ttl ip-version ipv4|ipv6 vni <vni> udp-src" 15506 " <udp-src> udp-dst <udp-dst> ip-tos <ip-tos> ip-ttl <ip-ttl>" 15507 " ip-src <ip-src> ip-dst <ip-dst> eth-src <eth-src>" 15508 " eth-dst <eth-dst>", 15509 .tokens = { 15510 (void *)&cmd_set_vxlan_set, 15511 (void *)&cmd_set_vxlan_vxlan_tos_ttl, 15512 (void *)&cmd_set_vxlan_ip_version, 15513 (void *)&cmd_set_vxlan_ip_version_value, 15514 (void *)&cmd_set_vxlan_vni, 15515 (void *)&cmd_set_vxlan_vni_value, 15516 (void *)&cmd_set_vxlan_udp_src, 15517 (void *)&cmd_set_vxlan_udp_src_value, 15518 (void *)&cmd_set_vxlan_udp_dst, 15519 (void *)&cmd_set_vxlan_udp_dst_value, 15520 (void *)&cmd_set_vxlan_ip_tos, 15521 (void *)&cmd_set_vxlan_ip_tos_value, 15522 (void *)&cmd_set_vxlan_ip_ttl, 15523 (void *)&cmd_set_vxlan_ip_ttl_value, 15524 (void *)&cmd_set_vxlan_ip_src, 15525 (void *)&cmd_set_vxlan_ip_src_value, 15526 (void *)&cmd_set_vxlan_ip_dst, 15527 (void *)&cmd_set_vxlan_ip_dst_value, 15528 (void *)&cmd_set_vxlan_eth_src, 15529 (void *)&cmd_set_vxlan_eth_src_value, 15530 (void *)&cmd_set_vxlan_eth_dst, 15531 (void *)&cmd_set_vxlan_eth_dst_value, 15532 NULL, 15533 }, 15534 }; 15535 15536 cmdline_parse_inst_t cmd_set_vxlan_with_vlan = { 15537 .f = cmd_set_vxlan_parsed, 15538 .data = NULL, 15539 .help_str = "set vxlan-with-vlan ip-version ipv4|ipv6 vni <vni>" 15540 " udp-src <udp-src> udp-dst <udp-dst> ip-src <ip-src> ip-dst" 15541 " <ip-dst> vlan-tci <vlan-tci> eth-src <eth-src> eth-dst" 15542 " <eth-dst>", 15543 .tokens = { 15544 (void *)&cmd_set_vxlan_set, 15545 (void *)&cmd_set_vxlan_vxlan_with_vlan, 15546 (void *)&cmd_set_vxlan_ip_version, 15547 (void *)&cmd_set_vxlan_ip_version_value, 15548 (void *)&cmd_set_vxlan_vni, 15549 (void *)&cmd_set_vxlan_vni_value, 15550 (void *)&cmd_set_vxlan_udp_src, 15551 (void *)&cmd_set_vxlan_udp_src_value, 15552 (void *)&cmd_set_vxlan_udp_dst, 15553 (void *)&cmd_set_vxlan_udp_dst_value, 15554 (void *)&cmd_set_vxlan_ip_src, 15555 (void *)&cmd_set_vxlan_ip_src_value, 15556 (void *)&cmd_set_vxlan_ip_dst, 15557 (void *)&cmd_set_vxlan_ip_dst_value, 15558 (void *)&cmd_set_vxlan_vlan, 15559 (void *)&cmd_set_vxlan_vlan_value, 15560 (void *)&cmd_set_vxlan_eth_src, 15561 (void *)&cmd_set_vxlan_eth_src_value, 15562 (void *)&cmd_set_vxlan_eth_dst, 15563 (void *)&cmd_set_vxlan_eth_dst_value, 15564 NULL, 15565 }, 15566 }; 15567 15568 /** Set NVGRE encapsulation details */ 15569 struct cmd_set_nvgre_result { 15570 cmdline_fixed_string_t set; 15571 cmdline_fixed_string_t nvgre; 15572 cmdline_fixed_string_t pos_token; 15573 cmdline_fixed_string_t ip_version; 15574 uint32_t tni; 15575 cmdline_ipaddr_t ip_src; 15576 cmdline_ipaddr_t ip_dst; 15577 uint16_t tci; 15578 struct rte_ether_addr eth_src; 15579 struct rte_ether_addr eth_dst; 15580 }; 15581 15582 cmdline_parse_token_string_t cmd_set_nvgre_set = 15583 TOKEN_STRING_INITIALIZER(struct cmd_set_nvgre_result, set, "set"); 15584 cmdline_parse_token_string_t cmd_set_nvgre_nvgre = 15585 TOKEN_STRING_INITIALIZER(struct cmd_set_nvgre_result, nvgre, "nvgre"); 15586 cmdline_parse_token_string_t cmd_set_nvgre_nvgre_with_vlan = 15587 TOKEN_STRING_INITIALIZER(struct cmd_set_nvgre_result, nvgre, 15588 "nvgre-with-vlan"); 15589 cmdline_parse_token_string_t cmd_set_nvgre_ip_version = 15590 TOKEN_STRING_INITIALIZER(struct cmd_set_nvgre_result, pos_token, 15591 "ip-version"); 15592 cmdline_parse_token_string_t cmd_set_nvgre_ip_version_value = 15593 TOKEN_STRING_INITIALIZER(struct cmd_set_nvgre_result, ip_version, 15594 "ipv4#ipv6"); 15595 cmdline_parse_token_string_t cmd_set_nvgre_tni = 15596 TOKEN_STRING_INITIALIZER(struct cmd_set_nvgre_result, pos_token, 15597 "tni"); 15598 cmdline_parse_token_num_t cmd_set_nvgre_tni_value = 15599 TOKEN_NUM_INITIALIZER(struct cmd_set_nvgre_result, tni, UINT32); 15600 cmdline_parse_token_string_t cmd_set_nvgre_ip_src = 15601 TOKEN_STRING_INITIALIZER(struct cmd_set_nvgre_result, pos_token, 15602 "ip-src"); 15603 cmdline_parse_token_num_t cmd_set_nvgre_ip_src_value = 15604 TOKEN_IPADDR_INITIALIZER(struct cmd_set_nvgre_result, ip_src); 15605 cmdline_parse_token_string_t cmd_set_nvgre_ip_dst = 15606 TOKEN_STRING_INITIALIZER(struct cmd_set_nvgre_result, pos_token, 15607 "ip-dst"); 15608 cmdline_parse_token_ipaddr_t cmd_set_nvgre_ip_dst_value = 15609 TOKEN_IPADDR_INITIALIZER(struct cmd_set_nvgre_result, ip_dst); 15610 cmdline_parse_token_string_t cmd_set_nvgre_vlan = 15611 TOKEN_STRING_INITIALIZER(struct cmd_set_nvgre_result, pos_token, 15612 "vlan-tci"); 15613 cmdline_parse_token_num_t cmd_set_nvgre_vlan_value = 15614 TOKEN_NUM_INITIALIZER(struct cmd_set_nvgre_result, tci, UINT16); 15615 cmdline_parse_token_string_t cmd_set_nvgre_eth_src = 15616 TOKEN_STRING_INITIALIZER(struct cmd_set_nvgre_result, pos_token, 15617 "eth-src"); 15618 cmdline_parse_token_etheraddr_t cmd_set_nvgre_eth_src_value = 15619 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_nvgre_result, eth_src); 15620 cmdline_parse_token_string_t cmd_set_nvgre_eth_dst = 15621 TOKEN_STRING_INITIALIZER(struct cmd_set_nvgre_result, pos_token, 15622 "eth-dst"); 15623 cmdline_parse_token_etheraddr_t cmd_set_nvgre_eth_dst_value = 15624 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_nvgre_result, eth_dst); 15625 15626 static void cmd_set_nvgre_parsed(void *parsed_result, 15627 __attribute__((unused)) struct cmdline *cl, 15628 __attribute__((unused)) void *data) 15629 { 15630 struct cmd_set_nvgre_result *res = parsed_result; 15631 union { 15632 uint32_t nvgre_tni; 15633 uint8_t tni[4]; 15634 } id = { 15635 .nvgre_tni = rte_cpu_to_be_32(res->tni) & RTE_BE32(0x00ffffff), 15636 }; 15637 15638 if (strcmp(res->nvgre, "nvgre") == 0) 15639 nvgre_encap_conf.select_vlan = 0; 15640 else if (strcmp(res->nvgre, "nvgre-with-vlan") == 0) 15641 nvgre_encap_conf.select_vlan = 1; 15642 if (strcmp(res->ip_version, "ipv4") == 0) 15643 nvgre_encap_conf.select_ipv4 = 1; 15644 else if (strcmp(res->ip_version, "ipv6") == 0) 15645 nvgre_encap_conf.select_ipv4 = 0; 15646 else 15647 return; 15648 rte_memcpy(nvgre_encap_conf.tni, &id.tni[1], 3); 15649 if (nvgre_encap_conf.select_ipv4) { 15650 IPV4_ADDR_TO_UINT(res->ip_src, nvgre_encap_conf.ipv4_src); 15651 IPV4_ADDR_TO_UINT(res->ip_dst, nvgre_encap_conf.ipv4_dst); 15652 } else { 15653 IPV6_ADDR_TO_ARRAY(res->ip_src, nvgre_encap_conf.ipv6_src); 15654 IPV6_ADDR_TO_ARRAY(res->ip_dst, nvgre_encap_conf.ipv6_dst); 15655 } 15656 if (nvgre_encap_conf.select_vlan) 15657 nvgre_encap_conf.vlan_tci = rte_cpu_to_be_16(res->tci); 15658 rte_memcpy(nvgre_encap_conf.eth_src, res->eth_src.addr_bytes, 15659 RTE_ETHER_ADDR_LEN); 15660 rte_memcpy(nvgre_encap_conf.eth_dst, res->eth_dst.addr_bytes, 15661 RTE_ETHER_ADDR_LEN); 15662 } 15663 15664 cmdline_parse_inst_t cmd_set_nvgre = { 15665 .f = cmd_set_nvgre_parsed, 15666 .data = NULL, 15667 .help_str = "set nvgre ip-version <ipv4|ipv6> tni <tni> ip-src" 15668 " <ip-src> ip-dst <ip-dst> eth-src <eth-src>" 15669 " eth-dst <eth-dst>", 15670 .tokens = { 15671 (void *)&cmd_set_nvgre_set, 15672 (void *)&cmd_set_nvgre_nvgre, 15673 (void *)&cmd_set_nvgre_ip_version, 15674 (void *)&cmd_set_nvgre_ip_version_value, 15675 (void *)&cmd_set_nvgre_tni, 15676 (void *)&cmd_set_nvgre_tni_value, 15677 (void *)&cmd_set_nvgre_ip_src, 15678 (void *)&cmd_set_nvgre_ip_src_value, 15679 (void *)&cmd_set_nvgre_ip_dst, 15680 (void *)&cmd_set_nvgre_ip_dst_value, 15681 (void *)&cmd_set_nvgre_eth_src, 15682 (void *)&cmd_set_nvgre_eth_src_value, 15683 (void *)&cmd_set_nvgre_eth_dst, 15684 (void *)&cmd_set_nvgre_eth_dst_value, 15685 NULL, 15686 }, 15687 }; 15688 15689 cmdline_parse_inst_t cmd_set_nvgre_with_vlan = { 15690 .f = cmd_set_nvgre_parsed, 15691 .data = NULL, 15692 .help_str = "set nvgre-with-vlan ip-version <ipv4|ipv6> tni <tni>" 15693 " ip-src <ip-src> ip-dst <ip-dst> vlan-tci <vlan-tci>" 15694 " eth-src <eth-src> eth-dst <eth-dst>", 15695 .tokens = { 15696 (void *)&cmd_set_nvgre_set, 15697 (void *)&cmd_set_nvgre_nvgre_with_vlan, 15698 (void *)&cmd_set_nvgre_ip_version, 15699 (void *)&cmd_set_nvgre_ip_version_value, 15700 (void *)&cmd_set_nvgre_tni, 15701 (void *)&cmd_set_nvgre_tni_value, 15702 (void *)&cmd_set_nvgre_ip_src, 15703 (void *)&cmd_set_nvgre_ip_src_value, 15704 (void *)&cmd_set_nvgre_ip_dst, 15705 (void *)&cmd_set_nvgre_ip_dst_value, 15706 (void *)&cmd_set_nvgre_vlan, 15707 (void *)&cmd_set_nvgre_vlan_value, 15708 (void *)&cmd_set_nvgre_eth_src, 15709 (void *)&cmd_set_nvgre_eth_src_value, 15710 (void *)&cmd_set_nvgre_eth_dst, 15711 (void *)&cmd_set_nvgre_eth_dst_value, 15712 NULL, 15713 }, 15714 }; 15715 15716 /** Set L2 encapsulation details */ 15717 struct cmd_set_l2_encap_result { 15718 cmdline_fixed_string_t set; 15719 cmdline_fixed_string_t l2_encap; 15720 cmdline_fixed_string_t pos_token; 15721 cmdline_fixed_string_t ip_version; 15722 uint32_t vlan_present:1; 15723 uint16_t tci; 15724 struct rte_ether_addr eth_src; 15725 struct rte_ether_addr eth_dst; 15726 }; 15727 15728 cmdline_parse_token_string_t cmd_set_l2_encap_set = 15729 TOKEN_STRING_INITIALIZER(struct cmd_set_l2_encap_result, set, "set"); 15730 cmdline_parse_token_string_t cmd_set_l2_encap_l2_encap = 15731 TOKEN_STRING_INITIALIZER(struct cmd_set_l2_encap_result, l2_encap, "l2_encap"); 15732 cmdline_parse_token_string_t cmd_set_l2_encap_l2_encap_with_vlan = 15733 TOKEN_STRING_INITIALIZER(struct cmd_set_l2_encap_result, l2_encap, 15734 "l2_encap-with-vlan"); 15735 cmdline_parse_token_string_t cmd_set_l2_encap_ip_version = 15736 TOKEN_STRING_INITIALIZER(struct cmd_set_l2_encap_result, pos_token, 15737 "ip-version"); 15738 cmdline_parse_token_string_t cmd_set_l2_encap_ip_version_value = 15739 TOKEN_STRING_INITIALIZER(struct cmd_set_l2_encap_result, ip_version, 15740 "ipv4#ipv6"); 15741 cmdline_parse_token_string_t cmd_set_l2_encap_vlan = 15742 TOKEN_STRING_INITIALIZER(struct cmd_set_l2_encap_result, pos_token, 15743 "vlan-tci"); 15744 cmdline_parse_token_num_t cmd_set_l2_encap_vlan_value = 15745 TOKEN_NUM_INITIALIZER(struct cmd_set_l2_encap_result, tci, UINT16); 15746 cmdline_parse_token_string_t cmd_set_l2_encap_eth_src = 15747 TOKEN_STRING_INITIALIZER(struct cmd_set_l2_encap_result, pos_token, 15748 "eth-src"); 15749 cmdline_parse_token_etheraddr_t cmd_set_l2_encap_eth_src_value = 15750 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_l2_encap_result, eth_src); 15751 cmdline_parse_token_string_t cmd_set_l2_encap_eth_dst = 15752 TOKEN_STRING_INITIALIZER(struct cmd_set_l2_encap_result, pos_token, 15753 "eth-dst"); 15754 cmdline_parse_token_etheraddr_t cmd_set_l2_encap_eth_dst_value = 15755 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_l2_encap_result, eth_dst); 15756 15757 static void cmd_set_l2_encap_parsed(void *parsed_result, 15758 __attribute__((unused)) struct cmdline *cl, 15759 __attribute__((unused)) void *data) 15760 { 15761 struct cmd_set_l2_encap_result *res = parsed_result; 15762 15763 if (strcmp(res->l2_encap, "l2_encap") == 0) 15764 l2_encap_conf.select_vlan = 0; 15765 else if (strcmp(res->l2_encap, "l2_encap-with-vlan") == 0) 15766 l2_encap_conf.select_vlan = 1; 15767 if (strcmp(res->ip_version, "ipv4") == 0) 15768 l2_encap_conf.select_ipv4 = 1; 15769 else if (strcmp(res->ip_version, "ipv6") == 0) 15770 l2_encap_conf.select_ipv4 = 0; 15771 else 15772 return; 15773 if (l2_encap_conf.select_vlan) 15774 l2_encap_conf.vlan_tci = rte_cpu_to_be_16(res->tci); 15775 rte_memcpy(l2_encap_conf.eth_src, res->eth_src.addr_bytes, 15776 RTE_ETHER_ADDR_LEN); 15777 rte_memcpy(l2_encap_conf.eth_dst, res->eth_dst.addr_bytes, 15778 RTE_ETHER_ADDR_LEN); 15779 } 15780 15781 cmdline_parse_inst_t cmd_set_l2_encap = { 15782 .f = cmd_set_l2_encap_parsed, 15783 .data = NULL, 15784 .help_str = "set l2_encap ip-version ipv4|ipv6" 15785 " eth-src <eth-src> eth-dst <eth-dst>", 15786 .tokens = { 15787 (void *)&cmd_set_l2_encap_set, 15788 (void *)&cmd_set_l2_encap_l2_encap, 15789 (void *)&cmd_set_l2_encap_ip_version, 15790 (void *)&cmd_set_l2_encap_ip_version_value, 15791 (void *)&cmd_set_l2_encap_eth_src, 15792 (void *)&cmd_set_l2_encap_eth_src_value, 15793 (void *)&cmd_set_l2_encap_eth_dst, 15794 (void *)&cmd_set_l2_encap_eth_dst_value, 15795 NULL, 15796 }, 15797 }; 15798 15799 cmdline_parse_inst_t cmd_set_l2_encap_with_vlan = { 15800 .f = cmd_set_l2_encap_parsed, 15801 .data = NULL, 15802 .help_str = "set l2_encap-with-vlan ip-version ipv4|ipv6" 15803 " vlan-tci <vlan-tci> eth-src <eth-src> eth-dst <eth-dst>", 15804 .tokens = { 15805 (void *)&cmd_set_l2_encap_set, 15806 (void *)&cmd_set_l2_encap_l2_encap_with_vlan, 15807 (void *)&cmd_set_l2_encap_ip_version, 15808 (void *)&cmd_set_l2_encap_ip_version_value, 15809 (void *)&cmd_set_l2_encap_vlan, 15810 (void *)&cmd_set_l2_encap_vlan_value, 15811 (void *)&cmd_set_l2_encap_eth_src, 15812 (void *)&cmd_set_l2_encap_eth_src_value, 15813 (void *)&cmd_set_l2_encap_eth_dst, 15814 (void *)&cmd_set_l2_encap_eth_dst_value, 15815 NULL, 15816 }, 15817 }; 15818 15819 /** Set L2 decapsulation details */ 15820 struct cmd_set_l2_decap_result { 15821 cmdline_fixed_string_t set; 15822 cmdline_fixed_string_t l2_decap; 15823 cmdline_fixed_string_t pos_token; 15824 uint32_t vlan_present:1; 15825 }; 15826 15827 cmdline_parse_token_string_t cmd_set_l2_decap_set = 15828 TOKEN_STRING_INITIALIZER(struct cmd_set_l2_decap_result, set, "set"); 15829 cmdline_parse_token_string_t cmd_set_l2_decap_l2_decap = 15830 TOKEN_STRING_INITIALIZER(struct cmd_set_l2_decap_result, l2_decap, 15831 "l2_decap"); 15832 cmdline_parse_token_string_t cmd_set_l2_decap_l2_decap_with_vlan = 15833 TOKEN_STRING_INITIALIZER(struct cmd_set_l2_decap_result, l2_decap, 15834 "l2_decap-with-vlan"); 15835 15836 static void cmd_set_l2_decap_parsed(void *parsed_result, 15837 __attribute__((unused)) struct cmdline *cl, 15838 __attribute__((unused)) void *data) 15839 { 15840 struct cmd_set_l2_decap_result *res = parsed_result; 15841 15842 if (strcmp(res->l2_decap, "l2_decap") == 0) 15843 l2_decap_conf.select_vlan = 0; 15844 else if (strcmp(res->l2_decap, "l2_decap-with-vlan") == 0) 15845 l2_decap_conf.select_vlan = 1; 15846 } 15847 15848 cmdline_parse_inst_t cmd_set_l2_decap = { 15849 .f = cmd_set_l2_decap_parsed, 15850 .data = NULL, 15851 .help_str = "set l2_decap", 15852 .tokens = { 15853 (void *)&cmd_set_l2_decap_set, 15854 (void *)&cmd_set_l2_decap_l2_decap, 15855 NULL, 15856 }, 15857 }; 15858 15859 cmdline_parse_inst_t cmd_set_l2_decap_with_vlan = { 15860 .f = cmd_set_l2_decap_parsed, 15861 .data = NULL, 15862 .help_str = "set l2_decap-with-vlan", 15863 .tokens = { 15864 (void *)&cmd_set_l2_decap_set, 15865 (void *)&cmd_set_l2_decap_l2_decap_with_vlan, 15866 NULL, 15867 }, 15868 }; 15869 15870 /** Set MPLSoGRE encapsulation details */ 15871 struct cmd_set_mplsogre_encap_result { 15872 cmdline_fixed_string_t set; 15873 cmdline_fixed_string_t mplsogre; 15874 cmdline_fixed_string_t pos_token; 15875 cmdline_fixed_string_t ip_version; 15876 uint32_t vlan_present:1; 15877 uint32_t label; 15878 cmdline_ipaddr_t ip_src; 15879 cmdline_ipaddr_t ip_dst; 15880 uint16_t tci; 15881 struct rte_ether_addr eth_src; 15882 struct rte_ether_addr eth_dst; 15883 }; 15884 15885 cmdline_parse_token_string_t cmd_set_mplsogre_encap_set = 15886 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_encap_result, set, 15887 "set"); 15888 cmdline_parse_token_string_t cmd_set_mplsogre_encap_mplsogre_encap = 15889 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_encap_result, mplsogre, 15890 "mplsogre_encap"); 15891 cmdline_parse_token_string_t cmd_set_mplsogre_encap_mplsogre_encap_with_vlan = 15892 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_encap_result, 15893 mplsogre, "mplsogre_encap-with-vlan"); 15894 cmdline_parse_token_string_t cmd_set_mplsogre_encap_ip_version = 15895 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_encap_result, 15896 pos_token, "ip-version"); 15897 cmdline_parse_token_string_t cmd_set_mplsogre_encap_ip_version_value = 15898 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_encap_result, 15899 ip_version, "ipv4#ipv6"); 15900 cmdline_parse_token_string_t cmd_set_mplsogre_encap_label = 15901 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_encap_result, 15902 pos_token, "label"); 15903 cmdline_parse_token_num_t cmd_set_mplsogre_encap_label_value = 15904 TOKEN_NUM_INITIALIZER(struct cmd_set_mplsogre_encap_result, label, 15905 UINT32); 15906 cmdline_parse_token_string_t cmd_set_mplsogre_encap_ip_src = 15907 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_encap_result, 15908 pos_token, "ip-src"); 15909 cmdline_parse_token_ipaddr_t cmd_set_mplsogre_encap_ip_src_value = 15910 TOKEN_IPADDR_INITIALIZER(struct cmd_set_mplsogre_encap_result, ip_src); 15911 cmdline_parse_token_string_t cmd_set_mplsogre_encap_ip_dst = 15912 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_encap_result, 15913 pos_token, "ip-dst"); 15914 cmdline_parse_token_ipaddr_t cmd_set_mplsogre_encap_ip_dst_value = 15915 TOKEN_IPADDR_INITIALIZER(struct cmd_set_mplsogre_encap_result, ip_dst); 15916 cmdline_parse_token_string_t cmd_set_mplsogre_encap_vlan = 15917 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_encap_result, 15918 pos_token, "vlan-tci"); 15919 cmdline_parse_token_num_t cmd_set_mplsogre_encap_vlan_value = 15920 TOKEN_NUM_INITIALIZER(struct cmd_set_mplsogre_encap_result, tci, 15921 UINT16); 15922 cmdline_parse_token_string_t cmd_set_mplsogre_encap_eth_src = 15923 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_encap_result, 15924 pos_token, "eth-src"); 15925 cmdline_parse_token_etheraddr_t cmd_set_mplsogre_encap_eth_src_value = 15926 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_mplsogre_encap_result, 15927 eth_src); 15928 cmdline_parse_token_string_t cmd_set_mplsogre_encap_eth_dst = 15929 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_encap_result, 15930 pos_token, "eth-dst"); 15931 cmdline_parse_token_etheraddr_t cmd_set_mplsogre_encap_eth_dst_value = 15932 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_mplsogre_encap_result, 15933 eth_dst); 15934 15935 static void cmd_set_mplsogre_encap_parsed(void *parsed_result, 15936 __attribute__((unused)) struct cmdline *cl, 15937 __attribute__((unused)) void *data) 15938 { 15939 struct cmd_set_mplsogre_encap_result *res = parsed_result; 15940 union { 15941 uint32_t mplsogre_label; 15942 uint8_t label[4]; 15943 } id = { 15944 .mplsogre_label = rte_cpu_to_be_32(res->label<<12), 15945 }; 15946 15947 if (strcmp(res->mplsogre, "mplsogre_encap") == 0) 15948 mplsogre_encap_conf.select_vlan = 0; 15949 else if (strcmp(res->mplsogre, "mplsogre_encap-with-vlan") == 0) 15950 mplsogre_encap_conf.select_vlan = 1; 15951 if (strcmp(res->ip_version, "ipv4") == 0) 15952 mplsogre_encap_conf.select_ipv4 = 1; 15953 else if (strcmp(res->ip_version, "ipv6") == 0) 15954 mplsogre_encap_conf.select_ipv4 = 0; 15955 else 15956 return; 15957 rte_memcpy(mplsogre_encap_conf.label, &id.label, 3); 15958 if (mplsogre_encap_conf.select_ipv4) { 15959 IPV4_ADDR_TO_UINT(res->ip_src, mplsogre_encap_conf.ipv4_src); 15960 IPV4_ADDR_TO_UINT(res->ip_dst, mplsogre_encap_conf.ipv4_dst); 15961 } else { 15962 IPV6_ADDR_TO_ARRAY(res->ip_src, mplsogre_encap_conf.ipv6_src); 15963 IPV6_ADDR_TO_ARRAY(res->ip_dst, mplsogre_encap_conf.ipv6_dst); 15964 } 15965 if (mplsogre_encap_conf.select_vlan) 15966 mplsogre_encap_conf.vlan_tci = rte_cpu_to_be_16(res->tci); 15967 rte_memcpy(mplsogre_encap_conf.eth_src, res->eth_src.addr_bytes, 15968 RTE_ETHER_ADDR_LEN); 15969 rte_memcpy(mplsogre_encap_conf.eth_dst, res->eth_dst.addr_bytes, 15970 RTE_ETHER_ADDR_LEN); 15971 } 15972 15973 cmdline_parse_inst_t cmd_set_mplsogre_encap = { 15974 .f = cmd_set_mplsogre_encap_parsed, 15975 .data = NULL, 15976 .help_str = "set mplsogre_encap ip-version ipv4|ipv6 label <label>" 15977 " ip-src <ip-src> ip-dst <ip-dst> eth-src <eth-src>" 15978 " eth-dst <eth-dst>", 15979 .tokens = { 15980 (void *)&cmd_set_mplsogre_encap_set, 15981 (void *)&cmd_set_mplsogre_encap_mplsogre_encap, 15982 (void *)&cmd_set_mplsogre_encap_ip_version, 15983 (void *)&cmd_set_mplsogre_encap_ip_version_value, 15984 (void *)&cmd_set_mplsogre_encap_label, 15985 (void *)&cmd_set_mplsogre_encap_label_value, 15986 (void *)&cmd_set_mplsogre_encap_ip_src, 15987 (void *)&cmd_set_mplsogre_encap_ip_src_value, 15988 (void *)&cmd_set_mplsogre_encap_ip_dst, 15989 (void *)&cmd_set_mplsogre_encap_ip_dst_value, 15990 (void *)&cmd_set_mplsogre_encap_eth_src, 15991 (void *)&cmd_set_mplsogre_encap_eth_src_value, 15992 (void *)&cmd_set_mplsogre_encap_eth_dst, 15993 (void *)&cmd_set_mplsogre_encap_eth_dst_value, 15994 NULL, 15995 }, 15996 }; 15997 15998 cmdline_parse_inst_t cmd_set_mplsogre_encap_with_vlan = { 15999 .f = cmd_set_mplsogre_encap_parsed, 16000 .data = NULL, 16001 .help_str = "set mplsogre_encap-with-vlan ip-version ipv4|ipv6" 16002 " label <label> ip-src <ip-src> ip-dst <ip-dst>" 16003 " vlan-tci <vlan-tci> eth-src <eth-src> eth-dst <eth-dst>", 16004 .tokens = { 16005 (void *)&cmd_set_mplsogre_encap_set, 16006 (void *)&cmd_set_mplsogre_encap_mplsogre_encap_with_vlan, 16007 (void *)&cmd_set_mplsogre_encap_ip_version, 16008 (void *)&cmd_set_mplsogre_encap_ip_version_value, 16009 (void *)&cmd_set_mplsogre_encap_label, 16010 (void *)&cmd_set_mplsogre_encap_label_value, 16011 (void *)&cmd_set_mplsogre_encap_ip_src, 16012 (void *)&cmd_set_mplsogre_encap_ip_src_value, 16013 (void *)&cmd_set_mplsogre_encap_ip_dst, 16014 (void *)&cmd_set_mplsogre_encap_ip_dst_value, 16015 (void *)&cmd_set_mplsogre_encap_vlan, 16016 (void *)&cmd_set_mplsogre_encap_vlan_value, 16017 (void *)&cmd_set_mplsogre_encap_eth_src, 16018 (void *)&cmd_set_mplsogre_encap_eth_src_value, 16019 (void *)&cmd_set_mplsogre_encap_eth_dst, 16020 (void *)&cmd_set_mplsogre_encap_eth_dst_value, 16021 NULL, 16022 }, 16023 }; 16024 16025 /** Set MPLSoGRE decapsulation details */ 16026 struct cmd_set_mplsogre_decap_result { 16027 cmdline_fixed_string_t set; 16028 cmdline_fixed_string_t mplsogre; 16029 cmdline_fixed_string_t pos_token; 16030 cmdline_fixed_string_t ip_version; 16031 uint32_t vlan_present:1; 16032 }; 16033 16034 cmdline_parse_token_string_t cmd_set_mplsogre_decap_set = 16035 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_decap_result, set, 16036 "set"); 16037 cmdline_parse_token_string_t cmd_set_mplsogre_decap_mplsogre_decap = 16038 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_decap_result, mplsogre, 16039 "mplsogre_decap"); 16040 cmdline_parse_token_string_t cmd_set_mplsogre_decap_mplsogre_decap_with_vlan = 16041 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_decap_result, 16042 mplsogre, "mplsogre_decap-with-vlan"); 16043 cmdline_parse_token_string_t cmd_set_mplsogre_decap_ip_version = 16044 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_decap_result, 16045 pos_token, "ip-version"); 16046 cmdline_parse_token_string_t cmd_set_mplsogre_decap_ip_version_value = 16047 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_decap_result, 16048 ip_version, "ipv4#ipv6"); 16049 16050 static void cmd_set_mplsogre_decap_parsed(void *parsed_result, 16051 __attribute__((unused)) struct cmdline *cl, 16052 __attribute__((unused)) void *data) 16053 { 16054 struct cmd_set_mplsogre_decap_result *res = parsed_result; 16055 16056 if (strcmp(res->mplsogre, "mplsogre_decap") == 0) 16057 mplsogre_decap_conf.select_vlan = 0; 16058 else if (strcmp(res->mplsogre, "mplsogre_decap-with-vlan") == 0) 16059 mplsogre_decap_conf.select_vlan = 1; 16060 if (strcmp(res->ip_version, "ipv4") == 0) 16061 mplsogre_decap_conf.select_ipv4 = 1; 16062 else if (strcmp(res->ip_version, "ipv6") == 0) 16063 mplsogre_decap_conf.select_ipv4 = 0; 16064 } 16065 16066 cmdline_parse_inst_t cmd_set_mplsogre_decap = { 16067 .f = cmd_set_mplsogre_decap_parsed, 16068 .data = NULL, 16069 .help_str = "set mplsogre_decap ip-version ipv4|ipv6", 16070 .tokens = { 16071 (void *)&cmd_set_mplsogre_decap_set, 16072 (void *)&cmd_set_mplsogre_decap_mplsogre_decap, 16073 (void *)&cmd_set_mplsogre_decap_ip_version, 16074 (void *)&cmd_set_mplsogre_decap_ip_version_value, 16075 NULL, 16076 }, 16077 }; 16078 16079 cmdline_parse_inst_t cmd_set_mplsogre_decap_with_vlan = { 16080 .f = cmd_set_mplsogre_decap_parsed, 16081 .data = NULL, 16082 .help_str = "set mplsogre_decap-with-vlan ip-version ipv4|ipv6", 16083 .tokens = { 16084 (void *)&cmd_set_mplsogre_decap_set, 16085 (void *)&cmd_set_mplsogre_decap_mplsogre_decap_with_vlan, 16086 (void *)&cmd_set_mplsogre_decap_ip_version, 16087 (void *)&cmd_set_mplsogre_decap_ip_version_value, 16088 NULL, 16089 }, 16090 }; 16091 16092 /** Set MPLSoUDP encapsulation details */ 16093 struct cmd_set_mplsoudp_encap_result { 16094 cmdline_fixed_string_t set; 16095 cmdline_fixed_string_t mplsoudp; 16096 cmdline_fixed_string_t pos_token; 16097 cmdline_fixed_string_t ip_version; 16098 uint32_t vlan_present:1; 16099 uint32_t label; 16100 uint16_t udp_src; 16101 uint16_t udp_dst; 16102 cmdline_ipaddr_t ip_src; 16103 cmdline_ipaddr_t ip_dst; 16104 uint16_t tci; 16105 struct rte_ether_addr eth_src; 16106 struct rte_ether_addr eth_dst; 16107 }; 16108 16109 cmdline_parse_token_string_t cmd_set_mplsoudp_encap_set = 16110 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_encap_result, set, 16111 "set"); 16112 cmdline_parse_token_string_t cmd_set_mplsoudp_encap_mplsoudp_encap = 16113 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_encap_result, mplsoudp, 16114 "mplsoudp_encap"); 16115 cmdline_parse_token_string_t cmd_set_mplsoudp_encap_mplsoudp_encap_with_vlan = 16116 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_encap_result, 16117 mplsoudp, "mplsoudp_encap-with-vlan"); 16118 cmdline_parse_token_string_t cmd_set_mplsoudp_encap_ip_version = 16119 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_encap_result, 16120 pos_token, "ip-version"); 16121 cmdline_parse_token_string_t cmd_set_mplsoudp_encap_ip_version_value = 16122 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_encap_result, 16123 ip_version, "ipv4#ipv6"); 16124 cmdline_parse_token_string_t cmd_set_mplsoudp_encap_label = 16125 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_encap_result, 16126 pos_token, "label"); 16127 cmdline_parse_token_num_t cmd_set_mplsoudp_encap_label_value = 16128 TOKEN_NUM_INITIALIZER(struct cmd_set_mplsoudp_encap_result, label, 16129 UINT32); 16130 cmdline_parse_token_string_t cmd_set_mplsoudp_encap_udp_src = 16131 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_encap_result, 16132 pos_token, "udp-src"); 16133 cmdline_parse_token_num_t cmd_set_mplsoudp_encap_udp_src_value = 16134 TOKEN_NUM_INITIALIZER(struct cmd_set_mplsoudp_encap_result, udp_src, 16135 UINT16); 16136 cmdline_parse_token_string_t cmd_set_mplsoudp_encap_udp_dst = 16137 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_encap_result, 16138 pos_token, "udp-dst"); 16139 cmdline_parse_token_num_t cmd_set_mplsoudp_encap_udp_dst_value = 16140 TOKEN_NUM_INITIALIZER(struct cmd_set_mplsoudp_encap_result, udp_dst, 16141 UINT16); 16142 cmdline_parse_token_string_t cmd_set_mplsoudp_encap_ip_src = 16143 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_encap_result, 16144 pos_token, "ip-src"); 16145 cmdline_parse_token_ipaddr_t cmd_set_mplsoudp_encap_ip_src_value = 16146 TOKEN_IPADDR_INITIALIZER(struct cmd_set_mplsoudp_encap_result, ip_src); 16147 cmdline_parse_token_string_t cmd_set_mplsoudp_encap_ip_dst = 16148 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_encap_result, 16149 pos_token, "ip-dst"); 16150 cmdline_parse_token_ipaddr_t cmd_set_mplsoudp_encap_ip_dst_value = 16151 TOKEN_IPADDR_INITIALIZER(struct cmd_set_mplsoudp_encap_result, ip_dst); 16152 cmdline_parse_token_string_t cmd_set_mplsoudp_encap_vlan = 16153 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_encap_result, 16154 pos_token, "vlan-tci"); 16155 cmdline_parse_token_num_t cmd_set_mplsoudp_encap_vlan_value = 16156 TOKEN_NUM_INITIALIZER(struct cmd_set_mplsoudp_encap_result, tci, 16157 UINT16); 16158 cmdline_parse_token_string_t cmd_set_mplsoudp_encap_eth_src = 16159 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_encap_result, 16160 pos_token, "eth-src"); 16161 cmdline_parse_token_etheraddr_t cmd_set_mplsoudp_encap_eth_src_value = 16162 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_mplsoudp_encap_result, 16163 eth_src); 16164 cmdline_parse_token_string_t cmd_set_mplsoudp_encap_eth_dst = 16165 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_encap_result, 16166 pos_token, "eth-dst"); 16167 cmdline_parse_token_etheraddr_t cmd_set_mplsoudp_encap_eth_dst_value = 16168 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_mplsoudp_encap_result, 16169 eth_dst); 16170 16171 static void cmd_set_mplsoudp_encap_parsed(void *parsed_result, 16172 __attribute__((unused)) struct cmdline *cl, 16173 __attribute__((unused)) void *data) 16174 { 16175 struct cmd_set_mplsoudp_encap_result *res = parsed_result; 16176 union { 16177 uint32_t mplsoudp_label; 16178 uint8_t label[4]; 16179 } id = { 16180 .mplsoudp_label = rte_cpu_to_be_32(res->label<<12), 16181 }; 16182 16183 if (strcmp(res->mplsoudp, "mplsoudp_encap") == 0) 16184 mplsoudp_encap_conf.select_vlan = 0; 16185 else if (strcmp(res->mplsoudp, "mplsoudp_encap-with-vlan") == 0) 16186 mplsoudp_encap_conf.select_vlan = 1; 16187 if (strcmp(res->ip_version, "ipv4") == 0) 16188 mplsoudp_encap_conf.select_ipv4 = 1; 16189 else if (strcmp(res->ip_version, "ipv6") == 0) 16190 mplsoudp_encap_conf.select_ipv4 = 0; 16191 else 16192 return; 16193 rte_memcpy(mplsoudp_encap_conf.label, &id.label, 3); 16194 mplsoudp_encap_conf.udp_src = rte_cpu_to_be_16(res->udp_src); 16195 mplsoudp_encap_conf.udp_dst = rte_cpu_to_be_16(res->udp_dst); 16196 if (mplsoudp_encap_conf.select_ipv4) { 16197 IPV4_ADDR_TO_UINT(res->ip_src, mplsoudp_encap_conf.ipv4_src); 16198 IPV4_ADDR_TO_UINT(res->ip_dst, mplsoudp_encap_conf.ipv4_dst); 16199 } else { 16200 IPV6_ADDR_TO_ARRAY(res->ip_src, mplsoudp_encap_conf.ipv6_src); 16201 IPV6_ADDR_TO_ARRAY(res->ip_dst, mplsoudp_encap_conf.ipv6_dst); 16202 } 16203 if (mplsoudp_encap_conf.select_vlan) 16204 mplsoudp_encap_conf.vlan_tci = rte_cpu_to_be_16(res->tci); 16205 rte_memcpy(mplsoudp_encap_conf.eth_src, res->eth_src.addr_bytes, 16206 RTE_ETHER_ADDR_LEN); 16207 rte_memcpy(mplsoudp_encap_conf.eth_dst, res->eth_dst.addr_bytes, 16208 RTE_ETHER_ADDR_LEN); 16209 } 16210 16211 cmdline_parse_inst_t cmd_set_mplsoudp_encap = { 16212 .f = cmd_set_mplsoudp_encap_parsed, 16213 .data = NULL, 16214 .help_str = "set mplsoudp_encap ip-version ipv4|ipv6 label <label>" 16215 " udp-src <udp-src> udp-dst <udp-dst> ip-src <ip-src>" 16216 " ip-dst <ip-dst> eth-src <eth-src> eth-dst <eth-dst>", 16217 .tokens = { 16218 (void *)&cmd_set_mplsoudp_encap_set, 16219 (void *)&cmd_set_mplsoudp_encap_mplsoudp_encap, 16220 (void *)&cmd_set_mplsoudp_encap_ip_version, 16221 (void *)&cmd_set_mplsoudp_encap_ip_version_value, 16222 (void *)&cmd_set_mplsoudp_encap_label, 16223 (void *)&cmd_set_mplsoudp_encap_label_value, 16224 (void *)&cmd_set_mplsoudp_encap_udp_src, 16225 (void *)&cmd_set_mplsoudp_encap_udp_src_value, 16226 (void *)&cmd_set_mplsoudp_encap_udp_dst, 16227 (void *)&cmd_set_mplsoudp_encap_udp_dst_value, 16228 (void *)&cmd_set_mplsoudp_encap_ip_src, 16229 (void *)&cmd_set_mplsoudp_encap_ip_src_value, 16230 (void *)&cmd_set_mplsoudp_encap_ip_dst, 16231 (void *)&cmd_set_mplsoudp_encap_ip_dst_value, 16232 (void *)&cmd_set_mplsoudp_encap_eth_src, 16233 (void *)&cmd_set_mplsoudp_encap_eth_src_value, 16234 (void *)&cmd_set_mplsoudp_encap_eth_dst, 16235 (void *)&cmd_set_mplsoudp_encap_eth_dst_value, 16236 NULL, 16237 }, 16238 }; 16239 16240 cmdline_parse_inst_t cmd_set_mplsoudp_encap_with_vlan = { 16241 .f = cmd_set_mplsoudp_encap_parsed, 16242 .data = NULL, 16243 .help_str = "set mplsoudp_encap-with-vlan ip-version ipv4|ipv6" 16244 " label <label> udp-src <udp-src> udp-dst <udp-dst>" 16245 " ip-src <ip-src> ip-dst <ip-dst> vlan-tci <vlan-tci>" 16246 " eth-src <eth-src> eth-dst <eth-dst>", 16247 .tokens = { 16248 (void *)&cmd_set_mplsoudp_encap_set, 16249 (void *)&cmd_set_mplsoudp_encap_mplsoudp_encap_with_vlan, 16250 (void *)&cmd_set_mplsoudp_encap_ip_version, 16251 (void *)&cmd_set_mplsoudp_encap_ip_version_value, 16252 (void *)&cmd_set_mplsoudp_encap_label, 16253 (void *)&cmd_set_mplsoudp_encap_label_value, 16254 (void *)&cmd_set_mplsoudp_encap_udp_src, 16255 (void *)&cmd_set_mplsoudp_encap_udp_src_value, 16256 (void *)&cmd_set_mplsoudp_encap_udp_dst, 16257 (void *)&cmd_set_mplsoudp_encap_udp_dst_value, 16258 (void *)&cmd_set_mplsoudp_encap_ip_src, 16259 (void *)&cmd_set_mplsoudp_encap_ip_src_value, 16260 (void *)&cmd_set_mplsoudp_encap_ip_dst, 16261 (void *)&cmd_set_mplsoudp_encap_ip_dst_value, 16262 (void *)&cmd_set_mplsoudp_encap_vlan, 16263 (void *)&cmd_set_mplsoudp_encap_vlan_value, 16264 (void *)&cmd_set_mplsoudp_encap_eth_src, 16265 (void *)&cmd_set_mplsoudp_encap_eth_src_value, 16266 (void *)&cmd_set_mplsoudp_encap_eth_dst, 16267 (void *)&cmd_set_mplsoudp_encap_eth_dst_value, 16268 NULL, 16269 }, 16270 }; 16271 16272 /** Set MPLSoUDP decapsulation details */ 16273 struct cmd_set_mplsoudp_decap_result { 16274 cmdline_fixed_string_t set; 16275 cmdline_fixed_string_t mplsoudp; 16276 cmdline_fixed_string_t pos_token; 16277 cmdline_fixed_string_t ip_version; 16278 uint32_t vlan_present:1; 16279 }; 16280 16281 cmdline_parse_token_string_t cmd_set_mplsoudp_decap_set = 16282 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_decap_result, set, 16283 "set"); 16284 cmdline_parse_token_string_t cmd_set_mplsoudp_decap_mplsoudp_decap = 16285 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_decap_result, mplsoudp, 16286 "mplsoudp_decap"); 16287 cmdline_parse_token_string_t cmd_set_mplsoudp_decap_mplsoudp_decap_with_vlan = 16288 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_decap_result, 16289 mplsoudp, "mplsoudp_decap-with-vlan"); 16290 cmdline_parse_token_string_t cmd_set_mplsoudp_decap_ip_version = 16291 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_decap_result, 16292 pos_token, "ip-version"); 16293 cmdline_parse_token_string_t cmd_set_mplsoudp_decap_ip_version_value = 16294 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_decap_result, 16295 ip_version, "ipv4#ipv6"); 16296 16297 static void cmd_set_mplsoudp_decap_parsed(void *parsed_result, 16298 __attribute__((unused)) struct cmdline *cl, 16299 __attribute__((unused)) void *data) 16300 { 16301 struct cmd_set_mplsoudp_decap_result *res = parsed_result; 16302 16303 if (strcmp(res->mplsoudp, "mplsoudp_decap") == 0) 16304 mplsoudp_decap_conf.select_vlan = 0; 16305 else if (strcmp(res->mplsoudp, "mplsoudp_decap-with-vlan") == 0) 16306 mplsoudp_decap_conf.select_vlan = 1; 16307 if (strcmp(res->ip_version, "ipv4") == 0) 16308 mplsoudp_decap_conf.select_ipv4 = 1; 16309 else if (strcmp(res->ip_version, "ipv6") == 0) 16310 mplsoudp_decap_conf.select_ipv4 = 0; 16311 } 16312 16313 cmdline_parse_inst_t cmd_set_mplsoudp_decap = { 16314 .f = cmd_set_mplsoudp_decap_parsed, 16315 .data = NULL, 16316 .help_str = "set mplsoudp_decap ip-version ipv4|ipv6", 16317 .tokens = { 16318 (void *)&cmd_set_mplsoudp_decap_set, 16319 (void *)&cmd_set_mplsoudp_decap_mplsoudp_decap, 16320 (void *)&cmd_set_mplsoudp_decap_ip_version, 16321 (void *)&cmd_set_mplsoudp_decap_ip_version_value, 16322 NULL, 16323 }, 16324 }; 16325 16326 cmdline_parse_inst_t cmd_set_mplsoudp_decap_with_vlan = { 16327 .f = cmd_set_mplsoudp_decap_parsed, 16328 .data = NULL, 16329 .help_str = "set mplsoudp_decap-with-vlan ip-version ipv4|ipv6", 16330 .tokens = { 16331 (void *)&cmd_set_mplsoudp_decap_set, 16332 (void *)&cmd_set_mplsoudp_decap_mplsoudp_decap_with_vlan, 16333 (void *)&cmd_set_mplsoudp_decap_ip_version, 16334 (void *)&cmd_set_mplsoudp_decap_ip_version_value, 16335 NULL, 16336 }, 16337 }; 16338 16339 /* Strict link priority scheduling mode setting */ 16340 static void 16341 cmd_strict_link_prio_parsed( 16342 void *parsed_result, 16343 __attribute__((unused)) struct cmdline *cl, 16344 __attribute__((unused)) void *data) 16345 { 16346 struct cmd_vf_tc_bw_result *res = parsed_result; 16347 int ret = -ENOTSUP; 16348 16349 if (port_id_is_invalid(res->port_id, ENABLED_WARN)) 16350 return; 16351 16352 #ifdef RTE_LIBRTE_I40E_PMD 16353 ret = rte_pmd_i40e_set_tc_strict_prio(res->port_id, res->tc_map); 16354 #endif 16355 16356 switch (ret) { 16357 case 0: 16358 break; 16359 case -EINVAL: 16360 printf("invalid tc_bitmap 0x%x\n", res->tc_map); 16361 break; 16362 case -ENODEV: 16363 printf("invalid port_id %d\n", res->port_id); 16364 break; 16365 case -ENOTSUP: 16366 printf("function not implemented\n"); 16367 break; 16368 default: 16369 printf("programming error: (%s)\n", strerror(-ret)); 16370 } 16371 } 16372 16373 cmdline_parse_inst_t cmd_strict_link_prio = { 16374 .f = cmd_strict_link_prio_parsed, 16375 .data = NULL, 16376 .help_str = "set tx strict-link-priority <port_id> <tc_bitmap>", 16377 .tokens = { 16378 (void *)&cmd_vf_tc_bw_set, 16379 (void *)&cmd_vf_tc_bw_tx, 16380 (void *)&cmd_vf_tc_bw_strict_link_prio, 16381 (void *)&cmd_vf_tc_bw_port_id, 16382 (void *)&cmd_vf_tc_bw_tc_map, 16383 NULL, 16384 }, 16385 }; 16386 16387 /* Load dynamic device personalization*/ 16388 struct cmd_ddp_add_result { 16389 cmdline_fixed_string_t ddp; 16390 cmdline_fixed_string_t add; 16391 portid_t port_id; 16392 char filepath[]; 16393 }; 16394 16395 cmdline_parse_token_string_t cmd_ddp_add_ddp = 16396 TOKEN_STRING_INITIALIZER(struct cmd_ddp_add_result, ddp, "ddp"); 16397 cmdline_parse_token_string_t cmd_ddp_add_add = 16398 TOKEN_STRING_INITIALIZER(struct cmd_ddp_add_result, add, "add"); 16399 cmdline_parse_token_num_t cmd_ddp_add_port_id = 16400 TOKEN_NUM_INITIALIZER(struct cmd_ddp_add_result, port_id, UINT16); 16401 cmdline_parse_token_string_t cmd_ddp_add_filepath = 16402 TOKEN_STRING_INITIALIZER(struct cmd_ddp_add_result, filepath, NULL); 16403 16404 static void 16405 cmd_ddp_add_parsed( 16406 void *parsed_result, 16407 __attribute__((unused)) struct cmdline *cl, 16408 __attribute__((unused)) void *data) 16409 { 16410 struct cmd_ddp_add_result *res = parsed_result; 16411 uint8_t *buff; 16412 uint32_t size; 16413 char *filepath; 16414 char *file_fld[2]; 16415 int file_num; 16416 int ret = -ENOTSUP; 16417 16418 if (!all_ports_stopped()) { 16419 printf("Please stop all ports first\n"); 16420 return; 16421 } 16422 16423 filepath = strdup(res->filepath); 16424 if (filepath == NULL) { 16425 printf("Failed to allocate memory\n"); 16426 return; 16427 } 16428 file_num = rte_strsplit(filepath, strlen(filepath), file_fld, 2, ','); 16429 16430 buff = open_file(file_fld[0], &size); 16431 if (!buff) { 16432 free((void *)filepath); 16433 return; 16434 } 16435 16436 #ifdef RTE_LIBRTE_I40E_PMD 16437 if (ret == -ENOTSUP) 16438 ret = rte_pmd_i40e_process_ddp_package(res->port_id, 16439 buff, size, 16440 RTE_PMD_I40E_PKG_OP_WR_ADD); 16441 #endif 16442 16443 if (ret == -EEXIST) 16444 printf("Profile has already existed.\n"); 16445 else if (ret < 0) 16446 printf("Failed to load profile.\n"); 16447 else if (file_num == 2) 16448 save_file(file_fld[1], buff, size); 16449 16450 close_file(buff); 16451 free((void *)filepath); 16452 } 16453 16454 cmdline_parse_inst_t cmd_ddp_add = { 16455 .f = cmd_ddp_add_parsed, 16456 .data = NULL, 16457 .help_str = "ddp add <port_id> <profile_path[,backup_profile_path]>", 16458 .tokens = { 16459 (void *)&cmd_ddp_add_ddp, 16460 (void *)&cmd_ddp_add_add, 16461 (void *)&cmd_ddp_add_port_id, 16462 (void *)&cmd_ddp_add_filepath, 16463 NULL, 16464 }, 16465 }; 16466 16467 /* Delete dynamic device personalization*/ 16468 struct cmd_ddp_del_result { 16469 cmdline_fixed_string_t ddp; 16470 cmdline_fixed_string_t del; 16471 portid_t port_id; 16472 char filepath[]; 16473 }; 16474 16475 cmdline_parse_token_string_t cmd_ddp_del_ddp = 16476 TOKEN_STRING_INITIALIZER(struct cmd_ddp_del_result, ddp, "ddp"); 16477 cmdline_parse_token_string_t cmd_ddp_del_del = 16478 TOKEN_STRING_INITIALIZER(struct cmd_ddp_del_result, del, "del"); 16479 cmdline_parse_token_num_t cmd_ddp_del_port_id = 16480 TOKEN_NUM_INITIALIZER(struct cmd_ddp_del_result, port_id, UINT16); 16481 cmdline_parse_token_string_t cmd_ddp_del_filepath = 16482 TOKEN_STRING_INITIALIZER(struct cmd_ddp_del_result, filepath, NULL); 16483 16484 static void 16485 cmd_ddp_del_parsed( 16486 void *parsed_result, 16487 __attribute__((unused)) struct cmdline *cl, 16488 __attribute__((unused)) void *data) 16489 { 16490 struct cmd_ddp_del_result *res = parsed_result; 16491 uint8_t *buff; 16492 uint32_t size; 16493 int ret = -ENOTSUP; 16494 16495 if (!all_ports_stopped()) { 16496 printf("Please stop all ports first\n"); 16497 return; 16498 } 16499 16500 buff = open_file(res->filepath, &size); 16501 if (!buff) 16502 return; 16503 16504 #ifdef RTE_LIBRTE_I40E_PMD 16505 if (ret == -ENOTSUP) 16506 ret = rte_pmd_i40e_process_ddp_package(res->port_id, 16507 buff, size, 16508 RTE_PMD_I40E_PKG_OP_WR_DEL); 16509 #endif 16510 16511 if (ret == -EACCES) 16512 printf("Profile does not exist.\n"); 16513 else if (ret < 0) 16514 printf("Failed to delete profile.\n"); 16515 16516 close_file(buff); 16517 } 16518 16519 cmdline_parse_inst_t cmd_ddp_del = { 16520 .f = cmd_ddp_del_parsed, 16521 .data = NULL, 16522 .help_str = "ddp del <port_id> <backup_profile_path>", 16523 .tokens = { 16524 (void *)&cmd_ddp_del_ddp, 16525 (void *)&cmd_ddp_del_del, 16526 (void *)&cmd_ddp_del_port_id, 16527 (void *)&cmd_ddp_del_filepath, 16528 NULL, 16529 }, 16530 }; 16531 16532 /* Get dynamic device personalization profile info */ 16533 struct cmd_ddp_info_result { 16534 cmdline_fixed_string_t ddp; 16535 cmdline_fixed_string_t get; 16536 cmdline_fixed_string_t info; 16537 char filepath[]; 16538 }; 16539 16540 cmdline_parse_token_string_t cmd_ddp_info_ddp = 16541 TOKEN_STRING_INITIALIZER(struct cmd_ddp_info_result, ddp, "ddp"); 16542 cmdline_parse_token_string_t cmd_ddp_info_get = 16543 TOKEN_STRING_INITIALIZER(struct cmd_ddp_info_result, get, "get"); 16544 cmdline_parse_token_string_t cmd_ddp_info_info = 16545 TOKEN_STRING_INITIALIZER(struct cmd_ddp_info_result, info, "info"); 16546 cmdline_parse_token_string_t cmd_ddp_info_filepath = 16547 TOKEN_STRING_INITIALIZER(struct cmd_ddp_info_result, filepath, NULL); 16548 16549 static void 16550 cmd_ddp_info_parsed( 16551 void *parsed_result, 16552 __attribute__((unused)) struct cmdline *cl, 16553 __attribute__((unused)) void *data) 16554 { 16555 struct cmd_ddp_info_result *res = parsed_result; 16556 uint8_t *pkg; 16557 uint32_t pkg_size; 16558 int ret = -ENOTSUP; 16559 #ifdef RTE_LIBRTE_I40E_PMD 16560 uint32_t i, j, n; 16561 uint8_t *buff; 16562 uint32_t buff_size = 0; 16563 struct rte_pmd_i40e_profile_info info; 16564 uint32_t dev_num = 0; 16565 struct rte_pmd_i40e_ddp_device_id *devs; 16566 uint32_t proto_num = 0; 16567 struct rte_pmd_i40e_proto_info *proto = NULL; 16568 uint32_t pctype_num = 0; 16569 struct rte_pmd_i40e_ptype_info *pctype; 16570 uint32_t ptype_num = 0; 16571 struct rte_pmd_i40e_ptype_info *ptype; 16572 uint8_t proto_id; 16573 16574 #endif 16575 16576 pkg = open_file(res->filepath, &pkg_size); 16577 if (!pkg) 16578 return; 16579 16580 #ifdef RTE_LIBRTE_I40E_PMD 16581 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size, 16582 (uint8_t *)&info, sizeof(info), 16583 RTE_PMD_I40E_PKG_INFO_GLOBAL_HEADER); 16584 if (!ret) { 16585 printf("Global Track id: 0x%x\n", info.track_id); 16586 printf("Global Version: %d.%d.%d.%d\n", 16587 info.version.major, 16588 info.version.minor, 16589 info.version.update, 16590 info.version.draft); 16591 printf("Global Package name: %s\n\n", info.name); 16592 } 16593 16594 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size, 16595 (uint8_t *)&info, sizeof(info), 16596 RTE_PMD_I40E_PKG_INFO_HEADER); 16597 if (!ret) { 16598 printf("i40e Profile Track id: 0x%x\n", info.track_id); 16599 printf("i40e Profile Version: %d.%d.%d.%d\n", 16600 info.version.major, 16601 info.version.minor, 16602 info.version.update, 16603 info.version.draft); 16604 printf("i40e Profile name: %s\n\n", info.name); 16605 } 16606 16607 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size, 16608 (uint8_t *)&buff_size, sizeof(buff_size), 16609 RTE_PMD_I40E_PKG_INFO_GLOBAL_NOTES_SIZE); 16610 if (!ret && buff_size) { 16611 buff = (uint8_t *)malloc(buff_size); 16612 if (buff) { 16613 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size, 16614 buff, buff_size, 16615 RTE_PMD_I40E_PKG_INFO_GLOBAL_NOTES); 16616 if (!ret) 16617 printf("Package Notes:\n%s\n\n", buff); 16618 free(buff); 16619 } 16620 } 16621 16622 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size, 16623 (uint8_t *)&dev_num, sizeof(dev_num), 16624 RTE_PMD_I40E_PKG_INFO_DEVID_NUM); 16625 if (!ret && dev_num) { 16626 buff_size = dev_num * sizeof(struct rte_pmd_i40e_ddp_device_id); 16627 devs = (struct rte_pmd_i40e_ddp_device_id *)malloc(buff_size); 16628 if (devs) { 16629 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size, 16630 (uint8_t *)devs, buff_size, 16631 RTE_PMD_I40E_PKG_INFO_DEVID_LIST); 16632 if (!ret) { 16633 printf("List of supported devices:\n"); 16634 for (i = 0; i < dev_num; i++) { 16635 printf(" %04X:%04X %04X:%04X\n", 16636 devs[i].vendor_dev_id >> 16, 16637 devs[i].vendor_dev_id & 0xFFFF, 16638 devs[i].sub_vendor_dev_id >> 16, 16639 devs[i].sub_vendor_dev_id & 0xFFFF); 16640 } 16641 printf("\n"); 16642 } 16643 free(devs); 16644 } 16645 } 16646 16647 /* get information about protocols and packet types */ 16648 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size, 16649 (uint8_t *)&proto_num, sizeof(proto_num), 16650 RTE_PMD_I40E_PKG_INFO_PROTOCOL_NUM); 16651 if (ret || !proto_num) 16652 goto no_print_return; 16653 16654 buff_size = proto_num * sizeof(struct rte_pmd_i40e_proto_info); 16655 proto = (struct rte_pmd_i40e_proto_info *)malloc(buff_size); 16656 if (!proto) 16657 goto no_print_return; 16658 16659 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size, (uint8_t *)proto, 16660 buff_size, 16661 RTE_PMD_I40E_PKG_INFO_PROTOCOL_LIST); 16662 if (!ret) { 16663 printf("List of used protocols:\n"); 16664 for (i = 0; i < proto_num; i++) 16665 printf(" %2u: %s\n", proto[i].proto_id, 16666 proto[i].name); 16667 printf("\n"); 16668 } 16669 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size, 16670 (uint8_t *)&pctype_num, sizeof(pctype_num), 16671 RTE_PMD_I40E_PKG_INFO_PCTYPE_NUM); 16672 if (ret || !pctype_num) 16673 goto no_print_pctypes; 16674 16675 buff_size = pctype_num * sizeof(struct rte_pmd_i40e_ptype_info); 16676 pctype = (struct rte_pmd_i40e_ptype_info *)malloc(buff_size); 16677 if (!pctype) 16678 goto no_print_pctypes; 16679 16680 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size, (uint8_t *)pctype, 16681 buff_size, 16682 RTE_PMD_I40E_PKG_INFO_PCTYPE_LIST); 16683 if (ret) { 16684 free(pctype); 16685 goto no_print_pctypes; 16686 } 16687 16688 printf("List of defined packet classification types:\n"); 16689 for (i = 0; i < pctype_num; i++) { 16690 printf(" %2u:", pctype[i].ptype_id); 16691 for (j = 0; j < RTE_PMD_I40E_PROTO_NUM; j++) { 16692 proto_id = pctype[i].protocols[j]; 16693 if (proto_id != RTE_PMD_I40E_PROTO_UNUSED) { 16694 for (n = 0; n < proto_num; n++) { 16695 if (proto[n].proto_id == proto_id) { 16696 printf(" %s", proto[n].name); 16697 break; 16698 } 16699 } 16700 } 16701 } 16702 printf("\n"); 16703 } 16704 printf("\n"); 16705 free(pctype); 16706 16707 no_print_pctypes: 16708 16709 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size, (uint8_t *)&ptype_num, 16710 sizeof(ptype_num), 16711 RTE_PMD_I40E_PKG_INFO_PTYPE_NUM); 16712 if (ret || !ptype_num) 16713 goto no_print_return; 16714 16715 buff_size = ptype_num * sizeof(struct rte_pmd_i40e_ptype_info); 16716 ptype = (struct rte_pmd_i40e_ptype_info *)malloc(buff_size); 16717 if (!ptype) 16718 goto no_print_return; 16719 16720 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size, (uint8_t *)ptype, 16721 buff_size, 16722 RTE_PMD_I40E_PKG_INFO_PTYPE_LIST); 16723 if (ret) { 16724 free(ptype); 16725 goto no_print_return; 16726 } 16727 printf("List of defined packet types:\n"); 16728 for (i = 0; i < ptype_num; i++) { 16729 printf(" %2u:", ptype[i].ptype_id); 16730 for (j = 0; j < RTE_PMD_I40E_PROTO_NUM; j++) { 16731 proto_id = ptype[i].protocols[j]; 16732 if (proto_id != RTE_PMD_I40E_PROTO_UNUSED) { 16733 for (n = 0; n < proto_num; n++) { 16734 if (proto[n].proto_id == proto_id) { 16735 printf(" %s", proto[n].name); 16736 break; 16737 } 16738 } 16739 } 16740 } 16741 printf("\n"); 16742 } 16743 free(ptype); 16744 printf("\n"); 16745 16746 ret = 0; 16747 no_print_return: 16748 if (proto) 16749 free(proto); 16750 #endif 16751 if (ret == -ENOTSUP) 16752 printf("Function not supported in PMD driver\n"); 16753 close_file(pkg); 16754 } 16755 16756 cmdline_parse_inst_t cmd_ddp_get_info = { 16757 .f = cmd_ddp_info_parsed, 16758 .data = NULL, 16759 .help_str = "ddp get info <profile_path>", 16760 .tokens = { 16761 (void *)&cmd_ddp_info_ddp, 16762 (void *)&cmd_ddp_info_get, 16763 (void *)&cmd_ddp_info_info, 16764 (void *)&cmd_ddp_info_filepath, 16765 NULL, 16766 }, 16767 }; 16768 16769 /* Get dynamic device personalization profile info list*/ 16770 #define PROFILE_INFO_SIZE 48 16771 #define MAX_PROFILE_NUM 16 16772 16773 struct cmd_ddp_get_list_result { 16774 cmdline_fixed_string_t ddp; 16775 cmdline_fixed_string_t get; 16776 cmdline_fixed_string_t list; 16777 portid_t port_id; 16778 }; 16779 16780 cmdline_parse_token_string_t cmd_ddp_get_list_ddp = 16781 TOKEN_STRING_INITIALIZER(struct cmd_ddp_get_list_result, ddp, "ddp"); 16782 cmdline_parse_token_string_t cmd_ddp_get_list_get = 16783 TOKEN_STRING_INITIALIZER(struct cmd_ddp_get_list_result, get, "get"); 16784 cmdline_parse_token_string_t cmd_ddp_get_list_list = 16785 TOKEN_STRING_INITIALIZER(struct cmd_ddp_get_list_result, list, "list"); 16786 cmdline_parse_token_num_t cmd_ddp_get_list_port_id = 16787 TOKEN_NUM_INITIALIZER(struct cmd_ddp_get_list_result, port_id, UINT16); 16788 16789 static void 16790 cmd_ddp_get_list_parsed( 16791 __attribute__((unused)) void *parsed_result, 16792 __attribute__((unused)) struct cmdline *cl, 16793 __attribute__((unused)) void *data) 16794 { 16795 #ifdef RTE_LIBRTE_I40E_PMD 16796 struct cmd_ddp_get_list_result *res = parsed_result; 16797 struct rte_pmd_i40e_profile_list *p_list; 16798 struct rte_pmd_i40e_profile_info *p_info; 16799 uint32_t p_num; 16800 uint32_t size; 16801 uint32_t i; 16802 #endif 16803 int ret = -ENOTSUP; 16804 16805 #ifdef RTE_LIBRTE_I40E_PMD 16806 size = PROFILE_INFO_SIZE * MAX_PROFILE_NUM + 4; 16807 p_list = (struct rte_pmd_i40e_profile_list *)malloc(size); 16808 if (!p_list) 16809 printf("%s: Failed to malloc buffer\n", __func__); 16810 16811 if (ret == -ENOTSUP) 16812 ret = rte_pmd_i40e_get_ddp_list(res->port_id, 16813 (uint8_t *)p_list, size); 16814 16815 if (!ret) { 16816 p_num = p_list->p_count; 16817 printf("Profile number is: %d\n\n", p_num); 16818 16819 for (i = 0; i < p_num; i++) { 16820 p_info = &p_list->p_info[i]; 16821 printf("Profile %d:\n", i); 16822 printf("Track id: 0x%x\n", p_info->track_id); 16823 printf("Version: %d.%d.%d.%d\n", 16824 p_info->version.major, 16825 p_info->version.minor, 16826 p_info->version.update, 16827 p_info->version.draft); 16828 printf("Profile name: %s\n\n", p_info->name); 16829 } 16830 } 16831 16832 free(p_list); 16833 #endif 16834 16835 if (ret < 0) 16836 printf("Failed to get ddp list\n"); 16837 } 16838 16839 cmdline_parse_inst_t cmd_ddp_get_list = { 16840 .f = cmd_ddp_get_list_parsed, 16841 .data = NULL, 16842 .help_str = "ddp get list <port_id>", 16843 .tokens = { 16844 (void *)&cmd_ddp_get_list_ddp, 16845 (void *)&cmd_ddp_get_list_get, 16846 (void *)&cmd_ddp_get_list_list, 16847 (void *)&cmd_ddp_get_list_port_id, 16848 NULL, 16849 }, 16850 }; 16851 16852 /* Configure input set */ 16853 struct cmd_cfg_input_set_result { 16854 cmdline_fixed_string_t port; 16855 cmdline_fixed_string_t cfg; 16856 portid_t port_id; 16857 cmdline_fixed_string_t pctype; 16858 uint8_t pctype_id; 16859 cmdline_fixed_string_t inset_type; 16860 cmdline_fixed_string_t opt; 16861 cmdline_fixed_string_t field; 16862 uint8_t field_idx; 16863 }; 16864 16865 static void 16866 cmd_cfg_input_set_parsed( 16867 __attribute__((unused)) void *parsed_result, 16868 __attribute__((unused)) struct cmdline *cl, 16869 __attribute__((unused)) void *data) 16870 { 16871 #ifdef RTE_LIBRTE_I40E_PMD 16872 struct cmd_cfg_input_set_result *res = parsed_result; 16873 enum rte_pmd_i40e_inset_type inset_type = INSET_NONE; 16874 struct rte_pmd_i40e_inset inset; 16875 #endif 16876 int ret = -ENOTSUP; 16877 16878 if (!all_ports_stopped()) { 16879 printf("Please stop all ports first\n"); 16880 return; 16881 } 16882 16883 #ifdef RTE_LIBRTE_I40E_PMD 16884 if (!strcmp(res->inset_type, "hash_inset")) 16885 inset_type = INSET_HASH; 16886 else if (!strcmp(res->inset_type, "fdir_inset")) 16887 inset_type = INSET_FDIR; 16888 else if (!strcmp(res->inset_type, "fdir_flx_inset")) 16889 inset_type = INSET_FDIR_FLX; 16890 ret = rte_pmd_i40e_inset_get(res->port_id, res->pctype_id, 16891 &inset, inset_type); 16892 if (ret) { 16893 printf("Failed to get input set.\n"); 16894 return; 16895 } 16896 16897 if (!strcmp(res->opt, "get")) { 16898 ret = rte_pmd_i40e_inset_field_get(inset.inset, 16899 res->field_idx); 16900 if (ret) 16901 printf("Field index %d is enabled.\n", res->field_idx); 16902 else 16903 printf("Field index %d is disabled.\n", res->field_idx); 16904 return; 16905 } else if (!strcmp(res->opt, "set")) 16906 ret = rte_pmd_i40e_inset_field_set(&inset.inset, 16907 res->field_idx); 16908 else if (!strcmp(res->opt, "clear")) 16909 ret = rte_pmd_i40e_inset_field_clear(&inset.inset, 16910 res->field_idx); 16911 if (ret) { 16912 printf("Failed to configure input set field.\n"); 16913 return; 16914 } 16915 16916 ret = rte_pmd_i40e_inset_set(res->port_id, res->pctype_id, 16917 &inset, inset_type); 16918 if (ret) { 16919 printf("Failed to set input set.\n"); 16920 return; 16921 } 16922 #endif 16923 16924 if (ret == -ENOTSUP) 16925 printf("Function not supported\n"); 16926 } 16927 16928 cmdline_parse_token_string_t cmd_cfg_input_set_port = 16929 TOKEN_STRING_INITIALIZER(struct cmd_cfg_input_set_result, 16930 port, "port"); 16931 cmdline_parse_token_string_t cmd_cfg_input_set_cfg = 16932 TOKEN_STRING_INITIALIZER(struct cmd_cfg_input_set_result, 16933 cfg, "config"); 16934 cmdline_parse_token_num_t cmd_cfg_input_set_port_id = 16935 TOKEN_NUM_INITIALIZER(struct cmd_cfg_input_set_result, 16936 port_id, UINT16); 16937 cmdline_parse_token_string_t cmd_cfg_input_set_pctype = 16938 TOKEN_STRING_INITIALIZER(struct cmd_cfg_input_set_result, 16939 pctype, "pctype"); 16940 cmdline_parse_token_num_t cmd_cfg_input_set_pctype_id = 16941 TOKEN_NUM_INITIALIZER(struct cmd_cfg_input_set_result, 16942 pctype_id, UINT8); 16943 cmdline_parse_token_string_t cmd_cfg_input_set_inset_type = 16944 TOKEN_STRING_INITIALIZER(struct cmd_cfg_input_set_result, 16945 inset_type, 16946 "hash_inset#fdir_inset#fdir_flx_inset"); 16947 cmdline_parse_token_string_t cmd_cfg_input_set_opt = 16948 TOKEN_STRING_INITIALIZER(struct cmd_cfg_input_set_result, 16949 opt, "get#set#clear"); 16950 cmdline_parse_token_string_t cmd_cfg_input_set_field = 16951 TOKEN_STRING_INITIALIZER(struct cmd_cfg_input_set_result, 16952 field, "field"); 16953 cmdline_parse_token_num_t cmd_cfg_input_set_field_idx = 16954 TOKEN_NUM_INITIALIZER(struct cmd_cfg_input_set_result, 16955 field_idx, UINT8); 16956 16957 cmdline_parse_inst_t cmd_cfg_input_set = { 16958 .f = cmd_cfg_input_set_parsed, 16959 .data = NULL, 16960 .help_str = "port config <port_id> pctype <pctype_id> hash_inset|" 16961 "fdir_inset|fdir_flx_inset get|set|clear field <field_idx>", 16962 .tokens = { 16963 (void *)&cmd_cfg_input_set_port, 16964 (void *)&cmd_cfg_input_set_cfg, 16965 (void *)&cmd_cfg_input_set_port_id, 16966 (void *)&cmd_cfg_input_set_pctype, 16967 (void *)&cmd_cfg_input_set_pctype_id, 16968 (void *)&cmd_cfg_input_set_inset_type, 16969 (void *)&cmd_cfg_input_set_opt, 16970 (void *)&cmd_cfg_input_set_field, 16971 (void *)&cmd_cfg_input_set_field_idx, 16972 NULL, 16973 }, 16974 }; 16975 16976 /* Clear input set */ 16977 struct cmd_clear_input_set_result { 16978 cmdline_fixed_string_t port; 16979 cmdline_fixed_string_t cfg; 16980 portid_t port_id; 16981 cmdline_fixed_string_t pctype; 16982 uint8_t pctype_id; 16983 cmdline_fixed_string_t inset_type; 16984 cmdline_fixed_string_t clear; 16985 cmdline_fixed_string_t all; 16986 }; 16987 16988 static void 16989 cmd_clear_input_set_parsed( 16990 __attribute__((unused)) void *parsed_result, 16991 __attribute__((unused)) struct cmdline *cl, 16992 __attribute__((unused)) void *data) 16993 { 16994 #ifdef RTE_LIBRTE_I40E_PMD 16995 struct cmd_clear_input_set_result *res = parsed_result; 16996 enum rte_pmd_i40e_inset_type inset_type = INSET_NONE; 16997 struct rte_pmd_i40e_inset inset; 16998 #endif 16999 int ret = -ENOTSUP; 17000 17001 if (!all_ports_stopped()) { 17002 printf("Please stop all ports first\n"); 17003 return; 17004 } 17005 17006 #ifdef RTE_LIBRTE_I40E_PMD 17007 if (!strcmp(res->inset_type, "hash_inset")) 17008 inset_type = INSET_HASH; 17009 else if (!strcmp(res->inset_type, "fdir_inset")) 17010 inset_type = INSET_FDIR; 17011 else if (!strcmp(res->inset_type, "fdir_flx_inset")) 17012 inset_type = INSET_FDIR_FLX; 17013 17014 memset(&inset, 0, sizeof(inset)); 17015 17016 ret = rte_pmd_i40e_inset_set(res->port_id, res->pctype_id, 17017 &inset, inset_type); 17018 if (ret) { 17019 printf("Failed to clear input set.\n"); 17020 return; 17021 } 17022 17023 #endif 17024 17025 if (ret == -ENOTSUP) 17026 printf("Function not supported\n"); 17027 } 17028 17029 cmdline_parse_token_string_t cmd_clear_input_set_port = 17030 TOKEN_STRING_INITIALIZER(struct cmd_clear_input_set_result, 17031 port, "port"); 17032 cmdline_parse_token_string_t cmd_clear_input_set_cfg = 17033 TOKEN_STRING_INITIALIZER(struct cmd_clear_input_set_result, 17034 cfg, "config"); 17035 cmdline_parse_token_num_t cmd_clear_input_set_port_id = 17036 TOKEN_NUM_INITIALIZER(struct cmd_clear_input_set_result, 17037 port_id, UINT16); 17038 cmdline_parse_token_string_t cmd_clear_input_set_pctype = 17039 TOKEN_STRING_INITIALIZER(struct cmd_clear_input_set_result, 17040 pctype, "pctype"); 17041 cmdline_parse_token_num_t cmd_clear_input_set_pctype_id = 17042 TOKEN_NUM_INITIALIZER(struct cmd_clear_input_set_result, 17043 pctype_id, UINT8); 17044 cmdline_parse_token_string_t cmd_clear_input_set_inset_type = 17045 TOKEN_STRING_INITIALIZER(struct cmd_clear_input_set_result, 17046 inset_type, 17047 "hash_inset#fdir_inset#fdir_flx_inset"); 17048 cmdline_parse_token_string_t cmd_clear_input_set_clear = 17049 TOKEN_STRING_INITIALIZER(struct cmd_clear_input_set_result, 17050 clear, "clear"); 17051 cmdline_parse_token_string_t cmd_clear_input_set_all = 17052 TOKEN_STRING_INITIALIZER(struct cmd_clear_input_set_result, 17053 all, "all"); 17054 17055 cmdline_parse_inst_t cmd_clear_input_set = { 17056 .f = cmd_clear_input_set_parsed, 17057 .data = NULL, 17058 .help_str = "port config <port_id> pctype <pctype_id> hash_inset|" 17059 "fdir_inset|fdir_flx_inset clear all", 17060 .tokens = { 17061 (void *)&cmd_clear_input_set_port, 17062 (void *)&cmd_clear_input_set_cfg, 17063 (void *)&cmd_clear_input_set_port_id, 17064 (void *)&cmd_clear_input_set_pctype, 17065 (void *)&cmd_clear_input_set_pctype_id, 17066 (void *)&cmd_clear_input_set_inset_type, 17067 (void *)&cmd_clear_input_set_clear, 17068 (void *)&cmd_clear_input_set_all, 17069 NULL, 17070 }, 17071 }; 17072 17073 /* show vf stats */ 17074 17075 /* Common result structure for show vf stats */ 17076 struct cmd_show_vf_stats_result { 17077 cmdline_fixed_string_t show; 17078 cmdline_fixed_string_t vf; 17079 cmdline_fixed_string_t stats; 17080 portid_t port_id; 17081 uint16_t vf_id; 17082 }; 17083 17084 /* Common CLI fields show vf stats*/ 17085 cmdline_parse_token_string_t cmd_show_vf_stats_show = 17086 TOKEN_STRING_INITIALIZER 17087 (struct cmd_show_vf_stats_result, 17088 show, "show"); 17089 cmdline_parse_token_string_t cmd_show_vf_stats_vf = 17090 TOKEN_STRING_INITIALIZER 17091 (struct cmd_show_vf_stats_result, 17092 vf, "vf"); 17093 cmdline_parse_token_string_t cmd_show_vf_stats_stats = 17094 TOKEN_STRING_INITIALIZER 17095 (struct cmd_show_vf_stats_result, 17096 stats, "stats"); 17097 cmdline_parse_token_num_t cmd_show_vf_stats_port_id = 17098 TOKEN_NUM_INITIALIZER 17099 (struct cmd_show_vf_stats_result, 17100 port_id, UINT16); 17101 cmdline_parse_token_num_t cmd_show_vf_stats_vf_id = 17102 TOKEN_NUM_INITIALIZER 17103 (struct cmd_show_vf_stats_result, 17104 vf_id, UINT16); 17105 17106 static void 17107 cmd_show_vf_stats_parsed( 17108 void *parsed_result, 17109 __attribute__((unused)) struct cmdline *cl, 17110 __attribute__((unused)) void *data) 17111 { 17112 struct cmd_show_vf_stats_result *res = parsed_result; 17113 struct rte_eth_stats stats; 17114 int ret = -ENOTSUP; 17115 static const char *nic_stats_border = "########################"; 17116 17117 if (port_id_is_invalid(res->port_id, ENABLED_WARN)) 17118 return; 17119 17120 memset(&stats, 0, sizeof(stats)); 17121 17122 #ifdef RTE_LIBRTE_I40E_PMD 17123 if (ret == -ENOTSUP) 17124 ret = rte_pmd_i40e_get_vf_stats(res->port_id, 17125 res->vf_id, 17126 &stats); 17127 #endif 17128 #ifdef RTE_LIBRTE_BNXT_PMD 17129 if (ret == -ENOTSUP) 17130 ret = rte_pmd_bnxt_get_vf_stats(res->port_id, 17131 res->vf_id, 17132 &stats); 17133 #endif 17134 17135 switch (ret) { 17136 case 0: 17137 break; 17138 case -EINVAL: 17139 printf("invalid vf_id %d\n", res->vf_id); 17140 break; 17141 case -ENODEV: 17142 printf("invalid port_id %d\n", res->port_id); 17143 break; 17144 case -ENOTSUP: 17145 printf("function not implemented\n"); 17146 break; 17147 default: 17148 printf("programming error: (%s)\n", strerror(-ret)); 17149 } 17150 17151 printf("\n %s NIC statistics for port %-2d vf %-2d %s\n", 17152 nic_stats_border, res->port_id, res->vf_id, nic_stats_border); 17153 17154 printf(" RX-packets: %-10"PRIu64" RX-missed: %-10"PRIu64" RX-bytes: " 17155 "%-"PRIu64"\n", 17156 stats.ipackets, stats.imissed, stats.ibytes); 17157 printf(" RX-errors: %-"PRIu64"\n", stats.ierrors); 17158 printf(" RX-nombuf: %-10"PRIu64"\n", 17159 stats.rx_nombuf); 17160 printf(" TX-packets: %-10"PRIu64" TX-errors: %-10"PRIu64" TX-bytes: " 17161 "%-"PRIu64"\n", 17162 stats.opackets, stats.oerrors, stats.obytes); 17163 17164 printf(" %s############################%s\n", 17165 nic_stats_border, nic_stats_border); 17166 } 17167 17168 cmdline_parse_inst_t cmd_show_vf_stats = { 17169 .f = cmd_show_vf_stats_parsed, 17170 .data = NULL, 17171 .help_str = "show vf stats <port_id> <vf_id>", 17172 .tokens = { 17173 (void *)&cmd_show_vf_stats_show, 17174 (void *)&cmd_show_vf_stats_vf, 17175 (void *)&cmd_show_vf_stats_stats, 17176 (void *)&cmd_show_vf_stats_port_id, 17177 (void *)&cmd_show_vf_stats_vf_id, 17178 NULL, 17179 }, 17180 }; 17181 17182 /* clear vf stats */ 17183 17184 /* Common result structure for clear vf stats */ 17185 struct cmd_clear_vf_stats_result { 17186 cmdline_fixed_string_t clear; 17187 cmdline_fixed_string_t vf; 17188 cmdline_fixed_string_t stats; 17189 portid_t port_id; 17190 uint16_t vf_id; 17191 }; 17192 17193 /* Common CLI fields clear vf stats*/ 17194 cmdline_parse_token_string_t cmd_clear_vf_stats_clear = 17195 TOKEN_STRING_INITIALIZER 17196 (struct cmd_clear_vf_stats_result, 17197 clear, "clear"); 17198 cmdline_parse_token_string_t cmd_clear_vf_stats_vf = 17199 TOKEN_STRING_INITIALIZER 17200 (struct cmd_clear_vf_stats_result, 17201 vf, "vf"); 17202 cmdline_parse_token_string_t cmd_clear_vf_stats_stats = 17203 TOKEN_STRING_INITIALIZER 17204 (struct cmd_clear_vf_stats_result, 17205 stats, "stats"); 17206 cmdline_parse_token_num_t cmd_clear_vf_stats_port_id = 17207 TOKEN_NUM_INITIALIZER 17208 (struct cmd_clear_vf_stats_result, 17209 port_id, UINT16); 17210 cmdline_parse_token_num_t cmd_clear_vf_stats_vf_id = 17211 TOKEN_NUM_INITIALIZER 17212 (struct cmd_clear_vf_stats_result, 17213 vf_id, UINT16); 17214 17215 static void 17216 cmd_clear_vf_stats_parsed( 17217 void *parsed_result, 17218 __attribute__((unused)) struct cmdline *cl, 17219 __attribute__((unused)) void *data) 17220 { 17221 struct cmd_clear_vf_stats_result *res = parsed_result; 17222 int ret = -ENOTSUP; 17223 17224 if (port_id_is_invalid(res->port_id, ENABLED_WARN)) 17225 return; 17226 17227 #ifdef RTE_LIBRTE_I40E_PMD 17228 if (ret == -ENOTSUP) 17229 ret = rte_pmd_i40e_reset_vf_stats(res->port_id, 17230 res->vf_id); 17231 #endif 17232 #ifdef RTE_LIBRTE_BNXT_PMD 17233 if (ret == -ENOTSUP) 17234 ret = rte_pmd_bnxt_reset_vf_stats(res->port_id, 17235 res->vf_id); 17236 #endif 17237 17238 switch (ret) { 17239 case 0: 17240 break; 17241 case -EINVAL: 17242 printf("invalid vf_id %d\n", res->vf_id); 17243 break; 17244 case -ENODEV: 17245 printf("invalid port_id %d\n", res->port_id); 17246 break; 17247 case -ENOTSUP: 17248 printf("function not implemented\n"); 17249 break; 17250 default: 17251 printf("programming error: (%s)\n", strerror(-ret)); 17252 } 17253 } 17254 17255 cmdline_parse_inst_t cmd_clear_vf_stats = { 17256 .f = cmd_clear_vf_stats_parsed, 17257 .data = NULL, 17258 .help_str = "clear vf stats <port_id> <vf_id>", 17259 .tokens = { 17260 (void *)&cmd_clear_vf_stats_clear, 17261 (void *)&cmd_clear_vf_stats_vf, 17262 (void *)&cmd_clear_vf_stats_stats, 17263 (void *)&cmd_clear_vf_stats_port_id, 17264 (void *)&cmd_clear_vf_stats_vf_id, 17265 NULL, 17266 }, 17267 }; 17268 17269 /* port config pctype mapping reset */ 17270 17271 /* Common result structure for port config pctype mapping reset */ 17272 struct cmd_pctype_mapping_reset_result { 17273 cmdline_fixed_string_t port; 17274 cmdline_fixed_string_t config; 17275 portid_t port_id; 17276 cmdline_fixed_string_t pctype; 17277 cmdline_fixed_string_t mapping; 17278 cmdline_fixed_string_t reset; 17279 }; 17280 17281 /* Common CLI fields for port config pctype mapping reset*/ 17282 cmdline_parse_token_string_t cmd_pctype_mapping_reset_port = 17283 TOKEN_STRING_INITIALIZER 17284 (struct cmd_pctype_mapping_reset_result, 17285 port, "port"); 17286 cmdline_parse_token_string_t cmd_pctype_mapping_reset_config = 17287 TOKEN_STRING_INITIALIZER 17288 (struct cmd_pctype_mapping_reset_result, 17289 config, "config"); 17290 cmdline_parse_token_num_t cmd_pctype_mapping_reset_port_id = 17291 TOKEN_NUM_INITIALIZER 17292 (struct cmd_pctype_mapping_reset_result, 17293 port_id, UINT16); 17294 cmdline_parse_token_string_t cmd_pctype_mapping_reset_pctype = 17295 TOKEN_STRING_INITIALIZER 17296 (struct cmd_pctype_mapping_reset_result, 17297 pctype, "pctype"); 17298 cmdline_parse_token_string_t cmd_pctype_mapping_reset_mapping = 17299 TOKEN_STRING_INITIALIZER 17300 (struct cmd_pctype_mapping_reset_result, 17301 mapping, "mapping"); 17302 cmdline_parse_token_string_t cmd_pctype_mapping_reset_reset = 17303 TOKEN_STRING_INITIALIZER 17304 (struct cmd_pctype_mapping_reset_result, 17305 reset, "reset"); 17306 17307 static void 17308 cmd_pctype_mapping_reset_parsed( 17309 void *parsed_result, 17310 __attribute__((unused)) struct cmdline *cl, 17311 __attribute__((unused)) void *data) 17312 { 17313 struct cmd_pctype_mapping_reset_result *res = parsed_result; 17314 int ret = -ENOTSUP; 17315 17316 if (port_id_is_invalid(res->port_id, ENABLED_WARN)) 17317 return; 17318 17319 #ifdef RTE_LIBRTE_I40E_PMD 17320 ret = rte_pmd_i40e_flow_type_mapping_reset(res->port_id); 17321 #endif 17322 17323 switch (ret) { 17324 case 0: 17325 break; 17326 case -ENODEV: 17327 printf("invalid port_id %d\n", res->port_id); 17328 break; 17329 case -ENOTSUP: 17330 printf("function not implemented\n"); 17331 break; 17332 default: 17333 printf("programming error: (%s)\n", strerror(-ret)); 17334 } 17335 } 17336 17337 cmdline_parse_inst_t cmd_pctype_mapping_reset = { 17338 .f = cmd_pctype_mapping_reset_parsed, 17339 .data = NULL, 17340 .help_str = "port config <port_id> pctype mapping reset", 17341 .tokens = { 17342 (void *)&cmd_pctype_mapping_reset_port, 17343 (void *)&cmd_pctype_mapping_reset_config, 17344 (void *)&cmd_pctype_mapping_reset_port_id, 17345 (void *)&cmd_pctype_mapping_reset_pctype, 17346 (void *)&cmd_pctype_mapping_reset_mapping, 17347 (void *)&cmd_pctype_mapping_reset_reset, 17348 NULL, 17349 }, 17350 }; 17351 17352 /* show port pctype mapping */ 17353 17354 /* Common result structure for show port pctype mapping */ 17355 struct cmd_pctype_mapping_get_result { 17356 cmdline_fixed_string_t show; 17357 cmdline_fixed_string_t port; 17358 portid_t port_id; 17359 cmdline_fixed_string_t pctype; 17360 cmdline_fixed_string_t mapping; 17361 }; 17362 17363 /* Common CLI fields for pctype mapping get */ 17364 cmdline_parse_token_string_t cmd_pctype_mapping_get_show = 17365 TOKEN_STRING_INITIALIZER 17366 (struct cmd_pctype_mapping_get_result, 17367 show, "show"); 17368 cmdline_parse_token_string_t cmd_pctype_mapping_get_port = 17369 TOKEN_STRING_INITIALIZER 17370 (struct cmd_pctype_mapping_get_result, 17371 port, "port"); 17372 cmdline_parse_token_num_t cmd_pctype_mapping_get_port_id = 17373 TOKEN_NUM_INITIALIZER 17374 (struct cmd_pctype_mapping_get_result, 17375 port_id, UINT16); 17376 cmdline_parse_token_string_t cmd_pctype_mapping_get_pctype = 17377 TOKEN_STRING_INITIALIZER 17378 (struct cmd_pctype_mapping_get_result, 17379 pctype, "pctype"); 17380 cmdline_parse_token_string_t cmd_pctype_mapping_get_mapping = 17381 TOKEN_STRING_INITIALIZER 17382 (struct cmd_pctype_mapping_get_result, 17383 mapping, "mapping"); 17384 17385 static void 17386 cmd_pctype_mapping_get_parsed( 17387 void *parsed_result, 17388 __attribute__((unused)) struct cmdline *cl, 17389 __attribute__((unused)) void *data) 17390 { 17391 struct cmd_pctype_mapping_get_result *res = parsed_result; 17392 int ret = -ENOTSUP; 17393 #ifdef RTE_LIBRTE_I40E_PMD 17394 struct rte_pmd_i40e_flow_type_mapping 17395 mapping[RTE_PMD_I40E_FLOW_TYPE_MAX]; 17396 int i, j, first_pctype; 17397 #endif 17398 17399 if (port_id_is_invalid(res->port_id, ENABLED_WARN)) 17400 return; 17401 17402 #ifdef RTE_LIBRTE_I40E_PMD 17403 ret = rte_pmd_i40e_flow_type_mapping_get(res->port_id, mapping); 17404 #endif 17405 17406 switch (ret) { 17407 case 0: 17408 break; 17409 case -ENODEV: 17410 printf("invalid port_id %d\n", res->port_id); 17411 return; 17412 case -ENOTSUP: 17413 printf("function not implemented\n"); 17414 return; 17415 default: 17416 printf("programming error: (%s)\n", strerror(-ret)); 17417 return; 17418 } 17419 17420 #ifdef RTE_LIBRTE_I40E_PMD 17421 for (i = 0; i < RTE_PMD_I40E_FLOW_TYPE_MAX; i++) { 17422 if (mapping[i].pctype != 0ULL) { 17423 first_pctype = 1; 17424 17425 printf("pctype: "); 17426 for (j = 0; j < RTE_PMD_I40E_PCTYPE_MAX; j++) { 17427 if (mapping[i].pctype & (1ULL << j)) { 17428 printf(first_pctype ? 17429 "%02d" : ",%02d", j); 17430 first_pctype = 0; 17431 } 17432 } 17433 printf(" -> flowtype: %02d\n", mapping[i].flow_type); 17434 } 17435 } 17436 #endif 17437 } 17438 17439 cmdline_parse_inst_t cmd_pctype_mapping_get = { 17440 .f = cmd_pctype_mapping_get_parsed, 17441 .data = NULL, 17442 .help_str = "show port <port_id> pctype mapping", 17443 .tokens = { 17444 (void *)&cmd_pctype_mapping_get_show, 17445 (void *)&cmd_pctype_mapping_get_port, 17446 (void *)&cmd_pctype_mapping_get_port_id, 17447 (void *)&cmd_pctype_mapping_get_pctype, 17448 (void *)&cmd_pctype_mapping_get_mapping, 17449 NULL, 17450 }, 17451 }; 17452 17453 /* port config pctype mapping update */ 17454 17455 /* Common result structure for port config pctype mapping update */ 17456 struct cmd_pctype_mapping_update_result { 17457 cmdline_fixed_string_t port; 17458 cmdline_fixed_string_t config; 17459 portid_t port_id; 17460 cmdline_fixed_string_t pctype; 17461 cmdline_fixed_string_t mapping; 17462 cmdline_fixed_string_t update; 17463 cmdline_fixed_string_t pctype_list; 17464 uint16_t flow_type; 17465 }; 17466 17467 /* Common CLI fields for pctype mapping update*/ 17468 cmdline_parse_token_string_t cmd_pctype_mapping_update_port = 17469 TOKEN_STRING_INITIALIZER 17470 (struct cmd_pctype_mapping_update_result, 17471 port, "port"); 17472 cmdline_parse_token_string_t cmd_pctype_mapping_update_config = 17473 TOKEN_STRING_INITIALIZER 17474 (struct cmd_pctype_mapping_update_result, 17475 config, "config"); 17476 cmdline_parse_token_num_t cmd_pctype_mapping_update_port_id = 17477 TOKEN_NUM_INITIALIZER 17478 (struct cmd_pctype_mapping_update_result, 17479 port_id, UINT16); 17480 cmdline_parse_token_string_t cmd_pctype_mapping_update_pctype = 17481 TOKEN_STRING_INITIALIZER 17482 (struct cmd_pctype_mapping_update_result, 17483 pctype, "pctype"); 17484 cmdline_parse_token_string_t cmd_pctype_mapping_update_mapping = 17485 TOKEN_STRING_INITIALIZER 17486 (struct cmd_pctype_mapping_update_result, 17487 mapping, "mapping"); 17488 cmdline_parse_token_string_t cmd_pctype_mapping_update_update = 17489 TOKEN_STRING_INITIALIZER 17490 (struct cmd_pctype_mapping_update_result, 17491 update, "update"); 17492 cmdline_parse_token_string_t cmd_pctype_mapping_update_pc_type = 17493 TOKEN_STRING_INITIALIZER 17494 (struct cmd_pctype_mapping_update_result, 17495 pctype_list, NULL); 17496 cmdline_parse_token_num_t cmd_pctype_mapping_update_flow_type = 17497 TOKEN_NUM_INITIALIZER 17498 (struct cmd_pctype_mapping_update_result, 17499 flow_type, UINT16); 17500 17501 static void 17502 cmd_pctype_mapping_update_parsed( 17503 void *parsed_result, 17504 __attribute__((unused)) struct cmdline *cl, 17505 __attribute__((unused)) void *data) 17506 { 17507 struct cmd_pctype_mapping_update_result *res = parsed_result; 17508 int ret = -ENOTSUP; 17509 #ifdef RTE_LIBRTE_I40E_PMD 17510 struct rte_pmd_i40e_flow_type_mapping mapping; 17511 unsigned int i; 17512 unsigned int nb_item; 17513 unsigned int pctype_list[RTE_PMD_I40E_PCTYPE_MAX]; 17514 #endif 17515 17516 if (port_id_is_invalid(res->port_id, ENABLED_WARN)) 17517 return; 17518 17519 #ifdef RTE_LIBRTE_I40E_PMD 17520 nb_item = parse_item_list(res->pctype_list, "pctypes", 17521 RTE_PMD_I40E_PCTYPE_MAX, pctype_list, 1); 17522 mapping.flow_type = res->flow_type; 17523 for (i = 0, mapping.pctype = 0ULL; i < nb_item; i++) 17524 mapping.pctype |= (1ULL << pctype_list[i]); 17525 ret = rte_pmd_i40e_flow_type_mapping_update(res->port_id, 17526 &mapping, 17527 1, 17528 0); 17529 #endif 17530 17531 switch (ret) { 17532 case 0: 17533 break; 17534 case -EINVAL: 17535 printf("invalid pctype or flow type\n"); 17536 break; 17537 case -ENODEV: 17538 printf("invalid port_id %d\n", res->port_id); 17539 break; 17540 case -ENOTSUP: 17541 printf("function not implemented\n"); 17542 break; 17543 default: 17544 printf("programming error: (%s)\n", strerror(-ret)); 17545 } 17546 } 17547 17548 cmdline_parse_inst_t cmd_pctype_mapping_update = { 17549 .f = cmd_pctype_mapping_update_parsed, 17550 .data = NULL, 17551 .help_str = "port config <port_id> pctype mapping update" 17552 " <pctype_id_0,[pctype_id_1]*> <flowtype_id>", 17553 .tokens = { 17554 (void *)&cmd_pctype_mapping_update_port, 17555 (void *)&cmd_pctype_mapping_update_config, 17556 (void *)&cmd_pctype_mapping_update_port_id, 17557 (void *)&cmd_pctype_mapping_update_pctype, 17558 (void *)&cmd_pctype_mapping_update_mapping, 17559 (void *)&cmd_pctype_mapping_update_update, 17560 (void *)&cmd_pctype_mapping_update_pc_type, 17561 (void *)&cmd_pctype_mapping_update_flow_type, 17562 NULL, 17563 }, 17564 }; 17565 17566 /* ptype mapping get */ 17567 17568 /* Common result structure for ptype mapping get */ 17569 struct cmd_ptype_mapping_get_result { 17570 cmdline_fixed_string_t ptype; 17571 cmdline_fixed_string_t mapping; 17572 cmdline_fixed_string_t get; 17573 portid_t port_id; 17574 uint8_t valid_only; 17575 }; 17576 17577 /* Common CLI fields for ptype mapping get */ 17578 cmdline_parse_token_string_t cmd_ptype_mapping_get_ptype = 17579 TOKEN_STRING_INITIALIZER 17580 (struct cmd_ptype_mapping_get_result, 17581 ptype, "ptype"); 17582 cmdline_parse_token_string_t cmd_ptype_mapping_get_mapping = 17583 TOKEN_STRING_INITIALIZER 17584 (struct cmd_ptype_mapping_get_result, 17585 mapping, "mapping"); 17586 cmdline_parse_token_string_t cmd_ptype_mapping_get_get = 17587 TOKEN_STRING_INITIALIZER 17588 (struct cmd_ptype_mapping_get_result, 17589 get, "get"); 17590 cmdline_parse_token_num_t cmd_ptype_mapping_get_port_id = 17591 TOKEN_NUM_INITIALIZER 17592 (struct cmd_ptype_mapping_get_result, 17593 port_id, UINT16); 17594 cmdline_parse_token_num_t cmd_ptype_mapping_get_valid_only = 17595 TOKEN_NUM_INITIALIZER 17596 (struct cmd_ptype_mapping_get_result, 17597 valid_only, UINT8); 17598 17599 static void 17600 cmd_ptype_mapping_get_parsed( 17601 void *parsed_result, 17602 __attribute__((unused)) struct cmdline *cl, 17603 __attribute__((unused)) void *data) 17604 { 17605 struct cmd_ptype_mapping_get_result *res = parsed_result; 17606 int ret = -ENOTSUP; 17607 #ifdef RTE_LIBRTE_I40E_PMD 17608 int max_ptype_num = 256; 17609 struct rte_pmd_i40e_ptype_mapping mapping[max_ptype_num]; 17610 uint16_t count; 17611 int i; 17612 #endif 17613 17614 if (port_id_is_invalid(res->port_id, ENABLED_WARN)) 17615 return; 17616 17617 #ifdef RTE_LIBRTE_I40E_PMD 17618 ret = rte_pmd_i40e_ptype_mapping_get(res->port_id, 17619 mapping, 17620 max_ptype_num, 17621 &count, 17622 res->valid_only); 17623 #endif 17624 17625 switch (ret) { 17626 case 0: 17627 break; 17628 case -ENODEV: 17629 printf("invalid port_id %d\n", res->port_id); 17630 break; 17631 case -ENOTSUP: 17632 printf("function not implemented\n"); 17633 break; 17634 default: 17635 printf("programming error: (%s)\n", strerror(-ret)); 17636 } 17637 17638 #ifdef RTE_LIBRTE_I40E_PMD 17639 if (!ret) { 17640 for (i = 0; i < count; i++) 17641 printf("%3d\t0x%08x\n", 17642 mapping[i].hw_ptype, mapping[i].sw_ptype); 17643 } 17644 #endif 17645 } 17646 17647 cmdline_parse_inst_t cmd_ptype_mapping_get = { 17648 .f = cmd_ptype_mapping_get_parsed, 17649 .data = NULL, 17650 .help_str = "ptype mapping get <port_id> <valid_only>", 17651 .tokens = { 17652 (void *)&cmd_ptype_mapping_get_ptype, 17653 (void *)&cmd_ptype_mapping_get_mapping, 17654 (void *)&cmd_ptype_mapping_get_get, 17655 (void *)&cmd_ptype_mapping_get_port_id, 17656 (void *)&cmd_ptype_mapping_get_valid_only, 17657 NULL, 17658 }, 17659 }; 17660 17661 /* ptype mapping replace */ 17662 17663 /* Common result structure for ptype mapping replace */ 17664 struct cmd_ptype_mapping_replace_result { 17665 cmdline_fixed_string_t ptype; 17666 cmdline_fixed_string_t mapping; 17667 cmdline_fixed_string_t replace; 17668 portid_t port_id; 17669 uint32_t target; 17670 uint8_t mask; 17671 uint32_t pkt_type; 17672 }; 17673 17674 /* Common CLI fields for ptype mapping replace */ 17675 cmdline_parse_token_string_t cmd_ptype_mapping_replace_ptype = 17676 TOKEN_STRING_INITIALIZER 17677 (struct cmd_ptype_mapping_replace_result, 17678 ptype, "ptype"); 17679 cmdline_parse_token_string_t cmd_ptype_mapping_replace_mapping = 17680 TOKEN_STRING_INITIALIZER 17681 (struct cmd_ptype_mapping_replace_result, 17682 mapping, "mapping"); 17683 cmdline_parse_token_string_t cmd_ptype_mapping_replace_replace = 17684 TOKEN_STRING_INITIALIZER 17685 (struct cmd_ptype_mapping_replace_result, 17686 replace, "replace"); 17687 cmdline_parse_token_num_t cmd_ptype_mapping_replace_port_id = 17688 TOKEN_NUM_INITIALIZER 17689 (struct cmd_ptype_mapping_replace_result, 17690 port_id, UINT16); 17691 cmdline_parse_token_num_t cmd_ptype_mapping_replace_target = 17692 TOKEN_NUM_INITIALIZER 17693 (struct cmd_ptype_mapping_replace_result, 17694 target, UINT32); 17695 cmdline_parse_token_num_t cmd_ptype_mapping_replace_mask = 17696 TOKEN_NUM_INITIALIZER 17697 (struct cmd_ptype_mapping_replace_result, 17698 mask, UINT8); 17699 cmdline_parse_token_num_t cmd_ptype_mapping_replace_pkt_type = 17700 TOKEN_NUM_INITIALIZER 17701 (struct cmd_ptype_mapping_replace_result, 17702 pkt_type, UINT32); 17703 17704 static void 17705 cmd_ptype_mapping_replace_parsed( 17706 void *parsed_result, 17707 __attribute__((unused)) struct cmdline *cl, 17708 __attribute__((unused)) void *data) 17709 { 17710 struct cmd_ptype_mapping_replace_result *res = parsed_result; 17711 int ret = -ENOTSUP; 17712 17713 if (port_id_is_invalid(res->port_id, ENABLED_WARN)) 17714 return; 17715 17716 #ifdef RTE_LIBRTE_I40E_PMD 17717 ret = rte_pmd_i40e_ptype_mapping_replace(res->port_id, 17718 res->target, 17719 res->mask, 17720 res->pkt_type); 17721 #endif 17722 17723 switch (ret) { 17724 case 0: 17725 break; 17726 case -EINVAL: 17727 printf("invalid ptype 0x%8x or 0x%8x\n", 17728 res->target, res->pkt_type); 17729 break; 17730 case -ENODEV: 17731 printf("invalid port_id %d\n", res->port_id); 17732 break; 17733 case -ENOTSUP: 17734 printf("function not implemented\n"); 17735 break; 17736 default: 17737 printf("programming error: (%s)\n", strerror(-ret)); 17738 } 17739 } 17740 17741 cmdline_parse_inst_t cmd_ptype_mapping_replace = { 17742 .f = cmd_ptype_mapping_replace_parsed, 17743 .data = NULL, 17744 .help_str = 17745 "ptype mapping replace <port_id> <target> <mask> <pkt_type>", 17746 .tokens = { 17747 (void *)&cmd_ptype_mapping_replace_ptype, 17748 (void *)&cmd_ptype_mapping_replace_mapping, 17749 (void *)&cmd_ptype_mapping_replace_replace, 17750 (void *)&cmd_ptype_mapping_replace_port_id, 17751 (void *)&cmd_ptype_mapping_replace_target, 17752 (void *)&cmd_ptype_mapping_replace_mask, 17753 (void *)&cmd_ptype_mapping_replace_pkt_type, 17754 NULL, 17755 }, 17756 }; 17757 17758 /* ptype mapping reset */ 17759 17760 /* Common result structure for ptype mapping reset */ 17761 struct cmd_ptype_mapping_reset_result { 17762 cmdline_fixed_string_t ptype; 17763 cmdline_fixed_string_t mapping; 17764 cmdline_fixed_string_t reset; 17765 portid_t port_id; 17766 }; 17767 17768 /* Common CLI fields for ptype mapping reset*/ 17769 cmdline_parse_token_string_t cmd_ptype_mapping_reset_ptype = 17770 TOKEN_STRING_INITIALIZER 17771 (struct cmd_ptype_mapping_reset_result, 17772 ptype, "ptype"); 17773 cmdline_parse_token_string_t cmd_ptype_mapping_reset_mapping = 17774 TOKEN_STRING_INITIALIZER 17775 (struct cmd_ptype_mapping_reset_result, 17776 mapping, "mapping"); 17777 cmdline_parse_token_string_t cmd_ptype_mapping_reset_reset = 17778 TOKEN_STRING_INITIALIZER 17779 (struct cmd_ptype_mapping_reset_result, 17780 reset, "reset"); 17781 cmdline_parse_token_num_t cmd_ptype_mapping_reset_port_id = 17782 TOKEN_NUM_INITIALIZER 17783 (struct cmd_ptype_mapping_reset_result, 17784 port_id, UINT16); 17785 17786 static void 17787 cmd_ptype_mapping_reset_parsed( 17788 void *parsed_result, 17789 __attribute__((unused)) struct cmdline *cl, 17790 __attribute__((unused)) void *data) 17791 { 17792 struct cmd_ptype_mapping_reset_result *res = parsed_result; 17793 int ret = -ENOTSUP; 17794 17795 if (port_id_is_invalid(res->port_id, ENABLED_WARN)) 17796 return; 17797 17798 #ifdef RTE_LIBRTE_I40E_PMD 17799 ret = rte_pmd_i40e_ptype_mapping_reset(res->port_id); 17800 #endif 17801 17802 switch (ret) { 17803 case 0: 17804 break; 17805 case -ENODEV: 17806 printf("invalid port_id %d\n", res->port_id); 17807 break; 17808 case -ENOTSUP: 17809 printf("function not implemented\n"); 17810 break; 17811 default: 17812 printf("programming error: (%s)\n", strerror(-ret)); 17813 } 17814 } 17815 17816 cmdline_parse_inst_t cmd_ptype_mapping_reset = { 17817 .f = cmd_ptype_mapping_reset_parsed, 17818 .data = NULL, 17819 .help_str = "ptype mapping reset <port_id>", 17820 .tokens = { 17821 (void *)&cmd_ptype_mapping_reset_ptype, 17822 (void *)&cmd_ptype_mapping_reset_mapping, 17823 (void *)&cmd_ptype_mapping_reset_reset, 17824 (void *)&cmd_ptype_mapping_reset_port_id, 17825 NULL, 17826 }, 17827 }; 17828 17829 /* ptype mapping update */ 17830 17831 /* Common result structure for ptype mapping update */ 17832 struct cmd_ptype_mapping_update_result { 17833 cmdline_fixed_string_t ptype; 17834 cmdline_fixed_string_t mapping; 17835 cmdline_fixed_string_t reset; 17836 portid_t port_id; 17837 uint8_t hw_ptype; 17838 uint32_t sw_ptype; 17839 }; 17840 17841 /* Common CLI fields for ptype mapping update*/ 17842 cmdline_parse_token_string_t cmd_ptype_mapping_update_ptype = 17843 TOKEN_STRING_INITIALIZER 17844 (struct cmd_ptype_mapping_update_result, 17845 ptype, "ptype"); 17846 cmdline_parse_token_string_t cmd_ptype_mapping_update_mapping = 17847 TOKEN_STRING_INITIALIZER 17848 (struct cmd_ptype_mapping_update_result, 17849 mapping, "mapping"); 17850 cmdline_parse_token_string_t cmd_ptype_mapping_update_update = 17851 TOKEN_STRING_INITIALIZER 17852 (struct cmd_ptype_mapping_update_result, 17853 reset, "update"); 17854 cmdline_parse_token_num_t cmd_ptype_mapping_update_port_id = 17855 TOKEN_NUM_INITIALIZER 17856 (struct cmd_ptype_mapping_update_result, 17857 port_id, UINT16); 17858 cmdline_parse_token_num_t cmd_ptype_mapping_update_hw_ptype = 17859 TOKEN_NUM_INITIALIZER 17860 (struct cmd_ptype_mapping_update_result, 17861 hw_ptype, UINT8); 17862 cmdline_parse_token_num_t cmd_ptype_mapping_update_sw_ptype = 17863 TOKEN_NUM_INITIALIZER 17864 (struct cmd_ptype_mapping_update_result, 17865 sw_ptype, UINT32); 17866 17867 static void 17868 cmd_ptype_mapping_update_parsed( 17869 void *parsed_result, 17870 __attribute__((unused)) struct cmdline *cl, 17871 __attribute__((unused)) void *data) 17872 { 17873 struct cmd_ptype_mapping_update_result *res = parsed_result; 17874 int ret = -ENOTSUP; 17875 #ifdef RTE_LIBRTE_I40E_PMD 17876 struct rte_pmd_i40e_ptype_mapping mapping; 17877 #endif 17878 if (port_id_is_invalid(res->port_id, ENABLED_WARN)) 17879 return; 17880 17881 #ifdef RTE_LIBRTE_I40E_PMD 17882 mapping.hw_ptype = res->hw_ptype; 17883 mapping.sw_ptype = res->sw_ptype; 17884 ret = rte_pmd_i40e_ptype_mapping_update(res->port_id, 17885 &mapping, 17886 1, 17887 0); 17888 #endif 17889 17890 switch (ret) { 17891 case 0: 17892 break; 17893 case -EINVAL: 17894 printf("invalid ptype 0x%8x\n", res->sw_ptype); 17895 break; 17896 case -ENODEV: 17897 printf("invalid port_id %d\n", res->port_id); 17898 break; 17899 case -ENOTSUP: 17900 printf("function not implemented\n"); 17901 break; 17902 default: 17903 printf("programming error: (%s)\n", strerror(-ret)); 17904 } 17905 } 17906 17907 cmdline_parse_inst_t cmd_ptype_mapping_update = { 17908 .f = cmd_ptype_mapping_update_parsed, 17909 .data = NULL, 17910 .help_str = "ptype mapping update <port_id> <hw_ptype> <sw_ptype>", 17911 .tokens = { 17912 (void *)&cmd_ptype_mapping_update_ptype, 17913 (void *)&cmd_ptype_mapping_update_mapping, 17914 (void *)&cmd_ptype_mapping_update_update, 17915 (void *)&cmd_ptype_mapping_update_port_id, 17916 (void *)&cmd_ptype_mapping_update_hw_ptype, 17917 (void *)&cmd_ptype_mapping_update_sw_ptype, 17918 NULL, 17919 }, 17920 }; 17921 17922 /* Common result structure for file commands */ 17923 struct cmd_cmdfile_result { 17924 cmdline_fixed_string_t load; 17925 cmdline_fixed_string_t filename; 17926 }; 17927 17928 /* Common CLI fields for file commands */ 17929 cmdline_parse_token_string_t cmd_load_cmdfile = 17930 TOKEN_STRING_INITIALIZER(struct cmd_cmdfile_result, load, "load"); 17931 cmdline_parse_token_string_t cmd_load_cmdfile_filename = 17932 TOKEN_STRING_INITIALIZER(struct cmd_cmdfile_result, filename, NULL); 17933 17934 static void 17935 cmd_load_from_file_parsed( 17936 void *parsed_result, 17937 __attribute__((unused)) struct cmdline *cl, 17938 __attribute__((unused)) void *data) 17939 { 17940 struct cmd_cmdfile_result *res = parsed_result; 17941 17942 cmdline_read_from_file(res->filename); 17943 } 17944 17945 cmdline_parse_inst_t cmd_load_from_file = { 17946 .f = cmd_load_from_file_parsed, 17947 .data = NULL, 17948 .help_str = "load <filename>", 17949 .tokens = { 17950 (void *)&cmd_load_cmdfile, 17951 (void *)&cmd_load_cmdfile_filename, 17952 NULL, 17953 }, 17954 }; 17955 17956 /* Get Rx offloads capabilities */ 17957 struct cmd_rx_offload_get_capa_result { 17958 cmdline_fixed_string_t show; 17959 cmdline_fixed_string_t port; 17960 portid_t port_id; 17961 cmdline_fixed_string_t rx_offload; 17962 cmdline_fixed_string_t capabilities; 17963 }; 17964 17965 cmdline_parse_token_string_t cmd_rx_offload_get_capa_show = 17966 TOKEN_STRING_INITIALIZER 17967 (struct cmd_rx_offload_get_capa_result, 17968 show, "show"); 17969 cmdline_parse_token_string_t cmd_rx_offload_get_capa_port = 17970 TOKEN_STRING_INITIALIZER 17971 (struct cmd_rx_offload_get_capa_result, 17972 port, "port"); 17973 cmdline_parse_token_num_t cmd_rx_offload_get_capa_port_id = 17974 TOKEN_NUM_INITIALIZER 17975 (struct cmd_rx_offload_get_capa_result, 17976 port_id, UINT16); 17977 cmdline_parse_token_string_t cmd_rx_offload_get_capa_rx_offload = 17978 TOKEN_STRING_INITIALIZER 17979 (struct cmd_rx_offload_get_capa_result, 17980 rx_offload, "rx_offload"); 17981 cmdline_parse_token_string_t cmd_rx_offload_get_capa_capabilities = 17982 TOKEN_STRING_INITIALIZER 17983 (struct cmd_rx_offload_get_capa_result, 17984 capabilities, "capabilities"); 17985 17986 static void 17987 print_rx_offloads(uint64_t offloads) 17988 { 17989 uint64_t single_offload; 17990 int begin; 17991 int end; 17992 int bit; 17993 17994 if (offloads == 0) 17995 return; 17996 17997 begin = __builtin_ctzll(offloads); 17998 end = sizeof(offloads) * CHAR_BIT - __builtin_clzll(offloads); 17999 18000 single_offload = 1ULL << begin; 18001 for (bit = begin; bit < end; bit++) { 18002 if (offloads & single_offload) 18003 printf(" %s", 18004 rte_eth_dev_rx_offload_name(single_offload)); 18005 single_offload <<= 1; 18006 } 18007 } 18008 18009 static void 18010 cmd_rx_offload_get_capa_parsed( 18011 void *parsed_result, 18012 __attribute__((unused)) struct cmdline *cl, 18013 __attribute__((unused)) void *data) 18014 { 18015 struct cmd_rx_offload_get_capa_result *res = parsed_result; 18016 struct rte_eth_dev_info dev_info; 18017 portid_t port_id = res->port_id; 18018 uint64_t queue_offloads; 18019 uint64_t port_offloads; 18020 int ret; 18021 18022 ret = eth_dev_info_get_print_err(port_id, &dev_info); 18023 if (ret != 0) 18024 return; 18025 18026 queue_offloads = dev_info.rx_queue_offload_capa; 18027 port_offloads = dev_info.rx_offload_capa ^ queue_offloads; 18028 18029 printf("Rx Offloading Capabilities of port %d :\n", port_id); 18030 printf(" Per Queue :"); 18031 print_rx_offloads(queue_offloads); 18032 18033 printf("\n"); 18034 printf(" Per Port :"); 18035 print_rx_offloads(port_offloads); 18036 printf("\n\n"); 18037 } 18038 18039 cmdline_parse_inst_t cmd_rx_offload_get_capa = { 18040 .f = cmd_rx_offload_get_capa_parsed, 18041 .data = NULL, 18042 .help_str = "show port <port_id> rx_offload capabilities", 18043 .tokens = { 18044 (void *)&cmd_rx_offload_get_capa_show, 18045 (void *)&cmd_rx_offload_get_capa_port, 18046 (void *)&cmd_rx_offload_get_capa_port_id, 18047 (void *)&cmd_rx_offload_get_capa_rx_offload, 18048 (void *)&cmd_rx_offload_get_capa_capabilities, 18049 NULL, 18050 } 18051 }; 18052 18053 /* Get Rx offloads configuration */ 18054 struct cmd_rx_offload_get_configuration_result { 18055 cmdline_fixed_string_t show; 18056 cmdline_fixed_string_t port; 18057 portid_t port_id; 18058 cmdline_fixed_string_t rx_offload; 18059 cmdline_fixed_string_t configuration; 18060 }; 18061 18062 cmdline_parse_token_string_t cmd_rx_offload_get_configuration_show = 18063 TOKEN_STRING_INITIALIZER 18064 (struct cmd_rx_offload_get_configuration_result, 18065 show, "show"); 18066 cmdline_parse_token_string_t cmd_rx_offload_get_configuration_port = 18067 TOKEN_STRING_INITIALIZER 18068 (struct cmd_rx_offload_get_configuration_result, 18069 port, "port"); 18070 cmdline_parse_token_num_t cmd_rx_offload_get_configuration_port_id = 18071 TOKEN_NUM_INITIALIZER 18072 (struct cmd_rx_offload_get_configuration_result, 18073 port_id, UINT16); 18074 cmdline_parse_token_string_t cmd_rx_offload_get_configuration_rx_offload = 18075 TOKEN_STRING_INITIALIZER 18076 (struct cmd_rx_offload_get_configuration_result, 18077 rx_offload, "rx_offload"); 18078 cmdline_parse_token_string_t cmd_rx_offload_get_configuration_configuration = 18079 TOKEN_STRING_INITIALIZER 18080 (struct cmd_rx_offload_get_configuration_result, 18081 configuration, "configuration"); 18082 18083 static void 18084 cmd_rx_offload_get_configuration_parsed( 18085 void *parsed_result, 18086 __attribute__((unused)) struct cmdline *cl, 18087 __attribute__((unused)) void *data) 18088 { 18089 struct cmd_rx_offload_get_configuration_result *res = parsed_result; 18090 struct rte_eth_dev_info dev_info; 18091 portid_t port_id = res->port_id; 18092 struct rte_port *port = &ports[port_id]; 18093 uint64_t port_offloads; 18094 uint64_t queue_offloads; 18095 uint16_t nb_rx_queues; 18096 int q; 18097 int ret; 18098 18099 printf("Rx Offloading Configuration of port %d :\n", port_id); 18100 18101 port_offloads = port->dev_conf.rxmode.offloads; 18102 printf(" Port :"); 18103 print_rx_offloads(port_offloads); 18104 printf("\n"); 18105 18106 ret = eth_dev_info_get_print_err(port_id, &dev_info); 18107 if (ret != 0) 18108 return; 18109 18110 nb_rx_queues = dev_info.nb_rx_queues; 18111 for (q = 0; q < nb_rx_queues; q++) { 18112 queue_offloads = port->rx_conf[q].offloads; 18113 printf(" Queue[%2d] :", q); 18114 print_rx_offloads(queue_offloads); 18115 printf("\n"); 18116 } 18117 printf("\n"); 18118 } 18119 18120 cmdline_parse_inst_t cmd_rx_offload_get_configuration = { 18121 .f = cmd_rx_offload_get_configuration_parsed, 18122 .data = NULL, 18123 .help_str = "show port <port_id> rx_offload configuration", 18124 .tokens = { 18125 (void *)&cmd_rx_offload_get_configuration_show, 18126 (void *)&cmd_rx_offload_get_configuration_port, 18127 (void *)&cmd_rx_offload_get_configuration_port_id, 18128 (void *)&cmd_rx_offload_get_configuration_rx_offload, 18129 (void *)&cmd_rx_offload_get_configuration_configuration, 18130 NULL, 18131 } 18132 }; 18133 18134 /* Enable/Disable a per port offloading */ 18135 struct cmd_config_per_port_rx_offload_result { 18136 cmdline_fixed_string_t port; 18137 cmdline_fixed_string_t config; 18138 portid_t port_id; 18139 cmdline_fixed_string_t rx_offload; 18140 cmdline_fixed_string_t offload; 18141 cmdline_fixed_string_t on_off; 18142 }; 18143 18144 cmdline_parse_token_string_t cmd_config_per_port_rx_offload_result_port = 18145 TOKEN_STRING_INITIALIZER 18146 (struct cmd_config_per_port_rx_offload_result, 18147 port, "port"); 18148 cmdline_parse_token_string_t cmd_config_per_port_rx_offload_result_config = 18149 TOKEN_STRING_INITIALIZER 18150 (struct cmd_config_per_port_rx_offload_result, 18151 config, "config"); 18152 cmdline_parse_token_num_t cmd_config_per_port_rx_offload_result_port_id = 18153 TOKEN_NUM_INITIALIZER 18154 (struct cmd_config_per_port_rx_offload_result, 18155 port_id, UINT16); 18156 cmdline_parse_token_string_t cmd_config_per_port_rx_offload_result_rx_offload = 18157 TOKEN_STRING_INITIALIZER 18158 (struct cmd_config_per_port_rx_offload_result, 18159 rx_offload, "rx_offload"); 18160 cmdline_parse_token_string_t cmd_config_per_port_rx_offload_result_offload = 18161 TOKEN_STRING_INITIALIZER 18162 (struct cmd_config_per_port_rx_offload_result, 18163 offload, "vlan_strip#ipv4_cksum#udp_cksum#tcp_cksum#tcp_lro#" 18164 "qinq_strip#outer_ipv4_cksum#macsec_strip#" 18165 "header_split#vlan_filter#vlan_extend#jumbo_frame#" 18166 "scatter#timestamp#security#keep_crc#rss_hash"); 18167 cmdline_parse_token_string_t cmd_config_per_port_rx_offload_result_on_off = 18168 TOKEN_STRING_INITIALIZER 18169 (struct cmd_config_per_port_rx_offload_result, 18170 on_off, "on#off"); 18171 18172 static uint64_t 18173 search_rx_offload(const char *name) 18174 { 18175 uint64_t single_offload; 18176 const char *single_name; 18177 int found = 0; 18178 unsigned int bit; 18179 18180 single_offload = 1; 18181 for (bit = 0; bit < sizeof(single_offload) * CHAR_BIT; bit++) { 18182 single_name = rte_eth_dev_rx_offload_name(single_offload); 18183 if (!strcasecmp(single_name, name)) { 18184 found = 1; 18185 break; 18186 } 18187 single_offload <<= 1; 18188 } 18189 18190 if (found) 18191 return single_offload; 18192 18193 return 0; 18194 } 18195 18196 static void 18197 cmd_config_per_port_rx_offload_parsed(void *parsed_result, 18198 __attribute__((unused)) struct cmdline *cl, 18199 __attribute__((unused)) void *data) 18200 { 18201 struct cmd_config_per_port_rx_offload_result *res = parsed_result; 18202 portid_t port_id = res->port_id; 18203 struct rte_eth_dev_info dev_info; 18204 struct rte_port *port = &ports[port_id]; 18205 uint64_t single_offload; 18206 uint16_t nb_rx_queues; 18207 int q; 18208 int ret; 18209 18210 if (port->port_status != RTE_PORT_STOPPED) { 18211 printf("Error: Can't config offload when Port %d " 18212 "is not stopped\n", port_id); 18213 return; 18214 } 18215 18216 single_offload = search_rx_offload(res->offload); 18217 if (single_offload == 0) { 18218 printf("Unknown offload name: %s\n", res->offload); 18219 return; 18220 } 18221 18222 ret = eth_dev_info_get_print_err(port_id, &dev_info); 18223 if (ret != 0) 18224 return; 18225 18226 nb_rx_queues = dev_info.nb_rx_queues; 18227 if (!strcmp(res->on_off, "on")) { 18228 port->dev_conf.rxmode.offloads |= single_offload; 18229 for (q = 0; q < nb_rx_queues; q++) 18230 port->rx_conf[q].offloads |= single_offload; 18231 } else { 18232 port->dev_conf.rxmode.offloads &= ~single_offload; 18233 for (q = 0; q < nb_rx_queues; q++) 18234 port->rx_conf[q].offloads &= ~single_offload; 18235 } 18236 18237 cmd_reconfig_device_queue(port_id, 1, 1); 18238 } 18239 18240 cmdline_parse_inst_t cmd_config_per_port_rx_offload = { 18241 .f = cmd_config_per_port_rx_offload_parsed, 18242 .data = NULL, 18243 .help_str = "port config <port_id> rx_offload vlan_strip|ipv4_cksum|" 18244 "udp_cksum|tcp_cksum|tcp_lro|qinq_strip|outer_ipv4_cksum|" 18245 "macsec_strip|header_split|vlan_filter|vlan_extend|" 18246 "jumbo_frame|scatter|timestamp|security|keep_crc|rss_hash " 18247 "on|off", 18248 .tokens = { 18249 (void *)&cmd_config_per_port_rx_offload_result_port, 18250 (void *)&cmd_config_per_port_rx_offload_result_config, 18251 (void *)&cmd_config_per_port_rx_offload_result_port_id, 18252 (void *)&cmd_config_per_port_rx_offload_result_rx_offload, 18253 (void *)&cmd_config_per_port_rx_offload_result_offload, 18254 (void *)&cmd_config_per_port_rx_offload_result_on_off, 18255 NULL, 18256 } 18257 }; 18258 18259 /* Enable/Disable a per queue offloading */ 18260 struct cmd_config_per_queue_rx_offload_result { 18261 cmdline_fixed_string_t port; 18262 portid_t port_id; 18263 cmdline_fixed_string_t rxq; 18264 uint16_t queue_id; 18265 cmdline_fixed_string_t rx_offload; 18266 cmdline_fixed_string_t offload; 18267 cmdline_fixed_string_t on_off; 18268 }; 18269 18270 cmdline_parse_token_string_t cmd_config_per_queue_rx_offload_result_port = 18271 TOKEN_STRING_INITIALIZER 18272 (struct cmd_config_per_queue_rx_offload_result, 18273 port, "port"); 18274 cmdline_parse_token_num_t cmd_config_per_queue_rx_offload_result_port_id = 18275 TOKEN_NUM_INITIALIZER 18276 (struct cmd_config_per_queue_rx_offload_result, 18277 port_id, UINT16); 18278 cmdline_parse_token_string_t cmd_config_per_queue_rx_offload_result_rxq = 18279 TOKEN_STRING_INITIALIZER 18280 (struct cmd_config_per_queue_rx_offload_result, 18281 rxq, "rxq"); 18282 cmdline_parse_token_num_t cmd_config_per_queue_rx_offload_result_queue_id = 18283 TOKEN_NUM_INITIALIZER 18284 (struct cmd_config_per_queue_rx_offload_result, 18285 queue_id, UINT16); 18286 cmdline_parse_token_string_t cmd_config_per_queue_rx_offload_result_rxoffload = 18287 TOKEN_STRING_INITIALIZER 18288 (struct cmd_config_per_queue_rx_offload_result, 18289 rx_offload, "rx_offload"); 18290 cmdline_parse_token_string_t cmd_config_per_queue_rx_offload_result_offload = 18291 TOKEN_STRING_INITIALIZER 18292 (struct cmd_config_per_queue_rx_offload_result, 18293 offload, "vlan_strip#ipv4_cksum#udp_cksum#tcp_cksum#tcp_lro#" 18294 "qinq_strip#outer_ipv4_cksum#macsec_strip#" 18295 "header_split#vlan_filter#vlan_extend#jumbo_frame#" 18296 "scatter#timestamp#security#keep_crc"); 18297 cmdline_parse_token_string_t cmd_config_per_queue_rx_offload_result_on_off = 18298 TOKEN_STRING_INITIALIZER 18299 (struct cmd_config_per_queue_rx_offload_result, 18300 on_off, "on#off"); 18301 18302 static void 18303 cmd_config_per_queue_rx_offload_parsed(void *parsed_result, 18304 __attribute__((unused)) struct cmdline *cl, 18305 __attribute__((unused)) void *data) 18306 { 18307 struct cmd_config_per_queue_rx_offload_result *res = parsed_result; 18308 struct rte_eth_dev_info dev_info; 18309 portid_t port_id = res->port_id; 18310 uint16_t queue_id = res->queue_id; 18311 struct rte_port *port = &ports[port_id]; 18312 uint64_t single_offload; 18313 int ret; 18314 18315 if (port->port_status != RTE_PORT_STOPPED) { 18316 printf("Error: Can't config offload when Port %d " 18317 "is not stopped\n", port_id); 18318 return; 18319 } 18320 18321 ret = eth_dev_info_get_print_err(port_id, &dev_info); 18322 if (ret != 0) 18323 return; 18324 18325 if (queue_id >= dev_info.nb_rx_queues) { 18326 printf("Error: input queue_id should be 0 ... " 18327 "%d\n", dev_info.nb_rx_queues - 1); 18328 return; 18329 } 18330 18331 single_offload = search_rx_offload(res->offload); 18332 if (single_offload == 0) { 18333 printf("Unknown offload name: %s\n", res->offload); 18334 return; 18335 } 18336 18337 if (!strcmp(res->on_off, "on")) 18338 port->rx_conf[queue_id].offloads |= single_offload; 18339 else 18340 port->rx_conf[queue_id].offloads &= ~single_offload; 18341 18342 cmd_reconfig_device_queue(port_id, 1, 1); 18343 } 18344 18345 cmdline_parse_inst_t cmd_config_per_queue_rx_offload = { 18346 .f = cmd_config_per_queue_rx_offload_parsed, 18347 .data = NULL, 18348 .help_str = "port <port_id> rxq <queue_id> rx_offload " 18349 "vlan_strip|ipv4_cksum|" 18350 "udp_cksum|tcp_cksum|tcp_lro|qinq_strip|outer_ipv4_cksum|" 18351 "macsec_strip|header_split|vlan_filter|vlan_extend|" 18352 "jumbo_frame|scatter|timestamp|security|keep_crc " 18353 "on|off", 18354 .tokens = { 18355 (void *)&cmd_config_per_queue_rx_offload_result_port, 18356 (void *)&cmd_config_per_queue_rx_offload_result_port_id, 18357 (void *)&cmd_config_per_queue_rx_offload_result_rxq, 18358 (void *)&cmd_config_per_queue_rx_offload_result_queue_id, 18359 (void *)&cmd_config_per_queue_rx_offload_result_rxoffload, 18360 (void *)&cmd_config_per_queue_rx_offload_result_offload, 18361 (void *)&cmd_config_per_queue_rx_offload_result_on_off, 18362 NULL, 18363 } 18364 }; 18365 18366 /* Get Tx offloads capabilities */ 18367 struct cmd_tx_offload_get_capa_result { 18368 cmdline_fixed_string_t show; 18369 cmdline_fixed_string_t port; 18370 portid_t port_id; 18371 cmdline_fixed_string_t tx_offload; 18372 cmdline_fixed_string_t capabilities; 18373 }; 18374 18375 cmdline_parse_token_string_t cmd_tx_offload_get_capa_show = 18376 TOKEN_STRING_INITIALIZER 18377 (struct cmd_tx_offload_get_capa_result, 18378 show, "show"); 18379 cmdline_parse_token_string_t cmd_tx_offload_get_capa_port = 18380 TOKEN_STRING_INITIALIZER 18381 (struct cmd_tx_offload_get_capa_result, 18382 port, "port"); 18383 cmdline_parse_token_num_t cmd_tx_offload_get_capa_port_id = 18384 TOKEN_NUM_INITIALIZER 18385 (struct cmd_tx_offload_get_capa_result, 18386 port_id, UINT16); 18387 cmdline_parse_token_string_t cmd_tx_offload_get_capa_tx_offload = 18388 TOKEN_STRING_INITIALIZER 18389 (struct cmd_tx_offload_get_capa_result, 18390 tx_offload, "tx_offload"); 18391 cmdline_parse_token_string_t cmd_tx_offload_get_capa_capabilities = 18392 TOKEN_STRING_INITIALIZER 18393 (struct cmd_tx_offload_get_capa_result, 18394 capabilities, "capabilities"); 18395 18396 static void 18397 print_tx_offloads(uint64_t offloads) 18398 { 18399 uint64_t single_offload; 18400 int begin; 18401 int end; 18402 int bit; 18403 18404 if (offloads == 0) 18405 return; 18406 18407 begin = __builtin_ctzll(offloads); 18408 end = sizeof(offloads) * CHAR_BIT - __builtin_clzll(offloads); 18409 18410 single_offload = 1ULL << begin; 18411 for (bit = begin; bit < end; bit++) { 18412 if (offloads & single_offload) 18413 printf(" %s", 18414 rte_eth_dev_tx_offload_name(single_offload)); 18415 single_offload <<= 1; 18416 } 18417 } 18418 18419 static void 18420 cmd_tx_offload_get_capa_parsed( 18421 void *parsed_result, 18422 __attribute__((unused)) struct cmdline *cl, 18423 __attribute__((unused)) void *data) 18424 { 18425 struct cmd_tx_offload_get_capa_result *res = parsed_result; 18426 struct rte_eth_dev_info dev_info; 18427 portid_t port_id = res->port_id; 18428 uint64_t queue_offloads; 18429 uint64_t port_offloads; 18430 int ret; 18431 18432 ret = eth_dev_info_get_print_err(port_id, &dev_info); 18433 if (ret != 0) 18434 return; 18435 18436 queue_offloads = dev_info.tx_queue_offload_capa; 18437 port_offloads = dev_info.tx_offload_capa ^ queue_offloads; 18438 18439 printf("Tx Offloading Capabilities of port %d :\n", port_id); 18440 printf(" Per Queue :"); 18441 print_tx_offloads(queue_offloads); 18442 18443 printf("\n"); 18444 printf(" Per Port :"); 18445 print_tx_offloads(port_offloads); 18446 printf("\n\n"); 18447 } 18448 18449 cmdline_parse_inst_t cmd_tx_offload_get_capa = { 18450 .f = cmd_tx_offload_get_capa_parsed, 18451 .data = NULL, 18452 .help_str = "show port <port_id> tx_offload capabilities", 18453 .tokens = { 18454 (void *)&cmd_tx_offload_get_capa_show, 18455 (void *)&cmd_tx_offload_get_capa_port, 18456 (void *)&cmd_tx_offload_get_capa_port_id, 18457 (void *)&cmd_tx_offload_get_capa_tx_offload, 18458 (void *)&cmd_tx_offload_get_capa_capabilities, 18459 NULL, 18460 } 18461 }; 18462 18463 /* Get Tx offloads configuration */ 18464 struct cmd_tx_offload_get_configuration_result { 18465 cmdline_fixed_string_t show; 18466 cmdline_fixed_string_t port; 18467 portid_t port_id; 18468 cmdline_fixed_string_t tx_offload; 18469 cmdline_fixed_string_t configuration; 18470 }; 18471 18472 cmdline_parse_token_string_t cmd_tx_offload_get_configuration_show = 18473 TOKEN_STRING_INITIALIZER 18474 (struct cmd_tx_offload_get_configuration_result, 18475 show, "show"); 18476 cmdline_parse_token_string_t cmd_tx_offload_get_configuration_port = 18477 TOKEN_STRING_INITIALIZER 18478 (struct cmd_tx_offload_get_configuration_result, 18479 port, "port"); 18480 cmdline_parse_token_num_t cmd_tx_offload_get_configuration_port_id = 18481 TOKEN_NUM_INITIALIZER 18482 (struct cmd_tx_offload_get_configuration_result, 18483 port_id, UINT16); 18484 cmdline_parse_token_string_t cmd_tx_offload_get_configuration_tx_offload = 18485 TOKEN_STRING_INITIALIZER 18486 (struct cmd_tx_offload_get_configuration_result, 18487 tx_offload, "tx_offload"); 18488 cmdline_parse_token_string_t cmd_tx_offload_get_configuration_configuration = 18489 TOKEN_STRING_INITIALIZER 18490 (struct cmd_tx_offload_get_configuration_result, 18491 configuration, "configuration"); 18492 18493 static void 18494 cmd_tx_offload_get_configuration_parsed( 18495 void *parsed_result, 18496 __attribute__((unused)) struct cmdline *cl, 18497 __attribute__((unused)) void *data) 18498 { 18499 struct cmd_tx_offload_get_configuration_result *res = parsed_result; 18500 struct rte_eth_dev_info dev_info; 18501 portid_t port_id = res->port_id; 18502 struct rte_port *port = &ports[port_id]; 18503 uint64_t port_offloads; 18504 uint64_t queue_offloads; 18505 uint16_t nb_tx_queues; 18506 int q; 18507 int ret; 18508 18509 printf("Tx Offloading Configuration of port %d :\n", port_id); 18510 18511 port_offloads = port->dev_conf.txmode.offloads; 18512 printf(" Port :"); 18513 print_tx_offloads(port_offloads); 18514 printf("\n"); 18515 18516 ret = eth_dev_info_get_print_err(port_id, &dev_info); 18517 if (ret != 0) 18518 return; 18519 18520 nb_tx_queues = dev_info.nb_tx_queues; 18521 for (q = 0; q < nb_tx_queues; q++) { 18522 queue_offloads = port->tx_conf[q].offloads; 18523 printf(" Queue[%2d] :", q); 18524 print_tx_offloads(queue_offloads); 18525 printf("\n"); 18526 } 18527 printf("\n"); 18528 } 18529 18530 cmdline_parse_inst_t cmd_tx_offload_get_configuration = { 18531 .f = cmd_tx_offload_get_configuration_parsed, 18532 .data = NULL, 18533 .help_str = "show port <port_id> tx_offload configuration", 18534 .tokens = { 18535 (void *)&cmd_tx_offload_get_configuration_show, 18536 (void *)&cmd_tx_offload_get_configuration_port, 18537 (void *)&cmd_tx_offload_get_configuration_port_id, 18538 (void *)&cmd_tx_offload_get_configuration_tx_offload, 18539 (void *)&cmd_tx_offload_get_configuration_configuration, 18540 NULL, 18541 } 18542 }; 18543 18544 /* Enable/Disable a per port offloading */ 18545 struct cmd_config_per_port_tx_offload_result { 18546 cmdline_fixed_string_t port; 18547 cmdline_fixed_string_t config; 18548 portid_t port_id; 18549 cmdline_fixed_string_t tx_offload; 18550 cmdline_fixed_string_t offload; 18551 cmdline_fixed_string_t on_off; 18552 }; 18553 18554 cmdline_parse_token_string_t cmd_config_per_port_tx_offload_result_port = 18555 TOKEN_STRING_INITIALIZER 18556 (struct cmd_config_per_port_tx_offload_result, 18557 port, "port"); 18558 cmdline_parse_token_string_t cmd_config_per_port_tx_offload_result_config = 18559 TOKEN_STRING_INITIALIZER 18560 (struct cmd_config_per_port_tx_offload_result, 18561 config, "config"); 18562 cmdline_parse_token_num_t cmd_config_per_port_tx_offload_result_port_id = 18563 TOKEN_NUM_INITIALIZER 18564 (struct cmd_config_per_port_tx_offload_result, 18565 port_id, UINT16); 18566 cmdline_parse_token_string_t cmd_config_per_port_tx_offload_result_tx_offload = 18567 TOKEN_STRING_INITIALIZER 18568 (struct cmd_config_per_port_tx_offload_result, 18569 tx_offload, "tx_offload"); 18570 cmdline_parse_token_string_t cmd_config_per_port_tx_offload_result_offload = 18571 TOKEN_STRING_INITIALIZER 18572 (struct cmd_config_per_port_tx_offload_result, 18573 offload, "vlan_insert#ipv4_cksum#udp_cksum#tcp_cksum#" 18574 "sctp_cksum#tcp_tso#udp_tso#outer_ipv4_cksum#" 18575 "qinq_insert#vxlan_tnl_tso#gre_tnl_tso#" 18576 "ipip_tnl_tso#geneve_tnl_tso#macsec_insert#" 18577 "mt_lockfree#multi_segs#mbuf_fast_free#security"); 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 on|off", 18663 .tokens = { 18664 (void *)&cmd_config_per_port_tx_offload_result_port, 18665 (void *)&cmd_config_per_port_tx_offload_result_config, 18666 (void *)&cmd_config_per_port_tx_offload_result_port_id, 18667 (void *)&cmd_config_per_port_tx_offload_result_tx_offload, 18668 (void *)&cmd_config_per_port_tx_offload_result_offload, 18669 (void *)&cmd_config_per_port_tx_offload_result_on_off, 18670 NULL, 18671 } 18672 }; 18673 18674 /* Enable/Disable a per queue offloading */ 18675 struct cmd_config_per_queue_tx_offload_result { 18676 cmdline_fixed_string_t port; 18677 portid_t port_id; 18678 cmdline_fixed_string_t txq; 18679 uint16_t queue_id; 18680 cmdline_fixed_string_t tx_offload; 18681 cmdline_fixed_string_t offload; 18682 cmdline_fixed_string_t on_off; 18683 }; 18684 18685 cmdline_parse_token_string_t cmd_config_per_queue_tx_offload_result_port = 18686 TOKEN_STRING_INITIALIZER 18687 (struct cmd_config_per_queue_tx_offload_result, 18688 port, "port"); 18689 cmdline_parse_token_num_t cmd_config_per_queue_tx_offload_result_port_id = 18690 TOKEN_NUM_INITIALIZER 18691 (struct cmd_config_per_queue_tx_offload_result, 18692 port_id, UINT16); 18693 cmdline_parse_token_string_t cmd_config_per_queue_tx_offload_result_txq = 18694 TOKEN_STRING_INITIALIZER 18695 (struct cmd_config_per_queue_tx_offload_result, 18696 txq, "txq"); 18697 cmdline_parse_token_num_t cmd_config_per_queue_tx_offload_result_queue_id = 18698 TOKEN_NUM_INITIALIZER 18699 (struct cmd_config_per_queue_tx_offload_result, 18700 queue_id, UINT16); 18701 cmdline_parse_token_string_t cmd_config_per_queue_tx_offload_result_txoffload = 18702 TOKEN_STRING_INITIALIZER 18703 (struct cmd_config_per_queue_tx_offload_result, 18704 tx_offload, "tx_offload"); 18705 cmdline_parse_token_string_t cmd_config_per_queue_tx_offload_result_offload = 18706 TOKEN_STRING_INITIALIZER 18707 (struct cmd_config_per_queue_tx_offload_result, 18708 offload, "vlan_insert#ipv4_cksum#udp_cksum#tcp_cksum#" 18709 "sctp_cksum#tcp_tso#udp_tso#outer_ipv4_cksum#" 18710 "qinq_insert#vxlan_tnl_tso#gre_tnl_tso#" 18711 "ipip_tnl_tso#geneve_tnl_tso#macsec_insert#" 18712 "mt_lockfree#multi_segs#mbuf_fast_free#security"); 18713 cmdline_parse_token_string_t cmd_config_per_queue_tx_offload_result_on_off = 18714 TOKEN_STRING_INITIALIZER 18715 (struct cmd_config_per_queue_tx_offload_result, 18716 on_off, "on#off"); 18717 18718 static void 18719 cmd_config_per_queue_tx_offload_parsed(void *parsed_result, 18720 __attribute__((unused)) struct cmdline *cl, 18721 __attribute__((unused)) void *data) 18722 { 18723 struct cmd_config_per_queue_tx_offload_result *res = parsed_result; 18724 struct rte_eth_dev_info dev_info; 18725 portid_t port_id = res->port_id; 18726 uint16_t queue_id = res->queue_id; 18727 struct rte_port *port = &ports[port_id]; 18728 uint64_t single_offload; 18729 int ret; 18730 18731 if (port->port_status != RTE_PORT_STOPPED) { 18732 printf("Error: Can't config offload when Port %d " 18733 "is not stopped\n", port_id); 18734 return; 18735 } 18736 18737 ret = eth_dev_info_get_print_err(port_id, &dev_info); 18738 if (ret != 0) 18739 return; 18740 18741 if (queue_id >= dev_info.nb_tx_queues) { 18742 printf("Error: input queue_id should be 0 ... " 18743 "%d\n", dev_info.nb_tx_queues - 1); 18744 return; 18745 } 18746 18747 single_offload = search_tx_offload(res->offload); 18748 if (single_offload == 0) { 18749 printf("Unknown offload name: %s\n", res->offload); 18750 return; 18751 } 18752 18753 if (!strcmp(res->on_off, "on")) 18754 port->tx_conf[queue_id].offloads |= single_offload; 18755 else 18756 port->tx_conf[queue_id].offloads &= ~single_offload; 18757 18758 cmd_reconfig_device_queue(port_id, 1, 1); 18759 } 18760 18761 cmdline_parse_inst_t cmd_config_per_queue_tx_offload = { 18762 .f = cmd_config_per_queue_tx_offload_parsed, 18763 .data = NULL, 18764 .help_str = "port <port_id> txq <queue_id> tx_offload " 18765 "vlan_insert|ipv4_cksum|udp_cksum|tcp_cksum|" 18766 "sctp_cksum|tcp_tso|udp_tso|outer_ipv4_cksum|" 18767 "qinq_insert|vxlan_tnl_tso|gre_tnl_tso|" 18768 "ipip_tnl_tso|geneve_tnl_tso|macsec_insert|" 18769 "mt_lockfree|multi_segs|mbuf_fast_free|security " 18770 "on|off", 18771 .tokens = { 18772 (void *)&cmd_config_per_queue_tx_offload_result_port, 18773 (void *)&cmd_config_per_queue_tx_offload_result_port_id, 18774 (void *)&cmd_config_per_queue_tx_offload_result_txq, 18775 (void *)&cmd_config_per_queue_tx_offload_result_queue_id, 18776 (void *)&cmd_config_per_queue_tx_offload_result_txoffload, 18777 (void *)&cmd_config_per_queue_tx_offload_result_offload, 18778 (void *)&cmd_config_per_queue_tx_offload_result_on_off, 18779 NULL, 18780 } 18781 }; 18782 18783 /* *** configure tx_metadata for specific port *** */ 18784 struct cmd_config_tx_metadata_specific_result { 18785 cmdline_fixed_string_t port; 18786 cmdline_fixed_string_t keyword; 18787 uint16_t port_id; 18788 cmdline_fixed_string_t item; 18789 uint32_t value; 18790 }; 18791 18792 static void 18793 cmd_config_tx_metadata_specific_parsed(void *parsed_result, 18794 __attribute__((unused)) struct cmdline *cl, 18795 __attribute__((unused)) void *data) 18796 { 18797 struct cmd_config_tx_metadata_specific_result *res = parsed_result; 18798 18799 if (port_id_is_invalid(res->port_id, ENABLED_WARN)) 18800 return; 18801 ports[res->port_id].tx_metadata = res->value; 18802 /* Add/remove callback to insert valid metadata in every Tx packet. */ 18803 if (ports[res->port_id].tx_metadata) 18804 add_tx_md_callback(res->port_id); 18805 else 18806 remove_tx_md_callback(res->port_id); 18807 rte_flow_dynf_metadata_register(); 18808 } 18809 18810 cmdline_parse_token_string_t cmd_config_tx_metadata_specific_port = 18811 TOKEN_STRING_INITIALIZER(struct cmd_config_tx_metadata_specific_result, 18812 port, "port"); 18813 cmdline_parse_token_string_t cmd_config_tx_metadata_specific_keyword = 18814 TOKEN_STRING_INITIALIZER(struct cmd_config_tx_metadata_specific_result, 18815 keyword, "config"); 18816 cmdline_parse_token_num_t cmd_config_tx_metadata_specific_id = 18817 TOKEN_NUM_INITIALIZER(struct cmd_config_tx_metadata_specific_result, 18818 port_id, UINT16); 18819 cmdline_parse_token_string_t cmd_config_tx_metadata_specific_item = 18820 TOKEN_STRING_INITIALIZER(struct cmd_config_tx_metadata_specific_result, 18821 item, "tx_metadata"); 18822 cmdline_parse_token_num_t cmd_config_tx_metadata_specific_value = 18823 TOKEN_NUM_INITIALIZER(struct cmd_config_tx_metadata_specific_result, 18824 value, UINT32); 18825 18826 cmdline_parse_inst_t cmd_config_tx_metadata_specific = { 18827 .f = cmd_config_tx_metadata_specific_parsed, 18828 .data = NULL, 18829 .help_str = "port config <port_id> tx_metadata <value>", 18830 .tokens = { 18831 (void *)&cmd_config_tx_metadata_specific_port, 18832 (void *)&cmd_config_tx_metadata_specific_keyword, 18833 (void *)&cmd_config_tx_metadata_specific_id, 18834 (void *)&cmd_config_tx_metadata_specific_item, 18835 (void *)&cmd_config_tx_metadata_specific_value, 18836 NULL, 18837 }, 18838 }; 18839 18840 /* *** display tx_metadata per port configuration *** */ 18841 struct cmd_show_tx_metadata_result { 18842 cmdline_fixed_string_t cmd_show; 18843 cmdline_fixed_string_t cmd_port; 18844 cmdline_fixed_string_t cmd_keyword; 18845 portid_t cmd_pid; 18846 }; 18847 18848 static void 18849 cmd_show_tx_metadata_parsed(void *parsed_result, 18850 __attribute__((unused)) struct cmdline *cl, 18851 __attribute__((unused)) void *data) 18852 { 18853 struct cmd_show_tx_metadata_result *res = parsed_result; 18854 18855 if (!rte_eth_dev_is_valid_port(res->cmd_pid)) { 18856 printf("invalid port id %u\n", res->cmd_pid); 18857 return; 18858 } 18859 if (!strcmp(res->cmd_keyword, "tx_metadata")) { 18860 printf("Port %u tx_metadata: %u\n", res->cmd_pid, 18861 ports[res->cmd_pid].tx_metadata); 18862 } 18863 } 18864 18865 cmdline_parse_token_string_t cmd_show_tx_metadata_show = 18866 TOKEN_STRING_INITIALIZER(struct cmd_show_tx_metadata_result, 18867 cmd_show, "show"); 18868 cmdline_parse_token_string_t cmd_show_tx_metadata_port = 18869 TOKEN_STRING_INITIALIZER(struct cmd_show_tx_metadata_result, 18870 cmd_port, "port"); 18871 cmdline_parse_token_num_t cmd_show_tx_metadata_pid = 18872 TOKEN_NUM_INITIALIZER(struct cmd_show_tx_metadata_result, 18873 cmd_pid, UINT16); 18874 cmdline_parse_token_string_t cmd_show_tx_metadata_keyword = 18875 TOKEN_STRING_INITIALIZER(struct cmd_show_tx_metadata_result, 18876 cmd_keyword, "tx_metadata"); 18877 18878 cmdline_parse_inst_t cmd_show_tx_metadata = { 18879 .f = cmd_show_tx_metadata_parsed, 18880 .data = NULL, 18881 .help_str = "show port <port_id> tx_metadata", 18882 .tokens = { 18883 (void *)&cmd_show_tx_metadata_show, 18884 (void *)&cmd_show_tx_metadata_port, 18885 (void *)&cmd_show_tx_metadata_pid, 18886 (void *)&cmd_show_tx_metadata_keyword, 18887 NULL, 18888 }, 18889 }; 18890 18891 /* show port supported ptypes */ 18892 18893 /* Common result structure for show port ptypes */ 18894 struct cmd_show_port_supported_ptypes_result { 18895 cmdline_fixed_string_t show; 18896 cmdline_fixed_string_t port; 18897 portid_t port_id; 18898 cmdline_fixed_string_t ptypes; 18899 }; 18900 18901 /* Common CLI fields for show port ptypes */ 18902 cmdline_parse_token_string_t cmd_show_port_supported_ptypes_show = 18903 TOKEN_STRING_INITIALIZER 18904 (struct cmd_show_port_supported_ptypes_result, 18905 show, "show"); 18906 cmdline_parse_token_string_t cmd_show_port_supported_ptypes_port = 18907 TOKEN_STRING_INITIALIZER 18908 (struct cmd_show_port_supported_ptypes_result, 18909 port, "port"); 18910 cmdline_parse_token_num_t cmd_show_port_supported_ptypes_port_id = 18911 TOKEN_NUM_INITIALIZER 18912 (struct cmd_show_port_supported_ptypes_result, 18913 port_id, UINT16); 18914 cmdline_parse_token_string_t cmd_show_port_supported_ptypes_ptypes = 18915 TOKEN_STRING_INITIALIZER 18916 (struct cmd_show_port_supported_ptypes_result, 18917 ptypes, "ptypes"); 18918 18919 static void 18920 cmd_show_port_supported_ptypes_parsed( 18921 void *parsed_result, 18922 __attribute__((unused)) struct cmdline *cl, 18923 __attribute__((unused)) void *data) 18924 { 18925 #define RSVD_PTYPE_MASK 0xf0000000 18926 #define MAX_PTYPES_PER_LAYER 16 18927 #define LTYPE_NAMESIZE 32 18928 #define PTYPE_NAMESIZE 256 18929 struct cmd_show_port_supported_ptypes_result *res = parsed_result; 18930 char buf[PTYPE_NAMESIZE], ltype[LTYPE_NAMESIZE]; 18931 uint32_t ptype_mask = RTE_PTYPE_L2_MASK; 18932 uint32_t ptypes[MAX_PTYPES_PER_LAYER]; 18933 uint16_t port_id = res->port_id; 18934 int ret, i; 18935 18936 ret = rte_eth_dev_get_supported_ptypes(port_id, ptype_mask, NULL, 0); 18937 if (ret < 0) 18938 return; 18939 18940 while (ptype_mask != RSVD_PTYPE_MASK) { 18941 18942 switch (ptype_mask) { 18943 case RTE_PTYPE_L2_MASK: 18944 strlcpy(ltype, "L2", sizeof(ltype)); 18945 break; 18946 case RTE_PTYPE_L3_MASK: 18947 strlcpy(ltype, "L3", sizeof(ltype)); 18948 break; 18949 case RTE_PTYPE_L4_MASK: 18950 strlcpy(ltype, "L4", sizeof(ltype)); 18951 break; 18952 case RTE_PTYPE_TUNNEL_MASK: 18953 strlcpy(ltype, "Tunnel", sizeof(ltype)); 18954 break; 18955 case RTE_PTYPE_INNER_L2_MASK: 18956 strlcpy(ltype, "Inner L2", sizeof(ltype)); 18957 break; 18958 case RTE_PTYPE_INNER_L3_MASK: 18959 strlcpy(ltype, "Inner L3", sizeof(ltype)); 18960 break; 18961 case RTE_PTYPE_INNER_L4_MASK: 18962 strlcpy(ltype, "Inner L4", sizeof(ltype)); 18963 break; 18964 default: 18965 return; 18966 } 18967 18968 ret = rte_eth_dev_get_supported_ptypes(res->port_id, 18969 ptype_mask, ptypes, 18970 MAX_PTYPES_PER_LAYER); 18971 18972 if (ret > 0) 18973 printf("Supported %s ptypes:\n", ltype); 18974 else 18975 printf("%s ptypes unsupported\n", ltype); 18976 18977 for (i = 0; i < ret; ++i) { 18978 rte_get_ptype_name(ptypes[i], buf, sizeof(buf)); 18979 printf("%s\n", buf); 18980 } 18981 18982 ptype_mask <<= 4; 18983 } 18984 } 18985 18986 cmdline_parse_inst_t cmd_show_port_supported_ptypes = { 18987 .f = cmd_show_port_supported_ptypes_parsed, 18988 .data = NULL, 18989 .help_str = "show port <port_id> ptypes", 18990 .tokens = { 18991 (void *)&cmd_show_port_supported_ptypes_show, 18992 (void *)&cmd_show_port_supported_ptypes_port, 18993 (void *)&cmd_show_port_supported_ptypes_port_id, 18994 (void *)&cmd_show_port_supported_ptypes_ptypes, 18995 NULL, 18996 }, 18997 }; 18998 18999 /* *** display rx/tx descriptor status *** */ 19000 struct cmd_show_rx_tx_desc_status_result { 19001 cmdline_fixed_string_t cmd_show; 19002 cmdline_fixed_string_t cmd_port; 19003 cmdline_fixed_string_t cmd_keyword; 19004 cmdline_fixed_string_t cmd_desc; 19005 cmdline_fixed_string_t cmd_status; 19006 portid_t cmd_pid; 19007 portid_t cmd_qid; 19008 portid_t cmd_did; 19009 }; 19010 19011 static void 19012 cmd_show_rx_tx_desc_status_parsed(void *parsed_result, 19013 __attribute__((unused)) struct cmdline *cl, 19014 __attribute__((unused)) void *data) 19015 { 19016 struct cmd_show_rx_tx_desc_status_result *res = parsed_result; 19017 int rc; 19018 19019 if (!rte_eth_dev_is_valid_port(res->cmd_pid)) { 19020 printf("invalid port id %u\n", res->cmd_pid); 19021 return; 19022 } 19023 19024 if (!strcmp(res->cmd_keyword, "rxq")) { 19025 rc = rte_eth_rx_descriptor_status(res->cmd_pid, res->cmd_qid, 19026 res->cmd_did); 19027 if (rc < 0) { 19028 printf("Invalid queueid = %d\n", res->cmd_qid); 19029 return; 19030 } 19031 if (rc == RTE_ETH_RX_DESC_AVAIL) 19032 printf("Desc status = AVAILABLE\n"); 19033 else if (rc == RTE_ETH_RX_DESC_DONE) 19034 printf("Desc status = DONE\n"); 19035 else 19036 printf("Desc status = UNAVAILABLE\n"); 19037 } else if (!strcmp(res->cmd_keyword, "txq")) { 19038 rc = rte_eth_tx_descriptor_status(res->cmd_pid, res->cmd_qid, 19039 res->cmd_did); 19040 if (rc < 0) { 19041 printf("Invalid queueid = %d\n", res->cmd_qid); 19042 return; 19043 } 19044 if (rc == RTE_ETH_TX_DESC_FULL) 19045 printf("Desc status = FULL\n"); 19046 else if (rc == RTE_ETH_TX_DESC_DONE) 19047 printf("Desc status = DONE\n"); 19048 else 19049 printf("Desc status = UNAVAILABLE\n"); 19050 } 19051 } 19052 19053 cmdline_parse_token_string_t cmd_show_rx_tx_desc_status_show = 19054 TOKEN_STRING_INITIALIZER(struct cmd_show_rx_tx_desc_status_result, 19055 cmd_show, "show"); 19056 cmdline_parse_token_string_t cmd_show_rx_tx_desc_status_port = 19057 TOKEN_STRING_INITIALIZER(struct cmd_show_rx_tx_desc_status_result, 19058 cmd_port, "port"); 19059 cmdline_parse_token_num_t cmd_show_rx_tx_desc_status_pid = 19060 TOKEN_NUM_INITIALIZER(struct cmd_show_rx_tx_desc_status_result, 19061 cmd_pid, UINT16); 19062 cmdline_parse_token_string_t cmd_show_rx_tx_desc_status_keyword = 19063 TOKEN_STRING_INITIALIZER(struct cmd_show_rx_tx_desc_status_result, 19064 cmd_keyword, "rxq#txq"); 19065 cmdline_parse_token_num_t cmd_show_rx_tx_desc_status_qid = 19066 TOKEN_NUM_INITIALIZER(struct cmd_show_rx_tx_desc_status_result, 19067 cmd_qid, UINT16); 19068 cmdline_parse_token_string_t cmd_show_rx_tx_desc_status_desc = 19069 TOKEN_STRING_INITIALIZER(struct cmd_show_rx_tx_desc_status_result, 19070 cmd_desc, "desc"); 19071 cmdline_parse_token_num_t cmd_show_rx_tx_desc_status_did = 19072 TOKEN_NUM_INITIALIZER(struct cmd_show_rx_tx_desc_status_result, 19073 cmd_did, UINT16); 19074 cmdline_parse_token_string_t cmd_show_rx_tx_desc_status_status = 19075 TOKEN_STRING_INITIALIZER(struct cmd_show_rx_tx_desc_status_result, 19076 cmd_status, "status"); 19077 cmdline_parse_inst_t cmd_show_rx_tx_desc_status = { 19078 .f = cmd_show_rx_tx_desc_status_parsed, 19079 .data = NULL, 19080 .help_str = "show port <port_id> rxq|txq <queue_id> desc <desc_id> " 19081 "status", 19082 .tokens = { 19083 (void *)&cmd_show_rx_tx_desc_status_show, 19084 (void *)&cmd_show_rx_tx_desc_status_port, 19085 (void *)&cmd_show_rx_tx_desc_status_pid, 19086 (void *)&cmd_show_rx_tx_desc_status_keyword, 19087 (void *)&cmd_show_rx_tx_desc_status_qid, 19088 (void *)&cmd_show_rx_tx_desc_status_desc, 19089 (void *)&cmd_show_rx_tx_desc_status_did, 19090 (void *)&cmd_show_rx_tx_desc_status_status, 19091 NULL, 19092 }, 19093 }; 19094 19095 /* Common result structure for set port ptypes */ 19096 struct cmd_set_port_ptypes_result { 19097 cmdline_fixed_string_t set; 19098 cmdline_fixed_string_t port; 19099 portid_t port_id; 19100 cmdline_fixed_string_t ptype_mask; 19101 uint32_t mask; 19102 }; 19103 19104 /* Common CLI fields for set port ptypes */ 19105 cmdline_parse_token_string_t cmd_set_port_ptypes_set = 19106 TOKEN_STRING_INITIALIZER 19107 (struct cmd_set_port_ptypes_result, 19108 set, "set"); 19109 cmdline_parse_token_string_t cmd_set_port_ptypes_port = 19110 TOKEN_STRING_INITIALIZER 19111 (struct cmd_set_port_ptypes_result, 19112 port, "port"); 19113 cmdline_parse_token_num_t cmd_set_port_ptypes_port_id = 19114 TOKEN_NUM_INITIALIZER 19115 (struct cmd_set_port_ptypes_result, 19116 port_id, UINT16); 19117 cmdline_parse_token_string_t cmd_set_port_ptypes_mask_str = 19118 TOKEN_STRING_INITIALIZER 19119 (struct cmd_set_port_ptypes_result, 19120 ptype_mask, "ptype_mask"); 19121 cmdline_parse_token_num_t cmd_set_port_ptypes_mask_u32 = 19122 TOKEN_NUM_INITIALIZER 19123 (struct cmd_set_port_ptypes_result, 19124 mask, UINT32); 19125 19126 static void 19127 cmd_set_port_ptypes_parsed( 19128 void *parsed_result, 19129 __attribute__((unused)) struct cmdline *cl, 19130 __attribute__((unused)) void *data) 19131 { 19132 struct cmd_set_port_ptypes_result *res = parsed_result; 19133 #define PTYPE_NAMESIZE 256 19134 char ptype_name[PTYPE_NAMESIZE]; 19135 uint16_t port_id = res->port_id; 19136 uint32_t ptype_mask = res->mask; 19137 int ret, i; 19138 19139 ret = rte_eth_dev_get_supported_ptypes(port_id, RTE_PTYPE_ALL_MASK, 19140 NULL, 0); 19141 if (ret <= 0) { 19142 printf("Port %d doesn't support any ptypes.\n", port_id); 19143 return; 19144 } 19145 19146 uint32_t ptypes[ret]; 19147 19148 ret = rte_eth_dev_set_ptypes(port_id, ptype_mask, ptypes, ret); 19149 if (ret < 0) { 19150 printf("Unable to set requested ptypes for Port %d\n", port_id); 19151 return; 19152 } 19153 19154 printf("Successfully set following ptypes for Port %d\n", port_id); 19155 for (i = 0; i < ret && ptypes[i] != RTE_PTYPE_UNKNOWN; i++) { 19156 rte_get_ptype_name(ptypes[i], ptype_name, sizeof(ptype_name)); 19157 printf("%s\n", ptype_name); 19158 } 19159 19160 clear_ptypes = false; 19161 } 19162 19163 cmdline_parse_inst_t cmd_set_port_ptypes = { 19164 .f = cmd_set_port_ptypes_parsed, 19165 .data = NULL, 19166 .help_str = "set port <port_id> ptype_mask <mask>", 19167 .tokens = { 19168 (void *)&cmd_set_port_ptypes_set, 19169 (void *)&cmd_set_port_ptypes_port, 19170 (void *)&cmd_set_port_ptypes_port_id, 19171 (void *)&cmd_set_port_ptypes_mask_str, 19172 (void *)&cmd_set_port_ptypes_mask_u32, 19173 NULL, 19174 }, 19175 }; 19176 19177 /* ******************************************************************************** */ 19178 19179 /* list of instructions */ 19180 cmdline_parse_ctx_t main_ctx[] = { 19181 (cmdline_parse_inst_t *)&cmd_help_brief, 19182 (cmdline_parse_inst_t *)&cmd_help_long, 19183 (cmdline_parse_inst_t *)&cmd_quit, 19184 (cmdline_parse_inst_t *)&cmd_load_from_file, 19185 (cmdline_parse_inst_t *)&cmd_showport, 19186 (cmdline_parse_inst_t *)&cmd_showqueue, 19187 (cmdline_parse_inst_t *)&cmd_showportall, 19188 (cmdline_parse_inst_t *)&cmd_showdevice, 19189 (cmdline_parse_inst_t *)&cmd_showcfg, 19190 (cmdline_parse_inst_t *)&cmd_showfwdall, 19191 (cmdline_parse_inst_t *)&cmd_start, 19192 (cmdline_parse_inst_t *)&cmd_start_tx_first, 19193 (cmdline_parse_inst_t *)&cmd_start_tx_first_n, 19194 (cmdline_parse_inst_t *)&cmd_set_link_up, 19195 (cmdline_parse_inst_t *)&cmd_set_link_down, 19196 (cmdline_parse_inst_t *)&cmd_reset, 19197 (cmdline_parse_inst_t *)&cmd_set_numbers, 19198 (cmdline_parse_inst_t *)&cmd_set_log, 19199 (cmdline_parse_inst_t *)&cmd_set_txpkts, 19200 (cmdline_parse_inst_t *)&cmd_set_txsplit, 19201 (cmdline_parse_inst_t *)&cmd_set_fwd_list, 19202 (cmdline_parse_inst_t *)&cmd_set_fwd_mask, 19203 (cmdline_parse_inst_t *)&cmd_set_fwd_mode, 19204 (cmdline_parse_inst_t *)&cmd_set_fwd_retry_mode, 19205 (cmdline_parse_inst_t *)&cmd_set_burst_tx_retry, 19206 (cmdline_parse_inst_t *)&cmd_set_promisc_mode_one, 19207 (cmdline_parse_inst_t *)&cmd_set_promisc_mode_all, 19208 (cmdline_parse_inst_t *)&cmd_set_allmulti_mode_one, 19209 (cmdline_parse_inst_t *)&cmd_set_allmulti_mode_all, 19210 (cmdline_parse_inst_t *)&cmd_set_flush_rx, 19211 (cmdline_parse_inst_t *)&cmd_set_link_check, 19212 (cmdline_parse_inst_t *)&cmd_set_bypass_mode, 19213 (cmdline_parse_inst_t *)&cmd_set_bypass_event, 19214 (cmdline_parse_inst_t *)&cmd_set_bypass_timeout, 19215 (cmdline_parse_inst_t *)&cmd_show_bypass_config, 19216 #ifdef RTE_LIBRTE_PMD_BOND 19217 (cmdline_parse_inst_t *) &cmd_set_bonding_mode, 19218 (cmdline_parse_inst_t *) &cmd_show_bonding_config, 19219 (cmdline_parse_inst_t *) &cmd_set_bonding_primary, 19220 (cmdline_parse_inst_t *) &cmd_add_bonding_slave, 19221 (cmdline_parse_inst_t *) &cmd_remove_bonding_slave, 19222 (cmdline_parse_inst_t *) &cmd_create_bonded_device, 19223 (cmdline_parse_inst_t *) &cmd_set_bond_mac_addr, 19224 (cmdline_parse_inst_t *) &cmd_set_balance_xmit_policy, 19225 (cmdline_parse_inst_t *) &cmd_set_bond_mon_period, 19226 (cmdline_parse_inst_t *) &cmd_set_lacp_dedicated_queues, 19227 (cmdline_parse_inst_t *) &cmd_set_bonding_agg_mode_policy, 19228 #endif 19229 (cmdline_parse_inst_t *)&cmd_vlan_offload, 19230 (cmdline_parse_inst_t *)&cmd_vlan_tpid, 19231 (cmdline_parse_inst_t *)&cmd_rx_vlan_filter_all, 19232 (cmdline_parse_inst_t *)&cmd_rx_vlan_filter, 19233 (cmdline_parse_inst_t *)&cmd_tx_vlan_set, 19234 (cmdline_parse_inst_t *)&cmd_tx_vlan_set_qinq, 19235 (cmdline_parse_inst_t *)&cmd_tx_vlan_reset, 19236 (cmdline_parse_inst_t *)&cmd_tx_vlan_set_pvid, 19237 (cmdline_parse_inst_t *)&cmd_csum_set, 19238 (cmdline_parse_inst_t *)&cmd_csum_show, 19239 (cmdline_parse_inst_t *)&cmd_csum_tunnel, 19240 (cmdline_parse_inst_t *)&cmd_tso_set, 19241 (cmdline_parse_inst_t *)&cmd_tso_show, 19242 (cmdline_parse_inst_t *)&cmd_tunnel_tso_set, 19243 (cmdline_parse_inst_t *)&cmd_tunnel_tso_show, 19244 (cmdline_parse_inst_t *)&cmd_gro_enable, 19245 (cmdline_parse_inst_t *)&cmd_gro_flush, 19246 (cmdline_parse_inst_t *)&cmd_gro_show, 19247 (cmdline_parse_inst_t *)&cmd_gso_enable, 19248 (cmdline_parse_inst_t *)&cmd_gso_size, 19249 (cmdline_parse_inst_t *)&cmd_gso_show, 19250 (cmdline_parse_inst_t *)&cmd_link_flow_control_set, 19251 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_rx, 19252 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_tx, 19253 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_hw, 19254 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_lw, 19255 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_pt, 19256 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_xon, 19257 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_macfwd, 19258 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_autoneg, 19259 (cmdline_parse_inst_t *)&cmd_priority_flow_control_set, 19260 (cmdline_parse_inst_t *)&cmd_config_dcb, 19261 (cmdline_parse_inst_t *)&cmd_read_reg, 19262 (cmdline_parse_inst_t *)&cmd_read_reg_bit_field, 19263 (cmdline_parse_inst_t *)&cmd_read_reg_bit, 19264 (cmdline_parse_inst_t *)&cmd_write_reg, 19265 (cmdline_parse_inst_t *)&cmd_write_reg_bit_field, 19266 (cmdline_parse_inst_t *)&cmd_write_reg_bit, 19267 (cmdline_parse_inst_t *)&cmd_read_rxd_txd, 19268 (cmdline_parse_inst_t *)&cmd_stop, 19269 (cmdline_parse_inst_t *)&cmd_mac_addr, 19270 (cmdline_parse_inst_t *)&cmd_set_fwd_eth_peer, 19271 (cmdline_parse_inst_t *)&cmd_set_qmap, 19272 (cmdline_parse_inst_t *)&cmd_set_xstats_hide_zero, 19273 (cmdline_parse_inst_t *)&cmd_operate_port, 19274 (cmdline_parse_inst_t *)&cmd_operate_specific_port, 19275 (cmdline_parse_inst_t *)&cmd_operate_attach_port, 19276 (cmdline_parse_inst_t *)&cmd_operate_detach_port, 19277 (cmdline_parse_inst_t *)&cmd_operate_detach_device, 19278 (cmdline_parse_inst_t *)&cmd_set_port_setup_on, 19279 (cmdline_parse_inst_t *)&cmd_config_speed_all, 19280 (cmdline_parse_inst_t *)&cmd_config_speed_specific, 19281 (cmdline_parse_inst_t *)&cmd_config_loopback_all, 19282 (cmdline_parse_inst_t *)&cmd_config_loopback_specific, 19283 (cmdline_parse_inst_t *)&cmd_config_rx_tx, 19284 (cmdline_parse_inst_t *)&cmd_config_mtu, 19285 (cmdline_parse_inst_t *)&cmd_config_max_pkt_len, 19286 (cmdline_parse_inst_t *)&cmd_config_max_lro_pkt_size, 19287 (cmdline_parse_inst_t *)&cmd_config_rx_mode_flag, 19288 (cmdline_parse_inst_t *)&cmd_config_rss, 19289 (cmdline_parse_inst_t *)&cmd_config_rxtx_ring_size, 19290 (cmdline_parse_inst_t *)&cmd_config_rxtx_queue, 19291 (cmdline_parse_inst_t *)&cmd_config_deferred_start_rxtx_queue, 19292 (cmdline_parse_inst_t *)&cmd_setup_rxtx_queue, 19293 (cmdline_parse_inst_t *)&cmd_config_rss_reta, 19294 (cmdline_parse_inst_t *)&cmd_showport_reta, 19295 (cmdline_parse_inst_t *)&cmd_config_burst, 19296 (cmdline_parse_inst_t *)&cmd_config_thresh, 19297 (cmdline_parse_inst_t *)&cmd_config_threshold, 19298 (cmdline_parse_inst_t *)&cmd_set_uc_hash_filter, 19299 (cmdline_parse_inst_t *)&cmd_set_uc_all_hash_filter, 19300 (cmdline_parse_inst_t *)&cmd_vf_mac_addr_filter, 19301 (cmdline_parse_inst_t *)&cmd_set_vf_macvlan_filter, 19302 (cmdline_parse_inst_t *)&cmd_queue_rate_limit, 19303 (cmdline_parse_inst_t *)&cmd_tunnel_filter, 19304 (cmdline_parse_inst_t *)&cmd_tunnel_udp_config, 19305 (cmdline_parse_inst_t *)&cmd_global_config, 19306 (cmdline_parse_inst_t *)&cmd_set_mirror_mask, 19307 (cmdline_parse_inst_t *)&cmd_set_mirror_link, 19308 (cmdline_parse_inst_t *)&cmd_reset_mirror_rule, 19309 (cmdline_parse_inst_t *)&cmd_showport_rss_hash, 19310 (cmdline_parse_inst_t *)&cmd_showport_rss_hash_key, 19311 (cmdline_parse_inst_t *)&cmd_config_rss_hash_key, 19312 (cmdline_parse_inst_t *)&cmd_dump, 19313 (cmdline_parse_inst_t *)&cmd_dump_one, 19314 (cmdline_parse_inst_t *)&cmd_ethertype_filter, 19315 (cmdline_parse_inst_t *)&cmd_syn_filter, 19316 (cmdline_parse_inst_t *)&cmd_2tuple_filter, 19317 (cmdline_parse_inst_t *)&cmd_5tuple_filter, 19318 (cmdline_parse_inst_t *)&cmd_flex_filter, 19319 (cmdline_parse_inst_t *)&cmd_add_del_ip_flow_director, 19320 (cmdline_parse_inst_t *)&cmd_add_del_udp_flow_director, 19321 (cmdline_parse_inst_t *)&cmd_add_del_sctp_flow_director, 19322 (cmdline_parse_inst_t *)&cmd_add_del_l2_flow_director, 19323 (cmdline_parse_inst_t *)&cmd_add_del_mac_vlan_flow_director, 19324 (cmdline_parse_inst_t *)&cmd_add_del_tunnel_flow_director, 19325 (cmdline_parse_inst_t *)&cmd_add_del_raw_flow_director, 19326 (cmdline_parse_inst_t *)&cmd_flush_flow_director, 19327 (cmdline_parse_inst_t *)&cmd_set_flow_director_ip_mask, 19328 (cmdline_parse_inst_t *)&cmd_set_flow_director_mac_vlan_mask, 19329 (cmdline_parse_inst_t *)&cmd_set_flow_director_tunnel_mask, 19330 (cmdline_parse_inst_t *)&cmd_set_flow_director_flex_mask, 19331 (cmdline_parse_inst_t *)&cmd_set_flow_director_flex_payload, 19332 (cmdline_parse_inst_t *)&cmd_get_sym_hash_ena_per_port, 19333 (cmdline_parse_inst_t *)&cmd_set_sym_hash_ena_per_port, 19334 (cmdline_parse_inst_t *)&cmd_get_hash_global_config, 19335 (cmdline_parse_inst_t *)&cmd_set_hash_global_config, 19336 (cmdline_parse_inst_t *)&cmd_set_hash_input_set, 19337 (cmdline_parse_inst_t *)&cmd_set_fdir_input_set, 19338 (cmdline_parse_inst_t *)&cmd_flow, 19339 (cmdline_parse_inst_t *)&cmd_show_port_meter_cap, 19340 (cmdline_parse_inst_t *)&cmd_add_port_meter_profile_srtcm, 19341 (cmdline_parse_inst_t *)&cmd_add_port_meter_profile_trtcm, 19342 (cmdline_parse_inst_t *)&cmd_del_port_meter_profile, 19343 (cmdline_parse_inst_t *)&cmd_create_port_meter, 19344 (cmdline_parse_inst_t *)&cmd_enable_port_meter, 19345 (cmdline_parse_inst_t *)&cmd_disable_port_meter, 19346 (cmdline_parse_inst_t *)&cmd_del_port_meter, 19347 (cmdline_parse_inst_t *)&cmd_set_port_meter_profile, 19348 (cmdline_parse_inst_t *)&cmd_set_port_meter_dscp_table, 19349 (cmdline_parse_inst_t *)&cmd_set_port_meter_policer_action, 19350 (cmdline_parse_inst_t *)&cmd_set_port_meter_stats_mask, 19351 (cmdline_parse_inst_t *)&cmd_show_port_meter_stats, 19352 (cmdline_parse_inst_t *)&cmd_mcast_addr, 19353 (cmdline_parse_inst_t *)&cmd_config_l2_tunnel_eth_type_all, 19354 (cmdline_parse_inst_t *)&cmd_config_l2_tunnel_eth_type_specific, 19355 (cmdline_parse_inst_t *)&cmd_config_l2_tunnel_en_dis_all, 19356 (cmdline_parse_inst_t *)&cmd_config_l2_tunnel_en_dis_specific, 19357 (cmdline_parse_inst_t *)&cmd_config_e_tag_insertion_en, 19358 (cmdline_parse_inst_t *)&cmd_config_e_tag_insertion_dis, 19359 (cmdline_parse_inst_t *)&cmd_config_e_tag_stripping_en_dis, 19360 (cmdline_parse_inst_t *)&cmd_config_e_tag_forwarding_en_dis, 19361 (cmdline_parse_inst_t *)&cmd_config_e_tag_filter_add, 19362 (cmdline_parse_inst_t *)&cmd_config_e_tag_filter_del, 19363 (cmdline_parse_inst_t *)&cmd_set_vf_vlan_anti_spoof, 19364 (cmdline_parse_inst_t *)&cmd_set_vf_mac_anti_spoof, 19365 (cmdline_parse_inst_t *)&cmd_set_vf_vlan_stripq, 19366 (cmdline_parse_inst_t *)&cmd_set_vf_vlan_insert, 19367 (cmdline_parse_inst_t *)&cmd_set_tx_loopback, 19368 (cmdline_parse_inst_t *)&cmd_set_all_queues_drop_en, 19369 (cmdline_parse_inst_t *)&cmd_set_vf_split_drop_en, 19370 (cmdline_parse_inst_t *)&cmd_set_macsec_offload_on, 19371 (cmdline_parse_inst_t *)&cmd_set_macsec_offload_off, 19372 (cmdline_parse_inst_t *)&cmd_set_macsec_sc, 19373 (cmdline_parse_inst_t *)&cmd_set_macsec_sa, 19374 (cmdline_parse_inst_t *)&cmd_set_vf_traffic, 19375 (cmdline_parse_inst_t *)&cmd_set_vf_rxmode, 19376 (cmdline_parse_inst_t *)&cmd_vf_rate_limit, 19377 (cmdline_parse_inst_t *)&cmd_vf_rxvlan_filter, 19378 (cmdline_parse_inst_t *)&cmd_set_vf_mac_addr, 19379 (cmdline_parse_inst_t *)&cmd_set_vf_promisc, 19380 (cmdline_parse_inst_t *)&cmd_set_vf_allmulti, 19381 (cmdline_parse_inst_t *)&cmd_set_vf_broadcast, 19382 (cmdline_parse_inst_t *)&cmd_set_vf_vlan_tag, 19383 (cmdline_parse_inst_t *)&cmd_vf_max_bw, 19384 (cmdline_parse_inst_t *)&cmd_vf_tc_min_bw, 19385 (cmdline_parse_inst_t *)&cmd_vf_tc_max_bw, 19386 (cmdline_parse_inst_t *)&cmd_strict_link_prio, 19387 (cmdline_parse_inst_t *)&cmd_tc_min_bw, 19388 #if defined RTE_LIBRTE_PMD_SOFTNIC && defined RTE_LIBRTE_SCHED 19389 (cmdline_parse_inst_t *)&cmd_set_port_tm_hierarchy_default, 19390 #endif 19391 (cmdline_parse_inst_t *)&cmd_set_vxlan, 19392 (cmdline_parse_inst_t *)&cmd_set_vxlan_tos_ttl, 19393 (cmdline_parse_inst_t *)&cmd_set_vxlan_with_vlan, 19394 (cmdline_parse_inst_t *)&cmd_set_nvgre, 19395 (cmdline_parse_inst_t *)&cmd_set_nvgre_with_vlan, 19396 (cmdline_parse_inst_t *)&cmd_set_l2_encap, 19397 (cmdline_parse_inst_t *)&cmd_set_l2_encap_with_vlan, 19398 (cmdline_parse_inst_t *)&cmd_set_l2_decap, 19399 (cmdline_parse_inst_t *)&cmd_set_l2_decap_with_vlan, 19400 (cmdline_parse_inst_t *)&cmd_set_mplsogre_encap, 19401 (cmdline_parse_inst_t *)&cmd_set_mplsogre_encap_with_vlan, 19402 (cmdline_parse_inst_t *)&cmd_set_mplsogre_decap, 19403 (cmdline_parse_inst_t *)&cmd_set_mplsogre_decap_with_vlan, 19404 (cmdline_parse_inst_t *)&cmd_set_mplsoudp_encap, 19405 (cmdline_parse_inst_t *)&cmd_set_mplsoudp_encap_with_vlan, 19406 (cmdline_parse_inst_t *)&cmd_set_mplsoudp_decap, 19407 (cmdline_parse_inst_t *)&cmd_set_mplsoudp_decap_with_vlan, 19408 (cmdline_parse_inst_t *)&cmd_ddp_add, 19409 (cmdline_parse_inst_t *)&cmd_ddp_del, 19410 (cmdline_parse_inst_t *)&cmd_ddp_get_list, 19411 (cmdline_parse_inst_t *)&cmd_ddp_get_info, 19412 (cmdline_parse_inst_t *)&cmd_cfg_input_set, 19413 (cmdline_parse_inst_t *)&cmd_clear_input_set, 19414 (cmdline_parse_inst_t *)&cmd_show_vf_stats, 19415 (cmdline_parse_inst_t *)&cmd_clear_vf_stats, 19416 (cmdline_parse_inst_t *)&cmd_show_port_supported_ptypes, 19417 (cmdline_parse_inst_t *)&cmd_set_port_ptypes, 19418 (cmdline_parse_inst_t *)&cmd_ptype_mapping_get, 19419 (cmdline_parse_inst_t *)&cmd_ptype_mapping_replace, 19420 (cmdline_parse_inst_t *)&cmd_ptype_mapping_reset, 19421 (cmdline_parse_inst_t *)&cmd_ptype_mapping_update, 19422 19423 (cmdline_parse_inst_t *)&cmd_pctype_mapping_get, 19424 (cmdline_parse_inst_t *)&cmd_pctype_mapping_reset, 19425 (cmdline_parse_inst_t *)&cmd_pctype_mapping_update, 19426 (cmdline_parse_inst_t *)&cmd_queue_region, 19427 (cmdline_parse_inst_t *)&cmd_region_flowtype, 19428 (cmdline_parse_inst_t *)&cmd_user_priority_region, 19429 (cmdline_parse_inst_t *)&cmd_flush_queue_region, 19430 (cmdline_parse_inst_t *)&cmd_show_queue_region_info_all, 19431 (cmdline_parse_inst_t *)&cmd_show_port_tm_cap, 19432 (cmdline_parse_inst_t *)&cmd_show_port_tm_level_cap, 19433 (cmdline_parse_inst_t *)&cmd_show_port_tm_node_cap, 19434 (cmdline_parse_inst_t *)&cmd_show_port_tm_node_type, 19435 (cmdline_parse_inst_t *)&cmd_show_port_tm_node_stats, 19436 (cmdline_parse_inst_t *)&cmd_add_port_tm_node_shaper_profile, 19437 (cmdline_parse_inst_t *)&cmd_del_port_tm_node_shaper_profile, 19438 (cmdline_parse_inst_t *)&cmd_add_port_tm_node_shared_shaper, 19439 (cmdline_parse_inst_t *)&cmd_del_port_tm_node_shared_shaper, 19440 (cmdline_parse_inst_t *)&cmd_add_port_tm_node_wred_profile, 19441 (cmdline_parse_inst_t *)&cmd_del_port_tm_node_wred_profile, 19442 (cmdline_parse_inst_t *)&cmd_set_port_tm_node_shaper_profile, 19443 (cmdline_parse_inst_t *)&cmd_add_port_tm_nonleaf_node, 19444 (cmdline_parse_inst_t *)&cmd_add_port_tm_leaf_node, 19445 (cmdline_parse_inst_t *)&cmd_del_port_tm_node, 19446 (cmdline_parse_inst_t *)&cmd_set_port_tm_node_parent, 19447 (cmdline_parse_inst_t *)&cmd_suspend_port_tm_node, 19448 (cmdline_parse_inst_t *)&cmd_resume_port_tm_node, 19449 (cmdline_parse_inst_t *)&cmd_port_tm_hierarchy_commit, 19450 (cmdline_parse_inst_t *)&cmd_port_tm_mark_ip_ecn, 19451 (cmdline_parse_inst_t *)&cmd_port_tm_mark_ip_dscp, 19452 (cmdline_parse_inst_t *)&cmd_port_tm_mark_vlan_dei, 19453 (cmdline_parse_inst_t *)&cmd_cfg_tunnel_udp_port, 19454 (cmdline_parse_inst_t *)&cmd_rx_offload_get_capa, 19455 (cmdline_parse_inst_t *)&cmd_rx_offload_get_configuration, 19456 (cmdline_parse_inst_t *)&cmd_config_per_port_rx_offload, 19457 (cmdline_parse_inst_t *)&cmd_config_per_queue_rx_offload, 19458 (cmdline_parse_inst_t *)&cmd_tx_offload_get_capa, 19459 (cmdline_parse_inst_t *)&cmd_tx_offload_get_configuration, 19460 (cmdline_parse_inst_t *)&cmd_config_per_port_tx_offload, 19461 (cmdline_parse_inst_t *)&cmd_config_per_queue_tx_offload, 19462 #ifdef RTE_LIBRTE_BPF 19463 (cmdline_parse_inst_t *)&cmd_operate_bpf_ld_parse, 19464 (cmdline_parse_inst_t *)&cmd_operate_bpf_unld_parse, 19465 #endif 19466 (cmdline_parse_inst_t *)&cmd_config_tx_metadata_specific, 19467 (cmdline_parse_inst_t *)&cmd_show_tx_metadata, 19468 (cmdline_parse_inst_t *)&cmd_show_rx_tx_desc_status, 19469 (cmdline_parse_inst_t *)&cmd_set_raw, 19470 (cmdline_parse_inst_t *)&cmd_show_set_raw, 19471 (cmdline_parse_inst_t *)&cmd_show_set_raw_all, 19472 NULL, 19473 }; 19474 19475 /* read cmdline commands from file */ 19476 void 19477 cmdline_read_from_file(const char *filename) 19478 { 19479 struct cmdline *cl; 19480 19481 cl = cmdline_file_new(main_ctx, "testpmd> ", filename); 19482 if (cl == NULL) { 19483 printf("Failed to create file based cmdline context: %s\n", 19484 filename); 19485 return; 19486 } 19487 19488 cmdline_interact(cl); 19489 cmdline_quit(cl); 19490 19491 cmdline_free(cl); 19492 19493 printf("Read CLI commands from %s\n", filename); 19494 } 19495 19496 /* prompt function, called from main on MASTER lcore */ 19497 void 19498 prompt(void) 19499 { 19500 /* initialize non-constant commands */ 19501 cmd_set_fwd_mode_init(); 19502 cmd_set_fwd_retry_mode_init(); 19503 19504 testpmd_cl = cmdline_stdin_new(main_ctx, "testpmd> "); 19505 if (testpmd_cl == NULL) 19506 return; 19507 cmdline_interact(testpmd_cl); 19508 cmdline_stdin_exit(testpmd_cl); 19509 } 19510 19511 void 19512 prompt_exit(void) 19513 { 19514 if (testpmd_cl != NULL) 19515 cmdline_quit(testpmd_cl); 19516 } 19517 19518 static void 19519 cmd_reconfig_device_queue(portid_t id, uint8_t dev, uint8_t queue) 19520 { 19521 if (id == (portid_t)RTE_PORT_ALL) { 19522 portid_t pid; 19523 19524 RTE_ETH_FOREACH_DEV(pid) { 19525 /* check if need_reconfig has been set to 1 */ 19526 if (ports[pid].need_reconfig == 0) 19527 ports[pid].need_reconfig = dev; 19528 /* check if need_reconfig_queues has been set to 1 */ 19529 if (ports[pid].need_reconfig_queues == 0) 19530 ports[pid].need_reconfig_queues = queue; 19531 } 19532 } else if (!port_id_is_invalid(id, DISABLED_WARN)) { 19533 /* check if need_reconfig has been set to 1 */ 19534 if (ports[id].need_reconfig == 0) 19535 ports[id].need_reconfig = dev; 19536 /* check if need_reconfig_queues has been set to 1 */ 19537 if (ports[id].need_reconfig_queues == 0) 19538 ports[id].need_reconfig_queues = queue; 19539 } 19540 } 19541