1 /* SPDX-License-Identifier: BSD-3-Clause 2 * Copyright(c) 2010-2016 Intel Corporation. 3 * Copyright(c) 2014 6WIND S.A. 4 */ 5 6 #include <stdarg.h> 7 #include <errno.h> 8 #include <stdio.h> 9 #include <stdint.h> 10 #include <string.h> 11 #include <termios.h> 12 #include <unistd.h> 13 #include <inttypes.h> 14 #ifdef __FreeBSD__ 15 #include <sys/socket.h> 16 #endif 17 #include <netinet/in.h> 18 19 #include <sys/queue.h> 20 21 #include <rte_common.h> 22 #include <rte_byteorder.h> 23 #include <rte_log.h> 24 #include <rte_debug.h> 25 #include <rte_cycles.h> 26 #include <rte_memory.h> 27 #include <rte_memzone.h> 28 #include <rte_malloc.h> 29 #include <rte_launch.h> 30 #include <rte_eal.h> 31 #include <rte_per_lcore.h> 32 #include <rte_lcore.h> 33 #include <rte_atomic.h> 34 #include <rte_branch_prediction.h> 35 #include <rte_ring.h> 36 #include <rte_mempool.h> 37 #include <rte_interrupts.h> 38 #include <rte_pci.h> 39 #include <rte_ether.h> 40 #include <rte_ethdev.h> 41 #include <rte_string_fns.h> 42 #include <rte_devargs.h> 43 #include <rte_flow.h> 44 #include <rte_gro.h> 45 46 #include <cmdline_rdline.h> 47 #include <cmdline_parse.h> 48 #include <cmdline_parse_num.h> 49 #include <cmdline_parse_string.h> 50 #include <cmdline_parse_ipaddr.h> 51 #include <cmdline_parse_etheraddr.h> 52 #include <cmdline_socket.h> 53 #include <cmdline.h> 54 #ifdef RTE_LIBRTE_PMD_BOND 55 #include <rte_eth_bond.h> 56 #include <rte_eth_bond_8023ad.h> 57 #endif 58 #if defined RTE_LIBRTE_DPAA_BUS && defined RTE_LIBRTE_DPAA_PMD 59 #include <rte_pmd_dpaa.h> 60 #endif 61 #ifdef RTE_LIBRTE_IXGBE_PMD 62 #include <rte_pmd_ixgbe.h> 63 #endif 64 #ifdef RTE_LIBRTE_I40E_PMD 65 #include <rte_pmd_i40e.h> 66 #endif 67 #ifdef RTE_LIBRTE_BNXT_PMD 68 #include <rte_pmd_bnxt.h> 69 #endif 70 #include "testpmd.h" 71 #include "cmdline_mtr.h" 72 #include "cmdline_tm.h" 73 #include "bpf_cmd.h" 74 75 static struct cmdline *testpmd_cl; 76 77 static void cmd_reconfig_device_queue(portid_t id, uint8_t dev, uint8_t queue); 78 79 /* *** Help command with introduction. *** */ 80 struct cmd_help_brief_result { 81 cmdline_fixed_string_t help; 82 }; 83 84 static void cmd_help_brief_parsed(__attribute__((unused)) void *parsed_result, 85 struct cmdline *cl, 86 __attribute__((unused)) void *data) 87 { 88 cmdline_printf( 89 cl, 90 "\n" 91 "Help is available for the following sections:\n\n" 92 " help control : Start and stop forwarding.\n" 93 " help display : Displaying port, stats and config " 94 "information.\n" 95 " help config : Configuration information.\n" 96 " help ports : Configuring ports.\n" 97 " help registers : Reading and setting port registers.\n" 98 " help filters : Filters configuration help.\n" 99 " help traffic_management : Traffic Management commmands.\n" 100 " help devices : Device related cmds.\n" 101 " help all : All of the above sections.\n\n" 102 ); 103 104 } 105 106 cmdline_parse_token_string_t cmd_help_brief_help = 107 TOKEN_STRING_INITIALIZER(struct cmd_help_brief_result, help, "help"); 108 109 cmdline_parse_inst_t cmd_help_brief = { 110 .f = cmd_help_brief_parsed, 111 .data = NULL, 112 .help_str = "help: Show help", 113 .tokens = { 114 (void *)&cmd_help_brief_help, 115 NULL, 116 }, 117 }; 118 119 /* *** Help command with help sections. *** */ 120 struct cmd_help_long_result { 121 cmdline_fixed_string_t help; 122 cmdline_fixed_string_t section; 123 }; 124 125 static void cmd_help_long_parsed(void *parsed_result, 126 struct cmdline *cl, 127 __attribute__((unused)) void *data) 128 { 129 int show_all = 0; 130 struct cmd_help_long_result *res = parsed_result; 131 132 if (!strcmp(res->section, "all")) 133 show_all = 1; 134 135 if (show_all || !strcmp(res->section, "control")) { 136 137 cmdline_printf( 138 cl, 139 "\n" 140 "Control forwarding:\n" 141 "-------------------\n\n" 142 143 "start\n" 144 " Start packet forwarding with current configuration.\n\n" 145 146 "start tx_first\n" 147 " Start packet forwarding with current config" 148 " after sending one burst of packets.\n\n" 149 150 "stop\n" 151 " Stop packet forwarding, and display accumulated" 152 " statistics.\n\n" 153 154 "quit\n" 155 " Quit to prompt.\n\n" 156 ); 157 } 158 159 if (show_all || !strcmp(res->section, "display")) { 160 161 cmdline_printf( 162 cl, 163 "\n" 164 "Display:\n" 165 "--------\n\n" 166 167 "show port (info|stats|summary|xstats|fdir|stat_qmap|dcb_tc|cap) (port_id|all)\n" 168 " Display information for port_id, or all.\n\n" 169 170 "show port X rss reta (size) (mask0,mask1,...)\n" 171 " Display the rss redirection table entry indicated" 172 " by masks on port X. size is used to indicate the" 173 " hardware supported reta size\n\n" 174 175 "show port (port_id) rss-hash [key]\n" 176 " Display the RSS hash functions and RSS hash key of port\n\n" 177 178 "clear port (info|stats|xstats|fdir|stat_qmap) (port_id|all)\n" 179 " Clear information for port_id, or all.\n\n" 180 181 "show (rxq|txq) info (port_id) (queue_id)\n" 182 " Display information for configured RX/TX queue.\n\n" 183 184 "show config (rxtx|cores|fwd|txpkts)\n" 185 " Display the given configuration.\n\n" 186 187 "read rxd (port_id) (queue_id) (rxd_id)\n" 188 " Display an RX descriptor of a port RX queue.\n\n" 189 190 "read txd (port_id) (queue_id) (txd_id)\n" 191 " Display a TX descriptor of a port TX queue.\n\n" 192 193 "ddp get list (port_id)\n" 194 " Get ddp profile info list\n\n" 195 196 "ddp get info (profile_path)\n" 197 " Get ddp profile information.\n\n" 198 199 "show vf stats (port_id) (vf_id)\n" 200 " Display a VF's statistics.\n\n" 201 202 "clear vf stats (port_id) (vf_id)\n" 203 " Reset a VF's statistics.\n\n" 204 205 "show port (port_id) pctype mapping\n" 206 " Get flow ptype to pctype mapping on a port\n\n" 207 208 "show port meter stats (port_id) (meter_id) (clear)\n" 209 " Get meter stats on a port\n\n" 210 211 "show fwd stats all\n" 212 " Display statistics for all fwd engines.\n\n" 213 214 "clear fwd stats all\n" 215 " Clear statistics for all fwd engines.\n\n" 216 217 "show port (port_id) rx_offload capabilities\n" 218 " List all per queue and per port Rx offloading" 219 " capabilities of a port\n\n" 220 221 "show port (port_id) rx_offload configuration\n" 222 " List port level and all queue level" 223 " Rx offloading configuration\n\n" 224 225 "show port (port_id) tx_offload capabilities\n" 226 " List all per queue and per port" 227 " Tx offloading capabilities of a port\n\n" 228 229 "show port (port_id) tx_offload configuration\n" 230 " List port level and all queue level" 231 " Tx offloading configuration\n\n" 232 233 "show port (port_id) tx_metadata\n" 234 " Show Tx metadata value set" 235 " for a specific port\n\n" 236 237 "show device info (<identifier>|all)" 238 " Show general information about devices probed.\n\n" 239 ); 240 } 241 242 if (show_all || !strcmp(res->section, "config")) { 243 cmdline_printf( 244 cl, 245 "\n" 246 "Configuration:\n" 247 "--------------\n" 248 "Configuration changes only become active when" 249 " forwarding is started/restarted.\n\n" 250 251 "set default\n" 252 " Reset forwarding to the default configuration.\n\n" 253 254 "set verbose (level)\n" 255 " Set the debug verbosity level X.\n\n" 256 257 "set log global|(type) (level)\n" 258 " Set the log level.\n\n" 259 260 "set nbport (num)\n" 261 " Set number of ports.\n\n" 262 263 "set nbcore (num)\n" 264 " Set number of cores.\n\n" 265 266 "set coremask (mask)\n" 267 " Set the forwarding cores hexadecimal mask.\n\n" 268 269 "set portmask (mask)\n" 270 " Set the forwarding ports hexadecimal mask.\n\n" 271 272 "set burst (num)\n" 273 " Set number of packets per burst.\n\n" 274 275 "set burst tx delay (microseconds) retry (num)\n" 276 " Set the transmit delay time and number of retries," 277 " effective when retry is enabled.\n\n" 278 279 "set txpkts (x[,y]*)\n" 280 " Set the length of each segment of TXONLY" 281 " and optionally CSUM packets.\n\n" 282 283 "set txsplit (off|on|rand)\n" 284 " Set the split policy for the TX packets." 285 " Right now only applicable for CSUM and TXONLY" 286 " modes\n\n" 287 288 "set corelist (x[,y]*)\n" 289 " Set the list of forwarding cores.\n\n" 290 291 "set portlist (x[,y]*)\n" 292 " Set the list of forwarding ports.\n\n" 293 294 "set port setup on (iterator|event)\n" 295 " Select how attached port is retrieved for setup.\n\n" 296 297 "set tx loopback (port_id) (on|off)\n" 298 " Enable or disable tx loopback.\n\n" 299 300 "set all queues drop (port_id) (on|off)\n" 301 " Set drop enable bit for all queues.\n\n" 302 303 "set vf split drop (port_id) (vf_id) (on|off)\n" 304 " Set split drop enable bit for a VF from the PF.\n\n" 305 306 "set vf mac antispoof (port_id) (vf_id) (on|off).\n" 307 " Set MAC antispoof for a VF from the PF.\n\n" 308 309 "set macsec offload (port_id) on encrypt (on|off) replay-protect (on|off)\n" 310 " Enable MACsec offload.\n\n" 311 312 "set macsec offload (port_id) off\n" 313 " Disable MACsec offload.\n\n" 314 315 "set macsec sc (tx|rx) (port_id) (mac) (pi)\n" 316 " Configure MACsec secure connection (SC).\n\n" 317 318 "set macsec sa (tx|rx) (port_id) (idx) (an) (pn) (key)\n" 319 " Configure MACsec secure association (SA).\n\n" 320 321 "set vf broadcast (port_id) (vf_id) (on|off)\n" 322 " Set VF broadcast for a VF from the PF.\n\n" 323 324 "vlan set strip (on|off) (port_id)\n" 325 " Set the VLAN strip on a port.\n\n" 326 327 "vlan set stripq (on|off) (port_id,queue_id)\n" 328 " Set the VLAN strip for a queue on a port.\n\n" 329 330 "set vf vlan stripq (port_id) (vf_id) (on|off)\n" 331 " Set the VLAN strip for all queues in a pool for a VF from the PF.\n\n" 332 333 "set vf vlan insert (port_id) (vf_id) (vlan_id)\n" 334 " Set VLAN insert for a VF from the PF.\n\n" 335 336 "set vf vlan antispoof (port_id) (vf_id) (on|off)\n" 337 " Set VLAN antispoof for a VF from the PF.\n\n" 338 339 "set vf vlan tag (port_id) (vf_id) (on|off)\n" 340 " Set VLAN tag for a VF from the PF.\n\n" 341 342 "set vf tx max-bandwidth (port_id) (vf_id) (bandwidth)\n" 343 " Set a VF's max bandwidth(Mbps).\n\n" 344 345 "set vf tc tx min-bandwidth (port_id) (vf_id) (bw1, bw2, ...)\n" 346 " Set all TCs' min bandwidth(%%) on a VF.\n\n" 347 348 "set vf tc tx max-bandwidth (port_id) (vf_id) (tc_no) (bandwidth)\n" 349 " Set a TC's max bandwidth(Mbps) on a VF.\n\n" 350 351 "set tx strict-link-priority (port_id) (tc_bitmap)\n" 352 " Set some TCs' strict link priority mode on a physical port.\n\n" 353 354 "set tc tx min-bandwidth (port_id) (bw1, bw2, ...)\n" 355 " Set all TCs' min bandwidth(%%) for all PF and VFs.\n\n" 356 357 "vlan set filter (on|off) (port_id)\n" 358 " Set the VLAN filter on a port.\n\n" 359 360 "vlan set qinq (on|off) (port_id)\n" 361 " Set the VLAN QinQ (extended queue in queue)" 362 " on a port.\n\n" 363 364 "vlan set (inner|outer) tpid (value) (port_id)\n" 365 " Set the VLAN TPID for Packet Filtering on" 366 " a port\n\n" 367 368 "rx_vlan add (vlan_id|all) (port_id)\n" 369 " Add a vlan_id, or all identifiers, to the set" 370 " of VLAN identifiers filtered by port_id.\n\n" 371 372 "rx_vlan rm (vlan_id|all) (port_id)\n" 373 " Remove a vlan_id, or all identifiers, from the set" 374 " of VLAN identifiers filtered by port_id.\n\n" 375 376 "rx_vlan add (vlan_id) port (port_id) vf (vf_mask)\n" 377 " Add a vlan_id, to the set of VLAN identifiers" 378 "filtered for VF(s) from port_id.\n\n" 379 380 "rx_vlan rm (vlan_id) port (port_id) vf (vf_mask)\n" 381 " Remove a vlan_id, to the set of VLAN identifiers" 382 "filtered for VF(s) from port_id.\n\n" 383 384 "tunnel_filter add (port_id) (outer_mac) (inner_mac) (ip_addr) " 385 "(inner_vlan) (vxlan|nvgre|ipingre|vxlan-gpe) (imac-ivlan|imac-ivlan-tenid|" 386 "imac-tenid|imac|omac-imac-tenid|oip|iip) (tenant_id) (queue_id)\n" 387 " add a tunnel filter of a port.\n\n" 388 389 "tunnel_filter rm (port_id) (outer_mac) (inner_mac) (ip_addr) " 390 "(inner_vlan) (vxlan|nvgre|ipingre|vxlan-gpe) (imac-ivlan|imac-ivlan-tenid|" 391 "imac-tenid|imac|omac-imac-tenid|oip|iip) (tenant_id) (queue_id)\n" 392 " remove a tunnel filter of a port.\n\n" 393 394 "rx_vxlan_port add (udp_port) (port_id)\n" 395 " Add an UDP port for VXLAN packet filter on a port\n\n" 396 397 "rx_vxlan_port rm (udp_port) (port_id)\n" 398 " Remove an UDP port for VXLAN packet filter on a port\n\n" 399 400 "tx_vlan set (port_id) vlan_id[, vlan_id_outer]\n" 401 " Set hardware insertion of VLAN IDs (single or double VLAN " 402 "depends on the number of VLAN IDs) in packets sent on a port.\n\n" 403 404 "tx_vlan set pvid port_id vlan_id (on|off)\n" 405 " Set port based TX VLAN insertion.\n\n" 406 407 "tx_vlan reset (port_id)\n" 408 " Disable hardware insertion of a VLAN header in" 409 " packets sent on a port.\n\n" 410 411 "csum set (ip|udp|tcp|sctp|outer-ip|outer-udp) (hw|sw) (port_id)\n" 412 " Select hardware or software calculation of the" 413 " checksum when transmitting a packet using the" 414 " csum forward engine.\n" 415 " ip|udp|tcp|sctp always concern the inner layer.\n" 416 " outer-ip concerns the outer IP layer in" 417 " outer-udp concerns the outer UDP layer in" 418 " case the packet is recognized as a tunnel packet by" 419 " the forward engine (vxlan, gre and ipip are supported)\n" 420 " Please check the NIC datasheet for HW limits.\n\n" 421 422 "csum parse-tunnel (on|off) (tx_port_id)\n" 423 " If disabled, treat tunnel packets as non-tunneled" 424 " packets (treat inner headers as payload). The port\n" 425 " argument is the port used for TX in csum forward" 426 " engine.\n\n" 427 428 "csum show (port_id)\n" 429 " Display tx checksum offload configuration\n\n" 430 431 "tso set (segsize) (portid)\n" 432 " Enable TCP Segmentation Offload in csum forward" 433 " engine.\n" 434 " Please check the NIC datasheet for HW limits.\n\n" 435 436 "tso show (portid)" 437 " Display the status of TCP Segmentation Offload.\n\n" 438 439 "set port (port_id) gro on|off\n" 440 " Enable or disable Generic Receive Offload in" 441 " csum forwarding engine.\n\n" 442 443 "show port (port_id) gro\n" 444 " Display GRO configuration.\n\n" 445 446 "set gro flush (cycles)\n" 447 " Set the cycle to flush GROed packets from" 448 " reassembly tables.\n\n" 449 450 "set port (port_id) gso (on|off)" 451 " Enable or disable Generic Segmentation Offload in" 452 " csum forwarding engine.\n\n" 453 454 "set gso segsz (length)\n" 455 " Set max packet length for output GSO segments," 456 " including packet header and payload.\n\n" 457 458 "show port (port_id) gso\n" 459 " Show GSO configuration.\n\n" 460 461 "set fwd (%s)\n" 462 " Set packet forwarding mode.\n\n" 463 464 "mac_addr add (port_id) (XX:XX:XX:XX:XX:XX)\n" 465 " Add a MAC address on port_id.\n\n" 466 467 "mac_addr remove (port_id) (XX:XX:XX:XX:XX:XX)\n" 468 " Remove a MAC address from port_id.\n\n" 469 470 "mac_addr set (port_id) (XX:XX:XX:XX:XX:XX)\n" 471 " Set the default MAC address for port_id.\n\n" 472 473 "mac_addr add port (port_id) vf (vf_id) (mac_address)\n" 474 " Add a MAC address for a VF on the port.\n\n" 475 476 "set vf mac addr (port_id) (vf_id) (XX:XX:XX:XX:XX:XX)\n" 477 " Set the MAC address for a VF from the PF.\n\n" 478 479 "set eth-peer (port_id) (peer_addr)\n" 480 " set the peer address for certain port.\n\n" 481 482 "set port (port_id) uta (mac_address|all) (on|off)\n" 483 " Add/Remove a or all unicast hash filter(s)" 484 "from port X.\n\n" 485 486 "set promisc (port_id|all) (on|off)\n" 487 " Set the promiscuous mode on port_id, or all.\n\n" 488 489 "set allmulti (port_id|all) (on|off)\n" 490 " Set the allmulti mode on port_id, or all.\n\n" 491 492 "set vf promisc (port_id) (vf_id) (on|off)\n" 493 " Set unicast promiscuous mode for a VF from the PF.\n\n" 494 495 "set vf allmulti (port_id) (vf_id) (on|off)\n" 496 " Set multicast promiscuous mode for a VF from the PF.\n\n" 497 498 "set flow_ctrl rx (on|off) tx (on|off) (high_water)" 499 " (low_water) (pause_time) (send_xon) mac_ctrl_frame_fwd" 500 " (on|off) autoneg (on|off) (port_id)\n" 501 "set flow_ctrl rx (on|off) (portid)\n" 502 "set flow_ctrl tx (on|off) (portid)\n" 503 "set flow_ctrl high_water (high_water) (portid)\n" 504 "set flow_ctrl low_water (low_water) (portid)\n" 505 "set flow_ctrl pause_time (pause_time) (portid)\n" 506 "set flow_ctrl send_xon (send_xon) (portid)\n" 507 "set flow_ctrl mac_ctrl_frame_fwd (on|off) (portid)\n" 508 "set flow_ctrl autoneg (on|off) (port_id)\n" 509 " Set the link flow control parameter on a port.\n\n" 510 511 "set pfc_ctrl rx (on|off) tx (on|off) (high_water)" 512 " (low_water) (pause_time) (priority) (port_id)\n" 513 " Set the priority flow control parameter on a" 514 " port.\n\n" 515 516 "set stat_qmap (tx|rx) (port_id) (queue_id) (qmapping)\n" 517 " Set statistics mapping (qmapping 0..15) for RX/TX" 518 " queue on port.\n" 519 " e.g., 'set stat_qmap rx 0 2 5' sets rx queue 2" 520 " on port 0 to mapping 5.\n\n" 521 522 "set xstats-hide-zero on|off\n" 523 " Set the option to hide the zero values" 524 " for xstats display.\n" 525 526 "set port (port_id) vf (vf_id) rx|tx on|off\n" 527 " Enable/Disable a VF receive/tranmit from a port\n\n" 528 529 "set port (port_id) vf (vf_id) (mac_addr)" 530 " (exact-mac#exact-mac-vlan#hashmac|hashmac-vlan) on|off\n" 531 " Add/Remove unicast or multicast MAC addr filter" 532 " for a VF.\n\n" 533 534 "set port (port_id) vf (vf_id) rxmode (AUPE|ROPE|BAM" 535 "|MPE) (on|off)\n" 536 " AUPE:accepts untagged VLAN;" 537 "ROPE:accept unicast hash\n\n" 538 " BAM:accepts broadcast packets;" 539 "MPE:accepts all multicast packets\n\n" 540 " Enable/Disable a VF receive mode of a port\n\n" 541 542 "set port (port_id) queue (queue_id) rate (rate_num)\n" 543 " Set rate limit for a queue of a port\n\n" 544 545 "set port (port_id) vf (vf_id) rate (rate_num) " 546 "queue_mask (queue_mask_value)\n" 547 " Set rate limit for queues in VF of a port\n\n" 548 549 "set port (port_id) mirror-rule (rule_id)" 550 " (pool-mirror-up|pool-mirror-down|vlan-mirror)" 551 " (poolmask|vlanid[,vlanid]*) dst-pool (pool_id) (on|off)\n" 552 " Set pool or vlan type mirror rule on a port.\n" 553 " e.g., 'set port 0 mirror-rule 0 vlan-mirror 0,1" 554 " dst-pool 0 on' enable mirror traffic with vlan 0,1" 555 " to pool 0.\n\n" 556 557 "set port (port_id) mirror-rule (rule_id)" 558 " (uplink-mirror|downlink-mirror) dst-pool" 559 " (pool_id) (on|off)\n" 560 " Set uplink or downlink type mirror rule on a port.\n" 561 " e.g., 'set port 0 mirror-rule 0 uplink-mirror dst-pool" 562 " 0 on' enable mirror income traffic to pool 0.\n\n" 563 564 "reset port (port_id) mirror-rule (rule_id)\n" 565 " Reset a mirror rule.\n\n" 566 567 "set flush_rx (on|off)\n" 568 " Flush (default) or don't flush RX streams before" 569 " forwarding. Mainly used with PCAP drivers.\n\n" 570 571 "set bypass mode (normal|bypass|isolate) (port_id)\n" 572 " Set the bypass mode for the lowest port on bypass enabled" 573 " NIC.\n\n" 574 575 "set bypass event (timeout|os_on|os_off|power_on|power_off) " 576 "mode (normal|bypass|isolate) (port_id)\n" 577 " Set the event required to initiate specified bypass mode for" 578 " the lowest port on a bypass enabled NIC where:\n" 579 " timeout = enable bypass after watchdog timeout.\n" 580 " os_on = enable bypass when OS/board is powered on.\n" 581 " os_off = enable bypass when OS/board is powered off.\n" 582 " power_on = enable bypass when power supply is turned on.\n" 583 " power_off = enable bypass when power supply is turned off." 584 "\n\n" 585 586 "set bypass timeout (0|1.5|2|3|4|8|16|32)\n" 587 " Set the bypass watchdog timeout to 'n' seconds" 588 " where 0 = instant.\n\n" 589 590 "show bypass config (port_id)\n" 591 " Show the bypass configuration for a bypass enabled NIC" 592 " using the lowest port on the NIC.\n\n" 593 594 #ifdef RTE_LIBRTE_PMD_BOND 595 "create bonded device (mode) (socket)\n" 596 " Create a new bonded device with specific bonding mode and socket.\n\n" 597 598 "add bonding slave (slave_id) (port_id)\n" 599 " Add a slave device to a bonded device.\n\n" 600 601 "remove bonding slave (slave_id) (port_id)\n" 602 " Remove a slave device from a bonded device.\n\n" 603 604 "set bonding mode (value) (port_id)\n" 605 " Set the bonding mode on a bonded device.\n\n" 606 607 "set bonding primary (slave_id) (port_id)\n" 608 " Set the primary slave for a bonded device.\n\n" 609 610 "show bonding config (port_id)\n" 611 " Show the bonding config for port_id.\n\n" 612 613 "set bonding mac_addr (port_id) (address)\n" 614 " Set the MAC address of a bonded device.\n\n" 615 616 "set bonding mode IEEE802.3AD aggregator policy (port_id) (agg_name)" 617 " Set Aggregation mode for IEEE802.3AD (mode 4)" 618 619 "set bonding xmit_balance_policy (port_id) (l2|l23|l34)\n" 620 " Set the transmit balance policy for bonded device running in balance mode.\n\n" 621 622 "set bonding mon_period (port_id) (value)\n" 623 " Set the bonding link status monitoring polling period in ms.\n\n" 624 625 "set bonding lacp dedicated_queues <port_id> (enable|disable)\n" 626 " Enable/disable dedicated queues for LACP control traffic.\n\n" 627 628 #endif 629 "set link-up port (port_id)\n" 630 " Set link up for a port.\n\n" 631 632 "set link-down port (port_id)\n" 633 " Set link down for a port.\n\n" 634 635 "E-tag set insertion on port-tag-id (value)" 636 " port (port_id) vf (vf_id)\n" 637 " Enable E-tag insertion for a VF on a port\n\n" 638 639 "E-tag set insertion off port (port_id) vf (vf_id)\n" 640 " Disable E-tag insertion for a VF on a port\n\n" 641 642 "E-tag set stripping (on|off) port (port_id)\n" 643 " Enable/disable E-tag stripping on a port\n\n" 644 645 "E-tag set forwarding (on|off) port (port_id)\n" 646 " Enable/disable E-tag based forwarding" 647 " on a port\n\n" 648 649 "E-tag set filter add e-tag-id (value) dst-pool" 650 " (pool_id) port (port_id)\n" 651 " Add an E-tag forwarding filter on a port\n\n" 652 653 "E-tag set filter del e-tag-id (value) port (port_id)\n" 654 " Delete an E-tag forwarding filter on a port\n\n" 655 656 "ddp add (port_id) (profile_path[,backup_profile_path])\n" 657 " Load a profile package on a port\n\n" 658 659 "ddp del (port_id) (backup_profile_path)\n" 660 " Delete a profile package from a port\n\n" 661 662 "ptype mapping get (port_id) (valid_only)\n" 663 " Get ptype mapping on a port\n\n" 664 665 "ptype mapping replace (port_id) (target) (mask) (pky_type)\n" 666 " Replace target with the pkt_type in ptype mapping\n\n" 667 668 "ptype mapping reset (port_id)\n" 669 " Reset ptype mapping on a port\n\n" 670 671 "ptype mapping update (port_id) (hw_ptype) (sw_ptype)\n" 672 " Update a ptype mapping item on a port\n\n" 673 674 "set port (port_id) queue-region region_id (value) " 675 "queue_start_index (value) queue_num (value)\n" 676 " Set a queue region on a port\n\n" 677 678 "set port (port_id) queue-region region_id (value) " 679 "flowtype (value)\n" 680 " Set a flowtype region index on a port\n\n" 681 682 "set port (port_id) queue-region UP (value) region_id (value)\n" 683 " Set the mapping of User Priority to " 684 "queue region on a port\n\n" 685 686 "set port (port_id) queue-region flush (on|off)\n" 687 " flush all queue region related configuration\n\n" 688 689 "show port meter cap (port_id)\n" 690 " Show port meter capability information\n\n" 691 692 "add port meter profile srtcm_rfc2697 (port_id) (profile_id) (cir) (cbs) (ebs)\n" 693 " meter profile add - srtcm rfc 2697\n\n" 694 695 "add port meter profile trtcm_rfc2698 (port_id) (profile_id) (cir) (pir) (cbs) (pbs)\n" 696 " meter profile add - trtcm rfc 2698\n\n" 697 698 "add port meter profile trtcm_rfc4115 (port_id) (profile_id) (cir) (eir) (cbs) (ebs)\n" 699 " meter profile add - trtcm rfc 4115\n\n" 700 701 "del port meter profile (port_id) (profile_id)\n" 702 " meter profile delete\n\n" 703 704 "create port meter (port_id) (mtr_id) (profile_id) (meter_enable)\n" 705 "(g_action) (y_action) (r_action) (stats_mask) (shared)\n" 706 "(use_pre_meter_color) [(dscp_tbl_entry0) (dscp_tbl_entry1)...\n" 707 "(dscp_tbl_entry63)]\n" 708 " meter create\n\n" 709 710 "enable port meter (port_id) (mtr_id)\n" 711 " meter enable\n\n" 712 713 "disable port meter (port_id) (mtr_id)\n" 714 " meter disable\n\n" 715 716 "del port meter (port_id) (mtr_id)\n" 717 " meter delete\n\n" 718 719 "set port meter profile (port_id) (mtr_id) (profile_id)\n" 720 " meter update meter profile\n\n" 721 722 "set port meter dscp table (port_id) (mtr_id) [(dscp_tbl_entry0)\n" 723 "(dscp_tbl_entry1)...(dscp_tbl_entry63)]\n" 724 " update meter dscp table entries\n\n" 725 726 "set port meter policer action (port_id) (mtr_id) (action_mask)\n" 727 "(action0) [(action1) (action2)]\n" 728 " meter update policer action\n\n" 729 730 "set port meter stats mask (port_id) (mtr_id) (stats_mask)\n" 731 " meter update stats\n\n" 732 733 "show port (port_id) queue-region\n" 734 " show all queue region related configuration info\n\n" 735 736 , list_pkt_forwarding_modes() 737 ); 738 } 739 740 if (show_all || !strcmp(res->section, "ports")) { 741 742 cmdline_printf( 743 cl, 744 "\n" 745 "Port Operations:\n" 746 "----------------\n\n" 747 748 "port start (port_id|all)\n" 749 " Start all ports or port_id.\n\n" 750 751 "port stop (port_id|all)\n" 752 " Stop all ports or port_id.\n\n" 753 754 "port close (port_id|all)\n" 755 " Close all ports or port_id.\n\n" 756 757 "port reset (port_id|all)\n" 758 " Reset all ports or port_id.\n\n" 759 760 "port attach (ident)\n" 761 " Attach physical or virtual dev by pci address or virtual device name\n\n" 762 763 "port detach (port_id)\n" 764 " Detach physical or virtual dev by port_id\n\n" 765 766 "port config (port_id|all)" 767 " speed (10|100|1000|10000|25000|40000|50000|100000|auto)" 768 " duplex (half|full|auto)\n" 769 " Set speed and duplex for all ports or port_id\n\n" 770 771 "port config (port_id|all) loopback (mode)\n" 772 " Set loopback mode for all ports or port_id\n\n" 773 774 "port config all (rxq|txq|rxd|txd) (value)\n" 775 " Set number for rxq/txq/rxd/txd.\n\n" 776 777 "port config all max-pkt-len (value)\n" 778 " Set the max packet length.\n\n" 779 780 "port config all drop-en (on|off)\n" 781 " Enable or disable packet drop on all RX queues of all ports when no " 782 "receive buffers available.\n\n" 783 784 "port config all rss (all|default|ip|tcp|udp|sctp|" 785 "ether|port|vxlan|geneve|nvgre|vxlan-gpe|none|<flowtype_id>)\n" 786 " Set the RSS mode.\n\n" 787 788 "port config port-id rss reta (hash,queue)[,(hash,queue)]\n" 789 " Set the RSS redirection table.\n\n" 790 791 "port config (port_id) dcb vt (on|off) (traffic_class)" 792 " pfc (on|off)\n" 793 " Set the DCB mode.\n\n" 794 795 "port config all burst (value)\n" 796 " Set the number of packets per burst.\n\n" 797 798 "port config all (txpt|txht|txwt|rxpt|rxht|rxwt)" 799 " (value)\n" 800 " Set the ring prefetch/host/writeback threshold" 801 " for tx/rx queue.\n\n" 802 803 "port config all (txfreet|txrst|rxfreet) (value)\n" 804 " Set free threshold for rx/tx, or set" 805 " tx rs bit threshold.\n\n" 806 "port config mtu X value\n" 807 " Set the MTU of port X to a given value\n\n" 808 809 "port config (port_id) (rxq|txq) (queue_id) ring_size (value)\n" 810 " Set a rx/tx queue's ring size configuration, the new" 811 " value will take effect after command that (re-)start the port" 812 " or command that setup the specific queue\n\n" 813 814 "port (port_id) (rxq|txq) (queue_id) (start|stop)\n" 815 " Start/stop a rx/tx queue of port X. Only take effect" 816 " when port X is started\n\n" 817 818 "port (port_id) (rxq|txq) (queue_id) deferred_start (on|off)\n" 819 " Switch on/off a deferred start of port X rx/tx queue. Only" 820 " take effect when port X is stopped.\n\n" 821 822 "port (port_id) (rxq|txq) (queue_id) setup\n" 823 " Setup a rx/tx queue of port X.\n\n" 824 825 "port config (port_id|all) l2-tunnel E-tag ether-type" 826 " (value)\n" 827 " Set the value of E-tag ether-type.\n\n" 828 829 "port config (port_id|all) l2-tunnel E-tag" 830 " (enable|disable)\n" 831 " Enable/disable the E-tag support.\n\n" 832 833 "port config (port_id) pctype mapping reset\n" 834 " Reset flow type to pctype mapping on a port\n\n" 835 836 "port config (port_id) pctype mapping update" 837 " (pctype_id_0[,pctype_id_1]*) (flow_type_id)\n" 838 " Update a flow type to pctype mapping item on a port\n\n" 839 840 "port config (port_id) pctype (pctype_id) hash_inset|" 841 "fdir_inset|fdir_flx_inset get|set|clear field\n" 842 " (field_idx)\n" 843 " Configure RSS|FDIR|FDIR_FLX input set for some pctype\n\n" 844 845 "port config (port_id) pctype (pctype_id) hash_inset|" 846 "fdir_inset|fdir_flx_inset clear all" 847 " Clear RSS|FDIR|FDIR_FLX input set completely for some pctype\n\n" 848 849 "port config (port_id) udp_tunnel_port add|rm vxlan|geneve (udp_port)\n\n" 850 " Add/remove UDP tunnel port for tunneling offload\n\n" 851 852 "port config <port_id> rx_offload vlan_strip|" 853 "ipv4_cksum|udp_cksum|tcp_cksum|tcp_lro|qinq_strip|" 854 "outer_ipv4_cksum|macsec_strip|header_split|" 855 "vlan_filter|vlan_extend|jumbo_frame|crc_strip|" 856 "scatter|timestamp|security|keep_crc on|off\n" 857 " Enable or disable a per port Rx offloading" 858 " on all Rx queues of a port\n\n" 859 860 "port (port_id) rxq (queue_id) rx_offload vlan_strip|" 861 "ipv4_cksum|udp_cksum|tcp_cksum|tcp_lro|qinq_strip|" 862 "outer_ipv4_cksum|macsec_strip|header_split|" 863 "vlan_filter|vlan_extend|jumbo_frame|crc_strip|" 864 "scatter|timestamp|security|keep_crc on|off\n" 865 " Enable or disable a per queue Rx offloading" 866 " only on a specific Rx queue\n\n" 867 868 "port config (port_id) tx_offload vlan_insert|" 869 "ipv4_cksum|udp_cksum|tcp_cksum|sctp_cksum|tcp_tso|" 870 "udp_tso|outer_ipv4_cksum|qinq_insert|vxlan_tnl_tso|" 871 "gre_tnl_tso|ipip_tnl_tso|geneve_tnl_tso|" 872 "macsec_insert|mt_lockfree|multi_segs|mbuf_fast_free|" 873 "security|match_metadata on|off\n" 874 " Enable or disable a per port Tx offloading" 875 " on all Tx queues of a port\n\n" 876 877 "port (port_id) txq (queue_id) tx_offload vlan_insert|" 878 "ipv4_cksum|udp_cksum|tcp_cksum|sctp_cksum|tcp_tso|" 879 "udp_tso|outer_ipv4_cksum|qinq_insert|vxlan_tnl_tso|" 880 "gre_tnl_tso|ipip_tnl_tso|geneve_tnl_tso|macsec_insert" 881 "|mt_lockfree|multi_segs|mbuf_fast_free|security" 882 " on|off\n" 883 " Enable or disable a per queue Tx offloading" 884 " only on a specific Tx queue\n\n" 885 886 "bpf-load rx|tx (port) (queue) (J|M|B) (file_name)\n" 887 " Load an eBPF program as a callback" 888 " for particular RX/TX queue\n\n" 889 890 "bpf-unload rx|tx (port) (queue)\n" 891 " Unload previously loaded eBPF program" 892 " for particular RX/TX queue\n\n" 893 894 "port config (port_id) tx_metadata (value)\n" 895 " Set Tx metadata value per port. Testpmd will add this value" 896 " to any Tx packet sent from this port\n\n" 897 ); 898 } 899 900 if (show_all || !strcmp(res->section, "registers")) { 901 902 cmdline_printf( 903 cl, 904 "\n" 905 "Registers:\n" 906 "----------\n\n" 907 908 "read reg (port_id) (address)\n" 909 " Display value of a port register.\n\n" 910 911 "read regfield (port_id) (address) (bit_x) (bit_y)\n" 912 " Display a port register bit field.\n\n" 913 914 "read regbit (port_id) (address) (bit_x)\n" 915 " Display a single port register bit.\n\n" 916 917 "write reg (port_id) (address) (value)\n" 918 " Set value of a port register.\n\n" 919 920 "write regfield (port_id) (address) (bit_x) (bit_y)" 921 " (value)\n" 922 " Set bit field of a port register.\n\n" 923 924 "write regbit (port_id) (address) (bit_x) (value)\n" 925 " Set single bit value of a port register.\n\n" 926 ); 927 } 928 if (show_all || !strcmp(res->section, "filters")) { 929 930 cmdline_printf( 931 cl, 932 "\n" 933 "filters:\n" 934 "--------\n\n" 935 936 "ethertype_filter (port_id) (add|del)" 937 " (mac_addr|mac_ignr) (mac_address) ethertype" 938 " (ether_type) (drop|fwd) queue (queue_id)\n" 939 " Add/Del an ethertype filter.\n\n" 940 941 "2tuple_filter (port_id) (add|del)" 942 " dst_port (dst_port_value) protocol (protocol_value)" 943 " mask (mask_value) tcp_flags (tcp_flags_value)" 944 " priority (prio_value) queue (queue_id)\n" 945 " Add/Del a 2tuple filter.\n\n" 946 947 "5tuple_filter (port_id) (add|del)" 948 " dst_ip (dst_address) src_ip (src_address)" 949 " dst_port (dst_port_value) src_port (src_port_value)" 950 " protocol (protocol_value)" 951 " mask (mask_value) tcp_flags (tcp_flags_value)" 952 " priority (prio_value) queue (queue_id)\n" 953 " Add/Del a 5tuple filter.\n\n" 954 955 "syn_filter (port_id) (add|del) priority (high|low) queue (queue_id)" 956 " Add/Del syn filter.\n\n" 957 958 "flex_filter (port_id) (add|del) len (len_value)" 959 " bytes (bytes_value) mask (mask_value)" 960 " priority (prio_value) queue (queue_id)\n" 961 " Add/Del a flex filter.\n\n" 962 963 "flow_director_filter (port_id) mode IP (add|del|update)" 964 " flow (ipv4-other|ipv4-frag|ipv6-other|ipv6-frag)" 965 " src (src_ip_address) dst (dst_ip_address)" 966 " tos (tos_value) proto (proto_value) ttl (ttl_value)" 967 " vlan (vlan_value) flexbytes (flexbytes_value)" 968 " (drop|fwd) pf|vf(vf_id) queue (queue_id)" 969 " fd_id (fd_id_value)\n" 970 " Add/Del an IP type flow director filter.\n\n" 971 972 "flow_director_filter (port_id) mode IP (add|del|update)" 973 " flow (ipv4-tcp|ipv4-udp|ipv6-tcp|ipv6-udp)" 974 " src (src_ip_address) (src_port)" 975 " dst (dst_ip_address) (dst_port)" 976 " tos (tos_value) ttl (ttl_value)" 977 " vlan (vlan_value) flexbytes (flexbytes_value)" 978 " (drop|fwd) pf|vf(vf_id) queue (queue_id)" 979 " fd_id (fd_id_value)\n" 980 " Add/Del an UDP/TCP type flow director filter.\n\n" 981 982 "flow_director_filter (port_id) mode IP (add|del|update)" 983 " flow (ipv4-sctp|ipv6-sctp)" 984 " src (src_ip_address) (src_port)" 985 " dst (dst_ip_address) (dst_port)" 986 " tag (verification_tag) " 987 " tos (tos_value) ttl (ttl_value)" 988 " vlan (vlan_value)" 989 " flexbytes (flexbytes_value) (drop|fwd)" 990 " pf|vf(vf_id) queue (queue_id) fd_id (fd_id_value)\n" 991 " Add/Del a SCTP type flow director filter.\n\n" 992 993 "flow_director_filter (port_id) mode IP (add|del|update)" 994 " flow l2_payload ether (ethertype)" 995 " flexbytes (flexbytes_value) (drop|fwd)" 996 " pf|vf(vf_id) queue (queue_id) fd_id (fd_id_value)\n" 997 " Add/Del a l2 payload type flow director filter.\n\n" 998 999 "flow_director_filter (port_id) mode MAC-VLAN (add|del|update)" 1000 " mac (mac_address) vlan (vlan_value)" 1001 " flexbytes (flexbytes_value) (drop|fwd)" 1002 " queue (queue_id) fd_id (fd_id_value)\n" 1003 " Add/Del a MAC-VLAN flow director filter.\n\n" 1004 1005 "flow_director_filter (port_id) mode Tunnel (add|del|update)" 1006 " mac (mac_address) vlan (vlan_value)" 1007 " tunnel (NVGRE|VxLAN) tunnel-id (tunnel_id_value)" 1008 " flexbytes (flexbytes_value) (drop|fwd)" 1009 " queue (queue_id) fd_id (fd_id_value)\n" 1010 " Add/Del a Tunnel flow director filter.\n\n" 1011 1012 "flow_director_filter (port_id) mode raw (add|del|update)" 1013 " flow (flow_id) (drop|fwd) queue (queue_id)" 1014 " fd_id (fd_id_value) packet (packet file name)\n" 1015 " Add/Del a raw type flow director filter.\n\n" 1016 1017 "flush_flow_director (port_id)\n" 1018 " Flush all flow director entries of a device.\n\n" 1019 1020 "flow_director_mask (port_id) mode IP vlan (vlan_value)" 1021 " src_mask (ipv4_src) (ipv6_src) (src_port)" 1022 " dst_mask (ipv4_dst) (ipv6_dst) (dst_port)\n" 1023 " Set flow director IP mask.\n\n" 1024 1025 "flow_director_mask (port_id) mode MAC-VLAN" 1026 " vlan (vlan_value)\n" 1027 " Set flow director MAC-VLAN mask.\n\n" 1028 1029 "flow_director_mask (port_id) mode Tunnel" 1030 " vlan (vlan_value) mac (mac_value)" 1031 " tunnel-type (tunnel_type_value)" 1032 " tunnel-id (tunnel_id_value)\n" 1033 " Set flow director Tunnel mask.\n\n" 1034 1035 "flow_director_flex_mask (port_id)" 1036 " flow (none|ipv4-other|ipv4-frag|ipv4-tcp|ipv4-udp|ipv4-sctp|" 1037 "ipv6-other|ipv6-frag|ipv6-tcp|ipv6-udp|ipv6-sctp|l2_payload|all)" 1038 " (mask)\n" 1039 " Configure mask of flex payload.\n\n" 1040 1041 "flow_director_flex_payload (port_id)" 1042 " (raw|l2|l3|l4) (config)\n" 1043 " Configure flex payload selection.\n\n" 1044 1045 "get_sym_hash_ena_per_port (port_id)\n" 1046 " get symmetric hash enable configuration per port.\n\n" 1047 1048 "set_sym_hash_ena_per_port (port_id) (enable|disable)\n" 1049 " set symmetric hash enable configuration per port" 1050 " to enable or disable.\n\n" 1051 1052 "get_hash_global_config (port_id)\n" 1053 " Get the global configurations of hash filters.\n\n" 1054 1055 "set_hash_global_config (port_id) (toeplitz|simple_xor|symmetric_toeplitz|default)" 1056 " (ipv4|ipv4-frag|ipv4-tcp|ipv4-udp|ipv4-sctp|ipv4-other|ipv6|" 1057 "ipv6-frag|ipv6-tcp|ipv6-udp|ipv6-sctp|ipv6-other|l2_payload)" 1058 " (enable|disable)\n" 1059 " Set the global configurations of hash filters.\n\n" 1060 1061 "set_hash_input_set (port_id) (ipv4|ipv4-frag|" 1062 "ipv4-tcp|ipv4-udp|ipv4-sctp|ipv4-other|ipv6|" 1063 "ipv6-frag|ipv6-tcp|ipv6-udp|ipv6-sctp|ipv6-other|" 1064 "l2_payload|<flowtype_id>) (ovlan|ivlan|src-ipv4|dst-ipv4|" 1065 "src-ipv6|dst-ipv6|ipv4-tos|ipv4-proto|ipv6-tc|" 1066 "ipv6-next-header|udp-src-port|udp-dst-port|" 1067 "tcp-src-port|tcp-dst-port|sctp-src-port|" 1068 "sctp-dst-port|sctp-veri-tag|udp-key|gre-key|fld-1st|" 1069 "fld-2nd|fld-3rd|fld-4th|fld-5th|fld-6th|fld-7th|" 1070 "fld-8th|none) (select|add)\n" 1071 " Set the input set for hash.\n\n" 1072 1073 "set_fdir_input_set (port_id) " 1074 "(ipv4-frag|ipv4-tcp|ipv4-udp|ipv4-sctp|ipv4-other|" 1075 "ipv6-frag|ipv6-tcp|ipv6-udp|ipv6-sctp|ipv6-other|" 1076 "l2_payload) (ivlan|ethertype|src-ipv4|dst-ipv4|src-ipv6|" 1077 "dst-ipv6|ipv4-tos|ipv4-proto|ipv4-ttl|ipv6-tc|" 1078 "ipv6-next-header|ipv6-hop-limits|udp-src-port|" 1079 "udp-dst-port|tcp-src-port|tcp-dst-port|" 1080 "sctp-src-port|sctp-dst-port|sctp-veri-tag|none)" 1081 " (select|add)\n" 1082 " Set the input set for FDir.\n\n" 1083 1084 "flow validate {port_id}" 1085 " [group {group_id}] [priority {level}]" 1086 " [ingress] [egress]" 1087 " pattern {item} [/ {item} [...]] / end" 1088 " actions {action} [/ {action} [...]] / end\n" 1089 " Check whether a flow rule can be created.\n\n" 1090 1091 "flow create {port_id}" 1092 " [group {group_id}] [priority {level}]" 1093 " [ingress] [egress]" 1094 " pattern {item} [/ {item} [...]] / end" 1095 " actions {action} [/ {action} [...]] / end\n" 1096 " Create a flow rule.\n\n" 1097 1098 "flow destroy {port_id} rule {rule_id} [...]\n" 1099 " Destroy specific flow rules.\n\n" 1100 1101 "flow flush {port_id}\n" 1102 " Destroy all flow rules.\n\n" 1103 1104 "flow query {port_id} {rule_id} {action}\n" 1105 " Query an existing flow rule.\n\n" 1106 1107 "flow list {port_id} [group {group_id}] [...]\n" 1108 " List existing flow rules sorted by priority," 1109 " filtered by group identifiers.\n\n" 1110 1111 "flow isolate {port_id} {boolean}\n" 1112 " Restrict ingress traffic to the defined" 1113 " flow rules\n\n" 1114 1115 "set vxlan ip-version (ipv4|ipv6) vni (vni) udp-src" 1116 " (udp-src) udp-dst (udp-dst) ip-src (ip-src) ip-dst" 1117 " (ip-dst) eth-src (eth-src) eth-dst (eth-dst)\n" 1118 " Configure the VXLAN encapsulation for flows.\n\n" 1119 1120 "set vxlan-with-vlan ip-version (ipv4|ipv6) vni (vni)" 1121 " udp-src (udp-src) udp-dst (udp-dst) ip-src (ip-src)" 1122 " ip-dst (ip-dst) vlan-tci (vlan-tci) eth-src (eth-src)" 1123 " eth-dst (eth-dst)\n" 1124 " Configure the VXLAN encapsulation for flows.\n\n" 1125 1126 "set vxlan-tos-ttl ip-version (ipv4|ipv6) vni (vni) udp-src" 1127 " (udp-src) udp-dst (udp-dst) ip-tos (ip-tos) ip-ttl (ip-ttl)" 1128 " ip-src (ip-src) ip-dst (ip-dst) eth-src (eth-src)" 1129 " eth-dst (eth-dst)\n" 1130 " Configure the VXLAN encapsulation for flows.\n\n" 1131 1132 "set nvgre ip-version (ipv4|ipv6) tni (tni) ip-src" 1133 " (ip-src) ip-dst (ip-dst) eth-src (eth-src) eth-dst" 1134 " (eth-dst)\n" 1135 " Configure the NVGRE encapsulation for flows.\n\n" 1136 1137 "set nvgre-with-vlan ip-version (ipv4|ipv6) tni (tni)" 1138 " ip-src (ip-src) ip-dst (ip-dst) vlan-tci (vlan-tci)" 1139 " eth-src (eth-src) eth-dst (eth-dst)\n" 1140 " Configure the NVGRE encapsulation for flows.\n\n" 1141 1142 "set raw_encap {flow items}\n" 1143 " Configure the encapsulation with raw data.\n\n" 1144 1145 "set raw_decap {flow items}\n" 1146 " Configure the decapsulation with raw data.\n\n" 1147 1148 ); 1149 } 1150 1151 if (show_all || !strcmp(res->section, "traffic_management")) { 1152 cmdline_printf( 1153 cl, 1154 "\n" 1155 "Traffic Management:\n" 1156 "--------------\n" 1157 "show port tm cap (port_id)\n" 1158 " Display the port TM capability.\n\n" 1159 1160 "show port tm level cap (port_id) (level_id)\n" 1161 " Display the port TM hierarchical level capability.\n\n" 1162 1163 "show port tm node cap (port_id) (node_id)\n" 1164 " Display the port TM node capability.\n\n" 1165 1166 "show port tm node type (port_id) (node_id)\n" 1167 " Display the port TM node type.\n\n" 1168 1169 "show port tm node stats (port_id) (node_id) (clear)\n" 1170 " Display the port TM node stats.\n\n" 1171 1172 #if defined RTE_LIBRTE_PMD_SOFTNIC && defined RTE_LIBRTE_SCHED 1173 "set port tm hierarchy default (port_id)\n" 1174 " Set default traffic Management hierarchy on a port\n\n" 1175 #endif 1176 1177 "add port tm node shaper profile (port_id) (shaper_profile_id)" 1178 " (cmit_tb_rate) (cmit_tb_size) (peak_tb_rate) (peak_tb_size)" 1179 " (packet_length_adjust)\n" 1180 " Add port tm node private shaper profile.\n\n" 1181 1182 "del port tm node shaper profile (port_id) (shaper_profile_id)\n" 1183 " Delete port tm node private shaper profile.\n\n" 1184 1185 "add port tm node shared shaper (port_id) (shared_shaper_id)" 1186 " (shaper_profile_id)\n" 1187 " Add/update port tm node shared shaper.\n\n" 1188 1189 "del port tm node shared shaper (port_id) (shared_shaper_id)\n" 1190 " Delete port tm node shared shaper.\n\n" 1191 1192 "set port tm node shaper profile (port_id) (node_id)" 1193 " (shaper_profile_id)\n" 1194 " Set port tm node shaper profile.\n\n" 1195 1196 "add port tm node wred profile (port_id) (wred_profile_id)" 1197 " (color_g) (min_th_g) (max_th_g) (maxp_inv_g) (wq_log2_g)" 1198 " (color_y) (min_th_y) (max_th_y) (maxp_inv_y) (wq_log2_y)" 1199 " (color_r) (min_th_r) (max_th_r) (maxp_inv_r) (wq_log2_r)\n" 1200 " Add port tm node wred profile.\n\n" 1201 1202 "del port tm node wred profile (port_id) (wred_profile_id)\n" 1203 " Delete port tm node wred profile.\n\n" 1204 1205 "add port tm nonleaf node (port_id) (node_id) (parent_node_id)" 1206 " (priority) (weight) (level_id) (shaper_profile_id)" 1207 " (n_sp_priorities) (stats_mask) (n_shared_shapers)" 1208 " [(shared_shaper_id_0) (shared_shaper_id_1)...]\n" 1209 " Add port tm nonleaf node.\n\n" 1210 1211 "add port tm leaf node (port_id) (node_id) (parent_node_id)" 1212 " (priority) (weight) (level_id) (shaper_profile_id)" 1213 " (cman_mode) (wred_profile_id) (stats_mask) (n_shared_shapers)" 1214 " [(shared_shaper_id_0) (shared_shaper_id_1)...]\n" 1215 " Add port tm leaf node.\n\n" 1216 1217 "del port tm node (port_id) (node_id)\n" 1218 " Delete port tm node.\n\n" 1219 1220 "set port tm node parent (port_id) (node_id) (parent_node_id)" 1221 " (priority) (weight)\n" 1222 " Set port tm node parent.\n\n" 1223 1224 "suspend port tm node (port_id) (node_id)" 1225 " Suspend tm node.\n\n" 1226 1227 "resume port tm node (port_id) (node_id)" 1228 " Resume tm node.\n\n" 1229 1230 "port tm hierarchy commit (port_id) (clean_on_fail)\n" 1231 " Commit tm hierarchy.\n\n" 1232 1233 "set port tm mark ip_ecn (port) (green) (yellow)" 1234 " (red)\n" 1235 " Enables/Disables the traffic management marking" 1236 " for IP ECN (Explicit Congestion Notification)" 1237 " packets on a given port\n\n" 1238 1239 "set port tm mark ip_dscp (port) (green) (yellow)" 1240 " (red)\n" 1241 " Enables/Disables the traffic management marking" 1242 " on the port for IP dscp packets\n\n" 1243 1244 "set port tm mark vlan_dei (port) (green) (yellow)" 1245 " (red)\n" 1246 " Enables/Disables the traffic management marking" 1247 " on the port for VLAN packets with DEI enabled\n\n" 1248 ); 1249 } 1250 1251 if (show_all || !strcmp(res->section, "devices")) { 1252 cmdline_printf( 1253 cl, 1254 "\n" 1255 "Device Operations:\n" 1256 "--------------\n" 1257 "device detach (identifier)\n" 1258 " Detach device by identifier.\n\n" 1259 ); 1260 } 1261 1262 } 1263 1264 cmdline_parse_token_string_t cmd_help_long_help = 1265 TOKEN_STRING_INITIALIZER(struct cmd_help_long_result, help, "help"); 1266 1267 cmdline_parse_token_string_t cmd_help_long_section = 1268 TOKEN_STRING_INITIALIZER(struct cmd_help_long_result, section, 1269 "all#control#display#config#" 1270 "ports#registers#filters#traffic_management#devices"); 1271 1272 cmdline_parse_inst_t cmd_help_long = { 1273 .f = cmd_help_long_parsed, 1274 .data = NULL, 1275 .help_str = "help all|control|display|config|ports|register|" 1276 "filters|traffic_management|devices: " 1277 "Show help", 1278 .tokens = { 1279 (void *)&cmd_help_long_help, 1280 (void *)&cmd_help_long_section, 1281 NULL, 1282 }, 1283 }; 1284 1285 1286 /* *** start/stop/close all ports *** */ 1287 struct cmd_operate_port_result { 1288 cmdline_fixed_string_t keyword; 1289 cmdline_fixed_string_t name; 1290 cmdline_fixed_string_t value; 1291 }; 1292 1293 static void cmd_operate_port_parsed(void *parsed_result, 1294 __attribute__((unused)) struct cmdline *cl, 1295 __attribute__((unused)) void *data) 1296 { 1297 struct cmd_operate_port_result *res = parsed_result; 1298 1299 if (!strcmp(res->name, "start")) 1300 start_port(RTE_PORT_ALL); 1301 else if (!strcmp(res->name, "stop")) 1302 stop_port(RTE_PORT_ALL); 1303 else if (!strcmp(res->name, "close")) 1304 close_port(RTE_PORT_ALL); 1305 else if (!strcmp(res->name, "reset")) 1306 reset_port(RTE_PORT_ALL); 1307 else 1308 printf("Unknown parameter\n"); 1309 } 1310 1311 cmdline_parse_token_string_t cmd_operate_port_all_cmd = 1312 TOKEN_STRING_INITIALIZER(struct cmd_operate_port_result, keyword, 1313 "port"); 1314 cmdline_parse_token_string_t cmd_operate_port_all_port = 1315 TOKEN_STRING_INITIALIZER(struct cmd_operate_port_result, name, 1316 "start#stop#close#reset"); 1317 cmdline_parse_token_string_t cmd_operate_port_all_all = 1318 TOKEN_STRING_INITIALIZER(struct cmd_operate_port_result, value, "all"); 1319 1320 cmdline_parse_inst_t cmd_operate_port = { 1321 .f = cmd_operate_port_parsed, 1322 .data = NULL, 1323 .help_str = "port start|stop|close all: Start/Stop/Close/Reset all ports", 1324 .tokens = { 1325 (void *)&cmd_operate_port_all_cmd, 1326 (void *)&cmd_operate_port_all_port, 1327 (void *)&cmd_operate_port_all_all, 1328 NULL, 1329 }, 1330 }; 1331 1332 /* *** start/stop/close specific port *** */ 1333 struct cmd_operate_specific_port_result { 1334 cmdline_fixed_string_t keyword; 1335 cmdline_fixed_string_t name; 1336 uint8_t value; 1337 }; 1338 1339 static void cmd_operate_specific_port_parsed(void *parsed_result, 1340 __attribute__((unused)) struct cmdline *cl, 1341 __attribute__((unused)) void *data) 1342 { 1343 struct cmd_operate_specific_port_result *res = parsed_result; 1344 1345 if (!strcmp(res->name, "start")) 1346 start_port(res->value); 1347 else if (!strcmp(res->name, "stop")) 1348 stop_port(res->value); 1349 else if (!strcmp(res->name, "close")) 1350 close_port(res->value); 1351 else if (!strcmp(res->name, "reset")) 1352 reset_port(res->value); 1353 else 1354 printf("Unknown parameter\n"); 1355 } 1356 1357 cmdline_parse_token_string_t cmd_operate_specific_port_cmd = 1358 TOKEN_STRING_INITIALIZER(struct cmd_operate_specific_port_result, 1359 keyword, "port"); 1360 cmdline_parse_token_string_t cmd_operate_specific_port_port = 1361 TOKEN_STRING_INITIALIZER(struct cmd_operate_specific_port_result, 1362 name, "start#stop#close#reset"); 1363 cmdline_parse_token_num_t cmd_operate_specific_port_id = 1364 TOKEN_NUM_INITIALIZER(struct cmd_operate_specific_port_result, 1365 value, UINT8); 1366 1367 cmdline_parse_inst_t cmd_operate_specific_port = { 1368 .f = cmd_operate_specific_port_parsed, 1369 .data = NULL, 1370 .help_str = "port start|stop|close <port_id>: Start/Stop/Close/Reset port_id", 1371 .tokens = { 1372 (void *)&cmd_operate_specific_port_cmd, 1373 (void *)&cmd_operate_specific_port_port, 1374 (void *)&cmd_operate_specific_port_id, 1375 NULL, 1376 }, 1377 }; 1378 1379 /* *** enable port setup (after attach) via iterator or event *** */ 1380 struct cmd_set_port_setup_on_result { 1381 cmdline_fixed_string_t set; 1382 cmdline_fixed_string_t port; 1383 cmdline_fixed_string_t setup; 1384 cmdline_fixed_string_t on; 1385 cmdline_fixed_string_t mode; 1386 }; 1387 1388 static void cmd_set_port_setup_on_parsed(void *parsed_result, 1389 __attribute__((unused)) struct cmdline *cl, 1390 __attribute__((unused)) void *data) 1391 { 1392 struct cmd_set_port_setup_on_result *res = parsed_result; 1393 1394 if (strcmp(res->mode, "event") == 0) 1395 setup_on_probe_event = true; 1396 else if (strcmp(res->mode, "iterator") == 0) 1397 setup_on_probe_event = false; 1398 else 1399 printf("Unknown mode\n"); 1400 } 1401 1402 cmdline_parse_token_string_t cmd_set_port_setup_on_set = 1403 TOKEN_STRING_INITIALIZER(struct cmd_set_port_setup_on_result, 1404 set, "set"); 1405 cmdline_parse_token_string_t cmd_set_port_setup_on_port = 1406 TOKEN_STRING_INITIALIZER(struct cmd_set_port_setup_on_result, 1407 port, "port"); 1408 cmdline_parse_token_string_t cmd_set_port_setup_on_setup = 1409 TOKEN_STRING_INITIALIZER(struct cmd_set_port_setup_on_result, 1410 setup, "setup"); 1411 cmdline_parse_token_string_t cmd_set_port_setup_on_on = 1412 TOKEN_STRING_INITIALIZER(struct cmd_set_port_setup_on_result, 1413 on, "on"); 1414 cmdline_parse_token_string_t cmd_set_port_setup_on_mode = 1415 TOKEN_STRING_INITIALIZER(struct cmd_set_port_setup_on_result, 1416 mode, "iterator#event"); 1417 1418 cmdline_parse_inst_t cmd_set_port_setup_on = { 1419 .f = cmd_set_port_setup_on_parsed, 1420 .data = NULL, 1421 .help_str = "set port setup on iterator|event", 1422 .tokens = { 1423 (void *)&cmd_set_port_setup_on_set, 1424 (void *)&cmd_set_port_setup_on_port, 1425 (void *)&cmd_set_port_setup_on_setup, 1426 (void *)&cmd_set_port_setup_on_on, 1427 (void *)&cmd_set_port_setup_on_mode, 1428 NULL, 1429 }, 1430 }; 1431 1432 /* *** attach a specified port *** */ 1433 struct cmd_operate_attach_port_result { 1434 cmdline_fixed_string_t port; 1435 cmdline_fixed_string_t keyword; 1436 cmdline_fixed_string_t identifier; 1437 }; 1438 1439 static void cmd_operate_attach_port_parsed(void *parsed_result, 1440 __attribute__((unused)) struct cmdline *cl, 1441 __attribute__((unused)) void *data) 1442 { 1443 struct cmd_operate_attach_port_result *res = parsed_result; 1444 1445 if (!strcmp(res->keyword, "attach")) 1446 attach_port(res->identifier); 1447 else 1448 printf("Unknown parameter\n"); 1449 } 1450 1451 cmdline_parse_token_string_t cmd_operate_attach_port_port = 1452 TOKEN_STRING_INITIALIZER(struct cmd_operate_attach_port_result, 1453 port, "port"); 1454 cmdline_parse_token_string_t cmd_operate_attach_port_keyword = 1455 TOKEN_STRING_INITIALIZER(struct cmd_operate_attach_port_result, 1456 keyword, "attach"); 1457 cmdline_parse_token_string_t cmd_operate_attach_port_identifier = 1458 TOKEN_STRING_INITIALIZER(struct cmd_operate_attach_port_result, 1459 identifier, NULL); 1460 1461 cmdline_parse_inst_t cmd_operate_attach_port = { 1462 .f = cmd_operate_attach_port_parsed, 1463 .data = NULL, 1464 .help_str = "port attach <identifier>: " 1465 "(identifier: pci address or virtual dev name)", 1466 .tokens = { 1467 (void *)&cmd_operate_attach_port_port, 1468 (void *)&cmd_operate_attach_port_keyword, 1469 (void *)&cmd_operate_attach_port_identifier, 1470 NULL, 1471 }, 1472 }; 1473 1474 /* *** detach a specified port *** */ 1475 struct cmd_operate_detach_port_result { 1476 cmdline_fixed_string_t port; 1477 cmdline_fixed_string_t keyword; 1478 portid_t port_id; 1479 }; 1480 1481 static void cmd_operate_detach_port_parsed(void *parsed_result, 1482 __attribute__((unused)) struct cmdline *cl, 1483 __attribute__((unused)) void *data) 1484 { 1485 struct cmd_operate_detach_port_result *res = parsed_result; 1486 1487 if (!strcmp(res->keyword, "detach")) 1488 detach_port_device(res->port_id); 1489 else 1490 printf("Unknown parameter\n"); 1491 } 1492 1493 cmdline_parse_token_string_t cmd_operate_detach_port_port = 1494 TOKEN_STRING_INITIALIZER(struct cmd_operate_detach_port_result, 1495 port, "port"); 1496 cmdline_parse_token_string_t cmd_operate_detach_port_keyword = 1497 TOKEN_STRING_INITIALIZER(struct cmd_operate_detach_port_result, 1498 keyword, "detach"); 1499 cmdline_parse_token_num_t cmd_operate_detach_port_port_id = 1500 TOKEN_NUM_INITIALIZER(struct cmd_operate_detach_port_result, 1501 port_id, UINT16); 1502 1503 cmdline_parse_inst_t cmd_operate_detach_port = { 1504 .f = cmd_operate_detach_port_parsed, 1505 .data = NULL, 1506 .help_str = "port detach <port_id>", 1507 .tokens = { 1508 (void *)&cmd_operate_detach_port_port, 1509 (void *)&cmd_operate_detach_port_keyword, 1510 (void *)&cmd_operate_detach_port_port_id, 1511 NULL, 1512 }, 1513 }; 1514 1515 /* *** detach device by identifier *** */ 1516 struct cmd_operate_detach_device_result { 1517 cmdline_fixed_string_t device; 1518 cmdline_fixed_string_t keyword; 1519 cmdline_fixed_string_t identifier; 1520 }; 1521 1522 static void cmd_operate_detach_device_parsed(void *parsed_result, 1523 __attribute__((unused)) struct cmdline *cl, 1524 __attribute__((unused)) void *data) 1525 { 1526 struct cmd_operate_detach_device_result *res = parsed_result; 1527 1528 if (!strcmp(res->keyword, "detach")) 1529 detach_device(res->identifier); 1530 else 1531 printf("Unknown parameter\n"); 1532 } 1533 1534 cmdline_parse_token_string_t cmd_operate_detach_device_device = 1535 TOKEN_STRING_INITIALIZER(struct cmd_operate_detach_device_result, 1536 device, "device"); 1537 cmdline_parse_token_string_t cmd_operate_detach_device_keyword = 1538 TOKEN_STRING_INITIALIZER(struct cmd_operate_detach_device_result, 1539 keyword, "detach"); 1540 cmdline_parse_token_string_t cmd_operate_detach_device_identifier = 1541 TOKEN_STRING_INITIALIZER(struct cmd_operate_detach_device_result, 1542 identifier, NULL); 1543 1544 cmdline_parse_inst_t cmd_operate_detach_device = { 1545 .f = cmd_operate_detach_device_parsed, 1546 .data = NULL, 1547 .help_str = "device detach <identifier>:" 1548 "(identifier: pci address or virtual dev name)", 1549 .tokens = { 1550 (void *)&cmd_operate_detach_device_device, 1551 (void *)&cmd_operate_detach_device_keyword, 1552 (void *)&cmd_operate_detach_device_identifier, 1553 NULL, 1554 }, 1555 }; 1556 /* *** configure speed for all ports *** */ 1557 struct cmd_config_speed_all { 1558 cmdline_fixed_string_t port; 1559 cmdline_fixed_string_t keyword; 1560 cmdline_fixed_string_t all; 1561 cmdline_fixed_string_t item1; 1562 cmdline_fixed_string_t item2; 1563 cmdline_fixed_string_t value1; 1564 cmdline_fixed_string_t value2; 1565 }; 1566 1567 static int 1568 parse_and_check_speed_duplex(char *speedstr, char *duplexstr, uint32_t *speed) 1569 { 1570 1571 int duplex; 1572 1573 if (!strcmp(duplexstr, "half")) { 1574 duplex = ETH_LINK_HALF_DUPLEX; 1575 } else if (!strcmp(duplexstr, "full")) { 1576 duplex = ETH_LINK_FULL_DUPLEX; 1577 } else if (!strcmp(duplexstr, "auto")) { 1578 duplex = ETH_LINK_FULL_DUPLEX; 1579 } else { 1580 printf("Unknown duplex parameter\n"); 1581 return -1; 1582 } 1583 1584 if (!strcmp(speedstr, "10")) { 1585 *speed = (duplex == ETH_LINK_HALF_DUPLEX) ? 1586 ETH_LINK_SPEED_10M_HD : ETH_LINK_SPEED_10M; 1587 } else if (!strcmp(speedstr, "100")) { 1588 *speed = (duplex == ETH_LINK_HALF_DUPLEX) ? 1589 ETH_LINK_SPEED_100M_HD : ETH_LINK_SPEED_100M; 1590 } else { 1591 if (duplex != ETH_LINK_FULL_DUPLEX) { 1592 printf("Invalid speed/duplex parameters\n"); 1593 return -1; 1594 } 1595 if (!strcmp(speedstr, "1000")) { 1596 *speed = ETH_LINK_SPEED_1G; 1597 } else if (!strcmp(speedstr, "10000")) { 1598 *speed = ETH_LINK_SPEED_10G; 1599 } else if (!strcmp(speedstr, "25000")) { 1600 *speed = ETH_LINK_SPEED_25G; 1601 } else if (!strcmp(speedstr, "40000")) { 1602 *speed = ETH_LINK_SPEED_40G; 1603 } else if (!strcmp(speedstr, "50000")) { 1604 *speed = ETH_LINK_SPEED_50G; 1605 } else if (!strcmp(speedstr, "100000")) { 1606 *speed = ETH_LINK_SPEED_100G; 1607 } else if (!strcmp(speedstr, "auto")) { 1608 *speed = ETH_LINK_SPEED_AUTONEG; 1609 } else { 1610 printf("Unknown speed parameter\n"); 1611 return -1; 1612 } 1613 } 1614 1615 return 0; 1616 } 1617 1618 static void 1619 cmd_config_speed_all_parsed(void *parsed_result, 1620 __attribute__((unused)) struct cmdline *cl, 1621 __attribute__((unused)) void *data) 1622 { 1623 struct cmd_config_speed_all *res = parsed_result; 1624 uint32_t link_speed; 1625 portid_t pid; 1626 1627 if (!all_ports_stopped()) { 1628 printf("Please stop all ports first\n"); 1629 return; 1630 } 1631 1632 if (parse_and_check_speed_duplex(res->value1, res->value2, 1633 &link_speed) < 0) 1634 return; 1635 1636 RTE_ETH_FOREACH_DEV(pid) { 1637 ports[pid].dev_conf.link_speeds = link_speed; 1638 } 1639 1640 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1); 1641 } 1642 1643 cmdline_parse_token_string_t cmd_config_speed_all_port = 1644 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_all, port, "port"); 1645 cmdline_parse_token_string_t cmd_config_speed_all_keyword = 1646 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_all, keyword, 1647 "config"); 1648 cmdline_parse_token_string_t cmd_config_speed_all_all = 1649 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_all, all, "all"); 1650 cmdline_parse_token_string_t cmd_config_speed_all_item1 = 1651 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_all, item1, "speed"); 1652 cmdline_parse_token_string_t cmd_config_speed_all_value1 = 1653 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_all, value1, 1654 "10#100#1000#10000#25000#40000#50000#100000#auto"); 1655 cmdline_parse_token_string_t cmd_config_speed_all_item2 = 1656 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_all, item2, "duplex"); 1657 cmdline_parse_token_string_t cmd_config_speed_all_value2 = 1658 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_all, value2, 1659 "half#full#auto"); 1660 1661 cmdline_parse_inst_t cmd_config_speed_all = { 1662 .f = cmd_config_speed_all_parsed, 1663 .data = NULL, 1664 .help_str = "port config all speed " 1665 "10|100|1000|10000|25000|40000|50000|100000|auto duplex " 1666 "half|full|auto", 1667 .tokens = { 1668 (void *)&cmd_config_speed_all_port, 1669 (void *)&cmd_config_speed_all_keyword, 1670 (void *)&cmd_config_speed_all_all, 1671 (void *)&cmd_config_speed_all_item1, 1672 (void *)&cmd_config_speed_all_value1, 1673 (void *)&cmd_config_speed_all_item2, 1674 (void *)&cmd_config_speed_all_value2, 1675 NULL, 1676 }, 1677 }; 1678 1679 /* *** configure speed for specific port *** */ 1680 struct cmd_config_speed_specific { 1681 cmdline_fixed_string_t port; 1682 cmdline_fixed_string_t keyword; 1683 portid_t id; 1684 cmdline_fixed_string_t item1; 1685 cmdline_fixed_string_t item2; 1686 cmdline_fixed_string_t value1; 1687 cmdline_fixed_string_t value2; 1688 }; 1689 1690 static void 1691 cmd_config_speed_specific_parsed(void *parsed_result, 1692 __attribute__((unused)) struct cmdline *cl, 1693 __attribute__((unused)) void *data) 1694 { 1695 struct cmd_config_speed_specific *res = parsed_result; 1696 uint32_t link_speed; 1697 1698 if (!all_ports_stopped()) { 1699 printf("Please stop all ports first\n"); 1700 return; 1701 } 1702 1703 if (port_id_is_invalid(res->id, ENABLED_WARN)) 1704 return; 1705 1706 if (parse_and_check_speed_duplex(res->value1, res->value2, 1707 &link_speed) < 0) 1708 return; 1709 1710 ports[res->id].dev_conf.link_speeds = link_speed; 1711 1712 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1); 1713 } 1714 1715 1716 cmdline_parse_token_string_t cmd_config_speed_specific_port = 1717 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_specific, port, 1718 "port"); 1719 cmdline_parse_token_string_t cmd_config_speed_specific_keyword = 1720 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_specific, keyword, 1721 "config"); 1722 cmdline_parse_token_num_t cmd_config_speed_specific_id = 1723 TOKEN_NUM_INITIALIZER(struct cmd_config_speed_specific, id, UINT16); 1724 cmdline_parse_token_string_t cmd_config_speed_specific_item1 = 1725 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_specific, item1, 1726 "speed"); 1727 cmdline_parse_token_string_t cmd_config_speed_specific_value1 = 1728 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_specific, value1, 1729 "10#100#1000#10000#25000#40000#50000#100000#auto"); 1730 cmdline_parse_token_string_t cmd_config_speed_specific_item2 = 1731 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_specific, item2, 1732 "duplex"); 1733 cmdline_parse_token_string_t cmd_config_speed_specific_value2 = 1734 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_specific, value2, 1735 "half#full#auto"); 1736 1737 cmdline_parse_inst_t cmd_config_speed_specific = { 1738 .f = cmd_config_speed_specific_parsed, 1739 .data = NULL, 1740 .help_str = "port config <port_id> speed " 1741 "10|100|1000|10000|25000|40000|50000|100000|auto duplex " 1742 "half|full|auto", 1743 .tokens = { 1744 (void *)&cmd_config_speed_specific_port, 1745 (void *)&cmd_config_speed_specific_keyword, 1746 (void *)&cmd_config_speed_specific_id, 1747 (void *)&cmd_config_speed_specific_item1, 1748 (void *)&cmd_config_speed_specific_value1, 1749 (void *)&cmd_config_speed_specific_item2, 1750 (void *)&cmd_config_speed_specific_value2, 1751 NULL, 1752 }, 1753 }; 1754 1755 /* *** configure loopback for all ports *** */ 1756 struct cmd_config_loopback_all { 1757 cmdline_fixed_string_t port; 1758 cmdline_fixed_string_t keyword; 1759 cmdline_fixed_string_t all; 1760 cmdline_fixed_string_t item; 1761 uint32_t mode; 1762 }; 1763 1764 static void 1765 cmd_config_loopback_all_parsed(void *parsed_result, 1766 __attribute__((unused)) struct cmdline *cl, 1767 __attribute__((unused)) void *data) 1768 { 1769 struct cmd_config_loopback_all *res = parsed_result; 1770 portid_t pid; 1771 1772 if (!all_ports_stopped()) { 1773 printf("Please stop all ports first\n"); 1774 return; 1775 } 1776 1777 RTE_ETH_FOREACH_DEV(pid) { 1778 ports[pid].dev_conf.lpbk_mode = res->mode; 1779 } 1780 1781 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1); 1782 } 1783 1784 cmdline_parse_token_string_t cmd_config_loopback_all_port = 1785 TOKEN_STRING_INITIALIZER(struct cmd_config_loopback_all, port, "port"); 1786 cmdline_parse_token_string_t cmd_config_loopback_all_keyword = 1787 TOKEN_STRING_INITIALIZER(struct cmd_config_loopback_all, keyword, 1788 "config"); 1789 cmdline_parse_token_string_t cmd_config_loopback_all_all = 1790 TOKEN_STRING_INITIALIZER(struct cmd_config_loopback_all, all, "all"); 1791 cmdline_parse_token_string_t cmd_config_loopback_all_item = 1792 TOKEN_STRING_INITIALIZER(struct cmd_config_loopback_all, item, 1793 "loopback"); 1794 cmdline_parse_token_num_t cmd_config_loopback_all_mode = 1795 TOKEN_NUM_INITIALIZER(struct cmd_config_loopback_all, mode, UINT32); 1796 1797 cmdline_parse_inst_t cmd_config_loopback_all = { 1798 .f = cmd_config_loopback_all_parsed, 1799 .data = NULL, 1800 .help_str = "port config all loopback <mode>", 1801 .tokens = { 1802 (void *)&cmd_config_loopback_all_port, 1803 (void *)&cmd_config_loopback_all_keyword, 1804 (void *)&cmd_config_loopback_all_all, 1805 (void *)&cmd_config_loopback_all_item, 1806 (void *)&cmd_config_loopback_all_mode, 1807 NULL, 1808 }, 1809 }; 1810 1811 /* *** configure loopback for specific port *** */ 1812 struct cmd_config_loopback_specific { 1813 cmdline_fixed_string_t port; 1814 cmdline_fixed_string_t keyword; 1815 uint16_t port_id; 1816 cmdline_fixed_string_t item; 1817 uint32_t mode; 1818 }; 1819 1820 static void 1821 cmd_config_loopback_specific_parsed(void *parsed_result, 1822 __attribute__((unused)) struct cmdline *cl, 1823 __attribute__((unused)) void *data) 1824 { 1825 struct cmd_config_loopback_specific *res = parsed_result; 1826 1827 if (port_id_is_invalid(res->port_id, ENABLED_WARN)) 1828 return; 1829 1830 if (!port_is_stopped(res->port_id)) { 1831 printf("Please stop port %u first\n", res->port_id); 1832 return; 1833 } 1834 1835 ports[res->port_id].dev_conf.lpbk_mode = res->mode; 1836 1837 cmd_reconfig_device_queue(res->port_id, 1, 1); 1838 } 1839 1840 1841 cmdline_parse_token_string_t cmd_config_loopback_specific_port = 1842 TOKEN_STRING_INITIALIZER(struct cmd_config_loopback_specific, port, 1843 "port"); 1844 cmdline_parse_token_string_t cmd_config_loopback_specific_keyword = 1845 TOKEN_STRING_INITIALIZER(struct cmd_config_loopback_specific, keyword, 1846 "config"); 1847 cmdline_parse_token_num_t cmd_config_loopback_specific_id = 1848 TOKEN_NUM_INITIALIZER(struct cmd_config_loopback_specific, port_id, 1849 UINT16); 1850 cmdline_parse_token_string_t cmd_config_loopback_specific_item = 1851 TOKEN_STRING_INITIALIZER(struct cmd_config_loopback_specific, item, 1852 "loopback"); 1853 cmdline_parse_token_num_t cmd_config_loopback_specific_mode = 1854 TOKEN_NUM_INITIALIZER(struct cmd_config_loopback_specific, mode, 1855 UINT32); 1856 1857 cmdline_parse_inst_t cmd_config_loopback_specific = { 1858 .f = cmd_config_loopback_specific_parsed, 1859 .data = NULL, 1860 .help_str = "port config <port_id> loopback <mode>", 1861 .tokens = { 1862 (void *)&cmd_config_loopback_specific_port, 1863 (void *)&cmd_config_loopback_specific_keyword, 1864 (void *)&cmd_config_loopback_specific_id, 1865 (void *)&cmd_config_loopback_specific_item, 1866 (void *)&cmd_config_loopback_specific_mode, 1867 NULL, 1868 }, 1869 }; 1870 1871 /* *** configure txq/rxq, txd/rxd *** */ 1872 struct cmd_config_rx_tx { 1873 cmdline_fixed_string_t port; 1874 cmdline_fixed_string_t keyword; 1875 cmdline_fixed_string_t all; 1876 cmdline_fixed_string_t name; 1877 uint16_t value; 1878 }; 1879 1880 static void 1881 cmd_config_rx_tx_parsed(void *parsed_result, 1882 __attribute__((unused)) struct cmdline *cl, 1883 __attribute__((unused)) void *data) 1884 { 1885 struct cmd_config_rx_tx *res = parsed_result; 1886 1887 if (!all_ports_stopped()) { 1888 printf("Please stop all ports first\n"); 1889 return; 1890 } 1891 if (!strcmp(res->name, "rxq")) { 1892 if (!res->value && !nb_txq) { 1893 printf("Warning: Either rx or tx queues should be non zero\n"); 1894 return; 1895 } 1896 if (check_nb_rxq(res->value) != 0) 1897 return; 1898 nb_rxq = res->value; 1899 } 1900 else if (!strcmp(res->name, "txq")) { 1901 if (!res->value && !nb_rxq) { 1902 printf("Warning: Either rx or tx queues should be non zero\n"); 1903 return; 1904 } 1905 if (check_nb_txq(res->value) != 0) 1906 return; 1907 nb_txq = res->value; 1908 } 1909 else if (!strcmp(res->name, "rxd")) { 1910 if (res->value <= 0 || res->value > RTE_TEST_RX_DESC_MAX) { 1911 printf("rxd %d invalid - must be > 0 && <= %d\n", 1912 res->value, RTE_TEST_RX_DESC_MAX); 1913 return; 1914 } 1915 nb_rxd = res->value; 1916 } else if (!strcmp(res->name, "txd")) { 1917 if (res->value <= 0 || res->value > RTE_TEST_TX_DESC_MAX) { 1918 printf("txd %d invalid - must be > 0 && <= %d\n", 1919 res->value, RTE_TEST_TX_DESC_MAX); 1920 return; 1921 } 1922 nb_txd = res->value; 1923 } else { 1924 printf("Unknown parameter\n"); 1925 return; 1926 } 1927 1928 fwd_config_setup(); 1929 1930 init_port_config(); 1931 1932 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1); 1933 } 1934 1935 cmdline_parse_token_string_t cmd_config_rx_tx_port = 1936 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_tx, port, "port"); 1937 cmdline_parse_token_string_t cmd_config_rx_tx_keyword = 1938 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_tx, keyword, "config"); 1939 cmdline_parse_token_string_t cmd_config_rx_tx_all = 1940 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_tx, all, "all"); 1941 cmdline_parse_token_string_t cmd_config_rx_tx_name = 1942 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_tx, name, 1943 "rxq#txq#rxd#txd"); 1944 cmdline_parse_token_num_t cmd_config_rx_tx_value = 1945 TOKEN_NUM_INITIALIZER(struct cmd_config_rx_tx, value, UINT16); 1946 1947 cmdline_parse_inst_t cmd_config_rx_tx = { 1948 .f = cmd_config_rx_tx_parsed, 1949 .data = NULL, 1950 .help_str = "port config all rxq|txq|rxd|txd <value>", 1951 .tokens = { 1952 (void *)&cmd_config_rx_tx_port, 1953 (void *)&cmd_config_rx_tx_keyword, 1954 (void *)&cmd_config_rx_tx_all, 1955 (void *)&cmd_config_rx_tx_name, 1956 (void *)&cmd_config_rx_tx_value, 1957 NULL, 1958 }, 1959 }; 1960 1961 /* *** config max packet length *** */ 1962 struct cmd_config_max_pkt_len_result { 1963 cmdline_fixed_string_t port; 1964 cmdline_fixed_string_t keyword; 1965 cmdline_fixed_string_t all; 1966 cmdline_fixed_string_t name; 1967 uint32_t value; 1968 }; 1969 1970 static void 1971 cmd_config_max_pkt_len_parsed(void *parsed_result, 1972 __attribute__((unused)) struct cmdline *cl, 1973 __attribute__((unused)) void *data) 1974 { 1975 struct cmd_config_max_pkt_len_result *res = parsed_result; 1976 portid_t pid; 1977 1978 if (!all_ports_stopped()) { 1979 printf("Please stop all ports first\n"); 1980 return; 1981 } 1982 1983 RTE_ETH_FOREACH_DEV(pid) { 1984 struct rte_port *port = &ports[pid]; 1985 uint64_t rx_offloads = port->dev_conf.rxmode.offloads; 1986 1987 if (!strcmp(res->name, "max-pkt-len")) { 1988 if (res->value < RTE_ETHER_MIN_LEN) { 1989 printf("max-pkt-len can not be less than %d\n", 1990 RTE_ETHER_MIN_LEN); 1991 return; 1992 } 1993 if (res->value == port->dev_conf.rxmode.max_rx_pkt_len) 1994 return; 1995 1996 port->dev_conf.rxmode.max_rx_pkt_len = res->value; 1997 if (res->value > RTE_ETHER_MAX_LEN) 1998 rx_offloads |= DEV_RX_OFFLOAD_JUMBO_FRAME; 1999 else 2000 rx_offloads &= ~DEV_RX_OFFLOAD_JUMBO_FRAME; 2001 port->dev_conf.rxmode.offloads = rx_offloads; 2002 } else { 2003 printf("Unknown parameter\n"); 2004 return; 2005 } 2006 } 2007 2008 init_port_config(); 2009 2010 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1); 2011 } 2012 2013 cmdline_parse_token_string_t cmd_config_max_pkt_len_port = 2014 TOKEN_STRING_INITIALIZER(struct cmd_config_max_pkt_len_result, port, 2015 "port"); 2016 cmdline_parse_token_string_t cmd_config_max_pkt_len_keyword = 2017 TOKEN_STRING_INITIALIZER(struct cmd_config_max_pkt_len_result, keyword, 2018 "config"); 2019 cmdline_parse_token_string_t cmd_config_max_pkt_len_all = 2020 TOKEN_STRING_INITIALIZER(struct cmd_config_max_pkt_len_result, all, 2021 "all"); 2022 cmdline_parse_token_string_t cmd_config_max_pkt_len_name = 2023 TOKEN_STRING_INITIALIZER(struct cmd_config_max_pkt_len_result, name, 2024 "max-pkt-len"); 2025 cmdline_parse_token_num_t cmd_config_max_pkt_len_value = 2026 TOKEN_NUM_INITIALIZER(struct cmd_config_max_pkt_len_result, value, 2027 UINT32); 2028 2029 cmdline_parse_inst_t cmd_config_max_pkt_len = { 2030 .f = cmd_config_max_pkt_len_parsed, 2031 .data = NULL, 2032 .help_str = "port config all max-pkt-len <value>", 2033 .tokens = { 2034 (void *)&cmd_config_max_pkt_len_port, 2035 (void *)&cmd_config_max_pkt_len_keyword, 2036 (void *)&cmd_config_max_pkt_len_all, 2037 (void *)&cmd_config_max_pkt_len_name, 2038 (void *)&cmd_config_max_pkt_len_value, 2039 NULL, 2040 }, 2041 }; 2042 2043 /* *** configure port MTU *** */ 2044 struct cmd_config_mtu_result { 2045 cmdline_fixed_string_t port; 2046 cmdline_fixed_string_t keyword; 2047 cmdline_fixed_string_t mtu; 2048 portid_t port_id; 2049 uint16_t value; 2050 }; 2051 2052 static void 2053 cmd_config_mtu_parsed(void *parsed_result, 2054 __attribute__((unused)) struct cmdline *cl, 2055 __attribute__((unused)) void *data) 2056 { 2057 struct cmd_config_mtu_result *res = parsed_result; 2058 2059 if (res->value < RTE_ETHER_MIN_LEN) { 2060 printf("mtu cannot be less than %d\n", RTE_ETHER_MIN_LEN); 2061 return; 2062 } 2063 port_mtu_set(res->port_id, res->value); 2064 } 2065 2066 cmdline_parse_token_string_t cmd_config_mtu_port = 2067 TOKEN_STRING_INITIALIZER(struct cmd_config_mtu_result, port, 2068 "port"); 2069 cmdline_parse_token_string_t cmd_config_mtu_keyword = 2070 TOKEN_STRING_INITIALIZER(struct cmd_config_mtu_result, keyword, 2071 "config"); 2072 cmdline_parse_token_string_t cmd_config_mtu_mtu = 2073 TOKEN_STRING_INITIALIZER(struct cmd_config_mtu_result, keyword, 2074 "mtu"); 2075 cmdline_parse_token_num_t cmd_config_mtu_port_id = 2076 TOKEN_NUM_INITIALIZER(struct cmd_config_mtu_result, port_id, UINT16); 2077 cmdline_parse_token_num_t cmd_config_mtu_value = 2078 TOKEN_NUM_INITIALIZER(struct cmd_config_mtu_result, value, UINT16); 2079 2080 cmdline_parse_inst_t cmd_config_mtu = { 2081 .f = cmd_config_mtu_parsed, 2082 .data = NULL, 2083 .help_str = "port config mtu <port_id> <value>", 2084 .tokens = { 2085 (void *)&cmd_config_mtu_port, 2086 (void *)&cmd_config_mtu_keyword, 2087 (void *)&cmd_config_mtu_mtu, 2088 (void *)&cmd_config_mtu_port_id, 2089 (void *)&cmd_config_mtu_value, 2090 NULL, 2091 }, 2092 }; 2093 2094 /* *** configure rx mode *** */ 2095 struct cmd_config_rx_mode_flag { 2096 cmdline_fixed_string_t port; 2097 cmdline_fixed_string_t keyword; 2098 cmdline_fixed_string_t all; 2099 cmdline_fixed_string_t name; 2100 cmdline_fixed_string_t value; 2101 }; 2102 2103 static void 2104 cmd_config_rx_mode_flag_parsed(void *parsed_result, 2105 __attribute__((unused)) struct cmdline *cl, 2106 __attribute__((unused)) void *data) 2107 { 2108 struct cmd_config_rx_mode_flag *res = parsed_result; 2109 2110 if (!all_ports_stopped()) { 2111 printf("Please stop all ports first\n"); 2112 return; 2113 } 2114 2115 if (!strcmp(res->name, "drop-en")) { 2116 if (!strcmp(res->value, "on")) 2117 rx_drop_en = 1; 2118 else if (!strcmp(res->value, "off")) 2119 rx_drop_en = 0; 2120 else { 2121 printf("Unknown parameter\n"); 2122 return; 2123 } 2124 } else { 2125 printf("Unknown parameter\n"); 2126 return; 2127 } 2128 2129 init_port_config(); 2130 2131 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1); 2132 } 2133 2134 cmdline_parse_token_string_t cmd_config_rx_mode_flag_port = 2135 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_mode_flag, port, "port"); 2136 cmdline_parse_token_string_t cmd_config_rx_mode_flag_keyword = 2137 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_mode_flag, keyword, 2138 "config"); 2139 cmdline_parse_token_string_t cmd_config_rx_mode_flag_all = 2140 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_mode_flag, all, "all"); 2141 cmdline_parse_token_string_t cmd_config_rx_mode_flag_name = 2142 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_mode_flag, name, 2143 "drop-en"); 2144 cmdline_parse_token_string_t cmd_config_rx_mode_flag_value = 2145 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_mode_flag, value, 2146 "on#off"); 2147 2148 cmdline_parse_inst_t cmd_config_rx_mode_flag = { 2149 .f = cmd_config_rx_mode_flag_parsed, 2150 .data = NULL, 2151 .help_str = "port config all drop-en on|off", 2152 .tokens = { 2153 (void *)&cmd_config_rx_mode_flag_port, 2154 (void *)&cmd_config_rx_mode_flag_keyword, 2155 (void *)&cmd_config_rx_mode_flag_all, 2156 (void *)&cmd_config_rx_mode_flag_name, 2157 (void *)&cmd_config_rx_mode_flag_value, 2158 NULL, 2159 }, 2160 }; 2161 2162 /* *** configure rss *** */ 2163 struct cmd_config_rss { 2164 cmdline_fixed_string_t port; 2165 cmdline_fixed_string_t keyword; 2166 cmdline_fixed_string_t all; 2167 cmdline_fixed_string_t name; 2168 cmdline_fixed_string_t value; 2169 }; 2170 2171 static void 2172 cmd_config_rss_parsed(void *parsed_result, 2173 __attribute__((unused)) struct cmdline *cl, 2174 __attribute__((unused)) void *data) 2175 { 2176 struct cmd_config_rss *res = parsed_result; 2177 struct rte_eth_rss_conf rss_conf = { .rss_key_len = 0, }; 2178 struct rte_eth_dev_info dev_info = { .flow_type_rss_offloads = 0, }; 2179 int use_default = 0; 2180 int all_updated = 1; 2181 int diag; 2182 uint16_t i; 2183 int ret; 2184 2185 if (!strcmp(res->value, "all")) 2186 rss_conf.rss_hf = ETH_RSS_IP | ETH_RSS_TCP | 2187 ETH_RSS_UDP | ETH_RSS_SCTP | 2188 ETH_RSS_L2_PAYLOAD; 2189 else if (!strcmp(res->value, "ip")) 2190 rss_conf.rss_hf = ETH_RSS_IP; 2191 else if (!strcmp(res->value, "udp")) 2192 rss_conf.rss_hf = ETH_RSS_UDP; 2193 else if (!strcmp(res->value, "tcp")) 2194 rss_conf.rss_hf = ETH_RSS_TCP; 2195 else if (!strcmp(res->value, "sctp")) 2196 rss_conf.rss_hf = ETH_RSS_SCTP; 2197 else if (!strcmp(res->value, "ether")) 2198 rss_conf.rss_hf = ETH_RSS_L2_PAYLOAD; 2199 else if (!strcmp(res->value, "port")) 2200 rss_conf.rss_hf = ETH_RSS_PORT; 2201 else if (!strcmp(res->value, "vxlan")) 2202 rss_conf.rss_hf = ETH_RSS_VXLAN; 2203 else if (!strcmp(res->value, "geneve")) 2204 rss_conf.rss_hf = ETH_RSS_GENEVE; 2205 else if (!strcmp(res->value, "nvgre")) 2206 rss_conf.rss_hf = ETH_RSS_NVGRE; 2207 else if (!strcmp(res->value, "none")) 2208 rss_conf.rss_hf = 0; 2209 else if (!strcmp(res->value, "default")) 2210 use_default = 1; 2211 else if (isdigit(res->value[0]) && atoi(res->value) > 0 && 2212 atoi(res->value) < 64) 2213 rss_conf.rss_hf = 1ULL << atoi(res->value); 2214 else { 2215 printf("Unknown parameter\n"); 2216 return; 2217 } 2218 rss_conf.rss_key = NULL; 2219 /* Update global configuration for RSS types. */ 2220 RTE_ETH_FOREACH_DEV(i) { 2221 struct rte_eth_rss_conf local_rss_conf; 2222 2223 ret = eth_dev_info_get_print_err(i, &dev_info); 2224 if (ret != 0) 2225 return; 2226 2227 if (use_default) 2228 rss_conf.rss_hf = dev_info.flow_type_rss_offloads; 2229 2230 local_rss_conf = rss_conf; 2231 local_rss_conf.rss_hf = rss_conf.rss_hf & 2232 dev_info.flow_type_rss_offloads; 2233 if (local_rss_conf.rss_hf != rss_conf.rss_hf) { 2234 printf("Port %u modified RSS hash function based on hardware support," 2235 "requested:%#"PRIx64" configured:%#"PRIx64"\n", 2236 i, rss_conf.rss_hf, local_rss_conf.rss_hf); 2237 } 2238 diag = rte_eth_dev_rss_hash_update(i, &local_rss_conf); 2239 if (diag < 0) { 2240 all_updated = 0; 2241 printf("Configuration of RSS hash at ethernet port %d " 2242 "failed with error (%d): %s.\n", 2243 i, -diag, strerror(-diag)); 2244 } 2245 } 2246 if (all_updated && !use_default) 2247 rss_hf = rss_conf.rss_hf; 2248 } 2249 2250 cmdline_parse_token_string_t cmd_config_rss_port = 2251 TOKEN_STRING_INITIALIZER(struct cmd_config_rss, port, "port"); 2252 cmdline_parse_token_string_t cmd_config_rss_keyword = 2253 TOKEN_STRING_INITIALIZER(struct cmd_config_rss, keyword, "config"); 2254 cmdline_parse_token_string_t cmd_config_rss_all = 2255 TOKEN_STRING_INITIALIZER(struct cmd_config_rss, all, "all"); 2256 cmdline_parse_token_string_t cmd_config_rss_name = 2257 TOKEN_STRING_INITIALIZER(struct cmd_config_rss, name, "rss"); 2258 cmdline_parse_token_string_t cmd_config_rss_value = 2259 TOKEN_STRING_INITIALIZER(struct cmd_config_rss, value, NULL); 2260 2261 cmdline_parse_inst_t cmd_config_rss = { 2262 .f = cmd_config_rss_parsed, 2263 .data = NULL, 2264 .help_str = "port config all rss " 2265 "all|default|ip|tcp|udp|sctp|ether|port|vxlan|geneve|nvgre|vxlan-gpe|none|<flowtype_id>", 2266 .tokens = { 2267 (void *)&cmd_config_rss_port, 2268 (void *)&cmd_config_rss_keyword, 2269 (void *)&cmd_config_rss_all, 2270 (void *)&cmd_config_rss_name, 2271 (void *)&cmd_config_rss_value, 2272 NULL, 2273 }, 2274 }; 2275 2276 /* *** configure rss hash key *** */ 2277 struct cmd_config_rss_hash_key { 2278 cmdline_fixed_string_t port; 2279 cmdline_fixed_string_t config; 2280 portid_t port_id; 2281 cmdline_fixed_string_t rss_hash_key; 2282 cmdline_fixed_string_t rss_type; 2283 cmdline_fixed_string_t key; 2284 }; 2285 2286 static uint8_t 2287 hexa_digit_to_value(char hexa_digit) 2288 { 2289 if ((hexa_digit >= '0') && (hexa_digit <= '9')) 2290 return (uint8_t) (hexa_digit - '0'); 2291 if ((hexa_digit >= 'a') && (hexa_digit <= 'f')) 2292 return (uint8_t) ((hexa_digit - 'a') + 10); 2293 if ((hexa_digit >= 'A') && (hexa_digit <= 'F')) 2294 return (uint8_t) ((hexa_digit - 'A') + 10); 2295 /* Invalid hexa digit */ 2296 return 0xFF; 2297 } 2298 2299 static uint8_t 2300 parse_and_check_key_hexa_digit(char *key, int idx) 2301 { 2302 uint8_t hexa_v; 2303 2304 hexa_v = hexa_digit_to_value(key[idx]); 2305 if (hexa_v == 0xFF) 2306 printf("invalid key: character %c at position %d is not a " 2307 "valid hexa digit\n", key[idx], idx); 2308 return hexa_v; 2309 } 2310 2311 static void 2312 cmd_config_rss_hash_key_parsed(void *parsed_result, 2313 __attribute__((unused)) struct cmdline *cl, 2314 __attribute__((unused)) void *data) 2315 { 2316 struct cmd_config_rss_hash_key *res = parsed_result; 2317 uint8_t hash_key[RSS_HASH_KEY_LENGTH]; 2318 uint8_t xdgt0; 2319 uint8_t xdgt1; 2320 int i; 2321 struct rte_eth_dev_info dev_info; 2322 uint8_t hash_key_size; 2323 uint32_t key_len; 2324 int ret; 2325 2326 ret = eth_dev_info_get_print_err(res->port_id, &dev_info); 2327 if (ret != 0) 2328 return; 2329 2330 if (dev_info.hash_key_size > 0 && 2331 dev_info.hash_key_size <= sizeof(hash_key)) 2332 hash_key_size = dev_info.hash_key_size; 2333 else { 2334 printf("dev_info did not provide a valid hash key size\n"); 2335 return; 2336 } 2337 /* Check the length of the RSS hash key */ 2338 key_len = strlen(res->key); 2339 if (key_len != (hash_key_size * 2)) { 2340 printf("key length: %d invalid - key must be a string of %d" 2341 " hexa-decimal numbers\n", 2342 (int) key_len, hash_key_size * 2); 2343 return; 2344 } 2345 /* Translate RSS hash key into binary representation */ 2346 for (i = 0; i < hash_key_size; i++) { 2347 xdgt0 = parse_and_check_key_hexa_digit(res->key, (i * 2)); 2348 if (xdgt0 == 0xFF) 2349 return; 2350 xdgt1 = parse_and_check_key_hexa_digit(res->key, (i * 2) + 1); 2351 if (xdgt1 == 0xFF) 2352 return; 2353 hash_key[i] = (uint8_t) ((xdgt0 * 16) + xdgt1); 2354 } 2355 port_rss_hash_key_update(res->port_id, res->rss_type, hash_key, 2356 hash_key_size); 2357 } 2358 2359 cmdline_parse_token_string_t cmd_config_rss_hash_key_port = 2360 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_hash_key, port, "port"); 2361 cmdline_parse_token_string_t cmd_config_rss_hash_key_config = 2362 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_hash_key, config, 2363 "config"); 2364 cmdline_parse_token_num_t cmd_config_rss_hash_key_port_id = 2365 TOKEN_NUM_INITIALIZER(struct cmd_config_rss_hash_key, port_id, UINT16); 2366 cmdline_parse_token_string_t cmd_config_rss_hash_key_rss_hash_key = 2367 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_hash_key, 2368 rss_hash_key, "rss-hash-key"); 2369 cmdline_parse_token_string_t cmd_config_rss_hash_key_rss_type = 2370 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_hash_key, rss_type, 2371 "ipv4#ipv4-frag#ipv4-tcp#ipv4-udp#ipv4-sctp#" 2372 "ipv4-other#ipv6#ipv6-frag#ipv6-tcp#ipv6-udp#" 2373 "ipv6-sctp#ipv6-other#l2-payload#ipv6-ex#" 2374 "ipv6-tcp-ex#ipv6-udp-ex"); 2375 cmdline_parse_token_string_t cmd_config_rss_hash_key_value = 2376 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_hash_key, key, NULL); 2377 2378 cmdline_parse_inst_t cmd_config_rss_hash_key = { 2379 .f = cmd_config_rss_hash_key_parsed, 2380 .data = NULL, 2381 .help_str = "port config <port_id> rss-hash-key " 2382 "ipv4|ipv4-frag|ipv4-tcp|ipv4-udp|ipv4-sctp|ipv4-other|" 2383 "ipv6|ipv6-frag|ipv6-tcp|ipv6-udp|ipv6-sctp|ipv6-other|" 2384 "l2-payload|ipv6-ex|ipv6-tcp-ex|ipv6-udp-ex " 2385 "<string of hex digits (variable length, NIC dependent)>", 2386 .tokens = { 2387 (void *)&cmd_config_rss_hash_key_port, 2388 (void *)&cmd_config_rss_hash_key_config, 2389 (void *)&cmd_config_rss_hash_key_port_id, 2390 (void *)&cmd_config_rss_hash_key_rss_hash_key, 2391 (void *)&cmd_config_rss_hash_key_rss_type, 2392 (void *)&cmd_config_rss_hash_key_value, 2393 NULL, 2394 }, 2395 }; 2396 2397 /* *** configure port rxq/txq ring size *** */ 2398 struct cmd_config_rxtx_ring_size { 2399 cmdline_fixed_string_t port; 2400 cmdline_fixed_string_t config; 2401 portid_t portid; 2402 cmdline_fixed_string_t rxtxq; 2403 uint16_t qid; 2404 cmdline_fixed_string_t rsize; 2405 uint16_t size; 2406 }; 2407 2408 static void 2409 cmd_config_rxtx_ring_size_parsed(void *parsed_result, 2410 __attribute__((unused)) struct cmdline *cl, 2411 __attribute__((unused)) void *data) 2412 { 2413 struct cmd_config_rxtx_ring_size *res = parsed_result; 2414 struct rte_port *port; 2415 uint8_t isrx; 2416 2417 if (port_id_is_invalid(res->portid, ENABLED_WARN)) 2418 return; 2419 2420 if (res->portid == (portid_t)RTE_PORT_ALL) { 2421 printf("Invalid port id\n"); 2422 return; 2423 } 2424 2425 port = &ports[res->portid]; 2426 2427 if (!strcmp(res->rxtxq, "rxq")) 2428 isrx = 1; 2429 else if (!strcmp(res->rxtxq, "txq")) 2430 isrx = 0; 2431 else { 2432 printf("Unknown parameter\n"); 2433 return; 2434 } 2435 2436 if (isrx && rx_queue_id_is_invalid(res->qid)) 2437 return; 2438 else if (!isrx && tx_queue_id_is_invalid(res->qid)) 2439 return; 2440 2441 if (isrx && res->size != 0 && res->size <= rx_free_thresh) { 2442 printf("Invalid rx ring_size, must > rx_free_thresh: %d\n", 2443 rx_free_thresh); 2444 return; 2445 } 2446 2447 if (isrx) 2448 port->nb_rx_desc[res->qid] = res->size; 2449 else 2450 port->nb_tx_desc[res->qid] = res->size; 2451 2452 cmd_reconfig_device_queue(res->portid, 0, 1); 2453 } 2454 2455 cmdline_parse_token_string_t cmd_config_rxtx_ring_size_port = 2456 TOKEN_STRING_INITIALIZER(struct cmd_config_rxtx_ring_size, 2457 port, "port"); 2458 cmdline_parse_token_string_t cmd_config_rxtx_ring_size_config = 2459 TOKEN_STRING_INITIALIZER(struct cmd_config_rxtx_ring_size, 2460 config, "config"); 2461 cmdline_parse_token_num_t cmd_config_rxtx_ring_size_portid = 2462 TOKEN_NUM_INITIALIZER(struct cmd_config_rxtx_ring_size, 2463 portid, UINT16); 2464 cmdline_parse_token_string_t cmd_config_rxtx_ring_size_rxtxq = 2465 TOKEN_STRING_INITIALIZER(struct cmd_config_rxtx_ring_size, 2466 rxtxq, "rxq#txq"); 2467 cmdline_parse_token_num_t cmd_config_rxtx_ring_size_qid = 2468 TOKEN_NUM_INITIALIZER(struct cmd_config_rxtx_ring_size, 2469 qid, UINT16); 2470 cmdline_parse_token_string_t cmd_config_rxtx_ring_size_rsize = 2471 TOKEN_STRING_INITIALIZER(struct cmd_config_rxtx_ring_size, 2472 rsize, "ring_size"); 2473 cmdline_parse_token_num_t cmd_config_rxtx_ring_size_size = 2474 TOKEN_NUM_INITIALIZER(struct cmd_config_rxtx_ring_size, 2475 size, UINT16); 2476 2477 cmdline_parse_inst_t cmd_config_rxtx_ring_size = { 2478 .f = cmd_config_rxtx_ring_size_parsed, 2479 .data = NULL, 2480 .help_str = "port config <port_id> rxq|txq <queue_id> ring_size <value>", 2481 .tokens = { 2482 (void *)&cmd_config_rxtx_ring_size_port, 2483 (void *)&cmd_config_rxtx_ring_size_config, 2484 (void *)&cmd_config_rxtx_ring_size_portid, 2485 (void *)&cmd_config_rxtx_ring_size_rxtxq, 2486 (void *)&cmd_config_rxtx_ring_size_qid, 2487 (void *)&cmd_config_rxtx_ring_size_rsize, 2488 (void *)&cmd_config_rxtx_ring_size_size, 2489 NULL, 2490 }, 2491 }; 2492 2493 /* *** configure port rxq/txq start/stop *** */ 2494 struct cmd_config_rxtx_queue { 2495 cmdline_fixed_string_t port; 2496 portid_t portid; 2497 cmdline_fixed_string_t rxtxq; 2498 uint16_t qid; 2499 cmdline_fixed_string_t opname; 2500 }; 2501 2502 static void 2503 cmd_config_rxtx_queue_parsed(void *parsed_result, 2504 __attribute__((unused)) struct cmdline *cl, 2505 __attribute__((unused)) void *data) 2506 { 2507 struct cmd_config_rxtx_queue *res = parsed_result; 2508 uint8_t isrx; 2509 uint8_t isstart; 2510 int ret = 0; 2511 2512 if (test_done == 0) { 2513 printf("Please stop forwarding first\n"); 2514 return; 2515 } 2516 2517 if (port_id_is_invalid(res->portid, ENABLED_WARN)) 2518 return; 2519 2520 if (port_is_started(res->portid) != 1) { 2521 printf("Please start port %u first\n", res->portid); 2522 return; 2523 } 2524 2525 if (!strcmp(res->rxtxq, "rxq")) 2526 isrx = 1; 2527 else if (!strcmp(res->rxtxq, "txq")) 2528 isrx = 0; 2529 else { 2530 printf("Unknown parameter\n"); 2531 return; 2532 } 2533 2534 if (isrx && rx_queue_id_is_invalid(res->qid)) 2535 return; 2536 else if (!isrx && tx_queue_id_is_invalid(res->qid)) 2537 return; 2538 2539 if (!strcmp(res->opname, "start")) 2540 isstart = 1; 2541 else if (!strcmp(res->opname, "stop")) 2542 isstart = 0; 2543 else { 2544 printf("Unknown parameter\n"); 2545 return; 2546 } 2547 2548 if (isstart && isrx) 2549 ret = rte_eth_dev_rx_queue_start(res->portid, res->qid); 2550 else if (!isstart && isrx) 2551 ret = rte_eth_dev_rx_queue_stop(res->portid, res->qid); 2552 else if (isstart && !isrx) 2553 ret = rte_eth_dev_tx_queue_start(res->portid, res->qid); 2554 else 2555 ret = rte_eth_dev_tx_queue_stop(res->portid, res->qid); 2556 2557 if (ret == -ENOTSUP) 2558 printf("Function not supported in PMD driver\n"); 2559 } 2560 2561 cmdline_parse_token_string_t cmd_config_rxtx_queue_port = 2562 TOKEN_STRING_INITIALIZER(struct cmd_config_rxtx_queue, port, "port"); 2563 cmdline_parse_token_num_t cmd_config_rxtx_queue_portid = 2564 TOKEN_NUM_INITIALIZER(struct cmd_config_rxtx_queue, portid, UINT16); 2565 cmdline_parse_token_string_t cmd_config_rxtx_queue_rxtxq = 2566 TOKEN_STRING_INITIALIZER(struct cmd_config_rxtx_queue, rxtxq, "rxq#txq"); 2567 cmdline_parse_token_num_t cmd_config_rxtx_queue_qid = 2568 TOKEN_NUM_INITIALIZER(struct cmd_config_rxtx_queue, qid, UINT16); 2569 cmdline_parse_token_string_t cmd_config_rxtx_queue_opname = 2570 TOKEN_STRING_INITIALIZER(struct cmd_config_rxtx_queue, opname, 2571 "start#stop"); 2572 2573 cmdline_parse_inst_t cmd_config_rxtx_queue = { 2574 .f = cmd_config_rxtx_queue_parsed, 2575 .data = NULL, 2576 .help_str = "port <port_id> rxq|txq <queue_id> start|stop", 2577 .tokens = { 2578 (void *)&cmd_config_rxtx_queue_port, 2579 (void *)&cmd_config_rxtx_queue_portid, 2580 (void *)&cmd_config_rxtx_queue_rxtxq, 2581 (void *)&cmd_config_rxtx_queue_qid, 2582 (void *)&cmd_config_rxtx_queue_opname, 2583 NULL, 2584 }, 2585 }; 2586 2587 /* *** configure port rxq/txq deferred start on/off *** */ 2588 struct cmd_config_deferred_start_rxtx_queue { 2589 cmdline_fixed_string_t port; 2590 portid_t port_id; 2591 cmdline_fixed_string_t rxtxq; 2592 uint16_t qid; 2593 cmdline_fixed_string_t opname; 2594 cmdline_fixed_string_t state; 2595 }; 2596 2597 static void 2598 cmd_config_deferred_start_rxtx_queue_parsed(void *parsed_result, 2599 __attribute__((unused)) struct cmdline *cl, 2600 __attribute__((unused)) void *data) 2601 { 2602 struct cmd_config_deferred_start_rxtx_queue *res = parsed_result; 2603 struct rte_port *port; 2604 uint8_t isrx; 2605 uint8_t ison; 2606 uint8_t needreconfig = 0; 2607 2608 if (port_id_is_invalid(res->port_id, ENABLED_WARN)) 2609 return; 2610 2611 if (port_is_started(res->port_id) != 0) { 2612 printf("Please stop port %u first\n", res->port_id); 2613 return; 2614 } 2615 2616 port = &ports[res->port_id]; 2617 2618 isrx = !strcmp(res->rxtxq, "rxq"); 2619 2620 if (isrx && rx_queue_id_is_invalid(res->qid)) 2621 return; 2622 else if (!isrx && tx_queue_id_is_invalid(res->qid)) 2623 return; 2624 2625 ison = !strcmp(res->state, "on"); 2626 2627 if (isrx && port->rx_conf[res->qid].rx_deferred_start != ison) { 2628 port->rx_conf[res->qid].rx_deferred_start = ison; 2629 needreconfig = 1; 2630 } else if (!isrx && port->tx_conf[res->qid].tx_deferred_start != ison) { 2631 port->tx_conf[res->qid].tx_deferred_start = ison; 2632 needreconfig = 1; 2633 } 2634 2635 if (needreconfig) 2636 cmd_reconfig_device_queue(res->port_id, 0, 1); 2637 } 2638 2639 cmdline_parse_token_string_t cmd_config_deferred_start_rxtx_queue_port = 2640 TOKEN_STRING_INITIALIZER(struct cmd_config_deferred_start_rxtx_queue, 2641 port, "port"); 2642 cmdline_parse_token_num_t cmd_config_deferred_start_rxtx_queue_port_id = 2643 TOKEN_NUM_INITIALIZER(struct cmd_config_deferred_start_rxtx_queue, 2644 port_id, UINT16); 2645 cmdline_parse_token_string_t cmd_config_deferred_start_rxtx_queue_rxtxq = 2646 TOKEN_STRING_INITIALIZER(struct cmd_config_deferred_start_rxtx_queue, 2647 rxtxq, "rxq#txq"); 2648 cmdline_parse_token_num_t cmd_config_deferred_start_rxtx_queue_qid = 2649 TOKEN_NUM_INITIALIZER(struct cmd_config_deferred_start_rxtx_queue, 2650 qid, UINT16); 2651 cmdline_parse_token_string_t cmd_config_deferred_start_rxtx_queue_opname = 2652 TOKEN_STRING_INITIALIZER(struct cmd_config_deferred_start_rxtx_queue, 2653 opname, "deferred_start"); 2654 cmdline_parse_token_string_t cmd_config_deferred_start_rxtx_queue_state = 2655 TOKEN_STRING_INITIALIZER(struct cmd_config_deferred_start_rxtx_queue, 2656 state, "on#off"); 2657 2658 cmdline_parse_inst_t cmd_config_deferred_start_rxtx_queue = { 2659 .f = cmd_config_deferred_start_rxtx_queue_parsed, 2660 .data = NULL, 2661 .help_str = "port <port_id> rxq|txq <queue_id> deferred_start on|off", 2662 .tokens = { 2663 (void *)&cmd_config_deferred_start_rxtx_queue_port, 2664 (void *)&cmd_config_deferred_start_rxtx_queue_port_id, 2665 (void *)&cmd_config_deferred_start_rxtx_queue_rxtxq, 2666 (void *)&cmd_config_deferred_start_rxtx_queue_qid, 2667 (void *)&cmd_config_deferred_start_rxtx_queue_opname, 2668 (void *)&cmd_config_deferred_start_rxtx_queue_state, 2669 NULL, 2670 }, 2671 }; 2672 2673 /* *** configure port rxq/txq setup *** */ 2674 struct cmd_setup_rxtx_queue { 2675 cmdline_fixed_string_t port; 2676 portid_t portid; 2677 cmdline_fixed_string_t rxtxq; 2678 uint16_t qid; 2679 cmdline_fixed_string_t setup; 2680 }; 2681 2682 /* Common CLI fields for queue setup */ 2683 cmdline_parse_token_string_t cmd_setup_rxtx_queue_port = 2684 TOKEN_STRING_INITIALIZER(struct cmd_setup_rxtx_queue, port, "port"); 2685 cmdline_parse_token_num_t cmd_setup_rxtx_queue_portid = 2686 TOKEN_NUM_INITIALIZER(struct cmd_setup_rxtx_queue, portid, UINT16); 2687 cmdline_parse_token_string_t cmd_setup_rxtx_queue_rxtxq = 2688 TOKEN_STRING_INITIALIZER(struct cmd_setup_rxtx_queue, rxtxq, "rxq#txq"); 2689 cmdline_parse_token_num_t cmd_setup_rxtx_queue_qid = 2690 TOKEN_NUM_INITIALIZER(struct cmd_setup_rxtx_queue, qid, UINT16); 2691 cmdline_parse_token_string_t cmd_setup_rxtx_queue_setup = 2692 TOKEN_STRING_INITIALIZER(struct cmd_setup_rxtx_queue, setup, "setup"); 2693 2694 static void 2695 cmd_setup_rxtx_queue_parsed( 2696 void *parsed_result, 2697 __attribute__((unused)) struct cmdline *cl, 2698 __attribute__((unused)) void *data) 2699 { 2700 struct cmd_setup_rxtx_queue *res = parsed_result; 2701 struct rte_port *port; 2702 struct rte_mempool *mp; 2703 unsigned int socket_id; 2704 uint8_t isrx = 0; 2705 int ret; 2706 2707 if (port_id_is_invalid(res->portid, ENABLED_WARN)) 2708 return; 2709 2710 if (res->portid == (portid_t)RTE_PORT_ALL) { 2711 printf("Invalid port id\n"); 2712 return; 2713 } 2714 2715 if (!strcmp(res->rxtxq, "rxq")) 2716 isrx = 1; 2717 else if (!strcmp(res->rxtxq, "txq")) 2718 isrx = 0; 2719 else { 2720 printf("Unknown parameter\n"); 2721 return; 2722 } 2723 2724 if (isrx && rx_queue_id_is_invalid(res->qid)) { 2725 printf("Invalid rx queue\n"); 2726 return; 2727 } else if (!isrx && tx_queue_id_is_invalid(res->qid)) { 2728 printf("Invalid tx queue\n"); 2729 return; 2730 } 2731 2732 port = &ports[res->portid]; 2733 if (isrx) { 2734 socket_id = rxring_numa[res->portid]; 2735 if (!numa_support || socket_id == NUMA_NO_CONFIG) 2736 socket_id = port->socket_id; 2737 2738 mp = mbuf_pool_find(socket_id); 2739 if (mp == NULL) { 2740 printf("Failed to setup RX queue: " 2741 "No mempool allocation" 2742 " on the socket %d\n", 2743 rxring_numa[res->portid]); 2744 return; 2745 } 2746 ret = rte_eth_rx_queue_setup(res->portid, 2747 res->qid, 2748 port->nb_rx_desc[res->qid], 2749 socket_id, 2750 &port->rx_conf[res->qid], 2751 mp); 2752 if (ret) 2753 printf("Failed to setup RX queue\n"); 2754 } else { 2755 socket_id = txring_numa[res->portid]; 2756 if (!numa_support || socket_id == NUMA_NO_CONFIG) 2757 socket_id = port->socket_id; 2758 2759 ret = rte_eth_tx_queue_setup(res->portid, 2760 res->qid, 2761 port->nb_tx_desc[res->qid], 2762 socket_id, 2763 &port->tx_conf[res->qid]); 2764 if (ret) 2765 printf("Failed to setup TX queue\n"); 2766 } 2767 } 2768 2769 cmdline_parse_inst_t cmd_setup_rxtx_queue = { 2770 .f = cmd_setup_rxtx_queue_parsed, 2771 .data = NULL, 2772 .help_str = "port <port_id> rxq|txq <queue_idx> setup", 2773 .tokens = { 2774 (void *)&cmd_setup_rxtx_queue_port, 2775 (void *)&cmd_setup_rxtx_queue_portid, 2776 (void *)&cmd_setup_rxtx_queue_rxtxq, 2777 (void *)&cmd_setup_rxtx_queue_qid, 2778 (void *)&cmd_setup_rxtx_queue_setup, 2779 NULL, 2780 }, 2781 }; 2782 2783 2784 /* *** Configure RSS RETA *** */ 2785 struct cmd_config_rss_reta { 2786 cmdline_fixed_string_t port; 2787 cmdline_fixed_string_t keyword; 2788 portid_t port_id; 2789 cmdline_fixed_string_t name; 2790 cmdline_fixed_string_t list_name; 2791 cmdline_fixed_string_t list_of_items; 2792 }; 2793 2794 static int 2795 parse_reta_config(const char *str, 2796 struct rte_eth_rss_reta_entry64 *reta_conf, 2797 uint16_t nb_entries) 2798 { 2799 int i; 2800 unsigned size; 2801 uint16_t hash_index, idx, shift; 2802 uint16_t nb_queue; 2803 char s[256]; 2804 const char *p, *p0 = str; 2805 char *end; 2806 enum fieldnames { 2807 FLD_HASH_INDEX = 0, 2808 FLD_QUEUE, 2809 _NUM_FLD 2810 }; 2811 unsigned long int_fld[_NUM_FLD]; 2812 char *str_fld[_NUM_FLD]; 2813 2814 while ((p = strchr(p0,'(')) != NULL) { 2815 ++p; 2816 if((p0 = strchr(p,')')) == NULL) 2817 return -1; 2818 2819 size = p0 - p; 2820 if(size >= sizeof(s)) 2821 return -1; 2822 2823 snprintf(s, sizeof(s), "%.*s", size, p); 2824 if (rte_strsplit(s, sizeof(s), str_fld, _NUM_FLD, ',') != _NUM_FLD) 2825 return -1; 2826 for (i = 0; i < _NUM_FLD; i++) { 2827 errno = 0; 2828 int_fld[i] = strtoul(str_fld[i], &end, 0); 2829 if (errno != 0 || end == str_fld[i] || 2830 int_fld[i] > 65535) 2831 return -1; 2832 } 2833 2834 hash_index = (uint16_t)int_fld[FLD_HASH_INDEX]; 2835 nb_queue = (uint16_t)int_fld[FLD_QUEUE]; 2836 2837 if (hash_index >= nb_entries) { 2838 printf("Invalid RETA hash index=%d\n", hash_index); 2839 return -1; 2840 } 2841 2842 idx = hash_index / RTE_RETA_GROUP_SIZE; 2843 shift = hash_index % RTE_RETA_GROUP_SIZE; 2844 reta_conf[idx].mask |= (1ULL << shift); 2845 reta_conf[idx].reta[shift] = nb_queue; 2846 } 2847 2848 return 0; 2849 } 2850 2851 static void 2852 cmd_set_rss_reta_parsed(void *parsed_result, 2853 __attribute__((unused)) struct cmdline *cl, 2854 __attribute__((unused)) void *data) 2855 { 2856 int ret; 2857 struct rte_eth_dev_info dev_info; 2858 struct rte_eth_rss_reta_entry64 reta_conf[8]; 2859 struct cmd_config_rss_reta *res = parsed_result; 2860 2861 ret = eth_dev_info_get_print_err(res->port_id, &dev_info); 2862 if (ret != 0) 2863 return; 2864 2865 if (dev_info.reta_size == 0) { 2866 printf("Redirection table size is 0 which is " 2867 "invalid for RSS\n"); 2868 return; 2869 } else 2870 printf("The reta size of port %d is %u\n", 2871 res->port_id, dev_info.reta_size); 2872 if (dev_info.reta_size > ETH_RSS_RETA_SIZE_512) { 2873 printf("Currently do not support more than %u entries of " 2874 "redirection table\n", ETH_RSS_RETA_SIZE_512); 2875 return; 2876 } 2877 2878 memset(reta_conf, 0, sizeof(reta_conf)); 2879 if (!strcmp(res->list_name, "reta")) { 2880 if (parse_reta_config(res->list_of_items, reta_conf, 2881 dev_info.reta_size)) { 2882 printf("Invalid RSS Redirection Table " 2883 "config entered\n"); 2884 return; 2885 } 2886 ret = rte_eth_dev_rss_reta_update(res->port_id, 2887 reta_conf, dev_info.reta_size); 2888 if (ret != 0) 2889 printf("Bad redirection table parameter, " 2890 "return code = %d \n", ret); 2891 } 2892 } 2893 2894 cmdline_parse_token_string_t cmd_config_rss_reta_port = 2895 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_reta, port, "port"); 2896 cmdline_parse_token_string_t cmd_config_rss_reta_keyword = 2897 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_reta, keyword, "config"); 2898 cmdline_parse_token_num_t cmd_config_rss_reta_port_id = 2899 TOKEN_NUM_INITIALIZER(struct cmd_config_rss_reta, port_id, UINT16); 2900 cmdline_parse_token_string_t cmd_config_rss_reta_name = 2901 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_reta, name, "rss"); 2902 cmdline_parse_token_string_t cmd_config_rss_reta_list_name = 2903 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_reta, list_name, "reta"); 2904 cmdline_parse_token_string_t cmd_config_rss_reta_list_of_items = 2905 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_reta, list_of_items, 2906 NULL); 2907 cmdline_parse_inst_t cmd_config_rss_reta = { 2908 .f = cmd_set_rss_reta_parsed, 2909 .data = NULL, 2910 .help_str = "port config <port_id> rss reta <hash,queue[,hash,queue]*>", 2911 .tokens = { 2912 (void *)&cmd_config_rss_reta_port, 2913 (void *)&cmd_config_rss_reta_keyword, 2914 (void *)&cmd_config_rss_reta_port_id, 2915 (void *)&cmd_config_rss_reta_name, 2916 (void *)&cmd_config_rss_reta_list_name, 2917 (void *)&cmd_config_rss_reta_list_of_items, 2918 NULL, 2919 }, 2920 }; 2921 2922 /* *** SHOW PORT RETA INFO *** */ 2923 struct cmd_showport_reta { 2924 cmdline_fixed_string_t show; 2925 cmdline_fixed_string_t port; 2926 portid_t port_id; 2927 cmdline_fixed_string_t rss; 2928 cmdline_fixed_string_t reta; 2929 uint16_t size; 2930 cmdline_fixed_string_t list_of_items; 2931 }; 2932 2933 static int 2934 showport_parse_reta_config(struct rte_eth_rss_reta_entry64 *conf, 2935 uint16_t nb_entries, 2936 char *str) 2937 { 2938 uint32_t size; 2939 const char *p, *p0 = str; 2940 char s[256]; 2941 char *end; 2942 char *str_fld[8]; 2943 uint16_t i; 2944 uint16_t num = (nb_entries + RTE_RETA_GROUP_SIZE - 1) / 2945 RTE_RETA_GROUP_SIZE; 2946 int ret; 2947 2948 p = strchr(p0, '('); 2949 if (p == NULL) 2950 return -1; 2951 p++; 2952 p0 = strchr(p, ')'); 2953 if (p0 == NULL) 2954 return -1; 2955 size = p0 - p; 2956 if (size >= sizeof(s)) { 2957 printf("The string size exceeds the internal buffer size\n"); 2958 return -1; 2959 } 2960 snprintf(s, sizeof(s), "%.*s", size, p); 2961 ret = rte_strsplit(s, sizeof(s), str_fld, num, ','); 2962 if (ret <= 0 || ret != num) { 2963 printf("The bits of masks do not match the number of " 2964 "reta entries: %u\n", num); 2965 return -1; 2966 } 2967 for (i = 0; i < ret; i++) 2968 conf[i].mask = (uint64_t)strtoul(str_fld[i], &end, 0); 2969 2970 return 0; 2971 } 2972 2973 static void 2974 cmd_showport_reta_parsed(void *parsed_result, 2975 __attribute__((unused)) struct cmdline *cl, 2976 __attribute__((unused)) void *data) 2977 { 2978 struct cmd_showport_reta *res = parsed_result; 2979 struct rte_eth_rss_reta_entry64 reta_conf[8]; 2980 struct rte_eth_dev_info dev_info; 2981 uint16_t max_reta_size; 2982 int ret; 2983 2984 ret = eth_dev_info_get_print_err(res->port_id, &dev_info); 2985 if (ret != 0) 2986 return; 2987 2988 max_reta_size = RTE_MIN(dev_info.reta_size, ETH_RSS_RETA_SIZE_512); 2989 if (res->size == 0 || res->size > max_reta_size) { 2990 printf("Invalid redirection table size: %u (1-%u)\n", 2991 res->size, max_reta_size); 2992 return; 2993 } 2994 2995 memset(reta_conf, 0, sizeof(reta_conf)); 2996 if (showport_parse_reta_config(reta_conf, res->size, 2997 res->list_of_items) < 0) { 2998 printf("Invalid string: %s for reta masks\n", 2999 res->list_of_items); 3000 return; 3001 } 3002 port_rss_reta_info(res->port_id, reta_conf, res->size); 3003 } 3004 3005 cmdline_parse_token_string_t cmd_showport_reta_show = 3006 TOKEN_STRING_INITIALIZER(struct cmd_showport_reta, show, "show"); 3007 cmdline_parse_token_string_t cmd_showport_reta_port = 3008 TOKEN_STRING_INITIALIZER(struct cmd_showport_reta, port, "port"); 3009 cmdline_parse_token_num_t cmd_showport_reta_port_id = 3010 TOKEN_NUM_INITIALIZER(struct cmd_showport_reta, port_id, UINT16); 3011 cmdline_parse_token_string_t cmd_showport_reta_rss = 3012 TOKEN_STRING_INITIALIZER(struct cmd_showport_reta, rss, "rss"); 3013 cmdline_parse_token_string_t cmd_showport_reta_reta = 3014 TOKEN_STRING_INITIALIZER(struct cmd_showport_reta, reta, "reta"); 3015 cmdline_parse_token_num_t cmd_showport_reta_size = 3016 TOKEN_NUM_INITIALIZER(struct cmd_showport_reta, size, UINT16); 3017 cmdline_parse_token_string_t cmd_showport_reta_list_of_items = 3018 TOKEN_STRING_INITIALIZER(struct cmd_showport_reta, 3019 list_of_items, NULL); 3020 3021 cmdline_parse_inst_t cmd_showport_reta = { 3022 .f = cmd_showport_reta_parsed, 3023 .data = NULL, 3024 .help_str = "show port <port_id> rss reta <size> <mask0[,mask1]*>", 3025 .tokens = { 3026 (void *)&cmd_showport_reta_show, 3027 (void *)&cmd_showport_reta_port, 3028 (void *)&cmd_showport_reta_port_id, 3029 (void *)&cmd_showport_reta_rss, 3030 (void *)&cmd_showport_reta_reta, 3031 (void *)&cmd_showport_reta_size, 3032 (void *)&cmd_showport_reta_list_of_items, 3033 NULL, 3034 }, 3035 }; 3036 3037 /* *** Show RSS hash configuration *** */ 3038 struct cmd_showport_rss_hash { 3039 cmdline_fixed_string_t show; 3040 cmdline_fixed_string_t port; 3041 portid_t port_id; 3042 cmdline_fixed_string_t rss_hash; 3043 cmdline_fixed_string_t rss_type; 3044 cmdline_fixed_string_t key; /* optional argument */ 3045 }; 3046 3047 static void cmd_showport_rss_hash_parsed(void *parsed_result, 3048 __attribute__((unused)) struct cmdline *cl, 3049 void *show_rss_key) 3050 { 3051 struct cmd_showport_rss_hash *res = parsed_result; 3052 3053 port_rss_hash_conf_show(res->port_id, show_rss_key != NULL); 3054 } 3055 3056 cmdline_parse_token_string_t cmd_showport_rss_hash_show = 3057 TOKEN_STRING_INITIALIZER(struct cmd_showport_rss_hash, show, "show"); 3058 cmdline_parse_token_string_t cmd_showport_rss_hash_port = 3059 TOKEN_STRING_INITIALIZER(struct cmd_showport_rss_hash, port, "port"); 3060 cmdline_parse_token_num_t cmd_showport_rss_hash_port_id = 3061 TOKEN_NUM_INITIALIZER(struct cmd_showport_rss_hash, port_id, UINT16); 3062 cmdline_parse_token_string_t cmd_showport_rss_hash_rss_hash = 3063 TOKEN_STRING_INITIALIZER(struct cmd_showport_rss_hash, rss_hash, 3064 "rss-hash"); 3065 cmdline_parse_token_string_t cmd_showport_rss_hash_rss_key = 3066 TOKEN_STRING_INITIALIZER(struct cmd_showport_rss_hash, key, "key"); 3067 3068 cmdline_parse_inst_t cmd_showport_rss_hash = { 3069 .f = cmd_showport_rss_hash_parsed, 3070 .data = NULL, 3071 .help_str = "show port <port_id> rss-hash", 3072 .tokens = { 3073 (void *)&cmd_showport_rss_hash_show, 3074 (void *)&cmd_showport_rss_hash_port, 3075 (void *)&cmd_showport_rss_hash_port_id, 3076 (void *)&cmd_showport_rss_hash_rss_hash, 3077 NULL, 3078 }, 3079 }; 3080 3081 cmdline_parse_inst_t cmd_showport_rss_hash_key = { 3082 .f = cmd_showport_rss_hash_parsed, 3083 .data = (void *)1, 3084 .help_str = "show port <port_id> rss-hash key", 3085 .tokens = { 3086 (void *)&cmd_showport_rss_hash_show, 3087 (void *)&cmd_showport_rss_hash_port, 3088 (void *)&cmd_showport_rss_hash_port_id, 3089 (void *)&cmd_showport_rss_hash_rss_hash, 3090 (void *)&cmd_showport_rss_hash_rss_key, 3091 NULL, 3092 }, 3093 }; 3094 3095 /* *** Configure DCB *** */ 3096 struct cmd_config_dcb { 3097 cmdline_fixed_string_t port; 3098 cmdline_fixed_string_t config; 3099 portid_t port_id; 3100 cmdline_fixed_string_t dcb; 3101 cmdline_fixed_string_t vt; 3102 cmdline_fixed_string_t vt_en; 3103 uint8_t num_tcs; 3104 cmdline_fixed_string_t pfc; 3105 cmdline_fixed_string_t pfc_en; 3106 }; 3107 3108 static void 3109 cmd_config_dcb_parsed(void *parsed_result, 3110 __attribute__((unused)) struct cmdline *cl, 3111 __attribute__((unused)) void *data) 3112 { 3113 struct cmd_config_dcb *res = parsed_result; 3114 portid_t port_id = res->port_id; 3115 struct rte_port *port; 3116 uint8_t pfc_en; 3117 int ret; 3118 3119 port = &ports[port_id]; 3120 /** Check if the port is not started **/ 3121 if (port->port_status != RTE_PORT_STOPPED) { 3122 printf("Please stop port %d first\n", port_id); 3123 return; 3124 } 3125 3126 if ((res->num_tcs != ETH_4_TCS) && (res->num_tcs != ETH_8_TCS)) { 3127 printf("The invalid number of traffic class," 3128 " only 4 or 8 allowed.\n"); 3129 return; 3130 } 3131 3132 if (nb_fwd_lcores < res->num_tcs) { 3133 printf("nb_cores shouldn't be less than number of TCs.\n"); 3134 return; 3135 } 3136 if (!strncmp(res->pfc_en, "on", 2)) 3137 pfc_en = 1; 3138 else 3139 pfc_en = 0; 3140 3141 /* DCB in VT mode */ 3142 if (!strncmp(res->vt_en, "on", 2)) 3143 ret = init_port_dcb_config(port_id, DCB_VT_ENABLED, 3144 (enum rte_eth_nb_tcs)res->num_tcs, 3145 pfc_en); 3146 else 3147 ret = init_port_dcb_config(port_id, DCB_ENABLED, 3148 (enum rte_eth_nb_tcs)res->num_tcs, 3149 pfc_en); 3150 3151 3152 if (ret != 0) { 3153 printf("Cannot initialize network ports.\n"); 3154 return; 3155 } 3156 3157 cmd_reconfig_device_queue(port_id, 1, 1); 3158 } 3159 3160 cmdline_parse_token_string_t cmd_config_dcb_port = 3161 TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, port, "port"); 3162 cmdline_parse_token_string_t cmd_config_dcb_config = 3163 TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, config, "config"); 3164 cmdline_parse_token_num_t cmd_config_dcb_port_id = 3165 TOKEN_NUM_INITIALIZER(struct cmd_config_dcb, port_id, UINT16); 3166 cmdline_parse_token_string_t cmd_config_dcb_dcb = 3167 TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, dcb, "dcb"); 3168 cmdline_parse_token_string_t cmd_config_dcb_vt = 3169 TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, vt, "vt"); 3170 cmdline_parse_token_string_t cmd_config_dcb_vt_en = 3171 TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, vt_en, "on#off"); 3172 cmdline_parse_token_num_t cmd_config_dcb_num_tcs = 3173 TOKEN_NUM_INITIALIZER(struct cmd_config_dcb, num_tcs, UINT8); 3174 cmdline_parse_token_string_t cmd_config_dcb_pfc= 3175 TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, pfc, "pfc"); 3176 cmdline_parse_token_string_t cmd_config_dcb_pfc_en = 3177 TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, pfc_en, "on#off"); 3178 3179 cmdline_parse_inst_t cmd_config_dcb = { 3180 .f = cmd_config_dcb_parsed, 3181 .data = NULL, 3182 .help_str = "port config <port-id> dcb vt on|off <num_tcs> pfc on|off", 3183 .tokens = { 3184 (void *)&cmd_config_dcb_port, 3185 (void *)&cmd_config_dcb_config, 3186 (void *)&cmd_config_dcb_port_id, 3187 (void *)&cmd_config_dcb_dcb, 3188 (void *)&cmd_config_dcb_vt, 3189 (void *)&cmd_config_dcb_vt_en, 3190 (void *)&cmd_config_dcb_num_tcs, 3191 (void *)&cmd_config_dcb_pfc, 3192 (void *)&cmd_config_dcb_pfc_en, 3193 NULL, 3194 }, 3195 }; 3196 3197 /* *** configure number of packets per burst *** */ 3198 struct cmd_config_burst { 3199 cmdline_fixed_string_t port; 3200 cmdline_fixed_string_t keyword; 3201 cmdline_fixed_string_t all; 3202 cmdline_fixed_string_t name; 3203 uint16_t value; 3204 }; 3205 3206 static void 3207 cmd_config_burst_parsed(void *parsed_result, 3208 __attribute__((unused)) struct cmdline *cl, 3209 __attribute__((unused)) void *data) 3210 { 3211 struct cmd_config_burst *res = parsed_result; 3212 struct rte_eth_dev_info dev_info; 3213 uint16_t rec_nb_pkts; 3214 int ret; 3215 3216 if (!all_ports_stopped()) { 3217 printf("Please stop all ports first\n"); 3218 return; 3219 } 3220 3221 if (!strcmp(res->name, "burst")) { 3222 if (res->value == 0) { 3223 /* If user gives a value of zero, query the PMD for 3224 * its recommended Rx burst size. Testpmd uses a single 3225 * size for all ports, so assume all ports are the same 3226 * NIC model and use the values from Port 0. 3227 */ 3228 ret = eth_dev_info_get_print_err(0, &dev_info); 3229 if (ret != 0) 3230 return; 3231 3232 rec_nb_pkts = dev_info.default_rxportconf.burst_size; 3233 3234 if (rec_nb_pkts == 0) { 3235 printf("PMD does not recommend a burst size.\n" 3236 "User provided value must be between" 3237 " 1 and %d\n", MAX_PKT_BURST); 3238 return; 3239 } else if (rec_nb_pkts > MAX_PKT_BURST) { 3240 printf("PMD recommended burst size of %d" 3241 " exceeds maximum value of %d\n", 3242 rec_nb_pkts, MAX_PKT_BURST); 3243 return; 3244 } 3245 printf("Using PMD-provided burst value of %d\n", 3246 rec_nb_pkts); 3247 nb_pkt_per_burst = rec_nb_pkts; 3248 } else if (res->value > MAX_PKT_BURST) { 3249 printf("burst must be >= 1 && <= %d\n", MAX_PKT_BURST); 3250 return; 3251 } else 3252 nb_pkt_per_burst = res->value; 3253 } else { 3254 printf("Unknown parameter\n"); 3255 return; 3256 } 3257 3258 init_port_config(); 3259 3260 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1); 3261 } 3262 3263 cmdline_parse_token_string_t cmd_config_burst_port = 3264 TOKEN_STRING_INITIALIZER(struct cmd_config_burst, port, "port"); 3265 cmdline_parse_token_string_t cmd_config_burst_keyword = 3266 TOKEN_STRING_INITIALIZER(struct cmd_config_burst, keyword, "config"); 3267 cmdline_parse_token_string_t cmd_config_burst_all = 3268 TOKEN_STRING_INITIALIZER(struct cmd_config_burst, all, "all"); 3269 cmdline_parse_token_string_t cmd_config_burst_name = 3270 TOKEN_STRING_INITIALIZER(struct cmd_config_burst, name, "burst"); 3271 cmdline_parse_token_num_t cmd_config_burst_value = 3272 TOKEN_NUM_INITIALIZER(struct cmd_config_burst, value, UINT16); 3273 3274 cmdline_parse_inst_t cmd_config_burst = { 3275 .f = cmd_config_burst_parsed, 3276 .data = NULL, 3277 .help_str = "port config all burst <value>", 3278 .tokens = { 3279 (void *)&cmd_config_burst_port, 3280 (void *)&cmd_config_burst_keyword, 3281 (void *)&cmd_config_burst_all, 3282 (void *)&cmd_config_burst_name, 3283 (void *)&cmd_config_burst_value, 3284 NULL, 3285 }, 3286 }; 3287 3288 /* *** configure rx/tx queues *** */ 3289 struct cmd_config_thresh { 3290 cmdline_fixed_string_t port; 3291 cmdline_fixed_string_t keyword; 3292 cmdline_fixed_string_t all; 3293 cmdline_fixed_string_t name; 3294 uint8_t value; 3295 }; 3296 3297 static void 3298 cmd_config_thresh_parsed(void *parsed_result, 3299 __attribute__((unused)) struct cmdline *cl, 3300 __attribute__((unused)) void *data) 3301 { 3302 struct cmd_config_thresh *res = parsed_result; 3303 3304 if (!all_ports_stopped()) { 3305 printf("Please stop all ports first\n"); 3306 return; 3307 } 3308 3309 if (!strcmp(res->name, "txpt")) 3310 tx_pthresh = res->value; 3311 else if(!strcmp(res->name, "txht")) 3312 tx_hthresh = res->value; 3313 else if(!strcmp(res->name, "txwt")) 3314 tx_wthresh = res->value; 3315 else if(!strcmp(res->name, "rxpt")) 3316 rx_pthresh = res->value; 3317 else if(!strcmp(res->name, "rxht")) 3318 rx_hthresh = res->value; 3319 else if(!strcmp(res->name, "rxwt")) 3320 rx_wthresh = res->value; 3321 else { 3322 printf("Unknown parameter\n"); 3323 return; 3324 } 3325 3326 init_port_config(); 3327 3328 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1); 3329 } 3330 3331 cmdline_parse_token_string_t cmd_config_thresh_port = 3332 TOKEN_STRING_INITIALIZER(struct cmd_config_thresh, port, "port"); 3333 cmdline_parse_token_string_t cmd_config_thresh_keyword = 3334 TOKEN_STRING_INITIALIZER(struct cmd_config_thresh, keyword, "config"); 3335 cmdline_parse_token_string_t cmd_config_thresh_all = 3336 TOKEN_STRING_INITIALIZER(struct cmd_config_thresh, all, "all"); 3337 cmdline_parse_token_string_t cmd_config_thresh_name = 3338 TOKEN_STRING_INITIALIZER(struct cmd_config_thresh, name, 3339 "txpt#txht#txwt#rxpt#rxht#rxwt"); 3340 cmdline_parse_token_num_t cmd_config_thresh_value = 3341 TOKEN_NUM_INITIALIZER(struct cmd_config_thresh, value, UINT8); 3342 3343 cmdline_parse_inst_t cmd_config_thresh = { 3344 .f = cmd_config_thresh_parsed, 3345 .data = NULL, 3346 .help_str = "port config all txpt|txht|txwt|rxpt|rxht|rxwt <value>", 3347 .tokens = { 3348 (void *)&cmd_config_thresh_port, 3349 (void *)&cmd_config_thresh_keyword, 3350 (void *)&cmd_config_thresh_all, 3351 (void *)&cmd_config_thresh_name, 3352 (void *)&cmd_config_thresh_value, 3353 NULL, 3354 }, 3355 }; 3356 3357 /* *** configure free/rs threshold *** */ 3358 struct cmd_config_threshold { 3359 cmdline_fixed_string_t port; 3360 cmdline_fixed_string_t keyword; 3361 cmdline_fixed_string_t all; 3362 cmdline_fixed_string_t name; 3363 uint16_t value; 3364 }; 3365 3366 static void 3367 cmd_config_threshold_parsed(void *parsed_result, 3368 __attribute__((unused)) struct cmdline *cl, 3369 __attribute__((unused)) void *data) 3370 { 3371 struct cmd_config_threshold *res = parsed_result; 3372 3373 if (!all_ports_stopped()) { 3374 printf("Please stop all ports first\n"); 3375 return; 3376 } 3377 3378 if (!strcmp(res->name, "txfreet")) 3379 tx_free_thresh = res->value; 3380 else if (!strcmp(res->name, "txrst")) 3381 tx_rs_thresh = res->value; 3382 else if (!strcmp(res->name, "rxfreet")) 3383 rx_free_thresh = res->value; 3384 else { 3385 printf("Unknown parameter\n"); 3386 return; 3387 } 3388 3389 init_port_config(); 3390 3391 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1); 3392 } 3393 3394 cmdline_parse_token_string_t cmd_config_threshold_port = 3395 TOKEN_STRING_INITIALIZER(struct cmd_config_threshold, port, "port"); 3396 cmdline_parse_token_string_t cmd_config_threshold_keyword = 3397 TOKEN_STRING_INITIALIZER(struct cmd_config_threshold, keyword, 3398 "config"); 3399 cmdline_parse_token_string_t cmd_config_threshold_all = 3400 TOKEN_STRING_INITIALIZER(struct cmd_config_threshold, all, "all"); 3401 cmdline_parse_token_string_t cmd_config_threshold_name = 3402 TOKEN_STRING_INITIALIZER(struct cmd_config_threshold, name, 3403 "txfreet#txrst#rxfreet"); 3404 cmdline_parse_token_num_t cmd_config_threshold_value = 3405 TOKEN_NUM_INITIALIZER(struct cmd_config_threshold, value, UINT16); 3406 3407 cmdline_parse_inst_t cmd_config_threshold = { 3408 .f = cmd_config_threshold_parsed, 3409 .data = NULL, 3410 .help_str = "port config all txfreet|txrst|rxfreet <value>", 3411 .tokens = { 3412 (void *)&cmd_config_threshold_port, 3413 (void *)&cmd_config_threshold_keyword, 3414 (void *)&cmd_config_threshold_all, 3415 (void *)&cmd_config_threshold_name, 3416 (void *)&cmd_config_threshold_value, 3417 NULL, 3418 }, 3419 }; 3420 3421 /* *** stop *** */ 3422 struct cmd_stop_result { 3423 cmdline_fixed_string_t stop; 3424 }; 3425 3426 static void cmd_stop_parsed(__attribute__((unused)) void *parsed_result, 3427 __attribute__((unused)) struct cmdline *cl, 3428 __attribute__((unused)) void *data) 3429 { 3430 stop_packet_forwarding(); 3431 } 3432 3433 cmdline_parse_token_string_t cmd_stop_stop = 3434 TOKEN_STRING_INITIALIZER(struct cmd_stop_result, stop, "stop"); 3435 3436 cmdline_parse_inst_t cmd_stop = { 3437 .f = cmd_stop_parsed, 3438 .data = NULL, 3439 .help_str = "stop: Stop packet forwarding", 3440 .tokens = { 3441 (void *)&cmd_stop_stop, 3442 NULL, 3443 }, 3444 }; 3445 3446 /* *** SET CORELIST and PORTLIST CONFIGURATION *** */ 3447 3448 unsigned int 3449 parse_item_list(char* str, const char* item_name, unsigned int max_items, 3450 unsigned int *parsed_items, int check_unique_values) 3451 { 3452 unsigned int nb_item; 3453 unsigned int value; 3454 unsigned int i; 3455 unsigned int j; 3456 int value_ok; 3457 char c; 3458 3459 /* 3460 * First parse all items in the list and store their value. 3461 */ 3462 value = 0; 3463 nb_item = 0; 3464 value_ok = 0; 3465 for (i = 0; i < strnlen(str, STR_TOKEN_SIZE); i++) { 3466 c = str[i]; 3467 if ((c >= '0') && (c <= '9')) { 3468 value = (unsigned int) (value * 10 + (c - '0')); 3469 value_ok = 1; 3470 continue; 3471 } 3472 if (c != ',') { 3473 printf("character %c is not a decimal digit\n", c); 3474 return 0; 3475 } 3476 if (! value_ok) { 3477 printf("No valid value before comma\n"); 3478 return 0; 3479 } 3480 if (nb_item < max_items) { 3481 parsed_items[nb_item] = value; 3482 value_ok = 0; 3483 value = 0; 3484 } 3485 nb_item++; 3486 } 3487 if (nb_item >= max_items) { 3488 printf("Number of %s = %u > %u (maximum items)\n", 3489 item_name, nb_item + 1, max_items); 3490 return 0; 3491 } 3492 parsed_items[nb_item++] = value; 3493 if (! check_unique_values) 3494 return nb_item; 3495 3496 /* 3497 * Then, check that all values in the list are differents. 3498 * No optimization here... 3499 */ 3500 for (i = 0; i < nb_item; i++) { 3501 for (j = i + 1; j < nb_item; j++) { 3502 if (parsed_items[j] == parsed_items[i]) { 3503 printf("duplicated %s %u at index %u and %u\n", 3504 item_name, parsed_items[i], i, j); 3505 return 0; 3506 } 3507 } 3508 } 3509 return nb_item; 3510 } 3511 3512 struct cmd_set_list_result { 3513 cmdline_fixed_string_t cmd_keyword; 3514 cmdline_fixed_string_t list_name; 3515 cmdline_fixed_string_t list_of_items; 3516 }; 3517 3518 static void cmd_set_list_parsed(void *parsed_result, 3519 __attribute__((unused)) struct cmdline *cl, 3520 __attribute__((unused)) void *data) 3521 { 3522 struct cmd_set_list_result *res; 3523 union { 3524 unsigned int lcorelist[RTE_MAX_LCORE]; 3525 unsigned int portlist[RTE_MAX_ETHPORTS]; 3526 } parsed_items; 3527 unsigned int nb_item; 3528 3529 if (test_done == 0) { 3530 printf("Please stop forwarding first\n"); 3531 return; 3532 } 3533 3534 res = parsed_result; 3535 if (!strcmp(res->list_name, "corelist")) { 3536 nb_item = parse_item_list(res->list_of_items, "core", 3537 RTE_MAX_LCORE, 3538 parsed_items.lcorelist, 1); 3539 if (nb_item > 0) { 3540 set_fwd_lcores_list(parsed_items.lcorelist, nb_item); 3541 fwd_config_setup(); 3542 } 3543 return; 3544 } 3545 if (!strcmp(res->list_name, "portlist")) { 3546 nb_item = parse_item_list(res->list_of_items, "port", 3547 RTE_MAX_ETHPORTS, 3548 parsed_items.portlist, 1); 3549 if (nb_item > 0) { 3550 set_fwd_ports_list(parsed_items.portlist, nb_item); 3551 fwd_config_setup(); 3552 } 3553 } 3554 } 3555 3556 cmdline_parse_token_string_t cmd_set_list_keyword = 3557 TOKEN_STRING_INITIALIZER(struct cmd_set_list_result, cmd_keyword, 3558 "set"); 3559 cmdline_parse_token_string_t cmd_set_list_name = 3560 TOKEN_STRING_INITIALIZER(struct cmd_set_list_result, list_name, 3561 "corelist#portlist"); 3562 cmdline_parse_token_string_t cmd_set_list_of_items = 3563 TOKEN_STRING_INITIALIZER(struct cmd_set_list_result, list_of_items, 3564 NULL); 3565 3566 cmdline_parse_inst_t cmd_set_fwd_list = { 3567 .f = cmd_set_list_parsed, 3568 .data = NULL, 3569 .help_str = "set corelist|portlist <list0[,list1]*>", 3570 .tokens = { 3571 (void *)&cmd_set_list_keyword, 3572 (void *)&cmd_set_list_name, 3573 (void *)&cmd_set_list_of_items, 3574 NULL, 3575 }, 3576 }; 3577 3578 /* *** SET COREMASK and PORTMASK CONFIGURATION *** */ 3579 3580 struct cmd_setmask_result { 3581 cmdline_fixed_string_t set; 3582 cmdline_fixed_string_t mask; 3583 uint64_t hexavalue; 3584 }; 3585 3586 static void cmd_set_mask_parsed(void *parsed_result, 3587 __attribute__((unused)) struct cmdline *cl, 3588 __attribute__((unused)) void *data) 3589 { 3590 struct cmd_setmask_result *res = parsed_result; 3591 3592 if (test_done == 0) { 3593 printf("Please stop forwarding first\n"); 3594 return; 3595 } 3596 if (!strcmp(res->mask, "coremask")) { 3597 set_fwd_lcores_mask(res->hexavalue); 3598 fwd_config_setup(); 3599 } else if (!strcmp(res->mask, "portmask")) { 3600 set_fwd_ports_mask(res->hexavalue); 3601 fwd_config_setup(); 3602 } 3603 } 3604 3605 cmdline_parse_token_string_t cmd_setmask_set = 3606 TOKEN_STRING_INITIALIZER(struct cmd_setmask_result, set, "set"); 3607 cmdline_parse_token_string_t cmd_setmask_mask = 3608 TOKEN_STRING_INITIALIZER(struct cmd_setmask_result, mask, 3609 "coremask#portmask"); 3610 cmdline_parse_token_num_t cmd_setmask_value = 3611 TOKEN_NUM_INITIALIZER(struct cmd_setmask_result, hexavalue, UINT64); 3612 3613 cmdline_parse_inst_t cmd_set_fwd_mask = { 3614 .f = cmd_set_mask_parsed, 3615 .data = NULL, 3616 .help_str = "set coremask|portmask <hexadecimal value>", 3617 .tokens = { 3618 (void *)&cmd_setmask_set, 3619 (void *)&cmd_setmask_mask, 3620 (void *)&cmd_setmask_value, 3621 NULL, 3622 }, 3623 }; 3624 3625 /* 3626 * SET NBPORT, NBCORE, PACKET BURST, and VERBOSE LEVEL CONFIGURATION 3627 */ 3628 struct cmd_set_result { 3629 cmdline_fixed_string_t set; 3630 cmdline_fixed_string_t what; 3631 uint16_t value; 3632 }; 3633 3634 static void cmd_set_parsed(void *parsed_result, 3635 __attribute__((unused)) struct cmdline *cl, 3636 __attribute__((unused)) void *data) 3637 { 3638 struct cmd_set_result *res = parsed_result; 3639 if (!strcmp(res->what, "nbport")) { 3640 set_fwd_ports_number(res->value); 3641 fwd_config_setup(); 3642 } else if (!strcmp(res->what, "nbcore")) { 3643 set_fwd_lcores_number(res->value); 3644 fwd_config_setup(); 3645 } else if (!strcmp(res->what, "burst")) 3646 set_nb_pkt_per_burst(res->value); 3647 else if (!strcmp(res->what, "verbose")) 3648 set_verbose_level(res->value); 3649 } 3650 3651 cmdline_parse_token_string_t cmd_set_set = 3652 TOKEN_STRING_INITIALIZER(struct cmd_set_result, set, "set"); 3653 cmdline_parse_token_string_t cmd_set_what = 3654 TOKEN_STRING_INITIALIZER(struct cmd_set_result, what, 3655 "nbport#nbcore#burst#verbose"); 3656 cmdline_parse_token_num_t cmd_set_value = 3657 TOKEN_NUM_INITIALIZER(struct cmd_set_result, value, UINT16); 3658 3659 cmdline_parse_inst_t cmd_set_numbers = { 3660 .f = cmd_set_parsed, 3661 .data = NULL, 3662 .help_str = "set nbport|nbcore|burst|verbose <value>", 3663 .tokens = { 3664 (void *)&cmd_set_set, 3665 (void *)&cmd_set_what, 3666 (void *)&cmd_set_value, 3667 NULL, 3668 }, 3669 }; 3670 3671 /* *** SET LOG LEVEL CONFIGURATION *** */ 3672 3673 struct cmd_set_log_result { 3674 cmdline_fixed_string_t set; 3675 cmdline_fixed_string_t log; 3676 cmdline_fixed_string_t type; 3677 uint32_t level; 3678 }; 3679 3680 static void 3681 cmd_set_log_parsed(void *parsed_result, 3682 __attribute__((unused)) struct cmdline *cl, 3683 __attribute__((unused)) void *data) 3684 { 3685 struct cmd_set_log_result *res; 3686 int ret; 3687 3688 res = parsed_result; 3689 if (!strcmp(res->type, "global")) 3690 rte_log_set_global_level(res->level); 3691 else { 3692 ret = rte_log_set_level_regexp(res->type, res->level); 3693 if (ret < 0) 3694 printf("Unable to set log level\n"); 3695 } 3696 } 3697 3698 cmdline_parse_token_string_t cmd_set_log_set = 3699 TOKEN_STRING_INITIALIZER(struct cmd_set_log_result, set, "set"); 3700 cmdline_parse_token_string_t cmd_set_log_log = 3701 TOKEN_STRING_INITIALIZER(struct cmd_set_log_result, log, "log"); 3702 cmdline_parse_token_string_t cmd_set_log_type = 3703 TOKEN_STRING_INITIALIZER(struct cmd_set_log_result, type, NULL); 3704 cmdline_parse_token_num_t cmd_set_log_level = 3705 TOKEN_NUM_INITIALIZER(struct cmd_set_log_result, level, UINT32); 3706 3707 cmdline_parse_inst_t cmd_set_log = { 3708 .f = cmd_set_log_parsed, 3709 .data = NULL, 3710 .help_str = "set log global|<type> <level>", 3711 .tokens = { 3712 (void *)&cmd_set_log_set, 3713 (void *)&cmd_set_log_log, 3714 (void *)&cmd_set_log_type, 3715 (void *)&cmd_set_log_level, 3716 NULL, 3717 }, 3718 }; 3719 3720 /* *** SET SEGMENT LENGTHS OF TXONLY PACKETS *** */ 3721 3722 struct cmd_set_txpkts_result { 3723 cmdline_fixed_string_t cmd_keyword; 3724 cmdline_fixed_string_t txpkts; 3725 cmdline_fixed_string_t seg_lengths; 3726 }; 3727 3728 static void 3729 cmd_set_txpkts_parsed(void *parsed_result, 3730 __attribute__((unused)) struct cmdline *cl, 3731 __attribute__((unused)) void *data) 3732 { 3733 struct cmd_set_txpkts_result *res; 3734 unsigned seg_lengths[RTE_MAX_SEGS_PER_PKT]; 3735 unsigned int nb_segs; 3736 3737 res = parsed_result; 3738 nb_segs = parse_item_list(res->seg_lengths, "segment lengths", 3739 RTE_MAX_SEGS_PER_PKT, seg_lengths, 0); 3740 if (nb_segs > 0) 3741 set_tx_pkt_segments(seg_lengths, nb_segs); 3742 } 3743 3744 cmdline_parse_token_string_t cmd_set_txpkts_keyword = 3745 TOKEN_STRING_INITIALIZER(struct cmd_set_txpkts_result, 3746 cmd_keyword, "set"); 3747 cmdline_parse_token_string_t cmd_set_txpkts_name = 3748 TOKEN_STRING_INITIALIZER(struct cmd_set_txpkts_result, 3749 txpkts, "txpkts"); 3750 cmdline_parse_token_string_t cmd_set_txpkts_lengths = 3751 TOKEN_STRING_INITIALIZER(struct cmd_set_txpkts_result, 3752 seg_lengths, NULL); 3753 3754 cmdline_parse_inst_t cmd_set_txpkts = { 3755 .f = cmd_set_txpkts_parsed, 3756 .data = NULL, 3757 .help_str = "set txpkts <len0[,len1]*>", 3758 .tokens = { 3759 (void *)&cmd_set_txpkts_keyword, 3760 (void *)&cmd_set_txpkts_name, 3761 (void *)&cmd_set_txpkts_lengths, 3762 NULL, 3763 }, 3764 }; 3765 3766 /* *** SET COPY AND SPLIT POLICY ON TX PACKETS *** */ 3767 3768 struct cmd_set_txsplit_result { 3769 cmdline_fixed_string_t cmd_keyword; 3770 cmdline_fixed_string_t txsplit; 3771 cmdline_fixed_string_t mode; 3772 }; 3773 3774 static void 3775 cmd_set_txsplit_parsed(void *parsed_result, 3776 __attribute__((unused)) struct cmdline *cl, 3777 __attribute__((unused)) void *data) 3778 { 3779 struct cmd_set_txsplit_result *res; 3780 3781 res = parsed_result; 3782 set_tx_pkt_split(res->mode); 3783 } 3784 3785 cmdline_parse_token_string_t cmd_set_txsplit_keyword = 3786 TOKEN_STRING_INITIALIZER(struct cmd_set_txsplit_result, 3787 cmd_keyword, "set"); 3788 cmdline_parse_token_string_t cmd_set_txsplit_name = 3789 TOKEN_STRING_INITIALIZER(struct cmd_set_txsplit_result, 3790 txsplit, "txsplit"); 3791 cmdline_parse_token_string_t cmd_set_txsplit_mode = 3792 TOKEN_STRING_INITIALIZER(struct cmd_set_txsplit_result, 3793 mode, NULL); 3794 3795 cmdline_parse_inst_t cmd_set_txsplit = { 3796 .f = cmd_set_txsplit_parsed, 3797 .data = NULL, 3798 .help_str = "set txsplit on|off|rand", 3799 .tokens = { 3800 (void *)&cmd_set_txsplit_keyword, 3801 (void *)&cmd_set_txsplit_name, 3802 (void *)&cmd_set_txsplit_mode, 3803 NULL, 3804 }, 3805 }; 3806 3807 /* *** ADD/REMOVE ALL VLAN IDENTIFIERS TO/FROM A PORT VLAN RX FILTER *** */ 3808 struct cmd_rx_vlan_filter_all_result { 3809 cmdline_fixed_string_t rx_vlan; 3810 cmdline_fixed_string_t what; 3811 cmdline_fixed_string_t all; 3812 portid_t port_id; 3813 }; 3814 3815 static void 3816 cmd_rx_vlan_filter_all_parsed(void *parsed_result, 3817 __attribute__((unused)) struct cmdline *cl, 3818 __attribute__((unused)) void *data) 3819 { 3820 struct cmd_rx_vlan_filter_all_result *res = parsed_result; 3821 3822 if (!strcmp(res->what, "add")) 3823 rx_vlan_all_filter_set(res->port_id, 1); 3824 else 3825 rx_vlan_all_filter_set(res->port_id, 0); 3826 } 3827 3828 cmdline_parse_token_string_t cmd_rx_vlan_filter_all_rx_vlan = 3829 TOKEN_STRING_INITIALIZER(struct cmd_rx_vlan_filter_all_result, 3830 rx_vlan, "rx_vlan"); 3831 cmdline_parse_token_string_t cmd_rx_vlan_filter_all_what = 3832 TOKEN_STRING_INITIALIZER(struct cmd_rx_vlan_filter_all_result, 3833 what, "add#rm"); 3834 cmdline_parse_token_string_t cmd_rx_vlan_filter_all_all = 3835 TOKEN_STRING_INITIALIZER(struct cmd_rx_vlan_filter_all_result, 3836 all, "all"); 3837 cmdline_parse_token_num_t cmd_rx_vlan_filter_all_portid = 3838 TOKEN_NUM_INITIALIZER(struct cmd_rx_vlan_filter_all_result, 3839 port_id, UINT16); 3840 3841 cmdline_parse_inst_t cmd_rx_vlan_filter_all = { 3842 .f = cmd_rx_vlan_filter_all_parsed, 3843 .data = NULL, 3844 .help_str = "rx_vlan add|rm all <port_id>: " 3845 "Add/Remove all identifiers to/from the set of VLAN " 3846 "identifiers filtered by a port", 3847 .tokens = { 3848 (void *)&cmd_rx_vlan_filter_all_rx_vlan, 3849 (void *)&cmd_rx_vlan_filter_all_what, 3850 (void *)&cmd_rx_vlan_filter_all_all, 3851 (void *)&cmd_rx_vlan_filter_all_portid, 3852 NULL, 3853 }, 3854 }; 3855 3856 /* *** VLAN OFFLOAD SET ON A PORT *** */ 3857 struct cmd_vlan_offload_result { 3858 cmdline_fixed_string_t vlan; 3859 cmdline_fixed_string_t set; 3860 cmdline_fixed_string_t vlan_type; 3861 cmdline_fixed_string_t what; 3862 cmdline_fixed_string_t on; 3863 cmdline_fixed_string_t port_id; 3864 }; 3865 3866 static void 3867 cmd_vlan_offload_parsed(void *parsed_result, 3868 __attribute__((unused)) struct cmdline *cl, 3869 __attribute__((unused)) void *data) 3870 { 3871 int on; 3872 struct cmd_vlan_offload_result *res = parsed_result; 3873 char *str; 3874 int i, len = 0; 3875 portid_t port_id = 0; 3876 unsigned int tmp; 3877 3878 str = res->port_id; 3879 len = strnlen(str, STR_TOKEN_SIZE); 3880 i = 0; 3881 /* Get port_id first */ 3882 while(i < len){ 3883 if(str[i] == ',') 3884 break; 3885 3886 i++; 3887 } 3888 str[i]='\0'; 3889 tmp = strtoul(str, NULL, 0); 3890 /* If port_id greater that what portid_t can represent, return */ 3891 if(tmp >= RTE_MAX_ETHPORTS) 3892 return; 3893 port_id = (portid_t)tmp; 3894 3895 if (!strcmp(res->on, "on")) 3896 on = 1; 3897 else 3898 on = 0; 3899 3900 if (!strcmp(res->what, "strip")) 3901 rx_vlan_strip_set(port_id, on); 3902 else if(!strcmp(res->what, "stripq")){ 3903 uint16_t queue_id = 0; 3904 3905 /* No queue_id, return */ 3906 if(i + 1 >= len) { 3907 printf("must specify (port,queue_id)\n"); 3908 return; 3909 } 3910 tmp = strtoul(str + i + 1, NULL, 0); 3911 /* If queue_id greater that what 16-bits can represent, return */ 3912 if(tmp > 0xffff) 3913 return; 3914 3915 queue_id = (uint16_t)tmp; 3916 rx_vlan_strip_set_on_queue(port_id, queue_id, on); 3917 } 3918 else if (!strcmp(res->what, "filter")) 3919 rx_vlan_filter_set(port_id, on); 3920 else 3921 vlan_extend_set(port_id, on); 3922 3923 return; 3924 } 3925 3926 cmdline_parse_token_string_t cmd_vlan_offload_vlan = 3927 TOKEN_STRING_INITIALIZER(struct cmd_vlan_offload_result, 3928 vlan, "vlan"); 3929 cmdline_parse_token_string_t cmd_vlan_offload_set = 3930 TOKEN_STRING_INITIALIZER(struct cmd_vlan_offload_result, 3931 set, "set"); 3932 cmdline_parse_token_string_t cmd_vlan_offload_what = 3933 TOKEN_STRING_INITIALIZER(struct cmd_vlan_offload_result, 3934 what, "strip#filter#qinq#stripq"); 3935 cmdline_parse_token_string_t cmd_vlan_offload_on = 3936 TOKEN_STRING_INITIALIZER(struct cmd_vlan_offload_result, 3937 on, "on#off"); 3938 cmdline_parse_token_string_t cmd_vlan_offload_portid = 3939 TOKEN_STRING_INITIALIZER(struct cmd_vlan_offload_result, 3940 port_id, NULL); 3941 3942 cmdline_parse_inst_t cmd_vlan_offload = { 3943 .f = cmd_vlan_offload_parsed, 3944 .data = NULL, 3945 .help_str = "vlan set strip|filter|qinq|stripq on|off " 3946 "<port_id[,queue_id]>: " 3947 "Filter/Strip for rx side qinq(extended) for both rx/tx sides", 3948 .tokens = { 3949 (void *)&cmd_vlan_offload_vlan, 3950 (void *)&cmd_vlan_offload_set, 3951 (void *)&cmd_vlan_offload_what, 3952 (void *)&cmd_vlan_offload_on, 3953 (void *)&cmd_vlan_offload_portid, 3954 NULL, 3955 }, 3956 }; 3957 3958 /* *** VLAN TPID SET ON A PORT *** */ 3959 struct cmd_vlan_tpid_result { 3960 cmdline_fixed_string_t vlan; 3961 cmdline_fixed_string_t set; 3962 cmdline_fixed_string_t vlan_type; 3963 cmdline_fixed_string_t what; 3964 uint16_t tp_id; 3965 portid_t port_id; 3966 }; 3967 3968 static void 3969 cmd_vlan_tpid_parsed(void *parsed_result, 3970 __attribute__((unused)) struct cmdline *cl, 3971 __attribute__((unused)) void *data) 3972 { 3973 struct cmd_vlan_tpid_result *res = parsed_result; 3974 enum rte_vlan_type vlan_type; 3975 3976 if (!strcmp(res->vlan_type, "inner")) 3977 vlan_type = ETH_VLAN_TYPE_INNER; 3978 else if (!strcmp(res->vlan_type, "outer")) 3979 vlan_type = ETH_VLAN_TYPE_OUTER; 3980 else { 3981 printf("Unknown vlan type\n"); 3982 return; 3983 } 3984 vlan_tpid_set(res->port_id, vlan_type, res->tp_id); 3985 } 3986 3987 cmdline_parse_token_string_t cmd_vlan_tpid_vlan = 3988 TOKEN_STRING_INITIALIZER(struct cmd_vlan_tpid_result, 3989 vlan, "vlan"); 3990 cmdline_parse_token_string_t cmd_vlan_tpid_set = 3991 TOKEN_STRING_INITIALIZER(struct cmd_vlan_tpid_result, 3992 set, "set"); 3993 cmdline_parse_token_string_t cmd_vlan_type = 3994 TOKEN_STRING_INITIALIZER(struct cmd_vlan_tpid_result, 3995 vlan_type, "inner#outer"); 3996 cmdline_parse_token_string_t cmd_vlan_tpid_what = 3997 TOKEN_STRING_INITIALIZER(struct cmd_vlan_tpid_result, 3998 what, "tpid"); 3999 cmdline_parse_token_num_t cmd_vlan_tpid_tpid = 4000 TOKEN_NUM_INITIALIZER(struct cmd_vlan_tpid_result, 4001 tp_id, UINT16); 4002 cmdline_parse_token_num_t cmd_vlan_tpid_portid = 4003 TOKEN_NUM_INITIALIZER(struct cmd_vlan_tpid_result, 4004 port_id, UINT16); 4005 4006 cmdline_parse_inst_t cmd_vlan_tpid = { 4007 .f = cmd_vlan_tpid_parsed, 4008 .data = NULL, 4009 .help_str = "vlan set inner|outer tpid <tp_id> <port_id>: " 4010 "Set the VLAN Ether type", 4011 .tokens = { 4012 (void *)&cmd_vlan_tpid_vlan, 4013 (void *)&cmd_vlan_tpid_set, 4014 (void *)&cmd_vlan_type, 4015 (void *)&cmd_vlan_tpid_what, 4016 (void *)&cmd_vlan_tpid_tpid, 4017 (void *)&cmd_vlan_tpid_portid, 4018 NULL, 4019 }, 4020 }; 4021 4022 /* *** ADD/REMOVE A VLAN IDENTIFIER TO/FROM A PORT VLAN RX FILTER *** */ 4023 struct cmd_rx_vlan_filter_result { 4024 cmdline_fixed_string_t rx_vlan; 4025 cmdline_fixed_string_t what; 4026 uint16_t vlan_id; 4027 portid_t port_id; 4028 }; 4029 4030 static void 4031 cmd_rx_vlan_filter_parsed(void *parsed_result, 4032 __attribute__((unused)) struct cmdline *cl, 4033 __attribute__((unused)) void *data) 4034 { 4035 struct cmd_rx_vlan_filter_result *res = parsed_result; 4036 4037 if (!strcmp(res->what, "add")) 4038 rx_vft_set(res->port_id, res->vlan_id, 1); 4039 else 4040 rx_vft_set(res->port_id, res->vlan_id, 0); 4041 } 4042 4043 cmdline_parse_token_string_t cmd_rx_vlan_filter_rx_vlan = 4044 TOKEN_STRING_INITIALIZER(struct cmd_rx_vlan_filter_result, 4045 rx_vlan, "rx_vlan"); 4046 cmdline_parse_token_string_t cmd_rx_vlan_filter_what = 4047 TOKEN_STRING_INITIALIZER(struct cmd_rx_vlan_filter_result, 4048 what, "add#rm"); 4049 cmdline_parse_token_num_t cmd_rx_vlan_filter_vlanid = 4050 TOKEN_NUM_INITIALIZER(struct cmd_rx_vlan_filter_result, 4051 vlan_id, UINT16); 4052 cmdline_parse_token_num_t cmd_rx_vlan_filter_portid = 4053 TOKEN_NUM_INITIALIZER(struct cmd_rx_vlan_filter_result, 4054 port_id, UINT16); 4055 4056 cmdline_parse_inst_t cmd_rx_vlan_filter = { 4057 .f = cmd_rx_vlan_filter_parsed, 4058 .data = NULL, 4059 .help_str = "rx_vlan add|rm <vlan_id> <port_id>: " 4060 "Add/Remove a VLAN identifier to/from the set of VLAN " 4061 "identifiers filtered by a port", 4062 .tokens = { 4063 (void *)&cmd_rx_vlan_filter_rx_vlan, 4064 (void *)&cmd_rx_vlan_filter_what, 4065 (void *)&cmd_rx_vlan_filter_vlanid, 4066 (void *)&cmd_rx_vlan_filter_portid, 4067 NULL, 4068 }, 4069 }; 4070 4071 /* *** ENABLE HARDWARE INSERTION OF VLAN HEADER IN TX PACKETS *** */ 4072 struct cmd_tx_vlan_set_result { 4073 cmdline_fixed_string_t tx_vlan; 4074 cmdline_fixed_string_t set; 4075 portid_t port_id; 4076 uint16_t vlan_id; 4077 }; 4078 4079 static void 4080 cmd_tx_vlan_set_parsed(void *parsed_result, 4081 __attribute__((unused)) struct cmdline *cl, 4082 __attribute__((unused)) void *data) 4083 { 4084 struct cmd_tx_vlan_set_result *res = parsed_result; 4085 4086 if (!port_is_stopped(res->port_id)) { 4087 printf("Please stop port %d first\n", res->port_id); 4088 return; 4089 } 4090 4091 tx_vlan_set(res->port_id, res->vlan_id); 4092 4093 cmd_reconfig_device_queue(res->port_id, 1, 1); 4094 } 4095 4096 cmdline_parse_token_string_t cmd_tx_vlan_set_tx_vlan = 4097 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_result, 4098 tx_vlan, "tx_vlan"); 4099 cmdline_parse_token_string_t cmd_tx_vlan_set_set = 4100 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_result, 4101 set, "set"); 4102 cmdline_parse_token_num_t cmd_tx_vlan_set_portid = 4103 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_result, 4104 port_id, UINT16); 4105 cmdline_parse_token_num_t cmd_tx_vlan_set_vlanid = 4106 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_result, 4107 vlan_id, UINT16); 4108 4109 cmdline_parse_inst_t cmd_tx_vlan_set = { 4110 .f = cmd_tx_vlan_set_parsed, 4111 .data = NULL, 4112 .help_str = "tx_vlan set <port_id> <vlan_id>: " 4113 "Enable hardware insertion of a single VLAN header " 4114 "with a given TAG Identifier in packets sent on a port", 4115 .tokens = { 4116 (void *)&cmd_tx_vlan_set_tx_vlan, 4117 (void *)&cmd_tx_vlan_set_set, 4118 (void *)&cmd_tx_vlan_set_portid, 4119 (void *)&cmd_tx_vlan_set_vlanid, 4120 NULL, 4121 }, 4122 }; 4123 4124 /* *** ENABLE HARDWARE INSERTION OF Double VLAN HEADER IN TX PACKETS *** */ 4125 struct cmd_tx_vlan_set_qinq_result { 4126 cmdline_fixed_string_t tx_vlan; 4127 cmdline_fixed_string_t set; 4128 portid_t port_id; 4129 uint16_t vlan_id; 4130 uint16_t vlan_id_outer; 4131 }; 4132 4133 static void 4134 cmd_tx_vlan_set_qinq_parsed(void *parsed_result, 4135 __attribute__((unused)) struct cmdline *cl, 4136 __attribute__((unused)) void *data) 4137 { 4138 struct cmd_tx_vlan_set_qinq_result *res = parsed_result; 4139 4140 if (!port_is_stopped(res->port_id)) { 4141 printf("Please stop port %d first\n", res->port_id); 4142 return; 4143 } 4144 4145 tx_qinq_set(res->port_id, res->vlan_id, res->vlan_id_outer); 4146 4147 cmd_reconfig_device_queue(res->port_id, 1, 1); 4148 } 4149 4150 cmdline_parse_token_string_t cmd_tx_vlan_set_qinq_tx_vlan = 4151 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_qinq_result, 4152 tx_vlan, "tx_vlan"); 4153 cmdline_parse_token_string_t cmd_tx_vlan_set_qinq_set = 4154 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_qinq_result, 4155 set, "set"); 4156 cmdline_parse_token_num_t cmd_tx_vlan_set_qinq_portid = 4157 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_qinq_result, 4158 port_id, UINT16); 4159 cmdline_parse_token_num_t cmd_tx_vlan_set_qinq_vlanid = 4160 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_qinq_result, 4161 vlan_id, UINT16); 4162 cmdline_parse_token_num_t cmd_tx_vlan_set_qinq_vlanid_outer = 4163 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_qinq_result, 4164 vlan_id_outer, UINT16); 4165 4166 cmdline_parse_inst_t cmd_tx_vlan_set_qinq = { 4167 .f = cmd_tx_vlan_set_qinq_parsed, 4168 .data = NULL, 4169 .help_str = "tx_vlan set <port_id> <vlan_id> <outer_vlan_id>: " 4170 "Enable hardware insertion of double VLAN header " 4171 "with given TAG Identifiers in packets sent on a port", 4172 .tokens = { 4173 (void *)&cmd_tx_vlan_set_qinq_tx_vlan, 4174 (void *)&cmd_tx_vlan_set_qinq_set, 4175 (void *)&cmd_tx_vlan_set_qinq_portid, 4176 (void *)&cmd_tx_vlan_set_qinq_vlanid, 4177 (void *)&cmd_tx_vlan_set_qinq_vlanid_outer, 4178 NULL, 4179 }, 4180 }; 4181 4182 /* *** ENABLE/DISABLE PORT BASED TX VLAN INSERTION *** */ 4183 struct cmd_tx_vlan_set_pvid_result { 4184 cmdline_fixed_string_t tx_vlan; 4185 cmdline_fixed_string_t set; 4186 cmdline_fixed_string_t pvid; 4187 portid_t port_id; 4188 uint16_t vlan_id; 4189 cmdline_fixed_string_t mode; 4190 }; 4191 4192 static void 4193 cmd_tx_vlan_set_pvid_parsed(void *parsed_result, 4194 __attribute__((unused)) struct cmdline *cl, 4195 __attribute__((unused)) void *data) 4196 { 4197 struct cmd_tx_vlan_set_pvid_result *res = parsed_result; 4198 4199 if (strcmp(res->mode, "on") == 0) 4200 tx_vlan_pvid_set(res->port_id, res->vlan_id, 1); 4201 else 4202 tx_vlan_pvid_set(res->port_id, res->vlan_id, 0); 4203 } 4204 4205 cmdline_parse_token_string_t cmd_tx_vlan_set_pvid_tx_vlan = 4206 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_pvid_result, 4207 tx_vlan, "tx_vlan"); 4208 cmdline_parse_token_string_t cmd_tx_vlan_set_pvid_set = 4209 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_pvid_result, 4210 set, "set"); 4211 cmdline_parse_token_string_t cmd_tx_vlan_set_pvid_pvid = 4212 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_pvid_result, 4213 pvid, "pvid"); 4214 cmdline_parse_token_num_t cmd_tx_vlan_set_pvid_port_id = 4215 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_pvid_result, 4216 port_id, UINT16); 4217 cmdline_parse_token_num_t cmd_tx_vlan_set_pvid_vlan_id = 4218 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_pvid_result, 4219 vlan_id, UINT16); 4220 cmdline_parse_token_string_t cmd_tx_vlan_set_pvid_mode = 4221 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_pvid_result, 4222 mode, "on#off"); 4223 4224 cmdline_parse_inst_t cmd_tx_vlan_set_pvid = { 4225 .f = cmd_tx_vlan_set_pvid_parsed, 4226 .data = NULL, 4227 .help_str = "tx_vlan set pvid <port_id> <vlan_id> on|off", 4228 .tokens = { 4229 (void *)&cmd_tx_vlan_set_pvid_tx_vlan, 4230 (void *)&cmd_tx_vlan_set_pvid_set, 4231 (void *)&cmd_tx_vlan_set_pvid_pvid, 4232 (void *)&cmd_tx_vlan_set_pvid_port_id, 4233 (void *)&cmd_tx_vlan_set_pvid_vlan_id, 4234 (void *)&cmd_tx_vlan_set_pvid_mode, 4235 NULL, 4236 }, 4237 }; 4238 4239 /* *** DISABLE HARDWARE INSERTION OF VLAN HEADER IN TX PACKETS *** */ 4240 struct cmd_tx_vlan_reset_result { 4241 cmdline_fixed_string_t tx_vlan; 4242 cmdline_fixed_string_t reset; 4243 portid_t port_id; 4244 }; 4245 4246 static void 4247 cmd_tx_vlan_reset_parsed(void *parsed_result, 4248 __attribute__((unused)) struct cmdline *cl, 4249 __attribute__((unused)) void *data) 4250 { 4251 struct cmd_tx_vlan_reset_result *res = parsed_result; 4252 4253 if (!port_is_stopped(res->port_id)) { 4254 printf("Please stop port %d first\n", res->port_id); 4255 return; 4256 } 4257 4258 tx_vlan_reset(res->port_id); 4259 4260 cmd_reconfig_device_queue(res->port_id, 1, 1); 4261 } 4262 4263 cmdline_parse_token_string_t cmd_tx_vlan_reset_tx_vlan = 4264 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_reset_result, 4265 tx_vlan, "tx_vlan"); 4266 cmdline_parse_token_string_t cmd_tx_vlan_reset_reset = 4267 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_reset_result, 4268 reset, "reset"); 4269 cmdline_parse_token_num_t cmd_tx_vlan_reset_portid = 4270 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_reset_result, 4271 port_id, UINT16); 4272 4273 cmdline_parse_inst_t cmd_tx_vlan_reset = { 4274 .f = cmd_tx_vlan_reset_parsed, 4275 .data = NULL, 4276 .help_str = "tx_vlan reset <port_id>: Disable hardware insertion of a " 4277 "VLAN header in packets sent on a port", 4278 .tokens = { 4279 (void *)&cmd_tx_vlan_reset_tx_vlan, 4280 (void *)&cmd_tx_vlan_reset_reset, 4281 (void *)&cmd_tx_vlan_reset_portid, 4282 NULL, 4283 }, 4284 }; 4285 4286 4287 /* *** ENABLE HARDWARE INSERTION OF CHECKSUM IN TX PACKETS *** */ 4288 struct cmd_csum_result { 4289 cmdline_fixed_string_t csum; 4290 cmdline_fixed_string_t mode; 4291 cmdline_fixed_string_t proto; 4292 cmdline_fixed_string_t hwsw; 4293 portid_t port_id; 4294 }; 4295 4296 static void 4297 csum_show(int port_id) 4298 { 4299 struct rte_eth_dev_info dev_info; 4300 uint64_t tx_offloads; 4301 int ret; 4302 4303 tx_offloads = ports[port_id].dev_conf.txmode.offloads; 4304 printf("Parse tunnel is %s\n", 4305 (ports[port_id].parse_tunnel) ? "on" : "off"); 4306 printf("IP checksum offload is %s\n", 4307 (tx_offloads & DEV_TX_OFFLOAD_IPV4_CKSUM) ? "hw" : "sw"); 4308 printf("UDP checksum offload is %s\n", 4309 (tx_offloads & DEV_TX_OFFLOAD_UDP_CKSUM) ? "hw" : "sw"); 4310 printf("TCP checksum offload is %s\n", 4311 (tx_offloads & DEV_TX_OFFLOAD_TCP_CKSUM) ? "hw" : "sw"); 4312 printf("SCTP checksum offload is %s\n", 4313 (tx_offloads & DEV_TX_OFFLOAD_SCTP_CKSUM) ? "hw" : "sw"); 4314 printf("Outer-Ip checksum offload is %s\n", 4315 (tx_offloads & DEV_TX_OFFLOAD_OUTER_IPV4_CKSUM) ? "hw" : "sw"); 4316 printf("Outer-Udp checksum offload is %s\n", 4317 (tx_offloads & DEV_TX_OFFLOAD_OUTER_UDP_CKSUM) ? "hw" : "sw"); 4318 4319 /* display warnings if configuration is not supported by the NIC */ 4320 ret = eth_dev_info_get_print_err(port_id, &dev_info); 4321 if (ret != 0) 4322 return; 4323 4324 if ((tx_offloads & DEV_TX_OFFLOAD_IPV4_CKSUM) && 4325 (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_IPV4_CKSUM) == 0) { 4326 printf("Warning: hardware IP checksum enabled but not " 4327 "supported by port %d\n", port_id); 4328 } 4329 if ((tx_offloads & DEV_TX_OFFLOAD_UDP_CKSUM) && 4330 (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_UDP_CKSUM) == 0) { 4331 printf("Warning: hardware UDP checksum enabled but not " 4332 "supported by port %d\n", port_id); 4333 } 4334 if ((tx_offloads & DEV_TX_OFFLOAD_TCP_CKSUM) && 4335 (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_TCP_CKSUM) == 0) { 4336 printf("Warning: hardware TCP checksum enabled but not " 4337 "supported by port %d\n", port_id); 4338 } 4339 if ((tx_offloads & DEV_TX_OFFLOAD_SCTP_CKSUM) && 4340 (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_SCTP_CKSUM) == 0) { 4341 printf("Warning: hardware SCTP checksum enabled but not " 4342 "supported by port %d\n", port_id); 4343 } 4344 if ((tx_offloads & DEV_TX_OFFLOAD_OUTER_IPV4_CKSUM) && 4345 (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_OUTER_IPV4_CKSUM) == 0) { 4346 printf("Warning: hardware outer IP checksum enabled but not " 4347 "supported by port %d\n", port_id); 4348 } 4349 if ((tx_offloads & DEV_TX_OFFLOAD_OUTER_UDP_CKSUM) && 4350 (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_OUTER_UDP_CKSUM) 4351 == 0) { 4352 printf("Warning: hardware outer UDP checksum enabled but not " 4353 "supported by port %d\n", port_id); 4354 } 4355 } 4356 4357 static void 4358 cmd_config_queue_tx_offloads(struct rte_port *port) 4359 { 4360 int k; 4361 4362 /* Apply queue tx offloads configuration */ 4363 for (k = 0; k < port->dev_info.max_rx_queues; k++) 4364 port->tx_conf[k].offloads = 4365 port->dev_conf.txmode.offloads; 4366 } 4367 4368 static void 4369 cmd_csum_parsed(void *parsed_result, 4370 __attribute__((unused)) struct cmdline *cl, 4371 __attribute__((unused)) void *data) 4372 { 4373 struct cmd_csum_result *res = parsed_result; 4374 int hw = 0; 4375 uint64_t csum_offloads = 0; 4376 struct rte_eth_dev_info dev_info; 4377 int ret; 4378 4379 if (port_id_is_invalid(res->port_id, ENABLED_WARN)) { 4380 printf("invalid port %d\n", res->port_id); 4381 return; 4382 } 4383 if (!port_is_stopped(res->port_id)) { 4384 printf("Please stop port %d first\n", res->port_id); 4385 return; 4386 } 4387 4388 ret = eth_dev_info_get_print_err(res->port_id, &dev_info); 4389 if (ret != 0) 4390 return; 4391 4392 if (!strcmp(res->mode, "set")) { 4393 4394 if (!strcmp(res->hwsw, "hw")) 4395 hw = 1; 4396 4397 if (!strcmp(res->proto, "ip")) { 4398 if (hw == 0 || (dev_info.tx_offload_capa & 4399 DEV_TX_OFFLOAD_IPV4_CKSUM)) { 4400 csum_offloads |= DEV_TX_OFFLOAD_IPV4_CKSUM; 4401 } else { 4402 printf("IP checksum offload is not supported " 4403 "by port %u\n", res->port_id); 4404 } 4405 } else if (!strcmp(res->proto, "udp")) { 4406 if (hw == 0 || (dev_info.tx_offload_capa & 4407 DEV_TX_OFFLOAD_UDP_CKSUM)) { 4408 csum_offloads |= DEV_TX_OFFLOAD_UDP_CKSUM; 4409 } else { 4410 printf("UDP checksum offload is not supported " 4411 "by port %u\n", res->port_id); 4412 } 4413 } else if (!strcmp(res->proto, "tcp")) { 4414 if (hw == 0 || (dev_info.tx_offload_capa & 4415 DEV_TX_OFFLOAD_TCP_CKSUM)) { 4416 csum_offloads |= DEV_TX_OFFLOAD_TCP_CKSUM; 4417 } else { 4418 printf("TCP checksum offload is not supported " 4419 "by port %u\n", res->port_id); 4420 } 4421 } else if (!strcmp(res->proto, "sctp")) { 4422 if (hw == 0 || (dev_info.tx_offload_capa & 4423 DEV_TX_OFFLOAD_SCTP_CKSUM)) { 4424 csum_offloads |= DEV_TX_OFFLOAD_SCTP_CKSUM; 4425 } else { 4426 printf("SCTP checksum offload is not supported " 4427 "by port %u\n", res->port_id); 4428 } 4429 } else if (!strcmp(res->proto, "outer-ip")) { 4430 if (hw == 0 || (dev_info.tx_offload_capa & 4431 DEV_TX_OFFLOAD_OUTER_IPV4_CKSUM)) { 4432 csum_offloads |= 4433 DEV_TX_OFFLOAD_OUTER_IPV4_CKSUM; 4434 } else { 4435 printf("Outer IP checksum offload is not " 4436 "supported by port %u\n", res->port_id); 4437 } 4438 } else if (!strcmp(res->proto, "outer-udp")) { 4439 if (hw == 0 || (dev_info.tx_offload_capa & 4440 DEV_TX_OFFLOAD_OUTER_UDP_CKSUM)) { 4441 csum_offloads |= 4442 DEV_TX_OFFLOAD_OUTER_UDP_CKSUM; 4443 } else { 4444 printf("Outer UDP checksum offload is not " 4445 "supported by port %u\n", res->port_id); 4446 } 4447 } 4448 4449 if (hw) { 4450 ports[res->port_id].dev_conf.txmode.offloads |= 4451 csum_offloads; 4452 } else { 4453 ports[res->port_id].dev_conf.txmode.offloads &= 4454 (~csum_offloads); 4455 } 4456 cmd_config_queue_tx_offloads(&ports[res->port_id]); 4457 } 4458 csum_show(res->port_id); 4459 4460 cmd_reconfig_device_queue(res->port_id, 1, 1); 4461 } 4462 4463 cmdline_parse_token_string_t cmd_csum_csum = 4464 TOKEN_STRING_INITIALIZER(struct cmd_csum_result, 4465 csum, "csum"); 4466 cmdline_parse_token_string_t cmd_csum_mode = 4467 TOKEN_STRING_INITIALIZER(struct cmd_csum_result, 4468 mode, "set"); 4469 cmdline_parse_token_string_t cmd_csum_proto = 4470 TOKEN_STRING_INITIALIZER(struct cmd_csum_result, 4471 proto, "ip#tcp#udp#sctp#outer-ip#outer-udp"); 4472 cmdline_parse_token_string_t cmd_csum_hwsw = 4473 TOKEN_STRING_INITIALIZER(struct cmd_csum_result, 4474 hwsw, "hw#sw"); 4475 cmdline_parse_token_num_t cmd_csum_portid = 4476 TOKEN_NUM_INITIALIZER(struct cmd_csum_result, 4477 port_id, UINT16); 4478 4479 cmdline_parse_inst_t cmd_csum_set = { 4480 .f = cmd_csum_parsed, 4481 .data = NULL, 4482 .help_str = "csum set ip|tcp|udp|sctp|outer-ip|outer-udp hw|sw <port_id>: " 4483 "Enable/Disable hardware calculation of L3/L4 checksum when " 4484 "using csum forward engine", 4485 .tokens = { 4486 (void *)&cmd_csum_csum, 4487 (void *)&cmd_csum_mode, 4488 (void *)&cmd_csum_proto, 4489 (void *)&cmd_csum_hwsw, 4490 (void *)&cmd_csum_portid, 4491 NULL, 4492 }, 4493 }; 4494 4495 cmdline_parse_token_string_t cmd_csum_mode_show = 4496 TOKEN_STRING_INITIALIZER(struct cmd_csum_result, 4497 mode, "show"); 4498 4499 cmdline_parse_inst_t cmd_csum_show = { 4500 .f = cmd_csum_parsed, 4501 .data = NULL, 4502 .help_str = "csum show <port_id>: Show checksum offload configuration", 4503 .tokens = { 4504 (void *)&cmd_csum_csum, 4505 (void *)&cmd_csum_mode_show, 4506 (void *)&cmd_csum_portid, 4507 NULL, 4508 }, 4509 }; 4510 4511 /* Enable/disable tunnel parsing */ 4512 struct cmd_csum_tunnel_result { 4513 cmdline_fixed_string_t csum; 4514 cmdline_fixed_string_t parse; 4515 cmdline_fixed_string_t onoff; 4516 portid_t port_id; 4517 }; 4518 4519 static void 4520 cmd_csum_tunnel_parsed(void *parsed_result, 4521 __attribute__((unused)) struct cmdline *cl, 4522 __attribute__((unused)) void *data) 4523 { 4524 struct cmd_csum_tunnel_result *res = parsed_result; 4525 4526 if (port_id_is_invalid(res->port_id, ENABLED_WARN)) 4527 return; 4528 4529 if (!strcmp(res->onoff, "on")) 4530 ports[res->port_id].parse_tunnel = 1; 4531 else 4532 ports[res->port_id].parse_tunnel = 0; 4533 4534 csum_show(res->port_id); 4535 } 4536 4537 cmdline_parse_token_string_t cmd_csum_tunnel_csum = 4538 TOKEN_STRING_INITIALIZER(struct cmd_csum_tunnel_result, 4539 csum, "csum"); 4540 cmdline_parse_token_string_t cmd_csum_tunnel_parse = 4541 TOKEN_STRING_INITIALIZER(struct cmd_csum_tunnel_result, 4542 parse, "parse-tunnel"); 4543 cmdline_parse_token_string_t cmd_csum_tunnel_onoff = 4544 TOKEN_STRING_INITIALIZER(struct cmd_csum_tunnel_result, 4545 onoff, "on#off"); 4546 cmdline_parse_token_num_t cmd_csum_tunnel_portid = 4547 TOKEN_NUM_INITIALIZER(struct cmd_csum_tunnel_result, 4548 port_id, UINT16); 4549 4550 cmdline_parse_inst_t cmd_csum_tunnel = { 4551 .f = cmd_csum_tunnel_parsed, 4552 .data = NULL, 4553 .help_str = "csum parse-tunnel on|off <port_id>: " 4554 "Enable/Disable parsing of tunnels for csum engine", 4555 .tokens = { 4556 (void *)&cmd_csum_tunnel_csum, 4557 (void *)&cmd_csum_tunnel_parse, 4558 (void *)&cmd_csum_tunnel_onoff, 4559 (void *)&cmd_csum_tunnel_portid, 4560 NULL, 4561 }, 4562 }; 4563 4564 /* *** ENABLE HARDWARE SEGMENTATION IN TX NON-TUNNELED PACKETS *** */ 4565 struct cmd_tso_set_result { 4566 cmdline_fixed_string_t tso; 4567 cmdline_fixed_string_t mode; 4568 uint16_t tso_segsz; 4569 portid_t port_id; 4570 }; 4571 4572 static void 4573 cmd_tso_set_parsed(void *parsed_result, 4574 __attribute__((unused)) struct cmdline *cl, 4575 __attribute__((unused)) void *data) 4576 { 4577 struct cmd_tso_set_result *res = parsed_result; 4578 struct rte_eth_dev_info dev_info; 4579 int ret; 4580 4581 if (port_id_is_invalid(res->port_id, ENABLED_WARN)) 4582 return; 4583 if (!port_is_stopped(res->port_id)) { 4584 printf("Please stop port %d first\n", res->port_id); 4585 return; 4586 } 4587 4588 if (!strcmp(res->mode, "set")) 4589 ports[res->port_id].tso_segsz = res->tso_segsz; 4590 4591 ret = eth_dev_info_get_print_err(res->port_id, &dev_info); 4592 if (ret != 0) 4593 return; 4594 4595 if ((ports[res->port_id].tso_segsz != 0) && 4596 (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_TCP_TSO) == 0) { 4597 printf("Error: TSO is not supported by port %d\n", 4598 res->port_id); 4599 return; 4600 } 4601 4602 if (ports[res->port_id].tso_segsz == 0) { 4603 ports[res->port_id].dev_conf.txmode.offloads &= 4604 ~DEV_TX_OFFLOAD_TCP_TSO; 4605 printf("TSO for non-tunneled packets is disabled\n"); 4606 } else { 4607 ports[res->port_id].dev_conf.txmode.offloads |= 4608 DEV_TX_OFFLOAD_TCP_TSO; 4609 printf("TSO segment size for non-tunneled packets is %d\n", 4610 ports[res->port_id].tso_segsz); 4611 } 4612 cmd_config_queue_tx_offloads(&ports[res->port_id]); 4613 4614 /* display warnings if configuration is not supported by the NIC */ 4615 ret = eth_dev_info_get_print_err(res->port_id, &dev_info); 4616 if (ret != 0) 4617 return; 4618 4619 if ((ports[res->port_id].tso_segsz != 0) && 4620 (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_TCP_TSO) == 0) { 4621 printf("Warning: TSO enabled but not " 4622 "supported by port %d\n", res->port_id); 4623 } 4624 4625 cmd_reconfig_device_queue(res->port_id, 1, 1); 4626 } 4627 4628 cmdline_parse_token_string_t cmd_tso_set_tso = 4629 TOKEN_STRING_INITIALIZER(struct cmd_tso_set_result, 4630 tso, "tso"); 4631 cmdline_parse_token_string_t cmd_tso_set_mode = 4632 TOKEN_STRING_INITIALIZER(struct cmd_tso_set_result, 4633 mode, "set"); 4634 cmdline_parse_token_num_t cmd_tso_set_tso_segsz = 4635 TOKEN_NUM_INITIALIZER(struct cmd_tso_set_result, 4636 tso_segsz, UINT16); 4637 cmdline_parse_token_num_t cmd_tso_set_portid = 4638 TOKEN_NUM_INITIALIZER(struct cmd_tso_set_result, 4639 port_id, UINT16); 4640 4641 cmdline_parse_inst_t cmd_tso_set = { 4642 .f = cmd_tso_set_parsed, 4643 .data = NULL, 4644 .help_str = "tso set <tso_segsz> <port_id>: " 4645 "Set TSO segment size of non-tunneled packets for csum engine " 4646 "(0 to disable)", 4647 .tokens = { 4648 (void *)&cmd_tso_set_tso, 4649 (void *)&cmd_tso_set_mode, 4650 (void *)&cmd_tso_set_tso_segsz, 4651 (void *)&cmd_tso_set_portid, 4652 NULL, 4653 }, 4654 }; 4655 4656 cmdline_parse_token_string_t cmd_tso_show_mode = 4657 TOKEN_STRING_INITIALIZER(struct cmd_tso_set_result, 4658 mode, "show"); 4659 4660 4661 cmdline_parse_inst_t cmd_tso_show = { 4662 .f = cmd_tso_set_parsed, 4663 .data = NULL, 4664 .help_str = "tso show <port_id>: " 4665 "Show TSO segment size of non-tunneled packets for csum engine", 4666 .tokens = { 4667 (void *)&cmd_tso_set_tso, 4668 (void *)&cmd_tso_show_mode, 4669 (void *)&cmd_tso_set_portid, 4670 NULL, 4671 }, 4672 }; 4673 4674 /* *** ENABLE HARDWARE SEGMENTATION IN TX TUNNELED PACKETS *** */ 4675 struct cmd_tunnel_tso_set_result { 4676 cmdline_fixed_string_t tso; 4677 cmdline_fixed_string_t mode; 4678 uint16_t tso_segsz; 4679 portid_t port_id; 4680 }; 4681 4682 static struct rte_eth_dev_info 4683 check_tunnel_tso_nic_support(portid_t port_id) 4684 { 4685 struct rte_eth_dev_info dev_info; 4686 4687 if (eth_dev_info_get_print_err(port_id, &dev_info) != 0) 4688 return dev_info; 4689 4690 if (!(dev_info.tx_offload_capa & DEV_TX_OFFLOAD_VXLAN_TNL_TSO)) 4691 printf("Warning: VXLAN TUNNEL TSO not supported therefore " 4692 "not enabled for port %d\n", port_id); 4693 if (!(dev_info.tx_offload_capa & DEV_TX_OFFLOAD_GRE_TNL_TSO)) 4694 printf("Warning: GRE TUNNEL TSO not supported therefore " 4695 "not enabled for port %d\n", port_id); 4696 if (!(dev_info.tx_offload_capa & DEV_TX_OFFLOAD_IPIP_TNL_TSO)) 4697 printf("Warning: IPIP TUNNEL TSO not supported therefore " 4698 "not enabled for port %d\n", port_id); 4699 if (!(dev_info.tx_offload_capa & DEV_TX_OFFLOAD_GENEVE_TNL_TSO)) 4700 printf("Warning: GENEVE TUNNEL TSO not supported therefore " 4701 "not enabled for port %d\n", port_id); 4702 if (!(dev_info.tx_offload_capa & DEV_TX_OFFLOAD_IP_TNL_TSO)) 4703 printf("Warning: IP TUNNEL TSO not supported therefore " 4704 "not enabled for port %d\n", port_id); 4705 if (!(dev_info.tx_offload_capa & DEV_TX_OFFLOAD_UDP_TNL_TSO)) 4706 printf("Warning: UDP TUNNEL TSO not supported therefore " 4707 "not enabled for port %d\n", port_id); 4708 return dev_info; 4709 } 4710 4711 static void 4712 cmd_tunnel_tso_set_parsed(void *parsed_result, 4713 __attribute__((unused)) struct cmdline *cl, 4714 __attribute__((unused)) void *data) 4715 { 4716 struct cmd_tunnel_tso_set_result *res = parsed_result; 4717 struct rte_eth_dev_info dev_info; 4718 4719 if (port_id_is_invalid(res->port_id, ENABLED_WARN)) 4720 return; 4721 if (!port_is_stopped(res->port_id)) { 4722 printf("Please stop port %d first\n", res->port_id); 4723 return; 4724 } 4725 4726 if (!strcmp(res->mode, "set")) 4727 ports[res->port_id].tunnel_tso_segsz = res->tso_segsz; 4728 4729 dev_info = check_tunnel_tso_nic_support(res->port_id); 4730 if (ports[res->port_id].tunnel_tso_segsz == 0) { 4731 ports[res->port_id].dev_conf.txmode.offloads &= 4732 ~(DEV_TX_OFFLOAD_VXLAN_TNL_TSO | 4733 DEV_TX_OFFLOAD_GRE_TNL_TSO | 4734 DEV_TX_OFFLOAD_IPIP_TNL_TSO | 4735 DEV_TX_OFFLOAD_GENEVE_TNL_TSO | 4736 DEV_TX_OFFLOAD_IP_TNL_TSO | 4737 DEV_TX_OFFLOAD_UDP_TNL_TSO); 4738 printf("TSO for tunneled packets is disabled\n"); 4739 } else { 4740 uint64_t tso_offloads = (DEV_TX_OFFLOAD_VXLAN_TNL_TSO | 4741 DEV_TX_OFFLOAD_GRE_TNL_TSO | 4742 DEV_TX_OFFLOAD_IPIP_TNL_TSO | 4743 DEV_TX_OFFLOAD_GENEVE_TNL_TSO | 4744 DEV_TX_OFFLOAD_IP_TNL_TSO | 4745 DEV_TX_OFFLOAD_UDP_TNL_TSO); 4746 4747 ports[res->port_id].dev_conf.txmode.offloads |= 4748 (tso_offloads & dev_info.tx_offload_capa); 4749 printf("TSO segment size for tunneled packets is %d\n", 4750 ports[res->port_id].tunnel_tso_segsz); 4751 4752 /* Below conditions are needed to make it work: 4753 * (1) tunnel TSO is supported by the NIC; 4754 * (2) "csum parse_tunnel" must be set so that tunneled pkts 4755 * are recognized; 4756 * (3) for tunneled pkts with outer L3 of IPv4, 4757 * "csum set outer-ip" must be set to hw, because after tso, 4758 * total_len of outer IP header is changed, and the checksum 4759 * of outer IP header calculated by sw should be wrong; that 4760 * is not necessary for IPv6 tunneled pkts because there's no 4761 * checksum in IP header anymore. 4762 */ 4763 4764 if (!ports[res->port_id].parse_tunnel) 4765 printf("Warning: csum parse_tunnel must be set " 4766 "so that tunneled packets are recognized\n"); 4767 if (!(ports[res->port_id].dev_conf.txmode.offloads & 4768 DEV_TX_OFFLOAD_OUTER_IPV4_CKSUM)) 4769 printf("Warning: csum set outer-ip must be set to hw " 4770 "if outer L3 is IPv4; not necessary for IPv6\n"); 4771 } 4772 4773 cmd_config_queue_tx_offloads(&ports[res->port_id]); 4774 cmd_reconfig_device_queue(res->port_id, 1, 1); 4775 } 4776 4777 cmdline_parse_token_string_t cmd_tunnel_tso_set_tso = 4778 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_tso_set_result, 4779 tso, "tunnel_tso"); 4780 cmdline_parse_token_string_t cmd_tunnel_tso_set_mode = 4781 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_tso_set_result, 4782 mode, "set"); 4783 cmdline_parse_token_num_t cmd_tunnel_tso_set_tso_segsz = 4784 TOKEN_NUM_INITIALIZER(struct cmd_tunnel_tso_set_result, 4785 tso_segsz, UINT16); 4786 cmdline_parse_token_num_t cmd_tunnel_tso_set_portid = 4787 TOKEN_NUM_INITIALIZER(struct cmd_tunnel_tso_set_result, 4788 port_id, UINT16); 4789 4790 cmdline_parse_inst_t cmd_tunnel_tso_set = { 4791 .f = cmd_tunnel_tso_set_parsed, 4792 .data = NULL, 4793 .help_str = "tunnel_tso set <tso_segsz> <port_id>: " 4794 "Set TSO segment size of tunneled packets for csum engine " 4795 "(0 to disable)", 4796 .tokens = { 4797 (void *)&cmd_tunnel_tso_set_tso, 4798 (void *)&cmd_tunnel_tso_set_mode, 4799 (void *)&cmd_tunnel_tso_set_tso_segsz, 4800 (void *)&cmd_tunnel_tso_set_portid, 4801 NULL, 4802 }, 4803 }; 4804 4805 cmdline_parse_token_string_t cmd_tunnel_tso_show_mode = 4806 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_tso_set_result, 4807 mode, "show"); 4808 4809 4810 cmdline_parse_inst_t cmd_tunnel_tso_show = { 4811 .f = cmd_tunnel_tso_set_parsed, 4812 .data = NULL, 4813 .help_str = "tunnel_tso show <port_id> " 4814 "Show TSO segment size of tunneled packets for csum engine", 4815 .tokens = { 4816 (void *)&cmd_tunnel_tso_set_tso, 4817 (void *)&cmd_tunnel_tso_show_mode, 4818 (void *)&cmd_tunnel_tso_set_portid, 4819 NULL, 4820 }, 4821 }; 4822 4823 /* *** SET GRO FOR A PORT *** */ 4824 struct cmd_gro_enable_result { 4825 cmdline_fixed_string_t cmd_set; 4826 cmdline_fixed_string_t cmd_port; 4827 cmdline_fixed_string_t cmd_keyword; 4828 cmdline_fixed_string_t cmd_onoff; 4829 portid_t cmd_pid; 4830 }; 4831 4832 static void 4833 cmd_gro_enable_parsed(void *parsed_result, 4834 __attribute__((unused)) struct cmdline *cl, 4835 __attribute__((unused)) void *data) 4836 { 4837 struct cmd_gro_enable_result *res; 4838 4839 res = parsed_result; 4840 if (!strcmp(res->cmd_keyword, "gro")) 4841 setup_gro(res->cmd_onoff, res->cmd_pid); 4842 } 4843 4844 cmdline_parse_token_string_t cmd_gro_enable_set = 4845 TOKEN_STRING_INITIALIZER(struct cmd_gro_enable_result, 4846 cmd_set, "set"); 4847 cmdline_parse_token_string_t cmd_gro_enable_port = 4848 TOKEN_STRING_INITIALIZER(struct cmd_gro_enable_result, 4849 cmd_keyword, "port"); 4850 cmdline_parse_token_num_t cmd_gro_enable_pid = 4851 TOKEN_NUM_INITIALIZER(struct cmd_gro_enable_result, 4852 cmd_pid, UINT16); 4853 cmdline_parse_token_string_t cmd_gro_enable_keyword = 4854 TOKEN_STRING_INITIALIZER(struct cmd_gro_enable_result, 4855 cmd_keyword, "gro"); 4856 cmdline_parse_token_string_t cmd_gro_enable_onoff = 4857 TOKEN_STRING_INITIALIZER(struct cmd_gro_enable_result, 4858 cmd_onoff, "on#off"); 4859 4860 cmdline_parse_inst_t cmd_gro_enable = { 4861 .f = cmd_gro_enable_parsed, 4862 .data = NULL, 4863 .help_str = "set port <port_id> gro on|off", 4864 .tokens = { 4865 (void *)&cmd_gro_enable_set, 4866 (void *)&cmd_gro_enable_port, 4867 (void *)&cmd_gro_enable_pid, 4868 (void *)&cmd_gro_enable_keyword, 4869 (void *)&cmd_gro_enable_onoff, 4870 NULL, 4871 }, 4872 }; 4873 4874 /* *** DISPLAY GRO CONFIGURATION *** */ 4875 struct cmd_gro_show_result { 4876 cmdline_fixed_string_t cmd_show; 4877 cmdline_fixed_string_t cmd_port; 4878 cmdline_fixed_string_t cmd_keyword; 4879 portid_t cmd_pid; 4880 }; 4881 4882 static void 4883 cmd_gro_show_parsed(void *parsed_result, 4884 __attribute__((unused)) struct cmdline *cl, 4885 __attribute__((unused)) void *data) 4886 { 4887 struct cmd_gro_show_result *res; 4888 4889 res = parsed_result; 4890 if (!strcmp(res->cmd_keyword, "gro")) 4891 show_gro(res->cmd_pid); 4892 } 4893 4894 cmdline_parse_token_string_t cmd_gro_show_show = 4895 TOKEN_STRING_INITIALIZER(struct cmd_gro_show_result, 4896 cmd_show, "show"); 4897 cmdline_parse_token_string_t cmd_gro_show_port = 4898 TOKEN_STRING_INITIALIZER(struct cmd_gro_show_result, 4899 cmd_port, "port"); 4900 cmdline_parse_token_num_t cmd_gro_show_pid = 4901 TOKEN_NUM_INITIALIZER(struct cmd_gro_show_result, 4902 cmd_pid, UINT16); 4903 cmdline_parse_token_string_t cmd_gro_show_keyword = 4904 TOKEN_STRING_INITIALIZER(struct cmd_gro_show_result, 4905 cmd_keyword, "gro"); 4906 4907 cmdline_parse_inst_t cmd_gro_show = { 4908 .f = cmd_gro_show_parsed, 4909 .data = NULL, 4910 .help_str = "show port <port_id> gro", 4911 .tokens = { 4912 (void *)&cmd_gro_show_show, 4913 (void *)&cmd_gro_show_port, 4914 (void *)&cmd_gro_show_pid, 4915 (void *)&cmd_gro_show_keyword, 4916 NULL, 4917 }, 4918 }; 4919 4920 /* *** SET FLUSH CYCLES FOR GRO *** */ 4921 struct cmd_gro_flush_result { 4922 cmdline_fixed_string_t cmd_set; 4923 cmdline_fixed_string_t cmd_keyword; 4924 cmdline_fixed_string_t cmd_flush; 4925 uint8_t cmd_cycles; 4926 }; 4927 4928 static void 4929 cmd_gro_flush_parsed(void *parsed_result, 4930 __attribute__((unused)) struct cmdline *cl, 4931 __attribute__((unused)) void *data) 4932 { 4933 struct cmd_gro_flush_result *res; 4934 4935 res = parsed_result; 4936 if ((!strcmp(res->cmd_keyword, "gro")) && 4937 (!strcmp(res->cmd_flush, "flush"))) 4938 setup_gro_flush_cycles(res->cmd_cycles); 4939 } 4940 4941 cmdline_parse_token_string_t cmd_gro_flush_set = 4942 TOKEN_STRING_INITIALIZER(struct cmd_gro_flush_result, 4943 cmd_set, "set"); 4944 cmdline_parse_token_string_t cmd_gro_flush_keyword = 4945 TOKEN_STRING_INITIALIZER(struct cmd_gro_flush_result, 4946 cmd_keyword, "gro"); 4947 cmdline_parse_token_string_t cmd_gro_flush_flush = 4948 TOKEN_STRING_INITIALIZER(struct cmd_gro_flush_result, 4949 cmd_flush, "flush"); 4950 cmdline_parse_token_num_t cmd_gro_flush_cycles = 4951 TOKEN_NUM_INITIALIZER(struct cmd_gro_flush_result, 4952 cmd_cycles, UINT8); 4953 4954 cmdline_parse_inst_t cmd_gro_flush = { 4955 .f = cmd_gro_flush_parsed, 4956 .data = NULL, 4957 .help_str = "set gro flush <cycles>", 4958 .tokens = { 4959 (void *)&cmd_gro_flush_set, 4960 (void *)&cmd_gro_flush_keyword, 4961 (void *)&cmd_gro_flush_flush, 4962 (void *)&cmd_gro_flush_cycles, 4963 NULL, 4964 }, 4965 }; 4966 4967 /* *** ENABLE/DISABLE GSO *** */ 4968 struct cmd_gso_enable_result { 4969 cmdline_fixed_string_t cmd_set; 4970 cmdline_fixed_string_t cmd_port; 4971 cmdline_fixed_string_t cmd_keyword; 4972 cmdline_fixed_string_t cmd_mode; 4973 portid_t cmd_pid; 4974 }; 4975 4976 static void 4977 cmd_gso_enable_parsed(void *parsed_result, 4978 __attribute__((unused)) struct cmdline *cl, 4979 __attribute__((unused)) void *data) 4980 { 4981 struct cmd_gso_enable_result *res; 4982 4983 res = parsed_result; 4984 if (!strcmp(res->cmd_keyword, "gso")) 4985 setup_gso(res->cmd_mode, res->cmd_pid); 4986 } 4987 4988 cmdline_parse_token_string_t cmd_gso_enable_set = 4989 TOKEN_STRING_INITIALIZER(struct cmd_gso_enable_result, 4990 cmd_set, "set"); 4991 cmdline_parse_token_string_t cmd_gso_enable_port = 4992 TOKEN_STRING_INITIALIZER(struct cmd_gso_enable_result, 4993 cmd_port, "port"); 4994 cmdline_parse_token_string_t cmd_gso_enable_keyword = 4995 TOKEN_STRING_INITIALIZER(struct cmd_gso_enable_result, 4996 cmd_keyword, "gso"); 4997 cmdline_parse_token_string_t cmd_gso_enable_mode = 4998 TOKEN_STRING_INITIALIZER(struct cmd_gso_enable_result, 4999 cmd_mode, "on#off"); 5000 cmdline_parse_token_num_t cmd_gso_enable_pid = 5001 TOKEN_NUM_INITIALIZER(struct cmd_gso_enable_result, 5002 cmd_pid, UINT16); 5003 5004 cmdline_parse_inst_t cmd_gso_enable = { 5005 .f = cmd_gso_enable_parsed, 5006 .data = NULL, 5007 .help_str = "set port <port_id> gso on|off", 5008 .tokens = { 5009 (void *)&cmd_gso_enable_set, 5010 (void *)&cmd_gso_enable_port, 5011 (void *)&cmd_gso_enable_pid, 5012 (void *)&cmd_gso_enable_keyword, 5013 (void *)&cmd_gso_enable_mode, 5014 NULL, 5015 }, 5016 }; 5017 5018 /* *** SET MAX PACKET LENGTH FOR GSO SEGMENTS *** */ 5019 struct cmd_gso_size_result { 5020 cmdline_fixed_string_t cmd_set; 5021 cmdline_fixed_string_t cmd_keyword; 5022 cmdline_fixed_string_t cmd_segsz; 5023 uint16_t cmd_size; 5024 }; 5025 5026 static void 5027 cmd_gso_size_parsed(void *parsed_result, 5028 __attribute__((unused)) struct cmdline *cl, 5029 __attribute__((unused)) void *data) 5030 { 5031 struct cmd_gso_size_result *res = parsed_result; 5032 5033 if (test_done == 0) { 5034 printf("Before setting GSO segsz, please first" 5035 " stop fowarding\n"); 5036 return; 5037 } 5038 5039 if (!strcmp(res->cmd_keyword, "gso") && 5040 !strcmp(res->cmd_segsz, "segsz")) { 5041 if (res->cmd_size < RTE_GSO_SEG_SIZE_MIN) 5042 printf("gso_size should be larger than %zu." 5043 " Please input a legal value\n", 5044 RTE_GSO_SEG_SIZE_MIN); 5045 else 5046 gso_max_segment_size = res->cmd_size; 5047 } 5048 } 5049 5050 cmdline_parse_token_string_t cmd_gso_size_set = 5051 TOKEN_STRING_INITIALIZER(struct cmd_gso_size_result, 5052 cmd_set, "set"); 5053 cmdline_parse_token_string_t cmd_gso_size_keyword = 5054 TOKEN_STRING_INITIALIZER(struct cmd_gso_size_result, 5055 cmd_keyword, "gso"); 5056 cmdline_parse_token_string_t cmd_gso_size_segsz = 5057 TOKEN_STRING_INITIALIZER(struct cmd_gso_size_result, 5058 cmd_segsz, "segsz"); 5059 cmdline_parse_token_num_t cmd_gso_size_size = 5060 TOKEN_NUM_INITIALIZER(struct cmd_gso_size_result, 5061 cmd_size, UINT16); 5062 5063 cmdline_parse_inst_t cmd_gso_size = { 5064 .f = cmd_gso_size_parsed, 5065 .data = NULL, 5066 .help_str = "set gso segsz <length>", 5067 .tokens = { 5068 (void *)&cmd_gso_size_set, 5069 (void *)&cmd_gso_size_keyword, 5070 (void *)&cmd_gso_size_segsz, 5071 (void *)&cmd_gso_size_size, 5072 NULL, 5073 }, 5074 }; 5075 5076 /* *** SHOW GSO CONFIGURATION *** */ 5077 struct cmd_gso_show_result { 5078 cmdline_fixed_string_t cmd_show; 5079 cmdline_fixed_string_t cmd_port; 5080 cmdline_fixed_string_t cmd_keyword; 5081 portid_t cmd_pid; 5082 }; 5083 5084 static void 5085 cmd_gso_show_parsed(void *parsed_result, 5086 __attribute__((unused)) struct cmdline *cl, 5087 __attribute__((unused)) void *data) 5088 { 5089 struct cmd_gso_show_result *res = parsed_result; 5090 5091 if (!rte_eth_dev_is_valid_port(res->cmd_pid)) { 5092 printf("invalid port id %u\n", res->cmd_pid); 5093 return; 5094 } 5095 if (!strcmp(res->cmd_keyword, "gso")) { 5096 if (gso_ports[res->cmd_pid].enable) { 5097 printf("Max GSO'd packet size: %uB\n" 5098 "Supported GSO types: TCP/IPv4, " 5099 "UDP/IPv4, VxLAN with inner " 5100 "TCP/IPv4 packet, GRE with inner " 5101 "TCP/IPv4 packet\n", 5102 gso_max_segment_size); 5103 } else 5104 printf("GSO is not enabled on Port %u\n", res->cmd_pid); 5105 } 5106 } 5107 5108 cmdline_parse_token_string_t cmd_gso_show_show = 5109 TOKEN_STRING_INITIALIZER(struct cmd_gso_show_result, 5110 cmd_show, "show"); 5111 cmdline_parse_token_string_t cmd_gso_show_port = 5112 TOKEN_STRING_INITIALIZER(struct cmd_gso_show_result, 5113 cmd_port, "port"); 5114 cmdline_parse_token_string_t cmd_gso_show_keyword = 5115 TOKEN_STRING_INITIALIZER(struct cmd_gso_show_result, 5116 cmd_keyword, "gso"); 5117 cmdline_parse_token_num_t cmd_gso_show_pid = 5118 TOKEN_NUM_INITIALIZER(struct cmd_gso_show_result, 5119 cmd_pid, UINT16); 5120 5121 cmdline_parse_inst_t cmd_gso_show = { 5122 .f = cmd_gso_show_parsed, 5123 .data = NULL, 5124 .help_str = "show port <port_id> gso", 5125 .tokens = { 5126 (void *)&cmd_gso_show_show, 5127 (void *)&cmd_gso_show_port, 5128 (void *)&cmd_gso_show_pid, 5129 (void *)&cmd_gso_show_keyword, 5130 NULL, 5131 }, 5132 }; 5133 5134 /* *** ENABLE/DISABLE FLUSH ON RX STREAMS *** */ 5135 struct cmd_set_flush_rx { 5136 cmdline_fixed_string_t set; 5137 cmdline_fixed_string_t flush_rx; 5138 cmdline_fixed_string_t mode; 5139 }; 5140 5141 static void 5142 cmd_set_flush_rx_parsed(void *parsed_result, 5143 __attribute__((unused)) struct cmdline *cl, 5144 __attribute__((unused)) void *data) 5145 { 5146 struct cmd_set_flush_rx *res = parsed_result; 5147 no_flush_rx = (uint8_t)((strcmp(res->mode, "on") == 0) ? 0 : 1); 5148 } 5149 5150 cmdline_parse_token_string_t cmd_setflushrx_set = 5151 TOKEN_STRING_INITIALIZER(struct cmd_set_flush_rx, 5152 set, "set"); 5153 cmdline_parse_token_string_t cmd_setflushrx_flush_rx = 5154 TOKEN_STRING_INITIALIZER(struct cmd_set_flush_rx, 5155 flush_rx, "flush_rx"); 5156 cmdline_parse_token_string_t cmd_setflushrx_mode = 5157 TOKEN_STRING_INITIALIZER(struct cmd_set_flush_rx, 5158 mode, "on#off"); 5159 5160 5161 cmdline_parse_inst_t cmd_set_flush_rx = { 5162 .f = cmd_set_flush_rx_parsed, 5163 .help_str = "set flush_rx on|off: Enable/Disable flush on rx streams", 5164 .data = NULL, 5165 .tokens = { 5166 (void *)&cmd_setflushrx_set, 5167 (void *)&cmd_setflushrx_flush_rx, 5168 (void *)&cmd_setflushrx_mode, 5169 NULL, 5170 }, 5171 }; 5172 5173 /* *** ENABLE/DISABLE LINK STATUS CHECK *** */ 5174 struct cmd_set_link_check { 5175 cmdline_fixed_string_t set; 5176 cmdline_fixed_string_t link_check; 5177 cmdline_fixed_string_t mode; 5178 }; 5179 5180 static void 5181 cmd_set_link_check_parsed(void *parsed_result, 5182 __attribute__((unused)) struct cmdline *cl, 5183 __attribute__((unused)) void *data) 5184 { 5185 struct cmd_set_link_check *res = parsed_result; 5186 no_link_check = (uint8_t)((strcmp(res->mode, "on") == 0) ? 0 : 1); 5187 } 5188 5189 cmdline_parse_token_string_t cmd_setlinkcheck_set = 5190 TOKEN_STRING_INITIALIZER(struct cmd_set_link_check, 5191 set, "set"); 5192 cmdline_parse_token_string_t cmd_setlinkcheck_link_check = 5193 TOKEN_STRING_INITIALIZER(struct cmd_set_link_check, 5194 link_check, "link_check"); 5195 cmdline_parse_token_string_t cmd_setlinkcheck_mode = 5196 TOKEN_STRING_INITIALIZER(struct cmd_set_link_check, 5197 mode, "on#off"); 5198 5199 5200 cmdline_parse_inst_t cmd_set_link_check = { 5201 .f = cmd_set_link_check_parsed, 5202 .help_str = "set link_check on|off: Enable/Disable link status check " 5203 "when starting/stopping a port", 5204 .data = NULL, 5205 .tokens = { 5206 (void *)&cmd_setlinkcheck_set, 5207 (void *)&cmd_setlinkcheck_link_check, 5208 (void *)&cmd_setlinkcheck_mode, 5209 NULL, 5210 }, 5211 }; 5212 5213 /* *** SET NIC BYPASS MODE *** */ 5214 struct cmd_set_bypass_mode_result { 5215 cmdline_fixed_string_t set; 5216 cmdline_fixed_string_t bypass; 5217 cmdline_fixed_string_t mode; 5218 cmdline_fixed_string_t value; 5219 portid_t port_id; 5220 }; 5221 5222 static void 5223 cmd_set_bypass_mode_parsed(void *parsed_result, 5224 __attribute__((unused)) struct cmdline *cl, 5225 __attribute__((unused)) void *data) 5226 { 5227 struct cmd_set_bypass_mode_result *res = parsed_result; 5228 portid_t port_id = res->port_id; 5229 int32_t rc = -EINVAL; 5230 5231 #if defined RTE_LIBRTE_IXGBE_PMD && defined RTE_LIBRTE_IXGBE_BYPASS 5232 uint32_t bypass_mode = RTE_PMD_IXGBE_BYPASS_MODE_NORMAL; 5233 5234 if (!strcmp(res->value, "bypass")) 5235 bypass_mode = RTE_PMD_IXGBE_BYPASS_MODE_BYPASS; 5236 else if (!strcmp(res->value, "isolate")) 5237 bypass_mode = RTE_PMD_IXGBE_BYPASS_MODE_ISOLATE; 5238 else 5239 bypass_mode = RTE_PMD_IXGBE_BYPASS_MODE_NORMAL; 5240 5241 /* Set the bypass mode for the relevant port. */ 5242 rc = rte_pmd_ixgbe_bypass_state_set(port_id, &bypass_mode); 5243 #endif 5244 if (rc != 0) 5245 printf("\t Failed to set bypass mode for port = %d.\n", port_id); 5246 } 5247 5248 cmdline_parse_token_string_t cmd_setbypass_mode_set = 5249 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_mode_result, 5250 set, "set"); 5251 cmdline_parse_token_string_t cmd_setbypass_mode_bypass = 5252 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_mode_result, 5253 bypass, "bypass"); 5254 cmdline_parse_token_string_t cmd_setbypass_mode_mode = 5255 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_mode_result, 5256 mode, "mode"); 5257 cmdline_parse_token_string_t cmd_setbypass_mode_value = 5258 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_mode_result, 5259 value, "normal#bypass#isolate"); 5260 cmdline_parse_token_num_t cmd_setbypass_mode_port = 5261 TOKEN_NUM_INITIALIZER(struct cmd_set_bypass_mode_result, 5262 port_id, UINT16); 5263 5264 cmdline_parse_inst_t cmd_set_bypass_mode = { 5265 .f = cmd_set_bypass_mode_parsed, 5266 .help_str = "set bypass mode normal|bypass|isolate <port_id>: " 5267 "Set the NIC bypass mode for port_id", 5268 .data = NULL, 5269 .tokens = { 5270 (void *)&cmd_setbypass_mode_set, 5271 (void *)&cmd_setbypass_mode_bypass, 5272 (void *)&cmd_setbypass_mode_mode, 5273 (void *)&cmd_setbypass_mode_value, 5274 (void *)&cmd_setbypass_mode_port, 5275 NULL, 5276 }, 5277 }; 5278 5279 /* *** SET NIC BYPASS EVENT *** */ 5280 struct cmd_set_bypass_event_result { 5281 cmdline_fixed_string_t set; 5282 cmdline_fixed_string_t bypass; 5283 cmdline_fixed_string_t event; 5284 cmdline_fixed_string_t event_value; 5285 cmdline_fixed_string_t mode; 5286 cmdline_fixed_string_t mode_value; 5287 portid_t port_id; 5288 }; 5289 5290 static void 5291 cmd_set_bypass_event_parsed(void *parsed_result, 5292 __attribute__((unused)) struct cmdline *cl, 5293 __attribute__((unused)) void *data) 5294 { 5295 int32_t rc = -EINVAL; 5296 struct cmd_set_bypass_event_result *res = parsed_result; 5297 portid_t port_id = res->port_id; 5298 5299 #if defined RTE_LIBRTE_IXGBE_PMD && defined RTE_LIBRTE_IXGBE_BYPASS 5300 uint32_t bypass_event = RTE_PMD_IXGBE_BYPASS_EVENT_NONE; 5301 uint32_t bypass_mode = RTE_PMD_IXGBE_BYPASS_MODE_NORMAL; 5302 5303 if (!strcmp(res->event_value, "timeout")) 5304 bypass_event = RTE_PMD_IXGBE_BYPASS_EVENT_TIMEOUT; 5305 else if (!strcmp(res->event_value, "os_on")) 5306 bypass_event = RTE_PMD_IXGBE_BYPASS_EVENT_OS_ON; 5307 else if (!strcmp(res->event_value, "os_off")) 5308 bypass_event = RTE_PMD_IXGBE_BYPASS_EVENT_OS_OFF; 5309 else if (!strcmp(res->event_value, "power_on")) 5310 bypass_event = RTE_PMD_IXGBE_BYPASS_EVENT_POWER_ON; 5311 else if (!strcmp(res->event_value, "power_off")) 5312 bypass_event = RTE_PMD_IXGBE_BYPASS_EVENT_POWER_OFF; 5313 else 5314 bypass_event = RTE_PMD_IXGBE_BYPASS_EVENT_NONE; 5315 5316 if (!strcmp(res->mode_value, "bypass")) 5317 bypass_mode = RTE_PMD_IXGBE_BYPASS_MODE_BYPASS; 5318 else if (!strcmp(res->mode_value, "isolate")) 5319 bypass_mode = RTE_PMD_IXGBE_BYPASS_MODE_ISOLATE; 5320 else 5321 bypass_mode = RTE_PMD_IXGBE_BYPASS_MODE_NORMAL; 5322 5323 /* Set the watchdog timeout. */ 5324 if (bypass_event == RTE_PMD_IXGBE_BYPASS_EVENT_TIMEOUT) { 5325 5326 rc = -EINVAL; 5327 if (RTE_PMD_IXGBE_BYPASS_TMT_VALID(bypass_timeout)) { 5328 rc = rte_pmd_ixgbe_bypass_wd_timeout_store(port_id, 5329 bypass_timeout); 5330 } 5331 if (rc != 0) { 5332 printf("Failed to set timeout value %u " 5333 "for port %d, errto code: %d.\n", 5334 bypass_timeout, port_id, rc); 5335 } 5336 } 5337 5338 /* Set the bypass event to transition to bypass mode. */ 5339 rc = rte_pmd_ixgbe_bypass_event_store(port_id, bypass_event, 5340 bypass_mode); 5341 #endif 5342 5343 if (rc != 0) 5344 printf("\t Failed to set bypass event for port = %d.\n", 5345 port_id); 5346 } 5347 5348 cmdline_parse_token_string_t cmd_setbypass_event_set = 5349 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_event_result, 5350 set, "set"); 5351 cmdline_parse_token_string_t cmd_setbypass_event_bypass = 5352 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_event_result, 5353 bypass, "bypass"); 5354 cmdline_parse_token_string_t cmd_setbypass_event_event = 5355 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_event_result, 5356 event, "event"); 5357 cmdline_parse_token_string_t cmd_setbypass_event_event_value = 5358 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_event_result, 5359 event_value, "none#timeout#os_off#os_on#power_on#power_off"); 5360 cmdline_parse_token_string_t cmd_setbypass_event_mode = 5361 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_event_result, 5362 mode, "mode"); 5363 cmdline_parse_token_string_t cmd_setbypass_event_mode_value = 5364 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_event_result, 5365 mode_value, "normal#bypass#isolate"); 5366 cmdline_parse_token_num_t cmd_setbypass_event_port = 5367 TOKEN_NUM_INITIALIZER(struct cmd_set_bypass_event_result, 5368 port_id, UINT16); 5369 5370 cmdline_parse_inst_t cmd_set_bypass_event = { 5371 .f = cmd_set_bypass_event_parsed, 5372 .help_str = "set bypass event none|timeout|os_on|os_off|power_on|" 5373 "power_off mode normal|bypass|isolate <port_id>: " 5374 "Set the NIC bypass event mode for port_id", 5375 .data = NULL, 5376 .tokens = { 5377 (void *)&cmd_setbypass_event_set, 5378 (void *)&cmd_setbypass_event_bypass, 5379 (void *)&cmd_setbypass_event_event, 5380 (void *)&cmd_setbypass_event_event_value, 5381 (void *)&cmd_setbypass_event_mode, 5382 (void *)&cmd_setbypass_event_mode_value, 5383 (void *)&cmd_setbypass_event_port, 5384 NULL, 5385 }, 5386 }; 5387 5388 5389 /* *** SET NIC BYPASS TIMEOUT *** */ 5390 struct cmd_set_bypass_timeout_result { 5391 cmdline_fixed_string_t set; 5392 cmdline_fixed_string_t bypass; 5393 cmdline_fixed_string_t timeout; 5394 cmdline_fixed_string_t value; 5395 }; 5396 5397 static void 5398 cmd_set_bypass_timeout_parsed(void *parsed_result, 5399 __attribute__((unused)) struct cmdline *cl, 5400 __attribute__((unused)) void *data) 5401 { 5402 __rte_unused struct cmd_set_bypass_timeout_result *res = parsed_result; 5403 5404 #if defined RTE_LIBRTE_IXGBE_PMD && defined RTE_LIBRTE_IXGBE_BYPASS 5405 if (!strcmp(res->value, "1.5")) 5406 bypass_timeout = RTE_PMD_IXGBE_BYPASS_TMT_1_5_SEC; 5407 else if (!strcmp(res->value, "2")) 5408 bypass_timeout = RTE_PMD_IXGBE_BYPASS_TMT_2_SEC; 5409 else if (!strcmp(res->value, "3")) 5410 bypass_timeout = RTE_PMD_IXGBE_BYPASS_TMT_3_SEC; 5411 else if (!strcmp(res->value, "4")) 5412 bypass_timeout = RTE_PMD_IXGBE_BYPASS_TMT_4_SEC; 5413 else if (!strcmp(res->value, "8")) 5414 bypass_timeout = RTE_PMD_IXGBE_BYPASS_TMT_8_SEC; 5415 else if (!strcmp(res->value, "16")) 5416 bypass_timeout = RTE_PMD_IXGBE_BYPASS_TMT_16_SEC; 5417 else if (!strcmp(res->value, "32")) 5418 bypass_timeout = RTE_PMD_IXGBE_BYPASS_TMT_32_SEC; 5419 else 5420 bypass_timeout = RTE_PMD_IXGBE_BYPASS_TMT_OFF; 5421 #endif 5422 } 5423 5424 cmdline_parse_token_string_t cmd_setbypass_timeout_set = 5425 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_timeout_result, 5426 set, "set"); 5427 cmdline_parse_token_string_t cmd_setbypass_timeout_bypass = 5428 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_timeout_result, 5429 bypass, "bypass"); 5430 cmdline_parse_token_string_t cmd_setbypass_timeout_timeout = 5431 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_timeout_result, 5432 timeout, "timeout"); 5433 cmdline_parse_token_string_t cmd_setbypass_timeout_value = 5434 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_timeout_result, 5435 value, "0#1.5#2#3#4#8#16#32"); 5436 5437 cmdline_parse_inst_t cmd_set_bypass_timeout = { 5438 .f = cmd_set_bypass_timeout_parsed, 5439 .help_str = "set bypass timeout 0|1.5|2|3|4|8|16|32: " 5440 "Set the NIC bypass watchdog timeout in seconds", 5441 .data = NULL, 5442 .tokens = { 5443 (void *)&cmd_setbypass_timeout_set, 5444 (void *)&cmd_setbypass_timeout_bypass, 5445 (void *)&cmd_setbypass_timeout_timeout, 5446 (void *)&cmd_setbypass_timeout_value, 5447 NULL, 5448 }, 5449 }; 5450 5451 /* *** SHOW NIC BYPASS MODE *** */ 5452 struct cmd_show_bypass_config_result { 5453 cmdline_fixed_string_t show; 5454 cmdline_fixed_string_t bypass; 5455 cmdline_fixed_string_t config; 5456 portid_t port_id; 5457 }; 5458 5459 static void 5460 cmd_show_bypass_config_parsed(void *parsed_result, 5461 __attribute__((unused)) struct cmdline *cl, 5462 __attribute__((unused)) void *data) 5463 { 5464 struct cmd_show_bypass_config_result *res = parsed_result; 5465 portid_t port_id = res->port_id; 5466 int rc = -EINVAL; 5467 #if defined RTE_LIBRTE_IXGBE_PMD && defined RTE_LIBRTE_IXGBE_BYPASS 5468 uint32_t event_mode; 5469 uint32_t bypass_mode; 5470 uint32_t timeout = bypass_timeout; 5471 int i; 5472 5473 static const char * const timeouts[RTE_PMD_IXGBE_BYPASS_TMT_NUM] = 5474 {"off", "1.5", "2", "3", "4", "8", "16", "32"}; 5475 static const char * const modes[RTE_PMD_IXGBE_BYPASS_MODE_NUM] = 5476 {"UNKNOWN", "normal", "bypass", "isolate"}; 5477 static const char * const events[RTE_PMD_IXGBE_BYPASS_EVENT_NUM] = { 5478 "NONE", 5479 "OS/board on", 5480 "power supply on", 5481 "OS/board off", 5482 "power supply off", 5483 "timeout"}; 5484 int num_events = (sizeof events) / (sizeof events[0]); 5485 5486 /* Display the bypass mode.*/ 5487 if (rte_pmd_ixgbe_bypass_state_show(port_id, &bypass_mode) != 0) { 5488 printf("\tFailed to get bypass mode for port = %d\n", port_id); 5489 return; 5490 } 5491 else { 5492 if (!RTE_PMD_IXGBE_BYPASS_MODE_VALID(bypass_mode)) 5493 bypass_mode = RTE_PMD_IXGBE_BYPASS_MODE_NONE; 5494 5495 printf("\tbypass mode = %s\n", modes[bypass_mode]); 5496 } 5497 5498 /* Display the bypass timeout.*/ 5499 if (!RTE_PMD_IXGBE_BYPASS_TMT_VALID(timeout)) 5500 timeout = RTE_PMD_IXGBE_BYPASS_TMT_OFF; 5501 5502 printf("\tbypass timeout = %s\n", timeouts[timeout]); 5503 5504 /* Display the bypass events and associated modes. */ 5505 for (i = RTE_PMD_IXGBE_BYPASS_EVENT_START; i < num_events; i++) { 5506 5507 if (rte_pmd_ixgbe_bypass_event_show(port_id, i, &event_mode)) { 5508 printf("\tFailed to get bypass mode for event = %s\n", 5509 events[i]); 5510 } else { 5511 if (!RTE_PMD_IXGBE_BYPASS_MODE_VALID(event_mode)) 5512 event_mode = RTE_PMD_IXGBE_BYPASS_MODE_NONE; 5513 5514 printf("\tbypass event: %-16s = %s\n", events[i], 5515 modes[event_mode]); 5516 } 5517 } 5518 #endif 5519 if (rc != 0) 5520 printf("\tFailed to get bypass configuration for port = %d\n", 5521 port_id); 5522 } 5523 5524 cmdline_parse_token_string_t cmd_showbypass_config_show = 5525 TOKEN_STRING_INITIALIZER(struct cmd_show_bypass_config_result, 5526 show, "show"); 5527 cmdline_parse_token_string_t cmd_showbypass_config_bypass = 5528 TOKEN_STRING_INITIALIZER(struct cmd_show_bypass_config_result, 5529 bypass, "bypass"); 5530 cmdline_parse_token_string_t cmd_showbypass_config_config = 5531 TOKEN_STRING_INITIALIZER(struct cmd_show_bypass_config_result, 5532 config, "config"); 5533 cmdline_parse_token_num_t cmd_showbypass_config_port = 5534 TOKEN_NUM_INITIALIZER(struct cmd_show_bypass_config_result, 5535 port_id, UINT16); 5536 5537 cmdline_parse_inst_t cmd_show_bypass_config = { 5538 .f = cmd_show_bypass_config_parsed, 5539 .help_str = "show bypass config <port_id>: " 5540 "Show the NIC bypass config for port_id", 5541 .data = NULL, 5542 .tokens = { 5543 (void *)&cmd_showbypass_config_show, 5544 (void *)&cmd_showbypass_config_bypass, 5545 (void *)&cmd_showbypass_config_config, 5546 (void *)&cmd_showbypass_config_port, 5547 NULL, 5548 }, 5549 }; 5550 5551 #ifdef RTE_LIBRTE_PMD_BOND 5552 /* *** SET BONDING MODE *** */ 5553 struct cmd_set_bonding_mode_result { 5554 cmdline_fixed_string_t set; 5555 cmdline_fixed_string_t bonding; 5556 cmdline_fixed_string_t mode; 5557 uint8_t value; 5558 portid_t port_id; 5559 }; 5560 5561 static void cmd_set_bonding_mode_parsed(void *parsed_result, 5562 __attribute__((unused)) struct cmdline *cl, 5563 __attribute__((unused)) void *data) 5564 { 5565 struct cmd_set_bonding_mode_result *res = parsed_result; 5566 portid_t port_id = res->port_id; 5567 5568 /* Set the bonding mode for the relevant port. */ 5569 if (0 != rte_eth_bond_mode_set(port_id, res->value)) 5570 printf("\t Failed to set bonding mode for port = %d.\n", port_id); 5571 } 5572 5573 cmdline_parse_token_string_t cmd_setbonding_mode_set = 5574 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_mode_result, 5575 set, "set"); 5576 cmdline_parse_token_string_t cmd_setbonding_mode_bonding = 5577 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_mode_result, 5578 bonding, "bonding"); 5579 cmdline_parse_token_string_t cmd_setbonding_mode_mode = 5580 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_mode_result, 5581 mode, "mode"); 5582 cmdline_parse_token_num_t cmd_setbonding_mode_value = 5583 TOKEN_NUM_INITIALIZER(struct cmd_set_bonding_mode_result, 5584 value, UINT8); 5585 cmdline_parse_token_num_t cmd_setbonding_mode_port = 5586 TOKEN_NUM_INITIALIZER(struct cmd_set_bonding_mode_result, 5587 port_id, UINT16); 5588 5589 cmdline_parse_inst_t cmd_set_bonding_mode = { 5590 .f = cmd_set_bonding_mode_parsed, 5591 .help_str = "set bonding mode <mode_value> <port_id>: " 5592 "Set the bonding mode for port_id", 5593 .data = NULL, 5594 .tokens = { 5595 (void *) &cmd_setbonding_mode_set, 5596 (void *) &cmd_setbonding_mode_bonding, 5597 (void *) &cmd_setbonding_mode_mode, 5598 (void *) &cmd_setbonding_mode_value, 5599 (void *) &cmd_setbonding_mode_port, 5600 NULL 5601 } 5602 }; 5603 5604 /* *** SET BONDING SLOW_QUEUE SW/HW *** */ 5605 struct cmd_set_bonding_lacp_dedicated_queues_result { 5606 cmdline_fixed_string_t set; 5607 cmdline_fixed_string_t bonding; 5608 cmdline_fixed_string_t lacp; 5609 cmdline_fixed_string_t dedicated_queues; 5610 portid_t port_id; 5611 cmdline_fixed_string_t mode; 5612 }; 5613 5614 static void cmd_set_bonding_lacp_dedicated_queues_parsed(void *parsed_result, 5615 __attribute__((unused)) struct cmdline *cl, 5616 __attribute__((unused)) void *data) 5617 { 5618 struct cmd_set_bonding_lacp_dedicated_queues_result *res = parsed_result; 5619 portid_t port_id = res->port_id; 5620 struct rte_port *port; 5621 5622 port = &ports[port_id]; 5623 5624 /** Check if the port is not started **/ 5625 if (port->port_status != RTE_PORT_STOPPED) { 5626 printf("Please stop port %d first\n", port_id); 5627 return; 5628 } 5629 5630 if (!strcmp(res->mode, "enable")) { 5631 if (rte_eth_bond_8023ad_dedicated_queues_enable(port_id) == 0) 5632 printf("Dedicate queues for LACP control packets" 5633 " enabled\n"); 5634 else 5635 printf("Enabling dedicate queues for LACP control " 5636 "packets on port %d failed\n", port_id); 5637 } else if (!strcmp(res->mode, "disable")) { 5638 if (rte_eth_bond_8023ad_dedicated_queues_disable(port_id) == 0) 5639 printf("Dedicated queues for LACP control packets " 5640 "disabled\n"); 5641 else 5642 printf("Disabling dedicated queues for LACP control " 5643 "traffic on port %d failed\n", port_id); 5644 } 5645 } 5646 5647 cmdline_parse_token_string_t cmd_setbonding_lacp_dedicated_queues_set = 5648 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_lacp_dedicated_queues_result, 5649 set, "set"); 5650 cmdline_parse_token_string_t cmd_setbonding_lacp_dedicated_queues_bonding = 5651 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_lacp_dedicated_queues_result, 5652 bonding, "bonding"); 5653 cmdline_parse_token_string_t cmd_setbonding_lacp_dedicated_queues_lacp = 5654 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_lacp_dedicated_queues_result, 5655 lacp, "lacp"); 5656 cmdline_parse_token_string_t cmd_setbonding_lacp_dedicated_queues_dedicated_queues = 5657 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_lacp_dedicated_queues_result, 5658 dedicated_queues, "dedicated_queues"); 5659 cmdline_parse_token_num_t cmd_setbonding_lacp_dedicated_queues_port_id = 5660 TOKEN_NUM_INITIALIZER(struct cmd_set_bonding_lacp_dedicated_queues_result, 5661 port_id, UINT16); 5662 cmdline_parse_token_string_t cmd_setbonding_lacp_dedicated_queues_mode = 5663 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_lacp_dedicated_queues_result, 5664 mode, "enable#disable"); 5665 5666 cmdline_parse_inst_t cmd_set_lacp_dedicated_queues = { 5667 .f = cmd_set_bonding_lacp_dedicated_queues_parsed, 5668 .help_str = "set bonding lacp dedicated_queues <port_id> " 5669 "enable|disable: " 5670 "Enable/disable dedicated queues for LACP control traffic for port_id", 5671 .data = NULL, 5672 .tokens = { 5673 (void *)&cmd_setbonding_lacp_dedicated_queues_set, 5674 (void *)&cmd_setbonding_lacp_dedicated_queues_bonding, 5675 (void *)&cmd_setbonding_lacp_dedicated_queues_lacp, 5676 (void *)&cmd_setbonding_lacp_dedicated_queues_dedicated_queues, 5677 (void *)&cmd_setbonding_lacp_dedicated_queues_port_id, 5678 (void *)&cmd_setbonding_lacp_dedicated_queues_mode, 5679 NULL 5680 } 5681 }; 5682 5683 /* *** SET BALANCE XMIT POLICY *** */ 5684 struct cmd_set_bonding_balance_xmit_policy_result { 5685 cmdline_fixed_string_t set; 5686 cmdline_fixed_string_t bonding; 5687 cmdline_fixed_string_t balance_xmit_policy; 5688 portid_t port_id; 5689 cmdline_fixed_string_t policy; 5690 }; 5691 5692 static void cmd_set_bonding_balance_xmit_policy_parsed(void *parsed_result, 5693 __attribute__((unused)) struct cmdline *cl, 5694 __attribute__((unused)) void *data) 5695 { 5696 struct cmd_set_bonding_balance_xmit_policy_result *res = parsed_result; 5697 portid_t port_id = res->port_id; 5698 uint8_t policy; 5699 5700 if (!strcmp(res->policy, "l2")) { 5701 policy = BALANCE_XMIT_POLICY_LAYER2; 5702 } else if (!strcmp(res->policy, "l23")) { 5703 policy = BALANCE_XMIT_POLICY_LAYER23; 5704 } else if (!strcmp(res->policy, "l34")) { 5705 policy = BALANCE_XMIT_POLICY_LAYER34; 5706 } else { 5707 printf("\t Invalid xmit policy selection"); 5708 return; 5709 } 5710 5711 /* Set the bonding mode for the relevant port. */ 5712 if (0 != rte_eth_bond_xmit_policy_set(port_id, policy)) { 5713 printf("\t Failed to set bonding balance xmit policy for port = %d.\n", 5714 port_id); 5715 } 5716 } 5717 5718 cmdline_parse_token_string_t cmd_setbonding_balance_xmit_policy_set = 5719 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_balance_xmit_policy_result, 5720 set, "set"); 5721 cmdline_parse_token_string_t cmd_setbonding_balance_xmit_policy_bonding = 5722 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_balance_xmit_policy_result, 5723 bonding, "bonding"); 5724 cmdline_parse_token_string_t cmd_setbonding_balance_xmit_policy_balance_xmit_policy = 5725 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_balance_xmit_policy_result, 5726 balance_xmit_policy, "balance_xmit_policy"); 5727 cmdline_parse_token_num_t cmd_setbonding_balance_xmit_policy_port = 5728 TOKEN_NUM_INITIALIZER(struct cmd_set_bonding_balance_xmit_policy_result, 5729 port_id, UINT16); 5730 cmdline_parse_token_string_t cmd_setbonding_balance_xmit_policy_policy = 5731 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_balance_xmit_policy_result, 5732 policy, "l2#l23#l34"); 5733 5734 cmdline_parse_inst_t cmd_set_balance_xmit_policy = { 5735 .f = cmd_set_bonding_balance_xmit_policy_parsed, 5736 .help_str = "set bonding balance_xmit_policy <port_id> " 5737 "l2|l23|l34: " 5738 "Set the bonding balance_xmit_policy for port_id", 5739 .data = NULL, 5740 .tokens = { 5741 (void *)&cmd_setbonding_balance_xmit_policy_set, 5742 (void *)&cmd_setbonding_balance_xmit_policy_bonding, 5743 (void *)&cmd_setbonding_balance_xmit_policy_balance_xmit_policy, 5744 (void *)&cmd_setbonding_balance_xmit_policy_port, 5745 (void *)&cmd_setbonding_balance_xmit_policy_policy, 5746 NULL 5747 } 5748 }; 5749 5750 /* *** SHOW NIC BONDING CONFIGURATION *** */ 5751 struct cmd_show_bonding_config_result { 5752 cmdline_fixed_string_t show; 5753 cmdline_fixed_string_t bonding; 5754 cmdline_fixed_string_t config; 5755 portid_t port_id; 5756 }; 5757 5758 static void cmd_show_bonding_config_parsed(void *parsed_result, 5759 __attribute__((unused)) struct cmdline *cl, 5760 __attribute__((unused)) void *data) 5761 { 5762 struct cmd_show_bonding_config_result *res = parsed_result; 5763 int bonding_mode, agg_mode; 5764 portid_t slaves[RTE_MAX_ETHPORTS]; 5765 int num_slaves, num_active_slaves; 5766 int primary_id; 5767 int i; 5768 portid_t port_id = res->port_id; 5769 5770 /* Display the bonding mode.*/ 5771 bonding_mode = rte_eth_bond_mode_get(port_id); 5772 if (bonding_mode < 0) { 5773 printf("\tFailed to get bonding mode for port = %d\n", port_id); 5774 return; 5775 } else 5776 printf("\tBonding mode: %d\n", bonding_mode); 5777 5778 if (bonding_mode == BONDING_MODE_BALANCE) { 5779 int balance_xmit_policy; 5780 5781 balance_xmit_policy = rte_eth_bond_xmit_policy_get(port_id); 5782 if (balance_xmit_policy < 0) { 5783 printf("\tFailed to get balance xmit policy for port = %d\n", 5784 port_id); 5785 return; 5786 } else { 5787 printf("\tBalance Xmit Policy: "); 5788 5789 switch (balance_xmit_policy) { 5790 case BALANCE_XMIT_POLICY_LAYER2: 5791 printf("BALANCE_XMIT_POLICY_LAYER2"); 5792 break; 5793 case BALANCE_XMIT_POLICY_LAYER23: 5794 printf("BALANCE_XMIT_POLICY_LAYER23"); 5795 break; 5796 case BALANCE_XMIT_POLICY_LAYER34: 5797 printf("BALANCE_XMIT_POLICY_LAYER34"); 5798 break; 5799 } 5800 printf("\n"); 5801 } 5802 } 5803 5804 if (bonding_mode == BONDING_MODE_8023AD) { 5805 agg_mode = rte_eth_bond_8023ad_agg_selection_get(port_id); 5806 printf("\tIEEE802.3AD Aggregator Mode: "); 5807 switch (agg_mode) { 5808 case AGG_BANDWIDTH: 5809 printf("bandwidth"); 5810 break; 5811 case AGG_STABLE: 5812 printf("stable"); 5813 break; 5814 case AGG_COUNT: 5815 printf("count"); 5816 break; 5817 } 5818 printf("\n"); 5819 } 5820 5821 num_slaves = rte_eth_bond_slaves_get(port_id, slaves, RTE_MAX_ETHPORTS); 5822 5823 if (num_slaves < 0) { 5824 printf("\tFailed to get slave list for port = %d\n", port_id); 5825 return; 5826 } 5827 if (num_slaves > 0) { 5828 printf("\tSlaves (%d): [", num_slaves); 5829 for (i = 0; i < num_slaves - 1; i++) 5830 printf("%d ", slaves[i]); 5831 5832 printf("%d]\n", slaves[num_slaves - 1]); 5833 } else { 5834 printf("\tSlaves: []\n"); 5835 5836 } 5837 5838 num_active_slaves = rte_eth_bond_active_slaves_get(port_id, slaves, 5839 RTE_MAX_ETHPORTS); 5840 5841 if (num_active_slaves < 0) { 5842 printf("\tFailed to get active slave list for port = %d\n", port_id); 5843 return; 5844 } 5845 if (num_active_slaves > 0) { 5846 printf("\tActive Slaves (%d): [", num_active_slaves); 5847 for (i = 0; i < num_active_slaves - 1; i++) 5848 printf("%d ", slaves[i]); 5849 5850 printf("%d]\n", slaves[num_active_slaves - 1]); 5851 5852 } else { 5853 printf("\tActive Slaves: []\n"); 5854 5855 } 5856 5857 primary_id = rte_eth_bond_primary_get(port_id); 5858 if (primary_id < 0) { 5859 printf("\tFailed to get primary slave for port = %d\n", port_id); 5860 return; 5861 } else 5862 printf("\tPrimary: [%d]\n", primary_id); 5863 5864 } 5865 5866 cmdline_parse_token_string_t cmd_showbonding_config_show = 5867 TOKEN_STRING_INITIALIZER(struct cmd_show_bonding_config_result, 5868 show, "show"); 5869 cmdline_parse_token_string_t cmd_showbonding_config_bonding = 5870 TOKEN_STRING_INITIALIZER(struct cmd_show_bonding_config_result, 5871 bonding, "bonding"); 5872 cmdline_parse_token_string_t cmd_showbonding_config_config = 5873 TOKEN_STRING_INITIALIZER(struct cmd_show_bonding_config_result, 5874 config, "config"); 5875 cmdline_parse_token_num_t cmd_showbonding_config_port = 5876 TOKEN_NUM_INITIALIZER(struct cmd_show_bonding_config_result, 5877 port_id, UINT16); 5878 5879 cmdline_parse_inst_t cmd_show_bonding_config = { 5880 .f = cmd_show_bonding_config_parsed, 5881 .help_str = "show bonding config <port_id>: " 5882 "Show the bonding config for port_id", 5883 .data = NULL, 5884 .tokens = { 5885 (void *)&cmd_showbonding_config_show, 5886 (void *)&cmd_showbonding_config_bonding, 5887 (void *)&cmd_showbonding_config_config, 5888 (void *)&cmd_showbonding_config_port, 5889 NULL 5890 } 5891 }; 5892 5893 /* *** SET BONDING PRIMARY *** */ 5894 struct cmd_set_bonding_primary_result { 5895 cmdline_fixed_string_t set; 5896 cmdline_fixed_string_t bonding; 5897 cmdline_fixed_string_t primary; 5898 portid_t slave_id; 5899 portid_t port_id; 5900 }; 5901 5902 static void cmd_set_bonding_primary_parsed(void *parsed_result, 5903 __attribute__((unused)) struct cmdline *cl, 5904 __attribute__((unused)) void *data) 5905 { 5906 struct cmd_set_bonding_primary_result *res = parsed_result; 5907 portid_t master_port_id = res->port_id; 5908 portid_t slave_port_id = res->slave_id; 5909 5910 /* Set the primary slave for a bonded device. */ 5911 if (0 != rte_eth_bond_primary_set(master_port_id, slave_port_id)) { 5912 printf("\t Failed to set primary slave for port = %d.\n", 5913 master_port_id); 5914 return; 5915 } 5916 init_port_config(); 5917 } 5918 5919 cmdline_parse_token_string_t cmd_setbonding_primary_set = 5920 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_primary_result, 5921 set, "set"); 5922 cmdline_parse_token_string_t cmd_setbonding_primary_bonding = 5923 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_primary_result, 5924 bonding, "bonding"); 5925 cmdline_parse_token_string_t cmd_setbonding_primary_primary = 5926 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_primary_result, 5927 primary, "primary"); 5928 cmdline_parse_token_num_t cmd_setbonding_primary_slave = 5929 TOKEN_NUM_INITIALIZER(struct cmd_set_bonding_primary_result, 5930 slave_id, UINT16); 5931 cmdline_parse_token_num_t cmd_setbonding_primary_port = 5932 TOKEN_NUM_INITIALIZER(struct cmd_set_bonding_primary_result, 5933 port_id, UINT16); 5934 5935 cmdline_parse_inst_t cmd_set_bonding_primary = { 5936 .f = cmd_set_bonding_primary_parsed, 5937 .help_str = "set bonding primary <slave_id> <port_id>: " 5938 "Set the primary slave for port_id", 5939 .data = NULL, 5940 .tokens = { 5941 (void *)&cmd_setbonding_primary_set, 5942 (void *)&cmd_setbonding_primary_bonding, 5943 (void *)&cmd_setbonding_primary_primary, 5944 (void *)&cmd_setbonding_primary_slave, 5945 (void *)&cmd_setbonding_primary_port, 5946 NULL 5947 } 5948 }; 5949 5950 /* *** ADD SLAVE *** */ 5951 struct cmd_add_bonding_slave_result { 5952 cmdline_fixed_string_t add; 5953 cmdline_fixed_string_t bonding; 5954 cmdline_fixed_string_t slave; 5955 portid_t slave_id; 5956 portid_t port_id; 5957 }; 5958 5959 static void cmd_add_bonding_slave_parsed(void *parsed_result, 5960 __attribute__((unused)) struct cmdline *cl, 5961 __attribute__((unused)) void *data) 5962 { 5963 struct cmd_add_bonding_slave_result *res = parsed_result; 5964 portid_t master_port_id = res->port_id; 5965 portid_t slave_port_id = res->slave_id; 5966 5967 /* add the slave for a bonded device. */ 5968 if (0 != rte_eth_bond_slave_add(master_port_id, slave_port_id)) { 5969 printf("\t Failed to add slave %d to master port = %d.\n", 5970 slave_port_id, master_port_id); 5971 return; 5972 } 5973 init_port_config(); 5974 set_port_slave_flag(slave_port_id); 5975 } 5976 5977 cmdline_parse_token_string_t cmd_addbonding_slave_add = 5978 TOKEN_STRING_INITIALIZER(struct cmd_add_bonding_slave_result, 5979 add, "add"); 5980 cmdline_parse_token_string_t cmd_addbonding_slave_bonding = 5981 TOKEN_STRING_INITIALIZER(struct cmd_add_bonding_slave_result, 5982 bonding, "bonding"); 5983 cmdline_parse_token_string_t cmd_addbonding_slave_slave = 5984 TOKEN_STRING_INITIALIZER(struct cmd_add_bonding_slave_result, 5985 slave, "slave"); 5986 cmdline_parse_token_num_t cmd_addbonding_slave_slaveid = 5987 TOKEN_NUM_INITIALIZER(struct cmd_add_bonding_slave_result, 5988 slave_id, UINT16); 5989 cmdline_parse_token_num_t cmd_addbonding_slave_port = 5990 TOKEN_NUM_INITIALIZER(struct cmd_add_bonding_slave_result, 5991 port_id, UINT16); 5992 5993 cmdline_parse_inst_t cmd_add_bonding_slave = { 5994 .f = cmd_add_bonding_slave_parsed, 5995 .help_str = "add bonding slave <slave_id> <port_id>: " 5996 "Add a slave device to a bonded device", 5997 .data = NULL, 5998 .tokens = { 5999 (void *)&cmd_addbonding_slave_add, 6000 (void *)&cmd_addbonding_slave_bonding, 6001 (void *)&cmd_addbonding_slave_slave, 6002 (void *)&cmd_addbonding_slave_slaveid, 6003 (void *)&cmd_addbonding_slave_port, 6004 NULL 6005 } 6006 }; 6007 6008 /* *** REMOVE SLAVE *** */ 6009 struct cmd_remove_bonding_slave_result { 6010 cmdline_fixed_string_t remove; 6011 cmdline_fixed_string_t bonding; 6012 cmdline_fixed_string_t slave; 6013 portid_t slave_id; 6014 portid_t port_id; 6015 }; 6016 6017 static void cmd_remove_bonding_slave_parsed(void *parsed_result, 6018 __attribute__((unused)) struct cmdline *cl, 6019 __attribute__((unused)) void *data) 6020 { 6021 struct cmd_remove_bonding_slave_result *res = parsed_result; 6022 portid_t master_port_id = res->port_id; 6023 portid_t slave_port_id = res->slave_id; 6024 6025 /* remove the slave from a bonded device. */ 6026 if (0 != rte_eth_bond_slave_remove(master_port_id, slave_port_id)) { 6027 printf("\t Failed to remove slave %d from master port = %d.\n", 6028 slave_port_id, master_port_id); 6029 return; 6030 } 6031 init_port_config(); 6032 clear_port_slave_flag(slave_port_id); 6033 } 6034 6035 cmdline_parse_token_string_t cmd_removebonding_slave_remove = 6036 TOKEN_STRING_INITIALIZER(struct cmd_remove_bonding_slave_result, 6037 remove, "remove"); 6038 cmdline_parse_token_string_t cmd_removebonding_slave_bonding = 6039 TOKEN_STRING_INITIALIZER(struct cmd_remove_bonding_slave_result, 6040 bonding, "bonding"); 6041 cmdline_parse_token_string_t cmd_removebonding_slave_slave = 6042 TOKEN_STRING_INITIALIZER(struct cmd_remove_bonding_slave_result, 6043 slave, "slave"); 6044 cmdline_parse_token_num_t cmd_removebonding_slave_slaveid = 6045 TOKEN_NUM_INITIALIZER(struct cmd_remove_bonding_slave_result, 6046 slave_id, UINT16); 6047 cmdline_parse_token_num_t cmd_removebonding_slave_port = 6048 TOKEN_NUM_INITIALIZER(struct cmd_remove_bonding_slave_result, 6049 port_id, UINT16); 6050 6051 cmdline_parse_inst_t cmd_remove_bonding_slave = { 6052 .f = cmd_remove_bonding_slave_parsed, 6053 .help_str = "remove bonding slave <slave_id> <port_id>: " 6054 "Remove a slave device from a bonded device", 6055 .data = NULL, 6056 .tokens = { 6057 (void *)&cmd_removebonding_slave_remove, 6058 (void *)&cmd_removebonding_slave_bonding, 6059 (void *)&cmd_removebonding_slave_slave, 6060 (void *)&cmd_removebonding_slave_slaveid, 6061 (void *)&cmd_removebonding_slave_port, 6062 NULL 6063 } 6064 }; 6065 6066 /* *** CREATE BONDED DEVICE *** */ 6067 struct cmd_create_bonded_device_result { 6068 cmdline_fixed_string_t create; 6069 cmdline_fixed_string_t bonded; 6070 cmdline_fixed_string_t device; 6071 uint8_t mode; 6072 uint8_t socket; 6073 }; 6074 6075 static int bond_dev_num = 0; 6076 6077 static void cmd_create_bonded_device_parsed(void *parsed_result, 6078 __attribute__((unused)) struct cmdline *cl, 6079 __attribute__((unused)) void *data) 6080 { 6081 struct cmd_create_bonded_device_result *res = parsed_result; 6082 char ethdev_name[RTE_ETH_NAME_MAX_LEN]; 6083 int port_id; 6084 int ret; 6085 6086 if (test_done == 0) { 6087 printf("Please stop forwarding first\n"); 6088 return; 6089 } 6090 6091 snprintf(ethdev_name, RTE_ETH_NAME_MAX_LEN, "net_bonding_testpmd_%d", 6092 bond_dev_num++); 6093 6094 /* Create a new bonded device. */ 6095 port_id = rte_eth_bond_create(ethdev_name, res->mode, res->socket); 6096 if (port_id < 0) { 6097 printf("\t Failed to create bonded device.\n"); 6098 return; 6099 } else { 6100 printf("Created new bonded device %s on (port %d).\n", ethdev_name, 6101 port_id); 6102 6103 /* Update number of ports */ 6104 nb_ports = rte_eth_dev_count_avail(); 6105 reconfig(port_id, res->socket); 6106 ret = rte_eth_promiscuous_enable(port_id); 6107 if (ret != 0) 6108 printf("Failed to enable promiscuous mode for port %u: %s - ignore\n", 6109 port_id, rte_strerror(-ret)); 6110 6111 ports[port_id].need_setup = 0; 6112 ports[port_id].port_status = RTE_PORT_STOPPED; 6113 } 6114 6115 } 6116 6117 cmdline_parse_token_string_t cmd_createbonded_device_create = 6118 TOKEN_STRING_INITIALIZER(struct cmd_create_bonded_device_result, 6119 create, "create"); 6120 cmdline_parse_token_string_t cmd_createbonded_device_bonded = 6121 TOKEN_STRING_INITIALIZER(struct cmd_create_bonded_device_result, 6122 bonded, "bonded"); 6123 cmdline_parse_token_string_t cmd_createbonded_device_device = 6124 TOKEN_STRING_INITIALIZER(struct cmd_create_bonded_device_result, 6125 device, "device"); 6126 cmdline_parse_token_num_t cmd_createbonded_device_mode = 6127 TOKEN_NUM_INITIALIZER(struct cmd_create_bonded_device_result, 6128 mode, UINT8); 6129 cmdline_parse_token_num_t cmd_createbonded_device_socket = 6130 TOKEN_NUM_INITIALIZER(struct cmd_create_bonded_device_result, 6131 socket, UINT8); 6132 6133 cmdline_parse_inst_t cmd_create_bonded_device = { 6134 .f = cmd_create_bonded_device_parsed, 6135 .help_str = "create bonded device <mode> <socket>: " 6136 "Create a new bonded device with specific bonding mode and socket", 6137 .data = NULL, 6138 .tokens = { 6139 (void *)&cmd_createbonded_device_create, 6140 (void *)&cmd_createbonded_device_bonded, 6141 (void *)&cmd_createbonded_device_device, 6142 (void *)&cmd_createbonded_device_mode, 6143 (void *)&cmd_createbonded_device_socket, 6144 NULL 6145 } 6146 }; 6147 6148 /* *** SET MAC ADDRESS IN BONDED DEVICE *** */ 6149 struct cmd_set_bond_mac_addr_result { 6150 cmdline_fixed_string_t set; 6151 cmdline_fixed_string_t bonding; 6152 cmdline_fixed_string_t mac_addr; 6153 uint16_t port_num; 6154 struct rte_ether_addr address; 6155 }; 6156 6157 static void cmd_set_bond_mac_addr_parsed(void *parsed_result, 6158 __attribute__((unused)) struct cmdline *cl, 6159 __attribute__((unused)) void *data) 6160 { 6161 struct cmd_set_bond_mac_addr_result *res = parsed_result; 6162 int ret; 6163 6164 if (port_id_is_invalid(res->port_num, ENABLED_WARN)) 6165 return; 6166 6167 ret = rte_eth_bond_mac_address_set(res->port_num, &res->address); 6168 6169 /* check the return value and print it if is < 0 */ 6170 if (ret < 0) 6171 printf("set_bond_mac_addr error: (%s)\n", strerror(-ret)); 6172 } 6173 6174 cmdline_parse_token_string_t cmd_set_bond_mac_addr_set = 6175 TOKEN_STRING_INITIALIZER(struct cmd_set_bond_mac_addr_result, set, "set"); 6176 cmdline_parse_token_string_t cmd_set_bond_mac_addr_bonding = 6177 TOKEN_STRING_INITIALIZER(struct cmd_set_bond_mac_addr_result, bonding, 6178 "bonding"); 6179 cmdline_parse_token_string_t cmd_set_bond_mac_addr_mac = 6180 TOKEN_STRING_INITIALIZER(struct cmd_set_bond_mac_addr_result, mac_addr, 6181 "mac_addr"); 6182 cmdline_parse_token_num_t cmd_set_bond_mac_addr_portnum = 6183 TOKEN_NUM_INITIALIZER(struct cmd_set_bond_mac_addr_result, 6184 port_num, UINT16); 6185 cmdline_parse_token_etheraddr_t cmd_set_bond_mac_addr_addr = 6186 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_bond_mac_addr_result, address); 6187 6188 cmdline_parse_inst_t cmd_set_bond_mac_addr = { 6189 .f = cmd_set_bond_mac_addr_parsed, 6190 .data = (void *) 0, 6191 .help_str = "set bonding mac_addr <port_id> <mac_addr>", 6192 .tokens = { 6193 (void *)&cmd_set_bond_mac_addr_set, 6194 (void *)&cmd_set_bond_mac_addr_bonding, 6195 (void *)&cmd_set_bond_mac_addr_mac, 6196 (void *)&cmd_set_bond_mac_addr_portnum, 6197 (void *)&cmd_set_bond_mac_addr_addr, 6198 NULL 6199 } 6200 }; 6201 6202 6203 /* *** SET LINK STATUS MONITORING POLLING PERIOD ON BONDED DEVICE *** */ 6204 struct cmd_set_bond_mon_period_result { 6205 cmdline_fixed_string_t set; 6206 cmdline_fixed_string_t bonding; 6207 cmdline_fixed_string_t mon_period; 6208 uint16_t port_num; 6209 uint32_t period_ms; 6210 }; 6211 6212 static void cmd_set_bond_mon_period_parsed(void *parsed_result, 6213 __attribute__((unused)) struct cmdline *cl, 6214 __attribute__((unused)) void *data) 6215 { 6216 struct cmd_set_bond_mon_period_result *res = parsed_result; 6217 int ret; 6218 6219 ret = rte_eth_bond_link_monitoring_set(res->port_num, res->period_ms); 6220 6221 /* check the return value and print it if is < 0 */ 6222 if (ret < 0) 6223 printf("set_bond_mac_addr error: (%s)\n", strerror(-ret)); 6224 } 6225 6226 cmdline_parse_token_string_t cmd_set_bond_mon_period_set = 6227 TOKEN_STRING_INITIALIZER(struct cmd_set_bond_mon_period_result, 6228 set, "set"); 6229 cmdline_parse_token_string_t cmd_set_bond_mon_period_bonding = 6230 TOKEN_STRING_INITIALIZER(struct cmd_set_bond_mon_period_result, 6231 bonding, "bonding"); 6232 cmdline_parse_token_string_t cmd_set_bond_mon_period_mon_period = 6233 TOKEN_STRING_INITIALIZER(struct cmd_set_bond_mon_period_result, 6234 mon_period, "mon_period"); 6235 cmdline_parse_token_num_t cmd_set_bond_mon_period_portnum = 6236 TOKEN_NUM_INITIALIZER(struct cmd_set_bond_mon_period_result, 6237 port_num, UINT16); 6238 cmdline_parse_token_num_t cmd_set_bond_mon_period_period_ms = 6239 TOKEN_NUM_INITIALIZER(struct cmd_set_bond_mon_period_result, 6240 period_ms, UINT32); 6241 6242 cmdline_parse_inst_t cmd_set_bond_mon_period = { 6243 .f = cmd_set_bond_mon_period_parsed, 6244 .data = (void *) 0, 6245 .help_str = "set bonding mon_period <port_id> <period_ms>", 6246 .tokens = { 6247 (void *)&cmd_set_bond_mon_period_set, 6248 (void *)&cmd_set_bond_mon_period_bonding, 6249 (void *)&cmd_set_bond_mon_period_mon_period, 6250 (void *)&cmd_set_bond_mon_period_portnum, 6251 (void *)&cmd_set_bond_mon_period_period_ms, 6252 NULL 6253 } 6254 }; 6255 6256 6257 6258 struct cmd_set_bonding_agg_mode_policy_result { 6259 cmdline_fixed_string_t set; 6260 cmdline_fixed_string_t bonding; 6261 cmdline_fixed_string_t agg_mode; 6262 uint16_t port_num; 6263 cmdline_fixed_string_t policy; 6264 }; 6265 6266 6267 static void 6268 cmd_set_bonding_agg_mode(void *parsed_result, 6269 __attribute__((unused)) struct cmdline *cl, 6270 __attribute__((unused)) void *data) 6271 { 6272 struct cmd_set_bonding_agg_mode_policy_result *res = parsed_result; 6273 uint8_t policy = AGG_BANDWIDTH; 6274 6275 if (!strcmp(res->policy, "bandwidth")) 6276 policy = AGG_BANDWIDTH; 6277 else if (!strcmp(res->policy, "stable")) 6278 policy = AGG_STABLE; 6279 else if (!strcmp(res->policy, "count")) 6280 policy = AGG_COUNT; 6281 6282 rte_eth_bond_8023ad_agg_selection_set(res->port_num, policy); 6283 } 6284 6285 6286 cmdline_parse_token_string_t cmd_set_bonding_agg_mode_set = 6287 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_agg_mode_policy_result, 6288 set, "set"); 6289 cmdline_parse_token_string_t cmd_set_bonding_agg_mode_bonding = 6290 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_agg_mode_policy_result, 6291 bonding, "bonding"); 6292 6293 cmdline_parse_token_string_t cmd_set_bonding_agg_mode_agg_mode = 6294 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_agg_mode_policy_result, 6295 agg_mode, "agg_mode"); 6296 6297 cmdline_parse_token_num_t cmd_set_bonding_agg_mode_portnum = 6298 TOKEN_NUM_INITIALIZER(struct cmd_set_bonding_agg_mode_policy_result, 6299 port_num, UINT16); 6300 6301 cmdline_parse_token_string_t cmd_set_bonding_agg_mode_policy_string = 6302 TOKEN_STRING_INITIALIZER( 6303 struct cmd_set_bonding_balance_xmit_policy_result, 6304 policy, "stable#bandwidth#count"); 6305 6306 cmdline_parse_inst_t cmd_set_bonding_agg_mode_policy = { 6307 .f = cmd_set_bonding_agg_mode, 6308 .data = (void *) 0, 6309 .help_str = "set bonding mode IEEE802.3AD aggregator policy <port_id> <agg_name>", 6310 .tokens = { 6311 (void *)&cmd_set_bonding_agg_mode_set, 6312 (void *)&cmd_set_bonding_agg_mode_bonding, 6313 (void *)&cmd_set_bonding_agg_mode_agg_mode, 6314 (void *)&cmd_set_bonding_agg_mode_portnum, 6315 (void *)&cmd_set_bonding_agg_mode_policy_string, 6316 NULL 6317 } 6318 }; 6319 6320 6321 #endif /* RTE_LIBRTE_PMD_BOND */ 6322 6323 /* *** SET FORWARDING MODE *** */ 6324 struct cmd_set_fwd_mode_result { 6325 cmdline_fixed_string_t set; 6326 cmdline_fixed_string_t fwd; 6327 cmdline_fixed_string_t mode; 6328 }; 6329 6330 static void cmd_set_fwd_mode_parsed(void *parsed_result, 6331 __attribute__((unused)) struct cmdline *cl, 6332 __attribute__((unused)) void *data) 6333 { 6334 struct cmd_set_fwd_mode_result *res = parsed_result; 6335 6336 retry_enabled = 0; 6337 set_pkt_forwarding_mode(res->mode); 6338 } 6339 6340 cmdline_parse_token_string_t cmd_setfwd_set = 6341 TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_mode_result, set, "set"); 6342 cmdline_parse_token_string_t cmd_setfwd_fwd = 6343 TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_mode_result, fwd, "fwd"); 6344 cmdline_parse_token_string_t cmd_setfwd_mode = 6345 TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_mode_result, mode, 6346 "" /* defined at init */); 6347 6348 cmdline_parse_inst_t cmd_set_fwd_mode = { 6349 .f = cmd_set_fwd_mode_parsed, 6350 .data = NULL, 6351 .help_str = NULL, /* defined at init */ 6352 .tokens = { 6353 (void *)&cmd_setfwd_set, 6354 (void *)&cmd_setfwd_fwd, 6355 (void *)&cmd_setfwd_mode, 6356 NULL, 6357 }, 6358 }; 6359 6360 static void cmd_set_fwd_mode_init(void) 6361 { 6362 char *modes, *c; 6363 static char token[128]; 6364 static char help[256]; 6365 cmdline_parse_token_string_t *token_struct; 6366 6367 modes = list_pkt_forwarding_modes(); 6368 snprintf(help, sizeof(help), "set fwd %s: " 6369 "Set packet forwarding mode", modes); 6370 cmd_set_fwd_mode.help_str = help; 6371 6372 /* string token separator is # */ 6373 for (c = token; *modes != '\0'; modes++) 6374 if (*modes == '|') 6375 *c++ = '#'; 6376 else 6377 *c++ = *modes; 6378 token_struct = (cmdline_parse_token_string_t*)cmd_set_fwd_mode.tokens[2]; 6379 token_struct->string_data.str = token; 6380 } 6381 6382 /* *** SET RETRY FORWARDING MODE *** */ 6383 struct cmd_set_fwd_retry_mode_result { 6384 cmdline_fixed_string_t set; 6385 cmdline_fixed_string_t fwd; 6386 cmdline_fixed_string_t mode; 6387 cmdline_fixed_string_t retry; 6388 }; 6389 6390 static void cmd_set_fwd_retry_mode_parsed(void *parsed_result, 6391 __attribute__((unused)) struct cmdline *cl, 6392 __attribute__((unused)) void *data) 6393 { 6394 struct cmd_set_fwd_retry_mode_result *res = parsed_result; 6395 6396 retry_enabled = 1; 6397 set_pkt_forwarding_mode(res->mode); 6398 } 6399 6400 cmdline_parse_token_string_t cmd_setfwd_retry_set = 6401 TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_retry_mode_result, 6402 set, "set"); 6403 cmdline_parse_token_string_t cmd_setfwd_retry_fwd = 6404 TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_retry_mode_result, 6405 fwd, "fwd"); 6406 cmdline_parse_token_string_t cmd_setfwd_retry_mode = 6407 TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_retry_mode_result, 6408 mode, 6409 "" /* defined at init */); 6410 cmdline_parse_token_string_t cmd_setfwd_retry_retry = 6411 TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_retry_mode_result, 6412 retry, "retry"); 6413 6414 cmdline_parse_inst_t cmd_set_fwd_retry_mode = { 6415 .f = cmd_set_fwd_retry_mode_parsed, 6416 .data = NULL, 6417 .help_str = NULL, /* defined at init */ 6418 .tokens = { 6419 (void *)&cmd_setfwd_retry_set, 6420 (void *)&cmd_setfwd_retry_fwd, 6421 (void *)&cmd_setfwd_retry_mode, 6422 (void *)&cmd_setfwd_retry_retry, 6423 NULL, 6424 }, 6425 }; 6426 6427 static void cmd_set_fwd_retry_mode_init(void) 6428 { 6429 char *modes, *c; 6430 static char token[128]; 6431 static char help[256]; 6432 cmdline_parse_token_string_t *token_struct; 6433 6434 modes = list_pkt_forwarding_retry_modes(); 6435 snprintf(help, sizeof(help), "set fwd %s retry: " 6436 "Set packet forwarding mode with retry", modes); 6437 cmd_set_fwd_retry_mode.help_str = help; 6438 6439 /* string token separator is # */ 6440 for (c = token; *modes != '\0'; modes++) 6441 if (*modes == '|') 6442 *c++ = '#'; 6443 else 6444 *c++ = *modes; 6445 token_struct = (cmdline_parse_token_string_t *) 6446 cmd_set_fwd_retry_mode.tokens[2]; 6447 token_struct->string_data.str = token; 6448 } 6449 6450 /* *** SET BURST TX DELAY TIME RETRY NUMBER *** */ 6451 struct cmd_set_burst_tx_retry_result { 6452 cmdline_fixed_string_t set; 6453 cmdline_fixed_string_t burst; 6454 cmdline_fixed_string_t tx; 6455 cmdline_fixed_string_t delay; 6456 uint32_t time; 6457 cmdline_fixed_string_t retry; 6458 uint32_t retry_num; 6459 }; 6460 6461 static void cmd_set_burst_tx_retry_parsed(void *parsed_result, 6462 __attribute__((unused)) struct cmdline *cl, 6463 __attribute__((unused)) void *data) 6464 { 6465 struct cmd_set_burst_tx_retry_result *res = parsed_result; 6466 6467 if (!strcmp(res->set, "set") && !strcmp(res->burst, "burst") 6468 && !strcmp(res->tx, "tx")) { 6469 if (!strcmp(res->delay, "delay")) 6470 burst_tx_delay_time = res->time; 6471 if (!strcmp(res->retry, "retry")) 6472 burst_tx_retry_num = res->retry_num; 6473 } 6474 6475 } 6476 6477 cmdline_parse_token_string_t cmd_set_burst_tx_retry_set = 6478 TOKEN_STRING_INITIALIZER(struct cmd_set_burst_tx_retry_result, set, "set"); 6479 cmdline_parse_token_string_t cmd_set_burst_tx_retry_burst = 6480 TOKEN_STRING_INITIALIZER(struct cmd_set_burst_tx_retry_result, burst, 6481 "burst"); 6482 cmdline_parse_token_string_t cmd_set_burst_tx_retry_tx = 6483 TOKEN_STRING_INITIALIZER(struct cmd_set_burst_tx_retry_result, tx, "tx"); 6484 cmdline_parse_token_string_t cmd_set_burst_tx_retry_delay = 6485 TOKEN_STRING_INITIALIZER(struct cmd_set_burst_tx_retry_result, delay, "delay"); 6486 cmdline_parse_token_num_t cmd_set_burst_tx_retry_time = 6487 TOKEN_NUM_INITIALIZER(struct cmd_set_burst_tx_retry_result, time, UINT32); 6488 cmdline_parse_token_string_t cmd_set_burst_tx_retry_retry = 6489 TOKEN_STRING_INITIALIZER(struct cmd_set_burst_tx_retry_result, retry, "retry"); 6490 cmdline_parse_token_num_t cmd_set_burst_tx_retry_retry_num = 6491 TOKEN_NUM_INITIALIZER(struct cmd_set_burst_tx_retry_result, retry_num, UINT32); 6492 6493 cmdline_parse_inst_t cmd_set_burst_tx_retry = { 6494 .f = cmd_set_burst_tx_retry_parsed, 6495 .help_str = "set burst tx delay <delay_usec> retry <num_retry>", 6496 .tokens = { 6497 (void *)&cmd_set_burst_tx_retry_set, 6498 (void *)&cmd_set_burst_tx_retry_burst, 6499 (void *)&cmd_set_burst_tx_retry_tx, 6500 (void *)&cmd_set_burst_tx_retry_delay, 6501 (void *)&cmd_set_burst_tx_retry_time, 6502 (void *)&cmd_set_burst_tx_retry_retry, 6503 (void *)&cmd_set_burst_tx_retry_retry_num, 6504 NULL, 6505 }, 6506 }; 6507 6508 /* *** SET PROMISC MODE *** */ 6509 struct cmd_set_promisc_mode_result { 6510 cmdline_fixed_string_t set; 6511 cmdline_fixed_string_t promisc; 6512 cmdline_fixed_string_t port_all; /* valid if "allports" argument == 1 */ 6513 uint16_t port_num; /* valid if "allports" argument == 0 */ 6514 cmdline_fixed_string_t mode; 6515 }; 6516 6517 static void cmd_set_promisc_mode_parsed(void *parsed_result, 6518 __attribute__((unused)) struct cmdline *cl, 6519 void *allports) 6520 { 6521 struct cmd_set_promisc_mode_result *res = parsed_result; 6522 int enable; 6523 portid_t i; 6524 6525 if (!strcmp(res->mode, "on")) 6526 enable = 1; 6527 else 6528 enable = 0; 6529 6530 /* all ports */ 6531 if (allports) { 6532 RTE_ETH_FOREACH_DEV(i) 6533 eth_set_promisc_mode(i, enable); 6534 } else { 6535 eth_set_promisc_mode(res->port_num, enable); 6536 } 6537 } 6538 6539 cmdline_parse_token_string_t cmd_setpromisc_set = 6540 TOKEN_STRING_INITIALIZER(struct cmd_set_promisc_mode_result, set, "set"); 6541 cmdline_parse_token_string_t cmd_setpromisc_promisc = 6542 TOKEN_STRING_INITIALIZER(struct cmd_set_promisc_mode_result, promisc, 6543 "promisc"); 6544 cmdline_parse_token_string_t cmd_setpromisc_portall = 6545 TOKEN_STRING_INITIALIZER(struct cmd_set_promisc_mode_result, port_all, 6546 "all"); 6547 cmdline_parse_token_num_t cmd_setpromisc_portnum = 6548 TOKEN_NUM_INITIALIZER(struct cmd_set_promisc_mode_result, port_num, 6549 UINT16); 6550 cmdline_parse_token_string_t cmd_setpromisc_mode = 6551 TOKEN_STRING_INITIALIZER(struct cmd_set_promisc_mode_result, mode, 6552 "on#off"); 6553 6554 cmdline_parse_inst_t cmd_set_promisc_mode_all = { 6555 .f = cmd_set_promisc_mode_parsed, 6556 .data = (void *)1, 6557 .help_str = "set promisc all on|off: Set promisc mode for all ports", 6558 .tokens = { 6559 (void *)&cmd_setpromisc_set, 6560 (void *)&cmd_setpromisc_promisc, 6561 (void *)&cmd_setpromisc_portall, 6562 (void *)&cmd_setpromisc_mode, 6563 NULL, 6564 }, 6565 }; 6566 6567 cmdline_parse_inst_t cmd_set_promisc_mode_one = { 6568 .f = cmd_set_promisc_mode_parsed, 6569 .data = (void *)0, 6570 .help_str = "set promisc <port_id> on|off: Set promisc mode on port_id", 6571 .tokens = { 6572 (void *)&cmd_setpromisc_set, 6573 (void *)&cmd_setpromisc_promisc, 6574 (void *)&cmd_setpromisc_portnum, 6575 (void *)&cmd_setpromisc_mode, 6576 NULL, 6577 }, 6578 }; 6579 6580 /* *** SET ALLMULTI MODE *** */ 6581 struct cmd_set_allmulti_mode_result { 6582 cmdline_fixed_string_t set; 6583 cmdline_fixed_string_t allmulti; 6584 cmdline_fixed_string_t port_all; /* valid if "allports" argument == 1 */ 6585 uint16_t port_num; /* valid if "allports" argument == 0 */ 6586 cmdline_fixed_string_t mode; 6587 }; 6588 6589 static void cmd_set_allmulti_mode_parsed(void *parsed_result, 6590 __attribute__((unused)) struct cmdline *cl, 6591 void *allports) 6592 { 6593 struct cmd_set_allmulti_mode_result *res = parsed_result; 6594 int enable; 6595 portid_t i; 6596 6597 if (!strcmp(res->mode, "on")) 6598 enable = 1; 6599 else 6600 enable = 0; 6601 6602 /* all ports */ 6603 if (allports) { 6604 RTE_ETH_FOREACH_DEV(i) { 6605 eth_set_allmulticast_mode(i, enable); 6606 } 6607 } 6608 else { 6609 eth_set_allmulticast_mode(res->port_num, enable); 6610 } 6611 } 6612 6613 cmdline_parse_token_string_t cmd_setallmulti_set = 6614 TOKEN_STRING_INITIALIZER(struct cmd_set_allmulti_mode_result, set, "set"); 6615 cmdline_parse_token_string_t cmd_setallmulti_allmulti = 6616 TOKEN_STRING_INITIALIZER(struct cmd_set_allmulti_mode_result, allmulti, 6617 "allmulti"); 6618 cmdline_parse_token_string_t cmd_setallmulti_portall = 6619 TOKEN_STRING_INITIALIZER(struct cmd_set_allmulti_mode_result, port_all, 6620 "all"); 6621 cmdline_parse_token_num_t cmd_setallmulti_portnum = 6622 TOKEN_NUM_INITIALIZER(struct cmd_set_allmulti_mode_result, port_num, 6623 UINT16); 6624 cmdline_parse_token_string_t cmd_setallmulti_mode = 6625 TOKEN_STRING_INITIALIZER(struct cmd_set_allmulti_mode_result, mode, 6626 "on#off"); 6627 6628 cmdline_parse_inst_t cmd_set_allmulti_mode_all = { 6629 .f = cmd_set_allmulti_mode_parsed, 6630 .data = (void *)1, 6631 .help_str = "set allmulti all on|off: Set allmulti mode for all ports", 6632 .tokens = { 6633 (void *)&cmd_setallmulti_set, 6634 (void *)&cmd_setallmulti_allmulti, 6635 (void *)&cmd_setallmulti_portall, 6636 (void *)&cmd_setallmulti_mode, 6637 NULL, 6638 }, 6639 }; 6640 6641 cmdline_parse_inst_t cmd_set_allmulti_mode_one = { 6642 .f = cmd_set_allmulti_mode_parsed, 6643 .data = (void *)0, 6644 .help_str = "set allmulti <port_id> on|off: " 6645 "Set allmulti mode on port_id", 6646 .tokens = { 6647 (void *)&cmd_setallmulti_set, 6648 (void *)&cmd_setallmulti_allmulti, 6649 (void *)&cmd_setallmulti_portnum, 6650 (void *)&cmd_setallmulti_mode, 6651 NULL, 6652 }, 6653 }; 6654 6655 /* *** SETUP ETHERNET LINK FLOW CONTROL *** */ 6656 struct cmd_link_flow_ctrl_set_result { 6657 cmdline_fixed_string_t set; 6658 cmdline_fixed_string_t flow_ctrl; 6659 cmdline_fixed_string_t rx; 6660 cmdline_fixed_string_t rx_lfc_mode; 6661 cmdline_fixed_string_t tx; 6662 cmdline_fixed_string_t tx_lfc_mode; 6663 cmdline_fixed_string_t mac_ctrl_frame_fwd; 6664 cmdline_fixed_string_t mac_ctrl_frame_fwd_mode; 6665 cmdline_fixed_string_t autoneg_str; 6666 cmdline_fixed_string_t autoneg; 6667 cmdline_fixed_string_t hw_str; 6668 uint32_t high_water; 6669 cmdline_fixed_string_t lw_str; 6670 uint32_t low_water; 6671 cmdline_fixed_string_t pt_str; 6672 uint16_t pause_time; 6673 cmdline_fixed_string_t xon_str; 6674 uint16_t send_xon; 6675 portid_t port_id; 6676 }; 6677 6678 cmdline_parse_token_string_t cmd_lfc_set_set = 6679 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result, 6680 set, "set"); 6681 cmdline_parse_token_string_t cmd_lfc_set_flow_ctrl = 6682 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result, 6683 flow_ctrl, "flow_ctrl"); 6684 cmdline_parse_token_string_t cmd_lfc_set_rx = 6685 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result, 6686 rx, "rx"); 6687 cmdline_parse_token_string_t cmd_lfc_set_rx_mode = 6688 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result, 6689 rx_lfc_mode, "on#off"); 6690 cmdline_parse_token_string_t cmd_lfc_set_tx = 6691 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result, 6692 tx, "tx"); 6693 cmdline_parse_token_string_t cmd_lfc_set_tx_mode = 6694 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result, 6695 tx_lfc_mode, "on#off"); 6696 cmdline_parse_token_string_t cmd_lfc_set_high_water_str = 6697 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result, 6698 hw_str, "high_water"); 6699 cmdline_parse_token_num_t cmd_lfc_set_high_water = 6700 TOKEN_NUM_INITIALIZER(struct cmd_link_flow_ctrl_set_result, 6701 high_water, UINT32); 6702 cmdline_parse_token_string_t cmd_lfc_set_low_water_str = 6703 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result, 6704 lw_str, "low_water"); 6705 cmdline_parse_token_num_t cmd_lfc_set_low_water = 6706 TOKEN_NUM_INITIALIZER(struct cmd_link_flow_ctrl_set_result, 6707 low_water, UINT32); 6708 cmdline_parse_token_string_t cmd_lfc_set_pause_time_str = 6709 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result, 6710 pt_str, "pause_time"); 6711 cmdline_parse_token_num_t cmd_lfc_set_pause_time = 6712 TOKEN_NUM_INITIALIZER(struct cmd_link_flow_ctrl_set_result, 6713 pause_time, UINT16); 6714 cmdline_parse_token_string_t cmd_lfc_set_send_xon_str = 6715 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result, 6716 xon_str, "send_xon"); 6717 cmdline_parse_token_num_t cmd_lfc_set_send_xon = 6718 TOKEN_NUM_INITIALIZER(struct cmd_link_flow_ctrl_set_result, 6719 send_xon, UINT16); 6720 cmdline_parse_token_string_t cmd_lfc_set_mac_ctrl_frame_fwd_mode = 6721 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result, 6722 mac_ctrl_frame_fwd, "mac_ctrl_frame_fwd"); 6723 cmdline_parse_token_string_t cmd_lfc_set_mac_ctrl_frame_fwd = 6724 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result, 6725 mac_ctrl_frame_fwd_mode, "on#off"); 6726 cmdline_parse_token_string_t cmd_lfc_set_autoneg_str = 6727 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result, 6728 autoneg_str, "autoneg"); 6729 cmdline_parse_token_string_t cmd_lfc_set_autoneg = 6730 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result, 6731 autoneg, "on#off"); 6732 cmdline_parse_token_num_t cmd_lfc_set_portid = 6733 TOKEN_NUM_INITIALIZER(struct cmd_link_flow_ctrl_set_result, 6734 port_id, UINT16); 6735 6736 /* forward declaration */ 6737 static void 6738 cmd_link_flow_ctrl_set_parsed(void *parsed_result, struct cmdline *cl, 6739 void *data); 6740 6741 cmdline_parse_inst_t cmd_link_flow_control_set = { 6742 .f = cmd_link_flow_ctrl_set_parsed, 6743 .data = NULL, 6744 .help_str = "set flow_ctrl rx on|off tx on|off <high_water> " 6745 "<low_water> <pause_time> <send_xon> mac_ctrl_frame_fwd on|off " 6746 "autoneg on|off <port_id>: Configure the Ethernet flow control", 6747 .tokens = { 6748 (void *)&cmd_lfc_set_set, 6749 (void *)&cmd_lfc_set_flow_ctrl, 6750 (void *)&cmd_lfc_set_rx, 6751 (void *)&cmd_lfc_set_rx_mode, 6752 (void *)&cmd_lfc_set_tx, 6753 (void *)&cmd_lfc_set_tx_mode, 6754 (void *)&cmd_lfc_set_high_water, 6755 (void *)&cmd_lfc_set_low_water, 6756 (void *)&cmd_lfc_set_pause_time, 6757 (void *)&cmd_lfc_set_send_xon, 6758 (void *)&cmd_lfc_set_mac_ctrl_frame_fwd_mode, 6759 (void *)&cmd_lfc_set_mac_ctrl_frame_fwd, 6760 (void *)&cmd_lfc_set_autoneg_str, 6761 (void *)&cmd_lfc_set_autoneg, 6762 (void *)&cmd_lfc_set_portid, 6763 NULL, 6764 }, 6765 }; 6766 6767 cmdline_parse_inst_t cmd_link_flow_control_set_rx = { 6768 .f = cmd_link_flow_ctrl_set_parsed, 6769 .data = (void *)&cmd_link_flow_control_set_rx, 6770 .help_str = "set flow_ctrl rx on|off <port_id>: " 6771 "Change rx flow control parameter", 6772 .tokens = { 6773 (void *)&cmd_lfc_set_set, 6774 (void *)&cmd_lfc_set_flow_ctrl, 6775 (void *)&cmd_lfc_set_rx, 6776 (void *)&cmd_lfc_set_rx_mode, 6777 (void *)&cmd_lfc_set_portid, 6778 NULL, 6779 }, 6780 }; 6781 6782 cmdline_parse_inst_t cmd_link_flow_control_set_tx = { 6783 .f = cmd_link_flow_ctrl_set_parsed, 6784 .data = (void *)&cmd_link_flow_control_set_tx, 6785 .help_str = "set flow_ctrl tx on|off <port_id>: " 6786 "Change tx flow control parameter", 6787 .tokens = { 6788 (void *)&cmd_lfc_set_set, 6789 (void *)&cmd_lfc_set_flow_ctrl, 6790 (void *)&cmd_lfc_set_tx, 6791 (void *)&cmd_lfc_set_tx_mode, 6792 (void *)&cmd_lfc_set_portid, 6793 NULL, 6794 }, 6795 }; 6796 6797 cmdline_parse_inst_t cmd_link_flow_control_set_hw = { 6798 .f = cmd_link_flow_ctrl_set_parsed, 6799 .data = (void *)&cmd_link_flow_control_set_hw, 6800 .help_str = "set flow_ctrl high_water <value> <port_id>: " 6801 "Change high water flow control parameter", 6802 .tokens = { 6803 (void *)&cmd_lfc_set_set, 6804 (void *)&cmd_lfc_set_flow_ctrl, 6805 (void *)&cmd_lfc_set_high_water_str, 6806 (void *)&cmd_lfc_set_high_water, 6807 (void *)&cmd_lfc_set_portid, 6808 NULL, 6809 }, 6810 }; 6811 6812 cmdline_parse_inst_t cmd_link_flow_control_set_lw = { 6813 .f = cmd_link_flow_ctrl_set_parsed, 6814 .data = (void *)&cmd_link_flow_control_set_lw, 6815 .help_str = "set flow_ctrl low_water <value> <port_id>: " 6816 "Change low water flow control parameter", 6817 .tokens = { 6818 (void *)&cmd_lfc_set_set, 6819 (void *)&cmd_lfc_set_flow_ctrl, 6820 (void *)&cmd_lfc_set_low_water_str, 6821 (void *)&cmd_lfc_set_low_water, 6822 (void *)&cmd_lfc_set_portid, 6823 NULL, 6824 }, 6825 }; 6826 6827 cmdline_parse_inst_t cmd_link_flow_control_set_pt = { 6828 .f = cmd_link_flow_ctrl_set_parsed, 6829 .data = (void *)&cmd_link_flow_control_set_pt, 6830 .help_str = "set flow_ctrl pause_time <value> <port_id>: " 6831 "Change pause time flow control parameter", 6832 .tokens = { 6833 (void *)&cmd_lfc_set_set, 6834 (void *)&cmd_lfc_set_flow_ctrl, 6835 (void *)&cmd_lfc_set_pause_time_str, 6836 (void *)&cmd_lfc_set_pause_time, 6837 (void *)&cmd_lfc_set_portid, 6838 NULL, 6839 }, 6840 }; 6841 6842 cmdline_parse_inst_t cmd_link_flow_control_set_xon = { 6843 .f = cmd_link_flow_ctrl_set_parsed, 6844 .data = (void *)&cmd_link_flow_control_set_xon, 6845 .help_str = "set flow_ctrl send_xon <value> <port_id>: " 6846 "Change send_xon flow control parameter", 6847 .tokens = { 6848 (void *)&cmd_lfc_set_set, 6849 (void *)&cmd_lfc_set_flow_ctrl, 6850 (void *)&cmd_lfc_set_send_xon_str, 6851 (void *)&cmd_lfc_set_send_xon, 6852 (void *)&cmd_lfc_set_portid, 6853 NULL, 6854 }, 6855 }; 6856 6857 cmdline_parse_inst_t cmd_link_flow_control_set_macfwd = { 6858 .f = cmd_link_flow_ctrl_set_parsed, 6859 .data = (void *)&cmd_link_flow_control_set_macfwd, 6860 .help_str = "set flow_ctrl mac_ctrl_frame_fwd on|off <port_id>: " 6861 "Change mac ctrl fwd flow control parameter", 6862 .tokens = { 6863 (void *)&cmd_lfc_set_set, 6864 (void *)&cmd_lfc_set_flow_ctrl, 6865 (void *)&cmd_lfc_set_mac_ctrl_frame_fwd_mode, 6866 (void *)&cmd_lfc_set_mac_ctrl_frame_fwd, 6867 (void *)&cmd_lfc_set_portid, 6868 NULL, 6869 }, 6870 }; 6871 6872 cmdline_parse_inst_t cmd_link_flow_control_set_autoneg = { 6873 .f = cmd_link_flow_ctrl_set_parsed, 6874 .data = (void *)&cmd_link_flow_control_set_autoneg, 6875 .help_str = "set flow_ctrl autoneg on|off <port_id>: " 6876 "Change autoneg flow control parameter", 6877 .tokens = { 6878 (void *)&cmd_lfc_set_set, 6879 (void *)&cmd_lfc_set_flow_ctrl, 6880 (void *)&cmd_lfc_set_autoneg_str, 6881 (void *)&cmd_lfc_set_autoneg, 6882 (void *)&cmd_lfc_set_portid, 6883 NULL, 6884 }, 6885 }; 6886 6887 static void 6888 cmd_link_flow_ctrl_set_parsed(void *parsed_result, 6889 __attribute__((unused)) struct cmdline *cl, 6890 void *data) 6891 { 6892 struct cmd_link_flow_ctrl_set_result *res = parsed_result; 6893 cmdline_parse_inst_t *cmd = data; 6894 struct rte_eth_fc_conf fc_conf; 6895 int rx_fc_en = 0; 6896 int tx_fc_en = 0; 6897 int ret; 6898 6899 /* 6900 * Rx on/off, flow control is enabled/disabled on RX side. This can indicate 6901 * the RTE_FC_TX_PAUSE, Transmit pause frame at the Rx side. 6902 * Tx on/off, flow control is enabled/disabled on TX side. This can indicate 6903 * the RTE_FC_RX_PAUSE, Respond to the pause frame at the Tx side. 6904 */ 6905 static enum rte_eth_fc_mode rx_tx_onoff_2_lfc_mode[2][2] = { 6906 {RTE_FC_NONE, RTE_FC_TX_PAUSE}, {RTE_FC_RX_PAUSE, RTE_FC_FULL} 6907 }; 6908 6909 /* Partial command line, retrieve current configuration */ 6910 if (cmd) { 6911 ret = rte_eth_dev_flow_ctrl_get(res->port_id, &fc_conf); 6912 if (ret != 0) { 6913 printf("cannot get current flow ctrl parameters, return" 6914 "code = %d\n", ret); 6915 return; 6916 } 6917 6918 if ((fc_conf.mode == RTE_FC_RX_PAUSE) || 6919 (fc_conf.mode == RTE_FC_FULL)) 6920 rx_fc_en = 1; 6921 if ((fc_conf.mode == RTE_FC_TX_PAUSE) || 6922 (fc_conf.mode == RTE_FC_FULL)) 6923 tx_fc_en = 1; 6924 } 6925 6926 if (!cmd || cmd == &cmd_link_flow_control_set_rx) 6927 rx_fc_en = (!strcmp(res->rx_lfc_mode, "on")) ? 1 : 0; 6928 6929 if (!cmd || cmd == &cmd_link_flow_control_set_tx) 6930 tx_fc_en = (!strcmp(res->tx_lfc_mode, "on")) ? 1 : 0; 6931 6932 fc_conf.mode = rx_tx_onoff_2_lfc_mode[rx_fc_en][tx_fc_en]; 6933 6934 if (!cmd || cmd == &cmd_link_flow_control_set_hw) 6935 fc_conf.high_water = res->high_water; 6936 6937 if (!cmd || cmd == &cmd_link_flow_control_set_lw) 6938 fc_conf.low_water = res->low_water; 6939 6940 if (!cmd || cmd == &cmd_link_flow_control_set_pt) 6941 fc_conf.pause_time = res->pause_time; 6942 6943 if (!cmd || cmd == &cmd_link_flow_control_set_xon) 6944 fc_conf.send_xon = res->send_xon; 6945 6946 if (!cmd || cmd == &cmd_link_flow_control_set_macfwd) { 6947 if (!strcmp(res->mac_ctrl_frame_fwd_mode, "on")) 6948 fc_conf.mac_ctrl_frame_fwd = 1; 6949 else 6950 fc_conf.mac_ctrl_frame_fwd = 0; 6951 } 6952 6953 if (!cmd || cmd == &cmd_link_flow_control_set_autoneg) 6954 fc_conf.autoneg = (!strcmp(res->autoneg, "on")) ? 1 : 0; 6955 6956 ret = rte_eth_dev_flow_ctrl_set(res->port_id, &fc_conf); 6957 if (ret != 0) 6958 printf("bad flow contrl parameter, return code = %d \n", ret); 6959 } 6960 6961 /* *** SETUP ETHERNET PRIORITY FLOW CONTROL *** */ 6962 struct cmd_priority_flow_ctrl_set_result { 6963 cmdline_fixed_string_t set; 6964 cmdline_fixed_string_t pfc_ctrl; 6965 cmdline_fixed_string_t rx; 6966 cmdline_fixed_string_t rx_pfc_mode; 6967 cmdline_fixed_string_t tx; 6968 cmdline_fixed_string_t tx_pfc_mode; 6969 uint32_t high_water; 6970 uint32_t low_water; 6971 uint16_t pause_time; 6972 uint8_t priority; 6973 portid_t port_id; 6974 }; 6975 6976 static void 6977 cmd_priority_flow_ctrl_set_parsed(void *parsed_result, 6978 __attribute__((unused)) struct cmdline *cl, 6979 __attribute__((unused)) void *data) 6980 { 6981 struct cmd_priority_flow_ctrl_set_result *res = parsed_result; 6982 struct rte_eth_pfc_conf pfc_conf; 6983 int rx_fc_enable, tx_fc_enable; 6984 int ret; 6985 6986 /* 6987 * Rx on/off, flow control is enabled/disabled on RX side. This can indicate 6988 * the RTE_FC_TX_PAUSE, Transmit pause frame at the Rx side. 6989 * Tx on/off, flow control is enabled/disabled on TX side. This can indicate 6990 * the RTE_FC_RX_PAUSE, Respond to the pause frame at the Tx side. 6991 */ 6992 static enum rte_eth_fc_mode rx_tx_onoff_2_pfc_mode[2][2] = { 6993 {RTE_FC_NONE, RTE_FC_RX_PAUSE}, {RTE_FC_TX_PAUSE, RTE_FC_FULL} 6994 }; 6995 6996 rx_fc_enable = (!strncmp(res->rx_pfc_mode, "on",2)) ? 1 : 0; 6997 tx_fc_enable = (!strncmp(res->tx_pfc_mode, "on",2)) ? 1 : 0; 6998 pfc_conf.fc.mode = rx_tx_onoff_2_pfc_mode[rx_fc_enable][tx_fc_enable]; 6999 pfc_conf.fc.high_water = res->high_water; 7000 pfc_conf.fc.low_water = res->low_water; 7001 pfc_conf.fc.pause_time = res->pause_time; 7002 pfc_conf.priority = res->priority; 7003 7004 ret = rte_eth_dev_priority_flow_ctrl_set(res->port_id, &pfc_conf); 7005 if (ret != 0) 7006 printf("bad priority flow contrl parameter, return code = %d \n", ret); 7007 } 7008 7009 cmdline_parse_token_string_t cmd_pfc_set_set = 7010 TOKEN_STRING_INITIALIZER(struct cmd_priority_flow_ctrl_set_result, 7011 set, "set"); 7012 cmdline_parse_token_string_t cmd_pfc_set_flow_ctrl = 7013 TOKEN_STRING_INITIALIZER(struct cmd_priority_flow_ctrl_set_result, 7014 pfc_ctrl, "pfc_ctrl"); 7015 cmdline_parse_token_string_t cmd_pfc_set_rx = 7016 TOKEN_STRING_INITIALIZER(struct cmd_priority_flow_ctrl_set_result, 7017 rx, "rx"); 7018 cmdline_parse_token_string_t cmd_pfc_set_rx_mode = 7019 TOKEN_STRING_INITIALIZER(struct cmd_priority_flow_ctrl_set_result, 7020 rx_pfc_mode, "on#off"); 7021 cmdline_parse_token_string_t cmd_pfc_set_tx = 7022 TOKEN_STRING_INITIALIZER(struct cmd_priority_flow_ctrl_set_result, 7023 tx, "tx"); 7024 cmdline_parse_token_string_t cmd_pfc_set_tx_mode = 7025 TOKEN_STRING_INITIALIZER(struct cmd_priority_flow_ctrl_set_result, 7026 tx_pfc_mode, "on#off"); 7027 cmdline_parse_token_num_t cmd_pfc_set_high_water = 7028 TOKEN_NUM_INITIALIZER(struct cmd_priority_flow_ctrl_set_result, 7029 high_water, UINT32); 7030 cmdline_parse_token_num_t cmd_pfc_set_low_water = 7031 TOKEN_NUM_INITIALIZER(struct cmd_priority_flow_ctrl_set_result, 7032 low_water, UINT32); 7033 cmdline_parse_token_num_t cmd_pfc_set_pause_time = 7034 TOKEN_NUM_INITIALIZER(struct cmd_priority_flow_ctrl_set_result, 7035 pause_time, UINT16); 7036 cmdline_parse_token_num_t cmd_pfc_set_priority = 7037 TOKEN_NUM_INITIALIZER(struct cmd_priority_flow_ctrl_set_result, 7038 priority, UINT8); 7039 cmdline_parse_token_num_t cmd_pfc_set_portid = 7040 TOKEN_NUM_INITIALIZER(struct cmd_priority_flow_ctrl_set_result, 7041 port_id, UINT16); 7042 7043 cmdline_parse_inst_t cmd_priority_flow_control_set = { 7044 .f = cmd_priority_flow_ctrl_set_parsed, 7045 .data = NULL, 7046 .help_str = "set pfc_ctrl rx on|off tx on|off <high_water> <low_water> " 7047 "<pause_time> <priority> <port_id>: " 7048 "Configure the Ethernet priority flow control", 7049 .tokens = { 7050 (void *)&cmd_pfc_set_set, 7051 (void *)&cmd_pfc_set_flow_ctrl, 7052 (void *)&cmd_pfc_set_rx, 7053 (void *)&cmd_pfc_set_rx_mode, 7054 (void *)&cmd_pfc_set_tx, 7055 (void *)&cmd_pfc_set_tx_mode, 7056 (void *)&cmd_pfc_set_high_water, 7057 (void *)&cmd_pfc_set_low_water, 7058 (void *)&cmd_pfc_set_pause_time, 7059 (void *)&cmd_pfc_set_priority, 7060 (void *)&cmd_pfc_set_portid, 7061 NULL, 7062 }, 7063 }; 7064 7065 /* *** RESET CONFIGURATION *** */ 7066 struct cmd_reset_result { 7067 cmdline_fixed_string_t reset; 7068 cmdline_fixed_string_t def; 7069 }; 7070 7071 static void cmd_reset_parsed(__attribute__((unused)) void *parsed_result, 7072 struct cmdline *cl, 7073 __attribute__((unused)) void *data) 7074 { 7075 cmdline_printf(cl, "Reset to default forwarding configuration...\n"); 7076 set_def_fwd_config(); 7077 } 7078 7079 cmdline_parse_token_string_t cmd_reset_set = 7080 TOKEN_STRING_INITIALIZER(struct cmd_reset_result, reset, "set"); 7081 cmdline_parse_token_string_t cmd_reset_def = 7082 TOKEN_STRING_INITIALIZER(struct cmd_reset_result, def, 7083 "default"); 7084 7085 cmdline_parse_inst_t cmd_reset = { 7086 .f = cmd_reset_parsed, 7087 .data = NULL, 7088 .help_str = "set default: Reset default forwarding configuration", 7089 .tokens = { 7090 (void *)&cmd_reset_set, 7091 (void *)&cmd_reset_def, 7092 NULL, 7093 }, 7094 }; 7095 7096 /* *** START FORWARDING *** */ 7097 struct cmd_start_result { 7098 cmdline_fixed_string_t start; 7099 }; 7100 7101 cmdline_parse_token_string_t cmd_start_start = 7102 TOKEN_STRING_INITIALIZER(struct cmd_start_result, start, "start"); 7103 7104 static void cmd_start_parsed(__attribute__((unused)) void *parsed_result, 7105 __attribute__((unused)) struct cmdline *cl, 7106 __attribute__((unused)) void *data) 7107 { 7108 start_packet_forwarding(0); 7109 } 7110 7111 cmdline_parse_inst_t cmd_start = { 7112 .f = cmd_start_parsed, 7113 .data = NULL, 7114 .help_str = "start: Start packet forwarding", 7115 .tokens = { 7116 (void *)&cmd_start_start, 7117 NULL, 7118 }, 7119 }; 7120 7121 /* *** START FORWARDING WITH ONE TX BURST FIRST *** */ 7122 struct cmd_start_tx_first_result { 7123 cmdline_fixed_string_t start; 7124 cmdline_fixed_string_t tx_first; 7125 }; 7126 7127 static void 7128 cmd_start_tx_first_parsed(__attribute__((unused)) void *parsed_result, 7129 __attribute__((unused)) struct cmdline *cl, 7130 __attribute__((unused)) void *data) 7131 { 7132 start_packet_forwarding(1); 7133 } 7134 7135 cmdline_parse_token_string_t cmd_start_tx_first_start = 7136 TOKEN_STRING_INITIALIZER(struct cmd_start_tx_first_result, start, 7137 "start"); 7138 cmdline_parse_token_string_t cmd_start_tx_first_tx_first = 7139 TOKEN_STRING_INITIALIZER(struct cmd_start_tx_first_result, 7140 tx_first, "tx_first"); 7141 7142 cmdline_parse_inst_t cmd_start_tx_first = { 7143 .f = cmd_start_tx_first_parsed, 7144 .data = NULL, 7145 .help_str = "start tx_first: Start packet forwarding, " 7146 "after sending 1 burst of packets", 7147 .tokens = { 7148 (void *)&cmd_start_tx_first_start, 7149 (void *)&cmd_start_tx_first_tx_first, 7150 NULL, 7151 }, 7152 }; 7153 7154 /* *** START FORWARDING WITH N TX BURST FIRST *** */ 7155 struct cmd_start_tx_first_n_result { 7156 cmdline_fixed_string_t start; 7157 cmdline_fixed_string_t tx_first; 7158 uint32_t tx_num; 7159 }; 7160 7161 static void 7162 cmd_start_tx_first_n_parsed(void *parsed_result, 7163 __attribute__((unused)) struct cmdline *cl, 7164 __attribute__((unused)) void *data) 7165 { 7166 struct cmd_start_tx_first_n_result *res = parsed_result; 7167 7168 start_packet_forwarding(res->tx_num); 7169 } 7170 7171 cmdline_parse_token_string_t cmd_start_tx_first_n_start = 7172 TOKEN_STRING_INITIALIZER(struct cmd_start_tx_first_n_result, 7173 start, "start"); 7174 cmdline_parse_token_string_t cmd_start_tx_first_n_tx_first = 7175 TOKEN_STRING_INITIALIZER(struct cmd_start_tx_first_n_result, 7176 tx_first, "tx_first"); 7177 cmdline_parse_token_num_t cmd_start_tx_first_n_tx_num = 7178 TOKEN_NUM_INITIALIZER(struct cmd_start_tx_first_n_result, 7179 tx_num, UINT32); 7180 7181 cmdline_parse_inst_t cmd_start_tx_first_n = { 7182 .f = cmd_start_tx_first_n_parsed, 7183 .data = NULL, 7184 .help_str = "start tx_first <num>: " 7185 "packet forwarding, after sending <num> bursts of packets", 7186 .tokens = { 7187 (void *)&cmd_start_tx_first_n_start, 7188 (void *)&cmd_start_tx_first_n_tx_first, 7189 (void *)&cmd_start_tx_first_n_tx_num, 7190 NULL, 7191 }, 7192 }; 7193 7194 /* *** SET LINK UP *** */ 7195 struct cmd_set_link_up_result { 7196 cmdline_fixed_string_t set; 7197 cmdline_fixed_string_t link_up; 7198 cmdline_fixed_string_t port; 7199 portid_t port_id; 7200 }; 7201 7202 cmdline_parse_token_string_t cmd_set_link_up_set = 7203 TOKEN_STRING_INITIALIZER(struct cmd_set_link_up_result, set, "set"); 7204 cmdline_parse_token_string_t cmd_set_link_up_link_up = 7205 TOKEN_STRING_INITIALIZER(struct cmd_set_link_up_result, link_up, 7206 "link-up"); 7207 cmdline_parse_token_string_t cmd_set_link_up_port = 7208 TOKEN_STRING_INITIALIZER(struct cmd_set_link_up_result, port, "port"); 7209 cmdline_parse_token_num_t cmd_set_link_up_port_id = 7210 TOKEN_NUM_INITIALIZER(struct cmd_set_link_up_result, port_id, UINT16); 7211 7212 static void cmd_set_link_up_parsed(__attribute__((unused)) void *parsed_result, 7213 __attribute__((unused)) struct cmdline *cl, 7214 __attribute__((unused)) void *data) 7215 { 7216 struct cmd_set_link_up_result *res = parsed_result; 7217 dev_set_link_up(res->port_id); 7218 } 7219 7220 cmdline_parse_inst_t cmd_set_link_up = { 7221 .f = cmd_set_link_up_parsed, 7222 .data = NULL, 7223 .help_str = "set link-up port <port id>", 7224 .tokens = { 7225 (void *)&cmd_set_link_up_set, 7226 (void *)&cmd_set_link_up_link_up, 7227 (void *)&cmd_set_link_up_port, 7228 (void *)&cmd_set_link_up_port_id, 7229 NULL, 7230 }, 7231 }; 7232 7233 /* *** SET LINK DOWN *** */ 7234 struct cmd_set_link_down_result { 7235 cmdline_fixed_string_t set; 7236 cmdline_fixed_string_t link_down; 7237 cmdline_fixed_string_t port; 7238 portid_t port_id; 7239 }; 7240 7241 cmdline_parse_token_string_t cmd_set_link_down_set = 7242 TOKEN_STRING_INITIALIZER(struct cmd_set_link_down_result, set, "set"); 7243 cmdline_parse_token_string_t cmd_set_link_down_link_down = 7244 TOKEN_STRING_INITIALIZER(struct cmd_set_link_down_result, link_down, 7245 "link-down"); 7246 cmdline_parse_token_string_t cmd_set_link_down_port = 7247 TOKEN_STRING_INITIALIZER(struct cmd_set_link_down_result, port, "port"); 7248 cmdline_parse_token_num_t cmd_set_link_down_port_id = 7249 TOKEN_NUM_INITIALIZER(struct cmd_set_link_down_result, port_id, UINT16); 7250 7251 static void cmd_set_link_down_parsed( 7252 __attribute__((unused)) void *parsed_result, 7253 __attribute__((unused)) struct cmdline *cl, 7254 __attribute__((unused)) void *data) 7255 { 7256 struct cmd_set_link_down_result *res = parsed_result; 7257 dev_set_link_down(res->port_id); 7258 } 7259 7260 cmdline_parse_inst_t cmd_set_link_down = { 7261 .f = cmd_set_link_down_parsed, 7262 .data = NULL, 7263 .help_str = "set link-down port <port id>", 7264 .tokens = { 7265 (void *)&cmd_set_link_down_set, 7266 (void *)&cmd_set_link_down_link_down, 7267 (void *)&cmd_set_link_down_port, 7268 (void *)&cmd_set_link_down_port_id, 7269 NULL, 7270 }, 7271 }; 7272 7273 /* *** SHOW CFG *** */ 7274 struct cmd_showcfg_result { 7275 cmdline_fixed_string_t show; 7276 cmdline_fixed_string_t cfg; 7277 cmdline_fixed_string_t what; 7278 }; 7279 7280 static void cmd_showcfg_parsed(void *parsed_result, 7281 __attribute__((unused)) struct cmdline *cl, 7282 __attribute__((unused)) void *data) 7283 { 7284 struct cmd_showcfg_result *res = parsed_result; 7285 if (!strcmp(res->what, "rxtx")) 7286 rxtx_config_display(); 7287 else if (!strcmp(res->what, "cores")) 7288 fwd_lcores_config_display(); 7289 else if (!strcmp(res->what, "fwd")) 7290 pkt_fwd_config_display(&cur_fwd_config); 7291 else if (!strcmp(res->what, "txpkts")) 7292 show_tx_pkt_segments(); 7293 } 7294 7295 cmdline_parse_token_string_t cmd_showcfg_show = 7296 TOKEN_STRING_INITIALIZER(struct cmd_showcfg_result, show, "show"); 7297 cmdline_parse_token_string_t cmd_showcfg_port = 7298 TOKEN_STRING_INITIALIZER(struct cmd_showcfg_result, cfg, "config"); 7299 cmdline_parse_token_string_t cmd_showcfg_what = 7300 TOKEN_STRING_INITIALIZER(struct cmd_showcfg_result, what, 7301 "rxtx#cores#fwd#txpkts"); 7302 7303 cmdline_parse_inst_t cmd_showcfg = { 7304 .f = cmd_showcfg_parsed, 7305 .data = NULL, 7306 .help_str = "show config rxtx|cores|fwd|txpkts", 7307 .tokens = { 7308 (void *)&cmd_showcfg_show, 7309 (void *)&cmd_showcfg_port, 7310 (void *)&cmd_showcfg_what, 7311 NULL, 7312 }, 7313 }; 7314 7315 /* *** SHOW ALL PORT INFO *** */ 7316 struct cmd_showportall_result { 7317 cmdline_fixed_string_t show; 7318 cmdline_fixed_string_t port; 7319 cmdline_fixed_string_t what; 7320 cmdline_fixed_string_t all; 7321 }; 7322 7323 static void cmd_showportall_parsed(void *parsed_result, 7324 __attribute__((unused)) struct cmdline *cl, 7325 __attribute__((unused)) void *data) 7326 { 7327 portid_t i; 7328 7329 struct cmd_showportall_result *res = parsed_result; 7330 if (!strcmp(res->show, "clear")) { 7331 if (!strcmp(res->what, "stats")) 7332 RTE_ETH_FOREACH_DEV(i) 7333 nic_stats_clear(i); 7334 else if (!strcmp(res->what, "xstats")) 7335 RTE_ETH_FOREACH_DEV(i) 7336 nic_xstats_clear(i); 7337 } else if (!strcmp(res->what, "info")) 7338 RTE_ETH_FOREACH_DEV(i) 7339 port_infos_display(i); 7340 else if (!strcmp(res->what, "summary")) { 7341 port_summary_header_display(); 7342 RTE_ETH_FOREACH_DEV(i) 7343 port_summary_display(i); 7344 } 7345 else if (!strcmp(res->what, "stats")) 7346 RTE_ETH_FOREACH_DEV(i) 7347 nic_stats_display(i); 7348 else if (!strcmp(res->what, "xstats")) 7349 RTE_ETH_FOREACH_DEV(i) 7350 nic_xstats_display(i); 7351 else if (!strcmp(res->what, "fdir")) 7352 RTE_ETH_FOREACH_DEV(i) 7353 fdir_get_infos(i); 7354 else if (!strcmp(res->what, "stat_qmap")) 7355 RTE_ETH_FOREACH_DEV(i) 7356 nic_stats_mapping_display(i); 7357 else if (!strcmp(res->what, "dcb_tc")) 7358 RTE_ETH_FOREACH_DEV(i) 7359 port_dcb_info_display(i); 7360 else if (!strcmp(res->what, "cap")) 7361 RTE_ETH_FOREACH_DEV(i) 7362 port_offload_cap_display(i); 7363 } 7364 7365 cmdline_parse_token_string_t cmd_showportall_show = 7366 TOKEN_STRING_INITIALIZER(struct cmd_showportall_result, show, 7367 "show#clear"); 7368 cmdline_parse_token_string_t cmd_showportall_port = 7369 TOKEN_STRING_INITIALIZER(struct cmd_showportall_result, port, "port"); 7370 cmdline_parse_token_string_t cmd_showportall_what = 7371 TOKEN_STRING_INITIALIZER(struct cmd_showportall_result, what, 7372 "info#summary#stats#xstats#fdir#stat_qmap#dcb_tc#cap"); 7373 cmdline_parse_token_string_t cmd_showportall_all = 7374 TOKEN_STRING_INITIALIZER(struct cmd_showportall_result, all, "all"); 7375 cmdline_parse_inst_t cmd_showportall = { 7376 .f = cmd_showportall_parsed, 7377 .data = NULL, 7378 .help_str = "show|clear port " 7379 "info|summary|stats|xstats|fdir|stat_qmap|dcb_tc|cap all", 7380 .tokens = { 7381 (void *)&cmd_showportall_show, 7382 (void *)&cmd_showportall_port, 7383 (void *)&cmd_showportall_what, 7384 (void *)&cmd_showportall_all, 7385 NULL, 7386 }, 7387 }; 7388 7389 /* *** SHOW PORT INFO *** */ 7390 struct cmd_showport_result { 7391 cmdline_fixed_string_t show; 7392 cmdline_fixed_string_t port; 7393 cmdline_fixed_string_t what; 7394 uint16_t portnum; 7395 }; 7396 7397 static void cmd_showport_parsed(void *parsed_result, 7398 __attribute__((unused)) struct cmdline *cl, 7399 __attribute__((unused)) void *data) 7400 { 7401 struct cmd_showport_result *res = parsed_result; 7402 if (!strcmp(res->show, "clear")) { 7403 if (!strcmp(res->what, "stats")) 7404 nic_stats_clear(res->portnum); 7405 else if (!strcmp(res->what, "xstats")) 7406 nic_xstats_clear(res->portnum); 7407 } else if (!strcmp(res->what, "info")) 7408 port_infos_display(res->portnum); 7409 else if (!strcmp(res->what, "summary")) { 7410 port_summary_header_display(); 7411 port_summary_display(res->portnum); 7412 } 7413 else if (!strcmp(res->what, "stats")) 7414 nic_stats_display(res->portnum); 7415 else if (!strcmp(res->what, "xstats")) 7416 nic_xstats_display(res->portnum); 7417 else if (!strcmp(res->what, "fdir")) 7418 fdir_get_infos(res->portnum); 7419 else if (!strcmp(res->what, "stat_qmap")) 7420 nic_stats_mapping_display(res->portnum); 7421 else if (!strcmp(res->what, "dcb_tc")) 7422 port_dcb_info_display(res->portnum); 7423 else if (!strcmp(res->what, "cap")) 7424 port_offload_cap_display(res->portnum); 7425 } 7426 7427 cmdline_parse_token_string_t cmd_showport_show = 7428 TOKEN_STRING_INITIALIZER(struct cmd_showport_result, show, 7429 "show#clear"); 7430 cmdline_parse_token_string_t cmd_showport_port = 7431 TOKEN_STRING_INITIALIZER(struct cmd_showport_result, port, "port"); 7432 cmdline_parse_token_string_t cmd_showport_what = 7433 TOKEN_STRING_INITIALIZER(struct cmd_showport_result, what, 7434 "info#summary#stats#xstats#fdir#stat_qmap#dcb_tc#cap"); 7435 cmdline_parse_token_num_t cmd_showport_portnum = 7436 TOKEN_NUM_INITIALIZER(struct cmd_showport_result, portnum, UINT16); 7437 7438 cmdline_parse_inst_t cmd_showport = { 7439 .f = cmd_showport_parsed, 7440 .data = NULL, 7441 .help_str = "show|clear port " 7442 "info|summary|stats|xstats|fdir|stat_qmap|dcb_tc|cap " 7443 "<port_id>", 7444 .tokens = { 7445 (void *)&cmd_showport_show, 7446 (void *)&cmd_showport_port, 7447 (void *)&cmd_showport_what, 7448 (void *)&cmd_showport_portnum, 7449 NULL, 7450 }, 7451 }; 7452 7453 /* *** SHOW DEVICE INFO *** */ 7454 struct cmd_showdevice_result { 7455 cmdline_fixed_string_t show; 7456 cmdline_fixed_string_t device; 7457 cmdline_fixed_string_t what; 7458 cmdline_fixed_string_t identifier; 7459 }; 7460 7461 static void cmd_showdevice_parsed(void *parsed_result, 7462 __attribute__((unused)) struct cmdline *cl, 7463 __attribute__((unused)) void *data) 7464 { 7465 struct cmd_showdevice_result *res = parsed_result; 7466 if (!strcmp(res->what, "info")) { 7467 if (!strcmp(res->identifier, "all")) 7468 device_infos_display(NULL); 7469 else 7470 device_infos_display(res->identifier); 7471 } 7472 } 7473 7474 cmdline_parse_token_string_t cmd_showdevice_show = 7475 TOKEN_STRING_INITIALIZER(struct cmd_showdevice_result, show, 7476 "show"); 7477 cmdline_parse_token_string_t cmd_showdevice_device = 7478 TOKEN_STRING_INITIALIZER(struct cmd_showdevice_result, device, "device"); 7479 cmdline_parse_token_string_t cmd_showdevice_what = 7480 TOKEN_STRING_INITIALIZER(struct cmd_showdevice_result, what, 7481 "info"); 7482 cmdline_parse_token_string_t cmd_showdevice_identifier = 7483 TOKEN_STRING_INITIALIZER(struct cmd_showdevice_result, 7484 identifier, NULL); 7485 7486 cmdline_parse_inst_t cmd_showdevice = { 7487 .f = cmd_showdevice_parsed, 7488 .data = NULL, 7489 .help_str = "show device info <identifier>|all", 7490 .tokens = { 7491 (void *)&cmd_showdevice_show, 7492 (void *)&cmd_showdevice_device, 7493 (void *)&cmd_showdevice_what, 7494 (void *)&cmd_showdevice_identifier, 7495 NULL, 7496 }, 7497 }; 7498 /* *** SHOW QUEUE INFO *** */ 7499 struct cmd_showqueue_result { 7500 cmdline_fixed_string_t show; 7501 cmdline_fixed_string_t type; 7502 cmdline_fixed_string_t what; 7503 uint16_t portnum; 7504 uint16_t queuenum; 7505 }; 7506 7507 static void 7508 cmd_showqueue_parsed(void *parsed_result, 7509 __attribute__((unused)) struct cmdline *cl, 7510 __attribute__((unused)) void *data) 7511 { 7512 struct cmd_showqueue_result *res = parsed_result; 7513 7514 if (!strcmp(res->type, "rxq")) 7515 rx_queue_infos_display(res->portnum, res->queuenum); 7516 else if (!strcmp(res->type, "txq")) 7517 tx_queue_infos_display(res->portnum, res->queuenum); 7518 } 7519 7520 cmdline_parse_token_string_t cmd_showqueue_show = 7521 TOKEN_STRING_INITIALIZER(struct cmd_showqueue_result, show, "show"); 7522 cmdline_parse_token_string_t cmd_showqueue_type = 7523 TOKEN_STRING_INITIALIZER(struct cmd_showqueue_result, type, "rxq#txq"); 7524 cmdline_parse_token_string_t cmd_showqueue_what = 7525 TOKEN_STRING_INITIALIZER(struct cmd_showqueue_result, what, "info"); 7526 cmdline_parse_token_num_t cmd_showqueue_portnum = 7527 TOKEN_NUM_INITIALIZER(struct cmd_showqueue_result, portnum, UINT16); 7528 cmdline_parse_token_num_t cmd_showqueue_queuenum = 7529 TOKEN_NUM_INITIALIZER(struct cmd_showqueue_result, queuenum, UINT16); 7530 7531 cmdline_parse_inst_t cmd_showqueue = { 7532 .f = cmd_showqueue_parsed, 7533 .data = NULL, 7534 .help_str = "show rxq|txq info <port_id> <queue_id>", 7535 .tokens = { 7536 (void *)&cmd_showqueue_show, 7537 (void *)&cmd_showqueue_type, 7538 (void *)&cmd_showqueue_what, 7539 (void *)&cmd_showqueue_portnum, 7540 (void *)&cmd_showqueue_queuenum, 7541 NULL, 7542 }, 7543 }; 7544 7545 /* show/clear fwd engine statistics */ 7546 struct fwd_result { 7547 cmdline_fixed_string_t action; 7548 cmdline_fixed_string_t fwd; 7549 cmdline_fixed_string_t stats; 7550 cmdline_fixed_string_t all; 7551 }; 7552 7553 cmdline_parse_token_string_t cmd_fwd_action = 7554 TOKEN_STRING_INITIALIZER(struct fwd_result, action, "show#clear"); 7555 cmdline_parse_token_string_t cmd_fwd_fwd = 7556 TOKEN_STRING_INITIALIZER(struct fwd_result, fwd, "fwd"); 7557 cmdline_parse_token_string_t cmd_fwd_stats = 7558 TOKEN_STRING_INITIALIZER(struct fwd_result, stats, "stats"); 7559 cmdline_parse_token_string_t cmd_fwd_all = 7560 TOKEN_STRING_INITIALIZER(struct fwd_result, all, "all"); 7561 7562 static void 7563 cmd_showfwdall_parsed(void *parsed_result, 7564 __rte_unused struct cmdline *cl, 7565 __rte_unused void *data) 7566 { 7567 struct fwd_result *res = parsed_result; 7568 7569 if (!strcmp(res->action, "show")) 7570 fwd_stats_display(); 7571 else 7572 fwd_stats_reset(); 7573 } 7574 7575 static cmdline_parse_inst_t cmd_showfwdall = { 7576 .f = cmd_showfwdall_parsed, 7577 .data = NULL, 7578 .help_str = "show|clear fwd stats all", 7579 .tokens = { 7580 (void *)&cmd_fwd_action, 7581 (void *)&cmd_fwd_fwd, 7582 (void *)&cmd_fwd_stats, 7583 (void *)&cmd_fwd_all, 7584 NULL, 7585 }, 7586 }; 7587 7588 /* *** READ PORT REGISTER *** */ 7589 struct cmd_read_reg_result { 7590 cmdline_fixed_string_t read; 7591 cmdline_fixed_string_t reg; 7592 portid_t port_id; 7593 uint32_t reg_off; 7594 }; 7595 7596 static void 7597 cmd_read_reg_parsed(void *parsed_result, 7598 __attribute__((unused)) struct cmdline *cl, 7599 __attribute__((unused)) void *data) 7600 { 7601 struct cmd_read_reg_result *res = parsed_result; 7602 port_reg_display(res->port_id, res->reg_off); 7603 } 7604 7605 cmdline_parse_token_string_t cmd_read_reg_read = 7606 TOKEN_STRING_INITIALIZER(struct cmd_read_reg_result, read, "read"); 7607 cmdline_parse_token_string_t cmd_read_reg_reg = 7608 TOKEN_STRING_INITIALIZER(struct cmd_read_reg_result, reg, "reg"); 7609 cmdline_parse_token_num_t cmd_read_reg_port_id = 7610 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_result, port_id, UINT16); 7611 cmdline_parse_token_num_t cmd_read_reg_reg_off = 7612 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_result, reg_off, UINT32); 7613 7614 cmdline_parse_inst_t cmd_read_reg = { 7615 .f = cmd_read_reg_parsed, 7616 .data = NULL, 7617 .help_str = "read reg <port_id> <reg_off>", 7618 .tokens = { 7619 (void *)&cmd_read_reg_read, 7620 (void *)&cmd_read_reg_reg, 7621 (void *)&cmd_read_reg_port_id, 7622 (void *)&cmd_read_reg_reg_off, 7623 NULL, 7624 }, 7625 }; 7626 7627 /* *** READ PORT REGISTER BIT FIELD *** */ 7628 struct cmd_read_reg_bit_field_result { 7629 cmdline_fixed_string_t read; 7630 cmdline_fixed_string_t regfield; 7631 portid_t port_id; 7632 uint32_t reg_off; 7633 uint8_t bit1_pos; 7634 uint8_t bit2_pos; 7635 }; 7636 7637 static void 7638 cmd_read_reg_bit_field_parsed(void *parsed_result, 7639 __attribute__((unused)) struct cmdline *cl, 7640 __attribute__((unused)) void *data) 7641 { 7642 struct cmd_read_reg_bit_field_result *res = parsed_result; 7643 port_reg_bit_field_display(res->port_id, res->reg_off, 7644 res->bit1_pos, res->bit2_pos); 7645 } 7646 7647 cmdline_parse_token_string_t cmd_read_reg_bit_field_read = 7648 TOKEN_STRING_INITIALIZER(struct cmd_read_reg_bit_field_result, read, 7649 "read"); 7650 cmdline_parse_token_string_t cmd_read_reg_bit_field_regfield = 7651 TOKEN_STRING_INITIALIZER(struct cmd_read_reg_bit_field_result, 7652 regfield, "regfield"); 7653 cmdline_parse_token_num_t cmd_read_reg_bit_field_port_id = 7654 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_field_result, port_id, 7655 UINT16); 7656 cmdline_parse_token_num_t cmd_read_reg_bit_field_reg_off = 7657 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_field_result, reg_off, 7658 UINT32); 7659 cmdline_parse_token_num_t cmd_read_reg_bit_field_bit1_pos = 7660 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_field_result, bit1_pos, 7661 UINT8); 7662 cmdline_parse_token_num_t cmd_read_reg_bit_field_bit2_pos = 7663 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_field_result, bit2_pos, 7664 UINT8); 7665 7666 cmdline_parse_inst_t cmd_read_reg_bit_field = { 7667 .f = cmd_read_reg_bit_field_parsed, 7668 .data = NULL, 7669 .help_str = "read regfield <port_id> <reg_off> <bit_x> <bit_y>: " 7670 "Read register bit field between bit_x and bit_y included", 7671 .tokens = { 7672 (void *)&cmd_read_reg_bit_field_read, 7673 (void *)&cmd_read_reg_bit_field_regfield, 7674 (void *)&cmd_read_reg_bit_field_port_id, 7675 (void *)&cmd_read_reg_bit_field_reg_off, 7676 (void *)&cmd_read_reg_bit_field_bit1_pos, 7677 (void *)&cmd_read_reg_bit_field_bit2_pos, 7678 NULL, 7679 }, 7680 }; 7681 7682 /* *** READ PORT REGISTER BIT *** */ 7683 struct cmd_read_reg_bit_result { 7684 cmdline_fixed_string_t read; 7685 cmdline_fixed_string_t regbit; 7686 portid_t port_id; 7687 uint32_t reg_off; 7688 uint8_t bit_pos; 7689 }; 7690 7691 static void 7692 cmd_read_reg_bit_parsed(void *parsed_result, 7693 __attribute__((unused)) struct cmdline *cl, 7694 __attribute__((unused)) void *data) 7695 { 7696 struct cmd_read_reg_bit_result *res = parsed_result; 7697 port_reg_bit_display(res->port_id, res->reg_off, res->bit_pos); 7698 } 7699 7700 cmdline_parse_token_string_t cmd_read_reg_bit_read = 7701 TOKEN_STRING_INITIALIZER(struct cmd_read_reg_bit_result, read, "read"); 7702 cmdline_parse_token_string_t cmd_read_reg_bit_regbit = 7703 TOKEN_STRING_INITIALIZER(struct cmd_read_reg_bit_result, 7704 regbit, "regbit"); 7705 cmdline_parse_token_num_t cmd_read_reg_bit_port_id = 7706 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_result, port_id, UINT16); 7707 cmdline_parse_token_num_t cmd_read_reg_bit_reg_off = 7708 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_result, reg_off, UINT32); 7709 cmdline_parse_token_num_t cmd_read_reg_bit_bit_pos = 7710 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_result, bit_pos, UINT8); 7711 7712 cmdline_parse_inst_t cmd_read_reg_bit = { 7713 .f = cmd_read_reg_bit_parsed, 7714 .data = NULL, 7715 .help_str = "read regbit <port_id> <reg_off> <bit_x>: 0 <= bit_x <= 31", 7716 .tokens = { 7717 (void *)&cmd_read_reg_bit_read, 7718 (void *)&cmd_read_reg_bit_regbit, 7719 (void *)&cmd_read_reg_bit_port_id, 7720 (void *)&cmd_read_reg_bit_reg_off, 7721 (void *)&cmd_read_reg_bit_bit_pos, 7722 NULL, 7723 }, 7724 }; 7725 7726 /* *** WRITE PORT REGISTER *** */ 7727 struct cmd_write_reg_result { 7728 cmdline_fixed_string_t write; 7729 cmdline_fixed_string_t reg; 7730 portid_t port_id; 7731 uint32_t reg_off; 7732 uint32_t value; 7733 }; 7734 7735 static void 7736 cmd_write_reg_parsed(void *parsed_result, 7737 __attribute__((unused)) struct cmdline *cl, 7738 __attribute__((unused)) void *data) 7739 { 7740 struct cmd_write_reg_result *res = parsed_result; 7741 port_reg_set(res->port_id, res->reg_off, res->value); 7742 } 7743 7744 cmdline_parse_token_string_t cmd_write_reg_write = 7745 TOKEN_STRING_INITIALIZER(struct cmd_write_reg_result, write, "write"); 7746 cmdline_parse_token_string_t cmd_write_reg_reg = 7747 TOKEN_STRING_INITIALIZER(struct cmd_write_reg_result, reg, "reg"); 7748 cmdline_parse_token_num_t cmd_write_reg_port_id = 7749 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_result, port_id, UINT16); 7750 cmdline_parse_token_num_t cmd_write_reg_reg_off = 7751 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_result, reg_off, UINT32); 7752 cmdline_parse_token_num_t cmd_write_reg_value = 7753 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_result, value, UINT32); 7754 7755 cmdline_parse_inst_t cmd_write_reg = { 7756 .f = cmd_write_reg_parsed, 7757 .data = NULL, 7758 .help_str = "write reg <port_id> <reg_off> <reg_value>", 7759 .tokens = { 7760 (void *)&cmd_write_reg_write, 7761 (void *)&cmd_write_reg_reg, 7762 (void *)&cmd_write_reg_port_id, 7763 (void *)&cmd_write_reg_reg_off, 7764 (void *)&cmd_write_reg_value, 7765 NULL, 7766 }, 7767 }; 7768 7769 /* *** WRITE PORT REGISTER BIT FIELD *** */ 7770 struct cmd_write_reg_bit_field_result { 7771 cmdline_fixed_string_t write; 7772 cmdline_fixed_string_t regfield; 7773 portid_t port_id; 7774 uint32_t reg_off; 7775 uint8_t bit1_pos; 7776 uint8_t bit2_pos; 7777 uint32_t value; 7778 }; 7779 7780 static void 7781 cmd_write_reg_bit_field_parsed(void *parsed_result, 7782 __attribute__((unused)) struct cmdline *cl, 7783 __attribute__((unused)) void *data) 7784 { 7785 struct cmd_write_reg_bit_field_result *res = parsed_result; 7786 port_reg_bit_field_set(res->port_id, res->reg_off, 7787 res->bit1_pos, res->bit2_pos, res->value); 7788 } 7789 7790 cmdline_parse_token_string_t cmd_write_reg_bit_field_write = 7791 TOKEN_STRING_INITIALIZER(struct cmd_write_reg_bit_field_result, write, 7792 "write"); 7793 cmdline_parse_token_string_t cmd_write_reg_bit_field_regfield = 7794 TOKEN_STRING_INITIALIZER(struct cmd_write_reg_bit_field_result, 7795 regfield, "regfield"); 7796 cmdline_parse_token_num_t cmd_write_reg_bit_field_port_id = 7797 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_field_result, port_id, 7798 UINT16); 7799 cmdline_parse_token_num_t cmd_write_reg_bit_field_reg_off = 7800 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_field_result, reg_off, 7801 UINT32); 7802 cmdline_parse_token_num_t cmd_write_reg_bit_field_bit1_pos = 7803 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_field_result, bit1_pos, 7804 UINT8); 7805 cmdline_parse_token_num_t cmd_write_reg_bit_field_bit2_pos = 7806 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_field_result, bit2_pos, 7807 UINT8); 7808 cmdline_parse_token_num_t cmd_write_reg_bit_field_value = 7809 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_field_result, value, 7810 UINT32); 7811 7812 cmdline_parse_inst_t cmd_write_reg_bit_field = { 7813 .f = cmd_write_reg_bit_field_parsed, 7814 .data = NULL, 7815 .help_str = "write regfield <port_id> <reg_off> <bit_x> <bit_y> " 7816 "<reg_value>: " 7817 "Set register bit field between bit_x and bit_y included", 7818 .tokens = { 7819 (void *)&cmd_write_reg_bit_field_write, 7820 (void *)&cmd_write_reg_bit_field_regfield, 7821 (void *)&cmd_write_reg_bit_field_port_id, 7822 (void *)&cmd_write_reg_bit_field_reg_off, 7823 (void *)&cmd_write_reg_bit_field_bit1_pos, 7824 (void *)&cmd_write_reg_bit_field_bit2_pos, 7825 (void *)&cmd_write_reg_bit_field_value, 7826 NULL, 7827 }, 7828 }; 7829 7830 /* *** WRITE PORT REGISTER BIT *** */ 7831 struct cmd_write_reg_bit_result { 7832 cmdline_fixed_string_t write; 7833 cmdline_fixed_string_t regbit; 7834 portid_t port_id; 7835 uint32_t reg_off; 7836 uint8_t bit_pos; 7837 uint8_t value; 7838 }; 7839 7840 static void 7841 cmd_write_reg_bit_parsed(void *parsed_result, 7842 __attribute__((unused)) struct cmdline *cl, 7843 __attribute__((unused)) void *data) 7844 { 7845 struct cmd_write_reg_bit_result *res = parsed_result; 7846 port_reg_bit_set(res->port_id, res->reg_off, res->bit_pos, res->value); 7847 } 7848 7849 cmdline_parse_token_string_t cmd_write_reg_bit_write = 7850 TOKEN_STRING_INITIALIZER(struct cmd_write_reg_bit_result, write, 7851 "write"); 7852 cmdline_parse_token_string_t cmd_write_reg_bit_regbit = 7853 TOKEN_STRING_INITIALIZER(struct cmd_write_reg_bit_result, 7854 regbit, "regbit"); 7855 cmdline_parse_token_num_t cmd_write_reg_bit_port_id = 7856 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_result, port_id, UINT16); 7857 cmdline_parse_token_num_t cmd_write_reg_bit_reg_off = 7858 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_result, reg_off, UINT32); 7859 cmdline_parse_token_num_t cmd_write_reg_bit_bit_pos = 7860 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_result, bit_pos, UINT8); 7861 cmdline_parse_token_num_t cmd_write_reg_bit_value = 7862 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_result, value, UINT8); 7863 7864 cmdline_parse_inst_t cmd_write_reg_bit = { 7865 .f = cmd_write_reg_bit_parsed, 7866 .data = NULL, 7867 .help_str = "write regbit <port_id> <reg_off> <bit_x> 0|1: " 7868 "0 <= bit_x <= 31", 7869 .tokens = { 7870 (void *)&cmd_write_reg_bit_write, 7871 (void *)&cmd_write_reg_bit_regbit, 7872 (void *)&cmd_write_reg_bit_port_id, 7873 (void *)&cmd_write_reg_bit_reg_off, 7874 (void *)&cmd_write_reg_bit_bit_pos, 7875 (void *)&cmd_write_reg_bit_value, 7876 NULL, 7877 }, 7878 }; 7879 7880 /* *** READ A RING DESCRIPTOR OF A PORT RX/TX QUEUE *** */ 7881 struct cmd_read_rxd_txd_result { 7882 cmdline_fixed_string_t read; 7883 cmdline_fixed_string_t rxd_txd; 7884 portid_t port_id; 7885 uint16_t queue_id; 7886 uint16_t desc_id; 7887 }; 7888 7889 static void 7890 cmd_read_rxd_txd_parsed(void *parsed_result, 7891 __attribute__((unused)) struct cmdline *cl, 7892 __attribute__((unused)) void *data) 7893 { 7894 struct cmd_read_rxd_txd_result *res = parsed_result; 7895 7896 if (!strcmp(res->rxd_txd, "rxd")) 7897 rx_ring_desc_display(res->port_id, res->queue_id, res->desc_id); 7898 else if (!strcmp(res->rxd_txd, "txd")) 7899 tx_ring_desc_display(res->port_id, res->queue_id, res->desc_id); 7900 } 7901 7902 cmdline_parse_token_string_t cmd_read_rxd_txd_read = 7903 TOKEN_STRING_INITIALIZER(struct cmd_read_rxd_txd_result, read, "read"); 7904 cmdline_parse_token_string_t cmd_read_rxd_txd_rxd_txd = 7905 TOKEN_STRING_INITIALIZER(struct cmd_read_rxd_txd_result, rxd_txd, 7906 "rxd#txd"); 7907 cmdline_parse_token_num_t cmd_read_rxd_txd_port_id = 7908 TOKEN_NUM_INITIALIZER(struct cmd_read_rxd_txd_result, port_id, UINT16); 7909 cmdline_parse_token_num_t cmd_read_rxd_txd_queue_id = 7910 TOKEN_NUM_INITIALIZER(struct cmd_read_rxd_txd_result, queue_id, UINT16); 7911 cmdline_parse_token_num_t cmd_read_rxd_txd_desc_id = 7912 TOKEN_NUM_INITIALIZER(struct cmd_read_rxd_txd_result, desc_id, UINT16); 7913 7914 cmdline_parse_inst_t cmd_read_rxd_txd = { 7915 .f = cmd_read_rxd_txd_parsed, 7916 .data = NULL, 7917 .help_str = "read rxd|txd <port_id> <queue_id> <desc_id>", 7918 .tokens = { 7919 (void *)&cmd_read_rxd_txd_read, 7920 (void *)&cmd_read_rxd_txd_rxd_txd, 7921 (void *)&cmd_read_rxd_txd_port_id, 7922 (void *)&cmd_read_rxd_txd_queue_id, 7923 (void *)&cmd_read_rxd_txd_desc_id, 7924 NULL, 7925 }, 7926 }; 7927 7928 /* *** QUIT *** */ 7929 struct cmd_quit_result { 7930 cmdline_fixed_string_t quit; 7931 }; 7932 7933 static void cmd_quit_parsed(__attribute__((unused)) void *parsed_result, 7934 struct cmdline *cl, 7935 __attribute__((unused)) void *data) 7936 { 7937 cmdline_quit(cl); 7938 } 7939 7940 cmdline_parse_token_string_t cmd_quit_quit = 7941 TOKEN_STRING_INITIALIZER(struct cmd_quit_result, quit, "quit"); 7942 7943 cmdline_parse_inst_t cmd_quit = { 7944 .f = cmd_quit_parsed, 7945 .data = NULL, 7946 .help_str = "quit: Exit application", 7947 .tokens = { 7948 (void *)&cmd_quit_quit, 7949 NULL, 7950 }, 7951 }; 7952 7953 /* *** ADD/REMOVE MAC ADDRESS FROM A PORT *** */ 7954 struct cmd_mac_addr_result { 7955 cmdline_fixed_string_t mac_addr_cmd; 7956 cmdline_fixed_string_t what; 7957 uint16_t port_num; 7958 struct rte_ether_addr address; 7959 }; 7960 7961 static void cmd_mac_addr_parsed(void *parsed_result, 7962 __attribute__((unused)) struct cmdline *cl, 7963 __attribute__((unused)) void *data) 7964 { 7965 struct cmd_mac_addr_result *res = parsed_result; 7966 int ret; 7967 7968 if (strcmp(res->what, "add") == 0) 7969 ret = rte_eth_dev_mac_addr_add(res->port_num, &res->address, 0); 7970 else if (strcmp(res->what, "set") == 0) 7971 ret = rte_eth_dev_default_mac_addr_set(res->port_num, 7972 &res->address); 7973 else 7974 ret = rte_eth_dev_mac_addr_remove(res->port_num, &res->address); 7975 7976 /* check the return value and print it if is < 0 */ 7977 if(ret < 0) 7978 printf("mac_addr_cmd error: (%s)\n", strerror(-ret)); 7979 7980 } 7981 7982 cmdline_parse_token_string_t cmd_mac_addr_cmd = 7983 TOKEN_STRING_INITIALIZER(struct cmd_mac_addr_result, mac_addr_cmd, 7984 "mac_addr"); 7985 cmdline_parse_token_string_t cmd_mac_addr_what = 7986 TOKEN_STRING_INITIALIZER(struct cmd_mac_addr_result, what, 7987 "add#remove#set"); 7988 cmdline_parse_token_num_t cmd_mac_addr_portnum = 7989 TOKEN_NUM_INITIALIZER(struct cmd_mac_addr_result, port_num, 7990 UINT16); 7991 cmdline_parse_token_etheraddr_t cmd_mac_addr_addr = 7992 TOKEN_ETHERADDR_INITIALIZER(struct cmd_mac_addr_result, address); 7993 7994 cmdline_parse_inst_t cmd_mac_addr = { 7995 .f = cmd_mac_addr_parsed, 7996 .data = (void *)0, 7997 .help_str = "mac_addr add|remove|set <port_id> <mac_addr>: " 7998 "Add/Remove/Set MAC address on port_id", 7999 .tokens = { 8000 (void *)&cmd_mac_addr_cmd, 8001 (void *)&cmd_mac_addr_what, 8002 (void *)&cmd_mac_addr_portnum, 8003 (void *)&cmd_mac_addr_addr, 8004 NULL, 8005 }, 8006 }; 8007 8008 /* *** SET THE PEER ADDRESS FOR CERTAIN PORT *** */ 8009 struct cmd_eth_peer_result { 8010 cmdline_fixed_string_t set; 8011 cmdline_fixed_string_t eth_peer; 8012 portid_t port_id; 8013 cmdline_fixed_string_t peer_addr; 8014 }; 8015 8016 static void cmd_set_eth_peer_parsed(void *parsed_result, 8017 __attribute__((unused)) struct cmdline *cl, 8018 __attribute__((unused)) void *data) 8019 { 8020 struct cmd_eth_peer_result *res = parsed_result; 8021 8022 if (test_done == 0) { 8023 printf("Please stop forwarding first\n"); 8024 return; 8025 } 8026 if (!strcmp(res->eth_peer, "eth-peer")) { 8027 set_fwd_eth_peer(res->port_id, res->peer_addr); 8028 fwd_config_setup(); 8029 } 8030 } 8031 cmdline_parse_token_string_t cmd_eth_peer_set = 8032 TOKEN_STRING_INITIALIZER(struct cmd_eth_peer_result, set, "set"); 8033 cmdline_parse_token_string_t cmd_eth_peer = 8034 TOKEN_STRING_INITIALIZER(struct cmd_eth_peer_result, eth_peer, "eth-peer"); 8035 cmdline_parse_token_num_t cmd_eth_peer_port_id = 8036 TOKEN_NUM_INITIALIZER(struct cmd_eth_peer_result, port_id, UINT16); 8037 cmdline_parse_token_string_t cmd_eth_peer_addr = 8038 TOKEN_STRING_INITIALIZER(struct cmd_eth_peer_result, peer_addr, NULL); 8039 8040 cmdline_parse_inst_t cmd_set_fwd_eth_peer = { 8041 .f = cmd_set_eth_peer_parsed, 8042 .data = NULL, 8043 .help_str = "set eth-peer <port_id> <peer_mac>", 8044 .tokens = { 8045 (void *)&cmd_eth_peer_set, 8046 (void *)&cmd_eth_peer, 8047 (void *)&cmd_eth_peer_port_id, 8048 (void *)&cmd_eth_peer_addr, 8049 NULL, 8050 }, 8051 }; 8052 8053 /* *** CONFIGURE QUEUE STATS COUNTER MAPPINGS *** */ 8054 struct cmd_set_qmap_result { 8055 cmdline_fixed_string_t set; 8056 cmdline_fixed_string_t qmap; 8057 cmdline_fixed_string_t what; 8058 portid_t port_id; 8059 uint16_t queue_id; 8060 uint8_t map_value; 8061 }; 8062 8063 static void 8064 cmd_set_qmap_parsed(void *parsed_result, 8065 __attribute__((unused)) struct cmdline *cl, 8066 __attribute__((unused)) void *data) 8067 { 8068 struct cmd_set_qmap_result *res = parsed_result; 8069 int is_rx = (strcmp(res->what, "tx") == 0) ? 0 : 1; 8070 8071 set_qmap(res->port_id, (uint8_t)is_rx, res->queue_id, res->map_value); 8072 } 8073 8074 cmdline_parse_token_string_t cmd_setqmap_set = 8075 TOKEN_STRING_INITIALIZER(struct cmd_set_qmap_result, 8076 set, "set"); 8077 cmdline_parse_token_string_t cmd_setqmap_qmap = 8078 TOKEN_STRING_INITIALIZER(struct cmd_set_qmap_result, 8079 qmap, "stat_qmap"); 8080 cmdline_parse_token_string_t cmd_setqmap_what = 8081 TOKEN_STRING_INITIALIZER(struct cmd_set_qmap_result, 8082 what, "tx#rx"); 8083 cmdline_parse_token_num_t cmd_setqmap_portid = 8084 TOKEN_NUM_INITIALIZER(struct cmd_set_qmap_result, 8085 port_id, UINT16); 8086 cmdline_parse_token_num_t cmd_setqmap_queueid = 8087 TOKEN_NUM_INITIALIZER(struct cmd_set_qmap_result, 8088 queue_id, UINT16); 8089 cmdline_parse_token_num_t cmd_setqmap_mapvalue = 8090 TOKEN_NUM_INITIALIZER(struct cmd_set_qmap_result, 8091 map_value, UINT8); 8092 8093 cmdline_parse_inst_t cmd_set_qmap = { 8094 .f = cmd_set_qmap_parsed, 8095 .data = NULL, 8096 .help_str = "set stat_qmap rx|tx <port_id> <queue_id> <map_value>: " 8097 "Set statistics mapping value on tx|rx queue_id of port_id", 8098 .tokens = { 8099 (void *)&cmd_setqmap_set, 8100 (void *)&cmd_setqmap_qmap, 8101 (void *)&cmd_setqmap_what, 8102 (void *)&cmd_setqmap_portid, 8103 (void *)&cmd_setqmap_queueid, 8104 (void *)&cmd_setqmap_mapvalue, 8105 NULL, 8106 }, 8107 }; 8108 8109 /* *** SET OPTION TO HIDE ZERO VALUES FOR XSTATS DISPLAY *** */ 8110 struct cmd_set_xstats_hide_zero_result { 8111 cmdline_fixed_string_t keyword; 8112 cmdline_fixed_string_t name; 8113 cmdline_fixed_string_t on_off; 8114 }; 8115 8116 static void 8117 cmd_set_xstats_hide_zero_parsed(void *parsed_result, 8118 __attribute__((unused)) struct cmdline *cl, 8119 __attribute__((unused)) void *data) 8120 { 8121 struct cmd_set_xstats_hide_zero_result *res; 8122 uint16_t on_off = 0; 8123 8124 res = parsed_result; 8125 on_off = !strcmp(res->on_off, "on") ? 1 : 0; 8126 set_xstats_hide_zero(on_off); 8127 } 8128 8129 cmdline_parse_token_string_t cmd_set_xstats_hide_zero_keyword = 8130 TOKEN_STRING_INITIALIZER(struct cmd_set_xstats_hide_zero_result, 8131 keyword, "set"); 8132 cmdline_parse_token_string_t cmd_set_xstats_hide_zero_name = 8133 TOKEN_STRING_INITIALIZER(struct cmd_set_xstats_hide_zero_result, 8134 name, "xstats-hide-zero"); 8135 cmdline_parse_token_string_t cmd_set_xstats_hide_zero_on_off = 8136 TOKEN_STRING_INITIALIZER(struct cmd_set_xstats_hide_zero_result, 8137 on_off, "on#off"); 8138 8139 cmdline_parse_inst_t cmd_set_xstats_hide_zero = { 8140 .f = cmd_set_xstats_hide_zero_parsed, 8141 .data = NULL, 8142 .help_str = "set xstats-hide-zero on|off", 8143 .tokens = { 8144 (void *)&cmd_set_xstats_hide_zero_keyword, 8145 (void *)&cmd_set_xstats_hide_zero_name, 8146 (void *)&cmd_set_xstats_hide_zero_on_off, 8147 NULL, 8148 }, 8149 }; 8150 8151 /* *** CONFIGURE UNICAST HASH TABLE *** */ 8152 struct cmd_set_uc_hash_table { 8153 cmdline_fixed_string_t set; 8154 cmdline_fixed_string_t port; 8155 portid_t port_id; 8156 cmdline_fixed_string_t what; 8157 struct rte_ether_addr address; 8158 cmdline_fixed_string_t mode; 8159 }; 8160 8161 static void 8162 cmd_set_uc_hash_parsed(void *parsed_result, 8163 __attribute__((unused)) struct cmdline *cl, 8164 __attribute__((unused)) void *data) 8165 { 8166 int ret=0; 8167 struct cmd_set_uc_hash_table *res = parsed_result; 8168 8169 int is_on = (strcmp(res->mode, "on") == 0) ? 1 : 0; 8170 8171 if (strcmp(res->what, "uta") == 0) 8172 ret = rte_eth_dev_uc_hash_table_set(res->port_id, 8173 &res->address,(uint8_t)is_on); 8174 if (ret < 0) 8175 printf("bad unicast hash table parameter, return code = %d \n", ret); 8176 8177 } 8178 8179 cmdline_parse_token_string_t cmd_set_uc_hash_set = 8180 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_hash_table, 8181 set, "set"); 8182 cmdline_parse_token_string_t cmd_set_uc_hash_port = 8183 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_hash_table, 8184 port, "port"); 8185 cmdline_parse_token_num_t cmd_set_uc_hash_portid = 8186 TOKEN_NUM_INITIALIZER(struct cmd_set_uc_hash_table, 8187 port_id, UINT16); 8188 cmdline_parse_token_string_t cmd_set_uc_hash_what = 8189 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_hash_table, 8190 what, "uta"); 8191 cmdline_parse_token_etheraddr_t cmd_set_uc_hash_mac = 8192 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_uc_hash_table, 8193 address); 8194 cmdline_parse_token_string_t cmd_set_uc_hash_mode = 8195 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_hash_table, 8196 mode, "on#off"); 8197 8198 cmdline_parse_inst_t cmd_set_uc_hash_filter = { 8199 .f = cmd_set_uc_hash_parsed, 8200 .data = NULL, 8201 .help_str = "set port <port_id> uta <mac_addr> on|off)", 8202 .tokens = { 8203 (void *)&cmd_set_uc_hash_set, 8204 (void *)&cmd_set_uc_hash_port, 8205 (void *)&cmd_set_uc_hash_portid, 8206 (void *)&cmd_set_uc_hash_what, 8207 (void *)&cmd_set_uc_hash_mac, 8208 (void *)&cmd_set_uc_hash_mode, 8209 NULL, 8210 }, 8211 }; 8212 8213 struct cmd_set_uc_all_hash_table { 8214 cmdline_fixed_string_t set; 8215 cmdline_fixed_string_t port; 8216 portid_t port_id; 8217 cmdline_fixed_string_t what; 8218 cmdline_fixed_string_t value; 8219 cmdline_fixed_string_t mode; 8220 }; 8221 8222 static void 8223 cmd_set_uc_all_hash_parsed(void *parsed_result, 8224 __attribute__((unused)) struct cmdline *cl, 8225 __attribute__((unused)) void *data) 8226 { 8227 int ret=0; 8228 struct cmd_set_uc_all_hash_table *res = parsed_result; 8229 8230 int is_on = (strcmp(res->mode, "on") == 0) ? 1 : 0; 8231 8232 if ((strcmp(res->what, "uta") == 0) && 8233 (strcmp(res->value, "all") == 0)) 8234 ret = rte_eth_dev_uc_all_hash_table_set(res->port_id,(uint8_t) is_on); 8235 if (ret < 0) 8236 printf("bad unicast hash table parameter," 8237 "return code = %d \n", ret); 8238 } 8239 8240 cmdline_parse_token_string_t cmd_set_uc_all_hash_set = 8241 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_all_hash_table, 8242 set, "set"); 8243 cmdline_parse_token_string_t cmd_set_uc_all_hash_port = 8244 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_all_hash_table, 8245 port, "port"); 8246 cmdline_parse_token_num_t cmd_set_uc_all_hash_portid = 8247 TOKEN_NUM_INITIALIZER(struct cmd_set_uc_all_hash_table, 8248 port_id, UINT16); 8249 cmdline_parse_token_string_t cmd_set_uc_all_hash_what = 8250 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_all_hash_table, 8251 what, "uta"); 8252 cmdline_parse_token_string_t cmd_set_uc_all_hash_value = 8253 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_all_hash_table, 8254 value,"all"); 8255 cmdline_parse_token_string_t cmd_set_uc_all_hash_mode = 8256 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_all_hash_table, 8257 mode, "on#off"); 8258 8259 cmdline_parse_inst_t cmd_set_uc_all_hash_filter = { 8260 .f = cmd_set_uc_all_hash_parsed, 8261 .data = NULL, 8262 .help_str = "set port <port_id> uta all on|off", 8263 .tokens = { 8264 (void *)&cmd_set_uc_all_hash_set, 8265 (void *)&cmd_set_uc_all_hash_port, 8266 (void *)&cmd_set_uc_all_hash_portid, 8267 (void *)&cmd_set_uc_all_hash_what, 8268 (void *)&cmd_set_uc_all_hash_value, 8269 (void *)&cmd_set_uc_all_hash_mode, 8270 NULL, 8271 }, 8272 }; 8273 8274 /* *** CONFIGURE MACVLAN FILTER FOR VF(s) *** */ 8275 struct cmd_set_vf_macvlan_filter { 8276 cmdline_fixed_string_t set; 8277 cmdline_fixed_string_t port; 8278 portid_t port_id; 8279 cmdline_fixed_string_t vf; 8280 uint8_t vf_id; 8281 struct rte_ether_addr address; 8282 cmdline_fixed_string_t filter_type; 8283 cmdline_fixed_string_t mode; 8284 }; 8285 8286 static void 8287 cmd_set_vf_macvlan_parsed(void *parsed_result, 8288 __attribute__((unused)) struct cmdline *cl, 8289 __attribute__((unused)) void *data) 8290 { 8291 int is_on, ret = 0; 8292 struct cmd_set_vf_macvlan_filter *res = parsed_result; 8293 struct rte_eth_mac_filter filter; 8294 8295 memset(&filter, 0, sizeof(struct rte_eth_mac_filter)); 8296 8297 rte_memcpy(&filter.mac_addr, &res->address, RTE_ETHER_ADDR_LEN); 8298 8299 /* set VF MAC filter */ 8300 filter.is_vf = 1; 8301 8302 /* set VF ID */ 8303 filter.dst_id = res->vf_id; 8304 8305 if (!strcmp(res->filter_type, "exact-mac")) 8306 filter.filter_type = RTE_MAC_PERFECT_MATCH; 8307 else if (!strcmp(res->filter_type, "exact-mac-vlan")) 8308 filter.filter_type = RTE_MACVLAN_PERFECT_MATCH; 8309 else if (!strcmp(res->filter_type, "hashmac")) 8310 filter.filter_type = RTE_MAC_HASH_MATCH; 8311 else if (!strcmp(res->filter_type, "hashmac-vlan")) 8312 filter.filter_type = RTE_MACVLAN_HASH_MATCH; 8313 8314 is_on = (strcmp(res->mode, "on") == 0) ? 1 : 0; 8315 8316 if (is_on) 8317 ret = rte_eth_dev_filter_ctrl(res->port_id, 8318 RTE_ETH_FILTER_MACVLAN, 8319 RTE_ETH_FILTER_ADD, 8320 &filter); 8321 else 8322 ret = rte_eth_dev_filter_ctrl(res->port_id, 8323 RTE_ETH_FILTER_MACVLAN, 8324 RTE_ETH_FILTER_DELETE, 8325 &filter); 8326 8327 if (ret < 0) 8328 printf("bad set MAC hash parameter, return code = %d\n", ret); 8329 8330 } 8331 8332 cmdline_parse_token_string_t cmd_set_vf_macvlan_set = 8333 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_macvlan_filter, 8334 set, "set"); 8335 cmdline_parse_token_string_t cmd_set_vf_macvlan_port = 8336 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_macvlan_filter, 8337 port, "port"); 8338 cmdline_parse_token_num_t cmd_set_vf_macvlan_portid = 8339 TOKEN_NUM_INITIALIZER(struct cmd_set_vf_macvlan_filter, 8340 port_id, UINT16); 8341 cmdline_parse_token_string_t cmd_set_vf_macvlan_vf = 8342 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_macvlan_filter, 8343 vf, "vf"); 8344 cmdline_parse_token_num_t cmd_set_vf_macvlan_vf_id = 8345 TOKEN_NUM_INITIALIZER(struct cmd_set_vf_macvlan_filter, 8346 vf_id, UINT8); 8347 cmdline_parse_token_etheraddr_t cmd_set_vf_macvlan_mac = 8348 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_vf_macvlan_filter, 8349 address); 8350 cmdline_parse_token_string_t cmd_set_vf_macvlan_filter_type = 8351 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_macvlan_filter, 8352 filter_type, "exact-mac#exact-mac-vlan" 8353 "#hashmac#hashmac-vlan"); 8354 cmdline_parse_token_string_t cmd_set_vf_macvlan_mode = 8355 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_macvlan_filter, 8356 mode, "on#off"); 8357 8358 cmdline_parse_inst_t cmd_set_vf_macvlan_filter = { 8359 .f = cmd_set_vf_macvlan_parsed, 8360 .data = NULL, 8361 .help_str = "set port <port_id> vf <vf_id> <mac_addr> " 8362 "exact-mac|exact-mac-vlan|hashmac|hashmac-vlan on|off: " 8363 "Exact match rule: exact match of MAC or MAC and VLAN; " 8364 "hash match rule: hash match of MAC and exact match of VLAN", 8365 .tokens = { 8366 (void *)&cmd_set_vf_macvlan_set, 8367 (void *)&cmd_set_vf_macvlan_port, 8368 (void *)&cmd_set_vf_macvlan_portid, 8369 (void *)&cmd_set_vf_macvlan_vf, 8370 (void *)&cmd_set_vf_macvlan_vf_id, 8371 (void *)&cmd_set_vf_macvlan_mac, 8372 (void *)&cmd_set_vf_macvlan_filter_type, 8373 (void *)&cmd_set_vf_macvlan_mode, 8374 NULL, 8375 }, 8376 }; 8377 8378 /* *** CONFIGURE VF TRAFFIC CONTROL *** */ 8379 struct cmd_set_vf_traffic { 8380 cmdline_fixed_string_t set; 8381 cmdline_fixed_string_t port; 8382 portid_t port_id; 8383 cmdline_fixed_string_t vf; 8384 uint8_t vf_id; 8385 cmdline_fixed_string_t what; 8386 cmdline_fixed_string_t mode; 8387 }; 8388 8389 static void 8390 cmd_set_vf_traffic_parsed(void *parsed_result, 8391 __attribute__((unused)) struct cmdline *cl, 8392 __attribute__((unused)) void *data) 8393 { 8394 struct cmd_set_vf_traffic *res = parsed_result; 8395 int is_rx = (strcmp(res->what, "rx") == 0) ? 1 : 0; 8396 int is_on = (strcmp(res->mode, "on") == 0) ? 1 : 0; 8397 8398 set_vf_traffic(res->port_id, (uint8_t)is_rx, res->vf_id,(uint8_t) is_on); 8399 } 8400 8401 cmdline_parse_token_string_t cmd_setvf_traffic_set = 8402 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_traffic, 8403 set, "set"); 8404 cmdline_parse_token_string_t cmd_setvf_traffic_port = 8405 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_traffic, 8406 port, "port"); 8407 cmdline_parse_token_num_t cmd_setvf_traffic_portid = 8408 TOKEN_NUM_INITIALIZER(struct cmd_set_vf_traffic, 8409 port_id, UINT16); 8410 cmdline_parse_token_string_t cmd_setvf_traffic_vf = 8411 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_traffic, 8412 vf, "vf"); 8413 cmdline_parse_token_num_t cmd_setvf_traffic_vfid = 8414 TOKEN_NUM_INITIALIZER(struct cmd_set_vf_traffic, 8415 vf_id, UINT8); 8416 cmdline_parse_token_string_t cmd_setvf_traffic_what = 8417 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_traffic, 8418 what, "tx#rx"); 8419 cmdline_parse_token_string_t cmd_setvf_traffic_mode = 8420 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_traffic, 8421 mode, "on#off"); 8422 8423 cmdline_parse_inst_t cmd_set_vf_traffic = { 8424 .f = cmd_set_vf_traffic_parsed, 8425 .data = NULL, 8426 .help_str = "set port <port_id> vf <vf_id> rx|tx on|off", 8427 .tokens = { 8428 (void *)&cmd_setvf_traffic_set, 8429 (void *)&cmd_setvf_traffic_port, 8430 (void *)&cmd_setvf_traffic_portid, 8431 (void *)&cmd_setvf_traffic_vf, 8432 (void *)&cmd_setvf_traffic_vfid, 8433 (void *)&cmd_setvf_traffic_what, 8434 (void *)&cmd_setvf_traffic_mode, 8435 NULL, 8436 }, 8437 }; 8438 8439 /* *** CONFIGURE VF RECEIVE MODE *** */ 8440 struct cmd_set_vf_rxmode { 8441 cmdline_fixed_string_t set; 8442 cmdline_fixed_string_t port; 8443 portid_t port_id; 8444 cmdline_fixed_string_t vf; 8445 uint8_t vf_id; 8446 cmdline_fixed_string_t what; 8447 cmdline_fixed_string_t mode; 8448 cmdline_fixed_string_t on; 8449 }; 8450 8451 static void 8452 cmd_set_vf_rxmode_parsed(void *parsed_result, 8453 __attribute__((unused)) struct cmdline *cl, 8454 __attribute__((unused)) void *data) 8455 { 8456 int ret = -ENOTSUP; 8457 uint16_t vf_rxmode = 0; 8458 struct cmd_set_vf_rxmode *res = parsed_result; 8459 8460 int is_on = (strcmp(res->on, "on") == 0) ? 1 : 0; 8461 if (!strcmp(res->what,"rxmode")) { 8462 if (!strcmp(res->mode, "AUPE")) 8463 vf_rxmode |= ETH_VMDQ_ACCEPT_UNTAG; 8464 else if (!strcmp(res->mode, "ROPE")) 8465 vf_rxmode |= ETH_VMDQ_ACCEPT_HASH_UC; 8466 else if (!strcmp(res->mode, "BAM")) 8467 vf_rxmode |= ETH_VMDQ_ACCEPT_BROADCAST; 8468 else if (!strncmp(res->mode, "MPE",3)) 8469 vf_rxmode |= ETH_VMDQ_ACCEPT_MULTICAST; 8470 } 8471 8472 RTE_SET_USED(is_on); 8473 8474 #ifdef RTE_LIBRTE_IXGBE_PMD 8475 if (ret == -ENOTSUP) 8476 ret = rte_pmd_ixgbe_set_vf_rxmode(res->port_id, res->vf_id, 8477 vf_rxmode, (uint8_t)is_on); 8478 #endif 8479 #ifdef RTE_LIBRTE_BNXT_PMD 8480 if (ret == -ENOTSUP) 8481 ret = rte_pmd_bnxt_set_vf_rxmode(res->port_id, res->vf_id, 8482 vf_rxmode, (uint8_t)is_on); 8483 #endif 8484 if (ret < 0) 8485 printf("bad VF receive mode parameter, return code = %d \n", 8486 ret); 8487 } 8488 8489 cmdline_parse_token_string_t cmd_set_vf_rxmode_set = 8490 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_rxmode, 8491 set, "set"); 8492 cmdline_parse_token_string_t cmd_set_vf_rxmode_port = 8493 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_rxmode, 8494 port, "port"); 8495 cmdline_parse_token_num_t cmd_set_vf_rxmode_portid = 8496 TOKEN_NUM_INITIALIZER(struct cmd_set_vf_rxmode, 8497 port_id, UINT16); 8498 cmdline_parse_token_string_t cmd_set_vf_rxmode_vf = 8499 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_rxmode, 8500 vf, "vf"); 8501 cmdline_parse_token_num_t cmd_set_vf_rxmode_vfid = 8502 TOKEN_NUM_INITIALIZER(struct cmd_set_vf_rxmode, 8503 vf_id, UINT8); 8504 cmdline_parse_token_string_t cmd_set_vf_rxmode_what = 8505 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_rxmode, 8506 what, "rxmode"); 8507 cmdline_parse_token_string_t cmd_set_vf_rxmode_mode = 8508 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_rxmode, 8509 mode, "AUPE#ROPE#BAM#MPE"); 8510 cmdline_parse_token_string_t cmd_set_vf_rxmode_on = 8511 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_rxmode, 8512 on, "on#off"); 8513 8514 cmdline_parse_inst_t cmd_set_vf_rxmode = { 8515 .f = cmd_set_vf_rxmode_parsed, 8516 .data = NULL, 8517 .help_str = "set port <port_id> vf <vf_id> rxmode " 8518 "AUPE|ROPE|BAM|MPE on|off", 8519 .tokens = { 8520 (void *)&cmd_set_vf_rxmode_set, 8521 (void *)&cmd_set_vf_rxmode_port, 8522 (void *)&cmd_set_vf_rxmode_portid, 8523 (void *)&cmd_set_vf_rxmode_vf, 8524 (void *)&cmd_set_vf_rxmode_vfid, 8525 (void *)&cmd_set_vf_rxmode_what, 8526 (void *)&cmd_set_vf_rxmode_mode, 8527 (void *)&cmd_set_vf_rxmode_on, 8528 NULL, 8529 }, 8530 }; 8531 8532 /* *** ADD MAC ADDRESS FILTER FOR A VF OF A PORT *** */ 8533 struct cmd_vf_mac_addr_result { 8534 cmdline_fixed_string_t mac_addr_cmd; 8535 cmdline_fixed_string_t what; 8536 cmdline_fixed_string_t port; 8537 uint16_t port_num; 8538 cmdline_fixed_string_t vf; 8539 uint8_t vf_num; 8540 struct rte_ether_addr address; 8541 }; 8542 8543 static void cmd_vf_mac_addr_parsed(void *parsed_result, 8544 __attribute__((unused)) struct cmdline *cl, 8545 __attribute__((unused)) void *data) 8546 { 8547 struct cmd_vf_mac_addr_result *res = parsed_result; 8548 int ret = -ENOTSUP; 8549 8550 if (strcmp(res->what, "add") != 0) 8551 return; 8552 8553 #ifdef RTE_LIBRTE_I40E_PMD 8554 if (ret == -ENOTSUP) 8555 ret = rte_pmd_i40e_add_vf_mac_addr(res->port_num, res->vf_num, 8556 &res->address); 8557 #endif 8558 #ifdef RTE_LIBRTE_BNXT_PMD 8559 if (ret == -ENOTSUP) 8560 ret = rte_pmd_bnxt_mac_addr_add(res->port_num, &res->address, 8561 res->vf_num); 8562 #endif 8563 8564 if(ret < 0) 8565 printf("vf_mac_addr_cmd error: (%s)\n", strerror(-ret)); 8566 8567 } 8568 8569 cmdline_parse_token_string_t cmd_vf_mac_addr_cmd = 8570 TOKEN_STRING_INITIALIZER(struct cmd_vf_mac_addr_result, 8571 mac_addr_cmd,"mac_addr"); 8572 cmdline_parse_token_string_t cmd_vf_mac_addr_what = 8573 TOKEN_STRING_INITIALIZER(struct cmd_vf_mac_addr_result, 8574 what,"add"); 8575 cmdline_parse_token_string_t cmd_vf_mac_addr_port = 8576 TOKEN_STRING_INITIALIZER(struct cmd_vf_mac_addr_result, 8577 port,"port"); 8578 cmdline_parse_token_num_t cmd_vf_mac_addr_portnum = 8579 TOKEN_NUM_INITIALIZER(struct cmd_vf_mac_addr_result, 8580 port_num, UINT16); 8581 cmdline_parse_token_string_t cmd_vf_mac_addr_vf = 8582 TOKEN_STRING_INITIALIZER(struct cmd_vf_mac_addr_result, 8583 vf,"vf"); 8584 cmdline_parse_token_num_t cmd_vf_mac_addr_vfnum = 8585 TOKEN_NUM_INITIALIZER(struct cmd_vf_mac_addr_result, 8586 vf_num, UINT8); 8587 cmdline_parse_token_etheraddr_t cmd_vf_mac_addr_addr = 8588 TOKEN_ETHERADDR_INITIALIZER(struct cmd_vf_mac_addr_result, 8589 address); 8590 8591 cmdline_parse_inst_t cmd_vf_mac_addr_filter = { 8592 .f = cmd_vf_mac_addr_parsed, 8593 .data = (void *)0, 8594 .help_str = "mac_addr add port <port_id> vf <vf_id> <mac_addr>: " 8595 "Add MAC address filtering for a VF on port_id", 8596 .tokens = { 8597 (void *)&cmd_vf_mac_addr_cmd, 8598 (void *)&cmd_vf_mac_addr_what, 8599 (void *)&cmd_vf_mac_addr_port, 8600 (void *)&cmd_vf_mac_addr_portnum, 8601 (void *)&cmd_vf_mac_addr_vf, 8602 (void *)&cmd_vf_mac_addr_vfnum, 8603 (void *)&cmd_vf_mac_addr_addr, 8604 NULL, 8605 }, 8606 }; 8607 8608 /* *** ADD/REMOVE A VLAN IDENTIFIER TO/FROM A PORT VLAN RX FILTER *** */ 8609 struct cmd_vf_rx_vlan_filter { 8610 cmdline_fixed_string_t rx_vlan; 8611 cmdline_fixed_string_t what; 8612 uint16_t vlan_id; 8613 cmdline_fixed_string_t port; 8614 portid_t port_id; 8615 cmdline_fixed_string_t vf; 8616 uint64_t vf_mask; 8617 }; 8618 8619 static void 8620 cmd_vf_rx_vlan_filter_parsed(void *parsed_result, 8621 __attribute__((unused)) struct cmdline *cl, 8622 __attribute__((unused)) void *data) 8623 { 8624 struct cmd_vf_rx_vlan_filter *res = parsed_result; 8625 int ret = -ENOTSUP; 8626 8627 __rte_unused int is_add = (strcmp(res->what, "add") == 0) ? 1 : 0; 8628 8629 #ifdef RTE_LIBRTE_IXGBE_PMD 8630 if (ret == -ENOTSUP) 8631 ret = rte_pmd_ixgbe_set_vf_vlan_filter(res->port_id, 8632 res->vlan_id, res->vf_mask, is_add); 8633 #endif 8634 #ifdef RTE_LIBRTE_I40E_PMD 8635 if (ret == -ENOTSUP) 8636 ret = rte_pmd_i40e_set_vf_vlan_filter(res->port_id, 8637 res->vlan_id, res->vf_mask, is_add); 8638 #endif 8639 #ifdef RTE_LIBRTE_BNXT_PMD 8640 if (ret == -ENOTSUP) 8641 ret = rte_pmd_bnxt_set_vf_vlan_filter(res->port_id, 8642 res->vlan_id, res->vf_mask, is_add); 8643 #endif 8644 8645 switch (ret) { 8646 case 0: 8647 break; 8648 case -EINVAL: 8649 printf("invalid vlan_id %d or vf_mask %"PRIu64"\n", 8650 res->vlan_id, res->vf_mask); 8651 break; 8652 case -ENODEV: 8653 printf("invalid port_id %d\n", res->port_id); 8654 break; 8655 case -ENOTSUP: 8656 printf("function not implemented or supported\n"); 8657 break; 8658 default: 8659 printf("programming error: (%s)\n", strerror(-ret)); 8660 } 8661 } 8662 8663 cmdline_parse_token_string_t cmd_vf_rx_vlan_filter_rx_vlan = 8664 TOKEN_STRING_INITIALIZER(struct cmd_vf_rx_vlan_filter, 8665 rx_vlan, "rx_vlan"); 8666 cmdline_parse_token_string_t cmd_vf_rx_vlan_filter_what = 8667 TOKEN_STRING_INITIALIZER(struct cmd_vf_rx_vlan_filter, 8668 what, "add#rm"); 8669 cmdline_parse_token_num_t cmd_vf_rx_vlan_filter_vlanid = 8670 TOKEN_NUM_INITIALIZER(struct cmd_vf_rx_vlan_filter, 8671 vlan_id, UINT16); 8672 cmdline_parse_token_string_t cmd_vf_rx_vlan_filter_port = 8673 TOKEN_STRING_INITIALIZER(struct cmd_vf_rx_vlan_filter, 8674 port, "port"); 8675 cmdline_parse_token_num_t cmd_vf_rx_vlan_filter_portid = 8676 TOKEN_NUM_INITIALIZER(struct cmd_vf_rx_vlan_filter, 8677 port_id, UINT16); 8678 cmdline_parse_token_string_t cmd_vf_rx_vlan_filter_vf = 8679 TOKEN_STRING_INITIALIZER(struct cmd_vf_rx_vlan_filter, 8680 vf, "vf"); 8681 cmdline_parse_token_num_t cmd_vf_rx_vlan_filter_vf_mask = 8682 TOKEN_NUM_INITIALIZER(struct cmd_vf_rx_vlan_filter, 8683 vf_mask, UINT64); 8684 8685 cmdline_parse_inst_t cmd_vf_rxvlan_filter = { 8686 .f = cmd_vf_rx_vlan_filter_parsed, 8687 .data = NULL, 8688 .help_str = "rx_vlan add|rm <vlan_id> port <port_id> vf <vf_mask>: " 8689 "(vf_mask = hexadecimal VF mask)", 8690 .tokens = { 8691 (void *)&cmd_vf_rx_vlan_filter_rx_vlan, 8692 (void *)&cmd_vf_rx_vlan_filter_what, 8693 (void *)&cmd_vf_rx_vlan_filter_vlanid, 8694 (void *)&cmd_vf_rx_vlan_filter_port, 8695 (void *)&cmd_vf_rx_vlan_filter_portid, 8696 (void *)&cmd_vf_rx_vlan_filter_vf, 8697 (void *)&cmd_vf_rx_vlan_filter_vf_mask, 8698 NULL, 8699 }, 8700 }; 8701 8702 /* *** SET RATE LIMIT FOR A QUEUE OF A PORT *** */ 8703 struct cmd_queue_rate_limit_result { 8704 cmdline_fixed_string_t set; 8705 cmdline_fixed_string_t port; 8706 uint16_t port_num; 8707 cmdline_fixed_string_t queue; 8708 uint8_t queue_num; 8709 cmdline_fixed_string_t rate; 8710 uint16_t rate_num; 8711 }; 8712 8713 static void cmd_queue_rate_limit_parsed(void *parsed_result, 8714 __attribute__((unused)) struct cmdline *cl, 8715 __attribute__((unused)) void *data) 8716 { 8717 struct cmd_queue_rate_limit_result *res = parsed_result; 8718 int ret = 0; 8719 8720 if ((strcmp(res->set, "set") == 0) && (strcmp(res->port, "port") == 0) 8721 && (strcmp(res->queue, "queue") == 0) 8722 && (strcmp(res->rate, "rate") == 0)) 8723 ret = set_queue_rate_limit(res->port_num, res->queue_num, 8724 res->rate_num); 8725 if (ret < 0) 8726 printf("queue_rate_limit_cmd error: (%s)\n", strerror(-ret)); 8727 8728 } 8729 8730 cmdline_parse_token_string_t cmd_queue_rate_limit_set = 8731 TOKEN_STRING_INITIALIZER(struct cmd_queue_rate_limit_result, 8732 set, "set"); 8733 cmdline_parse_token_string_t cmd_queue_rate_limit_port = 8734 TOKEN_STRING_INITIALIZER(struct cmd_queue_rate_limit_result, 8735 port, "port"); 8736 cmdline_parse_token_num_t cmd_queue_rate_limit_portnum = 8737 TOKEN_NUM_INITIALIZER(struct cmd_queue_rate_limit_result, 8738 port_num, UINT16); 8739 cmdline_parse_token_string_t cmd_queue_rate_limit_queue = 8740 TOKEN_STRING_INITIALIZER(struct cmd_queue_rate_limit_result, 8741 queue, "queue"); 8742 cmdline_parse_token_num_t cmd_queue_rate_limit_queuenum = 8743 TOKEN_NUM_INITIALIZER(struct cmd_queue_rate_limit_result, 8744 queue_num, UINT8); 8745 cmdline_parse_token_string_t cmd_queue_rate_limit_rate = 8746 TOKEN_STRING_INITIALIZER(struct cmd_queue_rate_limit_result, 8747 rate, "rate"); 8748 cmdline_parse_token_num_t cmd_queue_rate_limit_ratenum = 8749 TOKEN_NUM_INITIALIZER(struct cmd_queue_rate_limit_result, 8750 rate_num, UINT16); 8751 8752 cmdline_parse_inst_t cmd_queue_rate_limit = { 8753 .f = cmd_queue_rate_limit_parsed, 8754 .data = (void *)0, 8755 .help_str = "set port <port_id> queue <queue_id> rate <rate_value>: " 8756 "Set rate limit for a queue on port_id", 8757 .tokens = { 8758 (void *)&cmd_queue_rate_limit_set, 8759 (void *)&cmd_queue_rate_limit_port, 8760 (void *)&cmd_queue_rate_limit_portnum, 8761 (void *)&cmd_queue_rate_limit_queue, 8762 (void *)&cmd_queue_rate_limit_queuenum, 8763 (void *)&cmd_queue_rate_limit_rate, 8764 (void *)&cmd_queue_rate_limit_ratenum, 8765 NULL, 8766 }, 8767 }; 8768 8769 /* *** SET RATE LIMIT FOR A VF OF A PORT *** */ 8770 struct cmd_vf_rate_limit_result { 8771 cmdline_fixed_string_t set; 8772 cmdline_fixed_string_t port; 8773 uint16_t port_num; 8774 cmdline_fixed_string_t vf; 8775 uint8_t vf_num; 8776 cmdline_fixed_string_t rate; 8777 uint16_t rate_num; 8778 cmdline_fixed_string_t q_msk; 8779 uint64_t q_msk_val; 8780 }; 8781 8782 static void cmd_vf_rate_limit_parsed(void *parsed_result, 8783 __attribute__((unused)) struct cmdline *cl, 8784 __attribute__((unused)) void *data) 8785 { 8786 struct cmd_vf_rate_limit_result *res = parsed_result; 8787 int ret = 0; 8788 8789 if ((strcmp(res->set, "set") == 0) && (strcmp(res->port, "port") == 0) 8790 && (strcmp(res->vf, "vf") == 0) 8791 && (strcmp(res->rate, "rate") == 0) 8792 && (strcmp(res->q_msk, "queue_mask") == 0)) 8793 ret = set_vf_rate_limit(res->port_num, res->vf_num, 8794 res->rate_num, res->q_msk_val); 8795 if (ret < 0) 8796 printf("vf_rate_limit_cmd error: (%s)\n", strerror(-ret)); 8797 8798 } 8799 8800 cmdline_parse_token_string_t cmd_vf_rate_limit_set = 8801 TOKEN_STRING_INITIALIZER(struct cmd_vf_rate_limit_result, 8802 set, "set"); 8803 cmdline_parse_token_string_t cmd_vf_rate_limit_port = 8804 TOKEN_STRING_INITIALIZER(struct cmd_vf_rate_limit_result, 8805 port, "port"); 8806 cmdline_parse_token_num_t cmd_vf_rate_limit_portnum = 8807 TOKEN_NUM_INITIALIZER(struct cmd_vf_rate_limit_result, 8808 port_num, UINT16); 8809 cmdline_parse_token_string_t cmd_vf_rate_limit_vf = 8810 TOKEN_STRING_INITIALIZER(struct cmd_vf_rate_limit_result, 8811 vf, "vf"); 8812 cmdline_parse_token_num_t cmd_vf_rate_limit_vfnum = 8813 TOKEN_NUM_INITIALIZER(struct cmd_vf_rate_limit_result, 8814 vf_num, UINT8); 8815 cmdline_parse_token_string_t cmd_vf_rate_limit_rate = 8816 TOKEN_STRING_INITIALIZER(struct cmd_vf_rate_limit_result, 8817 rate, "rate"); 8818 cmdline_parse_token_num_t cmd_vf_rate_limit_ratenum = 8819 TOKEN_NUM_INITIALIZER(struct cmd_vf_rate_limit_result, 8820 rate_num, UINT16); 8821 cmdline_parse_token_string_t cmd_vf_rate_limit_q_msk = 8822 TOKEN_STRING_INITIALIZER(struct cmd_vf_rate_limit_result, 8823 q_msk, "queue_mask"); 8824 cmdline_parse_token_num_t cmd_vf_rate_limit_q_msk_val = 8825 TOKEN_NUM_INITIALIZER(struct cmd_vf_rate_limit_result, 8826 q_msk_val, UINT64); 8827 8828 cmdline_parse_inst_t cmd_vf_rate_limit = { 8829 .f = cmd_vf_rate_limit_parsed, 8830 .data = (void *)0, 8831 .help_str = "set port <port_id> vf <vf_id> rate <rate_value> " 8832 "queue_mask <queue_mask_value>: " 8833 "Set rate limit for queues of VF on port_id", 8834 .tokens = { 8835 (void *)&cmd_vf_rate_limit_set, 8836 (void *)&cmd_vf_rate_limit_port, 8837 (void *)&cmd_vf_rate_limit_portnum, 8838 (void *)&cmd_vf_rate_limit_vf, 8839 (void *)&cmd_vf_rate_limit_vfnum, 8840 (void *)&cmd_vf_rate_limit_rate, 8841 (void *)&cmd_vf_rate_limit_ratenum, 8842 (void *)&cmd_vf_rate_limit_q_msk, 8843 (void *)&cmd_vf_rate_limit_q_msk_val, 8844 NULL, 8845 }, 8846 }; 8847 8848 /* *** ADD TUNNEL FILTER OF A PORT *** */ 8849 struct cmd_tunnel_filter_result { 8850 cmdline_fixed_string_t cmd; 8851 cmdline_fixed_string_t what; 8852 portid_t port_id; 8853 struct rte_ether_addr outer_mac; 8854 struct rte_ether_addr inner_mac; 8855 cmdline_ipaddr_t ip_value; 8856 uint16_t inner_vlan; 8857 cmdline_fixed_string_t tunnel_type; 8858 cmdline_fixed_string_t filter_type; 8859 uint32_t tenant_id; 8860 uint16_t queue_num; 8861 }; 8862 8863 static void 8864 cmd_tunnel_filter_parsed(void *parsed_result, 8865 __attribute__((unused)) struct cmdline *cl, 8866 __attribute__((unused)) void *data) 8867 { 8868 struct cmd_tunnel_filter_result *res = parsed_result; 8869 struct rte_eth_tunnel_filter_conf tunnel_filter_conf; 8870 int ret = 0; 8871 8872 memset(&tunnel_filter_conf, 0, sizeof(tunnel_filter_conf)); 8873 8874 rte_ether_addr_copy(&res->outer_mac, &tunnel_filter_conf.outer_mac); 8875 rte_ether_addr_copy(&res->inner_mac, &tunnel_filter_conf.inner_mac); 8876 tunnel_filter_conf.inner_vlan = res->inner_vlan; 8877 8878 if (res->ip_value.family == AF_INET) { 8879 tunnel_filter_conf.ip_addr.ipv4_addr = 8880 res->ip_value.addr.ipv4.s_addr; 8881 tunnel_filter_conf.ip_type = RTE_TUNNEL_IPTYPE_IPV4; 8882 } else { 8883 memcpy(&(tunnel_filter_conf.ip_addr.ipv6_addr), 8884 &(res->ip_value.addr.ipv6), 8885 sizeof(struct in6_addr)); 8886 tunnel_filter_conf.ip_type = RTE_TUNNEL_IPTYPE_IPV6; 8887 } 8888 8889 if (!strcmp(res->filter_type, "imac-ivlan")) 8890 tunnel_filter_conf.filter_type = RTE_TUNNEL_FILTER_IMAC_IVLAN; 8891 else if (!strcmp(res->filter_type, "imac-ivlan-tenid")) 8892 tunnel_filter_conf.filter_type = 8893 RTE_TUNNEL_FILTER_IMAC_IVLAN_TENID; 8894 else if (!strcmp(res->filter_type, "imac-tenid")) 8895 tunnel_filter_conf.filter_type = RTE_TUNNEL_FILTER_IMAC_TENID; 8896 else if (!strcmp(res->filter_type, "imac")) 8897 tunnel_filter_conf.filter_type = ETH_TUNNEL_FILTER_IMAC; 8898 else if (!strcmp(res->filter_type, "omac-imac-tenid")) 8899 tunnel_filter_conf.filter_type = 8900 RTE_TUNNEL_FILTER_OMAC_TENID_IMAC; 8901 else if (!strcmp(res->filter_type, "oip")) 8902 tunnel_filter_conf.filter_type = ETH_TUNNEL_FILTER_OIP; 8903 else if (!strcmp(res->filter_type, "iip")) 8904 tunnel_filter_conf.filter_type = ETH_TUNNEL_FILTER_IIP; 8905 else { 8906 printf("The filter type is not supported"); 8907 return; 8908 } 8909 8910 if (!strcmp(res->tunnel_type, "vxlan")) 8911 tunnel_filter_conf.tunnel_type = RTE_TUNNEL_TYPE_VXLAN; 8912 else if (!strcmp(res->tunnel_type, "vxlan-gpe")) 8913 tunnel_filter_conf.tunnel_type = RTE_TUNNEL_TYPE_VXLAN_GPE; 8914 else if (!strcmp(res->tunnel_type, "nvgre")) 8915 tunnel_filter_conf.tunnel_type = RTE_TUNNEL_TYPE_NVGRE; 8916 else if (!strcmp(res->tunnel_type, "ipingre")) 8917 tunnel_filter_conf.tunnel_type = RTE_TUNNEL_TYPE_IP_IN_GRE; 8918 else { 8919 printf("The tunnel type %s not supported.\n", res->tunnel_type); 8920 return; 8921 } 8922 8923 tunnel_filter_conf.tenant_id = res->tenant_id; 8924 tunnel_filter_conf.queue_id = res->queue_num; 8925 if (!strcmp(res->what, "add")) 8926 ret = rte_eth_dev_filter_ctrl(res->port_id, 8927 RTE_ETH_FILTER_TUNNEL, 8928 RTE_ETH_FILTER_ADD, 8929 &tunnel_filter_conf); 8930 else 8931 ret = rte_eth_dev_filter_ctrl(res->port_id, 8932 RTE_ETH_FILTER_TUNNEL, 8933 RTE_ETH_FILTER_DELETE, 8934 &tunnel_filter_conf); 8935 if (ret < 0) 8936 printf("cmd_tunnel_filter_parsed error: (%s)\n", 8937 strerror(-ret)); 8938 8939 } 8940 cmdline_parse_token_string_t cmd_tunnel_filter_cmd = 8941 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_filter_result, 8942 cmd, "tunnel_filter"); 8943 cmdline_parse_token_string_t cmd_tunnel_filter_what = 8944 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_filter_result, 8945 what, "add#rm"); 8946 cmdline_parse_token_num_t cmd_tunnel_filter_port_id = 8947 TOKEN_NUM_INITIALIZER(struct cmd_tunnel_filter_result, 8948 port_id, UINT16); 8949 cmdline_parse_token_etheraddr_t cmd_tunnel_filter_outer_mac = 8950 TOKEN_ETHERADDR_INITIALIZER(struct cmd_tunnel_filter_result, 8951 outer_mac); 8952 cmdline_parse_token_etheraddr_t cmd_tunnel_filter_inner_mac = 8953 TOKEN_ETHERADDR_INITIALIZER(struct cmd_tunnel_filter_result, 8954 inner_mac); 8955 cmdline_parse_token_num_t cmd_tunnel_filter_innner_vlan = 8956 TOKEN_NUM_INITIALIZER(struct cmd_tunnel_filter_result, 8957 inner_vlan, UINT16); 8958 cmdline_parse_token_ipaddr_t cmd_tunnel_filter_ip_value = 8959 TOKEN_IPADDR_INITIALIZER(struct cmd_tunnel_filter_result, 8960 ip_value); 8961 cmdline_parse_token_string_t cmd_tunnel_filter_tunnel_type = 8962 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_filter_result, 8963 tunnel_type, "vxlan#nvgre#ipingre#vxlan-gpe"); 8964 8965 cmdline_parse_token_string_t cmd_tunnel_filter_filter_type = 8966 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_filter_result, 8967 filter_type, "oip#iip#imac-ivlan#imac-ivlan-tenid#imac-tenid#" 8968 "imac#omac-imac-tenid"); 8969 cmdline_parse_token_num_t cmd_tunnel_filter_tenant_id = 8970 TOKEN_NUM_INITIALIZER(struct cmd_tunnel_filter_result, 8971 tenant_id, UINT32); 8972 cmdline_parse_token_num_t cmd_tunnel_filter_queue_num = 8973 TOKEN_NUM_INITIALIZER(struct cmd_tunnel_filter_result, 8974 queue_num, UINT16); 8975 8976 cmdline_parse_inst_t cmd_tunnel_filter = { 8977 .f = cmd_tunnel_filter_parsed, 8978 .data = (void *)0, 8979 .help_str = "tunnel_filter add|rm <port_id> <outer_mac> <inner_mac> " 8980 "<ip> <inner_vlan> vxlan|nvgre|ipingre oip|iip|imac-ivlan|" 8981 "imac-ivlan-tenid|imac-tenid|imac|omac-imac-tenid <tenant_id> " 8982 "<queue_id>: Add/Rm tunnel filter of a port", 8983 .tokens = { 8984 (void *)&cmd_tunnel_filter_cmd, 8985 (void *)&cmd_tunnel_filter_what, 8986 (void *)&cmd_tunnel_filter_port_id, 8987 (void *)&cmd_tunnel_filter_outer_mac, 8988 (void *)&cmd_tunnel_filter_inner_mac, 8989 (void *)&cmd_tunnel_filter_ip_value, 8990 (void *)&cmd_tunnel_filter_innner_vlan, 8991 (void *)&cmd_tunnel_filter_tunnel_type, 8992 (void *)&cmd_tunnel_filter_filter_type, 8993 (void *)&cmd_tunnel_filter_tenant_id, 8994 (void *)&cmd_tunnel_filter_queue_num, 8995 NULL, 8996 }, 8997 }; 8998 8999 /* *** CONFIGURE TUNNEL UDP PORT *** */ 9000 struct cmd_tunnel_udp_config { 9001 cmdline_fixed_string_t cmd; 9002 cmdline_fixed_string_t what; 9003 uint16_t udp_port; 9004 portid_t port_id; 9005 }; 9006 9007 static void 9008 cmd_tunnel_udp_config_parsed(void *parsed_result, 9009 __attribute__((unused)) struct cmdline *cl, 9010 __attribute__((unused)) void *data) 9011 { 9012 struct cmd_tunnel_udp_config *res = parsed_result; 9013 struct rte_eth_udp_tunnel tunnel_udp; 9014 int ret; 9015 9016 tunnel_udp.udp_port = res->udp_port; 9017 9018 if (!strcmp(res->cmd, "rx_vxlan_port")) 9019 tunnel_udp.prot_type = RTE_TUNNEL_TYPE_VXLAN; 9020 9021 if (!strcmp(res->what, "add")) 9022 ret = rte_eth_dev_udp_tunnel_port_add(res->port_id, 9023 &tunnel_udp); 9024 else 9025 ret = rte_eth_dev_udp_tunnel_port_delete(res->port_id, 9026 &tunnel_udp); 9027 9028 if (ret < 0) 9029 printf("udp tunneling add error: (%s)\n", strerror(-ret)); 9030 } 9031 9032 cmdline_parse_token_string_t cmd_tunnel_udp_config_cmd = 9033 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_udp_config, 9034 cmd, "rx_vxlan_port"); 9035 cmdline_parse_token_string_t cmd_tunnel_udp_config_what = 9036 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_udp_config, 9037 what, "add#rm"); 9038 cmdline_parse_token_num_t cmd_tunnel_udp_config_udp_port = 9039 TOKEN_NUM_INITIALIZER(struct cmd_tunnel_udp_config, 9040 udp_port, UINT16); 9041 cmdline_parse_token_num_t cmd_tunnel_udp_config_port_id = 9042 TOKEN_NUM_INITIALIZER(struct cmd_tunnel_udp_config, 9043 port_id, UINT16); 9044 9045 cmdline_parse_inst_t cmd_tunnel_udp_config = { 9046 .f = cmd_tunnel_udp_config_parsed, 9047 .data = (void *)0, 9048 .help_str = "rx_vxlan_port add|rm <udp_port> <port_id>: " 9049 "Add/Remove a tunneling UDP port filter", 9050 .tokens = { 9051 (void *)&cmd_tunnel_udp_config_cmd, 9052 (void *)&cmd_tunnel_udp_config_what, 9053 (void *)&cmd_tunnel_udp_config_udp_port, 9054 (void *)&cmd_tunnel_udp_config_port_id, 9055 NULL, 9056 }, 9057 }; 9058 9059 struct cmd_config_tunnel_udp_port { 9060 cmdline_fixed_string_t port; 9061 cmdline_fixed_string_t config; 9062 portid_t port_id; 9063 cmdline_fixed_string_t udp_tunnel_port; 9064 cmdline_fixed_string_t action; 9065 cmdline_fixed_string_t tunnel_type; 9066 uint16_t udp_port; 9067 }; 9068 9069 static void 9070 cmd_cfg_tunnel_udp_port_parsed(void *parsed_result, 9071 __attribute__((unused)) struct cmdline *cl, 9072 __attribute__((unused)) void *data) 9073 { 9074 struct cmd_config_tunnel_udp_port *res = parsed_result; 9075 struct rte_eth_udp_tunnel tunnel_udp; 9076 int ret = 0; 9077 9078 if (port_id_is_invalid(res->port_id, ENABLED_WARN)) 9079 return; 9080 9081 tunnel_udp.udp_port = res->udp_port; 9082 9083 if (!strcmp(res->tunnel_type, "vxlan")) { 9084 tunnel_udp.prot_type = RTE_TUNNEL_TYPE_VXLAN; 9085 } else if (!strcmp(res->tunnel_type, "geneve")) { 9086 tunnel_udp.prot_type = RTE_TUNNEL_TYPE_GENEVE; 9087 } else if (!strcmp(res->tunnel_type, "vxlan-gpe")) { 9088 tunnel_udp.prot_type = RTE_TUNNEL_TYPE_VXLAN_GPE; 9089 } else { 9090 printf("Invalid tunnel type\n"); 9091 return; 9092 } 9093 9094 if (!strcmp(res->action, "add")) 9095 ret = rte_eth_dev_udp_tunnel_port_add(res->port_id, 9096 &tunnel_udp); 9097 else 9098 ret = rte_eth_dev_udp_tunnel_port_delete(res->port_id, 9099 &tunnel_udp); 9100 9101 if (ret < 0) 9102 printf("udp tunneling port add error: (%s)\n", strerror(-ret)); 9103 } 9104 9105 cmdline_parse_token_string_t cmd_config_tunnel_udp_port_port = 9106 TOKEN_STRING_INITIALIZER(struct cmd_config_tunnel_udp_port, port, 9107 "port"); 9108 cmdline_parse_token_string_t cmd_config_tunnel_udp_port_config = 9109 TOKEN_STRING_INITIALIZER(struct cmd_config_tunnel_udp_port, config, 9110 "config"); 9111 cmdline_parse_token_num_t cmd_config_tunnel_udp_port_port_id = 9112 TOKEN_NUM_INITIALIZER(struct cmd_config_tunnel_udp_port, port_id, 9113 UINT16); 9114 cmdline_parse_token_string_t cmd_config_tunnel_udp_port_tunnel_port = 9115 TOKEN_STRING_INITIALIZER(struct cmd_config_tunnel_udp_port, 9116 udp_tunnel_port, 9117 "udp_tunnel_port"); 9118 cmdline_parse_token_string_t cmd_config_tunnel_udp_port_action = 9119 TOKEN_STRING_INITIALIZER(struct cmd_config_tunnel_udp_port, action, 9120 "add#rm"); 9121 cmdline_parse_token_string_t cmd_config_tunnel_udp_port_tunnel_type = 9122 TOKEN_STRING_INITIALIZER(struct cmd_config_tunnel_udp_port, tunnel_type, 9123 "vxlan#geneve#vxlan-gpe"); 9124 cmdline_parse_token_num_t cmd_config_tunnel_udp_port_value = 9125 TOKEN_NUM_INITIALIZER(struct cmd_config_tunnel_udp_port, udp_port, 9126 UINT16); 9127 9128 cmdline_parse_inst_t cmd_cfg_tunnel_udp_port = { 9129 .f = cmd_cfg_tunnel_udp_port_parsed, 9130 .data = NULL, 9131 .help_str = "port config <port_id> udp_tunnel_port add|rm vxlan|geneve|vxlan-gpe <udp_port>", 9132 .tokens = { 9133 (void *)&cmd_config_tunnel_udp_port_port, 9134 (void *)&cmd_config_tunnel_udp_port_config, 9135 (void *)&cmd_config_tunnel_udp_port_port_id, 9136 (void *)&cmd_config_tunnel_udp_port_tunnel_port, 9137 (void *)&cmd_config_tunnel_udp_port_action, 9138 (void *)&cmd_config_tunnel_udp_port_tunnel_type, 9139 (void *)&cmd_config_tunnel_udp_port_value, 9140 NULL, 9141 }, 9142 }; 9143 9144 /* *** GLOBAL CONFIG *** */ 9145 struct cmd_global_config_result { 9146 cmdline_fixed_string_t cmd; 9147 portid_t port_id; 9148 cmdline_fixed_string_t cfg_type; 9149 uint8_t len; 9150 }; 9151 9152 static void 9153 cmd_global_config_parsed(void *parsed_result, 9154 __attribute__((unused)) struct cmdline *cl, 9155 __attribute__((unused)) void *data) 9156 { 9157 struct cmd_global_config_result *res = parsed_result; 9158 struct rte_eth_global_cfg conf; 9159 int ret; 9160 9161 memset(&conf, 0, sizeof(conf)); 9162 conf.cfg_type = RTE_ETH_GLOBAL_CFG_TYPE_GRE_KEY_LEN; 9163 conf.cfg.gre_key_len = res->len; 9164 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_NONE, 9165 RTE_ETH_FILTER_SET, &conf); 9166 if (ret != 0) 9167 printf("Global config error\n"); 9168 } 9169 9170 cmdline_parse_token_string_t cmd_global_config_cmd = 9171 TOKEN_STRING_INITIALIZER(struct cmd_global_config_result, cmd, 9172 "global_config"); 9173 cmdline_parse_token_num_t cmd_global_config_port_id = 9174 TOKEN_NUM_INITIALIZER(struct cmd_global_config_result, port_id, 9175 UINT16); 9176 cmdline_parse_token_string_t cmd_global_config_type = 9177 TOKEN_STRING_INITIALIZER(struct cmd_global_config_result, 9178 cfg_type, "gre-key-len"); 9179 cmdline_parse_token_num_t cmd_global_config_gre_key_len = 9180 TOKEN_NUM_INITIALIZER(struct cmd_global_config_result, 9181 len, UINT8); 9182 9183 cmdline_parse_inst_t cmd_global_config = { 9184 .f = cmd_global_config_parsed, 9185 .data = (void *)NULL, 9186 .help_str = "global_config <port_id> gre-key-len <key_len>", 9187 .tokens = { 9188 (void *)&cmd_global_config_cmd, 9189 (void *)&cmd_global_config_port_id, 9190 (void *)&cmd_global_config_type, 9191 (void *)&cmd_global_config_gre_key_len, 9192 NULL, 9193 }, 9194 }; 9195 9196 /* *** CONFIGURE VM MIRROR VLAN/POOL RULE *** */ 9197 struct cmd_set_mirror_mask_result { 9198 cmdline_fixed_string_t set; 9199 cmdline_fixed_string_t port; 9200 portid_t port_id; 9201 cmdline_fixed_string_t mirror; 9202 uint8_t rule_id; 9203 cmdline_fixed_string_t what; 9204 cmdline_fixed_string_t value; 9205 cmdline_fixed_string_t dstpool; 9206 uint8_t dstpool_id; 9207 cmdline_fixed_string_t on; 9208 }; 9209 9210 cmdline_parse_token_string_t cmd_mirror_mask_set = 9211 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result, 9212 set, "set"); 9213 cmdline_parse_token_string_t cmd_mirror_mask_port = 9214 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result, 9215 port, "port"); 9216 cmdline_parse_token_num_t cmd_mirror_mask_portid = 9217 TOKEN_NUM_INITIALIZER(struct cmd_set_mirror_mask_result, 9218 port_id, UINT16); 9219 cmdline_parse_token_string_t cmd_mirror_mask_mirror = 9220 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result, 9221 mirror, "mirror-rule"); 9222 cmdline_parse_token_num_t cmd_mirror_mask_ruleid = 9223 TOKEN_NUM_INITIALIZER(struct cmd_set_mirror_mask_result, 9224 rule_id, UINT8); 9225 cmdline_parse_token_string_t cmd_mirror_mask_what = 9226 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result, 9227 what, "pool-mirror-up#pool-mirror-down" 9228 "#vlan-mirror"); 9229 cmdline_parse_token_string_t cmd_mirror_mask_value = 9230 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result, 9231 value, NULL); 9232 cmdline_parse_token_string_t cmd_mirror_mask_dstpool = 9233 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result, 9234 dstpool, "dst-pool"); 9235 cmdline_parse_token_num_t cmd_mirror_mask_poolid = 9236 TOKEN_NUM_INITIALIZER(struct cmd_set_mirror_mask_result, 9237 dstpool_id, UINT8); 9238 cmdline_parse_token_string_t cmd_mirror_mask_on = 9239 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result, 9240 on, "on#off"); 9241 9242 static void 9243 cmd_set_mirror_mask_parsed(void *parsed_result, 9244 __attribute__((unused)) struct cmdline *cl, 9245 __attribute__((unused)) void *data) 9246 { 9247 int ret,nb_item,i; 9248 struct cmd_set_mirror_mask_result *res = parsed_result; 9249 struct rte_eth_mirror_conf mr_conf; 9250 9251 memset(&mr_conf, 0, sizeof(struct rte_eth_mirror_conf)); 9252 9253 unsigned int vlan_list[ETH_MIRROR_MAX_VLANS]; 9254 9255 mr_conf.dst_pool = res->dstpool_id; 9256 9257 if (!strcmp(res->what, "pool-mirror-up")) { 9258 mr_conf.pool_mask = strtoull(res->value, NULL, 16); 9259 mr_conf.rule_type = ETH_MIRROR_VIRTUAL_POOL_UP; 9260 } else if (!strcmp(res->what, "pool-mirror-down")) { 9261 mr_conf.pool_mask = strtoull(res->value, NULL, 16); 9262 mr_conf.rule_type = ETH_MIRROR_VIRTUAL_POOL_DOWN; 9263 } else if (!strcmp(res->what, "vlan-mirror")) { 9264 mr_conf.rule_type = ETH_MIRROR_VLAN; 9265 nb_item = parse_item_list(res->value, "vlan", 9266 ETH_MIRROR_MAX_VLANS, vlan_list, 1); 9267 if (nb_item <= 0) 9268 return; 9269 9270 for (i = 0; i < nb_item; i++) { 9271 if (vlan_list[i] > RTE_ETHER_MAX_VLAN_ID) { 9272 printf("Invalid vlan_id: must be < 4096\n"); 9273 return; 9274 } 9275 9276 mr_conf.vlan.vlan_id[i] = (uint16_t)vlan_list[i]; 9277 mr_conf.vlan.vlan_mask |= 1ULL << i; 9278 } 9279 } 9280 9281 if (!strcmp(res->on, "on")) 9282 ret = rte_eth_mirror_rule_set(res->port_id, &mr_conf, 9283 res->rule_id, 1); 9284 else 9285 ret = rte_eth_mirror_rule_set(res->port_id, &mr_conf, 9286 res->rule_id, 0); 9287 if (ret < 0) 9288 printf("mirror rule add error: (%s)\n", strerror(-ret)); 9289 } 9290 9291 cmdline_parse_inst_t cmd_set_mirror_mask = { 9292 .f = cmd_set_mirror_mask_parsed, 9293 .data = NULL, 9294 .help_str = "set port <port_id> mirror-rule <rule_id> " 9295 "pool-mirror-up|pool-mirror-down|vlan-mirror " 9296 "<pool_mask|vlan_id[,vlan_id]*> dst-pool <pool_id> on|off", 9297 .tokens = { 9298 (void *)&cmd_mirror_mask_set, 9299 (void *)&cmd_mirror_mask_port, 9300 (void *)&cmd_mirror_mask_portid, 9301 (void *)&cmd_mirror_mask_mirror, 9302 (void *)&cmd_mirror_mask_ruleid, 9303 (void *)&cmd_mirror_mask_what, 9304 (void *)&cmd_mirror_mask_value, 9305 (void *)&cmd_mirror_mask_dstpool, 9306 (void *)&cmd_mirror_mask_poolid, 9307 (void *)&cmd_mirror_mask_on, 9308 NULL, 9309 }, 9310 }; 9311 9312 /* *** CONFIGURE VM MIRROR UPLINK/DOWNLINK RULE *** */ 9313 struct cmd_set_mirror_link_result { 9314 cmdline_fixed_string_t set; 9315 cmdline_fixed_string_t port; 9316 portid_t port_id; 9317 cmdline_fixed_string_t mirror; 9318 uint8_t rule_id; 9319 cmdline_fixed_string_t what; 9320 cmdline_fixed_string_t dstpool; 9321 uint8_t dstpool_id; 9322 cmdline_fixed_string_t on; 9323 }; 9324 9325 cmdline_parse_token_string_t cmd_mirror_link_set = 9326 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_link_result, 9327 set, "set"); 9328 cmdline_parse_token_string_t cmd_mirror_link_port = 9329 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_link_result, 9330 port, "port"); 9331 cmdline_parse_token_num_t cmd_mirror_link_portid = 9332 TOKEN_NUM_INITIALIZER(struct cmd_set_mirror_link_result, 9333 port_id, UINT16); 9334 cmdline_parse_token_string_t cmd_mirror_link_mirror = 9335 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_link_result, 9336 mirror, "mirror-rule"); 9337 cmdline_parse_token_num_t cmd_mirror_link_ruleid = 9338 TOKEN_NUM_INITIALIZER(struct cmd_set_mirror_link_result, 9339 rule_id, UINT8); 9340 cmdline_parse_token_string_t cmd_mirror_link_what = 9341 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_link_result, 9342 what, "uplink-mirror#downlink-mirror"); 9343 cmdline_parse_token_string_t cmd_mirror_link_dstpool = 9344 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_link_result, 9345 dstpool, "dst-pool"); 9346 cmdline_parse_token_num_t cmd_mirror_link_poolid = 9347 TOKEN_NUM_INITIALIZER(struct cmd_set_mirror_link_result, 9348 dstpool_id, UINT8); 9349 cmdline_parse_token_string_t cmd_mirror_link_on = 9350 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_link_result, 9351 on, "on#off"); 9352 9353 static void 9354 cmd_set_mirror_link_parsed(void *parsed_result, 9355 __attribute__((unused)) struct cmdline *cl, 9356 __attribute__((unused)) void *data) 9357 { 9358 int ret; 9359 struct cmd_set_mirror_link_result *res = parsed_result; 9360 struct rte_eth_mirror_conf mr_conf; 9361 9362 memset(&mr_conf, 0, sizeof(struct rte_eth_mirror_conf)); 9363 if (!strcmp(res->what, "uplink-mirror")) 9364 mr_conf.rule_type = ETH_MIRROR_UPLINK_PORT; 9365 else 9366 mr_conf.rule_type = ETH_MIRROR_DOWNLINK_PORT; 9367 9368 mr_conf.dst_pool = res->dstpool_id; 9369 9370 if (!strcmp(res->on, "on")) 9371 ret = rte_eth_mirror_rule_set(res->port_id, &mr_conf, 9372 res->rule_id, 1); 9373 else 9374 ret = rte_eth_mirror_rule_set(res->port_id, &mr_conf, 9375 res->rule_id, 0); 9376 9377 /* check the return value and print it if is < 0 */ 9378 if (ret < 0) 9379 printf("mirror rule add error: (%s)\n", strerror(-ret)); 9380 9381 } 9382 9383 cmdline_parse_inst_t cmd_set_mirror_link = { 9384 .f = cmd_set_mirror_link_parsed, 9385 .data = NULL, 9386 .help_str = "set port <port_id> mirror-rule <rule_id> " 9387 "uplink-mirror|downlink-mirror dst-pool <pool_id> on|off", 9388 .tokens = { 9389 (void *)&cmd_mirror_link_set, 9390 (void *)&cmd_mirror_link_port, 9391 (void *)&cmd_mirror_link_portid, 9392 (void *)&cmd_mirror_link_mirror, 9393 (void *)&cmd_mirror_link_ruleid, 9394 (void *)&cmd_mirror_link_what, 9395 (void *)&cmd_mirror_link_dstpool, 9396 (void *)&cmd_mirror_link_poolid, 9397 (void *)&cmd_mirror_link_on, 9398 NULL, 9399 }, 9400 }; 9401 9402 /* *** RESET VM MIRROR RULE *** */ 9403 struct cmd_rm_mirror_rule_result { 9404 cmdline_fixed_string_t reset; 9405 cmdline_fixed_string_t port; 9406 portid_t port_id; 9407 cmdline_fixed_string_t mirror; 9408 uint8_t rule_id; 9409 }; 9410 9411 cmdline_parse_token_string_t cmd_rm_mirror_rule_reset = 9412 TOKEN_STRING_INITIALIZER(struct cmd_rm_mirror_rule_result, 9413 reset, "reset"); 9414 cmdline_parse_token_string_t cmd_rm_mirror_rule_port = 9415 TOKEN_STRING_INITIALIZER(struct cmd_rm_mirror_rule_result, 9416 port, "port"); 9417 cmdline_parse_token_num_t cmd_rm_mirror_rule_portid = 9418 TOKEN_NUM_INITIALIZER(struct cmd_rm_mirror_rule_result, 9419 port_id, UINT16); 9420 cmdline_parse_token_string_t cmd_rm_mirror_rule_mirror = 9421 TOKEN_STRING_INITIALIZER(struct cmd_rm_mirror_rule_result, 9422 mirror, "mirror-rule"); 9423 cmdline_parse_token_num_t cmd_rm_mirror_rule_ruleid = 9424 TOKEN_NUM_INITIALIZER(struct cmd_rm_mirror_rule_result, 9425 rule_id, UINT8); 9426 9427 static void 9428 cmd_reset_mirror_rule_parsed(void *parsed_result, 9429 __attribute__((unused)) struct cmdline *cl, 9430 __attribute__((unused)) void *data) 9431 { 9432 int ret; 9433 struct cmd_set_mirror_link_result *res = parsed_result; 9434 /* check rule_id */ 9435 ret = rte_eth_mirror_rule_reset(res->port_id,res->rule_id); 9436 if(ret < 0) 9437 printf("mirror rule remove error: (%s)\n", strerror(-ret)); 9438 } 9439 9440 cmdline_parse_inst_t cmd_reset_mirror_rule = { 9441 .f = cmd_reset_mirror_rule_parsed, 9442 .data = NULL, 9443 .help_str = "reset port <port_id> mirror-rule <rule_id>", 9444 .tokens = { 9445 (void *)&cmd_rm_mirror_rule_reset, 9446 (void *)&cmd_rm_mirror_rule_port, 9447 (void *)&cmd_rm_mirror_rule_portid, 9448 (void *)&cmd_rm_mirror_rule_mirror, 9449 (void *)&cmd_rm_mirror_rule_ruleid, 9450 NULL, 9451 }, 9452 }; 9453 9454 /* ******************************************************************************** */ 9455 9456 struct cmd_dump_result { 9457 cmdline_fixed_string_t dump; 9458 }; 9459 9460 static void 9461 dump_struct_sizes(void) 9462 { 9463 #define DUMP_SIZE(t) printf("sizeof(" #t ") = %u\n", (unsigned)sizeof(t)); 9464 DUMP_SIZE(struct rte_mbuf); 9465 DUMP_SIZE(struct rte_mempool); 9466 DUMP_SIZE(struct rte_ring); 9467 #undef DUMP_SIZE 9468 } 9469 9470 static void cmd_dump_parsed(void *parsed_result, 9471 __attribute__((unused)) struct cmdline *cl, 9472 __attribute__((unused)) void *data) 9473 { 9474 struct cmd_dump_result *res = parsed_result; 9475 9476 if (!strcmp(res->dump, "dump_physmem")) 9477 rte_dump_physmem_layout(stdout); 9478 else if (!strcmp(res->dump, "dump_memzone")) 9479 rte_memzone_dump(stdout); 9480 else if (!strcmp(res->dump, "dump_struct_sizes")) 9481 dump_struct_sizes(); 9482 else if (!strcmp(res->dump, "dump_ring")) 9483 rte_ring_list_dump(stdout); 9484 else if (!strcmp(res->dump, "dump_mempool")) 9485 rte_mempool_list_dump(stdout); 9486 else if (!strcmp(res->dump, "dump_devargs")) 9487 rte_devargs_dump(stdout); 9488 else if (!strcmp(res->dump, "dump_log_types")) 9489 rte_log_dump(stdout); 9490 } 9491 9492 cmdline_parse_token_string_t cmd_dump_dump = 9493 TOKEN_STRING_INITIALIZER(struct cmd_dump_result, dump, 9494 "dump_physmem#" 9495 "dump_memzone#" 9496 "dump_struct_sizes#" 9497 "dump_ring#" 9498 "dump_mempool#" 9499 "dump_devargs#" 9500 "dump_log_types"); 9501 9502 cmdline_parse_inst_t cmd_dump = { 9503 .f = cmd_dump_parsed, /* function to call */ 9504 .data = NULL, /* 2nd arg of func */ 9505 .help_str = "Dump status", 9506 .tokens = { /* token list, NULL terminated */ 9507 (void *)&cmd_dump_dump, 9508 NULL, 9509 }, 9510 }; 9511 9512 /* ******************************************************************************** */ 9513 9514 struct cmd_dump_one_result { 9515 cmdline_fixed_string_t dump; 9516 cmdline_fixed_string_t name; 9517 }; 9518 9519 static void cmd_dump_one_parsed(void *parsed_result, struct cmdline *cl, 9520 __attribute__((unused)) void *data) 9521 { 9522 struct cmd_dump_one_result *res = parsed_result; 9523 9524 if (!strcmp(res->dump, "dump_ring")) { 9525 struct rte_ring *r; 9526 r = rte_ring_lookup(res->name); 9527 if (r == NULL) { 9528 cmdline_printf(cl, "Cannot find ring\n"); 9529 return; 9530 } 9531 rte_ring_dump(stdout, r); 9532 } else if (!strcmp(res->dump, "dump_mempool")) { 9533 struct rte_mempool *mp; 9534 mp = rte_mempool_lookup(res->name); 9535 if (mp == NULL) { 9536 cmdline_printf(cl, "Cannot find mempool\n"); 9537 return; 9538 } 9539 rte_mempool_dump(stdout, mp); 9540 } 9541 } 9542 9543 cmdline_parse_token_string_t cmd_dump_one_dump = 9544 TOKEN_STRING_INITIALIZER(struct cmd_dump_one_result, dump, 9545 "dump_ring#dump_mempool"); 9546 9547 cmdline_parse_token_string_t cmd_dump_one_name = 9548 TOKEN_STRING_INITIALIZER(struct cmd_dump_one_result, name, NULL); 9549 9550 cmdline_parse_inst_t cmd_dump_one = { 9551 .f = cmd_dump_one_parsed, /* function to call */ 9552 .data = NULL, /* 2nd arg of func */ 9553 .help_str = "dump_ring|dump_mempool <name>: Dump one ring/mempool", 9554 .tokens = { /* token list, NULL terminated */ 9555 (void *)&cmd_dump_one_dump, 9556 (void *)&cmd_dump_one_name, 9557 NULL, 9558 }, 9559 }; 9560 9561 /* *** Add/Del syn filter *** */ 9562 struct cmd_syn_filter_result { 9563 cmdline_fixed_string_t filter; 9564 portid_t port_id; 9565 cmdline_fixed_string_t ops; 9566 cmdline_fixed_string_t priority; 9567 cmdline_fixed_string_t high; 9568 cmdline_fixed_string_t queue; 9569 uint16_t queue_id; 9570 }; 9571 9572 static void 9573 cmd_syn_filter_parsed(void *parsed_result, 9574 __attribute__((unused)) struct cmdline *cl, 9575 __attribute__((unused)) void *data) 9576 { 9577 struct cmd_syn_filter_result *res = parsed_result; 9578 struct rte_eth_syn_filter syn_filter; 9579 int ret = 0; 9580 9581 ret = rte_eth_dev_filter_supported(res->port_id, 9582 RTE_ETH_FILTER_SYN); 9583 if (ret < 0) { 9584 printf("syn filter is not supported on port %u.\n", 9585 res->port_id); 9586 return; 9587 } 9588 9589 memset(&syn_filter, 0, sizeof(syn_filter)); 9590 9591 if (!strcmp(res->ops, "add")) { 9592 if (!strcmp(res->high, "high")) 9593 syn_filter.hig_pri = 1; 9594 else 9595 syn_filter.hig_pri = 0; 9596 9597 syn_filter.queue = res->queue_id; 9598 ret = rte_eth_dev_filter_ctrl(res->port_id, 9599 RTE_ETH_FILTER_SYN, 9600 RTE_ETH_FILTER_ADD, 9601 &syn_filter); 9602 } else 9603 ret = rte_eth_dev_filter_ctrl(res->port_id, 9604 RTE_ETH_FILTER_SYN, 9605 RTE_ETH_FILTER_DELETE, 9606 &syn_filter); 9607 9608 if (ret < 0) 9609 printf("syn filter programming error: (%s)\n", 9610 strerror(-ret)); 9611 } 9612 9613 cmdline_parse_token_string_t cmd_syn_filter_filter = 9614 TOKEN_STRING_INITIALIZER(struct cmd_syn_filter_result, 9615 filter, "syn_filter"); 9616 cmdline_parse_token_num_t cmd_syn_filter_port_id = 9617 TOKEN_NUM_INITIALIZER(struct cmd_syn_filter_result, 9618 port_id, UINT16); 9619 cmdline_parse_token_string_t cmd_syn_filter_ops = 9620 TOKEN_STRING_INITIALIZER(struct cmd_syn_filter_result, 9621 ops, "add#del"); 9622 cmdline_parse_token_string_t cmd_syn_filter_priority = 9623 TOKEN_STRING_INITIALIZER(struct cmd_syn_filter_result, 9624 priority, "priority"); 9625 cmdline_parse_token_string_t cmd_syn_filter_high = 9626 TOKEN_STRING_INITIALIZER(struct cmd_syn_filter_result, 9627 high, "high#low"); 9628 cmdline_parse_token_string_t cmd_syn_filter_queue = 9629 TOKEN_STRING_INITIALIZER(struct cmd_syn_filter_result, 9630 queue, "queue"); 9631 cmdline_parse_token_num_t cmd_syn_filter_queue_id = 9632 TOKEN_NUM_INITIALIZER(struct cmd_syn_filter_result, 9633 queue_id, UINT16); 9634 9635 cmdline_parse_inst_t cmd_syn_filter = { 9636 .f = cmd_syn_filter_parsed, 9637 .data = NULL, 9638 .help_str = "syn_filter <port_id> add|del priority high|low queue " 9639 "<queue_id>: Add/Delete syn filter", 9640 .tokens = { 9641 (void *)&cmd_syn_filter_filter, 9642 (void *)&cmd_syn_filter_port_id, 9643 (void *)&cmd_syn_filter_ops, 9644 (void *)&cmd_syn_filter_priority, 9645 (void *)&cmd_syn_filter_high, 9646 (void *)&cmd_syn_filter_queue, 9647 (void *)&cmd_syn_filter_queue_id, 9648 NULL, 9649 }, 9650 }; 9651 9652 /* *** queue region set *** */ 9653 struct cmd_queue_region_result { 9654 cmdline_fixed_string_t set; 9655 cmdline_fixed_string_t port; 9656 portid_t port_id; 9657 cmdline_fixed_string_t cmd; 9658 cmdline_fixed_string_t region; 9659 uint8_t region_id; 9660 cmdline_fixed_string_t queue_start_index; 9661 uint8_t queue_id; 9662 cmdline_fixed_string_t queue_num; 9663 uint8_t queue_num_value; 9664 }; 9665 9666 static void 9667 cmd_queue_region_parsed(void *parsed_result, 9668 __attribute__((unused)) struct cmdline *cl, 9669 __attribute__((unused)) void *data) 9670 { 9671 struct cmd_queue_region_result *res = parsed_result; 9672 int ret = -ENOTSUP; 9673 #ifdef RTE_LIBRTE_I40E_PMD 9674 struct rte_pmd_i40e_queue_region_conf region_conf; 9675 enum rte_pmd_i40e_queue_region_op op_type; 9676 #endif 9677 9678 if (port_id_is_invalid(res->port_id, ENABLED_WARN)) 9679 return; 9680 9681 #ifdef RTE_LIBRTE_I40E_PMD 9682 memset(®ion_conf, 0, sizeof(region_conf)); 9683 op_type = RTE_PMD_I40E_RSS_QUEUE_REGION_SET; 9684 region_conf.region_id = res->region_id; 9685 region_conf.queue_num = res->queue_num_value; 9686 region_conf.queue_start_index = res->queue_id; 9687 9688 ret = rte_pmd_i40e_rss_queue_region_conf(res->port_id, 9689 op_type, ®ion_conf); 9690 #endif 9691 9692 switch (ret) { 9693 case 0: 9694 break; 9695 case -ENOTSUP: 9696 printf("function not implemented or supported\n"); 9697 break; 9698 default: 9699 printf("queue region config error: (%s)\n", strerror(-ret)); 9700 } 9701 } 9702 9703 cmdline_parse_token_string_t cmd_queue_region_set = 9704 TOKEN_STRING_INITIALIZER(struct cmd_queue_region_result, 9705 set, "set"); 9706 cmdline_parse_token_string_t cmd_queue_region_port = 9707 TOKEN_STRING_INITIALIZER(struct cmd_queue_region_result, port, "port"); 9708 cmdline_parse_token_num_t cmd_queue_region_port_id = 9709 TOKEN_NUM_INITIALIZER(struct cmd_queue_region_result, 9710 port_id, UINT16); 9711 cmdline_parse_token_string_t cmd_queue_region_cmd = 9712 TOKEN_STRING_INITIALIZER(struct cmd_queue_region_result, 9713 cmd, "queue-region"); 9714 cmdline_parse_token_string_t cmd_queue_region_id = 9715 TOKEN_STRING_INITIALIZER(struct cmd_queue_region_result, 9716 region, "region_id"); 9717 cmdline_parse_token_num_t cmd_queue_region_index = 9718 TOKEN_NUM_INITIALIZER(struct cmd_queue_region_result, 9719 region_id, UINT8); 9720 cmdline_parse_token_string_t cmd_queue_region_queue_start_index = 9721 TOKEN_STRING_INITIALIZER(struct cmd_queue_region_result, 9722 queue_start_index, "queue_start_index"); 9723 cmdline_parse_token_num_t cmd_queue_region_queue_id = 9724 TOKEN_NUM_INITIALIZER(struct cmd_queue_region_result, 9725 queue_id, UINT8); 9726 cmdline_parse_token_string_t cmd_queue_region_queue_num = 9727 TOKEN_STRING_INITIALIZER(struct cmd_queue_region_result, 9728 queue_num, "queue_num"); 9729 cmdline_parse_token_num_t cmd_queue_region_queue_num_value = 9730 TOKEN_NUM_INITIALIZER(struct cmd_queue_region_result, 9731 queue_num_value, UINT8); 9732 9733 cmdline_parse_inst_t cmd_queue_region = { 9734 .f = cmd_queue_region_parsed, 9735 .data = NULL, 9736 .help_str = "set port <port_id> queue-region region_id <value> " 9737 "queue_start_index <value> queue_num <value>: Set a queue region", 9738 .tokens = { 9739 (void *)&cmd_queue_region_set, 9740 (void *)&cmd_queue_region_port, 9741 (void *)&cmd_queue_region_port_id, 9742 (void *)&cmd_queue_region_cmd, 9743 (void *)&cmd_queue_region_id, 9744 (void *)&cmd_queue_region_index, 9745 (void *)&cmd_queue_region_queue_start_index, 9746 (void *)&cmd_queue_region_queue_id, 9747 (void *)&cmd_queue_region_queue_num, 9748 (void *)&cmd_queue_region_queue_num_value, 9749 NULL, 9750 }, 9751 }; 9752 9753 /* *** queue region and flowtype set *** */ 9754 struct cmd_region_flowtype_result { 9755 cmdline_fixed_string_t set; 9756 cmdline_fixed_string_t port; 9757 portid_t port_id; 9758 cmdline_fixed_string_t cmd; 9759 cmdline_fixed_string_t region; 9760 uint8_t region_id; 9761 cmdline_fixed_string_t flowtype; 9762 uint8_t flowtype_id; 9763 }; 9764 9765 static void 9766 cmd_region_flowtype_parsed(void *parsed_result, 9767 __attribute__((unused)) struct cmdline *cl, 9768 __attribute__((unused)) void *data) 9769 { 9770 struct cmd_region_flowtype_result *res = parsed_result; 9771 int ret = -ENOTSUP; 9772 #ifdef RTE_LIBRTE_I40E_PMD 9773 struct rte_pmd_i40e_queue_region_conf region_conf; 9774 enum rte_pmd_i40e_queue_region_op op_type; 9775 #endif 9776 9777 if (port_id_is_invalid(res->port_id, ENABLED_WARN)) 9778 return; 9779 9780 #ifdef RTE_LIBRTE_I40E_PMD 9781 memset(®ion_conf, 0, sizeof(region_conf)); 9782 9783 op_type = RTE_PMD_I40E_RSS_QUEUE_REGION_FLOWTYPE_SET; 9784 region_conf.region_id = res->region_id; 9785 region_conf.hw_flowtype = res->flowtype_id; 9786 9787 ret = rte_pmd_i40e_rss_queue_region_conf(res->port_id, 9788 op_type, ®ion_conf); 9789 #endif 9790 9791 switch (ret) { 9792 case 0: 9793 break; 9794 case -ENOTSUP: 9795 printf("function not implemented or supported\n"); 9796 break; 9797 default: 9798 printf("region flowtype config error: (%s)\n", strerror(-ret)); 9799 } 9800 } 9801 9802 cmdline_parse_token_string_t cmd_region_flowtype_set = 9803 TOKEN_STRING_INITIALIZER(struct cmd_region_flowtype_result, 9804 set, "set"); 9805 cmdline_parse_token_string_t cmd_region_flowtype_port = 9806 TOKEN_STRING_INITIALIZER(struct cmd_region_flowtype_result, 9807 port, "port"); 9808 cmdline_parse_token_num_t cmd_region_flowtype_port_index = 9809 TOKEN_NUM_INITIALIZER(struct cmd_region_flowtype_result, 9810 port_id, UINT16); 9811 cmdline_parse_token_string_t cmd_region_flowtype_cmd = 9812 TOKEN_STRING_INITIALIZER(struct cmd_region_flowtype_result, 9813 cmd, "queue-region"); 9814 cmdline_parse_token_string_t cmd_region_flowtype_index = 9815 TOKEN_STRING_INITIALIZER(struct cmd_region_flowtype_result, 9816 region, "region_id"); 9817 cmdline_parse_token_num_t cmd_region_flowtype_id = 9818 TOKEN_NUM_INITIALIZER(struct cmd_region_flowtype_result, 9819 region_id, UINT8); 9820 cmdline_parse_token_string_t cmd_region_flowtype_flow_index = 9821 TOKEN_STRING_INITIALIZER(struct cmd_region_flowtype_result, 9822 flowtype, "flowtype"); 9823 cmdline_parse_token_num_t cmd_region_flowtype_flow_id = 9824 TOKEN_NUM_INITIALIZER(struct cmd_region_flowtype_result, 9825 flowtype_id, UINT8); 9826 cmdline_parse_inst_t cmd_region_flowtype = { 9827 .f = cmd_region_flowtype_parsed, 9828 .data = NULL, 9829 .help_str = "set port <port_id> queue-region region_id <value> " 9830 "flowtype <value>: Set a flowtype region index", 9831 .tokens = { 9832 (void *)&cmd_region_flowtype_set, 9833 (void *)&cmd_region_flowtype_port, 9834 (void *)&cmd_region_flowtype_port_index, 9835 (void *)&cmd_region_flowtype_cmd, 9836 (void *)&cmd_region_flowtype_index, 9837 (void *)&cmd_region_flowtype_id, 9838 (void *)&cmd_region_flowtype_flow_index, 9839 (void *)&cmd_region_flowtype_flow_id, 9840 NULL, 9841 }, 9842 }; 9843 9844 /* *** User Priority (UP) to queue region (region_id) set *** */ 9845 struct cmd_user_priority_region_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 user_priority; 9851 uint8_t user_priority_id; 9852 cmdline_fixed_string_t region; 9853 uint8_t region_id; 9854 }; 9855 9856 static void 9857 cmd_user_priority_region_parsed(void *parsed_result, 9858 __attribute__((unused)) struct cmdline *cl, 9859 __attribute__((unused)) void *data) 9860 { 9861 struct cmd_user_priority_region_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 op_type = RTE_PMD_I40E_RSS_QUEUE_REGION_USER_PRIORITY_SET; 9874 region_conf.user_priority = res->user_priority_id; 9875 region_conf.region_id = res->region_id; 9876 9877 ret = rte_pmd_i40e_rss_queue_region_conf(res->port_id, 9878 op_type, ®ion_conf); 9879 #endif 9880 9881 switch (ret) { 9882 case 0: 9883 break; 9884 case -ENOTSUP: 9885 printf("function not implemented or supported\n"); 9886 break; 9887 default: 9888 printf("user_priority region config error: (%s)\n", 9889 strerror(-ret)); 9890 } 9891 } 9892 9893 cmdline_parse_token_string_t cmd_user_priority_region_set = 9894 TOKEN_STRING_INITIALIZER(struct cmd_user_priority_region_result, 9895 set, "set"); 9896 cmdline_parse_token_string_t cmd_user_priority_region_port = 9897 TOKEN_STRING_INITIALIZER(struct cmd_user_priority_region_result, 9898 port, "port"); 9899 cmdline_parse_token_num_t cmd_user_priority_region_port_index = 9900 TOKEN_NUM_INITIALIZER(struct cmd_user_priority_region_result, 9901 port_id, UINT16); 9902 cmdline_parse_token_string_t cmd_user_priority_region_cmd = 9903 TOKEN_STRING_INITIALIZER(struct cmd_user_priority_region_result, 9904 cmd, "queue-region"); 9905 cmdline_parse_token_string_t cmd_user_priority_region_UP = 9906 TOKEN_STRING_INITIALIZER(struct cmd_user_priority_region_result, 9907 user_priority, "UP"); 9908 cmdline_parse_token_num_t cmd_user_priority_region_UP_id = 9909 TOKEN_NUM_INITIALIZER(struct cmd_user_priority_region_result, 9910 user_priority_id, UINT8); 9911 cmdline_parse_token_string_t cmd_user_priority_region_region = 9912 TOKEN_STRING_INITIALIZER(struct cmd_user_priority_region_result, 9913 region, "region_id"); 9914 cmdline_parse_token_num_t cmd_user_priority_region_region_id = 9915 TOKEN_NUM_INITIALIZER(struct cmd_user_priority_region_result, 9916 region_id, UINT8); 9917 9918 cmdline_parse_inst_t cmd_user_priority_region = { 9919 .f = cmd_user_priority_region_parsed, 9920 .data = NULL, 9921 .help_str = "set port <port_id> queue-region UP <value> " 9922 "region_id <value>: Set the mapping of User Priority (UP) " 9923 "to queue region (region_id) ", 9924 .tokens = { 9925 (void *)&cmd_user_priority_region_set, 9926 (void *)&cmd_user_priority_region_port, 9927 (void *)&cmd_user_priority_region_port_index, 9928 (void *)&cmd_user_priority_region_cmd, 9929 (void *)&cmd_user_priority_region_UP, 9930 (void *)&cmd_user_priority_region_UP_id, 9931 (void *)&cmd_user_priority_region_region, 9932 (void *)&cmd_user_priority_region_region_id, 9933 NULL, 9934 }, 9935 }; 9936 9937 /* *** flush all queue region related configuration *** */ 9938 struct cmd_flush_queue_region_result { 9939 cmdline_fixed_string_t set; 9940 cmdline_fixed_string_t port; 9941 portid_t port_id; 9942 cmdline_fixed_string_t cmd; 9943 cmdline_fixed_string_t flush; 9944 cmdline_fixed_string_t what; 9945 }; 9946 9947 static void 9948 cmd_flush_queue_region_parsed(void *parsed_result, 9949 __attribute__((unused)) struct cmdline *cl, 9950 __attribute__((unused)) void *data) 9951 { 9952 struct cmd_flush_queue_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 9965 if (strcmp(res->what, "on") == 0) 9966 op_type = RTE_PMD_I40E_RSS_QUEUE_REGION_ALL_FLUSH_ON; 9967 else 9968 op_type = RTE_PMD_I40E_RSS_QUEUE_REGION_ALL_FLUSH_OFF; 9969 9970 ret = rte_pmd_i40e_rss_queue_region_conf(res->port_id, 9971 op_type, ®ion_conf); 9972 #endif 9973 9974 switch (ret) { 9975 case 0: 9976 break; 9977 case -ENOTSUP: 9978 printf("function not implemented or supported\n"); 9979 break; 9980 default: 9981 printf("queue region config flush error: (%s)\n", 9982 strerror(-ret)); 9983 } 9984 } 9985 9986 cmdline_parse_token_string_t cmd_flush_queue_region_set = 9987 TOKEN_STRING_INITIALIZER(struct cmd_flush_queue_region_result, 9988 set, "set"); 9989 cmdline_parse_token_string_t cmd_flush_queue_region_port = 9990 TOKEN_STRING_INITIALIZER(struct cmd_flush_queue_region_result, 9991 port, "port"); 9992 cmdline_parse_token_num_t cmd_flush_queue_region_port_index = 9993 TOKEN_NUM_INITIALIZER(struct cmd_flush_queue_region_result, 9994 port_id, UINT16); 9995 cmdline_parse_token_string_t cmd_flush_queue_region_cmd = 9996 TOKEN_STRING_INITIALIZER(struct cmd_flush_queue_region_result, 9997 cmd, "queue-region"); 9998 cmdline_parse_token_string_t cmd_flush_queue_region_flush = 9999 TOKEN_STRING_INITIALIZER(struct cmd_flush_queue_region_result, 10000 flush, "flush"); 10001 cmdline_parse_token_string_t cmd_flush_queue_region_what = 10002 TOKEN_STRING_INITIALIZER(struct cmd_flush_queue_region_result, 10003 what, "on#off"); 10004 10005 cmdline_parse_inst_t cmd_flush_queue_region = { 10006 .f = cmd_flush_queue_region_parsed, 10007 .data = NULL, 10008 .help_str = "set port <port_id> queue-region flush on|off" 10009 ": flush all queue region related configuration", 10010 .tokens = { 10011 (void *)&cmd_flush_queue_region_set, 10012 (void *)&cmd_flush_queue_region_port, 10013 (void *)&cmd_flush_queue_region_port_index, 10014 (void *)&cmd_flush_queue_region_cmd, 10015 (void *)&cmd_flush_queue_region_flush, 10016 (void *)&cmd_flush_queue_region_what, 10017 NULL, 10018 }, 10019 }; 10020 10021 /* *** get all queue region related configuration info *** */ 10022 struct cmd_show_queue_region_info { 10023 cmdline_fixed_string_t show; 10024 cmdline_fixed_string_t port; 10025 portid_t port_id; 10026 cmdline_fixed_string_t cmd; 10027 }; 10028 10029 static void 10030 cmd_show_queue_region_info_parsed(void *parsed_result, 10031 __attribute__((unused)) struct cmdline *cl, 10032 __attribute__((unused)) void *data) 10033 { 10034 struct cmd_show_queue_region_info *res = parsed_result; 10035 int ret = -ENOTSUP; 10036 #ifdef RTE_LIBRTE_I40E_PMD 10037 struct rte_pmd_i40e_queue_regions rte_pmd_regions; 10038 enum rte_pmd_i40e_queue_region_op op_type; 10039 #endif 10040 10041 if (port_id_is_invalid(res->port_id, ENABLED_WARN)) 10042 return; 10043 10044 #ifdef RTE_LIBRTE_I40E_PMD 10045 memset(&rte_pmd_regions, 0, sizeof(rte_pmd_regions)); 10046 10047 op_type = RTE_PMD_I40E_RSS_QUEUE_REGION_INFO_GET; 10048 10049 ret = rte_pmd_i40e_rss_queue_region_conf(res->port_id, 10050 op_type, &rte_pmd_regions); 10051 10052 port_queue_region_info_display(res->port_id, &rte_pmd_regions); 10053 #endif 10054 10055 switch (ret) { 10056 case 0: 10057 break; 10058 case -ENOTSUP: 10059 printf("function not implemented or supported\n"); 10060 break; 10061 default: 10062 printf("queue region config info show error: (%s)\n", 10063 strerror(-ret)); 10064 } 10065 } 10066 10067 cmdline_parse_token_string_t cmd_show_queue_region_info_get = 10068 TOKEN_STRING_INITIALIZER(struct cmd_show_queue_region_info, 10069 show, "show"); 10070 cmdline_parse_token_string_t cmd_show_queue_region_info_port = 10071 TOKEN_STRING_INITIALIZER(struct cmd_show_queue_region_info, 10072 port, "port"); 10073 cmdline_parse_token_num_t cmd_show_queue_region_info_port_index = 10074 TOKEN_NUM_INITIALIZER(struct cmd_show_queue_region_info, 10075 port_id, UINT16); 10076 cmdline_parse_token_string_t cmd_show_queue_region_info_cmd = 10077 TOKEN_STRING_INITIALIZER(struct cmd_show_queue_region_info, 10078 cmd, "queue-region"); 10079 10080 cmdline_parse_inst_t cmd_show_queue_region_info_all = { 10081 .f = cmd_show_queue_region_info_parsed, 10082 .data = NULL, 10083 .help_str = "show port <port_id> queue-region" 10084 ": show all queue region related configuration info", 10085 .tokens = { 10086 (void *)&cmd_show_queue_region_info_get, 10087 (void *)&cmd_show_queue_region_info_port, 10088 (void *)&cmd_show_queue_region_info_port_index, 10089 (void *)&cmd_show_queue_region_info_cmd, 10090 NULL, 10091 }, 10092 }; 10093 10094 /* *** ADD/REMOVE A 2tuple FILTER *** */ 10095 struct cmd_2tuple_filter_result { 10096 cmdline_fixed_string_t filter; 10097 portid_t port_id; 10098 cmdline_fixed_string_t ops; 10099 cmdline_fixed_string_t dst_port; 10100 uint16_t dst_port_value; 10101 cmdline_fixed_string_t protocol; 10102 uint8_t protocol_value; 10103 cmdline_fixed_string_t mask; 10104 uint8_t mask_value; 10105 cmdline_fixed_string_t tcp_flags; 10106 uint8_t tcp_flags_value; 10107 cmdline_fixed_string_t priority; 10108 uint8_t priority_value; 10109 cmdline_fixed_string_t queue; 10110 uint16_t queue_id; 10111 }; 10112 10113 static void 10114 cmd_2tuple_filter_parsed(void *parsed_result, 10115 __attribute__((unused)) struct cmdline *cl, 10116 __attribute__((unused)) void *data) 10117 { 10118 struct rte_eth_ntuple_filter filter; 10119 struct cmd_2tuple_filter_result *res = parsed_result; 10120 int ret = 0; 10121 10122 ret = rte_eth_dev_filter_supported(res->port_id, RTE_ETH_FILTER_NTUPLE); 10123 if (ret < 0) { 10124 printf("ntuple filter is not supported on port %u.\n", 10125 res->port_id); 10126 return; 10127 } 10128 10129 memset(&filter, 0, sizeof(struct rte_eth_ntuple_filter)); 10130 10131 filter.flags = RTE_2TUPLE_FLAGS; 10132 filter.dst_port_mask = (res->mask_value & 0x02) ? UINT16_MAX : 0; 10133 filter.proto_mask = (res->mask_value & 0x01) ? UINT8_MAX : 0; 10134 filter.proto = res->protocol_value; 10135 filter.priority = res->priority_value; 10136 if (res->tcp_flags_value != 0 && filter.proto != IPPROTO_TCP) { 10137 printf("nonzero tcp_flags is only meaningful" 10138 " when protocol is TCP.\n"); 10139 return; 10140 } 10141 if (res->tcp_flags_value > RTE_NTUPLE_TCP_FLAGS_MASK) { 10142 printf("invalid TCP flags.\n"); 10143 return; 10144 } 10145 10146 if (res->tcp_flags_value != 0) { 10147 filter.flags |= RTE_NTUPLE_FLAGS_TCP_FLAG; 10148 filter.tcp_flags = res->tcp_flags_value; 10149 } 10150 10151 /* need convert to big endian. */ 10152 filter.dst_port = rte_cpu_to_be_16(res->dst_port_value); 10153 filter.queue = res->queue_id; 10154 10155 if (!strcmp(res->ops, "add")) 10156 ret = rte_eth_dev_filter_ctrl(res->port_id, 10157 RTE_ETH_FILTER_NTUPLE, 10158 RTE_ETH_FILTER_ADD, 10159 &filter); 10160 else 10161 ret = rte_eth_dev_filter_ctrl(res->port_id, 10162 RTE_ETH_FILTER_NTUPLE, 10163 RTE_ETH_FILTER_DELETE, 10164 &filter); 10165 if (ret < 0) 10166 printf("2tuple filter programming error: (%s)\n", 10167 strerror(-ret)); 10168 10169 } 10170 10171 cmdline_parse_token_string_t cmd_2tuple_filter_filter = 10172 TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result, 10173 filter, "2tuple_filter"); 10174 cmdline_parse_token_num_t cmd_2tuple_filter_port_id = 10175 TOKEN_NUM_INITIALIZER(struct cmd_2tuple_filter_result, 10176 port_id, UINT16); 10177 cmdline_parse_token_string_t cmd_2tuple_filter_ops = 10178 TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result, 10179 ops, "add#del"); 10180 cmdline_parse_token_string_t cmd_2tuple_filter_dst_port = 10181 TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result, 10182 dst_port, "dst_port"); 10183 cmdline_parse_token_num_t cmd_2tuple_filter_dst_port_value = 10184 TOKEN_NUM_INITIALIZER(struct cmd_2tuple_filter_result, 10185 dst_port_value, UINT16); 10186 cmdline_parse_token_string_t cmd_2tuple_filter_protocol = 10187 TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result, 10188 protocol, "protocol"); 10189 cmdline_parse_token_num_t cmd_2tuple_filter_protocol_value = 10190 TOKEN_NUM_INITIALIZER(struct cmd_2tuple_filter_result, 10191 protocol_value, UINT8); 10192 cmdline_parse_token_string_t cmd_2tuple_filter_mask = 10193 TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result, 10194 mask, "mask"); 10195 cmdline_parse_token_num_t cmd_2tuple_filter_mask_value = 10196 TOKEN_NUM_INITIALIZER(struct cmd_2tuple_filter_result, 10197 mask_value, INT8); 10198 cmdline_parse_token_string_t cmd_2tuple_filter_tcp_flags = 10199 TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result, 10200 tcp_flags, "tcp_flags"); 10201 cmdline_parse_token_num_t cmd_2tuple_filter_tcp_flags_value = 10202 TOKEN_NUM_INITIALIZER(struct cmd_2tuple_filter_result, 10203 tcp_flags_value, UINT8); 10204 cmdline_parse_token_string_t cmd_2tuple_filter_priority = 10205 TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result, 10206 priority, "priority"); 10207 cmdline_parse_token_num_t cmd_2tuple_filter_priority_value = 10208 TOKEN_NUM_INITIALIZER(struct cmd_2tuple_filter_result, 10209 priority_value, UINT8); 10210 cmdline_parse_token_string_t cmd_2tuple_filter_queue = 10211 TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result, 10212 queue, "queue"); 10213 cmdline_parse_token_num_t cmd_2tuple_filter_queue_id = 10214 TOKEN_NUM_INITIALIZER(struct cmd_2tuple_filter_result, 10215 queue_id, UINT16); 10216 10217 cmdline_parse_inst_t cmd_2tuple_filter = { 10218 .f = cmd_2tuple_filter_parsed, 10219 .data = NULL, 10220 .help_str = "2tuple_filter <port_id> add|del dst_port <value> protocol " 10221 "<value> mask <value> tcp_flags <value> priority <value> queue " 10222 "<queue_id>: Add a 2tuple filter", 10223 .tokens = { 10224 (void *)&cmd_2tuple_filter_filter, 10225 (void *)&cmd_2tuple_filter_port_id, 10226 (void *)&cmd_2tuple_filter_ops, 10227 (void *)&cmd_2tuple_filter_dst_port, 10228 (void *)&cmd_2tuple_filter_dst_port_value, 10229 (void *)&cmd_2tuple_filter_protocol, 10230 (void *)&cmd_2tuple_filter_protocol_value, 10231 (void *)&cmd_2tuple_filter_mask, 10232 (void *)&cmd_2tuple_filter_mask_value, 10233 (void *)&cmd_2tuple_filter_tcp_flags, 10234 (void *)&cmd_2tuple_filter_tcp_flags_value, 10235 (void *)&cmd_2tuple_filter_priority, 10236 (void *)&cmd_2tuple_filter_priority_value, 10237 (void *)&cmd_2tuple_filter_queue, 10238 (void *)&cmd_2tuple_filter_queue_id, 10239 NULL, 10240 }, 10241 }; 10242 10243 /* *** ADD/REMOVE A 5tuple FILTER *** */ 10244 struct cmd_5tuple_filter_result { 10245 cmdline_fixed_string_t filter; 10246 portid_t port_id; 10247 cmdline_fixed_string_t ops; 10248 cmdline_fixed_string_t dst_ip; 10249 cmdline_ipaddr_t dst_ip_value; 10250 cmdline_fixed_string_t src_ip; 10251 cmdline_ipaddr_t src_ip_value; 10252 cmdline_fixed_string_t dst_port; 10253 uint16_t dst_port_value; 10254 cmdline_fixed_string_t src_port; 10255 uint16_t src_port_value; 10256 cmdline_fixed_string_t protocol; 10257 uint8_t protocol_value; 10258 cmdline_fixed_string_t mask; 10259 uint8_t mask_value; 10260 cmdline_fixed_string_t tcp_flags; 10261 uint8_t tcp_flags_value; 10262 cmdline_fixed_string_t priority; 10263 uint8_t priority_value; 10264 cmdline_fixed_string_t queue; 10265 uint16_t queue_id; 10266 }; 10267 10268 static void 10269 cmd_5tuple_filter_parsed(void *parsed_result, 10270 __attribute__((unused)) struct cmdline *cl, 10271 __attribute__((unused)) void *data) 10272 { 10273 struct rte_eth_ntuple_filter filter; 10274 struct cmd_5tuple_filter_result *res = parsed_result; 10275 int ret = 0; 10276 10277 ret = rte_eth_dev_filter_supported(res->port_id, RTE_ETH_FILTER_NTUPLE); 10278 if (ret < 0) { 10279 printf("ntuple filter is not supported on port %u.\n", 10280 res->port_id); 10281 return; 10282 } 10283 10284 memset(&filter, 0, sizeof(struct rte_eth_ntuple_filter)); 10285 10286 filter.flags = RTE_5TUPLE_FLAGS; 10287 filter.dst_ip_mask = (res->mask_value & 0x10) ? UINT32_MAX : 0; 10288 filter.src_ip_mask = (res->mask_value & 0x08) ? UINT32_MAX : 0; 10289 filter.dst_port_mask = (res->mask_value & 0x04) ? UINT16_MAX : 0; 10290 filter.src_port_mask = (res->mask_value & 0x02) ? UINT16_MAX : 0; 10291 filter.proto_mask = (res->mask_value & 0x01) ? UINT8_MAX : 0; 10292 filter.proto = res->protocol_value; 10293 filter.priority = res->priority_value; 10294 if (res->tcp_flags_value != 0 && filter.proto != IPPROTO_TCP) { 10295 printf("nonzero tcp_flags is only meaningful" 10296 " when protocol is TCP.\n"); 10297 return; 10298 } 10299 if (res->tcp_flags_value > RTE_NTUPLE_TCP_FLAGS_MASK) { 10300 printf("invalid TCP flags.\n"); 10301 return; 10302 } 10303 10304 if (res->tcp_flags_value != 0) { 10305 filter.flags |= RTE_NTUPLE_FLAGS_TCP_FLAG; 10306 filter.tcp_flags = res->tcp_flags_value; 10307 } 10308 10309 if (res->dst_ip_value.family == AF_INET) 10310 /* no need to convert, already big endian. */ 10311 filter.dst_ip = res->dst_ip_value.addr.ipv4.s_addr; 10312 else { 10313 if (filter.dst_ip_mask == 0) { 10314 printf("can not support ipv6 involved compare.\n"); 10315 return; 10316 } 10317 filter.dst_ip = 0; 10318 } 10319 10320 if (res->src_ip_value.family == AF_INET) 10321 /* no need to convert, already big endian. */ 10322 filter.src_ip = res->src_ip_value.addr.ipv4.s_addr; 10323 else { 10324 if (filter.src_ip_mask == 0) { 10325 printf("can not support ipv6 involved compare.\n"); 10326 return; 10327 } 10328 filter.src_ip = 0; 10329 } 10330 /* need convert to big endian. */ 10331 filter.dst_port = rte_cpu_to_be_16(res->dst_port_value); 10332 filter.src_port = rte_cpu_to_be_16(res->src_port_value); 10333 filter.queue = res->queue_id; 10334 10335 if (!strcmp(res->ops, "add")) 10336 ret = rte_eth_dev_filter_ctrl(res->port_id, 10337 RTE_ETH_FILTER_NTUPLE, 10338 RTE_ETH_FILTER_ADD, 10339 &filter); 10340 else 10341 ret = rte_eth_dev_filter_ctrl(res->port_id, 10342 RTE_ETH_FILTER_NTUPLE, 10343 RTE_ETH_FILTER_DELETE, 10344 &filter); 10345 if (ret < 0) 10346 printf("5tuple filter programming error: (%s)\n", 10347 strerror(-ret)); 10348 } 10349 10350 cmdline_parse_token_string_t cmd_5tuple_filter_filter = 10351 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result, 10352 filter, "5tuple_filter"); 10353 cmdline_parse_token_num_t cmd_5tuple_filter_port_id = 10354 TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result, 10355 port_id, UINT16); 10356 cmdline_parse_token_string_t cmd_5tuple_filter_ops = 10357 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result, 10358 ops, "add#del"); 10359 cmdline_parse_token_string_t cmd_5tuple_filter_dst_ip = 10360 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result, 10361 dst_ip, "dst_ip"); 10362 cmdline_parse_token_ipaddr_t cmd_5tuple_filter_dst_ip_value = 10363 TOKEN_IPADDR_INITIALIZER(struct cmd_5tuple_filter_result, 10364 dst_ip_value); 10365 cmdline_parse_token_string_t cmd_5tuple_filter_src_ip = 10366 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result, 10367 src_ip, "src_ip"); 10368 cmdline_parse_token_ipaddr_t cmd_5tuple_filter_src_ip_value = 10369 TOKEN_IPADDR_INITIALIZER(struct cmd_5tuple_filter_result, 10370 src_ip_value); 10371 cmdline_parse_token_string_t cmd_5tuple_filter_dst_port = 10372 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result, 10373 dst_port, "dst_port"); 10374 cmdline_parse_token_num_t cmd_5tuple_filter_dst_port_value = 10375 TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result, 10376 dst_port_value, UINT16); 10377 cmdline_parse_token_string_t cmd_5tuple_filter_src_port = 10378 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result, 10379 src_port, "src_port"); 10380 cmdline_parse_token_num_t cmd_5tuple_filter_src_port_value = 10381 TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result, 10382 src_port_value, UINT16); 10383 cmdline_parse_token_string_t cmd_5tuple_filter_protocol = 10384 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result, 10385 protocol, "protocol"); 10386 cmdline_parse_token_num_t cmd_5tuple_filter_protocol_value = 10387 TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result, 10388 protocol_value, UINT8); 10389 cmdline_parse_token_string_t cmd_5tuple_filter_mask = 10390 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result, 10391 mask, "mask"); 10392 cmdline_parse_token_num_t cmd_5tuple_filter_mask_value = 10393 TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result, 10394 mask_value, INT8); 10395 cmdline_parse_token_string_t cmd_5tuple_filter_tcp_flags = 10396 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result, 10397 tcp_flags, "tcp_flags"); 10398 cmdline_parse_token_num_t cmd_5tuple_filter_tcp_flags_value = 10399 TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result, 10400 tcp_flags_value, UINT8); 10401 cmdline_parse_token_string_t cmd_5tuple_filter_priority = 10402 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result, 10403 priority, "priority"); 10404 cmdline_parse_token_num_t cmd_5tuple_filter_priority_value = 10405 TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result, 10406 priority_value, UINT8); 10407 cmdline_parse_token_string_t cmd_5tuple_filter_queue = 10408 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result, 10409 queue, "queue"); 10410 cmdline_parse_token_num_t cmd_5tuple_filter_queue_id = 10411 TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result, 10412 queue_id, UINT16); 10413 10414 cmdline_parse_inst_t cmd_5tuple_filter = { 10415 .f = cmd_5tuple_filter_parsed, 10416 .data = NULL, 10417 .help_str = "5tuple_filter <port_id> add|del dst_ip <value> " 10418 "src_ip <value> dst_port <value> src_port <value> " 10419 "protocol <value> mask <value> tcp_flags <value> " 10420 "priority <value> queue <queue_id>: Add/Del a 5tuple filter", 10421 .tokens = { 10422 (void *)&cmd_5tuple_filter_filter, 10423 (void *)&cmd_5tuple_filter_port_id, 10424 (void *)&cmd_5tuple_filter_ops, 10425 (void *)&cmd_5tuple_filter_dst_ip, 10426 (void *)&cmd_5tuple_filter_dst_ip_value, 10427 (void *)&cmd_5tuple_filter_src_ip, 10428 (void *)&cmd_5tuple_filter_src_ip_value, 10429 (void *)&cmd_5tuple_filter_dst_port, 10430 (void *)&cmd_5tuple_filter_dst_port_value, 10431 (void *)&cmd_5tuple_filter_src_port, 10432 (void *)&cmd_5tuple_filter_src_port_value, 10433 (void *)&cmd_5tuple_filter_protocol, 10434 (void *)&cmd_5tuple_filter_protocol_value, 10435 (void *)&cmd_5tuple_filter_mask, 10436 (void *)&cmd_5tuple_filter_mask_value, 10437 (void *)&cmd_5tuple_filter_tcp_flags, 10438 (void *)&cmd_5tuple_filter_tcp_flags_value, 10439 (void *)&cmd_5tuple_filter_priority, 10440 (void *)&cmd_5tuple_filter_priority_value, 10441 (void *)&cmd_5tuple_filter_queue, 10442 (void *)&cmd_5tuple_filter_queue_id, 10443 NULL, 10444 }, 10445 }; 10446 10447 /* *** ADD/REMOVE A flex FILTER *** */ 10448 struct cmd_flex_filter_result { 10449 cmdline_fixed_string_t filter; 10450 cmdline_fixed_string_t ops; 10451 portid_t port_id; 10452 cmdline_fixed_string_t len; 10453 uint8_t len_value; 10454 cmdline_fixed_string_t bytes; 10455 cmdline_fixed_string_t bytes_value; 10456 cmdline_fixed_string_t mask; 10457 cmdline_fixed_string_t mask_value; 10458 cmdline_fixed_string_t priority; 10459 uint8_t priority_value; 10460 cmdline_fixed_string_t queue; 10461 uint16_t queue_id; 10462 }; 10463 10464 static int xdigit2val(unsigned char c) 10465 { 10466 int val; 10467 if (isdigit(c)) 10468 val = c - '0'; 10469 else if (isupper(c)) 10470 val = c - 'A' + 10; 10471 else 10472 val = c - 'a' + 10; 10473 return val; 10474 } 10475 10476 static void 10477 cmd_flex_filter_parsed(void *parsed_result, 10478 __attribute__((unused)) struct cmdline *cl, 10479 __attribute__((unused)) void *data) 10480 { 10481 int ret = 0; 10482 struct rte_eth_flex_filter filter; 10483 struct cmd_flex_filter_result *res = parsed_result; 10484 char *bytes_ptr, *mask_ptr; 10485 uint16_t len, i, j = 0; 10486 char c; 10487 int val; 10488 uint8_t byte = 0; 10489 10490 if (res->len_value > RTE_FLEX_FILTER_MAXLEN) { 10491 printf("the len exceed the max length 128\n"); 10492 return; 10493 } 10494 memset(&filter, 0, sizeof(struct rte_eth_flex_filter)); 10495 filter.len = res->len_value; 10496 filter.priority = res->priority_value; 10497 filter.queue = res->queue_id; 10498 bytes_ptr = res->bytes_value; 10499 mask_ptr = res->mask_value; 10500 10501 /* translate bytes string to array. */ 10502 if (bytes_ptr[0] == '0' && ((bytes_ptr[1] == 'x') || 10503 (bytes_ptr[1] == 'X'))) 10504 bytes_ptr += 2; 10505 len = strnlen(bytes_ptr, res->len_value * 2); 10506 if (len == 0 || (len % 8 != 0)) { 10507 printf("please check len and bytes input\n"); 10508 return; 10509 } 10510 for (i = 0; i < len; i++) { 10511 c = bytes_ptr[i]; 10512 if (isxdigit(c) == 0) { 10513 /* invalid characters. */ 10514 printf("invalid input\n"); 10515 return; 10516 } 10517 val = xdigit2val(c); 10518 if (i % 2) { 10519 byte |= val; 10520 filter.bytes[j] = byte; 10521 printf("bytes[%d]:%02x ", j, filter.bytes[j]); 10522 j++; 10523 byte = 0; 10524 } else 10525 byte |= val << 4; 10526 } 10527 printf("\n"); 10528 /* translate mask string to uint8_t array. */ 10529 if (mask_ptr[0] == '0' && ((mask_ptr[1] == 'x') || 10530 (mask_ptr[1] == 'X'))) 10531 mask_ptr += 2; 10532 len = strnlen(mask_ptr, (res->len_value + 3) / 4); 10533 if (len == 0) { 10534 printf("invalid input\n"); 10535 return; 10536 } 10537 j = 0; 10538 byte = 0; 10539 for (i = 0; i < len; i++) { 10540 c = mask_ptr[i]; 10541 if (isxdigit(c) == 0) { 10542 /* invalid characters. */ 10543 printf("invalid input\n"); 10544 return; 10545 } 10546 val = xdigit2val(c); 10547 if (i % 2) { 10548 byte |= val; 10549 filter.mask[j] = byte; 10550 printf("mask[%d]:%02x ", j, filter.mask[j]); 10551 j++; 10552 byte = 0; 10553 } else 10554 byte |= val << 4; 10555 } 10556 printf("\n"); 10557 10558 if (!strcmp(res->ops, "add")) 10559 ret = rte_eth_dev_filter_ctrl(res->port_id, 10560 RTE_ETH_FILTER_FLEXIBLE, 10561 RTE_ETH_FILTER_ADD, 10562 &filter); 10563 else 10564 ret = rte_eth_dev_filter_ctrl(res->port_id, 10565 RTE_ETH_FILTER_FLEXIBLE, 10566 RTE_ETH_FILTER_DELETE, 10567 &filter); 10568 10569 if (ret < 0) 10570 printf("flex filter setting error: (%s)\n", strerror(-ret)); 10571 } 10572 10573 cmdline_parse_token_string_t cmd_flex_filter_filter = 10574 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result, 10575 filter, "flex_filter"); 10576 cmdline_parse_token_num_t cmd_flex_filter_port_id = 10577 TOKEN_NUM_INITIALIZER(struct cmd_flex_filter_result, 10578 port_id, UINT16); 10579 cmdline_parse_token_string_t cmd_flex_filter_ops = 10580 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result, 10581 ops, "add#del"); 10582 cmdline_parse_token_string_t cmd_flex_filter_len = 10583 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result, 10584 len, "len"); 10585 cmdline_parse_token_num_t cmd_flex_filter_len_value = 10586 TOKEN_NUM_INITIALIZER(struct cmd_flex_filter_result, 10587 len_value, UINT8); 10588 cmdline_parse_token_string_t cmd_flex_filter_bytes = 10589 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result, 10590 bytes, "bytes"); 10591 cmdline_parse_token_string_t cmd_flex_filter_bytes_value = 10592 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result, 10593 bytes_value, NULL); 10594 cmdline_parse_token_string_t cmd_flex_filter_mask = 10595 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result, 10596 mask, "mask"); 10597 cmdline_parse_token_string_t cmd_flex_filter_mask_value = 10598 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result, 10599 mask_value, NULL); 10600 cmdline_parse_token_string_t cmd_flex_filter_priority = 10601 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result, 10602 priority, "priority"); 10603 cmdline_parse_token_num_t cmd_flex_filter_priority_value = 10604 TOKEN_NUM_INITIALIZER(struct cmd_flex_filter_result, 10605 priority_value, UINT8); 10606 cmdline_parse_token_string_t cmd_flex_filter_queue = 10607 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result, 10608 queue, "queue"); 10609 cmdline_parse_token_num_t cmd_flex_filter_queue_id = 10610 TOKEN_NUM_INITIALIZER(struct cmd_flex_filter_result, 10611 queue_id, UINT16); 10612 cmdline_parse_inst_t cmd_flex_filter = { 10613 .f = cmd_flex_filter_parsed, 10614 .data = NULL, 10615 .help_str = "flex_filter <port_id> add|del len <value> bytes " 10616 "<value> mask <value> priority <value> queue <queue_id>: " 10617 "Add/Del a flex filter", 10618 .tokens = { 10619 (void *)&cmd_flex_filter_filter, 10620 (void *)&cmd_flex_filter_port_id, 10621 (void *)&cmd_flex_filter_ops, 10622 (void *)&cmd_flex_filter_len, 10623 (void *)&cmd_flex_filter_len_value, 10624 (void *)&cmd_flex_filter_bytes, 10625 (void *)&cmd_flex_filter_bytes_value, 10626 (void *)&cmd_flex_filter_mask, 10627 (void *)&cmd_flex_filter_mask_value, 10628 (void *)&cmd_flex_filter_priority, 10629 (void *)&cmd_flex_filter_priority_value, 10630 (void *)&cmd_flex_filter_queue, 10631 (void *)&cmd_flex_filter_queue_id, 10632 NULL, 10633 }, 10634 }; 10635 10636 /* *** Filters Control *** */ 10637 10638 /* *** deal with ethertype filter *** */ 10639 struct cmd_ethertype_filter_result { 10640 cmdline_fixed_string_t filter; 10641 portid_t port_id; 10642 cmdline_fixed_string_t ops; 10643 cmdline_fixed_string_t mac; 10644 struct rte_ether_addr mac_addr; 10645 cmdline_fixed_string_t ethertype; 10646 uint16_t ethertype_value; 10647 cmdline_fixed_string_t drop; 10648 cmdline_fixed_string_t queue; 10649 uint16_t queue_id; 10650 }; 10651 10652 cmdline_parse_token_string_t cmd_ethertype_filter_filter = 10653 TOKEN_STRING_INITIALIZER(struct cmd_ethertype_filter_result, 10654 filter, "ethertype_filter"); 10655 cmdline_parse_token_num_t cmd_ethertype_filter_port_id = 10656 TOKEN_NUM_INITIALIZER(struct cmd_ethertype_filter_result, 10657 port_id, UINT16); 10658 cmdline_parse_token_string_t cmd_ethertype_filter_ops = 10659 TOKEN_STRING_INITIALIZER(struct cmd_ethertype_filter_result, 10660 ops, "add#del"); 10661 cmdline_parse_token_string_t cmd_ethertype_filter_mac = 10662 TOKEN_STRING_INITIALIZER(struct cmd_ethertype_filter_result, 10663 mac, "mac_addr#mac_ignr"); 10664 cmdline_parse_token_etheraddr_t cmd_ethertype_filter_mac_addr = 10665 TOKEN_ETHERADDR_INITIALIZER(struct cmd_ethertype_filter_result, 10666 mac_addr); 10667 cmdline_parse_token_string_t cmd_ethertype_filter_ethertype = 10668 TOKEN_STRING_INITIALIZER(struct cmd_ethertype_filter_result, 10669 ethertype, "ethertype"); 10670 cmdline_parse_token_num_t cmd_ethertype_filter_ethertype_value = 10671 TOKEN_NUM_INITIALIZER(struct cmd_ethertype_filter_result, 10672 ethertype_value, UINT16); 10673 cmdline_parse_token_string_t cmd_ethertype_filter_drop = 10674 TOKEN_STRING_INITIALIZER(struct cmd_ethertype_filter_result, 10675 drop, "drop#fwd"); 10676 cmdline_parse_token_string_t cmd_ethertype_filter_queue = 10677 TOKEN_STRING_INITIALIZER(struct cmd_ethertype_filter_result, 10678 queue, "queue"); 10679 cmdline_parse_token_num_t cmd_ethertype_filter_queue_id = 10680 TOKEN_NUM_INITIALIZER(struct cmd_ethertype_filter_result, 10681 queue_id, UINT16); 10682 10683 static void 10684 cmd_ethertype_filter_parsed(void *parsed_result, 10685 __attribute__((unused)) struct cmdline *cl, 10686 __attribute__((unused)) void *data) 10687 { 10688 struct cmd_ethertype_filter_result *res = parsed_result; 10689 struct rte_eth_ethertype_filter filter; 10690 int ret = 0; 10691 10692 ret = rte_eth_dev_filter_supported(res->port_id, 10693 RTE_ETH_FILTER_ETHERTYPE); 10694 if (ret < 0) { 10695 printf("ethertype filter is not supported on port %u.\n", 10696 res->port_id); 10697 return; 10698 } 10699 10700 memset(&filter, 0, sizeof(filter)); 10701 if (!strcmp(res->mac, "mac_addr")) { 10702 filter.flags |= RTE_ETHTYPE_FLAGS_MAC; 10703 rte_memcpy(&filter.mac_addr, &res->mac_addr, 10704 sizeof(struct rte_ether_addr)); 10705 } 10706 if (!strcmp(res->drop, "drop")) 10707 filter.flags |= RTE_ETHTYPE_FLAGS_DROP; 10708 filter.ether_type = res->ethertype_value; 10709 filter.queue = res->queue_id; 10710 10711 if (!strcmp(res->ops, "add")) 10712 ret = rte_eth_dev_filter_ctrl(res->port_id, 10713 RTE_ETH_FILTER_ETHERTYPE, 10714 RTE_ETH_FILTER_ADD, 10715 &filter); 10716 else 10717 ret = rte_eth_dev_filter_ctrl(res->port_id, 10718 RTE_ETH_FILTER_ETHERTYPE, 10719 RTE_ETH_FILTER_DELETE, 10720 &filter); 10721 if (ret < 0) 10722 printf("ethertype filter programming error: (%s)\n", 10723 strerror(-ret)); 10724 } 10725 10726 cmdline_parse_inst_t cmd_ethertype_filter = { 10727 .f = cmd_ethertype_filter_parsed, 10728 .data = NULL, 10729 .help_str = "ethertype_filter <port_id> add|del mac_addr|mac_ignr " 10730 "<mac_addr> ethertype <value> drop|fw queue <queue_id>: " 10731 "Add or delete an ethertype filter entry", 10732 .tokens = { 10733 (void *)&cmd_ethertype_filter_filter, 10734 (void *)&cmd_ethertype_filter_port_id, 10735 (void *)&cmd_ethertype_filter_ops, 10736 (void *)&cmd_ethertype_filter_mac, 10737 (void *)&cmd_ethertype_filter_mac_addr, 10738 (void *)&cmd_ethertype_filter_ethertype, 10739 (void *)&cmd_ethertype_filter_ethertype_value, 10740 (void *)&cmd_ethertype_filter_drop, 10741 (void *)&cmd_ethertype_filter_queue, 10742 (void *)&cmd_ethertype_filter_queue_id, 10743 NULL, 10744 }, 10745 }; 10746 10747 /* *** deal with flow director filter *** */ 10748 struct cmd_flow_director_result { 10749 cmdline_fixed_string_t flow_director_filter; 10750 portid_t port_id; 10751 cmdline_fixed_string_t mode; 10752 cmdline_fixed_string_t mode_value; 10753 cmdline_fixed_string_t ops; 10754 cmdline_fixed_string_t flow; 10755 cmdline_fixed_string_t flow_type; 10756 cmdline_fixed_string_t ether; 10757 uint16_t ether_type; 10758 cmdline_fixed_string_t src; 10759 cmdline_ipaddr_t ip_src; 10760 uint16_t port_src; 10761 cmdline_fixed_string_t dst; 10762 cmdline_ipaddr_t ip_dst; 10763 uint16_t port_dst; 10764 cmdline_fixed_string_t verify_tag; 10765 uint32_t verify_tag_value; 10766 cmdline_fixed_string_t tos; 10767 uint8_t tos_value; 10768 cmdline_fixed_string_t proto; 10769 uint8_t proto_value; 10770 cmdline_fixed_string_t ttl; 10771 uint8_t ttl_value; 10772 cmdline_fixed_string_t vlan; 10773 uint16_t vlan_value; 10774 cmdline_fixed_string_t flexbytes; 10775 cmdline_fixed_string_t flexbytes_value; 10776 cmdline_fixed_string_t pf_vf; 10777 cmdline_fixed_string_t drop; 10778 cmdline_fixed_string_t queue; 10779 uint16_t queue_id; 10780 cmdline_fixed_string_t fd_id; 10781 uint32_t fd_id_value; 10782 cmdline_fixed_string_t mac; 10783 struct rte_ether_addr mac_addr; 10784 cmdline_fixed_string_t tunnel; 10785 cmdline_fixed_string_t tunnel_type; 10786 cmdline_fixed_string_t tunnel_id; 10787 uint32_t tunnel_id_value; 10788 cmdline_fixed_string_t packet; 10789 char filepath[]; 10790 }; 10791 10792 static inline int 10793 parse_flexbytes(const char *q_arg, uint8_t *flexbytes, uint16_t max_num) 10794 { 10795 char s[256]; 10796 const char *p, *p0 = q_arg; 10797 char *end; 10798 unsigned long int_fld; 10799 char *str_fld[max_num]; 10800 int i; 10801 unsigned size; 10802 int ret = -1; 10803 10804 p = strchr(p0, '('); 10805 if (p == NULL) 10806 return -1; 10807 ++p; 10808 p0 = strchr(p, ')'); 10809 if (p0 == NULL) 10810 return -1; 10811 10812 size = p0 - p; 10813 if (size >= sizeof(s)) 10814 return -1; 10815 10816 snprintf(s, sizeof(s), "%.*s", size, p); 10817 ret = rte_strsplit(s, sizeof(s), str_fld, max_num, ','); 10818 if (ret < 0 || ret > max_num) 10819 return -1; 10820 for (i = 0; i < ret; i++) { 10821 errno = 0; 10822 int_fld = strtoul(str_fld[i], &end, 0); 10823 if (errno != 0 || *end != '\0' || int_fld > UINT8_MAX) 10824 return -1; 10825 flexbytes[i] = (uint8_t)int_fld; 10826 } 10827 return ret; 10828 } 10829 10830 static uint16_t 10831 str2flowtype(char *string) 10832 { 10833 uint8_t i = 0; 10834 static const struct { 10835 char str[32]; 10836 uint16_t type; 10837 } flowtype_str[] = { 10838 {"raw", RTE_ETH_FLOW_RAW}, 10839 {"ipv4", RTE_ETH_FLOW_IPV4}, 10840 {"ipv4-frag", RTE_ETH_FLOW_FRAG_IPV4}, 10841 {"ipv4-tcp", RTE_ETH_FLOW_NONFRAG_IPV4_TCP}, 10842 {"ipv4-udp", RTE_ETH_FLOW_NONFRAG_IPV4_UDP}, 10843 {"ipv4-sctp", RTE_ETH_FLOW_NONFRAG_IPV4_SCTP}, 10844 {"ipv4-other", RTE_ETH_FLOW_NONFRAG_IPV4_OTHER}, 10845 {"ipv6", RTE_ETH_FLOW_IPV6}, 10846 {"ipv6-frag", RTE_ETH_FLOW_FRAG_IPV6}, 10847 {"ipv6-tcp", RTE_ETH_FLOW_NONFRAG_IPV6_TCP}, 10848 {"ipv6-udp", RTE_ETH_FLOW_NONFRAG_IPV6_UDP}, 10849 {"ipv6-sctp", RTE_ETH_FLOW_NONFRAG_IPV6_SCTP}, 10850 {"ipv6-other", RTE_ETH_FLOW_NONFRAG_IPV6_OTHER}, 10851 {"l2_payload", RTE_ETH_FLOW_L2_PAYLOAD}, 10852 }; 10853 10854 for (i = 0; i < RTE_DIM(flowtype_str); i++) { 10855 if (!strcmp(flowtype_str[i].str, string)) 10856 return flowtype_str[i].type; 10857 } 10858 10859 if (isdigit(string[0]) && atoi(string) > 0 && atoi(string) < 64) 10860 return (uint16_t)atoi(string); 10861 10862 return RTE_ETH_FLOW_UNKNOWN; 10863 } 10864 10865 static enum rte_eth_fdir_tunnel_type 10866 str2fdir_tunneltype(char *string) 10867 { 10868 uint8_t i = 0; 10869 10870 static const struct { 10871 char str[32]; 10872 enum rte_eth_fdir_tunnel_type type; 10873 } tunneltype_str[] = { 10874 {"NVGRE", RTE_FDIR_TUNNEL_TYPE_NVGRE}, 10875 {"VxLAN", RTE_FDIR_TUNNEL_TYPE_VXLAN}, 10876 }; 10877 10878 for (i = 0; i < RTE_DIM(tunneltype_str); i++) { 10879 if (!strcmp(tunneltype_str[i].str, string)) 10880 return tunneltype_str[i].type; 10881 } 10882 return RTE_FDIR_TUNNEL_TYPE_UNKNOWN; 10883 } 10884 10885 #define IPV4_ADDR_TO_UINT(ip_addr, ip) \ 10886 do { \ 10887 if ((ip_addr).family == AF_INET) \ 10888 (ip) = (ip_addr).addr.ipv4.s_addr; \ 10889 else { \ 10890 printf("invalid parameter.\n"); \ 10891 return; \ 10892 } \ 10893 } while (0) 10894 10895 #define IPV6_ADDR_TO_ARRAY(ip_addr, ip) \ 10896 do { \ 10897 if ((ip_addr).family == AF_INET6) \ 10898 rte_memcpy(&(ip), \ 10899 &((ip_addr).addr.ipv6), \ 10900 sizeof(struct in6_addr)); \ 10901 else { \ 10902 printf("invalid parameter.\n"); \ 10903 return; \ 10904 } \ 10905 } while (0) 10906 10907 static void 10908 cmd_flow_director_filter_parsed(void *parsed_result, 10909 __attribute__((unused)) struct cmdline *cl, 10910 __attribute__((unused)) void *data) 10911 { 10912 struct cmd_flow_director_result *res = parsed_result; 10913 struct rte_eth_fdir_filter entry; 10914 uint8_t flexbytes[RTE_ETH_FDIR_MAX_FLEXLEN]; 10915 char *end; 10916 unsigned long vf_id; 10917 int ret = 0; 10918 10919 ret = rte_eth_dev_filter_supported(res->port_id, RTE_ETH_FILTER_FDIR); 10920 if (ret < 0) { 10921 printf("flow director is not supported on port %u.\n", 10922 res->port_id); 10923 return; 10924 } 10925 memset(flexbytes, 0, sizeof(flexbytes)); 10926 memset(&entry, 0, sizeof(struct rte_eth_fdir_filter)); 10927 10928 if (fdir_conf.mode == RTE_FDIR_MODE_PERFECT_MAC_VLAN) { 10929 if (strcmp(res->mode_value, "MAC-VLAN")) { 10930 printf("Please set mode to MAC-VLAN.\n"); 10931 return; 10932 } 10933 } else if (fdir_conf.mode == RTE_FDIR_MODE_PERFECT_TUNNEL) { 10934 if (strcmp(res->mode_value, "Tunnel")) { 10935 printf("Please set mode to Tunnel.\n"); 10936 return; 10937 } 10938 } else { 10939 if (!strcmp(res->mode_value, "raw")) { 10940 #ifdef RTE_LIBRTE_I40E_PMD 10941 struct rte_pmd_i40e_flow_type_mapping 10942 mapping[RTE_PMD_I40E_FLOW_TYPE_MAX]; 10943 struct rte_pmd_i40e_pkt_template_conf conf; 10944 uint16_t flow_type = str2flowtype(res->flow_type); 10945 uint16_t i, port = res->port_id; 10946 uint8_t add; 10947 10948 memset(&conf, 0, sizeof(conf)); 10949 10950 if (flow_type == RTE_ETH_FLOW_UNKNOWN) { 10951 printf("Invalid flow type specified.\n"); 10952 return; 10953 } 10954 ret = rte_pmd_i40e_flow_type_mapping_get(res->port_id, 10955 mapping); 10956 if (ret) 10957 return; 10958 if (mapping[flow_type].pctype == 0ULL) { 10959 printf("Invalid flow type specified.\n"); 10960 return; 10961 } 10962 for (i = 0; i < RTE_PMD_I40E_PCTYPE_MAX; i++) { 10963 if (mapping[flow_type].pctype & (1ULL << i)) { 10964 conf.input.pctype = i; 10965 break; 10966 } 10967 } 10968 10969 conf.input.packet = open_file(res->filepath, 10970 &conf.input.length); 10971 if (!conf.input.packet) 10972 return; 10973 if (!strcmp(res->drop, "drop")) 10974 conf.action.behavior = 10975 RTE_PMD_I40E_PKT_TEMPLATE_REJECT; 10976 else 10977 conf.action.behavior = 10978 RTE_PMD_I40E_PKT_TEMPLATE_ACCEPT; 10979 conf.action.report_status = 10980 RTE_PMD_I40E_PKT_TEMPLATE_REPORT_ID; 10981 conf.action.rx_queue = res->queue_id; 10982 conf.soft_id = res->fd_id_value; 10983 add = strcmp(res->ops, "del") ? 1 : 0; 10984 ret = rte_pmd_i40e_flow_add_del_packet_template(port, 10985 &conf, 10986 add); 10987 if (ret < 0) 10988 printf("flow director config error: (%s)\n", 10989 strerror(-ret)); 10990 close_file(conf.input.packet); 10991 #endif 10992 return; 10993 } else if (strcmp(res->mode_value, "IP")) { 10994 printf("Please set mode to IP or raw.\n"); 10995 return; 10996 } 10997 entry.input.flow_type = str2flowtype(res->flow_type); 10998 } 10999 11000 ret = parse_flexbytes(res->flexbytes_value, 11001 flexbytes, 11002 RTE_ETH_FDIR_MAX_FLEXLEN); 11003 if (ret < 0) { 11004 printf("error: Cannot parse flexbytes input.\n"); 11005 return; 11006 } 11007 11008 switch (entry.input.flow_type) { 11009 case RTE_ETH_FLOW_FRAG_IPV4: 11010 case RTE_ETH_FLOW_NONFRAG_IPV4_OTHER: 11011 entry.input.flow.ip4_flow.proto = res->proto_value; 11012 /* fall-through */ 11013 case RTE_ETH_FLOW_NONFRAG_IPV4_UDP: 11014 case RTE_ETH_FLOW_NONFRAG_IPV4_TCP: 11015 IPV4_ADDR_TO_UINT(res->ip_dst, 11016 entry.input.flow.ip4_flow.dst_ip); 11017 IPV4_ADDR_TO_UINT(res->ip_src, 11018 entry.input.flow.ip4_flow.src_ip); 11019 entry.input.flow.ip4_flow.tos = res->tos_value; 11020 entry.input.flow.ip4_flow.ttl = res->ttl_value; 11021 /* need convert to big endian. */ 11022 entry.input.flow.udp4_flow.dst_port = 11023 rte_cpu_to_be_16(res->port_dst); 11024 entry.input.flow.udp4_flow.src_port = 11025 rte_cpu_to_be_16(res->port_src); 11026 break; 11027 case RTE_ETH_FLOW_NONFRAG_IPV4_SCTP: 11028 IPV4_ADDR_TO_UINT(res->ip_dst, 11029 entry.input.flow.sctp4_flow.ip.dst_ip); 11030 IPV4_ADDR_TO_UINT(res->ip_src, 11031 entry.input.flow.sctp4_flow.ip.src_ip); 11032 entry.input.flow.ip4_flow.tos = res->tos_value; 11033 entry.input.flow.ip4_flow.ttl = res->ttl_value; 11034 /* need convert to big endian. */ 11035 entry.input.flow.sctp4_flow.dst_port = 11036 rte_cpu_to_be_16(res->port_dst); 11037 entry.input.flow.sctp4_flow.src_port = 11038 rte_cpu_to_be_16(res->port_src); 11039 entry.input.flow.sctp4_flow.verify_tag = 11040 rte_cpu_to_be_32(res->verify_tag_value); 11041 break; 11042 case RTE_ETH_FLOW_FRAG_IPV6: 11043 case RTE_ETH_FLOW_NONFRAG_IPV6_OTHER: 11044 entry.input.flow.ipv6_flow.proto = res->proto_value; 11045 /* fall-through */ 11046 case RTE_ETH_FLOW_NONFRAG_IPV6_UDP: 11047 case RTE_ETH_FLOW_NONFRAG_IPV6_TCP: 11048 IPV6_ADDR_TO_ARRAY(res->ip_dst, 11049 entry.input.flow.ipv6_flow.dst_ip); 11050 IPV6_ADDR_TO_ARRAY(res->ip_src, 11051 entry.input.flow.ipv6_flow.src_ip); 11052 entry.input.flow.ipv6_flow.tc = res->tos_value; 11053 entry.input.flow.ipv6_flow.hop_limits = res->ttl_value; 11054 /* need convert to big endian. */ 11055 entry.input.flow.udp6_flow.dst_port = 11056 rte_cpu_to_be_16(res->port_dst); 11057 entry.input.flow.udp6_flow.src_port = 11058 rte_cpu_to_be_16(res->port_src); 11059 break; 11060 case RTE_ETH_FLOW_NONFRAG_IPV6_SCTP: 11061 IPV6_ADDR_TO_ARRAY(res->ip_dst, 11062 entry.input.flow.sctp6_flow.ip.dst_ip); 11063 IPV6_ADDR_TO_ARRAY(res->ip_src, 11064 entry.input.flow.sctp6_flow.ip.src_ip); 11065 entry.input.flow.ipv6_flow.tc = res->tos_value; 11066 entry.input.flow.ipv6_flow.hop_limits = res->ttl_value; 11067 /* need convert to big endian. */ 11068 entry.input.flow.sctp6_flow.dst_port = 11069 rte_cpu_to_be_16(res->port_dst); 11070 entry.input.flow.sctp6_flow.src_port = 11071 rte_cpu_to_be_16(res->port_src); 11072 entry.input.flow.sctp6_flow.verify_tag = 11073 rte_cpu_to_be_32(res->verify_tag_value); 11074 break; 11075 case RTE_ETH_FLOW_L2_PAYLOAD: 11076 entry.input.flow.l2_flow.ether_type = 11077 rte_cpu_to_be_16(res->ether_type); 11078 break; 11079 default: 11080 break; 11081 } 11082 11083 if (fdir_conf.mode == RTE_FDIR_MODE_PERFECT_MAC_VLAN) 11084 rte_memcpy(&entry.input.flow.mac_vlan_flow.mac_addr, 11085 &res->mac_addr, 11086 sizeof(struct rte_ether_addr)); 11087 11088 if (fdir_conf.mode == RTE_FDIR_MODE_PERFECT_TUNNEL) { 11089 rte_memcpy(&entry.input.flow.tunnel_flow.mac_addr, 11090 &res->mac_addr, 11091 sizeof(struct rte_ether_addr)); 11092 entry.input.flow.tunnel_flow.tunnel_type = 11093 str2fdir_tunneltype(res->tunnel_type); 11094 entry.input.flow.tunnel_flow.tunnel_id = 11095 rte_cpu_to_be_32(res->tunnel_id_value); 11096 } 11097 11098 rte_memcpy(entry.input.flow_ext.flexbytes, 11099 flexbytes, 11100 RTE_ETH_FDIR_MAX_FLEXLEN); 11101 11102 entry.input.flow_ext.vlan_tci = rte_cpu_to_be_16(res->vlan_value); 11103 11104 entry.action.flex_off = 0; /*use 0 by default */ 11105 if (!strcmp(res->drop, "drop")) 11106 entry.action.behavior = RTE_ETH_FDIR_REJECT; 11107 else 11108 entry.action.behavior = RTE_ETH_FDIR_ACCEPT; 11109 11110 if (fdir_conf.mode != RTE_FDIR_MODE_PERFECT_MAC_VLAN && 11111 fdir_conf.mode != RTE_FDIR_MODE_PERFECT_TUNNEL) { 11112 if (!strcmp(res->pf_vf, "pf")) 11113 entry.input.flow_ext.is_vf = 0; 11114 else if (!strncmp(res->pf_vf, "vf", 2)) { 11115 struct rte_eth_dev_info dev_info; 11116 11117 ret = eth_dev_info_get_print_err(res->port_id, 11118 &dev_info); 11119 if (ret != 0) 11120 return; 11121 11122 errno = 0; 11123 vf_id = strtoul(res->pf_vf + 2, &end, 10); 11124 if (errno != 0 || *end != '\0' || 11125 vf_id >= dev_info.max_vfs) { 11126 printf("invalid parameter %s.\n", res->pf_vf); 11127 return; 11128 } 11129 entry.input.flow_ext.is_vf = 1; 11130 entry.input.flow_ext.dst_id = (uint16_t)vf_id; 11131 } else { 11132 printf("invalid parameter %s.\n", res->pf_vf); 11133 return; 11134 } 11135 } 11136 11137 /* set to report FD ID by default */ 11138 entry.action.report_status = RTE_ETH_FDIR_REPORT_ID; 11139 entry.action.rx_queue = res->queue_id; 11140 entry.soft_id = res->fd_id_value; 11141 if (!strcmp(res->ops, "add")) 11142 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_FDIR, 11143 RTE_ETH_FILTER_ADD, &entry); 11144 else if (!strcmp(res->ops, "del")) 11145 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_FDIR, 11146 RTE_ETH_FILTER_DELETE, &entry); 11147 else 11148 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_FDIR, 11149 RTE_ETH_FILTER_UPDATE, &entry); 11150 if (ret < 0) 11151 printf("flow director programming error: (%s)\n", 11152 strerror(-ret)); 11153 } 11154 11155 cmdline_parse_token_string_t cmd_flow_director_filter = 11156 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result, 11157 flow_director_filter, "flow_director_filter"); 11158 cmdline_parse_token_num_t cmd_flow_director_port_id = 11159 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result, 11160 port_id, UINT16); 11161 cmdline_parse_token_string_t cmd_flow_director_ops = 11162 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result, 11163 ops, "add#del#update"); 11164 cmdline_parse_token_string_t cmd_flow_director_flow = 11165 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result, 11166 flow, "flow"); 11167 cmdline_parse_token_string_t cmd_flow_director_flow_type = 11168 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result, 11169 flow_type, NULL); 11170 cmdline_parse_token_string_t cmd_flow_director_ether = 11171 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result, 11172 ether, "ether"); 11173 cmdline_parse_token_num_t cmd_flow_director_ether_type = 11174 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result, 11175 ether_type, UINT16); 11176 cmdline_parse_token_string_t cmd_flow_director_src = 11177 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result, 11178 src, "src"); 11179 cmdline_parse_token_ipaddr_t cmd_flow_director_ip_src = 11180 TOKEN_IPADDR_INITIALIZER(struct cmd_flow_director_result, 11181 ip_src); 11182 cmdline_parse_token_num_t cmd_flow_director_port_src = 11183 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result, 11184 port_src, UINT16); 11185 cmdline_parse_token_string_t cmd_flow_director_dst = 11186 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result, 11187 dst, "dst"); 11188 cmdline_parse_token_ipaddr_t cmd_flow_director_ip_dst = 11189 TOKEN_IPADDR_INITIALIZER(struct cmd_flow_director_result, 11190 ip_dst); 11191 cmdline_parse_token_num_t cmd_flow_director_port_dst = 11192 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result, 11193 port_dst, UINT16); 11194 cmdline_parse_token_string_t cmd_flow_director_verify_tag = 11195 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result, 11196 verify_tag, "verify_tag"); 11197 cmdline_parse_token_num_t cmd_flow_director_verify_tag_value = 11198 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result, 11199 verify_tag_value, UINT32); 11200 cmdline_parse_token_string_t cmd_flow_director_tos = 11201 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result, 11202 tos, "tos"); 11203 cmdline_parse_token_num_t cmd_flow_director_tos_value = 11204 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result, 11205 tos_value, UINT8); 11206 cmdline_parse_token_string_t cmd_flow_director_proto = 11207 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result, 11208 proto, "proto"); 11209 cmdline_parse_token_num_t cmd_flow_director_proto_value = 11210 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result, 11211 proto_value, UINT8); 11212 cmdline_parse_token_string_t cmd_flow_director_ttl = 11213 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result, 11214 ttl, "ttl"); 11215 cmdline_parse_token_num_t cmd_flow_director_ttl_value = 11216 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result, 11217 ttl_value, UINT8); 11218 cmdline_parse_token_string_t cmd_flow_director_vlan = 11219 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result, 11220 vlan, "vlan"); 11221 cmdline_parse_token_num_t cmd_flow_director_vlan_value = 11222 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result, 11223 vlan_value, UINT16); 11224 cmdline_parse_token_string_t cmd_flow_director_flexbytes = 11225 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result, 11226 flexbytes, "flexbytes"); 11227 cmdline_parse_token_string_t cmd_flow_director_flexbytes_value = 11228 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result, 11229 flexbytes_value, NULL); 11230 cmdline_parse_token_string_t cmd_flow_director_drop = 11231 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result, 11232 drop, "drop#fwd"); 11233 cmdline_parse_token_string_t cmd_flow_director_pf_vf = 11234 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result, 11235 pf_vf, NULL); 11236 cmdline_parse_token_string_t cmd_flow_director_queue = 11237 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result, 11238 queue, "queue"); 11239 cmdline_parse_token_num_t cmd_flow_director_queue_id = 11240 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result, 11241 queue_id, UINT16); 11242 cmdline_parse_token_string_t cmd_flow_director_fd_id = 11243 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result, 11244 fd_id, "fd_id"); 11245 cmdline_parse_token_num_t cmd_flow_director_fd_id_value = 11246 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result, 11247 fd_id_value, UINT32); 11248 11249 cmdline_parse_token_string_t cmd_flow_director_mode = 11250 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result, 11251 mode, "mode"); 11252 cmdline_parse_token_string_t cmd_flow_director_mode_ip = 11253 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result, 11254 mode_value, "IP"); 11255 cmdline_parse_token_string_t cmd_flow_director_mode_mac_vlan = 11256 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result, 11257 mode_value, "MAC-VLAN"); 11258 cmdline_parse_token_string_t cmd_flow_director_mode_tunnel = 11259 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result, 11260 mode_value, "Tunnel"); 11261 cmdline_parse_token_string_t cmd_flow_director_mode_raw = 11262 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result, 11263 mode_value, "raw"); 11264 cmdline_parse_token_string_t cmd_flow_director_mac = 11265 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result, 11266 mac, "mac"); 11267 cmdline_parse_token_etheraddr_t cmd_flow_director_mac_addr = 11268 TOKEN_ETHERADDR_INITIALIZER(struct cmd_flow_director_result, 11269 mac_addr); 11270 cmdline_parse_token_string_t cmd_flow_director_tunnel = 11271 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result, 11272 tunnel, "tunnel"); 11273 cmdline_parse_token_string_t cmd_flow_director_tunnel_type = 11274 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result, 11275 tunnel_type, "NVGRE#VxLAN"); 11276 cmdline_parse_token_string_t cmd_flow_director_tunnel_id = 11277 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result, 11278 tunnel_id, "tunnel-id"); 11279 cmdline_parse_token_num_t cmd_flow_director_tunnel_id_value = 11280 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result, 11281 tunnel_id_value, UINT32); 11282 cmdline_parse_token_string_t cmd_flow_director_packet = 11283 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result, 11284 packet, "packet"); 11285 cmdline_parse_token_string_t cmd_flow_director_filepath = 11286 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result, 11287 filepath, NULL); 11288 11289 cmdline_parse_inst_t cmd_add_del_ip_flow_director = { 11290 .f = cmd_flow_director_filter_parsed, 11291 .data = NULL, 11292 .help_str = "flow_director_filter <port_id> mode IP add|del|update flow" 11293 " ipv4-other|ipv4-frag|ipv4-tcp|ipv4-udp|ipv4-sctp|" 11294 "ipv6-other|ipv6-frag|ipv6-tcp|ipv6-udp|ipv6-sctp|" 11295 "l2_payload src <src_ip> dst <dst_ip> tos <tos_value> " 11296 "proto <proto_value> ttl <ttl_value> vlan <vlan_value> " 11297 "flexbytes <flexbyte_values> drop|fw <pf_vf> queue <queue_id> " 11298 "fd_id <fd_id_value>: " 11299 "Add or delete an ip flow director entry on NIC", 11300 .tokens = { 11301 (void *)&cmd_flow_director_filter, 11302 (void *)&cmd_flow_director_port_id, 11303 (void *)&cmd_flow_director_mode, 11304 (void *)&cmd_flow_director_mode_ip, 11305 (void *)&cmd_flow_director_ops, 11306 (void *)&cmd_flow_director_flow, 11307 (void *)&cmd_flow_director_flow_type, 11308 (void *)&cmd_flow_director_src, 11309 (void *)&cmd_flow_director_ip_src, 11310 (void *)&cmd_flow_director_dst, 11311 (void *)&cmd_flow_director_ip_dst, 11312 (void *)&cmd_flow_director_tos, 11313 (void *)&cmd_flow_director_tos_value, 11314 (void *)&cmd_flow_director_proto, 11315 (void *)&cmd_flow_director_proto_value, 11316 (void *)&cmd_flow_director_ttl, 11317 (void *)&cmd_flow_director_ttl_value, 11318 (void *)&cmd_flow_director_vlan, 11319 (void *)&cmd_flow_director_vlan_value, 11320 (void *)&cmd_flow_director_flexbytes, 11321 (void *)&cmd_flow_director_flexbytes_value, 11322 (void *)&cmd_flow_director_drop, 11323 (void *)&cmd_flow_director_pf_vf, 11324 (void *)&cmd_flow_director_queue, 11325 (void *)&cmd_flow_director_queue_id, 11326 (void *)&cmd_flow_director_fd_id, 11327 (void *)&cmd_flow_director_fd_id_value, 11328 NULL, 11329 }, 11330 }; 11331 11332 cmdline_parse_inst_t cmd_add_del_udp_flow_director = { 11333 .f = cmd_flow_director_filter_parsed, 11334 .data = NULL, 11335 .help_str = "flow_director_filter ... : Add or delete an udp/tcp flow " 11336 "director entry on NIC", 11337 .tokens = { 11338 (void *)&cmd_flow_director_filter, 11339 (void *)&cmd_flow_director_port_id, 11340 (void *)&cmd_flow_director_mode, 11341 (void *)&cmd_flow_director_mode_ip, 11342 (void *)&cmd_flow_director_ops, 11343 (void *)&cmd_flow_director_flow, 11344 (void *)&cmd_flow_director_flow_type, 11345 (void *)&cmd_flow_director_src, 11346 (void *)&cmd_flow_director_ip_src, 11347 (void *)&cmd_flow_director_port_src, 11348 (void *)&cmd_flow_director_dst, 11349 (void *)&cmd_flow_director_ip_dst, 11350 (void *)&cmd_flow_director_port_dst, 11351 (void *)&cmd_flow_director_tos, 11352 (void *)&cmd_flow_director_tos_value, 11353 (void *)&cmd_flow_director_ttl, 11354 (void *)&cmd_flow_director_ttl_value, 11355 (void *)&cmd_flow_director_vlan, 11356 (void *)&cmd_flow_director_vlan_value, 11357 (void *)&cmd_flow_director_flexbytes, 11358 (void *)&cmd_flow_director_flexbytes_value, 11359 (void *)&cmd_flow_director_drop, 11360 (void *)&cmd_flow_director_pf_vf, 11361 (void *)&cmd_flow_director_queue, 11362 (void *)&cmd_flow_director_queue_id, 11363 (void *)&cmd_flow_director_fd_id, 11364 (void *)&cmd_flow_director_fd_id_value, 11365 NULL, 11366 }, 11367 }; 11368 11369 cmdline_parse_inst_t cmd_add_del_sctp_flow_director = { 11370 .f = cmd_flow_director_filter_parsed, 11371 .data = NULL, 11372 .help_str = "flow_director_filter ... : Add or delete a sctp flow " 11373 "director entry on NIC", 11374 .tokens = { 11375 (void *)&cmd_flow_director_filter, 11376 (void *)&cmd_flow_director_port_id, 11377 (void *)&cmd_flow_director_mode, 11378 (void *)&cmd_flow_director_mode_ip, 11379 (void *)&cmd_flow_director_ops, 11380 (void *)&cmd_flow_director_flow, 11381 (void *)&cmd_flow_director_flow_type, 11382 (void *)&cmd_flow_director_src, 11383 (void *)&cmd_flow_director_ip_src, 11384 (void *)&cmd_flow_director_port_src, 11385 (void *)&cmd_flow_director_dst, 11386 (void *)&cmd_flow_director_ip_dst, 11387 (void *)&cmd_flow_director_port_dst, 11388 (void *)&cmd_flow_director_verify_tag, 11389 (void *)&cmd_flow_director_verify_tag_value, 11390 (void *)&cmd_flow_director_tos, 11391 (void *)&cmd_flow_director_tos_value, 11392 (void *)&cmd_flow_director_ttl, 11393 (void *)&cmd_flow_director_ttl_value, 11394 (void *)&cmd_flow_director_vlan, 11395 (void *)&cmd_flow_director_vlan_value, 11396 (void *)&cmd_flow_director_flexbytes, 11397 (void *)&cmd_flow_director_flexbytes_value, 11398 (void *)&cmd_flow_director_drop, 11399 (void *)&cmd_flow_director_pf_vf, 11400 (void *)&cmd_flow_director_queue, 11401 (void *)&cmd_flow_director_queue_id, 11402 (void *)&cmd_flow_director_fd_id, 11403 (void *)&cmd_flow_director_fd_id_value, 11404 NULL, 11405 }, 11406 }; 11407 11408 cmdline_parse_inst_t cmd_add_del_l2_flow_director = { 11409 .f = cmd_flow_director_filter_parsed, 11410 .data = NULL, 11411 .help_str = "flow_director_filter ... : Add or delete a L2 flow " 11412 "director entry on NIC", 11413 .tokens = { 11414 (void *)&cmd_flow_director_filter, 11415 (void *)&cmd_flow_director_port_id, 11416 (void *)&cmd_flow_director_mode, 11417 (void *)&cmd_flow_director_mode_ip, 11418 (void *)&cmd_flow_director_ops, 11419 (void *)&cmd_flow_director_flow, 11420 (void *)&cmd_flow_director_flow_type, 11421 (void *)&cmd_flow_director_ether, 11422 (void *)&cmd_flow_director_ether_type, 11423 (void *)&cmd_flow_director_flexbytes, 11424 (void *)&cmd_flow_director_flexbytes_value, 11425 (void *)&cmd_flow_director_drop, 11426 (void *)&cmd_flow_director_pf_vf, 11427 (void *)&cmd_flow_director_queue, 11428 (void *)&cmd_flow_director_queue_id, 11429 (void *)&cmd_flow_director_fd_id, 11430 (void *)&cmd_flow_director_fd_id_value, 11431 NULL, 11432 }, 11433 }; 11434 11435 cmdline_parse_inst_t cmd_add_del_mac_vlan_flow_director = { 11436 .f = cmd_flow_director_filter_parsed, 11437 .data = NULL, 11438 .help_str = "flow_director_filter ... : Add or delete a MAC VLAN flow " 11439 "director entry on NIC", 11440 .tokens = { 11441 (void *)&cmd_flow_director_filter, 11442 (void *)&cmd_flow_director_port_id, 11443 (void *)&cmd_flow_director_mode, 11444 (void *)&cmd_flow_director_mode_mac_vlan, 11445 (void *)&cmd_flow_director_ops, 11446 (void *)&cmd_flow_director_mac, 11447 (void *)&cmd_flow_director_mac_addr, 11448 (void *)&cmd_flow_director_vlan, 11449 (void *)&cmd_flow_director_vlan_value, 11450 (void *)&cmd_flow_director_flexbytes, 11451 (void *)&cmd_flow_director_flexbytes_value, 11452 (void *)&cmd_flow_director_drop, 11453 (void *)&cmd_flow_director_queue, 11454 (void *)&cmd_flow_director_queue_id, 11455 (void *)&cmd_flow_director_fd_id, 11456 (void *)&cmd_flow_director_fd_id_value, 11457 NULL, 11458 }, 11459 }; 11460 11461 cmdline_parse_inst_t cmd_add_del_tunnel_flow_director = { 11462 .f = cmd_flow_director_filter_parsed, 11463 .data = NULL, 11464 .help_str = "flow_director_filter ... : Add or delete a tunnel flow " 11465 "director entry on NIC", 11466 .tokens = { 11467 (void *)&cmd_flow_director_filter, 11468 (void *)&cmd_flow_director_port_id, 11469 (void *)&cmd_flow_director_mode, 11470 (void *)&cmd_flow_director_mode_tunnel, 11471 (void *)&cmd_flow_director_ops, 11472 (void *)&cmd_flow_director_mac, 11473 (void *)&cmd_flow_director_mac_addr, 11474 (void *)&cmd_flow_director_vlan, 11475 (void *)&cmd_flow_director_vlan_value, 11476 (void *)&cmd_flow_director_tunnel, 11477 (void *)&cmd_flow_director_tunnel_type, 11478 (void *)&cmd_flow_director_tunnel_id, 11479 (void *)&cmd_flow_director_tunnel_id_value, 11480 (void *)&cmd_flow_director_flexbytes, 11481 (void *)&cmd_flow_director_flexbytes_value, 11482 (void *)&cmd_flow_director_drop, 11483 (void *)&cmd_flow_director_queue, 11484 (void *)&cmd_flow_director_queue_id, 11485 (void *)&cmd_flow_director_fd_id, 11486 (void *)&cmd_flow_director_fd_id_value, 11487 NULL, 11488 }, 11489 }; 11490 11491 cmdline_parse_inst_t cmd_add_del_raw_flow_director = { 11492 .f = cmd_flow_director_filter_parsed, 11493 .data = NULL, 11494 .help_str = "flow_director_filter ... : Add or delete a raw flow " 11495 "director entry on NIC", 11496 .tokens = { 11497 (void *)&cmd_flow_director_filter, 11498 (void *)&cmd_flow_director_port_id, 11499 (void *)&cmd_flow_director_mode, 11500 (void *)&cmd_flow_director_mode_raw, 11501 (void *)&cmd_flow_director_ops, 11502 (void *)&cmd_flow_director_flow, 11503 (void *)&cmd_flow_director_flow_type, 11504 (void *)&cmd_flow_director_drop, 11505 (void *)&cmd_flow_director_queue, 11506 (void *)&cmd_flow_director_queue_id, 11507 (void *)&cmd_flow_director_fd_id, 11508 (void *)&cmd_flow_director_fd_id_value, 11509 (void *)&cmd_flow_director_packet, 11510 (void *)&cmd_flow_director_filepath, 11511 NULL, 11512 }, 11513 }; 11514 11515 struct cmd_flush_flow_director_result { 11516 cmdline_fixed_string_t flush_flow_director; 11517 portid_t port_id; 11518 }; 11519 11520 cmdline_parse_token_string_t cmd_flush_flow_director_flush = 11521 TOKEN_STRING_INITIALIZER(struct cmd_flush_flow_director_result, 11522 flush_flow_director, "flush_flow_director"); 11523 cmdline_parse_token_num_t cmd_flush_flow_director_port_id = 11524 TOKEN_NUM_INITIALIZER(struct cmd_flush_flow_director_result, 11525 port_id, UINT16); 11526 11527 static void 11528 cmd_flush_flow_director_parsed(void *parsed_result, 11529 __attribute__((unused)) struct cmdline *cl, 11530 __attribute__((unused)) void *data) 11531 { 11532 struct cmd_flow_director_result *res = parsed_result; 11533 int ret = 0; 11534 11535 ret = rte_eth_dev_filter_supported(res->port_id, RTE_ETH_FILTER_FDIR); 11536 if (ret < 0) { 11537 printf("flow director is not supported on port %u.\n", 11538 res->port_id); 11539 return; 11540 } 11541 11542 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_FDIR, 11543 RTE_ETH_FILTER_FLUSH, NULL); 11544 if (ret < 0) 11545 printf("flow director table flushing error: (%s)\n", 11546 strerror(-ret)); 11547 } 11548 11549 cmdline_parse_inst_t cmd_flush_flow_director = { 11550 .f = cmd_flush_flow_director_parsed, 11551 .data = NULL, 11552 .help_str = "flush_flow_director <port_id>: " 11553 "Flush all flow director entries of a device on NIC", 11554 .tokens = { 11555 (void *)&cmd_flush_flow_director_flush, 11556 (void *)&cmd_flush_flow_director_port_id, 11557 NULL, 11558 }, 11559 }; 11560 11561 /* *** deal with flow director mask *** */ 11562 struct cmd_flow_director_mask_result { 11563 cmdline_fixed_string_t flow_director_mask; 11564 portid_t port_id; 11565 cmdline_fixed_string_t mode; 11566 cmdline_fixed_string_t mode_value; 11567 cmdline_fixed_string_t vlan; 11568 uint16_t vlan_mask; 11569 cmdline_fixed_string_t src_mask; 11570 cmdline_ipaddr_t ipv4_src; 11571 cmdline_ipaddr_t ipv6_src; 11572 uint16_t port_src; 11573 cmdline_fixed_string_t dst_mask; 11574 cmdline_ipaddr_t ipv4_dst; 11575 cmdline_ipaddr_t ipv6_dst; 11576 uint16_t port_dst; 11577 cmdline_fixed_string_t mac; 11578 uint8_t mac_addr_byte_mask; 11579 cmdline_fixed_string_t tunnel_id; 11580 uint32_t tunnel_id_mask; 11581 cmdline_fixed_string_t tunnel_type; 11582 uint8_t tunnel_type_mask; 11583 }; 11584 11585 static void 11586 cmd_flow_director_mask_parsed(void *parsed_result, 11587 __attribute__((unused)) struct cmdline *cl, 11588 __attribute__((unused)) void *data) 11589 { 11590 struct cmd_flow_director_mask_result *res = parsed_result; 11591 struct rte_eth_fdir_masks *mask; 11592 struct rte_port *port; 11593 11594 port = &ports[res->port_id]; 11595 /** Check if the port is not started **/ 11596 if (port->port_status != RTE_PORT_STOPPED) { 11597 printf("Please stop port %d first\n", res->port_id); 11598 return; 11599 } 11600 11601 mask = &port->dev_conf.fdir_conf.mask; 11602 11603 if (fdir_conf.mode == RTE_FDIR_MODE_PERFECT_MAC_VLAN) { 11604 if (strcmp(res->mode_value, "MAC-VLAN")) { 11605 printf("Please set mode to MAC-VLAN.\n"); 11606 return; 11607 } 11608 11609 mask->vlan_tci_mask = rte_cpu_to_be_16(res->vlan_mask); 11610 } else if (fdir_conf.mode == RTE_FDIR_MODE_PERFECT_TUNNEL) { 11611 if (strcmp(res->mode_value, "Tunnel")) { 11612 printf("Please set mode to Tunnel.\n"); 11613 return; 11614 } 11615 11616 mask->vlan_tci_mask = rte_cpu_to_be_16(res->vlan_mask); 11617 mask->mac_addr_byte_mask = res->mac_addr_byte_mask; 11618 mask->tunnel_id_mask = rte_cpu_to_be_32(res->tunnel_id_mask); 11619 mask->tunnel_type_mask = res->tunnel_type_mask; 11620 } else { 11621 if (strcmp(res->mode_value, "IP")) { 11622 printf("Please set mode to IP.\n"); 11623 return; 11624 } 11625 11626 mask->vlan_tci_mask = rte_cpu_to_be_16(res->vlan_mask); 11627 IPV4_ADDR_TO_UINT(res->ipv4_src, mask->ipv4_mask.src_ip); 11628 IPV4_ADDR_TO_UINT(res->ipv4_dst, mask->ipv4_mask.dst_ip); 11629 IPV6_ADDR_TO_ARRAY(res->ipv6_src, mask->ipv6_mask.src_ip); 11630 IPV6_ADDR_TO_ARRAY(res->ipv6_dst, mask->ipv6_mask.dst_ip); 11631 mask->src_port_mask = rte_cpu_to_be_16(res->port_src); 11632 mask->dst_port_mask = rte_cpu_to_be_16(res->port_dst); 11633 } 11634 11635 cmd_reconfig_device_queue(res->port_id, 1, 1); 11636 } 11637 11638 cmdline_parse_token_string_t cmd_flow_director_mask = 11639 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result, 11640 flow_director_mask, "flow_director_mask"); 11641 cmdline_parse_token_num_t cmd_flow_director_mask_port_id = 11642 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_mask_result, 11643 port_id, UINT16); 11644 cmdline_parse_token_string_t cmd_flow_director_mask_vlan = 11645 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result, 11646 vlan, "vlan"); 11647 cmdline_parse_token_num_t cmd_flow_director_mask_vlan_value = 11648 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_mask_result, 11649 vlan_mask, UINT16); 11650 cmdline_parse_token_string_t cmd_flow_director_mask_src = 11651 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result, 11652 src_mask, "src_mask"); 11653 cmdline_parse_token_ipaddr_t cmd_flow_director_mask_ipv4_src = 11654 TOKEN_IPADDR_INITIALIZER(struct cmd_flow_director_mask_result, 11655 ipv4_src); 11656 cmdline_parse_token_ipaddr_t cmd_flow_director_mask_ipv6_src = 11657 TOKEN_IPADDR_INITIALIZER(struct cmd_flow_director_mask_result, 11658 ipv6_src); 11659 cmdline_parse_token_num_t cmd_flow_director_mask_port_src = 11660 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_mask_result, 11661 port_src, UINT16); 11662 cmdline_parse_token_string_t cmd_flow_director_mask_dst = 11663 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result, 11664 dst_mask, "dst_mask"); 11665 cmdline_parse_token_ipaddr_t cmd_flow_director_mask_ipv4_dst = 11666 TOKEN_IPADDR_INITIALIZER(struct cmd_flow_director_mask_result, 11667 ipv4_dst); 11668 cmdline_parse_token_ipaddr_t cmd_flow_director_mask_ipv6_dst = 11669 TOKEN_IPADDR_INITIALIZER(struct cmd_flow_director_mask_result, 11670 ipv6_dst); 11671 cmdline_parse_token_num_t cmd_flow_director_mask_port_dst = 11672 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_mask_result, 11673 port_dst, UINT16); 11674 11675 cmdline_parse_token_string_t cmd_flow_director_mask_mode = 11676 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result, 11677 mode, "mode"); 11678 cmdline_parse_token_string_t cmd_flow_director_mask_mode_ip = 11679 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result, 11680 mode_value, "IP"); 11681 cmdline_parse_token_string_t cmd_flow_director_mask_mode_mac_vlan = 11682 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result, 11683 mode_value, "MAC-VLAN"); 11684 cmdline_parse_token_string_t cmd_flow_director_mask_mode_tunnel = 11685 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result, 11686 mode_value, "Tunnel"); 11687 cmdline_parse_token_string_t cmd_flow_director_mask_mac = 11688 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result, 11689 mac, "mac"); 11690 cmdline_parse_token_num_t cmd_flow_director_mask_mac_value = 11691 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_mask_result, 11692 mac_addr_byte_mask, UINT8); 11693 cmdline_parse_token_string_t cmd_flow_director_mask_tunnel_type = 11694 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result, 11695 tunnel_type, "tunnel-type"); 11696 cmdline_parse_token_num_t cmd_flow_director_mask_tunnel_type_value = 11697 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_mask_result, 11698 tunnel_type_mask, UINT8); 11699 cmdline_parse_token_string_t cmd_flow_director_mask_tunnel_id = 11700 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result, 11701 tunnel_id, "tunnel-id"); 11702 cmdline_parse_token_num_t cmd_flow_director_mask_tunnel_id_value = 11703 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_mask_result, 11704 tunnel_id_mask, UINT32); 11705 11706 cmdline_parse_inst_t cmd_set_flow_director_ip_mask = { 11707 .f = cmd_flow_director_mask_parsed, 11708 .data = NULL, 11709 .help_str = "flow_director_mask ... : " 11710 "Set IP mode flow director's mask on NIC", 11711 .tokens = { 11712 (void *)&cmd_flow_director_mask, 11713 (void *)&cmd_flow_director_mask_port_id, 11714 (void *)&cmd_flow_director_mask_mode, 11715 (void *)&cmd_flow_director_mask_mode_ip, 11716 (void *)&cmd_flow_director_mask_vlan, 11717 (void *)&cmd_flow_director_mask_vlan_value, 11718 (void *)&cmd_flow_director_mask_src, 11719 (void *)&cmd_flow_director_mask_ipv4_src, 11720 (void *)&cmd_flow_director_mask_ipv6_src, 11721 (void *)&cmd_flow_director_mask_port_src, 11722 (void *)&cmd_flow_director_mask_dst, 11723 (void *)&cmd_flow_director_mask_ipv4_dst, 11724 (void *)&cmd_flow_director_mask_ipv6_dst, 11725 (void *)&cmd_flow_director_mask_port_dst, 11726 NULL, 11727 }, 11728 }; 11729 11730 cmdline_parse_inst_t cmd_set_flow_director_mac_vlan_mask = { 11731 .f = cmd_flow_director_mask_parsed, 11732 .data = NULL, 11733 .help_str = "flow_director_mask ... : Set MAC VLAN mode " 11734 "flow director's mask on NIC", 11735 .tokens = { 11736 (void *)&cmd_flow_director_mask, 11737 (void *)&cmd_flow_director_mask_port_id, 11738 (void *)&cmd_flow_director_mask_mode, 11739 (void *)&cmd_flow_director_mask_mode_mac_vlan, 11740 (void *)&cmd_flow_director_mask_vlan, 11741 (void *)&cmd_flow_director_mask_vlan_value, 11742 NULL, 11743 }, 11744 }; 11745 11746 cmdline_parse_inst_t cmd_set_flow_director_tunnel_mask = { 11747 .f = cmd_flow_director_mask_parsed, 11748 .data = NULL, 11749 .help_str = "flow_director_mask ... : Set tunnel mode " 11750 "flow director's mask on NIC", 11751 .tokens = { 11752 (void *)&cmd_flow_director_mask, 11753 (void *)&cmd_flow_director_mask_port_id, 11754 (void *)&cmd_flow_director_mask_mode, 11755 (void *)&cmd_flow_director_mask_mode_tunnel, 11756 (void *)&cmd_flow_director_mask_vlan, 11757 (void *)&cmd_flow_director_mask_vlan_value, 11758 (void *)&cmd_flow_director_mask_mac, 11759 (void *)&cmd_flow_director_mask_mac_value, 11760 (void *)&cmd_flow_director_mask_tunnel_type, 11761 (void *)&cmd_flow_director_mask_tunnel_type_value, 11762 (void *)&cmd_flow_director_mask_tunnel_id, 11763 (void *)&cmd_flow_director_mask_tunnel_id_value, 11764 NULL, 11765 }, 11766 }; 11767 11768 /* *** deal with flow director mask on flexible payload *** */ 11769 struct cmd_flow_director_flex_mask_result { 11770 cmdline_fixed_string_t flow_director_flexmask; 11771 portid_t port_id; 11772 cmdline_fixed_string_t flow; 11773 cmdline_fixed_string_t flow_type; 11774 cmdline_fixed_string_t mask; 11775 }; 11776 11777 static void 11778 cmd_flow_director_flex_mask_parsed(void *parsed_result, 11779 __attribute__((unused)) struct cmdline *cl, 11780 __attribute__((unused)) void *data) 11781 { 11782 struct cmd_flow_director_flex_mask_result *res = parsed_result; 11783 struct rte_eth_fdir_info fdir_info; 11784 struct rte_eth_fdir_flex_mask flex_mask; 11785 struct rte_port *port; 11786 uint64_t flow_type_mask; 11787 uint16_t i; 11788 int ret; 11789 11790 port = &ports[res->port_id]; 11791 /** Check if the port is not started **/ 11792 if (port->port_status != RTE_PORT_STOPPED) { 11793 printf("Please stop port %d first\n", res->port_id); 11794 return; 11795 } 11796 11797 memset(&flex_mask, 0, sizeof(struct rte_eth_fdir_flex_mask)); 11798 ret = parse_flexbytes(res->mask, 11799 flex_mask.mask, 11800 RTE_ETH_FDIR_MAX_FLEXLEN); 11801 if (ret < 0) { 11802 printf("error: Cannot parse mask input.\n"); 11803 return; 11804 } 11805 11806 memset(&fdir_info, 0, sizeof(fdir_info)); 11807 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_FDIR, 11808 RTE_ETH_FILTER_INFO, &fdir_info); 11809 if (ret < 0) { 11810 printf("Cannot get FDir filter info\n"); 11811 return; 11812 } 11813 11814 if (!strcmp(res->flow_type, "none")) { 11815 /* means don't specify the flow type */ 11816 flex_mask.flow_type = RTE_ETH_FLOW_UNKNOWN; 11817 for (i = 0; i < RTE_ETH_FLOW_MAX; i++) 11818 memset(&port->dev_conf.fdir_conf.flex_conf.flex_mask[i], 11819 0, sizeof(struct rte_eth_fdir_flex_mask)); 11820 port->dev_conf.fdir_conf.flex_conf.nb_flexmasks = 1; 11821 rte_memcpy(&port->dev_conf.fdir_conf.flex_conf.flex_mask[0], 11822 &flex_mask, 11823 sizeof(struct rte_eth_fdir_flex_mask)); 11824 cmd_reconfig_device_queue(res->port_id, 1, 1); 11825 return; 11826 } 11827 flow_type_mask = fdir_info.flow_types_mask[0]; 11828 if (!strcmp(res->flow_type, "all")) { 11829 if (!flow_type_mask) { 11830 printf("No flow type supported\n"); 11831 return; 11832 } 11833 for (i = RTE_ETH_FLOW_UNKNOWN; i < RTE_ETH_FLOW_MAX; i++) { 11834 if (flow_type_mask & (1ULL << i)) { 11835 flex_mask.flow_type = i; 11836 fdir_set_flex_mask(res->port_id, &flex_mask); 11837 } 11838 } 11839 cmd_reconfig_device_queue(res->port_id, 1, 1); 11840 return; 11841 } 11842 flex_mask.flow_type = str2flowtype(res->flow_type); 11843 if (!(flow_type_mask & (1ULL << flex_mask.flow_type))) { 11844 printf("Flow type %s not supported on port %d\n", 11845 res->flow_type, res->port_id); 11846 return; 11847 } 11848 fdir_set_flex_mask(res->port_id, &flex_mask); 11849 cmd_reconfig_device_queue(res->port_id, 1, 1); 11850 } 11851 11852 cmdline_parse_token_string_t cmd_flow_director_flexmask = 11853 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_flex_mask_result, 11854 flow_director_flexmask, 11855 "flow_director_flex_mask"); 11856 cmdline_parse_token_num_t cmd_flow_director_flexmask_port_id = 11857 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_flex_mask_result, 11858 port_id, UINT16); 11859 cmdline_parse_token_string_t cmd_flow_director_flexmask_flow = 11860 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_flex_mask_result, 11861 flow, "flow"); 11862 cmdline_parse_token_string_t cmd_flow_director_flexmask_flow_type = 11863 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_flex_mask_result, 11864 flow_type, "none#ipv4-other#ipv4-frag#ipv4-tcp#ipv4-udp#ipv4-sctp#" 11865 "ipv6-other#ipv6-frag#ipv6-tcp#ipv6-udp#ipv6-sctp#l2_payload#all"); 11866 cmdline_parse_token_string_t cmd_flow_director_flexmask_mask = 11867 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_flex_mask_result, 11868 mask, NULL); 11869 11870 cmdline_parse_inst_t cmd_set_flow_director_flex_mask = { 11871 .f = cmd_flow_director_flex_mask_parsed, 11872 .data = NULL, 11873 .help_str = "flow_director_flex_mask ... : " 11874 "Set flow director's flex mask on NIC", 11875 .tokens = { 11876 (void *)&cmd_flow_director_flexmask, 11877 (void *)&cmd_flow_director_flexmask_port_id, 11878 (void *)&cmd_flow_director_flexmask_flow, 11879 (void *)&cmd_flow_director_flexmask_flow_type, 11880 (void *)&cmd_flow_director_flexmask_mask, 11881 NULL, 11882 }, 11883 }; 11884 11885 /* *** deal with flow director flexible payload configuration *** */ 11886 struct cmd_flow_director_flexpayload_result { 11887 cmdline_fixed_string_t flow_director_flexpayload; 11888 portid_t port_id; 11889 cmdline_fixed_string_t payload_layer; 11890 cmdline_fixed_string_t payload_cfg; 11891 }; 11892 11893 static inline int 11894 parse_offsets(const char *q_arg, uint16_t *offsets, uint16_t max_num) 11895 { 11896 char s[256]; 11897 const char *p, *p0 = q_arg; 11898 char *end; 11899 unsigned long int_fld; 11900 char *str_fld[max_num]; 11901 int i; 11902 unsigned size; 11903 int ret = -1; 11904 11905 p = strchr(p0, '('); 11906 if (p == NULL) 11907 return -1; 11908 ++p; 11909 p0 = strchr(p, ')'); 11910 if (p0 == NULL) 11911 return -1; 11912 11913 size = p0 - p; 11914 if (size >= sizeof(s)) 11915 return -1; 11916 11917 snprintf(s, sizeof(s), "%.*s", size, p); 11918 ret = rte_strsplit(s, sizeof(s), str_fld, max_num, ','); 11919 if (ret < 0 || ret > max_num) 11920 return -1; 11921 for (i = 0; i < ret; i++) { 11922 errno = 0; 11923 int_fld = strtoul(str_fld[i], &end, 0); 11924 if (errno != 0 || *end != '\0' || int_fld > UINT16_MAX) 11925 return -1; 11926 offsets[i] = (uint16_t)int_fld; 11927 } 11928 return ret; 11929 } 11930 11931 static void 11932 cmd_flow_director_flxpld_parsed(void *parsed_result, 11933 __attribute__((unused)) struct cmdline *cl, 11934 __attribute__((unused)) void *data) 11935 { 11936 struct cmd_flow_director_flexpayload_result *res = parsed_result; 11937 struct rte_eth_flex_payload_cfg flex_cfg; 11938 struct rte_port *port; 11939 int ret = 0; 11940 11941 port = &ports[res->port_id]; 11942 /** Check if the port is not started **/ 11943 if (port->port_status != RTE_PORT_STOPPED) { 11944 printf("Please stop port %d first\n", res->port_id); 11945 return; 11946 } 11947 11948 memset(&flex_cfg, 0, sizeof(struct rte_eth_flex_payload_cfg)); 11949 11950 if (!strcmp(res->payload_layer, "raw")) 11951 flex_cfg.type = RTE_ETH_RAW_PAYLOAD; 11952 else if (!strcmp(res->payload_layer, "l2")) 11953 flex_cfg.type = RTE_ETH_L2_PAYLOAD; 11954 else if (!strcmp(res->payload_layer, "l3")) 11955 flex_cfg.type = RTE_ETH_L3_PAYLOAD; 11956 else if (!strcmp(res->payload_layer, "l4")) 11957 flex_cfg.type = RTE_ETH_L4_PAYLOAD; 11958 11959 ret = parse_offsets(res->payload_cfg, flex_cfg.src_offset, 11960 RTE_ETH_FDIR_MAX_FLEXLEN); 11961 if (ret < 0) { 11962 printf("error: Cannot parse flex payload input.\n"); 11963 return; 11964 } 11965 11966 fdir_set_flex_payload(res->port_id, &flex_cfg); 11967 cmd_reconfig_device_queue(res->port_id, 1, 1); 11968 } 11969 11970 cmdline_parse_token_string_t cmd_flow_director_flexpayload = 11971 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_flexpayload_result, 11972 flow_director_flexpayload, 11973 "flow_director_flex_payload"); 11974 cmdline_parse_token_num_t cmd_flow_director_flexpayload_port_id = 11975 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_flexpayload_result, 11976 port_id, UINT16); 11977 cmdline_parse_token_string_t cmd_flow_director_flexpayload_payload_layer = 11978 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_flexpayload_result, 11979 payload_layer, "raw#l2#l3#l4"); 11980 cmdline_parse_token_string_t cmd_flow_director_flexpayload_payload_cfg = 11981 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_flexpayload_result, 11982 payload_cfg, NULL); 11983 11984 cmdline_parse_inst_t cmd_set_flow_director_flex_payload = { 11985 .f = cmd_flow_director_flxpld_parsed, 11986 .data = NULL, 11987 .help_str = "flow_director_flexpayload ... : " 11988 "Set flow director's flex payload on NIC", 11989 .tokens = { 11990 (void *)&cmd_flow_director_flexpayload, 11991 (void *)&cmd_flow_director_flexpayload_port_id, 11992 (void *)&cmd_flow_director_flexpayload_payload_layer, 11993 (void *)&cmd_flow_director_flexpayload_payload_cfg, 11994 NULL, 11995 }, 11996 }; 11997 11998 /* Generic flow interface command. */ 11999 extern cmdline_parse_inst_t cmd_flow; 12000 12001 /* *** Classification Filters Control *** */ 12002 /* *** Get symmetric hash enable per port *** */ 12003 struct cmd_get_sym_hash_ena_per_port_result { 12004 cmdline_fixed_string_t get_sym_hash_ena_per_port; 12005 portid_t port_id; 12006 }; 12007 12008 static void 12009 cmd_get_sym_hash_per_port_parsed(void *parsed_result, 12010 __rte_unused struct cmdline *cl, 12011 __rte_unused void *data) 12012 { 12013 struct cmd_get_sym_hash_ena_per_port_result *res = parsed_result; 12014 struct rte_eth_hash_filter_info info; 12015 int ret; 12016 12017 if (rte_eth_dev_filter_supported(res->port_id, 12018 RTE_ETH_FILTER_HASH) < 0) { 12019 printf("RTE_ETH_FILTER_HASH not supported on port: %d\n", 12020 res->port_id); 12021 return; 12022 } 12023 12024 memset(&info, 0, sizeof(info)); 12025 info.info_type = RTE_ETH_HASH_FILTER_SYM_HASH_ENA_PER_PORT; 12026 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_HASH, 12027 RTE_ETH_FILTER_GET, &info); 12028 12029 if (ret < 0) { 12030 printf("Cannot get symmetric hash enable per port " 12031 "on port %u\n", res->port_id); 12032 return; 12033 } 12034 12035 printf("Symmetric hash is %s on port %u\n", info.info.enable ? 12036 "enabled" : "disabled", res->port_id); 12037 } 12038 12039 cmdline_parse_token_string_t cmd_get_sym_hash_ena_per_port_all = 12040 TOKEN_STRING_INITIALIZER(struct cmd_get_sym_hash_ena_per_port_result, 12041 get_sym_hash_ena_per_port, "get_sym_hash_ena_per_port"); 12042 cmdline_parse_token_num_t cmd_get_sym_hash_ena_per_port_port_id = 12043 TOKEN_NUM_INITIALIZER(struct cmd_get_sym_hash_ena_per_port_result, 12044 port_id, UINT16); 12045 12046 cmdline_parse_inst_t cmd_get_sym_hash_ena_per_port = { 12047 .f = cmd_get_sym_hash_per_port_parsed, 12048 .data = NULL, 12049 .help_str = "get_sym_hash_ena_per_port <port_id>", 12050 .tokens = { 12051 (void *)&cmd_get_sym_hash_ena_per_port_all, 12052 (void *)&cmd_get_sym_hash_ena_per_port_port_id, 12053 NULL, 12054 }, 12055 }; 12056 12057 /* *** Set symmetric hash enable per port *** */ 12058 struct cmd_set_sym_hash_ena_per_port_result { 12059 cmdline_fixed_string_t set_sym_hash_ena_per_port; 12060 cmdline_fixed_string_t enable; 12061 portid_t port_id; 12062 }; 12063 12064 static void 12065 cmd_set_sym_hash_per_port_parsed(void *parsed_result, 12066 __rte_unused struct cmdline *cl, 12067 __rte_unused void *data) 12068 { 12069 struct cmd_set_sym_hash_ena_per_port_result *res = parsed_result; 12070 struct rte_eth_hash_filter_info info; 12071 int ret; 12072 12073 if (rte_eth_dev_filter_supported(res->port_id, 12074 RTE_ETH_FILTER_HASH) < 0) { 12075 printf("RTE_ETH_FILTER_HASH not supported on port: %d\n", 12076 res->port_id); 12077 return; 12078 } 12079 12080 memset(&info, 0, sizeof(info)); 12081 info.info_type = RTE_ETH_HASH_FILTER_SYM_HASH_ENA_PER_PORT; 12082 if (!strcmp(res->enable, "enable")) 12083 info.info.enable = 1; 12084 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_HASH, 12085 RTE_ETH_FILTER_SET, &info); 12086 if (ret < 0) { 12087 printf("Cannot set symmetric hash enable per port on " 12088 "port %u\n", res->port_id); 12089 return; 12090 } 12091 printf("Symmetric hash has been set to %s on port %u\n", 12092 res->enable, res->port_id); 12093 } 12094 12095 cmdline_parse_token_string_t cmd_set_sym_hash_ena_per_port_all = 12096 TOKEN_STRING_INITIALIZER(struct cmd_set_sym_hash_ena_per_port_result, 12097 set_sym_hash_ena_per_port, "set_sym_hash_ena_per_port"); 12098 cmdline_parse_token_num_t cmd_set_sym_hash_ena_per_port_port_id = 12099 TOKEN_NUM_INITIALIZER(struct cmd_set_sym_hash_ena_per_port_result, 12100 port_id, UINT16); 12101 cmdline_parse_token_string_t cmd_set_sym_hash_ena_per_port_enable = 12102 TOKEN_STRING_INITIALIZER(struct cmd_set_sym_hash_ena_per_port_result, 12103 enable, "enable#disable"); 12104 12105 cmdline_parse_inst_t cmd_set_sym_hash_ena_per_port = { 12106 .f = cmd_set_sym_hash_per_port_parsed, 12107 .data = NULL, 12108 .help_str = "set_sym_hash_ena_per_port <port_id> enable|disable", 12109 .tokens = { 12110 (void *)&cmd_set_sym_hash_ena_per_port_all, 12111 (void *)&cmd_set_sym_hash_ena_per_port_port_id, 12112 (void *)&cmd_set_sym_hash_ena_per_port_enable, 12113 NULL, 12114 }, 12115 }; 12116 12117 /* Get global config of hash function */ 12118 struct cmd_get_hash_global_config_result { 12119 cmdline_fixed_string_t get_hash_global_config; 12120 portid_t port_id; 12121 }; 12122 12123 static char * 12124 flowtype_to_str(uint16_t ftype) 12125 { 12126 uint16_t i; 12127 static struct { 12128 char str[16]; 12129 uint16_t ftype; 12130 } ftype_table[] = { 12131 {"ipv4", RTE_ETH_FLOW_IPV4}, 12132 {"ipv4-frag", RTE_ETH_FLOW_FRAG_IPV4}, 12133 {"ipv4-tcp", RTE_ETH_FLOW_NONFRAG_IPV4_TCP}, 12134 {"ipv4-udp", RTE_ETH_FLOW_NONFRAG_IPV4_UDP}, 12135 {"ipv4-sctp", RTE_ETH_FLOW_NONFRAG_IPV4_SCTP}, 12136 {"ipv4-other", RTE_ETH_FLOW_NONFRAG_IPV4_OTHER}, 12137 {"ipv6", RTE_ETH_FLOW_IPV6}, 12138 {"ipv6-frag", RTE_ETH_FLOW_FRAG_IPV6}, 12139 {"ipv6-tcp", RTE_ETH_FLOW_NONFRAG_IPV6_TCP}, 12140 {"ipv6-udp", RTE_ETH_FLOW_NONFRAG_IPV6_UDP}, 12141 {"ipv6-sctp", RTE_ETH_FLOW_NONFRAG_IPV6_SCTP}, 12142 {"ipv6-other", RTE_ETH_FLOW_NONFRAG_IPV6_OTHER}, 12143 {"l2_payload", RTE_ETH_FLOW_L2_PAYLOAD}, 12144 {"port", RTE_ETH_FLOW_PORT}, 12145 {"vxlan", RTE_ETH_FLOW_VXLAN}, 12146 {"geneve", RTE_ETH_FLOW_GENEVE}, 12147 {"nvgre", RTE_ETH_FLOW_NVGRE}, 12148 {"vxlan-gpe", RTE_ETH_FLOW_VXLAN_GPE}, 12149 }; 12150 12151 for (i = 0; i < RTE_DIM(ftype_table); i++) { 12152 if (ftype_table[i].ftype == ftype) 12153 return ftype_table[i].str; 12154 } 12155 12156 return NULL; 12157 } 12158 12159 static void 12160 cmd_get_hash_global_config_parsed(void *parsed_result, 12161 __rte_unused struct cmdline *cl, 12162 __rte_unused void *data) 12163 { 12164 struct cmd_get_hash_global_config_result *res = parsed_result; 12165 struct rte_eth_hash_filter_info info; 12166 uint32_t idx, offset; 12167 uint16_t i; 12168 char *str; 12169 int ret; 12170 12171 if (rte_eth_dev_filter_supported(res->port_id, 12172 RTE_ETH_FILTER_HASH) < 0) { 12173 printf("RTE_ETH_FILTER_HASH not supported on port %d\n", 12174 res->port_id); 12175 return; 12176 } 12177 12178 memset(&info, 0, sizeof(info)); 12179 info.info_type = RTE_ETH_HASH_FILTER_GLOBAL_CONFIG; 12180 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_HASH, 12181 RTE_ETH_FILTER_GET, &info); 12182 if (ret < 0) { 12183 printf("Cannot get hash global configurations by port %d\n", 12184 res->port_id); 12185 return; 12186 } 12187 12188 switch (info.info.global_conf.hash_func) { 12189 case RTE_ETH_HASH_FUNCTION_TOEPLITZ: 12190 printf("Hash function is Toeplitz\n"); 12191 break; 12192 case RTE_ETH_HASH_FUNCTION_SIMPLE_XOR: 12193 printf("Hash function is Simple XOR\n"); 12194 break; 12195 case RTE_ETH_HASH_FUNCTION_SYMMETRIC_TOEPLITZ: 12196 printf("Hash function is Symmetric Toeplitz\n"); 12197 break; 12198 default: 12199 printf("Unknown hash function\n"); 12200 break; 12201 } 12202 12203 for (i = 0; i < RTE_ETH_FLOW_MAX; i++) { 12204 idx = i / UINT64_BIT; 12205 offset = i % UINT64_BIT; 12206 if (!(info.info.global_conf.valid_bit_mask[idx] & 12207 (1ULL << offset))) 12208 continue; 12209 str = flowtype_to_str(i); 12210 if (!str) 12211 continue; 12212 printf("Symmetric hash is %s globally for flow type %s " 12213 "by port %d\n", 12214 ((info.info.global_conf.sym_hash_enable_mask[idx] & 12215 (1ULL << offset)) ? "enabled" : "disabled"), str, 12216 res->port_id); 12217 } 12218 } 12219 12220 cmdline_parse_token_string_t cmd_get_hash_global_config_all = 12221 TOKEN_STRING_INITIALIZER(struct cmd_get_hash_global_config_result, 12222 get_hash_global_config, "get_hash_global_config"); 12223 cmdline_parse_token_num_t cmd_get_hash_global_config_port_id = 12224 TOKEN_NUM_INITIALIZER(struct cmd_get_hash_global_config_result, 12225 port_id, UINT16); 12226 12227 cmdline_parse_inst_t cmd_get_hash_global_config = { 12228 .f = cmd_get_hash_global_config_parsed, 12229 .data = NULL, 12230 .help_str = "get_hash_global_config <port_id>", 12231 .tokens = { 12232 (void *)&cmd_get_hash_global_config_all, 12233 (void *)&cmd_get_hash_global_config_port_id, 12234 NULL, 12235 }, 12236 }; 12237 12238 /* Set global config of hash function */ 12239 struct cmd_set_hash_global_config_result { 12240 cmdline_fixed_string_t set_hash_global_config; 12241 portid_t port_id; 12242 cmdline_fixed_string_t hash_func; 12243 cmdline_fixed_string_t flow_type; 12244 cmdline_fixed_string_t enable; 12245 }; 12246 12247 static void 12248 cmd_set_hash_global_config_parsed(void *parsed_result, 12249 __rte_unused struct cmdline *cl, 12250 __rte_unused void *data) 12251 { 12252 struct cmd_set_hash_global_config_result *res = parsed_result; 12253 struct rte_eth_hash_filter_info info; 12254 uint32_t ftype, idx, offset; 12255 int ret; 12256 12257 if (rte_eth_dev_filter_supported(res->port_id, 12258 RTE_ETH_FILTER_HASH) < 0) { 12259 printf("RTE_ETH_FILTER_HASH not supported on port %d\n", 12260 res->port_id); 12261 return; 12262 } 12263 memset(&info, 0, sizeof(info)); 12264 info.info_type = RTE_ETH_HASH_FILTER_GLOBAL_CONFIG; 12265 if (!strcmp(res->hash_func, "toeplitz")) 12266 info.info.global_conf.hash_func = 12267 RTE_ETH_HASH_FUNCTION_TOEPLITZ; 12268 else if (!strcmp(res->hash_func, "simple_xor")) 12269 info.info.global_conf.hash_func = 12270 RTE_ETH_HASH_FUNCTION_SIMPLE_XOR; 12271 else if (!strcmp(res->hash_func, "symmetric_toeplitz")) 12272 info.info.global_conf.hash_func = 12273 RTE_ETH_HASH_FUNCTION_SYMMETRIC_TOEPLITZ; 12274 else if (!strcmp(res->hash_func, "default")) 12275 info.info.global_conf.hash_func = 12276 RTE_ETH_HASH_FUNCTION_DEFAULT; 12277 12278 ftype = str2flowtype(res->flow_type); 12279 idx = ftype / UINT64_BIT; 12280 offset = ftype % UINT64_BIT; 12281 info.info.global_conf.valid_bit_mask[idx] |= (1ULL << offset); 12282 if (!strcmp(res->enable, "enable")) 12283 info.info.global_conf.sym_hash_enable_mask[idx] |= 12284 (1ULL << offset); 12285 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_HASH, 12286 RTE_ETH_FILTER_SET, &info); 12287 if (ret < 0) 12288 printf("Cannot set global hash configurations by port %d\n", 12289 res->port_id); 12290 else 12291 printf("Global hash configurations have been set " 12292 "successfully by port %d\n", res->port_id); 12293 } 12294 12295 cmdline_parse_token_string_t cmd_set_hash_global_config_all = 12296 TOKEN_STRING_INITIALIZER(struct cmd_set_hash_global_config_result, 12297 set_hash_global_config, "set_hash_global_config"); 12298 cmdline_parse_token_num_t cmd_set_hash_global_config_port_id = 12299 TOKEN_NUM_INITIALIZER(struct cmd_set_hash_global_config_result, 12300 port_id, UINT16); 12301 cmdline_parse_token_string_t cmd_set_hash_global_config_hash_func = 12302 TOKEN_STRING_INITIALIZER(struct cmd_set_hash_global_config_result, 12303 hash_func, "toeplitz#simple_xor#symmetric_toeplitz#default"); 12304 cmdline_parse_token_string_t cmd_set_hash_global_config_flow_type = 12305 TOKEN_STRING_INITIALIZER(struct cmd_set_hash_global_config_result, 12306 flow_type, 12307 "ipv4#ipv4-frag#ipv4-tcp#ipv4-udp#ipv4-sctp#ipv4-other#ipv6#" 12308 "ipv6-frag#ipv6-tcp#ipv6-udp#ipv6-sctp#ipv6-other#l2_payload"); 12309 cmdline_parse_token_string_t cmd_set_hash_global_config_enable = 12310 TOKEN_STRING_INITIALIZER(struct cmd_set_hash_global_config_result, 12311 enable, "enable#disable"); 12312 12313 cmdline_parse_inst_t cmd_set_hash_global_config = { 12314 .f = cmd_set_hash_global_config_parsed, 12315 .data = NULL, 12316 .help_str = "set_hash_global_config <port_id> " 12317 "toeplitz|simple_xor|symmetric_toeplitz|default " 12318 "ipv4|ipv4-frag|ipv4-tcp|ipv4-udp|ipv4-sctp|ipv4-other|" 12319 "ipv6|ipv6-frag|ipv6-tcp|ipv6-udp|ipv6-sctp|ipv6-other|" 12320 "l2_payload enable|disable", 12321 .tokens = { 12322 (void *)&cmd_set_hash_global_config_all, 12323 (void *)&cmd_set_hash_global_config_port_id, 12324 (void *)&cmd_set_hash_global_config_hash_func, 12325 (void *)&cmd_set_hash_global_config_flow_type, 12326 (void *)&cmd_set_hash_global_config_enable, 12327 NULL, 12328 }, 12329 }; 12330 12331 /* Set hash input set */ 12332 struct cmd_set_hash_input_set_result { 12333 cmdline_fixed_string_t set_hash_input_set; 12334 portid_t port_id; 12335 cmdline_fixed_string_t flow_type; 12336 cmdline_fixed_string_t inset_field; 12337 cmdline_fixed_string_t select; 12338 }; 12339 12340 static enum rte_eth_input_set_field 12341 str2inset(char *string) 12342 { 12343 uint16_t i; 12344 12345 static const struct { 12346 char str[32]; 12347 enum rte_eth_input_set_field inset; 12348 } inset_table[] = { 12349 {"ethertype", RTE_ETH_INPUT_SET_L2_ETHERTYPE}, 12350 {"ovlan", RTE_ETH_INPUT_SET_L2_OUTER_VLAN}, 12351 {"ivlan", RTE_ETH_INPUT_SET_L2_INNER_VLAN}, 12352 {"src-ipv4", RTE_ETH_INPUT_SET_L3_SRC_IP4}, 12353 {"dst-ipv4", RTE_ETH_INPUT_SET_L3_DST_IP4}, 12354 {"ipv4-tos", RTE_ETH_INPUT_SET_L3_IP4_TOS}, 12355 {"ipv4-proto", RTE_ETH_INPUT_SET_L3_IP4_PROTO}, 12356 {"ipv4-ttl", RTE_ETH_INPUT_SET_L3_IP4_TTL}, 12357 {"src-ipv6", RTE_ETH_INPUT_SET_L3_SRC_IP6}, 12358 {"dst-ipv6", RTE_ETH_INPUT_SET_L3_DST_IP6}, 12359 {"ipv6-tc", RTE_ETH_INPUT_SET_L3_IP6_TC}, 12360 {"ipv6-next-header", RTE_ETH_INPUT_SET_L3_IP6_NEXT_HEADER}, 12361 {"ipv6-hop-limits", RTE_ETH_INPUT_SET_L3_IP6_HOP_LIMITS}, 12362 {"udp-src-port", RTE_ETH_INPUT_SET_L4_UDP_SRC_PORT}, 12363 {"udp-dst-port", RTE_ETH_INPUT_SET_L4_UDP_DST_PORT}, 12364 {"tcp-src-port", RTE_ETH_INPUT_SET_L4_TCP_SRC_PORT}, 12365 {"tcp-dst-port", RTE_ETH_INPUT_SET_L4_TCP_DST_PORT}, 12366 {"sctp-src-port", RTE_ETH_INPUT_SET_L4_SCTP_SRC_PORT}, 12367 {"sctp-dst-port", RTE_ETH_INPUT_SET_L4_SCTP_DST_PORT}, 12368 {"sctp-veri-tag", RTE_ETH_INPUT_SET_L4_SCTP_VERIFICATION_TAG}, 12369 {"udp-key", RTE_ETH_INPUT_SET_TUNNEL_L4_UDP_KEY}, 12370 {"gre-key", RTE_ETH_INPUT_SET_TUNNEL_GRE_KEY}, 12371 {"fld-1st", RTE_ETH_INPUT_SET_FLEX_PAYLOAD_1ST_WORD}, 12372 {"fld-2nd", RTE_ETH_INPUT_SET_FLEX_PAYLOAD_2ND_WORD}, 12373 {"fld-3rd", RTE_ETH_INPUT_SET_FLEX_PAYLOAD_3RD_WORD}, 12374 {"fld-4th", RTE_ETH_INPUT_SET_FLEX_PAYLOAD_4TH_WORD}, 12375 {"fld-5th", RTE_ETH_INPUT_SET_FLEX_PAYLOAD_5TH_WORD}, 12376 {"fld-6th", RTE_ETH_INPUT_SET_FLEX_PAYLOAD_6TH_WORD}, 12377 {"fld-7th", RTE_ETH_INPUT_SET_FLEX_PAYLOAD_7TH_WORD}, 12378 {"fld-8th", RTE_ETH_INPUT_SET_FLEX_PAYLOAD_8TH_WORD}, 12379 {"none", RTE_ETH_INPUT_SET_NONE}, 12380 }; 12381 12382 for (i = 0; i < RTE_DIM(inset_table); i++) { 12383 if (!strcmp(string, inset_table[i].str)) 12384 return inset_table[i].inset; 12385 } 12386 12387 return RTE_ETH_INPUT_SET_UNKNOWN; 12388 } 12389 12390 static void 12391 cmd_set_hash_input_set_parsed(void *parsed_result, 12392 __rte_unused struct cmdline *cl, 12393 __rte_unused void *data) 12394 { 12395 struct cmd_set_hash_input_set_result *res = parsed_result; 12396 struct rte_eth_hash_filter_info info; 12397 12398 memset(&info, 0, sizeof(info)); 12399 info.info_type = RTE_ETH_HASH_FILTER_INPUT_SET_SELECT; 12400 info.info.input_set_conf.flow_type = str2flowtype(res->flow_type); 12401 info.info.input_set_conf.field[0] = str2inset(res->inset_field); 12402 info.info.input_set_conf.inset_size = 1; 12403 if (!strcmp(res->select, "select")) 12404 info.info.input_set_conf.op = RTE_ETH_INPUT_SET_SELECT; 12405 else if (!strcmp(res->select, "add")) 12406 info.info.input_set_conf.op = RTE_ETH_INPUT_SET_ADD; 12407 rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_HASH, 12408 RTE_ETH_FILTER_SET, &info); 12409 } 12410 12411 cmdline_parse_token_string_t cmd_set_hash_input_set_cmd = 12412 TOKEN_STRING_INITIALIZER(struct cmd_set_hash_input_set_result, 12413 set_hash_input_set, "set_hash_input_set"); 12414 cmdline_parse_token_num_t cmd_set_hash_input_set_port_id = 12415 TOKEN_NUM_INITIALIZER(struct cmd_set_hash_input_set_result, 12416 port_id, UINT16); 12417 cmdline_parse_token_string_t cmd_set_hash_input_set_flow_type = 12418 TOKEN_STRING_INITIALIZER(struct cmd_set_hash_input_set_result, 12419 flow_type, NULL); 12420 cmdline_parse_token_string_t cmd_set_hash_input_set_field = 12421 TOKEN_STRING_INITIALIZER(struct cmd_set_hash_input_set_result, 12422 inset_field, 12423 "ovlan#ivlan#src-ipv4#dst-ipv4#src-ipv6#dst-ipv6#" 12424 "ipv4-tos#ipv4-proto#ipv6-tc#ipv6-next-header#udp-src-port#" 12425 "udp-dst-port#tcp-src-port#tcp-dst-port#sctp-src-port#" 12426 "sctp-dst-port#sctp-veri-tag#udp-key#gre-key#fld-1st#" 12427 "fld-2nd#fld-3rd#fld-4th#fld-5th#fld-6th#fld-7th#" 12428 "fld-8th#none"); 12429 cmdline_parse_token_string_t cmd_set_hash_input_set_select = 12430 TOKEN_STRING_INITIALIZER(struct cmd_set_hash_input_set_result, 12431 select, "select#add"); 12432 12433 cmdline_parse_inst_t cmd_set_hash_input_set = { 12434 .f = cmd_set_hash_input_set_parsed, 12435 .data = NULL, 12436 .help_str = "set_hash_input_set <port_id> " 12437 "ipv4-frag|ipv4-tcp|ipv4-udp|ipv4-sctp|ipv4-other|" 12438 "ipv6-frag|ipv6-tcp|ipv6-udp|ipv6-sctp|ipv6-other|l2_payload|<flowtype_id> " 12439 "ovlan|ivlan|src-ipv4|dst-ipv4|src-ipv6|dst-ipv6|ipv4-tos|ipv4-proto|" 12440 "ipv6-tc|ipv6-next-header|udp-src-port|udp-dst-port|tcp-src-port|" 12441 "tcp-dst-port|sctp-src-port|sctp-dst-port|sctp-veri-tag|udp-key|" 12442 "gre-key|fld-1st|fld-2nd|fld-3rd|fld-4th|fld-5th|fld-6th|" 12443 "fld-7th|fld-8th|none select|add", 12444 .tokens = { 12445 (void *)&cmd_set_hash_input_set_cmd, 12446 (void *)&cmd_set_hash_input_set_port_id, 12447 (void *)&cmd_set_hash_input_set_flow_type, 12448 (void *)&cmd_set_hash_input_set_field, 12449 (void *)&cmd_set_hash_input_set_select, 12450 NULL, 12451 }, 12452 }; 12453 12454 /* Set flow director input set */ 12455 struct cmd_set_fdir_input_set_result { 12456 cmdline_fixed_string_t set_fdir_input_set; 12457 portid_t port_id; 12458 cmdline_fixed_string_t flow_type; 12459 cmdline_fixed_string_t inset_field; 12460 cmdline_fixed_string_t select; 12461 }; 12462 12463 static void 12464 cmd_set_fdir_input_set_parsed(void *parsed_result, 12465 __rte_unused struct cmdline *cl, 12466 __rte_unused void *data) 12467 { 12468 struct cmd_set_fdir_input_set_result *res = parsed_result; 12469 struct rte_eth_fdir_filter_info info; 12470 12471 memset(&info, 0, sizeof(info)); 12472 info.info_type = RTE_ETH_FDIR_FILTER_INPUT_SET_SELECT; 12473 info.info.input_set_conf.flow_type = str2flowtype(res->flow_type); 12474 info.info.input_set_conf.field[0] = str2inset(res->inset_field); 12475 info.info.input_set_conf.inset_size = 1; 12476 if (!strcmp(res->select, "select")) 12477 info.info.input_set_conf.op = RTE_ETH_INPUT_SET_SELECT; 12478 else if (!strcmp(res->select, "add")) 12479 info.info.input_set_conf.op = RTE_ETH_INPUT_SET_ADD; 12480 rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_FDIR, 12481 RTE_ETH_FILTER_SET, &info); 12482 } 12483 12484 cmdline_parse_token_string_t cmd_set_fdir_input_set_cmd = 12485 TOKEN_STRING_INITIALIZER(struct cmd_set_fdir_input_set_result, 12486 set_fdir_input_set, "set_fdir_input_set"); 12487 cmdline_parse_token_num_t cmd_set_fdir_input_set_port_id = 12488 TOKEN_NUM_INITIALIZER(struct cmd_set_fdir_input_set_result, 12489 port_id, UINT16); 12490 cmdline_parse_token_string_t cmd_set_fdir_input_set_flow_type = 12491 TOKEN_STRING_INITIALIZER(struct cmd_set_fdir_input_set_result, 12492 flow_type, 12493 "ipv4-frag#ipv4-tcp#ipv4-udp#ipv4-sctp#ipv4-other#" 12494 "ipv6-frag#ipv6-tcp#ipv6-udp#ipv6-sctp#ipv6-other#l2_payload"); 12495 cmdline_parse_token_string_t cmd_set_fdir_input_set_field = 12496 TOKEN_STRING_INITIALIZER(struct cmd_set_fdir_input_set_result, 12497 inset_field, 12498 "ivlan#ethertype#src-ipv4#dst-ipv4#src-ipv6#dst-ipv6#" 12499 "ipv4-tos#ipv4-proto#ipv4-ttl#ipv6-tc#ipv6-next-header#" 12500 "ipv6-hop-limits#udp-src-port#udp-dst-port#" 12501 "tcp-src-port#tcp-dst-port#sctp-src-port#sctp-dst-port#" 12502 "sctp-veri-tag#none"); 12503 cmdline_parse_token_string_t cmd_set_fdir_input_set_select = 12504 TOKEN_STRING_INITIALIZER(struct cmd_set_fdir_input_set_result, 12505 select, "select#add"); 12506 12507 cmdline_parse_inst_t cmd_set_fdir_input_set = { 12508 .f = cmd_set_fdir_input_set_parsed, 12509 .data = NULL, 12510 .help_str = "set_fdir_input_set <port_id> " 12511 "ipv4-frag|ipv4-tcp|ipv4-udp|ipv4-sctp|ipv4-other|" 12512 "ipv6-frag|ipv6-tcp|ipv6-udp|ipv6-sctp|ipv6-other|l2_payload " 12513 "ivlan|ethertype|src-ipv4|dst-ipv4|src-ipv6|dst-ipv6|" 12514 "ipv4-tos|ipv4-proto|ipv4-ttl|ipv6-tc|ipv6-next-header|" 12515 "ipv6-hop-limits|udp-src-port|udp-dst-port|" 12516 "tcp-src-port|tcp-dst-port|sctp-src-port|sctp-dst-port|" 12517 "sctp-veri-tag|none select|add", 12518 .tokens = { 12519 (void *)&cmd_set_fdir_input_set_cmd, 12520 (void *)&cmd_set_fdir_input_set_port_id, 12521 (void *)&cmd_set_fdir_input_set_flow_type, 12522 (void *)&cmd_set_fdir_input_set_field, 12523 (void *)&cmd_set_fdir_input_set_select, 12524 NULL, 12525 }, 12526 }; 12527 12528 /* *** ADD/REMOVE A MULTICAST MAC ADDRESS TO/FROM A PORT *** */ 12529 struct cmd_mcast_addr_result { 12530 cmdline_fixed_string_t mcast_addr_cmd; 12531 cmdline_fixed_string_t what; 12532 uint16_t port_num; 12533 struct rte_ether_addr mc_addr; 12534 }; 12535 12536 static void cmd_mcast_addr_parsed(void *parsed_result, 12537 __attribute__((unused)) struct cmdline *cl, 12538 __attribute__((unused)) void *data) 12539 { 12540 struct cmd_mcast_addr_result *res = parsed_result; 12541 12542 if (!rte_is_multicast_ether_addr(&res->mc_addr)) { 12543 printf("Invalid multicast addr %02X:%02X:%02X:%02X:%02X:%02X\n", 12544 res->mc_addr.addr_bytes[0], res->mc_addr.addr_bytes[1], 12545 res->mc_addr.addr_bytes[2], res->mc_addr.addr_bytes[3], 12546 res->mc_addr.addr_bytes[4], res->mc_addr.addr_bytes[5]); 12547 return; 12548 } 12549 if (strcmp(res->what, "add") == 0) 12550 mcast_addr_add(res->port_num, &res->mc_addr); 12551 else 12552 mcast_addr_remove(res->port_num, &res->mc_addr); 12553 } 12554 12555 cmdline_parse_token_string_t cmd_mcast_addr_cmd = 12556 TOKEN_STRING_INITIALIZER(struct cmd_mcast_addr_result, 12557 mcast_addr_cmd, "mcast_addr"); 12558 cmdline_parse_token_string_t cmd_mcast_addr_what = 12559 TOKEN_STRING_INITIALIZER(struct cmd_mcast_addr_result, what, 12560 "add#remove"); 12561 cmdline_parse_token_num_t cmd_mcast_addr_portnum = 12562 TOKEN_NUM_INITIALIZER(struct cmd_mcast_addr_result, port_num, UINT16); 12563 cmdline_parse_token_etheraddr_t cmd_mcast_addr_addr = 12564 TOKEN_ETHERADDR_INITIALIZER(struct cmd_mac_addr_result, address); 12565 12566 cmdline_parse_inst_t cmd_mcast_addr = { 12567 .f = cmd_mcast_addr_parsed, 12568 .data = (void *)0, 12569 .help_str = "mcast_addr add|remove <port_id> <mcast_addr>: " 12570 "Add/Remove multicast MAC address on port_id", 12571 .tokens = { 12572 (void *)&cmd_mcast_addr_cmd, 12573 (void *)&cmd_mcast_addr_what, 12574 (void *)&cmd_mcast_addr_portnum, 12575 (void *)&cmd_mcast_addr_addr, 12576 NULL, 12577 }, 12578 }; 12579 12580 /* l2 tunnel config 12581 * only support E-tag now. 12582 */ 12583 12584 /* Ether type config */ 12585 struct cmd_config_l2_tunnel_eth_type_result { 12586 cmdline_fixed_string_t port; 12587 cmdline_fixed_string_t config; 12588 cmdline_fixed_string_t all; 12589 portid_t id; 12590 cmdline_fixed_string_t l2_tunnel; 12591 cmdline_fixed_string_t l2_tunnel_type; 12592 cmdline_fixed_string_t eth_type; 12593 uint16_t eth_type_val; 12594 }; 12595 12596 cmdline_parse_token_string_t cmd_config_l2_tunnel_eth_type_port = 12597 TOKEN_STRING_INITIALIZER 12598 (struct cmd_config_l2_tunnel_eth_type_result, 12599 port, "port"); 12600 cmdline_parse_token_string_t cmd_config_l2_tunnel_eth_type_config = 12601 TOKEN_STRING_INITIALIZER 12602 (struct cmd_config_l2_tunnel_eth_type_result, 12603 config, "config"); 12604 cmdline_parse_token_string_t cmd_config_l2_tunnel_eth_type_all_str = 12605 TOKEN_STRING_INITIALIZER 12606 (struct cmd_config_l2_tunnel_eth_type_result, 12607 all, "all"); 12608 cmdline_parse_token_num_t cmd_config_l2_tunnel_eth_type_id = 12609 TOKEN_NUM_INITIALIZER 12610 (struct cmd_config_l2_tunnel_eth_type_result, 12611 id, UINT16); 12612 cmdline_parse_token_string_t cmd_config_l2_tunnel_eth_type_l2_tunnel = 12613 TOKEN_STRING_INITIALIZER 12614 (struct cmd_config_l2_tunnel_eth_type_result, 12615 l2_tunnel, "l2-tunnel"); 12616 cmdline_parse_token_string_t cmd_config_l2_tunnel_eth_type_l2_tunnel_type = 12617 TOKEN_STRING_INITIALIZER 12618 (struct cmd_config_l2_tunnel_eth_type_result, 12619 l2_tunnel_type, "E-tag"); 12620 cmdline_parse_token_string_t cmd_config_l2_tunnel_eth_type_eth_type = 12621 TOKEN_STRING_INITIALIZER 12622 (struct cmd_config_l2_tunnel_eth_type_result, 12623 eth_type, "ether-type"); 12624 cmdline_parse_token_num_t cmd_config_l2_tunnel_eth_type_eth_type_val = 12625 TOKEN_NUM_INITIALIZER 12626 (struct cmd_config_l2_tunnel_eth_type_result, 12627 eth_type_val, UINT16); 12628 12629 static enum rte_eth_tunnel_type 12630 str2fdir_l2_tunnel_type(char *string) 12631 { 12632 uint32_t i = 0; 12633 12634 static const struct { 12635 char str[32]; 12636 enum rte_eth_tunnel_type type; 12637 } l2_tunnel_type_str[] = { 12638 {"E-tag", RTE_L2_TUNNEL_TYPE_E_TAG}, 12639 }; 12640 12641 for (i = 0; i < RTE_DIM(l2_tunnel_type_str); i++) { 12642 if (!strcmp(l2_tunnel_type_str[i].str, string)) 12643 return l2_tunnel_type_str[i].type; 12644 } 12645 return RTE_TUNNEL_TYPE_NONE; 12646 } 12647 12648 /* ether type config for all ports */ 12649 static void 12650 cmd_config_l2_tunnel_eth_type_all_parsed 12651 (void *parsed_result, 12652 __attribute__((unused)) struct cmdline *cl, 12653 __attribute__((unused)) void *data) 12654 { 12655 struct cmd_config_l2_tunnel_eth_type_result *res = parsed_result; 12656 struct rte_eth_l2_tunnel_conf entry; 12657 portid_t pid; 12658 12659 entry.l2_tunnel_type = str2fdir_l2_tunnel_type(res->l2_tunnel_type); 12660 entry.ether_type = res->eth_type_val; 12661 12662 RTE_ETH_FOREACH_DEV(pid) { 12663 rte_eth_dev_l2_tunnel_eth_type_conf(pid, &entry); 12664 } 12665 } 12666 12667 cmdline_parse_inst_t cmd_config_l2_tunnel_eth_type_all = { 12668 .f = cmd_config_l2_tunnel_eth_type_all_parsed, 12669 .data = NULL, 12670 .help_str = "port config all l2-tunnel E-tag ether-type <value>", 12671 .tokens = { 12672 (void *)&cmd_config_l2_tunnel_eth_type_port, 12673 (void *)&cmd_config_l2_tunnel_eth_type_config, 12674 (void *)&cmd_config_l2_tunnel_eth_type_all_str, 12675 (void *)&cmd_config_l2_tunnel_eth_type_l2_tunnel, 12676 (void *)&cmd_config_l2_tunnel_eth_type_l2_tunnel_type, 12677 (void *)&cmd_config_l2_tunnel_eth_type_eth_type, 12678 (void *)&cmd_config_l2_tunnel_eth_type_eth_type_val, 12679 NULL, 12680 }, 12681 }; 12682 12683 /* ether type config for a specific port */ 12684 static void 12685 cmd_config_l2_tunnel_eth_type_specific_parsed( 12686 void *parsed_result, 12687 __attribute__((unused)) struct cmdline *cl, 12688 __attribute__((unused)) void *data) 12689 { 12690 struct cmd_config_l2_tunnel_eth_type_result *res = 12691 parsed_result; 12692 struct rte_eth_l2_tunnel_conf entry; 12693 12694 if (port_id_is_invalid(res->id, ENABLED_WARN)) 12695 return; 12696 12697 entry.l2_tunnel_type = str2fdir_l2_tunnel_type(res->l2_tunnel_type); 12698 entry.ether_type = res->eth_type_val; 12699 12700 rte_eth_dev_l2_tunnel_eth_type_conf(res->id, &entry); 12701 } 12702 12703 cmdline_parse_inst_t cmd_config_l2_tunnel_eth_type_specific = { 12704 .f = cmd_config_l2_tunnel_eth_type_specific_parsed, 12705 .data = NULL, 12706 .help_str = "port config <port_id> l2-tunnel E-tag ether-type <value>", 12707 .tokens = { 12708 (void *)&cmd_config_l2_tunnel_eth_type_port, 12709 (void *)&cmd_config_l2_tunnel_eth_type_config, 12710 (void *)&cmd_config_l2_tunnel_eth_type_id, 12711 (void *)&cmd_config_l2_tunnel_eth_type_l2_tunnel, 12712 (void *)&cmd_config_l2_tunnel_eth_type_l2_tunnel_type, 12713 (void *)&cmd_config_l2_tunnel_eth_type_eth_type, 12714 (void *)&cmd_config_l2_tunnel_eth_type_eth_type_val, 12715 NULL, 12716 }, 12717 }; 12718 12719 /* Enable/disable l2 tunnel */ 12720 struct cmd_config_l2_tunnel_en_dis_result { 12721 cmdline_fixed_string_t port; 12722 cmdline_fixed_string_t config; 12723 cmdline_fixed_string_t all; 12724 portid_t id; 12725 cmdline_fixed_string_t l2_tunnel; 12726 cmdline_fixed_string_t l2_tunnel_type; 12727 cmdline_fixed_string_t en_dis; 12728 }; 12729 12730 cmdline_parse_token_string_t cmd_config_l2_tunnel_en_dis_port = 12731 TOKEN_STRING_INITIALIZER 12732 (struct cmd_config_l2_tunnel_en_dis_result, 12733 port, "port"); 12734 cmdline_parse_token_string_t cmd_config_l2_tunnel_en_dis_config = 12735 TOKEN_STRING_INITIALIZER 12736 (struct cmd_config_l2_tunnel_en_dis_result, 12737 config, "config"); 12738 cmdline_parse_token_string_t cmd_config_l2_tunnel_en_dis_all_str = 12739 TOKEN_STRING_INITIALIZER 12740 (struct cmd_config_l2_tunnel_en_dis_result, 12741 all, "all"); 12742 cmdline_parse_token_num_t cmd_config_l2_tunnel_en_dis_id = 12743 TOKEN_NUM_INITIALIZER 12744 (struct cmd_config_l2_tunnel_en_dis_result, 12745 id, UINT16); 12746 cmdline_parse_token_string_t cmd_config_l2_tunnel_en_dis_l2_tunnel = 12747 TOKEN_STRING_INITIALIZER 12748 (struct cmd_config_l2_tunnel_en_dis_result, 12749 l2_tunnel, "l2-tunnel"); 12750 cmdline_parse_token_string_t cmd_config_l2_tunnel_en_dis_l2_tunnel_type = 12751 TOKEN_STRING_INITIALIZER 12752 (struct cmd_config_l2_tunnel_en_dis_result, 12753 l2_tunnel_type, "E-tag"); 12754 cmdline_parse_token_string_t cmd_config_l2_tunnel_en_dis_en_dis = 12755 TOKEN_STRING_INITIALIZER 12756 (struct cmd_config_l2_tunnel_en_dis_result, 12757 en_dis, "enable#disable"); 12758 12759 /* enable/disable l2 tunnel for all ports */ 12760 static void 12761 cmd_config_l2_tunnel_en_dis_all_parsed( 12762 void *parsed_result, 12763 __attribute__((unused)) struct cmdline *cl, 12764 __attribute__((unused)) void *data) 12765 { 12766 struct cmd_config_l2_tunnel_en_dis_result *res = parsed_result; 12767 struct rte_eth_l2_tunnel_conf entry; 12768 portid_t pid; 12769 uint8_t en; 12770 12771 entry.l2_tunnel_type = str2fdir_l2_tunnel_type(res->l2_tunnel_type); 12772 12773 if (!strcmp("enable", res->en_dis)) 12774 en = 1; 12775 else 12776 en = 0; 12777 12778 RTE_ETH_FOREACH_DEV(pid) { 12779 rte_eth_dev_l2_tunnel_offload_set(pid, 12780 &entry, 12781 ETH_L2_TUNNEL_ENABLE_MASK, 12782 en); 12783 } 12784 } 12785 12786 cmdline_parse_inst_t cmd_config_l2_tunnel_en_dis_all = { 12787 .f = cmd_config_l2_tunnel_en_dis_all_parsed, 12788 .data = NULL, 12789 .help_str = "port config all l2-tunnel E-tag enable|disable", 12790 .tokens = { 12791 (void *)&cmd_config_l2_tunnel_en_dis_port, 12792 (void *)&cmd_config_l2_tunnel_en_dis_config, 12793 (void *)&cmd_config_l2_tunnel_en_dis_all_str, 12794 (void *)&cmd_config_l2_tunnel_en_dis_l2_tunnel, 12795 (void *)&cmd_config_l2_tunnel_en_dis_l2_tunnel_type, 12796 (void *)&cmd_config_l2_tunnel_en_dis_en_dis, 12797 NULL, 12798 }, 12799 }; 12800 12801 /* enable/disable l2 tunnel for a port */ 12802 static void 12803 cmd_config_l2_tunnel_en_dis_specific_parsed( 12804 void *parsed_result, 12805 __attribute__((unused)) struct cmdline *cl, 12806 __attribute__((unused)) void *data) 12807 { 12808 struct cmd_config_l2_tunnel_en_dis_result *res = 12809 parsed_result; 12810 struct rte_eth_l2_tunnel_conf entry; 12811 12812 if (port_id_is_invalid(res->id, ENABLED_WARN)) 12813 return; 12814 12815 entry.l2_tunnel_type = str2fdir_l2_tunnel_type(res->l2_tunnel_type); 12816 12817 if (!strcmp("enable", res->en_dis)) 12818 rte_eth_dev_l2_tunnel_offload_set(res->id, 12819 &entry, 12820 ETH_L2_TUNNEL_ENABLE_MASK, 12821 1); 12822 else 12823 rte_eth_dev_l2_tunnel_offload_set(res->id, 12824 &entry, 12825 ETH_L2_TUNNEL_ENABLE_MASK, 12826 0); 12827 } 12828 12829 cmdline_parse_inst_t cmd_config_l2_tunnel_en_dis_specific = { 12830 .f = cmd_config_l2_tunnel_en_dis_specific_parsed, 12831 .data = NULL, 12832 .help_str = "port config <port_id> l2-tunnel E-tag enable|disable", 12833 .tokens = { 12834 (void *)&cmd_config_l2_tunnel_en_dis_port, 12835 (void *)&cmd_config_l2_tunnel_en_dis_config, 12836 (void *)&cmd_config_l2_tunnel_en_dis_id, 12837 (void *)&cmd_config_l2_tunnel_en_dis_l2_tunnel, 12838 (void *)&cmd_config_l2_tunnel_en_dis_l2_tunnel_type, 12839 (void *)&cmd_config_l2_tunnel_en_dis_en_dis, 12840 NULL, 12841 }, 12842 }; 12843 12844 /* E-tag configuration */ 12845 12846 /* Common result structure for all E-tag configuration */ 12847 struct cmd_config_e_tag_result { 12848 cmdline_fixed_string_t e_tag; 12849 cmdline_fixed_string_t set; 12850 cmdline_fixed_string_t insertion; 12851 cmdline_fixed_string_t stripping; 12852 cmdline_fixed_string_t forwarding; 12853 cmdline_fixed_string_t filter; 12854 cmdline_fixed_string_t add; 12855 cmdline_fixed_string_t del; 12856 cmdline_fixed_string_t on; 12857 cmdline_fixed_string_t off; 12858 cmdline_fixed_string_t on_off; 12859 cmdline_fixed_string_t port_tag_id; 12860 uint32_t port_tag_id_val; 12861 cmdline_fixed_string_t e_tag_id; 12862 uint16_t e_tag_id_val; 12863 cmdline_fixed_string_t dst_pool; 12864 uint8_t dst_pool_val; 12865 cmdline_fixed_string_t port; 12866 portid_t port_id; 12867 cmdline_fixed_string_t vf; 12868 uint8_t vf_id; 12869 }; 12870 12871 /* Common CLI fields for all E-tag configuration */ 12872 cmdline_parse_token_string_t cmd_config_e_tag_e_tag = 12873 TOKEN_STRING_INITIALIZER 12874 (struct cmd_config_e_tag_result, 12875 e_tag, "E-tag"); 12876 cmdline_parse_token_string_t cmd_config_e_tag_set = 12877 TOKEN_STRING_INITIALIZER 12878 (struct cmd_config_e_tag_result, 12879 set, "set"); 12880 cmdline_parse_token_string_t cmd_config_e_tag_insertion = 12881 TOKEN_STRING_INITIALIZER 12882 (struct cmd_config_e_tag_result, 12883 insertion, "insertion"); 12884 cmdline_parse_token_string_t cmd_config_e_tag_stripping = 12885 TOKEN_STRING_INITIALIZER 12886 (struct cmd_config_e_tag_result, 12887 stripping, "stripping"); 12888 cmdline_parse_token_string_t cmd_config_e_tag_forwarding = 12889 TOKEN_STRING_INITIALIZER 12890 (struct cmd_config_e_tag_result, 12891 forwarding, "forwarding"); 12892 cmdline_parse_token_string_t cmd_config_e_tag_filter = 12893 TOKEN_STRING_INITIALIZER 12894 (struct cmd_config_e_tag_result, 12895 filter, "filter"); 12896 cmdline_parse_token_string_t cmd_config_e_tag_add = 12897 TOKEN_STRING_INITIALIZER 12898 (struct cmd_config_e_tag_result, 12899 add, "add"); 12900 cmdline_parse_token_string_t cmd_config_e_tag_del = 12901 TOKEN_STRING_INITIALIZER 12902 (struct cmd_config_e_tag_result, 12903 del, "del"); 12904 cmdline_parse_token_string_t cmd_config_e_tag_on = 12905 TOKEN_STRING_INITIALIZER 12906 (struct cmd_config_e_tag_result, 12907 on, "on"); 12908 cmdline_parse_token_string_t cmd_config_e_tag_off = 12909 TOKEN_STRING_INITIALIZER 12910 (struct cmd_config_e_tag_result, 12911 off, "off"); 12912 cmdline_parse_token_string_t cmd_config_e_tag_on_off = 12913 TOKEN_STRING_INITIALIZER 12914 (struct cmd_config_e_tag_result, 12915 on_off, "on#off"); 12916 cmdline_parse_token_string_t cmd_config_e_tag_port_tag_id = 12917 TOKEN_STRING_INITIALIZER 12918 (struct cmd_config_e_tag_result, 12919 port_tag_id, "port-tag-id"); 12920 cmdline_parse_token_num_t cmd_config_e_tag_port_tag_id_val = 12921 TOKEN_NUM_INITIALIZER 12922 (struct cmd_config_e_tag_result, 12923 port_tag_id_val, UINT32); 12924 cmdline_parse_token_string_t cmd_config_e_tag_e_tag_id = 12925 TOKEN_STRING_INITIALIZER 12926 (struct cmd_config_e_tag_result, 12927 e_tag_id, "e-tag-id"); 12928 cmdline_parse_token_num_t cmd_config_e_tag_e_tag_id_val = 12929 TOKEN_NUM_INITIALIZER 12930 (struct cmd_config_e_tag_result, 12931 e_tag_id_val, UINT16); 12932 cmdline_parse_token_string_t cmd_config_e_tag_dst_pool = 12933 TOKEN_STRING_INITIALIZER 12934 (struct cmd_config_e_tag_result, 12935 dst_pool, "dst-pool"); 12936 cmdline_parse_token_num_t cmd_config_e_tag_dst_pool_val = 12937 TOKEN_NUM_INITIALIZER 12938 (struct cmd_config_e_tag_result, 12939 dst_pool_val, UINT8); 12940 cmdline_parse_token_string_t cmd_config_e_tag_port = 12941 TOKEN_STRING_INITIALIZER 12942 (struct cmd_config_e_tag_result, 12943 port, "port"); 12944 cmdline_parse_token_num_t cmd_config_e_tag_port_id = 12945 TOKEN_NUM_INITIALIZER 12946 (struct cmd_config_e_tag_result, 12947 port_id, UINT16); 12948 cmdline_parse_token_string_t cmd_config_e_tag_vf = 12949 TOKEN_STRING_INITIALIZER 12950 (struct cmd_config_e_tag_result, 12951 vf, "vf"); 12952 cmdline_parse_token_num_t cmd_config_e_tag_vf_id = 12953 TOKEN_NUM_INITIALIZER 12954 (struct cmd_config_e_tag_result, 12955 vf_id, UINT8); 12956 12957 /* E-tag insertion configuration */ 12958 static void 12959 cmd_config_e_tag_insertion_en_parsed( 12960 void *parsed_result, 12961 __attribute__((unused)) struct cmdline *cl, 12962 __attribute__((unused)) void *data) 12963 { 12964 struct cmd_config_e_tag_result *res = 12965 parsed_result; 12966 struct rte_eth_l2_tunnel_conf entry; 12967 12968 if (port_id_is_invalid(res->port_id, ENABLED_WARN)) 12969 return; 12970 12971 entry.l2_tunnel_type = RTE_L2_TUNNEL_TYPE_E_TAG; 12972 entry.tunnel_id = res->port_tag_id_val; 12973 entry.vf_id = res->vf_id; 12974 rte_eth_dev_l2_tunnel_offload_set(res->port_id, 12975 &entry, 12976 ETH_L2_TUNNEL_INSERTION_MASK, 12977 1); 12978 } 12979 12980 static void 12981 cmd_config_e_tag_insertion_dis_parsed( 12982 void *parsed_result, 12983 __attribute__((unused)) struct cmdline *cl, 12984 __attribute__((unused)) void *data) 12985 { 12986 struct cmd_config_e_tag_result *res = 12987 parsed_result; 12988 struct rte_eth_l2_tunnel_conf entry; 12989 12990 if (port_id_is_invalid(res->port_id, ENABLED_WARN)) 12991 return; 12992 12993 entry.l2_tunnel_type = RTE_L2_TUNNEL_TYPE_E_TAG; 12994 entry.vf_id = res->vf_id; 12995 12996 rte_eth_dev_l2_tunnel_offload_set(res->port_id, 12997 &entry, 12998 ETH_L2_TUNNEL_INSERTION_MASK, 12999 0); 13000 } 13001 13002 cmdline_parse_inst_t cmd_config_e_tag_insertion_en = { 13003 .f = cmd_config_e_tag_insertion_en_parsed, 13004 .data = NULL, 13005 .help_str = "E-tag ... : E-tag insertion enable", 13006 .tokens = { 13007 (void *)&cmd_config_e_tag_e_tag, 13008 (void *)&cmd_config_e_tag_set, 13009 (void *)&cmd_config_e_tag_insertion, 13010 (void *)&cmd_config_e_tag_on, 13011 (void *)&cmd_config_e_tag_port_tag_id, 13012 (void *)&cmd_config_e_tag_port_tag_id_val, 13013 (void *)&cmd_config_e_tag_port, 13014 (void *)&cmd_config_e_tag_port_id, 13015 (void *)&cmd_config_e_tag_vf, 13016 (void *)&cmd_config_e_tag_vf_id, 13017 NULL, 13018 }, 13019 }; 13020 13021 cmdline_parse_inst_t cmd_config_e_tag_insertion_dis = { 13022 .f = cmd_config_e_tag_insertion_dis_parsed, 13023 .data = NULL, 13024 .help_str = "E-tag ... : E-tag insertion disable", 13025 .tokens = { 13026 (void *)&cmd_config_e_tag_e_tag, 13027 (void *)&cmd_config_e_tag_set, 13028 (void *)&cmd_config_e_tag_insertion, 13029 (void *)&cmd_config_e_tag_off, 13030 (void *)&cmd_config_e_tag_port, 13031 (void *)&cmd_config_e_tag_port_id, 13032 (void *)&cmd_config_e_tag_vf, 13033 (void *)&cmd_config_e_tag_vf_id, 13034 NULL, 13035 }, 13036 }; 13037 13038 /* E-tag stripping configuration */ 13039 static void 13040 cmd_config_e_tag_stripping_parsed( 13041 void *parsed_result, 13042 __attribute__((unused)) struct cmdline *cl, 13043 __attribute__((unused)) void *data) 13044 { 13045 struct cmd_config_e_tag_result *res = 13046 parsed_result; 13047 struct rte_eth_l2_tunnel_conf entry; 13048 13049 if (port_id_is_invalid(res->port_id, ENABLED_WARN)) 13050 return; 13051 13052 entry.l2_tunnel_type = RTE_L2_TUNNEL_TYPE_E_TAG; 13053 13054 if (!strcmp(res->on_off, "on")) 13055 rte_eth_dev_l2_tunnel_offload_set 13056 (res->port_id, 13057 &entry, 13058 ETH_L2_TUNNEL_STRIPPING_MASK, 13059 1); 13060 else 13061 rte_eth_dev_l2_tunnel_offload_set 13062 (res->port_id, 13063 &entry, 13064 ETH_L2_TUNNEL_STRIPPING_MASK, 13065 0); 13066 } 13067 13068 cmdline_parse_inst_t cmd_config_e_tag_stripping_en_dis = { 13069 .f = cmd_config_e_tag_stripping_parsed, 13070 .data = NULL, 13071 .help_str = "E-tag ... : E-tag stripping enable/disable", 13072 .tokens = { 13073 (void *)&cmd_config_e_tag_e_tag, 13074 (void *)&cmd_config_e_tag_set, 13075 (void *)&cmd_config_e_tag_stripping, 13076 (void *)&cmd_config_e_tag_on_off, 13077 (void *)&cmd_config_e_tag_port, 13078 (void *)&cmd_config_e_tag_port_id, 13079 NULL, 13080 }, 13081 }; 13082 13083 /* E-tag forwarding configuration */ 13084 static void 13085 cmd_config_e_tag_forwarding_parsed( 13086 void *parsed_result, 13087 __attribute__((unused)) struct cmdline *cl, 13088 __attribute__((unused)) void *data) 13089 { 13090 struct cmd_config_e_tag_result *res = parsed_result; 13091 struct rte_eth_l2_tunnel_conf entry; 13092 13093 if (port_id_is_invalid(res->port_id, ENABLED_WARN)) 13094 return; 13095 13096 entry.l2_tunnel_type = RTE_L2_TUNNEL_TYPE_E_TAG; 13097 13098 if (!strcmp(res->on_off, "on")) 13099 rte_eth_dev_l2_tunnel_offload_set 13100 (res->port_id, 13101 &entry, 13102 ETH_L2_TUNNEL_FORWARDING_MASK, 13103 1); 13104 else 13105 rte_eth_dev_l2_tunnel_offload_set 13106 (res->port_id, 13107 &entry, 13108 ETH_L2_TUNNEL_FORWARDING_MASK, 13109 0); 13110 } 13111 13112 cmdline_parse_inst_t cmd_config_e_tag_forwarding_en_dis = { 13113 .f = cmd_config_e_tag_forwarding_parsed, 13114 .data = NULL, 13115 .help_str = "E-tag ... : E-tag forwarding enable/disable", 13116 .tokens = { 13117 (void *)&cmd_config_e_tag_e_tag, 13118 (void *)&cmd_config_e_tag_set, 13119 (void *)&cmd_config_e_tag_forwarding, 13120 (void *)&cmd_config_e_tag_on_off, 13121 (void *)&cmd_config_e_tag_port, 13122 (void *)&cmd_config_e_tag_port_id, 13123 NULL, 13124 }, 13125 }; 13126 13127 /* E-tag filter configuration */ 13128 static void 13129 cmd_config_e_tag_filter_add_parsed( 13130 void *parsed_result, 13131 __attribute__((unused)) struct cmdline *cl, 13132 __attribute__((unused)) void *data) 13133 { 13134 struct cmd_config_e_tag_result *res = parsed_result; 13135 struct rte_eth_l2_tunnel_conf entry; 13136 int ret = 0; 13137 13138 if (port_id_is_invalid(res->port_id, ENABLED_WARN)) 13139 return; 13140 13141 if (res->e_tag_id_val > 0x3fff) { 13142 printf("e-tag-id must be equal or less than 0x3fff.\n"); 13143 return; 13144 } 13145 13146 ret = rte_eth_dev_filter_supported(res->port_id, 13147 RTE_ETH_FILTER_L2_TUNNEL); 13148 if (ret < 0) { 13149 printf("E-tag filter is not supported on port %u.\n", 13150 res->port_id); 13151 return; 13152 } 13153 13154 entry.l2_tunnel_type = RTE_L2_TUNNEL_TYPE_E_TAG; 13155 entry.tunnel_id = res->e_tag_id_val; 13156 entry.pool = res->dst_pool_val; 13157 13158 ret = rte_eth_dev_filter_ctrl(res->port_id, 13159 RTE_ETH_FILTER_L2_TUNNEL, 13160 RTE_ETH_FILTER_ADD, 13161 &entry); 13162 if (ret < 0) 13163 printf("E-tag filter programming error: (%s)\n", 13164 strerror(-ret)); 13165 } 13166 13167 cmdline_parse_inst_t cmd_config_e_tag_filter_add = { 13168 .f = cmd_config_e_tag_filter_add_parsed, 13169 .data = NULL, 13170 .help_str = "E-tag ... : E-tag filter add", 13171 .tokens = { 13172 (void *)&cmd_config_e_tag_e_tag, 13173 (void *)&cmd_config_e_tag_set, 13174 (void *)&cmd_config_e_tag_filter, 13175 (void *)&cmd_config_e_tag_add, 13176 (void *)&cmd_config_e_tag_e_tag_id, 13177 (void *)&cmd_config_e_tag_e_tag_id_val, 13178 (void *)&cmd_config_e_tag_dst_pool, 13179 (void *)&cmd_config_e_tag_dst_pool_val, 13180 (void *)&cmd_config_e_tag_port, 13181 (void *)&cmd_config_e_tag_port_id, 13182 NULL, 13183 }, 13184 }; 13185 13186 static void 13187 cmd_config_e_tag_filter_del_parsed( 13188 void *parsed_result, 13189 __attribute__((unused)) struct cmdline *cl, 13190 __attribute__((unused)) void *data) 13191 { 13192 struct cmd_config_e_tag_result *res = parsed_result; 13193 struct rte_eth_l2_tunnel_conf entry; 13194 int ret = 0; 13195 13196 if (port_id_is_invalid(res->port_id, ENABLED_WARN)) 13197 return; 13198 13199 if (res->e_tag_id_val > 0x3fff) { 13200 printf("e-tag-id must be less than 0x3fff.\n"); 13201 return; 13202 } 13203 13204 ret = rte_eth_dev_filter_supported(res->port_id, 13205 RTE_ETH_FILTER_L2_TUNNEL); 13206 if (ret < 0) { 13207 printf("E-tag filter is not supported on port %u.\n", 13208 res->port_id); 13209 return; 13210 } 13211 13212 entry.l2_tunnel_type = RTE_L2_TUNNEL_TYPE_E_TAG; 13213 entry.tunnel_id = res->e_tag_id_val; 13214 13215 ret = rte_eth_dev_filter_ctrl(res->port_id, 13216 RTE_ETH_FILTER_L2_TUNNEL, 13217 RTE_ETH_FILTER_DELETE, 13218 &entry); 13219 if (ret < 0) 13220 printf("E-tag filter programming error: (%s)\n", 13221 strerror(-ret)); 13222 } 13223 13224 cmdline_parse_inst_t cmd_config_e_tag_filter_del = { 13225 .f = cmd_config_e_tag_filter_del_parsed, 13226 .data = NULL, 13227 .help_str = "E-tag ... : E-tag filter delete", 13228 .tokens = { 13229 (void *)&cmd_config_e_tag_e_tag, 13230 (void *)&cmd_config_e_tag_set, 13231 (void *)&cmd_config_e_tag_filter, 13232 (void *)&cmd_config_e_tag_del, 13233 (void *)&cmd_config_e_tag_e_tag_id, 13234 (void *)&cmd_config_e_tag_e_tag_id_val, 13235 (void *)&cmd_config_e_tag_port, 13236 (void *)&cmd_config_e_tag_port_id, 13237 NULL, 13238 }, 13239 }; 13240 13241 /* vf vlan anti spoof configuration */ 13242 13243 /* Common result structure for vf vlan anti spoof */ 13244 struct cmd_vf_vlan_anti_spoof_result { 13245 cmdline_fixed_string_t set; 13246 cmdline_fixed_string_t vf; 13247 cmdline_fixed_string_t vlan; 13248 cmdline_fixed_string_t antispoof; 13249 portid_t port_id; 13250 uint32_t vf_id; 13251 cmdline_fixed_string_t on_off; 13252 }; 13253 13254 /* Common CLI fields for vf vlan anti spoof enable disable */ 13255 cmdline_parse_token_string_t cmd_vf_vlan_anti_spoof_set = 13256 TOKEN_STRING_INITIALIZER 13257 (struct cmd_vf_vlan_anti_spoof_result, 13258 set, "set"); 13259 cmdline_parse_token_string_t cmd_vf_vlan_anti_spoof_vf = 13260 TOKEN_STRING_INITIALIZER 13261 (struct cmd_vf_vlan_anti_spoof_result, 13262 vf, "vf"); 13263 cmdline_parse_token_string_t cmd_vf_vlan_anti_spoof_vlan = 13264 TOKEN_STRING_INITIALIZER 13265 (struct cmd_vf_vlan_anti_spoof_result, 13266 vlan, "vlan"); 13267 cmdline_parse_token_string_t cmd_vf_vlan_anti_spoof_antispoof = 13268 TOKEN_STRING_INITIALIZER 13269 (struct cmd_vf_vlan_anti_spoof_result, 13270 antispoof, "antispoof"); 13271 cmdline_parse_token_num_t cmd_vf_vlan_anti_spoof_port_id = 13272 TOKEN_NUM_INITIALIZER 13273 (struct cmd_vf_vlan_anti_spoof_result, 13274 port_id, UINT16); 13275 cmdline_parse_token_num_t cmd_vf_vlan_anti_spoof_vf_id = 13276 TOKEN_NUM_INITIALIZER 13277 (struct cmd_vf_vlan_anti_spoof_result, 13278 vf_id, UINT32); 13279 cmdline_parse_token_string_t cmd_vf_vlan_anti_spoof_on_off = 13280 TOKEN_STRING_INITIALIZER 13281 (struct cmd_vf_vlan_anti_spoof_result, 13282 on_off, "on#off"); 13283 13284 static void 13285 cmd_set_vf_vlan_anti_spoof_parsed( 13286 void *parsed_result, 13287 __attribute__((unused)) struct cmdline *cl, 13288 __attribute__((unused)) void *data) 13289 { 13290 struct cmd_vf_vlan_anti_spoof_result *res = parsed_result; 13291 int ret = -ENOTSUP; 13292 13293 __rte_unused int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0; 13294 13295 if (port_id_is_invalid(res->port_id, ENABLED_WARN)) 13296 return; 13297 13298 #ifdef RTE_LIBRTE_IXGBE_PMD 13299 if (ret == -ENOTSUP) 13300 ret = rte_pmd_ixgbe_set_vf_vlan_anti_spoof(res->port_id, 13301 res->vf_id, is_on); 13302 #endif 13303 #ifdef RTE_LIBRTE_I40E_PMD 13304 if (ret == -ENOTSUP) 13305 ret = rte_pmd_i40e_set_vf_vlan_anti_spoof(res->port_id, 13306 res->vf_id, is_on); 13307 #endif 13308 #ifdef RTE_LIBRTE_BNXT_PMD 13309 if (ret == -ENOTSUP) 13310 ret = rte_pmd_bnxt_set_vf_vlan_anti_spoof(res->port_id, 13311 res->vf_id, is_on); 13312 #endif 13313 13314 switch (ret) { 13315 case 0: 13316 break; 13317 case -EINVAL: 13318 printf("invalid vf_id %d\n", res->vf_id); 13319 break; 13320 case -ENODEV: 13321 printf("invalid port_id %d\n", res->port_id); 13322 break; 13323 case -ENOTSUP: 13324 printf("function not implemented\n"); 13325 break; 13326 default: 13327 printf("programming error: (%s)\n", strerror(-ret)); 13328 } 13329 } 13330 13331 cmdline_parse_inst_t cmd_set_vf_vlan_anti_spoof = { 13332 .f = cmd_set_vf_vlan_anti_spoof_parsed, 13333 .data = NULL, 13334 .help_str = "set vf vlan antispoof <port_id> <vf_id> on|off", 13335 .tokens = { 13336 (void *)&cmd_vf_vlan_anti_spoof_set, 13337 (void *)&cmd_vf_vlan_anti_spoof_vf, 13338 (void *)&cmd_vf_vlan_anti_spoof_vlan, 13339 (void *)&cmd_vf_vlan_anti_spoof_antispoof, 13340 (void *)&cmd_vf_vlan_anti_spoof_port_id, 13341 (void *)&cmd_vf_vlan_anti_spoof_vf_id, 13342 (void *)&cmd_vf_vlan_anti_spoof_on_off, 13343 NULL, 13344 }, 13345 }; 13346 13347 /* vf mac anti spoof configuration */ 13348 13349 /* Common result structure for vf mac anti spoof */ 13350 struct cmd_vf_mac_anti_spoof_result { 13351 cmdline_fixed_string_t set; 13352 cmdline_fixed_string_t vf; 13353 cmdline_fixed_string_t mac; 13354 cmdline_fixed_string_t antispoof; 13355 portid_t port_id; 13356 uint32_t vf_id; 13357 cmdline_fixed_string_t on_off; 13358 }; 13359 13360 /* Common CLI fields for vf mac anti spoof enable disable */ 13361 cmdline_parse_token_string_t cmd_vf_mac_anti_spoof_set = 13362 TOKEN_STRING_INITIALIZER 13363 (struct cmd_vf_mac_anti_spoof_result, 13364 set, "set"); 13365 cmdline_parse_token_string_t cmd_vf_mac_anti_spoof_vf = 13366 TOKEN_STRING_INITIALIZER 13367 (struct cmd_vf_mac_anti_spoof_result, 13368 vf, "vf"); 13369 cmdline_parse_token_string_t cmd_vf_mac_anti_spoof_mac = 13370 TOKEN_STRING_INITIALIZER 13371 (struct cmd_vf_mac_anti_spoof_result, 13372 mac, "mac"); 13373 cmdline_parse_token_string_t cmd_vf_mac_anti_spoof_antispoof = 13374 TOKEN_STRING_INITIALIZER 13375 (struct cmd_vf_mac_anti_spoof_result, 13376 antispoof, "antispoof"); 13377 cmdline_parse_token_num_t cmd_vf_mac_anti_spoof_port_id = 13378 TOKEN_NUM_INITIALIZER 13379 (struct cmd_vf_mac_anti_spoof_result, 13380 port_id, UINT16); 13381 cmdline_parse_token_num_t cmd_vf_mac_anti_spoof_vf_id = 13382 TOKEN_NUM_INITIALIZER 13383 (struct cmd_vf_mac_anti_spoof_result, 13384 vf_id, UINT32); 13385 cmdline_parse_token_string_t cmd_vf_mac_anti_spoof_on_off = 13386 TOKEN_STRING_INITIALIZER 13387 (struct cmd_vf_mac_anti_spoof_result, 13388 on_off, "on#off"); 13389 13390 static void 13391 cmd_set_vf_mac_anti_spoof_parsed( 13392 void *parsed_result, 13393 __attribute__((unused)) struct cmdline *cl, 13394 __attribute__((unused)) void *data) 13395 { 13396 struct cmd_vf_mac_anti_spoof_result *res = parsed_result; 13397 int ret = -ENOTSUP; 13398 13399 __rte_unused int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0; 13400 13401 if (port_id_is_invalid(res->port_id, ENABLED_WARN)) 13402 return; 13403 13404 #ifdef RTE_LIBRTE_IXGBE_PMD 13405 if (ret == -ENOTSUP) 13406 ret = rte_pmd_ixgbe_set_vf_mac_anti_spoof(res->port_id, 13407 res->vf_id, is_on); 13408 #endif 13409 #ifdef RTE_LIBRTE_I40E_PMD 13410 if (ret == -ENOTSUP) 13411 ret = rte_pmd_i40e_set_vf_mac_anti_spoof(res->port_id, 13412 res->vf_id, is_on); 13413 #endif 13414 #ifdef RTE_LIBRTE_BNXT_PMD 13415 if (ret == -ENOTSUP) 13416 ret = rte_pmd_bnxt_set_vf_mac_anti_spoof(res->port_id, 13417 res->vf_id, is_on); 13418 #endif 13419 13420 switch (ret) { 13421 case 0: 13422 break; 13423 case -EINVAL: 13424 printf("invalid vf_id %d or is_on %d\n", res->vf_id, is_on); 13425 break; 13426 case -ENODEV: 13427 printf("invalid port_id %d\n", res->port_id); 13428 break; 13429 case -ENOTSUP: 13430 printf("function not implemented\n"); 13431 break; 13432 default: 13433 printf("programming error: (%s)\n", strerror(-ret)); 13434 } 13435 } 13436 13437 cmdline_parse_inst_t cmd_set_vf_mac_anti_spoof = { 13438 .f = cmd_set_vf_mac_anti_spoof_parsed, 13439 .data = NULL, 13440 .help_str = "set vf mac antispoof <port_id> <vf_id> on|off", 13441 .tokens = { 13442 (void *)&cmd_vf_mac_anti_spoof_set, 13443 (void *)&cmd_vf_mac_anti_spoof_vf, 13444 (void *)&cmd_vf_mac_anti_spoof_mac, 13445 (void *)&cmd_vf_mac_anti_spoof_antispoof, 13446 (void *)&cmd_vf_mac_anti_spoof_port_id, 13447 (void *)&cmd_vf_mac_anti_spoof_vf_id, 13448 (void *)&cmd_vf_mac_anti_spoof_on_off, 13449 NULL, 13450 }, 13451 }; 13452 13453 /* vf vlan strip queue configuration */ 13454 13455 /* Common result structure for vf mac anti spoof */ 13456 struct cmd_vf_vlan_stripq_result { 13457 cmdline_fixed_string_t set; 13458 cmdline_fixed_string_t vf; 13459 cmdline_fixed_string_t vlan; 13460 cmdline_fixed_string_t stripq; 13461 portid_t port_id; 13462 uint16_t vf_id; 13463 cmdline_fixed_string_t on_off; 13464 }; 13465 13466 /* Common CLI fields for vf vlan strip enable disable */ 13467 cmdline_parse_token_string_t cmd_vf_vlan_stripq_set = 13468 TOKEN_STRING_INITIALIZER 13469 (struct cmd_vf_vlan_stripq_result, 13470 set, "set"); 13471 cmdline_parse_token_string_t cmd_vf_vlan_stripq_vf = 13472 TOKEN_STRING_INITIALIZER 13473 (struct cmd_vf_vlan_stripq_result, 13474 vf, "vf"); 13475 cmdline_parse_token_string_t cmd_vf_vlan_stripq_vlan = 13476 TOKEN_STRING_INITIALIZER 13477 (struct cmd_vf_vlan_stripq_result, 13478 vlan, "vlan"); 13479 cmdline_parse_token_string_t cmd_vf_vlan_stripq_stripq = 13480 TOKEN_STRING_INITIALIZER 13481 (struct cmd_vf_vlan_stripq_result, 13482 stripq, "stripq"); 13483 cmdline_parse_token_num_t cmd_vf_vlan_stripq_port_id = 13484 TOKEN_NUM_INITIALIZER 13485 (struct cmd_vf_vlan_stripq_result, 13486 port_id, UINT16); 13487 cmdline_parse_token_num_t cmd_vf_vlan_stripq_vf_id = 13488 TOKEN_NUM_INITIALIZER 13489 (struct cmd_vf_vlan_stripq_result, 13490 vf_id, UINT16); 13491 cmdline_parse_token_string_t cmd_vf_vlan_stripq_on_off = 13492 TOKEN_STRING_INITIALIZER 13493 (struct cmd_vf_vlan_stripq_result, 13494 on_off, "on#off"); 13495 13496 static void 13497 cmd_set_vf_vlan_stripq_parsed( 13498 void *parsed_result, 13499 __attribute__((unused)) struct cmdline *cl, 13500 __attribute__((unused)) void *data) 13501 { 13502 struct cmd_vf_vlan_stripq_result *res = parsed_result; 13503 int ret = -ENOTSUP; 13504 13505 __rte_unused int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0; 13506 13507 if (port_id_is_invalid(res->port_id, ENABLED_WARN)) 13508 return; 13509 13510 #ifdef RTE_LIBRTE_IXGBE_PMD 13511 if (ret == -ENOTSUP) 13512 ret = rte_pmd_ixgbe_set_vf_vlan_stripq(res->port_id, 13513 res->vf_id, is_on); 13514 #endif 13515 #ifdef RTE_LIBRTE_I40E_PMD 13516 if (ret == -ENOTSUP) 13517 ret = rte_pmd_i40e_set_vf_vlan_stripq(res->port_id, 13518 res->vf_id, is_on); 13519 #endif 13520 #ifdef RTE_LIBRTE_BNXT_PMD 13521 if (ret == -ENOTSUP) 13522 ret = rte_pmd_bnxt_set_vf_vlan_stripq(res->port_id, 13523 res->vf_id, is_on); 13524 #endif 13525 13526 switch (ret) { 13527 case 0: 13528 break; 13529 case -EINVAL: 13530 printf("invalid vf_id %d or is_on %d\n", res->vf_id, is_on); 13531 break; 13532 case -ENODEV: 13533 printf("invalid port_id %d\n", res->port_id); 13534 break; 13535 case -ENOTSUP: 13536 printf("function not implemented\n"); 13537 break; 13538 default: 13539 printf("programming error: (%s)\n", strerror(-ret)); 13540 } 13541 } 13542 13543 cmdline_parse_inst_t cmd_set_vf_vlan_stripq = { 13544 .f = cmd_set_vf_vlan_stripq_parsed, 13545 .data = NULL, 13546 .help_str = "set vf vlan stripq <port_id> <vf_id> on|off", 13547 .tokens = { 13548 (void *)&cmd_vf_vlan_stripq_set, 13549 (void *)&cmd_vf_vlan_stripq_vf, 13550 (void *)&cmd_vf_vlan_stripq_vlan, 13551 (void *)&cmd_vf_vlan_stripq_stripq, 13552 (void *)&cmd_vf_vlan_stripq_port_id, 13553 (void *)&cmd_vf_vlan_stripq_vf_id, 13554 (void *)&cmd_vf_vlan_stripq_on_off, 13555 NULL, 13556 }, 13557 }; 13558 13559 /* vf vlan insert configuration */ 13560 13561 /* Common result structure for vf vlan insert */ 13562 struct cmd_vf_vlan_insert_result { 13563 cmdline_fixed_string_t set; 13564 cmdline_fixed_string_t vf; 13565 cmdline_fixed_string_t vlan; 13566 cmdline_fixed_string_t insert; 13567 portid_t port_id; 13568 uint16_t vf_id; 13569 uint16_t vlan_id; 13570 }; 13571 13572 /* Common CLI fields for vf vlan insert enable disable */ 13573 cmdline_parse_token_string_t cmd_vf_vlan_insert_set = 13574 TOKEN_STRING_INITIALIZER 13575 (struct cmd_vf_vlan_insert_result, 13576 set, "set"); 13577 cmdline_parse_token_string_t cmd_vf_vlan_insert_vf = 13578 TOKEN_STRING_INITIALIZER 13579 (struct cmd_vf_vlan_insert_result, 13580 vf, "vf"); 13581 cmdline_parse_token_string_t cmd_vf_vlan_insert_vlan = 13582 TOKEN_STRING_INITIALIZER 13583 (struct cmd_vf_vlan_insert_result, 13584 vlan, "vlan"); 13585 cmdline_parse_token_string_t cmd_vf_vlan_insert_insert = 13586 TOKEN_STRING_INITIALIZER 13587 (struct cmd_vf_vlan_insert_result, 13588 insert, "insert"); 13589 cmdline_parse_token_num_t cmd_vf_vlan_insert_port_id = 13590 TOKEN_NUM_INITIALIZER 13591 (struct cmd_vf_vlan_insert_result, 13592 port_id, UINT16); 13593 cmdline_parse_token_num_t cmd_vf_vlan_insert_vf_id = 13594 TOKEN_NUM_INITIALIZER 13595 (struct cmd_vf_vlan_insert_result, 13596 vf_id, UINT16); 13597 cmdline_parse_token_num_t cmd_vf_vlan_insert_vlan_id = 13598 TOKEN_NUM_INITIALIZER 13599 (struct cmd_vf_vlan_insert_result, 13600 vlan_id, UINT16); 13601 13602 static void 13603 cmd_set_vf_vlan_insert_parsed( 13604 void *parsed_result, 13605 __attribute__((unused)) struct cmdline *cl, 13606 __attribute__((unused)) void *data) 13607 { 13608 struct cmd_vf_vlan_insert_result *res = parsed_result; 13609 int ret = -ENOTSUP; 13610 13611 if (port_id_is_invalid(res->port_id, ENABLED_WARN)) 13612 return; 13613 13614 #ifdef RTE_LIBRTE_IXGBE_PMD 13615 if (ret == -ENOTSUP) 13616 ret = rte_pmd_ixgbe_set_vf_vlan_insert(res->port_id, res->vf_id, 13617 res->vlan_id); 13618 #endif 13619 #ifdef RTE_LIBRTE_I40E_PMD 13620 if (ret == -ENOTSUP) 13621 ret = rte_pmd_i40e_set_vf_vlan_insert(res->port_id, res->vf_id, 13622 res->vlan_id); 13623 #endif 13624 #ifdef RTE_LIBRTE_BNXT_PMD 13625 if (ret == -ENOTSUP) 13626 ret = rte_pmd_bnxt_set_vf_vlan_insert(res->port_id, res->vf_id, 13627 res->vlan_id); 13628 #endif 13629 13630 switch (ret) { 13631 case 0: 13632 break; 13633 case -EINVAL: 13634 printf("invalid vf_id %d or vlan_id %d\n", res->vf_id, res->vlan_id); 13635 break; 13636 case -ENODEV: 13637 printf("invalid port_id %d\n", res->port_id); 13638 break; 13639 case -ENOTSUP: 13640 printf("function not implemented\n"); 13641 break; 13642 default: 13643 printf("programming error: (%s)\n", strerror(-ret)); 13644 } 13645 } 13646 13647 cmdline_parse_inst_t cmd_set_vf_vlan_insert = { 13648 .f = cmd_set_vf_vlan_insert_parsed, 13649 .data = NULL, 13650 .help_str = "set vf vlan insert <port_id> <vf_id> <vlan_id>", 13651 .tokens = { 13652 (void *)&cmd_vf_vlan_insert_set, 13653 (void *)&cmd_vf_vlan_insert_vf, 13654 (void *)&cmd_vf_vlan_insert_vlan, 13655 (void *)&cmd_vf_vlan_insert_insert, 13656 (void *)&cmd_vf_vlan_insert_port_id, 13657 (void *)&cmd_vf_vlan_insert_vf_id, 13658 (void *)&cmd_vf_vlan_insert_vlan_id, 13659 NULL, 13660 }, 13661 }; 13662 13663 /* tx loopback configuration */ 13664 13665 /* Common result structure for tx loopback */ 13666 struct cmd_tx_loopback_result { 13667 cmdline_fixed_string_t set; 13668 cmdline_fixed_string_t tx; 13669 cmdline_fixed_string_t loopback; 13670 portid_t port_id; 13671 cmdline_fixed_string_t on_off; 13672 }; 13673 13674 /* Common CLI fields for tx loopback enable disable */ 13675 cmdline_parse_token_string_t cmd_tx_loopback_set = 13676 TOKEN_STRING_INITIALIZER 13677 (struct cmd_tx_loopback_result, 13678 set, "set"); 13679 cmdline_parse_token_string_t cmd_tx_loopback_tx = 13680 TOKEN_STRING_INITIALIZER 13681 (struct cmd_tx_loopback_result, 13682 tx, "tx"); 13683 cmdline_parse_token_string_t cmd_tx_loopback_loopback = 13684 TOKEN_STRING_INITIALIZER 13685 (struct cmd_tx_loopback_result, 13686 loopback, "loopback"); 13687 cmdline_parse_token_num_t cmd_tx_loopback_port_id = 13688 TOKEN_NUM_INITIALIZER 13689 (struct cmd_tx_loopback_result, 13690 port_id, UINT16); 13691 cmdline_parse_token_string_t cmd_tx_loopback_on_off = 13692 TOKEN_STRING_INITIALIZER 13693 (struct cmd_tx_loopback_result, 13694 on_off, "on#off"); 13695 13696 static void 13697 cmd_set_tx_loopback_parsed( 13698 void *parsed_result, 13699 __attribute__((unused)) struct cmdline *cl, 13700 __attribute__((unused)) void *data) 13701 { 13702 struct cmd_tx_loopback_result *res = parsed_result; 13703 int ret = -ENOTSUP; 13704 13705 __rte_unused int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0; 13706 13707 if (port_id_is_invalid(res->port_id, ENABLED_WARN)) 13708 return; 13709 13710 #ifdef RTE_LIBRTE_IXGBE_PMD 13711 if (ret == -ENOTSUP) 13712 ret = rte_pmd_ixgbe_set_tx_loopback(res->port_id, is_on); 13713 #endif 13714 #ifdef RTE_LIBRTE_I40E_PMD 13715 if (ret == -ENOTSUP) 13716 ret = rte_pmd_i40e_set_tx_loopback(res->port_id, is_on); 13717 #endif 13718 #ifdef RTE_LIBRTE_BNXT_PMD 13719 if (ret == -ENOTSUP) 13720 ret = rte_pmd_bnxt_set_tx_loopback(res->port_id, is_on); 13721 #endif 13722 #if defined RTE_LIBRTE_DPAA_BUS && defined RTE_LIBRTE_DPAA_PMD 13723 if (ret == -ENOTSUP) 13724 ret = rte_pmd_dpaa_set_tx_loopback(res->port_id, is_on); 13725 #endif 13726 13727 switch (ret) { 13728 case 0: 13729 break; 13730 case -EINVAL: 13731 printf("invalid is_on %d\n", is_on); 13732 break; 13733 case -ENODEV: 13734 printf("invalid port_id %d\n", res->port_id); 13735 break; 13736 case -ENOTSUP: 13737 printf("function not implemented\n"); 13738 break; 13739 default: 13740 printf("programming error: (%s)\n", strerror(-ret)); 13741 } 13742 } 13743 13744 cmdline_parse_inst_t cmd_set_tx_loopback = { 13745 .f = cmd_set_tx_loopback_parsed, 13746 .data = NULL, 13747 .help_str = "set tx loopback <port_id> on|off", 13748 .tokens = { 13749 (void *)&cmd_tx_loopback_set, 13750 (void *)&cmd_tx_loopback_tx, 13751 (void *)&cmd_tx_loopback_loopback, 13752 (void *)&cmd_tx_loopback_port_id, 13753 (void *)&cmd_tx_loopback_on_off, 13754 NULL, 13755 }, 13756 }; 13757 13758 /* all queues drop enable configuration */ 13759 13760 /* Common result structure for all queues drop enable */ 13761 struct cmd_all_queues_drop_en_result { 13762 cmdline_fixed_string_t set; 13763 cmdline_fixed_string_t all; 13764 cmdline_fixed_string_t queues; 13765 cmdline_fixed_string_t drop; 13766 portid_t port_id; 13767 cmdline_fixed_string_t on_off; 13768 }; 13769 13770 /* Common CLI fields for tx loopback enable disable */ 13771 cmdline_parse_token_string_t cmd_all_queues_drop_en_set = 13772 TOKEN_STRING_INITIALIZER 13773 (struct cmd_all_queues_drop_en_result, 13774 set, "set"); 13775 cmdline_parse_token_string_t cmd_all_queues_drop_en_all = 13776 TOKEN_STRING_INITIALIZER 13777 (struct cmd_all_queues_drop_en_result, 13778 all, "all"); 13779 cmdline_parse_token_string_t cmd_all_queues_drop_en_queues = 13780 TOKEN_STRING_INITIALIZER 13781 (struct cmd_all_queues_drop_en_result, 13782 queues, "queues"); 13783 cmdline_parse_token_string_t cmd_all_queues_drop_en_drop = 13784 TOKEN_STRING_INITIALIZER 13785 (struct cmd_all_queues_drop_en_result, 13786 drop, "drop"); 13787 cmdline_parse_token_num_t cmd_all_queues_drop_en_port_id = 13788 TOKEN_NUM_INITIALIZER 13789 (struct cmd_all_queues_drop_en_result, 13790 port_id, UINT16); 13791 cmdline_parse_token_string_t cmd_all_queues_drop_en_on_off = 13792 TOKEN_STRING_INITIALIZER 13793 (struct cmd_all_queues_drop_en_result, 13794 on_off, "on#off"); 13795 13796 static void 13797 cmd_set_all_queues_drop_en_parsed( 13798 void *parsed_result, 13799 __attribute__((unused)) struct cmdline *cl, 13800 __attribute__((unused)) void *data) 13801 { 13802 struct cmd_all_queues_drop_en_result *res = parsed_result; 13803 int ret = -ENOTSUP; 13804 int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0; 13805 13806 if (port_id_is_invalid(res->port_id, ENABLED_WARN)) 13807 return; 13808 13809 #ifdef RTE_LIBRTE_IXGBE_PMD 13810 if (ret == -ENOTSUP) 13811 ret = rte_pmd_ixgbe_set_all_queues_drop_en(res->port_id, is_on); 13812 #endif 13813 #ifdef RTE_LIBRTE_BNXT_PMD 13814 if (ret == -ENOTSUP) 13815 ret = rte_pmd_bnxt_set_all_queues_drop_en(res->port_id, is_on); 13816 #endif 13817 switch (ret) { 13818 case 0: 13819 break; 13820 case -EINVAL: 13821 printf("invalid is_on %d\n", is_on); 13822 break; 13823 case -ENODEV: 13824 printf("invalid port_id %d\n", res->port_id); 13825 break; 13826 case -ENOTSUP: 13827 printf("function not implemented\n"); 13828 break; 13829 default: 13830 printf("programming error: (%s)\n", strerror(-ret)); 13831 } 13832 } 13833 13834 cmdline_parse_inst_t cmd_set_all_queues_drop_en = { 13835 .f = cmd_set_all_queues_drop_en_parsed, 13836 .data = NULL, 13837 .help_str = "set all queues drop <port_id> on|off", 13838 .tokens = { 13839 (void *)&cmd_all_queues_drop_en_set, 13840 (void *)&cmd_all_queues_drop_en_all, 13841 (void *)&cmd_all_queues_drop_en_queues, 13842 (void *)&cmd_all_queues_drop_en_drop, 13843 (void *)&cmd_all_queues_drop_en_port_id, 13844 (void *)&cmd_all_queues_drop_en_on_off, 13845 NULL, 13846 }, 13847 }; 13848 13849 /* vf split drop enable configuration */ 13850 13851 /* Common result structure for vf split drop enable */ 13852 struct cmd_vf_split_drop_en_result { 13853 cmdline_fixed_string_t set; 13854 cmdline_fixed_string_t vf; 13855 cmdline_fixed_string_t split; 13856 cmdline_fixed_string_t drop; 13857 portid_t port_id; 13858 uint16_t vf_id; 13859 cmdline_fixed_string_t on_off; 13860 }; 13861 13862 /* Common CLI fields for vf split drop enable disable */ 13863 cmdline_parse_token_string_t cmd_vf_split_drop_en_set = 13864 TOKEN_STRING_INITIALIZER 13865 (struct cmd_vf_split_drop_en_result, 13866 set, "set"); 13867 cmdline_parse_token_string_t cmd_vf_split_drop_en_vf = 13868 TOKEN_STRING_INITIALIZER 13869 (struct cmd_vf_split_drop_en_result, 13870 vf, "vf"); 13871 cmdline_parse_token_string_t cmd_vf_split_drop_en_split = 13872 TOKEN_STRING_INITIALIZER 13873 (struct cmd_vf_split_drop_en_result, 13874 split, "split"); 13875 cmdline_parse_token_string_t cmd_vf_split_drop_en_drop = 13876 TOKEN_STRING_INITIALIZER 13877 (struct cmd_vf_split_drop_en_result, 13878 drop, "drop"); 13879 cmdline_parse_token_num_t cmd_vf_split_drop_en_port_id = 13880 TOKEN_NUM_INITIALIZER 13881 (struct cmd_vf_split_drop_en_result, 13882 port_id, UINT16); 13883 cmdline_parse_token_num_t cmd_vf_split_drop_en_vf_id = 13884 TOKEN_NUM_INITIALIZER 13885 (struct cmd_vf_split_drop_en_result, 13886 vf_id, UINT16); 13887 cmdline_parse_token_string_t cmd_vf_split_drop_en_on_off = 13888 TOKEN_STRING_INITIALIZER 13889 (struct cmd_vf_split_drop_en_result, 13890 on_off, "on#off"); 13891 13892 static void 13893 cmd_set_vf_split_drop_en_parsed( 13894 void *parsed_result, 13895 __attribute__((unused)) struct cmdline *cl, 13896 __attribute__((unused)) void *data) 13897 { 13898 struct cmd_vf_split_drop_en_result *res = parsed_result; 13899 int ret = -ENOTSUP; 13900 int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0; 13901 13902 if (port_id_is_invalid(res->port_id, ENABLED_WARN)) 13903 return; 13904 13905 #ifdef RTE_LIBRTE_IXGBE_PMD 13906 ret = rte_pmd_ixgbe_set_vf_split_drop_en(res->port_id, res->vf_id, 13907 is_on); 13908 #endif 13909 switch (ret) { 13910 case 0: 13911 break; 13912 case -EINVAL: 13913 printf("invalid vf_id %d or is_on %d\n", res->vf_id, is_on); 13914 break; 13915 case -ENODEV: 13916 printf("invalid port_id %d\n", res->port_id); 13917 break; 13918 case -ENOTSUP: 13919 printf("not supported on port %d\n", res->port_id); 13920 break; 13921 default: 13922 printf("programming error: (%s)\n", strerror(-ret)); 13923 } 13924 } 13925 13926 cmdline_parse_inst_t cmd_set_vf_split_drop_en = { 13927 .f = cmd_set_vf_split_drop_en_parsed, 13928 .data = NULL, 13929 .help_str = "set vf split drop <port_id> <vf_id> on|off", 13930 .tokens = { 13931 (void *)&cmd_vf_split_drop_en_set, 13932 (void *)&cmd_vf_split_drop_en_vf, 13933 (void *)&cmd_vf_split_drop_en_split, 13934 (void *)&cmd_vf_split_drop_en_drop, 13935 (void *)&cmd_vf_split_drop_en_port_id, 13936 (void *)&cmd_vf_split_drop_en_vf_id, 13937 (void *)&cmd_vf_split_drop_en_on_off, 13938 NULL, 13939 }, 13940 }; 13941 13942 /* vf mac address configuration */ 13943 13944 /* Common result structure for vf mac address */ 13945 struct cmd_set_vf_mac_addr_result { 13946 cmdline_fixed_string_t set; 13947 cmdline_fixed_string_t vf; 13948 cmdline_fixed_string_t mac; 13949 cmdline_fixed_string_t addr; 13950 portid_t port_id; 13951 uint16_t vf_id; 13952 struct rte_ether_addr mac_addr; 13953 13954 }; 13955 13956 /* Common CLI fields for vf split drop enable disable */ 13957 cmdline_parse_token_string_t cmd_set_vf_mac_addr_set = 13958 TOKEN_STRING_INITIALIZER 13959 (struct cmd_set_vf_mac_addr_result, 13960 set, "set"); 13961 cmdline_parse_token_string_t cmd_set_vf_mac_addr_vf = 13962 TOKEN_STRING_INITIALIZER 13963 (struct cmd_set_vf_mac_addr_result, 13964 vf, "vf"); 13965 cmdline_parse_token_string_t cmd_set_vf_mac_addr_mac = 13966 TOKEN_STRING_INITIALIZER 13967 (struct cmd_set_vf_mac_addr_result, 13968 mac, "mac"); 13969 cmdline_parse_token_string_t cmd_set_vf_mac_addr_addr = 13970 TOKEN_STRING_INITIALIZER 13971 (struct cmd_set_vf_mac_addr_result, 13972 addr, "addr"); 13973 cmdline_parse_token_num_t cmd_set_vf_mac_addr_port_id = 13974 TOKEN_NUM_INITIALIZER 13975 (struct cmd_set_vf_mac_addr_result, 13976 port_id, UINT16); 13977 cmdline_parse_token_num_t cmd_set_vf_mac_addr_vf_id = 13978 TOKEN_NUM_INITIALIZER 13979 (struct cmd_set_vf_mac_addr_result, 13980 vf_id, UINT16); 13981 cmdline_parse_token_etheraddr_t cmd_set_vf_mac_addr_mac_addr = 13982 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_vf_mac_addr_result, 13983 mac_addr); 13984 13985 static void 13986 cmd_set_vf_mac_addr_parsed( 13987 void *parsed_result, 13988 __attribute__((unused)) struct cmdline *cl, 13989 __attribute__((unused)) void *data) 13990 { 13991 struct cmd_set_vf_mac_addr_result *res = parsed_result; 13992 int ret = -ENOTSUP; 13993 13994 if (port_id_is_invalid(res->port_id, ENABLED_WARN)) 13995 return; 13996 13997 #ifdef RTE_LIBRTE_IXGBE_PMD 13998 if (ret == -ENOTSUP) 13999 ret = rte_pmd_ixgbe_set_vf_mac_addr(res->port_id, res->vf_id, 14000 &res->mac_addr); 14001 #endif 14002 #ifdef RTE_LIBRTE_I40E_PMD 14003 if (ret == -ENOTSUP) 14004 ret = rte_pmd_i40e_set_vf_mac_addr(res->port_id, res->vf_id, 14005 &res->mac_addr); 14006 #endif 14007 #ifdef RTE_LIBRTE_BNXT_PMD 14008 if (ret == -ENOTSUP) 14009 ret = rte_pmd_bnxt_set_vf_mac_addr(res->port_id, res->vf_id, 14010 &res->mac_addr); 14011 #endif 14012 14013 switch (ret) { 14014 case 0: 14015 break; 14016 case -EINVAL: 14017 printf("invalid vf_id %d or mac_addr\n", res->vf_id); 14018 break; 14019 case -ENODEV: 14020 printf("invalid port_id %d\n", res->port_id); 14021 break; 14022 case -ENOTSUP: 14023 printf("function not implemented\n"); 14024 break; 14025 default: 14026 printf("programming error: (%s)\n", strerror(-ret)); 14027 } 14028 } 14029 14030 cmdline_parse_inst_t cmd_set_vf_mac_addr = { 14031 .f = cmd_set_vf_mac_addr_parsed, 14032 .data = NULL, 14033 .help_str = "set vf mac addr <port_id> <vf_id> <mac_addr>", 14034 .tokens = { 14035 (void *)&cmd_set_vf_mac_addr_set, 14036 (void *)&cmd_set_vf_mac_addr_vf, 14037 (void *)&cmd_set_vf_mac_addr_mac, 14038 (void *)&cmd_set_vf_mac_addr_addr, 14039 (void *)&cmd_set_vf_mac_addr_port_id, 14040 (void *)&cmd_set_vf_mac_addr_vf_id, 14041 (void *)&cmd_set_vf_mac_addr_mac_addr, 14042 NULL, 14043 }, 14044 }; 14045 14046 /* MACsec configuration */ 14047 14048 /* Common result structure for MACsec offload enable */ 14049 struct cmd_macsec_offload_on_result { 14050 cmdline_fixed_string_t set; 14051 cmdline_fixed_string_t macsec; 14052 cmdline_fixed_string_t offload; 14053 portid_t port_id; 14054 cmdline_fixed_string_t on; 14055 cmdline_fixed_string_t encrypt; 14056 cmdline_fixed_string_t en_on_off; 14057 cmdline_fixed_string_t replay_protect; 14058 cmdline_fixed_string_t rp_on_off; 14059 }; 14060 14061 /* Common CLI fields for MACsec offload disable */ 14062 cmdline_parse_token_string_t cmd_macsec_offload_on_set = 14063 TOKEN_STRING_INITIALIZER 14064 (struct cmd_macsec_offload_on_result, 14065 set, "set"); 14066 cmdline_parse_token_string_t cmd_macsec_offload_on_macsec = 14067 TOKEN_STRING_INITIALIZER 14068 (struct cmd_macsec_offload_on_result, 14069 macsec, "macsec"); 14070 cmdline_parse_token_string_t cmd_macsec_offload_on_offload = 14071 TOKEN_STRING_INITIALIZER 14072 (struct cmd_macsec_offload_on_result, 14073 offload, "offload"); 14074 cmdline_parse_token_num_t cmd_macsec_offload_on_port_id = 14075 TOKEN_NUM_INITIALIZER 14076 (struct cmd_macsec_offload_on_result, 14077 port_id, UINT16); 14078 cmdline_parse_token_string_t cmd_macsec_offload_on_on = 14079 TOKEN_STRING_INITIALIZER 14080 (struct cmd_macsec_offload_on_result, 14081 on, "on"); 14082 cmdline_parse_token_string_t cmd_macsec_offload_on_encrypt = 14083 TOKEN_STRING_INITIALIZER 14084 (struct cmd_macsec_offload_on_result, 14085 encrypt, "encrypt"); 14086 cmdline_parse_token_string_t cmd_macsec_offload_on_en_on_off = 14087 TOKEN_STRING_INITIALIZER 14088 (struct cmd_macsec_offload_on_result, 14089 en_on_off, "on#off"); 14090 cmdline_parse_token_string_t cmd_macsec_offload_on_replay_protect = 14091 TOKEN_STRING_INITIALIZER 14092 (struct cmd_macsec_offload_on_result, 14093 replay_protect, "replay-protect"); 14094 cmdline_parse_token_string_t cmd_macsec_offload_on_rp_on_off = 14095 TOKEN_STRING_INITIALIZER 14096 (struct cmd_macsec_offload_on_result, 14097 rp_on_off, "on#off"); 14098 14099 static void 14100 cmd_set_macsec_offload_on_parsed( 14101 void *parsed_result, 14102 __attribute__((unused)) struct cmdline *cl, 14103 __attribute__((unused)) void *data) 14104 { 14105 struct cmd_macsec_offload_on_result *res = parsed_result; 14106 int ret = -ENOTSUP; 14107 portid_t port_id = res->port_id; 14108 int en = (strcmp(res->en_on_off, "on") == 0) ? 1 : 0; 14109 int rp = (strcmp(res->rp_on_off, "on") == 0) ? 1 : 0; 14110 struct rte_eth_dev_info dev_info; 14111 14112 if (port_id_is_invalid(port_id, ENABLED_WARN)) 14113 return; 14114 if (!port_is_stopped(port_id)) { 14115 printf("Please stop port %d first\n", port_id); 14116 return; 14117 } 14118 14119 ret = eth_dev_info_get_print_err(port_id, &dev_info); 14120 if (ret != 0) 14121 return; 14122 14123 if (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_MACSEC_INSERT) { 14124 #ifdef RTE_LIBRTE_IXGBE_PMD 14125 ret = rte_pmd_ixgbe_macsec_enable(port_id, en, rp); 14126 #endif 14127 } 14128 RTE_SET_USED(en); 14129 RTE_SET_USED(rp); 14130 14131 switch (ret) { 14132 case 0: 14133 ports[port_id].dev_conf.txmode.offloads |= 14134 DEV_TX_OFFLOAD_MACSEC_INSERT; 14135 cmd_reconfig_device_queue(port_id, 1, 1); 14136 break; 14137 case -ENODEV: 14138 printf("invalid port_id %d\n", port_id); 14139 break; 14140 case -ENOTSUP: 14141 printf("not supported on port %d\n", port_id); 14142 break; 14143 default: 14144 printf("programming error: (%s)\n", strerror(-ret)); 14145 } 14146 } 14147 14148 cmdline_parse_inst_t cmd_set_macsec_offload_on = { 14149 .f = cmd_set_macsec_offload_on_parsed, 14150 .data = NULL, 14151 .help_str = "set macsec offload <port_id> on " 14152 "encrypt on|off replay-protect on|off", 14153 .tokens = { 14154 (void *)&cmd_macsec_offload_on_set, 14155 (void *)&cmd_macsec_offload_on_macsec, 14156 (void *)&cmd_macsec_offload_on_offload, 14157 (void *)&cmd_macsec_offload_on_port_id, 14158 (void *)&cmd_macsec_offload_on_on, 14159 (void *)&cmd_macsec_offload_on_encrypt, 14160 (void *)&cmd_macsec_offload_on_en_on_off, 14161 (void *)&cmd_macsec_offload_on_replay_protect, 14162 (void *)&cmd_macsec_offload_on_rp_on_off, 14163 NULL, 14164 }, 14165 }; 14166 14167 /* Common result structure for MACsec offload disable */ 14168 struct cmd_macsec_offload_off_result { 14169 cmdline_fixed_string_t set; 14170 cmdline_fixed_string_t macsec; 14171 cmdline_fixed_string_t offload; 14172 portid_t port_id; 14173 cmdline_fixed_string_t off; 14174 }; 14175 14176 /* Common CLI fields for MACsec offload disable */ 14177 cmdline_parse_token_string_t cmd_macsec_offload_off_set = 14178 TOKEN_STRING_INITIALIZER 14179 (struct cmd_macsec_offload_off_result, 14180 set, "set"); 14181 cmdline_parse_token_string_t cmd_macsec_offload_off_macsec = 14182 TOKEN_STRING_INITIALIZER 14183 (struct cmd_macsec_offload_off_result, 14184 macsec, "macsec"); 14185 cmdline_parse_token_string_t cmd_macsec_offload_off_offload = 14186 TOKEN_STRING_INITIALIZER 14187 (struct cmd_macsec_offload_off_result, 14188 offload, "offload"); 14189 cmdline_parse_token_num_t cmd_macsec_offload_off_port_id = 14190 TOKEN_NUM_INITIALIZER 14191 (struct cmd_macsec_offload_off_result, 14192 port_id, UINT16); 14193 cmdline_parse_token_string_t cmd_macsec_offload_off_off = 14194 TOKEN_STRING_INITIALIZER 14195 (struct cmd_macsec_offload_off_result, 14196 off, "off"); 14197 14198 static void 14199 cmd_set_macsec_offload_off_parsed( 14200 void *parsed_result, 14201 __attribute__((unused)) struct cmdline *cl, 14202 __attribute__((unused)) void *data) 14203 { 14204 struct cmd_macsec_offload_off_result *res = parsed_result; 14205 int ret = -ENOTSUP; 14206 struct rte_eth_dev_info dev_info; 14207 portid_t port_id = res->port_id; 14208 14209 if (port_id_is_invalid(port_id, ENABLED_WARN)) 14210 return; 14211 if (!port_is_stopped(port_id)) { 14212 printf("Please stop port %d first\n", port_id); 14213 return; 14214 } 14215 14216 ret = eth_dev_info_get_print_err(port_id, &dev_info); 14217 if (ret != 0) 14218 return; 14219 14220 if (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_MACSEC_INSERT) { 14221 #ifdef RTE_LIBRTE_IXGBE_PMD 14222 ret = rte_pmd_ixgbe_macsec_disable(port_id); 14223 #endif 14224 } 14225 switch (ret) { 14226 case 0: 14227 ports[port_id].dev_conf.txmode.offloads &= 14228 ~DEV_TX_OFFLOAD_MACSEC_INSERT; 14229 cmd_reconfig_device_queue(port_id, 1, 1); 14230 break; 14231 case -ENODEV: 14232 printf("invalid port_id %d\n", port_id); 14233 break; 14234 case -ENOTSUP: 14235 printf("not supported on port %d\n", port_id); 14236 break; 14237 default: 14238 printf("programming error: (%s)\n", strerror(-ret)); 14239 } 14240 } 14241 14242 cmdline_parse_inst_t cmd_set_macsec_offload_off = { 14243 .f = cmd_set_macsec_offload_off_parsed, 14244 .data = NULL, 14245 .help_str = "set macsec offload <port_id> off", 14246 .tokens = { 14247 (void *)&cmd_macsec_offload_off_set, 14248 (void *)&cmd_macsec_offload_off_macsec, 14249 (void *)&cmd_macsec_offload_off_offload, 14250 (void *)&cmd_macsec_offload_off_port_id, 14251 (void *)&cmd_macsec_offload_off_off, 14252 NULL, 14253 }, 14254 }; 14255 14256 /* Common result structure for MACsec secure connection configure */ 14257 struct cmd_macsec_sc_result { 14258 cmdline_fixed_string_t set; 14259 cmdline_fixed_string_t macsec; 14260 cmdline_fixed_string_t sc; 14261 cmdline_fixed_string_t tx_rx; 14262 portid_t port_id; 14263 struct rte_ether_addr mac; 14264 uint16_t pi; 14265 }; 14266 14267 /* Common CLI fields for MACsec secure connection configure */ 14268 cmdline_parse_token_string_t cmd_macsec_sc_set = 14269 TOKEN_STRING_INITIALIZER 14270 (struct cmd_macsec_sc_result, 14271 set, "set"); 14272 cmdline_parse_token_string_t cmd_macsec_sc_macsec = 14273 TOKEN_STRING_INITIALIZER 14274 (struct cmd_macsec_sc_result, 14275 macsec, "macsec"); 14276 cmdline_parse_token_string_t cmd_macsec_sc_sc = 14277 TOKEN_STRING_INITIALIZER 14278 (struct cmd_macsec_sc_result, 14279 sc, "sc"); 14280 cmdline_parse_token_string_t cmd_macsec_sc_tx_rx = 14281 TOKEN_STRING_INITIALIZER 14282 (struct cmd_macsec_sc_result, 14283 tx_rx, "tx#rx"); 14284 cmdline_parse_token_num_t cmd_macsec_sc_port_id = 14285 TOKEN_NUM_INITIALIZER 14286 (struct cmd_macsec_sc_result, 14287 port_id, UINT16); 14288 cmdline_parse_token_etheraddr_t cmd_macsec_sc_mac = 14289 TOKEN_ETHERADDR_INITIALIZER 14290 (struct cmd_macsec_sc_result, 14291 mac); 14292 cmdline_parse_token_num_t cmd_macsec_sc_pi = 14293 TOKEN_NUM_INITIALIZER 14294 (struct cmd_macsec_sc_result, 14295 pi, UINT16); 14296 14297 static void 14298 cmd_set_macsec_sc_parsed( 14299 void *parsed_result, 14300 __attribute__((unused)) struct cmdline *cl, 14301 __attribute__((unused)) void *data) 14302 { 14303 struct cmd_macsec_sc_result *res = parsed_result; 14304 int ret = -ENOTSUP; 14305 int is_tx = (strcmp(res->tx_rx, "tx") == 0) ? 1 : 0; 14306 14307 #ifdef RTE_LIBRTE_IXGBE_PMD 14308 ret = is_tx ? 14309 rte_pmd_ixgbe_macsec_config_txsc(res->port_id, 14310 res->mac.addr_bytes) : 14311 rte_pmd_ixgbe_macsec_config_rxsc(res->port_id, 14312 res->mac.addr_bytes, res->pi); 14313 #endif 14314 RTE_SET_USED(is_tx); 14315 14316 switch (ret) { 14317 case 0: 14318 break; 14319 case -ENODEV: 14320 printf("invalid port_id %d\n", res->port_id); 14321 break; 14322 case -ENOTSUP: 14323 printf("not supported on port %d\n", res->port_id); 14324 break; 14325 default: 14326 printf("programming error: (%s)\n", strerror(-ret)); 14327 } 14328 } 14329 14330 cmdline_parse_inst_t cmd_set_macsec_sc = { 14331 .f = cmd_set_macsec_sc_parsed, 14332 .data = NULL, 14333 .help_str = "set macsec sc tx|rx <port_id> <mac> <pi>", 14334 .tokens = { 14335 (void *)&cmd_macsec_sc_set, 14336 (void *)&cmd_macsec_sc_macsec, 14337 (void *)&cmd_macsec_sc_sc, 14338 (void *)&cmd_macsec_sc_tx_rx, 14339 (void *)&cmd_macsec_sc_port_id, 14340 (void *)&cmd_macsec_sc_mac, 14341 (void *)&cmd_macsec_sc_pi, 14342 NULL, 14343 }, 14344 }; 14345 14346 /* Common result structure for MACsec secure connection configure */ 14347 struct cmd_macsec_sa_result { 14348 cmdline_fixed_string_t set; 14349 cmdline_fixed_string_t macsec; 14350 cmdline_fixed_string_t sa; 14351 cmdline_fixed_string_t tx_rx; 14352 portid_t port_id; 14353 uint8_t idx; 14354 uint8_t an; 14355 uint32_t pn; 14356 cmdline_fixed_string_t key; 14357 }; 14358 14359 /* Common CLI fields for MACsec secure connection configure */ 14360 cmdline_parse_token_string_t cmd_macsec_sa_set = 14361 TOKEN_STRING_INITIALIZER 14362 (struct cmd_macsec_sa_result, 14363 set, "set"); 14364 cmdline_parse_token_string_t cmd_macsec_sa_macsec = 14365 TOKEN_STRING_INITIALIZER 14366 (struct cmd_macsec_sa_result, 14367 macsec, "macsec"); 14368 cmdline_parse_token_string_t cmd_macsec_sa_sa = 14369 TOKEN_STRING_INITIALIZER 14370 (struct cmd_macsec_sa_result, 14371 sa, "sa"); 14372 cmdline_parse_token_string_t cmd_macsec_sa_tx_rx = 14373 TOKEN_STRING_INITIALIZER 14374 (struct cmd_macsec_sa_result, 14375 tx_rx, "tx#rx"); 14376 cmdline_parse_token_num_t cmd_macsec_sa_port_id = 14377 TOKEN_NUM_INITIALIZER 14378 (struct cmd_macsec_sa_result, 14379 port_id, UINT16); 14380 cmdline_parse_token_num_t cmd_macsec_sa_idx = 14381 TOKEN_NUM_INITIALIZER 14382 (struct cmd_macsec_sa_result, 14383 idx, UINT8); 14384 cmdline_parse_token_num_t cmd_macsec_sa_an = 14385 TOKEN_NUM_INITIALIZER 14386 (struct cmd_macsec_sa_result, 14387 an, UINT8); 14388 cmdline_parse_token_num_t cmd_macsec_sa_pn = 14389 TOKEN_NUM_INITIALIZER 14390 (struct cmd_macsec_sa_result, 14391 pn, UINT32); 14392 cmdline_parse_token_string_t cmd_macsec_sa_key = 14393 TOKEN_STRING_INITIALIZER 14394 (struct cmd_macsec_sa_result, 14395 key, NULL); 14396 14397 static void 14398 cmd_set_macsec_sa_parsed( 14399 void *parsed_result, 14400 __attribute__((unused)) struct cmdline *cl, 14401 __attribute__((unused)) void *data) 14402 { 14403 struct cmd_macsec_sa_result *res = parsed_result; 14404 int ret = -ENOTSUP; 14405 int is_tx = (strcmp(res->tx_rx, "tx") == 0) ? 1 : 0; 14406 uint8_t key[16] = { 0 }; 14407 uint8_t xdgt0; 14408 uint8_t xdgt1; 14409 int key_len; 14410 int i; 14411 14412 key_len = strlen(res->key) / 2; 14413 if (key_len > 16) 14414 key_len = 16; 14415 14416 for (i = 0; i < key_len; i++) { 14417 xdgt0 = parse_and_check_key_hexa_digit(res->key, (i * 2)); 14418 if (xdgt0 == 0xFF) 14419 return; 14420 xdgt1 = parse_and_check_key_hexa_digit(res->key, (i * 2) + 1); 14421 if (xdgt1 == 0xFF) 14422 return; 14423 key[i] = (uint8_t) ((xdgt0 * 16) + xdgt1); 14424 } 14425 14426 #ifdef RTE_LIBRTE_IXGBE_PMD 14427 ret = is_tx ? 14428 rte_pmd_ixgbe_macsec_select_txsa(res->port_id, 14429 res->idx, res->an, res->pn, key) : 14430 rte_pmd_ixgbe_macsec_select_rxsa(res->port_id, 14431 res->idx, res->an, res->pn, key); 14432 #endif 14433 RTE_SET_USED(is_tx); 14434 RTE_SET_USED(key); 14435 14436 switch (ret) { 14437 case 0: 14438 break; 14439 case -EINVAL: 14440 printf("invalid idx %d or an %d\n", res->idx, res->an); 14441 break; 14442 case -ENODEV: 14443 printf("invalid port_id %d\n", res->port_id); 14444 break; 14445 case -ENOTSUP: 14446 printf("not supported on port %d\n", res->port_id); 14447 break; 14448 default: 14449 printf("programming error: (%s)\n", strerror(-ret)); 14450 } 14451 } 14452 14453 cmdline_parse_inst_t cmd_set_macsec_sa = { 14454 .f = cmd_set_macsec_sa_parsed, 14455 .data = NULL, 14456 .help_str = "set macsec sa tx|rx <port_id> <idx> <an> <pn> <key>", 14457 .tokens = { 14458 (void *)&cmd_macsec_sa_set, 14459 (void *)&cmd_macsec_sa_macsec, 14460 (void *)&cmd_macsec_sa_sa, 14461 (void *)&cmd_macsec_sa_tx_rx, 14462 (void *)&cmd_macsec_sa_port_id, 14463 (void *)&cmd_macsec_sa_idx, 14464 (void *)&cmd_macsec_sa_an, 14465 (void *)&cmd_macsec_sa_pn, 14466 (void *)&cmd_macsec_sa_key, 14467 NULL, 14468 }, 14469 }; 14470 14471 /* VF unicast promiscuous mode configuration */ 14472 14473 /* Common result structure for VF unicast promiscuous mode */ 14474 struct cmd_vf_promisc_result { 14475 cmdline_fixed_string_t set; 14476 cmdline_fixed_string_t vf; 14477 cmdline_fixed_string_t promisc; 14478 portid_t port_id; 14479 uint32_t vf_id; 14480 cmdline_fixed_string_t on_off; 14481 }; 14482 14483 /* Common CLI fields for VF unicast promiscuous mode enable disable */ 14484 cmdline_parse_token_string_t cmd_vf_promisc_set = 14485 TOKEN_STRING_INITIALIZER 14486 (struct cmd_vf_promisc_result, 14487 set, "set"); 14488 cmdline_parse_token_string_t cmd_vf_promisc_vf = 14489 TOKEN_STRING_INITIALIZER 14490 (struct cmd_vf_promisc_result, 14491 vf, "vf"); 14492 cmdline_parse_token_string_t cmd_vf_promisc_promisc = 14493 TOKEN_STRING_INITIALIZER 14494 (struct cmd_vf_promisc_result, 14495 promisc, "promisc"); 14496 cmdline_parse_token_num_t cmd_vf_promisc_port_id = 14497 TOKEN_NUM_INITIALIZER 14498 (struct cmd_vf_promisc_result, 14499 port_id, UINT16); 14500 cmdline_parse_token_num_t cmd_vf_promisc_vf_id = 14501 TOKEN_NUM_INITIALIZER 14502 (struct cmd_vf_promisc_result, 14503 vf_id, UINT32); 14504 cmdline_parse_token_string_t cmd_vf_promisc_on_off = 14505 TOKEN_STRING_INITIALIZER 14506 (struct cmd_vf_promisc_result, 14507 on_off, "on#off"); 14508 14509 static void 14510 cmd_set_vf_promisc_parsed( 14511 void *parsed_result, 14512 __attribute__((unused)) struct cmdline *cl, 14513 __attribute__((unused)) void *data) 14514 { 14515 struct cmd_vf_promisc_result *res = parsed_result; 14516 int ret = -ENOTSUP; 14517 14518 __rte_unused int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0; 14519 14520 if (port_id_is_invalid(res->port_id, ENABLED_WARN)) 14521 return; 14522 14523 #ifdef RTE_LIBRTE_I40E_PMD 14524 ret = rte_pmd_i40e_set_vf_unicast_promisc(res->port_id, 14525 res->vf_id, is_on); 14526 #endif 14527 14528 switch (ret) { 14529 case 0: 14530 break; 14531 case -EINVAL: 14532 printf("invalid vf_id %d\n", res->vf_id); 14533 break; 14534 case -ENODEV: 14535 printf("invalid port_id %d\n", res->port_id); 14536 break; 14537 case -ENOTSUP: 14538 printf("function not implemented\n"); 14539 break; 14540 default: 14541 printf("programming error: (%s)\n", strerror(-ret)); 14542 } 14543 } 14544 14545 cmdline_parse_inst_t cmd_set_vf_promisc = { 14546 .f = cmd_set_vf_promisc_parsed, 14547 .data = NULL, 14548 .help_str = "set vf promisc <port_id> <vf_id> on|off: " 14549 "Set unicast promiscuous mode for a VF from the PF", 14550 .tokens = { 14551 (void *)&cmd_vf_promisc_set, 14552 (void *)&cmd_vf_promisc_vf, 14553 (void *)&cmd_vf_promisc_promisc, 14554 (void *)&cmd_vf_promisc_port_id, 14555 (void *)&cmd_vf_promisc_vf_id, 14556 (void *)&cmd_vf_promisc_on_off, 14557 NULL, 14558 }, 14559 }; 14560 14561 /* VF multicast promiscuous mode configuration */ 14562 14563 /* Common result structure for VF multicast promiscuous mode */ 14564 struct cmd_vf_allmulti_result { 14565 cmdline_fixed_string_t set; 14566 cmdline_fixed_string_t vf; 14567 cmdline_fixed_string_t allmulti; 14568 portid_t port_id; 14569 uint32_t vf_id; 14570 cmdline_fixed_string_t on_off; 14571 }; 14572 14573 /* Common CLI fields for VF multicast promiscuous mode enable disable */ 14574 cmdline_parse_token_string_t cmd_vf_allmulti_set = 14575 TOKEN_STRING_INITIALIZER 14576 (struct cmd_vf_allmulti_result, 14577 set, "set"); 14578 cmdline_parse_token_string_t cmd_vf_allmulti_vf = 14579 TOKEN_STRING_INITIALIZER 14580 (struct cmd_vf_allmulti_result, 14581 vf, "vf"); 14582 cmdline_parse_token_string_t cmd_vf_allmulti_allmulti = 14583 TOKEN_STRING_INITIALIZER 14584 (struct cmd_vf_allmulti_result, 14585 allmulti, "allmulti"); 14586 cmdline_parse_token_num_t cmd_vf_allmulti_port_id = 14587 TOKEN_NUM_INITIALIZER 14588 (struct cmd_vf_allmulti_result, 14589 port_id, UINT16); 14590 cmdline_parse_token_num_t cmd_vf_allmulti_vf_id = 14591 TOKEN_NUM_INITIALIZER 14592 (struct cmd_vf_allmulti_result, 14593 vf_id, UINT32); 14594 cmdline_parse_token_string_t cmd_vf_allmulti_on_off = 14595 TOKEN_STRING_INITIALIZER 14596 (struct cmd_vf_allmulti_result, 14597 on_off, "on#off"); 14598 14599 static void 14600 cmd_set_vf_allmulti_parsed( 14601 void *parsed_result, 14602 __attribute__((unused)) struct cmdline *cl, 14603 __attribute__((unused)) void *data) 14604 { 14605 struct cmd_vf_allmulti_result *res = parsed_result; 14606 int ret = -ENOTSUP; 14607 14608 __rte_unused int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0; 14609 14610 if (port_id_is_invalid(res->port_id, ENABLED_WARN)) 14611 return; 14612 14613 #ifdef RTE_LIBRTE_I40E_PMD 14614 ret = rte_pmd_i40e_set_vf_multicast_promisc(res->port_id, 14615 res->vf_id, is_on); 14616 #endif 14617 14618 switch (ret) { 14619 case 0: 14620 break; 14621 case -EINVAL: 14622 printf("invalid vf_id %d\n", res->vf_id); 14623 break; 14624 case -ENODEV: 14625 printf("invalid port_id %d\n", res->port_id); 14626 break; 14627 case -ENOTSUP: 14628 printf("function not implemented\n"); 14629 break; 14630 default: 14631 printf("programming error: (%s)\n", strerror(-ret)); 14632 } 14633 } 14634 14635 cmdline_parse_inst_t cmd_set_vf_allmulti = { 14636 .f = cmd_set_vf_allmulti_parsed, 14637 .data = NULL, 14638 .help_str = "set vf allmulti <port_id> <vf_id> on|off: " 14639 "Set multicast promiscuous mode for a VF from the PF", 14640 .tokens = { 14641 (void *)&cmd_vf_allmulti_set, 14642 (void *)&cmd_vf_allmulti_vf, 14643 (void *)&cmd_vf_allmulti_allmulti, 14644 (void *)&cmd_vf_allmulti_port_id, 14645 (void *)&cmd_vf_allmulti_vf_id, 14646 (void *)&cmd_vf_allmulti_on_off, 14647 NULL, 14648 }, 14649 }; 14650 14651 /* vf broadcast mode configuration */ 14652 14653 /* Common result structure for vf broadcast */ 14654 struct cmd_set_vf_broadcast_result { 14655 cmdline_fixed_string_t set; 14656 cmdline_fixed_string_t vf; 14657 cmdline_fixed_string_t broadcast; 14658 portid_t port_id; 14659 uint16_t vf_id; 14660 cmdline_fixed_string_t on_off; 14661 }; 14662 14663 /* Common CLI fields for vf broadcast enable disable */ 14664 cmdline_parse_token_string_t cmd_set_vf_broadcast_set = 14665 TOKEN_STRING_INITIALIZER 14666 (struct cmd_set_vf_broadcast_result, 14667 set, "set"); 14668 cmdline_parse_token_string_t cmd_set_vf_broadcast_vf = 14669 TOKEN_STRING_INITIALIZER 14670 (struct cmd_set_vf_broadcast_result, 14671 vf, "vf"); 14672 cmdline_parse_token_string_t cmd_set_vf_broadcast_broadcast = 14673 TOKEN_STRING_INITIALIZER 14674 (struct cmd_set_vf_broadcast_result, 14675 broadcast, "broadcast"); 14676 cmdline_parse_token_num_t cmd_set_vf_broadcast_port_id = 14677 TOKEN_NUM_INITIALIZER 14678 (struct cmd_set_vf_broadcast_result, 14679 port_id, UINT16); 14680 cmdline_parse_token_num_t cmd_set_vf_broadcast_vf_id = 14681 TOKEN_NUM_INITIALIZER 14682 (struct cmd_set_vf_broadcast_result, 14683 vf_id, UINT16); 14684 cmdline_parse_token_string_t cmd_set_vf_broadcast_on_off = 14685 TOKEN_STRING_INITIALIZER 14686 (struct cmd_set_vf_broadcast_result, 14687 on_off, "on#off"); 14688 14689 static void 14690 cmd_set_vf_broadcast_parsed( 14691 void *parsed_result, 14692 __attribute__((unused)) struct cmdline *cl, 14693 __attribute__((unused)) void *data) 14694 { 14695 struct cmd_set_vf_broadcast_result *res = parsed_result; 14696 int ret = -ENOTSUP; 14697 14698 __rte_unused int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0; 14699 14700 if (port_id_is_invalid(res->port_id, ENABLED_WARN)) 14701 return; 14702 14703 #ifdef RTE_LIBRTE_I40E_PMD 14704 ret = rte_pmd_i40e_set_vf_broadcast(res->port_id, 14705 res->vf_id, is_on); 14706 #endif 14707 14708 switch (ret) { 14709 case 0: 14710 break; 14711 case -EINVAL: 14712 printf("invalid vf_id %d or is_on %d\n", res->vf_id, is_on); 14713 break; 14714 case -ENODEV: 14715 printf("invalid port_id %d\n", res->port_id); 14716 break; 14717 case -ENOTSUP: 14718 printf("function not implemented\n"); 14719 break; 14720 default: 14721 printf("programming error: (%s)\n", strerror(-ret)); 14722 } 14723 } 14724 14725 cmdline_parse_inst_t cmd_set_vf_broadcast = { 14726 .f = cmd_set_vf_broadcast_parsed, 14727 .data = NULL, 14728 .help_str = "set vf broadcast <port_id> <vf_id> on|off", 14729 .tokens = { 14730 (void *)&cmd_set_vf_broadcast_set, 14731 (void *)&cmd_set_vf_broadcast_vf, 14732 (void *)&cmd_set_vf_broadcast_broadcast, 14733 (void *)&cmd_set_vf_broadcast_port_id, 14734 (void *)&cmd_set_vf_broadcast_vf_id, 14735 (void *)&cmd_set_vf_broadcast_on_off, 14736 NULL, 14737 }, 14738 }; 14739 14740 /* vf vlan tag configuration */ 14741 14742 /* Common result structure for vf vlan tag */ 14743 struct cmd_set_vf_vlan_tag_result { 14744 cmdline_fixed_string_t set; 14745 cmdline_fixed_string_t vf; 14746 cmdline_fixed_string_t vlan; 14747 cmdline_fixed_string_t tag; 14748 portid_t port_id; 14749 uint16_t vf_id; 14750 cmdline_fixed_string_t on_off; 14751 }; 14752 14753 /* Common CLI fields for vf vlan tag enable disable */ 14754 cmdline_parse_token_string_t cmd_set_vf_vlan_tag_set = 14755 TOKEN_STRING_INITIALIZER 14756 (struct cmd_set_vf_vlan_tag_result, 14757 set, "set"); 14758 cmdline_parse_token_string_t cmd_set_vf_vlan_tag_vf = 14759 TOKEN_STRING_INITIALIZER 14760 (struct cmd_set_vf_vlan_tag_result, 14761 vf, "vf"); 14762 cmdline_parse_token_string_t cmd_set_vf_vlan_tag_vlan = 14763 TOKEN_STRING_INITIALIZER 14764 (struct cmd_set_vf_vlan_tag_result, 14765 vlan, "vlan"); 14766 cmdline_parse_token_string_t cmd_set_vf_vlan_tag_tag = 14767 TOKEN_STRING_INITIALIZER 14768 (struct cmd_set_vf_vlan_tag_result, 14769 tag, "tag"); 14770 cmdline_parse_token_num_t cmd_set_vf_vlan_tag_port_id = 14771 TOKEN_NUM_INITIALIZER 14772 (struct cmd_set_vf_vlan_tag_result, 14773 port_id, UINT16); 14774 cmdline_parse_token_num_t cmd_set_vf_vlan_tag_vf_id = 14775 TOKEN_NUM_INITIALIZER 14776 (struct cmd_set_vf_vlan_tag_result, 14777 vf_id, UINT16); 14778 cmdline_parse_token_string_t cmd_set_vf_vlan_tag_on_off = 14779 TOKEN_STRING_INITIALIZER 14780 (struct cmd_set_vf_vlan_tag_result, 14781 on_off, "on#off"); 14782 14783 static void 14784 cmd_set_vf_vlan_tag_parsed( 14785 void *parsed_result, 14786 __attribute__((unused)) struct cmdline *cl, 14787 __attribute__((unused)) void *data) 14788 { 14789 struct cmd_set_vf_vlan_tag_result *res = parsed_result; 14790 int ret = -ENOTSUP; 14791 14792 __rte_unused int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0; 14793 14794 if (port_id_is_invalid(res->port_id, ENABLED_WARN)) 14795 return; 14796 14797 #ifdef RTE_LIBRTE_I40E_PMD 14798 ret = rte_pmd_i40e_set_vf_vlan_tag(res->port_id, 14799 res->vf_id, is_on); 14800 #endif 14801 14802 switch (ret) { 14803 case 0: 14804 break; 14805 case -EINVAL: 14806 printf("invalid vf_id %d or is_on %d\n", res->vf_id, is_on); 14807 break; 14808 case -ENODEV: 14809 printf("invalid port_id %d\n", res->port_id); 14810 break; 14811 case -ENOTSUP: 14812 printf("function not implemented\n"); 14813 break; 14814 default: 14815 printf("programming error: (%s)\n", strerror(-ret)); 14816 } 14817 } 14818 14819 cmdline_parse_inst_t cmd_set_vf_vlan_tag = { 14820 .f = cmd_set_vf_vlan_tag_parsed, 14821 .data = NULL, 14822 .help_str = "set vf vlan tag <port_id> <vf_id> on|off", 14823 .tokens = { 14824 (void *)&cmd_set_vf_vlan_tag_set, 14825 (void *)&cmd_set_vf_vlan_tag_vf, 14826 (void *)&cmd_set_vf_vlan_tag_vlan, 14827 (void *)&cmd_set_vf_vlan_tag_tag, 14828 (void *)&cmd_set_vf_vlan_tag_port_id, 14829 (void *)&cmd_set_vf_vlan_tag_vf_id, 14830 (void *)&cmd_set_vf_vlan_tag_on_off, 14831 NULL, 14832 }, 14833 }; 14834 14835 /* Common definition of VF and TC TX bandwidth configuration */ 14836 struct cmd_vf_tc_bw_result { 14837 cmdline_fixed_string_t set; 14838 cmdline_fixed_string_t vf; 14839 cmdline_fixed_string_t tc; 14840 cmdline_fixed_string_t tx; 14841 cmdline_fixed_string_t min_bw; 14842 cmdline_fixed_string_t max_bw; 14843 cmdline_fixed_string_t strict_link_prio; 14844 portid_t port_id; 14845 uint16_t vf_id; 14846 uint8_t tc_no; 14847 uint32_t bw; 14848 cmdline_fixed_string_t bw_list; 14849 uint8_t tc_map; 14850 }; 14851 14852 cmdline_parse_token_string_t cmd_vf_tc_bw_set = 14853 TOKEN_STRING_INITIALIZER 14854 (struct cmd_vf_tc_bw_result, 14855 set, "set"); 14856 cmdline_parse_token_string_t cmd_vf_tc_bw_vf = 14857 TOKEN_STRING_INITIALIZER 14858 (struct cmd_vf_tc_bw_result, 14859 vf, "vf"); 14860 cmdline_parse_token_string_t cmd_vf_tc_bw_tc = 14861 TOKEN_STRING_INITIALIZER 14862 (struct cmd_vf_tc_bw_result, 14863 tc, "tc"); 14864 cmdline_parse_token_string_t cmd_vf_tc_bw_tx = 14865 TOKEN_STRING_INITIALIZER 14866 (struct cmd_vf_tc_bw_result, 14867 tx, "tx"); 14868 cmdline_parse_token_string_t cmd_vf_tc_bw_strict_link_prio = 14869 TOKEN_STRING_INITIALIZER 14870 (struct cmd_vf_tc_bw_result, 14871 strict_link_prio, "strict-link-priority"); 14872 cmdline_parse_token_string_t cmd_vf_tc_bw_min_bw = 14873 TOKEN_STRING_INITIALIZER 14874 (struct cmd_vf_tc_bw_result, 14875 min_bw, "min-bandwidth"); 14876 cmdline_parse_token_string_t cmd_vf_tc_bw_max_bw = 14877 TOKEN_STRING_INITIALIZER 14878 (struct cmd_vf_tc_bw_result, 14879 max_bw, "max-bandwidth"); 14880 cmdline_parse_token_num_t cmd_vf_tc_bw_port_id = 14881 TOKEN_NUM_INITIALIZER 14882 (struct cmd_vf_tc_bw_result, 14883 port_id, UINT16); 14884 cmdline_parse_token_num_t cmd_vf_tc_bw_vf_id = 14885 TOKEN_NUM_INITIALIZER 14886 (struct cmd_vf_tc_bw_result, 14887 vf_id, UINT16); 14888 cmdline_parse_token_num_t cmd_vf_tc_bw_tc_no = 14889 TOKEN_NUM_INITIALIZER 14890 (struct cmd_vf_tc_bw_result, 14891 tc_no, UINT8); 14892 cmdline_parse_token_num_t cmd_vf_tc_bw_bw = 14893 TOKEN_NUM_INITIALIZER 14894 (struct cmd_vf_tc_bw_result, 14895 bw, UINT32); 14896 cmdline_parse_token_string_t cmd_vf_tc_bw_bw_list = 14897 TOKEN_STRING_INITIALIZER 14898 (struct cmd_vf_tc_bw_result, 14899 bw_list, NULL); 14900 cmdline_parse_token_num_t cmd_vf_tc_bw_tc_map = 14901 TOKEN_NUM_INITIALIZER 14902 (struct cmd_vf_tc_bw_result, 14903 tc_map, UINT8); 14904 14905 /* VF max bandwidth setting */ 14906 static void 14907 cmd_vf_max_bw_parsed( 14908 void *parsed_result, 14909 __attribute__((unused)) struct cmdline *cl, 14910 __attribute__((unused)) void *data) 14911 { 14912 struct cmd_vf_tc_bw_result *res = parsed_result; 14913 int ret = -ENOTSUP; 14914 14915 if (port_id_is_invalid(res->port_id, ENABLED_WARN)) 14916 return; 14917 14918 #ifdef RTE_LIBRTE_I40E_PMD 14919 ret = rte_pmd_i40e_set_vf_max_bw(res->port_id, 14920 res->vf_id, res->bw); 14921 #endif 14922 14923 switch (ret) { 14924 case 0: 14925 break; 14926 case -EINVAL: 14927 printf("invalid vf_id %d or bandwidth %d\n", 14928 res->vf_id, res->bw); 14929 break; 14930 case -ENODEV: 14931 printf("invalid port_id %d\n", res->port_id); 14932 break; 14933 case -ENOTSUP: 14934 printf("function not implemented\n"); 14935 break; 14936 default: 14937 printf("programming error: (%s)\n", strerror(-ret)); 14938 } 14939 } 14940 14941 cmdline_parse_inst_t cmd_vf_max_bw = { 14942 .f = cmd_vf_max_bw_parsed, 14943 .data = NULL, 14944 .help_str = "set vf tx max-bandwidth <port_id> <vf_id> <bandwidth>", 14945 .tokens = { 14946 (void *)&cmd_vf_tc_bw_set, 14947 (void *)&cmd_vf_tc_bw_vf, 14948 (void *)&cmd_vf_tc_bw_tx, 14949 (void *)&cmd_vf_tc_bw_max_bw, 14950 (void *)&cmd_vf_tc_bw_port_id, 14951 (void *)&cmd_vf_tc_bw_vf_id, 14952 (void *)&cmd_vf_tc_bw_bw, 14953 NULL, 14954 }, 14955 }; 14956 14957 static int 14958 vf_tc_min_bw_parse_bw_list(uint8_t *bw_list, 14959 uint8_t *tc_num, 14960 char *str) 14961 { 14962 uint32_t size; 14963 const char *p, *p0 = str; 14964 char s[256]; 14965 char *end; 14966 char *str_fld[16]; 14967 uint16_t i; 14968 int ret; 14969 14970 p = strchr(p0, '('); 14971 if (p == NULL) { 14972 printf("The bandwidth-list should be '(bw1, bw2, ...)'\n"); 14973 return -1; 14974 } 14975 p++; 14976 p0 = strchr(p, ')'); 14977 if (p0 == NULL) { 14978 printf("The bandwidth-list should be '(bw1, bw2, ...)'\n"); 14979 return -1; 14980 } 14981 size = p0 - p; 14982 if (size >= sizeof(s)) { 14983 printf("The string size exceeds the internal buffer size\n"); 14984 return -1; 14985 } 14986 snprintf(s, sizeof(s), "%.*s", size, p); 14987 ret = rte_strsplit(s, sizeof(s), str_fld, 16, ','); 14988 if (ret <= 0) { 14989 printf("Failed to get the bandwidth list. "); 14990 return -1; 14991 } 14992 *tc_num = ret; 14993 for (i = 0; i < ret; i++) 14994 bw_list[i] = (uint8_t)strtoul(str_fld[i], &end, 0); 14995 14996 return 0; 14997 } 14998 14999 /* TC min bandwidth setting */ 15000 static void 15001 cmd_vf_tc_min_bw_parsed( 15002 void *parsed_result, 15003 __attribute__((unused)) struct cmdline *cl, 15004 __attribute__((unused)) void *data) 15005 { 15006 struct cmd_vf_tc_bw_result *res = parsed_result; 15007 uint8_t tc_num; 15008 uint8_t bw[16]; 15009 int ret = -ENOTSUP; 15010 15011 if (port_id_is_invalid(res->port_id, ENABLED_WARN)) 15012 return; 15013 15014 ret = vf_tc_min_bw_parse_bw_list(bw, &tc_num, res->bw_list); 15015 if (ret) 15016 return; 15017 15018 #ifdef RTE_LIBRTE_I40E_PMD 15019 ret = rte_pmd_i40e_set_vf_tc_bw_alloc(res->port_id, res->vf_id, 15020 tc_num, bw); 15021 #endif 15022 15023 switch (ret) { 15024 case 0: 15025 break; 15026 case -EINVAL: 15027 printf("invalid vf_id %d or bandwidth\n", res->vf_id); 15028 break; 15029 case -ENODEV: 15030 printf("invalid port_id %d\n", res->port_id); 15031 break; 15032 case -ENOTSUP: 15033 printf("function not implemented\n"); 15034 break; 15035 default: 15036 printf("programming error: (%s)\n", strerror(-ret)); 15037 } 15038 } 15039 15040 cmdline_parse_inst_t cmd_vf_tc_min_bw = { 15041 .f = cmd_vf_tc_min_bw_parsed, 15042 .data = NULL, 15043 .help_str = "set vf tc tx min-bandwidth <port_id> <vf_id>" 15044 " <bw1, bw2, ...>", 15045 .tokens = { 15046 (void *)&cmd_vf_tc_bw_set, 15047 (void *)&cmd_vf_tc_bw_vf, 15048 (void *)&cmd_vf_tc_bw_tc, 15049 (void *)&cmd_vf_tc_bw_tx, 15050 (void *)&cmd_vf_tc_bw_min_bw, 15051 (void *)&cmd_vf_tc_bw_port_id, 15052 (void *)&cmd_vf_tc_bw_vf_id, 15053 (void *)&cmd_vf_tc_bw_bw_list, 15054 NULL, 15055 }, 15056 }; 15057 15058 static void 15059 cmd_tc_min_bw_parsed( 15060 void *parsed_result, 15061 __attribute__((unused)) struct cmdline *cl, 15062 __attribute__((unused)) void *data) 15063 { 15064 struct cmd_vf_tc_bw_result *res = parsed_result; 15065 struct rte_port *port; 15066 uint8_t tc_num; 15067 uint8_t bw[16]; 15068 int ret = -ENOTSUP; 15069 15070 if (port_id_is_invalid(res->port_id, ENABLED_WARN)) 15071 return; 15072 15073 port = &ports[res->port_id]; 15074 /** Check if the port is not started **/ 15075 if (port->port_status != RTE_PORT_STOPPED) { 15076 printf("Please stop port %d first\n", res->port_id); 15077 return; 15078 } 15079 15080 ret = vf_tc_min_bw_parse_bw_list(bw, &tc_num, res->bw_list); 15081 if (ret) 15082 return; 15083 15084 #ifdef RTE_LIBRTE_IXGBE_PMD 15085 ret = rte_pmd_ixgbe_set_tc_bw_alloc(res->port_id, tc_num, bw); 15086 #endif 15087 15088 switch (ret) { 15089 case 0: 15090 break; 15091 case -EINVAL: 15092 printf("invalid bandwidth\n"); 15093 break; 15094 case -ENODEV: 15095 printf("invalid port_id %d\n", res->port_id); 15096 break; 15097 case -ENOTSUP: 15098 printf("function not implemented\n"); 15099 break; 15100 default: 15101 printf("programming error: (%s)\n", strerror(-ret)); 15102 } 15103 } 15104 15105 cmdline_parse_inst_t cmd_tc_min_bw = { 15106 .f = cmd_tc_min_bw_parsed, 15107 .data = NULL, 15108 .help_str = "set tc tx min-bandwidth <port_id> <bw1, bw2, ...>", 15109 .tokens = { 15110 (void *)&cmd_vf_tc_bw_set, 15111 (void *)&cmd_vf_tc_bw_tc, 15112 (void *)&cmd_vf_tc_bw_tx, 15113 (void *)&cmd_vf_tc_bw_min_bw, 15114 (void *)&cmd_vf_tc_bw_port_id, 15115 (void *)&cmd_vf_tc_bw_bw_list, 15116 NULL, 15117 }, 15118 }; 15119 15120 /* TC max bandwidth setting */ 15121 static void 15122 cmd_vf_tc_max_bw_parsed( 15123 void *parsed_result, 15124 __attribute__((unused)) struct cmdline *cl, 15125 __attribute__((unused)) void *data) 15126 { 15127 struct cmd_vf_tc_bw_result *res = parsed_result; 15128 int ret = -ENOTSUP; 15129 15130 if (port_id_is_invalid(res->port_id, ENABLED_WARN)) 15131 return; 15132 15133 #ifdef RTE_LIBRTE_I40E_PMD 15134 ret = rte_pmd_i40e_set_vf_tc_max_bw(res->port_id, res->vf_id, 15135 res->tc_no, res->bw); 15136 #endif 15137 15138 switch (ret) { 15139 case 0: 15140 break; 15141 case -EINVAL: 15142 printf("invalid vf_id %d, tc_no %d or bandwidth %d\n", 15143 res->vf_id, res->tc_no, res->bw); 15144 break; 15145 case -ENODEV: 15146 printf("invalid port_id %d\n", res->port_id); 15147 break; 15148 case -ENOTSUP: 15149 printf("function not implemented\n"); 15150 break; 15151 default: 15152 printf("programming error: (%s)\n", strerror(-ret)); 15153 } 15154 } 15155 15156 cmdline_parse_inst_t cmd_vf_tc_max_bw = { 15157 .f = cmd_vf_tc_max_bw_parsed, 15158 .data = NULL, 15159 .help_str = "set vf tc tx max-bandwidth <port_id> <vf_id> <tc_no>" 15160 " <bandwidth>", 15161 .tokens = { 15162 (void *)&cmd_vf_tc_bw_set, 15163 (void *)&cmd_vf_tc_bw_vf, 15164 (void *)&cmd_vf_tc_bw_tc, 15165 (void *)&cmd_vf_tc_bw_tx, 15166 (void *)&cmd_vf_tc_bw_max_bw, 15167 (void *)&cmd_vf_tc_bw_port_id, 15168 (void *)&cmd_vf_tc_bw_vf_id, 15169 (void *)&cmd_vf_tc_bw_tc_no, 15170 (void *)&cmd_vf_tc_bw_bw, 15171 NULL, 15172 }, 15173 }; 15174 15175 15176 #if defined RTE_LIBRTE_PMD_SOFTNIC && defined RTE_LIBRTE_SCHED 15177 15178 /* *** Set Port default Traffic Management Hierarchy *** */ 15179 struct cmd_set_port_tm_hierarchy_default_result { 15180 cmdline_fixed_string_t set; 15181 cmdline_fixed_string_t port; 15182 cmdline_fixed_string_t tm; 15183 cmdline_fixed_string_t hierarchy; 15184 cmdline_fixed_string_t def; 15185 portid_t port_id; 15186 }; 15187 15188 cmdline_parse_token_string_t cmd_set_port_tm_hierarchy_default_set = 15189 TOKEN_STRING_INITIALIZER( 15190 struct cmd_set_port_tm_hierarchy_default_result, set, "set"); 15191 cmdline_parse_token_string_t cmd_set_port_tm_hierarchy_default_port = 15192 TOKEN_STRING_INITIALIZER( 15193 struct cmd_set_port_tm_hierarchy_default_result, port, "port"); 15194 cmdline_parse_token_string_t cmd_set_port_tm_hierarchy_default_tm = 15195 TOKEN_STRING_INITIALIZER( 15196 struct cmd_set_port_tm_hierarchy_default_result, tm, "tm"); 15197 cmdline_parse_token_string_t cmd_set_port_tm_hierarchy_default_hierarchy = 15198 TOKEN_STRING_INITIALIZER( 15199 struct cmd_set_port_tm_hierarchy_default_result, 15200 hierarchy, "hierarchy"); 15201 cmdline_parse_token_string_t cmd_set_port_tm_hierarchy_default_default = 15202 TOKEN_STRING_INITIALIZER( 15203 struct cmd_set_port_tm_hierarchy_default_result, 15204 def, "default"); 15205 cmdline_parse_token_num_t cmd_set_port_tm_hierarchy_default_port_id = 15206 TOKEN_NUM_INITIALIZER( 15207 struct cmd_set_port_tm_hierarchy_default_result, 15208 port_id, UINT16); 15209 15210 static void cmd_set_port_tm_hierarchy_default_parsed(void *parsed_result, 15211 __attribute__((unused)) struct cmdline *cl, 15212 __attribute__((unused)) void *data) 15213 { 15214 struct cmd_set_port_tm_hierarchy_default_result *res = parsed_result; 15215 struct rte_port *p; 15216 portid_t port_id = res->port_id; 15217 15218 if (port_id_is_invalid(port_id, ENABLED_WARN)) 15219 return; 15220 15221 p = &ports[port_id]; 15222 15223 /* Forward mode: tm */ 15224 if (strcmp(cur_fwd_config.fwd_eng->fwd_mode_name, "softnic")) { 15225 printf(" softnicfwd mode not enabled(error)\n"); 15226 return; 15227 } 15228 15229 /* Set the default tm hierarchy */ 15230 p->softport.default_tm_hierarchy_enable = 1; 15231 } 15232 15233 cmdline_parse_inst_t cmd_set_port_tm_hierarchy_default = { 15234 .f = cmd_set_port_tm_hierarchy_default_parsed, 15235 .data = NULL, 15236 .help_str = "set port tm hierarchy default <port_id>", 15237 .tokens = { 15238 (void *)&cmd_set_port_tm_hierarchy_default_set, 15239 (void *)&cmd_set_port_tm_hierarchy_default_port, 15240 (void *)&cmd_set_port_tm_hierarchy_default_tm, 15241 (void *)&cmd_set_port_tm_hierarchy_default_hierarchy, 15242 (void *)&cmd_set_port_tm_hierarchy_default_default, 15243 (void *)&cmd_set_port_tm_hierarchy_default_port_id, 15244 NULL, 15245 }, 15246 }; 15247 #endif 15248 15249 /** Set VXLAN encapsulation details */ 15250 struct cmd_set_vxlan_result { 15251 cmdline_fixed_string_t set; 15252 cmdline_fixed_string_t vxlan; 15253 cmdline_fixed_string_t pos_token; 15254 cmdline_fixed_string_t ip_version; 15255 uint32_t vlan_present:1; 15256 uint32_t vni; 15257 uint16_t udp_src; 15258 uint16_t udp_dst; 15259 cmdline_ipaddr_t ip_src; 15260 cmdline_ipaddr_t ip_dst; 15261 uint16_t tci; 15262 uint8_t tos; 15263 uint8_t ttl; 15264 struct rte_ether_addr eth_src; 15265 struct rte_ether_addr eth_dst; 15266 }; 15267 15268 cmdline_parse_token_string_t cmd_set_vxlan_set = 15269 TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, set, "set"); 15270 cmdline_parse_token_string_t cmd_set_vxlan_vxlan = 15271 TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, vxlan, "vxlan"); 15272 cmdline_parse_token_string_t cmd_set_vxlan_vxlan_tos_ttl = 15273 TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, vxlan, 15274 "vxlan-tos-ttl"); 15275 cmdline_parse_token_string_t cmd_set_vxlan_vxlan_with_vlan = 15276 TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, vxlan, 15277 "vxlan-with-vlan"); 15278 cmdline_parse_token_string_t cmd_set_vxlan_ip_version = 15279 TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, pos_token, 15280 "ip-version"); 15281 cmdline_parse_token_string_t cmd_set_vxlan_ip_version_value = 15282 TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, ip_version, 15283 "ipv4#ipv6"); 15284 cmdline_parse_token_string_t cmd_set_vxlan_vni = 15285 TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, pos_token, 15286 "vni"); 15287 cmdline_parse_token_num_t cmd_set_vxlan_vni_value = 15288 TOKEN_NUM_INITIALIZER(struct cmd_set_vxlan_result, vni, UINT32); 15289 cmdline_parse_token_string_t cmd_set_vxlan_udp_src = 15290 TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, pos_token, 15291 "udp-src"); 15292 cmdline_parse_token_num_t cmd_set_vxlan_udp_src_value = 15293 TOKEN_NUM_INITIALIZER(struct cmd_set_vxlan_result, udp_src, UINT16); 15294 cmdline_parse_token_string_t cmd_set_vxlan_udp_dst = 15295 TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, pos_token, 15296 "udp-dst"); 15297 cmdline_parse_token_num_t cmd_set_vxlan_udp_dst_value = 15298 TOKEN_NUM_INITIALIZER(struct cmd_set_vxlan_result, udp_dst, UINT16); 15299 cmdline_parse_token_string_t cmd_set_vxlan_ip_tos = 15300 TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, pos_token, 15301 "ip-tos"); 15302 cmdline_parse_token_num_t cmd_set_vxlan_ip_tos_value = 15303 TOKEN_NUM_INITIALIZER(struct cmd_set_vxlan_result, tos, UINT8); 15304 cmdline_parse_token_string_t cmd_set_vxlan_ip_ttl = 15305 TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, pos_token, 15306 "ip-ttl"); 15307 cmdline_parse_token_num_t cmd_set_vxlan_ip_ttl_value = 15308 TOKEN_NUM_INITIALIZER(struct cmd_set_vxlan_result, ttl, UINT8); 15309 cmdline_parse_token_string_t cmd_set_vxlan_ip_src = 15310 TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, pos_token, 15311 "ip-src"); 15312 cmdline_parse_token_ipaddr_t cmd_set_vxlan_ip_src_value = 15313 TOKEN_IPADDR_INITIALIZER(struct cmd_set_vxlan_result, ip_src); 15314 cmdline_parse_token_string_t cmd_set_vxlan_ip_dst = 15315 TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, pos_token, 15316 "ip-dst"); 15317 cmdline_parse_token_ipaddr_t cmd_set_vxlan_ip_dst_value = 15318 TOKEN_IPADDR_INITIALIZER(struct cmd_set_vxlan_result, ip_dst); 15319 cmdline_parse_token_string_t cmd_set_vxlan_vlan = 15320 TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, pos_token, 15321 "vlan-tci"); 15322 cmdline_parse_token_num_t cmd_set_vxlan_vlan_value = 15323 TOKEN_NUM_INITIALIZER(struct cmd_set_vxlan_result, tci, UINT16); 15324 cmdline_parse_token_string_t cmd_set_vxlan_eth_src = 15325 TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, pos_token, 15326 "eth-src"); 15327 cmdline_parse_token_etheraddr_t cmd_set_vxlan_eth_src_value = 15328 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_vxlan_result, eth_src); 15329 cmdline_parse_token_string_t cmd_set_vxlan_eth_dst = 15330 TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, pos_token, 15331 "eth-dst"); 15332 cmdline_parse_token_etheraddr_t cmd_set_vxlan_eth_dst_value = 15333 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_vxlan_result, eth_dst); 15334 15335 static void cmd_set_vxlan_parsed(void *parsed_result, 15336 __attribute__((unused)) struct cmdline *cl, 15337 __attribute__((unused)) void *data) 15338 { 15339 struct cmd_set_vxlan_result *res = parsed_result; 15340 union { 15341 uint32_t vxlan_id; 15342 uint8_t vni[4]; 15343 } id = { 15344 .vxlan_id = rte_cpu_to_be_32(res->vni) & RTE_BE32(0x00ffffff), 15345 }; 15346 15347 vxlan_encap_conf.select_tos_ttl = 0; 15348 if (strcmp(res->vxlan, "vxlan") == 0) 15349 vxlan_encap_conf.select_vlan = 0; 15350 else if (strcmp(res->vxlan, "vxlan-with-vlan") == 0) 15351 vxlan_encap_conf.select_vlan = 1; 15352 else if (strcmp(res->vxlan, "vxlan-tos-ttl") == 0) { 15353 vxlan_encap_conf.select_vlan = 0; 15354 vxlan_encap_conf.select_tos_ttl = 1; 15355 } 15356 if (strcmp(res->ip_version, "ipv4") == 0) 15357 vxlan_encap_conf.select_ipv4 = 1; 15358 else if (strcmp(res->ip_version, "ipv6") == 0) 15359 vxlan_encap_conf.select_ipv4 = 0; 15360 else 15361 return; 15362 rte_memcpy(vxlan_encap_conf.vni, &id.vni[1], 3); 15363 vxlan_encap_conf.udp_src = rte_cpu_to_be_16(res->udp_src); 15364 vxlan_encap_conf.udp_dst = rte_cpu_to_be_16(res->udp_dst); 15365 vxlan_encap_conf.ip_tos = res->tos; 15366 vxlan_encap_conf.ip_ttl = res->ttl; 15367 if (vxlan_encap_conf.select_ipv4) { 15368 IPV4_ADDR_TO_UINT(res->ip_src, vxlan_encap_conf.ipv4_src); 15369 IPV4_ADDR_TO_UINT(res->ip_dst, vxlan_encap_conf.ipv4_dst); 15370 } else { 15371 IPV6_ADDR_TO_ARRAY(res->ip_src, vxlan_encap_conf.ipv6_src); 15372 IPV6_ADDR_TO_ARRAY(res->ip_dst, vxlan_encap_conf.ipv6_dst); 15373 } 15374 if (vxlan_encap_conf.select_vlan) 15375 vxlan_encap_conf.vlan_tci = rte_cpu_to_be_16(res->tci); 15376 rte_memcpy(vxlan_encap_conf.eth_src, res->eth_src.addr_bytes, 15377 RTE_ETHER_ADDR_LEN); 15378 rte_memcpy(vxlan_encap_conf.eth_dst, res->eth_dst.addr_bytes, 15379 RTE_ETHER_ADDR_LEN); 15380 } 15381 15382 cmdline_parse_inst_t cmd_set_vxlan = { 15383 .f = cmd_set_vxlan_parsed, 15384 .data = NULL, 15385 .help_str = "set vxlan ip-version ipv4|ipv6 vni <vni> udp-src" 15386 " <udp-src> udp-dst <udp-dst> ip-src <ip-src> ip-dst <ip-dst>" 15387 " eth-src <eth-src> eth-dst <eth-dst>", 15388 .tokens = { 15389 (void *)&cmd_set_vxlan_set, 15390 (void *)&cmd_set_vxlan_vxlan, 15391 (void *)&cmd_set_vxlan_ip_version, 15392 (void *)&cmd_set_vxlan_ip_version_value, 15393 (void *)&cmd_set_vxlan_vni, 15394 (void *)&cmd_set_vxlan_vni_value, 15395 (void *)&cmd_set_vxlan_udp_src, 15396 (void *)&cmd_set_vxlan_udp_src_value, 15397 (void *)&cmd_set_vxlan_udp_dst, 15398 (void *)&cmd_set_vxlan_udp_dst_value, 15399 (void *)&cmd_set_vxlan_ip_src, 15400 (void *)&cmd_set_vxlan_ip_src_value, 15401 (void *)&cmd_set_vxlan_ip_dst, 15402 (void *)&cmd_set_vxlan_ip_dst_value, 15403 (void *)&cmd_set_vxlan_eth_src, 15404 (void *)&cmd_set_vxlan_eth_src_value, 15405 (void *)&cmd_set_vxlan_eth_dst, 15406 (void *)&cmd_set_vxlan_eth_dst_value, 15407 NULL, 15408 }, 15409 }; 15410 15411 cmdline_parse_inst_t cmd_set_vxlan_tos_ttl = { 15412 .f = cmd_set_vxlan_parsed, 15413 .data = NULL, 15414 .help_str = "set vxlan-tos-ttl ip-version ipv4|ipv6 vni <vni> udp-src" 15415 " <udp-src> udp-dst <udp-dst> ip-tos <ip-tos> ip-ttl <ip-ttl>" 15416 " ip-src <ip-src> ip-dst <ip-dst> eth-src <eth-src>" 15417 " eth-dst <eth-dst>", 15418 .tokens = { 15419 (void *)&cmd_set_vxlan_set, 15420 (void *)&cmd_set_vxlan_vxlan_tos_ttl, 15421 (void *)&cmd_set_vxlan_ip_version, 15422 (void *)&cmd_set_vxlan_ip_version_value, 15423 (void *)&cmd_set_vxlan_vni, 15424 (void *)&cmd_set_vxlan_vni_value, 15425 (void *)&cmd_set_vxlan_udp_src, 15426 (void *)&cmd_set_vxlan_udp_src_value, 15427 (void *)&cmd_set_vxlan_udp_dst, 15428 (void *)&cmd_set_vxlan_udp_dst_value, 15429 (void *)&cmd_set_vxlan_ip_tos, 15430 (void *)&cmd_set_vxlan_ip_tos_value, 15431 (void *)&cmd_set_vxlan_ip_ttl, 15432 (void *)&cmd_set_vxlan_ip_ttl_value, 15433 (void *)&cmd_set_vxlan_ip_src, 15434 (void *)&cmd_set_vxlan_ip_src_value, 15435 (void *)&cmd_set_vxlan_ip_dst, 15436 (void *)&cmd_set_vxlan_ip_dst_value, 15437 (void *)&cmd_set_vxlan_eth_src, 15438 (void *)&cmd_set_vxlan_eth_src_value, 15439 (void *)&cmd_set_vxlan_eth_dst, 15440 (void *)&cmd_set_vxlan_eth_dst_value, 15441 NULL, 15442 }, 15443 }; 15444 15445 cmdline_parse_inst_t cmd_set_vxlan_with_vlan = { 15446 .f = cmd_set_vxlan_parsed, 15447 .data = NULL, 15448 .help_str = "set vxlan-with-vlan ip-version ipv4|ipv6 vni <vni>" 15449 " udp-src <udp-src> udp-dst <udp-dst> ip-src <ip-src> ip-dst" 15450 " <ip-dst> vlan-tci <vlan-tci> eth-src <eth-src> eth-dst" 15451 " <eth-dst>", 15452 .tokens = { 15453 (void *)&cmd_set_vxlan_set, 15454 (void *)&cmd_set_vxlan_vxlan_with_vlan, 15455 (void *)&cmd_set_vxlan_ip_version, 15456 (void *)&cmd_set_vxlan_ip_version_value, 15457 (void *)&cmd_set_vxlan_vni, 15458 (void *)&cmd_set_vxlan_vni_value, 15459 (void *)&cmd_set_vxlan_udp_src, 15460 (void *)&cmd_set_vxlan_udp_src_value, 15461 (void *)&cmd_set_vxlan_udp_dst, 15462 (void *)&cmd_set_vxlan_udp_dst_value, 15463 (void *)&cmd_set_vxlan_ip_src, 15464 (void *)&cmd_set_vxlan_ip_src_value, 15465 (void *)&cmd_set_vxlan_ip_dst, 15466 (void *)&cmd_set_vxlan_ip_dst_value, 15467 (void *)&cmd_set_vxlan_vlan, 15468 (void *)&cmd_set_vxlan_vlan_value, 15469 (void *)&cmd_set_vxlan_eth_src, 15470 (void *)&cmd_set_vxlan_eth_src_value, 15471 (void *)&cmd_set_vxlan_eth_dst, 15472 (void *)&cmd_set_vxlan_eth_dst_value, 15473 NULL, 15474 }, 15475 }; 15476 15477 /** Set NVGRE encapsulation details */ 15478 struct cmd_set_nvgre_result { 15479 cmdline_fixed_string_t set; 15480 cmdline_fixed_string_t nvgre; 15481 cmdline_fixed_string_t pos_token; 15482 cmdline_fixed_string_t ip_version; 15483 uint32_t tni; 15484 cmdline_ipaddr_t ip_src; 15485 cmdline_ipaddr_t ip_dst; 15486 uint16_t tci; 15487 struct rte_ether_addr eth_src; 15488 struct rte_ether_addr eth_dst; 15489 }; 15490 15491 cmdline_parse_token_string_t cmd_set_nvgre_set = 15492 TOKEN_STRING_INITIALIZER(struct cmd_set_nvgre_result, set, "set"); 15493 cmdline_parse_token_string_t cmd_set_nvgre_nvgre = 15494 TOKEN_STRING_INITIALIZER(struct cmd_set_nvgre_result, nvgre, "nvgre"); 15495 cmdline_parse_token_string_t cmd_set_nvgre_nvgre_with_vlan = 15496 TOKEN_STRING_INITIALIZER(struct cmd_set_nvgre_result, nvgre, 15497 "nvgre-with-vlan"); 15498 cmdline_parse_token_string_t cmd_set_nvgre_ip_version = 15499 TOKEN_STRING_INITIALIZER(struct cmd_set_nvgre_result, pos_token, 15500 "ip-version"); 15501 cmdline_parse_token_string_t cmd_set_nvgre_ip_version_value = 15502 TOKEN_STRING_INITIALIZER(struct cmd_set_nvgre_result, ip_version, 15503 "ipv4#ipv6"); 15504 cmdline_parse_token_string_t cmd_set_nvgre_tni = 15505 TOKEN_STRING_INITIALIZER(struct cmd_set_nvgre_result, pos_token, 15506 "tni"); 15507 cmdline_parse_token_num_t cmd_set_nvgre_tni_value = 15508 TOKEN_NUM_INITIALIZER(struct cmd_set_nvgre_result, tni, UINT32); 15509 cmdline_parse_token_string_t cmd_set_nvgre_ip_src = 15510 TOKEN_STRING_INITIALIZER(struct cmd_set_nvgre_result, pos_token, 15511 "ip-src"); 15512 cmdline_parse_token_num_t cmd_set_nvgre_ip_src_value = 15513 TOKEN_IPADDR_INITIALIZER(struct cmd_set_nvgre_result, ip_src); 15514 cmdline_parse_token_string_t cmd_set_nvgre_ip_dst = 15515 TOKEN_STRING_INITIALIZER(struct cmd_set_nvgre_result, pos_token, 15516 "ip-dst"); 15517 cmdline_parse_token_ipaddr_t cmd_set_nvgre_ip_dst_value = 15518 TOKEN_IPADDR_INITIALIZER(struct cmd_set_nvgre_result, ip_dst); 15519 cmdline_parse_token_string_t cmd_set_nvgre_vlan = 15520 TOKEN_STRING_INITIALIZER(struct cmd_set_nvgre_result, pos_token, 15521 "vlan-tci"); 15522 cmdline_parse_token_num_t cmd_set_nvgre_vlan_value = 15523 TOKEN_NUM_INITIALIZER(struct cmd_set_nvgre_result, tci, UINT16); 15524 cmdline_parse_token_string_t cmd_set_nvgre_eth_src = 15525 TOKEN_STRING_INITIALIZER(struct cmd_set_nvgre_result, pos_token, 15526 "eth-src"); 15527 cmdline_parse_token_etheraddr_t cmd_set_nvgre_eth_src_value = 15528 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_nvgre_result, eth_src); 15529 cmdline_parse_token_string_t cmd_set_nvgre_eth_dst = 15530 TOKEN_STRING_INITIALIZER(struct cmd_set_nvgre_result, pos_token, 15531 "eth-dst"); 15532 cmdline_parse_token_etheraddr_t cmd_set_nvgre_eth_dst_value = 15533 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_nvgre_result, eth_dst); 15534 15535 static void cmd_set_nvgre_parsed(void *parsed_result, 15536 __attribute__((unused)) struct cmdline *cl, 15537 __attribute__((unused)) void *data) 15538 { 15539 struct cmd_set_nvgre_result *res = parsed_result; 15540 union { 15541 uint32_t nvgre_tni; 15542 uint8_t tni[4]; 15543 } id = { 15544 .nvgre_tni = rte_cpu_to_be_32(res->tni) & RTE_BE32(0x00ffffff), 15545 }; 15546 15547 if (strcmp(res->nvgre, "nvgre") == 0) 15548 nvgre_encap_conf.select_vlan = 0; 15549 else if (strcmp(res->nvgre, "nvgre-with-vlan") == 0) 15550 nvgre_encap_conf.select_vlan = 1; 15551 if (strcmp(res->ip_version, "ipv4") == 0) 15552 nvgre_encap_conf.select_ipv4 = 1; 15553 else if (strcmp(res->ip_version, "ipv6") == 0) 15554 nvgre_encap_conf.select_ipv4 = 0; 15555 else 15556 return; 15557 rte_memcpy(nvgre_encap_conf.tni, &id.tni[1], 3); 15558 if (nvgre_encap_conf.select_ipv4) { 15559 IPV4_ADDR_TO_UINT(res->ip_src, nvgre_encap_conf.ipv4_src); 15560 IPV4_ADDR_TO_UINT(res->ip_dst, nvgre_encap_conf.ipv4_dst); 15561 } else { 15562 IPV6_ADDR_TO_ARRAY(res->ip_src, nvgre_encap_conf.ipv6_src); 15563 IPV6_ADDR_TO_ARRAY(res->ip_dst, nvgre_encap_conf.ipv6_dst); 15564 } 15565 if (nvgre_encap_conf.select_vlan) 15566 nvgre_encap_conf.vlan_tci = rte_cpu_to_be_16(res->tci); 15567 rte_memcpy(nvgre_encap_conf.eth_src, res->eth_src.addr_bytes, 15568 RTE_ETHER_ADDR_LEN); 15569 rte_memcpy(nvgre_encap_conf.eth_dst, res->eth_dst.addr_bytes, 15570 RTE_ETHER_ADDR_LEN); 15571 } 15572 15573 cmdline_parse_inst_t cmd_set_nvgre = { 15574 .f = cmd_set_nvgre_parsed, 15575 .data = NULL, 15576 .help_str = "set nvgre ip-version <ipv4|ipv6> tni <tni> ip-src" 15577 " <ip-src> ip-dst <ip-dst> eth-src <eth-src>" 15578 " eth-dst <eth-dst>", 15579 .tokens = { 15580 (void *)&cmd_set_nvgre_set, 15581 (void *)&cmd_set_nvgre_nvgre, 15582 (void *)&cmd_set_nvgre_ip_version, 15583 (void *)&cmd_set_nvgre_ip_version_value, 15584 (void *)&cmd_set_nvgre_tni, 15585 (void *)&cmd_set_nvgre_tni_value, 15586 (void *)&cmd_set_nvgre_ip_src, 15587 (void *)&cmd_set_nvgre_ip_src_value, 15588 (void *)&cmd_set_nvgre_ip_dst, 15589 (void *)&cmd_set_nvgre_ip_dst_value, 15590 (void *)&cmd_set_nvgre_eth_src, 15591 (void *)&cmd_set_nvgre_eth_src_value, 15592 (void *)&cmd_set_nvgre_eth_dst, 15593 (void *)&cmd_set_nvgre_eth_dst_value, 15594 NULL, 15595 }, 15596 }; 15597 15598 cmdline_parse_inst_t cmd_set_nvgre_with_vlan = { 15599 .f = cmd_set_nvgre_parsed, 15600 .data = NULL, 15601 .help_str = "set nvgre-with-vlan ip-version <ipv4|ipv6> tni <tni>" 15602 " ip-src <ip-src> ip-dst <ip-dst> vlan-tci <vlan-tci>" 15603 " eth-src <eth-src> eth-dst <eth-dst>", 15604 .tokens = { 15605 (void *)&cmd_set_nvgre_set, 15606 (void *)&cmd_set_nvgre_nvgre_with_vlan, 15607 (void *)&cmd_set_nvgre_ip_version, 15608 (void *)&cmd_set_nvgre_ip_version_value, 15609 (void *)&cmd_set_nvgre_tni, 15610 (void *)&cmd_set_nvgre_tni_value, 15611 (void *)&cmd_set_nvgre_ip_src, 15612 (void *)&cmd_set_nvgre_ip_src_value, 15613 (void *)&cmd_set_nvgre_ip_dst, 15614 (void *)&cmd_set_nvgre_ip_dst_value, 15615 (void *)&cmd_set_nvgre_vlan, 15616 (void *)&cmd_set_nvgre_vlan_value, 15617 (void *)&cmd_set_nvgre_eth_src, 15618 (void *)&cmd_set_nvgre_eth_src_value, 15619 (void *)&cmd_set_nvgre_eth_dst, 15620 (void *)&cmd_set_nvgre_eth_dst_value, 15621 NULL, 15622 }, 15623 }; 15624 15625 /** Set L2 encapsulation details */ 15626 struct cmd_set_l2_encap_result { 15627 cmdline_fixed_string_t set; 15628 cmdline_fixed_string_t l2_encap; 15629 cmdline_fixed_string_t pos_token; 15630 cmdline_fixed_string_t ip_version; 15631 uint32_t vlan_present:1; 15632 uint16_t tci; 15633 struct rte_ether_addr eth_src; 15634 struct rte_ether_addr eth_dst; 15635 }; 15636 15637 cmdline_parse_token_string_t cmd_set_l2_encap_set = 15638 TOKEN_STRING_INITIALIZER(struct cmd_set_l2_encap_result, set, "set"); 15639 cmdline_parse_token_string_t cmd_set_l2_encap_l2_encap = 15640 TOKEN_STRING_INITIALIZER(struct cmd_set_l2_encap_result, l2_encap, "l2_encap"); 15641 cmdline_parse_token_string_t cmd_set_l2_encap_l2_encap_with_vlan = 15642 TOKEN_STRING_INITIALIZER(struct cmd_set_l2_encap_result, l2_encap, 15643 "l2_encap-with-vlan"); 15644 cmdline_parse_token_string_t cmd_set_l2_encap_ip_version = 15645 TOKEN_STRING_INITIALIZER(struct cmd_set_l2_encap_result, pos_token, 15646 "ip-version"); 15647 cmdline_parse_token_string_t cmd_set_l2_encap_ip_version_value = 15648 TOKEN_STRING_INITIALIZER(struct cmd_set_l2_encap_result, ip_version, 15649 "ipv4#ipv6"); 15650 cmdline_parse_token_string_t cmd_set_l2_encap_vlan = 15651 TOKEN_STRING_INITIALIZER(struct cmd_set_l2_encap_result, pos_token, 15652 "vlan-tci"); 15653 cmdline_parse_token_num_t cmd_set_l2_encap_vlan_value = 15654 TOKEN_NUM_INITIALIZER(struct cmd_set_l2_encap_result, tci, UINT16); 15655 cmdline_parse_token_string_t cmd_set_l2_encap_eth_src = 15656 TOKEN_STRING_INITIALIZER(struct cmd_set_l2_encap_result, pos_token, 15657 "eth-src"); 15658 cmdline_parse_token_etheraddr_t cmd_set_l2_encap_eth_src_value = 15659 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_l2_encap_result, eth_src); 15660 cmdline_parse_token_string_t cmd_set_l2_encap_eth_dst = 15661 TOKEN_STRING_INITIALIZER(struct cmd_set_l2_encap_result, pos_token, 15662 "eth-dst"); 15663 cmdline_parse_token_etheraddr_t cmd_set_l2_encap_eth_dst_value = 15664 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_l2_encap_result, eth_dst); 15665 15666 static void cmd_set_l2_encap_parsed(void *parsed_result, 15667 __attribute__((unused)) struct cmdline *cl, 15668 __attribute__((unused)) void *data) 15669 { 15670 struct cmd_set_l2_encap_result *res = parsed_result; 15671 15672 if (strcmp(res->l2_encap, "l2_encap") == 0) 15673 l2_encap_conf.select_vlan = 0; 15674 else if (strcmp(res->l2_encap, "l2_encap-with-vlan") == 0) 15675 l2_encap_conf.select_vlan = 1; 15676 if (strcmp(res->ip_version, "ipv4") == 0) 15677 l2_encap_conf.select_ipv4 = 1; 15678 else if (strcmp(res->ip_version, "ipv6") == 0) 15679 l2_encap_conf.select_ipv4 = 0; 15680 else 15681 return; 15682 if (l2_encap_conf.select_vlan) 15683 l2_encap_conf.vlan_tci = rte_cpu_to_be_16(res->tci); 15684 rte_memcpy(l2_encap_conf.eth_src, res->eth_src.addr_bytes, 15685 RTE_ETHER_ADDR_LEN); 15686 rte_memcpy(l2_encap_conf.eth_dst, res->eth_dst.addr_bytes, 15687 RTE_ETHER_ADDR_LEN); 15688 } 15689 15690 cmdline_parse_inst_t cmd_set_l2_encap = { 15691 .f = cmd_set_l2_encap_parsed, 15692 .data = NULL, 15693 .help_str = "set l2_encap ip-version ipv4|ipv6" 15694 " eth-src <eth-src> eth-dst <eth-dst>", 15695 .tokens = { 15696 (void *)&cmd_set_l2_encap_set, 15697 (void *)&cmd_set_l2_encap_l2_encap, 15698 (void *)&cmd_set_l2_encap_ip_version, 15699 (void *)&cmd_set_l2_encap_ip_version_value, 15700 (void *)&cmd_set_l2_encap_eth_src, 15701 (void *)&cmd_set_l2_encap_eth_src_value, 15702 (void *)&cmd_set_l2_encap_eth_dst, 15703 (void *)&cmd_set_l2_encap_eth_dst_value, 15704 NULL, 15705 }, 15706 }; 15707 15708 cmdline_parse_inst_t cmd_set_l2_encap_with_vlan = { 15709 .f = cmd_set_l2_encap_parsed, 15710 .data = NULL, 15711 .help_str = "set l2_encap-with-vlan ip-version ipv4|ipv6" 15712 " vlan-tci <vlan-tci> eth-src <eth-src> eth-dst <eth-dst>", 15713 .tokens = { 15714 (void *)&cmd_set_l2_encap_set, 15715 (void *)&cmd_set_l2_encap_l2_encap_with_vlan, 15716 (void *)&cmd_set_l2_encap_ip_version, 15717 (void *)&cmd_set_l2_encap_ip_version_value, 15718 (void *)&cmd_set_l2_encap_vlan, 15719 (void *)&cmd_set_l2_encap_vlan_value, 15720 (void *)&cmd_set_l2_encap_eth_src, 15721 (void *)&cmd_set_l2_encap_eth_src_value, 15722 (void *)&cmd_set_l2_encap_eth_dst, 15723 (void *)&cmd_set_l2_encap_eth_dst_value, 15724 NULL, 15725 }, 15726 }; 15727 15728 /** Set L2 decapsulation details */ 15729 struct cmd_set_l2_decap_result { 15730 cmdline_fixed_string_t set; 15731 cmdline_fixed_string_t l2_decap; 15732 cmdline_fixed_string_t pos_token; 15733 uint32_t vlan_present:1; 15734 }; 15735 15736 cmdline_parse_token_string_t cmd_set_l2_decap_set = 15737 TOKEN_STRING_INITIALIZER(struct cmd_set_l2_decap_result, set, "set"); 15738 cmdline_parse_token_string_t cmd_set_l2_decap_l2_decap = 15739 TOKEN_STRING_INITIALIZER(struct cmd_set_l2_decap_result, l2_decap, 15740 "l2_decap"); 15741 cmdline_parse_token_string_t cmd_set_l2_decap_l2_decap_with_vlan = 15742 TOKEN_STRING_INITIALIZER(struct cmd_set_l2_decap_result, l2_decap, 15743 "l2_decap-with-vlan"); 15744 15745 static void cmd_set_l2_decap_parsed(void *parsed_result, 15746 __attribute__((unused)) struct cmdline *cl, 15747 __attribute__((unused)) void *data) 15748 { 15749 struct cmd_set_l2_decap_result *res = parsed_result; 15750 15751 if (strcmp(res->l2_decap, "l2_decap") == 0) 15752 l2_decap_conf.select_vlan = 0; 15753 else if (strcmp(res->l2_decap, "l2_decap-with-vlan") == 0) 15754 l2_decap_conf.select_vlan = 1; 15755 } 15756 15757 cmdline_parse_inst_t cmd_set_l2_decap = { 15758 .f = cmd_set_l2_decap_parsed, 15759 .data = NULL, 15760 .help_str = "set l2_decap", 15761 .tokens = { 15762 (void *)&cmd_set_l2_decap_set, 15763 (void *)&cmd_set_l2_decap_l2_decap, 15764 NULL, 15765 }, 15766 }; 15767 15768 cmdline_parse_inst_t cmd_set_l2_decap_with_vlan = { 15769 .f = cmd_set_l2_decap_parsed, 15770 .data = NULL, 15771 .help_str = "set l2_decap-with-vlan", 15772 .tokens = { 15773 (void *)&cmd_set_l2_decap_set, 15774 (void *)&cmd_set_l2_decap_l2_decap_with_vlan, 15775 NULL, 15776 }, 15777 }; 15778 15779 /** Set MPLSoGRE encapsulation details */ 15780 struct cmd_set_mplsogre_encap_result { 15781 cmdline_fixed_string_t set; 15782 cmdline_fixed_string_t mplsogre; 15783 cmdline_fixed_string_t pos_token; 15784 cmdline_fixed_string_t ip_version; 15785 uint32_t vlan_present:1; 15786 uint32_t label; 15787 cmdline_ipaddr_t ip_src; 15788 cmdline_ipaddr_t ip_dst; 15789 uint16_t tci; 15790 struct rte_ether_addr eth_src; 15791 struct rte_ether_addr eth_dst; 15792 }; 15793 15794 cmdline_parse_token_string_t cmd_set_mplsogre_encap_set = 15795 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_encap_result, set, 15796 "set"); 15797 cmdline_parse_token_string_t cmd_set_mplsogre_encap_mplsogre_encap = 15798 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_encap_result, mplsogre, 15799 "mplsogre_encap"); 15800 cmdline_parse_token_string_t cmd_set_mplsogre_encap_mplsogre_encap_with_vlan = 15801 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_encap_result, 15802 mplsogre, "mplsogre_encap-with-vlan"); 15803 cmdline_parse_token_string_t cmd_set_mplsogre_encap_ip_version = 15804 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_encap_result, 15805 pos_token, "ip-version"); 15806 cmdline_parse_token_string_t cmd_set_mplsogre_encap_ip_version_value = 15807 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_encap_result, 15808 ip_version, "ipv4#ipv6"); 15809 cmdline_parse_token_string_t cmd_set_mplsogre_encap_label = 15810 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_encap_result, 15811 pos_token, "label"); 15812 cmdline_parse_token_num_t cmd_set_mplsogre_encap_label_value = 15813 TOKEN_NUM_INITIALIZER(struct cmd_set_mplsogre_encap_result, label, 15814 UINT32); 15815 cmdline_parse_token_string_t cmd_set_mplsogre_encap_ip_src = 15816 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_encap_result, 15817 pos_token, "ip-src"); 15818 cmdline_parse_token_ipaddr_t cmd_set_mplsogre_encap_ip_src_value = 15819 TOKEN_IPADDR_INITIALIZER(struct cmd_set_mplsogre_encap_result, ip_src); 15820 cmdline_parse_token_string_t cmd_set_mplsogre_encap_ip_dst = 15821 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_encap_result, 15822 pos_token, "ip-dst"); 15823 cmdline_parse_token_ipaddr_t cmd_set_mplsogre_encap_ip_dst_value = 15824 TOKEN_IPADDR_INITIALIZER(struct cmd_set_mplsogre_encap_result, ip_dst); 15825 cmdline_parse_token_string_t cmd_set_mplsogre_encap_vlan = 15826 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_encap_result, 15827 pos_token, "vlan-tci"); 15828 cmdline_parse_token_num_t cmd_set_mplsogre_encap_vlan_value = 15829 TOKEN_NUM_INITIALIZER(struct cmd_set_mplsogre_encap_result, tci, 15830 UINT16); 15831 cmdline_parse_token_string_t cmd_set_mplsogre_encap_eth_src = 15832 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_encap_result, 15833 pos_token, "eth-src"); 15834 cmdline_parse_token_etheraddr_t cmd_set_mplsogre_encap_eth_src_value = 15835 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_mplsogre_encap_result, 15836 eth_src); 15837 cmdline_parse_token_string_t cmd_set_mplsogre_encap_eth_dst = 15838 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_encap_result, 15839 pos_token, "eth-dst"); 15840 cmdline_parse_token_etheraddr_t cmd_set_mplsogre_encap_eth_dst_value = 15841 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_mplsogre_encap_result, 15842 eth_dst); 15843 15844 static void cmd_set_mplsogre_encap_parsed(void *parsed_result, 15845 __attribute__((unused)) struct cmdline *cl, 15846 __attribute__((unused)) void *data) 15847 { 15848 struct cmd_set_mplsogre_encap_result *res = parsed_result; 15849 union { 15850 uint32_t mplsogre_label; 15851 uint8_t label[4]; 15852 } id = { 15853 .mplsogre_label = rte_cpu_to_be_32(res->label<<12), 15854 }; 15855 15856 if (strcmp(res->mplsogre, "mplsogre_encap") == 0) 15857 mplsogre_encap_conf.select_vlan = 0; 15858 else if (strcmp(res->mplsogre, "mplsogre_encap-with-vlan") == 0) 15859 mplsogre_encap_conf.select_vlan = 1; 15860 if (strcmp(res->ip_version, "ipv4") == 0) 15861 mplsogre_encap_conf.select_ipv4 = 1; 15862 else if (strcmp(res->ip_version, "ipv6") == 0) 15863 mplsogre_encap_conf.select_ipv4 = 0; 15864 else 15865 return; 15866 rte_memcpy(mplsogre_encap_conf.label, &id.label, 3); 15867 if (mplsogre_encap_conf.select_ipv4) { 15868 IPV4_ADDR_TO_UINT(res->ip_src, mplsogre_encap_conf.ipv4_src); 15869 IPV4_ADDR_TO_UINT(res->ip_dst, mplsogre_encap_conf.ipv4_dst); 15870 } else { 15871 IPV6_ADDR_TO_ARRAY(res->ip_src, mplsogre_encap_conf.ipv6_src); 15872 IPV6_ADDR_TO_ARRAY(res->ip_dst, mplsogre_encap_conf.ipv6_dst); 15873 } 15874 if (mplsogre_encap_conf.select_vlan) 15875 mplsogre_encap_conf.vlan_tci = rte_cpu_to_be_16(res->tci); 15876 rte_memcpy(mplsogre_encap_conf.eth_src, res->eth_src.addr_bytes, 15877 RTE_ETHER_ADDR_LEN); 15878 rte_memcpy(mplsogre_encap_conf.eth_dst, res->eth_dst.addr_bytes, 15879 RTE_ETHER_ADDR_LEN); 15880 } 15881 15882 cmdline_parse_inst_t cmd_set_mplsogre_encap = { 15883 .f = cmd_set_mplsogre_encap_parsed, 15884 .data = NULL, 15885 .help_str = "set mplsogre_encap ip-version ipv4|ipv6 label <label>" 15886 " ip-src <ip-src> ip-dst <ip-dst> eth-src <eth-src>" 15887 " eth-dst <eth-dst>", 15888 .tokens = { 15889 (void *)&cmd_set_mplsogre_encap_set, 15890 (void *)&cmd_set_mplsogre_encap_mplsogre_encap, 15891 (void *)&cmd_set_mplsogre_encap_ip_version, 15892 (void *)&cmd_set_mplsogre_encap_ip_version_value, 15893 (void *)&cmd_set_mplsogre_encap_label, 15894 (void *)&cmd_set_mplsogre_encap_label_value, 15895 (void *)&cmd_set_mplsogre_encap_ip_src, 15896 (void *)&cmd_set_mplsogre_encap_ip_src_value, 15897 (void *)&cmd_set_mplsogre_encap_ip_dst, 15898 (void *)&cmd_set_mplsogre_encap_ip_dst_value, 15899 (void *)&cmd_set_mplsogre_encap_eth_src, 15900 (void *)&cmd_set_mplsogre_encap_eth_src_value, 15901 (void *)&cmd_set_mplsogre_encap_eth_dst, 15902 (void *)&cmd_set_mplsogre_encap_eth_dst_value, 15903 NULL, 15904 }, 15905 }; 15906 15907 cmdline_parse_inst_t cmd_set_mplsogre_encap_with_vlan = { 15908 .f = cmd_set_mplsogre_encap_parsed, 15909 .data = NULL, 15910 .help_str = "set mplsogre_encap-with-vlan ip-version ipv4|ipv6" 15911 " label <label> ip-src <ip-src> ip-dst <ip-dst>" 15912 " vlan-tci <vlan-tci> eth-src <eth-src> eth-dst <eth-dst>", 15913 .tokens = { 15914 (void *)&cmd_set_mplsogre_encap_set, 15915 (void *)&cmd_set_mplsogre_encap_mplsogre_encap_with_vlan, 15916 (void *)&cmd_set_mplsogre_encap_ip_version, 15917 (void *)&cmd_set_mplsogre_encap_ip_version_value, 15918 (void *)&cmd_set_mplsogre_encap_label, 15919 (void *)&cmd_set_mplsogre_encap_label_value, 15920 (void *)&cmd_set_mplsogre_encap_ip_src, 15921 (void *)&cmd_set_mplsogre_encap_ip_src_value, 15922 (void *)&cmd_set_mplsogre_encap_ip_dst, 15923 (void *)&cmd_set_mplsogre_encap_ip_dst_value, 15924 (void *)&cmd_set_mplsogre_encap_vlan, 15925 (void *)&cmd_set_mplsogre_encap_vlan_value, 15926 (void *)&cmd_set_mplsogre_encap_eth_src, 15927 (void *)&cmd_set_mplsogre_encap_eth_src_value, 15928 (void *)&cmd_set_mplsogre_encap_eth_dst, 15929 (void *)&cmd_set_mplsogre_encap_eth_dst_value, 15930 NULL, 15931 }, 15932 }; 15933 15934 /** Set MPLSoGRE decapsulation details */ 15935 struct cmd_set_mplsogre_decap_result { 15936 cmdline_fixed_string_t set; 15937 cmdline_fixed_string_t mplsogre; 15938 cmdline_fixed_string_t pos_token; 15939 cmdline_fixed_string_t ip_version; 15940 uint32_t vlan_present:1; 15941 }; 15942 15943 cmdline_parse_token_string_t cmd_set_mplsogre_decap_set = 15944 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_decap_result, set, 15945 "set"); 15946 cmdline_parse_token_string_t cmd_set_mplsogre_decap_mplsogre_decap = 15947 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_decap_result, mplsogre, 15948 "mplsogre_decap"); 15949 cmdline_parse_token_string_t cmd_set_mplsogre_decap_mplsogre_decap_with_vlan = 15950 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_decap_result, 15951 mplsogre, "mplsogre_decap-with-vlan"); 15952 cmdline_parse_token_string_t cmd_set_mplsogre_decap_ip_version = 15953 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_decap_result, 15954 pos_token, "ip-version"); 15955 cmdline_parse_token_string_t cmd_set_mplsogre_decap_ip_version_value = 15956 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_decap_result, 15957 ip_version, "ipv4#ipv6"); 15958 15959 static void cmd_set_mplsogre_decap_parsed(void *parsed_result, 15960 __attribute__((unused)) struct cmdline *cl, 15961 __attribute__((unused)) void *data) 15962 { 15963 struct cmd_set_mplsogre_decap_result *res = parsed_result; 15964 15965 if (strcmp(res->mplsogre, "mplsogre_decap") == 0) 15966 mplsogre_decap_conf.select_vlan = 0; 15967 else if (strcmp(res->mplsogre, "mplsogre_decap-with-vlan") == 0) 15968 mplsogre_decap_conf.select_vlan = 1; 15969 if (strcmp(res->ip_version, "ipv4") == 0) 15970 mplsogre_decap_conf.select_ipv4 = 1; 15971 else if (strcmp(res->ip_version, "ipv6") == 0) 15972 mplsogre_decap_conf.select_ipv4 = 0; 15973 } 15974 15975 cmdline_parse_inst_t cmd_set_mplsogre_decap = { 15976 .f = cmd_set_mplsogre_decap_parsed, 15977 .data = NULL, 15978 .help_str = "set mplsogre_decap ip-version ipv4|ipv6", 15979 .tokens = { 15980 (void *)&cmd_set_mplsogre_decap_set, 15981 (void *)&cmd_set_mplsogre_decap_mplsogre_decap, 15982 (void *)&cmd_set_mplsogre_decap_ip_version, 15983 (void *)&cmd_set_mplsogre_decap_ip_version_value, 15984 NULL, 15985 }, 15986 }; 15987 15988 cmdline_parse_inst_t cmd_set_mplsogre_decap_with_vlan = { 15989 .f = cmd_set_mplsogre_decap_parsed, 15990 .data = NULL, 15991 .help_str = "set mplsogre_decap-with-vlan ip-version ipv4|ipv6", 15992 .tokens = { 15993 (void *)&cmd_set_mplsogre_decap_set, 15994 (void *)&cmd_set_mplsogre_decap_mplsogre_decap_with_vlan, 15995 (void *)&cmd_set_mplsogre_decap_ip_version, 15996 (void *)&cmd_set_mplsogre_decap_ip_version_value, 15997 NULL, 15998 }, 15999 }; 16000 16001 /** Set MPLSoUDP encapsulation details */ 16002 struct cmd_set_mplsoudp_encap_result { 16003 cmdline_fixed_string_t set; 16004 cmdline_fixed_string_t mplsoudp; 16005 cmdline_fixed_string_t pos_token; 16006 cmdline_fixed_string_t ip_version; 16007 uint32_t vlan_present:1; 16008 uint32_t label; 16009 uint16_t udp_src; 16010 uint16_t udp_dst; 16011 cmdline_ipaddr_t ip_src; 16012 cmdline_ipaddr_t ip_dst; 16013 uint16_t tci; 16014 struct rte_ether_addr eth_src; 16015 struct rte_ether_addr eth_dst; 16016 }; 16017 16018 cmdline_parse_token_string_t cmd_set_mplsoudp_encap_set = 16019 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_encap_result, set, 16020 "set"); 16021 cmdline_parse_token_string_t cmd_set_mplsoudp_encap_mplsoudp_encap = 16022 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_encap_result, mplsoudp, 16023 "mplsoudp_encap"); 16024 cmdline_parse_token_string_t cmd_set_mplsoudp_encap_mplsoudp_encap_with_vlan = 16025 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_encap_result, 16026 mplsoudp, "mplsoudp_encap-with-vlan"); 16027 cmdline_parse_token_string_t cmd_set_mplsoudp_encap_ip_version = 16028 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_encap_result, 16029 pos_token, "ip-version"); 16030 cmdline_parse_token_string_t cmd_set_mplsoudp_encap_ip_version_value = 16031 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_encap_result, 16032 ip_version, "ipv4#ipv6"); 16033 cmdline_parse_token_string_t cmd_set_mplsoudp_encap_label = 16034 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_encap_result, 16035 pos_token, "label"); 16036 cmdline_parse_token_num_t cmd_set_mplsoudp_encap_label_value = 16037 TOKEN_NUM_INITIALIZER(struct cmd_set_mplsoudp_encap_result, label, 16038 UINT32); 16039 cmdline_parse_token_string_t cmd_set_mplsoudp_encap_udp_src = 16040 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_encap_result, 16041 pos_token, "udp-src"); 16042 cmdline_parse_token_num_t cmd_set_mplsoudp_encap_udp_src_value = 16043 TOKEN_NUM_INITIALIZER(struct cmd_set_mplsoudp_encap_result, udp_src, 16044 UINT16); 16045 cmdline_parse_token_string_t cmd_set_mplsoudp_encap_udp_dst = 16046 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_encap_result, 16047 pos_token, "udp-dst"); 16048 cmdline_parse_token_num_t cmd_set_mplsoudp_encap_udp_dst_value = 16049 TOKEN_NUM_INITIALIZER(struct cmd_set_mplsoudp_encap_result, udp_dst, 16050 UINT16); 16051 cmdline_parse_token_string_t cmd_set_mplsoudp_encap_ip_src = 16052 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_encap_result, 16053 pos_token, "ip-src"); 16054 cmdline_parse_token_ipaddr_t cmd_set_mplsoudp_encap_ip_src_value = 16055 TOKEN_IPADDR_INITIALIZER(struct cmd_set_mplsoudp_encap_result, ip_src); 16056 cmdline_parse_token_string_t cmd_set_mplsoudp_encap_ip_dst = 16057 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_encap_result, 16058 pos_token, "ip-dst"); 16059 cmdline_parse_token_ipaddr_t cmd_set_mplsoudp_encap_ip_dst_value = 16060 TOKEN_IPADDR_INITIALIZER(struct cmd_set_mplsoudp_encap_result, ip_dst); 16061 cmdline_parse_token_string_t cmd_set_mplsoudp_encap_vlan = 16062 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_encap_result, 16063 pos_token, "vlan-tci"); 16064 cmdline_parse_token_num_t cmd_set_mplsoudp_encap_vlan_value = 16065 TOKEN_NUM_INITIALIZER(struct cmd_set_mplsoudp_encap_result, tci, 16066 UINT16); 16067 cmdline_parse_token_string_t cmd_set_mplsoudp_encap_eth_src = 16068 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_encap_result, 16069 pos_token, "eth-src"); 16070 cmdline_parse_token_etheraddr_t cmd_set_mplsoudp_encap_eth_src_value = 16071 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_mplsoudp_encap_result, 16072 eth_src); 16073 cmdline_parse_token_string_t cmd_set_mplsoudp_encap_eth_dst = 16074 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_encap_result, 16075 pos_token, "eth-dst"); 16076 cmdline_parse_token_etheraddr_t cmd_set_mplsoudp_encap_eth_dst_value = 16077 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_mplsoudp_encap_result, 16078 eth_dst); 16079 16080 static void cmd_set_mplsoudp_encap_parsed(void *parsed_result, 16081 __attribute__((unused)) struct cmdline *cl, 16082 __attribute__((unused)) void *data) 16083 { 16084 struct cmd_set_mplsoudp_encap_result *res = parsed_result; 16085 union { 16086 uint32_t mplsoudp_label; 16087 uint8_t label[4]; 16088 } id = { 16089 .mplsoudp_label = rte_cpu_to_be_32(res->label<<12), 16090 }; 16091 16092 if (strcmp(res->mplsoudp, "mplsoudp_encap") == 0) 16093 mplsoudp_encap_conf.select_vlan = 0; 16094 else if (strcmp(res->mplsoudp, "mplsoudp_encap-with-vlan") == 0) 16095 mplsoudp_encap_conf.select_vlan = 1; 16096 if (strcmp(res->ip_version, "ipv4") == 0) 16097 mplsoudp_encap_conf.select_ipv4 = 1; 16098 else if (strcmp(res->ip_version, "ipv6") == 0) 16099 mplsoudp_encap_conf.select_ipv4 = 0; 16100 else 16101 return; 16102 rte_memcpy(mplsoudp_encap_conf.label, &id.label, 3); 16103 mplsoudp_encap_conf.udp_src = rte_cpu_to_be_16(res->udp_src); 16104 mplsoudp_encap_conf.udp_dst = rte_cpu_to_be_16(res->udp_dst); 16105 if (mplsoudp_encap_conf.select_ipv4) { 16106 IPV4_ADDR_TO_UINT(res->ip_src, mplsoudp_encap_conf.ipv4_src); 16107 IPV4_ADDR_TO_UINT(res->ip_dst, mplsoudp_encap_conf.ipv4_dst); 16108 } else { 16109 IPV6_ADDR_TO_ARRAY(res->ip_src, mplsoudp_encap_conf.ipv6_src); 16110 IPV6_ADDR_TO_ARRAY(res->ip_dst, mplsoudp_encap_conf.ipv6_dst); 16111 } 16112 if (mplsoudp_encap_conf.select_vlan) 16113 mplsoudp_encap_conf.vlan_tci = rte_cpu_to_be_16(res->tci); 16114 rte_memcpy(mplsoudp_encap_conf.eth_src, res->eth_src.addr_bytes, 16115 RTE_ETHER_ADDR_LEN); 16116 rte_memcpy(mplsoudp_encap_conf.eth_dst, res->eth_dst.addr_bytes, 16117 RTE_ETHER_ADDR_LEN); 16118 } 16119 16120 cmdline_parse_inst_t cmd_set_mplsoudp_encap = { 16121 .f = cmd_set_mplsoudp_encap_parsed, 16122 .data = NULL, 16123 .help_str = "set mplsoudp_encap ip-version ipv4|ipv6 label <label>" 16124 " udp-src <udp-src> udp-dst <udp-dst> ip-src <ip-src>" 16125 " ip-dst <ip-dst> eth-src <eth-src> eth-dst <eth-dst>", 16126 .tokens = { 16127 (void *)&cmd_set_mplsoudp_encap_set, 16128 (void *)&cmd_set_mplsoudp_encap_mplsoudp_encap, 16129 (void *)&cmd_set_mplsoudp_encap_ip_version, 16130 (void *)&cmd_set_mplsoudp_encap_ip_version_value, 16131 (void *)&cmd_set_mplsoudp_encap_label, 16132 (void *)&cmd_set_mplsoudp_encap_label_value, 16133 (void *)&cmd_set_mplsoudp_encap_udp_src, 16134 (void *)&cmd_set_mplsoudp_encap_udp_src_value, 16135 (void *)&cmd_set_mplsoudp_encap_udp_dst, 16136 (void *)&cmd_set_mplsoudp_encap_udp_dst_value, 16137 (void *)&cmd_set_mplsoudp_encap_ip_src, 16138 (void *)&cmd_set_mplsoudp_encap_ip_src_value, 16139 (void *)&cmd_set_mplsoudp_encap_ip_dst, 16140 (void *)&cmd_set_mplsoudp_encap_ip_dst_value, 16141 (void *)&cmd_set_mplsoudp_encap_eth_src, 16142 (void *)&cmd_set_mplsoudp_encap_eth_src_value, 16143 (void *)&cmd_set_mplsoudp_encap_eth_dst, 16144 (void *)&cmd_set_mplsoudp_encap_eth_dst_value, 16145 NULL, 16146 }, 16147 }; 16148 16149 cmdline_parse_inst_t cmd_set_mplsoudp_encap_with_vlan = { 16150 .f = cmd_set_mplsoudp_encap_parsed, 16151 .data = NULL, 16152 .help_str = "set mplsoudp_encap-with-vlan ip-version ipv4|ipv6" 16153 " label <label> udp-src <udp-src> udp-dst <udp-dst>" 16154 " ip-src <ip-src> ip-dst <ip-dst> vlan-tci <vlan-tci>" 16155 " eth-src <eth-src> eth-dst <eth-dst>", 16156 .tokens = { 16157 (void *)&cmd_set_mplsoudp_encap_set, 16158 (void *)&cmd_set_mplsoudp_encap_mplsoudp_encap_with_vlan, 16159 (void *)&cmd_set_mplsoudp_encap_ip_version, 16160 (void *)&cmd_set_mplsoudp_encap_ip_version_value, 16161 (void *)&cmd_set_mplsoudp_encap_label, 16162 (void *)&cmd_set_mplsoudp_encap_label_value, 16163 (void *)&cmd_set_mplsoudp_encap_udp_src, 16164 (void *)&cmd_set_mplsoudp_encap_udp_src_value, 16165 (void *)&cmd_set_mplsoudp_encap_udp_dst, 16166 (void *)&cmd_set_mplsoudp_encap_udp_dst_value, 16167 (void *)&cmd_set_mplsoudp_encap_ip_src, 16168 (void *)&cmd_set_mplsoudp_encap_ip_src_value, 16169 (void *)&cmd_set_mplsoudp_encap_ip_dst, 16170 (void *)&cmd_set_mplsoudp_encap_ip_dst_value, 16171 (void *)&cmd_set_mplsoudp_encap_vlan, 16172 (void *)&cmd_set_mplsoudp_encap_vlan_value, 16173 (void *)&cmd_set_mplsoudp_encap_eth_src, 16174 (void *)&cmd_set_mplsoudp_encap_eth_src_value, 16175 (void *)&cmd_set_mplsoudp_encap_eth_dst, 16176 (void *)&cmd_set_mplsoudp_encap_eth_dst_value, 16177 NULL, 16178 }, 16179 }; 16180 16181 /** Set MPLSoUDP decapsulation details */ 16182 struct cmd_set_mplsoudp_decap_result { 16183 cmdline_fixed_string_t set; 16184 cmdline_fixed_string_t mplsoudp; 16185 cmdline_fixed_string_t pos_token; 16186 cmdline_fixed_string_t ip_version; 16187 uint32_t vlan_present:1; 16188 }; 16189 16190 cmdline_parse_token_string_t cmd_set_mplsoudp_decap_set = 16191 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_decap_result, set, 16192 "set"); 16193 cmdline_parse_token_string_t cmd_set_mplsoudp_decap_mplsoudp_decap = 16194 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_decap_result, mplsoudp, 16195 "mplsoudp_decap"); 16196 cmdline_parse_token_string_t cmd_set_mplsoudp_decap_mplsoudp_decap_with_vlan = 16197 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_decap_result, 16198 mplsoudp, "mplsoudp_decap-with-vlan"); 16199 cmdline_parse_token_string_t cmd_set_mplsoudp_decap_ip_version = 16200 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_decap_result, 16201 pos_token, "ip-version"); 16202 cmdline_parse_token_string_t cmd_set_mplsoudp_decap_ip_version_value = 16203 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_decap_result, 16204 ip_version, "ipv4#ipv6"); 16205 16206 static void cmd_set_mplsoudp_decap_parsed(void *parsed_result, 16207 __attribute__((unused)) struct cmdline *cl, 16208 __attribute__((unused)) void *data) 16209 { 16210 struct cmd_set_mplsoudp_decap_result *res = parsed_result; 16211 16212 if (strcmp(res->mplsoudp, "mplsoudp_decap") == 0) 16213 mplsoudp_decap_conf.select_vlan = 0; 16214 else if (strcmp(res->mplsoudp, "mplsoudp_decap-with-vlan") == 0) 16215 mplsoudp_decap_conf.select_vlan = 1; 16216 if (strcmp(res->ip_version, "ipv4") == 0) 16217 mplsoudp_decap_conf.select_ipv4 = 1; 16218 else if (strcmp(res->ip_version, "ipv6") == 0) 16219 mplsoudp_decap_conf.select_ipv4 = 0; 16220 } 16221 16222 cmdline_parse_inst_t cmd_set_mplsoudp_decap = { 16223 .f = cmd_set_mplsoudp_decap_parsed, 16224 .data = NULL, 16225 .help_str = "set mplsoudp_decap ip-version ipv4|ipv6", 16226 .tokens = { 16227 (void *)&cmd_set_mplsoudp_decap_set, 16228 (void *)&cmd_set_mplsoudp_decap_mplsoudp_decap, 16229 (void *)&cmd_set_mplsoudp_decap_ip_version, 16230 (void *)&cmd_set_mplsoudp_decap_ip_version_value, 16231 NULL, 16232 }, 16233 }; 16234 16235 cmdline_parse_inst_t cmd_set_mplsoudp_decap_with_vlan = { 16236 .f = cmd_set_mplsoudp_decap_parsed, 16237 .data = NULL, 16238 .help_str = "set mplsoudp_decap-with-vlan ip-version ipv4|ipv6", 16239 .tokens = { 16240 (void *)&cmd_set_mplsoudp_decap_set, 16241 (void *)&cmd_set_mplsoudp_decap_mplsoudp_decap_with_vlan, 16242 (void *)&cmd_set_mplsoudp_decap_ip_version, 16243 (void *)&cmd_set_mplsoudp_decap_ip_version_value, 16244 NULL, 16245 }, 16246 }; 16247 16248 /* Strict link priority scheduling mode setting */ 16249 static void 16250 cmd_strict_link_prio_parsed( 16251 void *parsed_result, 16252 __attribute__((unused)) struct cmdline *cl, 16253 __attribute__((unused)) void *data) 16254 { 16255 struct cmd_vf_tc_bw_result *res = parsed_result; 16256 int ret = -ENOTSUP; 16257 16258 if (port_id_is_invalid(res->port_id, ENABLED_WARN)) 16259 return; 16260 16261 #ifdef RTE_LIBRTE_I40E_PMD 16262 ret = rte_pmd_i40e_set_tc_strict_prio(res->port_id, res->tc_map); 16263 #endif 16264 16265 switch (ret) { 16266 case 0: 16267 break; 16268 case -EINVAL: 16269 printf("invalid tc_bitmap 0x%x\n", res->tc_map); 16270 break; 16271 case -ENODEV: 16272 printf("invalid port_id %d\n", res->port_id); 16273 break; 16274 case -ENOTSUP: 16275 printf("function not implemented\n"); 16276 break; 16277 default: 16278 printf("programming error: (%s)\n", strerror(-ret)); 16279 } 16280 } 16281 16282 cmdline_parse_inst_t cmd_strict_link_prio = { 16283 .f = cmd_strict_link_prio_parsed, 16284 .data = NULL, 16285 .help_str = "set tx strict-link-priority <port_id> <tc_bitmap>", 16286 .tokens = { 16287 (void *)&cmd_vf_tc_bw_set, 16288 (void *)&cmd_vf_tc_bw_tx, 16289 (void *)&cmd_vf_tc_bw_strict_link_prio, 16290 (void *)&cmd_vf_tc_bw_port_id, 16291 (void *)&cmd_vf_tc_bw_tc_map, 16292 NULL, 16293 }, 16294 }; 16295 16296 /* Load dynamic device personalization*/ 16297 struct cmd_ddp_add_result { 16298 cmdline_fixed_string_t ddp; 16299 cmdline_fixed_string_t add; 16300 portid_t port_id; 16301 char filepath[]; 16302 }; 16303 16304 cmdline_parse_token_string_t cmd_ddp_add_ddp = 16305 TOKEN_STRING_INITIALIZER(struct cmd_ddp_add_result, ddp, "ddp"); 16306 cmdline_parse_token_string_t cmd_ddp_add_add = 16307 TOKEN_STRING_INITIALIZER(struct cmd_ddp_add_result, add, "add"); 16308 cmdline_parse_token_num_t cmd_ddp_add_port_id = 16309 TOKEN_NUM_INITIALIZER(struct cmd_ddp_add_result, port_id, UINT16); 16310 cmdline_parse_token_string_t cmd_ddp_add_filepath = 16311 TOKEN_STRING_INITIALIZER(struct cmd_ddp_add_result, filepath, NULL); 16312 16313 static void 16314 cmd_ddp_add_parsed( 16315 void *parsed_result, 16316 __attribute__((unused)) struct cmdline *cl, 16317 __attribute__((unused)) void *data) 16318 { 16319 struct cmd_ddp_add_result *res = parsed_result; 16320 uint8_t *buff; 16321 uint32_t size; 16322 char *filepath; 16323 char *file_fld[2]; 16324 int file_num; 16325 int ret = -ENOTSUP; 16326 16327 if (!all_ports_stopped()) { 16328 printf("Please stop all ports first\n"); 16329 return; 16330 } 16331 16332 filepath = strdup(res->filepath); 16333 if (filepath == NULL) { 16334 printf("Failed to allocate memory\n"); 16335 return; 16336 } 16337 file_num = rte_strsplit(filepath, strlen(filepath), file_fld, 2, ','); 16338 16339 buff = open_file(file_fld[0], &size); 16340 if (!buff) { 16341 free((void *)filepath); 16342 return; 16343 } 16344 16345 #ifdef RTE_LIBRTE_I40E_PMD 16346 if (ret == -ENOTSUP) 16347 ret = rte_pmd_i40e_process_ddp_package(res->port_id, 16348 buff, size, 16349 RTE_PMD_I40E_PKG_OP_WR_ADD); 16350 #endif 16351 16352 if (ret == -EEXIST) 16353 printf("Profile has already existed.\n"); 16354 else if (ret < 0) 16355 printf("Failed to load profile.\n"); 16356 else if (file_num == 2) 16357 save_file(file_fld[1], buff, size); 16358 16359 close_file(buff); 16360 free((void *)filepath); 16361 } 16362 16363 cmdline_parse_inst_t cmd_ddp_add = { 16364 .f = cmd_ddp_add_parsed, 16365 .data = NULL, 16366 .help_str = "ddp add <port_id> <profile_path[,backup_profile_path]>", 16367 .tokens = { 16368 (void *)&cmd_ddp_add_ddp, 16369 (void *)&cmd_ddp_add_add, 16370 (void *)&cmd_ddp_add_port_id, 16371 (void *)&cmd_ddp_add_filepath, 16372 NULL, 16373 }, 16374 }; 16375 16376 /* Delete dynamic device personalization*/ 16377 struct cmd_ddp_del_result { 16378 cmdline_fixed_string_t ddp; 16379 cmdline_fixed_string_t del; 16380 portid_t port_id; 16381 char filepath[]; 16382 }; 16383 16384 cmdline_parse_token_string_t cmd_ddp_del_ddp = 16385 TOKEN_STRING_INITIALIZER(struct cmd_ddp_del_result, ddp, "ddp"); 16386 cmdline_parse_token_string_t cmd_ddp_del_del = 16387 TOKEN_STRING_INITIALIZER(struct cmd_ddp_del_result, del, "del"); 16388 cmdline_parse_token_num_t cmd_ddp_del_port_id = 16389 TOKEN_NUM_INITIALIZER(struct cmd_ddp_del_result, port_id, UINT16); 16390 cmdline_parse_token_string_t cmd_ddp_del_filepath = 16391 TOKEN_STRING_INITIALIZER(struct cmd_ddp_del_result, filepath, NULL); 16392 16393 static void 16394 cmd_ddp_del_parsed( 16395 void *parsed_result, 16396 __attribute__((unused)) struct cmdline *cl, 16397 __attribute__((unused)) void *data) 16398 { 16399 struct cmd_ddp_del_result *res = parsed_result; 16400 uint8_t *buff; 16401 uint32_t size; 16402 int ret = -ENOTSUP; 16403 16404 if (!all_ports_stopped()) { 16405 printf("Please stop all ports first\n"); 16406 return; 16407 } 16408 16409 buff = open_file(res->filepath, &size); 16410 if (!buff) 16411 return; 16412 16413 #ifdef RTE_LIBRTE_I40E_PMD 16414 if (ret == -ENOTSUP) 16415 ret = rte_pmd_i40e_process_ddp_package(res->port_id, 16416 buff, size, 16417 RTE_PMD_I40E_PKG_OP_WR_DEL); 16418 #endif 16419 16420 if (ret == -EACCES) 16421 printf("Profile does not exist.\n"); 16422 else if (ret < 0) 16423 printf("Failed to delete profile.\n"); 16424 16425 close_file(buff); 16426 } 16427 16428 cmdline_parse_inst_t cmd_ddp_del = { 16429 .f = cmd_ddp_del_parsed, 16430 .data = NULL, 16431 .help_str = "ddp del <port_id> <backup_profile_path>", 16432 .tokens = { 16433 (void *)&cmd_ddp_del_ddp, 16434 (void *)&cmd_ddp_del_del, 16435 (void *)&cmd_ddp_del_port_id, 16436 (void *)&cmd_ddp_del_filepath, 16437 NULL, 16438 }, 16439 }; 16440 16441 /* Get dynamic device personalization profile info */ 16442 struct cmd_ddp_info_result { 16443 cmdline_fixed_string_t ddp; 16444 cmdline_fixed_string_t get; 16445 cmdline_fixed_string_t info; 16446 char filepath[]; 16447 }; 16448 16449 cmdline_parse_token_string_t cmd_ddp_info_ddp = 16450 TOKEN_STRING_INITIALIZER(struct cmd_ddp_info_result, ddp, "ddp"); 16451 cmdline_parse_token_string_t cmd_ddp_info_get = 16452 TOKEN_STRING_INITIALIZER(struct cmd_ddp_info_result, get, "get"); 16453 cmdline_parse_token_string_t cmd_ddp_info_info = 16454 TOKEN_STRING_INITIALIZER(struct cmd_ddp_info_result, info, "info"); 16455 cmdline_parse_token_string_t cmd_ddp_info_filepath = 16456 TOKEN_STRING_INITIALIZER(struct cmd_ddp_info_result, filepath, NULL); 16457 16458 static void 16459 cmd_ddp_info_parsed( 16460 void *parsed_result, 16461 __attribute__((unused)) struct cmdline *cl, 16462 __attribute__((unused)) void *data) 16463 { 16464 struct cmd_ddp_info_result *res = parsed_result; 16465 uint8_t *pkg; 16466 uint32_t pkg_size; 16467 int ret = -ENOTSUP; 16468 #ifdef RTE_LIBRTE_I40E_PMD 16469 uint32_t i, j, n; 16470 uint8_t *buff; 16471 uint32_t buff_size = 0; 16472 struct rte_pmd_i40e_profile_info info; 16473 uint32_t dev_num = 0; 16474 struct rte_pmd_i40e_ddp_device_id *devs; 16475 uint32_t proto_num = 0; 16476 struct rte_pmd_i40e_proto_info *proto = NULL; 16477 uint32_t pctype_num = 0; 16478 struct rte_pmd_i40e_ptype_info *pctype; 16479 uint32_t ptype_num = 0; 16480 struct rte_pmd_i40e_ptype_info *ptype; 16481 uint8_t proto_id; 16482 16483 #endif 16484 16485 pkg = open_file(res->filepath, &pkg_size); 16486 if (!pkg) 16487 return; 16488 16489 #ifdef RTE_LIBRTE_I40E_PMD 16490 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size, 16491 (uint8_t *)&info, sizeof(info), 16492 RTE_PMD_I40E_PKG_INFO_GLOBAL_HEADER); 16493 if (!ret) { 16494 printf("Global Track id: 0x%x\n", info.track_id); 16495 printf("Global Version: %d.%d.%d.%d\n", 16496 info.version.major, 16497 info.version.minor, 16498 info.version.update, 16499 info.version.draft); 16500 printf("Global Package name: %s\n\n", info.name); 16501 } 16502 16503 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size, 16504 (uint8_t *)&info, sizeof(info), 16505 RTE_PMD_I40E_PKG_INFO_HEADER); 16506 if (!ret) { 16507 printf("i40e Profile Track id: 0x%x\n", info.track_id); 16508 printf("i40e Profile Version: %d.%d.%d.%d\n", 16509 info.version.major, 16510 info.version.minor, 16511 info.version.update, 16512 info.version.draft); 16513 printf("i40e Profile name: %s\n\n", info.name); 16514 } 16515 16516 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size, 16517 (uint8_t *)&buff_size, sizeof(buff_size), 16518 RTE_PMD_I40E_PKG_INFO_GLOBAL_NOTES_SIZE); 16519 if (!ret && buff_size) { 16520 buff = (uint8_t *)malloc(buff_size); 16521 if (buff) { 16522 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size, 16523 buff, buff_size, 16524 RTE_PMD_I40E_PKG_INFO_GLOBAL_NOTES); 16525 if (!ret) 16526 printf("Package Notes:\n%s\n\n", buff); 16527 free(buff); 16528 } 16529 } 16530 16531 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size, 16532 (uint8_t *)&dev_num, sizeof(dev_num), 16533 RTE_PMD_I40E_PKG_INFO_DEVID_NUM); 16534 if (!ret && dev_num) { 16535 buff_size = dev_num * sizeof(struct rte_pmd_i40e_ddp_device_id); 16536 devs = (struct rte_pmd_i40e_ddp_device_id *)malloc(buff_size); 16537 if (devs) { 16538 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size, 16539 (uint8_t *)devs, buff_size, 16540 RTE_PMD_I40E_PKG_INFO_DEVID_LIST); 16541 if (!ret) { 16542 printf("List of supported devices:\n"); 16543 for (i = 0; i < dev_num; i++) { 16544 printf(" %04X:%04X %04X:%04X\n", 16545 devs[i].vendor_dev_id >> 16, 16546 devs[i].vendor_dev_id & 0xFFFF, 16547 devs[i].sub_vendor_dev_id >> 16, 16548 devs[i].sub_vendor_dev_id & 0xFFFF); 16549 } 16550 printf("\n"); 16551 } 16552 free(devs); 16553 } 16554 } 16555 16556 /* get information about protocols and packet types */ 16557 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size, 16558 (uint8_t *)&proto_num, sizeof(proto_num), 16559 RTE_PMD_I40E_PKG_INFO_PROTOCOL_NUM); 16560 if (ret || !proto_num) 16561 goto no_print_return; 16562 16563 buff_size = proto_num * sizeof(struct rte_pmd_i40e_proto_info); 16564 proto = (struct rte_pmd_i40e_proto_info *)malloc(buff_size); 16565 if (!proto) 16566 goto no_print_return; 16567 16568 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size, (uint8_t *)proto, 16569 buff_size, 16570 RTE_PMD_I40E_PKG_INFO_PROTOCOL_LIST); 16571 if (!ret) { 16572 printf("List of used protocols:\n"); 16573 for (i = 0; i < proto_num; i++) 16574 printf(" %2u: %s\n", proto[i].proto_id, 16575 proto[i].name); 16576 printf("\n"); 16577 } 16578 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size, 16579 (uint8_t *)&pctype_num, sizeof(pctype_num), 16580 RTE_PMD_I40E_PKG_INFO_PCTYPE_NUM); 16581 if (ret || !pctype_num) 16582 goto no_print_pctypes; 16583 16584 buff_size = pctype_num * sizeof(struct rte_pmd_i40e_ptype_info); 16585 pctype = (struct rte_pmd_i40e_ptype_info *)malloc(buff_size); 16586 if (!pctype) 16587 goto no_print_pctypes; 16588 16589 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size, (uint8_t *)pctype, 16590 buff_size, 16591 RTE_PMD_I40E_PKG_INFO_PCTYPE_LIST); 16592 if (ret) { 16593 free(pctype); 16594 goto no_print_pctypes; 16595 } 16596 16597 printf("List of defined packet classification types:\n"); 16598 for (i = 0; i < pctype_num; i++) { 16599 printf(" %2u:", pctype[i].ptype_id); 16600 for (j = 0; j < RTE_PMD_I40E_PROTO_NUM; j++) { 16601 proto_id = pctype[i].protocols[j]; 16602 if (proto_id != RTE_PMD_I40E_PROTO_UNUSED) { 16603 for (n = 0; n < proto_num; n++) { 16604 if (proto[n].proto_id == proto_id) { 16605 printf(" %s", proto[n].name); 16606 break; 16607 } 16608 } 16609 } 16610 } 16611 printf("\n"); 16612 } 16613 printf("\n"); 16614 free(pctype); 16615 16616 no_print_pctypes: 16617 16618 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size, (uint8_t *)&ptype_num, 16619 sizeof(ptype_num), 16620 RTE_PMD_I40E_PKG_INFO_PTYPE_NUM); 16621 if (ret || !ptype_num) 16622 goto no_print_return; 16623 16624 buff_size = ptype_num * sizeof(struct rte_pmd_i40e_ptype_info); 16625 ptype = (struct rte_pmd_i40e_ptype_info *)malloc(buff_size); 16626 if (!ptype) 16627 goto no_print_return; 16628 16629 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size, (uint8_t *)ptype, 16630 buff_size, 16631 RTE_PMD_I40E_PKG_INFO_PTYPE_LIST); 16632 if (ret) { 16633 free(ptype); 16634 goto no_print_return; 16635 } 16636 printf("List of defined packet types:\n"); 16637 for (i = 0; i < ptype_num; i++) { 16638 printf(" %2u:", ptype[i].ptype_id); 16639 for (j = 0; j < RTE_PMD_I40E_PROTO_NUM; j++) { 16640 proto_id = ptype[i].protocols[j]; 16641 if (proto_id != RTE_PMD_I40E_PROTO_UNUSED) { 16642 for (n = 0; n < proto_num; n++) { 16643 if (proto[n].proto_id == proto_id) { 16644 printf(" %s", proto[n].name); 16645 break; 16646 } 16647 } 16648 } 16649 } 16650 printf("\n"); 16651 } 16652 free(ptype); 16653 printf("\n"); 16654 16655 ret = 0; 16656 no_print_return: 16657 if (proto) 16658 free(proto); 16659 #endif 16660 if (ret == -ENOTSUP) 16661 printf("Function not supported in PMD driver\n"); 16662 close_file(pkg); 16663 } 16664 16665 cmdline_parse_inst_t cmd_ddp_get_info = { 16666 .f = cmd_ddp_info_parsed, 16667 .data = NULL, 16668 .help_str = "ddp get info <profile_path>", 16669 .tokens = { 16670 (void *)&cmd_ddp_info_ddp, 16671 (void *)&cmd_ddp_info_get, 16672 (void *)&cmd_ddp_info_info, 16673 (void *)&cmd_ddp_info_filepath, 16674 NULL, 16675 }, 16676 }; 16677 16678 /* Get dynamic device personalization profile info list*/ 16679 #define PROFILE_INFO_SIZE 48 16680 #define MAX_PROFILE_NUM 16 16681 16682 struct cmd_ddp_get_list_result { 16683 cmdline_fixed_string_t ddp; 16684 cmdline_fixed_string_t get; 16685 cmdline_fixed_string_t list; 16686 portid_t port_id; 16687 }; 16688 16689 cmdline_parse_token_string_t cmd_ddp_get_list_ddp = 16690 TOKEN_STRING_INITIALIZER(struct cmd_ddp_get_list_result, ddp, "ddp"); 16691 cmdline_parse_token_string_t cmd_ddp_get_list_get = 16692 TOKEN_STRING_INITIALIZER(struct cmd_ddp_get_list_result, get, "get"); 16693 cmdline_parse_token_string_t cmd_ddp_get_list_list = 16694 TOKEN_STRING_INITIALIZER(struct cmd_ddp_get_list_result, list, "list"); 16695 cmdline_parse_token_num_t cmd_ddp_get_list_port_id = 16696 TOKEN_NUM_INITIALIZER(struct cmd_ddp_get_list_result, port_id, UINT16); 16697 16698 static void 16699 cmd_ddp_get_list_parsed( 16700 __attribute__((unused)) void *parsed_result, 16701 __attribute__((unused)) struct cmdline *cl, 16702 __attribute__((unused)) void *data) 16703 { 16704 #ifdef RTE_LIBRTE_I40E_PMD 16705 struct cmd_ddp_get_list_result *res = parsed_result; 16706 struct rte_pmd_i40e_profile_list *p_list; 16707 struct rte_pmd_i40e_profile_info *p_info; 16708 uint32_t p_num; 16709 uint32_t size; 16710 uint32_t i; 16711 #endif 16712 int ret = -ENOTSUP; 16713 16714 #ifdef RTE_LIBRTE_I40E_PMD 16715 size = PROFILE_INFO_SIZE * MAX_PROFILE_NUM + 4; 16716 p_list = (struct rte_pmd_i40e_profile_list *)malloc(size); 16717 if (!p_list) 16718 printf("%s: Failed to malloc buffer\n", __func__); 16719 16720 if (ret == -ENOTSUP) 16721 ret = rte_pmd_i40e_get_ddp_list(res->port_id, 16722 (uint8_t *)p_list, size); 16723 16724 if (!ret) { 16725 p_num = p_list->p_count; 16726 printf("Profile number is: %d\n\n", p_num); 16727 16728 for (i = 0; i < p_num; i++) { 16729 p_info = &p_list->p_info[i]; 16730 printf("Profile %d:\n", i); 16731 printf("Track id: 0x%x\n", p_info->track_id); 16732 printf("Version: %d.%d.%d.%d\n", 16733 p_info->version.major, 16734 p_info->version.minor, 16735 p_info->version.update, 16736 p_info->version.draft); 16737 printf("Profile name: %s\n\n", p_info->name); 16738 } 16739 } 16740 16741 free(p_list); 16742 #endif 16743 16744 if (ret < 0) 16745 printf("Failed to get ddp list\n"); 16746 } 16747 16748 cmdline_parse_inst_t cmd_ddp_get_list = { 16749 .f = cmd_ddp_get_list_parsed, 16750 .data = NULL, 16751 .help_str = "ddp get list <port_id>", 16752 .tokens = { 16753 (void *)&cmd_ddp_get_list_ddp, 16754 (void *)&cmd_ddp_get_list_get, 16755 (void *)&cmd_ddp_get_list_list, 16756 (void *)&cmd_ddp_get_list_port_id, 16757 NULL, 16758 }, 16759 }; 16760 16761 /* Configure input set */ 16762 struct cmd_cfg_input_set_result { 16763 cmdline_fixed_string_t port; 16764 cmdline_fixed_string_t cfg; 16765 portid_t port_id; 16766 cmdline_fixed_string_t pctype; 16767 uint8_t pctype_id; 16768 cmdline_fixed_string_t inset_type; 16769 cmdline_fixed_string_t opt; 16770 cmdline_fixed_string_t field; 16771 uint8_t field_idx; 16772 }; 16773 16774 static void 16775 cmd_cfg_input_set_parsed( 16776 __attribute__((unused)) void *parsed_result, 16777 __attribute__((unused)) struct cmdline *cl, 16778 __attribute__((unused)) void *data) 16779 { 16780 #ifdef RTE_LIBRTE_I40E_PMD 16781 struct cmd_cfg_input_set_result *res = parsed_result; 16782 enum rte_pmd_i40e_inset_type inset_type = INSET_NONE; 16783 struct rte_pmd_i40e_inset inset; 16784 #endif 16785 int ret = -ENOTSUP; 16786 16787 if (!all_ports_stopped()) { 16788 printf("Please stop all ports first\n"); 16789 return; 16790 } 16791 16792 #ifdef RTE_LIBRTE_I40E_PMD 16793 if (!strcmp(res->inset_type, "hash_inset")) 16794 inset_type = INSET_HASH; 16795 else if (!strcmp(res->inset_type, "fdir_inset")) 16796 inset_type = INSET_FDIR; 16797 else if (!strcmp(res->inset_type, "fdir_flx_inset")) 16798 inset_type = INSET_FDIR_FLX; 16799 ret = rte_pmd_i40e_inset_get(res->port_id, res->pctype_id, 16800 &inset, inset_type); 16801 if (ret) { 16802 printf("Failed to get input set.\n"); 16803 return; 16804 } 16805 16806 if (!strcmp(res->opt, "get")) { 16807 ret = rte_pmd_i40e_inset_field_get(inset.inset, 16808 res->field_idx); 16809 if (ret) 16810 printf("Field index %d is enabled.\n", res->field_idx); 16811 else 16812 printf("Field index %d is disabled.\n", res->field_idx); 16813 return; 16814 } else if (!strcmp(res->opt, "set")) 16815 ret = rte_pmd_i40e_inset_field_set(&inset.inset, 16816 res->field_idx); 16817 else if (!strcmp(res->opt, "clear")) 16818 ret = rte_pmd_i40e_inset_field_clear(&inset.inset, 16819 res->field_idx); 16820 if (ret) { 16821 printf("Failed to configure input set field.\n"); 16822 return; 16823 } 16824 16825 ret = rte_pmd_i40e_inset_set(res->port_id, res->pctype_id, 16826 &inset, inset_type); 16827 if (ret) { 16828 printf("Failed to set input set.\n"); 16829 return; 16830 } 16831 #endif 16832 16833 if (ret == -ENOTSUP) 16834 printf("Function not supported\n"); 16835 } 16836 16837 cmdline_parse_token_string_t cmd_cfg_input_set_port = 16838 TOKEN_STRING_INITIALIZER(struct cmd_cfg_input_set_result, 16839 port, "port"); 16840 cmdline_parse_token_string_t cmd_cfg_input_set_cfg = 16841 TOKEN_STRING_INITIALIZER(struct cmd_cfg_input_set_result, 16842 cfg, "config"); 16843 cmdline_parse_token_num_t cmd_cfg_input_set_port_id = 16844 TOKEN_NUM_INITIALIZER(struct cmd_cfg_input_set_result, 16845 port_id, UINT16); 16846 cmdline_parse_token_string_t cmd_cfg_input_set_pctype = 16847 TOKEN_STRING_INITIALIZER(struct cmd_cfg_input_set_result, 16848 pctype, "pctype"); 16849 cmdline_parse_token_num_t cmd_cfg_input_set_pctype_id = 16850 TOKEN_NUM_INITIALIZER(struct cmd_cfg_input_set_result, 16851 pctype_id, UINT8); 16852 cmdline_parse_token_string_t cmd_cfg_input_set_inset_type = 16853 TOKEN_STRING_INITIALIZER(struct cmd_cfg_input_set_result, 16854 inset_type, 16855 "hash_inset#fdir_inset#fdir_flx_inset"); 16856 cmdline_parse_token_string_t cmd_cfg_input_set_opt = 16857 TOKEN_STRING_INITIALIZER(struct cmd_cfg_input_set_result, 16858 opt, "get#set#clear"); 16859 cmdline_parse_token_string_t cmd_cfg_input_set_field = 16860 TOKEN_STRING_INITIALIZER(struct cmd_cfg_input_set_result, 16861 field, "field"); 16862 cmdline_parse_token_num_t cmd_cfg_input_set_field_idx = 16863 TOKEN_NUM_INITIALIZER(struct cmd_cfg_input_set_result, 16864 field_idx, UINT8); 16865 16866 cmdline_parse_inst_t cmd_cfg_input_set = { 16867 .f = cmd_cfg_input_set_parsed, 16868 .data = NULL, 16869 .help_str = "port config <port_id> pctype <pctype_id> hash_inset|" 16870 "fdir_inset|fdir_flx_inset get|set|clear field <field_idx>", 16871 .tokens = { 16872 (void *)&cmd_cfg_input_set_port, 16873 (void *)&cmd_cfg_input_set_cfg, 16874 (void *)&cmd_cfg_input_set_port_id, 16875 (void *)&cmd_cfg_input_set_pctype, 16876 (void *)&cmd_cfg_input_set_pctype_id, 16877 (void *)&cmd_cfg_input_set_inset_type, 16878 (void *)&cmd_cfg_input_set_opt, 16879 (void *)&cmd_cfg_input_set_field, 16880 (void *)&cmd_cfg_input_set_field_idx, 16881 NULL, 16882 }, 16883 }; 16884 16885 /* Clear input set */ 16886 struct cmd_clear_input_set_result { 16887 cmdline_fixed_string_t port; 16888 cmdline_fixed_string_t cfg; 16889 portid_t port_id; 16890 cmdline_fixed_string_t pctype; 16891 uint8_t pctype_id; 16892 cmdline_fixed_string_t inset_type; 16893 cmdline_fixed_string_t clear; 16894 cmdline_fixed_string_t all; 16895 }; 16896 16897 static void 16898 cmd_clear_input_set_parsed( 16899 __attribute__((unused)) void *parsed_result, 16900 __attribute__((unused)) struct cmdline *cl, 16901 __attribute__((unused)) void *data) 16902 { 16903 #ifdef RTE_LIBRTE_I40E_PMD 16904 struct cmd_clear_input_set_result *res = parsed_result; 16905 enum rte_pmd_i40e_inset_type inset_type = INSET_NONE; 16906 struct rte_pmd_i40e_inset inset; 16907 #endif 16908 int ret = -ENOTSUP; 16909 16910 if (!all_ports_stopped()) { 16911 printf("Please stop all ports first\n"); 16912 return; 16913 } 16914 16915 #ifdef RTE_LIBRTE_I40E_PMD 16916 if (!strcmp(res->inset_type, "hash_inset")) 16917 inset_type = INSET_HASH; 16918 else if (!strcmp(res->inset_type, "fdir_inset")) 16919 inset_type = INSET_FDIR; 16920 else if (!strcmp(res->inset_type, "fdir_flx_inset")) 16921 inset_type = INSET_FDIR_FLX; 16922 16923 memset(&inset, 0, sizeof(inset)); 16924 16925 ret = rte_pmd_i40e_inset_set(res->port_id, res->pctype_id, 16926 &inset, inset_type); 16927 if (ret) { 16928 printf("Failed to clear input set.\n"); 16929 return; 16930 } 16931 16932 #endif 16933 16934 if (ret == -ENOTSUP) 16935 printf("Function not supported\n"); 16936 } 16937 16938 cmdline_parse_token_string_t cmd_clear_input_set_port = 16939 TOKEN_STRING_INITIALIZER(struct cmd_clear_input_set_result, 16940 port, "port"); 16941 cmdline_parse_token_string_t cmd_clear_input_set_cfg = 16942 TOKEN_STRING_INITIALIZER(struct cmd_clear_input_set_result, 16943 cfg, "config"); 16944 cmdline_parse_token_num_t cmd_clear_input_set_port_id = 16945 TOKEN_NUM_INITIALIZER(struct cmd_clear_input_set_result, 16946 port_id, UINT16); 16947 cmdline_parse_token_string_t cmd_clear_input_set_pctype = 16948 TOKEN_STRING_INITIALIZER(struct cmd_clear_input_set_result, 16949 pctype, "pctype"); 16950 cmdline_parse_token_num_t cmd_clear_input_set_pctype_id = 16951 TOKEN_NUM_INITIALIZER(struct cmd_clear_input_set_result, 16952 pctype_id, UINT8); 16953 cmdline_parse_token_string_t cmd_clear_input_set_inset_type = 16954 TOKEN_STRING_INITIALIZER(struct cmd_clear_input_set_result, 16955 inset_type, 16956 "hash_inset#fdir_inset#fdir_flx_inset"); 16957 cmdline_parse_token_string_t cmd_clear_input_set_clear = 16958 TOKEN_STRING_INITIALIZER(struct cmd_clear_input_set_result, 16959 clear, "clear"); 16960 cmdline_parse_token_string_t cmd_clear_input_set_all = 16961 TOKEN_STRING_INITIALIZER(struct cmd_clear_input_set_result, 16962 all, "all"); 16963 16964 cmdline_parse_inst_t cmd_clear_input_set = { 16965 .f = cmd_clear_input_set_parsed, 16966 .data = NULL, 16967 .help_str = "port config <port_id> pctype <pctype_id> hash_inset|" 16968 "fdir_inset|fdir_flx_inset clear all", 16969 .tokens = { 16970 (void *)&cmd_clear_input_set_port, 16971 (void *)&cmd_clear_input_set_cfg, 16972 (void *)&cmd_clear_input_set_port_id, 16973 (void *)&cmd_clear_input_set_pctype, 16974 (void *)&cmd_clear_input_set_pctype_id, 16975 (void *)&cmd_clear_input_set_inset_type, 16976 (void *)&cmd_clear_input_set_clear, 16977 (void *)&cmd_clear_input_set_all, 16978 NULL, 16979 }, 16980 }; 16981 16982 /* show vf stats */ 16983 16984 /* Common result structure for show vf stats */ 16985 struct cmd_show_vf_stats_result { 16986 cmdline_fixed_string_t show; 16987 cmdline_fixed_string_t vf; 16988 cmdline_fixed_string_t stats; 16989 portid_t port_id; 16990 uint16_t vf_id; 16991 }; 16992 16993 /* Common CLI fields show vf stats*/ 16994 cmdline_parse_token_string_t cmd_show_vf_stats_show = 16995 TOKEN_STRING_INITIALIZER 16996 (struct cmd_show_vf_stats_result, 16997 show, "show"); 16998 cmdline_parse_token_string_t cmd_show_vf_stats_vf = 16999 TOKEN_STRING_INITIALIZER 17000 (struct cmd_show_vf_stats_result, 17001 vf, "vf"); 17002 cmdline_parse_token_string_t cmd_show_vf_stats_stats = 17003 TOKEN_STRING_INITIALIZER 17004 (struct cmd_show_vf_stats_result, 17005 stats, "stats"); 17006 cmdline_parse_token_num_t cmd_show_vf_stats_port_id = 17007 TOKEN_NUM_INITIALIZER 17008 (struct cmd_show_vf_stats_result, 17009 port_id, UINT16); 17010 cmdline_parse_token_num_t cmd_show_vf_stats_vf_id = 17011 TOKEN_NUM_INITIALIZER 17012 (struct cmd_show_vf_stats_result, 17013 vf_id, UINT16); 17014 17015 static void 17016 cmd_show_vf_stats_parsed( 17017 void *parsed_result, 17018 __attribute__((unused)) struct cmdline *cl, 17019 __attribute__((unused)) void *data) 17020 { 17021 struct cmd_show_vf_stats_result *res = parsed_result; 17022 struct rte_eth_stats stats; 17023 int ret = -ENOTSUP; 17024 static const char *nic_stats_border = "########################"; 17025 17026 if (port_id_is_invalid(res->port_id, ENABLED_WARN)) 17027 return; 17028 17029 memset(&stats, 0, sizeof(stats)); 17030 17031 #ifdef RTE_LIBRTE_I40E_PMD 17032 if (ret == -ENOTSUP) 17033 ret = rte_pmd_i40e_get_vf_stats(res->port_id, 17034 res->vf_id, 17035 &stats); 17036 #endif 17037 #ifdef RTE_LIBRTE_BNXT_PMD 17038 if (ret == -ENOTSUP) 17039 ret = rte_pmd_bnxt_get_vf_stats(res->port_id, 17040 res->vf_id, 17041 &stats); 17042 #endif 17043 17044 switch (ret) { 17045 case 0: 17046 break; 17047 case -EINVAL: 17048 printf("invalid vf_id %d\n", res->vf_id); 17049 break; 17050 case -ENODEV: 17051 printf("invalid port_id %d\n", res->port_id); 17052 break; 17053 case -ENOTSUP: 17054 printf("function not implemented\n"); 17055 break; 17056 default: 17057 printf("programming error: (%s)\n", strerror(-ret)); 17058 } 17059 17060 printf("\n %s NIC statistics for port %-2d vf %-2d %s\n", 17061 nic_stats_border, res->port_id, res->vf_id, nic_stats_border); 17062 17063 printf(" RX-packets: %-10"PRIu64" RX-missed: %-10"PRIu64" RX-bytes: " 17064 "%-"PRIu64"\n", 17065 stats.ipackets, stats.imissed, stats.ibytes); 17066 printf(" RX-errors: %-"PRIu64"\n", stats.ierrors); 17067 printf(" RX-nombuf: %-10"PRIu64"\n", 17068 stats.rx_nombuf); 17069 printf(" TX-packets: %-10"PRIu64" TX-errors: %-10"PRIu64" TX-bytes: " 17070 "%-"PRIu64"\n", 17071 stats.opackets, stats.oerrors, stats.obytes); 17072 17073 printf(" %s############################%s\n", 17074 nic_stats_border, nic_stats_border); 17075 } 17076 17077 cmdline_parse_inst_t cmd_show_vf_stats = { 17078 .f = cmd_show_vf_stats_parsed, 17079 .data = NULL, 17080 .help_str = "show vf stats <port_id> <vf_id>", 17081 .tokens = { 17082 (void *)&cmd_show_vf_stats_show, 17083 (void *)&cmd_show_vf_stats_vf, 17084 (void *)&cmd_show_vf_stats_stats, 17085 (void *)&cmd_show_vf_stats_port_id, 17086 (void *)&cmd_show_vf_stats_vf_id, 17087 NULL, 17088 }, 17089 }; 17090 17091 /* clear vf stats */ 17092 17093 /* Common result structure for clear vf stats */ 17094 struct cmd_clear_vf_stats_result { 17095 cmdline_fixed_string_t clear; 17096 cmdline_fixed_string_t vf; 17097 cmdline_fixed_string_t stats; 17098 portid_t port_id; 17099 uint16_t vf_id; 17100 }; 17101 17102 /* Common CLI fields clear vf stats*/ 17103 cmdline_parse_token_string_t cmd_clear_vf_stats_clear = 17104 TOKEN_STRING_INITIALIZER 17105 (struct cmd_clear_vf_stats_result, 17106 clear, "clear"); 17107 cmdline_parse_token_string_t cmd_clear_vf_stats_vf = 17108 TOKEN_STRING_INITIALIZER 17109 (struct cmd_clear_vf_stats_result, 17110 vf, "vf"); 17111 cmdline_parse_token_string_t cmd_clear_vf_stats_stats = 17112 TOKEN_STRING_INITIALIZER 17113 (struct cmd_clear_vf_stats_result, 17114 stats, "stats"); 17115 cmdline_parse_token_num_t cmd_clear_vf_stats_port_id = 17116 TOKEN_NUM_INITIALIZER 17117 (struct cmd_clear_vf_stats_result, 17118 port_id, UINT16); 17119 cmdline_parse_token_num_t cmd_clear_vf_stats_vf_id = 17120 TOKEN_NUM_INITIALIZER 17121 (struct cmd_clear_vf_stats_result, 17122 vf_id, UINT16); 17123 17124 static void 17125 cmd_clear_vf_stats_parsed( 17126 void *parsed_result, 17127 __attribute__((unused)) struct cmdline *cl, 17128 __attribute__((unused)) void *data) 17129 { 17130 struct cmd_clear_vf_stats_result *res = parsed_result; 17131 int ret = -ENOTSUP; 17132 17133 if (port_id_is_invalid(res->port_id, ENABLED_WARN)) 17134 return; 17135 17136 #ifdef RTE_LIBRTE_I40E_PMD 17137 if (ret == -ENOTSUP) 17138 ret = rte_pmd_i40e_reset_vf_stats(res->port_id, 17139 res->vf_id); 17140 #endif 17141 #ifdef RTE_LIBRTE_BNXT_PMD 17142 if (ret == -ENOTSUP) 17143 ret = rte_pmd_bnxt_reset_vf_stats(res->port_id, 17144 res->vf_id); 17145 #endif 17146 17147 switch (ret) { 17148 case 0: 17149 break; 17150 case -EINVAL: 17151 printf("invalid vf_id %d\n", res->vf_id); 17152 break; 17153 case -ENODEV: 17154 printf("invalid port_id %d\n", res->port_id); 17155 break; 17156 case -ENOTSUP: 17157 printf("function not implemented\n"); 17158 break; 17159 default: 17160 printf("programming error: (%s)\n", strerror(-ret)); 17161 } 17162 } 17163 17164 cmdline_parse_inst_t cmd_clear_vf_stats = { 17165 .f = cmd_clear_vf_stats_parsed, 17166 .data = NULL, 17167 .help_str = "clear vf stats <port_id> <vf_id>", 17168 .tokens = { 17169 (void *)&cmd_clear_vf_stats_clear, 17170 (void *)&cmd_clear_vf_stats_vf, 17171 (void *)&cmd_clear_vf_stats_stats, 17172 (void *)&cmd_clear_vf_stats_port_id, 17173 (void *)&cmd_clear_vf_stats_vf_id, 17174 NULL, 17175 }, 17176 }; 17177 17178 /* port config pctype mapping reset */ 17179 17180 /* Common result structure for port config pctype mapping reset */ 17181 struct cmd_pctype_mapping_reset_result { 17182 cmdline_fixed_string_t port; 17183 cmdline_fixed_string_t config; 17184 portid_t port_id; 17185 cmdline_fixed_string_t pctype; 17186 cmdline_fixed_string_t mapping; 17187 cmdline_fixed_string_t reset; 17188 }; 17189 17190 /* Common CLI fields for port config pctype mapping reset*/ 17191 cmdline_parse_token_string_t cmd_pctype_mapping_reset_port = 17192 TOKEN_STRING_INITIALIZER 17193 (struct cmd_pctype_mapping_reset_result, 17194 port, "port"); 17195 cmdline_parse_token_string_t cmd_pctype_mapping_reset_config = 17196 TOKEN_STRING_INITIALIZER 17197 (struct cmd_pctype_mapping_reset_result, 17198 config, "config"); 17199 cmdline_parse_token_num_t cmd_pctype_mapping_reset_port_id = 17200 TOKEN_NUM_INITIALIZER 17201 (struct cmd_pctype_mapping_reset_result, 17202 port_id, UINT16); 17203 cmdline_parse_token_string_t cmd_pctype_mapping_reset_pctype = 17204 TOKEN_STRING_INITIALIZER 17205 (struct cmd_pctype_mapping_reset_result, 17206 pctype, "pctype"); 17207 cmdline_parse_token_string_t cmd_pctype_mapping_reset_mapping = 17208 TOKEN_STRING_INITIALIZER 17209 (struct cmd_pctype_mapping_reset_result, 17210 mapping, "mapping"); 17211 cmdline_parse_token_string_t cmd_pctype_mapping_reset_reset = 17212 TOKEN_STRING_INITIALIZER 17213 (struct cmd_pctype_mapping_reset_result, 17214 reset, "reset"); 17215 17216 static void 17217 cmd_pctype_mapping_reset_parsed( 17218 void *parsed_result, 17219 __attribute__((unused)) struct cmdline *cl, 17220 __attribute__((unused)) void *data) 17221 { 17222 struct cmd_pctype_mapping_reset_result *res = parsed_result; 17223 int ret = -ENOTSUP; 17224 17225 if (port_id_is_invalid(res->port_id, ENABLED_WARN)) 17226 return; 17227 17228 #ifdef RTE_LIBRTE_I40E_PMD 17229 ret = rte_pmd_i40e_flow_type_mapping_reset(res->port_id); 17230 #endif 17231 17232 switch (ret) { 17233 case 0: 17234 break; 17235 case -ENODEV: 17236 printf("invalid port_id %d\n", res->port_id); 17237 break; 17238 case -ENOTSUP: 17239 printf("function not implemented\n"); 17240 break; 17241 default: 17242 printf("programming error: (%s)\n", strerror(-ret)); 17243 } 17244 } 17245 17246 cmdline_parse_inst_t cmd_pctype_mapping_reset = { 17247 .f = cmd_pctype_mapping_reset_parsed, 17248 .data = NULL, 17249 .help_str = "port config <port_id> pctype mapping reset", 17250 .tokens = { 17251 (void *)&cmd_pctype_mapping_reset_port, 17252 (void *)&cmd_pctype_mapping_reset_config, 17253 (void *)&cmd_pctype_mapping_reset_port_id, 17254 (void *)&cmd_pctype_mapping_reset_pctype, 17255 (void *)&cmd_pctype_mapping_reset_mapping, 17256 (void *)&cmd_pctype_mapping_reset_reset, 17257 NULL, 17258 }, 17259 }; 17260 17261 /* show port pctype mapping */ 17262 17263 /* Common result structure for show port pctype mapping */ 17264 struct cmd_pctype_mapping_get_result { 17265 cmdline_fixed_string_t show; 17266 cmdline_fixed_string_t port; 17267 portid_t port_id; 17268 cmdline_fixed_string_t pctype; 17269 cmdline_fixed_string_t mapping; 17270 }; 17271 17272 /* Common CLI fields for pctype mapping get */ 17273 cmdline_parse_token_string_t cmd_pctype_mapping_get_show = 17274 TOKEN_STRING_INITIALIZER 17275 (struct cmd_pctype_mapping_get_result, 17276 show, "show"); 17277 cmdline_parse_token_string_t cmd_pctype_mapping_get_port = 17278 TOKEN_STRING_INITIALIZER 17279 (struct cmd_pctype_mapping_get_result, 17280 port, "port"); 17281 cmdline_parse_token_num_t cmd_pctype_mapping_get_port_id = 17282 TOKEN_NUM_INITIALIZER 17283 (struct cmd_pctype_mapping_get_result, 17284 port_id, UINT16); 17285 cmdline_parse_token_string_t cmd_pctype_mapping_get_pctype = 17286 TOKEN_STRING_INITIALIZER 17287 (struct cmd_pctype_mapping_get_result, 17288 pctype, "pctype"); 17289 cmdline_parse_token_string_t cmd_pctype_mapping_get_mapping = 17290 TOKEN_STRING_INITIALIZER 17291 (struct cmd_pctype_mapping_get_result, 17292 mapping, "mapping"); 17293 17294 static void 17295 cmd_pctype_mapping_get_parsed( 17296 void *parsed_result, 17297 __attribute__((unused)) struct cmdline *cl, 17298 __attribute__((unused)) void *data) 17299 { 17300 struct cmd_pctype_mapping_get_result *res = parsed_result; 17301 int ret = -ENOTSUP; 17302 #ifdef RTE_LIBRTE_I40E_PMD 17303 struct rte_pmd_i40e_flow_type_mapping 17304 mapping[RTE_PMD_I40E_FLOW_TYPE_MAX]; 17305 int i, j, first_pctype; 17306 #endif 17307 17308 if (port_id_is_invalid(res->port_id, ENABLED_WARN)) 17309 return; 17310 17311 #ifdef RTE_LIBRTE_I40E_PMD 17312 ret = rte_pmd_i40e_flow_type_mapping_get(res->port_id, mapping); 17313 #endif 17314 17315 switch (ret) { 17316 case 0: 17317 break; 17318 case -ENODEV: 17319 printf("invalid port_id %d\n", res->port_id); 17320 return; 17321 case -ENOTSUP: 17322 printf("function not implemented\n"); 17323 return; 17324 default: 17325 printf("programming error: (%s)\n", strerror(-ret)); 17326 return; 17327 } 17328 17329 #ifdef RTE_LIBRTE_I40E_PMD 17330 for (i = 0; i < RTE_PMD_I40E_FLOW_TYPE_MAX; i++) { 17331 if (mapping[i].pctype != 0ULL) { 17332 first_pctype = 1; 17333 17334 printf("pctype: "); 17335 for (j = 0; j < RTE_PMD_I40E_PCTYPE_MAX; j++) { 17336 if (mapping[i].pctype & (1ULL << j)) { 17337 printf(first_pctype ? 17338 "%02d" : ",%02d", j); 17339 first_pctype = 0; 17340 } 17341 } 17342 printf(" -> flowtype: %02d\n", mapping[i].flow_type); 17343 } 17344 } 17345 #endif 17346 } 17347 17348 cmdline_parse_inst_t cmd_pctype_mapping_get = { 17349 .f = cmd_pctype_mapping_get_parsed, 17350 .data = NULL, 17351 .help_str = "show port <port_id> pctype mapping", 17352 .tokens = { 17353 (void *)&cmd_pctype_mapping_get_show, 17354 (void *)&cmd_pctype_mapping_get_port, 17355 (void *)&cmd_pctype_mapping_get_port_id, 17356 (void *)&cmd_pctype_mapping_get_pctype, 17357 (void *)&cmd_pctype_mapping_get_mapping, 17358 NULL, 17359 }, 17360 }; 17361 17362 /* port config pctype mapping update */ 17363 17364 /* Common result structure for port config pctype mapping update */ 17365 struct cmd_pctype_mapping_update_result { 17366 cmdline_fixed_string_t port; 17367 cmdline_fixed_string_t config; 17368 portid_t port_id; 17369 cmdline_fixed_string_t pctype; 17370 cmdline_fixed_string_t mapping; 17371 cmdline_fixed_string_t update; 17372 cmdline_fixed_string_t pctype_list; 17373 uint16_t flow_type; 17374 }; 17375 17376 /* Common CLI fields for pctype mapping update*/ 17377 cmdline_parse_token_string_t cmd_pctype_mapping_update_port = 17378 TOKEN_STRING_INITIALIZER 17379 (struct cmd_pctype_mapping_update_result, 17380 port, "port"); 17381 cmdline_parse_token_string_t cmd_pctype_mapping_update_config = 17382 TOKEN_STRING_INITIALIZER 17383 (struct cmd_pctype_mapping_update_result, 17384 config, "config"); 17385 cmdline_parse_token_num_t cmd_pctype_mapping_update_port_id = 17386 TOKEN_NUM_INITIALIZER 17387 (struct cmd_pctype_mapping_update_result, 17388 port_id, UINT16); 17389 cmdline_parse_token_string_t cmd_pctype_mapping_update_pctype = 17390 TOKEN_STRING_INITIALIZER 17391 (struct cmd_pctype_mapping_update_result, 17392 pctype, "pctype"); 17393 cmdline_parse_token_string_t cmd_pctype_mapping_update_mapping = 17394 TOKEN_STRING_INITIALIZER 17395 (struct cmd_pctype_mapping_update_result, 17396 mapping, "mapping"); 17397 cmdline_parse_token_string_t cmd_pctype_mapping_update_update = 17398 TOKEN_STRING_INITIALIZER 17399 (struct cmd_pctype_mapping_update_result, 17400 update, "update"); 17401 cmdline_parse_token_string_t cmd_pctype_mapping_update_pc_type = 17402 TOKEN_STRING_INITIALIZER 17403 (struct cmd_pctype_mapping_update_result, 17404 pctype_list, NULL); 17405 cmdline_parse_token_num_t cmd_pctype_mapping_update_flow_type = 17406 TOKEN_NUM_INITIALIZER 17407 (struct cmd_pctype_mapping_update_result, 17408 flow_type, UINT16); 17409 17410 static void 17411 cmd_pctype_mapping_update_parsed( 17412 void *parsed_result, 17413 __attribute__((unused)) struct cmdline *cl, 17414 __attribute__((unused)) void *data) 17415 { 17416 struct cmd_pctype_mapping_update_result *res = parsed_result; 17417 int ret = -ENOTSUP; 17418 #ifdef RTE_LIBRTE_I40E_PMD 17419 struct rte_pmd_i40e_flow_type_mapping mapping; 17420 unsigned int i; 17421 unsigned int nb_item; 17422 unsigned int pctype_list[RTE_PMD_I40E_PCTYPE_MAX]; 17423 #endif 17424 17425 if (port_id_is_invalid(res->port_id, ENABLED_WARN)) 17426 return; 17427 17428 #ifdef RTE_LIBRTE_I40E_PMD 17429 nb_item = parse_item_list(res->pctype_list, "pctypes", 17430 RTE_PMD_I40E_PCTYPE_MAX, pctype_list, 1); 17431 mapping.flow_type = res->flow_type; 17432 for (i = 0, mapping.pctype = 0ULL; i < nb_item; i++) 17433 mapping.pctype |= (1ULL << pctype_list[i]); 17434 ret = rte_pmd_i40e_flow_type_mapping_update(res->port_id, 17435 &mapping, 17436 1, 17437 0); 17438 #endif 17439 17440 switch (ret) { 17441 case 0: 17442 break; 17443 case -EINVAL: 17444 printf("invalid pctype or flow type\n"); 17445 break; 17446 case -ENODEV: 17447 printf("invalid port_id %d\n", res->port_id); 17448 break; 17449 case -ENOTSUP: 17450 printf("function not implemented\n"); 17451 break; 17452 default: 17453 printf("programming error: (%s)\n", strerror(-ret)); 17454 } 17455 } 17456 17457 cmdline_parse_inst_t cmd_pctype_mapping_update = { 17458 .f = cmd_pctype_mapping_update_parsed, 17459 .data = NULL, 17460 .help_str = "port config <port_id> pctype mapping update" 17461 " <pctype_id_0,[pctype_id_1]*> <flowtype_id>", 17462 .tokens = { 17463 (void *)&cmd_pctype_mapping_update_port, 17464 (void *)&cmd_pctype_mapping_update_config, 17465 (void *)&cmd_pctype_mapping_update_port_id, 17466 (void *)&cmd_pctype_mapping_update_pctype, 17467 (void *)&cmd_pctype_mapping_update_mapping, 17468 (void *)&cmd_pctype_mapping_update_update, 17469 (void *)&cmd_pctype_mapping_update_pc_type, 17470 (void *)&cmd_pctype_mapping_update_flow_type, 17471 NULL, 17472 }, 17473 }; 17474 17475 /* ptype mapping get */ 17476 17477 /* Common result structure for ptype mapping get */ 17478 struct cmd_ptype_mapping_get_result { 17479 cmdline_fixed_string_t ptype; 17480 cmdline_fixed_string_t mapping; 17481 cmdline_fixed_string_t get; 17482 portid_t port_id; 17483 uint8_t valid_only; 17484 }; 17485 17486 /* Common CLI fields for ptype mapping get */ 17487 cmdline_parse_token_string_t cmd_ptype_mapping_get_ptype = 17488 TOKEN_STRING_INITIALIZER 17489 (struct cmd_ptype_mapping_get_result, 17490 ptype, "ptype"); 17491 cmdline_parse_token_string_t cmd_ptype_mapping_get_mapping = 17492 TOKEN_STRING_INITIALIZER 17493 (struct cmd_ptype_mapping_get_result, 17494 mapping, "mapping"); 17495 cmdline_parse_token_string_t cmd_ptype_mapping_get_get = 17496 TOKEN_STRING_INITIALIZER 17497 (struct cmd_ptype_mapping_get_result, 17498 get, "get"); 17499 cmdline_parse_token_num_t cmd_ptype_mapping_get_port_id = 17500 TOKEN_NUM_INITIALIZER 17501 (struct cmd_ptype_mapping_get_result, 17502 port_id, UINT16); 17503 cmdline_parse_token_num_t cmd_ptype_mapping_get_valid_only = 17504 TOKEN_NUM_INITIALIZER 17505 (struct cmd_ptype_mapping_get_result, 17506 valid_only, UINT8); 17507 17508 static void 17509 cmd_ptype_mapping_get_parsed( 17510 void *parsed_result, 17511 __attribute__((unused)) struct cmdline *cl, 17512 __attribute__((unused)) void *data) 17513 { 17514 struct cmd_ptype_mapping_get_result *res = parsed_result; 17515 int ret = -ENOTSUP; 17516 #ifdef RTE_LIBRTE_I40E_PMD 17517 int max_ptype_num = 256; 17518 struct rte_pmd_i40e_ptype_mapping mapping[max_ptype_num]; 17519 uint16_t count; 17520 int i; 17521 #endif 17522 17523 if (port_id_is_invalid(res->port_id, ENABLED_WARN)) 17524 return; 17525 17526 #ifdef RTE_LIBRTE_I40E_PMD 17527 ret = rte_pmd_i40e_ptype_mapping_get(res->port_id, 17528 mapping, 17529 max_ptype_num, 17530 &count, 17531 res->valid_only); 17532 #endif 17533 17534 switch (ret) { 17535 case 0: 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 #ifdef RTE_LIBRTE_I40E_PMD 17548 if (!ret) { 17549 for (i = 0; i < count; i++) 17550 printf("%3d\t0x%08x\n", 17551 mapping[i].hw_ptype, mapping[i].sw_ptype); 17552 } 17553 #endif 17554 } 17555 17556 cmdline_parse_inst_t cmd_ptype_mapping_get = { 17557 .f = cmd_ptype_mapping_get_parsed, 17558 .data = NULL, 17559 .help_str = "ptype mapping get <port_id> <valid_only>", 17560 .tokens = { 17561 (void *)&cmd_ptype_mapping_get_ptype, 17562 (void *)&cmd_ptype_mapping_get_mapping, 17563 (void *)&cmd_ptype_mapping_get_get, 17564 (void *)&cmd_ptype_mapping_get_port_id, 17565 (void *)&cmd_ptype_mapping_get_valid_only, 17566 NULL, 17567 }, 17568 }; 17569 17570 /* ptype mapping replace */ 17571 17572 /* Common result structure for ptype mapping replace */ 17573 struct cmd_ptype_mapping_replace_result { 17574 cmdline_fixed_string_t ptype; 17575 cmdline_fixed_string_t mapping; 17576 cmdline_fixed_string_t replace; 17577 portid_t port_id; 17578 uint32_t target; 17579 uint8_t mask; 17580 uint32_t pkt_type; 17581 }; 17582 17583 /* Common CLI fields for ptype mapping replace */ 17584 cmdline_parse_token_string_t cmd_ptype_mapping_replace_ptype = 17585 TOKEN_STRING_INITIALIZER 17586 (struct cmd_ptype_mapping_replace_result, 17587 ptype, "ptype"); 17588 cmdline_parse_token_string_t cmd_ptype_mapping_replace_mapping = 17589 TOKEN_STRING_INITIALIZER 17590 (struct cmd_ptype_mapping_replace_result, 17591 mapping, "mapping"); 17592 cmdline_parse_token_string_t cmd_ptype_mapping_replace_replace = 17593 TOKEN_STRING_INITIALIZER 17594 (struct cmd_ptype_mapping_replace_result, 17595 replace, "replace"); 17596 cmdline_parse_token_num_t cmd_ptype_mapping_replace_port_id = 17597 TOKEN_NUM_INITIALIZER 17598 (struct cmd_ptype_mapping_replace_result, 17599 port_id, UINT16); 17600 cmdline_parse_token_num_t cmd_ptype_mapping_replace_target = 17601 TOKEN_NUM_INITIALIZER 17602 (struct cmd_ptype_mapping_replace_result, 17603 target, UINT32); 17604 cmdline_parse_token_num_t cmd_ptype_mapping_replace_mask = 17605 TOKEN_NUM_INITIALIZER 17606 (struct cmd_ptype_mapping_replace_result, 17607 mask, UINT8); 17608 cmdline_parse_token_num_t cmd_ptype_mapping_replace_pkt_type = 17609 TOKEN_NUM_INITIALIZER 17610 (struct cmd_ptype_mapping_replace_result, 17611 pkt_type, UINT32); 17612 17613 static void 17614 cmd_ptype_mapping_replace_parsed( 17615 void *parsed_result, 17616 __attribute__((unused)) struct cmdline *cl, 17617 __attribute__((unused)) void *data) 17618 { 17619 struct cmd_ptype_mapping_replace_result *res = parsed_result; 17620 int ret = -ENOTSUP; 17621 17622 if (port_id_is_invalid(res->port_id, ENABLED_WARN)) 17623 return; 17624 17625 #ifdef RTE_LIBRTE_I40E_PMD 17626 ret = rte_pmd_i40e_ptype_mapping_replace(res->port_id, 17627 res->target, 17628 res->mask, 17629 res->pkt_type); 17630 #endif 17631 17632 switch (ret) { 17633 case 0: 17634 break; 17635 case -EINVAL: 17636 printf("invalid ptype 0x%8x or 0x%8x\n", 17637 res->target, res->pkt_type); 17638 break; 17639 case -ENODEV: 17640 printf("invalid port_id %d\n", res->port_id); 17641 break; 17642 case -ENOTSUP: 17643 printf("function not implemented\n"); 17644 break; 17645 default: 17646 printf("programming error: (%s)\n", strerror(-ret)); 17647 } 17648 } 17649 17650 cmdline_parse_inst_t cmd_ptype_mapping_replace = { 17651 .f = cmd_ptype_mapping_replace_parsed, 17652 .data = NULL, 17653 .help_str = 17654 "ptype mapping replace <port_id> <target> <mask> <pkt_type>", 17655 .tokens = { 17656 (void *)&cmd_ptype_mapping_replace_ptype, 17657 (void *)&cmd_ptype_mapping_replace_mapping, 17658 (void *)&cmd_ptype_mapping_replace_replace, 17659 (void *)&cmd_ptype_mapping_replace_port_id, 17660 (void *)&cmd_ptype_mapping_replace_target, 17661 (void *)&cmd_ptype_mapping_replace_mask, 17662 (void *)&cmd_ptype_mapping_replace_pkt_type, 17663 NULL, 17664 }, 17665 }; 17666 17667 /* ptype mapping reset */ 17668 17669 /* Common result structure for ptype mapping reset */ 17670 struct cmd_ptype_mapping_reset_result { 17671 cmdline_fixed_string_t ptype; 17672 cmdline_fixed_string_t mapping; 17673 cmdline_fixed_string_t reset; 17674 portid_t port_id; 17675 }; 17676 17677 /* Common CLI fields for ptype mapping reset*/ 17678 cmdline_parse_token_string_t cmd_ptype_mapping_reset_ptype = 17679 TOKEN_STRING_INITIALIZER 17680 (struct cmd_ptype_mapping_reset_result, 17681 ptype, "ptype"); 17682 cmdline_parse_token_string_t cmd_ptype_mapping_reset_mapping = 17683 TOKEN_STRING_INITIALIZER 17684 (struct cmd_ptype_mapping_reset_result, 17685 mapping, "mapping"); 17686 cmdline_parse_token_string_t cmd_ptype_mapping_reset_reset = 17687 TOKEN_STRING_INITIALIZER 17688 (struct cmd_ptype_mapping_reset_result, 17689 reset, "reset"); 17690 cmdline_parse_token_num_t cmd_ptype_mapping_reset_port_id = 17691 TOKEN_NUM_INITIALIZER 17692 (struct cmd_ptype_mapping_reset_result, 17693 port_id, UINT16); 17694 17695 static void 17696 cmd_ptype_mapping_reset_parsed( 17697 void *parsed_result, 17698 __attribute__((unused)) struct cmdline *cl, 17699 __attribute__((unused)) void *data) 17700 { 17701 struct cmd_ptype_mapping_reset_result *res = parsed_result; 17702 int ret = -ENOTSUP; 17703 17704 if (port_id_is_invalid(res->port_id, ENABLED_WARN)) 17705 return; 17706 17707 #ifdef RTE_LIBRTE_I40E_PMD 17708 ret = rte_pmd_i40e_ptype_mapping_reset(res->port_id); 17709 #endif 17710 17711 switch (ret) { 17712 case 0: 17713 break; 17714 case -ENODEV: 17715 printf("invalid port_id %d\n", res->port_id); 17716 break; 17717 case -ENOTSUP: 17718 printf("function not implemented\n"); 17719 break; 17720 default: 17721 printf("programming error: (%s)\n", strerror(-ret)); 17722 } 17723 } 17724 17725 cmdline_parse_inst_t cmd_ptype_mapping_reset = { 17726 .f = cmd_ptype_mapping_reset_parsed, 17727 .data = NULL, 17728 .help_str = "ptype mapping reset <port_id>", 17729 .tokens = { 17730 (void *)&cmd_ptype_mapping_reset_ptype, 17731 (void *)&cmd_ptype_mapping_reset_mapping, 17732 (void *)&cmd_ptype_mapping_reset_reset, 17733 (void *)&cmd_ptype_mapping_reset_port_id, 17734 NULL, 17735 }, 17736 }; 17737 17738 /* ptype mapping update */ 17739 17740 /* Common result structure for ptype mapping update */ 17741 struct cmd_ptype_mapping_update_result { 17742 cmdline_fixed_string_t ptype; 17743 cmdline_fixed_string_t mapping; 17744 cmdline_fixed_string_t reset; 17745 portid_t port_id; 17746 uint8_t hw_ptype; 17747 uint32_t sw_ptype; 17748 }; 17749 17750 /* Common CLI fields for ptype mapping update*/ 17751 cmdline_parse_token_string_t cmd_ptype_mapping_update_ptype = 17752 TOKEN_STRING_INITIALIZER 17753 (struct cmd_ptype_mapping_update_result, 17754 ptype, "ptype"); 17755 cmdline_parse_token_string_t cmd_ptype_mapping_update_mapping = 17756 TOKEN_STRING_INITIALIZER 17757 (struct cmd_ptype_mapping_update_result, 17758 mapping, "mapping"); 17759 cmdline_parse_token_string_t cmd_ptype_mapping_update_update = 17760 TOKEN_STRING_INITIALIZER 17761 (struct cmd_ptype_mapping_update_result, 17762 reset, "update"); 17763 cmdline_parse_token_num_t cmd_ptype_mapping_update_port_id = 17764 TOKEN_NUM_INITIALIZER 17765 (struct cmd_ptype_mapping_update_result, 17766 port_id, UINT16); 17767 cmdline_parse_token_num_t cmd_ptype_mapping_update_hw_ptype = 17768 TOKEN_NUM_INITIALIZER 17769 (struct cmd_ptype_mapping_update_result, 17770 hw_ptype, UINT8); 17771 cmdline_parse_token_num_t cmd_ptype_mapping_update_sw_ptype = 17772 TOKEN_NUM_INITIALIZER 17773 (struct cmd_ptype_mapping_update_result, 17774 sw_ptype, UINT32); 17775 17776 static void 17777 cmd_ptype_mapping_update_parsed( 17778 void *parsed_result, 17779 __attribute__((unused)) struct cmdline *cl, 17780 __attribute__((unused)) void *data) 17781 { 17782 struct cmd_ptype_mapping_update_result *res = parsed_result; 17783 int ret = -ENOTSUP; 17784 #ifdef RTE_LIBRTE_I40E_PMD 17785 struct rte_pmd_i40e_ptype_mapping mapping; 17786 #endif 17787 if (port_id_is_invalid(res->port_id, ENABLED_WARN)) 17788 return; 17789 17790 #ifdef RTE_LIBRTE_I40E_PMD 17791 mapping.hw_ptype = res->hw_ptype; 17792 mapping.sw_ptype = res->sw_ptype; 17793 ret = rte_pmd_i40e_ptype_mapping_update(res->port_id, 17794 &mapping, 17795 1, 17796 0); 17797 #endif 17798 17799 switch (ret) { 17800 case 0: 17801 break; 17802 case -EINVAL: 17803 printf("invalid ptype 0x%8x\n", res->sw_ptype); 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_update = { 17817 .f = cmd_ptype_mapping_update_parsed, 17818 .data = NULL, 17819 .help_str = "ptype mapping update <port_id> <hw_ptype> <sw_ptype>", 17820 .tokens = { 17821 (void *)&cmd_ptype_mapping_update_ptype, 17822 (void *)&cmd_ptype_mapping_update_mapping, 17823 (void *)&cmd_ptype_mapping_update_update, 17824 (void *)&cmd_ptype_mapping_update_port_id, 17825 (void *)&cmd_ptype_mapping_update_hw_ptype, 17826 (void *)&cmd_ptype_mapping_update_sw_ptype, 17827 NULL, 17828 }, 17829 }; 17830 17831 /* Common result structure for file commands */ 17832 struct cmd_cmdfile_result { 17833 cmdline_fixed_string_t load; 17834 cmdline_fixed_string_t filename; 17835 }; 17836 17837 /* Common CLI fields for file commands */ 17838 cmdline_parse_token_string_t cmd_load_cmdfile = 17839 TOKEN_STRING_INITIALIZER(struct cmd_cmdfile_result, load, "load"); 17840 cmdline_parse_token_string_t cmd_load_cmdfile_filename = 17841 TOKEN_STRING_INITIALIZER(struct cmd_cmdfile_result, filename, NULL); 17842 17843 static void 17844 cmd_load_from_file_parsed( 17845 void *parsed_result, 17846 __attribute__((unused)) struct cmdline *cl, 17847 __attribute__((unused)) void *data) 17848 { 17849 struct cmd_cmdfile_result *res = parsed_result; 17850 17851 cmdline_read_from_file(res->filename); 17852 } 17853 17854 cmdline_parse_inst_t cmd_load_from_file = { 17855 .f = cmd_load_from_file_parsed, 17856 .data = NULL, 17857 .help_str = "load <filename>", 17858 .tokens = { 17859 (void *)&cmd_load_cmdfile, 17860 (void *)&cmd_load_cmdfile_filename, 17861 NULL, 17862 }, 17863 }; 17864 17865 /* Get Rx offloads capabilities */ 17866 struct cmd_rx_offload_get_capa_result { 17867 cmdline_fixed_string_t show; 17868 cmdline_fixed_string_t port; 17869 portid_t port_id; 17870 cmdline_fixed_string_t rx_offload; 17871 cmdline_fixed_string_t capabilities; 17872 }; 17873 17874 cmdline_parse_token_string_t cmd_rx_offload_get_capa_show = 17875 TOKEN_STRING_INITIALIZER 17876 (struct cmd_rx_offload_get_capa_result, 17877 show, "show"); 17878 cmdline_parse_token_string_t cmd_rx_offload_get_capa_port = 17879 TOKEN_STRING_INITIALIZER 17880 (struct cmd_rx_offload_get_capa_result, 17881 port, "port"); 17882 cmdline_parse_token_num_t cmd_rx_offload_get_capa_port_id = 17883 TOKEN_NUM_INITIALIZER 17884 (struct cmd_rx_offload_get_capa_result, 17885 port_id, UINT16); 17886 cmdline_parse_token_string_t cmd_rx_offload_get_capa_rx_offload = 17887 TOKEN_STRING_INITIALIZER 17888 (struct cmd_rx_offload_get_capa_result, 17889 rx_offload, "rx_offload"); 17890 cmdline_parse_token_string_t cmd_rx_offload_get_capa_capabilities = 17891 TOKEN_STRING_INITIALIZER 17892 (struct cmd_rx_offload_get_capa_result, 17893 capabilities, "capabilities"); 17894 17895 static void 17896 print_rx_offloads(uint64_t offloads) 17897 { 17898 uint64_t single_offload; 17899 int begin; 17900 int end; 17901 int bit; 17902 17903 if (offloads == 0) 17904 return; 17905 17906 begin = __builtin_ctzll(offloads); 17907 end = sizeof(offloads) * CHAR_BIT - __builtin_clzll(offloads); 17908 17909 single_offload = 1ULL << begin; 17910 for (bit = begin; bit < end; bit++) { 17911 if (offloads & single_offload) 17912 printf(" %s", 17913 rte_eth_dev_rx_offload_name(single_offload)); 17914 single_offload <<= 1; 17915 } 17916 } 17917 17918 static void 17919 cmd_rx_offload_get_capa_parsed( 17920 void *parsed_result, 17921 __attribute__((unused)) struct cmdline *cl, 17922 __attribute__((unused)) void *data) 17923 { 17924 struct cmd_rx_offload_get_capa_result *res = parsed_result; 17925 struct rte_eth_dev_info dev_info; 17926 portid_t port_id = res->port_id; 17927 uint64_t queue_offloads; 17928 uint64_t port_offloads; 17929 int ret; 17930 17931 ret = eth_dev_info_get_print_err(port_id, &dev_info); 17932 if (ret != 0) 17933 return; 17934 17935 queue_offloads = dev_info.rx_queue_offload_capa; 17936 port_offloads = dev_info.rx_offload_capa ^ queue_offloads; 17937 17938 printf("Rx Offloading Capabilities of port %d :\n", port_id); 17939 printf(" Per Queue :"); 17940 print_rx_offloads(queue_offloads); 17941 17942 printf("\n"); 17943 printf(" Per Port :"); 17944 print_rx_offloads(port_offloads); 17945 printf("\n\n"); 17946 } 17947 17948 cmdline_parse_inst_t cmd_rx_offload_get_capa = { 17949 .f = cmd_rx_offload_get_capa_parsed, 17950 .data = NULL, 17951 .help_str = "show port <port_id> rx_offload capabilities", 17952 .tokens = { 17953 (void *)&cmd_rx_offload_get_capa_show, 17954 (void *)&cmd_rx_offload_get_capa_port, 17955 (void *)&cmd_rx_offload_get_capa_port_id, 17956 (void *)&cmd_rx_offload_get_capa_rx_offload, 17957 (void *)&cmd_rx_offload_get_capa_capabilities, 17958 NULL, 17959 } 17960 }; 17961 17962 /* Get Rx offloads configuration */ 17963 struct cmd_rx_offload_get_configuration_result { 17964 cmdline_fixed_string_t show; 17965 cmdline_fixed_string_t port; 17966 portid_t port_id; 17967 cmdline_fixed_string_t rx_offload; 17968 cmdline_fixed_string_t configuration; 17969 }; 17970 17971 cmdline_parse_token_string_t cmd_rx_offload_get_configuration_show = 17972 TOKEN_STRING_INITIALIZER 17973 (struct cmd_rx_offload_get_configuration_result, 17974 show, "show"); 17975 cmdline_parse_token_string_t cmd_rx_offload_get_configuration_port = 17976 TOKEN_STRING_INITIALIZER 17977 (struct cmd_rx_offload_get_configuration_result, 17978 port, "port"); 17979 cmdline_parse_token_num_t cmd_rx_offload_get_configuration_port_id = 17980 TOKEN_NUM_INITIALIZER 17981 (struct cmd_rx_offload_get_configuration_result, 17982 port_id, UINT16); 17983 cmdline_parse_token_string_t cmd_rx_offload_get_configuration_rx_offload = 17984 TOKEN_STRING_INITIALIZER 17985 (struct cmd_rx_offload_get_configuration_result, 17986 rx_offload, "rx_offload"); 17987 cmdline_parse_token_string_t cmd_rx_offload_get_configuration_configuration = 17988 TOKEN_STRING_INITIALIZER 17989 (struct cmd_rx_offload_get_configuration_result, 17990 configuration, "configuration"); 17991 17992 static void 17993 cmd_rx_offload_get_configuration_parsed( 17994 void *parsed_result, 17995 __attribute__((unused)) struct cmdline *cl, 17996 __attribute__((unused)) void *data) 17997 { 17998 struct cmd_rx_offload_get_configuration_result *res = parsed_result; 17999 struct rte_eth_dev_info dev_info; 18000 portid_t port_id = res->port_id; 18001 struct rte_port *port = &ports[port_id]; 18002 uint64_t port_offloads; 18003 uint64_t queue_offloads; 18004 uint16_t nb_rx_queues; 18005 int q; 18006 int ret; 18007 18008 printf("Rx Offloading Configuration of port %d :\n", port_id); 18009 18010 port_offloads = port->dev_conf.rxmode.offloads; 18011 printf(" Port :"); 18012 print_rx_offloads(port_offloads); 18013 printf("\n"); 18014 18015 ret = eth_dev_info_get_print_err(port_id, &dev_info); 18016 if (ret != 0) 18017 return; 18018 18019 nb_rx_queues = dev_info.nb_rx_queues; 18020 for (q = 0; q < nb_rx_queues; q++) { 18021 queue_offloads = port->rx_conf[q].offloads; 18022 printf(" Queue[%2d] :", q); 18023 print_rx_offloads(queue_offloads); 18024 printf("\n"); 18025 } 18026 printf("\n"); 18027 } 18028 18029 cmdline_parse_inst_t cmd_rx_offload_get_configuration = { 18030 .f = cmd_rx_offload_get_configuration_parsed, 18031 .data = NULL, 18032 .help_str = "show port <port_id> rx_offload configuration", 18033 .tokens = { 18034 (void *)&cmd_rx_offload_get_configuration_show, 18035 (void *)&cmd_rx_offload_get_configuration_port, 18036 (void *)&cmd_rx_offload_get_configuration_port_id, 18037 (void *)&cmd_rx_offload_get_configuration_rx_offload, 18038 (void *)&cmd_rx_offload_get_configuration_configuration, 18039 NULL, 18040 } 18041 }; 18042 18043 /* Enable/Disable a per port offloading */ 18044 struct cmd_config_per_port_rx_offload_result { 18045 cmdline_fixed_string_t port; 18046 cmdline_fixed_string_t config; 18047 portid_t port_id; 18048 cmdline_fixed_string_t rx_offload; 18049 cmdline_fixed_string_t offload; 18050 cmdline_fixed_string_t on_off; 18051 }; 18052 18053 cmdline_parse_token_string_t cmd_config_per_port_rx_offload_result_port = 18054 TOKEN_STRING_INITIALIZER 18055 (struct cmd_config_per_port_rx_offload_result, 18056 port, "port"); 18057 cmdline_parse_token_string_t cmd_config_per_port_rx_offload_result_config = 18058 TOKEN_STRING_INITIALIZER 18059 (struct cmd_config_per_port_rx_offload_result, 18060 config, "config"); 18061 cmdline_parse_token_num_t cmd_config_per_port_rx_offload_result_port_id = 18062 TOKEN_NUM_INITIALIZER 18063 (struct cmd_config_per_port_rx_offload_result, 18064 port_id, UINT16); 18065 cmdline_parse_token_string_t cmd_config_per_port_rx_offload_result_rx_offload = 18066 TOKEN_STRING_INITIALIZER 18067 (struct cmd_config_per_port_rx_offload_result, 18068 rx_offload, "rx_offload"); 18069 cmdline_parse_token_string_t cmd_config_per_port_rx_offload_result_offload = 18070 TOKEN_STRING_INITIALIZER 18071 (struct cmd_config_per_port_rx_offload_result, 18072 offload, "vlan_strip#ipv4_cksum#udp_cksum#tcp_cksum#tcp_lro#" 18073 "qinq_strip#outer_ipv4_cksum#macsec_strip#" 18074 "header_split#vlan_filter#vlan_extend#jumbo_frame#" 18075 "crc_strip#scatter#timestamp#security#keep_crc"); 18076 cmdline_parse_token_string_t cmd_config_per_port_rx_offload_result_on_off = 18077 TOKEN_STRING_INITIALIZER 18078 (struct cmd_config_per_port_rx_offload_result, 18079 on_off, "on#off"); 18080 18081 static uint64_t 18082 search_rx_offload(const char *name) 18083 { 18084 uint64_t single_offload; 18085 const char *single_name; 18086 int found = 0; 18087 unsigned int bit; 18088 18089 single_offload = 1; 18090 for (bit = 0; bit < sizeof(single_offload) * CHAR_BIT; bit++) { 18091 single_name = rte_eth_dev_rx_offload_name(single_offload); 18092 if (!strcasecmp(single_name, name)) { 18093 found = 1; 18094 break; 18095 } 18096 single_offload <<= 1; 18097 } 18098 18099 if (found) 18100 return single_offload; 18101 18102 return 0; 18103 } 18104 18105 static void 18106 cmd_config_per_port_rx_offload_parsed(void *parsed_result, 18107 __attribute__((unused)) struct cmdline *cl, 18108 __attribute__((unused)) void *data) 18109 { 18110 struct cmd_config_per_port_rx_offload_result *res = parsed_result; 18111 portid_t port_id = res->port_id; 18112 struct rte_eth_dev_info dev_info; 18113 struct rte_port *port = &ports[port_id]; 18114 uint64_t single_offload; 18115 uint16_t nb_rx_queues; 18116 int q; 18117 int ret; 18118 18119 if (port->port_status != RTE_PORT_STOPPED) { 18120 printf("Error: Can't config offload when Port %d " 18121 "is not stopped\n", port_id); 18122 return; 18123 } 18124 18125 single_offload = search_rx_offload(res->offload); 18126 if (single_offload == 0) { 18127 printf("Unknown offload name: %s\n", res->offload); 18128 return; 18129 } 18130 18131 ret = eth_dev_info_get_print_err(port_id, &dev_info); 18132 if (ret != 0) 18133 return; 18134 18135 nb_rx_queues = dev_info.nb_rx_queues; 18136 if (!strcmp(res->on_off, "on")) { 18137 port->dev_conf.rxmode.offloads |= single_offload; 18138 for (q = 0; q < nb_rx_queues; q++) 18139 port->rx_conf[q].offloads |= single_offload; 18140 } else { 18141 port->dev_conf.rxmode.offloads &= ~single_offload; 18142 for (q = 0; q < nb_rx_queues; q++) 18143 port->rx_conf[q].offloads &= ~single_offload; 18144 } 18145 18146 cmd_reconfig_device_queue(port_id, 1, 1); 18147 } 18148 18149 cmdline_parse_inst_t cmd_config_per_port_rx_offload = { 18150 .f = cmd_config_per_port_rx_offload_parsed, 18151 .data = NULL, 18152 .help_str = "port config <port_id> rx_offload vlan_strip|ipv4_cksum|" 18153 "udp_cksum|tcp_cksum|tcp_lro|qinq_strip|outer_ipv4_cksum|" 18154 "macsec_strip|header_split|vlan_filter|vlan_extend|" 18155 "jumbo_frame|crc_strip|scatter|timestamp|security|keep_crc " 18156 "on|off", 18157 .tokens = { 18158 (void *)&cmd_config_per_port_rx_offload_result_port, 18159 (void *)&cmd_config_per_port_rx_offload_result_config, 18160 (void *)&cmd_config_per_port_rx_offload_result_port_id, 18161 (void *)&cmd_config_per_port_rx_offload_result_rx_offload, 18162 (void *)&cmd_config_per_port_rx_offload_result_offload, 18163 (void *)&cmd_config_per_port_rx_offload_result_on_off, 18164 NULL, 18165 } 18166 }; 18167 18168 /* Enable/Disable a per queue offloading */ 18169 struct cmd_config_per_queue_rx_offload_result { 18170 cmdline_fixed_string_t port; 18171 portid_t port_id; 18172 cmdline_fixed_string_t rxq; 18173 uint16_t queue_id; 18174 cmdline_fixed_string_t rx_offload; 18175 cmdline_fixed_string_t offload; 18176 cmdline_fixed_string_t on_off; 18177 }; 18178 18179 cmdline_parse_token_string_t cmd_config_per_queue_rx_offload_result_port = 18180 TOKEN_STRING_INITIALIZER 18181 (struct cmd_config_per_queue_rx_offload_result, 18182 port, "port"); 18183 cmdline_parse_token_num_t cmd_config_per_queue_rx_offload_result_port_id = 18184 TOKEN_NUM_INITIALIZER 18185 (struct cmd_config_per_queue_rx_offload_result, 18186 port_id, UINT16); 18187 cmdline_parse_token_string_t cmd_config_per_queue_rx_offload_result_rxq = 18188 TOKEN_STRING_INITIALIZER 18189 (struct cmd_config_per_queue_rx_offload_result, 18190 rxq, "rxq"); 18191 cmdline_parse_token_num_t cmd_config_per_queue_rx_offload_result_queue_id = 18192 TOKEN_NUM_INITIALIZER 18193 (struct cmd_config_per_queue_rx_offload_result, 18194 queue_id, UINT16); 18195 cmdline_parse_token_string_t cmd_config_per_queue_rx_offload_result_rxoffload = 18196 TOKEN_STRING_INITIALIZER 18197 (struct cmd_config_per_queue_rx_offload_result, 18198 rx_offload, "rx_offload"); 18199 cmdline_parse_token_string_t cmd_config_per_queue_rx_offload_result_offload = 18200 TOKEN_STRING_INITIALIZER 18201 (struct cmd_config_per_queue_rx_offload_result, 18202 offload, "vlan_strip#ipv4_cksum#udp_cksum#tcp_cksum#tcp_lro#" 18203 "qinq_strip#outer_ipv4_cksum#macsec_strip#" 18204 "header_split#vlan_filter#vlan_extend#jumbo_frame#" 18205 "crc_strip#scatter#timestamp#security#keep_crc"); 18206 cmdline_parse_token_string_t cmd_config_per_queue_rx_offload_result_on_off = 18207 TOKEN_STRING_INITIALIZER 18208 (struct cmd_config_per_queue_rx_offload_result, 18209 on_off, "on#off"); 18210 18211 static void 18212 cmd_config_per_queue_rx_offload_parsed(void *parsed_result, 18213 __attribute__((unused)) struct cmdline *cl, 18214 __attribute__((unused)) void *data) 18215 { 18216 struct cmd_config_per_queue_rx_offload_result *res = parsed_result; 18217 struct rte_eth_dev_info dev_info; 18218 portid_t port_id = res->port_id; 18219 uint16_t queue_id = res->queue_id; 18220 struct rte_port *port = &ports[port_id]; 18221 uint64_t single_offload; 18222 int ret; 18223 18224 if (port->port_status != RTE_PORT_STOPPED) { 18225 printf("Error: Can't config offload when Port %d " 18226 "is not stopped\n", port_id); 18227 return; 18228 } 18229 18230 ret = eth_dev_info_get_print_err(port_id, &dev_info); 18231 if (ret != 0) 18232 return; 18233 18234 if (queue_id >= dev_info.nb_rx_queues) { 18235 printf("Error: input queue_id should be 0 ... " 18236 "%d\n", dev_info.nb_rx_queues - 1); 18237 return; 18238 } 18239 18240 single_offload = search_rx_offload(res->offload); 18241 if (single_offload == 0) { 18242 printf("Unknown offload name: %s\n", res->offload); 18243 return; 18244 } 18245 18246 if (!strcmp(res->on_off, "on")) 18247 port->rx_conf[queue_id].offloads |= single_offload; 18248 else 18249 port->rx_conf[queue_id].offloads &= ~single_offload; 18250 18251 cmd_reconfig_device_queue(port_id, 1, 1); 18252 } 18253 18254 cmdline_parse_inst_t cmd_config_per_queue_rx_offload = { 18255 .f = cmd_config_per_queue_rx_offload_parsed, 18256 .data = NULL, 18257 .help_str = "port <port_id> rxq <queue_id> rx_offload " 18258 "vlan_strip|ipv4_cksum|" 18259 "udp_cksum|tcp_cksum|tcp_lro|qinq_strip|outer_ipv4_cksum|" 18260 "macsec_strip|header_split|vlan_filter|vlan_extend|" 18261 "jumbo_frame|crc_strip|scatter|timestamp|security|keep_crc " 18262 "on|off", 18263 .tokens = { 18264 (void *)&cmd_config_per_queue_rx_offload_result_port, 18265 (void *)&cmd_config_per_queue_rx_offload_result_port_id, 18266 (void *)&cmd_config_per_queue_rx_offload_result_rxq, 18267 (void *)&cmd_config_per_queue_rx_offload_result_queue_id, 18268 (void *)&cmd_config_per_queue_rx_offload_result_rxoffload, 18269 (void *)&cmd_config_per_queue_rx_offload_result_offload, 18270 (void *)&cmd_config_per_queue_rx_offload_result_on_off, 18271 NULL, 18272 } 18273 }; 18274 18275 /* Get Tx offloads capabilities */ 18276 struct cmd_tx_offload_get_capa_result { 18277 cmdline_fixed_string_t show; 18278 cmdline_fixed_string_t port; 18279 portid_t port_id; 18280 cmdline_fixed_string_t tx_offload; 18281 cmdline_fixed_string_t capabilities; 18282 }; 18283 18284 cmdline_parse_token_string_t cmd_tx_offload_get_capa_show = 18285 TOKEN_STRING_INITIALIZER 18286 (struct cmd_tx_offload_get_capa_result, 18287 show, "show"); 18288 cmdline_parse_token_string_t cmd_tx_offload_get_capa_port = 18289 TOKEN_STRING_INITIALIZER 18290 (struct cmd_tx_offload_get_capa_result, 18291 port, "port"); 18292 cmdline_parse_token_num_t cmd_tx_offload_get_capa_port_id = 18293 TOKEN_NUM_INITIALIZER 18294 (struct cmd_tx_offload_get_capa_result, 18295 port_id, UINT16); 18296 cmdline_parse_token_string_t cmd_tx_offload_get_capa_tx_offload = 18297 TOKEN_STRING_INITIALIZER 18298 (struct cmd_tx_offload_get_capa_result, 18299 tx_offload, "tx_offload"); 18300 cmdline_parse_token_string_t cmd_tx_offload_get_capa_capabilities = 18301 TOKEN_STRING_INITIALIZER 18302 (struct cmd_tx_offload_get_capa_result, 18303 capabilities, "capabilities"); 18304 18305 static void 18306 print_tx_offloads(uint64_t offloads) 18307 { 18308 uint64_t single_offload; 18309 int begin; 18310 int end; 18311 int bit; 18312 18313 if (offloads == 0) 18314 return; 18315 18316 begin = __builtin_ctzll(offloads); 18317 end = sizeof(offloads) * CHAR_BIT - __builtin_clzll(offloads); 18318 18319 single_offload = 1ULL << begin; 18320 for (bit = begin; bit < end; bit++) { 18321 if (offloads & single_offload) 18322 printf(" %s", 18323 rte_eth_dev_tx_offload_name(single_offload)); 18324 single_offload <<= 1; 18325 } 18326 } 18327 18328 static void 18329 cmd_tx_offload_get_capa_parsed( 18330 void *parsed_result, 18331 __attribute__((unused)) struct cmdline *cl, 18332 __attribute__((unused)) void *data) 18333 { 18334 struct cmd_tx_offload_get_capa_result *res = parsed_result; 18335 struct rte_eth_dev_info dev_info; 18336 portid_t port_id = res->port_id; 18337 uint64_t queue_offloads; 18338 uint64_t port_offloads; 18339 int ret; 18340 18341 ret = eth_dev_info_get_print_err(port_id, &dev_info); 18342 if (ret != 0) 18343 return; 18344 18345 queue_offloads = dev_info.tx_queue_offload_capa; 18346 port_offloads = dev_info.tx_offload_capa ^ queue_offloads; 18347 18348 printf("Tx Offloading Capabilities of port %d :\n", port_id); 18349 printf(" Per Queue :"); 18350 print_tx_offloads(queue_offloads); 18351 18352 printf("\n"); 18353 printf(" Per Port :"); 18354 print_tx_offloads(port_offloads); 18355 printf("\n\n"); 18356 } 18357 18358 cmdline_parse_inst_t cmd_tx_offload_get_capa = { 18359 .f = cmd_tx_offload_get_capa_parsed, 18360 .data = NULL, 18361 .help_str = "show port <port_id> tx_offload capabilities", 18362 .tokens = { 18363 (void *)&cmd_tx_offload_get_capa_show, 18364 (void *)&cmd_tx_offload_get_capa_port, 18365 (void *)&cmd_tx_offload_get_capa_port_id, 18366 (void *)&cmd_tx_offload_get_capa_tx_offload, 18367 (void *)&cmd_tx_offload_get_capa_capabilities, 18368 NULL, 18369 } 18370 }; 18371 18372 /* Get Tx offloads configuration */ 18373 struct cmd_tx_offload_get_configuration_result { 18374 cmdline_fixed_string_t show; 18375 cmdline_fixed_string_t port; 18376 portid_t port_id; 18377 cmdline_fixed_string_t tx_offload; 18378 cmdline_fixed_string_t configuration; 18379 }; 18380 18381 cmdline_parse_token_string_t cmd_tx_offload_get_configuration_show = 18382 TOKEN_STRING_INITIALIZER 18383 (struct cmd_tx_offload_get_configuration_result, 18384 show, "show"); 18385 cmdline_parse_token_string_t cmd_tx_offload_get_configuration_port = 18386 TOKEN_STRING_INITIALIZER 18387 (struct cmd_tx_offload_get_configuration_result, 18388 port, "port"); 18389 cmdline_parse_token_num_t cmd_tx_offload_get_configuration_port_id = 18390 TOKEN_NUM_INITIALIZER 18391 (struct cmd_tx_offload_get_configuration_result, 18392 port_id, UINT16); 18393 cmdline_parse_token_string_t cmd_tx_offload_get_configuration_tx_offload = 18394 TOKEN_STRING_INITIALIZER 18395 (struct cmd_tx_offload_get_configuration_result, 18396 tx_offload, "tx_offload"); 18397 cmdline_parse_token_string_t cmd_tx_offload_get_configuration_configuration = 18398 TOKEN_STRING_INITIALIZER 18399 (struct cmd_tx_offload_get_configuration_result, 18400 configuration, "configuration"); 18401 18402 static void 18403 cmd_tx_offload_get_configuration_parsed( 18404 void *parsed_result, 18405 __attribute__((unused)) struct cmdline *cl, 18406 __attribute__((unused)) void *data) 18407 { 18408 struct cmd_tx_offload_get_configuration_result *res = parsed_result; 18409 struct rte_eth_dev_info dev_info; 18410 portid_t port_id = res->port_id; 18411 struct rte_port *port = &ports[port_id]; 18412 uint64_t port_offloads; 18413 uint64_t queue_offloads; 18414 uint16_t nb_tx_queues; 18415 int q; 18416 int ret; 18417 18418 printf("Tx Offloading Configuration of port %d :\n", port_id); 18419 18420 port_offloads = port->dev_conf.txmode.offloads; 18421 printf(" Port :"); 18422 print_tx_offloads(port_offloads); 18423 printf("\n"); 18424 18425 ret = eth_dev_info_get_print_err(port_id, &dev_info); 18426 if (ret != 0) 18427 return; 18428 18429 nb_tx_queues = dev_info.nb_tx_queues; 18430 for (q = 0; q < nb_tx_queues; q++) { 18431 queue_offloads = port->tx_conf[q].offloads; 18432 printf(" Queue[%2d] :", q); 18433 print_tx_offloads(queue_offloads); 18434 printf("\n"); 18435 } 18436 printf("\n"); 18437 } 18438 18439 cmdline_parse_inst_t cmd_tx_offload_get_configuration = { 18440 .f = cmd_tx_offload_get_configuration_parsed, 18441 .data = NULL, 18442 .help_str = "show port <port_id> tx_offload configuration", 18443 .tokens = { 18444 (void *)&cmd_tx_offload_get_configuration_show, 18445 (void *)&cmd_tx_offload_get_configuration_port, 18446 (void *)&cmd_tx_offload_get_configuration_port_id, 18447 (void *)&cmd_tx_offload_get_configuration_tx_offload, 18448 (void *)&cmd_tx_offload_get_configuration_configuration, 18449 NULL, 18450 } 18451 }; 18452 18453 /* Enable/Disable a per port offloading */ 18454 struct cmd_config_per_port_tx_offload_result { 18455 cmdline_fixed_string_t port; 18456 cmdline_fixed_string_t config; 18457 portid_t port_id; 18458 cmdline_fixed_string_t tx_offload; 18459 cmdline_fixed_string_t offload; 18460 cmdline_fixed_string_t on_off; 18461 }; 18462 18463 cmdline_parse_token_string_t cmd_config_per_port_tx_offload_result_port = 18464 TOKEN_STRING_INITIALIZER 18465 (struct cmd_config_per_port_tx_offload_result, 18466 port, "port"); 18467 cmdline_parse_token_string_t cmd_config_per_port_tx_offload_result_config = 18468 TOKEN_STRING_INITIALIZER 18469 (struct cmd_config_per_port_tx_offload_result, 18470 config, "config"); 18471 cmdline_parse_token_num_t cmd_config_per_port_tx_offload_result_port_id = 18472 TOKEN_NUM_INITIALIZER 18473 (struct cmd_config_per_port_tx_offload_result, 18474 port_id, UINT16); 18475 cmdline_parse_token_string_t cmd_config_per_port_tx_offload_result_tx_offload = 18476 TOKEN_STRING_INITIALIZER 18477 (struct cmd_config_per_port_tx_offload_result, 18478 tx_offload, "tx_offload"); 18479 cmdline_parse_token_string_t cmd_config_per_port_tx_offload_result_offload = 18480 TOKEN_STRING_INITIALIZER 18481 (struct cmd_config_per_port_tx_offload_result, 18482 offload, "vlan_insert#ipv4_cksum#udp_cksum#tcp_cksum#" 18483 "sctp_cksum#tcp_tso#udp_tso#outer_ipv4_cksum#" 18484 "qinq_insert#vxlan_tnl_tso#gre_tnl_tso#" 18485 "ipip_tnl_tso#geneve_tnl_tso#macsec_insert#" 18486 "mt_lockfree#multi_segs#mbuf_fast_free#security#" 18487 "match_metadata"); 18488 cmdline_parse_token_string_t cmd_config_per_port_tx_offload_result_on_off = 18489 TOKEN_STRING_INITIALIZER 18490 (struct cmd_config_per_port_tx_offload_result, 18491 on_off, "on#off"); 18492 18493 static uint64_t 18494 search_tx_offload(const char *name) 18495 { 18496 uint64_t single_offload; 18497 const char *single_name; 18498 int found = 0; 18499 unsigned int bit; 18500 18501 single_offload = 1; 18502 for (bit = 0; bit < sizeof(single_offload) * CHAR_BIT; bit++) { 18503 single_name = rte_eth_dev_tx_offload_name(single_offload); 18504 if (single_name == NULL) 18505 break; 18506 if (!strcasecmp(single_name, name)) { 18507 found = 1; 18508 break; 18509 } else if (!strcasecmp(single_name, "UNKNOWN")) 18510 break; 18511 single_offload <<= 1; 18512 } 18513 18514 if (found) 18515 return single_offload; 18516 18517 return 0; 18518 } 18519 18520 static void 18521 cmd_config_per_port_tx_offload_parsed(void *parsed_result, 18522 __attribute__((unused)) struct cmdline *cl, 18523 __attribute__((unused)) void *data) 18524 { 18525 struct cmd_config_per_port_tx_offload_result *res = parsed_result; 18526 portid_t port_id = res->port_id; 18527 struct rte_eth_dev_info dev_info; 18528 struct rte_port *port = &ports[port_id]; 18529 uint64_t single_offload; 18530 uint16_t nb_tx_queues; 18531 int q; 18532 int ret; 18533 18534 if (port->port_status != RTE_PORT_STOPPED) { 18535 printf("Error: Can't config offload when Port %d " 18536 "is not stopped\n", port_id); 18537 return; 18538 } 18539 18540 single_offload = search_tx_offload(res->offload); 18541 if (single_offload == 0) { 18542 printf("Unknown offload name: %s\n", res->offload); 18543 return; 18544 } 18545 18546 ret = eth_dev_info_get_print_err(port_id, &dev_info); 18547 if (ret != 0) 18548 return; 18549 18550 nb_tx_queues = dev_info.nb_tx_queues; 18551 if (!strcmp(res->on_off, "on")) { 18552 port->dev_conf.txmode.offloads |= single_offload; 18553 for (q = 0; q < nb_tx_queues; q++) 18554 port->tx_conf[q].offloads |= single_offload; 18555 } else { 18556 port->dev_conf.txmode.offloads &= ~single_offload; 18557 for (q = 0; q < nb_tx_queues; q++) 18558 port->tx_conf[q].offloads &= ~single_offload; 18559 } 18560 18561 cmd_reconfig_device_queue(port_id, 1, 1); 18562 } 18563 18564 cmdline_parse_inst_t cmd_config_per_port_tx_offload = { 18565 .f = cmd_config_per_port_tx_offload_parsed, 18566 .data = NULL, 18567 .help_str = "port config <port_id> tx_offload " 18568 "vlan_insert|ipv4_cksum|udp_cksum|tcp_cksum|" 18569 "sctp_cksum|tcp_tso|udp_tso|outer_ipv4_cksum|" 18570 "qinq_insert|vxlan_tnl_tso|gre_tnl_tso|" 18571 "ipip_tnl_tso|geneve_tnl_tso|macsec_insert|" 18572 "mt_lockfree|multi_segs|mbuf_fast_free|security|" 18573 "match_metadata on|off", 18574 .tokens = { 18575 (void *)&cmd_config_per_port_tx_offload_result_port, 18576 (void *)&cmd_config_per_port_tx_offload_result_config, 18577 (void *)&cmd_config_per_port_tx_offload_result_port_id, 18578 (void *)&cmd_config_per_port_tx_offload_result_tx_offload, 18579 (void *)&cmd_config_per_port_tx_offload_result_offload, 18580 (void *)&cmd_config_per_port_tx_offload_result_on_off, 18581 NULL, 18582 } 18583 }; 18584 18585 /* Enable/Disable a per queue offloading */ 18586 struct cmd_config_per_queue_tx_offload_result { 18587 cmdline_fixed_string_t port; 18588 portid_t port_id; 18589 cmdline_fixed_string_t txq; 18590 uint16_t queue_id; 18591 cmdline_fixed_string_t tx_offload; 18592 cmdline_fixed_string_t offload; 18593 cmdline_fixed_string_t on_off; 18594 }; 18595 18596 cmdline_parse_token_string_t cmd_config_per_queue_tx_offload_result_port = 18597 TOKEN_STRING_INITIALIZER 18598 (struct cmd_config_per_queue_tx_offload_result, 18599 port, "port"); 18600 cmdline_parse_token_num_t cmd_config_per_queue_tx_offload_result_port_id = 18601 TOKEN_NUM_INITIALIZER 18602 (struct cmd_config_per_queue_tx_offload_result, 18603 port_id, UINT16); 18604 cmdline_parse_token_string_t cmd_config_per_queue_tx_offload_result_txq = 18605 TOKEN_STRING_INITIALIZER 18606 (struct cmd_config_per_queue_tx_offload_result, 18607 txq, "txq"); 18608 cmdline_parse_token_num_t cmd_config_per_queue_tx_offload_result_queue_id = 18609 TOKEN_NUM_INITIALIZER 18610 (struct cmd_config_per_queue_tx_offload_result, 18611 queue_id, UINT16); 18612 cmdline_parse_token_string_t cmd_config_per_queue_tx_offload_result_txoffload = 18613 TOKEN_STRING_INITIALIZER 18614 (struct cmd_config_per_queue_tx_offload_result, 18615 tx_offload, "tx_offload"); 18616 cmdline_parse_token_string_t cmd_config_per_queue_tx_offload_result_offload = 18617 TOKEN_STRING_INITIALIZER 18618 (struct cmd_config_per_queue_tx_offload_result, 18619 offload, "vlan_insert#ipv4_cksum#udp_cksum#tcp_cksum#" 18620 "sctp_cksum#tcp_tso#udp_tso#outer_ipv4_cksum#" 18621 "qinq_insert#vxlan_tnl_tso#gre_tnl_tso#" 18622 "ipip_tnl_tso#geneve_tnl_tso#macsec_insert#" 18623 "mt_lockfree#multi_segs#mbuf_fast_free#security"); 18624 cmdline_parse_token_string_t cmd_config_per_queue_tx_offload_result_on_off = 18625 TOKEN_STRING_INITIALIZER 18626 (struct cmd_config_per_queue_tx_offload_result, 18627 on_off, "on#off"); 18628 18629 static void 18630 cmd_config_per_queue_tx_offload_parsed(void *parsed_result, 18631 __attribute__((unused)) struct cmdline *cl, 18632 __attribute__((unused)) void *data) 18633 { 18634 struct cmd_config_per_queue_tx_offload_result *res = parsed_result; 18635 struct rte_eth_dev_info dev_info; 18636 portid_t port_id = res->port_id; 18637 uint16_t queue_id = res->queue_id; 18638 struct rte_port *port = &ports[port_id]; 18639 uint64_t single_offload; 18640 int ret; 18641 18642 if (port->port_status != RTE_PORT_STOPPED) { 18643 printf("Error: Can't config offload when Port %d " 18644 "is not stopped\n", port_id); 18645 return; 18646 } 18647 18648 ret = eth_dev_info_get_print_err(port_id, &dev_info); 18649 if (ret != 0) 18650 return; 18651 18652 if (queue_id >= dev_info.nb_tx_queues) { 18653 printf("Error: input queue_id should be 0 ... " 18654 "%d\n", dev_info.nb_tx_queues - 1); 18655 return; 18656 } 18657 18658 single_offload = search_tx_offload(res->offload); 18659 if (single_offload == 0) { 18660 printf("Unknown offload name: %s\n", res->offload); 18661 return; 18662 } 18663 18664 if (!strcmp(res->on_off, "on")) 18665 port->tx_conf[queue_id].offloads |= single_offload; 18666 else 18667 port->tx_conf[queue_id].offloads &= ~single_offload; 18668 18669 cmd_reconfig_device_queue(port_id, 1, 1); 18670 } 18671 18672 cmdline_parse_inst_t cmd_config_per_queue_tx_offload = { 18673 .f = cmd_config_per_queue_tx_offload_parsed, 18674 .data = NULL, 18675 .help_str = "port <port_id> txq <queue_id> tx_offload " 18676 "vlan_insert|ipv4_cksum|udp_cksum|tcp_cksum|" 18677 "sctp_cksum|tcp_tso|udp_tso|outer_ipv4_cksum|" 18678 "qinq_insert|vxlan_tnl_tso|gre_tnl_tso|" 18679 "ipip_tnl_tso|geneve_tnl_tso|macsec_insert|" 18680 "mt_lockfree|multi_segs|mbuf_fast_free|security " 18681 "on|off", 18682 .tokens = { 18683 (void *)&cmd_config_per_queue_tx_offload_result_port, 18684 (void *)&cmd_config_per_queue_tx_offload_result_port_id, 18685 (void *)&cmd_config_per_queue_tx_offload_result_txq, 18686 (void *)&cmd_config_per_queue_tx_offload_result_queue_id, 18687 (void *)&cmd_config_per_queue_tx_offload_result_txoffload, 18688 (void *)&cmd_config_per_queue_tx_offload_result_offload, 18689 (void *)&cmd_config_per_queue_tx_offload_result_on_off, 18690 NULL, 18691 } 18692 }; 18693 18694 /* *** configure tx_metadata for specific port *** */ 18695 struct cmd_config_tx_metadata_specific_result { 18696 cmdline_fixed_string_t port; 18697 cmdline_fixed_string_t keyword; 18698 uint16_t port_id; 18699 cmdline_fixed_string_t item; 18700 uint32_t value; 18701 }; 18702 18703 static void 18704 cmd_config_tx_metadata_specific_parsed(void *parsed_result, 18705 __attribute__((unused)) struct cmdline *cl, 18706 __attribute__((unused)) void *data) 18707 { 18708 struct cmd_config_tx_metadata_specific_result *res = parsed_result; 18709 18710 if (port_id_is_invalid(res->port_id, ENABLED_WARN)) 18711 return; 18712 ports[res->port_id].tx_metadata = rte_cpu_to_be_32(res->value); 18713 /* Add/remove callback to insert valid metadata in every Tx packet. */ 18714 if (ports[res->port_id].tx_metadata) 18715 add_tx_md_callback(res->port_id); 18716 else 18717 remove_tx_md_callback(res->port_id); 18718 } 18719 18720 cmdline_parse_token_string_t cmd_config_tx_metadata_specific_port = 18721 TOKEN_STRING_INITIALIZER(struct cmd_config_tx_metadata_specific_result, 18722 port, "port"); 18723 cmdline_parse_token_string_t cmd_config_tx_metadata_specific_keyword = 18724 TOKEN_STRING_INITIALIZER(struct cmd_config_tx_metadata_specific_result, 18725 keyword, "config"); 18726 cmdline_parse_token_num_t cmd_config_tx_metadata_specific_id = 18727 TOKEN_NUM_INITIALIZER(struct cmd_config_tx_metadata_specific_result, 18728 port_id, UINT16); 18729 cmdline_parse_token_string_t cmd_config_tx_metadata_specific_item = 18730 TOKEN_STRING_INITIALIZER(struct cmd_config_tx_metadata_specific_result, 18731 item, "tx_metadata"); 18732 cmdline_parse_token_num_t cmd_config_tx_metadata_specific_value = 18733 TOKEN_NUM_INITIALIZER(struct cmd_config_tx_metadata_specific_result, 18734 value, UINT32); 18735 18736 cmdline_parse_inst_t cmd_config_tx_metadata_specific = { 18737 .f = cmd_config_tx_metadata_specific_parsed, 18738 .data = NULL, 18739 .help_str = "port config <port_id> tx_metadata <value>", 18740 .tokens = { 18741 (void *)&cmd_config_tx_metadata_specific_port, 18742 (void *)&cmd_config_tx_metadata_specific_keyword, 18743 (void *)&cmd_config_tx_metadata_specific_id, 18744 (void *)&cmd_config_tx_metadata_specific_item, 18745 (void *)&cmd_config_tx_metadata_specific_value, 18746 NULL, 18747 }, 18748 }; 18749 18750 /* *** display tx_metadata per port configuration *** */ 18751 struct cmd_show_tx_metadata_result { 18752 cmdline_fixed_string_t cmd_show; 18753 cmdline_fixed_string_t cmd_port; 18754 cmdline_fixed_string_t cmd_keyword; 18755 portid_t cmd_pid; 18756 }; 18757 18758 static void 18759 cmd_show_tx_metadata_parsed(void *parsed_result, 18760 __attribute__((unused)) struct cmdline *cl, 18761 __attribute__((unused)) void *data) 18762 { 18763 struct cmd_show_tx_metadata_result *res = parsed_result; 18764 18765 if (!rte_eth_dev_is_valid_port(res->cmd_pid)) { 18766 printf("invalid port id %u\n", res->cmd_pid); 18767 return; 18768 } 18769 if (!strcmp(res->cmd_keyword, "tx_metadata")) { 18770 printf("Port %u tx_metadata: %u\n", res->cmd_pid, 18771 rte_be_to_cpu_32(ports[res->cmd_pid].tx_metadata)); 18772 } 18773 } 18774 18775 cmdline_parse_token_string_t cmd_show_tx_metadata_show = 18776 TOKEN_STRING_INITIALIZER(struct cmd_show_tx_metadata_result, 18777 cmd_show, "show"); 18778 cmdline_parse_token_string_t cmd_show_tx_metadata_port = 18779 TOKEN_STRING_INITIALIZER(struct cmd_show_tx_metadata_result, 18780 cmd_port, "port"); 18781 cmdline_parse_token_num_t cmd_show_tx_metadata_pid = 18782 TOKEN_NUM_INITIALIZER(struct cmd_show_tx_metadata_result, 18783 cmd_pid, UINT16); 18784 cmdline_parse_token_string_t cmd_show_tx_metadata_keyword = 18785 TOKEN_STRING_INITIALIZER(struct cmd_show_tx_metadata_result, 18786 cmd_keyword, "tx_metadata"); 18787 18788 cmdline_parse_inst_t cmd_show_tx_metadata = { 18789 .f = cmd_show_tx_metadata_parsed, 18790 .data = NULL, 18791 .help_str = "show port <port_id> tx_metadata", 18792 .tokens = { 18793 (void *)&cmd_show_tx_metadata_show, 18794 (void *)&cmd_show_tx_metadata_port, 18795 (void *)&cmd_show_tx_metadata_pid, 18796 (void *)&cmd_show_tx_metadata_keyword, 18797 NULL, 18798 }, 18799 }; 18800 18801 /* ******************************************************************************** */ 18802 18803 /* list of instructions */ 18804 cmdline_parse_ctx_t main_ctx[] = { 18805 (cmdline_parse_inst_t *)&cmd_help_brief, 18806 (cmdline_parse_inst_t *)&cmd_help_long, 18807 (cmdline_parse_inst_t *)&cmd_quit, 18808 (cmdline_parse_inst_t *)&cmd_load_from_file, 18809 (cmdline_parse_inst_t *)&cmd_showport, 18810 (cmdline_parse_inst_t *)&cmd_showqueue, 18811 (cmdline_parse_inst_t *)&cmd_showportall, 18812 (cmdline_parse_inst_t *)&cmd_showdevice, 18813 (cmdline_parse_inst_t *)&cmd_showcfg, 18814 (cmdline_parse_inst_t *)&cmd_showfwdall, 18815 (cmdline_parse_inst_t *)&cmd_start, 18816 (cmdline_parse_inst_t *)&cmd_start_tx_first, 18817 (cmdline_parse_inst_t *)&cmd_start_tx_first_n, 18818 (cmdline_parse_inst_t *)&cmd_set_link_up, 18819 (cmdline_parse_inst_t *)&cmd_set_link_down, 18820 (cmdline_parse_inst_t *)&cmd_reset, 18821 (cmdline_parse_inst_t *)&cmd_set_numbers, 18822 (cmdline_parse_inst_t *)&cmd_set_log, 18823 (cmdline_parse_inst_t *)&cmd_set_txpkts, 18824 (cmdline_parse_inst_t *)&cmd_set_txsplit, 18825 (cmdline_parse_inst_t *)&cmd_set_fwd_list, 18826 (cmdline_parse_inst_t *)&cmd_set_fwd_mask, 18827 (cmdline_parse_inst_t *)&cmd_set_fwd_mode, 18828 (cmdline_parse_inst_t *)&cmd_set_fwd_retry_mode, 18829 (cmdline_parse_inst_t *)&cmd_set_burst_tx_retry, 18830 (cmdline_parse_inst_t *)&cmd_set_promisc_mode_one, 18831 (cmdline_parse_inst_t *)&cmd_set_promisc_mode_all, 18832 (cmdline_parse_inst_t *)&cmd_set_allmulti_mode_one, 18833 (cmdline_parse_inst_t *)&cmd_set_allmulti_mode_all, 18834 (cmdline_parse_inst_t *)&cmd_set_flush_rx, 18835 (cmdline_parse_inst_t *)&cmd_set_link_check, 18836 (cmdline_parse_inst_t *)&cmd_set_bypass_mode, 18837 (cmdline_parse_inst_t *)&cmd_set_bypass_event, 18838 (cmdline_parse_inst_t *)&cmd_set_bypass_timeout, 18839 (cmdline_parse_inst_t *)&cmd_show_bypass_config, 18840 #ifdef RTE_LIBRTE_PMD_BOND 18841 (cmdline_parse_inst_t *) &cmd_set_bonding_mode, 18842 (cmdline_parse_inst_t *) &cmd_show_bonding_config, 18843 (cmdline_parse_inst_t *) &cmd_set_bonding_primary, 18844 (cmdline_parse_inst_t *) &cmd_add_bonding_slave, 18845 (cmdline_parse_inst_t *) &cmd_remove_bonding_slave, 18846 (cmdline_parse_inst_t *) &cmd_create_bonded_device, 18847 (cmdline_parse_inst_t *) &cmd_set_bond_mac_addr, 18848 (cmdline_parse_inst_t *) &cmd_set_balance_xmit_policy, 18849 (cmdline_parse_inst_t *) &cmd_set_bond_mon_period, 18850 (cmdline_parse_inst_t *) &cmd_set_lacp_dedicated_queues, 18851 (cmdline_parse_inst_t *) &cmd_set_bonding_agg_mode_policy, 18852 #endif 18853 (cmdline_parse_inst_t *)&cmd_vlan_offload, 18854 (cmdline_parse_inst_t *)&cmd_vlan_tpid, 18855 (cmdline_parse_inst_t *)&cmd_rx_vlan_filter_all, 18856 (cmdline_parse_inst_t *)&cmd_rx_vlan_filter, 18857 (cmdline_parse_inst_t *)&cmd_tx_vlan_set, 18858 (cmdline_parse_inst_t *)&cmd_tx_vlan_set_qinq, 18859 (cmdline_parse_inst_t *)&cmd_tx_vlan_reset, 18860 (cmdline_parse_inst_t *)&cmd_tx_vlan_set_pvid, 18861 (cmdline_parse_inst_t *)&cmd_csum_set, 18862 (cmdline_parse_inst_t *)&cmd_csum_show, 18863 (cmdline_parse_inst_t *)&cmd_csum_tunnel, 18864 (cmdline_parse_inst_t *)&cmd_tso_set, 18865 (cmdline_parse_inst_t *)&cmd_tso_show, 18866 (cmdline_parse_inst_t *)&cmd_tunnel_tso_set, 18867 (cmdline_parse_inst_t *)&cmd_tunnel_tso_show, 18868 (cmdline_parse_inst_t *)&cmd_gro_enable, 18869 (cmdline_parse_inst_t *)&cmd_gro_flush, 18870 (cmdline_parse_inst_t *)&cmd_gro_show, 18871 (cmdline_parse_inst_t *)&cmd_gso_enable, 18872 (cmdline_parse_inst_t *)&cmd_gso_size, 18873 (cmdline_parse_inst_t *)&cmd_gso_show, 18874 (cmdline_parse_inst_t *)&cmd_link_flow_control_set, 18875 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_rx, 18876 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_tx, 18877 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_hw, 18878 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_lw, 18879 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_pt, 18880 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_xon, 18881 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_macfwd, 18882 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_autoneg, 18883 (cmdline_parse_inst_t *)&cmd_priority_flow_control_set, 18884 (cmdline_parse_inst_t *)&cmd_config_dcb, 18885 (cmdline_parse_inst_t *)&cmd_read_reg, 18886 (cmdline_parse_inst_t *)&cmd_read_reg_bit_field, 18887 (cmdline_parse_inst_t *)&cmd_read_reg_bit, 18888 (cmdline_parse_inst_t *)&cmd_write_reg, 18889 (cmdline_parse_inst_t *)&cmd_write_reg_bit_field, 18890 (cmdline_parse_inst_t *)&cmd_write_reg_bit, 18891 (cmdline_parse_inst_t *)&cmd_read_rxd_txd, 18892 (cmdline_parse_inst_t *)&cmd_stop, 18893 (cmdline_parse_inst_t *)&cmd_mac_addr, 18894 (cmdline_parse_inst_t *)&cmd_set_fwd_eth_peer, 18895 (cmdline_parse_inst_t *)&cmd_set_qmap, 18896 (cmdline_parse_inst_t *)&cmd_set_xstats_hide_zero, 18897 (cmdline_parse_inst_t *)&cmd_operate_port, 18898 (cmdline_parse_inst_t *)&cmd_operate_specific_port, 18899 (cmdline_parse_inst_t *)&cmd_operate_attach_port, 18900 (cmdline_parse_inst_t *)&cmd_operate_detach_port, 18901 (cmdline_parse_inst_t *)&cmd_operate_detach_device, 18902 (cmdline_parse_inst_t *)&cmd_set_port_setup_on, 18903 (cmdline_parse_inst_t *)&cmd_config_speed_all, 18904 (cmdline_parse_inst_t *)&cmd_config_speed_specific, 18905 (cmdline_parse_inst_t *)&cmd_config_loopback_all, 18906 (cmdline_parse_inst_t *)&cmd_config_loopback_specific, 18907 (cmdline_parse_inst_t *)&cmd_config_rx_tx, 18908 (cmdline_parse_inst_t *)&cmd_config_mtu, 18909 (cmdline_parse_inst_t *)&cmd_config_max_pkt_len, 18910 (cmdline_parse_inst_t *)&cmd_config_rx_mode_flag, 18911 (cmdline_parse_inst_t *)&cmd_config_rss, 18912 (cmdline_parse_inst_t *)&cmd_config_rxtx_ring_size, 18913 (cmdline_parse_inst_t *)&cmd_config_rxtx_queue, 18914 (cmdline_parse_inst_t *)&cmd_config_deferred_start_rxtx_queue, 18915 (cmdline_parse_inst_t *)&cmd_setup_rxtx_queue, 18916 (cmdline_parse_inst_t *)&cmd_config_rss_reta, 18917 (cmdline_parse_inst_t *)&cmd_showport_reta, 18918 (cmdline_parse_inst_t *)&cmd_config_burst, 18919 (cmdline_parse_inst_t *)&cmd_config_thresh, 18920 (cmdline_parse_inst_t *)&cmd_config_threshold, 18921 (cmdline_parse_inst_t *)&cmd_set_uc_hash_filter, 18922 (cmdline_parse_inst_t *)&cmd_set_uc_all_hash_filter, 18923 (cmdline_parse_inst_t *)&cmd_vf_mac_addr_filter, 18924 (cmdline_parse_inst_t *)&cmd_set_vf_macvlan_filter, 18925 (cmdline_parse_inst_t *)&cmd_queue_rate_limit, 18926 (cmdline_parse_inst_t *)&cmd_tunnel_filter, 18927 (cmdline_parse_inst_t *)&cmd_tunnel_udp_config, 18928 (cmdline_parse_inst_t *)&cmd_global_config, 18929 (cmdline_parse_inst_t *)&cmd_set_mirror_mask, 18930 (cmdline_parse_inst_t *)&cmd_set_mirror_link, 18931 (cmdline_parse_inst_t *)&cmd_reset_mirror_rule, 18932 (cmdline_parse_inst_t *)&cmd_showport_rss_hash, 18933 (cmdline_parse_inst_t *)&cmd_showport_rss_hash_key, 18934 (cmdline_parse_inst_t *)&cmd_config_rss_hash_key, 18935 (cmdline_parse_inst_t *)&cmd_dump, 18936 (cmdline_parse_inst_t *)&cmd_dump_one, 18937 (cmdline_parse_inst_t *)&cmd_ethertype_filter, 18938 (cmdline_parse_inst_t *)&cmd_syn_filter, 18939 (cmdline_parse_inst_t *)&cmd_2tuple_filter, 18940 (cmdline_parse_inst_t *)&cmd_5tuple_filter, 18941 (cmdline_parse_inst_t *)&cmd_flex_filter, 18942 (cmdline_parse_inst_t *)&cmd_add_del_ip_flow_director, 18943 (cmdline_parse_inst_t *)&cmd_add_del_udp_flow_director, 18944 (cmdline_parse_inst_t *)&cmd_add_del_sctp_flow_director, 18945 (cmdline_parse_inst_t *)&cmd_add_del_l2_flow_director, 18946 (cmdline_parse_inst_t *)&cmd_add_del_mac_vlan_flow_director, 18947 (cmdline_parse_inst_t *)&cmd_add_del_tunnel_flow_director, 18948 (cmdline_parse_inst_t *)&cmd_add_del_raw_flow_director, 18949 (cmdline_parse_inst_t *)&cmd_flush_flow_director, 18950 (cmdline_parse_inst_t *)&cmd_set_flow_director_ip_mask, 18951 (cmdline_parse_inst_t *)&cmd_set_flow_director_mac_vlan_mask, 18952 (cmdline_parse_inst_t *)&cmd_set_flow_director_tunnel_mask, 18953 (cmdline_parse_inst_t *)&cmd_set_flow_director_flex_mask, 18954 (cmdline_parse_inst_t *)&cmd_set_flow_director_flex_payload, 18955 (cmdline_parse_inst_t *)&cmd_get_sym_hash_ena_per_port, 18956 (cmdline_parse_inst_t *)&cmd_set_sym_hash_ena_per_port, 18957 (cmdline_parse_inst_t *)&cmd_get_hash_global_config, 18958 (cmdline_parse_inst_t *)&cmd_set_hash_global_config, 18959 (cmdline_parse_inst_t *)&cmd_set_hash_input_set, 18960 (cmdline_parse_inst_t *)&cmd_set_fdir_input_set, 18961 (cmdline_parse_inst_t *)&cmd_flow, 18962 (cmdline_parse_inst_t *)&cmd_show_port_meter_cap, 18963 (cmdline_parse_inst_t *)&cmd_add_port_meter_profile_srtcm, 18964 (cmdline_parse_inst_t *)&cmd_add_port_meter_profile_trtcm, 18965 (cmdline_parse_inst_t *)&cmd_del_port_meter_profile, 18966 (cmdline_parse_inst_t *)&cmd_create_port_meter, 18967 (cmdline_parse_inst_t *)&cmd_enable_port_meter, 18968 (cmdline_parse_inst_t *)&cmd_disable_port_meter, 18969 (cmdline_parse_inst_t *)&cmd_del_port_meter, 18970 (cmdline_parse_inst_t *)&cmd_set_port_meter_profile, 18971 (cmdline_parse_inst_t *)&cmd_set_port_meter_dscp_table, 18972 (cmdline_parse_inst_t *)&cmd_set_port_meter_policer_action, 18973 (cmdline_parse_inst_t *)&cmd_set_port_meter_stats_mask, 18974 (cmdline_parse_inst_t *)&cmd_show_port_meter_stats, 18975 (cmdline_parse_inst_t *)&cmd_mcast_addr, 18976 (cmdline_parse_inst_t *)&cmd_config_l2_tunnel_eth_type_all, 18977 (cmdline_parse_inst_t *)&cmd_config_l2_tunnel_eth_type_specific, 18978 (cmdline_parse_inst_t *)&cmd_config_l2_tunnel_en_dis_all, 18979 (cmdline_parse_inst_t *)&cmd_config_l2_tunnel_en_dis_specific, 18980 (cmdline_parse_inst_t *)&cmd_config_e_tag_insertion_en, 18981 (cmdline_parse_inst_t *)&cmd_config_e_tag_insertion_dis, 18982 (cmdline_parse_inst_t *)&cmd_config_e_tag_stripping_en_dis, 18983 (cmdline_parse_inst_t *)&cmd_config_e_tag_forwarding_en_dis, 18984 (cmdline_parse_inst_t *)&cmd_config_e_tag_filter_add, 18985 (cmdline_parse_inst_t *)&cmd_config_e_tag_filter_del, 18986 (cmdline_parse_inst_t *)&cmd_set_vf_vlan_anti_spoof, 18987 (cmdline_parse_inst_t *)&cmd_set_vf_mac_anti_spoof, 18988 (cmdline_parse_inst_t *)&cmd_set_vf_vlan_stripq, 18989 (cmdline_parse_inst_t *)&cmd_set_vf_vlan_insert, 18990 (cmdline_parse_inst_t *)&cmd_set_tx_loopback, 18991 (cmdline_parse_inst_t *)&cmd_set_all_queues_drop_en, 18992 (cmdline_parse_inst_t *)&cmd_set_vf_split_drop_en, 18993 (cmdline_parse_inst_t *)&cmd_set_macsec_offload_on, 18994 (cmdline_parse_inst_t *)&cmd_set_macsec_offload_off, 18995 (cmdline_parse_inst_t *)&cmd_set_macsec_sc, 18996 (cmdline_parse_inst_t *)&cmd_set_macsec_sa, 18997 (cmdline_parse_inst_t *)&cmd_set_vf_traffic, 18998 (cmdline_parse_inst_t *)&cmd_set_vf_rxmode, 18999 (cmdline_parse_inst_t *)&cmd_vf_rate_limit, 19000 (cmdline_parse_inst_t *)&cmd_vf_rxvlan_filter, 19001 (cmdline_parse_inst_t *)&cmd_set_vf_mac_addr, 19002 (cmdline_parse_inst_t *)&cmd_set_vf_promisc, 19003 (cmdline_parse_inst_t *)&cmd_set_vf_allmulti, 19004 (cmdline_parse_inst_t *)&cmd_set_vf_broadcast, 19005 (cmdline_parse_inst_t *)&cmd_set_vf_vlan_tag, 19006 (cmdline_parse_inst_t *)&cmd_vf_max_bw, 19007 (cmdline_parse_inst_t *)&cmd_vf_tc_min_bw, 19008 (cmdline_parse_inst_t *)&cmd_vf_tc_max_bw, 19009 (cmdline_parse_inst_t *)&cmd_strict_link_prio, 19010 (cmdline_parse_inst_t *)&cmd_tc_min_bw, 19011 #if defined RTE_LIBRTE_PMD_SOFTNIC && defined RTE_LIBRTE_SCHED 19012 (cmdline_parse_inst_t *)&cmd_set_port_tm_hierarchy_default, 19013 #endif 19014 (cmdline_parse_inst_t *)&cmd_set_vxlan, 19015 (cmdline_parse_inst_t *)&cmd_set_vxlan_tos_ttl, 19016 (cmdline_parse_inst_t *)&cmd_set_vxlan_with_vlan, 19017 (cmdline_parse_inst_t *)&cmd_set_nvgre, 19018 (cmdline_parse_inst_t *)&cmd_set_nvgre_with_vlan, 19019 (cmdline_parse_inst_t *)&cmd_set_l2_encap, 19020 (cmdline_parse_inst_t *)&cmd_set_l2_encap_with_vlan, 19021 (cmdline_parse_inst_t *)&cmd_set_l2_decap, 19022 (cmdline_parse_inst_t *)&cmd_set_l2_decap_with_vlan, 19023 (cmdline_parse_inst_t *)&cmd_set_mplsogre_encap, 19024 (cmdline_parse_inst_t *)&cmd_set_mplsogre_encap_with_vlan, 19025 (cmdline_parse_inst_t *)&cmd_set_mplsogre_decap, 19026 (cmdline_parse_inst_t *)&cmd_set_mplsogre_decap_with_vlan, 19027 (cmdline_parse_inst_t *)&cmd_set_mplsoudp_encap, 19028 (cmdline_parse_inst_t *)&cmd_set_mplsoudp_encap_with_vlan, 19029 (cmdline_parse_inst_t *)&cmd_set_mplsoudp_decap, 19030 (cmdline_parse_inst_t *)&cmd_set_mplsoudp_decap_with_vlan, 19031 (cmdline_parse_inst_t *)&cmd_ddp_add, 19032 (cmdline_parse_inst_t *)&cmd_ddp_del, 19033 (cmdline_parse_inst_t *)&cmd_ddp_get_list, 19034 (cmdline_parse_inst_t *)&cmd_ddp_get_info, 19035 (cmdline_parse_inst_t *)&cmd_cfg_input_set, 19036 (cmdline_parse_inst_t *)&cmd_clear_input_set, 19037 (cmdline_parse_inst_t *)&cmd_show_vf_stats, 19038 (cmdline_parse_inst_t *)&cmd_clear_vf_stats, 19039 (cmdline_parse_inst_t *)&cmd_ptype_mapping_get, 19040 (cmdline_parse_inst_t *)&cmd_ptype_mapping_replace, 19041 (cmdline_parse_inst_t *)&cmd_ptype_mapping_reset, 19042 (cmdline_parse_inst_t *)&cmd_ptype_mapping_update, 19043 19044 (cmdline_parse_inst_t *)&cmd_pctype_mapping_get, 19045 (cmdline_parse_inst_t *)&cmd_pctype_mapping_reset, 19046 (cmdline_parse_inst_t *)&cmd_pctype_mapping_update, 19047 (cmdline_parse_inst_t *)&cmd_queue_region, 19048 (cmdline_parse_inst_t *)&cmd_region_flowtype, 19049 (cmdline_parse_inst_t *)&cmd_user_priority_region, 19050 (cmdline_parse_inst_t *)&cmd_flush_queue_region, 19051 (cmdline_parse_inst_t *)&cmd_show_queue_region_info_all, 19052 (cmdline_parse_inst_t *)&cmd_show_port_tm_cap, 19053 (cmdline_parse_inst_t *)&cmd_show_port_tm_level_cap, 19054 (cmdline_parse_inst_t *)&cmd_show_port_tm_node_cap, 19055 (cmdline_parse_inst_t *)&cmd_show_port_tm_node_type, 19056 (cmdline_parse_inst_t *)&cmd_show_port_tm_node_stats, 19057 (cmdline_parse_inst_t *)&cmd_add_port_tm_node_shaper_profile, 19058 (cmdline_parse_inst_t *)&cmd_del_port_tm_node_shaper_profile, 19059 (cmdline_parse_inst_t *)&cmd_add_port_tm_node_shared_shaper, 19060 (cmdline_parse_inst_t *)&cmd_del_port_tm_node_shared_shaper, 19061 (cmdline_parse_inst_t *)&cmd_add_port_tm_node_wred_profile, 19062 (cmdline_parse_inst_t *)&cmd_del_port_tm_node_wred_profile, 19063 (cmdline_parse_inst_t *)&cmd_set_port_tm_node_shaper_profile, 19064 (cmdline_parse_inst_t *)&cmd_add_port_tm_nonleaf_node, 19065 (cmdline_parse_inst_t *)&cmd_add_port_tm_leaf_node, 19066 (cmdline_parse_inst_t *)&cmd_del_port_tm_node, 19067 (cmdline_parse_inst_t *)&cmd_set_port_tm_node_parent, 19068 (cmdline_parse_inst_t *)&cmd_suspend_port_tm_node, 19069 (cmdline_parse_inst_t *)&cmd_resume_port_tm_node, 19070 (cmdline_parse_inst_t *)&cmd_port_tm_hierarchy_commit, 19071 (cmdline_parse_inst_t *)&cmd_port_tm_mark_ip_ecn, 19072 (cmdline_parse_inst_t *)&cmd_port_tm_mark_ip_dscp, 19073 (cmdline_parse_inst_t *)&cmd_port_tm_mark_vlan_dei, 19074 (cmdline_parse_inst_t *)&cmd_cfg_tunnel_udp_port, 19075 (cmdline_parse_inst_t *)&cmd_rx_offload_get_capa, 19076 (cmdline_parse_inst_t *)&cmd_rx_offload_get_configuration, 19077 (cmdline_parse_inst_t *)&cmd_config_per_port_rx_offload, 19078 (cmdline_parse_inst_t *)&cmd_config_per_queue_rx_offload, 19079 (cmdline_parse_inst_t *)&cmd_tx_offload_get_capa, 19080 (cmdline_parse_inst_t *)&cmd_tx_offload_get_configuration, 19081 (cmdline_parse_inst_t *)&cmd_config_per_port_tx_offload, 19082 (cmdline_parse_inst_t *)&cmd_config_per_queue_tx_offload, 19083 #ifdef RTE_LIBRTE_BPF 19084 (cmdline_parse_inst_t *)&cmd_operate_bpf_ld_parse, 19085 (cmdline_parse_inst_t *)&cmd_operate_bpf_unld_parse, 19086 #endif 19087 (cmdline_parse_inst_t *)&cmd_config_tx_metadata_specific, 19088 (cmdline_parse_inst_t *)&cmd_show_tx_metadata, 19089 (cmdline_parse_inst_t *)&cmd_set_raw, 19090 NULL, 19091 }; 19092 19093 /* read cmdline commands from file */ 19094 void 19095 cmdline_read_from_file(const char *filename) 19096 { 19097 struct cmdline *cl; 19098 19099 cl = cmdline_file_new(main_ctx, "testpmd> ", filename); 19100 if (cl == NULL) { 19101 printf("Failed to create file based cmdline context: %s\n", 19102 filename); 19103 return; 19104 } 19105 19106 cmdline_interact(cl); 19107 cmdline_quit(cl); 19108 19109 cmdline_free(cl); 19110 19111 printf("Read CLI commands from %s\n", filename); 19112 } 19113 19114 /* prompt function, called from main on MASTER lcore */ 19115 void 19116 prompt(void) 19117 { 19118 /* initialize non-constant commands */ 19119 cmd_set_fwd_mode_init(); 19120 cmd_set_fwd_retry_mode_init(); 19121 19122 testpmd_cl = cmdline_stdin_new(main_ctx, "testpmd> "); 19123 if (testpmd_cl == NULL) 19124 return; 19125 cmdline_interact(testpmd_cl); 19126 cmdline_stdin_exit(testpmd_cl); 19127 } 19128 19129 void 19130 prompt_exit(void) 19131 { 19132 if (testpmd_cl != NULL) 19133 cmdline_quit(testpmd_cl); 19134 } 19135 19136 static void 19137 cmd_reconfig_device_queue(portid_t id, uint8_t dev, uint8_t queue) 19138 { 19139 if (id == (portid_t)RTE_PORT_ALL) { 19140 portid_t pid; 19141 19142 RTE_ETH_FOREACH_DEV(pid) { 19143 /* check if need_reconfig has been set to 1 */ 19144 if (ports[pid].need_reconfig == 0) 19145 ports[pid].need_reconfig = dev; 19146 /* check if need_reconfig_queues has been set to 1 */ 19147 if (ports[pid].need_reconfig_queues == 0) 19148 ports[pid].need_reconfig_queues = queue; 19149 } 19150 } else if (!port_id_is_invalid(id, DISABLED_WARN)) { 19151 /* check if need_reconfig has been set to 1 */ 19152 if (ports[id].need_reconfig == 0) 19153 ports[id].need_reconfig = dev; 19154 /* check if need_reconfig_queues has been set to 1 */ 19155 if (ports[id].need_reconfig_queues == 0) 19156 ports[id].need_reconfig_queues = queue; 19157 } 19158 } 19159