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 #ifndef __linux__ 15 #ifndef __FreeBSD__ 16 #include <net/socket.h> 17 #else 18 #include <sys/socket.h> 19 #endif 20 #endif 21 #include <netinet/in.h> 22 23 #include <sys/queue.h> 24 25 #include <rte_common.h> 26 #include <rte_byteorder.h> 27 #include <rte_log.h> 28 #include <rte_debug.h> 29 #include <rte_cycles.h> 30 #include <rte_memory.h> 31 #include <rte_memzone.h> 32 #include <rte_malloc.h> 33 #include <rte_launch.h> 34 #include <rte_eal.h> 35 #include <rte_per_lcore.h> 36 #include <rte_lcore.h> 37 #include <rte_atomic.h> 38 #include <rte_branch_prediction.h> 39 #include <rte_ring.h> 40 #include <rte_mempool.h> 41 #include <rte_interrupts.h> 42 #include <rte_pci.h> 43 #include <rte_ether.h> 44 #include <rte_ethdev.h> 45 #include <rte_string_fns.h> 46 #include <rte_devargs.h> 47 #include <rte_flow.h> 48 #include <rte_gro.h> 49 50 #include <cmdline_rdline.h> 51 #include <cmdline_parse.h> 52 #include <cmdline_parse_num.h> 53 #include <cmdline_parse_string.h> 54 #include <cmdline_parse_ipaddr.h> 55 #include <cmdline_parse_etheraddr.h> 56 #include <cmdline_socket.h> 57 #include <cmdline.h> 58 #ifdef RTE_LIBRTE_PMD_BOND 59 #include <rte_eth_bond.h> 60 #include <rte_eth_bond_8023ad.h> 61 #endif 62 #if defined RTE_LIBRTE_DPAA_BUS && defined RTE_LIBRTE_DPAA_PMD 63 #include <rte_pmd_dpaa.h> 64 #endif 65 #ifdef RTE_LIBRTE_IXGBE_PMD 66 #include <rte_pmd_ixgbe.h> 67 #endif 68 #ifdef RTE_LIBRTE_I40E_PMD 69 #include <rte_pmd_i40e.h> 70 #endif 71 #ifdef RTE_LIBRTE_BNXT_PMD 72 #include <rte_pmd_bnxt.h> 73 #endif 74 #include "testpmd.h" 75 #include "cmdline_mtr.h" 76 #include "cmdline_tm.h" 77 #include "bpf_cmd.h" 78 79 static struct cmdline *testpmd_cl; 80 81 static void cmd_reconfig_device_queue(portid_t id, uint8_t dev, uint8_t queue); 82 83 /* *** Help command with introduction. *** */ 84 struct cmd_help_brief_result { 85 cmdline_fixed_string_t help; 86 }; 87 88 static void cmd_help_brief_parsed(__attribute__((unused)) void *parsed_result, 89 struct cmdline *cl, 90 __attribute__((unused)) void *data) 91 { 92 cmdline_printf( 93 cl, 94 "\n" 95 "Help is available for the following sections:\n\n" 96 " help control : Start and stop forwarding.\n" 97 " help display : Displaying port, stats and config " 98 "information.\n" 99 " help config : Configuration information.\n" 100 " help ports : Configuring ports.\n" 101 " help registers : Reading and setting port registers.\n" 102 " help filters : Filters configuration help.\n" 103 " help traffic_management : Traffic Management commmands.\n" 104 " help devices : Device related cmds.\n" 105 " help all : All of the above sections.\n\n" 106 ); 107 108 } 109 110 cmdline_parse_token_string_t cmd_help_brief_help = 111 TOKEN_STRING_INITIALIZER(struct cmd_help_brief_result, help, "help"); 112 113 cmdline_parse_inst_t cmd_help_brief = { 114 .f = cmd_help_brief_parsed, 115 .data = NULL, 116 .help_str = "help: Show help", 117 .tokens = { 118 (void *)&cmd_help_brief_help, 119 NULL, 120 }, 121 }; 122 123 /* *** Help command with help sections. *** */ 124 struct cmd_help_long_result { 125 cmdline_fixed_string_t help; 126 cmdline_fixed_string_t section; 127 }; 128 129 static void cmd_help_long_parsed(void *parsed_result, 130 struct cmdline *cl, 131 __attribute__((unused)) void *data) 132 { 133 int show_all = 0; 134 struct cmd_help_long_result *res = parsed_result; 135 136 if (!strcmp(res->section, "all")) 137 show_all = 1; 138 139 if (show_all || !strcmp(res->section, "control")) { 140 141 cmdline_printf( 142 cl, 143 "\n" 144 "Control forwarding:\n" 145 "-------------------\n\n" 146 147 "start\n" 148 " Start packet forwarding with current configuration.\n\n" 149 150 "start tx_first\n" 151 " Start packet forwarding with current config" 152 " after sending one burst of packets.\n\n" 153 154 "stop\n" 155 " Stop packet forwarding, and display accumulated" 156 " statistics.\n\n" 157 158 "quit\n" 159 " Quit to prompt.\n\n" 160 ); 161 } 162 163 if (show_all || !strcmp(res->section, "display")) { 164 165 cmdline_printf( 166 cl, 167 "\n" 168 "Display:\n" 169 "--------\n\n" 170 171 "show port (info|stats|summary|xstats|fdir|stat_qmap|dcb_tc|cap) (port_id|all)\n" 172 " Display information for port_id, or all.\n\n" 173 174 "show port X rss reta (size) (mask0,mask1,...)\n" 175 " Display the rss redirection table entry indicated" 176 " by masks on port X. size is used to indicate the" 177 " hardware supported reta size\n\n" 178 179 "show port (port_id) rss-hash [key]\n" 180 " Display the RSS hash functions and RSS hash key of port\n\n" 181 182 "clear port (info|stats|xstats|fdir|stat_qmap) (port_id|all)\n" 183 " Clear information for port_id, or all.\n\n" 184 185 "show (rxq|txq) info (port_id) (queue_id)\n" 186 " Display information for configured RX/TX queue.\n\n" 187 188 "show config (rxtx|cores|fwd|txpkts)\n" 189 " Display the given configuration.\n\n" 190 191 "read rxd (port_id) (queue_id) (rxd_id)\n" 192 " Display an RX descriptor of a port RX queue.\n\n" 193 194 "read txd (port_id) (queue_id) (txd_id)\n" 195 " Display a TX descriptor of a port TX queue.\n\n" 196 197 "ddp get list (port_id)\n" 198 " Get ddp profile info list\n\n" 199 200 "ddp get info (profile_path)\n" 201 " Get ddp profile information.\n\n" 202 203 "show vf stats (port_id) (vf_id)\n" 204 " Display a VF's statistics.\n\n" 205 206 "clear vf stats (port_id) (vf_id)\n" 207 " Reset a VF's statistics.\n\n" 208 209 "show port (port_id) pctype mapping\n" 210 " Get flow ptype to pctype mapping on a port\n\n" 211 212 "show port meter stats (port_id) (meter_id) (clear)\n" 213 " Get meter stats on a port\n\n" 214 215 "show fwd stats all\n" 216 " Display statistics for all fwd engines.\n\n" 217 218 "clear fwd stats all\n" 219 " Clear statistics for all fwd engines.\n\n" 220 221 "show port (port_id) rx_offload capabilities\n" 222 " List all per queue and per port Rx offloading" 223 " capabilities of a port\n\n" 224 225 "show port (port_id) rx_offload configuration\n" 226 " List port level and all queue level" 227 " Rx offloading configuration\n\n" 228 229 "show port (port_id) tx_offload capabilities\n" 230 " List all per queue and per port" 231 " Tx offloading capabilities of a port\n\n" 232 233 "show port (port_id) tx_offload configuration\n" 234 " List port level and all queue level" 235 " Tx offloading configuration\n\n" 236 237 "show port (port_id) tx_metadata\n" 238 " Show Tx metadata value set" 239 " for a specific port\n\n" 240 241 "show device info (<identifier>|all)" 242 " Show general information about devices probed.\n\n" 243 ); 244 } 245 246 if (show_all || !strcmp(res->section, "config")) { 247 cmdline_printf( 248 cl, 249 "\n" 250 "Configuration:\n" 251 "--------------\n" 252 "Configuration changes only become active when" 253 " forwarding is started/restarted.\n\n" 254 255 "set default\n" 256 " Reset forwarding to the default configuration.\n\n" 257 258 "set verbose (level)\n" 259 " Set the debug verbosity level X.\n\n" 260 261 "set log global|(type) (level)\n" 262 " Set the log level.\n\n" 263 264 "set nbport (num)\n" 265 " Set number of ports.\n\n" 266 267 "set nbcore (num)\n" 268 " Set number of cores.\n\n" 269 270 "set coremask (mask)\n" 271 " Set the forwarding cores hexadecimal mask.\n\n" 272 273 "set portmask (mask)\n" 274 " Set the forwarding ports hexadecimal mask.\n\n" 275 276 "set burst (num)\n" 277 " Set number of packets per burst.\n\n" 278 279 "set burst tx delay (microseconds) retry (num)\n" 280 " Set the transmit delay time and number of retries," 281 " effective when retry is enabled.\n\n" 282 283 "set txpkts (x[,y]*)\n" 284 " Set the length of each segment of TXONLY" 285 " and optionally CSUM packets.\n\n" 286 287 "set txsplit (off|on|rand)\n" 288 " Set the split policy for the TX packets." 289 " Right now only applicable for CSUM and TXONLY" 290 " modes\n\n" 291 292 "set corelist (x[,y]*)\n" 293 " Set the list of forwarding cores.\n\n" 294 295 "set portlist (x[,y]*)\n" 296 " Set the list of forwarding ports.\n\n" 297 298 "set port setup on (iterator|event)\n" 299 " Select how attached port is retrieved for setup.\n\n" 300 301 "set tx loopback (port_id) (on|off)\n" 302 " Enable or disable tx loopback.\n\n" 303 304 "set all queues drop (port_id) (on|off)\n" 305 " Set drop enable bit for all queues.\n\n" 306 307 "set vf split drop (port_id) (vf_id) (on|off)\n" 308 " Set split drop enable bit for a VF from the PF.\n\n" 309 310 "set vf mac antispoof (port_id) (vf_id) (on|off).\n" 311 " Set MAC antispoof for a VF from the PF.\n\n" 312 313 "set macsec offload (port_id) on encrypt (on|off) replay-protect (on|off)\n" 314 " Enable MACsec offload.\n\n" 315 316 "set macsec offload (port_id) off\n" 317 " Disable MACsec offload.\n\n" 318 319 "set macsec sc (tx|rx) (port_id) (mac) (pi)\n" 320 " Configure MACsec secure connection (SC).\n\n" 321 322 "set macsec sa (tx|rx) (port_id) (idx) (an) (pn) (key)\n" 323 " Configure MACsec secure association (SA).\n\n" 324 325 "set vf broadcast (port_id) (vf_id) (on|off)\n" 326 " Set VF broadcast for a VF from the PF.\n\n" 327 328 "vlan set strip (on|off) (port_id)\n" 329 " Set the VLAN strip on a port.\n\n" 330 331 "vlan set stripq (on|off) (port_id,queue_id)\n" 332 " Set the VLAN strip for a queue on a port.\n\n" 333 334 "set vf vlan stripq (port_id) (vf_id) (on|off)\n" 335 " Set the VLAN strip for all queues in a pool for a VF from the PF.\n\n" 336 337 "set vf vlan insert (port_id) (vf_id) (vlan_id)\n" 338 " Set VLAN insert for a VF from the PF.\n\n" 339 340 "set vf vlan antispoof (port_id) (vf_id) (on|off)\n" 341 " Set VLAN antispoof for a VF from the PF.\n\n" 342 343 "set vf vlan tag (port_id) (vf_id) (on|off)\n" 344 " Set VLAN tag for a VF from the PF.\n\n" 345 346 "set vf tx max-bandwidth (port_id) (vf_id) (bandwidth)\n" 347 " Set a VF's max bandwidth(Mbps).\n\n" 348 349 "set vf tc tx min-bandwidth (port_id) (vf_id) (bw1, bw2, ...)\n" 350 " Set all TCs' min bandwidth(%%) on a VF.\n\n" 351 352 "set vf tc tx max-bandwidth (port_id) (vf_id) (tc_no) (bandwidth)\n" 353 " Set a TC's max bandwidth(Mbps) on a VF.\n\n" 354 355 "set tx strict-link-priority (port_id) (tc_bitmap)\n" 356 " Set some TCs' strict link priority mode on a physical port.\n\n" 357 358 "set tc tx min-bandwidth (port_id) (bw1, bw2, ...)\n" 359 " Set all TCs' min bandwidth(%%) for all PF and VFs.\n\n" 360 361 "vlan set filter (on|off) (port_id)\n" 362 " Set the VLAN filter on a port.\n\n" 363 364 "vlan set qinq (on|off) (port_id)\n" 365 " Set the VLAN QinQ (extended queue in queue)" 366 " on a port.\n\n" 367 368 "vlan set (inner|outer) tpid (value) (port_id)\n" 369 " Set the VLAN TPID for Packet Filtering on" 370 " a port\n\n" 371 372 "rx_vlan add (vlan_id|all) (port_id)\n" 373 " Add a vlan_id, or all identifiers, to the set" 374 " of VLAN identifiers filtered by port_id.\n\n" 375 376 "rx_vlan rm (vlan_id|all) (port_id)\n" 377 " Remove a vlan_id, or all identifiers, from the set" 378 " of VLAN identifiers filtered by port_id.\n\n" 379 380 "rx_vlan add (vlan_id) port (port_id) vf (vf_mask)\n" 381 " Add a vlan_id, to the set of VLAN identifiers" 382 "filtered for VF(s) from port_id.\n\n" 383 384 "rx_vlan rm (vlan_id) port (port_id) vf (vf_mask)\n" 385 " Remove a vlan_id, to the set of VLAN identifiers" 386 "filtered for VF(s) from port_id.\n\n" 387 388 "tunnel_filter add (port_id) (outer_mac) (inner_mac) (ip_addr) " 389 "(inner_vlan) (vxlan|nvgre|ipingre|vxlan-gpe) (imac-ivlan|imac-ivlan-tenid|" 390 "imac-tenid|imac|omac-imac-tenid|oip|iip) (tenant_id) (queue_id)\n" 391 " add a tunnel filter of a port.\n\n" 392 393 "tunnel_filter rm (port_id) (outer_mac) (inner_mac) (ip_addr) " 394 "(inner_vlan) (vxlan|nvgre|ipingre|vxlan-gpe) (imac-ivlan|imac-ivlan-tenid|" 395 "imac-tenid|imac|omac-imac-tenid|oip|iip) (tenant_id) (queue_id)\n" 396 " remove a tunnel filter of a port.\n\n" 397 398 "rx_vxlan_port add (udp_port) (port_id)\n" 399 " Add an UDP port for VXLAN packet filter on a port\n\n" 400 401 "rx_vxlan_port rm (udp_port) (port_id)\n" 402 " Remove an UDP port for VXLAN packet filter on a port\n\n" 403 404 "tx_vlan set (port_id) vlan_id[, vlan_id_outer]\n" 405 " Set hardware insertion of VLAN IDs (single or double VLAN " 406 "depends on the number of VLAN IDs) in packets sent on a port.\n\n" 407 408 "tx_vlan set pvid port_id vlan_id (on|off)\n" 409 " Set port based TX VLAN insertion.\n\n" 410 411 "tx_vlan reset (port_id)\n" 412 " Disable hardware insertion of a VLAN header in" 413 " packets sent on a port.\n\n" 414 415 "csum set (ip|udp|tcp|sctp|outer-ip|outer-udp) (hw|sw) (port_id)\n" 416 " Select hardware or software calculation of the" 417 " checksum when transmitting a packet using the" 418 " csum forward engine.\n" 419 " ip|udp|tcp|sctp always concern the inner layer.\n" 420 " outer-ip concerns the outer IP layer in" 421 " outer-udp concerns the outer UDP layer in" 422 " case the packet is recognized as a tunnel packet by" 423 " the forward engine (vxlan, gre and ipip are supported)\n" 424 " Please check the NIC datasheet for HW limits.\n\n" 425 426 "csum parse-tunnel (on|off) (tx_port_id)\n" 427 " If disabled, treat tunnel packets as non-tunneled" 428 " packets (treat inner headers as payload). The port\n" 429 " argument is the port used for TX in csum forward" 430 " engine.\n\n" 431 432 "csum show (port_id)\n" 433 " Display tx checksum offload configuration\n\n" 434 435 "tso set (segsize) (portid)\n" 436 " Enable TCP Segmentation Offload in csum forward" 437 " engine.\n" 438 " Please check the NIC datasheet for HW limits.\n\n" 439 440 "tso show (portid)" 441 " Display the status of TCP Segmentation Offload.\n\n" 442 443 "set port (port_id) gro on|off\n" 444 " Enable or disable Generic Receive Offload in" 445 " csum forwarding engine.\n\n" 446 447 "show port (port_id) gro\n" 448 " Display GRO configuration.\n\n" 449 450 "set gro flush (cycles)\n" 451 " Set the cycle to flush GROed packets from" 452 " reassembly tables.\n\n" 453 454 "set port (port_id) gso (on|off)" 455 " Enable or disable Generic Segmentation Offload in" 456 " csum forwarding engine.\n\n" 457 458 "set gso segsz (length)\n" 459 " Set max packet length for output GSO segments," 460 " including packet header and payload.\n\n" 461 462 "show port (port_id) gso\n" 463 " Show GSO configuration.\n\n" 464 465 "set fwd (%s)\n" 466 " Set packet forwarding mode.\n\n" 467 468 "mac_addr add (port_id) (XX:XX:XX:XX:XX:XX)\n" 469 " Add a MAC address on port_id.\n\n" 470 471 "mac_addr remove (port_id) (XX:XX:XX:XX:XX:XX)\n" 472 " Remove a MAC address from port_id.\n\n" 473 474 "mac_addr set (port_id) (XX:XX:XX:XX:XX:XX)\n" 475 " Set the default MAC address for port_id.\n\n" 476 477 "mac_addr add port (port_id) vf (vf_id) (mac_address)\n" 478 " Add a MAC address for a VF on the port.\n\n" 479 480 "set vf mac addr (port_id) (vf_id) (XX:XX:XX:XX:XX:XX)\n" 481 " Set the MAC address for a VF from the PF.\n\n" 482 483 "set eth-peer (port_id) (peer_addr)\n" 484 " set the peer address for certain port.\n\n" 485 486 "set port (port_id) uta (mac_address|all) (on|off)\n" 487 " Add/Remove a or all unicast hash filter(s)" 488 "from port X.\n\n" 489 490 "set promisc (port_id|all) (on|off)\n" 491 " Set the promiscuous mode on port_id, or all.\n\n" 492 493 "set allmulti (port_id|all) (on|off)\n" 494 " Set the allmulti mode on port_id, or all.\n\n" 495 496 "set vf promisc (port_id) (vf_id) (on|off)\n" 497 " Set unicast promiscuous mode for a VF from the PF.\n\n" 498 499 "set vf allmulti (port_id) (vf_id) (on|off)\n" 500 " Set multicast promiscuous mode for a VF from the PF.\n\n" 501 502 "set flow_ctrl rx (on|off) tx (on|off) (high_water)" 503 " (low_water) (pause_time) (send_xon) mac_ctrl_frame_fwd" 504 " (on|off) autoneg (on|off) (port_id)\n" 505 "set flow_ctrl rx (on|off) (portid)\n" 506 "set flow_ctrl tx (on|off) (portid)\n" 507 "set flow_ctrl high_water (high_water) (portid)\n" 508 "set flow_ctrl low_water (low_water) (portid)\n" 509 "set flow_ctrl pause_time (pause_time) (portid)\n" 510 "set flow_ctrl send_xon (send_xon) (portid)\n" 511 "set flow_ctrl mac_ctrl_frame_fwd (on|off) (portid)\n" 512 "set flow_ctrl autoneg (on|off) (port_id)\n" 513 " Set the link flow control parameter on a port.\n\n" 514 515 "set pfc_ctrl rx (on|off) tx (on|off) (high_water)" 516 " (low_water) (pause_time) (priority) (port_id)\n" 517 " Set the priority flow control parameter on a" 518 " port.\n\n" 519 520 "set stat_qmap (tx|rx) (port_id) (queue_id) (qmapping)\n" 521 " Set statistics mapping (qmapping 0..15) for RX/TX" 522 " queue on port.\n" 523 " e.g., 'set stat_qmap rx 0 2 5' sets rx queue 2" 524 " on port 0 to mapping 5.\n\n" 525 526 "set xstats-hide-zero on|off\n" 527 " Set the option to hide the zero values" 528 " for xstats display.\n" 529 530 "set port (port_id) vf (vf_id) rx|tx on|off\n" 531 " Enable/Disable a VF receive/tranmit from a port\n\n" 532 533 "set port (port_id) vf (vf_id) (mac_addr)" 534 " (exact-mac#exact-mac-vlan#hashmac|hashmac-vlan) on|off\n" 535 " Add/Remove unicast or multicast MAC addr filter" 536 " for a VF.\n\n" 537 538 "set port (port_id) vf (vf_id) rxmode (AUPE|ROPE|BAM" 539 "|MPE) (on|off)\n" 540 " AUPE:accepts untagged VLAN;" 541 "ROPE:accept unicast hash\n\n" 542 " BAM:accepts broadcast packets;" 543 "MPE:accepts all multicast packets\n\n" 544 " Enable/Disable a VF receive mode of a port\n\n" 545 546 "set port (port_id) queue (queue_id) rate (rate_num)\n" 547 " Set rate limit for a queue of a port\n\n" 548 549 "set port (port_id) vf (vf_id) rate (rate_num) " 550 "queue_mask (queue_mask_value)\n" 551 " Set rate limit for queues in VF of a port\n\n" 552 553 "set port (port_id) mirror-rule (rule_id)" 554 " (pool-mirror-up|pool-mirror-down|vlan-mirror)" 555 " (poolmask|vlanid[,vlanid]*) dst-pool (pool_id) (on|off)\n" 556 " Set pool or vlan type mirror rule on a port.\n" 557 " e.g., 'set port 0 mirror-rule 0 vlan-mirror 0,1" 558 " dst-pool 0 on' enable mirror traffic with vlan 0,1" 559 " to pool 0.\n\n" 560 561 "set port (port_id) mirror-rule (rule_id)" 562 " (uplink-mirror|downlink-mirror) dst-pool" 563 " (pool_id) (on|off)\n" 564 " Set uplink or downlink type mirror rule on a port.\n" 565 " e.g., 'set port 0 mirror-rule 0 uplink-mirror dst-pool" 566 " 0 on' enable mirror income traffic to pool 0.\n\n" 567 568 "reset port (port_id) mirror-rule (rule_id)\n" 569 " Reset a mirror rule.\n\n" 570 571 "set flush_rx (on|off)\n" 572 " Flush (default) or don't flush RX streams before" 573 " forwarding. Mainly used with PCAP drivers.\n\n" 574 575 "set bypass mode (normal|bypass|isolate) (port_id)\n" 576 " Set the bypass mode for the lowest port on bypass enabled" 577 " NIC.\n\n" 578 579 "set bypass event (timeout|os_on|os_off|power_on|power_off) " 580 "mode (normal|bypass|isolate) (port_id)\n" 581 " Set the event required to initiate specified bypass mode for" 582 " the lowest port on a bypass enabled NIC where:\n" 583 " timeout = enable bypass after watchdog timeout.\n" 584 " os_on = enable bypass when OS/board is powered on.\n" 585 " os_off = enable bypass when OS/board is powered off.\n" 586 " power_on = enable bypass when power supply is turned on.\n" 587 " power_off = enable bypass when power supply is turned off." 588 "\n\n" 589 590 "set bypass timeout (0|1.5|2|3|4|8|16|32)\n" 591 " Set the bypass watchdog timeout to 'n' seconds" 592 " where 0 = instant.\n\n" 593 594 "show bypass config (port_id)\n" 595 " Show the bypass configuration for a bypass enabled NIC" 596 " using the lowest port on the NIC.\n\n" 597 598 #ifdef RTE_LIBRTE_PMD_BOND 599 "create bonded device (mode) (socket)\n" 600 " Create a new bonded device with specific bonding mode and socket.\n\n" 601 602 "add bonding slave (slave_id) (port_id)\n" 603 " Add a slave device to a bonded device.\n\n" 604 605 "remove bonding slave (slave_id) (port_id)\n" 606 " Remove a slave device from a bonded device.\n\n" 607 608 "set bonding mode (value) (port_id)\n" 609 " Set the bonding mode on a bonded device.\n\n" 610 611 "set bonding primary (slave_id) (port_id)\n" 612 " Set the primary slave for a bonded device.\n\n" 613 614 "show bonding config (port_id)\n" 615 " Show the bonding config for port_id.\n\n" 616 617 "set bonding mac_addr (port_id) (address)\n" 618 " Set the MAC address of a bonded device.\n\n" 619 620 "set bonding mode IEEE802.3AD aggregator policy (port_id) (agg_name)" 621 " Set Aggregation mode for IEEE802.3AD (mode 4)" 622 623 "set bonding xmit_balance_policy (port_id) (l2|l23|l34)\n" 624 " Set the transmit balance policy for bonded device running in balance mode.\n\n" 625 626 "set bonding mon_period (port_id) (value)\n" 627 " Set the bonding link status monitoring polling period in ms.\n\n" 628 629 "set bonding lacp dedicated_queues <port_id> (enable|disable)\n" 630 " Enable/disable dedicated queues for LACP control traffic.\n\n" 631 632 #endif 633 "set link-up port (port_id)\n" 634 " Set link up for a port.\n\n" 635 636 "set link-down port (port_id)\n" 637 " Set link down for a port.\n\n" 638 639 "E-tag set insertion on port-tag-id (value)" 640 " port (port_id) vf (vf_id)\n" 641 " Enable E-tag insertion for a VF on a port\n\n" 642 643 "E-tag set insertion off port (port_id) vf (vf_id)\n" 644 " Disable E-tag insertion for a VF on a port\n\n" 645 646 "E-tag set stripping (on|off) port (port_id)\n" 647 " Enable/disable E-tag stripping on a port\n\n" 648 649 "E-tag set forwarding (on|off) port (port_id)\n" 650 " Enable/disable E-tag based forwarding" 651 " on a port\n\n" 652 653 "E-tag set filter add e-tag-id (value) dst-pool" 654 " (pool_id) port (port_id)\n" 655 " Add an E-tag forwarding filter on a port\n\n" 656 657 "E-tag set filter del e-tag-id (value) port (port_id)\n" 658 " Delete an E-tag forwarding filter on a port\n\n" 659 660 "ddp add (port_id) (profile_path[,backup_profile_path])\n" 661 " Load a profile package on a port\n\n" 662 663 "ddp del (port_id) (backup_profile_path)\n" 664 " Delete a profile package from a port\n\n" 665 666 "ptype mapping get (port_id) (valid_only)\n" 667 " Get ptype mapping on a port\n\n" 668 669 "ptype mapping replace (port_id) (target) (mask) (pky_type)\n" 670 " Replace target with the pkt_type in ptype mapping\n\n" 671 672 "ptype mapping reset (port_id)\n" 673 " Reset ptype mapping on a port\n\n" 674 675 "ptype mapping update (port_id) (hw_ptype) (sw_ptype)\n" 676 " Update a ptype mapping item on a port\n\n" 677 678 "set port (port_id) queue-region region_id (value) " 679 "queue_start_index (value) queue_num (value)\n" 680 " Set a queue region on a port\n\n" 681 682 "set port (port_id) queue-region region_id (value) " 683 "flowtype (value)\n" 684 " Set a flowtype region index on a port\n\n" 685 686 "set port (port_id) queue-region UP (value) region_id (value)\n" 687 " Set the mapping of User Priority to " 688 "queue region on a port\n\n" 689 690 "set port (port_id) queue-region flush (on|off)\n" 691 " flush all queue region related configuration\n\n" 692 693 "show port meter cap (port_id)\n" 694 " Show port meter capability information\n\n" 695 696 "add port meter profile srtcm_rfc2697 (port_id) (profile_id) (cir) (cbs) (ebs)\n" 697 " meter profile add - srtcm rfc 2697\n\n" 698 699 "add port meter profile trtcm_rfc2698 (port_id) (profile_id) (cir) (pir) (cbs) (pbs)\n" 700 " meter profile add - trtcm rfc 2698\n\n" 701 702 "add port meter profile trtcm_rfc4115 (port_id) (profile_id) (cir) (eir) (cbs) (ebs)\n" 703 " meter profile add - trtcm rfc 4115\n\n" 704 705 "del port meter profile (port_id) (profile_id)\n" 706 " meter profile delete\n\n" 707 708 "create port meter (port_id) (mtr_id) (profile_id) (meter_enable)\n" 709 "(g_action) (y_action) (r_action) (stats_mask) (shared)\n" 710 "(use_pre_meter_color) [(dscp_tbl_entry0) (dscp_tbl_entry1)...\n" 711 "(dscp_tbl_entry63)]\n" 712 " meter create\n\n" 713 714 "enable port meter (port_id) (mtr_id)\n" 715 " meter enable\n\n" 716 717 "disable port meter (port_id) (mtr_id)\n" 718 " meter disable\n\n" 719 720 "del port meter (port_id) (mtr_id)\n" 721 " meter delete\n\n" 722 723 "set port meter profile (port_id) (mtr_id) (profile_id)\n" 724 " meter update meter profile\n\n" 725 726 "set port meter dscp table (port_id) (mtr_id) [(dscp_tbl_entry0)\n" 727 "(dscp_tbl_entry1)...(dscp_tbl_entry63)]\n" 728 " update meter dscp table entries\n\n" 729 730 "set port meter policer action (port_id) (mtr_id) (action_mask)\n" 731 "(action0) [(action1) (action2)]\n" 732 " meter update policer action\n\n" 733 734 "set port meter stats mask (port_id) (mtr_id) (stats_mask)\n" 735 " meter update stats\n\n" 736 737 "show port (port_id) queue-region\n" 738 " show all queue region related configuration info\n\n" 739 740 , list_pkt_forwarding_modes() 741 ); 742 } 743 744 if (show_all || !strcmp(res->section, "ports")) { 745 746 cmdline_printf( 747 cl, 748 "\n" 749 "Port Operations:\n" 750 "----------------\n\n" 751 752 "port start (port_id|all)\n" 753 " Start all ports or port_id.\n\n" 754 755 "port stop (port_id|all)\n" 756 " Stop all ports or port_id.\n\n" 757 758 "port close (port_id|all)\n" 759 " Close all ports or port_id.\n\n" 760 761 "port attach (ident)\n" 762 " Attach physical or virtual dev by pci address or virtual device name\n\n" 763 764 "port detach (port_id)\n" 765 " Detach physical or virtual dev by port_id\n\n" 766 767 "port config (port_id|all)" 768 " speed (10|100|1000|10000|25000|40000|50000|100000|auto)" 769 " duplex (half|full|auto)\n" 770 " Set speed and duplex for all ports or port_id\n\n" 771 772 "port config (port_id|all) loopback (mode)\n" 773 " Set loopback mode for all ports or port_id\n\n" 774 775 "port config all (rxq|txq|rxd|txd) (value)\n" 776 " Set number for rxq/txq/rxd/txd.\n\n" 777 778 "port config all max-pkt-len (value)\n" 779 " Set the max packet length.\n\n" 780 781 "port config all drop-en (on|off)\n" 782 " Enable or disable packet drop on all RX queues of all ports when no " 783 "receive buffers available.\n\n" 784 785 "port config all rss (all|default|ip|tcp|udp|sctp|" 786 "ether|port|vxlan|geneve|nvgre|vxlan-gpe|none|<flowtype_id>)\n" 787 " Set the RSS mode.\n\n" 788 789 "port config port-id rss reta (hash,queue)[,(hash,queue)]\n" 790 " Set the RSS redirection table.\n\n" 791 792 "port config (port_id) dcb vt (on|off) (traffic_class)" 793 " pfc (on|off)\n" 794 " Set the DCB mode.\n\n" 795 796 "port config all burst (value)\n" 797 " Set the number of packets per burst.\n\n" 798 799 "port config all (txpt|txht|txwt|rxpt|rxht|rxwt)" 800 " (value)\n" 801 " Set the ring prefetch/host/writeback threshold" 802 " for tx/rx queue.\n\n" 803 804 "port config all (txfreet|txrst|rxfreet) (value)\n" 805 " Set free threshold for rx/tx, or set" 806 " tx rs bit threshold.\n\n" 807 "port config mtu X value\n" 808 " Set the MTU of port X to a given value\n\n" 809 810 "port config (port_id) (rxq|txq) (queue_id) ring_size (value)\n" 811 " Set a rx/tx queue's ring size configuration, the new" 812 " value will take effect after command that (re-)start the port" 813 " or command that setup the specific queue\n\n" 814 815 "port (port_id) (rxq|txq) (queue_id) (start|stop)\n" 816 " Start/stop a rx/tx queue of port X. Only take effect" 817 " when port X is started\n\n" 818 819 "port (port_id) (rxq|txq) (queue_id) deferred_start (on|off)\n" 820 " Switch on/off a deferred start of port X rx/tx queue. Only" 821 " take effect when port X is stopped.\n\n" 822 823 "port (port_id) (rxq|txq) (queue_id) setup\n" 824 " Setup a rx/tx queue of port X.\n\n" 825 826 "port config (port_id|all) l2-tunnel E-tag ether-type" 827 " (value)\n" 828 " Set the value of E-tag ether-type.\n\n" 829 830 "port config (port_id|all) l2-tunnel E-tag" 831 " (enable|disable)\n" 832 " Enable/disable the E-tag support.\n\n" 833 834 "port config (port_id) pctype mapping reset\n" 835 " Reset flow type to pctype mapping on a port\n\n" 836 837 "port config (port_id) pctype mapping update" 838 " (pctype_id_0[,pctype_id_1]*) (flow_type_id)\n" 839 " Update a flow type to pctype mapping item on a port\n\n" 840 841 "port config (port_id) pctype (pctype_id) hash_inset|" 842 "fdir_inset|fdir_flx_inset get|set|clear field\n" 843 " (field_idx)\n" 844 " Configure RSS|FDIR|FDIR_FLX input set for some pctype\n\n" 845 846 "port config (port_id) pctype (pctype_id) hash_inset|" 847 "fdir_inset|fdir_flx_inset clear all" 848 " Clear RSS|FDIR|FDIR_FLX input set completely for some pctype\n\n" 849 850 "port config (port_id) udp_tunnel_port add|rm vxlan|geneve (udp_port)\n\n" 851 " Add/remove UDP tunnel port for tunneling offload\n\n" 852 853 "port config <port_id> rx_offload vlan_strip|" 854 "ipv4_cksum|udp_cksum|tcp_cksum|tcp_lro|qinq_strip|" 855 "outer_ipv4_cksum|macsec_strip|header_split|" 856 "vlan_filter|vlan_extend|jumbo_frame|crc_strip|" 857 "scatter|timestamp|security|keep_crc on|off\n" 858 " Enable or disable a per port Rx offloading" 859 " on all Rx queues of a port\n\n" 860 861 "port (port_id) rxq (queue_id) rx_offload vlan_strip|" 862 "ipv4_cksum|udp_cksum|tcp_cksum|tcp_lro|qinq_strip|" 863 "outer_ipv4_cksum|macsec_strip|header_split|" 864 "vlan_filter|vlan_extend|jumbo_frame|crc_strip|" 865 "scatter|timestamp|security|keep_crc on|off\n" 866 " Enable or disable a per queue Rx offloading" 867 " only on a specific Rx queue\n\n" 868 869 "port config (port_id) tx_offload vlan_insert|" 870 "ipv4_cksum|udp_cksum|tcp_cksum|sctp_cksum|tcp_tso|" 871 "udp_tso|outer_ipv4_cksum|qinq_insert|vxlan_tnl_tso|" 872 "gre_tnl_tso|ipip_tnl_tso|geneve_tnl_tso|" 873 "macsec_insert|mt_lockfree|multi_segs|mbuf_fast_free|" 874 "security|match_metadata on|off\n" 875 " Enable or disable a per port Tx offloading" 876 " on all Tx queues of a port\n\n" 877 878 "port (port_id) txq (queue_id) tx_offload vlan_insert|" 879 "ipv4_cksum|udp_cksum|tcp_cksum|sctp_cksum|tcp_tso|" 880 "udp_tso|outer_ipv4_cksum|qinq_insert|vxlan_tnl_tso|" 881 "gre_tnl_tso|ipip_tnl_tso|geneve_tnl_tso|macsec_insert" 882 "|mt_lockfree|multi_segs|mbuf_fast_free|security" 883 " on|off\n" 884 " Enable or disable a per queue Tx offloading" 885 " only on a specific Tx queue\n\n" 886 887 "bpf-load rx|tx (port) (queue) (J|M|B) (file_name)\n" 888 " Load an eBPF program as a callback" 889 " for particular RX/TX queue\n\n" 890 891 "bpf-unload rx|tx (port) (queue)\n" 892 " Unload previously loaded eBPF program" 893 " for particular RX/TX queue\n\n" 894 895 "port config (port_id) tx_metadata (value)\n" 896 " Set Tx metadata value per port. Testpmd will add this value" 897 " to any Tx packet sent from this port\n\n" 898 ); 899 } 900 901 if (show_all || !strcmp(res->section, "registers")) { 902 903 cmdline_printf( 904 cl, 905 "\n" 906 "Registers:\n" 907 "----------\n\n" 908 909 "read reg (port_id) (address)\n" 910 " Display value of a port register.\n\n" 911 912 "read regfield (port_id) (address) (bit_x) (bit_y)\n" 913 " Display a port register bit field.\n\n" 914 915 "read regbit (port_id) (address) (bit_x)\n" 916 " Display a single port register bit.\n\n" 917 918 "write reg (port_id) (address) (value)\n" 919 " Set value of a port register.\n\n" 920 921 "write regfield (port_id) (address) (bit_x) (bit_y)" 922 " (value)\n" 923 " Set bit field of a port register.\n\n" 924 925 "write regbit (port_id) (address) (bit_x) (value)\n" 926 " Set single bit value of a port register.\n\n" 927 ); 928 } 929 if (show_all || !strcmp(res->section, "filters")) { 930 931 cmdline_printf( 932 cl, 933 "\n" 934 "filters:\n" 935 "--------\n\n" 936 937 "ethertype_filter (port_id) (add|del)" 938 " (mac_addr|mac_ignr) (mac_address) ethertype" 939 " (ether_type) (drop|fwd) queue (queue_id)\n" 940 " Add/Del an ethertype filter.\n\n" 941 942 "2tuple_filter (port_id) (add|del)" 943 " dst_port (dst_port_value) protocol (protocol_value)" 944 " mask (mask_value) tcp_flags (tcp_flags_value)" 945 " priority (prio_value) queue (queue_id)\n" 946 " Add/Del a 2tuple filter.\n\n" 947 948 "5tuple_filter (port_id) (add|del)" 949 " dst_ip (dst_address) src_ip (src_address)" 950 " dst_port (dst_port_value) src_port (src_port_value)" 951 " protocol (protocol_value)" 952 " mask (mask_value) tcp_flags (tcp_flags_value)" 953 " priority (prio_value) queue (queue_id)\n" 954 " Add/Del a 5tuple filter.\n\n" 955 956 "syn_filter (port_id) (add|del) priority (high|low) queue (queue_id)" 957 " Add/Del syn filter.\n\n" 958 959 "flex_filter (port_id) (add|del) len (len_value)" 960 " bytes (bytes_value) mask (mask_value)" 961 " priority (prio_value) queue (queue_id)\n" 962 " Add/Del a flex filter.\n\n" 963 964 "flow_director_filter (port_id) mode IP (add|del|update)" 965 " flow (ipv4-other|ipv4-frag|ipv6-other|ipv6-frag)" 966 " src (src_ip_address) dst (dst_ip_address)" 967 " tos (tos_value) proto (proto_value) ttl (ttl_value)" 968 " vlan (vlan_value) flexbytes (flexbytes_value)" 969 " (drop|fwd) pf|vf(vf_id) queue (queue_id)" 970 " fd_id (fd_id_value)\n" 971 " Add/Del an IP type flow director filter.\n\n" 972 973 "flow_director_filter (port_id) mode IP (add|del|update)" 974 " flow (ipv4-tcp|ipv4-udp|ipv6-tcp|ipv6-udp)" 975 " src (src_ip_address) (src_port)" 976 " dst (dst_ip_address) (dst_port)" 977 " tos (tos_value) ttl (ttl_value)" 978 " vlan (vlan_value) flexbytes (flexbytes_value)" 979 " (drop|fwd) pf|vf(vf_id) queue (queue_id)" 980 " fd_id (fd_id_value)\n" 981 " Add/Del an UDP/TCP type flow director filter.\n\n" 982 983 "flow_director_filter (port_id) mode IP (add|del|update)" 984 " flow (ipv4-sctp|ipv6-sctp)" 985 " src (src_ip_address) (src_port)" 986 " dst (dst_ip_address) (dst_port)" 987 " tag (verification_tag) " 988 " tos (tos_value) ttl (ttl_value)" 989 " vlan (vlan_value)" 990 " flexbytes (flexbytes_value) (drop|fwd)" 991 " pf|vf(vf_id) queue (queue_id) fd_id (fd_id_value)\n" 992 " Add/Del a SCTP type flow director filter.\n\n" 993 994 "flow_director_filter (port_id) mode IP (add|del|update)" 995 " flow l2_payload ether (ethertype)" 996 " flexbytes (flexbytes_value) (drop|fwd)" 997 " pf|vf(vf_id) queue (queue_id) fd_id (fd_id_value)\n" 998 " Add/Del a l2 payload type flow director filter.\n\n" 999 1000 "flow_director_filter (port_id) mode MAC-VLAN (add|del|update)" 1001 " mac (mac_address) vlan (vlan_value)" 1002 " flexbytes (flexbytes_value) (drop|fwd)" 1003 " queue (queue_id) fd_id (fd_id_value)\n" 1004 " Add/Del a MAC-VLAN flow director filter.\n\n" 1005 1006 "flow_director_filter (port_id) mode Tunnel (add|del|update)" 1007 " mac (mac_address) vlan (vlan_value)" 1008 " tunnel (NVGRE|VxLAN) tunnel-id (tunnel_id_value)" 1009 " flexbytes (flexbytes_value) (drop|fwd)" 1010 " queue (queue_id) fd_id (fd_id_value)\n" 1011 " Add/Del a Tunnel flow director filter.\n\n" 1012 1013 "flow_director_filter (port_id) mode raw (add|del|update)" 1014 " flow (flow_id) (drop|fwd) queue (queue_id)" 1015 " fd_id (fd_id_value) packet (packet file name)\n" 1016 " Add/Del a raw type flow director filter.\n\n" 1017 1018 "flush_flow_director (port_id)\n" 1019 " Flush all flow director entries of a device.\n\n" 1020 1021 "flow_director_mask (port_id) mode IP vlan (vlan_value)" 1022 " src_mask (ipv4_src) (ipv6_src) (src_port)" 1023 " dst_mask (ipv4_dst) (ipv6_dst) (dst_port)\n" 1024 " Set flow director IP mask.\n\n" 1025 1026 "flow_director_mask (port_id) mode MAC-VLAN" 1027 " vlan (vlan_value)\n" 1028 " Set flow director MAC-VLAN mask.\n\n" 1029 1030 "flow_director_mask (port_id) mode Tunnel" 1031 " vlan (vlan_value) mac (mac_value)" 1032 " tunnel-type (tunnel_type_value)" 1033 " tunnel-id (tunnel_id_value)\n" 1034 " Set flow director Tunnel mask.\n\n" 1035 1036 "flow_director_flex_mask (port_id)" 1037 " flow (none|ipv4-other|ipv4-frag|ipv4-tcp|ipv4-udp|ipv4-sctp|" 1038 "ipv6-other|ipv6-frag|ipv6-tcp|ipv6-udp|ipv6-sctp|l2_payload|all)" 1039 " (mask)\n" 1040 " Configure mask of flex payload.\n\n" 1041 1042 "flow_director_flex_payload (port_id)" 1043 " (raw|l2|l3|l4) (config)\n" 1044 " Configure flex payload selection.\n\n" 1045 1046 "get_sym_hash_ena_per_port (port_id)\n" 1047 " get symmetric hash enable configuration per port.\n\n" 1048 1049 "set_sym_hash_ena_per_port (port_id) (enable|disable)\n" 1050 " set symmetric hash enable configuration per port" 1051 " to enable or disable.\n\n" 1052 1053 "get_hash_global_config (port_id)\n" 1054 " Get the global configurations of hash filters.\n\n" 1055 1056 "set_hash_global_config (port_id) (toeplitz|simple_xor|default)" 1057 " (ipv4|ipv4-frag|ipv4-tcp|ipv4-udp|ipv4-sctp|ipv4-other|ipv6|" 1058 "ipv6-frag|ipv6-tcp|ipv6-udp|ipv6-sctp|ipv6-other|l2_payload)" 1059 " (enable|disable)\n" 1060 " Set the global configurations of hash filters.\n\n" 1061 1062 "set_hash_input_set (port_id) (ipv4|ipv4-frag|" 1063 "ipv4-tcp|ipv4-udp|ipv4-sctp|ipv4-other|ipv6|" 1064 "ipv6-frag|ipv6-tcp|ipv6-udp|ipv6-sctp|ipv6-other|" 1065 "l2_payload|<flowtype_id>) (ovlan|ivlan|src-ipv4|dst-ipv4|" 1066 "src-ipv6|dst-ipv6|ipv4-tos|ipv4-proto|ipv6-tc|" 1067 "ipv6-next-header|udp-src-port|udp-dst-port|" 1068 "tcp-src-port|tcp-dst-port|sctp-src-port|" 1069 "sctp-dst-port|sctp-veri-tag|udp-key|gre-key|fld-1st|" 1070 "fld-2nd|fld-3rd|fld-4th|fld-5th|fld-6th|fld-7th|" 1071 "fld-8th|none) (select|add)\n" 1072 " Set the input set for hash.\n\n" 1073 1074 "set_fdir_input_set (port_id) " 1075 "(ipv4-frag|ipv4-tcp|ipv4-udp|ipv4-sctp|ipv4-other|" 1076 "ipv6-frag|ipv6-tcp|ipv6-udp|ipv6-sctp|ipv6-other|" 1077 "l2_payload) (ivlan|ethertype|src-ipv4|dst-ipv4|src-ipv6|" 1078 "dst-ipv6|ipv4-tos|ipv4-proto|ipv4-ttl|ipv6-tc|" 1079 "ipv6-next-header|ipv6-hop-limits|udp-src-port|" 1080 "udp-dst-port|tcp-src-port|tcp-dst-port|" 1081 "sctp-src-port|sctp-dst-port|sctp-veri-tag|none)" 1082 " (select|add)\n" 1083 " Set the input set for FDir.\n\n" 1084 1085 "flow validate {port_id}" 1086 " [group {group_id}] [priority {level}]" 1087 " [ingress] [egress]" 1088 " pattern {item} [/ {item} [...]] / end" 1089 " actions {action} [/ {action} [...]] / end\n" 1090 " Check whether a flow rule can be created.\n\n" 1091 1092 "flow create {port_id}" 1093 " [group {group_id}] [priority {level}]" 1094 " [ingress] [egress]" 1095 " pattern {item} [/ {item} [...]] / end" 1096 " actions {action} [/ {action} [...]] / end\n" 1097 " Create a flow rule.\n\n" 1098 1099 "flow destroy {port_id} rule {rule_id} [...]\n" 1100 " Destroy specific flow rules.\n\n" 1101 1102 "flow flush {port_id}\n" 1103 " Destroy all flow rules.\n\n" 1104 1105 "flow query {port_id} {rule_id} {action}\n" 1106 " Query an existing flow rule.\n\n" 1107 1108 "flow list {port_id} [group {group_id}] [...]\n" 1109 " List existing flow rules sorted by priority," 1110 " filtered by group identifiers.\n\n" 1111 1112 "flow isolate {port_id} {boolean}\n" 1113 " Restrict ingress traffic to the defined" 1114 " flow rules\n\n" 1115 1116 "set vxlan ip-version (ipv4|ipv6) vni (vni) udp-src" 1117 " (udp-src) udp-dst (udp-dst) ip-src (ip-src) ip-dst" 1118 " (ip-dst) eth-src (eth-src) eth-dst (eth-dst)\n" 1119 " Configure the VXLAN encapsulation for flows.\n\n" 1120 1121 "set vxlan-with-vlan ip-version (ipv4|ipv6) vni (vni)" 1122 " udp-src (udp-src) udp-dst (udp-dst) ip-src (ip-src)" 1123 " ip-dst (ip-dst) vlan-tci (vlan-tci) eth-src (eth-src)" 1124 " eth-dst (eth-dst)\n" 1125 " Configure the VXLAN encapsulation for flows.\n\n" 1126 1127 "set vxlan-tos-ttl ip-version (ipv4|ipv6) vni (vni) udp-src" 1128 " (udp-src) udp-dst (udp-dst) ip-tos (ip-tos) ip-ttl (ip-ttl)" 1129 " ip-src (ip-src) ip-dst (ip-dst) eth-src (eth-src)" 1130 " eth-dst (eth-dst)\n" 1131 " Configure the VXLAN encapsulation for flows.\n\n" 1132 1133 "set nvgre ip-version (ipv4|ipv6) tni (tni) ip-src" 1134 " (ip-src) ip-dst (ip-dst) eth-src (eth-src) eth-dst" 1135 " (eth-dst)\n" 1136 " Configure the NVGRE encapsulation for flows.\n\n" 1137 1138 "set nvgre-with-vlan ip-version (ipv4|ipv6) tni (tni)" 1139 " ip-src (ip-src) ip-dst (ip-dst) vlan-tci (vlan-tci)" 1140 " eth-src (eth-src) eth-dst (eth-dst)\n" 1141 " Configure the NVGRE encapsulation for flows.\n\n" 1142 1143 "set raw_encap {flow items}\n" 1144 " Configure the encapsulation with raw data.\n\n" 1145 1146 "set raw_decap {flow items}\n" 1147 " Configure the decapsulation with raw data.\n\n" 1148 1149 ); 1150 } 1151 1152 if (show_all || !strcmp(res->section, "traffic_management")) { 1153 cmdline_printf( 1154 cl, 1155 "\n" 1156 "Traffic Management:\n" 1157 "--------------\n" 1158 "show port tm cap (port_id)\n" 1159 " Display the port TM capability.\n\n" 1160 1161 "show port tm level cap (port_id) (level_id)\n" 1162 " Display the port TM hierarchical level capability.\n\n" 1163 1164 "show port tm node cap (port_id) (node_id)\n" 1165 " Display the port TM node capability.\n\n" 1166 1167 "show port tm node type (port_id) (node_id)\n" 1168 " Display the port TM node type.\n\n" 1169 1170 "show port tm node stats (port_id) (node_id) (clear)\n" 1171 " Display the port TM node stats.\n\n" 1172 1173 #if defined RTE_LIBRTE_PMD_SOFTNIC && defined RTE_LIBRTE_SCHED 1174 "set port tm hierarchy default (port_id)\n" 1175 " Set default traffic Management hierarchy on a port\n\n" 1176 #endif 1177 1178 "add port tm node shaper profile (port_id) (shaper_profile_id)" 1179 " (cmit_tb_rate) (cmit_tb_size) (peak_tb_rate) (peak_tb_size)" 1180 " (packet_length_adjust)\n" 1181 " Add port tm node private shaper profile.\n\n" 1182 1183 "del port tm node shaper profile (port_id) (shaper_profile_id)\n" 1184 " Delete port tm node private shaper profile.\n\n" 1185 1186 "add port tm node shared shaper (port_id) (shared_shaper_id)" 1187 " (shaper_profile_id)\n" 1188 " Add/update port tm node shared shaper.\n\n" 1189 1190 "del port tm node shared shaper (port_id) (shared_shaper_id)\n" 1191 " Delete port tm node shared shaper.\n\n" 1192 1193 "set port tm node shaper profile (port_id) (node_id)" 1194 " (shaper_profile_id)\n" 1195 " Set port tm node shaper profile.\n\n" 1196 1197 "add port tm node wred profile (port_id) (wred_profile_id)" 1198 " (color_g) (min_th_g) (max_th_g) (maxp_inv_g) (wq_log2_g)" 1199 " (color_y) (min_th_y) (max_th_y) (maxp_inv_y) (wq_log2_y)" 1200 " (color_r) (min_th_r) (max_th_r) (maxp_inv_r) (wq_log2_r)\n" 1201 " Add port tm node wred profile.\n\n" 1202 1203 "del port tm node wred profile (port_id) (wred_profile_id)\n" 1204 " Delete port tm node wred profile.\n\n" 1205 1206 "add port tm nonleaf node (port_id) (node_id) (parent_node_id)" 1207 " (priority) (weight) (level_id) (shaper_profile_id)" 1208 " (n_sp_priorities) (stats_mask) (n_shared_shapers)" 1209 " [(shared_shaper_id_0) (shared_shaper_id_1)...]\n" 1210 " Add port tm nonleaf node.\n\n" 1211 1212 "add port tm leaf node (port_id) (node_id) (parent_node_id)" 1213 " (priority) (weight) (level_id) (shaper_profile_id)" 1214 " (cman_mode) (wred_profile_id) (stats_mask) (n_shared_shapers)" 1215 " [(shared_shaper_id_0) (shared_shaper_id_1)...]\n" 1216 " Add port tm leaf node.\n\n" 1217 1218 "del port tm node (port_id) (node_id)\n" 1219 " Delete port tm node.\n\n" 1220 1221 "set port tm node parent (port_id) (node_id) (parent_node_id)" 1222 " (priority) (weight)\n" 1223 " Set port tm node parent.\n\n" 1224 1225 "suspend port tm node (port_id) (node_id)" 1226 " Suspend tm node.\n\n" 1227 1228 "resume port tm node (port_id) (node_id)" 1229 " Resume tm node.\n\n" 1230 1231 "port tm hierarchy commit (port_id) (clean_on_fail)\n" 1232 " Commit tm hierarchy.\n\n" 1233 1234 "set port tm mark ip_ecn (port) (green) (yellow)" 1235 " (red)\n" 1236 " Enables/Disables the traffic management marking" 1237 " for IP ECN (Explicit Congestion Notification)" 1238 " packets on a given port\n\n" 1239 1240 "set port tm mark ip_dscp (port) (green) (yellow)" 1241 " (red)\n" 1242 " Enables/Disables the traffic management marking" 1243 " on the port for IP dscp packets\n\n" 1244 1245 "set port tm mark vlan_dei (port) (green) (yellow)" 1246 " (red)\n" 1247 " Enables/Disables the traffic management marking" 1248 " on the port for VLAN packets with DEI enabled\n\n" 1249 ); 1250 } 1251 1252 if (show_all || !strcmp(res->section, "devices")) { 1253 cmdline_printf( 1254 cl, 1255 "\n" 1256 "Device Operations:\n" 1257 "--------------\n" 1258 "device detach (identifier)\n" 1259 " Detach device by identifier.\n\n" 1260 ); 1261 } 1262 1263 } 1264 1265 cmdline_parse_token_string_t cmd_help_long_help = 1266 TOKEN_STRING_INITIALIZER(struct cmd_help_long_result, help, "help"); 1267 1268 cmdline_parse_token_string_t cmd_help_long_section = 1269 TOKEN_STRING_INITIALIZER(struct cmd_help_long_result, section, 1270 "all#control#display#config#" 1271 "ports#registers#filters#traffic_management#devices"); 1272 1273 cmdline_parse_inst_t cmd_help_long = { 1274 .f = cmd_help_long_parsed, 1275 .data = NULL, 1276 .help_str = "help all|control|display|config|ports|register|" 1277 "filters|traffic_management|devices: " 1278 "Show help", 1279 .tokens = { 1280 (void *)&cmd_help_long_help, 1281 (void *)&cmd_help_long_section, 1282 NULL, 1283 }, 1284 }; 1285 1286 1287 /* *** start/stop/close all ports *** */ 1288 struct cmd_operate_port_result { 1289 cmdline_fixed_string_t keyword; 1290 cmdline_fixed_string_t name; 1291 cmdline_fixed_string_t value; 1292 }; 1293 1294 static void cmd_operate_port_parsed(void *parsed_result, 1295 __attribute__((unused)) struct cmdline *cl, 1296 __attribute__((unused)) void *data) 1297 { 1298 struct cmd_operate_port_result *res = parsed_result; 1299 1300 if (!strcmp(res->name, "start")) 1301 start_port(RTE_PORT_ALL); 1302 else if (!strcmp(res->name, "stop")) 1303 stop_port(RTE_PORT_ALL); 1304 else if (!strcmp(res->name, "close")) 1305 close_port(RTE_PORT_ALL); 1306 else if (!strcmp(res->name, "reset")) 1307 reset_port(RTE_PORT_ALL); 1308 else 1309 printf("Unknown parameter\n"); 1310 } 1311 1312 cmdline_parse_token_string_t cmd_operate_port_all_cmd = 1313 TOKEN_STRING_INITIALIZER(struct cmd_operate_port_result, keyword, 1314 "port"); 1315 cmdline_parse_token_string_t cmd_operate_port_all_port = 1316 TOKEN_STRING_INITIALIZER(struct cmd_operate_port_result, name, 1317 "start#stop#close#reset"); 1318 cmdline_parse_token_string_t cmd_operate_port_all_all = 1319 TOKEN_STRING_INITIALIZER(struct cmd_operate_port_result, value, "all"); 1320 1321 cmdline_parse_inst_t cmd_operate_port = { 1322 .f = cmd_operate_port_parsed, 1323 .data = NULL, 1324 .help_str = "port start|stop|close all: Start/Stop/Close/Reset all ports", 1325 .tokens = { 1326 (void *)&cmd_operate_port_all_cmd, 1327 (void *)&cmd_operate_port_all_port, 1328 (void *)&cmd_operate_port_all_all, 1329 NULL, 1330 }, 1331 }; 1332 1333 /* *** start/stop/close specific port *** */ 1334 struct cmd_operate_specific_port_result { 1335 cmdline_fixed_string_t keyword; 1336 cmdline_fixed_string_t name; 1337 uint8_t value; 1338 }; 1339 1340 static void cmd_operate_specific_port_parsed(void *parsed_result, 1341 __attribute__((unused)) struct cmdline *cl, 1342 __attribute__((unused)) void *data) 1343 { 1344 struct cmd_operate_specific_port_result *res = parsed_result; 1345 1346 if (!strcmp(res->name, "start")) 1347 start_port(res->value); 1348 else if (!strcmp(res->name, "stop")) 1349 stop_port(res->value); 1350 else if (!strcmp(res->name, "close")) 1351 close_port(res->value); 1352 else if (!strcmp(res->name, "reset")) 1353 reset_port(res->value); 1354 else 1355 printf("Unknown parameter\n"); 1356 } 1357 1358 cmdline_parse_token_string_t cmd_operate_specific_port_cmd = 1359 TOKEN_STRING_INITIALIZER(struct cmd_operate_specific_port_result, 1360 keyword, "port"); 1361 cmdline_parse_token_string_t cmd_operate_specific_port_port = 1362 TOKEN_STRING_INITIALIZER(struct cmd_operate_specific_port_result, 1363 name, "start#stop#close#reset"); 1364 cmdline_parse_token_num_t cmd_operate_specific_port_id = 1365 TOKEN_NUM_INITIALIZER(struct cmd_operate_specific_port_result, 1366 value, UINT8); 1367 1368 cmdline_parse_inst_t cmd_operate_specific_port = { 1369 .f = cmd_operate_specific_port_parsed, 1370 .data = NULL, 1371 .help_str = "port start|stop|close <port_id>: Start/Stop/Close/Reset port_id", 1372 .tokens = { 1373 (void *)&cmd_operate_specific_port_cmd, 1374 (void *)&cmd_operate_specific_port_port, 1375 (void *)&cmd_operate_specific_port_id, 1376 NULL, 1377 }, 1378 }; 1379 1380 /* *** enable port setup (after attach) via iterator or event *** */ 1381 struct cmd_set_port_setup_on_result { 1382 cmdline_fixed_string_t set; 1383 cmdline_fixed_string_t port; 1384 cmdline_fixed_string_t setup; 1385 cmdline_fixed_string_t on; 1386 cmdline_fixed_string_t mode; 1387 }; 1388 1389 static void cmd_set_port_setup_on_parsed(void *parsed_result, 1390 __attribute__((unused)) struct cmdline *cl, 1391 __attribute__((unused)) void *data) 1392 { 1393 struct cmd_set_port_setup_on_result *res = parsed_result; 1394 1395 if (strcmp(res->mode, "event") == 0) 1396 setup_on_probe_event = true; 1397 else if (strcmp(res->mode, "iterator") == 0) 1398 setup_on_probe_event = false; 1399 else 1400 printf("Unknown mode\n"); 1401 } 1402 1403 cmdline_parse_token_string_t cmd_set_port_setup_on_set = 1404 TOKEN_STRING_INITIALIZER(struct cmd_set_port_setup_on_result, 1405 set, "set"); 1406 cmdline_parse_token_string_t cmd_set_port_setup_on_port = 1407 TOKEN_STRING_INITIALIZER(struct cmd_set_port_setup_on_result, 1408 port, "port"); 1409 cmdline_parse_token_string_t cmd_set_port_setup_on_setup = 1410 TOKEN_STRING_INITIALIZER(struct cmd_set_port_setup_on_result, 1411 setup, "setup"); 1412 cmdline_parse_token_string_t cmd_set_port_setup_on_on = 1413 TOKEN_STRING_INITIALIZER(struct cmd_set_port_setup_on_result, 1414 on, "on"); 1415 cmdline_parse_token_string_t cmd_set_port_setup_on_mode = 1416 TOKEN_STRING_INITIALIZER(struct cmd_set_port_setup_on_result, 1417 mode, "iterator#event"); 1418 1419 cmdline_parse_inst_t cmd_set_port_setup_on = { 1420 .f = cmd_set_port_setup_on_parsed, 1421 .data = NULL, 1422 .help_str = "set port setup on iterator|event", 1423 .tokens = { 1424 (void *)&cmd_set_port_setup_on_set, 1425 (void *)&cmd_set_port_setup_on_port, 1426 (void *)&cmd_set_port_setup_on_setup, 1427 (void *)&cmd_set_port_setup_on_on, 1428 (void *)&cmd_set_port_setup_on_mode, 1429 NULL, 1430 }, 1431 }; 1432 1433 /* *** attach a specified port *** */ 1434 struct cmd_operate_attach_port_result { 1435 cmdline_fixed_string_t port; 1436 cmdline_fixed_string_t keyword; 1437 cmdline_fixed_string_t identifier; 1438 }; 1439 1440 static void cmd_operate_attach_port_parsed(void *parsed_result, 1441 __attribute__((unused)) struct cmdline *cl, 1442 __attribute__((unused)) void *data) 1443 { 1444 struct cmd_operate_attach_port_result *res = parsed_result; 1445 1446 if (!strcmp(res->keyword, "attach")) 1447 attach_port(res->identifier); 1448 else 1449 printf("Unknown parameter\n"); 1450 } 1451 1452 cmdline_parse_token_string_t cmd_operate_attach_port_port = 1453 TOKEN_STRING_INITIALIZER(struct cmd_operate_attach_port_result, 1454 port, "port"); 1455 cmdline_parse_token_string_t cmd_operate_attach_port_keyword = 1456 TOKEN_STRING_INITIALIZER(struct cmd_operate_attach_port_result, 1457 keyword, "attach"); 1458 cmdline_parse_token_string_t cmd_operate_attach_port_identifier = 1459 TOKEN_STRING_INITIALIZER(struct cmd_operate_attach_port_result, 1460 identifier, NULL); 1461 1462 cmdline_parse_inst_t cmd_operate_attach_port = { 1463 .f = cmd_operate_attach_port_parsed, 1464 .data = NULL, 1465 .help_str = "port attach <identifier>: " 1466 "(identifier: pci address or virtual dev name)", 1467 .tokens = { 1468 (void *)&cmd_operate_attach_port_port, 1469 (void *)&cmd_operate_attach_port_keyword, 1470 (void *)&cmd_operate_attach_port_identifier, 1471 NULL, 1472 }, 1473 }; 1474 1475 /* *** detach a specified port *** */ 1476 struct cmd_operate_detach_port_result { 1477 cmdline_fixed_string_t port; 1478 cmdline_fixed_string_t keyword; 1479 portid_t port_id; 1480 }; 1481 1482 static void cmd_operate_detach_port_parsed(void *parsed_result, 1483 __attribute__((unused)) struct cmdline *cl, 1484 __attribute__((unused)) void *data) 1485 { 1486 struct cmd_operate_detach_port_result *res = parsed_result; 1487 1488 if (!strcmp(res->keyword, "detach")) 1489 detach_port_device(res->port_id); 1490 else 1491 printf("Unknown parameter\n"); 1492 } 1493 1494 cmdline_parse_token_string_t cmd_operate_detach_port_port = 1495 TOKEN_STRING_INITIALIZER(struct cmd_operate_detach_port_result, 1496 port, "port"); 1497 cmdline_parse_token_string_t cmd_operate_detach_port_keyword = 1498 TOKEN_STRING_INITIALIZER(struct cmd_operate_detach_port_result, 1499 keyword, "detach"); 1500 cmdline_parse_token_num_t cmd_operate_detach_port_port_id = 1501 TOKEN_NUM_INITIALIZER(struct cmd_operate_detach_port_result, 1502 port_id, UINT16); 1503 1504 cmdline_parse_inst_t cmd_operate_detach_port = { 1505 .f = cmd_operate_detach_port_parsed, 1506 .data = NULL, 1507 .help_str = "port detach <port_id>", 1508 .tokens = { 1509 (void *)&cmd_operate_detach_port_port, 1510 (void *)&cmd_operate_detach_port_keyword, 1511 (void *)&cmd_operate_detach_port_port_id, 1512 NULL, 1513 }, 1514 }; 1515 1516 /* *** detach device by identifier *** */ 1517 struct cmd_operate_detach_device_result { 1518 cmdline_fixed_string_t device; 1519 cmdline_fixed_string_t keyword; 1520 cmdline_fixed_string_t identifier; 1521 }; 1522 1523 static void cmd_operate_detach_device_parsed(void *parsed_result, 1524 __attribute__((unused)) struct cmdline *cl, 1525 __attribute__((unused)) void *data) 1526 { 1527 struct cmd_operate_detach_device_result *res = parsed_result; 1528 1529 if (!strcmp(res->keyword, "detach")) 1530 detach_device(res->identifier); 1531 else 1532 printf("Unknown parameter\n"); 1533 } 1534 1535 cmdline_parse_token_string_t cmd_operate_detach_device_device = 1536 TOKEN_STRING_INITIALIZER(struct cmd_operate_detach_device_result, 1537 device, "device"); 1538 cmdline_parse_token_string_t cmd_operate_detach_device_keyword = 1539 TOKEN_STRING_INITIALIZER(struct cmd_operate_detach_device_result, 1540 keyword, "detach"); 1541 cmdline_parse_token_string_t cmd_operate_detach_device_identifier = 1542 TOKEN_STRING_INITIALIZER(struct cmd_operate_detach_device_result, 1543 identifier, NULL); 1544 1545 cmdline_parse_inst_t cmd_operate_detach_device = { 1546 .f = cmd_operate_detach_device_parsed, 1547 .data = NULL, 1548 .help_str = "device detach <identifier>:" 1549 "(identifier: pci address or virtual dev name)", 1550 .tokens = { 1551 (void *)&cmd_operate_detach_device_device, 1552 (void *)&cmd_operate_detach_device_keyword, 1553 (void *)&cmd_operate_detach_device_identifier, 1554 NULL, 1555 }, 1556 }; 1557 /* *** configure speed for all ports *** */ 1558 struct cmd_config_speed_all { 1559 cmdline_fixed_string_t port; 1560 cmdline_fixed_string_t keyword; 1561 cmdline_fixed_string_t all; 1562 cmdline_fixed_string_t item1; 1563 cmdline_fixed_string_t item2; 1564 cmdline_fixed_string_t value1; 1565 cmdline_fixed_string_t value2; 1566 }; 1567 1568 static int 1569 parse_and_check_speed_duplex(char *speedstr, char *duplexstr, uint32_t *speed) 1570 { 1571 1572 int duplex; 1573 1574 if (!strcmp(duplexstr, "half")) { 1575 duplex = ETH_LINK_HALF_DUPLEX; 1576 } else if (!strcmp(duplexstr, "full")) { 1577 duplex = ETH_LINK_FULL_DUPLEX; 1578 } else if (!strcmp(duplexstr, "auto")) { 1579 duplex = ETH_LINK_FULL_DUPLEX; 1580 } else { 1581 printf("Unknown duplex parameter\n"); 1582 return -1; 1583 } 1584 1585 if (!strcmp(speedstr, "10")) { 1586 *speed = (duplex == ETH_LINK_HALF_DUPLEX) ? 1587 ETH_LINK_SPEED_10M_HD : ETH_LINK_SPEED_10M; 1588 } else if (!strcmp(speedstr, "100")) { 1589 *speed = (duplex == ETH_LINK_HALF_DUPLEX) ? 1590 ETH_LINK_SPEED_100M_HD : ETH_LINK_SPEED_100M; 1591 } else { 1592 if (duplex != ETH_LINK_FULL_DUPLEX) { 1593 printf("Invalid speed/duplex parameters\n"); 1594 return -1; 1595 } 1596 if (!strcmp(speedstr, "1000")) { 1597 *speed = ETH_LINK_SPEED_1G; 1598 } else if (!strcmp(speedstr, "10000")) { 1599 *speed = ETH_LINK_SPEED_10G; 1600 } else if (!strcmp(speedstr, "25000")) { 1601 *speed = ETH_LINK_SPEED_25G; 1602 } else if (!strcmp(speedstr, "40000")) { 1603 *speed = ETH_LINK_SPEED_40G; 1604 } else if (!strcmp(speedstr, "50000")) { 1605 *speed = ETH_LINK_SPEED_50G; 1606 } else if (!strcmp(speedstr, "100000")) { 1607 *speed = ETH_LINK_SPEED_100G; 1608 } else if (!strcmp(speedstr, "auto")) { 1609 *speed = ETH_LINK_SPEED_AUTONEG; 1610 } else { 1611 printf("Unknown speed parameter\n"); 1612 return -1; 1613 } 1614 } 1615 1616 return 0; 1617 } 1618 1619 static void 1620 cmd_config_speed_all_parsed(void *parsed_result, 1621 __attribute__((unused)) struct cmdline *cl, 1622 __attribute__((unused)) void *data) 1623 { 1624 struct cmd_config_speed_all *res = parsed_result; 1625 uint32_t link_speed; 1626 portid_t pid; 1627 1628 if (!all_ports_stopped()) { 1629 printf("Please stop all ports first\n"); 1630 return; 1631 } 1632 1633 if (parse_and_check_speed_duplex(res->value1, res->value2, 1634 &link_speed) < 0) 1635 return; 1636 1637 RTE_ETH_FOREACH_DEV(pid) { 1638 ports[pid].dev_conf.link_speeds = link_speed; 1639 } 1640 1641 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1); 1642 } 1643 1644 cmdline_parse_token_string_t cmd_config_speed_all_port = 1645 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_all, port, "port"); 1646 cmdline_parse_token_string_t cmd_config_speed_all_keyword = 1647 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_all, keyword, 1648 "config"); 1649 cmdline_parse_token_string_t cmd_config_speed_all_all = 1650 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_all, all, "all"); 1651 cmdline_parse_token_string_t cmd_config_speed_all_item1 = 1652 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_all, item1, "speed"); 1653 cmdline_parse_token_string_t cmd_config_speed_all_value1 = 1654 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_all, value1, 1655 "10#100#1000#10000#25000#40000#50000#100000#auto"); 1656 cmdline_parse_token_string_t cmd_config_speed_all_item2 = 1657 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_all, item2, "duplex"); 1658 cmdline_parse_token_string_t cmd_config_speed_all_value2 = 1659 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_all, value2, 1660 "half#full#auto"); 1661 1662 cmdline_parse_inst_t cmd_config_speed_all = { 1663 .f = cmd_config_speed_all_parsed, 1664 .data = NULL, 1665 .help_str = "port config all speed " 1666 "10|100|1000|10000|25000|40000|50000|100000|auto duplex " 1667 "half|full|auto", 1668 .tokens = { 1669 (void *)&cmd_config_speed_all_port, 1670 (void *)&cmd_config_speed_all_keyword, 1671 (void *)&cmd_config_speed_all_all, 1672 (void *)&cmd_config_speed_all_item1, 1673 (void *)&cmd_config_speed_all_value1, 1674 (void *)&cmd_config_speed_all_item2, 1675 (void *)&cmd_config_speed_all_value2, 1676 NULL, 1677 }, 1678 }; 1679 1680 /* *** configure speed for specific port *** */ 1681 struct cmd_config_speed_specific { 1682 cmdline_fixed_string_t port; 1683 cmdline_fixed_string_t keyword; 1684 portid_t id; 1685 cmdline_fixed_string_t item1; 1686 cmdline_fixed_string_t item2; 1687 cmdline_fixed_string_t value1; 1688 cmdline_fixed_string_t value2; 1689 }; 1690 1691 static void 1692 cmd_config_speed_specific_parsed(void *parsed_result, 1693 __attribute__((unused)) struct cmdline *cl, 1694 __attribute__((unused)) void *data) 1695 { 1696 struct cmd_config_speed_specific *res = parsed_result; 1697 uint32_t link_speed; 1698 1699 if (!all_ports_stopped()) { 1700 printf("Please stop all ports first\n"); 1701 return; 1702 } 1703 1704 if (port_id_is_invalid(res->id, ENABLED_WARN)) 1705 return; 1706 1707 if (parse_and_check_speed_duplex(res->value1, res->value2, 1708 &link_speed) < 0) 1709 return; 1710 1711 ports[res->id].dev_conf.link_speeds = link_speed; 1712 1713 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1); 1714 } 1715 1716 1717 cmdline_parse_token_string_t cmd_config_speed_specific_port = 1718 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_specific, port, 1719 "port"); 1720 cmdline_parse_token_string_t cmd_config_speed_specific_keyword = 1721 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_specific, keyword, 1722 "config"); 1723 cmdline_parse_token_num_t cmd_config_speed_specific_id = 1724 TOKEN_NUM_INITIALIZER(struct cmd_config_speed_specific, id, UINT16); 1725 cmdline_parse_token_string_t cmd_config_speed_specific_item1 = 1726 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_specific, item1, 1727 "speed"); 1728 cmdline_parse_token_string_t cmd_config_speed_specific_value1 = 1729 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_specific, value1, 1730 "10#100#1000#10000#25000#40000#50000#100000#auto"); 1731 cmdline_parse_token_string_t cmd_config_speed_specific_item2 = 1732 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_specific, item2, 1733 "duplex"); 1734 cmdline_parse_token_string_t cmd_config_speed_specific_value2 = 1735 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_specific, value2, 1736 "half#full#auto"); 1737 1738 cmdline_parse_inst_t cmd_config_speed_specific = { 1739 .f = cmd_config_speed_specific_parsed, 1740 .data = NULL, 1741 .help_str = "port config <port_id> speed " 1742 "10|100|1000|10000|25000|40000|50000|100000|auto duplex " 1743 "half|full|auto", 1744 .tokens = { 1745 (void *)&cmd_config_speed_specific_port, 1746 (void *)&cmd_config_speed_specific_keyword, 1747 (void *)&cmd_config_speed_specific_id, 1748 (void *)&cmd_config_speed_specific_item1, 1749 (void *)&cmd_config_speed_specific_value1, 1750 (void *)&cmd_config_speed_specific_item2, 1751 (void *)&cmd_config_speed_specific_value2, 1752 NULL, 1753 }, 1754 }; 1755 1756 /* *** configure loopback for all ports *** */ 1757 struct cmd_config_loopback_all { 1758 cmdline_fixed_string_t port; 1759 cmdline_fixed_string_t keyword; 1760 cmdline_fixed_string_t all; 1761 cmdline_fixed_string_t item; 1762 uint32_t mode; 1763 }; 1764 1765 static void 1766 cmd_config_loopback_all_parsed(void *parsed_result, 1767 __attribute__((unused)) struct cmdline *cl, 1768 __attribute__((unused)) void *data) 1769 { 1770 struct cmd_config_loopback_all *res = parsed_result; 1771 portid_t pid; 1772 1773 if (!all_ports_stopped()) { 1774 printf("Please stop all ports first\n"); 1775 return; 1776 } 1777 1778 RTE_ETH_FOREACH_DEV(pid) { 1779 ports[pid].dev_conf.lpbk_mode = res->mode; 1780 } 1781 1782 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1); 1783 } 1784 1785 cmdline_parse_token_string_t cmd_config_loopback_all_port = 1786 TOKEN_STRING_INITIALIZER(struct cmd_config_loopback_all, port, "port"); 1787 cmdline_parse_token_string_t cmd_config_loopback_all_keyword = 1788 TOKEN_STRING_INITIALIZER(struct cmd_config_loopback_all, keyword, 1789 "config"); 1790 cmdline_parse_token_string_t cmd_config_loopback_all_all = 1791 TOKEN_STRING_INITIALIZER(struct cmd_config_loopback_all, all, "all"); 1792 cmdline_parse_token_string_t cmd_config_loopback_all_item = 1793 TOKEN_STRING_INITIALIZER(struct cmd_config_loopback_all, item, 1794 "loopback"); 1795 cmdline_parse_token_num_t cmd_config_loopback_all_mode = 1796 TOKEN_NUM_INITIALIZER(struct cmd_config_loopback_all, mode, UINT32); 1797 1798 cmdline_parse_inst_t cmd_config_loopback_all = { 1799 .f = cmd_config_loopback_all_parsed, 1800 .data = NULL, 1801 .help_str = "port config all loopback <mode>", 1802 .tokens = { 1803 (void *)&cmd_config_loopback_all_port, 1804 (void *)&cmd_config_loopback_all_keyword, 1805 (void *)&cmd_config_loopback_all_all, 1806 (void *)&cmd_config_loopback_all_item, 1807 (void *)&cmd_config_loopback_all_mode, 1808 NULL, 1809 }, 1810 }; 1811 1812 /* *** configure loopback for specific port *** */ 1813 struct cmd_config_loopback_specific { 1814 cmdline_fixed_string_t port; 1815 cmdline_fixed_string_t keyword; 1816 uint16_t port_id; 1817 cmdline_fixed_string_t item; 1818 uint32_t mode; 1819 }; 1820 1821 static void 1822 cmd_config_loopback_specific_parsed(void *parsed_result, 1823 __attribute__((unused)) struct cmdline *cl, 1824 __attribute__((unused)) void *data) 1825 { 1826 struct cmd_config_loopback_specific *res = parsed_result; 1827 1828 if (port_id_is_invalid(res->port_id, ENABLED_WARN)) 1829 return; 1830 1831 if (!port_is_stopped(res->port_id)) { 1832 printf("Please stop port %u first\n", res->port_id); 1833 return; 1834 } 1835 1836 ports[res->port_id].dev_conf.lpbk_mode = res->mode; 1837 1838 cmd_reconfig_device_queue(res->port_id, 1, 1); 1839 } 1840 1841 1842 cmdline_parse_token_string_t cmd_config_loopback_specific_port = 1843 TOKEN_STRING_INITIALIZER(struct cmd_config_loopback_specific, port, 1844 "port"); 1845 cmdline_parse_token_string_t cmd_config_loopback_specific_keyword = 1846 TOKEN_STRING_INITIALIZER(struct cmd_config_loopback_specific, keyword, 1847 "config"); 1848 cmdline_parse_token_num_t cmd_config_loopback_specific_id = 1849 TOKEN_NUM_INITIALIZER(struct cmd_config_loopback_specific, port_id, 1850 UINT16); 1851 cmdline_parse_token_string_t cmd_config_loopback_specific_item = 1852 TOKEN_STRING_INITIALIZER(struct cmd_config_loopback_specific, item, 1853 "loopback"); 1854 cmdline_parse_token_num_t cmd_config_loopback_specific_mode = 1855 TOKEN_NUM_INITIALIZER(struct cmd_config_loopback_specific, mode, 1856 UINT32); 1857 1858 cmdline_parse_inst_t cmd_config_loopback_specific = { 1859 .f = cmd_config_loopback_specific_parsed, 1860 .data = NULL, 1861 .help_str = "port config <port_id> loopback <mode>", 1862 .tokens = { 1863 (void *)&cmd_config_loopback_specific_port, 1864 (void *)&cmd_config_loopback_specific_keyword, 1865 (void *)&cmd_config_loopback_specific_id, 1866 (void *)&cmd_config_loopback_specific_item, 1867 (void *)&cmd_config_loopback_specific_mode, 1868 NULL, 1869 }, 1870 }; 1871 1872 /* *** configure txq/rxq, txd/rxd *** */ 1873 struct cmd_config_rx_tx { 1874 cmdline_fixed_string_t port; 1875 cmdline_fixed_string_t keyword; 1876 cmdline_fixed_string_t all; 1877 cmdline_fixed_string_t name; 1878 uint16_t value; 1879 }; 1880 1881 static void 1882 cmd_config_rx_tx_parsed(void *parsed_result, 1883 __attribute__((unused)) struct cmdline *cl, 1884 __attribute__((unused)) void *data) 1885 { 1886 struct cmd_config_rx_tx *res = parsed_result; 1887 1888 if (!all_ports_stopped()) { 1889 printf("Please stop all ports first\n"); 1890 return; 1891 } 1892 if (!strcmp(res->name, "rxq")) { 1893 if (!res->value && !nb_txq) { 1894 printf("Warning: Either rx or tx queues should be non zero\n"); 1895 return; 1896 } 1897 if (check_nb_rxq(res->value) != 0) 1898 return; 1899 nb_rxq = res->value; 1900 } 1901 else if (!strcmp(res->name, "txq")) { 1902 if (!res->value && !nb_rxq) { 1903 printf("Warning: Either rx or tx queues should be non zero\n"); 1904 return; 1905 } 1906 if (check_nb_txq(res->value) != 0) 1907 return; 1908 nb_txq = res->value; 1909 } 1910 else if (!strcmp(res->name, "rxd")) { 1911 if (res->value <= 0 || res->value > RTE_TEST_RX_DESC_MAX) { 1912 printf("rxd %d invalid - must be > 0 && <= %d\n", 1913 res->value, RTE_TEST_RX_DESC_MAX); 1914 return; 1915 } 1916 nb_rxd = res->value; 1917 } else if (!strcmp(res->name, "txd")) { 1918 if (res->value <= 0 || res->value > RTE_TEST_TX_DESC_MAX) { 1919 printf("txd %d invalid - must be > 0 && <= %d\n", 1920 res->value, RTE_TEST_TX_DESC_MAX); 1921 return; 1922 } 1923 nb_txd = res->value; 1924 } else { 1925 printf("Unknown parameter\n"); 1926 return; 1927 } 1928 1929 fwd_config_setup(); 1930 1931 init_port_config(); 1932 1933 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1); 1934 } 1935 1936 cmdline_parse_token_string_t cmd_config_rx_tx_port = 1937 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_tx, port, "port"); 1938 cmdline_parse_token_string_t cmd_config_rx_tx_keyword = 1939 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_tx, keyword, "config"); 1940 cmdline_parse_token_string_t cmd_config_rx_tx_all = 1941 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_tx, all, "all"); 1942 cmdline_parse_token_string_t cmd_config_rx_tx_name = 1943 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_tx, name, 1944 "rxq#txq#rxd#txd"); 1945 cmdline_parse_token_num_t cmd_config_rx_tx_value = 1946 TOKEN_NUM_INITIALIZER(struct cmd_config_rx_tx, value, UINT16); 1947 1948 cmdline_parse_inst_t cmd_config_rx_tx = { 1949 .f = cmd_config_rx_tx_parsed, 1950 .data = NULL, 1951 .help_str = "port config all rxq|txq|rxd|txd <value>", 1952 .tokens = { 1953 (void *)&cmd_config_rx_tx_port, 1954 (void *)&cmd_config_rx_tx_keyword, 1955 (void *)&cmd_config_rx_tx_all, 1956 (void *)&cmd_config_rx_tx_name, 1957 (void *)&cmd_config_rx_tx_value, 1958 NULL, 1959 }, 1960 }; 1961 1962 /* *** config max packet length *** */ 1963 struct cmd_config_max_pkt_len_result { 1964 cmdline_fixed_string_t port; 1965 cmdline_fixed_string_t keyword; 1966 cmdline_fixed_string_t all; 1967 cmdline_fixed_string_t name; 1968 uint32_t value; 1969 }; 1970 1971 static void 1972 cmd_config_max_pkt_len_parsed(void *parsed_result, 1973 __attribute__((unused)) struct cmdline *cl, 1974 __attribute__((unused)) void *data) 1975 { 1976 struct cmd_config_max_pkt_len_result *res = parsed_result; 1977 portid_t pid; 1978 1979 if (!all_ports_stopped()) { 1980 printf("Please stop all ports first\n"); 1981 return; 1982 } 1983 1984 RTE_ETH_FOREACH_DEV(pid) { 1985 struct rte_port *port = &ports[pid]; 1986 uint64_t rx_offloads = port->dev_conf.rxmode.offloads; 1987 1988 if (!strcmp(res->name, "max-pkt-len")) { 1989 if (res->value < RTE_ETHER_MIN_LEN) { 1990 printf("max-pkt-len can not be less than %d\n", 1991 RTE_ETHER_MIN_LEN); 1992 return; 1993 } 1994 if (res->value == port->dev_conf.rxmode.max_rx_pkt_len) 1995 return; 1996 1997 port->dev_conf.rxmode.max_rx_pkt_len = res->value; 1998 if (res->value > RTE_ETHER_MAX_LEN) 1999 rx_offloads |= DEV_RX_OFFLOAD_JUMBO_FRAME; 2000 else 2001 rx_offloads &= ~DEV_RX_OFFLOAD_JUMBO_FRAME; 2002 port->dev_conf.rxmode.offloads = rx_offloads; 2003 } else { 2004 printf("Unknown parameter\n"); 2005 return; 2006 } 2007 } 2008 2009 init_port_config(); 2010 2011 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1); 2012 } 2013 2014 cmdline_parse_token_string_t cmd_config_max_pkt_len_port = 2015 TOKEN_STRING_INITIALIZER(struct cmd_config_max_pkt_len_result, port, 2016 "port"); 2017 cmdline_parse_token_string_t cmd_config_max_pkt_len_keyword = 2018 TOKEN_STRING_INITIALIZER(struct cmd_config_max_pkt_len_result, keyword, 2019 "config"); 2020 cmdline_parse_token_string_t cmd_config_max_pkt_len_all = 2021 TOKEN_STRING_INITIALIZER(struct cmd_config_max_pkt_len_result, all, 2022 "all"); 2023 cmdline_parse_token_string_t cmd_config_max_pkt_len_name = 2024 TOKEN_STRING_INITIALIZER(struct cmd_config_max_pkt_len_result, name, 2025 "max-pkt-len"); 2026 cmdline_parse_token_num_t cmd_config_max_pkt_len_value = 2027 TOKEN_NUM_INITIALIZER(struct cmd_config_max_pkt_len_result, value, 2028 UINT32); 2029 2030 cmdline_parse_inst_t cmd_config_max_pkt_len = { 2031 .f = cmd_config_max_pkt_len_parsed, 2032 .data = NULL, 2033 .help_str = "port config all max-pkt-len <value>", 2034 .tokens = { 2035 (void *)&cmd_config_max_pkt_len_port, 2036 (void *)&cmd_config_max_pkt_len_keyword, 2037 (void *)&cmd_config_max_pkt_len_all, 2038 (void *)&cmd_config_max_pkt_len_name, 2039 (void *)&cmd_config_max_pkt_len_value, 2040 NULL, 2041 }, 2042 }; 2043 2044 /* *** configure port MTU *** */ 2045 struct cmd_config_mtu_result { 2046 cmdline_fixed_string_t port; 2047 cmdline_fixed_string_t keyword; 2048 cmdline_fixed_string_t mtu; 2049 portid_t port_id; 2050 uint16_t value; 2051 }; 2052 2053 static void 2054 cmd_config_mtu_parsed(void *parsed_result, 2055 __attribute__((unused)) struct cmdline *cl, 2056 __attribute__((unused)) void *data) 2057 { 2058 struct cmd_config_mtu_result *res = parsed_result; 2059 2060 if (res->value < RTE_ETHER_MIN_LEN) { 2061 printf("mtu cannot be less than %d\n", RTE_ETHER_MIN_LEN); 2062 return; 2063 } 2064 port_mtu_set(res->port_id, res->value); 2065 } 2066 2067 cmdline_parse_token_string_t cmd_config_mtu_port = 2068 TOKEN_STRING_INITIALIZER(struct cmd_config_mtu_result, port, 2069 "port"); 2070 cmdline_parse_token_string_t cmd_config_mtu_keyword = 2071 TOKEN_STRING_INITIALIZER(struct cmd_config_mtu_result, keyword, 2072 "config"); 2073 cmdline_parse_token_string_t cmd_config_mtu_mtu = 2074 TOKEN_STRING_INITIALIZER(struct cmd_config_mtu_result, keyword, 2075 "mtu"); 2076 cmdline_parse_token_num_t cmd_config_mtu_port_id = 2077 TOKEN_NUM_INITIALIZER(struct cmd_config_mtu_result, port_id, UINT16); 2078 cmdline_parse_token_num_t cmd_config_mtu_value = 2079 TOKEN_NUM_INITIALIZER(struct cmd_config_mtu_result, value, UINT16); 2080 2081 cmdline_parse_inst_t cmd_config_mtu = { 2082 .f = cmd_config_mtu_parsed, 2083 .data = NULL, 2084 .help_str = "port config mtu <port_id> <value>", 2085 .tokens = { 2086 (void *)&cmd_config_mtu_port, 2087 (void *)&cmd_config_mtu_keyword, 2088 (void *)&cmd_config_mtu_mtu, 2089 (void *)&cmd_config_mtu_port_id, 2090 (void *)&cmd_config_mtu_value, 2091 NULL, 2092 }, 2093 }; 2094 2095 /* *** configure rx mode *** */ 2096 struct cmd_config_rx_mode_flag { 2097 cmdline_fixed_string_t port; 2098 cmdline_fixed_string_t keyword; 2099 cmdline_fixed_string_t all; 2100 cmdline_fixed_string_t name; 2101 cmdline_fixed_string_t value; 2102 }; 2103 2104 static void 2105 cmd_config_rx_mode_flag_parsed(void *parsed_result, 2106 __attribute__((unused)) struct cmdline *cl, 2107 __attribute__((unused)) void *data) 2108 { 2109 struct cmd_config_rx_mode_flag *res = parsed_result; 2110 2111 if (!all_ports_stopped()) { 2112 printf("Please stop all ports first\n"); 2113 return; 2114 } 2115 2116 if (!strcmp(res->name, "drop-en")) { 2117 if (!strcmp(res->value, "on")) 2118 rx_drop_en = 1; 2119 else if (!strcmp(res->value, "off")) 2120 rx_drop_en = 0; 2121 else { 2122 printf("Unknown parameter\n"); 2123 return; 2124 } 2125 } else { 2126 printf("Unknown parameter\n"); 2127 return; 2128 } 2129 2130 init_port_config(); 2131 2132 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1); 2133 } 2134 2135 cmdline_parse_token_string_t cmd_config_rx_mode_flag_port = 2136 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_mode_flag, port, "port"); 2137 cmdline_parse_token_string_t cmd_config_rx_mode_flag_keyword = 2138 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_mode_flag, keyword, 2139 "config"); 2140 cmdline_parse_token_string_t cmd_config_rx_mode_flag_all = 2141 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_mode_flag, all, "all"); 2142 cmdline_parse_token_string_t cmd_config_rx_mode_flag_name = 2143 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_mode_flag, name, 2144 "drop-en"); 2145 cmdline_parse_token_string_t cmd_config_rx_mode_flag_value = 2146 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_mode_flag, value, 2147 "on#off"); 2148 2149 cmdline_parse_inst_t cmd_config_rx_mode_flag = { 2150 .f = cmd_config_rx_mode_flag_parsed, 2151 .data = NULL, 2152 .help_str = "port config all drop-en on|off", 2153 .tokens = { 2154 (void *)&cmd_config_rx_mode_flag_port, 2155 (void *)&cmd_config_rx_mode_flag_keyword, 2156 (void *)&cmd_config_rx_mode_flag_all, 2157 (void *)&cmd_config_rx_mode_flag_name, 2158 (void *)&cmd_config_rx_mode_flag_value, 2159 NULL, 2160 }, 2161 }; 2162 2163 /* *** configure rss *** */ 2164 struct cmd_config_rss { 2165 cmdline_fixed_string_t port; 2166 cmdline_fixed_string_t keyword; 2167 cmdline_fixed_string_t all; 2168 cmdline_fixed_string_t name; 2169 cmdline_fixed_string_t value; 2170 }; 2171 2172 static void 2173 cmd_config_rss_parsed(void *parsed_result, 2174 __attribute__((unused)) struct cmdline *cl, 2175 __attribute__((unused)) void *data) 2176 { 2177 struct cmd_config_rss *res = parsed_result; 2178 struct rte_eth_rss_conf rss_conf = { .rss_key_len = 0, }; 2179 struct rte_eth_dev_info dev_info = { .flow_type_rss_offloads = 0, }; 2180 int use_default = 0; 2181 int all_updated = 1; 2182 int diag; 2183 uint16_t i; 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 rte_eth_dev_info_get(i, &dev_info); 2224 if (use_default) 2225 rss_conf.rss_hf = dev_info.flow_type_rss_offloads; 2226 2227 local_rss_conf = rss_conf; 2228 local_rss_conf.rss_hf = rss_conf.rss_hf & 2229 dev_info.flow_type_rss_offloads; 2230 if (local_rss_conf.rss_hf != rss_conf.rss_hf) { 2231 printf("Port %u modified RSS hash function based on hardware support," 2232 "requested:%#"PRIx64" configured:%#"PRIx64"\n", 2233 i, rss_conf.rss_hf, local_rss_conf.rss_hf); 2234 } 2235 diag = rte_eth_dev_rss_hash_update(i, &local_rss_conf); 2236 if (diag < 0) { 2237 all_updated = 0; 2238 printf("Configuration of RSS hash at ethernet port %d " 2239 "failed with error (%d): %s.\n", 2240 i, -diag, strerror(-diag)); 2241 } 2242 } 2243 if (all_updated && !use_default) 2244 rss_hf = rss_conf.rss_hf; 2245 } 2246 2247 cmdline_parse_token_string_t cmd_config_rss_port = 2248 TOKEN_STRING_INITIALIZER(struct cmd_config_rss, port, "port"); 2249 cmdline_parse_token_string_t cmd_config_rss_keyword = 2250 TOKEN_STRING_INITIALIZER(struct cmd_config_rss, keyword, "config"); 2251 cmdline_parse_token_string_t cmd_config_rss_all = 2252 TOKEN_STRING_INITIALIZER(struct cmd_config_rss, all, "all"); 2253 cmdline_parse_token_string_t cmd_config_rss_name = 2254 TOKEN_STRING_INITIALIZER(struct cmd_config_rss, name, "rss"); 2255 cmdline_parse_token_string_t cmd_config_rss_value = 2256 TOKEN_STRING_INITIALIZER(struct cmd_config_rss, value, NULL); 2257 2258 cmdline_parse_inst_t cmd_config_rss = { 2259 .f = cmd_config_rss_parsed, 2260 .data = NULL, 2261 .help_str = "port config all rss " 2262 "all|default|ip|tcp|udp|sctp|ether|port|vxlan|geneve|nvgre|vxlan-gpe|none|<flowtype_id>", 2263 .tokens = { 2264 (void *)&cmd_config_rss_port, 2265 (void *)&cmd_config_rss_keyword, 2266 (void *)&cmd_config_rss_all, 2267 (void *)&cmd_config_rss_name, 2268 (void *)&cmd_config_rss_value, 2269 NULL, 2270 }, 2271 }; 2272 2273 /* *** configure rss hash key *** */ 2274 struct cmd_config_rss_hash_key { 2275 cmdline_fixed_string_t port; 2276 cmdline_fixed_string_t config; 2277 portid_t port_id; 2278 cmdline_fixed_string_t rss_hash_key; 2279 cmdline_fixed_string_t rss_type; 2280 cmdline_fixed_string_t key; 2281 }; 2282 2283 static uint8_t 2284 hexa_digit_to_value(char hexa_digit) 2285 { 2286 if ((hexa_digit >= '0') && (hexa_digit <= '9')) 2287 return (uint8_t) (hexa_digit - '0'); 2288 if ((hexa_digit >= 'a') && (hexa_digit <= 'f')) 2289 return (uint8_t) ((hexa_digit - 'a') + 10); 2290 if ((hexa_digit >= 'A') && (hexa_digit <= 'F')) 2291 return (uint8_t) ((hexa_digit - 'A') + 10); 2292 /* Invalid hexa digit */ 2293 return 0xFF; 2294 } 2295 2296 static uint8_t 2297 parse_and_check_key_hexa_digit(char *key, int idx) 2298 { 2299 uint8_t hexa_v; 2300 2301 hexa_v = hexa_digit_to_value(key[idx]); 2302 if (hexa_v == 0xFF) 2303 printf("invalid key: character %c at position %d is not a " 2304 "valid hexa digit\n", key[idx], idx); 2305 return hexa_v; 2306 } 2307 2308 static void 2309 cmd_config_rss_hash_key_parsed(void *parsed_result, 2310 __attribute__((unused)) struct cmdline *cl, 2311 __attribute__((unused)) void *data) 2312 { 2313 struct cmd_config_rss_hash_key *res = parsed_result; 2314 uint8_t hash_key[RSS_HASH_KEY_LENGTH]; 2315 uint8_t xdgt0; 2316 uint8_t xdgt1; 2317 int i; 2318 struct rte_eth_dev_info dev_info; 2319 uint8_t hash_key_size; 2320 uint32_t key_len; 2321 2322 memset(&dev_info, 0, sizeof(dev_info)); 2323 rte_eth_dev_info_get(res->port_id, &dev_info); 2324 if (dev_info.hash_key_size > 0 && 2325 dev_info.hash_key_size <= sizeof(hash_key)) 2326 hash_key_size = dev_info.hash_key_size; 2327 else { 2328 printf("dev_info did not provide a valid hash key size\n"); 2329 return; 2330 } 2331 /* Check the length of the RSS hash key */ 2332 key_len = strlen(res->key); 2333 if (key_len != (hash_key_size * 2)) { 2334 printf("key length: %d invalid - key must be a string of %d" 2335 " hexa-decimal numbers\n", 2336 (int) key_len, hash_key_size * 2); 2337 return; 2338 } 2339 /* Translate RSS hash key into binary representation */ 2340 for (i = 0; i < hash_key_size; i++) { 2341 xdgt0 = parse_and_check_key_hexa_digit(res->key, (i * 2)); 2342 if (xdgt0 == 0xFF) 2343 return; 2344 xdgt1 = parse_and_check_key_hexa_digit(res->key, (i * 2) + 1); 2345 if (xdgt1 == 0xFF) 2346 return; 2347 hash_key[i] = (uint8_t) ((xdgt0 * 16) + xdgt1); 2348 } 2349 port_rss_hash_key_update(res->port_id, res->rss_type, hash_key, 2350 hash_key_size); 2351 } 2352 2353 cmdline_parse_token_string_t cmd_config_rss_hash_key_port = 2354 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_hash_key, port, "port"); 2355 cmdline_parse_token_string_t cmd_config_rss_hash_key_config = 2356 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_hash_key, config, 2357 "config"); 2358 cmdline_parse_token_num_t cmd_config_rss_hash_key_port_id = 2359 TOKEN_NUM_INITIALIZER(struct cmd_config_rss_hash_key, port_id, UINT16); 2360 cmdline_parse_token_string_t cmd_config_rss_hash_key_rss_hash_key = 2361 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_hash_key, 2362 rss_hash_key, "rss-hash-key"); 2363 cmdline_parse_token_string_t cmd_config_rss_hash_key_rss_type = 2364 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_hash_key, rss_type, 2365 "ipv4#ipv4-frag#ipv4-tcp#ipv4-udp#ipv4-sctp#" 2366 "ipv4-other#ipv6#ipv6-frag#ipv6-tcp#ipv6-udp#" 2367 "ipv6-sctp#ipv6-other#l2-payload#ipv6-ex#" 2368 "ipv6-tcp-ex#ipv6-udp-ex"); 2369 cmdline_parse_token_string_t cmd_config_rss_hash_key_value = 2370 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_hash_key, key, NULL); 2371 2372 cmdline_parse_inst_t cmd_config_rss_hash_key = { 2373 .f = cmd_config_rss_hash_key_parsed, 2374 .data = NULL, 2375 .help_str = "port config <port_id> rss-hash-key " 2376 "ipv4|ipv4-frag|ipv4-tcp|ipv4-udp|ipv4-sctp|ipv4-other|" 2377 "ipv6|ipv6-frag|ipv6-tcp|ipv6-udp|ipv6-sctp|ipv6-other|" 2378 "l2-payload|ipv6-ex|ipv6-tcp-ex|ipv6-udp-ex " 2379 "<string of hex digits (variable length, NIC dependent)>", 2380 .tokens = { 2381 (void *)&cmd_config_rss_hash_key_port, 2382 (void *)&cmd_config_rss_hash_key_config, 2383 (void *)&cmd_config_rss_hash_key_port_id, 2384 (void *)&cmd_config_rss_hash_key_rss_hash_key, 2385 (void *)&cmd_config_rss_hash_key_rss_type, 2386 (void *)&cmd_config_rss_hash_key_value, 2387 NULL, 2388 }, 2389 }; 2390 2391 /* *** configure port rxq/txq ring size *** */ 2392 struct cmd_config_rxtx_ring_size { 2393 cmdline_fixed_string_t port; 2394 cmdline_fixed_string_t config; 2395 portid_t portid; 2396 cmdline_fixed_string_t rxtxq; 2397 uint16_t qid; 2398 cmdline_fixed_string_t rsize; 2399 uint16_t size; 2400 }; 2401 2402 static void 2403 cmd_config_rxtx_ring_size_parsed(void *parsed_result, 2404 __attribute__((unused)) struct cmdline *cl, 2405 __attribute__((unused)) void *data) 2406 { 2407 struct cmd_config_rxtx_ring_size *res = parsed_result; 2408 struct rte_port *port; 2409 uint8_t isrx; 2410 2411 if (port_id_is_invalid(res->portid, ENABLED_WARN)) 2412 return; 2413 2414 if (res->portid == (portid_t)RTE_PORT_ALL) { 2415 printf("Invalid port id\n"); 2416 return; 2417 } 2418 2419 port = &ports[res->portid]; 2420 2421 if (!strcmp(res->rxtxq, "rxq")) 2422 isrx = 1; 2423 else if (!strcmp(res->rxtxq, "txq")) 2424 isrx = 0; 2425 else { 2426 printf("Unknown parameter\n"); 2427 return; 2428 } 2429 2430 if (isrx && rx_queue_id_is_invalid(res->qid)) 2431 return; 2432 else if (!isrx && tx_queue_id_is_invalid(res->qid)) 2433 return; 2434 2435 if (isrx && res->size != 0 && res->size <= rx_free_thresh) { 2436 printf("Invalid rx ring_size, must > rx_free_thresh: %d\n", 2437 rx_free_thresh); 2438 return; 2439 } 2440 2441 if (isrx) 2442 port->nb_rx_desc[res->qid] = res->size; 2443 else 2444 port->nb_tx_desc[res->qid] = res->size; 2445 2446 cmd_reconfig_device_queue(res->portid, 0, 1); 2447 } 2448 2449 cmdline_parse_token_string_t cmd_config_rxtx_ring_size_port = 2450 TOKEN_STRING_INITIALIZER(struct cmd_config_rxtx_ring_size, 2451 port, "port"); 2452 cmdline_parse_token_string_t cmd_config_rxtx_ring_size_config = 2453 TOKEN_STRING_INITIALIZER(struct cmd_config_rxtx_ring_size, 2454 config, "config"); 2455 cmdline_parse_token_num_t cmd_config_rxtx_ring_size_portid = 2456 TOKEN_NUM_INITIALIZER(struct cmd_config_rxtx_ring_size, 2457 portid, UINT16); 2458 cmdline_parse_token_string_t cmd_config_rxtx_ring_size_rxtxq = 2459 TOKEN_STRING_INITIALIZER(struct cmd_config_rxtx_ring_size, 2460 rxtxq, "rxq#txq"); 2461 cmdline_parse_token_num_t cmd_config_rxtx_ring_size_qid = 2462 TOKEN_NUM_INITIALIZER(struct cmd_config_rxtx_ring_size, 2463 qid, UINT16); 2464 cmdline_parse_token_string_t cmd_config_rxtx_ring_size_rsize = 2465 TOKEN_STRING_INITIALIZER(struct cmd_config_rxtx_ring_size, 2466 rsize, "ring_size"); 2467 cmdline_parse_token_num_t cmd_config_rxtx_ring_size_size = 2468 TOKEN_NUM_INITIALIZER(struct cmd_config_rxtx_ring_size, 2469 size, UINT16); 2470 2471 cmdline_parse_inst_t cmd_config_rxtx_ring_size = { 2472 .f = cmd_config_rxtx_ring_size_parsed, 2473 .data = NULL, 2474 .help_str = "port config <port_id> rxq|txq <queue_id> ring_size <value>", 2475 .tokens = { 2476 (void *)&cmd_config_rxtx_ring_size_port, 2477 (void *)&cmd_config_rxtx_ring_size_config, 2478 (void *)&cmd_config_rxtx_ring_size_portid, 2479 (void *)&cmd_config_rxtx_ring_size_rxtxq, 2480 (void *)&cmd_config_rxtx_ring_size_qid, 2481 (void *)&cmd_config_rxtx_ring_size_rsize, 2482 (void *)&cmd_config_rxtx_ring_size_size, 2483 NULL, 2484 }, 2485 }; 2486 2487 /* *** configure port rxq/txq start/stop *** */ 2488 struct cmd_config_rxtx_queue { 2489 cmdline_fixed_string_t port; 2490 portid_t portid; 2491 cmdline_fixed_string_t rxtxq; 2492 uint16_t qid; 2493 cmdline_fixed_string_t opname; 2494 }; 2495 2496 static void 2497 cmd_config_rxtx_queue_parsed(void *parsed_result, 2498 __attribute__((unused)) struct cmdline *cl, 2499 __attribute__((unused)) void *data) 2500 { 2501 struct cmd_config_rxtx_queue *res = parsed_result; 2502 uint8_t isrx; 2503 uint8_t isstart; 2504 int ret = 0; 2505 2506 if (test_done == 0) { 2507 printf("Please stop forwarding first\n"); 2508 return; 2509 } 2510 2511 if (port_id_is_invalid(res->portid, ENABLED_WARN)) 2512 return; 2513 2514 if (port_is_started(res->portid) != 1) { 2515 printf("Please start port %u first\n", res->portid); 2516 return; 2517 } 2518 2519 if (!strcmp(res->rxtxq, "rxq")) 2520 isrx = 1; 2521 else if (!strcmp(res->rxtxq, "txq")) 2522 isrx = 0; 2523 else { 2524 printf("Unknown parameter\n"); 2525 return; 2526 } 2527 2528 if (isrx && rx_queue_id_is_invalid(res->qid)) 2529 return; 2530 else if (!isrx && tx_queue_id_is_invalid(res->qid)) 2531 return; 2532 2533 if (!strcmp(res->opname, "start")) 2534 isstart = 1; 2535 else if (!strcmp(res->opname, "stop")) 2536 isstart = 0; 2537 else { 2538 printf("Unknown parameter\n"); 2539 return; 2540 } 2541 2542 if (isstart && isrx) 2543 ret = rte_eth_dev_rx_queue_start(res->portid, res->qid); 2544 else if (!isstart && isrx) 2545 ret = rte_eth_dev_rx_queue_stop(res->portid, res->qid); 2546 else if (isstart && !isrx) 2547 ret = rte_eth_dev_tx_queue_start(res->portid, res->qid); 2548 else 2549 ret = rte_eth_dev_tx_queue_stop(res->portid, res->qid); 2550 2551 if (ret == -ENOTSUP) 2552 printf("Function not supported in PMD driver\n"); 2553 } 2554 2555 cmdline_parse_token_string_t cmd_config_rxtx_queue_port = 2556 TOKEN_STRING_INITIALIZER(struct cmd_config_rxtx_queue, port, "port"); 2557 cmdline_parse_token_num_t cmd_config_rxtx_queue_portid = 2558 TOKEN_NUM_INITIALIZER(struct cmd_config_rxtx_queue, portid, UINT16); 2559 cmdline_parse_token_string_t cmd_config_rxtx_queue_rxtxq = 2560 TOKEN_STRING_INITIALIZER(struct cmd_config_rxtx_queue, rxtxq, "rxq#txq"); 2561 cmdline_parse_token_num_t cmd_config_rxtx_queue_qid = 2562 TOKEN_NUM_INITIALIZER(struct cmd_config_rxtx_queue, qid, UINT16); 2563 cmdline_parse_token_string_t cmd_config_rxtx_queue_opname = 2564 TOKEN_STRING_INITIALIZER(struct cmd_config_rxtx_queue, opname, 2565 "start#stop"); 2566 2567 cmdline_parse_inst_t cmd_config_rxtx_queue = { 2568 .f = cmd_config_rxtx_queue_parsed, 2569 .data = NULL, 2570 .help_str = "port <port_id> rxq|txq <queue_id> start|stop", 2571 .tokens = { 2572 (void *)&cmd_config_rxtx_queue_port, 2573 (void *)&cmd_config_rxtx_queue_portid, 2574 (void *)&cmd_config_rxtx_queue_rxtxq, 2575 (void *)&cmd_config_rxtx_queue_qid, 2576 (void *)&cmd_config_rxtx_queue_opname, 2577 NULL, 2578 }, 2579 }; 2580 2581 /* *** configure port rxq/txq deferred start on/off *** */ 2582 struct cmd_config_deferred_start_rxtx_queue { 2583 cmdline_fixed_string_t port; 2584 portid_t port_id; 2585 cmdline_fixed_string_t rxtxq; 2586 uint16_t qid; 2587 cmdline_fixed_string_t opname; 2588 cmdline_fixed_string_t state; 2589 }; 2590 2591 static void 2592 cmd_config_deferred_start_rxtx_queue_parsed(void *parsed_result, 2593 __attribute__((unused)) struct cmdline *cl, 2594 __attribute__((unused)) void *data) 2595 { 2596 struct cmd_config_deferred_start_rxtx_queue *res = parsed_result; 2597 struct rte_port *port; 2598 uint8_t isrx; 2599 uint8_t ison; 2600 uint8_t needreconfig = 0; 2601 2602 if (port_id_is_invalid(res->port_id, ENABLED_WARN)) 2603 return; 2604 2605 if (port_is_started(res->port_id) != 0) { 2606 printf("Please stop port %u first\n", res->port_id); 2607 return; 2608 } 2609 2610 port = &ports[res->port_id]; 2611 2612 isrx = !strcmp(res->rxtxq, "rxq"); 2613 2614 if (isrx && rx_queue_id_is_invalid(res->qid)) 2615 return; 2616 else if (!isrx && tx_queue_id_is_invalid(res->qid)) 2617 return; 2618 2619 ison = !strcmp(res->state, "on"); 2620 2621 if (isrx && port->rx_conf[res->qid].rx_deferred_start != ison) { 2622 port->rx_conf[res->qid].rx_deferred_start = ison; 2623 needreconfig = 1; 2624 } else if (!isrx && port->tx_conf[res->qid].tx_deferred_start != ison) { 2625 port->tx_conf[res->qid].tx_deferred_start = ison; 2626 needreconfig = 1; 2627 } 2628 2629 if (needreconfig) 2630 cmd_reconfig_device_queue(res->port_id, 0, 1); 2631 } 2632 2633 cmdline_parse_token_string_t cmd_config_deferred_start_rxtx_queue_port = 2634 TOKEN_STRING_INITIALIZER(struct cmd_config_deferred_start_rxtx_queue, 2635 port, "port"); 2636 cmdline_parse_token_num_t cmd_config_deferred_start_rxtx_queue_port_id = 2637 TOKEN_NUM_INITIALIZER(struct cmd_config_deferred_start_rxtx_queue, 2638 port_id, UINT16); 2639 cmdline_parse_token_string_t cmd_config_deferred_start_rxtx_queue_rxtxq = 2640 TOKEN_STRING_INITIALIZER(struct cmd_config_deferred_start_rxtx_queue, 2641 rxtxq, "rxq#txq"); 2642 cmdline_parse_token_num_t cmd_config_deferred_start_rxtx_queue_qid = 2643 TOKEN_NUM_INITIALIZER(struct cmd_config_deferred_start_rxtx_queue, 2644 qid, UINT16); 2645 cmdline_parse_token_string_t cmd_config_deferred_start_rxtx_queue_opname = 2646 TOKEN_STRING_INITIALIZER(struct cmd_config_deferred_start_rxtx_queue, 2647 opname, "deferred_start"); 2648 cmdline_parse_token_string_t cmd_config_deferred_start_rxtx_queue_state = 2649 TOKEN_STRING_INITIALIZER(struct cmd_config_deferred_start_rxtx_queue, 2650 state, "on#off"); 2651 2652 cmdline_parse_inst_t cmd_config_deferred_start_rxtx_queue = { 2653 .f = cmd_config_deferred_start_rxtx_queue_parsed, 2654 .data = NULL, 2655 .help_str = "port <port_id> rxq|txq <queue_id> deferred_start on|off", 2656 .tokens = { 2657 (void *)&cmd_config_deferred_start_rxtx_queue_port, 2658 (void *)&cmd_config_deferred_start_rxtx_queue_port_id, 2659 (void *)&cmd_config_deferred_start_rxtx_queue_rxtxq, 2660 (void *)&cmd_config_deferred_start_rxtx_queue_qid, 2661 (void *)&cmd_config_deferred_start_rxtx_queue_opname, 2662 (void *)&cmd_config_deferred_start_rxtx_queue_state, 2663 NULL, 2664 }, 2665 }; 2666 2667 /* *** configure port rxq/txq setup *** */ 2668 struct cmd_setup_rxtx_queue { 2669 cmdline_fixed_string_t port; 2670 portid_t portid; 2671 cmdline_fixed_string_t rxtxq; 2672 uint16_t qid; 2673 cmdline_fixed_string_t setup; 2674 }; 2675 2676 /* Common CLI fields for queue setup */ 2677 cmdline_parse_token_string_t cmd_setup_rxtx_queue_port = 2678 TOKEN_STRING_INITIALIZER(struct cmd_setup_rxtx_queue, port, "port"); 2679 cmdline_parse_token_num_t cmd_setup_rxtx_queue_portid = 2680 TOKEN_NUM_INITIALIZER(struct cmd_setup_rxtx_queue, portid, UINT16); 2681 cmdline_parse_token_string_t cmd_setup_rxtx_queue_rxtxq = 2682 TOKEN_STRING_INITIALIZER(struct cmd_setup_rxtx_queue, rxtxq, "rxq#txq"); 2683 cmdline_parse_token_num_t cmd_setup_rxtx_queue_qid = 2684 TOKEN_NUM_INITIALIZER(struct cmd_setup_rxtx_queue, qid, UINT16); 2685 cmdline_parse_token_string_t cmd_setup_rxtx_queue_setup = 2686 TOKEN_STRING_INITIALIZER(struct cmd_setup_rxtx_queue, setup, "setup"); 2687 2688 static void 2689 cmd_setup_rxtx_queue_parsed( 2690 void *parsed_result, 2691 __attribute__((unused)) struct cmdline *cl, 2692 __attribute__((unused)) void *data) 2693 { 2694 struct cmd_setup_rxtx_queue *res = parsed_result; 2695 struct rte_port *port; 2696 struct rte_mempool *mp; 2697 unsigned int socket_id; 2698 uint8_t isrx = 0; 2699 int ret; 2700 2701 if (port_id_is_invalid(res->portid, ENABLED_WARN)) 2702 return; 2703 2704 if (res->portid == (portid_t)RTE_PORT_ALL) { 2705 printf("Invalid port id\n"); 2706 return; 2707 } 2708 2709 if (!strcmp(res->rxtxq, "rxq")) 2710 isrx = 1; 2711 else if (!strcmp(res->rxtxq, "txq")) 2712 isrx = 0; 2713 else { 2714 printf("Unknown parameter\n"); 2715 return; 2716 } 2717 2718 if (isrx && rx_queue_id_is_invalid(res->qid)) { 2719 printf("Invalid rx queue\n"); 2720 return; 2721 } else if (!isrx && tx_queue_id_is_invalid(res->qid)) { 2722 printf("Invalid tx queue\n"); 2723 return; 2724 } 2725 2726 port = &ports[res->portid]; 2727 if (isrx) { 2728 socket_id = rxring_numa[res->portid]; 2729 if (!numa_support || socket_id == NUMA_NO_CONFIG) 2730 socket_id = port->socket_id; 2731 2732 mp = mbuf_pool_find(socket_id); 2733 if (mp == NULL) { 2734 printf("Failed to setup RX queue: " 2735 "No mempool allocation" 2736 " on the socket %d\n", 2737 rxring_numa[res->portid]); 2738 return; 2739 } 2740 ret = rte_eth_rx_queue_setup(res->portid, 2741 res->qid, 2742 port->nb_rx_desc[res->qid], 2743 socket_id, 2744 &port->rx_conf[res->qid], 2745 mp); 2746 if (ret) 2747 printf("Failed to setup RX queue\n"); 2748 } else { 2749 socket_id = txring_numa[res->portid]; 2750 if (!numa_support || socket_id == NUMA_NO_CONFIG) 2751 socket_id = port->socket_id; 2752 2753 ret = rte_eth_tx_queue_setup(res->portid, 2754 res->qid, 2755 port->nb_tx_desc[res->qid], 2756 socket_id, 2757 &port->tx_conf[res->qid]); 2758 if (ret) 2759 printf("Failed to setup TX queue\n"); 2760 } 2761 } 2762 2763 cmdline_parse_inst_t cmd_setup_rxtx_queue = { 2764 .f = cmd_setup_rxtx_queue_parsed, 2765 .data = NULL, 2766 .help_str = "port <port_id> rxq|txq <queue_idx> setup", 2767 .tokens = { 2768 (void *)&cmd_setup_rxtx_queue_port, 2769 (void *)&cmd_setup_rxtx_queue_portid, 2770 (void *)&cmd_setup_rxtx_queue_rxtxq, 2771 (void *)&cmd_setup_rxtx_queue_qid, 2772 (void *)&cmd_setup_rxtx_queue_setup, 2773 NULL, 2774 }, 2775 }; 2776 2777 2778 /* *** Configure RSS RETA *** */ 2779 struct cmd_config_rss_reta { 2780 cmdline_fixed_string_t port; 2781 cmdline_fixed_string_t keyword; 2782 portid_t port_id; 2783 cmdline_fixed_string_t name; 2784 cmdline_fixed_string_t list_name; 2785 cmdline_fixed_string_t list_of_items; 2786 }; 2787 2788 static int 2789 parse_reta_config(const char *str, 2790 struct rte_eth_rss_reta_entry64 *reta_conf, 2791 uint16_t nb_entries) 2792 { 2793 int i; 2794 unsigned size; 2795 uint16_t hash_index, idx, shift; 2796 uint16_t nb_queue; 2797 char s[256]; 2798 const char *p, *p0 = str; 2799 char *end; 2800 enum fieldnames { 2801 FLD_HASH_INDEX = 0, 2802 FLD_QUEUE, 2803 _NUM_FLD 2804 }; 2805 unsigned long int_fld[_NUM_FLD]; 2806 char *str_fld[_NUM_FLD]; 2807 2808 while ((p = strchr(p0,'(')) != NULL) { 2809 ++p; 2810 if((p0 = strchr(p,')')) == NULL) 2811 return -1; 2812 2813 size = p0 - p; 2814 if(size >= sizeof(s)) 2815 return -1; 2816 2817 snprintf(s, sizeof(s), "%.*s", size, p); 2818 if (rte_strsplit(s, sizeof(s), str_fld, _NUM_FLD, ',') != _NUM_FLD) 2819 return -1; 2820 for (i = 0; i < _NUM_FLD; i++) { 2821 errno = 0; 2822 int_fld[i] = strtoul(str_fld[i], &end, 0); 2823 if (errno != 0 || end == str_fld[i] || 2824 int_fld[i] > 65535) 2825 return -1; 2826 } 2827 2828 hash_index = (uint16_t)int_fld[FLD_HASH_INDEX]; 2829 nb_queue = (uint16_t)int_fld[FLD_QUEUE]; 2830 2831 if (hash_index >= nb_entries) { 2832 printf("Invalid RETA hash index=%d\n", hash_index); 2833 return -1; 2834 } 2835 2836 idx = hash_index / RTE_RETA_GROUP_SIZE; 2837 shift = hash_index % RTE_RETA_GROUP_SIZE; 2838 reta_conf[idx].mask |= (1ULL << shift); 2839 reta_conf[idx].reta[shift] = nb_queue; 2840 } 2841 2842 return 0; 2843 } 2844 2845 static void 2846 cmd_set_rss_reta_parsed(void *parsed_result, 2847 __attribute__((unused)) struct cmdline *cl, 2848 __attribute__((unused)) void *data) 2849 { 2850 int ret; 2851 struct rte_eth_dev_info dev_info; 2852 struct rte_eth_rss_reta_entry64 reta_conf[8]; 2853 struct cmd_config_rss_reta *res = parsed_result; 2854 2855 memset(&dev_info, 0, sizeof(dev_info)); 2856 rte_eth_dev_info_get(res->port_id, &dev_info); 2857 if (dev_info.reta_size == 0) { 2858 printf("Redirection table size is 0 which is " 2859 "invalid for RSS\n"); 2860 return; 2861 } else 2862 printf("The reta size of port %d is %u\n", 2863 res->port_id, dev_info.reta_size); 2864 if (dev_info.reta_size > ETH_RSS_RETA_SIZE_512) { 2865 printf("Currently do not support more than %u entries of " 2866 "redirection table\n", ETH_RSS_RETA_SIZE_512); 2867 return; 2868 } 2869 2870 memset(reta_conf, 0, sizeof(reta_conf)); 2871 if (!strcmp(res->list_name, "reta")) { 2872 if (parse_reta_config(res->list_of_items, reta_conf, 2873 dev_info.reta_size)) { 2874 printf("Invalid RSS Redirection Table " 2875 "config entered\n"); 2876 return; 2877 } 2878 ret = rte_eth_dev_rss_reta_update(res->port_id, 2879 reta_conf, dev_info.reta_size); 2880 if (ret != 0) 2881 printf("Bad redirection table parameter, " 2882 "return code = %d \n", ret); 2883 } 2884 } 2885 2886 cmdline_parse_token_string_t cmd_config_rss_reta_port = 2887 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_reta, port, "port"); 2888 cmdline_parse_token_string_t cmd_config_rss_reta_keyword = 2889 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_reta, keyword, "config"); 2890 cmdline_parse_token_num_t cmd_config_rss_reta_port_id = 2891 TOKEN_NUM_INITIALIZER(struct cmd_config_rss_reta, port_id, UINT16); 2892 cmdline_parse_token_string_t cmd_config_rss_reta_name = 2893 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_reta, name, "rss"); 2894 cmdline_parse_token_string_t cmd_config_rss_reta_list_name = 2895 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_reta, list_name, "reta"); 2896 cmdline_parse_token_string_t cmd_config_rss_reta_list_of_items = 2897 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_reta, list_of_items, 2898 NULL); 2899 cmdline_parse_inst_t cmd_config_rss_reta = { 2900 .f = cmd_set_rss_reta_parsed, 2901 .data = NULL, 2902 .help_str = "port config <port_id> rss reta <hash,queue[,hash,queue]*>", 2903 .tokens = { 2904 (void *)&cmd_config_rss_reta_port, 2905 (void *)&cmd_config_rss_reta_keyword, 2906 (void *)&cmd_config_rss_reta_port_id, 2907 (void *)&cmd_config_rss_reta_name, 2908 (void *)&cmd_config_rss_reta_list_name, 2909 (void *)&cmd_config_rss_reta_list_of_items, 2910 NULL, 2911 }, 2912 }; 2913 2914 /* *** SHOW PORT RETA INFO *** */ 2915 struct cmd_showport_reta { 2916 cmdline_fixed_string_t show; 2917 cmdline_fixed_string_t port; 2918 portid_t port_id; 2919 cmdline_fixed_string_t rss; 2920 cmdline_fixed_string_t reta; 2921 uint16_t size; 2922 cmdline_fixed_string_t list_of_items; 2923 }; 2924 2925 static int 2926 showport_parse_reta_config(struct rte_eth_rss_reta_entry64 *conf, 2927 uint16_t nb_entries, 2928 char *str) 2929 { 2930 uint32_t size; 2931 const char *p, *p0 = str; 2932 char s[256]; 2933 char *end; 2934 char *str_fld[8]; 2935 uint16_t i; 2936 uint16_t num = (nb_entries + RTE_RETA_GROUP_SIZE - 1) / 2937 RTE_RETA_GROUP_SIZE; 2938 int ret; 2939 2940 p = strchr(p0, '('); 2941 if (p == NULL) 2942 return -1; 2943 p++; 2944 p0 = strchr(p, ')'); 2945 if (p0 == NULL) 2946 return -1; 2947 size = p0 - p; 2948 if (size >= sizeof(s)) { 2949 printf("The string size exceeds the internal buffer size\n"); 2950 return -1; 2951 } 2952 snprintf(s, sizeof(s), "%.*s", size, p); 2953 ret = rte_strsplit(s, sizeof(s), str_fld, num, ','); 2954 if (ret <= 0 || ret != num) { 2955 printf("The bits of masks do not match the number of " 2956 "reta entries: %u\n", num); 2957 return -1; 2958 } 2959 for (i = 0; i < ret; i++) 2960 conf[i].mask = (uint64_t)strtoul(str_fld[i], &end, 0); 2961 2962 return 0; 2963 } 2964 2965 static void 2966 cmd_showport_reta_parsed(void *parsed_result, 2967 __attribute__((unused)) struct cmdline *cl, 2968 __attribute__((unused)) void *data) 2969 { 2970 struct cmd_showport_reta *res = parsed_result; 2971 struct rte_eth_rss_reta_entry64 reta_conf[8]; 2972 struct rte_eth_dev_info dev_info; 2973 uint16_t max_reta_size; 2974 2975 memset(&dev_info, 0, sizeof(dev_info)); 2976 rte_eth_dev_info_get(res->port_id, &dev_info); 2977 max_reta_size = RTE_MIN(dev_info.reta_size, ETH_RSS_RETA_SIZE_512); 2978 if (res->size == 0 || res->size > max_reta_size) { 2979 printf("Invalid redirection table size: %u (1-%u)\n", 2980 res->size, max_reta_size); 2981 return; 2982 } 2983 2984 memset(reta_conf, 0, sizeof(reta_conf)); 2985 if (showport_parse_reta_config(reta_conf, res->size, 2986 res->list_of_items) < 0) { 2987 printf("Invalid string: %s for reta masks\n", 2988 res->list_of_items); 2989 return; 2990 } 2991 port_rss_reta_info(res->port_id, reta_conf, res->size); 2992 } 2993 2994 cmdline_parse_token_string_t cmd_showport_reta_show = 2995 TOKEN_STRING_INITIALIZER(struct cmd_showport_reta, show, "show"); 2996 cmdline_parse_token_string_t cmd_showport_reta_port = 2997 TOKEN_STRING_INITIALIZER(struct cmd_showport_reta, port, "port"); 2998 cmdline_parse_token_num_t cmd_showport_reta_port_id = 2999 TOKEN_NUM_INITIALIZER(struct cmd_showport_reta, port_id, UINT16); 3000 cmdline_parse_token_string_t cmd_showport_reta_rss = 3001 TOKEN_STRING_INITIALIZER(struct cmd_showport_reta, rss, "rss"); 3002 cmdline_parse_token_string_t cmd_showport_reta_reta = 3003 TOKEN_STRING_INITIALIZER(struct cmd_showport_reta, reta, "reta"); 3004 cmdline_parse_token_num_t cmd_showport_reta_size = 3005 TOKEN_NUM_INITIALIZER(struct cmd_showport_reta, size, UINT16); 3006 cmdline_parse_token_string_t cmd_showport_reta_list_of_items = 3007 TOKEN_STRING_INITIALIZER(struct cmd_showport_reta, 3008 list_of_items, NULL); 3009 3010 cmdline_parse_inst_t cmd_showport_reta = { 3011 .f = cmd_showport_reta_parsed, 3012 .data = NULL, 3013 .help_str = "show port <port_id> rss reta <size> <mask0[,mask1]*>", 3014 .tokens = { 3015 (void *)&cmd_showport_reta_show, 3016 (void *)&cmd_showport_reta_port, 3017 (void *)&cmd_showport_reta_port_id, 3018 (void *)&cmd_showport_reta_rss, 3019 (void *)&cmd_showport_reta_reta, 3020 (void *)&cmd_showport_reta_size, 3021 (void *)&cmd_showport_reta_list_of_items, 3022 NULL, 3023 }, 3024 }; 3025 3026 /* *** Show RSS hash configuration *** */ 3027 struct cmd_showport_rss_hash { 3028 cmdline_fixed_string_t show; 3029 cmdline_fixed_string_t port; 3030 portid_t port_id; 3031 cmdline_fixed_string_t rss_hash; 3032 cmdline_fixed_string_t rss_type; 3033 cmdline_fixed_string_t key; /* optional argument */ 3034 }; 3035 3036 static void cmd_showport_rss_hash_parsed(void *parsed_result, 3037 __attribute__((unused)) struct cmdline *cl, 3038 void *show_rss_key) 3039 { 3040 struct cmd_showport_rss_hash *res = parsed_result; 3041 3042 port_rss_hash_conf_show(res->port_id, show_rss_key != NULL); 3043 } 3044 3045 cmdline_parse_token_string_t cmd_showport_rss_hash_show = 3046 TOKEN_STRING_INITIALIZER(struct cmd_showport_rss_hash, show, "show"); 3047 cmdline_parse_token_string_t cmd_showport_rss_hash_port = 3048 TOKEN_STRING_INITIALIZER(struct cmd_showport_rss_hash, port, "port"); 3049 cmdline_parse_token_num_t cmd_showport_rss_hash_port_id = 3050 TOKEN_NUM_INITIALIZER(struct cmd_showport_rss_hash, port_id, UINT16); 3051 cmdline_parse_token_string_t cmd_showport_rss_hash_rss_hash = 3052 TOKEN_STRING_INITIALIZER(struct cmd_showport_rss_hash, rss_hash, 3053 "rss-hash"); 3054 cmdline_parse_token_string_t cmd_showport_rss_hash_rss_key = 3055 TOKEN_STRING_INITIALIZER(struct cmd_showport_rss_hash, key, "key"); 3056 3057 cmdline_parse_inst_t cmd_showport_rss_hash = { 3058 .f = cmd_showport_rss_hash_parsed, 3059 .data = NULL, 3060 .help_str = "show port <port_id> rss-hash", 3061 .tokens = { 3062 (void *)&cmd_showport_rss_hash_show, 3063 (void *)&cmd_showport_rss_hash_port, 3064 (void *)&cmd_showport_rss_hash_port_id, 3065 (void *)&cmd_showport_rss_hash_rss_hash, 3066 NULL, 3067 }, 3068 }; 3069 3070 cmdline_parse_inst_t cmd_showport_rss_hash_key = { 3071 .f = cmd_showport_rss_hash_parsed, 3072 .data = (void *)1, 3073 .help_str = "show port <port_id> rss-hash key", 3074 .tokens = { 3075 (void *)&cmd_showport_rss_hash_show, 3076 (void *)&cmd_showport_rss_hash_port, 3077 (void *)&cmd_showport_rss_hash_port_id, 3078 (void *)&cmd_showport_rss_hash_rss_hash, 3079 (void *)&cmd_showport_rss_hash_rss_key, 3080 NULL, 3081 }, 3082 }; 3083 3084 /* *** Configure DCB *** */ 3085 struct cmd_config_dcb { 3086 cmdline_fixed_string_t port; 3087 cmdline_fixed_string_t config; 3088 portid_t port_id; 3089 cmdline_fixed_string_t dcb; 3090 cmdline_fixed_string_t vt; 3091 cmdline_fixed_string_t vt_en; 3092 uint8_t num_tcs; 3093 cmdline_fixed_string_t pfc; 3094 cmdline_fixed_string_t pfc_en; 3095 }; 3096 3097 static void 3098 cmd_config_dcb_parsed(void *parsed_result, 3099 __attribute__((unused)) struct cmdline *cl, 3100 __attribute__((unused)) void *data) 3101 { 3102 struct cmd_config_dcb *res = parsed_result; 3103 portid_t port_id = res->port_id; 3104 struct rte_port *port; 3105 uint8_t pfc_en; 3106 int ret; 3107 3108 port = &ports[port_id]; 3109 /** Check if the port is not started **/ 3110 if (port->port_status != RTE_PORT_STOPPED) { 3111 printf("Please stop port %d first\n", port_id); 3112 return; 3113 } 3114 3115 if ((res->num_tcs != ETH_4_TCS) && (res->num_tcs != ETH_8_TCS)) { 3116 printf("The invalid number of traffic class," 3117 " only 4 or 8 allowed.\n"); 3118 return; 3119 } 3120 3121 if (nb_fwd_lcores < res->num_tcs) { 3122 printf("nb_cores shouldn't be less than number of TCs.\n"); 3123 return; 3124 } 3125 if (!strncmp(res->pfc_en, "on", 2)) 3126 pfc_en = 1; 3127 else 3128 pfc_en = 0; 3129 3130 /* DCB in VT mode */ 3131 if (!strncmp(res->vt_en, "on", 2)) 3132 ret = init_port_dcb_config(port_id, DCB_VT_ENABLED, 3133 (enum rte_eth_nb_tcs)res->num_tcs, 3134 pfc_en); 3135 else 3136 ret = init_port_dcb_config(port_id, DCB_ENABLED, 3137 (enum rte_eth_nb_tcs)res->num_tcs, 3138 pfc_en); 3139 3140 3141 if (ret != 0) { 3142 printf("Cannot initialize network ports.\n"); 3143 return; 3144 } 3145 3146 cmd_reconfig_device_queue(port_id, 1, 1); 3147 } 3148 3149 cmdline_parse_token_string_t cmd_config_dcb_port = 3150 TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, port, "port"); 3151 cmdline_parse_token_string_t cmd_config_dcb_config = 3152 TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, config, "config"); 3153 cmdline_parse_token_num_t cmd_config_dcb_port_id = 3154 TOKEN_NUM_INITIALIZER(struct cmd_config_dcb, port_id, UINT16); 3155 cmdline_parse_token_string_t cmd_config_dcb_dcb = 3156 TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, dcb, "dcb"); 3157 cmdline_parse_token_string_t cmd_config_dcb_vt = 3158 TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, vt, "vt"); 3159 cmdline_parse_token_string_t cmd_config_dcb_vt_en = 3160 TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, vt_en, "on#off"); 3161 cmdline_parse_token_num_t cmd_config_dcb_num_tcs = 3162 TOKEN_NUM_INITIALIZER(struct cmd_config_dcb, num_tcs, UINT8); 3163 cmdline_parse_token_string_t cmd_config_dcb_pfc= 3164 TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, pfc, "pfc"); 3165 cmdline_parse_token_string_t cmd_config_dcb_pfc_en = 3166 TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, pfc_en, "on#off"); 3167 3168 cmdline_parse_inst_t cmd_config_dcb = { 3169 .f = cmd_config_dcb_parsed, 3170 .data = NULL, 3171 .help_str = "port config <port-id> dcb vt on|off <num_tcs> pfc on|off", 3172 .tokens = { 3173 (void *)&cmd_config_dcb_port, 3174 (void *)&cmd_config_dcb_config, 3175 (void *)&cmd_config_dcb_port_id, 3176 (void *)&cmd_config_dcb_dcb, 3177 (void *)&cmd_config_dcb_vt, 3178 (void *)&cmd_config_dcb_vt_en, 3179 (void *)&cmd_config_dcb_num_tcs, 3180 (void *)&cmd_config_dcb_pfc, 3181 (void *)&cmd_config_dcb_pfc_en, 3182 NULL, 3183 }, 3184 }; 3185 3186 /* *** configure number of packets per burst *** */ 3187 struct cmd_config_burst { 3188 cmdline_fixed_string_t port; 3189 cmdline_fixed_string_t keyword; 3190 cmdline_fixed_string_t all; 3191 cmdline_fixed_string_t name; 3192 uint16_t value; 3193 }; 3194 3195 static void 3196 cmd_config_burst_parsed(void *parsed_result, 3197 __attribute__((unused)) struct cmdline *cl, 3198 __attribute__((unused)) void *data) 3199 { 3200 struct cmd_config_burst *res = parsed_result; 3201 struct rte_eth_dev_info dev_info; 3202 uint16_t rec_nb_pkts; 3203 3204 if (!all_ports_stopped()) { 3205 printf("Please stop all ports first\n"); 3206 return; 3207 } 3208 3209 if (!strcmp(res->name, "burst")) { 3210 if (res->value == 0) { 3211 /* If user gives a value of zero, query the PMD for 3212 * its recommended Rx burst size. Testpmd uses a single 3213 * size for all ports, so assume all ports are the same 3214 * NIC model and use the values from Port 0. 3215 */ 3216 rte_eth_dev_info_get(0, &dev_info); 3217 rec_nb_pkts = dev_info.default_rxportconf.burst_size; 3218 3219 if (rec_nb_pkts == 0) { 3220 printf("PMD does not recommend a burst size.\n" 3221 "User provided value must be between" 3222 " 1 and %d\n", MAX_PKT_BURST); 3223 return; 3224 } else if (rec_nb_pkts > MAX_PKT_BURST) { 3225 printf("PMD recommended burst size of %d" 3226 " exceeds maximum value of %d\n", 3227 rec_nb_pkts, MAX_PKT_BURST); 3228 return; 3229 } 3230 printf("Using PMD-provided burst value of %d\n", 3231 rec_nb_pkts); 3232 nb_pkt_per_burst = rec_nb_pkts; 3233 } else if (res->value > MAX_PKT_BURST) { 3234 printf("burst must be >= 1 && <= %d\n", MAX_PKT_BURST); 3235 return; 3236 } else 3237 nb_pkt_per_burst = res->value; 3238 } else { 3239 printf("Unknown parameter\n"); 3240 return; 3241 } 3242 3243 init_port_config(); 3244 3245 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1); 3246 } 3247 3248 cmdline_parse_token_string_t cmd_config_burst_port = 3249 TOKEN_STRING_INITIALIZER(struct cmd_config_burst, port, "port"); 3250 cmdline_parse_token_string_t cmd_config_burst_keyword = 3251 TOKEN_STRING_INITIALIZER(struct cmd_config_burst, keyword, "config"); 3252 cmdline_parse_token_string_t cmd_config_burst_all = 3253 TOKEN_STRING_INITIALIZER(struct cmd_config_burst, all, "all"); 3254 cmdline_parse_token_string_t cmd_config_burst_name = 3255 TOKEN_STRING_INITIALIZER(struct cmd_config_burst, name, "burst"); 3256 cmdline_parse_token_num_t cmd_config_burst_value = 3257 TOKEN_NUM_INITIALIZER(struct cmd_config_burst, value, UINT16); 3258 3259 cmdline_parse_inst_t cmd_config_burst = { 3260 .f = cmd_config_burst_parsed, 3261 .data = NULL, 3262 .help_str = "port config all burst <value>", 3263 .tokens = { 3264 (void *)&cmd_config_burst_port, 3265 (void *)&cmd_config_burst_keyword, 3266 (void *)&cmd_config_burst_all, 3267 (void *)&cmd_config_burst_name, 3268 (void *)&cmd_config_burst_value, 3269 NULL, 3270 }, 3271 }; 3272 3273 /* *** configure rx/tx queues *** */ 3274 struct cmd_config_thresh { 3275 cmdline_fixed_string_t port; 3276 cmdline_fixed_string_t keyword; 3277 cmdline_fixed_string_t all; 3278 cmdline_fixed_string_t name; 3279 uint8_t value; 3280 }; 3281 3282 static void 3283 cmd_config_thresh_parsed(void *parsed_result, 3284 __attribute__((unused)) struct cmdline *cl, 3285 __attribute__((unused)) void *data) 3286 { 3287 struct cmd_config_thresh *res = parsed_result; 3288 3289 if (!all_ports_stopped()) { 3290 printf("Please stop all ports first\n"); 3291 return; 3292 } 3293 3294 if (!strcmp(res->name, "txpt")) 3295 tx_pthresh = res->value; 3296 else if(!strcmp(res->name, "txht")) 3297 tx_hthresh = res->value; 3298 else if(!strcmp(res->name, "txwt")) 3299 tx_wthresh = res->value; 3300 else if(!strcmp(res->name, "rxpt")) 3301 rx_pthresh = res->value; 3302 else if(!strcmp(res->name, "rxht")) 3303 rx_hthresh = res->value; 3304 else if(!strcmp(res->name, "rxwt")) 3305 rx_wthresh = res->value; 3306 else { 3307 printf("Unknown parameter\n"); 3308 return; 3309 } 3310 3311 init_port_config(); 3312 3313 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1); 3314 } 3315 3316 cmdline_parse_token_string_t cmd_config_thresh_port = 3317 TOKEN_STRING_INITIALIZER(struct cmd_config_thresh, port, "port"); 3318 cmdline_parse_token_string_t cmd_config_thresh_keyword = 3319 TOKEN_STRING_INITIALIZER(struct cmd_config_thresh, keyword, "config"); 3320 cmdline_parse_token_string_t cmd_config_thresh_all = 3321 TOKEN_STRING_INITIALIZER(struct cmd_config_thresh, all, "all"); 3322 cmdline_parse_token_string_t cmd_config_thresh_name = 3323 TOKEN_STRING_INITIALIZER(struct cmd_config_thresh, name, 3324 "txpt#txht#txwt#rxpt#rxht#rxwt"); 3325 cmdline_parse_token_num_t cmd_config_thresh_value = 3326 TOKEN_NUM_INITIALIZER(struct cmd_config_thresh, value, UINT8); 3327 3328 cmdline_parse_inst_t cmd_config_thresh = { 3329 .f = cmd_config_thresh_parsed, 3330 .data = NULL, 3331 .help_str = "port config all txpt|txht|txwt|rxpt|rxht|rxwt <value>", 3332 .tokens = { 3333 (void *)&cmd_config_thresh_port, 3334 (void *)&cmd_config_thresh_keyword, 3335 (void *)&cmd_config_thresh_all, 3336 (void *)&cmd_config_thresh_name, 3337 (void *)&cmd_config_thresh_value, 3338 NULL, 3339 }, 3340 }; 3341 3342 /* *** configure free/rs threshold *** */ 3343 struct cmd_config_threshold { 3344 cmdline_fixed_string_t port; 3345 cmdline_fixed_string_t keyword; 3346 cmdline_fixed_string_t all; 3347 cmdline_fixed_string_t name; 3348 uint16_t value; 3349 }; 3350 3351 static void 3352 cmd_config_threshold_parsed(void *parsed_result, 3353 __attribute__((unused)) struct cmdline *cl, 3354 __attribute__((unused)) void *data) 3355 { 3356 struct cmd_config_threshold *res = parsed_result; 3357 3358 if (!all_ports_stopped()) { 3359 printf("Please stop all ports first\n"); 3360 return; 3361 } 3362 3363 if (!strcmp(res->name, "txfreet")) 3364 tx_free_thresh = res->value; 3365 else if (!strcmp(res->name, "txrst")) 3366 tx_rs_thresh = res->value; 3367 else if (!strcmp(res->name, "rxfreet")) 3368 rx_free_thresh = res->value; 3369 else { 3370 printf("Unknown parameter\n"); 3371 return; 3372 } 3373 3374 init_port_config(); 3375 3376 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1); 3377 } 3378 3379 cmdline_parse_token_string_t cmd_config_threshold_port = 3380 TOKEN_STRING_INITIALIZER(struct cmd_config_threshold, port, "port"); 3381 cmdline_parse_token_string_t cmd_config_threshold_keyword = 3382 TOKEN_STRING_INITIALIZER(struct cmd_config_threshold, keyword, 3383 "config"); 3384 cmdline_parse_token_string_t cmd_config_threshold_all = 3385 TOKEN_STRING_INITIALIZER(struct cmd_config_threshold, all, "all"); 3386 cmdline_parse_token_string_t cmd_config_threshold_name = 3387 TOKEN_STRING_INITIALIZER(struct cmd_config_threshold, name, 3388 "txfreet#txrst#rxfreet"); 3389 cmdline_parse_token_num_t cmd_config_threshold_value = 3390 TOKEN_NUM_INITIALIZER(struct cmd_config_threshold, value, UINT16); 3391 3392 cmdline_parse_inst_t cmd_config_threshold = { 3393 .f = cmd_config_threshold_parsed, 3394 .data = NULL, 3395 .help_str = "port config all txfreet|txrst|rxfreet <value>", 3396 .tokens = { 3397 (void *)&cmd_config_threshold_port, 3398 (void *)&cmd_config_threshold_keyword, 3399 (void *)&cmd_config_threshold_all, 3400 (void *)&cmd_config_threshold_name, 3401 (void *)&cmd_config_threshold_value, 3402 NULL, 3403 }, 3404 }; 3405 3406 /* *** stop *** */ 3407 struct cmd_stop_result { 3408 cmdline_fixed_string_t stop; 3409 }; 3410 3411 static void cmd_stop_parsed(__attribute__((unused)) void *parsed_result, 3412 __attribute__((unused)) struct cmdline *cl, 3413 __attribute__((unused)) void *data) 3414 { 3415 stop_packet_forwarding(); 3416 } 3417 3418 cmdline_parse_token_string_t cmd_stop_stop = 3419 TOKEN_STRING_INITIALIZER(struct cmd_stop_result, stop, "stop"); 3420 3421 cmdline_parse_inst_t cmd_stop = { 3422 .f = cmd_stop_parsed, 3423 .data = NULL, 3424 .help_str = "stop: Stop packet forwarding", 3425 .tokens = { 3426 (void *)&cmd_stop_stop, 3427 NULL, 3428 }, 3429 }; 3430 3431 /* *** SET CORELIST and PORTLIST CONFIGURATION *** */ 3432 3433 unsigned int 3434 parse_item_list(char* str, const char* item_name, unsigned int max_items, 3435 unsigned int *parsed_items, int check_unique_values) 3436 { 3437 unsigned int nb_item; 3438 unsigned int value; 3439 unsigned int i; 3440 unsigned int j; 3441 int value_ok; 3442 char c; 3443 3444 /* 3445 * First parse all items in the list and store their value. 3446 */ 3447 value = 0; 3448 nb_item = 0; 3449 value_ok = 0; 3450 for (i = 0; i < strnlen(str, STR_TOKEN_SIZE); i++) { 3451 c = str[i]; 3452 if ((c >= '0') && (c <= '9')) { 3453 value = (unsigned int) (value * 10 + (c - '0')); 3454 value_ok = 1; 3455 continue; 3456 } 3457 if (c != ',') { 3458 printf("character %c is not a decimal digit\n", c); 3459 return 0; 3460 } 3461 if (! value_ok) { 3462 printf("No valid value before comma\n"); 3463 return 0; 3464 } 3465 if (nb_item < max_items) { 3466 parsed_items[nb_item] = value; 3467 value_ok = 0; 3468 value = 0; 3469 } 3470 nb_item++; 3471 } 3472 if (nb_item >= max_items) { 3473 printf("Number of %s = %u > %u (maximum items)\n", 3474 item_name, nb_item + 1, max_items); 3475 return 0; 3476 } 3477 parsed_items[nb_item++] = value; 3478 if (! check_unique_values) 3479 return nb_item; 3480 3481 /* 3482 * Then, check that all values in the list are differents. 3483 * No optimization here... 3484 */ 3485 for (i = 0; i < nb_item; i++) { 3486 for (j = i + 1; j < nb_item; j++) { 3487 if (parsed_items[j] == parsed_items[i]) { 3488 printf("duplicated %s %u at index %u and %u\n", 3489 item_name, parsed_items[i], i, j); 3490 return 0; 3491 } 3492 } 3493 } 3494 return nb_item; 3495 } 3496 3497 struct cmd_set_list_result { 3498 cmdline_fixed_string_t cmd_keyword; 3499 cmdline_fixed_string_t list_name; 3500 cmdline_fixed_string_t list_of_items; 3501 }; 3502 3503 static void cmd_set_list_parsed(void *parsed_result, 3504 __attribute__((unused)) struct cmdline *cl, 3505 __attribute__((unused)) void *data) 3506 { 3507 struct cmd_set_list_result *res; 3508 union { 3509 unsigned int lcorelist[RTE_MAX_LCORE]; 3510 unsigned int portlist[RTE_MAX_ETHPORTS]; 3511 } parsed_items; 3512 unsigned int nb_item; 3513 3514 if (test_done == 0) { 3515 printf("Please stop forwarding first\n"); 3516 return; 3517 } 3518 3519 res = parsed_result; 3520 if (!strcmp(res->list_name, "corelist")) { 3521 nb_item = parse_item_list(res->list_of_items, "core", 3522 RTE_MAX_LCORE, 3523 parsed_items.lcorelist, 1); 3524 if (nb_item > 0) { 3525 set_fwd_lcores_list(parsed_items.lcorelist, nb_item); 3526 fwd_config_setup(); 3527 } 3528 return; 3529 } 3530 if (!strcmp(res->list_name, "portlist")) { 3531 nb_item = parse_item_list(res->list_of_items, "port", 3532 RTE_MAX_ETHPORTS, 3533 parsed_items.portlist, 1); 3534 if (nb_item > 0) { 3535 set_fwd_ports_list(parsed_items.portlist, nb_item); 3536 fwd_config_setup(); 3537 } 3538 } 3539 } 3540 3541 cmdline_parse_token_string_t cmd_set_list_keyword = 3542 TOKEN_STRING_INITIALIZER(struct cmd_set_list_result, cmd_keyword, 3543 "set"); 3544 cmdline_parse_token_string_t cmd_set_list_name = 3545 TOKEN_STRING_INITIALIZER(struct cmd_set_list_result, list_name, 3546 "corelist#portlist"); 3547 cmdline_parse_token_string_t cmd_set_list_of_items = 3548 TOKEN_STRING_INITIALIZER(struct cmd_set_list_result, list_of_items, 3549 NULL); 3550 3551 cmdline_parse_inst_t cmd_set_fwd_list = { 3552 .f = cmd_set_list_parsed, 3553 .data = NULL, 3554 .help_str = "set corelist|portlist <list0[,list1]*>", 3555 .tokens = { 3556 (void *)&cmd_set_list_keyword, 3557 (void *)&cmd_set_list_name, 3558 (void *)&cmd_set_list_of_items, 3559 NULL, 3560 }, 3561 }; 3562 3563 /* *** SET COREMASK and PORTMASK CONFIGURATION *** */ 3564 3565 struct cmd_setmask_result { 3566 cmdline_fixed_string_t set; 3567 cmdline_fixed_string_t mask; 3568 uint64_t hexavalue; 3569 }; 3570 3571 static void cmd_set_mask_parsed(void *parsed_result, 3572 __attribute__((unused)) struct cmdline *cl, 3573 __attribute__((unused)) void *data) 3574 { 3575 struct cmd_setmask_result *res = parsed_result; 3576 3577 if (test_done == 0) { 3578 printf("Please stop forwarding first\n"); 3579 return; 3580 } 3581 if (!strcmp(res->mask, "coremask")) { 3582 set_fwd_lcores_mask(res->hexavalue); 3583 fwd_config_setup(); 3584 } else if (!strcmp(res->mask, "portmask")) { 3585 set_fwd_ports_mask(res->hexavalue); 3586 fwd_config_setup(); 3587 } 3588 } 3589 3590 cmdline_parse_token_string_t cmd_setmask_set = 3591 TOKEN_STRING_INITIALIZER(struct cmd_setmask_result, set, "set"); 3592 cmdline_parse_token_string_t cmd_setmask_mask = 3593 TOKEN_STRING_INITIALIZER(struct cmd_setmask_result, mask, 3594 "coremask#portmask"); 3595 cmdline_parse_token_num_t cmd_setmask_value = 3596 TOKEN_NUM_INITIALIZER(struct cmd_setmask_result, hexavalue, UINT64); 3597 3598 cmdline_parse_inst_t cmd_set_fwd_mask = { 3599 .f = cmd_set_mask_parsed, 3600 .data = NULL, 3601 .help_str = "set coremask|portmask <hexadecimal value>", 3602 .tokens = { 3603 (void *)&cmd_setmask_set, 3604 (void *)&cmd_setmask_mask, 3605 (void *)&cmd_setmask_value, 3606 NULL, 3607 }, 3608 }; 3609 3610 /* 3611 * SET NBPORT, NBCORE, PACKET BURST, and VERBOSE LEVEL CONFIGURATION 3612 */ 3613 struct cmd_set_result { 3614 cmdline_fixed_string_t set; 3615 cmdline_fixed_string_t what; 3616 uint16_t value; 3617 }; 3618 3619 static void cmd_set_parsed(void *parsed_result, 3620 __attribute__((unused)) struct cmdline *cl, 3621 __attribute__((unused)) void *data) 3622 { 3623 struct cmd_set_result *res = parsed_result; 3624 if (!strcmp(res->what, "nbport")) { 3625 set_fwd_ports_number(res->value); 3626 fwd_config_setup(); 3627 } else if (!strcmp(res->what, "nbcore")) { 3628 set_fwd_lcores_number(res->value); 3629 fwd_config_setup(); 3630 } else if (!strcmp(res->what, "burst")) 3631 set_nb_pkt_per_burst(res->value); 3632 else if (!strcmp(res->what, "verbose")) 3633 set_verbose_level(res->value); 3634 } 3635 3636 cmdline_parse_token_string_t cmd_set_set = 3637 TOKEN_STRING_INITIALIZER(struct cmd_set_result, set, "set"); 3638 cmdline_parse_token_string_t cmd_set_what = 3639 TOKEN_STRING_INITIALIZER(struct cmd_set_result, what, 3640 "nbport#nbcore#burst#verbose"); 3641 cmdline_parse_token_num_t cmd_set_value = 3642 TOKEN_NUM_INITIALIZER(struct cmd_set_result, value, UINT16); 3643 3644 cmdline_parse_inst_t cmd_set_numbers = { 3645 .f = cmd_set_parsed, 3646 .data = NULL, 3647 .help_str = "set nbport|nbcore|burst|verbose <value>", 3648 .tokens = { 3649 (void *)&cmd_set_set, 3650 (void *)&cmd_set_what, 3651 (void *)&cmd_set_value, 3652 NULL, 3653 }, 3654 }; 3655 3656 /* *** SET LOG LEVEL CONFIGURATION *** */ 3657 3658 struct cmd_set_log_result { 3659 cmdline_fixed_string_t set; 3660 cmdline_fixed_string_t log; 3661 cmdline_fixed_string_t type; 3662 uint32_t level; 3663 }; 3664 3665 static void 3666 cmd_set_log_parsed(void *parsed_result, 3667 __attribute__((unused)) struct cmdline *cl, 3668 __attribute__((unused)) void *data) 3669 { 3670 struct cmd_set_log_result *res; 3671 int ret; 3672 3673 res = parsed_result; 3674 if (!strcmp(res->type, "global")) 3675 rte_log_set_global_level(res->level); 3676 else { 3677 ret = rte_log_set_level_regexp(res->type, res->level); 3678 if (ret < 0) 3679 printf("Unable to set log level\n"); 3680 } 3681 } 3682 3683 cmdline_parse_token_string_t cmd_set_log_set = 3684 TOKEN_STRING_INITIALIZER(struct cmd_set_log_result, set, "set"); 3685 cmdline_parse_token_string_t cmd_set_log_log = 3686 TOKEN_STRING_INITIALIZER(struct cmd_set_log_result, log, "log"); 3687 cmdline_parse_token_string_t cmd_set_log_type = 3688 TOKEN_STRING_INITIALIZER(struct cmd_set_log_result, type, NULL); 3689 cmdline_parse_token_num_t cmd_set_log_level = 3690 TOKEN_NUM_INITIALIZER(struct cmd_set_log_result, level, UINT32); 3691 3692 cmdline_parse_inst_t cmd_set_log = { 3693 .f = cmd_set_log_parsed, 3694 .data = NULL, 3695 .help_str = "set log global|<type> <level>", 3696 .tokens = { 3697 (void *)&cmd_set_log_set, 3698 (void *)&cmd_set_log_log, 3699 (void *)&cmd_set_log_type, 3700 (void *)&cmd_set_log_level, 3701 NULL, 3702 }, 3703 }; 3704 3705 /* *** SET SEGMENT LENGTHS OF TXONLY PACKETS *** */ 3706 3707 struct cmd_set_txpkts_result { 3708 cmdline_fixed_string_t cmd_keyword; 3709 cmdline_fixed_string_t txpkts; 3710 cmdline_fixed_string_t seg_lengths; 3711 }; 3712 3713 static void 3714 cmd_set_txpkts_parsed(void *parsed_result, 3715 __attribute__((unused)) struct cmdline *cl, 3716 __attribute__((unused)) void *data) 3717 { 3718 struct cmd_set_txpkts_result *res; 3719 unsigned seg_lengths[RTE_MAX_SEGS_PER_PKT]; 3720 unsigned int nb_segs; 3721 3722 res = parsed_result; 3723 nb_segs = parse_item_list(res->seg_lengths, "segment lengths", 3724 RTE_MAX_SEGS_PER_PKT, seg_lengths, 0); 3725 if (nb_segs > 0) 3726 set_tx_pkt_segments(seg_lengths, nb_segs); 3727 } 3728 3729 cmdline_parse_token_string_t cmd_set_txpkts_keyword = 3730 TOKEN_STRING_INITIALIZER(struct cmd_set_txpkts_result, 3731 cmd_keyword, "set"); 3732 cmdline_parse_token_string_t cmd_set_txpkts_name = 3733 TOKEN_STRING_INITIALIZER(struct cmd_set_txpkts_result, 3734 txpkts, "txpkts"); 3735 cmdline_parse_token_string_t cmd_set_txpkts_lengths = 3736 TOKEN_STRING_INITIALIZER(struct cmd_set_txpkts_result, 3737 seg_lengths, NULL); 3738 3739 cmdline_parse_inst_t cmd_set_txpkts = { 3740 .f = cmd_set_txpkts_parsed, 3741 .data = NULL, 3742 .help_str = "set txpkts <len0[,len1]*>", 3743 .tokens = { 3744 (void *)&cmd_set_txpkts_keyword, 3745 (void *)&cmd_set_txpkts_name, 3746 (void *)&cmd_set_txpkts_lengths, 3747 NULL, 3748 }, 3749 }; 3750 3751 /* *** SET COPY AND SPLIT POLICY ON TX PACKETS *** */ 3752 3753 struct cmd_set_txsplit_result { 3754 cmdline_fixed_string_t cmd_keyword; 3755 cmdline_fixed_string_t txsplit; 3756 cmdline_fixed_string_t mode; 3757 }; 3758 3759 static void 3760 cmd_set_txsplit_parsed(void *parsed_result, 3761 __attribute__((unused)) struct cmdline *cl, 3762 __attribute__((unused)) void *data) 3763 { 3764 struct cmd_set_txsplit_result *res; 3765 3766 res = parsed_result; 3767 set_tx_pkt_split(res->mode); 3768 } 3769 3770 cmdline_parse_token_string_t cmd_set_txsplit_keyword = 3771 TOKEN_STRING_INITIALIZER(struct cmd_set_txsplit_result, 3772 cmd_keyword, "set"); 3773 cmdline_parse_token_string_t cmd_set_txsplit_name = 3774 TOKEN_STRING_INITIALIZER(struct cmd_set_txsplit_result, 3775 txsplit, "txsplit"); 3776 cmdline_parse_token_string_t cmd_set_txsplit_mode = 3777 TOKEN_STRING_INITIALIZER(struct cmd_set_txsplit_result, 3778 mode, NULL); 3779 3780 cmdline_parse_inst_t cmd_set_txsplit = { 3781 .f = cmd_set_txsplit_parsed, 3782 .data = NULL, 3783 .help_str = "set txsplit on|off|rand", 3784 .tokens = { 3785 (void *)&cmd_set_txsplit_keyword, 3786 (void *)&cmd_set_txsplit_name, 3787 (void *)&cmd_set_txsplit_mode, 3788 NULL, 3789 }, 3790 }; 3791 3792 /* *** ADD/REMOVE ALL VLAN IDENTIFIERS TO/FROM A PORT VLAN RX FILTER *** */ 3793 struct cmd_rx_vlan_filter_all_result { 3794 cmdline_fixed_string_t rx_vlan; 3795 cmdline_fixed_string_t what; 3796 cmdline_fixed_string_t all; 3797 portid_t port_id; 3798 }; 3799 3800 static void 3801 cmd_rx_vlan_filter_all_parsed(void *parsed_result, 3802 __attribute__((unused)) struct cmdline *cl, 3803 __attribute__((unused)) void *data) 3804 { 3805 struct cmd_rx_vlan_filter_all_result *res = parsed_result; 3806 3807 if (!strcmp(res->what, "add")) 3808 rx_vlan_all_filter_set(res->port_id, 1); 3809 else 3810 rx_vlan_all_filter_set(res->port_id, 0); 3811 } 3812 3813 cmdline_parse_token_string_t cmd_rx_vlan_filter_all_rx_vlan = 3814 TOKEN_STRING_INITIALIZER(struct cmd_rx_vlan_filter_all_result, 3815 rx_vlan, "rx_vlan"); 3816 cmdline_parse_token_string_t cmd_rx_vlan_filter_all_what = 3817 TOKEN_STRING_INITIALIZER(struct cmd_rx_vlan_filter_all_result, 3818 what, "add#rm"); 3819 cmdline_parse_token_string_t cmd_rx_vlan_filter_all_all = 3820 TOKEN_STRING_INITIALIZER(struct cmd_rx_vlan_filter_all_result, 3821 all, "all"); 3822 cmdline_parse_token_num_t cmd_rx_vlan_filter_all_portid = 3823 TOKEN_NUM_INITIALIZER(struct cmd_rx_vlan_filter_all_result, 3824 port_id, UINT16); 3825 3826 cmdline_parse_inst_t cmd_rx_vlan_filter_all = { 3827 .f = cmd_rx_vlan_filter_all_parsed, 3828 .data = NULL, 3829 .help_str = "rx_vlan add|rm all <port_id>: " 3830 "Add/Remove all identifiers to/from the set of VLAN " 3831 "identifiers filtered by a port", 3832 .tokens = { 3833 (void *)&cmd_rx_vlan_filter_all_rx_vlan, 3834 (void *)&cmd_rx_vlan_filter_all_what, 3835 (void *)&cmd_rx_vlan_filter_all_all, 3836 (void *)&cmd_rx_vlan_filter_all_portid, 3837 NULL, 3838 }, 3839 }; 3840 3841 /* *** VLAN OFFLOAD SET ON A PORT *** */ 3842 struct cmd_vlan_offload_result { 3843 cmdline_fixed_string_t vlan; 3844 cmdline_fixed_string_t set; 3845 cmdline_fixed_string_t vlan_type; 3846 cmdline_fixed_string_t what; 3847 cmdline_fixed_string_t on; 3848 cmdline_fixed_string_t port_id; 3849 }; 3850 3851 static void 3852 cmd_vlan_offload_parsed(void *parsed_result, 3853 __attribute__((unused)) struct cmdline *cl, 3854 __attribute__((unused)) void *data) 3855 { 3856 int on; 3857 struct cmd_vlan_offload_result *res = parsed_result; 3858 char *str; 3859 int i, len = 0; 3860 portid_t port_id = 0; 3861 unsigned int tmp; 3862 3863 str = res->port_id; 3864 len = strnlen(str, STR_TOKEN_SIZE); 3865 i = 0; 3866 /* Get port_id first */ 3867 while(i < len){ 3868 if(str[i] == ',') 3869 break; 3870 3871 i++; 3872 } 3873 str[i]='\0'; 3874 tmp = strtoul(str, NULL, 0); 3875 /* If port_id greater that what portid_t can represent, return */ 3876 if(tmp >= RTE_MAX_ETHPORTS) 3877 return; 3878 port_id = (portid_t)tmp; 3879 3880 if (!strcmp(res->on, "on")) 3881 on = 1; 3882 else 3883 on = 0; 3884 3885 if (!strcmp(res->what, "strip")) 3886 rx_vlan_strip_set(port_id, on); 3887 else if(!strcmp(res->what, "stripq")){ 3888 uint16_t queue_id = 0; 3889 3890 /* No queue_id, return */ 3891 if(i + 1 >= len) { 3892 printf("must specify (port,queue_id)\n"); 3893 return; 3894 } 3895 tmp = strtoul(str + i + 1, NULL, 0); 3896 /* If queue_id greater that what 16-bits can represent, return */ 3897 if(tmp > 0xffff) 3898 return; 3899 3900 queue_id = (uint16_t)tmp; 3901 rx_vlan_strip_set_on_queue(port_id, queue_id, on); 3902 } 3903 else if (!strcmp(res->what, "filter")) 3904 rx_vlan_filter_set(port_id, on); 3905 else 3906 vlan_extend_set(port_id, on); 3907 3908 return; 3909 } 3910 3911 cmdline_parse_token_string_t cmd_vlan_offload_vlan = 3912 TOKEN_STRING_INITIALIZER(struct cmd_vlan_offload_result, 3913 vlan, "vlan"); 3914 cmdline_parse_token_string_t cmd_vlan_offload_set = 3915 TOKEN_STRING_INITIALIZER(struct cmd_vlan_offload_result, 3916 set, "set"); 3917 cmdline_parse_token_string_t cmd_vlan_offload_what = 3918 TOKEN_STRING_INITIALIZER(struct cmd_vlan_offload_result, 3919 what, "strip#filter#qinq#stripq"); 3920 cmdline_parse_token_string_t cmd_vlan_offload_on = 3921 TOKEN_STRING_INITIALIZER(struct cmd_vlan_offload_result, 3922 on, "on#off"); 3923 cmdline_parse_token_string_t cmd_vlan_offload_portid = 3924 TOKEN_STRING_INITIALIZER(struct cmd_vlan_offload_result, 3925 port_id, NULL); 3926 3927 cmdline_parse_inst_t cmd_vlan_offload = { 3928 .f = cmd_vlan_offload_parsed, 3929 .data = NULL, 3930 .help_str = "vlan set strip|filter|qinq|stripq on|off " 3931 "<port_id[,queue_id]>: " 3932 "Filter/Strip for rx side qinq(extended) for both rx/tx sides", 3933 .tokens = { 3934 (void *)&cmd_vlan_offload_vlan, 3935 (void *)&cmd_vlan_offload_set, 3936 (void *)&cmd_vlan_offload_what, 3937 (void *)&cmd_vlan_offload_on, 3938 (void *)&cmd_vlan_offload_portid, 3939 NULL, 3940 }, 3941 }; 3942 3943 /* *** VLAN TPID SET ON A PORT *** */ 3944 struct cmd_vlan_tpid_result { 3945 cmdline_fixed_string_t vlan; 3946 cmdline_fixed_string_t set; 3947 cmdline_fixed_string_t vlan_type; 3948 cmdline_fixed_string_t what; 3949 uint16_t tp_id; 3950 portid_t port_id; 3951 }; 3952 3953 static void 3954 cmd_vlan_tpid_parsed(void *parsed_result, 3955 __attribute__((unused)) struct cmdline *cl, 3956 __attribute__((unused)) void *data) 3957 { 3958 struct cmd_vlan_tpid_result *res = parsed_result; 3959 enum rte_vlan_type vlan_type; 3960 3961 if (!strcmp(res->vlan_type, "inner")) 3962 vlan_type = ETH_VLAN_TYPE_INNER; 3963 else if (!strcmp(res->vlan_type, "outer")) 3964 vlan_type = ETH_VLAN_TYPE_OUTER; 3965 else { 3966 printf("Unknown vlan type\n"); 3967 return; 3968 } 3969 vlan_tpid_set(res->port_id, vlan_type, res->tp_id); 3970 } 3971 3972 cmdline_parse_token_string_t cmd_vlan_tpid_vlan = 3973 TOKEN_STRING_INITIALIZER(struct cmd_vlan_tpid_result, 3974 vlan, "vlan"); 3975 cmdline_parse_token_string_t cmd_vlan_tpid_set = 3976 TOKEN_STRING_INITIALIZER(struct cmd_vlan_tpid_result, 3977 set, "set"); 3978 cmdline_parse_token_string_t cmd_vlan_type = 3979 TOKEN_STRING_INITIALIZER(struct cmd_vlan_tpid_result, 3980 vlan_type, "inner#outer"); 3981 cmdline_parse_token_string_t cmd_vlan_tpid_what = 3982 TOKEN_STRING_INITIALIZER(struct cmd_vlan_tpid_result, 3983 what, "tpid"); 3984 cmdline_parse_token_num_t cmd_vlan_tpid_tpid = 3985 TOKEN_NUM_INITIALIZER(struct cmd_vlan_tpid_result, 3986 tp_id, UINT16); 3987 cmdline_parse_token_num_t cmd_vlan_tpid_portid = 3988 TOKEN_NUM_INITIALIZER(struct cmd_vlan_tpid_result, 3989 port_id, UINT16); 3990 3991 cmdline_parse_inst_t cmd_vlan_tpid = { 3992 .f = cmd_vlan_tpid_parsed, 3993 .data = NULL, 3994 .help_str = "vlan set inner|outer tpid <tp_id> <port_id>: " 3995 "Set the VLAN Ether type", 3996 .tokens = { 3997 (void *)&cmd_vlan_tpid_vlan, 3998 (void *)&cmd_vlan_tpid_set, 3999 (void *)&cmd_vlan_type, 4000 (void *)&cmd_vlan_tpid_what, 4001 (void *)&cmd_vlan_tpid_tpid, 4002 (void *)&cmd_vlan_tpid_portid, 4003 NULL, 4004 }, 4005 }; 4006 4007 /* *** ADD/REMOVE A VLAN IDENTIFIER TO/FROM A PORT VLAN RX FILTER *** */ 4008 struct cmd_rx_vlan_filter_result { 4009 cmdline_fixed_string_t rx_vlan; 4010 cmdline_fixed_string_t what; 4011 uint16_t vlan_id; 4012 portid_t port_id; 4013 }; 4014 4015 static void 4016 cmd_rx_vlan_filter_parsed(void *parsed_result, 4017 __attribute__((unused)) struct cmdline *cl, 4018 __attribute__((unused)) void *data) 4019 { 4020 struct cmd_rx_vlan_filter_result *res = parsed_result; 4021 4022 if (!strcmp(res->what, "add")) 4023 rx_vft_set(res->port_id, res->vlan_id, 1); 4024 else 4025 rx_vft_set(res->port_id, res->vlan_id, 0); 4026 } 4027 4028 cmdline_parse_token_string_t cmd_rx_vlan_filter_rx_vlan = 4029 TOKEN_STRING_INITIALIZER(struct cmd_rx_vlan_filter_result, 4030 rx_vlan, "rx_vlan"); 4031 cmdline_parse_token_string_t cmd_rx_vlan_filter_what = 4032 TOKEN_STRING_INITIALIZER(struct cmd_rx_vlan_filter_result, 4033 what, "add#rm"); 4034 cmdline_parse_token_num_t cmd_rx_vlan_filter_vlanid = 4035 TOKEN_NUM_INITIALIZER(struct cmd_rx_vlan_filter_result, 4036 vlan_id, UINT16); 4037 cmdline_parse_token_num_t cmd_rx_vlan_filter_portid = 4038 TOKEN_NUM_INITIALIZER(struct cmd_rx_vlan_filter_result, 4039 port_id, UINT16); 4040 4041 cmdline_parse_inst_t cmd_rx_vlan_filter = { 4042 .f = cmd_rx_vlan_filter_parsed, 4043 .data = NULL, 4044 .help_str = "rx_vlan add|rm <vlan_id> <port_id>: " 4045 "Add/Remove a VLAN identifier to/from the set of VLAN " 4046 "identifiers filtered by a port", 4047 .tokens = { 4048 (void *)&cmd_rx_vlan_filter_rx_vlan, 4049 (void *)&cmd_rx_vlan_filter_what, 4050 (void *)&cmd_rx_vlan_filter_vlanid, 4051 (void *)&cmd_rx_vlan_filter_portid, 4052 NULL, 4053 }, 4054 }; 4055 4056 /* *** ENABLE HARDWARE INSERTION OF VLAN HEADER IN TX PACKETS *** */ 4057 struct cmd_tx_vlan_set_result { 4058 cmdline_fixed_string_t tx_vlan; 4059 cmdline_fixed_string_t set; 4060 portid_t port_id; 4061 uint16_t vlan_id; 4062 }; 4063 4064 static void 4065 cmd_tx_vlan_set_parsed(void *parsed_result, 4066 __attribute__((unused)) struct cmdline *cl, 4067 __attribute__((unused)) void *data) 4068 { 4069 struct cmd_tx_vlan_set_result *res = parsed_result; 4070 4071 if (!port_is_stopped(res->port_id)) { 4072 printf("Please stop port %d first\n", res->port_id); 4073 return; 4074 } 4075 4076 tx_vlan_set(res->port_id, res->vlan_id); 4077 4078 cmd_reconfig_device_queue(res->port_id, 1, 1); 4079 } 4080 4081 cmdline_parse_token_string_t cmd_tx_vlan_set_tx_vlan = 4082 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_result, 4083 tx_vlan, "tx_vlan"); 4084 cmdline_parse_token_string_t cmd_tx_vlan_set_set = 4085 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_result, 4086 set, "set"); 4087 cmdline_parse_token_num_t cmd_tx_vlan_set_portid = 4088 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_result, 4089 port_id, UINT16); 4090 cmdline_parse_token_num_t cmd_tx_vlan_set_vlanid = 4091 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_result, 4092 vlan_id, UINT16); 4093 4094 cmdline_parse_inst_t cmd_tx_vlan_set = { 4095 .f = cmd_tx_vlan_set_parsed, 4096 .data = NULL, 4097 .help_str = "tx_vlan set <port_id> <vlan_id>: " 4098 "Enable hardware insertion of a single VLAN header " 4099 "with a given TAG Identifier in packets sent on a port", 4100 .tokens = { 4101 (void *)&cmd_tx_vlan_set_tx_vlan, 4102 (void *)&cmd_tx_vlan_set_set, 4103 (void *)&cmd_tx_vlan_set_portid, 4104 (void *)&cmd_tx_vlan_set_vlanid, 4105 NULL, 4106 }, 4107 }; 4108 4109 /* *** ENABLE HARDWARE INSERTION OF Double VLAN HEADER IN TX PACKETS *** */ 4110 struct cmd_tx_vlan_set_qinq_result { 4111 cmdline_fixed_string_t tx_vlan; 4112 cmdline_fixed_string_t set; 4113 portid_t port_id; 4114 uint16_t vlan_id; 4115 uint16_t vlan_id_outer; 4116 }; 4117 4118 static void 4119 cmd_tx_vlan_set_qinq_parsed(void *parsed_result, 4120 __attribute__((unused)) struct cmdline *cl, 4121 __attribute__((unused)) void *data) 4122 { 4123 struct cmd_tx_vlan_set_qinq_result *res = parsed_result; 4124 4125 if (!port_is_stopped(res->port_id)) { 4126 printf("Please stop port %d first\n", res->port_id); 4127 return; 4128 } 4129 4130 tx_qinq_set(res->port_id, res->vlan_id, res->vlan_id_outer); 4131 4132 cmd_reconfig_device_queue(res->port_id, 1, 1); 4133 } 4134 4135 cmdline_parse_token_string_t cmd_tx_vlan_set_qinq_tx_vlan = 4136 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_qinq_result, 4137 tx_vlan, "tx_vlan"); 4138 cmdline_parse_token_string_t cmd_tx_vlan_set_qinq_set = 4139 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_qinq_result, 4140 set, "set"); 4141 cmdline_parse_token_num_t cmd_tx_vlan_set_qinq_portid = 4142 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_qinq_result, 4143 port_id, UINT16); 4144 cmdline_parse_token_num_t cmd_tx_vlan_set_qinq_vlanid = 4145 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_qinq_result, 4146 vlan_id, UINT16); 4147 cmdline_parse_token_num_t cmd_tx_vlan_set_qinq_vlanid_outer = 4148 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_qinq_result, 4149 vlan_id_outer, UINT16); 4150 4151 cmdline_parse_inst_t cmd_tx_vlan_set_qinq = { 4152 .f = cmd_tx_vlan_set_qinq_parsed, 4153 .data = NULL, 4154 .help_str = "tx_vlan set <port_id> <vlan_id> <outer_vlan_id>: " 4155 "Enable hardware insertion of double VLAN header " 4156 "with given TAG Identifiers in packets sent on a port", 4157 .tokens = { 4158 (void *)&cmd_tx_vlan_set_qinq_tx_vlan, 4159 (void *)&cmd_tx_vlan_set_qinq_set, 4160 (void *)&cmd_tx_vlan_set_qinq_portid, 4161 (void *)&cmd_tx_vlan_set_qinq_vlanid, 4162 (void *)&cmd_tx_vlan_set_qinq_vlanid_outer, 4163 NULL, 4164 }, 4165 }; 4166 4167 /* *** ENABLE/DISABLE PORT BASED TX VLAN INSERTION *** */ 4168 struct cmd_tx_vlan_set_pvid_result { 4169 cmdline_fixed_string_t tx_vlan; 4170 cmdline_fixed_string_t set; 4171 cmdline_fixed_string_t pvid; 4172 portid_t port_id; 4173 uint16_t vlan_id; 4174 cmdline_fixed_string_t mode; 4175 }; 4176 4177 static void 4178 cmd_tx_vlan_set_pvid_parsed(void *parsed_result, 4179 __attribute__((unused)) struct cmdline *cl, 4180 __attribute__((unused)) void *data) 4181 { 4182 struct cmd_tx_vlan_set_pvid_result *res = parsed_result; 4183 4184 if (strcmp(res->mode, "on") == 0) 4185 tx_vlan_pvid_set(res->port_id, res->vlan_id, 1); 4186 else 4187 tx_vlan_pvid_set(res->port_id, res->vlan_id, 0); 4188 } 4189 4190 cmdline_parse_token_string_t cmd_tx_vlan_set_pvid_tx_vlan = 4191 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_pvid_result, 4192 tx_vlan, "tx_vlan"); 4193 cmdline_parse_token_string_t cmd_tx_vlan_set_pvid_set = 4194 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_pvid_result, 4195 set, "set"); 4196 cmdline_parse_token_string_t cmd_tx_vlan_set_pvid_pvid = 4197 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_pvid_result, 4198 pvid, "pvid"); 4199 cmdline_parse_token_num_t cmd_tx_vlan_set_pvid_port_id = 4200 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_pvid_result, 4201 port_id, UINT16); 4202 cmdline_parse_token_num_t cmd_tx_vlan_set_pvid_vlan_id = 4203 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_pvid_result, 4204 vlan_id, UINT16); 4205 cmdline_parse_token_string_t cmd_tx_vlan_set_pvid_mode = 4206 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_pvid_result, 4207 mode, "on#off"); 4208 4209 cmdline_parse_inst_t cmd_tx_vlan_set_pvid = { 4210 .f = cmd_tx_vlan_set_pvid_parsed, 4211 .data = NULL, 4212 .help_str = "tx_vlan set pvid <port_id> <vlan_id> on|off", 4213 .tokens = { 4214 (void *)&cmd_tx_vlan_set_pvid_tx_vlan, 4215 (void *)&cmd_tx_vlan_set_pvid_set, 4216 (void *)&cmd_tx_vlan_set_pvid_pvid, 4217 (void *)&cmd_tx_vlan_set_pvid_port_id, 4218 (void *)&cmd_tx_vlan_set_pvid_vlan_id, 4219 (void *)&cmd_tx_vlan_set_pvid_mode, 4220 NULL, 4221 }, 4222 }; 4223 4224 /* *** DISABLE HARDWARE INSERTION OF VLAN HEADER IN TX PACKETS *** */ 4225 struct cmd_tx_vlan_reset_result { 4226 cmdline_fixed_string_t tx_vlan; 4227 cmdline_fixed_string_t reset; 4228 portid_t port_id; 4229 }; 4230 4231 static void 4232 cmd_tx_vlan_reset_parsed(void *parsed_result, 4233 __attribute__((unused)) struct cmdline *cl, 4234 __attribute__((unused)) void *data) 4235 { 4236 struct cmd_tx_vlan_reset_result *res = parsed_result; 4237 4238 if (!port_is_stopped(res->port_id)) { 4239 printf("Please stop port %d first\n", res->port_id); 4240 return; 4241 } 4242 4243 tx_vlan_reset(res->port_id); 4244 4245 cmd_reconfig_device_queue(res->port_id, 1, 1); 4246 } 4247 4248 cmdline_parse_token_string_t cmd_tx_vlan_reset_tx_vlan = 4249 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_reset_result, 4250 tx_vlan, "tx_vlan"); 4251 cmdline_parse_token_string_t cmd_tx_vlan_reset_reset = 4252 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_reset_result, 4253 reset, "reset"); 4254 cmdline_parse_token_num_t cmd_tx_vlan_reset_portid = 4255 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_reset_result, 4256 port_id, UINT16); 4257 4258 cmdline_parse_inst_t cmd_tx_vlan_reset = { 4259 .f = cmd_tx_vlan_reset_parsed, 4260 .data = NULL, 4261 .help_str = "tx_vlan reset <port_id>: Disable hardware insertion of a " 4262 "VLAN header in packets sent on a port", 4263 .tokens = { 4264 (void *)&cmd_tx_vlan_reset_tx_vlan, 4265 (void *)&cmd_tx_vlan_reset_reset, 4266 (void *)&cmd_tx_vlan_reset_portid, 4267 NULL, 4268 }, 4269 }; 4270 4271 4272 /* *** ENABLE HARDWARE INSERTION OF CHECKSUM IN TX PACKETS *** */ 4273 struct cmd_csum_result { 4274 cmdline_fixed_string_t csum; 4275 cmdline_fixed_string_t mode; 4276 cmdline_fixed_string_t proto; 4277 cmdline_fixed_string_t hwsw; 4278 portid_t port_id; 4279 }; 4280 4281 static void 4282 csum_show(int port_id) 4283 { 4284 struct rte_eth_dev_info dev_info; 4285 uint64_t tx_offloads; 4286 4287 tx_offloads = ports[port_id].dev_conf.txmode.offloads; 4288 printf("Parse tunnel is %s\n", 4289 (ports[port_id].parse_tunnel) ? "on" : "off"); 4290 printf("IP checksum offload is %s\n", 4291 (tx_offloads & DEV_TX_OFFLOAD_IPV4_CKSUM) ? "hw" : "sw"); 4292 printf("UDP checksum offload is %s\n", 4293 (tx_offloads & DEV_TX_OFFLOAD_UDP_CKSUM) ? "hw" : "sw"); 4294 printf("TCP checksum offload is %s\n", 4295 (tx_offloads & DEV_TX_OFFLOAD_TCP_CKSUM) ? "hw" : "sw"); 4296 printf("SCTP checksum offload is %s\n", 4297 (tx_offloads & DEV_TX_OFFLOAD_SCTP_CKSUM) ? "hw" : "sw"); 4298 printf("Outer-Ip checksum offload is %s\n", 4299 (tx_offloads & DEV_TX_OFFLOAD_OUTER_IPV4_CKSUM) ? "hw" : "sw"); 4300 printf("Outer-Udp checksum offload is %s\n", 4301 (tx_offloads & DEV_TX_OFFLOAD_OUTER_UDP_CKSUM) ? "hw" : "sw"); 4302 4303 /* display warnings if configuration is not supported by the NIC */ 4304 rte_eth_dev_info_get(port_id, &dev_info); 4305 if ((tx_offloads & DEV_TX_OFFLOAD_IPV4_CKSUM) && 4306 (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_IPV4_CKSUM) == 0) { 4307 printf("Warning: hardware IP checksum enabled but not " 4308 "supported by port %d\n", port_id); 4309 } 4310 if ((tx_offloads & DEV_TX_OFFLOAD_UDP_CKSUM) && 4311 (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_UDP_CKSUM) == 0) { 4312 printf("Warning: hardware UDP checksum enabled but not " 4313 "supported by port %d\n", port_id); 4314 } 4315 if ((tx_offloads & DEV_TX_OFFLOAD_TCP_CKSUM) && 4316 (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_TCP_CKSUM) == 0) { 4317 printf("Warning: hardware TCP checksum enabled but not " 4318 "supported by port %d\n", port_id); 4319 } 4320 if ((tx_offloads & DEV_TX_OFFLOAD_SCTP_CKSUM) && 4321 (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_SCTP_CKSUM) == 0) { 4322 printf("Warning: hardware SCTP checksum enabled but not " 4323 "supported by port %d\n", port_id); 4324 } 4325 if ((tx_offloads & DEV_TX_OFFLOAD_OUTER_IPV4_CKSUM) && 4326 (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_OUTER_IPV4_CKSUM) == 0) { 4327 printf("Warning: hardware outer IP checksum enabled but not " 4328 "supported by port %d\n", port_id); 4329 } 4330 if ((tx_offloads & DEV_TX_OFFLOAD_OUTER_UDP_CKSUM) && 4331 (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_OUTER_UDP_CKSUM) 4332 == 0) { 4333 printf("Warning: hardware outer UDP checksum enabled but not " 4334 "supported by port %d\n", port_id); 4335 } 4336 } 4337 4338 static void 4339 cmd_config_queue_tx_offloads(struct rte_port *port) 4340 { 4341 int k; 4342 4343 /* Apply queue tx offloads configuration */ 4344 for (k = 0; k < port->dev_info.max_rx_queues; k++) 4345 port->tx_conf[k].offloads = 4346 port->dev_conf.txmode.offloads; 4347 } 4348 4349 static void 4350 cmd_csum_parsed(void *parsed_result, 4351 __attribute__((unused)) struct cmdline *cl, 4352 __attribute__((unused)) void *data) 4353 { 4354 struct cmd_csum_result *res = parsed_result; 4355 int hw = 0; 4356 uint64_t csum_offloads = 0; 4357 struct rte_eth_dev_info dev_info; 4358 4359 if (port_id_is_invalid(res->port_id, ENABLED_WARN)) { 4360 printf("invalid port %d\n", res->port_id); 4361 return; 4362 } 4363 if (!port_is_stopped(res->port_id)) { 4364 printf("Please stop port %d first\n", res->port_id); 4365 return; 4366 } 4367 4368 rte_eth_dev_info_get(res->port_id, &dev_info); 4369 if (!strcmp(res->mode, "set")) { 4370 4371 if (!strcmp(res->hwsw, "hw")) 4372 hw = 1; 4373 4374 if (!strcmp(res->proto, "ip")) { 4375 if (hw == 0 || (dev_info.tx_offload_capa & 4376 DEV_TX_OFFLOAD_IPV4_CKSUM)) { 4377 csum_offloads |= DEV_TX_OFFLOAD_IPV4_CKSUM; 4378 } else { 4379 printf("IP checksum offload is not supported " 4380 "by port %u\n", res->port_id); 4381 } 4382 } else if (!strcmp(res->proto, "udp")) { 4383 if (hw == 0 || (dev_info.tx_offload_capa & 4384 DEV_TX_OFFLOAD_UDP_CKSUM)) { 4385 csum_offloads |= DEV_TX_OFFLOAD_UDP_CKSUM; 4386 } else { 4387 printf("UDP checksum offload is not supported " 4388 "by port %u\n", res->port_id); 4389 } 4390 } else if (!strcmp(res->proto, "tcp")) { 4391 if (hw == 0 || (dev_info.tx_offload_capa & 4392 DEV_TX_OFFLOAD_TCP_CKSUM)) { 4393 csum_offloads |= DEV_TX_OFFLOAD_TCP_CKSUM; 4394 } else { 4395 printf("TCP checksum offload is not supported " 4396 "by port %u\n", res->port_id); 4397 } 4398 } else if (!strcmp(res->proto, "sctp")) { 4399 if (hw == 0 || (dev_info.tx_offload_capa & 4400 DEV_TX_OFFLOAD_SCTP_CKSUM)) { 4401 csum_offloads |= DEV_TX_OFFLOAD_SCTP_CKSUM; 4402 } else { 4403 printf("SCTP checksum offload is not supported " 4404 "by port %u\n", res->port_id); 4405 } 4406 } else if (!strcmp(res->proto, "outer-ip")) { 4407 if (hw == 0 || (dev_info.tx_offload_capa & 4408 DEV_TX_OFFLOAD_OUTER_IPV4_CKSUM)) { 4409 csum_offloads |= 4410 DEV_TX_OFFLOAD_OUTER_IPV4_CKSUM; 4411 } else { 4412 printf("Outer IP checksum offload is not " 4413 "supported by port %u\n", res->port_id); 4414 } 4415 } else if (!strcmp(res->proto, "outer-udp")) { 4416 if (hw == 0 || (dev_info.tx_offload_capa & 4417 DEV_TX_OFFLOAD_OUTER_UDP_CKSUM)) { 4418 csum_offloads |= 4419 DEV_TX_OFFLOAD_OUTER_UDP_CKSUM; 4420 } else { 4421 printf("Outer UDP checksum offload is not " 4422 "supported by port %u\n", res->port_id); 4423 } 4424 } 4425 4426 if (hw) { 4427 ports[res->port_id].dev_conf.txmode.offloads |= 4428 csum_offloads; 4429 } else { 4430 ports[res->port_id].dev_conf.txmode.offloads &= 4431 (~csum_offloads); 4432 } 4433 cmd_config_queue_tx_offloads(&ports[res->port_id]); 4434 } 4435 csum_show(res->port_id); 4436 4437 cmd_reconfig_device_queue(res->port_id, 1, 1); 4438 } 4439 4440 cmdline_parse_token_string_t cmd_csum_csum = 4441 TOKEN_STRING_INITIALIZER(struct cmd_csum_result, 4442 csum, "csum"); 4443 cmdline_parse_token_string_t cmd_csum_mode = 4444 TOKEN_STRING_INITIALIZER(struct cmd_csum_result, 4445 mode, "set"); 4446 cmdline_parse_token_string_t cmd_csum_proto = 4447 TOKEN_STRING_INITIALIZER(struct cmd_csum_result, 4448 proto, "ip#tcp#udp#sctp#outer-ip#outer-udp"); 4449 cmdline_parse_token_string_t cmd_csum_hwsw = 4450 TOKEN_STRING_INITIALIZER(struct cmd_csum_result, 4451 hwsw, "hw#sw"); 4452 cmdline_parse_token_num_t cmd_csum_portid = 4453 TOKEN_NUM_INITIALIZER(struct cmd_csum_result, 4454 port_id, UINT16); 4455 4456 cmdline_parse_inst_t cmd_csum_set = { 4457 .f = cmd_csum_parsed, 4458 .data = NULL, 4459 .help_str = "csum set ip|tcp|udp|sctp|outer-ip|outer-udp hw|sw <port_id>: " 4460 "Enable/Disable hardware calculation of L3/L4 checksum when " 4461 "using csum forward engine", 4462 .tokens = { 4463 (void *)&cmd_csum_csum, 4464 (void *)&cmd_csum_mode, 4465 (void *)&cmd_csum_proto, 4466 (void *)&cmd_csum_hwsw, 4467 (void *)&cmd_csum_portid, 4468 NULL, 4469 }, 4470 }; 4471 4472 cmdline_parse_token_string_t cmd_csum_mode_show = 4473 TOKEN_STRING_INITIALIZER(struct cmd_csum_result, 4474 mode, "show"); 4475 4476 cmdline_parse_inst_t cmd_csum_show = { 4477 .f = cmd_csum_parsed, 4478 .data = NULL, 4479 .help_str = "csum show <port_id>: Show checksum offload configuration", 4480 .tokens = { 4481 (void *)&cmd_csum_csum, 4482 (void *)&cmd_csum_mode_show, 4483 (void *)&cmd_csum_portid, 4484 NULL, 4485 }, 4486 }; 4487 4488 /* Enable/disable tunnel parsing */ 4489 struct cmd_csum_tunnel_result { 4490 cmdline_fixed_string_t csum; 4491 cmdline_fixed_string_t parse; 4492 cmdline_fixed_string_t onoff; 4493 portid_t port_id; 4494 }; 4495 4496 static void 4497 cmd_csum_tunnel_parsed(void *parsed_result, 4498 __attribute__((unused)) struct cmdline *cl, 4499 __attribute__((unused)) void *data) 4500 { 4501 struct cmd_csum_tunnel_result *res = parsed_result; 4502 4503 if (port_id_is_invalid(res->port_id, ENABLED_WARN)) 4504 return; 4505 4506 if (!strcmp(res->onoff, "on")) 4507 ports[res->port_id].parse_tunnel = 1; 4508 else 4509 ports[res->port_id].parse_tunnel = 0; 4510 4511 csum_show(res->port_id); 4512 } 4513 4514 cmdline_parse_token_string_t cmd_csum_tunnel_csum = 4515 TOKEN_STRING_INITIALIZER(struct cmd_csum_tunnel_result, 4516 csum, "csum"); 4517 cmdline_parse_token_string_t cmd_csum_tunnel_parse = 4518 TOKEN_STRING_INITIALIZER(struct cmd_csum_tunnel_result, 4519 parse, "parse-tunnel"); 4520 cmdline_parse_token_string_t cmd_csum_tunnel_onoff = 4521 TOKEN_STRING_INITIALIZER(struct cmd_csum_tunnel_result, 4522 onoff, "on#off"); 4523 cmdline_parse_token_num_t cmd_csum_tunnel_portid = 4524 TOKEN_NUM_INITIALIZER(struct cmd_csum_tunnel_result, 4525 port_id, UINT16); 4526 4527 cmdline_parse_inst_t cmd_csum_tunnel = { 4528 .f = cmd_csum_tunnel_parsed, 4529 .data = NULL, 4530 .help_str = "csum parse-tunnel on|off <port_id>: " 4531 "Enable/Disable parsing of tunnels for csum engine", 4532 .tokens = { 4533 (void *)&cmd_csum_tunnel_csum, 4534 (void *)&cmd_csum_tunnel_parse, 4535 (void *)&cmd_csum_tunnel_onoff, 4536 (void *)&cmd_csum_tunnel_portid, 4537 NULL, 4538 }, 4539 }; 4540 4541 /* *** ENABLE HARDWARE SEGMENTATION IN TX NON-TUNNELED PACKETS *** */ 4542 struct cmd_tso_set_result { 4543 cmdline_fixed_string_t tso; 4544 cmdline_fixed_string_t mode; 4545 uint16_t tso_segsz; 4546 portid_t port_id; 4547 }; 4548 4549 static void 4550 cmd_tso_set_parsed(void *parsed_result, 4551 __attribute__((unused)) struct cmdline *cl, 4552 __attribute__((unused)) void *data) 4553 { 4554 struct cmd_tso_set_result *res = parsed_result; 4555 struct rte_eth_dev_info dev_info; 4556 4557 if (port_id_is_invalid(res->port_id, ENABLED_WARN)) 4558 return; 4559 if (!port_is_stopped(res->port_id)) { 4560 printf("Please stop port %d first\n", res->port_id); 4561 return; 4562 } 4563 4564 if (!strcmp(res->mode, "set")) 4565 ports[res->port_id].tso_segsz = res->tso_segsz; 4566 4567 rte_eth_dev_info_get(res->port_id, &dev_info); 4568 if ((ports[res->port_id].tso_segsz != 0) && 4569 (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_TCP_TSO) == 0) { 4570 printf("Error: TSO is not supported by port %d\n", 4571 res->port_id); 4572 return; 4573 } 4574 4575 if (ports[res->port_id].tso_segsz == 0) { 4576 ports[res->port_id].dev_conf.txmode.offloads &= 4577 ~DEV_TX_OFFLOAD_TCP_TSO; 4578 printf("TSO for non-tunneled packets is disabled\n"); 4579 } else { 4580 ports[res->port_id].dev_conf.txmode.offloads |= 4581 DEV_TX_OFFLOAD_TCP_TSO; 4582 printf("TSO segment size for non-tunneled packets is %d\n", 4583 ports[res->port_id].tso_segsz); 4584 } 4585 cmd_config_queue_tx_offloads(&ports[res->port_id]); 4586 4587 /* display warnings if configuration is not supported by the NIC */ 4588 rte_eth_dev_info_get(res->port_id, &dev_info); 4589 if ((ports[res->port_id].tso_segsz != 0) && 4590 (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_TCP_TSO) == 0) { 4591 printf("Warning: TSO enabled but not " 4592 "supported by port %d\n", res->port_id); 4593 } 4594 4595 cmd_reconfig_device_queue(res->port_id, 1, 1); 4596 } 4597 4598 cmdline_parse_token_string_t cmd_tso_set_tso = 4599 TOKEN_STRING_INITIALIZER(struct cmd_tso_set_result, 4600 tso, "tso"); 4601 cmdline_parse_token_string_t cmd_tso_set_mode = 4602 TOKEN_STRING_INITIALIZER(struct cmd_tso_set_result, 4603 mode, "set"); 4604 cmdline_parse_token_num_t cmd_tso_set_tso_segsz = 4605 TOKEN_NUM_INITIALIZER(struct cmd_tso_set_result, 4606 tso_segsz, UINT16); 4607 cmdline_parse_token_num_t cmd_tso_set_portid = 4608 TOKEN_NUM_INITIALIZER(struct cmd_tso_set_result, 4609 port_id, UINT16); 4610 4611 cmdline_parse_inst_t cmd_tso_set = { 4612 .f = cmd_tso_set_parsed, 4613 .data = NULL, 4614 .help_str = "tso set <tso_segsz> <port_id>: " 4615 "Set TSO segment size of non-tunneled packets for csum engine " 4616 "(0 to disable)", 4617 .tokens = { 4618 (void *)&cmd_tso_set_tso, 4619 (void *)&cmd_tso_set_mode, 4620 (void *)&cmd_tso_set_tso_segsz, 4621 (void *)&cmd_tso_set_portid, 4622 NULL, 4623 }, 4624 }; 4625 4626 cmdline_parse_token_string_t cmd_tso_show_mode = 4627 TOKEN_STRING_INITIALIZER(struct cmd_tso_set_result, 4628 mode, "show"); 4629 4630 4631 cmdline_parse_inst_t cmd_tso_show = { 4632 .f = cmd_tso_set_parsed, 4633 .data = NULL, 4634 .help_str = "tso show <port_id>: " 4635 "Show TSO segment size of non-tunneled packets for csum engine", 4636 .tokens = { 4637 (void *)&cmd_tso_set_tso, 4638 (void *)&cmd_tso_show_mode, 4639 (void *)&cmd_tso_set_portid, 4640 NULL, 4641 }, 4642 }; 4643 4644 /* *** ENABLE HARDWARE SEGMENTATION IN TX TUNNELED PACKETS *** */ 4645 struct cmd_tunnel_tso_set_result { 4646 cmdline_fixed_string_t tso; 4647 cmdline_fixed_string_t mode; 4648 uint16_t tso_segsz; 4649 portid_t port_id; 4650 }; 4651 4652 static struct rte_eth_dev_info 4653 check_tunnel_tso_nic_support(portid_t port_id) 4654 { 4655 struct rte_eth_dev_info dev_info; 4656 4657 rte_eth_dev_info_get(port_id, &dev_info); 4658 if (!(dev_info.tx_offload_capa & DEV_TX_OFFLOAD_VXLAN_TNL_TSO)) 4659 printf("Warning: VXLAN TUNNEL TSO not supported therefore " 4660 "not enabled for port %d\n", port_id); 4661 if (!(dev_info.tx_offload_capa & DEV_TX_OFFLOAD_GRE_TNL_TSO)) 4662 printf("Warning: GRE TUNNEL TSO not supported therefore " 4663 "not enabled for port %d\n", port_id); 4664 if (!(dev_info.tx_offload_capa & DEV_TX_OFFLOAD_IPIP_TNL_TSO)) 4665 printf("Warning: IPIP TUNNEL TSO not supported therefore " 4666 "not enabled for port %d\n", port_id); 4667 if (!(dev_info.tx_offload_capa & DEV_TX_OFFLOAD_GENEVE_TNL_TSO)) 4668 printf("Warning: GENEVE TUNNEL TSO not supported therefore " 4669 "not enabled for port %d\n", port_id); 4670 if (!(dev_info.tx_offload_capa & DEV_TX_OFFLOAD_IP_TNL_TSO)) 4671 printf("Warning: IP TUNNEL TSO not supported therefore " 4672 "not enabled for port %d\n", port_id); 4673 if (!(dev_info.tx_offload_capa & DEV_TX_OFFLOAD_UDP_TNL_TSO)) 4674 printf("Warning: UDP TUNNEL TSO not supported therefore " 4675 "not enabled for port %d\n", port_id); 4676 return dev_info; 4677 } 4678 4679 static void 4680 cmd_tunnel_tso_set_parsed(void *parsed_result, 4681 __attribute__((unused)) struct cmdline *cl, 4682 __attribute__((unused)) void *data) 4683 { 4684 struct cmd_tunnel_tso_set_result *res = parsed_result; 4685 struct rte_eth_dev_info dev_info; 4686 4687 if (port_id_is_invalid(res->port_id, ENABLED_WARN)) 4688 return; 4689 if (!port_is_stopped(res->port_id)) { 4690 printf("Please stop port %d first\n", res->port_id); 4691 return; 4692 } 4693 4694 if (!strcmp(res->mode, "set")) 4695 ports[res->port_id].tunnel_tso_segsz = res->tso_segsz; 4696 4697 dev_info = check_tunnel_tso_nic_support(res->port_id); 4698 if (ports[res->port_id].tunnel_tso_segsz == 0) { 4699 ports[res->port_id].dev_conf.txmode.offloads &= 4700 ~(DEV_TX_OFFLOAD_VXLAN_TNL_TSO | 4701 DEV_TX_OFFLOAD_GRE_TNL_TSO | 4702 DEV_TX_OFFLOAD_IPIP_TNL_TSO | 4703 DEV_TX_OFFLOAD_GENEVE_TNL_TSO | 4704 DEV_TX_OFFLOAD_IP_TNL_TSO | 4705 DEV_TX_OFFLOAD_UDP_TNL_TSO); 4706 printf("TSO for tunneled packets is disabled\n"); 4707 } else { 4708 uint64_t tso_offloads = (DEV_TX_OFFLOAD_VXLAN_TNL_TSO | 4709 DEV_TX_OFFLOAD_GRE_TNL_TSO | 4710 DEV_TX_OFFLOAD_IPIP_TNL_TSO | 4711 DEV_TX_OFFLOAD_GENEVE_TNL_TSO | 4712 DEV_TX_OFFLOAD_IP_TNL_TSO | 4713 DEV_TX_OFFLOAD_UDP_TNL_TSO); 4714 4715 ports[res->port_id].dev_conf.txmode.offloads |= 4716 (tso_offloads & dev_info.tx_offload_capa); 4717 printf("TSO segment size for tunneled packets is %d\n", 4718 ports[res->port_id].tunnel_tso_segsz); 4719 4720 /* Below conditions are needed to make it work: 4721 * (1) tunnel TSO is supported by the NIC; 4722 * (2) "csum parse_tunnel" must be set so that tunneled pkts 4723 * are recognized; 4724 * (3) for tunneled pkts with outer L3 of IPv4, 4725 * "csum set outer-ip" must be set to hw, because after tso, 4726 * total_len of outer IP header is changed, and the checksum 4727 * of outer IP header calculated by sw should be wrong; that 4728 * is not necessary for IPv6 tunneled pkts because there's no 4729 * checksum in IP header anymore. 4730 */ 4731 4732 if (!ports[res->port_id].parse_tunnel) 4733 printf("Warning: csum parse_tunnel must be set " 4734 "so that tunneled packets are recognized\n"); 4735 if (!(ports[res->port_id].dev_conf.txmode.offloads & 4736 DEV_TX_OFFLOAD_OUTER_IPV4_CKSUM)) 4737 printf("Warning: csum set outer-ip must be set to hw " 4738 "if outer L3 is IPv4; not necessary for IPv6\n"); 4739 } 4740 4741 cmd_config_queue_tx_offloads(&ports[res->port_id]); 4742 cmd_reconfig_device_queue(res->port_id, 1, 1); 4743 } 4744 4745 cmdline_parse_token_string_t cmd_tunnel_tso_set_tso = 4746 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_tso_set_result, 4747 tso, "tunnel_tso"); 4748 cmdline_parse_token_string_t cmd_tunnel_tso_set_mode = 4749 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_tso_set_result, 4750 mode, "set"); 4751 cmdline_parse_token_num_t cmd_tunnel_tso_set_tso_segsz = 4752 TOKEN_NUM_INITIALIZER(struct cmd_tunnel_tso_set_result, 4753 tso_segsz, UINT16); 4754 cmdline_parse_token_num_t cmd_tunnel_tso_set_portid = 4755 TOKEN_NUM_INITIALIZER(struct cmd_tunnel_tso_set_result, 4756 port_id, UINT16); 4757 4758 cmdline_parse_inst_t cmd_tunnel_tso_set = { 4759 .f = cmd_tunnel_tso_set_parsed, 4760 .data = NULL, 4761 .help_str = "tunnel_tso set <tso_segsz> <port_id>: " 4762 "Set TSO segment size of tunneled packets for csum engine " 4763 "(0 to disable)", 4764 .tokens = { 4765 (void *)&cmd_tunnel_tso_set_tso, 4766 (void *)&cmd_tunnel_tso_set_mode, 4767 (void *)&cmd_tunnel_tso_set_tso_segsz, 4768 (void *)&cmd_tunnel_tso_set_portid, 4769 NULL, 4770 }, 4771 }; 4772 4773 cmdline_parse_token_string_t cmd_tunnel_tso_show_mode = 4774 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_tso_set_result, 4775 mode, "show"); 4776 4777 4778 cmdline_parse_inst_t cmd_tunnel_tso_show = { 4779 .f = cmd_tunnel_tso_set_parsed, 4780 .data = NULL, 4781 .help_str = "tunnel_tso show <port_id> " 4782 "Show TSO segment size of tunneled packets for csum engine", 4783 .tokens = { 4784 (void *)&cmd_tunnel_tso_set_tso, 4785 (void *)&cmd_tunnel_tso_show_mode, 4786 (void *)&cmd_tunnel_tso_set_portid, 4787 NULL, 4788 }, 4789 }; 4790 4791 /* *** SET GRO FOR A PORT *** */ 4792 struct cmd_gro_enable_result { 4793 cmdline_fixed_string_t cmd_set; 4794 cmdline_fixed_string_t cmd_port; 4795 cmdline_fixed_string_t cmd_keyword; 4796 cmdline_fixed_string_t cmd_onoff; 4797 portid_t cmd_pid; 4798 }; 4799 4800 static void 4801 cmd_gro_enable_parsed(void *parsed_result, 4802 __attribute__((unused)) struct cmdline *cl, 4803 __attribute__((unused)) void *data) 4804 { 4805 struct cmd_gro_enable_result *res; 4806 4807 res = parsed_result; 4808 if (!strcmp(res->cmd_keyword, "gro")) 4809 setup_gro(res->cmd_onoff, res->cmd_pid); 4810 } 4811 4812 cmdline_parse_token_string_t cmd_gro_enable_set = 4813 TOKEN_STRING_INITIALIZER(struct cmd_gro_enable_result, 4814 cmd_set, "set"); 4815 cmdline_parse_token_string_t cmd_gro_enable_port = 4816 TOKEN_STRING_INITIALIZER(struct cmd_gro_enable_result, 4817 cmd_keyword, "port"); 4818 cmdline_parse_token_num_t cmd_gro_enable_pid = 4819 TOKEN_NUM_INITIALIZER(struct cmd_gro_enable_result, 4820 cmd_pid, UINT16); 4821 cmdline_parse_token_string_t cmd_gro_enable_keyword = 4822 TOKEN_STRING_INITIALIZER(struct cmd_gro_enable_result, 4823 cmd_keyword, "gro"); 4824 cmdline_parse_token_string_t cmd_gro_enable_onoff = 4825 TOKEN_STRING_INITIALIZER(struct cmd_gro_enable_result, 4826 cmd_onoff, "on#off"); 4827 4828 cmdline_parse_inst_t cmd_gro_enable = { 4829 .f = cmd_gro_enable_parsed, 4830 .data = NULL, 4831 .help_str = "set port <port_id> gro on|off", 4832 .tokens = { 4833 (void *)&cmd_gro_enable_set, 4834 (void *)&cmd_gro_enable_port, 4835 (void *)&cmd_gro_enable_pid, 4836 (void *)&cmd_gro_enable_keyword, 4837 (void *)&cmd_gro_enable_onoff, 4838 NULL, 4839 }, 4840 }; 4841 4842 /* *** DISPLAY GRO CONFIGURATION *** */ 4843 struct cmd_gro_show_result { 4844 cmdline_fixed_string_t cmd_show; 4845 cmdline_fixed_string_t cmd_port; 4846 cmdline_fixed_string_t cmd_keyword; 4847 portid_t cmd_pid; 4848 }; 4849 4850 static void 4851 cmd_gro_show_parsed(void *parsed_result, 4852 __attribute__((unused)) struct cmdline *cl, 4853 __attribute__((unused)) void *data) 4854 { 4855 struct cmd_gro_show_result *res; 4856 4857 res = parsed_result; 4858 if (!strcmp(res->cmd_keyword, "gro")) 4859 show_gro(res->cmd_pid); 4860 } 4861 4862 cmdline_parse_token_string_t cmd_gro_show_show = 4863 TOKEN_STRING_INITIALIZER(struct cmd_gro_show_result, 4864 cmd_show, "show"); 4865 cmdline_parse_token_string_t cmd_gro_show_port = 4866 TOKEN_STRING_INITIALIZER(struct cmd_gro_show_result, 4867 cmd_port, "port"); 4868 cmdline_parse_token_num_t cmd_gro_show_pid = 4869 TOKEN_NUM_INITIALIZER(struct cmd_gro_show_result, 4870 cmd_pid, UINT16); 4871 cmdline_parse_token_string_t cmd_gro_show_keyword = 4872 TOKEN_STRING_INITIALIZER(struct cmd_gro_show_result, 4873 cmd_keyword, "gro"); 4874 4875 cmdline_parse_inst_t cmd_gro_show = { 4876 .f = cmd_gro_show_parsed, 4877 .data = NULL, 4878 .help_str = "show port <port_id> gro", 4879 .tokens = { 4880 (void *)&cmd_gro_show_show, 4881 (void *)&cmd_gro_show_port, 4882 (void *)&cmd_gro_show_pid, 4883 (void *)&cmd_gro_show_keyword, 4884 NULL, 4885 }, 4886 }; 4887 4888 /* *** SET FLUSH CYCLES FOR GRO *** */ 4889 struct cmd_gro_flush_result { 4890 cmdline_fixed_string_t cmd_set; 4891 cmdline_fixed_string_t cmd_keyword; 4892 cmdline_fixed_string_t cmd_flush; 4893 uint8_t cmd_cycles; 4894 }; 4895 4896 static void 4897 cmd_gro_flush_parsed(void *parsed_result, 4898 __attribute__((unused)) struct cmdline *cl, 4899 __attribute__((unused)) void *data) 4900 { 4901 struct cmd_gro_flush_result *res; 4902 4903 res = parsed_result; 4904 if ((!strcmp(res->cmd_keyword, "gro")) && 4905 (!strcmp(res->cmd_flush, "flush"))) 4906 setup_gro_flush_cycles(res->cmd_cycles); 4907 } 4908 4909 cmdline_parse_token_string_t cmd_gro_flush_set = 4910 TOKEN_STRING_INITIALIZER(struct cmd_gro_flush_result, 4911 cmd_set, "set"); 4912 cmdline_parse_token_string_t cmd_gro_flush_keyword = 4913 TOKEN_STRING_INITIALIZER(struct cmd_gro_flush_result, 4914 cmd_keyword, "gro"); 4915 cmdline_parse_token_string_t cmd_gro_flush_flush = 4916 TOKEN_STRING_INITIALIZER(struct cmd_gro_flush_result, 4917 cmd_flush, "flush"); 4918 cmdline_parse_token_num_t cmd_gro_flush_cycles = 4919 TOKEN_NUM_INITIALIZER(struct cmd_gro_flush_result, 4920 cmd_cycles, UINT8); 4921 4922 cmdline_parse_inst_t cmd_gro_flush = { 4923 .f = cmd_gro_flush_parsed, 4924 .data = NULL, 4925 .help_str = "set gro flush <cycles>", 4926 .tokens = { 4927 (void *)&cmd_gro_flush_set, 4928 (void *)&cmd_gro_flush_keyword, 4929 (void *)&cmd_gro_flush_flush, 4930 (void *)&cmd_gro_flush_cycles, 4931 NULL, 4932 }, 4933 }; 4934 4935 /* *** ENABLE/DISABLE GSO *** */ 4936 struct cmd_gso_enable_result { 4937 cmdline_fixed_string_t cmd_set; 4938 cmdline_fixed_string_t cmd_port; 4939 cmdline_fixed_string_t cmd_keyword; 4940 cmdline_fixed_string_t cmd_mode; 4941 portid_t cmd_pid; 4942 }; 4943 4944 static void 4945 cmd_gso_enable_parsed(void *parsed_result, 4946 __attribute__((unused)) struct cmdline *cl, 4947 __attribute__((unused)) void *data) 4948 { 4949 struct cmd_gso_enable_result *res; 4950 4951 res = parsed_result; 4952 if (!strcmp(res->cmd_keyword, "gso")) 4953 setup_gso(res->cmd_mode, res->cmd_pid); 4954 } 4955 4956 cmdline_parse_token_string_t cmd_gso_enable_set = 4957 TOKEN_STRING_INITIALIZER(struct cmd_gso_enable_result, 4958 cmd_set, "set"); 4959 cmdline_parse_token_string_t cmd_gso_enable_port = 4960 TOKEN_STRING_INITIALIZER(struct cmd_gso_enable_result, 4961 cmd_port, "port"); 4962 cmdline_parse_token_string_t cmd_gso_enable_keyword = 4963 TOKEN_STRING_INITIALIZER(struct cmd_gso_enable_result, 4964 cmd_keyword, "gso"); 4965 cmdline_parse_token_string_t cmd_gso_enable_mode = 4966 TOKEN_STRING_INITIALIZER(struct cmd_gso_enable_result, 4967 cmd_mode, "on#off"); 4968 cmdline_parse_token_num_t cmd_gso_enable_pid = 4969 TOKEN_NUM_INITIALIZER(struct cmd_gso_enable_result, 4970 cmd_pid, UINT16); 4971 4972 cmdline_parse_inst_t cmd_gso_enable = { 4973 .f = cmd_gso_enable_parsed, 4974 .data = NULL, 4975 .help_str = "set port <port_id> gso on|off", 4976 .tokens = { 4977 (void *)&cmd_gso_enable_set, 4978 (void *)&cmd_gso_enable_port, 4979 (void *)&cmd_gso_enable_pid, 4980 (void *)&cmd_gso_enable_keyword, 4981 (void *)&cmd_gso_enable_mode, 4982 NULL, 4983 }, 4984 }; 4985 4986 /* *** SET MAX PACKET LENGTH FOR GSO SEGMENTS *** */ 4987 struct cmd_gso_size_result { 4988 cmdline_fixed_string_t cmd_set; 4989 cmdline_fixed_string_t cmd_keyword; 4990 cmdline_fixed_string_t cmd_segsz; 4991 uint16_t cmd_size; 4992 }; 4993 4994 static void 4995 cmd_gso_size_parsed(void *parsed_result, 4996 __attribute__((unused)) struct cmdline *cl, 4997 __attribute__((unused)) void *data) 4998 { 4999 struct cmd_gso_size_result *res = parsed_result; 5000 5001 if (test_done == 0) { 5002 printf("Before setting GSO segsz, please first" 5003 " stop fowarding\n"); 5004 return; 5005 } 5006 5007 if (!strcmp(res->cmd_keyword, "gso") && 5008 !strcmp(res->cmd_segsz, "segsz")) { 5009 if (res->cmd_size < RTE_GSO_SEG_SIZE_MIN) 5010 printf("gso_size should be larger than %zu." 5011 " Please input a legal value\n", 5012 RTE_GSO_SEG_SIZE_MIN); 5013 else 5014 gso_max_segment_size = res->cmd_size; 5015 } 5016 } 5017 5018 cmdline_parse_token_string_t cmd_gso_size_set = 5019 TOKEN_STRING_INITIALIZER(struct cmd_gso_size_result, 5020 cmd_set, "set"); 5021 cmdline_parse_token_string_t cmd_gso_size_keyword = 5022 TOKEN_STRING_INITIALIZER(struct cmd_gso_size_result, 5023 cmd_keyword, "gso"); 5024 cmdline_parse_token_string_t cmd_gso_size_segsz = 5025 TOKEN_STRING_INITIALIZER(struct cmd_gso_size_result, 5026 cmd_segsz, "segsz"); 5027 cmdline_parse_token_num_t cmd_gso_size_size = 5028 TOKEN_NUM_INITIALIZER(struct cmd_gso_size_result, 5029 cmd_size, UINT16); 5030 5031 cmdline_parse_inst_t cmd_gso_size = { 5032 .f = cmd_gso_size_parsed, 5033 .data = NULL, 5034 .help_str = "set gso segsz <length>", 5035 .tokens = { 5036 (void *)&cmd_gso_size_set, 5037 (void *)&cmd_gso_size_keyword, 5038 (void *)&cmd_gso_size_segsz, 5039 (void *)&cmd_gso_size_size, 5040 NULL, 5041 }, 5042 }; 5043 5044 /* *** SHOW GSO CONFIGURATION *** */ 5045 struct cmd_gso_show_result { 5046 cmdline_fixed_string_t cmd_show; 5047 cmdline_fixed_string_t cmd_port; 5048 cmdline_fixed_string_t cmd_keyword; 5049 portid_t cmd_pid; 5050 }; 5051 5052 static void 5053 cmd_gso_show_parsed(void *parsed_result, 5054 __attribute__((unused)) struct cmdline *cl, 5055 __attribute__((unused)) void *data) 5056 { 5057 struct cmd_gso_show_result *res = parsed_result; 5058 5059 if (!rte_eth_dev_is_valid_port(res->cmd_pid)) { 5060 printf("invalid port id %u\n", res->cmd_pid); 5061 return; 5062 } 5063 if (!strcmp(res->cmd_keyword, "gso")) { 5064 if (gso_ports[res->cmd_pid].enable) { 5065 printf("Max GSO'd packet size: %uB\n" 5066 "Supported GSO types: TCP/IPv4, " 5067 "UDP/IPv4, VxLAN with inner " 5068 "TCP/IPv4 packet, GRE with inner " 5069 "TCP/IPv4 packet\n", 5070 gso_max_segment_size); 5071 } else 5072 printf("GSO is not enabled on Port %u\n", res->cmd_pid); 5073 } 5074 } 5075 5076 cmdline_parse_token_string_t cmd_gso_show_show = 5077 TOKEN_STRING_INITIALIZER(struct cmd_gso_show_result, 5078 cmd_show, "show"); 5079 cmdline_parse_token_string_t cmd_gso_show_port = 5080 TOKEN_STRING_INITIALIZER(struct cmd_gso_show_result, 5081 cmd_port, "port"); 5082 cmdline_parse_token_string_t cmd_gso_show_keyword = 5083 TOKEN_STRING_INITIALIZER(struct cmd_gso_show_result, 5084 cmd_keyword, "gso"); 5085 cmdline_parse_token_num_t cmd_gso_show_pid = 5086 TOKEN_NUM_INITIALIZER(struct cmd_gso_show_result, 5087 cmd_pid, UINT16); 5088 5089 cmdline_parse_inst_t cmd_gso_show = { 5090 .f = cmd_gso_show_parsed, 5091 .data = NULL, 5092 .help_str = "show port <port_id> gso", 5093 .tokens = { 5094 (void *)&cmd_gso_show_show, 5095 (void *)&cmd_gso_show_port, 5096 (void *)&cmd_gso_show_pid, 5097 (void *)&cmd_gso_show_keyword, 5098 NULL, 5099 }, 5100 }; 5101 5102 /* *** ENABLE/DISABLE FLUSH ON RX STREAMS *** */ 5103 struct cmd_set_flush_rx { 5104 cmdline_fixed_string_t set; 5105 cmdline_fixed_string_t flush_rx; 5106 cmdline_fixed_string_t mode; 5107 }; 5108 5109 static void 5110 cmd_set_flush_rx_parsed(void *parsed_result, 5111 __attribute__((unused)) struct cmdline *cl, 5112 __attribute__((unused)) void *data) 5113 { 5114 struct cmd_set_flush_rx *res = parsed_result; 5115 no_flush_rx = (uint8_t)((strcmp(res->mode, "on") == 0) ? 0 : 1); 5116 } 5117 5118 cmdline_parse_token_string_t cmd_setflushrx_set = 5119 TOKEN_STRING_INITIALIZER(struct cmd_set_flush_rx, 5120 set, "set"); 5121 cmdline_parse_token_string_t cmd_setflushrx_flush_rx = 5122 TOKEN_STRING_INITIALIZER(struct cmd_set_flush_rx, 5123 flush_rx, "flush_rx"); 5124 cmdline_parse_token_string_t cmd_setflushrx_mode = 5125 TOKEN_STRING_INITIALIZER(struct cmd_set_flush_rx, 5126 mode, "on#off"); 5127 5128 5129 cmdline_parse_inst_t cmd_set_flush_rx = { 5130 .f = cmd_set_flush_rx_parsed, 5131 .help_str = "set flush_rx on|off: Enable/Disable flush on rx streams", 5132 .data = NULL, 5133 .tokens = { 5134 (void *)&cmd_setflushrx_set, 5135 (void *)&cmd_setflushrx_flush_rx, 5136 (void *)&cmd_setflushrx_mode, 5137 NULL, 5138 }, 5139 }; 5140 5141 /* *** ENABLE/DISABLE LINK STATUS CHECK *** */ 5142 struct cmd_set_link_check { 5143 cmdline_fixed_string_t set; 5144 cmdline_fixed_string_t link_check; 5145 cmdline_fixed_string_t mode; 5146 }; 5147 5148 static void 5149 cmd_set_link_check_parsed(void *parsed_result, 5150 __attribute__((unused)) struct cmdline *cl, 5151 __attribute__((unused)) void *data) 5152 { 5153 struct cmd_set_link_check *res = parsed_result; 5154 no_link_check = (uint8_t)((strcmp(res->mode, "on") == 0) ? 0 : 1); 5155 } 5156 5157 cmdline_parse_token_string_t cmd_setlinkcheck_set = 5158 TOKEN_STRING_INITIALIZER(struct cmd_set_link_check, 5159 set, "set"); 5160 cmdline_parse_token_string_t cmd_setlinkcheck_link_check = 5161 TOKEN_STRING_INITIALIZER(struct cmd_set_link_check, 5162 link_check, "link_check"); 5163 cmdline_parse_token_string_t cmd_setlinkcheck_mode = 5164 TOKEN_STRING_INITIALIZER(struct cmd_set_link_check, 5165 mode, "on#off"); 5166 5167 5168 cmdline_parse_inst_t cmd_set_link_check = { 5169 .f = cmd_set_link_check_parsed, 5170 .help_str = "set link_check on|off: Enable/Disable link status check " 5171 "when starting/stopping a port", 5172 .data = NULL, 5173 .tokens = { 5174 (void *)&cmd_setlinkcheck_set, 5175 (void *)&cmd_setlinkcheck_link_check, 5176 (void *)&cmd_setlinkcheck_mode, 5177 NULL, 5178 }, 5179 }; 5180 5181 /* *** SET NIC BYPASS MODE *** */ 5182 struct cmd_set_bypass_mode_result { 5183 cmdline_fixed_string_t set; 5184 cmdline_fixed_string_t bypass; 5185 cmdline_fixed_string_t mode; 5186 cmdline_fixed_string_t value; 5187 portid_t port_id; 5188 }; 5189 5190 static void 5191 cmd_set_bypass_mode_parsed(void *parsed_result, 5192 __attribute__((unused)) struct cmdline *cl, 5193 __attribute__((unused)) void *data) 5194 { 5195 struct cmd_set_bypass_mode_result *res = parsed_result; 5196 portid_t port_id = res->port_id; 5197 int32_t rc = -EINVAL; 5198 5199 #if defined RTE_LIBRTE_IXGBE_PMD && defined RTE_LIBRTE_IXGBE_BYPASS 5200 uint32_t bypass_mode = RTE_PMD_IXGBE_BYPASS_MODE_NORMAL; 5201 5202 if (!strcmp(res->value, "bypass")) 5203 bypass_mode = RTE_PMD_IXGBE_BYPASS_MODE_BYPASS; 5204 else if (!strcmp(res->value, "isolate")) 5205 bypass_mode = RTE_PMD_IXGBE_BYPASS_MODE_ISOLATE; 5206 else 5207 bypass_mode = RTE_PMD_IXGBE_BYPASS_MODE_NORMAL; 5208 5209 /* Set the bypass mode for the relevant port. */ 5210 rc = rte_pmd_ixgbe_bypass_state_set(port_id, &bypass_mode); 5211 #endif 5212 if (rc != 0) 5213 printf("\t Failed to set bypass mode for port = %d.\n", port_id); 5214 } 5215 5216 cmdline_parse_token_string_t cmd_setbypass_mode_set = 5217 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_mode_result, 5218 set, "set"); 5219 cmdline_parse_token_string_t cmd_setbypass_mode_bypass = 5220 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_mode_result, 5221 bypass, "bypass"); 5222 cmdline_parse_token_string_t cmd_setbypass_mode_mode = 5223 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_mode_result, 5224 mode, "mode"); 5225 cmdline_parse_token_string_t cmd_setbypass_mode_value = 5226 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_mode_result, 5227 value, "normal#bypass#isolate"); 5228 cmdline_parse_token_num_t cmd_setbypass_mode_port = 5229 TOKEN_NUM_INITIALIZER(struct cmd_set_bypass_mode_result, 5230 port_id, UINT16); 5231 5232 cmdline_parse_inst_t cmd_set_bypass_mode = { 5233 .f = cmd_set_bypass_mode_parsed, 5234 .help_str = "set bypass mode normal|bypass|isolate <port_id>: " 5235 "Set the NIC bypass mode for port_id", 5236 .data = NULL, 5237 .tokens = { 5238 (void *)&cmd_setbypass_mode_set, 5239 (void *)&cmd_setbypass_mode_bypass, 5240 (void *)&cmd_setbypass_mode_mode, 5241 (void *)&cmd_setbypass_mode_value, 5242 (void *)&cmd_setbypass_mode_port, 5243 NULL, 5244 }, 5245 }; 5246 5247 /* *** SET NIC BYPASS EVENT *** */ 5248 struct cmd_set_bypass_event_result { 5249 cmdline_fixed_string_t set; 5250 cmdline_fixed_string_t bypass; 5251 cmdline_fixed_string_t event; 5252 cmdline_fixed_string_t event_value; 5253 cmdline_fixed_string_t mode; 5254 cmdline_fixed_string_t mode_value; 5255 portid_t port_id; 5256 }; 5257 5258 static void 5259 cmd_set_bypass_event_parsed(void *parsed_result, 5260 __attribute__((unused)) struct cmdline *cl, 5261 __attribute__((unused)) void *data) 5262 { 5263 int32_t rc = -EINVAL; 5264 struct cmd_set_bypass_event_result *res = parsed_result; 5265 portid_t port_id = res->port_id; 5266 5267 #if defined RTE_LIBRTE_IXGBE_PMD && defined RTE_LIBRTE_IXGBE_BYPASS 5268 uint32_t bypass_event = RTE_PMD_IXGBE_BYPASS_EVENT_NONE; 5269 uint32_t bypass_mode = RTE_PMD_IXGBE_BYPASS_MODE_NORMAL; 5270 5271 if (!strcmp(res->event_value, "timeout")) 5272 bypass_event = RTE_PMD_IXGBE_BYPASS_EVENT_TIMEOUT; 5273 else if (!strcmp(res->event_value, "os_on")) 5274 bypass_event = RTE_PMD_IXGBE_BYPASS_EVENT_OS_ON; 5275 else if (!strcmp(res->event_value, "os_off")) 5276 bypass_event = RTE_PMD_IXGBE_BYPASS_EVENT_OS_OFF; 5277 else if (!strcmp(res->event_value, "power_on")) 5278 bypass_event = RTE_PMD_IXGBE_BYPASS_EVENT_POWER_ON; 5279 else if (!strcmp(res->event_value, "power_off")) 5280 bypass_event = RTE_PMD_IXGBE_BYPASS_EVENT_POWER_OFF; 5281 else 5282 bypass_event = RTE_PMD_IXGBE_BYPASS_EVENT_NONE; 5283 5284 if (!strcmp(res->mode_value, "bypass")) 5285 bypass_mode = RTE_PMD_IXGBE_BYPASS_MODE_BYPASS; 5286 else if (!strcmp(res->mode_value, "isolate")) 5287 bypass_mode = RTE_PMD_IXGBE_BYPASS_MODE_ISOLATE; 5288 else 5289 bypass_mode = RTE_PMD_IXGBE_BYPASS_MODE_NORMAL; 5290 5291 /* Set the watchdog timeout. */ 5292 if (bypass_event == RTE_PMD_IXGBE_BYPASS_EVENT_TIMEOUT) { 5293 5294 rc = -EINVAL; 5295 if (RTE_PMD_IXGBE_BYPASS_TMT_VALID(bypass_timeout)) { 5296 rc = rte_pmd_ixgbe_bypass_wd_timeout_store(port_id, 5297 bypass_timeout); 5298 } 5299 if (rc != 0) { 5300 printf("Failed to set timeout value %u " 5301 "for port %d, errto code: %d.\n", 5302 bypass_timeout, port_id, rc); 5303 } 5304 } 5305 5306 /* Set the bypass event to transition to bypass mode. */ 5307 rc = rte_pmd_ixgbe_bypass_event_store(port_id, bypass_event, 5308 bypass_mode); 5309 #endif 5310 5311 if (rc != 0) 5312 printf("\t Failed to set bypass event for port = %d.\n", 5313 port_id); 5314 } 5315 5316 cmdline_parse_token_string_t cmd_setbypass_event_set = 5317 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_event_result, 5318 set, "set"); 5319 cmdline_parse_token_string_t cmd_setbypass_event_bypass = 5320 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_event_result, 5321 bypass, "bypass"); 5322 cmdline_parse_token_string_t cmd_setbypass_event_event = 5323 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_event_result, 5324 event, "event"); 5325 cmdline_parse_token_string_t cmd_setbypass_event_event_value = 5326 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_event_result, 5327 event_value, "none#timeout#os_off#os_on#power_on#power_off"); 5328 cmdline_parse_token_string_t cmd_setbypass_event_mode = 5329 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_event_result, 5330 mode, "mode"); 5331 cmdline_parse_token_string_t cmd_setbypass_event_mode_value = 5332 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_event_result, 5333 mode_value, "normal#bypass#isolate"); 5334 cmdline_parse_token_num_t cmd_setbypass_event_port = 5335 TOKEN_NUM_INITIALIZER(struct cmd_set_bypass_event_result, 5336 port_id, UINT16); 5337 5338 cmdline_parse_inst_t cmd_set_bypass_event = { 5339 .f = cmd_set_bypass_event_parsed, 5340 .help_str = "set bypass event none|timeout|os_on|os_off|power_on|" 5341 "power_off mode normal|bypass|isolate <port_id>: " 5342 "Set the NIC bypass event mode for port_id", 5343 .data = NULL, 5344 .tokens = { 5345 (void *)&cmd_setbypass_event_set, 5346 (void *)&cmd_setbypass_event_bypass, 5347 (void *)&cmd_setbypass_event_event, 5348 (void *)&cmd_setbypass_event_event_value, 5349 (void *)&cmd_setbypass_event_mode, 5350 (void *)&cmd_setbypass_event_mode_value, 5351 (void *)&cmd_setbypass_event_port, 5352 NULL, 5353 }, 5354 }; 5355 5356 5357 /* *** SET NIC BYPASS TIMEOUT *** */ 5358 struct cmd_set_bypass_timeout_result { 5359 cmdline_fixed_string_t set; 5360 cmdline_fixed_string_t bypass; 5361 cmdline_fixed_string_t timeout; 5362 cmdline_fixed_string_t value; 5363 }; 5364 5365 static void 5366 cmd_set_bypass_timeout_parsed(void *parsed_result, 5367 __attribute__((unused)) struct cmdline *cl, 5368 __attribute__((unused)) void *data) 5369 { 5370 __rte_unused struct cmd_set_bypass_timeout_result *res = parsed_result; 5371 5372 #if defined RTE_LIBRTE_IXGBE_PMD && defined RTE_LIBRTE_IXGBE_BYPASS 5373 if (!strcmp(res->value, "1.5")) 5374 bypass_timeout = RTE_PMD_IXGBE_BYPASS_TMT_1_5_SEC; 5375 else if (!strcmp(res->value, "2")) 5376 bypass_timeout = RTE_PMD_IXGBE_BYPASS_TMT_2_SEC; 5377 else if (!strcmp(res->value, "3")) 5378 bypass_timeout = RTE_PMD_IXGBE_BYPASS_TMT_3_SEC; 5379 else if (!strcmp(res->value, "4")) 5380 bypass_timeout = RTE_PMD_IXGBE_BYPASS_TMT_4_SEC; 5381 else if (!strcmp(res->value, "8")) 5382 bypass_timeout = RTE_PMD_IXGBE_BYPASS_TMT_8_SEC; 5383 else if (!strcmp(res->value, "16")) 5384 bypass_timeout = RTE_PMD_IXGBE_BYPASS_TMT_16_SEC; 5385 else if (!strcmp(res->value, "32")) 5386 bypass_timeout = RTE_PMD_IXGBE_BYPASS_TMT_32_SEC; 5387 else 5388 bypass_timeout = RTE_PMD_IXGBE_BYPASS_TMT_OFF; 5389 #endif 5390 } 5391 5392 cmdline_parse_token_string_t cmd_setbypass_timeout_set = 5393 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_timeout_result, 5394 set, "set"); 5395 cmdline_parse_token_string_t cmd_setbypass_timeout_bypass = 5396 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_timeout_result, 5397 bypass, "bypass"); 5398 cmdline_parse_token_string_t cmd_setbypass_timeout_timeout = 5399 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_timeout_result, 5400 timeout, "timeout"); 5401 cmdline_parse_token_string_t cmd_setbypass_timeout_value = 5402 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_timeout_result, 5403 value, "0#1.5#2#3#4#8#16#32"); 5404 5405 cmdline_parse_inst_t cmd_set_bypass_timeout = { 5406 .f = cmd_set_bypass_timeout_parsed, 5407 .help_str = "set bypass timeout 0|1.5|2|3|4|8|16|32: " 5408 "Set the NIC bypass watchdog timeout in seconds", 5409 .data = NULL, 5410 .tokens = { 5411 (void *)&cmd_setbypass_timeout_set, 5412 (void *)&cmd_setbypass_timeout_bypass, 5413 (void *)&cmd_setbypass_timeout_timeout, 5414 (void *)&cmd_setbypass_timeout_value, 5415 NULL, 5416 }, 5417 }; 5418 5419 /* *** SHOW NIC BYPASS MODE *** */ 5420 struct cmd_show_bypass_config_result { 5421 cmdline_fixed_string_t show; 5422 cmdline_fixed_string_t bypass; 5423 cmdline_fixed_string_t config; 5424 portid_t port_id; 5425 }; 5426 5427 static void 5428 cmd_show_bypass_config_parsed(void *parsed_result, 5429 __attribute__((unused)) struct cmdline *cl, 5430 __attribute__((unused)) void *data) 5431 { 5432 struct cmd_show_bypass_config_result *res = parsed_result; 5433 portid_t port_id = res->port_id; 5434 int rc = -EINVAL; 5435 #if defined RTE_LIBRTE_IXGBE_PMD && defined RTE_LIBRTE_IXGBE_BYPASS 5436 uint32_t event_mode; 5437 uint32_t bypass_mode; 5438 uint32_t timeout = bypass_timeout; 5439 int i; 5440 5441 static const char * const timeouts[RTE_PMD_IXGBE_BYPASS_TMT_NUM] = 5442 {"off", "1.5", "2", "3", "4", "8", "16", "32"}; 5443 static const char * const modes[RTE_PMD_IXGBE_BYPASS_MODE_NUM] = 5444 {"UNKNOWN", "normal", "bypass", "isolate"}; 5445 static const char * const events[RTE_PMD_IXGBE_BYPASS_EVENT_NUM] = { 5446 "NONE", 5447 "OS/board on", 5448 "power supply on", 5449 "OS/board off", 5450 "power supply off", 5451 "timeout"}; 5452 int num_events = (sizeof events) / (sizeof events[0]); 5453 5454 /* Display the bypass mode.*/ 5455 if (rte_pmd_ixgbe_bypass_state_show(port_id, &bypass_mode) != 0) { 5456 printf("\tFailed to get bypass mode for port = %d\n", port_id); 5457 return; 5458 } 5459 else { 5460 if (!RTE_PMD_IXGBE_BYPASS_MODE_VALID(bypass_mode)) 5461 bypass_mode = RTE_PMD_IXGBE_BYPASS_MODE_NONE; 5462 5463 printf("\tbypass mode = %s\n", modes[bypass_mode]); 5464 } 5465 5466 /* Display the bypass timeout.*/ 5467 if (!RTE_PMD_IXGBE_BYPASS_TMT_VALID(timeout)) 5468 timeout = RTE_PMD_IXGBE_BYPASS_TMT_OFF; 5469 5470 printf("\tbypass timeout = %s\n", timeouts[timeout]); 5471 5472 /* Display the bypass events and associated modes. */ 5473 for (i = RTE_PMD_IXGBE_BYPASS_EVENT_START; i < num_events; i++) { 5474 5475 if (rte_pmd_ixgbe_bypass_event_show(port_id, i, &event_mode)) { 5476 printf("\tFailed to get bypass mode for event = %s\n", 5477 events[i]); 5478 } else { 5479 if (!RTE_PMD_IXGBE_BYPASS_MODE_VALID(event_mode)) 5480 event_mode = RTE_PMD_IXGBE_BYPASS_MODE_NONE; 5481 5482 printf("\tbypass event: %-16s = %s\n", events[i], 5483 modes[event_mode]); 5484 } 5485 } 5486 #endif 5487 if (rc != 0) 5488 printf("\tFailed to get bypass configuration for port = %d\n", 5489 port_id); 5490 } 5491 5492 cmdline_parse_token_string_t cmd_showbypass_config_show = 5493 TOKEN_STRING_INITIALIZER(struct cmd_show_bypass_config_result, 5494 show, "show"); 5495 cmdline_parse_token_string_t cmd_showbypass_config_bypass = 5496 TOKEN_STRING_INITIALIZER(struct cmd_show_bypass_config_result, 5497 bypass, "bypass"); 5498 cmdline_parse_token_string_t cmd_showbypass_config_config = 5499 TOKEN_STRING_INITIALIZER(struct cmd_show_bypass_config_result, 5500 config, "config"); 5501 cmdline_parse_token_num_t cmd_showbypass_config_port = 5502 TOKEN_NUM_INITIALIZER(struct cmd_show_bypass_config_result, 5503 port_id, UINT16); 5504 5505 cmdline_parse_inst_t cmd_show_bypass_config = { 5506 .f = cmd_show_bypass_config_parsed, 5507 .help_str = "show bypass config <port_id>: " 5508 "Show the NIC bypass config for port_id", 5509 .data = NULL, 5510 .tokens = { 5511 (void *)&cmd_showbypass_config_show, 5512 (void *)&cmd_showbypass_config_bypass, 5513 (void *)&cmd_showbypass_config_config, 5514 (void *)&cmd_showbypass_config_port, 5515 NULL, 5516 }, 5517 }; 5518 5519 #ifdef RTE_LIBRTE_PMD_BOND 5520 /* *** SET BONDING MODE *** */ 5521 struct cmd_set_bonding_mode_result { 5522 cmdline_fixed_string_t set; 5523 cmdline_fixed_string_t bonding; 5524 cmdline_fixed_string_t mode; 5525 uint8_t value; 5526 portid_t port_id; 5527 }; 5528 5529 static void cmd_set_bonding_mode_parsed(void *parsed_result, 5530 __attribute__((unused)) struct cmdline *cl, 5531 __attribute__((unused)) void *data) 5532 { 5533 struct cmd_set_bonding_mode_result *res = parsed_result; 5534 portid_t port_id = res->port_id; 5535 5536 /* Set the bonding mode for the relevant port. */ 5537 if (0 != rte_eth_bond_mode_set(port_id, res->value)) 5538 printf("\t Failed to set bonding mode for port = %d.\n", port_id); 5539 } 5540 5541 cmdline_parse_token_string_t cmd_setbonding_mode_set = 5542 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_mode_result, 5543 set, "set"); 5544 cmdline_parse_token_string_t cmd_setbonding_mode_bonding = 5545 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_mode_result, 5546 bonding, "bonding"); 5547 cmdline_parse_token_string_t cmd_setbonding_mode_mode = 5548 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_mode_result, 5549 mode, "mode"); 5550 cmdline_parse_token_num_t cmd_setbonding_mode_value = 5551 TOKEN_NUM_INITIALIZER(struct cmd_set_bonding_mode_result, 5552 value, UINT8); 5553 cmdline_parse_token_num_t cmd_setbonding_mode_port = 5554 TOKEN_NUM_INITIALIZER(struct cmd_set_bonding_mode_result, 5555 port_id, UINT16); 5556 5557 cmdline_parse_inst_t cmd_set_bonding_mode = { 5558 .f = cmd_set_bonding_mode_parsed, 5559 .help_str = "set bonding mode <mode_value> <port_id>: " 5560 "Set the bonding mode for port_id", 5561 .data = NULL, 5562 .tokens = { 5563 (void *) &cmd_setbonding_mode_set, 5564 (void *) &cmd_setbonding_mode_bonding, 5565 (void *) &cmd_setbonding_mode_mode, 5566 (void *) &cmd_setbonding_mode_value, 5567 (void *) &cmd_setbonding_mode_port, 5568 NULL 5569 } 5570 }; 5571 5572 /* *** SET BONDING SLOW_QUEUE SW/HW *** */ 5573 struct cmd_set_bonding_lacp_dedicated_queues_result { 5574 cmdline_fixed_string_t set; 5575 cmdline_fixed_string_t bonding; 5576 cmdline_fixed_string_t lacp; 5577 cmdline_fixed_string_t dedicated_queues; 5578 portid_t port_id; 5579 cmdline_fixed_string_t mode; 5580 }; 5581 5582 static void cmd_set_bonding_lacp_dedicated_queues_parsed(void *parsed_result, 5583 __attribute__((unused)) struct cmdline *cl, 5584 __attribute__((unused)) void *data) 5585 { 5586 struct cmd_set_bonding_lacp_dedicated_queues_result *res = parsed_result; 5587 portid_t port_id = res->port_id; 5588 struct rte_port *port; 5589 5590 port = &ports[port_id]; 5591 5592 /** Check if the port is not started **/ 5593 if (port->port_status != RTE_PORT_STOPPED) { 5594 printf("Please stop port %d first\n", port_id); 5595 return; 5596 } 5597 5598 if (!strcmp(res->mode, "enable")) { 5599 if (rte_eth_bond_8023ad_dedicated_queues_enable(port_id) == 0) 5600 printf("Dedicate queues for LACP control packets" 5601 " enabled\n"); 5602 else 5603 printf("Enabling dedicate queues for LACP control " 5604 "packets on port %d failed\n", port_id); 5605 } else if (!strcmp(res->mode, "disable")) { 5606 if (rte_eth_bond_8023ad_dedicated_queues_disable(port_id) == 0) 5607 printf("Dedicated queues for LACP control packets " 5608 "disabled\n"); 5609 else 5610 printf("Disabling dedicated queues for LACP control " 5611 "traffic on port %d failed\n", port_id); 5612 } 5613 } 5614 5615 cmdline_parse_token_string_t cmd_setbonding_lacp_dedicated_queues_set = 5616 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_lacp_dedicated_queues_result, 5617 set, "set"); 5618 cmdline_parse_token_string_t cmd_setbonding_lacp_dedicated_queues_bonding = 5619 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_lacp_dedicated_queues_result, 5620 bonding, "bonding"); 5621 cmdline_parse_token_string_t cmd_setbonding_lacp_dedicated_queues_lacp = 5622 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_lacp_dedicated_queues_result, 5623 lacp, "lacp"); 5624 cmdline_parse_token_string_t cmd_setbonding_lacp_dedicated_queues_dedicated_queues = 5625 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_lacp_dedicated_queues_result, 5626 dedicated_queues, "dedicated_queues"); 5627 cmdline_parse_token_num_t cmd_setbonding_lacp_dedicated_queues_port_id = 5628 TOKEN_NUM_INITIALIZER(struct cmd_set_bonding_lacp_dedicated_queues_result, 5629 port_id, UINT16); 5630 cmdline_parse_token_string_t cmd_setbonding_lacp_dedicated_queues_mode = 5631 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_lacp_dedicated_queues_result, 5632 mode, "enable#disable"); 5633 5634 cmdline_parse_inst_t cmd_set_lacp_dedicated_queues = { 5635 .f = cmd_set_bonding_lacp_dedicated_queues_parsed, 5636 .help_str = "set bonding lacp dedicated_queues <port_id> " 5637 "enable|disable: " 5638 "Enable/disable dedicated queues for LACP control traffic for port_id", 5639 .data = NULL, 5640 .tokens = { 5641 (void *)&cmd_setbonding_lacp_dedicated_queues_set, 5642 (void *)&cmd_setbonding_lacp_dedicated_queues_bonding, 5643 (void *)&cmd_setbonding_lacp_dedicated_queues_lacp, 5644 (void *)&cmd_setbonding_lacp_dedicated_queues_dedicated_queues, 5645 (void *)&cmd_setbonding_lacp_dedicated_queues_port_id, 5646 (void *)&cmd_setbonding_lacp_dedicated_queues_mode, 5647 NULL 5648 } 5649 }; 5650 5651 /* *** SET BALANCE XMIT POLICY *** */ 5652 struct cmd_set_bonding_balance_xmit_policy_result { 5653 cmdline_fixed_string_t set; 5654 cmdline_fixed_string_t bonding; 5655 cmdline_fixed_string_t balance_xmit_policy; 5656 portid_t port_id; 5657 cmdline_fixed_string_t policy; 5658 }; 5659 5660 static void cmd_set_bonding_balance_xmit_policy_parsed(void *parsed_result, 5661 __attribute__((unused)) struct cmdline *cl, 5662 __attribute__((unused)) void *data) 5663 { 5664 struct cmd_set_bonding_balance_xmit_policy_result *res = parsed_result; 5665 portid_t port_id = res->port_id; 5666 uint8_t policy; 5667 5668 if (!strcmp(res->policy, "l2")) { 5669 policy = BALANCE_XMIT_POLICY_LAYER2; 5670 } else if (!strcmp(res->policy, "l23")) { 5671 policy = BALANCE_XMIT_POLICY_LAYER23; 5672 } else if (!strcmp(res->policy, "l34")) { 5673 policy = BALANCE_XMIT_POLICY_LAYER34; 5674 } else { 5675 printf("\t Invalid xmit policy selection"); 5676 return; 5677 } 5678 5679 /* Set the bonding mode for the relevant port. */ 5680 if (0 != rte_eth_bond_xmit_policy_set(port_id, policy)) { 5681 printf("\t Failed to set bonding balance xmit policy for port = %d.\n", 5682 port_id); 5683 } 5684 } 5685 5686 cmdline_parse_token_string_t cmd_setbonding_balance_xmit_policy_set = 5687 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_balance_xmit_policy_result, 5688 set, "set"); 5689 cmdline_parse_token_string_t cmd_setbonding_balance_xmit_policy_bonding = 5690 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_balance_xmit_policy_result, 5691 bonding, "bonding"); 5692 cmdline_parse_token_string_t cmd_setbonding_balance_xmit_policy_balance_xmit_policy = 5693 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_balance_xmit_policy_result, 5694 balance_xmit_policy, "balance_xmit_policy"); 5695 cmdline_parse_token_num_t cmd_setbonding_balance_xmit_policy_port = 5696 TOKEN_NUM_INITIALIZER(struct cmd_set_bonding_balance_xmit_policy_result, 5697 port_id, UINT16); 5698 cmdline_parse_token_string_t cmd_setbonding_balance_xmit_policy_policy = 5699 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_balance_xmit_policy_result, 5700 policy, "l2#l23#l34"); 5701 5702 cmdline_parse_inst_t cmd_set_balance_xmit_policy = { 5703 .f = cmd_set_bonding_balance_xmit_policy_parsed, 5704 .help_str = "set bonding balance_xmit_policy <port_id> " 5705 "l2|l23|l34: " 5706 "Set the bonding balance_xmit_policy for port_id", 5707 .data = NULL, 5708 .tokens = { 5709 (void *)&cmd_setbonding_balance_xmit_policy_set, 5710 (void *)&cmd_setbonding_balance_xmit_policy_bonding, 5711 (void *)&cmd_setbonding_balance_xmit_policy_balance_xmit_policy, 5712 (void *)&cmd_setbonding_balance_xmit_policy_port, 5713 (void *)&cmd_setbonding_balance_xmit_policy_policy, 5714 NULL 5715 } 5716 }; 5717 5718 /* *** SHOW NIC BONDING CONFIGURATION *** */ 5719 struct cmd_show_bonding_config_result { 5720 cmdline_fixed_string_t show; 5721 cmdline_fixed_string_t bonding; 5722 cmdline_fixed_string_t config; 5723 portid_t port_id; 5724 }; 5725 5726 static void cmd_show_bonding_config_parsed(void *parsed_result, 5727 __attribute__((unused)) struct cmdline *cl, 5728 __attribute__((unused)) void *data) 5729 { 5730 struct cmd_show_bonding_config_result *res = parsed_result; 5731 int bonding_mode, agg_mode; 5732 portid_t slaves[RTE_MAX_ETHPORTS]; 5733 int num_slaves, num_active_slaves; 5734 int primary_id; 5735 int i; 5736 portid_t port_id = res->port_id; 5737 5738 /* Display the bonding mode.*/ 5739 bonding_mode = rte_eth_bond_mode_get(port_id); 5740 if (bonding_mode < 0) { 5741 printf("\tFailed to get bonding mode for port = %d\n", port_id); 5742 return; 5743 } else 5744 printf("\tBonding mode: %d\n", bonding_mode); 5745 5746 if (bonding_mode == BONDING_MODE_BALANCE) { 5747 int balance_xmit_policy; 5748 5749 balance_xmit_policy = rte_eth_bond_xmit_policy_get(port_id); 5750 if (balance_xmit_policy < 0) { 5751 printf("\tFailed to get balance xmit policy for port = %d\n", 5752 port_id); 5753 return; 5754 } else { 5755 printf("\tBalance Xmit Policy: "); 5756 5757 switch (balance_xmit_policy) { 5758 case BALANCE_XMIT_POLICY_LAYER2: 5759 printf("BALANCE_XMIT_POLICY_LAYER2"); 5760 break; 5761 case BALANCE_XMIT_POLICY_LAYER23: 5762 printf("BALANCE_XMIT_POLICY_LAYER23"); 5763 break; 5764 case BALANCE_XMIT_POLICY_LAYER34: 5765 printf("BALANCE_XMIT_POLICY_LAYER34"); 5766 break; 5767 } 5768 printf("\n"); 5769 } 5770 } 5771 5772 if (bonding_mode == BONDING_MODE_8023AD) { 5773 agg_mode = rte_eth_bond_8023ad_agg_selection_get(port_id); 5774 printf("\tIEEE802.3AD Aggregator Mode: "); 5775 switch (agg_mode) { 5776 case AGG_BANDWIDTH: 5777 printf("bandwidth"); 5778 break; 5779 case AGG_STABLE: 5780 printf("stable"); 5781 break; 5782 case AGG_COUNT: 5783 printf("count"); 5784 break; 5785 } 5786 printf("\n"); 5787 } 5788 5789 num_slaves = rte_eth_bond_slaves_get(port_id, slaves, RTE_MAX_ETHPORTS); 5790 5791 if (num_slaves < 0) { 5792 printf("\tFailed to get slave list for port = %d\n", port_id); 5793 return; 5794 } 5795 if (num_slaves > 0) { 5796 printf("\tSlaves (%d): [", num_slaves); 5797 for (i = 0; i < num_slaves - 1; i++) 5798 printf("%d ", slaves[i]); 5799 5800 printf("%d]\n", slaves[num_slaves - 1]); 5801 } else { 5802 printf("\tSlaves: []\n"); 5803 5804 } 5805 5806 num_active_slaves = rte_eth_bond_active_slaves_get(port_id, slaves, 5807 RTE_MAX_ETHPORTS); 5808 5809 if (num_active_slaves < 0) { 5810 printf("\tFailed to get active slave list for port = %d\n", port_id); 5811 return; 5812 } 5813 if (num_active_slaves > 0) { 5814 printf("\tActive Slaves (%d): [", num_active_slaves); 5815 for (i = 0; i < num_active_slaves - 1; i++) 5816 printf("%d ", slaves[i]); 5817 5818 printf("%d]\n", slaves[num_active_slaves - 1]); 5819 5820 } else { 5821 printf("\tActive Slaves: []\n"); 5822 5823 } 5824 5825 primary_id = rte_eth_bond_primary_get(port_id); 5826 if (primary_id < 0) { 5827 printf("\tFailed to get primary slave for port = %d\n", port_id); 5828 return; 5829 } else 5830 printf("\tPrimary: [%d]\n", primary_id); 5831 5832 } 5833 5834 cmdline_parse_token_string_t cmd_showbonding_config_show = 5835 TOKEN_STRING_INITIALIZER(struct cmd_show_bonding_config_result, 5836 show, "show"); 5837 cmdline_parse_token_string_t cmd_showbonding_config_bonding = 5838 TOKEN_STRING_INITIALIZER(struct cmd_show_bonding_config_result, 5839 bonding, "bonding"); 5840 cmdline_parse_token_string_t cmd_showbonding_config_config = 5841 TOKEN_STRING_INITIALIZER(struct cmd_show_bonding_config_result, 5842 config, "config"); 5843 cmdline_parse_token_num_t cmd_showbonding_config_port = 5844 TOKEN_NUM_INITIALIZER(struct cmd_show_bonding_config_result, 5845 port_id, UINT16); 5846 5847 cmdline_parse_inst_t cmd_show_bonding_config = { 5848 .f = cmd_show_bonding_config_parsed, 5849 .help_str = "show bonding config <port_id>: " 5850 "Show the bonding config for port_id", 5851 .data = NULL, 5852 .tokens = { 5853 (void *)&cmd_showbonding_config_show, 5854 (void *)&cmd_showbonding_config_bonding, 5855 (void *)&cmd_showbonding_config_config, 5856 (void *)&cmd_showbonding_config_port, 5857 NULL 5858 } 5859 }; 5860 5861 /* *** SET BONDING PRIMARY *** */ 5862 struct cmd_set_bonding_primary_result { 5863 cmdline_fixed_string_t set; 5864 cmdline_fixed_string_t bonding; 5865 cmdline_fixed_string_t primary; 5866 portid_t slave_id; 5867 portid_t port_id; 5868 }; 5869 5870 static void cmd_set_bonding_primary_parsed(void *parsed_result, 5871 __attribute__((unused)) struct cmdline *cl, 5872 __attribute__((unused)) void *data) 5873 { 5874 struct cmd_set_bonding_primary_result *res = parsed_result; 5875 portid_t master_port_id = res->port_id; 5876 portid_t slave_port_id = res->slave_id; 5877 5878 /* Set the primary slave for a bonded device. */ 5879 if (0 != rte_eth_bond_primary_set(master_port_id, slave_port_id)) { 5880 printf("\t Failed to set primary slave for port = %d.\n", 5881 master_port_id); 5882 return; 5883 } 5884 init_port_config(); 5885 } 5886 5887 cmdline_parse_token_string_t cmd_setbonding_primary_set = 5888 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_primary_result, 5889 set, "set"); 5890 cmdline_parse_token_string_t cmd_setbonding_primary_bonding = 5891 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_primary_result, 5892 bonding, "bonding"); 5893 cmdline_parse_token_string_t cmd_setbonding_primary_primary = 5894 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_primary_result, 5895 primary, "primary"); 5896 cmdline_parse_token_num_t cmd_setbonding_primary_slave = 5897 TOKEN_NUM_INITIALIZER(struct cmd_set_bonding_primary_result, 5898 slave_id, UINT16); 5899 cmdline_parse_token_num_t cmd_setbonding_primary_port = 5900 TOKEN_NUM_INITIALIZER(struct cmd_set_bonding_primary_result, 5901 port_id, UINT16); 5902 5903 cmdline_parse_inst_t cmd_set_bonding_primary = { 5904 .f = cmd_set_bonding_primary_parsed, 5905 .help_str = "set bonding primary <slave_id> <port_id>: " 5906 "Set the primary slave for port_id", 5907 .data = NULL, 5908 .tokens = { 5909 (void *)&cmd_setbonding_primary_set, 5910 (void *)&cmd_setbonding_primary_bonding, 5911 (void *)&cmd_setbonding_primary_primary, 5912 (void *)&cmd_setbonding_primary_slave, 5913 (void *)&cmd_setbonding_primary_port, 5914 NULL 5915 } 5916 }; 5917 5918 /* *** ADD SLAVE *** */ 5919 struct cmd_add_bonding_slave_result { 5920 cmdline_fixed_string_t add; 5921 cmdline_fixed_string_t bonding; 5922 cmdline_fixed_string_t slave; 5923 portid_t slave_id; 5924 portid_t port_id; 5925 }; 5926 5927 static void cmd_add_bonding_slave_parsed(void *parsed_result, 5928 __attribute__((unused)) struct cmdline *cl, 5929 __attribute__((unused)) void *data) 5930 { 5931 struct cmd_add_bonding_slave_result *res = parsed_result; 5932 portid_t master_port_id = res->port_id; 5933 portid_t slave_port_id = res->slave_id; 5934 5935 /* add the slave for a bonded device. */ 5936 if (0 != rte_eth_bond_slave_add(master_port_id, slave_port_id)) { 5937 printf("\t Failed to add slave %d to master port = %d.\n", 5938 slave_port_id, master_port_id); 5939 return; 5940 } 5941 init_port_config(); 5942 set_port_slave_flag(slave_port_id); 5943 } 5944 5945 cmdline_parse_token_string_t cmd_addbonding_slave_add = 5946 TOKEN_STRING_INITIALIZER(struct cmd_add_bonding_slave_result, 5947 add, "add"); 5948 cmdline_parse_token_string_t cmd_addbonding_slave_bonding = 5949 TOKEN_STRING_INITIALIZER(struct cmd_add_bonding_slave_result, 5950 bonding, "bonding"); 5951 cmdline_parse_token_string_t cmd_addbonding_slave_slave = 5952 TOKEN_STRING_INITIALIZER(struct cmd_add_bonding_slave_result, 5953 slave, "slave"); 5954 cmdline_parse_token_num_t cmd_addbonding_slave_slaveid = 5955 TOKEN_NUM_INITIALIZER(struct cmd_add_bonding_slave_result, 5956 slave_id, UINT16); 5957 cmdline_parse_token_num_t cmd_addbonding_slave_port = 5958 TOKEN_NUM_INITIALIZER(struct cmd_add_bonding_slave_result, 5959 port_id, UINT16); 5960 5961 cmdline_parse_inst_t cmd_add_bonding_slave = { 5962 .f = cmd_add_bonding_slave_parsed, 5963 .help_str = "add bonding slave <slave_id> <port_id>: " 5964 "Add a slave device to a bonded device", 5965 .data = NULL, 5966 .tokens = { 5967 (void *)&cmd_addbonding_slave_add, 5968 (void *)&cmd_addbonding_slave_bonding, 5969 (void *)&cmd_addbonding_slave_slave, 5970 (void *)&cmd_addbonding_slave_slaveid, 5971 (void *)&cmd_addbonding_slave_port, 5972 NULL 5973 } 5974 }; 5975 5976 /* *** REMOVE SLAVE *** */ 5977 struct cmd_remove_bonding_slave_result { 5978 cmdline_fixed_string_t remove; 5979 cmdline_fixed_string_t bonding; 5980 cmdline_fixed_string_t slave; 5981 portid_t slave_id; 5982 portid_t port_id; 5983 }; 5984 5985 static void cmd_remove_bonding_slave_parsed(void *parsed_result, 5986 __attribute__((unused)) struct cmdline *cl, 5987 __attribute__((unused)) void *data) 5988 { 5989 struct cmd_remove_bonding_slave_result *res = parsed_result; 5990 portid_t master_port_id = res->port_id; 5991 portid_t slave_port_id = res->slave_id; 5992 5993 /* remove the slave from a bonded device. */ 5994 if (0 != rte_eth_bond_slave_remove(master_port_id, slave_port_id)) { 5995 printf("\t Failed to remove slave %d from master port = %d.\n", 5996 slave_port_id, master_port_id); 5997 return; 5998 } 5999 init_port_config(); 6000 clear_port_slave_flag(slave_port_id); 6001 } 6002 6003 cmdline_parse_token_string_t cmd_removebonding_slave_remove = 6004 TOKEN_STRING_INITIALIZER(struct cmd_remove_bonding_slave_result, 6005 remove, "remove"); 6006 cmdline_parse_token_string_t cmd_removebonding_slave_bonding = 6007 TOKEN_STRING_INITIALIZER(struct cmd_remove_bonding_slave_result, 6008 bonding, "bonding"); 6009 cmdline_parse_token_string_t cmd_removebonding_slave_slave = 6010 TOKEN_STRING_INITIALIZER(struct cmd_remove_bonding_slave_result, 6011 slave, "slave"); 6012 cmdline_parse_token_num_t cmd_removebonding_slave_slaveid = 6013 TOKEN_NUM_INITIALIZER(struct cmd_remove_bonding_slave_result, 6014 slave_id, UINT16); 6015 cmdline_parse_token_num_t cmd_removebonding_slave_port = 6016 TOKEN_NUM_INITIALIZER(struct cmd_remove_bonding_slave_result, 6017 port_id, UINT16); 6018 6019 cmdline_parse_inst_t cmd_remove_bonding_slave = { 6020 .f = cmd_remove_bonding_slave_parsed, 6021 .help_str = "remove bonding slave <slave_id> <port_id>: " 6022 "Remove a slave device from a bonded device", 6023 .data = NULL, 6024 .tokens = { 6025 (void *)&cmd_removebonding_slave_remove, 6026 (void *)&cmd_removebonding_slave_bonding, 6027 (void *)&cmd_removebonding_slave_slave, 6028 (void *)&cmd_removebonding_slave_slaveid, 6029 (void *)&cmd_removebonding_slave_port, 6030 NULL 6031 } 6032 }; 6033 6034 /* *** CREATE BONDED DEVICE *** */ 6035 struct cmd_create_bonded_device_result { 6036 cmdline_fixed_string_t create; 6037 cmdline_fixed_string_t bonded; 6038 cmdline_fixed_string_t device; 6039 uint8_t mode; 6040 uint8_t socket; 6041 }; 6042 6043 static int bond_dev_num = 0; 6044 6045 static void cmd_create_bonded_device_parsed(void *parsed_result, 6046 __attribute__((unused)) struct cmdline *cl, 6047 __attribute__((unused)) void *data) 6048 { 6049 struct cmd_create_bonded_device_result *res = parsed_result; 6050 char ethdev_name[RTE_ETH_NAME_MAX_LEN]; 6051 int port_id; 6052 6053 if (test_done == 0) { 6054 printf("Please stop forwarding first\n"); 6055 return; 6056 } 6057 6058 snprintf(ethdev_name, RTE_ETH_NAME_MAX_LEN, "net_bonding_testpmd_%d", 6059 bond_dev_num++); 6060 6061 /* Create a new bonded device. */ 6062 port_id = rte_eth_bond_create(ethdev_name, res->mode, res->socket); 6063 if (port_id < 0) { 6064 printf("\t Failed to create bonded device.\n"); 6065 return; 6066 } else { 6067 printf("Created new bonded device %s on (port %d).\n", ethdev_name, 6068 port_id); 6069 6070 /* Update number of ports */ 6071 nb_ports = rte_eth_dev_count_avail(); 6072 reconfig(port_id, res->socket); 6073 rte_eth_promiscuous_enable(port_id); 6074 ports[port_id].need_setup = 0; 6075 ports[port_id].port_status = RTE_PORT_STOPPED; 6076 } 6077 6078 } 6079 6080 cmdline_parse_token_string_t cmd_createbonded_device_create = 6081 TOKEN_STRING_INITIALIZER(struct cmd_create_bonded_device_result, 6082 create, "create"); 6083 cmdline_parse_token_string_t cmd_createbonded_device_bonded = 6084 TOKEN_STRING_INITIALIZER(struct cmd_create_bonded_device_result, 6085 bonded, "bonded"); 6086 cmdline_parse_token_string_t cmd_createbonded_device_device = 6087 TOKEN_STRING_INITIALIZER(struct cmd_create_bonded_device_result, 6088 device, "device"); 6089 cmdline_parse_token_num_t cmd_createbonded_device_mode = 6090 TOKEN_NUM_INITIALIZER(struct cmd_create_bonded_device_result, 6091 mode, UINT8); 6092 cmdline_parse_token_num_t cmd_createbonded_device_socket = 6093 TOKEN_NUM_INITIALIZER(struct cmd_create_bonded_device_result, 6094 socket, UINT8); 6095 6096 cmdline_parse_inst_t cmd_create_bonded_device = { 6097 .f = cmd_create_bonded_device_parsed, 6098 .help_str = "create bonded device <mode> <socket>: " 6099 "Create a new bonded device with specific bonding mode and socket", 6100 .data = NULL, 6101 .tokens = { 6102 (void *)&cmd_createbonded_device_create, 6103 (void *)&cmd_createbonded_device_bonded, 6104 (void *)&cmd_createbonded_device_device, 6105 (void *)&cmd_createbonded_device_mode, 6106 (void *)&cmd_createbonded_device_socket, 6107 NULL 6108 } 6109 }; 6110 6111 /* *** SET MAC ADDRESS IN BONDED DEVICE *** */ 6112 struct cmd_set_bond_mac_addr_result { 6113 cmdline_fixed_string_t set; 6114 cmdline_fixed_string_t bonding; 6115 cmdline_fixed_string_t mac_addr; 6116 uint16_t port_num; 6117 struct rte_ether_addr address; 6118 }; 6119 6120 static void cmd_set_bond_mac_addr_parsed(void *parsed_result, 6121 __attribute__((unused)) struct cmdline *cl, 6122 __attribute__((unused)) void *data) 6123 { 6124 struct cmd_set_bond_mac_addr_result *res = parsed_result; 6125 int ret; 6126 6127 if (port_id_is_invalid(res->port_num, ENABLED_WARN)) 6128 return; 6129 6130 ret = rte_eth_bond_mac_address_set(res->port_num, &res->address); 6131 6132 /* check the return value and print it if is < 0 */ 6133 if (ret < 0) 6134 printf("set_bond_mac_addr error: (%s)\n", strerror(-ret)); 6135 } 6136 6137 cmdline_parse_token_string_t cmd_set_bond_mac_addr_set = 6138 TOKEN_STRING_INITIALIZER(struct cmd_set_bond_mac_addr_result, set, "set"); 6139 cmdline_parse_token_string_t cmd_set_bond_mac_addr_bonding = 6140 TOKEN_STRING_INITIALIZER(struct cmd_set_bond_mac_addr_result, bonding, 6141 "bonding"); 6142 cmdline_parse_token_string_t cmd_set_bond_mac_addr_mac = 6143 TOKEN_STRING_INITIALIZER(struct cmd_set_bond_mac_addr_result, mac_addr, 6144 "mac_addr"); 6145 cmdline_parse_token_num_t cmd_set_bond_mac_addr_portnum = 6146 TOKEN_NUM_INITIALIZER(struct cmd_set_bond_mac_addr_result, 6147 port_num, UINT16); 6148 cmdline_parse_token_etheraddr_t cmd_set_bond_mac_addr_addr = 6149 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_bond_mac_addr_result, address); 6150 6151 cmdline_parse_inst_t cmd_set_bond_mac_addr = { 6152 .f = cmd_set_bond_mac_addr_parsed, 6153 .data = (void *) 0, 6154 .help_str = "set bonding mac_addr <port_id> <mac_addr>", 6155 .tokens = { 6156 (void *)&cmd_set_bond_mac_addr_set, 6157 (void *)&cmd_set_bond_mac_addr_bonding, 6158 (void *)&cmd_set_bond_mac_addr_mac, 6159 (void *)&cmd_set_bond_mac_addr_portnum, 6160 (void *)&cmd_set_bond_mac_addr_addr, 6161 NULL 6162 } 6163 }; 6164 6165 6166 /* *** SET LINK STATUS MONITORING POLLING PERIOD ON BONDED DEVICE *** */ 6167 struct cmd_set_bond_mon_period_result { 6168 cmdline_fixed_string_t set; 6169 cmdline_fixed_string_t bonding; 6170 cmdline_fixed_string_t mon_period; 6171 uint16_t port_num; 6172 uint32_t period_ms; 6173 }; 6174 6175 static void cmd_set_bond_mon_period_parsed(void *parsed_result, 6176 __attribute__((unused)) struct cmdline *cl, 6177 __attribute__((unused)) void *data) 6178 { 6179 struct cmd_set_bond_mon_period_result *res = parsed_result; 6180 int ret; 6181 6182 ret = rte_eth_bond_link_monitoring_set(res->port_num, res->period_ms); 6183 6184 /* check the return value and print it if is < 0 */ 6185 if (ret < 0) 6186 printf("set_bond_mac_addr error: (%s)\n", strerror(-ret)); 6187 } 6188 6189 cmdline_parse_token_string_t cmd_set_bond_mon_period_set = 6190 TOKEN_STRING_INITIALIZER(struct cmd_set_bond_mon_period_result, 6191 set, "set"); 6192 cmdline_parse_token_string_t cmd_set_bond_mon_period_bonding = 6193 TOKEN_STRING_INITIALIZER(struct cmd_set_bond_mon_period_result, 6194 bonding, "bonding"); 6195 cmdline_parse_token_string_t cmd_set_bond_mon_period_mon_period = 6196 TOKEN_STRING_INITIALIZER(struct cmd_set_bond_mon_period_result, 6197 mon_period, "mon_period"); 6198 cmdline_parse_token_num_t cmd_set_bond_mon_period_portnum = 6199 TOKEN_NUM_INITIALIZER(struct cmd_set_bond_mon_period_result, 6200 port_num, UINT16); 6201 cmdline_parse_token_num_t cmd_set_bond_mon_period_period_ms = 6202 TOKEN_NUM_INITIALIZER(struct cmd_set_bond_mon_period_result, 6203 period_ms, UINT32); 6204 6205 cmdline_parse_inst_t cmd_set_bond_mon_period = { 6206 .f = cmd_set_bond_mon_period_parsed, 6207 .data = (void *) 0, 6208 .help_str = "set bonding mon_period <port_id> <period_ms>", 6209 .tokens = { 6210 (void *)&cmd_set_bond_mon_period_set, 6211 (void *)&cmd_set_bond_mon_period_bonding, 6212 (void *)&cmd_set_bond_mon_period_mon_period, 6213 (void *)&cmd_set_bond_mon_period_portnum, 6214 (void *)&cmd_set_bond_mon_period_period_ms, 6215 NULL 6216 } 6217 }; 6218 6219 6220 6221 struct cmd_set_bonding_agg_mode_policy_result { 6222 cmdline_fixed_string_t set; 6223 cmdline_fixed_string_t bonding; 6224 cmdline_fixed_string_t agg_mode; 6225 uint16_t port_num; 6226 cmdline_fixed_string_t policy; 6227 }; 6228 6229 6230 static void 6231 cmd_set_bonding_agg_mode(void *parsed_result, 6232 __attribute__((unused)) struct cmdline *cl, 6233 __attribute__((unused)) void *data) 6234 { 6235 struct cmd_set_bonding_agg_mode_policy_result *res = parsed_result; 6236 uint8_t policy = AGG_BANDWIDTH; 6237 6238 if (!strcmp(res->policy, "bandwidth")) 6239 policy = AGG_BANDWIDTH; 6240 else if (!strcmp(res->policy, "stable")) 6241 policy = AGG_STABLE; 6242 else if (!strcmp(res->policy, "count")) 6243 policy = AGG_COUNT; 6244 6245 rte_eth_bond_8023ad_agg_selection_set(res->port_num, policy); 6246 } 6247 6248 6249 cmdline_parse_token_string_t cmd_set_bonding_agg_mode_set = 6250 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_agg_mode_policy_result, 6251 set, "set"); 6252 cmdline_parse_token_string_t cmd_set_bonding_agg_mode_bonding = 6253 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_agg_mode_policy_result, 6254 bonding, "bonding"); 6255 6256 cmdline_parse_token_string_t cmd_set_bonding_agg_mode_agg_mode = 6257 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_agg_mode_policy_result, 6258 agg_mode, "agg_mode"); 6259 6260 cmdline_parse_token_num_t cmd_set_bonding_agg_mode_portnum = 6261 TOKEN_NUM_INITIALIZER(struct cmd_set_bonding_agg_mode_policy_result, 6262 port_num, UINT16); 6263 6264 cmdline_parse_token_string_t cmd_set_bonding_agg_mode_policy_string = 6265 TOKEN_STRING_INITIALIZER( 6266 struct cmd_set_bonding_balance_xmit_policy_result, 6267 policy, "stable#bandwidth#count"); 6268 6269 cmdline_parse_inst_t cmd_set_bonding_agg_mode_policy = { 6270 .f = cmd_set_bonding_agg_mode, 6271 .data = (void *) 0, 6272 .help_str = "set bonding mode IEEE802.3AD aggregator policy <port_id> <agg_name>", 6273 .tokens = { 6274 (void *)&cmd_set_bonding_agg_mode_set, 6275 (void *)&cmd_set_bonding_agg_mode_bonding, 6276 (void *)&cmd_set_bonding_agg_mode_agg_mode, 6277 (void *)&cmd_set_bonding_agg_mode_portnum, 6278 (void *)&cmd_set_bonding_agg_mode_policy_string, 6279 NULL 6280 } 6281 }; 6282 6283 6284 #endif /* RTE_LIBRTE_PMD_BOND */ 6285 6286 /* *** SET FORWARDING MODE *** */ 6287 struct cmd_set_fwd_mode_result { 6288 cmdline_fixed_string_t set; 6289 cmdline_fixed_string_t fwd; 6290 cmdline_fixed_string_t mode; 6291 }; 6292 6293 static void cmd_set_fwd_mode_parsed(void *parsed_result, 6294 __attribute__((unused)) struct cmdline *cl, 6295 __attribute__((unused)) void *data) 6296 { 6297 struct cmd_set_fwd_mode_result *res = parsed_result; 6298 6299 retry_enabled = 0; 6300 set_pkt_forwarding_mode(res->mode); 6301 } 6302 6303 cmdline_parse_token_string_t cmd_setfwd_set = 6304 TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_mode_result, set, "set"); 6305 cmdline_parse_token_string_t cmd_setfwd_fwd = 6306 TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_mode_result, fwd, "fwd"); 6307 cmdline_parse_token_string_t cmd_setfwd_mode = 6308 TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_mode_result, mode, 6309 "" /* defined at init */); 6310 6311 cmdline_parse_inst_t cmd_set_fwd_mode = { 6312 .f = cmd_set_fwd_mode_parsed, 6313 .data = NULL, 6314 .help_str = NULL, /* defined at init */ 6315 .tokens = { 6316 (void *)&cmd_setfwd_set, 6317 (void *)&cmd_setfwd_fwd, 6318 (void *)&cmd_setfwd_mode, 6319 NULL, 6320 }, 6321 }; 6322 6323 static void cmd_set_fwd_mode_init(void) 6324 { 6325 char *modes, *c; 6326 static char token[128]; 6327 static char help[256]; 6328 cmdline_parse_token_string_t *token_struct; 6329 6330 modes = list_pkt_forwarding_modes(); 6331 snprintf(help, sizeof(help), "set fwd %s: " 6332 "Set packet forwarding mode", modes); 6333 cmd_set_fwd_mode.help_str = help; 6334 6335 /* string token separator is # */ 6336 for (c = token; *modes != '\0'; modes++) 6337 if (*modes == '|') 6338 *c++ = '#'; 6339 else 6340 *c++ = *modes; 6341 token_struct = (cmdline_parse_token_string_t*)cmd_set_fwd_mode.tokens[2]; 6342 token_struct->string_data.str = token; 6343 } 6344 6345 /* *** SET RETRY FORWARDING MODE *** */ 6346 struct cmd_set_fwd_retry_mode_result { 6347 cmdline_fixed_string_t set; 6348 cmdline_fixed_string_t fwd; 6349 cmdline_fixed_string_t mode; 6350 cmdline_fixed_string_t retry; 6351 }; 6352 6353 static void cmd_set_fwd_retry_mode_parsed(void *parsed_result, 6354 __attribute__((unused)) struct cmdline *cl, 6355 __attribute__((unused)) void *data) 6356 { 6357 struct cmd_set_fwd_retry_mode_result *res = parsed_result; 6358 6359 retry_enabled = 1; 6360 set_pkt_forwarding_mode(res->mode); 6361 } 6362 6363 cmdline_parse_token_string_t cmd_setfwd_retry_set = 6364 TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_retry_mode_result, 6365 set, "set"); 6366 cmdline_parse_token_string_t cmd_setfwd_retry_fwd = 6367 TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_retry_mode_result, 6368 fwd, "fwd"); 6369 cmdline_parse_token_string_t cmd_setfwd_retry_mode = 6370 TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_retry_mode_result, 6371 mode, 6372 "" /* defined at init */); 6373 cmdline_parse_token_string_t cmd_setfwd_retry_retry = 6374 TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_retry_mode_result, 6375 retry, "retry"); 6376 6377 cmdline_parse_inst_t cmd_set_fwd_retry_mode = { 6378 .f = cmd_set_fwd_retry_mode_parsed, 6379 .data = NULL, 6380 .help_str = NULL, /* defined at init */ 6381 .tokens = { 6382 (void *)&cmd_setfwd_retry_set, 6383 (void *)&cmd_setfwd_retry_fwd, 6384 (void *)&cmd_setfwd_retry_mode, 6385 (void *)&cmd_setfwd_retry_retry, 6386 NULL, 6387 }, 6388 }; 6389 6390 static void cmd_set_fwd_retry_mode_init(void) 6391 { 6392 char *modes, *c; 6393 static char token[128]; 6394 static char help[256]; 6395 cmdline_parse_token_string_t *token_struct; 6396 6397 modes = list_pkt_forwarding_retry_modes(); 6398 snprintf(help, sizeof(help), "set fwd %s retry: " 6399 "Set packet forwarding mode with retry", modes); 6400 cmd_set_fwd_retry_mode.help_str = help; 6401 6402 /* string token separator is # */ 6403 for (c = token; *modes != '\0'; modes++) 6404 if (*modes == '|') 6405 *c++ = '#'; 6406 else 6407 *c++ = *modes; 6408 token_struct = (cmdline_parse_token_string_t *) 6409 cmd_set_fwd_retry_mode.tokens[2]; 6410 token_struct->string_data.str = token; 6411 } 6412 6413 /* *** SET BURST TX DELAY TIME RETRY NUMBER *** */ 6414 struct cmd_set_burst_tx_retry_result { 6415 cmdline_fixed_string_t set; 6416 cmdline_fixed_string_t burst; 6417 cmdline_fixed_string_t tx; 6418 cmdline_fixed_string_t delay; 6419 uint32_t time; 6420 cmdline_fixed_string_t retry; 6421 uint32_t retry_num; 6422 }; 6423 6424 static void cmd_set_burst_tx_retry_parsed(void *parsed_result, 6425 __attribute__((unused)) struct cmdline *cl, 6426 __attribute__((unused)) void *data) 6427 { 6428 struct cmd_set_burst_tx_retry_result *res = parsed_result; 6429 6430 if (!strcmp(res->set, "set") && !strcmp(res->burst, "burst") 6431 && !strcmp(res->tx, "tx")) { 6432 if (!strcmp(res->delay, "delay")) 6433 burst_tx_delay_time = res->time; 6434 if (!strcmp(res->retry, "retry")) 6435 burst_tx_retry_num = res->retry_num; 6436 } 6437 6438 } 6439 6440 cmdline_parse_token_string_t cmd_set_burst_tx_retry_set = 6441 TOKEN_STRING_INITIALIZER(struct cmd_set_burst_tx_retry_result, set, "set"); 6442 cmdline_parse_token_string_t cmd_set_burst_tx_retry_burst = 6443 TOKEN_STRING_INITIALIZER(struct cmd_set_burst_tx_retry_result, burst, 6444 "burst"); 6445 cmdline_parse_token_string_t cmd_set_burst_tx_retry_tx = 6446 TOKEN_STRING_INITIALIZER(struct cmd_set_burst_tx_retry_result, tx, "tx"); 6447 cmdline_parse_token_string_t cmd_set_burst_tx_retry_delay = 6448 TOKEN_STRING_INITIALIZER(struct cmd_set_burst_tx_retry_result, delay, "delay"); 6449 cmdline_parse_token_num_t cmd_set_burst_tx_retry_time = 6450 TOKEN_NUM_INITIALIZER(struct cmd_set_burst_tx_retry_result, time, UINT32); 6451 cmdline_parse_token_string_t cmd_set_burst_tx_retry_retry = 6452 TOKEN_STRING_INITIALIZER(struct cmd_set_burst_tx_retry_result, retry, "retry"); 6453 cmdline_parse_token_num_t cmd_set_burst_tx_retry_retry_num = 6454 TOKEN_NUM_INITIALIZER(struct cmd_set_burst_tx_retry_result, retry_num, UINT32); 6455 6456 cmdline_parse_inst_t cmd_set_burst_tx_retry = { 6457 .f = cmd_set_burst_tx_retry_parsed, 6458 .help_str = "set burst tx delay <delay_usec> retry <num_retry>", 6459 .tokens = { 6460 (void *)&cmd_set_burst_tx_retry_set, 6461 (void *)&cmd_set_burst_tx_retry_burst, 6462 (void *)&cmd_set_burst_tx_retry_tx, 6463 (void *)&cmd_set_burst_tx_retry_delay, 6464 (void *)&cmd_set_burst_tx_retry_time, 6465 (void *)&cmd_set_burst_tx_retry_retry, 6466 (void *)&cmd_set_burst_tx_retry_retry_num, 6467 NULL, 6468 }, 6469 }; 6470 6471 /* *** SET PROMISC MODE *** */ 6472 struct cmd_set_promisc_mode_result { 6473 cmdline_fixed_string_t set; 6474 cmdline_fixed_string_t promisc; 6475 cmdline_fixed_string_t port_all; /* valid if "allports" argument == 1 */ 6476 uint16_t port_num; /* valid if "allports" argument == 0 */ 6477 cmdline_fixed_string_t mode; 6478 }; 6479 6480 static void cmd_set_promisc_mode_parsed(void *parsed_result, 6481 __attribute__((unused)) struct cmdline *cl, 6482 void *allports) 6483 { 6484 struct cmd_set_promisc_mode_result *res = parsed_result; 6485 int enable; 6486 portid_t i; 6487 6488 if (!strcmp(res->mode, "on")) 6489 enable = 1; 6490 else 6491 enable = 0; 6492 6493 /* all ports */ 6494 if (allports) { 6495 RTE_ETH_FOREACH_DEV(i) { 6496 if (enable) 6497 rte_eth_promiscuous_enable(i); 6498 else 6499 rte_eth_promiscuous_disable(i); 6500 } 6501 } 6502 else { 6503 if (enable) 6504 rte_eth_promiscuous_enable(res->port_num); 6505 else 6506 rte_eth_promiscuous_disable(res->port_num); 6507 } 6508 } 6509 6510 cmdline_parse_token_string_t cmd_setpromisc_set = 6511 TOKEN_STRING_INITIALIZER(struct cmd_set_promisc_mode_result, set, "set"); 6512 cmdline_parse_token_string_t cmd_setpromisc_promisc = 6513 TOKEN_STRING_INITIALIZER(struct cmd_set_promisc_mode_result, promisc, 6514 "promisc"); 6515 cmdline_parse_token_string_t cmd_setpromisc_portall = 6516 TOKEN_STRING_INITIALIZER(struct cmd_set_promisc_mode_result, port_all, 6517 "all"); 6518 cmdline_parse_token_num_t cmd_setpromisc_portnum = 6519 TOKEN_NUM_INITIALIZER(struct cmd_set_promisc_mode_result, port_num, 6520 UINT16); 6521 cmdline_parse_token_string_t cmd_setpromisc_mode = 6522 TOKEN_STRING_INITIALIZER(struct cmd_set_promisc_mode_result, mode, 6523 "on#off"); 6524 6525 cmdline_parse_inst_t cmd_set_promisc_mode_all = { 6526 .f = cmd_set_promisc_mode_parsed, 6527 .data = (void *)1, 6528 .help_str = "set promisc all on|off: Set promisc mode for all ports", 6529 .tokens = { 6530 (void *)&cmd_setpromisc_set, 6531 (void *)&cmd_setpromisc_promisc, 6532 (void *)&cmd_setpromisc_portall, 6533 (void *)&cmd_setpromisc_mode, 6534 NULL, 6535 }, 6536 }; 6537 6538 cmdline_parse_inst_t cmd_set_promisc_mode_one = { 6539 .f = cmd_set_promisc_mode_parsed, 6540 .data = (void *)0, 6541 .help_str = "set promisc <port_id> on|off: Set promisc mode on port_id", 6542 .tokens = { 6543 (void *)&cmd_setpromisc_set, 6544 (void *)&cmd_setpromisc_promisc, 6545 (void *)&cmd_setpromisc_portnum, 6546 (void *)&cmd_setpromisc_mode, 6547 NULL, 6548 }, 6549 }; 6550 6551 /* *** SET ALLMULTI MODE *** */ 6552 struct cmd_set_allmulti_mode_result { 6553 cmdline_fixed_string_t set; 6554 cmdline_fixed_string_t allmulti; 6555 cmdline_fixed_string_t port_all; /* valid if "allports" argument == 1 */ 6556 uint16_t port_num; /* valid if "allports" argument == 0 */ 6557 cmdline_fixed_string_t mode; 6558 }; 6559 6560 static void cmd_set_allmulti_mode_parsed(void *parsed_result, 6561 __attribute__((unused)) struct cmdline *cl, 6562 void *allports) 6563 { 6564 struct cmd_set_allmulti_mode_result *res = parsed_result; 6565 int enable; 6566 portid_t i; 6567 6568 if (!strcmp(res->mode, "on")) 6569 enable = 1; 6570 else 6571 enable = 0; 6572 6573 /* all ports */ 6574 if (allports) { 6575 RTE_ETH_FOREACH_DEV(i) { 6576 if (enable) 6577 rte_eth_allmulticast_enable(i); 6578 else 6579 rte_eth_allmulticast_disable(i); 6580 } 6581 } 6582 else { 6583 if (enable) 6584 rte_eth_allmulticast_enable(res->port_num); 6585 else 6586 rte_eth_allmulticast_disable(res->port_num); 6587 } 6588 } 6589 6590 cmdline_parse_token_string_t cmd_setallmulti_set = 6591 TOKEN_STRING_INITIALIZER(struct cmd_set_allmulti_mode_result, set, "set"); 6592 cmdline_parse_token_string_t cmd_setallmulti_allmulti = 6593 TOKEN_STRING_INITIALIZER(struct cmd_set_allmulti_mode_result, allmulti, 6594 "allmulti"); 6595 cmdline_parse_token_string_t cmd_setallmulti_portall = 6596 TOKEN_STRING_INITIALIZER(struct cmd_set_allmulti_mode_result, port_all, 6597 "all"); 6598 cmdline_parse_token_num_t cmd_setallmulti_portnum = 6599 TOKEN_NUM_INITIALIZER(struct cmd_set_allmulti_mode_result, port_num, 6600 UINT16); 6601 cmdline_parse_token_string_t cmd_setallmulti_mode = 6602 TOKEN_STRING_INITIALIZER(struct cmd_set_allmulti_mode_result, mode, 6603 "on#off"); 6604 6605 cmdline_parse_inst_t cmd_set_allmulti_mode_all = { 6606 .f = cmd_set_allmulti_mode_parsed, 6607 .data = (void *)1, 6608 .help_str = "set allmulti all on|off: Set allmulti mode for all ports", 6609 .tokens = { 6610 (void *)&cmd_setallmulti_set, 6611 (void *)&cmd_setallmulti_allmulti, 6612 (void *)&cmd_setallmulti_portall, 6613 (void *)&cmd_setallmulti_mode, 6614 NULL, 6615 }, 6616 }; 6617 6618 cmdline_parse_inst_t cmd_set_allmulti_mode_one = { 6619 .f = cmd_set_allmulti_mode_parsed, 6620 .data = (void *)0, 6621 .help_str = "set allmulti <port_id> on|off: " 6622 "Set allmulti mode on port_id", 6623 .tokens = { 6624 (void *)&cmd_setallmulti_set, 6625 (void *)&cmd_setallmulti_allmulti, 6626 (void *)&cmd_setallmulti_portnum, 6627 (void *)&cmd_setallmulti_mode, 6628 NULL, 6629 }, 6630 }; 6631 6632 /* *** SETUP ETHERNET LINK FLOW CONTROL *** */ 6633 struct cmd_link_flow_ctrl_set_result { 6634 cmdline_fixed_string_t set; 6635 cmdline_fixed_string_t flow_ctrl; 6636 cmdline_fixed_string_t rx; 6637 cmdline_fixed_string_t rx_lfc_mode; 6638 cmdline_fixed_string_t tx; 6639 cmdline_fixed_string_t tx_lfc_mode; 6640 cmdline_fixed_string_t mac_ctrl_frame_fwd; 6641 cmdline_fixed_string_t mac_ctrl_frame_fwd_mode; 6642 cmdline_fixed_string_t autoneg_str; 6643 cmdline_fixed_string_t autoneg; 6644 cmdline_fixed_string_t hw_str; 6645 uint32_t high_water; 6646 cmdline_fixed_string_t lw_str; 6647 uint32_t low_water; 6648 cmdline_fixed_string_t pt_str; 6649 uint16_t pause_time; 6650 cmdline_fixed_string_t xon_str; 6651 uint16_t send_xon; 6652 portid_t port_id; 6653 }; 6654 6655 cmdline_parse_token_string_t cmd_lfc_set_set = 6656 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result, 6657 set, "set"); 6658 cmdline_parse_token_string_t cmd_lfc_set_flow_ctrl = 6659 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result, 6660 flow_ctrl, "flow_ctrl"); 6661 cmdline_parse_token_string_t cmd_lfc_set_rx = 6662 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result, 6663 rx, "rx"); 6664 cmdline_parse_token_string_t cmd_lfc_set_rx_mode = 6665 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result, 6666 rx_lfc_mode, "on#off"); 6667 cmdline_parse_token_string_t cmd_lfc_set_tx = 6668 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result, 6669 tx, "tx"); 6670 cmdline_parse_token_string_t cmd_lfc_set_tx_mode = 6671 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result, 6672 tx_lfc_mode, "on#off"); 6673 cmdline_parse_token_string_t cmd_lfc_set_high_water_str = 6674 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result, 6675 hw_str, "high_water"); 6676 cmdline_parse_token_num_t cmd_lfc_set_high_water = 6677 TOKEN_NUM_INITIALIZER(struct cmd_link_flow_ctrl_set_result, 6678 high_water, UINT32); 6679 cmdline_parse_token_string_t cmd_lfc_set_low_water_str = 6680 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result, 6681 lw_str, "low_water"); 6682 cmdline_parse_token_num_t cmd_lfc_set_low_water = 6683 TOKEN_NUM_INITIALIZER(struct cmd_link_flow_ctrl_set_result, 6684 low_water, UINT32); 6685 cmdline_parse_token_string_t cmd_lfc_set_pause_time_str = 6686 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result, 6687 pt_str, "pause_time"); 6688 cmdline_parse_token_num_t cmd_lfc_set_pause_time = 6689 TOKEN_NUM_INITIALIZER(struct cmd_link_flow_ctrl_set_result, 6690 pause_time, UINT16); 6691 cmdline_parse_token_string_t cmd_lfc_set_send_xon_str = 6692 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result, 6693 xon_str, "send_xon"); 6694 cmdline_parse_token_num_t cmd_lfc_set_send_xon = 6695 TOKEN_NUM_INITIALIZER(struct cmd_link_flow_ctrl_set_result, 6696 send_xon, UINT16); 6697 cmdline_parse_token_string_t cmd_lfc_set_mac_ctrl_frame_fwd_mode = 6698 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result, 6699 mac_ctrl_frame_fwd, "mac_ctrl_frame_fwd"); 6700 cmdline_parse_token_string_t cmd_lfc_set_mac_ctrl_frame_fwd = 6701 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result, 6702 mac_ctrl_frame_fwd_mode, "on#off"); 6703 cmdline_parse_token_string_t cmd_lfc_set_autoneg_str = 6704 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result, 6705 autoneg_str, "autoneg"); 6706 cmdline_parse_token_string_t cmd_lfc_set_autoneg = 6707 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result, 6708 autoneg, "on#off"); 6709 cmdline_parse_token_num_t cmd_lfc_set_portid = 6710 TOKEN_NUM_INITIALIZER(struct cmd_link_flow_ctrl_set_result, 6711 port_id, UINT16); 6712 6713 /* forward declaration */ 6714 static void 6715 cmd_link_flow_ctrl_set_parsed(void *parsed_result, struct cmdline *cl, 6716 void *data); 6717 6718 cmdline_parse_inst_t cmd_link_flow_control_set = { 6719 .f = cmd_link_flow_ctrl_set_parsed, 6720 .data = NULL, 6721 .help_str = "set flow_ctrl rx on|off tx on|off <high_water> " 6722 "<low_water> <pause_time> <send_xon> mac_ctrl_frame_fwd on|off " 6723 "autoneg on|off <port_id>: Configure the Ethernet flow control", 6724 .tokens = { 6725 (void *)&cmd_lfc_set_set, 6726 (void *)&cmd_lfc_set_flow_ctrl, 6727 (void *)&cmd_lfc_set_rx, 6728 (void *)&cmd_lfc_set_rx_mode, 6729 (void *)&cmd_lfc_set_tx, 6730 (void *)&cmd_lfc_set_tx_mode, 6731 (void *)&cmd_lfc_set_high_water, 6732 (void *)&cmd_lfc_set_low_water, 6733 (void *)&cmd_lfc_set_pause_time, 6734 (void *)&cmd_lfc_set_send_xon, 6735 (void *)&cmd_lfc_set_mac_ctrl_frame_fwd_mode, 6736 (void *)&cmd_lfc_set_mac_ctrl_frame_fwd, 6737 (void *)&cmd_lfc_set_autoneg_str, 6738 (void *)&cmd_lfc_set_autoneg, 6739 (void *)&cmd_lfc_set_portid, 6740 NULL, 6741 }, 6742 }; 6743 6744 cmdline_parse_inst_t cmd_link_flow_control_set_rx = { 6745 .f = cmd_link_flow_ctrl_set_parsed, 6746 .data = (void *)&cmd_link_flow_control_set_rx, 6747 .help_str = "set flow_ctrl rx on|off <port_id>: " 6748 "Change rx flow control parameter", 6749 .tokens = { 6750 (void *)&cmd_lfc_set_set, 6751 (void *)&cmd_lfc_set_flow_ctrl, 6752 (void *)&cmd_lfc_set_rx, 6753 (void *)&cmd_lfc_set_rx_mode, 6754 (void *)&cmd_lfc_set_portid, 6755 NULL, 6756 }, 6757 }; 6758 6759 cmdline_parse_inst_t cmd_link_flow_control_set_tx = { 6760 .f = cmd_link_flow_ctrl_set_parsed, 6761 .data = (void *)&cmd_link_flow_control_set_tx, 6762 .help_str = "set flow_ctrl tx on|off <port_id>: " 6763 "Change tx flow control parameter", 6764 .tokens = { 6765 (void *)&cmd_lfc_set_set, 6766 (void *)&cmd_lfc_set_flow_ctrl, 6767 (void *)&cmd_lfc_set_tx, 6768 (void *)&cmd_lfc_set_tx_mode, 6769 (void *)&cmd_lfc_set_portid, 6770 NULL, 6771 }, 6772 }; 6773 6774 cmdline_parse_inst_t cmd_link_flow_control_set_hw = { 6775 .f = cmd_link_flow_ctrl_set_parsed, 6776 .data = (void *)&cmd_link_flow_control_set_hw, 6777 .help_str = "set flow_ctrl high_water <value> <port_id>: " 6778 "Change high water flow control parameter", 6779 .tokens = { 6780 (void *)&cmd_lfc_set_set, 6781 (void *)&cmd_lfc_set_flow_ctrl, 6782 (void *)&cmd_lfc_set_high_water_str, 6783 (void *)&cmd_lfc_set_high_water, 6784 (void *)&cmd_lfc_set_portid, 6785 NULL, 6786 }, 6787 }; 6788 6789 cmdline_parse_inst_t cmd_link_flow_control_set_lw = { 6790 .f = cmd_link_flow_ctrl_set_parsed, 6791 .data = (void *)&cmd_link_flow_control_set_lw, 6792 .help_str = "set flow_ctrl low_water <value> <port_id>: " 6793 "Change low water flow control parameter", 6794 .tokens = { 6795 (void *)&cmd_lfc_set_set, 6796 (void *)&cmd_lfc_set_flow_ctrl, 6797 (void *)&cmd_lfc_set_low_water_str, 6798 (void *)&cmd_lfc_set_low_water, 6799 (void *)&cmd_lfc_set_portid, 6800 NULL, 6801 }, 6802 }; 6803 6804 cmdline_parse_inst_t cmd_link_flow_control_set_pt = { 6805 .f = cmd_link_flow_ctrl_set_parsed, 6806 .data = (void *)&cmd_link_flow_control_set_pt, 6807 .help_str = "set flow_ctrl pause_time <value> <port_id>: " 6808 "Change pause time flow control parameter", 6809 .tokens = { 6810 (void *)&cmd_lfc_set_set, 6811 (void *)&cmd_lfc_set_flow_ctrl, 6812 (void *)&cmd_lfc_set_pause_time_str, 6813 (void *)&cmd_lfc_set_pause_time, 6814 (void *)&cmd_lfc_set_portid, 6815 NULL, 6816 }, 6817 }; 6818 6819 cmdline_parse_inst_t cmd_link_flow_control_set_xon = { 6820 .f = cmd_link_flow_ctrl_set_parsed, 6821 .data = (void *)&cmd_link_flow_control_set_xon, 6822 .help_str = "set flow_ctrl send_xon <value> <port_id>: " 6823 "Change send_xon flow control parameter", 6824 .tokens = { 6825 (void *)&cmd_lfc_set_set, 6826 (void *)&cmd_lfc_set_flow_ctrl, 6827 (void *)&cmd_lfc_set_send_xon_str, 6828 (void *)&cmd_lfc_set_send_xon, 6829 (void *)&cmd_lfc_set_portid, 6830 NULL, 6831 }, 6832 }; 6833 6834 cmdline_parse_inst_t cmd_link_flow_control_set_macfwd = { 6835 .f = cmd_link_flow_ctrl_set_parsed, 6836 .data = (void *)&cmd_link_flow_control_set_macfwd, 6837 .help_str = "set flow_ctrl mac_ctrl_frame_fwd on|off <port_id>: " 6838 "Change mac ctrl fwd flow control parameter", 6839 .tokens = { 6840 (void *)&cmd_lfc_set_set, 6841 (void *)&cmd_lfc_set_flow_ctrl, 6842 (void *)&cmd_lfc_set_mac_ctrl_frame_fwd_mode, 6843 (void *)&cmd_lfc_set_mac_ctrl_frame_fwd, 6844 (void *)&cmd_lfc_set_portid, 6845 NULL, 6846 }, 6847 }; 6848 6849 cmdline_parse_inst_t cmd_link_flow_control_set_autoneg = { 6850 .f = cmd_link_flow_ctrl_set_parsed, 6851 .data = (void *)&cmd_link_flow_control_set_autoneg, 6852 .help_str = "set flow_ctrl autoneg on|off <port_id>: " 6853 "Change autoneg flow control parameter", 6854 .tokens = { 6855 (void *)&cmd_lfc_set_set, 6856 (void *)&cmd_lfc_set_flow_ctrl, 6857 (void *)&cmd_lfc_set_autoneg_str, 6858 (void *)&cmd_lfc_set_autoneg, 6859 (void *)&cmd_lfc_set_portid, 6860 NULL, 6861 }, 6862 }; 6863 6864 static void 6865 cmd_link_flow_ctrl_set_parsed(void *parsed_result, 6866 __attribute__((unused)) struct cmdline *cl, 6867 void *data) 6868 { 6869 struct cmd_link_flow_ctrl_set_result *res = parsed_result; 6870 cmdline_parse_inst_t *cmd = data; 6871 struct rte_eth_fc_conf fc_conf; 6872 int rx_fc_en = 0; 6873 int tx_fc_en = 0; 6874 int ret; 6875 6876 /* 6877 * Rx on/off, flow control is enabled/disabled on RX side. This can indicate 6878 * the RTE_FC_TX_PAUSE, Transmit pause frame at the Rx side. 6879 * Tx on/off, flow control is enabled/disabled on TX side. This can indicate 6880 * the RTE_FC_RX_PAUSE, Respond to the pause frame at the Tx side. 6881 */ 6882 static enum rte_eth_fc_mode rx_tx_onoff_2_lfc_mode[2][2] = { 6883 {RTE_FC_NONE, RTE_FC_TX_PAUSE}, {RTE_FC_RX_PAUSE, RTE_FC_FULL} 6884 }; 6885 6886 /* Partial command line, retrieve current configuration */ 6887 if (cmd) { 6888 ret = rte_eth_dev_flow_ctrl_get(res->port_id, &fc_conf); 6889 if (ret != 0) { 6890 printf("cannot get current flow ctrl parameters, return" 6891 "code = %d\n", ret); 6892 return; 6893 } 6894 6895 if ((fc_conf.mode == RTE_FC_RX_PAUSE) || 6896 (fc_conf.mode == RTE_FC_FULL)) 6897 rx_fc_en = 1; 6898 if ((fc_conf.mode == RTE_FC_TX_PAUSE) || 6899 (fc_conf.mode == RTE_FC_FULL)) 6900 tx_fc_en = 1; 6901 } 6902 6903 if (!cmd || cmd == &cmd_link_flow_control_set_rx) 6904 rx_fc_en = (!strcmp(res->rx_lfc_mode, "on")) ? 1 : 0; 6905 6906 if (!cmd || cmd == &cmd_link_flow_control_set_tx) 6907 tx_fc_en = (!strcmp(res->tx_lfc_mode, "on")) ? 1 : 0; 6908 6909 fc_conf.mode = rx_tx_onoff_2_lfc_mode[rx_fc_en][tx_fc_en]; 6910 6911 if (!cmd || cmd == &cmd_link_flow_control_set_hw) 6912 fc_conf.high_water = res->high_water; 6913 6914 if (!cmd || cmd == &cmd_link_flow_control_set_lw) 6915 fc_conf.low_water = res->low_water; 6916 6917 if (!cmd || cmd == &cmd_link_flow_control_set_pt) 6918 fc_conf.pause_time = res->pause_time; 6919 6920 if (!cmd || cmd == &cmd_link_flow_control_set_xon) 6921 fc_conf.send_xon = res->send_xon; 6922 6923 if (!cmd || cmd == &cmd_link_flow_control_set_macfwd) { 6924 if (!strcmp(res->mac_ctrl_frame_fwd_mode, "on")) 6925 fc_conf.mac_ctrl_frame_fwd = 1; 6926 else 6927 fc_conf.mac_ctrl_frame_fwd = 0; 6928 } 6929 6930 if (!cmd || cmd == &cmd_link_flow_control_set_autoneg) 6931 fc_conf.autoneg = (!strcmp(res->autoneg, "on")) ? 1 : 0; 6932 6933 ret = rte_eth_dev_flow_ctrl_set(res->port_id, &fc_conf); 6934 if (ret != 0) 6935 printf("bad flow contrl parameter, return code = %d \n", ret); 6936 } 6937 6938 /* *** SETUP ETHERNET PRIORITY FLOW CONTROL *** */ 6939 struct cmd_priority_flow_ctrl_set_result { 6940 cmdline_fixed_string_t set; 6941 cmdline_fixed_string_t pfc_ctrl; 6942 cmdline_fixed_string_t rx; 6943 cmdline_fixed_string_t rx_pfc_mode; 6944 cmdline_fixed_string_t tx; 6945 cmdline_fixed_string_t tx_pfc_mode; 6946 uint32_t high_water; 6947 uint32_t low_water; 6948 uint16_t pause_time; 6949 uint8_t priority; 6950 portid_t port_id; 6951 }; 6952 6953 static void 6954 cmd_priority_flow_ctrl_set_parsed(void *parsed_result, 6955 __attribute__((unused)) struct cmdline *cl, 6956 __attribute__((unused)) void *data) 6957 { 6958 struct cmd_priority_flow_ctrl_set_result *res = parsed_result; 6959 struct rte_eth_pfc_conf pfc_conf; 6960 int rx_fc_enable, tx_fc_enable; 6961 int ret; 6962 6963 /* 6964 * Rx on/off, flow control is enabled/disabled on RX side. This can indicate 6965 * the RTE_FC_TX_PAUSE, Transmit pause frame at the Rx side. 6966 * Tx on/off, flow control is enabled/disabled on TX side. This can indicate 6967 * the RTE_FC_RX_PAUSE, Respond to the pause frame at the Tx side. 6968 */ 6969 static enum rte_eth_fc_mode rx_tx_onoff_2_pfc_mode[2][2] = { 6970 {RTE_FC_NONE, RTE_FC_RX_PAUSE}, {RTE_FC_TX_PAUSE, RTE_FC_FULL} 6971 }; 6972 6973 rx_fc_enable = (!strncmp(res->rx_pfc_mode, "on",2)) ? 1 : 0; 6974 tx_fc_enable = (!strncmp(res->tx_pfc_mode, "on",2)) ? 1 : 0; 6975 pfc_conf.fc.mode = rx_tx_onoff_2_pfc_mode[rx_fc_enable][tx_fc_enable]; 6976 pfc_conf.fc.high_water = res->high_water; 6977 pfc_conf.fc.low_water = res->low_water; 6978 pfc_conf.fc.pause_time = res->pause_time; 6979 pfc_conf.priority = res->priority; 6980 6981 ret = rte_eth_dev_priority_flow_ctrl_set(res->port_id, &pfc_conf); 6982 if (ret != 0) 6983 printf("bad priority flow contrl parameter, return code = %d \n", ret); 6984 } 6985 6986 cmdline_parse_token_string_t cmd_pfc_set_set = 6987 TOKEN_STRING_INITIALIZER(struct cmd_priority_flow_ctrl_set_result, 6988 set, "set"); 6989 cmdline_parse_token_string_t cmd_pfc_set_flow_ctrl = 6990 TOKEN_STRING_INITIALIZER(struct cmd_priority_flow_ctrl_set_result, 6991 pfc_ctrl, "pfc_ctrl"); 6992 cmdline_parse_token_string_t cmd_pfc_set_rx = 6993 TOKEN_STRING_INITIALIZER(struct cmd_priority_flow_ctrl_set_result, 6994 rx, "rx"); 6995 cmdline_parse_token_string_t cmd_pfc_set_rx_mode = 6996 TOKEN_STRING_INITIALIZER(struct cmd_priority_flow_ctrl_set_result, 6997 rx_pfc_mode, "on#off"); 6998 cmdline_parse_token_string_t cmd_pfc_set_tx = 6999 TOKEN_STRING_INITIALIZER(struct cmd_priority_flow_ctrl_set_result, 7000 tx, "tx"); 7001 cmdline_parse_token_string_t cmd_pfc_set_tx_mode = 7002 TOKEN_STRING_INITIALIZER(struct cmd_priority_flow_ctrl_set_result, 7003 tx_pfc_mode, "on#off"); 7004 cmdline_parse_token_num_t cmd_pfc_set_high_water = 7005 TOKEN_NUM_INITIALIZER(struct cmd_priority_flow_ctrl_set_result, 7006 high_water, UINT32); 7007 cmdline_parse_token_num_t cmd_pfc_set_low_water = 7008 TOKEN_NUM_INITIALIZER(struct cmd_priority_flow_ctrl_set_result, 7009 low_water, UINT32); 7010 cmdline_parse_token_num_t cmd_pfc_set_pause_time = 7011 TOKEN_NUM_INITIALIZER(struct cmd_priority_flow_ctrl_set_result, 7012 pause_time, UINT16); 7013 cmdline_parse_token_num_t cmd_pfc_set_priority = 7014 TOKEN_NUM_INITIALIZER(struct cmd_priority_flow_ctrl_set_result, 7015 priority, UINT8); 7016 cmdline_parse_token_num_t cmd_pfc_set_portid = 7017 TOKEN_NUM_INITIALIZER(struct cmd_priority_flow_ctrl_set_result, 7018 port_id, UINT16); 7019 7020 cmdline_parse_inst_t cmd_priority_flow_control_set = { 7021 .f = cmd_priority_flow_ctrl_set_parsed, 7022 .data = NULL, 7023 .help_str = "set pfc_ctrl rx on|off tx on|off <high_water> <low_water> " 7024 "<pause_time> <priority> <port_id>: " 7025 "Configure the Ethernet priority flow control", 7026 .tokens = { 7027 (void *)&cmd_pfc_set_set, 7028 (void *)&cmd_pfc_set_flow_ctrl, 7029 (void *)&cmd_pfc_set_rx, 7030 (void *)&cmd_pfc_set_rx_mode, 7031 (void *)&cmd_pfc_set_tx, 7032 (void *)&cmd_pfc_set_tx_mode, 7033 (void *)&cmd_pfc_set_high_water, 7034 (void *)&cmd_pfc_set_low_water, 7035 (void *)&cmd_pfc_set_pause_time, 7036 (void *)&cmd_pfc_set_priority, 7037 (void *)&cmd_pfc_set_portid, 7038 NULL, 7039 }, 7040 }; 7041 7042 /* *** RESET CONFIGURATION *** */ 7043 struct cmd_reset_result { 7044 cmdline_fixed_string_t reset; 7045 cmdline_fixed_string_t def; 7046 }; 7047 7048 static void cmd_reset_parsed(__attribute__((unused)) void *parsed_result, 7049 struct cmdline *cl, 7050 __attribute__((unused)) void *data) 7051 { 7052 cmdline_printf(cl, "Reset to default forwarding configuration...\n"); 7053 set_def_fwd_config(); 7054 } 7055 7056 cmdline_parse_token_string_t cmd_reset_set = 7057 TOKEN_STRING_INITIALIZER(struct cmd_reset_result, reset, "set"); 7058 cmdline_parse_token_string_t cmd_reset_def = 7059 TOKEN_STRING_INITIALIZER(struct cmd_reset_result, def, 7060 "default"); 7061 7062 cmdline_parse_inst_t cmd_reset = { 7063 .f = cmd_reset_parsed, 7064 .data = NULL, 7065 .help_str = "set default: Reset default forwarding configuration", 7066 .tokens = { 7067 (void *)&cmd_reset_set, 7068 (void *)&cmd_reset_def, 7069 NULL, 7070 }, 7071 }; 7072 7073 /* *** START FORWARDING *** */ 7074 struct cmd_start_result { 7075 cmdline_fixed_string_t start; 7076 }; 7077 7078 cmdline_parse_token_string_t cmd_start_start = 7079 TOKEN_STRING_INITIALIZER(struct cmd_start_result, start, "start"); 7080 7081 static void cmd_start_parsed(__attribute__((unused)) void *parsed_result, 7082 __attribute__((unused)) struct cmdline *cl, 7083 __attribute__((unused)) void *data) 7084 { 7085 start_packet_forwarding(0); 7086 } 7087 7088 cmdline_parse_inst_t cmd_start = { 7089 .f = cmd_start_parsed, 7090 .data = NULL, 7091 .help_str = "start: Start packet forwarding", 7092 .tokens = { 7093 (void *)&cmd_start_start, 7094 NULL, 7095 }, 7096 }; 7097 7098 /* *** START FORWARDING WITH ONE TX BURST FIRST *** */ 7099 struct cmd_start_tx_first_result { 7100 cmdline_fixed_string_t start; 7101 cmdline_fixed_string_t tx_first; 7102 }; 7103 7104 static void 7105 cmd_start_tx_first_parsed(__attribute__((unused)) void *parsed_result, 7106 __attribute__((unused)) struct cmdline *cl, 7107 __attribute__((unused)) void *data) 7108 { 7109 start_packet_forwarding(1); 7110 } 7111 7112 cmdline_parse_token_string_t cmd_start_tx_first_start = 7113 TOKEN_STRING_INITIALIZER(struct cmd_start_tx_first_result, start, 7114 "start"); 7115 cmdline_parse_token_string_t cmd_start_tx_first_tx_first = 7116 TOKEN_STRING_INITIALIZER(struct cmd_start_tx_first_result, 7117 tx_first, "tx_first"); 7118 7119 cmdline_parse_inst_t cmd_start_tx_first = { 7120 .f = cmd_start_tx_first_parsed, 7121 .data = NULL, 7122 .help_str = "start tx_first: Start packet forwarding, " 7123 "after sending 1 burst of packets", 7124 .tokens = { 7125 (void *)&cmd_start_tx_first_start, 7126 (void *)&cmd_start_tx_first_tx_first, 7127 NULL, 7128 }, 7129 }; 7130 7131 /* *** START FORWARDING WITH N TX BURST FIRST *** */ 7132 struct cmd_start_tx_first_n_result { 7133 cmdline_fixed_string_t start; 7134 cmdline_fixed_string_t tx_first; 7135 uint32_t tx_num; 7136 }; 7137 7138 static void 7139 cmd_start_tx_first_n_parsed(void *parsed_result, 7140 __attribute__((unused)) struct cmdline *cl, 7141 __attribute__((unused)) void *data) 7142 { 7143 struct cmd_start_tx_first_n_result *res = parsed_result; 7144 7145 start_packet_forwarding(res->tx_num); 7146 } 7147 7148 cmdline_parse_token_string_t cmd_start_tx_first_n_start = 7149 TOKEN_STRING_INITIALIZER(struct cmd_start_tx_first_n_result, 7150 start, "start"); 7151 cmdline_parse_token_string_t cmd_start_tx_first_n_tx_first = 7152 TOKEN_STRING_INITIALIZER(struct cmd_start_tx_first_n_result, 7153 tx_first, "tx_first"); 7154 cmdline_parse_token_num_t cmd_start_tx_first_n_tx_num = 7155 TOKEN_NUM_INITIALIZER(struct cmd_start_tx_first_n_result, 7156 tx_num, UINT32); 7157 7158 cmdline_parse_inst_t cmd_start_tx_first_n = { 7159 .f = cmd_start_tx_first_n_parsed, 7160 .data = NULL, 7161 .help_str = "start tx_first <num>: " 7162 "packet forwarding, after sending <num> bursts of packets", 7163 .tokens = { 7164 (void *)&cmd_start_tx_first_n_start, 7165 (void *)&cmd_start_tx_first_n_tx_first, 7166 (void *)&cmd_start_tx_first_n_tx_num, 7167 NULL, 7168 }, 7169 }; 7170 7171 /* *** SET LINK UP *** */ 7172 struct cmd_set_link_up_result { 7173 cmdline_fixed_string_t set; 7174 cmdline_fixed_string_t link_up; 7175 cmdline_fixed_string_t port; 7176 portid_t port_id; 7177 }; 7178 7179 cmdline_parse_token_string_t cmd_set_link_up_set = 7180 TOKEN_STRING_INITIALIZER(struct cmd_set_link_up_result, set, "set"); 7181 cmdline_parse_token_string_t cmd_set_link_up_link_up = 7182 TOKEN_STRING_INITIALIZER(struct cmd_set_link_up_result, link_up, 7183 "link-up"); 7184 cmdline_parse_token_string_t cmd_set_link_up_port = 7185 TOKEN_STRING_INITIALIZER(struct cmd_set_link_up_result, port, "port"); 7186 cmdline_parse_token_num_t cmd_set_link_up_port_id = 7187 TOKEN_NUM_INITIALIZER(struct cmd_set_link_up_result, port_id, UINT16); 7188 7189 static void cmd_set_link_up_parsed(__attribute__((unused)) void *parsed_result, 7190 __attribute__((unused)) struct cmdline *cl, 7191 __attribute__((unused)) void *data) 7192 { 7193 struct cmd_set_link_up_result *res = parsed_result; 7194 dev_set_link_up(res->port_id); 7195 } 7196 7197 cmdline_parse_inst_t cmd_set_link_up = { 7198 .f = cmd_set_link_up_parsed, 7199 .data = NULL, 7200 .help_str = "set link-up port <port id>", 7201 .tokens = { 7202 (void *)&cmd_set_link_up_set, 7203 (void *)&cmd_set_link_up_link_up, 7204 (void *)&cmd_set_link_up_port, 7205 (void *)&cmd_set_link_up_port_id, 7206 NULL, 7207 }, 7208 }; 7209 7210 /* *** SET LINK DOWN *** */ 7211 struct cmd_set_link_down_result { 7212 cmdline_fixed_string_t set; 7213 cmdline_fixed_string_t link_down; 7214 cmdline_fixed_string_t port; 7215 portid_t port_id; 7216 }; 7217 7218 cmdline_parse_token_string_t cmd_set_link_down_set = 7219 TOKEN_STRING_INITIALIZER(struct cmd_set_link_down_result, set, "set"); 7220 cmdline_parse_token_string_t cmd_set_link_down_link_down = 7221 TOKEN_STRING_INITIALIZER(struct cmd_set_link_down_result, link_down, 7222 "link-down"); 7223 cmdline_parse_token_string_t cmd_set_link_down_port = 7224 TOKEN_STRING_INITIALIZER(struct cmd_set_link_down_result, port, "port"); 7225 cmdline_parse_token_num_t cmd_set_link_down_port_id = 7226 TOKEN_NUM_INITIALIZER(struct cmd_set_link_down_result, port_id, UINT16); 7227 7228 static void cmd_set_link_down_parsed( 7229 __attribute__((unused)) void *parsed_result, 7230 __attribute__((unused)) struct cmdline *cl, 7231 __attribute__((unused)) void *data) 7232 { 7233 struct cmd_set_link_down_result *res = parsed_result; 7234 dev_set_link_down(res->port_id); 7235 } 7236 7237 cmdline_parse_inst_t cmd_set_link_down = { 7238 .f = cmd_set_link_down_parsed, 7239 .data = NULL, 7240 .help_str = "set link-down port <port id>", 7241 .tokens = { 7242 (void *)&cmd_set_link_down_set, 7243 (void *)&cmd_set_link_down_link_down, 7244 (void *)&cmd_set_link_down_port, 7245 (void *)&cmd_set_link_down_port_id, 7246 NULL, 7247 }, 7248 }; 7249 7250 /* *** SHOW CFG *** */ 7251 struct cmd_showcfg_result { 7252 cmdline_fixed_string_t show; 7253 cmdline_fixed_string_t cfg; 7254 cmdline_fixed_string_t what; 7255 }; 7256 7257 static void cmd_showcfg_parsed(void *parsed_result, 7258 __attribute__((unused)) struct cmdline *cl, 7259 __attribute__((unused)) void *data) 7260 { 7261 struct cmd_showcfg_result *res = parsed_result; 7262 if (!strcmp(res->what, "rxtx")) 7263 rxtx_config_display(); 7264 else if (!strcmp(res->what, "cores")) 7265 fwd_lcores_config_display(); 7266 else if (!strcmp(res->what, "fwd")) 7267 pkt_fwd_config_display(&cur_fwd_config); 7268 else if (!strcmp(res->what, "txpkts")) 7269 show_tx_pkt_segments(); 7270 } 7271 7272 cmdline_parse_token_string_t cmd_showcfg_show = 7273 TOKEN_STRING_INITIALIZER(struct cmd_showcfg_result, show, "show"); 7274 cmdline_parse_token_string_t cmd_showcfg_port = 7275 TOKEN_STRING_INITIALIZER(struct cmd_showcfg_result, cfg, "config"); 7276 cmdline_parse_token_string_t cmd_showcfg_what = 7277 TOKEN_STRING_INITIALIZER(struct cmd_showcfg_result, what, 7278 "rxtx#cores#fwd#txpkts"); 7279 7280 cmdline_parse_inst_t cmd_showcfg = { 7281 .f = cmd_showcfg_parsed, 7282 .data = NULL, 7283 .help_str = "show config rxtx|cores|fwd|txpkts", 7284 .tokens = { 7285 (void *)&cmd_showcfg_show, 7286 (void *)&cmd_showcfg_port, 7287 (void *)&cmd_showcfg_what, 7288 NULL, 7289 }, 7290 }; 7291 7292 /* *** SHOW ALL PORT INFO *** */ 7293 struct cmd_showportall_result { 7294 cmdline_fixed_string_t show; 7295 cmdline_fixed_string_t port; 7296 cmdline_fixed_string_t what; 7297 cmdline_fixed_string_t all; 7298 }; 7299 7300 static void cmd_showportall_parsed(void *parsed_result, 7301 __attribute__((unused)) struct cmdline *cl, 7302 __attribute__((unused)) void *data) 7303 { 7304 portid_t i; 7305 7306 struct cmd_showportall_result *res = parsed_result; 7307 if (!strcmp(res->show, "clear")) { 7308 if (!strcmp(res->what, "stats")) 7309 RTE_ETH_FOREACH_DEV(i) 7310 nic_stats_clear(i); 7311 else if (!strcmp(res->what, "xstats")) 7312 RTE_ETH_FOREACH_DEV(i) 7313 nic_xstats_clear(i); 7314 } else if (!strcmp(res->what, "info")) 7315 RTE_ETH_FOREACH_DEV(i) 7316 port_infos_display(i); 7317 else if (!strcmp(res->what, "summary")) { 7318 port_summary_header_display(); 7319 RTE_ETH_FOREACH_DEV(i) 7320 port_summary_display(i); 7321 } 7322 else if (!strcmp(res->what, "stats")) 7323 RTE_ETH_FOREACH_DEV(i) 7324 nic_stats_display(i); 7325 else if (!strcmp(res->what, "xstats")) 7326 RTE_ETH_FOREACH_DEV(i) 7327 nic_xstats_display(i); 7328 else if (!strcmp(res->what, "fdir")) 7329 RTE_ETH_FOREACH_DEV(i) 7330 fdir_get_infos(i); 7331 else if (!strcmp(res->what, "stat_qmap")) 7332 RTE_ETH_FOREACH_DEV(i) 7333 nic_stats_mapping_display(i); 7334 else if (!strcmp(res->what, "dcb_tc")) 7335 RTE_ETH_FOREACH_DEV(i) 7336 port_dcb_info_display(i); 7337 else if (!strcmp(res->what, "cap")) 7338 RTE_ETH_FOREACH_DEV(i) 7339 port_offload_cap_display(i); 7340 } 7341 7342 cmdline_parse_token_string_t cmd_showportall_show = 7343 TOKEN_STRING_INITIALIZER(struct cmd_showportall_result, show, 7344 "show#clear"); 7345 cmdline_parse_token_string_t cmd_showportall_port = 7346 TOKEN_STRING_INITIALIZER(struct cmd_showportall_result, port, "port"); 7347 cmdline_parse_token_string_t cmd_showportall_what = 7348 TOKEN_STRING_INITIALIZER(struct cmd_showportall_result, what, 7349 "info#summary#stats#xstats#fdir#stat_qmap#dcb_tc#cap"); 7350 cmdline_parse_token_string_t cmd_showportall_all = 7351 TOKEN_STRING_INITIALIZER(struct cmd_showportall_result, all, "all"); 7352 cmdline_parse_inst_t cmd_showportall = { 7353 .f = cmd_showportall_parsed, 7354 .data = NULL, 7355 .help_str = "show|clear port " 7356 "info|summary|stats|xstats|fdir|stat_qmap|dcb_tc|cap all", 7357 .tokens = { 7358 (void *)&cmd_showportall_show, 7359 (void *)&cmd_showportall_port, 7360 (void *)&cmd_showportall_what, 7361 (void *)&cmd_showportall_all, 7362 NULL, 7363 }, 7364 }; 7365 7366 /* *** SHOW PORT INFO *** */ 7367 struct cmd_showport_result { 7368 cmdline_fixed_string_t show; 7369 cmdline_fixed_string_t port; 7370 cmdline_fixed_string_t what; 7371 uint16_t portnum; 7372 }; 7373 7374 static void cmd_showport_parsed(void *parsed_result, 7375 __attribute__((unused)) struct cmdline *cl, 7376 __attribute__((unused)) void *data) 7377 { 7378 struct cmd_showport_result *res = parsed_result; 7379 if (!strcmp(res->show, "clear")) { 7380 if (!strcmp(res->what, "stats")) 7381 nic_stats_clear(res->portnum); 7382 else if (!strcmp(res->what, "xstats")) 7383 nic_xstats_clear(res->portnum); 7384 } else if (!strcmp(res->what, "info")) 7385 port_infos_display(res->portnum); 7386 else if (!strcmp(res->what, "summary")) { 7387 port_summary_header_display(); 7388 port_summary_display(res->portnum); 7389 } 7390 else if (!strcmp(res->what, "stats")) 7391 nic_stats_display(res->portnum); 7392 else if (!strcmp(res->what, "xstats")) 7393 nic_xstats_display(res->portnum); 7394 else if (!strcmp(res->what, "fdir")) 7395 fdir_get_infos(res->portnum); 7396 else if (!strcmp(res->what, "stat_qmap")) 7397 nic_stats_mapping_display(res->portnum); 7398 else if (!strcmp(res->what, "dcb_tc")) 7399 port_dcb_info_display(res->portnum); 7400 else if (!strcmp(res->what, "cap")) 7401 port_offload_cap_display(res->portnum); 7402 } 7403 7404 cmdline_parse_token_string_t cmd_showport_show = 7405 TOKEN_STRING_INITIALIZER(struct cmd_showport_result, show, 7406 "show#clear"); 7407 cmdline_parse_token_string_t cmd_showport_port = 7408 TOKEN_STRING_INITIALIZER(struct cmd_showport_result, port, "port"); 7409 cmdline_parse_token_string_t cmd_showport_what = 7410 TOKEN_STRING_INITIALIZER(struct cmd_showport_result, what, 7411 "info#summary#stats#xstats#fdir#stat_qmap#dcb_tc#cap"); 7412 cmdline_parse_token_num_t cmd_showport_portnum = 7413 TOKEN_NUM_INITIALIZER(struct cmd_showport_result, portnum, UINT16); 7414 7415 cmdline_parse_inst_t cmd_showport = { 7416 .f = cmd_showport_parsed, 7417 .data = NULL, 7418 .help_str = "show|clear port " 7419 "info|summary|stats|xstats|fdir|stat_qmap|dcb_tc|cap " 7420 "<port_id>", 7421 .tokens = { 7422 (void *)&cmd_showport_show, 7423 (void *)&cmd_showport_port, 7424 (void *)&cmd_showport_what, 7425 (void *)&cmd_showport_portnum, 7426 NULL, 7427 }, 7428 }; 7429 7430 /* *** SHOW DEVICE INFO *** */ 7431 struct cmd_showdevice_result { 7432 cmdline_fixed_string_t show; 7433 cmdline_fixed_string_t device; 7434 cmdline_fixed_string_t what; 7435 cmdline_fixed_string_t identifier; 7436 }; 7437 7438 static void cmd_showdevice_parsed(void *parsed_result, 7439 __attribute__((unused)) struct cmdline *cl, 7440 __attribute__((unused)) void *data) 7441 { 7442 struct cmd_showdevice_result *res = parsed_result; 7443 if (!strcmp(res->what, "info")) { 7444 if (!strcmp(res->identifier, "all")) 7445 device_infos_display(NULL); 7446 else 7447 device_infos_display(res->identifier); 7448 } 7449 } 7450 7451 cmdline_parse_token_string_t cmd_showdevice_show = 7452 TOKEN_STRING_INITIALIZER(struct cmd_showdevice_result, show, 7453 "show"); 7454 cmdline_parse_token_string_t cmd_showdevice_device = 7455 TOKEN_STRING_INITIALIZER(struct cmd_showdevice_result, device, "device"); 7456 cmdline_parse_token_string_t cmd_showdevice_what = 7457 TOKEN_STRING_INITIALIZER(struct cmd_showdevice_result, what, 7458 "info"); 7459 cmdline_parse_token_string_t cmd_showdevice_identifier = 7460 TOKEN_STRING_INITIALIZER(struct cmd_showdevice_result, 7461 identifier, NULL); 7462 7463 cmdline_parse_inst_t cmd_showdevice = { 7464 .f = cmd_showdevice_parsed, 7465 .data = NULL, 7466 .help_str = "show device info <identifier>|all", 7467 .tokens = { 7468 (void *)&cmd_showdevice_show, 7469 (void *)&cmd_showdevice_device, 7470 (void *)&cmd_showdevice_what, 7471 (void *)&cmd_showdevice_identifier, 7472 NULL, 7473 }, 7474 }; 7475 /* *** SHOW QUEUE INFO *** */ 7476 struct cmd_showqueue_result { 7477 cmdline_fixed_string_t show; 7478 cmdline_fixed_string_t type; 7479 cmdline_fixed_string_t what; 7480 uint16_t portnum; 7481 uint16_t queuenum; 7482 }; 7483 7484 static void 7485 cmd_showqueue_parsed(void *parsed_result, 7486 __attribute__((unused)) struct cmdline *cl, 7487 __attribute__((unused)) void *data) 7488 { 7489 struct cmd_showqueue_result *res = parsed_result; 7490 7491 if (!strcmp(res->type, "rxq")) 7492 rx_queue_infos_display(res->portnum, res->queuenum); 7493 else if (!strcmp(res->type, "txq")) 7494 tx_queue_infos_display(res->portnum, res->queuenum); 7495 } 7496 7497 cmdline_parse_token_string_t cmd_showqueue_show = 7498 TOKEN_STRING_INITIALIZER(struct cmd_showqueue_result, show, "show"); 7499 cmdline_parse_token_string_t cmd_showqueue_type = 7500 TOKEN_STRING_INITIALIZER(struct cmd_showqueue_result, type, "rxq#txq"); 7501 cmdline_parse_token_string_t cmd_showqueue_what = 7502 TOKEN_STRING_INITIALIZER(struct cmd_showqueue_result, what, "info"); 7503 cmdline_parse_token_num_t cmd_showqueue_portnum = 7504 TOKEN_NUM_INITIALIZER(struct cmd_showqueue_result, portnum, UINT16); 7505 cmdline_parse_token_num_t cmd_showqueue_queuenum = 7506 TOKEN_NUM_INITIALIZER(struct cmd_showqueue_result, queuenum, UINT16); 7507 7508 cmdline_parse_inst_t cmd_showqueue = { 7509 .f = cmd_showqueue_parsed, 7510 .data = NULL, 7511 .help_str = "show rxq|txq info <port_id> <queue_id>", 7512 .tokens = { 7513 (void *)&cmd_showqueue_show, 7514 (void *)&cmd_showqueue_type, 7515 (void *)&cmd_showqueue_what, 7516 (void *)&cmd_showqueue_portnum, 7517 (void *)&cmd_showqueue_queuenum, 7518 NULL, 7519 }, 7520 }; 7521 7522 /* show/clear fwd engine statistics */ 7523 struct fwd_result { 7524 cmdline_fixed_string_t action; 7525 cmdline_fixed_string_t fwd; 7526 cmdline_fixed_string_t stats; 7527 cmdline_fixed_string_t all; 7528 }; 7529 7530 cmdline_parse_token_string_t cmd_fwd_action = 7531 TOKEN_STRING_INITIALIZER(struct fwd_result, action, "show#clear"); 7532 cmdline_parse_token_string_t cmd_fwd_fwd = 7533 TOKEN_STRING_INITIALIZER(struct fwd_result, fwd, "fwd"); 7534 cmdline_parse_token_string_t cmd_fwd_stats = 7535 TOKEN_STRING_INITIALIZER(struct fwd_result, stats, "stats"); 7536 cmdline_parse_token_string_t cmd_fwd_all = 7537 TOKEN_STRING_INITIALIZER(struct fwd_result, all, "all"); 7538 7539 static void 7540 cmd_showfwdall_parsed(void *parsed_result, 7541 __rte_unused struct cmdline *cl, 7542 __rte_unused void *data) 7543 { 7544 struct fwd_result *res = parsed_result; 7545 7546 if (!strcmp(res->action, "show")) 7547 fwd_stats_display(); 7548 else 7549 fwd_stats_reset(); 7550 } 7551 7552 static cmdline_parse_inst_t cmd_showfwdall = { 7553 .f = cmd_showfwdall_parsed, 7554 .data = NULL, 7555 .help_str = "show|clear fwd stats all", 7556 .tokens = { 7557 (void *)&cmd_fwd_action, 7558 (void *)&cmd_fwd_fwd, 7559 (void *)&cmd_fwd_stats, 7560 (void *)&cmd_fwd_all, 7561 NULL, 7562 }, 7563 }; 7564 7565 /* *** READ PORT REGISTER *** */ 7566 struct cmd_read_reg_result { 7567 cmdline_fixed_string_t read; 7568 cmdline_fixed_string_t reg; 7569 portid_t port_id; 7570 uint32_t reg_off; 7571 }; 7572 7573 static void 7574 cmd_read_reg_parsed(void *parsed_result, 7575 __attribute__((unused)) struct cmdline *cl, 7576 __attribute__((unused)) void *data) 7577 { 7578 struct cmd_read_reg_result *res = parsed_result; 7579 port_reg_display(res->port_id, res->reg_off); 7580 } 7581 7582 cmdline_parse_token_string_t cmd_read_reg_read = 7583 TOKEN_STRING_INITIALIZER(struct cmd_read_reg_result, read, "read"); 7584 cmdline_parse_token_string_t cmd_read_reg_reg = 7585 TOKEN_STRING_INITIALIZER(struct cmd_read_reg_result, reg, "reg"); 7586 cmdline_parse_token_num_t cmd_read_reg_port_id = 7587 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_result, port_id, UINT16); 7588 cmdline_parse_token_num_t cmd_read_reg_reg_off = 7589 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_result, reg_off, UINT32); 7590 7591 cmdline_parse_inst_t cmd_read_reg = { 7592 .f = cmd_read_reg_parsed, 7593 .data = NULL, 7594 .help_str = "read reg <port_id> <reg_off>", 7595 .tokens = { 7596 (void *)&cmd_read_reg_read, 7597 (void *)&cmd_read_reg_reg, 7598 (void *)&cmd_read_reg_port_id, 7599 (void *)&cmd_read_reg_reg_off, 7600 NULL, 7601 }, 7602 }; 7603 7604 /* *** READ PORT REGISTER BIT FIELD *** */ 7605 struct cmd_read_reg_bit_field_result { 7606 cmdline_fixed_string_t read; 7607 cmdline_fixed_string_t regfield; 7608 portid_t port_id; 7609 uint32_t reg_off; 7610 uint8_t bit1_pos; 7611 uint8_t bit2_pos; 7612 }; 7613 7614 static void 7615 cmd_read_reg_bit_field_parsed(void *parsed_result, 7616 __attribute__((unused)) struct cmdline *cl, 7617 __attribute__((unused)) void *data) 7618 { 7619 struct cmd_read_reg_bit_field_result *res = parsed_result; 7620 port_reg_bit_field_display(res->port_id, res->reg_off, 7621 res->bit1_pos, res->bit2_pos); 7622 } 7623 7624 cmdline_parse_token_string_t cmd_read_reg_bit_field_read = 7625 TOKEN_STRING_INITIALIZER(struct cmd_read_reg_bit_field_result, read, 7626 "read"); 7627 cmdline_parse_token_string_t cmd_read_reg_bit_field_regfield = 7628 TOKEN_STRING_INITIALIZER(struct cmd_read_reg_bit_field_result, 7629 regfield, "regfield"); 7630 cmdline_parse_token_num_t cmd_read_reg_bit_field_port_id = 7631 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_field_result, port_id, 7632 UINT16); 7633 cmdline_parse_token_num_t cmd_read_reg_bit_field_reg_off = 7634 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_field_result, reg_off, 7635 UINT32); 7636 cmdline_parse_token_num_t cmd_read_reg_bit_field_bit1_pos = 7637 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_field_result, bit1_pos, 7638 UINT8); 7639 cmdline_parse_token_num_t cmd_read_reg_bit_field_bit2_pos = 7640 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_field_result, bit2_pos, 7641 UINT8); 7642 7643 cmdline_parse_inst_t cmd_read_reg_bit_field = { 7644 .f = cmd_read_reg_bit_field_parsed, 7645 .data = NULL, 7646 .help_str = "read regfield <port_id> <reg_off> <bit_x> <bit_y>: " 7647 "Read register bit field between bit_x and bit_y included", 7648 .tokens = { 7649 (void *)&cmd_read_reg_bit_field_read, 7650 (void *)&cmd_read_reg_bit_field_regfield, 7651 (void *)&cmd_read_reg_bit_field_port_id, 7652 (void *)&cmd_read_reg_bit_field_reg_off, 7653 (void *)&cmd_read_reg_bit_field_bit1_pos, 7654 (void *)&cmd_read_reg_bit_field_bit2_pos, 7655 NULL, 7656 }, 7657 }; 7658 7659 /* *** READ PORT REGISTER BIT *** */ 7660 struct cmd_read_reg_bit_result { 7661 cmdline_fixed_string_t read; 7662 cmdline_fixed_string_t regbit; 7663 portid_t port_id; 7664 uint32_t reg_off; 7665 uint8_t bit_pos; 7666 }; 7667 7668 static void 7669 cmd_read_reg_bit_parsed(void *parsed_result, 7670 __attribute__((unused)) struct cmdline *cl, 7671 __attribute__((unused)) void *data) 7672 { 7673 struct cmd_read_reg_bit_result *res = parsed_result; 7674 port_reg_bit_display(res->port_id, res->reg_off, res->bit_pos); 7675 } 7676 7677 cmdline_parse_token_string_t cmd_read_reg_bit_read = 7678 TOKEN_STRING_INITIALIZER(struct cmd_read_reg_bit_result, read, "read"); 7679 cmdline_parse_token_string_t cmd_read_reg_bit_regbit = 7680 TOKEN_STRING_INITIALIZER(struct cmd_read_reg_bit_result, 7681 regbit, "regbit"); 7682 cmdline_parse_token_num_t cmd_read_reg_bit_port_id = 7683 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_result, port_id, UINT16); 7684 cmdline_parse_token_num_t cmd_read_reg_bit_reg_off = 7685 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_result, reg_off, UINT32); 7686 cmdline_parse_token_num_t cmd_read_reg_bit_bit_pos = 7687 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_result, bit_pos, UINT8); 7688 7689 cmdline_parse_inst_t cmd_read_reg_bit = { 7690 .f = cmd_read_reg_bit_parsed, 7691 .data = NULL, 7692 .help_str = "read regbit <port_id> <reg_off> <bit_x>: 0 <= bit_x <= 31", 7693 .tokens = { 7694 (void *)&cmd_read_reg_bit_read, 7695 (void *)&cmd_read_reg_bit_regbit, 7696 (void *)&cmd_read_reg_bit_port_id, 7697 (void *)&cmd_read_reg_bit_reg_off, 7698 (void *)&cmd_read_reg_bit_bit_pos, 7699 NULL, 7700 }, 7701 }; 7702 7703 /* *** WRITE PORT REGISTER *** */ 7704 struct cmd_write_reg_result { 7705 cmdline_fixed_string_t write; 7706 cmdline_fixed_string_t reg; 7707 portid_t port_id; 7708 uint32_t reg_off; 7709 uint32_t value; 7710 }; 7711 7712 static void 7713 cmd_write_reg_parsed(void *parsed_result, 7714 __attribute__((unused)) struct cmdline *cl, 7715 __attribute__((unused)) void *data) 7716 { 7717 struct cmd_write_reg_result *res = parsed_result; 7718 port_reg_set(res->port_id, res->reg_off, res->value); 7719 } 7720 7721 cmdline_parse_token_string_t cmd_write_reg_write = 7722 TOKEN_STRING_INITIALIZER(struct cmd_write_reg_result, write, "write"); 7723 cmdline_parse_token_string_t cmd_write_reg_reg = 7724 TOKEN_STRING_INITIALIZER(struct cmd_write_reg_result, reg, "reg"); 7725 cmdline_parse_token_num_t cmd_write_reg_port_id = 7726 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_result, port_id, UINT16); 7727 cmdline_parse_token_num_t cmd_write_reg_reg_off = 7728 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_result, reg_off, UINT32); 7729 cmdline_parse_token_num_t cmd_write_reg_value = 7730 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_result, value, UINT32); 7731 7732 cmdline_parse_inst_t cmd_write_reg = { 7733 .f = cmd_write_reg_parsed, 7734 .data = NULL, 7735 .help_str = "write reg <port_id> <reg_off> <reg_value>", 7736 .tokens = { 7737 (void *)&cmd_write_reg_write, 7738 (void *)&cmd_write_reg_reg, 7739 (void *)&cmd_write_reg_port_id, 7740 (void *)&cmd_write_reg_reg_off, 7741 (void *)&cmd_write_reg_value, 7742 NULL, 7743 }, 7744 }; 7745 7746 /* *** WRITE PORT REGISTER BIT FIELD *** */ 7747 struct cmd_write_reg_bit_field_result { 7748 cmdline_fixed_string_t write; 7749 cmdline_fixed_string_t regfield; 7750 portid_t port_id; 7751 uint32_t reg_off; 7752 uint8_t bit1_pos; 7753 uint8_t bit2_pos; 7754 uint32_t value; 7755 }; 7756 7757 static void 7758 cmd_write_reg_bit_field_parsed(void *parsed_result, 7759 __attribute__((unused)) struct cmdline *cl, 7760 __attribute__((unused)) void *data) 7761 { 7762 struct cmd_write_reg_bit_field_result *res = parsed_result; 7763 port_reg_bit_field_set(res->port_id, res->reg_off, 7764 res->bit1_pos, res->bit2_pos, res->value); 7765 } 7766 7767 cmdline_parse_token_string_t cmd_write_reg_bit_field_write = 7768 TOKEN_STRING_INITIALIZER(struct cmd_write_reg_bit_field_result, write, 7769 "write"); 7770 cmdline_parse_token_string_t cmd_write_reg_bit_field_regfield = 7771 TOKEN_STRING_INITIALIZER(struct cmd_write_reg_bit_field_result, 7772 regfield, "regfield"); 7773 cmdline_parse_token_num_t cmd_write_reg_bit_field_port_id = 7774 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_field_result, port_id, 7775 UINT16); 7776 cmdline_parse_token_num_t cmd_write_reg_bit_field_reg_off = 7777 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_field_result, reg_off, 7778 UINT32); 7779 cmdline_parse_token_num_t cmd_write_reg_bit_field_bit1_pos = 7780 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_field_result, bit1_pos, 7781 UINT8); 7782 cmdline_parse_token_num_t cmd_write_reg_bit_field_bit2_pos = 7783 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_field_result, bit2_pos, 7784 UINT8); 7785 cmdline_parse_token_num_t cmd_write_reg_bit_field_value = 7786 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_field_result, value, 7787 UINT32); 7788 7789 cmdline_parse_inst_t cmd_write_reg_bit_field = { 7790 .f = cmd_write_reg_bit_field_parsed, 7791 .data = NULL, 7792 .help_str = "write regfield <port_id> <reg_off> <bit_x> <bit_y> " 7793 "<reg_value>: " 7794 "Set register bit field between bit_x and bit_y included", 7795 .tokens = { 7796 (void *)&cmd_write_reg_bit_field_write, 7797 (void *)&cmd_write_reg_bit_field_regfield, 7798 (void *)&cmd_write_reg_bit_field_port_id, 7799 (void *)&cmd_write_reg_bit_field_reg_off, 7800 (void *)&cmd_write_reg_bit_field_bit1_pos, 7801 (void *)&cmd_write_reg_bit_field_bit2_pos, 7802 (void *)&cmd_write_reg_bit_field_value, 7803 NULL, 7804 }, 7805 }; 7806 7807 /* *** WRITE PORT REGISTER BIT *** */ 7808 struct cmd_write_reg_bit_result { 7809 cmdline_fixed_string_t write; 7810 cmdline_fixed_string_t regbit; 7811 portid_t port_id; 7812 uint32_t reg_off; 7813 uint8_t bit_pos; 7814 uint8_t value; 7815 }; 7816 7817 static void 7818 cmd_write_reg_bit_parsed(void *parsed_result, 7819 __attribute__((unused)) struct cmdline *cl, 7820 __attribute__((unused)) void *data) 7821 { 7822 struct cmd_write_reg_bit_result *res = parsed_result; 7823 port_reg_bit_set(res->port_id, res->reg_off, res->bit_pos, res->value); 7824 } 7825 7826 cmdline_parse_token_string_t cmd_write_reg_bit_write = 7827 TOKEN_STRING_INITIALIZER(struct cmd_write_reg_bit_result, write, 7828 "write"); 7829 cmdline_parse_token_string_t cmd_write_reg_bit_regbit = 7830 TOKEN_STRING_INITIALIZER(struct cmd_write_reg_bit_result, 7831 regbit, "regbit"); 7832 cmdline_parse_token_num_t cmd_write_reg_bit_port_id = 7833 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_result, port_id, UINT16); 7834 cmdline_parse_token_num_t cmd_write_reg_bit_reg_off = 7835 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_result, reg_off, UINT32); 7836 cmdline_parse_token_num_t cmd_write_reg_bit_bit_pos = 7837 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_result, bit_pos, UINT8); 7838 cmdline_parse_token_num_t cmd_write_reg_bit_value = 7839 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_result, value, UINT8); 7840 7841 cmdline_parse_inst_t cmd_write_reg_bit = { 7842 .f = cmd_write_reg_bit_parsed, 7843 .data = NULL, 7844 .help_str = "write regbit <port_id> <reg_off> <bit_x> 0|1: " 7845 "0 <= bit_x <= 31", 7846 .tokens = { 7847 (void *)&cmd_write_reg_bit_write, 7848 (void *)&cmd_write_reg_bit_regbit, 7849 (void *)&cmd_write_reg_bit_port_id, 7850 (void *)&cmd_write_reg_bit_reg_off, 7851 (void *)&cmd_write_reg_bit_bit_pos, 7852 (void *)&cmd_write_reg_bit_value, 7853 NULL, 7854 }, 7855 }; 7856 7857 /* *** READ A RING DESCRIPTOR OF A PORT RX/TX QUEUE *** */ 7858 struct cmd_read_rxd_txd_result { 7859 cmdline_fixed_string_t read; 7860 cmdline_fixed_string_t rxd_txd; 7861 portid_t port_id; 7862 uint16_t queue_id; 7863 uint16_t desc_id; 7864 }; 7865 7866 static void 7867 cmd_read_rxd_txd_parsed(void *parsed_result, 7868 __attribute__((unused)) struct cmdline *cl, 7869 __attribute__((unused)) void *data) 7870 { 7871 struct cmd_read_rxd_txd_result *res = parsed_result; 7872 7873 if (!strcmp(res->rxd_txd, "rxd")) 7874 rx_ring_desc_display(res->port_id, res->queue_id, res->desc_id); 7875 else if (!strcmp(res->rxd_txd, "txd")) 7876 tx_ring_desc_display(res->port_id, res->queue_id, res->desc_id); 7877 } 7878 7879 cmdline_parse_token_string_t cmd_read_rxd_txd_read = 7880 TOKEN_STRING_INITIALIZER(struct cmd_read_rxd_txd_result, read, "read"); 7881 cmdline_parse_token_string_t cmd_read_rxd_txd_rxd_txd = 7882 TOKEN_STRING_INITIALIZER(struct cmd_read_rxd_txd_result, rxd_txd, 7883 "rxd#txd"); 7884 cmdline_parse_token_num_t cmd_read_rxd_txd_port_id = 7885 TOKEN_NUM_INITIALIZER(struct cmd_read_rxd_txd_result, port_id, UINT16); 7886 cmdline_parse_token_num_t cmd_read_rxd_txd_queue_id = 7887 TOKEN_NUM_INITIALIZER(struct cmd_read_rxd_txd_result, queue_id, UINT16); 7888 cmdline_parse_token_num_t cmd_read_rxd_txd_desc_id = 7889 TOKEN_NUM_INITIALIZER(struct cmd_read_rxd_txd_result, desc_id, UINT16); 7890 7891 cmdline_parse_inst_t cmd_read_rxd_txd = { 7892 .f = cmd_read_rxd_txd_parsed, 7893 .data = NULL, 7894 .help_str = "read rxd|txd <port_id> <queue_id> <desc_id>", 7895 .tokens = { 7896 (void *)&cmd_read_rxd_txd_read, 7897 (void *)&cmd_read_rxd_txd_rxd_txd, 7898 (void *)&cmd_read_rxd_txd_port_id, 7899 (void *)&cmd_read_rxd_txd_queue_id, 7900 (void *)&cmd_read_rxd_txd_desc_id, 7901 NULL, 7902 }, 7903 }; 7904 7905 /* *** QUIT *** */ 7906 struct cmd_quit_result { 7907 cmdline_fixed_string_t quit; 7908 }; 7909 7910 static void cmd_quit_parsed(__attribute__((unused)) void *parsed_result, 7911 struct cmdline *cl, 7912 __attribute__((unused)) void *data) 7913 { 7914 cmdline_quit(cl); 7915 } 7916 7917 cmdline_parse_token_string_t cmd_quit_quit = 7918 TOKEN_STRING_INITIALIZER(struct cmd_quit_result, quit, "quit"); 7919 7920 cmdline_parse_inst_t cmd_quit = { 7921 .f = cmd_quit_parsed, 7922 .data = NULL, 7923 .help_str = "quit: Exit application", 7924 .tokens = { 7925 (void *)&cmd_quit_quit, 7926 NULL, 7927 }, 7928 }; 7929 7930 /* *** ADD/REMOVE MAC ADDRESS FROM A PORT *** */ 7931 struct cmd_mac_addr_result { 7932 cmdline_fixed_string_t mac_addr_cmd; 7933 cmdline_fixed_string_t what; 7934 uint16_t port_num; 7935 struct rte_ether_addr address; 7936 }; 7937 7938 static void cmd_mac_addr_parsed(void *parsed_result, 7939 __attribute__((unused)) struct cmdline *cl, 7940 __attribute__((unused)) void *data) 7941 { 7942 struct cmd_mac_addr_result *res = parsed_result; 7943 int ret; 7944 7945 if (strcmp(res->what, "add") == 0) 7946 ret = rte_eth_dev_mac_addr_add(res->port_num, &res->address, 0); 7947 else if (strcmp(res->what, "set") == 0) 7948 ret = rte_eth_dev_default_mac_addr_set(res->port_num, 7949 &res->address); 7950 else 7951 ret = rte_eth_dev_mac_addr_remove(res->port_num, &res->address); 7952 7953 /* check the return value and print it if is < 0 */ 7954 if(ret < 0) 7955 printf("mac_addr_cmd error: (%s)\n", strerror(-ret)); 7956 7957 } 7958 7959 cmdline_parse_token_string_t cmd_mac_addr_cmd = 7960 TOKEN_STRING_INITIALIZER(struct cmd_mac_addr_result, mac_addr_cmd, 7961 "mac_addr"); 7962 cmdline_parse_token_string_t cmd_mac_addr_what = 7963 TOKEN_STRING_INITIALIZER(struct cmd_mac_addr_result, what, 7964 "add#remove#set"); 7965 cmdline_parse_token_num_t cmd_mac_addr_portnum = 7966 TOKEN_NUM_INITIALIZER(struct cmd_mac_addr_result, port_num, 7967 UINT16); 7968 cmdline_parse_token_etheraddr_t cmd_mac_addr_addr = 7969 TOKEN_ETHERADDR_INITIALIZER(struct cmd_mac_addr_result, address); 7970 7971 cmdline_parse_inst_t cmd_mac_addr = { 7972 .f = cmd_mac_addr_parsed, 7973 .data = (void *)0, 7974 .help_str = "mac_addr add|remove|set <port_id> <mac_addr>: " 7975 "Add/Remove/Set MAC address on port_id", 7976 .tokens = { 7977 (void *)&cmd_mac_addr_cmd, 7978 (void *)&cmd_mac_addr_what, 7979 (void *)&cmd_mac_addr_portnum, 7980 (void *)&cmd_mac_addr_addr, 7981 NULL, 7982 }, 7983 }; 7984 7985 /* *** SET THE PEER ADDRESS FOR CERTAIN PORT *** */ 7986 struct cmd_eth_peer_result { 7987 cmdline_fixed_string_t set; 7988 cmdline_fixed_string_t eth_peer; 7989 portid_t port_id; 7990 cmdline_fixed_string_t peer_addr; 7991 }; 7992 7993 static void cmd_set_eth_peer_parsed(void *parsed_result, 7994 __attribute__((unused)) struct cmdline *cl, 7995 __attribute__((unused)) void *data) 7996 { 7997 struct cmd_eth_peer_result *res = parsed_result; 7998 7999 if (test_done == 0) { 8000 printf("Please stop forwarding first\n"); 8001 return; 8002 } 8003 if (!strcmp(res->eth_peer, "eth-peer")) { 8004 set_fwd_eth_peer(res->port_id, res->peer_addr); 8005 fwd_config_setup(); 8006 } 8007 } 8008 cmdline_parse_token_string_t cmd_eth_peer_set = 8009 TOKEN_STRING_INITIALIZER(struct cmd_eth_peer_result, set, "set"); 8010 cmdline_parse_token_string_t cmd_eth_peer = 8011 TOKEN_STRING_INITIALIZER(struct cmd_eth_peer_result, eth_peer, "eth-peer"); 8012 cmdline_parse_token_num_t cmd_eth_peer_port_id = 8013 TOKEN_NUM_INITIALIZER(struct cmd_eth_peer_result, port_id, UINT16); 8014 cmdline_parse_token_string_t cmd_eth_peer_addr = 8015 TOKEN_STRING_INITIALIZER(struct cmd_eth_peer_result, peer_addr, NULL); 8016 8017 cmdline_parse_inst_t cmd_set_fwd_eth_peer = { 8018 .f = cmd_set_eth_peer_parsed, 8019 .data = NULL, 8020 .help_str = "set eth-peer <port_id> <peer_mac>", 8021 .tokens = { 8022 (void *)&cmd_eth_peer_set, 8023 (void *)&cmd_eth_peer, 8024 (void *)&cmd_eth_peer_port_id, 8025 (void *)&cmd_eth_peer_addr, 8026 NULL, 8027 }, 8028 }; 8029 8030 /* *** CONFIGURE QUEUE STATS COUNTER MAPPINGS *** */ 8031 struct cmd_set_qmap_result { 8032 cmdline_fixed_string_t set; 8033 cmdline_fixed_string_t qmap; 8034 cmdline_fixed_string_t what; 8035 portid_t port_id; 8036 uint16_t queue_id; 8037 uint8_t map_value; 8038 }; 8039 8040 static void 8041 cmd_set_qmap_parsed(void *parsed_result, 8042 __attribute__((unused)) struct cmdline *cl, 8043 __attribute__((unused)) void *data) 8044 { 8045 struct cmd_set_qmap_result *res = parsed_result; 8046 int is_rx = (strcmp(res->what, "tx") == 0) ? 0 : 1; 8047 8048 set_qmap(res->port_id, (uint8_t)is_rx, res->queue_id, res->map_value); 8049 } 8050 8051 cmdline_parse_token_string_t cmd_setqmap_set = 8052 TOKEN_STRING_INITIALIZER(struct cmd_set_qmap_result, 8053 set, "set"); 8054 cmdline_parse_token_string_t cmd_setqmap_qmap = 8055 TOKEN_STRING_INITIALIZER(struct cmd_set_qmap_result, 8056 qmap, "stat_qmap"); 8057 cmdline_parse_token_string_t cmd_setqmap_what = 8058 TOKEN_STRING_INITIALIZER(struct cmd_set_qmap_result, 8059 what, "tx#rx"); 8060 cmdline_parse_token_num_t cmd_setqmap_portid = 8061 TOKEN_NUM_INITIALIZER(struct cmd_set_qmap_result, 8062 port_id, UINT16); 8063 cmdline_parse_token_num_t cmd_setqmap_queueid = 8064 TOKEN_NUM_INITIALIZER(struct cmd_set_qmap_result, 8065 queue_id, UINT16); 8066 cmdline_parse_token_num_t cmd_setqmap_mapvalue = 8067 TOKEN_NUM_INITIALIZER(struct cmd_set_qmap_result, 8068 map_value, UINT8); 8069 8070 cmdline_parse_inst_t cmd_set_qmap = { 8071 .f = cmd_set_qmap_parsed, 8072 .data = NULL, 8073 .help_str = "set stat_qmap rx|tx <port_id> <queue_id> <map_value>: " 8074 "Set statistics mapping value on tx|rx queue_id of port_id", 8075 .tokens = { 8076 (void *)&cmd_setqmap_set, 8077 (void *)&cmd_setqmap_qmap, 8078 (void *)&cmd_setqmap_what, 8079 (void *)&cmd_setqmap_portid, 8080 (void *)&cmd_setqmap_queueid, 8081 (void *)&cmd_setqmap_mapvalue, 8082 NULL, 8083 }, 8084 }; 8085 8086 /* *** SET OPTION TO HIDE ZERO VALUES FOR XSTATS DISPLAY *** */ 8087 struct cmd_set_xstats_hide_zero_result { 8088 cmdline_fixed_string_t keyword; 8089 cmdline_fixed_string_t name; 8090 cmdline_fixed_string_t on_off; 8091 }; 8092 8093 static void 8094 cmd_set_xstats_hide_zero_parsed(void *parsed_result, 8095 __attribute__((unused)) struct cmdline *cl, 8096 __attribute__((unused)) void *data) 8097 { 8098 struct cmd_set_xstats_hide_zero_result *res; 8099 uint16_t on_off = 0; 8100 8101 res = parsed_result; 8102 on_off = !strcmp(res->on_off, "on") ? 1 : 0; 8103 set_xstats_hide_zero(on_off); 8104 } 8105 8106 cmdline_parse_token_string_t cmd_set_xstats_hide_zero_keyword = 8107 TOKEN_STRING_INITIALIZER(struct cmd_set_xstats_hide_zero_result, 8108 keyword, "set"); 8109 cmdline_parse_token_string_t cmd_set_xstats_hide_zero_name = 8110 TOKEN_STRING_INITIALIZER(struct cmd_set_xstats_hide_zero_result, 8111 name, "xstats-hide-zero"); 8112 cmdline_parse_token_string_t cmd_set_xstats_hide_zero_on_off = 8113 TOKEN_STRING_INITIALIZER(struct cmd_set_xstats_hide_zero_result, 8114 on_off, "on#off"); 8115 8116 cmdline_parse_inst_t cmd_set_xstats_hide_zero = { 8117 .f = cmd_set_xstats_hide_zero_parsed, 8118 .data = NULL, 8119 .help_str = "set xstats-hide-zero on|off", 8120 .tokens = { 8121 (void *)&cmd_set_xstats_hide_zero_keyword, 8122 (void *)&cmd_set_xstats_hide_zero_name, 8123 (void *)&cmd_set_xstats_hide_zero_on_off, 8124 NULL, 8125 }, 8126 }; 8127 8128 /* *** CONFIGURE UNICAST HASH TABLE *** */ 8129 struct cmd_set_uc_hash_table { 8130 cmdline_fixed_string_t set; 8131 cmdline_fixed_string_t port; 8132 portid_t port_id; 8133 cmdline_fixed_string_t what; 8134 struct rte_ether_addr address; 8135 cmdline_fixed_string_t mode; 8136 }; 8137 8138 static void 8139 cmd_set_uc_hash_parsed(void *parsed_result, 8140 __attribute__((unused)) struct cmdline *cl, 8141 __attribute__((unused)) void *data) 8142 { 8143 int ret=0; 8144 struct cmd_set_uc_hash_table *res = parsed_result; 8145 8146 int is_on = (strcmp(res->mode, "on") == 0) ? 1 : 0; 8147 8148 if (strcmp(res->what, "uta") == 0) 8149 ret = rte_eth_dev_uc_hash_table_set(res->port_id, 8150 &res->address,(uint8_t)is_on); 8151 if (ret < 0) 8152 printf("bad unicast hash table parameter, return code = %d \n", ret); 8153 8154 } 8155 8156 cmdline_parse_token_string_t cmd_set_uc_hash_set = 8157 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_hash_table, 8158 set, "set"); 8159 cmdline_parse_token_string_t cmd_set_uc_hash_port = 8160 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_hash_table, 8161 port, "port"); 8162 cmdline_parse_token_num_t cmd_set_uc_hash_portid = 8163 TOKEN_NUM_INITIALIZER(struct cmd_set_uc_hash_table, 8164 port_id, UINT16); 8165 cmdline_parse_token_string_t cmd_set_uc_hash_what = 8166 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_hash_table, 8167 what, "uta"); 8168 cmdline_parse_token_etheraddr_t cmd_set_uc_hash_mac = 8169 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_uc_hash_table, 8170 address); 8171 cmdline_parse_token_string_t cmd_set_uc_hash_mode = 8172 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_hash_table, 8173 mode, "on#off"); 8174 8175 cmdline_parse_inst_t cmd_set_uc_hash_filter = { 8176 .f = cmd_set_uc_hash_parsed, 8177 .data = NULL, 8178 .help_str = "set port <port_id> uta <mac_addr> on|off)", 8179 .tokens = { 8180 (void *)&cmd_set_uc_hash_set, 8181 (void *)&cmd_set_uc_hash_port, 8182 (void *)&cmd_set_uc_hash_portid, 8183 (void *)&cmd_set_uc_hash_what, 8184 (void *)&cmd_set_uc_hash_mac, 8185 (void *)&cmd_set_uc_hash_mode, 8186 NULL, 8187 }, 8188 }; 8189 8190 struct cmd_set_uc_all_hash_table { 8191 cmdline_fixed_string_t set; 8192 cmdline_fixed_string_t port; 8193 portid_t port_id; 8194 cmdline_fixed_string_t what; 8195 cmdline_fixed_string_t value; 8196 cmdline_fixed_string_t mode; 8197 }; 8198 8199 static void 8200 cmd_set_uc_all_hash_parsed(void *parsed_result, 8201 __attribute__((unused)) struct cmdline *cl, 8202 __attribute__((unused)) void *data) 8203 { 8204 int ret=0; 8205 struct cmd_set_uc_all_hash_table *res = parsed_result; 8206 8207 int is_on = (strcmp(res->mode, "on") == 0) ? 1 : 0; 8208 8209 if ((strcmp(res->what, "uta") == 0) && 8210 (strcmp(res->value, "all") == 0)) 8211 ret = rte_eth_dev_uc_all_hash_table_set(res->port_id,(uint8_t) is_on); 8212 if (ret < 0) 8213 printf("bad unicast hash table parameter," 8214 "return code = %d \n", ret); 8215 } 8216 8217 cmdline_parse_token_string_t cmd_set_uc_all_hash_set = 8218 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_all_hash_table, 8219 set, "set"); 8220 cmdline_parse_token_string_t cmd_set_uc_all_hash_port = 8221 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_all_hash_table, 8222 port, "port"); 8223 cmdline_parse_token_num_t cmd_set_uc_all_hash_portid = 8224 TOKEN_NUM_INITIALIZER(struct cmd_set_uc_all_hash_table, 8225 port_id, UINT16); 8226 cmdline_parse_token_string_t cmd_set_uc_all_hash_what = 8227 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_all_hash_table, 8228 what, "uta"); 8229 cmdline_parse_token_string_t cmd_set_uc_all_hash_value = 8230 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_all_hash_table, 8231 value,"all"); 8232 cmdline_parse_token_string_t cmd_set_uc_all_hash_mode = 8233 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_all_hash_table, 8234 mode, "on#off"); 8235 8236 cmdline_parse_inst_t cmd_set_uc_all_hash_filter = { 8237 .f = cmd_set_uc_all_hash_parsed, 8238 .data = NULL, 8239 .help_str = "set port <port_id> uta all on|off", 8240 .tokens = { 8241 (void *)&cmd_set_uc_all_hash_set, 8242 (void *)&cmd_set_uc_all_hash_port, 8243 (void *)&cmd_set_uc_all_hash_portid, 8244 (void *)&cmd_set_uc_all_hash_what, 8245 (void *)&cmd_set_uc_all_hash_value, 8246 (void *)&cmd_set_uc_all_hash_mode, 8247 NULL, 8248 }, 8249 }; 8250 8251 /* *** CONFIGURE MACVLAN FILTER FOR VF(s) *** */ 8252 struct cmd_set_vf_macvlan_filter { 8253 cmdline_fixed_string_t set; 8254 cmdline_fixed_string_t port; 8255 portid_t port_id; 8256 cmdline_fixed_string_t vf; 8257 uint8_t vf_id; 8258 struct rte_ether_addr address; 8259 cmdline_fixed_string_t filter_type; 8260 cmdline_fixed_string_t mode; 8261 }; 8262 8263 static void 8264 cmd_set_vf_macvlan_parsed(void *parsed_result, 8265 __attribute__((unused)) struct cmdline *cl, 8266 __attribute__((unused)) void *data) 8267 { 8268 int is_on, ret = 0; 8269 struct cmd_set_vf_macvlan_filter *res = parsed_result; 8270 struct rte_eth_mac_filter filter; 8271 8272 memset(&filter, 0, sizeof(struct rte_eth_mac_filter)); 8273 8274 rte_memcpy(&filter.mac_addr, &res->address, RTE_ETHER_ADDR_LEN); 8275 8276 /* set VF MAC filter */ 8277 filter.is_vf = 1; 8278 8279 /* set VF ID */ 8280 filter.dst_id = res->vf_id; 8281 8282 if (!strcmp(res->filter_type, "exact-mac")) 8283 filter.filter_type = RTE_MAC_PERFECT_MATCH; 8284 else if (!strcmp(res->filter_type, "exact-mac-vlan")) 8285 filter.filter_type = RTE_MACVLAN_PERFECT_MATCH; 8286 else if (!strcmp(res->filter_type, "hashmac")) 8287 filter.filter_type = RTE_MAC_HASH_MATCH; 8288 else if (!strcmp(res->filter_type, "hashmac-vlan")) 8289 filter.filter_type = RTE_MACVLAN_HASH_MATCH; 8290 8291 is_on = (strcmp(res->mode, "on") == 0) ? 1 : 0; 8292 8293 if (is_on) 8294 ret = rte_eth_dev_filter_ctrl(res->port_id, 8295 RTE_ETH_FILTER_MACVLAN, 8296 RTE_ETH_FILTER_ADD, 8297 &filter); 8298 else 8299 ret = rte_eth_dev_filter_ctrl(res->port_id, 8300 RTE_ETH_FILTER_MACVLAN, 8301 RTE_ETH_FILTER_DELETE, 8302 &filter); 8303 8304 if (ret < 0) 8305 printf("bad set MAC hash parameter, return code = %d\n", ret); 8306 8307 } 8308 8309 cmdline_parse_token_string_t cmd_set_vf_macvlan_set = 8310 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_macvlan_filter, 8311 set, "set"); 8312 cmdline_parse_token_string_t cmd_set_vf_macvlan_port = 8313 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_macvlan_filter, 8314 port, "port"); 8315 cmdline_parse_token_num_t cmd_set_vf_macvlan_portid = 8316 TOKEN_NUM_INITIALIZER(struct cmd_set_vf_macvlan_filter, 8317 port_id, UINT16); 8318 cmdline_parse_token_string_t cmd_set_vf_macvlan_vf = 8319 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_macvlan_filter, 8320 vf, "vf"); 8321 cmdline_parse_token_num_t cmd_set_vf_macvlan_vf_id = 8322 TOKEN_NUM_INITIALIZER(struct cmd_set_vf_macvlan_filter, 8323 vf_id, UINT8); 8324 cmdline_parse_token_etheraddr_t cmd_set_vf_macvlan_mac = 8325 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_vf_macvlan_filter, 8326 address); 8327 cmdline_parse_token_string_t cmd_set_vf_macvlan_filter_type = 8328 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_macvlan_filter, 8329 filter_type, "exact-mac#exact-mac-vlan" 8330 "#hashmac#hashmac-vlan"); 8331 cmdline_parse_token_string_t cmd_set_vf_macvlan_mode = 8332 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_macvlan_filter, 8333 mode, "on#off"); 8334 8335 cmdline_parse_inst_t cmd_set_vf_macvlan_filter = { 8336 .f = cmd_set_vf_macvlan_parsed, 8337 .data = NULL, 8338 .help_str = "set port <port_id> vf <vf_id> <mac_addr> " 8339 "exact-mac|exact-mac-vlan|hashmac|hashmac-vlan on|off: " 8340 "Exact match rule: exact match of MAC or MAC and VLAN; " 8341 "hash match rule: hash match of MAC and exact match of VLAN", 8342 .tokens = { 8343 (void *)&cmd_set_vf_macvlan_set, 8344 (void *)&cmd_set_vf_macvlan_port, 8345 (void *)&cmd_set_vf_macvlan_portid, 8346 (void *)&cmd_set_vf_macvlan_vf, 8347 (void *)&cmd_set_vf_macvlan_vf_id, 8348 (void *)&cmd_set_vf_macvlan_mac, 8349 (void *)&cmd_set_vf_macvlan_filter_type, 8350 (void *)&cmd_set_vf_macvlan_mode, 8351 NULL, 8352 }, 8353 }; 8354 8355 /* *** CONFIGURE VF TRAFFIC CONTROL *** */ 8356 struct cmd_set_vf_traffic { 8357 cmdline_fixed_string_t set; 8358 cmdline_fixed_string_t port; 8359 portid_t port_id; 8360 cmdline_fixed_string_t vf; 8361 uint8_t vf_id; 8362 cmdline_fixed_string_t what; 8363 cmdline_fixed_string_t mode; 8364 }; 8365 8366 static void 8367 cmd_set_vf_traffic_parsed(void *parsed_result, 8368 __attribute__((unused)) struct cmdline *cl, 8369 __attribute__((unused)) void *data) 8370 { 8371 struct cmd_set_vf_traffic *res = parsed_result; 8372 int is_rx = (strcmp(res->what, "rx") == 0) ? 1 : 0; 8373 int is_on = (strcmp(res->mode, "on") == 0) ? 1 : 0; 8374 8375 set_vf_traffic(res->port_id, (uint8_t)is_rx, res->vf_id,(uint8_t) is_on); 8376 } 8377 8378 cmdline_parse_token_string_t cmd_setvf_traffic_set = 8379 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_traffic, 8380 set, "set"); 8381 cmdline_parse_token_string_t cmd_setvf_traffic_port = 8382 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_traffic, 8383 port, "port"); 8384 cmdline_parse_token_num_t cmd_setvf_traffic_portid = 8385 TOKEN_NUM_INITIALIZER(struct cmd_set_vf_traffic, 8386 port_id, UINT16); 8387 cmdline_parse_token_string_t cmd_setvf_traffic_vf = 8388 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_traffic, 8389 vf, "vf"); 8390 cmdline_parse_token_num_t cmd_setvf_traffic_vfid = 8391 TOKEN_NUM_INITIALIZER(struct cmd_set_vf_traffic, 8392 vf_id, UINT8); 8393 cmdline_parse_token_string_t cmd_setvf_traffic_what = 8394 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_traffic, 8395 what, "tx#rx"); 8396 cmdline_parse_token_string_t cmd_setvf_traffic_mode = 8397 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_traffic, 8398 mode, "on#off"); 8399 8400 cmdline_parse_inst_t cmd_set_vf_traffic = { 8401 .f = cmd_set_vf_traffic_parsed, 8402 .data = NULL, 8403 .help_str = "set port <port_id> vf <vf_id> rx|tx on|off", 8404 .tokens = { 8405 (void *)&cmd_setvf_traffic_set, 8406 (void *)&cmd_setvf_traffic_port, 8407 (void *)&cmd_setvf_traffic_portid, 8408 (void *)&cmd_setvf_traffic_vf, 8409 (void *)&cmd_setvf_traffic_vfid, 8410 (void *)&cmd_setvf_traffic_what, 8411 (void *)&cmd_setvf_traffic_mode, 8412 NULL, 8413 }, 8414 }; 8415 8416 /* *** CONFIGURE VF RECEIVE MODE *** */ 8417 struct cmd_set_vf_rxmode { 8418 cmdline_fixed_string_t set; 8419 cmdline_fixed_string_t port; 8420 portid_t port_id; 8421 cmdline_fixed_string_t vf; 8422 uint8_t vf_id; 8423 cmdline_fixed_string_t what; 8424 cmdline_fixed_string_t mode; 8425 cmdline_fixed_string_t on; 8426 }; 8427 8428 static void 8429 cmd_set_vf_rxmode_parsed(void *parsed_result, 8430 __attribute__((unused)) struct cmdline *cl, 8431 __attribute__((unused)) void *data) 8432 { 8433 int ret = -ENOTSUP; 8434 uint16_t vf_rxmode = 0; 8435 struct cmd_set_vf_rxmode *res = parsed_result; 8436 8437 int is_on = (strcmp(res->on, "on") == 0) ? 1 : 0; 8438 if (!strcmp(res->what,"rxmode")) { 8439 if (!strcmp(res->mode, "AUPE")) 8440 vf_rxmode |= ETH_VMDQ_ACCEPT_UNTAG; 8441 else if (!strcmp(res->mode, "ROPE")) 8442 vf_rxmode |= ETH_VMDQ_ACCEPT_HASH_UC; 8443 else if (!strcmp(res->mode, "BAM")) 8444 vf_rxmode |= ETH_VMDQ_ACCEPT_BROADCAST; 8445 else if (!strncmp(res->mode, "MPE",3)) 8446 vf_rxmode |= ETH_VMDQ_ACCEPT_MULTICAST; 8447 } 8448 8449 RTE_SET_USED(is_on); 8450 8451 #ifdef RTE_LIBRTE_IXGBE_PMD 8452 if (ret == -ENOTSUP) 8453 ret = rte_pmd_ixgbe_set_vf_rxmode(res->port_id, res->vf_id, 8454 vf_rxmode, (uint8_t)is_on); 8455 #endif 8456 #ifdef RTE_LIBRTE_BNXT_PMD 8457 if (ret == -ENOTSUP) 8458 ret = rte_pmd_bnxt_set_vf_rxmode(res->port_id, res->vf_id, 8459 vf_rxmode, (uint8_t)is_on); 8460 #endif 8461 if (ret < 0) 8462 printf("bad VF receive mode parameter, return code = %d \n", 8463 ret); 8464 } 8465 8466 cmdline_parse_token_string_t cmd_set_vf_rxmode_set = 8467 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_rxmode, 8468 set, "set"); 8469 cmdline_parse_token_string_t cmd_set_vf_rxmode_port = 8470 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_rxmode, 8471 port, "port"); 8472 cmdline_parse_token_num_t cmd_set_vf_rxmode_portid = 8473 TOKEN_NUM_INITIALIZER(struct cmd_set_vf_rxmode, 8474 port_id, UINT16); 8475 cmdline_parse_token_string_t cmd_set_vf_rxmode_vf = 8476 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_rxmode, 8477 vf, "vf"); 8478 cmdline_parse_token_num_t cmd_set_vf_rxmode_vfid = 8479 TOKEN_NUM_INITIALIZER(struct cmd_set_vf_rxmode, 8480 vf_id, UINT8); 8481 cmdline_parse_token_string_t cmd_set_vf_rxmode_what = 8482 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_rxmode, 8483 what, "rxmode"); 8484 cmdline_parse_token_string_t cmd_set_vf_rxmode_mode = 8485 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_rxmode, 8486 mode, "AUPE#ROPE#BAM#MPE"); 8487 cmdline_parse_token_string_t cmd_set_vf_rxmode_on = 8488 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_rxmode, 8489 on, "on#off"); 8490 8491 cmdline_parse_inst_t cmd_set_vf_rxmode = { 8492 .f = cmd_set_vf_rxmode_parsed, 8493 .data = NULL, 8494 .help_str = "set port <port_id> vf <vf_id> rxmode " 8495 "AUPE|ROPE|BAM|MPE on|off", 8496 .tokens = { 8497 (void *)&cmd_set_vf_rxmode_set, 8498 (void *)&cmd_set_vf_rxmode_port, 8499 (void *)&cmd_set_vf_rxmode_portid, 8500 (void *)&cmd_set_vf_rxmode_vf, 8501 (void *)&cmd_set_vf_rxmode_vfid, 8502 (void *)&cmd_set_vf_rxmode_what, 8503 (void *)&cmd_set_vf_rxmode_mode, 8504 (void *)&cmd_set_vf_rxmode_on, 8505 NULL, 8506 }, 8507 }; 8508 8509 /* *** ADD MAC ADDRESS FILTER FOR A VF OF A PORT *** */ 8510 struct cmd_vf_mac_addr_result { 8511 cmdline_fixed_string_t mac_addr_cmd; 8512 cmdline_fixed_string_t what; 8513 cmdline_fixed_string_t port; 8514 uint16_t port_num; 8515 cmdline_fixed_string_t vf; 8516 uint8_t vf_num; 8517 struct rte_ether_addr address; 8518 }; 8519 8520 static void cmd_vf_mac_addr_parsed(void *parsed_result, 8521 __attribute__((unused)) struct cmdline *cl, 8522 __attribute__((unused)) void *data) 8523 { 8524 struct cmd_vf_mac_addr_result *res = parsed_result; 8525 int ret = -ENOTSUP; 8526 8527 if (strcmp(res->what, "add") != 0) 8528 return; 8529 8530 #ifdef RTE_LIBRTE_I40E_PMD 8531 if (ret == -ENOTSUP) 8532 ret = rte_pmd_i40e_add_vf_mac_addr(res->port_num, res->vf_num, 8533 &res->address); 8534 #endif 8535 #ifdef RTE_LIBRTE_BNXT_PMD 8536 if (ret == -ENOTSUP) 8537 ret = rte_pmd_bnxt_mac_addr_add(res->port_num, &res->address, 8538 res->vf_num); 8539 #endif 8540 8541 if(ret < 0) 8542 printf("vf_mac_addr_cmd error: (%s)\n", strerror(-ret)); 8543 8544 } 8545 8546 cmdline_parse_token_string_t cmd_vf_mac_addr_cmd = 8547 TOKEN_STRING_INITIALIZER(struct cmd_vf_mac_addr_result, 8548 mac_addr_cmd,"mac_addr"); 8549 cmdline_parse_token_string_t cmd_vf_mac_addr_what = 8550 TOKEN_STRING_INITIALIZER(struct cmd_vf_mac_addr_result, 8551 what,"add"); 8552 cmdline_parse_token_string_t cmd_vf_mac_addr_port = 8553 TOKEN_STRING_INITIALIZER(struct cmd_vf_mac_addr_result, 8554 port,"port"); 8555 cmdline_parse_token_num_t cmd_vf_mac_addr_portnum = 8556 TOKEN_NUM_INITIALIZER(struct cmd_vf_mac_addr_result, 8557 port_num, UINT16); 8558 cmdline_parse_token_string_t cmd_vf_mac_addr_vf = 8559 TOKEN_STRING_INITIALIZER(struct cmd_vf_mac_addr_result, 8560 vf,"vf"); 8561 cmdline_parse_token_num_t cmd_vf_mac_addr_vfnum = 8562 TOKEN_NUM_INITIALIZER(struct cmd_vf_mac_addr_result, 8563 vf_num, UINT8); 8564 cmdline_parse_token_etheraddr_t cmd_vf_mac_addr_addr = 8565 TOKEN_ETHERADDR_INITIALIZER(struct cmd_vf_mac_addr_result, 8566 address); 8567 8568 cmdline_parse_inst_t cmd_vf_mac_addr_filter = { 8569 .f = cmd_vf_mac_addr_parsed, 8570 .data = (void *)0, 8571 .help_str = "mac_addr add port <port_id> vf <vf_id> <mac_addr>: " 8572 "Add MAC address filtering for a VF on port_id", 8573 .tokens = { 8574 (void *)&cmd_vf_mac_addr_cmd, 8575 (void *)&cmd_vf_mac_addr_what, 8576 (void *)&cmd_vf_mac_addr_port, 8577 (void *)&cmd_vf_mac_addr_portnum, 8578 (void *)&cmd_vf_mac_addr_vf, 8579 (void *)&cmd_vf_mac_addr_vfnum, 8580 (void *)&cmd_vf_mac_addr_addr, 8581 NULL, 8582 }, 8583 }; 8584 8585 /* *** ADD/REMOVE A VLAN IDENTIFIER TO/FROM A PORT VLAN RX FILTER *** */ 8586 struct cmd_vf_rx_vlan_filter { 8587 cmdline_fixed_string_t rx_vlan; 8588 cmdline_fixed_string_t what; 8589 uint16_t vlan_id; 8590 cmdline_fixed_string_t port; 8591 portid_t port_id; 8592 cmdline_fixed_string_t vf; 8593 uint64_t vf_mask; 8594 }; 8595 8596 static void 8597 cmd_vf_rx_vlan_filter_parsed(void *parsed_result, 8598 __attribute__((unused)) struct cmdline *cl, 8599 __attribute__((unused)) void *data) 8600 { 8601 struct cmd_vf_rx_vlan_filter *res = parsed_result; 8602 int ret = -ENOTSUP; 8603 8604 __rte_unused int is_add = (strcmp(res->what, "add") == 0) ? 1 : 0; 8605 8606 #ifdef RTE_LIBRTE_IXGBE_PMD 8607 if (ret == -ENOTSUP) 8608 ret = rte_pmd_ixgbe_set_vf_vlan_filter(res->port_id, 8609 res->vlan_id, res->vf_mask, is_add); 8610 #endif 8611 #ifdef RTE_LIBRTE_I40E_PMD 8612 if (ret == -ENOTSUP) 8613 ret = rte_pmd_i40e_set_vf_vlan_filter(res->port_id, 8614 res->vlan_id, res->vf_mask, is_add); 8615 #endif 8616 #ifdef RTE_LIBRTE_BNXT_PMD 8617 if (ret == -ENOTSUP) 8618 ret = rte_pmd_bnxt_set_vf_vlan_filter(res->port_id, 8619 res->vlan_id, res->vf_mask, is_add); 8620 #endif 8621 8622 switch (ret) { 8623 case 0: 8624 break; 8625 case -EINVAL: 8626 printf("invalid vlan_id %d or vf_mask %"PRIu64"\n", 8627 res->vlan_id, res->vf_mask); 8628 break; 8629 case -ENODEV: 8630 printf("invalid port_id %d\n", res->port_id); 8631 break; 8632 case -ENOTSUP: 8633 printf("function not implemented or supported\n"); 8634 break; 8635 default: 8636 printf("programming error: (%s)\n", strerror(-ret)); 8637 } 8638 } 8639 8640 cmdline_parse_token_string_t cmd_vf_rx_vlan_filter_rx_vlan = 8641 TOKEN_STRING_INITIALIZER(struct cmd_vf_rx_vlan_filter, 8642 rx_vlan, "rx_vlan"); 8643 cmdline_parse_token_string_t cmd_vf_rx_vlan_filter_what = 8644 TOKEN_STRING_INITIALIZER(struct cmd_vf_rx_vlan_filter, 8645 what, "add#rm"); 8646 cmdline_parse_token_num_t cmd_vf_rx_vlan_filter_vlanid = 8647 TOKEN_NUM_INITIALIZER(struct cmd_vf_rx_vlan_filter, 8648 vlan_id, UINT16); 8649 cmdline_parse_token_string_t cmd_vf_rx_vlan_filter_port = 8650 TOKEN_STRING_INITIALIZER(struct cmd_vf_rx_vlan_filter, 8651 port, "port"); 8652 cmdline_parse_token_num_t cmd_vf_rx_vlan_filter_portid = 8653 TOKEN_NUM_INITIALIZER(struct cmd_vf_rx_vlan_filter, 8654 port_id, UINT16); 8655 cmdline_parse_token_string_t cmd_vf_rx_vlan_filter_vf = 8656 TOKEN_STRING_INITIALIZER(struct cmd_vf_rx_vlan_filter, 8657 vf, "vf"); 8658 cmdline_parse_token_num_t cmd_vf_rx_vlan_filter_vf_mask = 8659 TOKEN_NUM_INITIALIZER(struct cmd_vf_rx_vlan_filter, 8660 vf_mask, UINT64); 8661 8662 cmdline_parse_inst_t cmd_vf_rxvlan_filter = { 8663 .f = cmd_vf_rx_vlan_filter_parsed, 8664 .data = NULL, 8665 .help_str = "rx_vlan add|rm <vlan_id> port <port_id> vf <vf_mask>: " 8666 "(vf_mask = hexadecimal VF mask)", 8667 .tokens = { 8668 (void *)&cmd_vf_rx_vlan_filter_rx_vlan, 8669 (void *)&cmd_vf_rx_vlan_filter_what, 8670 (void *)&cmd_vf_rx_vlan_filter_vlanid, 8671 (void *)&cmd_vf_rx_vlan_filter_port, 8672 (void *)&cmd_vf_rx_vlan_filter_portid, 8673 (void *)&cmd_vf_rx_vlan_filter_vf, 8674 (void *)&cmd_vf_rx_vlan_filter_vf_mask, 8675 NULL, 8676 }, 8677 }; 8678 8679 /* *** SET RATE LIMIT FOR A QUEUE OF A PORT *** */ 8680 struct cmd_queue_rate_limit_result { 8681 cmdline_fixed_string_t set; 8682 cmdline_fixed_string_t port; 8683 uint16_t port_num; 8684 cmdline_fixed_string_t queue; 8685 uint8_t queue_num; 8686 cmdline_fixed_string_t rate; 8687 uint16_t rate_num; 8688 }; 8689 8690 static void cmd_queue_rate_limit_parsed(void *parsed_result, 8691 __attribute__((unused)) struct cmdline *cl, 8692 __attribute__((unused)) void *data) 8693 { 8694 struct cmd_queue_rate_limit_result *res = parsed_result; 8695 int ret = 0; 8696 8697 if ((strcmp(res->set, "set") == 0) && (strcmp(res->port, "port") == 0) 8698 && (strcmp(res->queue, "queue") == 0) 8699 && (strcmp(res->rate, "rate") == 0)) 8700 ret = set_queue_rate_limit(res->port_num, res->queue_num, 8701 res->rate_num); 8702 if (ret < 0) 8703 printf("queue_rate_limit_cmd error: (%s)\n", strerror(-ret)); 8704 8705 } 8706 8707 cmdline_parse_token_string_t cmd_queue_rate_limit_set = 8708 TOKEN_STRING_INITIALIZER(struct cmd_queue_rate_limit_result, 8709 set, "set"); 8710 cmdline_parse_token_string_t cmd_queue_rate_limit_port = 8711 TOKEN_STRING_INITIALIZER(struct cmd_queue_rate_limit_result, 8712 port, "port"); 8713 cmdline_parse_token_num_t cmd_queue_rate_limit_portnum = 8714 TOKEN_NUM_INITIALIZER(struct cmd_queue_rate_limit_result, 8715 port_num, UINT16); 8716 cmdline_parse_token_string_t cmd_queue_rate_limit_queue = 8717 TOKEN_STRING_INITIALIZER(struct cmd_queue_rate_limit_result, 8718 queue, "queue"); 8719 cmdline_parse_token_num_t cmd_queue_rate_limit_queuenum = 8720 TOKEN_NUM_INITIALIZER(struct cmd_queue_rate_limit_result, 8721 queue_num, UINT8); 8722 cmdline_parse_token_string_t cmd_queue_rate_limit_rate = 8723 TOKEN_STRING_INITIALIZER(struct cmd_queue_rate_limit_result, 8724 rate, "rate"); 8725 cmdline_parse_token_num_t cmd_queue_rate_limit_ratenum = 8726 TOKEN_NUM_INITIALIZER(struct cmd_queue_rate_limit_result, 8727 rate_num, UINT16); 8728 8729 cmdline_parse_inst_t cmd_queue_rate_limit = { 8730 .f = cmd_queue_rate_limit_parsed, 8731 .data = (void *)0, 8732 .help_str = "set port <port_id> queue <queue_id> rate <rate_value>: " 8733 "Set rate limit for a queue on port_id", 8734 .tokens = { 8735 (void *)&cmd_queue_rate_limit_set, 8736 (void *)&cmd_queue_rate_limit_port, 8737 (void *)&cmd_queue_rate_limit_portnum, 8738 (void *)&cmd_queue_rate_limit_queue, 8739 (void *)&cmd_queue_rate_limit_queuenum, 8740 (void *)&cmd_queue_rate_limit_rate, 8741 (void *)&cmd_queue_rate_limit_ratenum, 8742 NULL, 8743 }, 8744 }; 8745 8746 /* *** SET RATE LIMIT FOR A VF OF A PORT *** */ 8747 struct cmd_vf_rate_limit_result { 8748 cmdline_fixed_string_t set; 8749 cmdline_fixed_string_t port; 8750 uint16_t port_num; 8751 cmdline_fixed_string_t vf; 8752 uint8_t vf_num; 8753 cmdline_fixed_string_t rate; 8754 uint16_t rate_num; 8755 cmdline_fixed_string_t q_msk; 8756 uint64_t q_msk_val; 8757 }; 8758 8759 static void cmd_vf_rate_limit_parsed(void *parsed_result, 8760 __attribute__((unused)) struct cmdline *cl, 8761 __attribute__((unused)) void *data) 8762 { 8763 struct cmd_vf_rate_limit_result *res = parsed_result; 8764 int ret = 0; 8765 8766 if ((strcmp(res->set, "set") == 0) && (strcmp(res->port, "port") == 0) 8767 && (strcmp(res->vf, "vf") == 0) 8768 && (strcmp(res->rate, "rate") == 0) 8769 && (strcmp(res->q_msk, "queue_mask") == 0)) 8770 ret = set_vf_rate_limit(res->port_num, res->vf_num, 8771 res->rate_num, res->q_msk_val); 8772 if (ret < 0) 8773 printf("vf_rate_limit_cmd error: (%s)\n", strerror(-ret)); 8774 8775 } 8776 8777 cmdline_parse_token_string_t cmd_vf_rate_limit_set = 8778 TOKEN_STRING_INITIALIZER(struct cmd_vf_rate_limit_result, 8779 set, "set"); 8780 cmdline_parse_token_string_t cmd_vf_rate_limit_port = 8781 TOKEN_STRING_INITIALIZER(struct cmd_vf_rate_limit_result, 8782 port, "port"); 8783 cmdline_parse_token_num_t cmd_vf_rate_limit_portnum = 8784 TOKEN_NUM_INITIALIZER(struct cmd_vf_rate_limit_result, 8785 port_num, UINT16); 8786 cmdline_parse_token_string_t cmd_vf_rate_limit_vf = 8787 TOKEN_STRING_INITIALIZER(struct cmd_vf_rate_limit_result, 8788 vf, "vf"); 8789 cmdline_parse_token_num_t cmd_vf_rate_limit_vfnum = 8790 TOKEN_NUM_INITIALIZER(struct cmd_vf_rate_limit_result, 8791 vf_num, UINT8); 8792 cmdline_parse_token_string_t cmd_vf_rate_limit_rate = 8793 TOKEN_STRING_INITIALIZER(struct cmd_vf_rate_limit_result, 8794 rate, "rate"); 8795 cmdline_parse_token_num_t cmd_vf_rate_limit_ratenum = 8796 TOKEN_NUM_INITIALIZER(struct cmd_vf_rate_limit_result, 8797 rate_num, UINT16); 8798 cmdline_parse_token_string_t cmd_vf_rate_limit_q_msk = 8799 TOKEN_STRING_INITIALIZER(struct cmd_vf_rate_limit_result, 8800 q_msk, "queue_mask"); 8801 cmdline_parse_token_num_t cmd_vf_rate_limit_q_msk_val = 8802 TOKEN_NUM_INITIALIZER(struct cmd_vf_rate_limit_result, 8803 q_msk_val, UINT64); 8804 8805 cmdline_parse_inst_t cmd_vf_rate_limit = { 8806 .f = cmd_vf_rate_limit_parsed, 8807 .data = (void *)0, 8808 .help_str = "set port <port_id> vf <vf_id> rate <rate_value> " 8809 "queue_mask <queue_mask_value>: " 8810 "Set rate limit for queues of VF on port_id", 8811 .tokens = { 8812 (void *)&cmd_vf_rate_limit_set, 8813 (void *)&cmd_vf_rate_limit_port, 8814 (void *)&cmd_vf_rate_limit_portnum, 8815 (void *)&cmd_vf_rate_limit_vf, 8816 (void *)&cmd_vf_rate_limit_vfnum, 8817 (void *)&cmd_vf_rate_limit_rate, 8818 (void *)&cmd_vf_rate_limit_ratenum, 8819 (void *)&cmd_vf_rate_limit_q_msk, 8820 (void *)&cmd_vf_rate_limit_q_msk_val, 8821 NULL, 8822 }, 8823 }; 8824 8825 /* *** ADD TUNNEL FILTER OF A PORT *** */ 8826 struct cmd_tunnel_filter_result { 8827 cmdline_fixed_string_t cmd; 8828 cmdline_fixed_string_t what; 8829 portid_t port_id; 8830 struct rte_ether_addr outer_mac; 8831 struct rte_ether_addr inner_mac; 8832 cmdline_ipaddr_t ip_value; 8833 uint16_t inner_vlan; 8834 cmdline_fixed_string_t tunnel_type; 8835 cmdline_fixed_string_t filter_type; 8836 uint32_t tenant_id; 8837 uint16_t queue_num; 8838 }; 8839 8840 static void 8841 cmd_tunnel_filter_parsed(void *parsed_result, 8842 __attribute__((unused)) struct cmdline *cl, 8843 __attribute__((unused)) void *data) 8844 { 8845 struct cmd_tunnel_filter_result *res = parsed_result; 8846 struct rte_eth_tunnel_filter_conf tunnel_filter_conf; 8847 int ret = 0; 8848 8849 memset(&tunnel_filter_conf, 0, sizeof(tunnel_filter_conf)); 8850 8851 rte_ether_addr_copy(&res->outer_mac, &tunnel_filter_conf.outer_mac); 8852 rte_ether_addr_copy(&res->inner_mac, &tunnel_filter_conf.inner_mac); 8853 tunnel_filter_conf.inner_vlan = res->inner_vlan; 8854 8855 if (res->ip_value.family == AF_INET) { 8856 tunnel_filter_conf.ip_addr.ipv4_addr = 8857 res->ip_value.addr.ipv4.s_addr; 8858 tunnel_filter_conf.ip_type = RTE_TUNNEL_IPTYPE_IPV4; 8859 } else { 8860 memcpy(&(tunnel_filter_conf.ip_addr.ipv6_addr), 8861 &(res->ip_value.addr.ipv6), 8862 sizeof(struct in6_addr)); 8863 tunnel_filter_conf.ip_type = RTE_TUNNEL_IPTYPE_IPV6; 8864 } 8865 8866 if (!strcmp(res->filter_type, "imac-ivlan")) 8867 tunnel_filter_conf.filter_type = RTE_TUNNEL_FILTER_IMAC_IVLAN; 8868 else if (!strcmp(res->filter_type, "imac-ivlan-tenid")) 8869 tunnel_filter_conf.filter_type = 8870 RTE_TUNNEL_FILTER_IMAC_IVLAN_TENID; 8871 else if (!strcmp(res->filter_type, "imac-tenid")) 8872 tunnel_filter_conf.filter_type = RTE_TUNNEL_FILTER_IMAC_TENID; 8873 else if (!strcmp(res->filter_type, "imac")) 8874 tunnel_filter_conf.filter_type = ETH_TUNNEL_FILTER_IMAC; 8875 else if (!strcmp(res->filter_type, "omac-imac-tenid")) 8876 tunnel_filter_conf.filter_type = 8877 RTE_TUNNEL_FILTER_OMAC_TENID_IMAC; 8878 else if (!strcmp(res->filter_type, "oip")) 8879 tunnel_filter_conf.filter_type = ETH_TUNNEL_FILTER_OIP; 8880 else if (!strcmp(res->filter_type, "iip")) 8881 tunnel_filter_conf.filter_type = ETH_TUNNEL_FILTER_IIP; 8882 else { 8883 printf("The filter type is not supported"); 8884 return; 8885 } 8886 8887 if (!strcmp(res->tunnel_type, "vxlan")) 8888 tunnel_filter_conf.tunnel_type = RTE_TUNNEL_TYPE_VXLAN; 8889 else if (!strcmp(res->tunnel_type, "vxlan-gpe")) 8890 tunnel_filter_conf.tunnel_type = RTE_TUNNEL_TYPE_VXLAN_GPE; 8891 else if (!strcmp(res->tunnel_type, "nvgre")) 8892 tunnel_filter_conf.tunnel_type = RTE_TUNNEL_TYPE_NVGRE; 8893 else if (!strcmp(res->tunnel_type, "ipingre")) 8894 tunnel_filter_conf.tunnel_type = RTE_TUNNEL_TYPE_IP_IN_GRE; 8895 else { 8896 printf("The tunnel type %s not supported.\n", res->tunnel_type); 8897 return; 8898 } 8899 8900 tunnel_filter_conf.tenant_id = res->tenant_id; 8901 tunnel_filter_conf.queue_id = res->queue_num; 8902 if (!strcmp(res->what, "add")) 8903 ret = rte_eth_dev_filter_ctrl(res->port_id, 8904 RTE_ETH_FILTER_TUNNEL, 8905 RTE_ETH_FILTER_ADD, 8906 &tunnel_filter_conf); 8907 else 8908 ret = rte_eth_dev_filter_ctrl(res->port_id, 8909 RTE_ETH_FILTER_TUNNEL, 8910 RTE_ETH_FILTER_DELETE, 8911 &tunnel_filter_conf); 8912 if (ret < 0) 8913 printf("cmd_tunnel_filter_parsed error: (%s)\n", 8914 strerror(-ret)); 8915 8916 } 8917 cmdline_parse_token_string_t cmd_tunnel_filter_cmd = 8918 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_filter_result, 8919 cmd, "tunnel_filter"); 8920 cmdline_parse_token_string_t cmd_tunnel_filter_what = 8921 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_filter_result, 8922 what, "add#rm"); 8923 cmdline_parse_token_num_t cmd_tunnel_filter_port_id = 8924 TOKEN_NUM_INITIALIZER(struct cmd_tunnel_filter_result, 8925 port_id, UINT16); 8926 cmdline_parse_token_etheraddr_t cmd_tunnel_filter_outer_mac = 8927 TOKEN_ETHERADDR_INITIALIZER(struct cmd_tunnel_filter_result, 8928 outer_mac); 8929 cmdline_parse_token_etheraddr_t cmd_tunnel_filter_inner_mac = 8930 TOKEN_ETHERADDR_INITIALIZER(struct cmd_tunnel_filter_result, 8931 inner_mac); 8932 cmdline_parse_token_num_t cmd_tunnel_filter_innner_vlan = 8933 TOKEN_NUM_INITIALIZER(struct cmd_tunnel_filter_result, 8934 inner_vlan, UINT16); 8935 cmdline_parse_token_ipaddr_t cmd_tunnel_filter_ip_value = 8936 TOKEN_IPADDR_INITIALIZER(struct cmd_tunnel_filter_result, 8937 ip_value); 8938 cmdline_parse_token_string_t cmd_tunnel_filter_tunnel_type = 8939 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_filter_result, 8940 tunnel_type, "vxlan#nvgre#ipingre#vxlan-gpe"); 8941 8942 cmdline_parse_token_string_t cmd_tunnel_filter_filter_type = 8943 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_filter_result, 8944 filter_type, "oip#iip#imac-ivlan#imac-ivlan-tenid#imac-tenid#" 8945 "imac#omac-imac-tenid"); 8946 cmdline_parse_token_num_t cmd_tunnel_filter_tenant_id = 8947 TOKEN_NUM_INITIALIZER(struct cmd_tunnel_filter_result, 8948 tenant_id, UINT32); 8949 cmdline_parse_token_num_t cmd_tunnel_filter_queue_num = 8950 TOKEN_NUM_INITIALIZER(struct cmd_tunnel_filter_result, 8951 queue_num, UINT16); 8952 8953 cmdline_parse_inst_t cmd_tunnel_filter = { 8954 .f = cmd_tunnel_filter_parsed, 8955 .data = (void *)0, 8956 .help_str = "tunnel_filter add|rm <port_id> <outer_mac> <inner_mac> " 8957 "<ip> <inner_vlan> vxlan|nvgre|ipingre oip|iip|imac-ivlan|" 8958 "imac-ivlan-tenid|imac-tenid|imac|omac-imac-tenid <tenant_id> " 8959 "<queue_id>: Add/Rm tunnel filter of a port", 8960 .tokens = { 8961 (void *)&cmd_tunnel_filter_cmd, 8962 (void *)&cmd_tunnel_filter_what, 8963 (void *)&cmd_tunnel_filter_port_id, 8964 (void *)&cmd_tunnel_filter_outer_mac, 8965 (void *)&cmd_tunnel_filter_inner_mac, 8966 (void *)&cmd_tunnel_filter_ip_value, 8967 (void *)&cmd_tunnel_filter_innner_vlan, 8968 (void *)&cmd_tunnel_filter_tunnel_type, 8969 (void *)&cmd_tunnel_filter_filter_type, 8970 (void *)&cmd_tunnel_filter_tenant_id, 8971 (void *)&cmd_tunnel_filter_queue_num, 8972 NULL, 8973 }, 8974 }; 8975 8976 /* *** CONFIGURE TUNNEL UDP PORT *** */ 8977 struct cmd_tunnel_udp_config { 8978 cmdline_fixed_string_t cmd; 8979 cmdline_fixed_string_t what; 8980 uint16_t udp_port; 8981 portid_t port_id; 8982 }; 8983 8984 static void 8985 cmd_tunnel_udp_config_parsed(void *parsed_result, 8986 __attribute__((unused)) struct cmdline *cl, 8987 __attribute__((unused)) void *data) 8988 { 8989 struct cmd_tunnel_udp_config *res = parsed_result; 8990 struct rte_eth_udp_tunnel tunnel_udp; 8991 int ret; 8992 8993 tunnel_udp.udp_port = res->udp_port; 8994 8995 if (!strcmp(res->cmd, "rx_vxlan_port")) 8996 tunnel_udp.prot_type = RTE_TUNNEL_TYPE_VXLAN; 8997 8998 if (!strcmp(res->what, "add")) 8999 ret = rte_eth_dev_udp_tunnel_port_add(res->port_id, 9000 &tunnel_udp); 9001 else 9002 ret = rte_eth_dev_udp_tunnel_port_delete(res->port_id, 9003 &tunnel_udp); 9004 9005 if (ret < 0) 9006 printf("udp tunneling add error: (%s)\n", strerror(-ret)); 9007 } 9008 9009 cmdline_parse_token_string_t cmd_tunnel_udp_config_cmd = 9010 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_udp_config, 9011 cmd, "rx_vxlan_port"); 9012 cmdline_parse_token_string_t cmd_tunnel_udp_config_what = 9013 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_udp_config, 9014 what, "add#rm"); 9015 cmdline_parse_token_num_t cmd_tunnel_udp_config_udp_port = 9016 TOKEN_NUM_INITIALIZER(struct cmd_tunnel_udp_config, 9017 udp_port, UINT16); 9018 cmdline_parse_token_num_t cmd_tunnel_udp_config_port_id = 9019 TOKEN_NUM_INITIALIZER(struct cmd_tunnel_udp_config, 9020 port_id, UINT16); 9021 9022 cmdline_parse_inst_t cmd_tunnel_udp_config = { 9023 .f = cmd_tunnel_udp_config_parsed, 9024 .data = (void *)0, 9025 .help_str = "rx_vxlan_port add|rm <udp_port> <port_id>: " 9026 "Add/Remove a tunneling UDP port filter", 9027 .tokens = { 9028 (void *)&cmd_tunnel_udp_config_cmd, 9029 (void *)&cmd_tunnel_udp_config_what, 9030 (void *)&cmd_tunnel_udp_config_udp_port, 9031 (void *)&cmd_tunnel_udp_config_port_id, 9032 NULL, 9033 }, 9034 }; 9035 9036 struct cmd_config_tunnel_udp_port { 9037 cmdline_fixed_string_t port; 9038 cmdline_fixed_string_t config; 9039 portid_t port_id; 9040 cmdline_fixed_string_t udp_tunnel_port; 9041 cmdline_fixed_string_t action; 9042 cmdline_fixed_string_t tunnel_type; 9043 uint16_t udp_port; 9044 }; 9045 9046 static void 9047 cmd_cfg_tunnel_udp_port_parsed(void *parsed_result, 9048 __attribute__((unused)) struct cmdline *cl, 9049 __attribute__((unused)) void *data) 9050 { 9051 struct cmd_config_tunnel_udp_port *res = parsed_result; 9052 struct rte_eth_udp_tunnel tunnel_udp; 9053 int ret = 0; 9054 9055 if (port_id_is_invalid(res->port_id, ENABLED_WARN)) 9056 return; 9057 9058 tunnel_udp.udp_port = res->udp_port; 9059 9060 if (!strcmp(res->tunnel_type, "vxlan")) { 9061 tunnel_udp.prot_type = RTE_TUNNEL_TYPE_VXLAN; 9062 } else if (!strcmp(res->tunnel_type, "geneve")) { 9063 tunnel_udp.prot_type = RTE_TUNNEL_TYPE_GENEVE; 9064 } else if (!strcmp(res->tunnel_type, "vxlan-gpe")) { 9065 tunnel_udp.prot_type = RTE_TUNNEL_TYPE_VXLAN_GPE; 9066 } else { 9067 printf("Invalid tunnel type\n"); 9068 return; 9069 } 9070 9071 if (!strcmp(res->action, "add")) 9072 ret = rte_eth_dev_udp_tunnel_port_add(res->port_id, 9073 &tunnel_udp); 9074 else 9075 ret = rte_eth_dev_udp_tunnel_port_delete(res->port_id, 9076 &tunnel_udp); 9077 9078 if (ret < 0) 9079 printf("udp tunneling port add error: (%s)\n", strerror(-ret)); 9080 } 9081 9082 cmdline_parse_token_string_t cmd_config_tunnel_udp_port_port = 9083 TOKEN_STRING_INITIALIZER(struct cmd_config_tunnel_udp_port, port, 9084 "port"); 9085 cmdline_parse_token_string_t cmd_config_tunnel_udp_port_config = 9086 TOKEN_STRING_INITIALIZER(struct cmd_config_tunnel_udp_port, config, 9087 "config"); 9088 cmdline_parse_token_num_t cmd_config_tunnel_udp_port_port_id = 9089 TOKEN_NUM_INITIALIZER(struct cmd_config_tunnel_udp_port, port_id, 9090 UINT16); 9091 cmdline_parse_token_string_t cmd_config_tunnel_udp_port_tunnel_port = 9092 TOKEN_STRING_INITIALIZER(struct cmd_config_tunnel_udp_port, 9093 udp_tunnel_port, 9094 "udp_tunnel_port"); 9095 cmdline_parse_token_string_t cmd_config_tunnel_udp_port_action = 9096 TOKEN_STRING_INITIALIZER(struct cmd_config_tunnel_udp_port, action, 9097 "add#rm"); 9098 cmdline_parse_token_string_t cmd_config_tunnel_udp_port_tunnel_type = 9099 TOKEN_STRING_INITIALIZER(struct cmd_config_tunnel_udp_port, tunnel_type, 9100 "vxlan#geneve#vxlan-gpe"); 9101 cmdline_parse_token_num_t cmd_config_tunnel_udp_port_value = 9102 TOKEN_NUM_INITIALIZER(struct cmd_config_tunnel_udp_port, udp_port, 9103 UINT16); 9104 9105 cmdline_parse_inst_t cmd_cfg_tunnel_udp_port = { 9106 .f = cmd_cfg_tunnel_udp_port_parsed, 9107 .data = NULL, 9108 .help_str = "port config <port_id> udp_tunnel_port add|rm vxlan|geneve|vxlan-gpe <udp_port>", 9109 .tokens = { 9110 (void *)&cmd_config_tunnel_udp_port_port, 9111 (void *)&cmd_config_tunnel_udp_port_config, 9112 (void *)&cmd_config_tunnel_udp_port_port_id, 9113 (void *)&cmd_config_tunnel_udp_port_tunnel_port, 9114 (void *)&cmd_config_tunnel_udp_port_action, 9115 (void *)&cmd_config_tunnel_udp_port_tunnel_type, 9116 (void *)&cmd_config_tunnel_udp_port_value, 9117 NULL, 9118 }, 9119 }; 9120 9121 /* *** GLOBAL CONFIG *** */ 9122 struct cmd_global_config_result { 9123 cmdline_fixed_string_t cmd; 9124 portid_t port_id; 9125 cmdline_fixed_string_t cfg_type; 9126 uint8_t len; 9127 }; 9128 9129 static void 9130 cmd_global_config_parsed(void *parsed_result, 9131 __attribute__((unused)) struct cmdline *cl, 9132 __attribute__((unused)) void *data) 9133 { 9134 struct cmd_global_config_result *res = parsed_result; 9135 struct rte_eth_global_cfg conf; 9136 int ret; 9137 9138 memset(&conf, 0, sizeof(conf)); 9139 conf.cfg_type = RTE_ETH_GLOBAL_CFG_TYPE_GRE_KEY_LEN; 9140 conf.cfg.gre_key_len = res->len; 9141 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_NONE, 9142 RTE_ETH_FILTER_SET, &conf); 9143 if (ret != 0) 9144 printf("Global config error\n"); 9145 } 9146 9147 cmdline_parse_token_string_t cmd_global_config_cmd = 9148 TOKEN_STRING_INITIALIZER(struct cmd_global_config_result, cmd, 9149 "global_config"); 9150 cmdline_parse_token_num_t cmd_global_config_port_id = 9151 TOKEN_NUM_INITIALIZER(struct cmd_global_config_result, port_id, 9152 UINT16); 9153 cmdline_parse_token_string_t cmd_global_config_type = 9154 TOKEN_STRING_INITIALIZER(struct cmd_global_config_result, 9155 cfg_type, "gre-key-len"); 9156 cmdline_parse_token_num_t cmd_global_config_gre_key_len = 9157 TOKEN_NUM_INITIALIZER(struct cmd_global_config_result, 9158 len, UINT8); 9159 9160 cmdline_parse_inst_t cmd_global_config = { 9161 .f = cmd_global_config_parsed, 9162 .data = (void *)NULL, 9163 .help_str = "global_config <port_id> gre-key-len <key_len>", 9164 .tokens = { 9165 (void *)&cmd_global_config_cmd, 9166 (void *)&cmd_global_config_port_id, 9167 (void *)&cmd_global_config_type, 9168 (void *)&cmd_global_config_gre_key_len, 9169 NULL, 9170 }, 9171 }; 9172 9173 /* *** CONFIGURE VM MIRROR VLAN/POOL RULE *** */ 9174 struct cmd_set_mirror_mask_result { 9175 cmdline_fixed_string_t set; 9176 cmdline_fixed_string_t port; 9177 portid_t port_id; 9178 cmdline_fixed_string_t mirror; 9179 uint8_t rule_id; 9180 cmdline_fixed_string_t what; 9181 cmdline_fixed_string_t value; 9182 cmdline_fixed_string_t dstpool; 9183 uint8_t dstpool_id; 9184 cmdline_fixed_string_t on; 9185 }; 9186 9187 cmdline_parse_token_string_t cmd_mirror_mask_set = 9188 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result, 9189 set, "set"); 9190 cmdline_parse_token_string_t cmd_mirror_mask_port = 9191 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result, 9192 port, "port"); 9193 cmdline_parse_token_num_t cmd_mirror_mask_portid = 9194 TOKEN_NUM_INITIALIZER(struct cmd_set_mirror_mask_result, 9195 port_id, UINT16); 9196 cmdline_parse_token_string_t cmd_mirror_mask_mirror = 9197 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result, 9198 mirror, "mirror-rule"); 9199 cmdline_parse_token_num_t cmd_mirror_mask_ruleid = 9200 TOKEN_NUM_INITIALIZER(struct cmd_set_mirror_mask_result, 9201 rule_id, UINT8); 9202 cmdline_parse_token_string_t cmd_mirror_mask_what = 9203 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result, 9204 what, "pool-mirror-up#pool-mirror-down" 9205 "#vlan-mirror"); 9206 cmdline_parse_token_string_t cmd_mirror_mask_value = 9207 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result, 9208 value, NULL); 9209 cmdline_parse_token_string_t cmd_mirror_mask_dstpool = 9210 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result, 9211 dstpool, "dst-pool"); 9212 cmdline_parse_token_num_t cmd_mirror_mask_poolid = 9213 TOKEN_NUM_INITIALIZER(struct cmd_set_mirror_mask_result, 9214 dstpool_id, UINT8); 9215 cmdline_parse_token_string_t cmd_mirror_mask_on = 9216 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result, 9217 on, "on#off"); 9218 9219 static void 9220 cmd_set_mirror_mask_parsed(void *parsed_result, 9221 __attribute__((unused)) struct cmdline *cl, 9222 __attribute__((unused)) void *data) 9223 { 9224 int ret,nb_item,i; 9225 struct cmd_set_mirror_mask_result *res = parsed_result; 9226 struct rte_eth_mirror_conf mr_conf; 9227 9228 memset(&mr_conf, 0, sizeof(struct rte_eth_mirror_conf)); 9229 9230 unsigned int vlan_list[ETH_MIRROR_MAX_VLANS]; 9231 9232 mr_conf.dst_pool = res->dstpool_id; 9233 9234 if (!strcmp(res->what, "pool-mirror-up")) { 9235 mr_conf.pool_mask = strtoull(res->value, NULL, 16); 9236 mr_conf.rule_type = ETH_MIRROR_VIRTUAL_POOL_UP; 9237 } else if (!strcmp(res->what, "pool-mirror-down")) { 9238 mr_conf.pool_mask = strtoull(res->value, NULL, 16); 9239 mr_conf.rule_type = ETH_MIRROR_VIRTUAL_POOL_DOWN; 9240 } else if (!strcmp(res->what, "vlan-mirror")) { 9241 mr_conf.rule_type = ETH_MIRROR_VLAN; 9242 nb_item = parse_item_list(res->value, "vlan", 9243 ETH_MIRROR_MAX_VLANS, vlan_list, 1); 9244 if (nb_item <= 0) 9245 return; 9246 9247 for (i = 0; i < nb_item; i++) { 9248 if (vlan_list[i] > RTE_ETHER_MAX_VLAN_ID) { 9249 printf("Invalid vlan_id: must be < 4096\n"); 9250 return; 9251 } 9252 9253 mr_conf.vlan.vlan_id[i] = (uint16_t)vlan_list[i]; 9254 mr_conf.vlan.vlan_mask |= 1ULL << i; 9255 } 9256 } 9257 9258 if (!strcmp(res->on, "on")) 9259 ret = rte_eth_mirror_rule_set(res->port_id, &mr_conf, 9260 res->rule_id, 1); 9261 else 9262 ret = rte_eth_mirror_rule_set(res->port_id, &mr_conf, 9263 res->rule_id, 0); 9264 if (ret < 0) 9265 printf("mirror rule add error: (%s)\n", strerror(-ret)); 9266 } 9267 9268 cmdline_parse_inst_t cmd_set_mirror_mask = { 9269 .f = cmd_set_mirror_mask_parsed, 9270 .data = NULL, 9271 .help_str = "set port <port_id> mirror-rule <rule_id> " 9272 "pool-mirror-up|pool-mirror-down|vlan-mirror " 9273 "<pool_mask|vlan_id[,vlan_id]*> dst-pool <pool_id> on|off", 9274 .tokens = { 9275 (void *)&cmd_mirror_mask_set, 9276 (void *)&cmd_mirror_mask_port, 9277 (void *)&cmd_mirror_mask_portid, 9278 (void *)&cmd_mirror_mask_mirror, 9279 (void *)&cmd_mirror_mask_ruleid, 9280 (void *)&cmd_mirror_mask_what, 9281 (void *)&cmd_mirror_mask_value, 9282 (void *)&cmd_mirror_mask_dstpool, 9283 (void *)&cmd_mirror_mask_poolid, 9284 (void *)&cmd_mirror_mask_on, 9285 NULL, 9286 }, 9287 }; 9288 9289 /* *** CONFIGURE VM MIRROR UPLINK/DOWNLINK RULE *** */ 9290 struct cmd_set_mirror_link_result { 9291 cmdline_fixed_string_t set; 9292 cmdline_fixed_string_t port; 9293 portid_t port_id; 9294 cmdline_fixed_string_t mirror; 9295 uint8_t rule_id; 9296 cmdline_fixed_string_t what; 9297 cmdline_fixed_string_t dstpool; 9298 uint8_t dstpool_id; 9299 cmdline_fixed_string_t on; 9300 }; 9301 9302 cmdline_parse_token_string_t cmd_mirror_link_set = 9303 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_link_result, 9304 set, "set"); 9305 cmdline_parse_token_string_t cmd_mirror_link_port = 9306 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_link_result, 9307 port, "port"); 9308 cmdline_parse_token_num_t cmd_mirror_link_portid = 9309 TOKEN_NUM_INITIALIZER(struct cmd_set_mirror_link_result, 9310 port_id, UINT16); 9311 cmdline_parse_token_string_t cmd_mirror_link_mirror = 9312 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_link_result, 9313 mirror, "mirror-rule"); 9314 cmdline_parse_token_num_t cmd_mirror_link_ruleid = 9315 TOKEN_NUM_INITIALIZER(struct cmd_set_mirror_link_result, 9316 rule_id, UINT8); 9317 cmdline_parse_token_string_t cmd_mirror_link_what = 9318 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_link_result, 9319 what, "uplink-mirror#downlink-mirror"); 9320 cmdline_parse_token_string_t cmd_mirror_link_dstpool = 9321 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_link_result, 9322 dstpool, "dst-pool"); 9323 cmdline_parse_token_num_t cmd_mirror_link_poolid = 9324 TOKEN_NUM_INITIALIZER(struct cmd_set_mirror_link_result, 9325 dstpool_id, UINT8); 9326 cmdline_parse_token_string_t cmd_mirror_link_on = 9327 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_link_result, 9328 on, "on#off"); 9329 9330 static void 9331 cmd_set_mirror_link_parsed(void *parsed_result, 9332 __attribute__((unused)) struct cmdline *cl, 9333 __attribute__((unused)) void *data) 9334 { 9335 int ret; 9336 struct cmd_set_mirror_link_result *res = parsed_result; 9337 struct rte_eth_mirror_conf mr_conf; 9338 9339 memset(&mr_conf, 0, sizeof(struct rte_eth_mirror_conf)); 9340 if (!strcmp(res->what, "uplink-mirror")) 9341 mr_conf.rule_type = ETH_MIRROR_UPLINK_PORT; 9342 else 9343 mr_conf.rule_type = ETH_MIRROR_DOWNLINK_PORT; 9344 9345 mr_conf.dst_pool = res->dstpool_id; 9346 9347 if (!strcmp(res->on, "on")) 9348 ret = rte_eth_mirror_rule_set(res->port_id, &mr_conf, 9349 res->rule_id, 1); 9350 else 9351 ret = rte_eth_mirror_rule_set(res->port_id, &mr_conf, 9352 res->rule_id, 0); 9353 9354 /* check the return value and print it if is < 0 */ 9355 if (ret < 0) 9356 printf("mirror rule add error: (%s)\n", strerror(-ret)); 9357 9358 } 9359 9360 cmdline_parse_inst_t cmd_set_mirror_link = { 9361 .f = cmd_set_mirror_link_parsed, 9362 .data = NULL, 9363 .help_str = "set port <port_id> mirror-rule <rule_id> " 9364 "uplink-mirror|downlink-mirror dst-pool <pool_id> on|off", 9365 .tokens = { 9366 (void *)&cmd_mirror_link_set, 9367 (void *)&cmd_mirror_link_port, 9368 (void *)&cmd_mirror_link_portid, 9369 (void *)&cmd_mirror_link_mirror, 9370 (void *)&cmd_mirror_link_ruleid, 9371 (void *)&cmd_mirror_link_what, 9372 (void *)&cmd_mirror_link_dstpool, 9373 (void *)&cmd_mirror_link_poolid, 9374 (void *)&cmd_mirror_link_on, 9375 NULL, 9376 }, 9377 }; 9378 9379 /* *** RESET VM MIRROR RULE *** */ 9380 struct cmd_rm_mirror_rule_result { 9381 cmdline_fixed_string_t reset; 9382 cmdline_fixed_string_t port; 9383 portid_t port_id; 9384 cmdline_fixed_string_t mirror; 9385 uint8_t rule_id; 9386 }; 9387 9388 cmdline_parse_token_string_t cmd_rm_mirror_rule_reset = 9389 TOKEN_STRING_INITIALIZER(struct cmd_rm_mirror_rule_result, 9390 reset, "reset"); 9391 cmdline_parse_token_string_t cmd_rm_mirror_rule_port = 9392 TOKEN_STRING_INITIALIZER(struct cmd_rm_mirror_rule_result, 9393 port, "port"); 9394 cmdline_parse_token_num_t cmd_rm_mirror_rule_portid = 9395 TOKEN_NUM_INITIALIZER(struct cmd_rm_mirror_rule_result, 9396 port_id, UINT16); 9397 cmdline_parse_token_string_t cmd_rm_mirror_rule_mirror = 9398 TOKEN_STRING_INITIALIZER(struct cmd_rm_mirror_rule_result, 9399 mirror, "mirror-rule"); 9400 cmdline_parse_token_num_t cmd_rm_mirror_rule_ruleid = 9401 TOKEN_NUM_INITIALIZER(struct cmd_rm_mirror_rule_result, 9402 rule_id, UINT8); 9403 9404 static void 9405 cmd_reset_mirror_rule_parsed(void *parsed_result, 9406 __attribute__((unused)) struct cmdline *cl, 9407 __attribute__((unused)) void *data) 9408 { 9409 int ret; 9410 struct cmd_set_mirror_link_result *res = parsed_result; 9411 /* check rule_id */ 9412 ret = rte_eth_mirror_rule_reset(res->port_id,res->rule_id); 9413 if(ret < 0) 9414 printf("mirror rule remove error: (%s)\n", strerror(-ret)); 9415 } 9416 9417 cmdline_parse_inst_t cmd_reset_mirror_rule = { 9418 .f = cmd_reset_mirror_rule_parsed, 9419 .data = NULL, 9420 .help_str = "reset port <port_id> mirror-rule <rule_id>", 9421 .tokens = { 9422 (void *)&cmd_rm_mirror_rule_reset, 9423 (void *)&cmd_rm_mirror_rule_port, 9424 (void *)&cmd_rm_mirror_rule_portid, 9425 (void *)&cmd_rm_mirror_rule_mirror, 9426 (void *)&cmd_rm_mirror_rule_ruleid, 9427 NULL, 9428 }, 9429 }; 9430 9431 /* ******************************************************************************** */ 9432 9433 struct cmd_dump_result { 9434 cmdline_fixed_string_t dump; 9435 }; 9436 9437 static void 9438 dump_struct_sizes(void) 9439 { 9440 #define DUMP_SIZE(t) printf("sizeof(" #t ") = %u\n", (unsigned)sizeof(t)); 9441 DUMP_SIZE(struct rte_mbuf); 9442 DUMP_SIZE(struct rte_mempool); 9443 DUMP_SIZE(struct rte_ring); 9444 #undef DUMP_SIZE 9445 } 9446 9447 static void cmd_dump_parsed(void *parsed_result, 9448 __attribute__((unused)) struct cmdline *cl, 9449 __attribute__((unused)) void *data) 9450 { 9451 struct cmd_dump_result *res = parsed_result; 9452 9453 if (!strcmp(res->dump, "dump_physmem")) 9454 rte_dump_physmem_layout(stdout); 9455 else if (!strcmp(res->dump, "dump_memzone")) 9456 rte_memzone_dump(stdout); 9457 else if (!strcmp(res->dump, "dump_struct_sizes")) 9458 dump_struct_sizes(); 9459 else if (!strcmp(res->dump, "dump_ring")) 9460 rte_ring_list_dump(stdout); 9461 else if (!strcmp(res->dump, "dump_mempool")) 9462 rte_mempool_list_dump(stdout); 9463 else if (!strcmp(res->dump, "dump_devargs")) 9464 rte_devargs_dump(stdout); 9465 else if (!strcmp(res->dump, "dump_log_types")) 9466 rte_log_dump(stdout); 9467 } 9468 9469 cmdline_parse_token_string_t cmd_dump_dump = 9470 TOKEN_STRING_INITIALIZER(struct cmd_dump_result, dump, 9471 "dump_physmem#" 9472 "dump_memzone#" 9473 "dump_struct_sizes#" 9474 "dump_ring#" 9475 "dump_mempool#" 9476 "dump_devargs#" 9477 "dump_log_types"); 9478 9479 cmdline_parse_inst_t cmd_dump = { 9480 .f = cmd_dump_parsed, /* function to call */ 9481 .data = NULL, /* 2nd arg of func */ 9482 .help_str = "Dump status", 9483 .tokens = { /* token list, NULL terminated */ 9484 (void *)&cmd_dump_dump, 9485 NULL, 9486 }, 9487 }; 9488 9489 /* ******************************************************************************** */ 9490 9491 struct cmd_dump_one_result { 9492 cmdline_fixed_string_t dump; 9493 cmdline_fixed_string_t name; 9494 }; 9495 9496 static void cmd_dump_one_parsed(void *parsed_result, struct cmdline *cl, 9497 __attribute__((unused)) void *data) 9498 { 9499 struct cmd_dump_one_result *res = parsed_result; 9500 9501 if (!strcmp(res->dump, "dump_ring")) { 9502 struct rte_ring *r; 9503 r = rte_ring_lookup(res->name); 9504 if (r == NULL) { 9505 cmdline_printf(cl, "Cannot find ring\n"); 9506 return; 9507 } 9508 rte_ring_dump(stdout, r); 9509 } else if (!strcmp(res->dump, "dump_mempool")) { 9510 struct rte_mempool *mp; 9511 mp = rte_mempool_lookup(res->name); 9512 if (mp == NULL) { 9513 cmdline_printf(cl, "Cannot find mempool\n"); 9514 return; 9515 } 9516 rte_mempool_dump(stdout, mp); 9517 } 9518 } 9519 9520 cmdline_parse_token_string_t cmd_dump_one_dump = 9521 TOKEN_STRING_INITIALIZER(struct cmd_dump_one_result, dump, 9522 "dump_ring#dump_mempool"); 9523 9524 cmdline_parse_token_string_t cmd_dump_one_name = 9525 TOKEN_STRING_INITIALIZER(struct cmd_dump_one_result, name, NULL); 9526 9527 cmdline_parse_inst_t cmd_dump_one = { 9528 .f = cmd_dump_one_parsed, /* function to call */ 9529 .data = NULL, /* 2nd arg of func */ 9530 .help_str = "dump_ring|dump_mempool <name>: Dump one ring/mempool", 9531 .tokens = { /* token list, NULL terminated */ 9532 (void *)&cmd_dump_one_dump, 9533 (void *)&cmd_dump_one_name, 9534 NULL, 9535 }, 9536 }; 9537 9538 /* *** Add/Del syn filter *** */ 9539 struct cmd_syn_filter_result { 9540 cmdline_fixed_string_t filter; 9541 portid_t port_id; 9542 cmdline_fixed_string_t ops; 9543 cmdline_fixed_string_t priority; 9544 cmdline_fixed_string_t high; 9545 cmdline_fixed_string_t queue; 9546 uint16_t queue_id; 9547 }; 9548 9549 static void 9550 cmd_syn_filter_parsed(void *parsed_result, 9551 __attribute__((unused)) struct cmdline *cl, 9552 __attribute__((unused)) void *data) 9553 { 9554 struct cmd_syn_filter_result *res = parsed_result; 9555 struct rte_eth_syn_filter syn_filter; 9556 int ret = 0; 9557 9558 ret = rte_eth_dev_filter_supported(res->port_id, 9559 RTE_ETH_FILTER_SYN); 9560 if (ret < 0) { 9561 printf("syn filter is not supported on port %u.\n", 9562 res->port_id); 9563 return; 9564 } 9565 9566 memset(&syn_filter, 0, sizeof(syn_filter)); 9567 9568 if (!strcmp(res->ops, "add")) { 9569 if (!strcmp(res->high, "high")) 9570 syn_filter.hig_pri = 1; 9571 else 9572 syn_filter.hig_pri = 0; 9573 9574 syn_filter.queue = res->queue_id; 9575 ret = rte_eth_dev_filter_ctrl(res->port_id, 9576 RTE_ETH_FILTER_SYN, 9577 RTE_ETH_FILTER_ADD, 9578 &syn_filter); 9579 } else 9580 ret = rte_eth_dev_filter_ctrl(res->port_id, 9581 RTE_ETH_FILTER_SYN, 9582 RTE_ETH_FILTER_DELETE, 9583 &syn_filter); 9584 9585 if (ret < 0) 9586 printf("syn filter programming error: (%s)\n", 9587 strerror(-ret)); 9588 } 9589 9590 cmdline_parse_token_string_t cmd_syn_filter_filter = 9591 TOKEN_STRING_INITIALIZER(struct cmd_syn_filter_result, 9592 filter, "syn_filter"); 9593 cmdline_parse_token_num_t cmd_syn_filter_port_id = 9594 TOKEN_NUM_INITIALIZER(struct cmd_syn_filter_result, 9595 port_id, UINT16); 9596 cmdline_parse_token_string_t cmd_syn_filter_ops = 9597 TOKEN_STRING_INITIALIZER(struct cmd_syn_filter_result, 9598 ops, "add#del"); 9599 cmdline_parse_token_string_t cmd_syn_filter_priority = 9600 TOKEN_STRING_INITIALIZER(struct cmd_syn_filter_result, 9601 priority, "priority"); 9602 cmdline_parse_token_string_t cmd_syn_filter_high = 9603 TOKEN_STRING_INITIALIZER(struct cmd_syn_filter_result, 9604 high, "high#low"); 9605 cmdline_parse_token_string_t cmd_syn_filter_queue = 9606 TOKEN_STRING_INITIALIZER(struct cmd_syn_filter_result, 9607 queue, "queue"); 9608 cmdline_parse_token_num_t cmd_syn_filter_queue_id = 9609 TOKEN_NUM_INITIALIZER(struct cmd_syn_filter_result, 9610 queue_id, UINT16); 9611 9612 cmdline_parse_inst_t cmd_syn_filter = { 9613 .f = cmd_syn_filter_parsed, 9614 .data = NULL, 9615 .help_str = "syn_filter <port_id> add|del priority high|low queue " 9616 "<queue_id>: Add/Delete syn filter", 9617 .tokens = { 9618 (void *)&cmd_syn_filter_filter, 9619 (void *)&cmd_syn_filter_port_id, 9620 (void *)&cmd_syn_filter_ops, 9621 (void *)&cmd_syn_filter_priority, 9622 (void *)&cmd_syn_filter_high, 9623 (void *)&cmd_syn_filter_queue, 9624 (void *)&cmd_syn_filter_queue_id, 9625 NULL, 9626 }, 9627 }; 9628 9629 /* *** queue region set *** */ 9630 struct cmd_queue_region_result { 9631 cmdline_fixed_string_t set; 9632 cmdline_fixed_string_t port; 9633 portid_t port_id; 9634 cmdline_fixed_string_t cmd; 9635 cmdline_fixed_string_t region; 9636 uint8_t region_id; 9637 cmdline_fixed_string_t queue_start_index; 9638 uint8_t queue_id; 9639 cmdline_fixed_string_t queue_num; 9640 uint8_t queue_num_value; 9641 }; 9642 9643 static void 9644 cmd_queue_region_parsed(void *parsed_result, 9645 __attribute__((unused)) struct cmdline *cl, 9646 __attribute__((unused)) void *data) 9647 { 9648 struct cmd_queue_region_result *res = parsed_result; 9649 int ret = -ENOTSUP; 9650 #ifdef RTE_LIBRTE_I40E_PMD 9651 struct rte_pmd_i40e_queue_region_conf region_conf; 9652 enum rte_pmd_i40e_queue_region_op op_type; 9653 #endif 9654 9655 if (port_id_is_invalid(res->port_id, ENABLED_WARN)) 9656 return; 9657 9658 #ifdef RTE_LIBRTE_I40E_PMD 9659 memset(®ion_conf, 0, sizeof(region_conf)); 9660 op_type = RTE_PMD_I40E_RSS_QUEUE_REGION_SET; 9661 region_conf.region_id = res->region_id; 9662 region_conf.queue_num = res->queue_num_value; 9663 region_conf.queue_start_index = res->queue_id; 9664 9665 ret = rte_pmd_i40e_rss_queue_region_conf(res->port_id, 9666 op_type, ®ion_conf); 9667 #endif 9668 9669 switch (ret) { 9670 case 0: 9671 break; 9672 case -ENOTSUP: 9673 printf("function not implemented or supported\n"); 9674 break; 9675 default: 9676 printf("queue region config error: (%s)\n", strerror(-ret)); 9677 } 9678 } 9679 9680 cmdline_parse_token_string_t cmd_queue_region_set = 9681 TOKEN_STRING_INITIALIZER(struct cmd_queue_region_result, 9682 set, "set"); 9683 cmdline_parse_token_string_t cmd_queue_region_port = 9684 TOKEN_STRING_INITIALIZER(struct cmd_queue_region_result, port, "port"); 9685 cmdline_parse_token_num_t cmd_queue_region_port_id = 9686 TOKEN_NUM_INITIALIZER(struct cmd_queue_region_result, 9687 port_id, UINT16); 9688 cmdline_parse_token_string_t cmd_queue_region_cmd = 9689 TOKEN_STRING_INITIALIZER(struct cmd_queue_region_result, 9690 cmd, "queue-region"); 9691 cmdline_parse_token_string_t cmd_queue_region_id = 9692 TOKEN_STRING_INITIALIZER(struct cmd_queue_region_result, 9693 region, "region_id"); 9694 cmdline_parse_token_num_t cmd_queue_region_index = 9695 TOKEN_NUM_INITIALIZER(struct cmd_queue_region_result, 9696 region_id, UINT8); 9697 cmdline_parse_token_string_t cmd_queue_region_queue_start_index = 9698 TOKEN_STRING_INITIALIZER(struct cmd_queue_region_result, 9699 queue_start_index, "queue_start_index"); 9700 cmdline_parse_token_num_t cmd_queue_region_queue_id = 9701 TOKEN_NUM_INITIALIZER(struct cmd_queue_region_result, 9702 queue_id, UINT8); 9703 cmdline_parse_token_string_t cmd_queue_region_queue_num = 9704 TOKEN_STRING_INITIALIZER(struct cmd_queue_region_result, 9705 queue_num, "queue_num"); 9706 cmdline_parse_token_num_t cmd_queue_region_queue_num_value = 9707 TOKEN_NUM_INITIALIZER(struct cmd_queue_region_result, 9708 queue_num_value, UINT8); 9709 9710 cmdline_parse_inst_t cmd_queue_region = { 9711 .f = cmd_queue_region_parsed, 9712 .data = NULL, 9713 .help_str = "set port <port_id> queue-region region_id <value> " 9714 "queue_start_index <value> queue_num <value>: Set a queue region", 9715 .tokens = { 9716 (void *)&cmd_queue_region_set, 9717 (void *)&cmd_queue_region_port, 9718 (void *)&cmd_queue_region_port_id, 9719 (void *)&cmd_queue_region_cmd, 9720 (void *)&cmd_queue_region_id, 9721 (void *)&cmd_queue_region_index, 9722 (void *)&cmd_queue_region_queue_start_index, 9723 (void *)&cmd_queue_region_queue_id, 9724 (void *)&cmd_queue_region_queue_num, 9725 (void *)&cmd_queue_region_queue_num_value, 9726 NULL, 9727 }, 9728 }; 9729 9730 /* *** queue region and flowtype set *** */ 9731 struct cmd_region_flowtype_result { 9732 cmdline_fixed_string_t set; 9733 cmdline_fixed_string_t port; 9734 portid_t port_id; 9735 cmdline_fixed_string_t cmd; 9736 cmdline_fixed_string_t region; 9737 uint8_t region_id; 9738 cmdline_fixed_string_t flowtype; 9739 uint8_t flowtype_id; 9740 }; 9741 9742 static void 9743 cmd_region_flowtype_parsed(void *parsed_result, 9744 __attribute__((unused)) struct cmdline *cl, 9745 __attribute__((unused)) void *data) 9746 { 9747 struct cmd_region_flowtype_result *res = parsed_result; 9748 int ret = -ENOTSUP; 9749 #ifdef RTE_LIBRTE_I40E_PMD 9750 struct rte_pmd_i40e_queue_region_conf region_conf; 9751 enum rte_pmd_i40e_queue_region_op op_type; 9752 #endif 9753 9754 if (port_id_is_invalid(res->port_id, ENABLED_WARN)) 9755 return; 9756 9757 #ifdef RTE_LIBRTE_I40E_PMD 9758 memset(®ion_conf, 0, sizeof(region_conf)); 9759 9760 op_type = RTE_PMD_I40E_RSS_QUEUE_REGION_FLOWTYPE_SET; 9761 region_conf.region_id = res->region_id; 9762 region_conf.hw_flowtype = res->flowtype_id; 9763 9764 ret = rte_pmd_i40e_rss_queue_region_conf(res->port_id, 9765 op_type, ®ion_conf); 9766 #endif 9767 9768 switch (ret) { 9769 case 0: 9770 break; 9771 case -ENOTSUP: 9772 printf("function not implemented or supported\n"); 9773 break; 9774 default: 9775 printf("region flowtype config error: (%s)\n", strerror(-ret)); 9776 } 9777 } 9778 9779 cmdline_parse_token_string_t cmd_region_flowtype_set = 9780 TOKEN_STRING_INITIALIZER(struct cmd_region_flowtype_result, 9781 set, "set"); 9782 cmdline_parse_token_string_t cmd_region_flowtype_port = 9783 TOKEN_STRING_INITIALIZER(struct cmd_region_flowtype_result, 9784 port, "port"); 9785 cmdline_parse_token_num_t cmd_region_flowtype_port_index = 9786 TOKEN_NUM_INITIALIZER(struct cmd_region_flowtype_result, 9787 port_id, UINT16); 9788 cmdline_parse_token_string_t cmd_region_flowtype_cmd = 9789 TOKEN_STRING_INITIALIZER(struct cmd_region_flowtype_result, 9790 cmd, "queue-region"); 9791 cmdline_parse_token_string_t cmd_region_flowtype_index = 9792 TOKEN_STRING_INITIALIZER(struct cmd_region_flowtype_result, 9793 region, "region_id"); 9794 cmdline_parse_token_num_t cmd_region_flowtype_id = 9795 TOKEN_NUM_INITIALIZER(struct cmd_region_flowtype_result, 9796 region_id, UINT8); 9797 cmdline_parse_token_string_t cmd_region_flowtype_flow_index = 9798 TOKEN_STRING_INITIALIZER(struct cmd_region_flowtype_result, 9799 flowtype, "flowtype"); 9800 cmdline_parse_token_num_t cmd_region_flowtype_flow_id = 9801 TOKEN_NUM_INITIALIZER(struct cmd_region_flowtype_result, 9802 flowtype_id, UINT8); 9803 cmdline_parse_inst_t cmd_region_flowtype = { 9804 .f = cmd_region_flowtype_parsed, 9805 .data = NULL, 9806 .help_str = "set port <port_id> queue-region region_id <value> " 9807 "flowtype <value>: Set a flowtype region index", 9808 .tokens = { 9809 (void *)&cmd_region_flowtype_set, 9810 (void *)&cmd_region_flowtype_port, 9811 (void *)&cmd_region_flowtype_port_index, 9812 (void *)&cmd_region_flowtype_cmd, 9813 (void *)&cmd_region_flowtype_index, 9814 (void *)&cmd_region_flowtype_id, 9815 (void *)&cmd_region_flowtype_flow_index, 9816 (void *)&cmd_region_flowtype_flow_id, 9817 NULL, 9818 }, 9819 }; 9820 9821 /* *** User Priority (UP) to queue region (region_id) set *** */ 9822 struct cmd_user_priority_region_result { 9823 cmdline_fixed_string_t set; 9824 cmdline_fixed_string_t port; 9825 portid_t port_id; 9826 cmdline_fixed_string_t cmd; 9827 cmdline_fixed_string_t user_priority; 9828 uint8_t user_priority_id; 9829 cmdline_fixed_string_t region; 9830 uint8_t region_id; 9831 }; 9832 9833 static void 9834 cmd_user_priority_region_parsed(void *parsed_result, 9835 __attribute__((unused)) struct cmdline *cl, 9836 __attribute__((unused)) void *data) 9837 { 9838 struct cmd_user_priority_region_result *res = parsed_result; 9839 int ret = -ENOTSUP; 9840 #ifdef RTE_LIBRTE_I40E_PMD 9841 struct rte_pmd_i40e_queue_region_conf region_conf; 9842 enum rte_pmd_i40e_queue_region_op op_type; 9843 #endif 9844 9845 if (port_id_is_invalid(res->port_id, ENABLED_WARN)) 9846 return; 9847 9848 #ifdef RTE_LIBRTE_I40E_PMD 9849 memset(®ion_conf, 0, sizeof(region_conf)); 9850 op_type = RTE_PMD_I40E_RSS_QUEUE_REGION_USER_PRIORITY_SET; 9851 region_conf.user_priority = res->user_priority_id; 9852 region_conf.region_id = res->region_id; 9853 9854 ret = rte_pmd_i40e_rss_queue_region_conf(res->port_id, 9855 op_type, ®ion_conf); 9856 #endif 9857 9858 switch (ret) { 9859 case 0: 9860 break; 9861 case -ENOTSUP: 9862 printf("function not implemented or supported\n"); 9863 break; 9864 default: 9865 printf("user_priority region config error: (%s)\n", 9866 strerror(-ret)); 9867 } 9868 } 9869 9870 cmdline_parse_token_string_t cmd_user_priority_region_set = 9871 TOKEN_STRING_INITIALIZER(struct cmd_user_priority_region_result, 9872 set, "set"); 9873 cmdline_parse_token_string_t cmd_user_priority_region_port = 9874 TOKEN_STRING_INITIALIZER(struct cmd_user_priority_region_result, 9875 port, "port"); 9876 cmdline_parse_token_num_t cmd_user_priority_region_port_index = 9877 TOKEN_NUM_INITIALIZER(struct cmd_user_priority_region_result, 9878 port_id, UINT16); 9879 cmdline_parse_token_string_t cmd_user_priority_region_cmd = 9880 TOKEN_STRING_INITIALIZER(struct cmd_user_priority_region_result, 9881 cmd, "queue-region"); 9882 cmdline_parse_token_string_t cmd_user_priority_region_UP = 9883 TOKEN_STRING_INITIALIZER(struct cmd_user_priority_region_result, 9884 user_priority, "UP"); 9885 cmdline_parse_token_num_t cmd_user_priority_region_UP_id = 9886 TOKEN_NUM_INITIALIZER(struct cmd_user_priority_region_result, 9887 user_priority_id, UINT8); 9888 cmdline_parse_token_string_t cmd_user_priority_region_region = 9889 TOKEN_STRING_INITIALIZER(struct cmd_user_priority_region_result, 9890 region, "region_id"); 9891 cmdline_parse_token_num_t cmd_user_priority_region_region_id = 9892 TOKEN_NUM_INITIALIZER(struct cmd_user_priority_region_result, 9893 region_id, UINT8); 9894 9895 cmdline_parse_inst_t cmd_user_priority_region = { 9896 .f = cmd_user_priority_region_parsed, 9897 .data = NULL, 9898 .help_str = "set port <port_id> queue-region UP <value> " 9899 "region_id <value>: Set the mapping of User Priority (UP) " 9900 "to queue region (region_id) ", 9901 .tokens = { 9902 (void *)&cmd_user_priority_region_set, 9903 (void *)&cmd_user_priority_region_port, 9904 (void *)&cmd_user_priority_region_port_index, 9905 (void *)&cmd_user_priority_region_cmd, 9906 (void *)&cmd_user_priority_region_UP, 9907 (void *)&cmd_user_priority_region_UP_id, 9908 (void *)&cmd_user_priority_region_region, 9909 (void *)&cmd_user_priority_region_region_id, 9910 NULL, 9911 }, 9912 }; 9913 9914 /* *** flush all queue region related configuration *** */ 9915 struct cmd_flush_queue_region_result { 9916 cmdline_fixed_string_t set; 9917 cmdline_fixed_string_t port; 9918 portid_t port_id; 9919 cmdline_fixed_string_t cmd; 9920 cmdline_fixed_string_t flush; 9921 cmdline_fixed_string_t what; 9922 }; 9923 9924 static void 9925 cmd_flush_queue_region_parsed(void *parsed_result, 9926 __attribute__((unused)) struct cmdline *cl, 9927 __attribute__((unused)) void *data) 9928 { 9929 struct cmd_flush_queue_region_result *res = parsed_result; 9930 int ret = -ENOTSUP; 9931 #ifdef RTE_LIBRTE_I40E_PMD 9932 struct rte_pmd_i40e_queue_region_conf region_conf; 9933 enum rte_pmd_i40e_queue_region_op op_type; 9934 #endif 9935 9936 if (port_id_is_invalid(res->port_id, ENABLED_WARN)) 9937 return; 9938 9939 #ifdef RTE_LIBRTE_I40E_PMD 9940 memset(®ion_conf, 0, sizeof(region_conf)); 9941 9942 if (strcmp(res->what, "on") == 0) 9943 op_type = RTE_PMD_I40E_RSS_QUEUE_REGION_ALL_FLUSH_ON; 9944 else 9945 op_type = RTE_PMD_I40E_RSS_QUEUE_REGION_ALL_FLUSH_OFF; 9946 9947 ret = rte_pmd_i40e_rss_queue_region_conf(res->port_id, 9948 op_type, ®ion_conf); 9949 #endif 9950 9951 switch (ret) { 9952 case 0: 9953 break; 9954 case -ENOTSUP: 9955 printf("function not implemented or supported\n"); 9956 break; 9957 default: 9958 printf("queue region config flush error: (%s)\n", 9959 strerror(-ret)); 9960 } 9961 } 9962 9963 cmdline_parse_token_string_t cmd_flush_queue_region_set = 9964 TOKEN_STRING_INITIALIZER(struct cmd_flush_queue_region_result, 9965 set, "set"); 9966 cmdline_parse_token_string_t cmd_flush_queue_region_port = 9967 TOKEN_STRING_INITIALIZER(struct cmd_flush_queue_region_result, 9968 port, "port"); 9969 cmdline_parse_token_num_t cmd_flush_queue_region_port_index = 9970 TOKEN_NUM_INITIALIZER(struct cmd_flush_queue_region_result, 9971 port_id, UINT16); 9972 cmdline_parse_token_string_t cmd_flush_queue_region_cmd = 9973 TOKEN_STRING_INITIALIZER(struct cmd_flush_queue_region_result, 9974 cmd, "queue-region"); 9975 cmdline_parse_token_string_t cmd_flush_queue_region_flush = 9976 TOKEN_STRING_INITIALIZER(struct cmd_flush_queue_region_result, 9977 flush, "flush"); 9978 cmdline_parse_token_string_t cmd_flush_queue_region_what = 9979 TOKEN_STRING_INITIALIZER(struct cmd_flush_queue_region_result, 9980 what, "on#off"); 9981 9982 cmdline_parse_inst_t cmd_flush_queue_region = { 9983 .f = cmd_flush_queue_region_parsed, 9984 .data = NULL, 9985 .help_str = "set port <port_id> queue-region flush on|off" 9986 ": flush all queue region related configuration", 9987 .tokens = { 9988 (void *)&cmd_flush_queue_region_set, 9989 (void *)&cmd_flush_queue_region_port, 9990 (void *)&cmd_flush_queue_region_port_index, 9991 (void *)&cmd_flush_queue_region_cmd, 9992 (void *)&cmd_flush_queue_region_flush, 9993 (void *)&cmd_flush_queue_region_what, 9994 NULL, 9995 }, 9996 }; 9997 9998 /* *** get all queue region related configuration info *** */ 9999 struct cmd_show_queue_region_info { 10000 cmdline_fixed_string_t show; 10001 cmdline_fixed_string_t port; 10002 portid_t port_id; 10003 cmdline_fixed_string_t cmd; 10004 }; 10005 10006 static void 10007 cmd_show_queue_region_info_parsed(void *parsed_result, 10008 __attribute__((unused)) struct cmdline *cl, 10009 __attribute__((unused)) void *data) 10010 { 10011 struct cmd_show_queue_region_info *res = parsed_result; 10012 int ret = -ENOTSUP; 10013 #ifdef RTE_LIBRTE_I40E_PMD 10014 struct rte_pmd_i40e_queue_regions rte_pmd_regions; 10015 enum rte_pmd_i40e_queue_region_op op_type; 10016 #endif 10017 10018 if (port_id_is_invalid(res->port_id, ENABLED_WARN)) 10019 return; 10020 10021 #ifdef RTE_LIBRTE_I40E_PMD 10022 memset(&rte_pmd_regions, 0, sizeof(rte_pmd_regions)); 10023 10024 op_type = RTE_PMD_I40E_RSS_QUEUE_REGION_INFO_GET; 10025 10026 ret = rte_pmd_i40e_rss_queue_region_conf(res->port_id, 10027 op_type, &rte_pmd_regions); 10028 10029 port_queue_region_info_display(res->port_id, &rte_pmd_regions); 10030 #endif 10031 10032 switch (ret) { 10033 case 0: 10034 break; 10035 case -ENOTSUP: 10036 printf("function not implemented or supported\n"); 10037 break; 10038 default: 10039 printf("queue region config info show error: (%s)\n", 10040 strerror(-ret)); 10041 } 10042 } 10043 10044 cmdline_parse_token_string_t cmd_show_queue_region_info_get = 10045 TOKEN_STRING_INITIALIZER(struct cmd_show_queue_region_info, 10046 show, "show"); 10047 cmdline_parse_token_string_t cmd_show_queue_region_info_port = 10048 TOKEN_STRING_INITIALIZER(struct cmd_show_queue_region_info, 10049 port, "port"); 10050 cmdline_parse_token_num_t cmd_show_queue_region_info_port_index = 10051 TOKEN_NUM_INITIALIZER(struct cmd_show_queue_region_info, 10052 port_id, UINT16); 10053 cmdline_parse_token_string_t cmd_show_queue_region_info_cmd = 10054 TOKEN_STRING_INITIALIZER(struct cmd_show_queue_region_info, 10055 cmd, "queue-region"); 10056 10057 cmdline_parse_inst_t cmd_show_queue_region_info_all = { 10058 .f = cmd_show_queue_region_info_parsed, 10059 .data = NULL, 10060 .help_str = "show port <port_id> queue-region" 10061 ": show all queue region related configuration info", 10062 .tokens = { 10063 (void *)&cmd_show_queue_region_info_get, 10064 (void *)&cmd_show_queue_region_info_port, 10065 (void *)&cmd_show_queue_region_info_port_index, 10066 (void *)&cmd_show_queue_region_info_cmd, 10067 NULL, 10068 }, 10069 }; 10070 10071 /* *** ADD/REMOVE A 2tuple FILTER *** */ 10072 struct cmd_2tuple_filter_result { 10073 cmdline_fixed_string_t filter; 10074 portid_t port_id; 10075 cmdline_fixed_string_t ops; 10076 cmdline_fixed_string_t dst_port; 10077 uint16_t dst_port_value; 10078 cmdline_fixed_string_t protocol; 10079 uint8_t protocol_value; 10080 cmdline_fixed_string_t mask; 10081 uint8_t mask_value; 10082 cmdline_fixed_string_t tcp_flags; 10083 uint8_t tcp_flags_value; 10084 cmdline_fixed_string_t priority; 10085 uint8_t priority_value; 10086 cmdline_fixed_string_t queue; 10087 uint16_t queue_id; 10088 }; 10089 10090 static void 10091 cmd_2tuple_filter_parsed(void *parsed_result, 10092 __attribute__((unused)) struct cmdline *cl, 10093 __attribute__((unused)) void *data) 10094 { 10095 struct rte_eth_ntuple_filter filter; 10096 struct cmd_2tuple_filter_result *res = parsed_result; 10097 int ret = 0; 10098 10099 ret = rte_eth_dev_filter_supported(res->port_id, RTE_ETH_FILTER_NTUPLE); 10100 if (ret < 0) { 10101 printf("ntuple filter is not supported on port %u.\n", 10102 res->port_id); 10103 return; 10104 } 10105 10106 memset(&filter, 0, sizeof(struct rte_eth_ntuple_filter)); 10107 10108 filter.flags = RTE_2TUPLE_FLAGS; 10109 filter.dst_port_mask = (res->mask_value & 0x02) ? UINT16_MAX : 0; 10110 filter.proto_mask = (res->mask_value & 0x01) ? UINT8_MAX : 0; 10111 filter.proto = res->protocol_value; 10112 filter.priority = res->priority_value; 10113 if (res->tcp_flags_value != 0 && filter.proto != IPPROTO_TCP) { 10114 printf("nonzero tcp_flags is only meaningful" 10115 " when protocol is TCP.\n"); 10116 return; 10117 } 10118 if (res->tcp_flags_value > RTE_NTUPLE_TCP_FLAGS_MASK) { 10119 printf("invalid TCP flags.\n"); 10120 return; 10121 } 10122 10123 if (res->tcp_flags_value != 0) { 10124 filter.flags |= RTE_NTUPLE_FLAGS_TCP_FLAG; 10125 filter.tcp_flags = res->tcp_flags_value; 10126 } 10127 10128 /* need convert to big endian. */ 10129 filter.dst_port = rte_cpu_to_be_16(res->dst_port_value); 10130 filter.queue = res->queue_id; 10131 10132 if (!strcmp(res->ops, "add")) 10133 ret = rte_eth_dev_filter_ctrl(res->port_id, 10134 RTE_ETH_FILTER_NTUPLE, 10135 RTE_ETH_FILTER_ADD, 10136 &filter); 10137 else 10138 ret = rte_eth_dev_filter_ctrl(res->port_id, 10139 RTE_ETH_FILTER_NTUPLE, 10140 RTE_ETH_FILTER_DELETE, 10141 &filter); 10142 if (ret < 0) 10143 printf("2tuple filter programming error: (%s)\n", 10144 strerror(-ret)); 10145 10146 } 10147 10148 cmdline_parse_token_string_t cmd_2tuple_filter_filter = 10149 TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result, 10150 filter, "2tuple_filter"); 10151 cmdline_parse_token_num_t cmd_2tuple_filter_port_id = 10152 TOKEN_NUM_INITIALIZER(struct cmd_2tuple_filter_result, 10153 port_id, UINT16); 10154 cmdline_parse_token_string_t cmd_2tuple_filter_ops = 10155 TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result, 10156 ops, "add#del"); 10157 cmdline_parse_token_string_t cmd_2tuple_filter_dst_port = 10158 TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result, 10159 dst_port, "dst_port"); 10160 cmdline_parse_token_num_t cmd_2tuple_filter_dst_port_value = 10161 TOKEN_NUM_INITIALIZER(struct cmd_2tuple_filter_result, 10162 dst_port_value, UINT16); 10163 cmdline_parse_token_string_t cmd_2tuple_filter_protocol = 10164 TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result, 10165 protocol, "protocol"); 10166 cmdline_parse_token_num_t cmd_2tuple_filter_protocol_value = 10167 TOKEN_NUM_INITIALIZER(struct cmd_2tuple_filter_result, 10168 protocol_value, UINT8); 10169 cmdline_parse_token_string_t cmd_2tuple_filter_mask = 10170 TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result, 10171 mask, "mask"); 10172 cmdline_parse_token_num_t cmd_2tuple_filter_mask_value = 10173 TOKEN_NUM_INITIALIZER(struct cmd_2tuple_filter_result, 10174 mask_value, INT8); 10175 cmdline_parse_token_string_t cmd_2tuple_filter_tcp_flags = 10176 TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result, 10177 tcp_flags, "tcp_flags"); 10178 cmdline_parse_token_num_t cmd_2tuple_filter_tcp_flags_value = 10179 TOKEN_NUM_INITIALIZER(struct cmd_2tuple_filter_result, 10180 tcp_flags_value, UINT8); 10181 cmdline_parse_token_string_t cmd_2tuple_filter_priority = 10182 TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result, 10183 priority, "priority"); 10184 cmdline_parse_token_num_t cmd_2tuple_filter_priority_value = 10185 TOKEN_NUM_INITIALIZER(struct cmd_2tuple_filter_result, 10186 priority_value, UINT8); 10187 cmdline_parse_token_string_t cmd_2tuple_filter_queue = 10188 TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result, 10189 queue, "queue"); 10190 cmdline_parse_token_num_t cmd_2tuple_filter_queue_id = 10191 TOKEN_NUM_INITIALIZER(struct cmd_2tuple_filter_result, 10192 queue_id, UINT16); 10193 10194 cmdline_parse_inst_t cmd_2tuple_filter = { 10195 .f = cmd_2tuple_filter_parsed, 10196 .data = NULL, 10197 .help_str = "2tuple_filter <port_id> add|del dst_port <value> protocol " 10198 "<value> mask <value> tcp_flags <value> priority <value> queue " 10199 "<queue_id>: Add a 2tuple filter", 10200 .tokens = { 10201 (void *)&cmd_2tuple_filter_filter, 10202 (void *)&cmd_2tuple_filter_port_id, 10203 (void *)&cmd_2tuple_filter_ops, 10204 (void *)&cmd_2tuple_filter_dst_port, 10205 (void *)&cmd_2tuple_filter_dst_port_value, 10206 (void *)&cmd_2tuple_filter_protocol, 10207 (void *)&cmd_2tuple_filter_protocol_value, 10208 (void *)&cmd_2tuple_filter_mask, 10209 (void *)&cmd_2tuple_filter_mask_value, 10210 (void *)&cmd_2tuple_filter_tcp_flags, 10211 (void *)&cmd_2tuple_filter_tcp_flags_value, 10212 (void *)&cmd_2tuple_filter_priority, 10213 (void *)&cmd_2tuple_filter_priority_value, 10214 (void *)&cmd_2tuple_filter_queue, 10215 (void *)&cmd_2tuple_filter_queue_id, 10216 NULL, 10217 }, 10218 }; 10219 10220 /* *** ADD/REMOVE A 5tuple FILTER *** */ 10221 struct cmd_5tuple_filter_result { 10222 cmdline_fixed_string_t filter; 10223 portid_t port_id; 10224 cmdline_fixed_string_t ops; 10225 cmdline_fixed_string_t dst_ip; 10226 cmdline_ipaddr_t dst_ip_value; 10227 cmdline_fixed_string_t src_ip; 10228 cmdline_ipaddr_t src_ip_value; 10229 cmdline_fixed_string_t dst_port; 10230 uint16_t dst_port_value; 10231 cmdline_fixed_string_t src_port; 10232 uint16_t src_port_value; 10233 cmdline_fixed_string_t protocol; 10234 uint8_t protocol_value; 10235 cmdline_fixed_string_t mask; 10236 uint8_t mask_value; 10237 cmdline_fixed_string_t tcp_flags; 10238 uint8_t tcp_flags_value; 10239 cmdline_fixed_string_t priority; 10240 uint8_t priority_value; 10241 cmdline_fixed_string_t queue; 10242 uint16_t queue_id; 10243 }; 10244 10245 static void 10246 cmd_5tuple_filter_parsed(void *parsed_result, 10247 __attribute__((unused)) struct cmdline *cl, 10248 __attribute__((unused)) void *data) 10249 { 10250 struct rte_eth_ntuple_filter filter; 10251 struct cmd_5tuple_filter_result *res = parsed_result; 10252 int ret = 0; 10253 10254 ret = rte_eth_dev_filter_supported(res->port_id, RTE_ETH_FILTER_NTUPLE); 10255 if (ret < 0) { 10256 printf("ntuple filter is not supported on port %u.\n", 10257 res->port_id); 10258 return; 10259 } 10260 10261 memset(&filter, 0, sizeof(struct rte_eth_ntuple_filter)); 10262 10263 filter.flags = RTE_5TUPLE_FLAGS; 10264 filter.dst_ip_mask = (res->mask_value & 0x10) ? UINT32_MAX : 0; 10265 filter.src_ip_mask = (res->mask_value & 0x08) ? UINT32_MAX : 0; 10266 filter.dst_port_mask = (res->mask_value & 0x04) ? UINT16_MAX : 0; 10267 filter.src_port_mask = (res->mask_value & 0x02) ? UINT16_MAX : 0; 10268 filter.proto_mask = (res->mask_value & 0x01) ? UINT8_MAX : 0; 10269 filter.proto = res->protocol_value; 10270 filter.priority = res->priority_value; 10271 if (res->tcp_flags_value != 0 && filter.proto != IPPROTO_TCP) { 10272 printf("nonzero tcp_flags is only meaningful" 10273 " when protocol is TCP.\n"); 10274 return; 10275 } 10276 if (res->tcp_flags_value > RTE_NTUPLE_TCP_FLAGS_MASK) { 10277 printf("invalid TCP flags.\n"); 10278 return; 10279 } 10280 10281 if (res->tcp_flags_value != 0) { 10282 filter.flags |= RTE_NTUPLE_FLAGS_TCP_FLAG; 10283 filter.tcp_flags = res->tcp_flags_value; 10284 } 10285 10286 if (res->dst_ip_value.family == AF_INET) 10287 /* no need to convert, already big endian. */ 10288 filter.dst_ip = res->dst_ip_value.addr.ipv4.s_addr; 10289 else { 10290 if (filter.dst_ip_mask == 0) { 10291 printf("can not support ipv6 involved compare.\n"); 10292 return; 10293 } 10294 filter.dst_ip = 0; 10295 } 10296 10297 if (res->src_ip_value.family == AF_INET) 10298 /* no need to convert, already big endian. */ 10299 filter.src_ip = res->src_ip_value.addr.ipv4.s_addr; 10300 else { 10301 if (filter.src_ip_mask == 0) { 10302 printf("can not support ipv6 involved compare.\n"); 10303 return; 10304 } 10305 filter.src_ip = 0; 10306 } 10307 /* need convert to big endian. */ 10308 filter.dst_port = rte_cpu_to_be_16(res->dst_port_value); 10309 filter.src_port = rte_cpu_to_be_16(res->src_port_value); 10310 filter.queue = res->queue_id; 10311 10312 if (!strcmp(res->ops, "add")) 10313 ret = rte_eth_dev_filter_ctrl(res->port_id, 10314 RTE_ETH_FILTER_NTUPLE, 10315 RTE_ETH_FILTER_ADD, 10316 &filter); 10317 else 10318 ret = rte_eth_dev_filter_ctrl(res->port_id, 10319 RTE_ETH_FILTER_NTUPLE, 10320 RTE_ETH_FILTER_DELETE, 10321 &filter); 10322 if (ret < 0) 10323 printf("5tuple filter programming error: (%s)\n", 10324 strerror(-ret)); 10325 } 10326 10327 cmdline_parse_token_string_t cmd_5tuple_filter_filter = 10328 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result, 10329 filter, "5tuple_filter"); 10330 cmdline_parse_token_num_t cmd_5tuple_filter_port_id = 10331 TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result, 10332 port_id, UINT16); 10333 cmdline_parse_token_string_t cmd_5tuple_filter_ops = 10334 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result, 10335 ops, "add#del"); 10336 cmdline_parse_token_string_t cmd_5tuple_filter_dst_ip = 10337 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result, 10338 dst_ip, "dst_ip"); 10339 cmdline_parse_token_ipaddr_t cmd_5tuple_filter_dst_ip_value = 10340 TOKEN_IPADDR_INITIALIZER(struct cmd_5tuple_filter_result, 10341 dst_ip_value); 10342 cmdline_parse_token_string_t cmd_5tuple_filter_src_ip = 10343 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result, 10344 src_ip, "src_ip"); 10345 cmdline_parse_token_ipaddr_t cmd_5tuple_filter_src_ip_value = 10346 TOKEN_IPADDR_INITIALIZER(struct cmd_5tuple_filter_result, 10347 src_ip_value); 10348 cmdline_parse_token_string_t cmd_5tuple_filter_dst_port = 10349 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result, 10350 dst_port, "dst_port"); 10351 cmdline_parse_token_num_t cmd_5tuple_filter_dst_port_value = 10352 TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result, 10353 dst_port_value, UINT16); 10354 cmdline_parse_token_string_t cmd_5tuple_filter_src_port = 10355 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result, 10356 src_port, "src_port"); 10357 cmdline_parse_token_num_t cmd_5tuple_filter_src_port_value = 10358 TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result, 10359 src_port_value, UINT16); 10360 cmdline_parse_token_string_t cmd_5tuple_filter_protocol = 10361 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result, 10362 protocol, "protocol"); 10363 cmdline_parse_token_num_t cmd_5tuple_filter_protocol_value = 10364 TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result, 10365 protocol_value, UINT8); 10366 cmdline_parse_token_string_t cmd_5tuple_filter_mask = 10367 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result, 10368 mask, "mask"); 10369 cmdline_parse_token_num_t cmd_5tuple_filter_mask_value = 10370 TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result, 10371 mask_value, INT8); 10372 cmdline_parse_token_string_t cmd_5tuple_filter_tcp_flags = 10373 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result, 10374 tcp_flags, "tcp_flags"); 10375 cmdline_parse_token_num_t cmd_5tuple_filter_tcp_flags_value = 10376 TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result, 10377 tcp_flags_value, UINT8); 10378 cmdline_parse_token_string_t cmd_5tuple_filter_priority = 10379 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result, 10380 priority, "priority"); 10381 cmdline_parse_token_num_t cmd_5tuple_filter_priority_value = 10382 TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result, 10383 priority_value, UINT8); 10384 cmdline_parse_token_string_t cmd_5tuple_filter_queue = 10385 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result, 10386 queue, "queue"); 10387 cmdline_parse_token_num_t cmd_5tuple_filter_queue_id = 10388 TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result, 10389 queue_id, UINT16); 10390 10391 cmdline_parse_inst_t cmd_5tuple_filter = { 10392 .f = cmd_5tuple_filter_parsed, 10393 .data = NULL, 10394 .help_str = "5tuple_filter <port_id> add|del dst_ip <value> " 10395 "src_ip <value> dst_port <value> src_port <value> " 10396 "protocol <value> mask <value> tcp_flags <value> " 10397 "priority <value> queue <queue_id>: Add/Del a 5tuple filter", 10398 .tokens = { 10399 (void *)&cmd_5tuple_filter_filter, 10400 (void *)&cmd_5tuple_filter_port_id, 10401 (void *)&cmd_5tuple_filter_ops, 10402 (void *)&cmd_5tuple_filter_dst_ip, 10403 (void *)&cmd_5tuple_filter_dst_ip_value, 10404 (void *)&cmd_5tuple_filter_src_ip, 10405 (void *)&cmd_5tuple_filter_src_ip_value, 10406 (void *)&cmd_5tuple_filter_dst_port, 10407 (void *)&cmd_5tuple_filter_dst_port_value, 10408 (void *)&cmd_5tuple_filter_src_port, 10409 (void *)&cmd_5tuple_filter_src_port_value, 10410 (void *)&cmd_5tuple_filter_protocol, 10411 (void *)&cmd_5tuple_filter_protocol_value, 10412 (void *)&cmd_5tuple_filter_mask, 10413 (void *)&cmd_5tuple_filter_mask_value, 10414 (void *)&cmd_5tuple_filter_tcp_flags, 10415 (void *)&cmd_5tuple_filter_tcp_flags_value, 10416 (void *)&cmd_5tuple_filter_priority, 10417 (void *)&cmd_5tuple_filter_priority_value, 10418 (void *)&cmd_5tuple_filter_queue, 10419 (void *)&cmd_5tuple_filter_queue_id, 10420 NULL, 10421 }, 10422 }; 10423 10424 /* *** ADD/REMOVE A flex FILTER *** */ 10425 struct cmd_flex_filter_result { 10426 cmdline_fixed_string_t filter; 10427 cmdline_fixed_string_t ops; 10428 portid_t port_id; 10429 cmdline_fixed_string_t len; 10430 uint8_t len_value; 10431 cmdline_fixed_string_t bytes; 10432 cmdline_fixed_string_t bytes_value; 10433 cmdline_fixed_string_t mask; 10434 cmdline_fixed_string_t mask_value; 10435 cmdline_fixed_string_t priority; 10436 uint8_t priority_value; 10437 cmdline_fixed_string_t queue; 10438 uint16_t queue_id; 10439 }; 10440 10441 static int xdigit2val(unsigned char c) 10442 { 10443 int val; 10444 if (isdigit(c)) 10445 val = c - '0'; 10446 else if (isupper(c)) 10447 val = c - 'A' + 10; 10448 else 10449 val = c - 'a' + 10; 10450 return val; 10451 } 10452 10453 static void 10454 cmd_flex_filter_parsed(void *parsed_result, 10455 __attribute__((unused)) struct cmdline *cl, 10456 __attribute__((unused)) void *data) 10457 { 10458 int ret = 0; 10459 struct rte_eth_flex_filter filter; 10460 struct cmd_flex_filter_result *res = parsed_result; 10461 char *bytes_ptr, *mask_ptr; 10462 uint16_t len, i, j = 0; 10463 char c; 10464 int val; 10465 uint8_t byte = 0; 10466 10467 if (res->len_value > RTE_FLEX_FILTER_MAXLEN) { 10468 printf("the len exceed the max length 128\n"); 10469 return; 10470 } 10471 memset(&filter, 0, sizeof(struct rte_eth_flex_filter)); 10472 filter.len = res->len_value; 10473 filter.priority = res->priority_value; 10474 filter.queue = res->queue_id; 10475 bytes_ptr = res->bytes_value; 10476 mask_ptr = res->mask_value; 10477 10478 /* translate bytes string to array. */ 10479 if (bytes_ptr[0] == '0' && ((bytes_ptr[1] == 'x') || 10480 (bytes_ptr[1] == 'X'))) 10481 bytes_ptr += 2; 10482 len = strnlen(bytes_ptr, res->len_value * 2); 10483 if (len == 0 || (len % 8 != 0)) { 10484 printf("please check len and bytes input\n"); 10485 return; 10486 } 10487 for (i = 0; i < len; i++) { 10488 c = bytes_ptr[i]; 10489 if (isxdigit(c) == 0) { 10490 /* invalid characters. */ 10491 printf("invalid input\n"); 10492 return; 10493 } 10494 val = xdigit2val(c); 10495 if (i % 2) { 10496 byte |= val; 10497 filter.bytes[j] = byte; 10498 printf("bytes[%d]:%02x ", j, filter.bytes[j]); 10499 j++; 10500 byte = 0; 10501 } else 10502 byte |= val << 4; 10503 } 10504 printf("\n"); 10505 /* translate mask string to uint8_t array. */ 10506 if (mask_ptr[0] == '0' && ((mask_ptr[1] == 'x') || 10507 (mask_ptr[1] == 'X'))) 10508 mask_ptr += 2; 10509 len = strnlen(mask_ptr, (res->len_value + 3) / 4); 10510 if (len == 0) { 10511 printf("invalid input\n"); 10512 return; 10513 } 10514 j = 0; 10515 byte = 0; 10516 for (i = 0; i < len; i++) { 10517 c = mask_ptr[i]; 10518 if (isxdigit(c) == 0) { 10519 /* invalid characters. */ 10520 printf("invalid input\n"); 10521 return; 10522 } 10523 val = xdigit2val(c); 10524 if (i % 2) { 10525 byte |= val; 10526 filter.mask[j] = byte; 10527 printf("mask[%d]:%02x ", j, filter.mask[j]); 10528 j++; 10529 byte = 0; 10530 } else 10531 byte |= val << 4; 10532 } 10533 printf("\n"); 10534 10535 if (!strcmp(res->ops, "add")) 10536 ret = rte_eth_dev_filter_ctrl(res->port_id, 10537 RTE_ETH_FILTER_FLEXIBLE, 10538 RTE_ETH_FILTER_ADD, 10539 &filter); 10540 else 10541 ret = rte_eth_dev_filter_ctrl(res->port_id, 10542 RTE_ETH_FILTER_FLEXIBLE, 10543 RTE_ETH_FILTER_DELETE, 10544 &filter); 10545 10546 if (ret < 0) 10547 printf("flex filter setting error: (%s)\n", strerror(-ret)); 10548 } 10549 10550 cmdline_parse_token_string_t cmd_flex_filter_filter = 10551 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result, 10552 filter, "flex_filter"); 10553 cmdline_parse_token_num_t cmd_flex_filter_port_id = 10554 TOKEN_NUM_INITIALIZER(struct cmd_flex_filter_result, 10555 port_id, UINT16); 10556 cmdline_parse_token_string_t cmd_flex_filter_ops = 10557 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result, 10558 ops, "add#del"); 10559 cmdline_parse_token_string_t cmd_flex_filter_len = 10560 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result, 10561 len, "len"); 10562 cmdline_parse_token_num_t cmd_flex_filter_len_value = 10563 TOKEN_NUM_INITIALIZER(struct cmd_flex_filter_result, 10564 len_value, UINT8); 10565 cmdline_parse_token_string_t cmd_flex_filter_bytes = 10566 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result, 10567 bytes, "bytes"); 10568 cmdline_parse_token_string_t cmd_flex_filter_bytes_value = 10569 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result, 10570 bytes_value, NULL); 10571 cmdline_parse_token_string_t cmd_flex_filter_mask = 10572 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result, 10573 mask, "mask"); 10574 cmdline_parse_token_string_t cmd_flex_filter_mask_value = 10575 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result, 10576 mask_value, NULL); 10577 cmdline_parse_token_string_t cmd_flex_filter_priority = 10578 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result, 10579 priority, "priority"); 10580 cmdline_parse_token_num_t cmd_flex_filter_priority_value = 10581 TOKEN_NUM_INITIALIZER(struct cmd_flex_filter_result, 10582 priority_value, UINT8); 10583 cmdline_parse_token_string_t cmd_flex_filter_queue = 10584 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result, 10585 queue, "queue"); 10586 cmdline_parse_token_num_t cmd_flex_filter_queue_id = 10587 TOKEN_NUM_INITIALIZER(struct cmd_flex_filter_result, 10588 queue_id, UINT16); 10589 cmdline_parse_inst_t cmd_flex_filter = { 10590 .f = cmd_flex_filter_parsed, 10591 .data = NULL, 10592 .help_str = "flex_filter <port_id> add|del len <value> bytes " 10593 "<value> mask <value> priority <value> queue <queue_id>: " 10594 "Add/Del a flex filter", 10595 .tokens = { 10596 (void *)&cmd_flex_filter_filter, 10597 (void *)&cmd_flex_filter_port_id, 10598 (void *)&cmd_flex_filter_ops, 10599 (void *)&cmd_flex_filter_len, 10600 (void *)&cmd_flex_filter_len_value, 10601 (void *)&cmd_flex_filter_bytes, 10602 (void *)&cmd_flex_filter_bytes_value, 10603 (void *)&cmd_flex_filter_mask, 10604 (void *)&cmd_flex_filter_mask_value, 10605 (void *)&cmd_flex_filter_priority, 10606 (void *)&cmd_flex_filter_priority_value, 10607 (void *)&cmd_flex_filter_queue, 10608 (void *)&cmd_flex_filter_queue_id, 10609 NULL, 10610 }, 10611 }; 10612 10613 /* *** Filters Control *** */ 10614 10615 /* *** deal with ethertype filter *** */ 10616 struct cmd_ethertype_filter_result { 10617 cmdline_fixed_string_t filter; 10618 portid_t port_id; 10619 cmdline_fixed_string_t ops; 10620 cmdline_fixed_string_t mac; 10621 struct rte_ether_addr mac_addr; 10622 cmdline_fixed_string_t ethertype; 10623 uint16_t ethertype_value; 10624 cmdline_fixed_string_t drop; 10625 cmdline_fixed_string_t queue; 10626 uint16_t queue_id; 10627 }; 10628 10629 cmdline_parse_token_string_t cmd_ethertype_filter_filter = 10630 TOKEN_STRING_INITIALIZER(struct cmd_ethertype_filter_result, 10631 filter, "ethertype_filter"); 10632 cmdline_parse_token_num_t cmd_ethertype_filter_port_id = 10633 TOKEN_NUM_INITIALIZER(struct cmd_ethertype_filter_result, 10634 port_id, UINT16); 10635 cmdline_parse_token_string_t cmd_ethertype_filter_ops = 10636 TOKEN_STRING_INITIALIZER(struct cmd_ethertype_filter_result, 10637 ops, "add#del"); 10638 cmdline_parse_token_string_t cmd_ethertype_filter_mac = 10639 TOKEN_STRING_INITIALIZER(struct cmd_ethertype_filter_result, 10640 mac, "mac_addr#mac_ignr"); 10641 cmdline_parse_token_etheraddr_t cmd_ethertype_filter_mac_addr = 10642 TOKEN_ETHERADDR_INITIALIZER(struct cmd_ethertype_filter_result, 10643 mac_addr); 10644 cmdline_parse_token_string_t cmd_ethertype_filter_ethertype = 10645 TOKEN_STRING_INITIALIZER(struct cmd_ethertype_filter_result, 10646 ethertype, "ethertype"); 10647 cmdline_parse_token_num_t cmd_ethertype_filter_ethertype_value = 10648 TOKEN_NUM_INITIALIZER(struct cmd_ethertype_filter_result, 10649 ethertype_value, UINT16); 10650 cmdline_parse_token_string_t cmd_ethertype_filter_drop = 10651 TOKEN_STRING_INITIALIZER(struct cmd_ethertype_filter_result, 10652 drop, "drop#fwd"); 10653 cmdline_parse_token_string_t cmd_ethertype_filter_queue = 10654 TOKEN_STRING_INITIALIZER(struct cmd_ethertype_filter_result, 10655 queue, "queue"); 10656 cmdline_parse_token_num_t cmd_ethertype_filter_queue_id = 10657 TOKEN_NUM_INITIALIZER(struct cmd_ethertype_filter_result, 10658 queue_id, UINT16); 10659 10660 static void 10661 cmd_ethertype_filter_parsed(void *parsed_result, 10662 __attribute__((unused)) struct cmdline *cl, 10663 __attribute__((unused)) void *data) 10664 { 10665 struct cmd_ethertype_filter_result *res = parsed_result; 10666 struct rte_eth_ethertype_filter filter; 10667 int ret = 0; 10668 10669 ret = rte_eth_dev_filter_supported(res->port_id, 10670 RTE_ETH_FILTER_ETHERTYPE); 10671 if (ret < 0) { 10672 printf("ethertype filter is not supported on port %u.\n", 10673 res->port_id); 10674 return; 10675 } 10676 10677 memset(&filter, 0, sizeof(filter)); 10678 if (!strcmp(res->mac, "mac_addr")) { 10679 filter.flags |= RTE_ETHTYPE_FLAGS_MAC; 10680 rte_memcpy(&filter.mac_addr, &res->mac_addr, 10681 sizeof(struct rte_ether_addr)); 10682 } 10683 if (!strcmp(res->drop, "drop")) 10684 filter.flags |= RTE_ETHTYPE_FLAGS_DROP; 10685 filter.ether_type = res->ethertype_value; 10686 filter.queue = res->queue_id; 10687 10688 if (!strcmp(res->ops, "add")) 10689 ret = rte_eth_dev_filter_ctrl(res->port_id, 10690 RTE_ETH_FILTER_ETHERTYPE, 10691 RTE_ETH_FILTER_ADD, 10692 &filter); 10693 else 10694 ret = rte_eth_dev_filter_ctrl(res->port_id, 10695 RTE_ETH_FILTER_ETHERTYPE, 10696 RTE_ETH_FILTER_DELETE, 10697 &filter); 10698 if (ret < 0) 10699 printf("ethertype filter programming error: (%s)\n", 10700 strerror(-ret)); 10701 } 10702 10703 cmdline_parse_inst_t cmd_ethertype_filter = { 10704 .f = cmd_ethertype_filter_parsed, 10705 .data = NULL, 10706 .help_str = "ethertype_filter <port_id> add|del mac_addr|mac_ignr " 10707 "<mac_addr> ethertype <value> drop|fw queue <queue_id>: " 10708 "Add or delete an ethertype filter entry", 10709 .tokens = { 10710 (void *)&cmd_ethertype_filter_filter, 10711 (void *)&cmd_ethertype_filter_port_id, 10712 (void *)&cmd_ethertype_filter_ops, 10713 (void *)&cmd_ethertype_filter_mac, 10714 (void *)&cmd_ethertype_filter_mac_addr, 10715 (void *)&cmd_ethertype_filter_ethertype, 10716 (void *)&cmd_ethertype_filter_ethertype_value, 10717 (void *)&cmd_ethertype_filter_drop, 10718 (void *)&cmd_ethertype_filter_queue, 10719 (void *)&cmd_ethertype_filter_queue_id, 10720 NULL, 10721 }, 10722 }; 10723 10724 /* *** deal with flow director filter *** */ 10725 struct cmd_flow_director_result { 10726 cmdline_fixed_string_t flow_director_filter; 10727 portid_t port_id; 10728 cmdline_fixed_string_t mode; 10729 cmdline_fixed_string_t mode_value; 10730 cmdline_fixed_string_t ops; 10731 cmdline_fixed_string_t flow; 10732 cmdline_fixed_string_t flow_type; 10733 cmdline_fixed_string_t ether; 10734 uint16_t ether_type; 10735 cmdline_fixed_string_t src; 10736 cmdline_ipaddr_t ip_src; 10737 uint16_t port_src; 10738 cmdline_fixed_string_t dst; 10739 cmdline_ipaddr_t ip_dst; 10740 uint16_t port_dst; 10741 cmdline_fixed_string_t verify_tag; 10742 uint32_t verify_tag_value; 10743 cmdline_fixed_string_t tos; 10744 uint8_t tos_value; 10745 cmdline_fixed_string_t proto; 10746 uint8_t proto_value; 10747 cmdline_fixed_string_t ttl; 10748 uint8_t ttl_value; 10749 cmdline_fixed_string_t vlan; 10750 uint16_t vlan_value; 10751 cmdline_fixed_string_t flexbytes; 10752 cmdline_fixed_string_t flexbytes_value; 10753 cmdline_fixed_string_t pf_vf; 10754 cmdline_fixed_string_t drop; 10755 cmdline_fixed_string_t queue; 10756 uint16_t queue_id; 10757 cmdline_fixed_string_t fd_id; 10758 uint32_t fd_id_value; 10759 cmdline_fixed_string_t mac; 10760 struct rte_ether_addr mac_addr; 10761 cmdline_fixed_string_t tunnel; 10762 cmdline_fixed_string_t tunnel_type; 10763 cmdline_fixed_string_t tunnel_id; 10764 uint32_t tunnel_id_value; 10765 cmdline_fixed_string_t packet; 10766 char filepath[]; 10767 }; 10768 10769 static inline int 10770 parse_flexbytes(const char *q_arg, uint8_t *flexbytes, uint16_t max_num) 10771 { 10772 char s[256]; 10773 const char *p, *p0 = q_arg; 10774 char *end; 10775 unsigned long int_fld; 10776 char *str_fld[max_num]; 10777 int i; 10778 unsigned size; 10779 int ret = -1; 10780 10781 p = strchr(p0, '('); 10782 if (p == NULL) 10783 return -1; 10784 ++p; 10785 p0 = strchr(p, ')'); 10786 if (p0 == NULL) 10787 return -1; 10788 10789 size = p0 - p; 10790 if (size >= sizeof(s)) 10791 return -1; 10792 10793 snprintf(s, sizeof(s), "%.*s", size, p); 10794 ret = rte_strsplit(s, sizeof(s), str_fld, max_num, ','); 10795 if (ret < 0 || ret > max_num) 10796 return -1; 10797 for (i = 0; i < ret; i++) { 10798 errno = 0; 10799 int_fld = strtoul(str_fld[i], &end, 0); 10800 if (errno != 0 || *end != '\0' || int_fld > UINT8_MAX) 10801 return -1; 10802 flexbytes[i] = (uint8_t)int_fld; 10803 } 10804 return ret; 10805 } 10806 10807 static uint16_t 10808 str2flowtype(char *string) 10809 { 10810 uint8_t i = 0; 10811 static const struct { 10812 char str[32]; 10813 uint16_t type; 10814 } flowtype_str[] = { 10815 {"raw", RTE_ETH_FLOW_RAW}, 10816 {"ipv4", RTE_ETH_FLOW_IPV4}, 10817 {"ipv4-frag", RTE_ETH_FLOW_FRAG_IPV4}, 10818 {"ipv4-tcp", RTE_ETH_FLOW_NONFRAG_IPV4_TCP}, 10819 {"ipv4-udp", RTE_ETH_FLOW_NONFRAG_IPV4_UDP}, 10820 {"ipv4-sctp", RTE_ETH_FLOW_NONFRAG_IPV4_SCTP}, 10821 {"ipv4-other", RTE_ETH_FLOW_NONFRAG_IPV4_OTHER}, 10822 {"ipv6", RTE_ETH_FLOW_IPV6}, 10823 {"ipv6-frag", RTE_ETH_FLOW_FRAG_IPV6}, 10824 {"ipv6-tcp", RTE_ETH_FLOW_NONFRAG_IPV6_TCP}, 10825 {"ipv6-udp", RTE_ETH_FLOW_NONFRAG_IPV6_UDP}, 10826 {"ipv6-sctp", RTE_ETH_FLOW_NONFRAG_IPV6_SCTP}, 10827 {"ipv6-other", RTE_ETH_FLOW_NONFRAG_IPV6_OTHER}, 10828 {"l2_payload", RTE_ETH_FLOW_L2_PAYLOAD}, 10829 }; 10830 10831 for (i = 0; i < RTE_DIM(flowtype_str); i++) { 10832 if (!strcmp(flowtype_str[i].str, string)) 10833 return flowtype_str[i].type; 10834 } 10835 10836 if (isdigit(string[0]) && atoi(string) > 0 && atoi(string) < 64) 10837 return (uint16_t)atoi(string); 10838 10839 return RTE_ETH_FLOW_UNKNOWN; 10840 } 10841 10842 static enum rte_eth_fdir_tunnel_type 10843 str2fdir_tunneltype(char *string) 10844 { 10845 uint8_t i = 0; 10846 10847 static const struct { 10848 char str[32]; 10849 enum rte_eth_fdir_tunnel_type type; 10850 } tunneltype_str[] = { 10851 {"NVGRE", RTE_FDIR_TUNNEL_TYPE_NVGRE}, 10852 {"VxLAN", RTE_FDIR_TUNNEL_TYPE_VXLAN}, 10853 }; 10854 10855 for (i = 0; i < RTE_DIM(tunneltype_str); i++) { 10856 if (!strcmp(tunneltype_str[i].str, string)) 10857 return tunneltype_str[i].type; 10858 } 10859 return RTE_FDIR_TUNNEL_TYPE_UNKNOWN; 10860 } 10861 10862 #define IPV4_ADDR_TO_UINT(ip_addr, ip) \ 10863 do { \ 10864 if ((ip_addr).family == AF_INET) \ 10865 (ip) = (ip_addr).addr.ipv4.s_addr; \ 10866 else { \ 10867 printf("invalid parameter.\n"); \ 10868 return; \ 10869 } \ 10870 } while (0) 10871 10872 #define IPV6_ADDR_TO_ARRAY(ip_addr, ip) \ 10873 do { \ 10874 if ((ip_addr).family == AF_INET6) \ 10875 rte_memcpy(&(ip), \ 10876 &((ip_addr).addr.ipv6), \ 10877 sizeof(struct in6_addr)); \ 10878 else { \ 10879 printf("invalid parameter.\n"); \ 10880 return; \ 10881 } \ 10882 } while (0) 10883 10884 static void 10885 cmd_flow_director_filter_parsed(void *parsed_result, 10886 __attribute__((unused)) struct cmdline *cl, 10887 __attribute__((unused)) void *data) 10888 { 10889 struct cmd_flow_director_result *res = parsed_result; 10890 struct rte_eth_fdir_filter entry; 10891 uint8_t flexbytes[RTE_ETH_FDIR_MAX_FLEXLEN]; 10892 char *end; 10893 unsigned long vf_id; 10894 int ret = 0; 10895 10896 ret = rte_eth_dev_filter_supported(res->port_id, RTE_ETH_FILTER_FDIR); 10897 if (ret < 0) { 10898 printf("flow director is not supported on port %u.\n", 10899 res->port_id); 10900 return; 10901 } 10902 memset(flexbytes, 0, sizeof(flexbytes)); 10903 memset(&entry, 0, sizeof(struct rte_eth_fdir_filter)); 10904 10905 if (fdir_conf.mode == RTE_FDIR_MODE_PERFECT_MAC_VLAN) { 10906 if (strcmp(res->mode_value, "MAC-VLAN")) { 10907 printf("Please set mode to MAC-VLAN.\n"); 10908 return; 10909 } 10910 } else if (fdir_conf.mode == RTE_FDIR_MODE_PERFECT_TUNNEL) { 10911 if (strcmp(res->mode_value, "Tunnel")) { 10912 printf("Please set mode to Tunnel.\n"); 10913 return; 10914 } 10915 } else { 10916 if (!strcmp(res->mode_value, "raw")) { 10917 #ifdef RTE_LIBRTE_I40E_PMD 10918 struct rte_pmd_i40e_flow_type_mapping 10919 mapping[RTE_PMD_I40E_FLOW_TYPE_MAX]; 10920 struct rte_pmd_i40e_pkt_template_conf conf; 10921 uint16_t flow_type = str2flowtype(res->flow_type); 10922 uint16_t i, port = res->port_id; 10923 uint8_t add; 10924 10925 memset(&conf, 0, sizeof(conf)); 10926 10927 if (flow_type == RTE_ETH_FLOW_UNKNOWN) { 10928 printf("Invalid flow type specified.\n"); 10929 return; 10930 } 10931 ret = rte_pmd_i40e_flow_type_mapping_get(res->port_id, 10932 mapping); 10933 if (ret) 10934 return; 10935 if (mapping[flow_type].pctype == 0ULL) { 10936 printf("Invalid flow type specified.\n"); 10937 return; 10938 } 10939 for (i = 0; i < RTE_PMD_I40E_PCTYPE_MAX; i++) { 10940 if (mapping[flow_type].pctype & (1ULL << i)) { 10941 conf.input.pctype = i; 10942 break; 10943 } 10944 } 10945 10946 conf.input.packet = open_file(res->filepath, 10947 &conf.input.length); 10948 if (!conf.input.packet) 10949 return; 10950 if (!strcmp(res->drop, "drop")) 10951 conf.action.behavior = 10952 RTE_PMD_I40E_PKT_TEMPLATE_REJECT; 10953 else 10954 conf.action.behavior = 10955 RTE_PMD_I40E_PKT_TEMPLATE_ACCEPT; 10956 conf.action.report_status = 10957 RTE_PMD_I40E_PKT_TEMPLATE_REPORT_ID; 10958 conf.action.rx_queue = res->queue_id; 10959 conf.soft_id = res->fd_id_value; 10960 add = strcmp(res->ops, "del") ? 1 : 0; 10961 ret = rte_pmd_i40e_flow_add_del_packet_template(port, 10962 &conf, 10963 add); 10964 if (ret < 0) 10965 printf("flow director config error: (%s)\n", 10966 strerror(-ret)); 10967 close_file(conf.input.packet); 10968 #endif 10969 return; 10970 } else if (strcmp(res->mode_value, "IP")) { 10971 printf("Please set mode to IP or raw.\n"); 10972 return; 10973 } 10974 entry.input.flow_type = str2flowtype(res->flow_type); 10975 } 10976 10977 ret = parse_flexbytes(res->flexbytes_value, 10978 flexbytes, 10979 RTE_ETH_FDIR_MAX_FLEXLEN); 10980 if (ret < 0) { 10981 printf("error: Cannot parse flexbytes input.\n"); 10982 return; 10983 } 10984 10985 switch (entry.input.flow_type) { 10986 case RTE_ETH_FLOW_FRAG_IPV4: 10987 case RTE_ETH_FLOW_NONFRAG_IPV4_OTHER: 10988 entry.input.flow.ip4_flow.proto = res->proto_value; 10989 /* fall-through */ 10990 case RTE_ETH_FLOW_NONFRAG_IPV4_UDP: 10991 case RTE_ETH_FLOW_NONFRAG_IPV4_TCP: 10992 IPV4_ADDR_TO_UINT(res->ip_dst, 10993 entry.input.flow.ip4_flow.dst_ip); 10994 IPV4_ADDR_TO_UINT(res->ip_src, 10995 entry.input.flow.ip4_flow.src_ip); 10996 entry.input.flow.ip4_flow.tos = res->tos_value; 10997 entry.input.flow.ip4_flow.ttl = res->ttl_value; 10998 /* need convert to big endian. */ 10999 entry.input.flow.udp4_flow.dst_port = 11000 rte_cpu_to_be_16(res->port_dst); 11001 entry.input.flow.udp4_flow.src_port = 11002 rte_cpu_to_be_16(res->port_src); 11003 break; 11004 case RTE_ETH_FLOW_NONFRAG_IPV4_SCTP: 11005 IPV4_ADDR_TO_UINT(res->ip_dst, 11006 entry.input.flow.sctp4_flow.ip.dst_ip); 11007 IPV4_ADDR_TO_UINT(res->ip_src, 11008 entry.input.flow.sctp4_flow.ip.src_ip); 11009 entry.input.flow.ip4_flow.tos = res->tos_value; 11010 entry.input.flow.ip4_flow.ttl = res->ttl_value; 11011 /* need convert to big endian. */ 11012 entry.input.flow.sctp4_flow.dst_port = 11013 rte_cpu_to_be_16(res->port_dst); 11014 entry.input.flow.sctp4_flow.src_port = 11015 rte_cpu_to_be_16(res->port_src); 11016 entry.input.flow.sctp4_flow.verify_tag = 11017 rte_cpu_to_be_32(res->verify_tag_value); 11018 break; 11019 case RTE_ETH_FLOW_FRAG_IPV6: 11020 case RTE_ETH_FLOW_NONFRAG_IPV6_OTHER: 11021 entry.input.flow.ipv6_flow.proto = res->proto_value; 11022 /* fall-through */ 11023 case RTE_ETH_FLOW_NONFRAG_IPV6_UDP: 11024 case RTE_ETH_FLOW_NONFRAG_IPV6_TCP: 11025 IPV6_ADDR_TO_ARRAY(res->ip_dst, 11026 entry.input.flow.ipv6_flow.dst_ip); 11027 IPV6_ADDR_TO_ARRAY(res->ip_src, 11028 entry.input.flow.ipv6_flow.src_ip); 11029 entry.input.flow.ipv6_flow.tc = res->tos_value; 11030 entry.input.flow.ipv6_flow.hop_limits = res->ttl_value; 11031 /* need convert to big endian. */ 11032 entry.input.flow.udp6_flow.dst_port = 11033 rte_cpu_to_be_16(res->port_dst); 11034 entry.input.flow.udp6_flow.src_port = 11035 rte_cpu_to_be_16(res->port_src); 11036 break; 11037 case RTE_ETH_FLOW_NONFRAG_IPV6_SCTP: 11038 IPV6_ADDR_TO_ARRAY(res->ip_dst, 11039 entry.input.flow.sctp6_flow.ip.dst_ip); 11040 IPV6_ADDR_TO_ARRAY(res->ip_src, 11041 entry.input.flow.sctp6_flow.ip.src_ip); 11042 entry.input.flow.ipv6_flow.tc = res->tos_value; 11043 entry.input.flow.ipv6_flow.hop_limits = res->ttl_value; 11044 /* need convert to big endian. */ 11045 entry.input.flow.sctp6_flow.dst_port = 11046 rte_cpu_to_be_16(res->port_dst); 11047 entry.input.flow.sctp6_flow.src_port = 11048 rte_cpu_to_be_16(res->port_src); 11049 entry.input.flow.sctp6_flow.verify_tag = 11050 rte_cpu_to_be_32(res->verify_tag_value); 11051 break; 11052 case RTE_ETH_FLOW_L2_PAYLOAD: 11053 entry.input.flow.l2_flow.ether_type = 11054 rte_cpu_to_be_16(res->ether_type); 11055 break; 11056 default: 11057 break; 11058 } 11059 11060 if (fdir_conf.mode == RTE_FDIR_MODE_PERFECT_MAC_VLAN) 11061 rte_memcpy(&entry.input.flow.mac_vlan_flow.mac_addr, 11062 &res->mac_addr, 11063 sizeof(struct rte_ether_addr)); 11064 11065 if (fdir_conf.mode == RTE_FDIR_MODE_PERFECT_TUNNEL) { 11066 rte_memcpy(&entry.input.flow.tunnel_flow.mac_addr, 11067 &res->mac_addr, 11068 sizeof(struct rte_ether_addr)); 11069 entry.input.flow.tunnel_flow.tunnel_type = 11070 str2fdir_tunneltype(res->tunnel_type); 11071 entry.input.flow.tunnel_flow.tunnel_id = 11072 rte_cpu_to_be_32(res->tunnel_id_value); 11073 } 11074 11075 rte_memcpy(entry.input.flow_ext.flexbytes, 11076 flexbytes, 11077 RTE_ETH_FDIR_MAX_FLEXLEN); 11078 11079 entry.input.flow_ext.vlan_tci = rte_cpu_to_be_16(res->vlan_value); 11080 11081 entry.action.flex_off = 0; /*use 0 by default */ 11082 if (!strcmp(res->drop, "drop")) 11083 entry.action.behavior = RTE_ETH_FDIR_REJECT; 11084 else 11085 entry.action.behavior = RTE_ETH_FDIR_ACCEPT; 11086 11087 if (fdir_conf.mode != RTE_FDIR_MODE_PERFECT_MAC_VLAN && 11088 fdir_conf.mode != RTE_FDIR_MODE_PERFECT_TUNNEL) { 11089 if (!strcmp(res->pf_vf, "pf")) 11090 entry.input.flow_ext.is_vf = 0; 11091 else if (!strncmp(res->pf_vf, "vf", 2)) { 11092 struct rte_eth_dev_info dev_info; 11093 11094 memset(&dev_info, 0, sizeof(dev_info)); 11095 rte_eth_dev_info_get(res->port_id, &dev_info); 11096 errno = 0; 11097 vf_id = strtoul(res->pf_vf + 2, &end, 10); 11098 if (errno != 0 || *end != '\0' || 11099 vf_id >= dev_info.max_vfs) { 11100 printf("invalid parameter %s.\n", res->pf_vf); 11101 return; 11102 } 11103 entry.input.flow_ext.is_vf = 1; 11104 entry.input.flow_ext.dst_id = (uint16_t)vf_id; 11105 } else { 11106 printf("invalid parameter %s.\n", res->pf_vf); 11107 return; 11108 } 11109 } 11110 11111 /* set to report FD ID by default */ 11112 entry.action.report_status = RTE_ETH_FDIR_REPORT_ID; 11113 entry.action.rx_queue = res->queue_id; 11114 entry.soft_id = res->fd_id_value; 11115 if (!strcmp(res->ops, "add")) 11116 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_FDIR, 11117 RTE_ETH_FILTER_ADD, &entry); 11118 else if (!strcmp(res->ops, "del")) 11119 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_FDIR, 11120 RTE_ETH_FILTER_DELETE, &entry); 11121 else 11122 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_FDIR, 11123 RTE_ETH_FILTER_UPDATE, &entry); 11124 if (ret < 0) 11125 printf("flow director programming error: (%s)\n", 11126 strerror(-ret)); 11127 } 11128 11129 cmdline_parse_token_string_t cmd_flow_director_filter = 11130 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result, 11131 flow_director_filter, "flow_director_filter"); 11132 cmdline_parse_token_num_t cmd_flow_director_port_id = 11133 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result, 11134 port_id, UINT16); 11135 cmdline_parse_token_string_t cmd_flow_director_ops = 11136 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result, 11137 ops, "add#del#update"); 11138 cmdline_parse_token_string_t cmd_flow_director_flow = 11139 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result, 11140 flow, "flow"); 11141 cmdline_parse_token_string_t cmd_flow_director_flow_type = 11142 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result, 11143 flow_type, NULL); 11144 cmdline_parse_token_string_t cmd_flow_director_ether = 11145 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result, 11146 ether, "ether"); 11147 cmdline_parse_token_num_t cmd_flow_director_ether_type = 11148 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result, 11149 ether_type, UINT16); 11150 cmdline_parse_token_string_t cmd_flow_director_src = 11151 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result, 11152 src, "src"); 11153 cmdline_parse_token_ipaddr_t cmd_flow_director_ip_src = 11154 TOKEN_IPADDR_INITIALIZER(struct cmd_flow_director_result, 11155 ip_src); 11156 cmdline_parse_token_num_t cmd_flow_director_port_src = 11157 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result, 11158 port_src, UINT16); 11159 cmdline_parse_token_string_t cmd_flow_director_dst = 11160 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result, 11161 dst, "dst"); 11162 cmdline_parse_token_ipaddr_t cmd_flow_director_ip_dst = 11163 TOKEN_IPADDR_INITIALIZER(struct cmd_flow_director_result, 11164 ip_dst); 11165 cmdline_parse_token_num_t cmd_flow_director_port_dst = 11166 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result, 11167 port_dst, UINT16); 11168 cmdline_parse_token_string_t cmd_flow_director_verify_tag = 11169 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result, 11170 verify_tag, "verify_tag"); 11171 cmdline_parse_token_num_t cmd_flow_director_verify_tag_value = 11172 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result, 11173 verify_tag_value, UINT32); 11174 cmdline_parse_token_string_t cmd_flow_director_tos = 11175 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result, 11176 tos, "tos"); 11177 cmdline_parse_token_num_t cmd_flow_director_tos_value = 11178 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result, 11179 tos_value, UINT8); 11180 cmdline_parse_token_string_t cmd_flow_director_proto = 11181 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result, 11182 proto, "proto"); 11183 cmdline_parse_token_num_t cmd_flow_director_proto_value = 11184 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result, 11185 proto_value, UINT8); 11186 cmdline_parse_token_string_t cmd_flow_director_ttl = 11187 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result, 11188 ttl, "ttl"); 11189 cmdline_parse_token_num_t cmd_flow_director_ttl_value = 11190 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result, 11191 ttl_value, UINT8); 11192 cmdline_parse_token_string_t cmd_flow_director_vlan = 11193 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result, 11194 vlan, "vlan"); 11195 cmdline_parse_token_num_t cmd_flow_director_vlan_value = 11196 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result, 11197 vlan_value, UINT16); 11198 cmdline_parse_token_string_t cmd_flow_director_flexbytes = 11199 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result, 11200 flexbytes, "flexbytes"); 11201 cmdline_parse_token_string_t cmd_flow_director_flexbytes_value = 11202 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result, 11203 flexbytes_value, NULL); 11204 cmdline_parse_token_string_t cmd_flow_director_drop = 11205 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result, 11206 drop, "drop#fwd"); 11207 cmdline_parse_token_string_t cmd_flow_director_pf_vf = 11208 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result, 11209 pf_vf, NULL); 11210 cmdline_parse_token_string_t cmd_flow_director_queue = 11211 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result, 11212 queue, "queue"); 11213 cmdline_parse_token_num_t cmd_flow_director_queue_id = 11214 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result, 11215 queue_id, UINT16); 11216 cmdline_parse_token_string_t cmd_flow_director_fd_id = 11217 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result, 11218 fd_id, "fd_id"); 11219 cmdline_parse_token_num_t cmd_flow_director_fd_id_value = 11220 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result, 11221 fd_id_value, UINT32); 11222 11223 cmdline_parse_token_string_t cmd_flow_director_mode = 11224 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result, 11225 mode, "mode"); 11226 cmdline_parse_token_string_t cmd_flow_director_mode_ip = 11227 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result, 11228 mode_value, "IP"); 11229 cmdline_parse_token_string_t cmd_flow_director_mode_mac_vlan = 11230 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result, 11231 mode_value, "MAC-VLAN"); 11232 cmdline_parse_token_string_t cmd_flow_director_mode_tunnel = 11233 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result, 11234 mode_value, "Tunnel"); 11235 cmdline_parse_token_string_t cmd_flow_director_mode_raw = 11236 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result, 11237 mode_value, "raw"); 11238 cmdline_parse_token_string_t cmd_flow_director_mac = 11239 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result, 11240 mac, "mac"); 11241 cmdline_parse_token_etheraddr_t cmd_flow_director_mac_addr = 11242 TOKEN_ETHERADDR_INITIALIZER(struct cmd_flow_director_result, 11243 mac_addr); 11244 cmdline_parse_token_string_t cmd_flow_director_tunnel = 11245 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result, 11246 tunnel, "tunnel"); 11247 cmdline_parse_token_string_t cmd_flow_director_tunnel_type = 11248 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result, 11249 tunnel_type, "NVGRE#VxLAN"); 11250 cmdline_parse_token_string_t cmd_flow_director_tunnel_id = 11251 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result, 11252 tunnel_id, "tunnel-id"); 11253 cmdline_parse_token_num_t cmd_flow_director_tunnel_id_value = 11254 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result, 11255 tunnel_id_value, UINT32); 11256 cmdline_parse_token_string_t cmd_flow_director_packet = 11257 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result, 11258 packet, "packet"); 11259 cmdline_parse_token_string_t cmd_flow_director_filepath = 11260 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result, 11261 filepath, NULL); 11262 11263 cmdline_parse_inst_t cmd_add_del_ip_flow_director = { 11264 .f = cmd_flow_director_filter_parsed, 11265 .data = NULL, 11266 .help_str = "flow_director_filter <port_id> mode IP add|del|update flow" 11267 " ipv4-other|ipv4-frag|ipv4-tcp|ipv4-udp|ipv4-sctp|" 11268 "ipv6-other|ipv6-frag|ipv6-tcp|ipv6-udp|ipv6-sctp|" 11269 "l2_payload src <src_ip> dst <dst_ip> tos <tos_value> " 11270 "proto <proto_value> ttl <ttl_value> vlan <vlan_value> " 11271 "flexbytes <flexbyte_values> drop|fw <pf_vf> queue <queue_id> " 11272 "fd_id <fd_id_value>: " 11273 "Add or delete an ip flow director entry on NIC", 11274 .tokens = { 11275 (void *)&cmd_flow_director_filter, 11276 (void *)&cmd_flow_director_port_id, 11277 (void *)&cmd_flow_director_mode, 11278 (void *)&cmd_flow_director_mode_ip, 11279 (void *)&cmd_flow_director_ops, 11280 (void *)&cmd_flow_director_flow, 11281 (void *)&cmd_flow_director_flow_type, 11282 (void *)&cmd_flow_director_src, 11283 (void *)&cmd_flow_director_ip_src, 11284 (void *)&cmd_flow_director_dst, 11285 (void *)&cmd_flow_director_ip_dst, 11286 (void *)&cmd_flow_director_tos, 11287 (void *)&cmd_flow_director_tos_value, 11288 (void *)&cmd_flow_director_proto, 11289 (void *)&cmd_flow_director_proto_value, 11290 (void *)&cmd_flow_director_ttl, 11291 (void *)&cmd_flow_director_ttl_value, 11292 (void *)&cmd_flow_director_vlan, 11293 (void *)&cmd_flow_director_vlan_value, 11294 (void *)&cmd_flow_director_flexbytes, 11295 (void *)&cmd_flow_director_flexbytes_value, 11296 (void *)&cmd_flow_director_drop, 11297 (void *)&cmd_flow_director_pf_vf, 11298 (void *)&cmd_flow_director_queue, 11299 (void *)&cmd_flow_director_queue_id, 11300 (void *)&cmd_flow_director_fd_id, 11301 (void *)&cmd_flow_director_fd_id_value, 11302 NULL, 11303 }, 11304 }; 11305 11306 cmdline_parse_inst_t cmd_add_del_udp_flow_director = { 11307 .f = cmd_flow_director_filter_parsed, 11308 .data = NULL, 11309 .help_str = "flow_director_filter ... : Add or delete an udp/tcp flow " 11310 "director entry on NIC", 11311 .tokens = { 11312 (void *)&cmd_flow_director_filter, 11313 (void *)&cmd_flow_director_port_id, 11314 (void *)&cmd_flow_director_mode, 11315 (void *)&cmd_flow_director_mode_ip, 11316 (void *)&cmd_flow_director_ops, 11317 (void *)&cmd_flow_director_flow, 11318 (void *)&cmd_flow_director_flow_type, 11319 (void *)&cmd_flow_director_src, 11320 (void *)&cmd_flow_director_ip_src, 11321 (void *)&cmd_flow_director_port_src, 11322 (void *)&cmd_flow_director_dst, 11323 (void *)&cmd_flow_director_ip_dst, 11324 (void *)&cmd_flow_director_port_dst, 11325 (void *)&cmd_flow_director_tos, 11326 (void *)&cmd_flow_director_tos_value, 11327 (void *)&cmd_flow_director_ttl, 11328 (void *)&cmd_flow_director_ttl_value, 11329 (void *)&cmd_flow_director_vlan, 11330 (void *)&cmd_flow_director_vlan_value, 11331 (void *)&cmd_flow_director_flexbytes, 11332 (void *)&cmd_flow_director_flexbytes_value, 11333 (void *)&cmd_flow_director_drop, 11334 (void *)&cmd_flow_director_pf_vf, 11335 (void *)&cmd_flow_director_queue, 11336 (void *)&cmd_flow_director_queue_id, 11337 (void *)&cmd_flow_director_fd_id, 11338 (void *)&cmd_flow_director_fd_id_value, 11339 NULL, 11340 }, 11341 }; 11342 11343 cmdline_parse_inst_t cmd_add_del_sctp_flow_director = { 11344 .f = cmd_flow_director_filter_parsed, 11345 .data = NULL, 11346 .help_str = "flow_director_filter ... : Add or delete a sctp flow " 11347 "director entry on NIC", 11348 .tokens = { 11349 (void *)&cmd_flow_director_filter, 11350 (void *)&cmd_flow_director_port_id, 11351 (void *)&cmd_flow_director_mode, 11352 (void *)&cmd_flow_director_mode_ip, 11353 (void *)&cmd_flow_director_ops, 11354 (void *)&cmd_flow_director_flow, 11355 (void *)&cmd_flow_director_flow_type, 11356 (void *)&cmd_flow_director_src, 11357 (void *)&cmd_flow_director_ip_src, 11358 (void *)&cmd_flow_director_port_src, 11359 (void *)&cmd_flow_director_dst, 11360 (void *)&cmd_flow_director_ip_dst, 11361 (void *)&cmd_flow_director_port_dst, 11362 (void *)&cmd_flow_director_verify_tag, 11363 (void *)&cmd_flow_director_verify_tag_value, 11364 (void *)&cmd_flow_director_tos, 11365 (void *)&cmd_flow_director_tos_value, 11366 (void *)&cmd_flow_director_ttl, 11367 (void *)&cmd_flow_director_ttl_value, 11368 (void *)&cmd_flow_director_vlan, 11369 (void *)&cmd_flow_director_vlan_value, 11370 (void *)&cmd_flow_director_flexbytes, 11371 (void *)&cmd_flow_director_flexbytes_value, 11372 (void *)&cmd_flow_director_drop, 11373 (void *)&cmd_flow_director_pf_vf, 11374 (void *)&cmd_flow_director_queue, 11375 (void *)&cmd_flow_director_queue_id, 11376 (void *)&cmd_flow_director_fd_id, 11377 (void *)&cmd_flow_director_fd_id_value, 11378 NULL, 11379 }, 11380 }; 11381 11382 cmdline_parse_inst_t cmd_add_del_l2_flow_director = { 11383 .f = cmd_flow_director_filter_parsed, 11384 .data = NULL, 11385 .help_str = "flow_director_filter ... : Add or delete a L2 flow " 11386 "director entry on NIC", 11387 .tokens = { 11388 (void *)&cmd_flow_director_filter, 11389 (void *)&cmd_flow_director_port_id, 11390 (void *)&cmd_flow_director_mode, 11391 (void *)&cmd_flow_director_mode_ip, 11392 (void *)&cmd_flow_director_ops, 11393 (void *)&cmd_flow_director_flow, 11394 (void *)&cmd_flow_director_flow_type, 11395 (void *)&cmd_flow_director_ether, 11396 (void *)&cmd_flow_director_ether_type, 11397 (void *)&cmd_flow_director_flexbytes, 11398 (void *)&cmd_flow_director_flexbytes_value, 11399 (void *)&cmd_flow_director_drop, 11400 (void *)&cmd_flow_director_pf_vf, 11401 (void *)&cmd_flow_director_queue, 11402 (void *)&cmd_flow_director_queue_id, 11403 (void *)&cmd_flow_director_fd_id, 11404 (void *)&cmd_flow_director_fd_id_value, 11405 NULL, 11406 }, 11407 }; 11408 11409 cmdline_parse_inst_t cmd_add_del_mac_vlan_flow_director = { 11410 .f = cmd_flow_director_filter_parsed, 11411 .data = NULL, 11412 .help_str = "flow_director_filter ... : Add or delete a MAC VLAN flow " 11413 "director entry on NIC", 11414 .tokens = { 11415 (void *)&cmd_flow_director_filter, 11416 (void *)&cmd_flow_director_port_id, 11417 (void *)&cmd_flow_director_mode, 11418 (void *)&cmd_flow_director_mode_mac_vlan, 11419 (void *)&cmd_flow_director_ops, 11420 (void *)&cmd_flow_director_mac, 11421 (void *)&cmd_flow_director_mac_addr, 11422 (void *)&cmd_flow_director_vlan, 11423 (void *)&cmd_flow_director_vlan_value, 11424 (void *)&cmd_flow_director_flexbytes, 11425 (void *)&cmd_flow_director_flexbytes_value, 11426 (void *)&cmd_flow_director_drop, 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_tunnel_flow_director = { 11436 .f = cmd_flow_director_filter_parsed, 11437 .data = NULL, 11438 .help_str = "flow_director_filter ... : Add or delete a tunnel 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_tunnel, 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_tunnel, 11451 (void *)&cmd_flow_director_tunnel_type, 11452 (void *)&cmd_flow_director_tunnel_id, 11453 (void *)&cmd_flow_director_tunnel_id_value, 11454 (void *)&cmd_flow_director_flexbytes, 11455 (void *)&cmd_flow_director_flexbytes_value, 11456 (void *)&cmd_flow_director_drop, 11457 (void *)&cmd_flow_director_queue, 11458 (void *)&cmd_flow_director_queue_id, 11459 (void *)&cmd_flow_director_fd_id, 11460 (void *)&cmd_flow_director_fd_id_value, 11461 NULL, 11462 }, 11463 }; 11464 11465 cmdline_parse_inst_t cmd_add_del_raw_flow_director = { 11466 .f = cmd_flow_director_filter_parsed, 11467 .data = NULL, 11468 .help_str = "flow_director_filter ... : Add or delete a raw flow " 11469 "director entry on NIC", 11470 .tokens = { 11471 (void *)&cmd_flow_director_filter, 11472 (void *)&cmd_flow_director_port_id, 11473 (void *)&cmd_flow_director_mode, 11474 (void *)&cmd_flow_director_mode_raw, 11475 (void *)&cmd_flow_director_ops, 11476 (void *)&cmd_flow_director_flow, 11477 (void *)&cmd_flow_director_flow_type, 11478 (void *)&cmd_flow_director_drop, 11479 (void *)&cmd_flow_director_queue, 11480 (void *)&cmd_flow_director_queue_id, 11481 (void *)&cmd_flow_director_fd_id, 11482 (void *)&cmd_flow_director_fd_id_value, 11483 (void *)&cmd_flow_director_packet, 11484 (void *)&cmd_flow_director_filepath, 11485 NULL, 11486 }, 11487 }; 11488 11489 struct cmd_flush_flow_director_result { 11490 cmdline_fixed_string_t flush_flow_director; 11491 portid_t port_id; 11492 }; 11493 11494 cmdline_parse_token_string_t cmd_flush_flow_director_flush = 11495 TOKEN_STRING_INITIALIZER(struct cmd_flush_flow_director_result, 11496 flush_flow_director, "flush_flow_director"); 11497 cmdline_parse_token_num_t cmd_flush_flow_director_port_id = 11498 TOKEN_NUM_INITIALIZER(struct cmd_flush_flow_director_result, 11499 port_id, UINT16); 11500 11501 static void 11502 cmd_flush_flow_director_parsed(void *parsed_result, 11503 __attribute__((unused)) struct cmdline *cl, 11504 __attribute__((unused)) void *data) 11505 { 11506 struct cmd_flow_director_result *res = parsed_result; 11507 int ret = 0; 11508 11509 ret = rte_eth_dev_filter_supported(res->port_id, RTE_ETH_FILTER_FDIR); 11510 if (ret < 0) { 11511 printf("flow director is not supported on port %u.\n", 11512 res->port_id); 11513 return; 11514 } 11515 11516 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_FDIR, 11517 RTE_ETH_FILTER_FLUSH, NULL); 11518 if (ret < 0) 11519 printf("flow director table flushing error: (%s)\n", 11520 strerror(-ret)); 11521 } 11522 11523 cmdline_parse_inst_t cmd_flush_flow_director = { 11524 .f = cmd_flush_flow_director_parsed, 11525 .data = NULL, 11526 .help_str = "flush_flow_director <port_id>: " 11527 "Flush all flow director entries of a device on NIC", 11528 .tokens = { 11529 (void *)&cmd_flush_flow_director_flush, 11530 (void *)&cmd_flush_flow_director_port_id, 11531 NULL, 11532 }, 11533 }; 11534 11535 /* *** deal with flow director mask *** */ 11536 struct cmd_flow_director_mask_result { 11537 cmdline_fixed_string_t flow_director_mask; 11538 portid_t port_id; 11539 cmdline_fixed_string_t mode; 11540 cmdline_fixed_string_t mode_value; 11541 cmdline_fixed_string_t vlan; 11542 uint16_t vlan_mask; 11543 cmdline_fixed_string_t src_mask; 11544 cmdline_ipaddr_t ipv4_src; 11545 cmdline_ipaddr_t ipv6_src; 11546 uint16_t port_src; 11547 cmdline_fixed_string_t dst_mask; 11548 cmdline_ipaddr_t ipv4_dst; 11549 cmdline_ipaddr_t ipv6_dst; 11550 uint16_t port_dst; 11551 cmdline_fixed_string_t mac; 11552 uint8_t mac_addr_byte_mask; 11553 cmdline_fixed_string_t tunnel_id; 11554 uint32_t tunnel_id_mask; 11555 cmdline_fixed_string_t tunnel_type; 11556 uint8_t tunnel_type_mask; 11557 }; 11558 11559 static void 11560 cmd_flow_director_mask_parsed(void *parsed_result, 11561 __attribute__((unused)) struct cmdline *cl, 11562 __attribute__((unused)) void *data) 11563 { 11564 struct cmd_flow_director_mask_result *res = parsed_result; 11565 struct rte_eth_fdir_masks *mask; 11566 struct rte_port *port; 11567 11568 port = &ports[res->port_id]; 11569 /** Check if the port is not started **/ 11570 if (port->port_status != RTE_PORT_STOPPED) { 11571 printf("Please stop port %d first\n", res->port_id); 11572 return; 11573 } 11574 11575 mask = &port->dev_conf.fdir_conf.mask; 11576 11577 if (fdir_conf.mode == RTE_FDIR_MODE_PERFECT_MAC_VLAN) { 11578 if (strcmp(res->mode_value, "MAC-VLAN")) { 11579 printf("Please set mode to MAC-VLAN.\n"); 11580 return; 11581 } 11582 11583 mask->vlan_tci_mask = rte_cpu_to_be_16(res->vlan_mask); 11584 } else if (fdir_conf.mode == RTE_FDIR_MODE_PERFECT_TUNNEL) { 11585 if (strcmp(res->mode_value, "Tunnel")) { 11586 printf("Please set mode to Tunnel.\n"); 11587 return; 11588 } 11589 11590 mask->vlan_tci_mask = rte_cpu_to_be_16(res->vlan_mask); 11591 mask->mac_addr_byte_mask = res->mac_addr_byte_mask; 11592 mask->tunnel_id_mask = rte_cpu_to_be_32(res->tunnel_id_mask); 11593 mask->tunnel_type_mask = res->tunnel_type_mask; 11594 } else { 11595 if (strcmp(res->mode_value, "IP")) { 11596 printf("Please set mode to IP.\n"); 11597 return; 11598 } 11599 11600 mask->vlan_tci_mask = rte_cpu_to_be_16(res->vlan_mask); 11601 IPV4_ADDR_TO_UINT(res->ipv4_src, mask->ipv4_mask.src_ip); 11602 IPV4_ADDR_TO_UINT(res->ipv4_dst, mask->ipv4_mask.dst_ip); 11603 IPV6_ADDR_TO_ARRAY(res->ipv6_src, mask->ipv6_mask.src_ip); 11604 IPV6_ADDR_TO_ARRAY(res->ipv6_dst, mask->ipv6_mask.dst_ip); 11605 mask->src_port_mask = rte_cpu_to_be_16(res->port_src); 11606 mask->dst_port_mask = rte_cpu_to_be_16(res->port_dst); 11607 } 11608 11609 cmd_reconfig_device_queue(res->port_id, 1, 1); 11610 } 11611 11612 cmdline_parse_token_string_t cmd_flow_director_mask = 11613 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result, 11614 flow_director_mask, "flow_director_mask"); 11615 cmdline_parse_token_num_t cmd_flow_director_mask_port_id = 11616 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_mask_result, 11617 port_id, UINT16); 11618 cmdline_parse_token_string_t cmd_flow_director_mask_vlan = 11619 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result, 11620 vlan, "vlan"); 11621 cmdline_parse_token_num_t cmd_flow_director_mask_vlan_value = 11622 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_mask_result, 11623 vlan_mask, UINT16); 11624 cmdline_parse_token_string_t cmd_flow_director_mask_src = 11625 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result, 11626 src_mask, "src_mask"); 11627 cmdline_parse_token_ipaddr_t cmd_flow_director_mask_ipv4_src = 11628 TOKEN_IPADDR_INITIALIZER(struct cmd_flow_director_mask_result, 11629 ipv4_src); 11630 cmdline_parse_token_ipaddr_t cmd_flow_director_mask_ipv6_src = 11631 TOKEN_IPADDR_INITIALIZER(struct cmd_flow_director_mask_result, 11632 ipv6_src); 11633 cmdline_parse_token_num_t cmd_flow_director_mask_port_src = 11634 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_mask_result, 11635 port_src, UINT16); 11636 cmdline_parse_token_string_t cmd_flow_director_mask_dst = 11637 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result, 11638 dst_mask, "dst_mask"); 11639 cmdline_parse_token_ipaddr_t cmd_flow_director_mask_ipv4_dst = 11640 TOKEN_IPADDR_INITIALIZER(struct cmd_flow_director_mask_result, 11641 ipv4_dst); 11642 cmdline_parse_token_ipaddr_t cmd_flow_director_mask_ipv6_dst = 11643 TOKEN_IPADDR_INITIALIZER(struct cmd_flow_director_mask_result, 11644 ipv6_dst); 11645 cmdline_parse_token_num_t cmd_flow_director_mask_port_dst = 11646 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_mask_result, 11647 port_dst, UINT16); 11648 11649 cmdline_parse_token_string_t cmd_flow_director_mask_mode = 11650 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result, 11651 mode, "mode"); 11652 cmdline_parse_token_string_t cmd_flow_director_mask_mode_ip = 11653 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result, 11654 mode_value, "IP"); 11655 cmdline_parse_token_string_t cmd_flow_director_mask_mode_mac_vlan = 11656 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result, 11657 mode_value, "MAC-VLAN"); 11658 cmdline_parse_token_string_t cmd_flow_director_mask_mode_tunnel = 11659 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result, 11660 mode_value, "Tunnel"); 11661 cmdline_parse_token_string_t cmd_flow_director_mask_mac = 11662 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result, 11663 mac, "mac"); 11664 cmdline_parse_token_num_t cmd_flow_director_mask_mac_value = 11665 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_mask_result, 11666 mac_addr_byte_mask, UINT8); 11667 cmdline_parse_token_string_t cmd_flow_director_mask_tunnel_type = 11668 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result, 11669 tunnel_type, "tunnel-type"); 11670 cmdline_parse_token_num_t cmd_flow_director_mask_tunnel_type_value = 11671 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_mask_result, 11672 tunnel_type_mask, UINT8); 11673 cmdline_parse_token_string_t cmd_flow_director_mask_tunnel_id = 11674 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result, 11675 tunnel_id, "tunnel-id"); 11676 cmdline_parse_token_num_t cmd_flow_director_mask_tunnel_id_value = 11677 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_mask_result, 11678 tunnel_id_mask, UINT32); 11679 11680 cmdline_parse_inst_t cmd_set_flow_director_ip_mask = { 11681 .f = cmd_flow_director_mask_parsed, 11682 .data = NULL, 11683 .help_str = "flow_director_mask ... : " 11684 "Set IP mode flow director's mask on NIC", 11685 .tokens = { 11686 (void *)&cmd_flow_director_mask, 11687 (void *)&cmd_flow_director_mask_port_id, 11688 (void *)&cmd_flow_director_mask_mode, 11689 (void *)&cmd_flow_director_mask_mode_ip, 11690 (void *)&cmd_flow_director_mask_vlan, 11691 (void *)&cmd_flow_director_mask_vlan_value, 11692 (void *)&cmd_flow_director_mask_src, 11693 (void *)&cmd_flow_director_mask_ipv4_src, 11694 (void *)&cmd_flow_director_mask_ipv6_src, 11695 (void *)&cmd_flow_director_mask_port_src, 11696 (void *)&cmd_flow_director_mask_dst, 11697 (void *)&cmd_flow_director_mask_ipv4_dst, 11698 (void *)&cmd_flow_director_mask_ipv6_dst, 11699 (void *)&cmd_flow_director_mask_port_dst, 11700 NULL, 11701 }, 11702 }; 11703 11704 cmdline_parse_inst_t cmd_set_flow_director_mac_vlan_mask = { 11705 .f = cmd_flow_director_mask_parsed, 11706 .data = NULL, 11707 .help_str = "flow_director_mask ... : Set MAC VLAN mode " 11708 "flow director's mask on NIC", 11709 .tokens = { 11710 (void *)&cmd_flow_director_mask, 11711 (void *)&cmd_flow_director_mask_port_id, 11712 (void *)&cmd_flow_director_mask_mode, 11713 (void *)&cmd_flow_director_mask_mode_mac_vlan, 11714 (void *)&cmd_flow_director_mask_vlan, 11715 (void *)&cmd_flow_director_mask_vlan_value, 11716 NULL, 11717 }, 11718 }; 11719 11720 cmdline_parse_inst_t cmd_set_flow_director_tunnel_mask = { 11721 .f = cmd_flow_director_mask_parsed, 11722 .data = NULL, 11723 .help_str = "flow_director_mask ... : Set tunnel mode " 11724 "flow director's mask on NIC", 11725 .tokens = { 11726 (void *)&cmd_flow_director_mask, 11727 (void *)&cmd_flow_director_mask_port_id, 11728 (void *)&cmd_flow_director_mask_mode, 11729 (void *)&cmd_flow_director_mask_mode_tunnel, 11730 (void *)&cmd_flow_director_mask_vlan, 11731 (void *)&cmd_flow_director_mask_vlan_value, 11732 (void *)&cmd_flow_director_mask_mac, 11733 (void *)&cmd_flow_director_mask_mac_value, 11734 (void *)&cmd_flow_director_mask_tunnel_type, 11735 (void *)&cmd_flow_director_mask_tunnel_type_value, 11736 (void *)&cmd_flow_director_mask_tunnel_id, 11737 (void *)&cmd_flow_director_mask_tunnel_id_value, 11738 NULL, 11739 }, 11740 }; 11741 11742 /* *** deal with flow director mask on flexible payload *** */ 11743 struct cmd_flow_director_flex_mask_result { 11744 cmdline_fixed_string_t flow_director_flexmask; 11745 portid_t port_id; 11746 cmdline_fixed_string_t flow; 11747 cmdline_fixed_string_t flow_type; 11748 cmdline_fixed_string_t mask; 11749 }; 11750 11751 static void 11752 cmd_flow_director_flex_mask_parsed(void *parsed_result, 11753 __attribute__((unused)) struct cmdline *cl, 11754 __attribute__((unused)) void *data) 11755 { 11756 struct cmd_flow_director_flex_mask_result *res = parsed_result; 11757 struct rte_eth_fdir_info fdir_info; 11758 struct rte_eth_fdir_flex_mask flex_mask; 11759 struct rte_port *port; 11760 uint64_t flow_type_mask; 11761 uint16_t i; 11762 int ret; 11763 11764 port = &ports[res->port_id]; 11765 /** Check if the port is not started **/ 11766 if (port->port_status != RTE_PORT_STOPPED) { 11767 printf("Please stop port %d first\n", res->port_id); 11768 return; 11769 } 11770 11771 memset(&flex_mask, 0, sizeof(struct rte_eth_fdir_flex_mask)); 11772 ret = parse_flexbytes(res->mask, 11773 flex_mask.mask, 11774 RTE_ETH_FDIR_MAX_FLEXLEN); 11775 if (ret < 0) { 11776 printf("error: Cannot parse mask input.\n"); 11777 return; 11778 } 11779 11780 memset(&fdir_info, 0, sizeof(fdir_info)); 11781 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_FDIR, 11782 RTE_ETH_FILTER_INFO, &fdir_info); 11783 if (ret < 0) { 11784 printf("Cannot get FDir filter info\n"); 11785 return; 11786 } 11787 11788 if (!strcmp(res->flow_type, "none")) { 11789 /* means don't specify the flow type */ 11790 flex_mask.flow_type = RTE_ETH_FLOW_UNKNOWN; 11791 for (i = 0; i < RTE_ETH_FLOW_MAX; i++) 11792 memset(&port->dev_conf.fdir_conf.flex_conf.flex_mask[i], 11793 0, sizeof(struct rte_eth_fdir_flex_mask)); 11794 port->dev_conf.fdir_conf.flex_conf.nb_flexmasks = 1; 11795 rte_memcpy(&port->dev_conf.fdir_conf.flex_conf.flex_mask[0], 11796 &flex_mask, 11797 sizeof(struct rte_eth_fdir_flex_mask)); 11798 cmd_reconfig_device_queue(res->port_id, 1, 1); 11799 return; 11800 } 11801 flow_type_mask = fdir_info.flow_types_mask[0]; 11802 if (!strcmp(res->flow_type, "all")) { 11803 if (!flow_type_mask) { 11804 printf("No flow type supported\n"); 11805 return; 11806 } 11807 for (i = RTE_ETH_FLOW_UNKNOWN; i < RTE_ETH_FLOW_MAX; i++) { 11808 if (flow_type_mask & (1ULL << i)) { 11809 flex_mask.flow_type = i; 11810 fdir_set_flex_mask(res->port_id, &flex_mask); 11811 } 11812 } 11813 cmd_reconfig_device_queue(res->port_id, 1, 1); 11814 return; 11815 } 11816 flex_mask.flow_type = str2flowtype(res->flow_type); 11817 if (!(flow_type_mask & (1ULL << flex_mask.flow_type))) { 11818 printf("Flow type %s not supported on port %d\n", 11819 res->flow_type, res->port_id); 11820 return; 11821 } 11822 fdir_set_flex_mask(res->port_id, &flex_mask); 11823 cmd_reconfig_device_queue(res->port_id, 1, 1); 11824 } 11825 11826 cmdline_parse_token_string_t cmd_flow_director_flexmask = 11827 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_flex_mask_result, 11828 flow_director_flexmask, 11829 "flow_director_flex_mask"); 11830 cmdline_parse_token_num_t cmd_flow_director_flexmask_port_id = 11831 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_flex_mask_result, 11832 port_id, UINT16); 11833 cmdline_parse_token_string_t cmd_flow_director_flexmask_flow = 11834 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_flex_mask_result, 11835 flow, "flow"); 11836 cmdline_parse_token_string_t cmd_flow_director_flexmask_flow_type = 11837 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_flex_mask_result, 11838 flow_type, "none#ipv4-other#ipv4-frag#ipv4-tcp#ipv4-udp#ipv4-sctp#" 11839 "ipv6-other#ipv6-frag#ipv6-tcp#ipv6-udp#ipv6-sctp#l2_payload#all"); 11840 cmdline_parse_token_string_t cmd_flow_director_flexmask_mask = 11841 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_flex_mask_result, 11842 mask, NULL); 11843 11844 cmdline_parse_inst_t cmd_set_flow_director_flex_mask = { 11845 .f = cmd_flow_director_flex_mask_parsed, 11846 .data = NULL, 11847 .help_str = "flow_director_flex_mask ... : " 11848 "Set flow director's flex mask on NIC", 11849 .tokens = { 11850 (void *)&cmd_flow_director_flexmask, 11851 (void *)&cmd_flow_director_flexmask_port_id, 11852 (void *)&cmd_flow_director_flexmask_flow, 11853 (void *)&cmd_flow_director_flexmask_flow_type, 11854 (void *)&cmd_flow_director_flexmask_mask, 11855 NULL, 11856 }, 11857 }; 11858 11859 /* *** deal with flow director flexible payload configuration *** */ 11860 struct cmd_flow_director_flexpayload_result { 11861 cmdline_fixed_string_t flow_director_flexpayload; 11862 portid_t port_id; 11863 cmdline_fixed_string_t payload_layer; 11864 cmdline_fixed_string_t payload_cfg; 11865 }; 11866 11867 static inline int 11868 parse_offsets(const char *q_arg, uint16_t *offsets, uint16_t max_num) 11869 { 11870 char s[256]; 11871 const char *p, *p0 = q_arg; 11872 char *end; 11873 unsigned long int_fld; 11874 char *str_fld[max_num]; 11875 int i; 11876 unsigned size; 11877 int ret = -1; 11878 11879 p = strchr(p0, '('); 11880 if (p == NULL) 11881 return -1; 11882 ++p; 11883 p0 = strchr(p, ')'); 11884 if (p0 == NULL) 11885 return -1; 11886 11887 size = p0 - p; 11888 if (size >= sizeof(s)) 11889 return -1; 11890 11891 snprintf(s, sizeof(s), "%.*s", size, p); 11892 ret = rte_strsplit(s, sizeof(s), str_fld, max_num, ','); 11893 if (ret < 0 || ret > max_num) 11894 return -1; 11895 for (i = 0; i < ret; i++) { 11896 errno = 0; 11897 int_fld = strtoul(str_fld[i], &end, 0); 11898 if (errno != 0 || *end != '\0' || int_fld > UINT16_MAX) 11899 return -1; 11900 offsets[i] = (uint16_t)int_fld; 11901 } 11902 return ret; 11903 } 11904 11905 static void 11906 cmd_flow_director_flxpld_parsed(void *parsed_result, 11907 __attribute__((unused)) struct cmdline *cl, 11908 __attribute__((unused)) void *data) 11909 { 11910 struct cmd_flow_director_flexpayload_result *res = parsed_result; 11911 struct rte_eth_flex_payload_cfg flex_cfg; 11912 struct rte_port *port; 11913 int ret = 0; 11914 11915 port = &ports[res->port_id]; 11916 /** Check if the port is not started **/ 11917 if (port->port_status != RTE_PORT_STOPPED) { 11918 printf("Please stop port %d first\n", res->port_id); 11919 return; 11920 } 11921 11922 memset(&flex_cfg, 0, sizeof(struct rte_eth_flex_payload_cfg)); 11923 11924 if (!strcmp(res->payload_layer, "raw")) 11925 flex_cfg.type = RTE_ETH_RAW_PAYLOAD; 11926 else if (!strcmp(res->payload_layer, "l2")) 11927 flex_cfg.type = RTE_ETH_L2_PAYLOAD; 11928 else if (!strcmp(res->payload_layer, "l3")) 11929 flex_cfg.type = RTE_ETH_L3_PAYLOAD; 11930 else if (!strcmp(res->payload_layer, "l4")) 11931 flex_cfg.type = RTE_ETH_L4_PAYLOAD; 11932 11933 ret = parse_offsets(res->payload_cfg, flex_cfg.src_offset, 11934 RTE_ETH_FDIR_MAX_FLEXLEN); 11935 if (ret < 0) { 11936 printf("error: Cannot parse flex payload input.\n"); 11937 return; 11938 } 11939 11940 fdir_set_flex_payload(res->port_id, &flex_cfg); 11941 cmd_reconfig_device_queue(res->port_id, 1, 1); 11942 } 11943 11944 cmdline_parse_token_string_t cmd_flow_director_flexpayload = 11945 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_flexpayload_result, 11946 flow_director_flexpayload, 11947 "flow_director_flex_payload"); 11948 cmdline_parse_token_num_t cmd_flow_director_flexpayload_port_id = 11949 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_flexpayload_result, 11950 port_id, UINT16); 11951 cmdline_parse_token_string_t cmd_flow_director_flexpayload_payload_layer = 11952 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_flexpayload_result, 11953 payload_layer, "raw#l2#l3#l4"); 11954 cmdline_parse_token_string_t cmd_flow_director_flexpayload_payload_cfg = 11955 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_flexpayload_result, 11956 payload_cfg, NULL); 11957 11958 cmdline_parse_inst_t cmd_set_flow_director_flex_payload = { 11959 .f = cmd_flow_director_flxpld_parsed, 11960 .data = NULL, 11961 .help_str = "flow_director_flexpayload ... : " 11962 "Set flow director's flex payload on NIC", 11963 .tokens = { 11964 (void *)&cmd_flow_director_flexpayload, 11965 (void *)&cmd_flow_director_flexpayload_port_id, 11966 (void *)&cmd_flow_director_flexpayload_payload_layer, 11967 (void *)&cmd_flow_director_flexpayload_payload_cfg, 11968 NULL, 11969 }, 11970 }; 11971 11972 /* Generic flow interface command. */ 11973 extern cmdline_parse_inst_t cmd_flow; 11974 11975 /* *** Classification Filters Control *** */ 11976 /* *** Get symmetric hash enable per port *** */ 11977 struct cmd_get_sym_hash_ena_per_port_result { 11978 cmdline_fixed_string_t get_sym_hash_ena_per_port; 11979 portid_t port_id; 11980 }; 11981 11982 static void 11983 cmd_get_sym_hash_per_port_parsed(void *parsed_result, 11984 __rte_unused struct cmdline *cl, 11985 __rte_unused void *data) 11986 { 11987 struct cmd_get_sym_hash_ena_per_port_result *res = parsed_result; 11988 struct rte_eth_hash_filter_info info; 11989 int ret; 11990 11991 if (rte_eth_dev_filter_supported(res->port_id, 11992 RTE_ETH_FILTER_HASH) < 0) { 11993 printf("RTE_ETH_FILTER_HASH not supported on port: %d\n", 11994 res->port_id); 11995 return; 11996 } 11997 11998 memset(&info, 0, sizeof(info)); 11999 info.info_type = RTE_ETH_HASH_FILTER_SYM_HASH_ENA_PER_PORT; 12000 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_HASH, 12001 RTE_ETH_FILTER_GET, &info); 12002 12003 if (ret < 0) { 12004 printf("Cannot get symmetric hash enable per port " 12005 "on port %u\n", res->port_id); 12006 return; 12007 } 12008 12009 printf("Symmetric hash is %s on port %u\n", info.info.enable ? 12010 "enabled" : "disabled", res->port_id); 12011 } 12012 12013 cmdline_parse_token_string_t cmd_get_sym_hash_ena_per_port_all = 12014 TOKEN_STRING_INITIALIZER(struct cmd_get_sym_hash_ena_per_port_result, 12015 get_sym_hash_ena_per_port, "get_sym_hash_ena_per_port"); 12016 cmdline_parse_token_num_t cmd_get_sym_hash_ena_per_port_port_id = 12017 TOKEN_NUM_INITIALIZER(struct cmd_get_sym_hash_ena_per_port_result, 12018 port_id, UINT16); 12019 12020 cmdline_parse_inst_t cmd_get_sym_hash_ena_per_port = { 12021 .f = cmd_get_sym_hash_per_port_parsed, 12022 .data = NULL, 12023 .help_str = "get_sym_hash_ena_per_port <port_id>", 12024 .tokens = { 12025 (void *)&cmd_get_sym_hash_ena_per_port_all, 12026 (void *)&cmd_get_sym_hash_ena_per_port_port_id, 12027 NULL, 12028 }, 12029 }; 12030 12031 /* *** Set symmetric hash enable per port *** */ 12032 struct cmd_set_sym_hash_ena_per_port_result { 12033 cmdline_fixed_string_t set_sym_hash_ena_per_port; 12034 cmdline_fixed_string_t enable; 12035 portid_t port_id; 12036 }; 12037 12038 static void 12039 cmd_set_sym_hash_per_port_parsed(void *parsed_result, 12040 __rte_unused struct cmdline *cl, 12041 __rte_unused void *data) 12042 { 12043 struct cmd_set_sym_hash_ena_per_port_result *res = parsed_result; 12044 struct rte_eth_hash_filter_info info; 12045 int ret; 12046 12047 if (rte_eth_dev_filter_supported(res->port_id, 12048 RTE_ETH_FILTER_HASH) < 0) { 12049 printf("RTE_ETH_FILTER_HASH not supported on port: %d\n", 12050 res->port_id); 12051 return; 12052 } 12053 12054 memset(&info, 0, sizeof(info)); 12055 info.info_type = RTE_ETH_HASH_FILTER_SYM_HASH_ENA_PER_PORT; 12056 if (!strcmp(res->enable, "enable")) 12057 info.info.enable = 1; 12058 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_HASH, 12059 RTE_ETH_FILTER_SET, &info); 12060 if (ret < 0) { 12061 printf("Cannot set symmetric hash enable per port on " 12062 "port %u\n", res->port_id); 12063 return; 12064 } 12065 printf("Symmetric hash has been set to %s on port %u\n", 12066 res->enable, res->port_id); 12067 } 12068 12069 cmdline_parse_token_string_t cmd_set_sym_hash_ena_per_port_all = 12070 TOKEN_STRING_INITIALIZER(struct cmd_set_sym_hash_ena_per_port_result, 12071 set_sym_hash_ena_per_port, "set_sym_hash_ena_per_port"); 12072 cmdline_parse_token_num_t cmd_set_sym_hash_ena_per_port_port_id = 12073 TOKEN_NUM_INITIALIZER(struct cmd_set_sym_hash_ena_per_port_result, 12074 port_id, UINT16); 12075 cmdline_parse_token_string_t cmd_set_sym_hash_ena_per_port_enable = 12076 TOKEN_STRING_INITIALIZER(struct cmd_set_sym_hash_ena_per_port_result, 12077 enable, "enable#disable"); 12078 12079 cmdline_parse_inst_t cmd_set_sym_hash_ena_per_port = { 12080 .f = cmd_set_sym_hash_per_port_parsed, 12081 .data = NULL, 12082 .help_str = "set_sym_hash_ena_per_port <port_id> enable|disable", 12083 .tokens = { 12084 (void *)&cmd_set_sym_hash_ena_per_port_all, 12085 (void *)&cmd_set_sym_hash_ena_per_port_port_id, 12086 (void *)&cmd_set_sym_hash_ena_per_port_enable, 12087 NULL, 12088 }, 12089 }; 12090 12091 /* Get global config of hash function */ 12092 struct cmd_get_hash_global_config_result { 12093 cmdline_fixed_string_t get_hash_global_config; 12094 portid_t port_id; 12095 }; 12096 12097 static char * 12098 flowtype_to_str(uint16_t ftype) 12099 { 12100 uint16_t i; 12101 static struct { 12102 char str[16]; 12103 uint16_t ftype; 12104 } ftype_table[] = { 12105 {"ipv4", RTE_ETH_FLOW_IPV4}, 12106 {"ipv4-frag", RTE_ETH_FLOW_FRAG_IPV4}, 12107 {"ipv4-tcp", RTE_ETH_FLOW_NONFRAG_IPV4_TCP}, 12108 {"ipv4-udp", RTE_ETH_FLOW_NONFRAG_IPV4_UDP}, 12109 {"ipv4-sctp", RTE_ETH_FLOW_NONFRAG_IPV4_SCTP}, 12110 {"ipv4-other", RTE_ETH_FLOW_NONFRAG_IPV4_OTHER}, 12111 {"ipv6", RTE_ETH_FLOW_IPV6}, 12112 {"ipv6-frag", RTE_ETH_FLOW_FRAG_IPV6}, 12113 {"ipv6-tcp", RTE_ETH_FLOW_NONFRAG_IPV6_TCP}, 12114 {"ipv6-udp", RTE_ETH_FLOW_NONFRAG_IPV6_UDP}, 12115 {"ipv6-sctp", RTE_ETH_FLOW_NONFRAG_IPV6_SCTP}, 12116 {"ipv6-other", RTE_ETH_FLOW_NONFRAG_IPV6_OTHER}, 12117 {"l2_payload", RTE_ETH_FLOW_L2_PAYLOAD}, 12118 {"port", RTE_ETH_FLOW_PORT}, 12119 {"vxlan", RTE_ETH_FLOW_VXLAN}, 12120 {"geneve", RTE_ETH_FLOW_GENEVE}, 12121 {"nvgre", RTE_ETH_FLOW_NVGRE}, 12122 {"vxlan-gpe", RTE_ETH_FLOW_VXLAN_GPE}, 12123 }; 12124 12125 for (i = 0; i < RTE_DIM(ftype_table); i++) { 12126 if (ftype_table[i].ftype == ftype) 12127 return ftype_table[i].str; 12128 } 12129 12130 return NULL; 12131 } 12132 12133 static void 12134 cmd_get_hash_global_config_parsed(void *parsed_result, 12135 __rte_unused struct cmdline *cl, 12136 __rte_unused void *data) 12137 { 12138 struct cmd_get_hash_global_config_result *res = parsed_result; 12139 struct rte_eth_hash_filter_info info; 12140 uint32_t idx, offset; 12141 uint16_t i; 12142 char *str; 12143 int ret; 12144 12145 if (rte_eth_dev_filter_supported(res->port_id, 12146 RTE_ETH_FILTER_HASH) < 0) { 12147 printf("RTE_ETH_FILTER_HASH not supported on port %d\n", 12148 res->port_id); 12149 return; 12150 } 12151 12152 memset(&info, 0, sizeof(info)); 12153 info.info_type = RTE_ETH_HASH_FILTER_GLOBAL_CONFIG; 12154 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_HASH, 12155 RTE_ETH_FILTER_GET, &info); 12156 if (ret < 0) { 12157 printf("Cannot get hash global configurations by port %d\n", 12158 res->port_id); 12159 return; 12160 } 12161 12162 switch (info.info.global_conf.hash_func) { 12163 case RTE_ETH_HASH_FUNCTION_TOEPLITZ: 12164 printf("Hash function is Toeplitz\n"); 12165 break; 12166 case RTE_ETH_HASH_FUNCTION_SIMPLE_XOR: 12167 printf("Hash function is Simple XOR\n"); 12168 break; 12169 default: 12170 printf("Unknown hash function\n"); 12171 break; 12172 } 12173 12174 for (i = 0; i < RTE_ETH_FLOW_MAX; i++) { 12175 idx = i / UINT64_BIT; 12176 offset = i % UINT64_BIT; 12177 if (!(info.info.global_conf.valid_bit_mask[idx] & 12178 (1ULL << offset))) 12179 continue; 12180 str = flowtype_to_str(i); 12181 if (!str) 12182 continue; 12183 printf("Symmetric hash is %s globally for flow type %s " 12184 "by port %d\n", 12185 ((info.info.global_conf.sym_hash_enable_mask[idx] & 12186 (1ULL << offset)) ? "enabled" : "disabled"), str, 12187 res->port_id); 12188 } 12189 } 12190 12191 cmdline_parse_token_string_t cmd_get_hash_global_config_all = 12192 TOKEN_STRING_INITIALIZER(struct cmd_get_hash_global_config_result, 12193 get_hash_global_config, "get_hash_global_config"); 12194 cmdline_parse_token_num_t cmd_get_hash_global_config_port_id = 12195 TOKEN_NUM_INITIALIZER(struct cmd_get_hash_global_config_result, 12196 port_id, UINT16); 12197 12198 cmdline_parse_inst_t cmd_get_hash_global_config = { 12199 .f = cmd_get_hash_global_config_parsed, 12200 .data = NULL, 12201 .help_str = "get_hash_global_config <port_id>", 12202 .tokens = { 12203 (void *)&cmd_get_hash_global_config_all, 12204 (void *)&cmd_get_hash_global_config_port_id, 12205 NULL, 12206 }, 12207 }; 12208 12209 /* Set global config of hash function */ 12210 struct cmd_set_hash_global_config_result { 12211 cmdline_fixed_string_t set_hash_global_config; 12212 portid_t port_id; 12213 cmdline_fixed_string_t hash_func; 12214 cmdline_fixed_string_t flow_type; 12215 cmdline_fixed_string_t enable; 12216 }; 12217 12218 static void 12219 cmd_set_hash_global_config_parsed(void *parsed_result, 12220 __rte_unused struct cmdline *cl, 12221 __rte_unused void *data) 12222 { 12223 struct cmd_set_hash_global_config_result *res = parsed_result; 12224 struct rte_eth_hash_filter_info info; 12225 uint32_t ftype, idx, offset; 12226 int ret; 12227 12228 if (rte_eth_dev_filter_supported(res->port_id, 12229 RTE_ETH_FILTER_HASH) < 0) { 12230 printf("RTE_ETH_FILTER_HASH not supported on port %d\n", 12231 res->port_id); 12232 return; 12233 } 12234 memset(&info, 0, sizeof(info)); 12235 info.info_type = RTE_ETH_HASH_FILTER_GLOBAL_CONFIG; 12236 if (!strcmp(res->hash_func, "toeplitz")) 12237 info.info.global_conf.hash_func = 12238 RTE_ETH_HASH_FUNCTION_TOEPLITZ; 12239 else if (!strcmp(res->hash_func, "simple_xor")) 12240 info.info.global_conf.hash_func = 12241 RTE_ETH_HASH_FUNCTION_SIMPLE_XOR; 12242 else if (!strcmp(res->hash_func, "default")) 12243 info.info.global_conf.hash_func = 12244 RTE_ETH_HASH_FUNCTION_DEFAULT; 12245 12246 ftype = str2flowtype(res->flow_type); 12247 idx = ftype / UINT64_BIT; 12248 offset = ftype % UINT64_BIT; 12249 info.info.global_conf.valid_bit_mask[idx] |= (1ULL << offset); 12250 if (!strcmp(res->enable, "enable")) 12251 info.info.global_conf.sym_hash_enable_mask[idx] |= 12252 (1ULL << offset); 12253 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_HASH, 12254 RTE_ETH_FILTER_SET, &info); 12255 if (ret < 0) 12256 printf("Cannot set global hash configurations by port %d\n", 12257 res->port_id); 12258 else 12259 printf("Global hash configurations have been set " 12260 "successfully by port %d\n", res->port_id); 12261 } 12262 12263 cmdline_parse_token_string_t cmd_set_hash_global_config_all = 12264 TOKEN_STRING_INITIALIZER(struct cmd_set_hash_global_config_result, 12265 set_hash_global_config, "set_hash_global_config"); 12266 cmdline_parse_token_num_t cmd_set_hash_global_config_port_id = 12267 TOKEN_NUM_INITIALIZER(struct cmd_set_hash_global_config_result, 12268 port_id, UINT16); 12269 cmdline_parse_token_string_t cmd_set_hash_global_config_hash_func = 12270 TOKEN_STRING_INITIALIZER(struct cmd_set_hash_global_config_result, 12271 hash_func, "toeplitz#simple_xor#default"); 12272 cmdline_parse_token_string_t cmd_set_hash_global_config_flow_type = 12273 TOKEN_STRING_INITIALIZER(struct cmd_set_hash_global_config_result, 12274 flow_type, 12275 "ipv4#ipv4-frag#ipv4-tcp#ipv4-udp#ipv4-sctp#ipv4-other#ipv6#" 12276 "ipv6-frag#ipv6-tcp#ipv6-udp#ipv6-sctp#ipv6-other#l2_payload"); 12277 cmdline_parse_token_string_t cmd_set_hash_global_config_enable = 12278 TOKEN_STRING_INITIALIZER(struct cmd_set_hash_global_config_result, 12279 enable, "enable#disable"); 12280 12281 cmdline_parse_inst_t cmd_set_hash_global_config = { 12282 .f = cmd_set_hash_global_config_parsed, 12283 .data = NULL, 12284 .help_str = "set_hash_global_config <port_id> " 12285 "toeplitz|simple_xor|default " 12286 "ipv4|ipv4-frag|ipv4-tcp|ipv4-udp|ipv4-sctp|ipv4-other|" 12287 "ipv6|ipv6-frag|ipv6-tcp|ipv6-udp|ipv6-sctp|ipv6-other|" 12288 "l2_payload enable|disable", 12289 .tokens = { 12290 (void *)&cmd_set_hash_global_config_all, 12291 (void *)&cmd_set_hash_global_config_port_id, 12292 (void *)&cmd_set_hash_global_config_hash_func, 12293 (void *)&cmd_set_hash_global_config_flow_type, 12294 (void *)&cmd_set_hash_global_config_enable, 12295 NULL, 12296 }, 12297 }; 12298 12299 /* Set hash input set */ 12300 struct cmd_set_hash_input_set_result { 12301 cmdline_fixed_string_t set_hash_input_set; 12302 portid_t port_id; 12303 cmdline_fixed_string_t flow_type; 12304 cmdline_fixed_string_t inset_field; 12305 cmdline_fixed_string_t select; 12306 }; 12307 12308 static enum rte_eth_input_set_field 12309 str2inset(char *string) 12310 { 12311 uint16_t i; 12312 12313 static const struct { 12314 char str[32]; 12315 enum rte_eth_input_set_field inset; 12316 } inset_table[] = { 12317 {"ethertype", RTE_ETH_INPUT_SET_L2_ETHERTYPE}, 12318 {"ovlan", RTE_ETH_INPUT_SET_L2_OUTER_VLAN}, 12319 {"ivlan", RTE_ETH_INPUT_SET_L2_INNER_VLAN}, 12320 {"src-ipv4", RTE_ETH_INPUT_SET_L3_SRC_IP4}, 12321 {"dst-ipv4", RTE_ETH_INPUT_SET_L3_DST_IP4}, 12322 {"ipv4-tos", RTE_ETH_INPUT_SET_L3_IP4_TOS}, 12323 {"ipv4-proto", RTE_ETH_INPUT_SET_L3_IP4_PROTO}, 12324 {"ipv4-ttl", RTE_ETH_INPUT_SET_L3_IP4_TTL}, 12325 {"src-ipv6", RTE_ETH_INPUT_SET_L3_SRC_IP6}, 12326 {"dst-ipv6", RTE_ETH_INPUT_SET_L3_DST_IP6}, 12327 {"ipv6-tc", RTE_ETH_INPUT_SET_L3_IP6_TC}, 12328 {"ipv6-next-header", RTE_ETH_INPUT_SET_L3_IP6_NEXT_HEADER}, 12329 {"ipv6-hop-limits", RTE_ETH_INPUT_SET_L3_IP6_HOP_LIMITS}, 12330 {"udp-src-port", RTE_ETH_INPUT_SET_L4_UDP_SRC_PORT}, 12331 {"udp-dst-port", RTE_ETH_INPUT_SET_L4_UDP_DST_PORT}, 12332 {"tcp-src-port", RTE_ETH_INPUT_SET_L4_TCP_SRC_PORT}, 12333 {"tcp-dst-port", RTE_ETH_INPUT_SET_L4_TCP_DST_PORT}, 12334 {"sctp-src-port", RTE_ETH_INPUT_SET_L4_SCTP_SRC_PORT}, 12335 {"sctp-dst-port", RTE_ETH_INPUT_SET_L4_SCTP_DST_PORT}, 12336 {"sctp-veri-tag", RTE_ETH_INPUT_SET_L4_SCTP_VERIFICATION_TAG}, 12337 {"udp-key", RTE_ETH_INPUT_SET_TUNNEL_L4_UDP_KEY}, 12338 {"gre-key", RTE_ETH_INPUT_SET_TUNNEL_GRE_KEY}, 12339 {"fld-1st", RTE_ETH_INPUT_SET_FLEX_PAYLOAD_1ST_WORD}, 12340 {"fld-2nd", RTE_ETH_INPUT_SET_FLEX_PAYLOAD_2ND_WORD}, 12341 {"fld-3rd", RTE_ETH_INPUT_SET_FLEX_PAYLOAD_3RD_WORD}, 12342 {"fld-4th", RTE_ETH_INPUT_SET_FLEX_PAYLOAD_4TH_WORD}, 12343 {"fld-5th", RTE_ETH_INPUT_SET_FLEX_PAYLOAD_5TH_WORD}, 12344 {"fld-6th", RTE_ETH_INPUT_SET_FLEX_PAYLOAD_6TH_WORD}, 12345 {"fld-7th", RTE_ETH_INPUT_SET_FLEX_PAYLOAD_7TH_WORD}, 12346 {"fld-8th", RTE_ETH_INPUT_SET_FLEX_PAYLOAD_8TH_WORD}, 12347 {"none", RTE_ETH_INPUT_SET_NONE}, 12348 }; 12349 12350 for (i = 0; i < RTE_DIM(inset_table); i++) { 12351 if (!strcmp(string, inset_table[i].str)) 12352 return inset_table[i].inset; 12353 } 12354 12355 return RTE_ETH_INPUT_SET_UNKNOWN; 12356 } 12357 12358 static void 12359 cmd_set_hash_input_set_parsed(void *parsed_result, 12360 __rte_unused struct cmdline *cl, 12361 __rte_unused void *data) 12362 { 12363 struct cmd_set_hash_input_set_result *res = parsed_result; 12364 struct rte_eth_hash_filter_info info; 12365 12366 memset(&info, 0, sizeof(info)); 12367 info.info_type = RTE_ETH_HASH_FILTER_INPUT_SET_SELECT; 12368 info.info.input_set_conf.flow_type = str2flowtype(res->flow_type); 12369 info.info.input_set_conf.field[0] = str2inset(res->inset_field); 12370 info.info.input_set_conf.inset_size = 1; 12371 if (!strcmp(res->select, "select")) 12372 info.info.input_set_conf.op = RTE_ETH_INPUT_SET_SELECT; 12373 else if (!strcmp(res->select, "add")) 12374 info.info.input_set_conf.op = RTE_ETH_INPUT_SET_ADD; 12375 rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_HASH, 12376 RTE_ETH_FILTER_SET, &info); 12377 } 12378 12379 cmdline_parse_token_string_t cmd_set_hash_input_set_cmd = 12380 TOKEN_STRING_INITIALIZER(struct cmd_set_hash_input_set_result, 12381 set_hash_input_set, "set_hash_input_set"); 12382 cmdline_parse_token_num_t cmd_set_hash_input_set_port_id = 12383 TOKEN_NUM_INITIALIZER(struct cmd_set_hash_input_set_result, 12384 port_id, UINT16); 12385 cmdline_parse_token_string_t cmd_set_hash_input_set_flow_type = 12386 TOKEN_STRING_INITIALIZER(struct cmd_set_hash_input_set_result, 12387 flow_type, NULL); 12388 cmdline_parse_token_string_t cmd_set_hash_input_set_field = 12389 TOKEN_STRING_INITIALIZER(struct cmd_set_hash_input_set_result, 12390 inset_field, 12391 "ovlan#ivlan#src-ipv4#dst-ipv4#src-ipv6#dst-ipv6#" 12392 "ipv4-tos#ipv4-proto#ipv6-tc#ipv6-next-header#udp-src-port#" 12393 "udp-dst-port#tcp-src-port#tcp-dst-port#sctp-src-port#" 12394 "sctp-dst-port#sctp-veri-tag#udp-key#gre-key#fld-1st#" 12395 "fld-2nd#fld-3rd#fld-4th#fld-5th#fld-6th#fld-7th#" 12396 "fld-8th#none"); 12397 cmdline_parse_token_string_t cmd_set_hash_input_set_select = 12398 TOKEN_STRING_INITIALIZER(struct cmd_set_hash_input_set_result, 12399 select, "select#add"); 12400 12401 cmdline_parse_inst_t cmd_set_hash_input_set = { 12402 .f = cmd_set_hash_input_set_parsed, 12403 .data = NULL, 12404 .help_str = "set_hash_input_set <port_id> " 12405 "ipv4-frag|ipv4-tcp|ipv4-udp|ipv4-sctp|ipv4-other|" 12406 "ipv6-frag|ipv6-tcp|ipv6-udp|ipv6-sctp|ipv6-other|l2_payload|<flowtype_id> " 12407 "ovlan|ivlan|src-ipv4|dst-ipv4|src-ipv6|dst-ipv6|ipv4-tos|ipv4-proto|" 12408 "ipv6-tc|ipv6-next-header|udp-src-port|udp-dst-port|tcp-src-port|" 12409 "tcp-dst-port|sctp-src-port|sctp-dst-port|sctp-veri-tag|udp-key|" 12410 "gre-key|fld-1st|fld-2nd|fld-3rd|fld-4th|fld-5th|fld-6th|" 12411 "fld-7th|fld-8th|none select|add", 12412 .tokens = { 12413 (void *)&cmd_set_hash_input_set_cmd, 12414 (void *)&cmd_set_hash_input_set_port_id, 12415 (void *)&cmd_set_hash_input_set_flow_type, 12416 (void *)&cmd_set_hash_input_set_field, 12417 (void *)&cmd_set_hash_input_set_select, 12418 NULL, 12419 }, 12420 }; 12421 12422 /* Set flow director input set */ 12423 struct cmd_set_fdir_input_set_result { 12424 cmdline_fixed_string_t set_fdir_input_set; 12425 portid_t port_id; 12426 cmdline_fixed_string_t flow_type; 12427 cmdline_fixed_string_t inset_field; 12428 cmdline_fixed_string_t select; 12429 }; 12430 12431 static void 12432 cmd_set_fdir_input_set_parsed(void *parsed_result, 12433 __rte_unused struct cmdline *cl, 12434 __rte_unused void *data) 12435 { 12436 struct cmd_set_fdir_input_set_result *res = parsed_result; 12437 struct rte_eth_fdir_filter_info info; 12438 12439 memset(&info, 0, sizeof(info)); 12440 info.info_type = RTE_ETH_FDIR_FILTER_INPUT_SET_SELECT; 12441 info.info.input_set_conf.flow_type = str2flowtype(res->flow_type); 12442 info.info.input_set_conf.field[0] = str2inset(res->inset_field); 12443 info.info.input_set_conf.inset_size = 1; 12444 if (!strcmp(res->select, "select")) 12445 info.info.input_set_conf.op = RTE_ETH_INPUT_SET_SELECT; 12446 else if (!strcmp(res->select, "add")) 12447 info.info.input_set_conf.op = RTE_ETH_INPUT_SET_ADD; 12448 rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_FDIR, 12449 RTE_ETH_FILTER_SET, &info); 12450 } 12451 12452 cmdline_parse_token_string_t cmd_set_fdir_input_set_cmd = 12453 TOKEN_STRING_INITIALIZER(struct cmd_set_fdir_input_set_result, 12454 set_fdir_input_set, "set_fdir_input_set"); 12455 cmdline_parse_token_num_t cmd_set_fdir_input_set_port_id = 12456 TOKEN_NUM_INITIALIZER(struct cmd_set_fdir_input_set_result, 12457 port_id, UINT16); 12458 cmdline_parse_token_string_t cmd_set_fdir_input_set_flow_type = 12459 TOKEN_STRING_INITIALIZER(struct cmd_set_fdir_input_set_result, 12460 flow_type, 12461 "ipv4-frag#ipv4-tcp#ipv4-udp#ipv4-sctp#ipv4-other#" 12462 "ipv6-frag#ipv6-tcp#ipv6-udp#ipv6-sctp#ipv6-other#l2_payload"); 12463 cmdline_parse_token_string_t cmd_set_fdir_input_set_field = 12464 TOKEN_STRING_INITIALIZER(struct cmd_set_fdir_input_set_result, 12465 inset_field, 12466 "ivlan#ethertype#src-ipv4#dst-ipv4#src-ipv6#dst-ipv6#" 12467 "ipv4-tos#ipv4-proto#ipv4-ttl#ipv6-tc#ipv6-next-header#" 12468 "ipv6-hop-limits#udp-src-port#udp-dst-port#" 12469 "tcp-src-port#tcp-dst-port#sctp-src-port#sctp-dst-port#" 12470 "sctp-veri-tag#none"); 12471 cmdline_parse_token_string_t cmd_set_fdir_input_set_select = 12472 TOKEN_STRING_INITIALIZER(struct cmd_set_fdir_input_set_result, 12473 select, "select#add"); 12474 12475 cmdline_parse_inst_t cmd_set_fdir_input_set = { 12476 .f = cmd_set_fdir_input_set_parsed, 12477 .data = NULL, 12478 .help_str = "set_fdir_input_set <port_id> " 12479 "ipv4-frag|ipv4-tcp|ipv4-udp|ipv4-sctp|ipv4-other|" 12480 "ipv6-frag|ipv6-tcp|ipv6-udp|ipv6-sctp|ipv6-other|l2_payload " 12481 "ivlan|ethertype|src-ipv4|dst-ipv4|src-ipv6|dst-ipv6|" 12482 "ipv4-tos|ipv4-proto|ipv4-ttl|ipv6-tc|ipv6-next-header|" 12483 "ipv6-hop-limits|udp-src-port|udp-dst-port|" 12484 "tcp-src-port|tcp-dst-port|sctp-src-port|sctp-dst-port|" 12485 "sctp-veri-tag|none select|add", 12486 .tokens = { 12487 (void *)&cmd_set_fdir_input_set_cmd, 12488 (void *)&cmd_set_fdir_input_set_port_id, 12489 (void *)&cmd_set_fdir_input_set_flow_type, 12490 (void *)&cmd_set_fdir_input_set_field, 12491 (void *)&cmd_set_fdir_input_set_select, 12492 NULL, 12493 }, 12494 }; 12495 12496 /* *** ADD/REMOVE A MULTICAST MAC ADDRESS TO/FROM A PORT *** */ 12497 struct cmd_mcast_addr_result { 12498 cmdline_fixed_string_t mcast_addr_cmd; 12499 cmdline_fixed_string_t what; 12500 uint16_t port_num; 12501 struct rte_ether_addr mc_addr; 12502 }; 12503 12504 static void cmd_mcast_addr_parsed(void *parsed_result, 12505 __attribute__((unused)) struct cmdline *cl, 12506 __attribute__((unused)) void *data) 12507 { 12508 struct cmd_mcast_addr_result *res = parsed_result; 12509 12510 if (!rte_is_multicast_ether_addr(&res->mc_addr)) { 12511 printf("Invalid multicast addr %02X:%02X:%02X:%02X:%02X:%02X\n", 12512 res->mc_addr.addr_bytes[0], res->mc_addr.addr_bytes[1], 12513 res->mc_addr.addr_bytes[2], res->mc_addr.addr_bytes[3], 12514 res->mc_addr.addr_bytes[4], res->mc_addr.addr_bytes[5]); 12515 return; 12516 } 12517 if (strcmp(res->what, "add") == 0) 12518 mcast_addr_add(res->port_num, &res->mc_addr); 12519 else 12520 mcast_addr_remove(res->port_num, &res->mc_addr); 12521 } 12522 12523 cmdline_parse_token_string_t cmd_mcast_addr_cmd = 12524 TOKEN_STRING_INITIALIZER(struct cmd_mcast_addr_result, 12525 mcast_addr_cmd, "mcast_addr"); 12526 cmdline_parse_token_string_t cmd_mcast_addr_what = 12527 TOKEN_STRING_INITIALIZER(struct cmd_mcast_addr_result, what, 12528 "add#remove"); 12529 cmdline_parse_token_num_t cmd_mcast_addr_portnum = 12530 TOKEN_NUM_INITIALIZER(struct cmd_mcast_addr_result, port_num, UINT16); 12531 cmdline_parse_token_etheraddr_t cmd_mcast_addr_addr = 12532 TOKEN_ETHERADDR_INITIALIZER(struct cmd_mac_addr_result, address); 12533 12534 cmdline_parse_inst_t cmd_mcast_addr = { 12535 .f = cmd_mcast_addr_parsed, 12536 .data = (void *)0, 12537 .help_str = "mcast_addr add|remove <port_id> <mcast_addr>: " 12538 "Add/Remove multicast MAC address on port_id", 12539 .tokens = { 12540 (void *)&cmd_mcast_addr_cmd, 12541 (void *)&cmd_mcast_addr_what, 12542 (void *)&cmd_mcast_addr_portnum, 12543 (void *)&cmd_mcast_addr_addr, 12544 NULL, 12545 }, 12546 }; 12547 12548 /* l2 tunnel config 12549 * only support E-tag now. 12550 */ 12551 12552 /* Ether type config */ 12553 struct cmd_config_l2_tunnel_eth_type_result { 12554 cmdline_fixed_string_t port; 12555 cmdline_fixed_string_t config; 12556 cmdline_fixed_string_t all; 12557 portid_t id; 12558 cmdline_fixed_string_t l2_tunnel; 12559 cmdline_fixed_string_t l2_tunnel_type; 12560 cmdline_fixed_string_t eth_type; 12561 uint16_t eth_type_val; 12562 }; 12563 12564 cmdline_parse_token_string_t cmd_config_l2_tunnel_eth_type_port = 12565 TOKEN_STRING_INITIALIZER 12566 (struct cmd_config_l2_tunnel_eth_type_result, 12567 port, "port"); 12568 cmdline_parse_token_string_t cmd_config_l2_tunnel_eth_type_config = 12569 TOKEN_STRING_INITIALIZER 12570 (struct cmd_config_l2_tunnel_eth_type_result, 12571 config, "config"); 12572 cmdline_parse_token_string_t cmd_config_l2_tunnel_eth_type_all_str = 12573 TOKEN_STRING_INITIALIZER 12574 (struct cmd_config_l2_tunnel_eth_type_result, 12575 all, "all"); 12576 cmdline_parse_token_num_t cmd_config_l2_tunnel_eth_type_id = 12577 TOKEN_NUM_INITIALIZER 12578 (struct cmd_config_l2_tunnel_eth_type_result, 12579 id, UINT16); 12580 cmdline_parse_token_string_t cmd_config_l2_tunnel_eth_type_l2_tunnel = 12581 TOKEN_STRING_INITIALIZER 12582 (struct cmd_config_l2_tunnel_eth_type_result, 12583 l2_tunnel, "l2-tunnel"); 12584 cmdline_parse_token_string_t cmd_config_l2_tunnel_eth_type_l2_tunnel_type = 12585 TOKEN_STRING_INITIALIZER 12586 (struct cmd_config_l2_tunnel_eth_type_result, 12587 l2_tunnel_type, "E-tag"); 12588 cmdline_parse_token_string_t cmd_config_l2_tunnel_eth_type_eth_type = 12589 TOKEN_STRING_INITIALIZER 12590 (struct cmd_config_l2_tunnel_eth_type_result, 12591 eth_type, "ether-type"); 12592 cmdline_parse_token_num_t cmd_config_l2_tunnel_eth_type_eth_type_val = 12593 TOKEN_NUM_INITIALIZER 12594 (struct cmd_config_l2_tunnel_eth_type_result, 12595 eth_type_val, UINT16); 12596 12597 static enum rte_eth_tunnel_type 12598 str2fdir_l2_tunnel_type(char *string) 12599 { 12600 uint32_t i = 0; 12601 12602 static const struct { 12603 char str[32]; 12604 enum rte_eth_tunnel_type type; 12605 } l2_tunnel_type_str[] = { 12606 {"E-tag", RTE_L2_TUNNEL_TYPE_E_TAG}, 12607 }; 12608 12609 for (i = 0; i < RTE_DIM(l2_tunnel_type_str); i++) { 12610 if (!strcmp(l2_tunnel_type_str[i].str, string)) 12611 return l2_tunnel_type_str[i].type; 12612 } 12613 return RTE_TUNNEL_TYPE_NONE; 12614 } 12615 12616 /* ether type config for all ports */ 12617 static void 12618 cmd_config_l2_tunnel_eth_type_all_parsed 12619 (void *parsed_result, 12620 __attribute__((unused)) struct cmdline *cl, 12621 __attribute__((unused)) void *data) 12622 { 12623 struct cmd_config_l2_tunnel_eth_type_result *res = parsed_result; 12624 struct rte_eth_l2_tunnel_conf entry; 12625 portid_t pid; 12626 12627 entry.l2_tunnel_type = str2fdir_l2_tunnel_type(res->l2_tunnel_type); 12628 entry.ether_type = res->eth_type_val; 12629 12630 RTE_ETH_FOREACH_DEV(pid) { 12631 rte_eth_dev_l2_tunnel_eth_type_conf(pid, &entry); 12632 } 12633 } 12634 12635 cmdline_parse_inst_t cmd_config_l2_tunnel_eth_type_all = { 12636 .f = cmd_config_l2_tunnel_eth_type_all_parsed, 12637 .data = NULL, 12638 .help_str = "port config all l2-tunnel E-tag ether-type <value>", 12639 .tokens = { 12640 (void *)&cmd_config_l2_tunnel_eth_type_port, 12641 (void *)&cmd_config_l2_tunnel_eth_type_config, 12642 (void *)&cmd_config_l2_tunnel_eth_type_all_str, 12643 (void *)&cmd_config_l2_tunnel_eth_type_l2_tunnel, 12644 (void *)&cmd_config_l2_tunnel_eth_type_l2_tunnel_type, 12645 (void *)&cmd_config_l2_tunnel_eth_type_eth_type, 12646 (void *)&cmd_config_l2_tunnel_eth_type_eth_type_val, 12647 NULL, 12648 }, 12649 }; 12650 12651 /* ether type config for a specific port */ 12652 static void 12653 cmd_config_l2_tunnel_eth_type_specific_parsed( 12654 void *parsed_result, 12655 __attribute__((unused)) struct cmdline *cl, 12656 __attribute__((unused)) void *data) 12657 { 12658 struct cmd_config_l2_tunnel_eth_type_result *res = 12659 parsed_result; 12660 struct rte_eth_l2_tunnel_conf entry; 12661 12662 if (port_id_is_invalid(res->id, ENABLED_WARN)) 12663 return; 12664 12665 entry.l2_tunnel_type = str2fdir_l2_tunnel_type(res->l2_tunnel_type); 12666 entry.ether_type = res->eth_type_val; 12667 12668 rte_eth_dev_l2_tunnel_eth_type_conf(res->id, &entry); 12669 } 12670 12671 cmdline_parse_inst_t cmd_config_l2_tunnel_eth_type_specific = { 12672 .f = cmd_config_l2_tunnel_eth_type_specific_parsed, 12673 .data = NULL, 12674 .help_str = "port config <port_id> l2-tunnel E-tag ether-type <value>", 12675 .tokens = { 12676 (void *)&cmd_config_l2_tunnel_eth_type_port, 12677 (void *)&cmd_config_l2_tunnel_eth_type_config, 12678 (void *)&cmd_config_l2_tunnel_eth_type_id, 12679 (void *)&cmd_config_l2_tunnel_eth_type_l2_tunnel, 12680 (void *)&cmd_config_l2_tunnel_eth_type_l2_tunnel_type, 12681 (void *)&cmd_config_l2_tunnel_eth_type_eth_type, 12682 (void *)&cmd_config_l2_tunnel_eth_type_eth_type_val, 12683 NULL, 12684 }, 12685 }; 12686 12687 /* Enable/disable l2 tunnel */ 12688 struct cmd_config_l2_tunnel_en_dis_result { 12689 cmdline_fixed_string_t port; 12690 cmdline_fixed_string_t config; 12691 cmdline_fixed_string_t all; 12692 portid_t id; 12693 cmdline_fixed_string_t l2_tunnel; 12694 cmdline_fixed_string_t l2_tunnel_type; 12695 cmdline_fixed_string_t en_dis; 12696 }; 12697 12698 cmdline_parse_token_string_t cmd_config_l2_tunnel_en_dis_port = 12699 TOKEN_STRING_INITIALIZER 12700 (struct cmd_config_l2_tunnel_en_dis_result, 12701 port, "port"); 12702 cmdline_parse_token_string_t cmd_config_l2_tunnel_en_dis_config = 12703 TOKEN_STRING_INITIALIZER 12704 (struct cmd_config_l2_tunnel_en_dis_result, 12705 config, "config"); 12706 cmdline_parse_token_string_t cmd_config_l2_tunnel_en_dis_all_str = 12707 TOKEN_STRING_INITIALIZER 12708 (struct cmd_config_l2_tunnel_en_dis_result, 12709 all, "all"); 12710 cmdline_parse_token_num_t cmd_config_l2_tunnel_en_dis_id = 12711 TOKEN_NUM_INITIALIZER 12712 (struct cmd_config_l2_tunnel_en_dis_result, 12713 id, UINT16); 12714 cmdline_parse_token_string_t cmd_config_l2_tunnel_en_dis_l2_tunnel = 12715 TOKEN_STRING_INITIALIZER 12716 (struct cmd_config_l2_tunnel_en_dis_result, 12717 l2_tunnel, "l2-tunnel"); 12718 cmdline_parse_token_string_t cmd_config_l2_tunnel_en_dis_l2_tunnel_type = 12719 TOKEN_STRING_INITIALIZER 12720 (struct cmd_config_l2_tunnel_en_dis_result, 12721 l2_tunnel_type, "E-tag"); 12722 cmdline_parse_token_string_t cmd_config_l2_tunnel_en_dis_en_dis = 12723 TOKEN_STRING_INITIALIZER 12724 (struct cmd_config_l2_tunnel_en_dis_result, 12725 en_dis, "enable#disable"); 12726 12727 /* enable/disable l2 tunnel for all ports */ 12728 static void 12729 cmd_config_l2_tunnel_en_dis_all_parsed( 12730 void *parsed_result, 12731 __attribute__((unused)) struct cmdline *cl, 12732 __attribute__((unused)) void *data) 12733 { 12734 struct cmd_config_l2_tunnel_en_dis_result *res = parsed_result; 12735 struct rte_eth_l2_tunnel_conf entry; 12736 portid_t pid; 12737 uint8_t en; 12738 12739 entry.l2_tunnel_type = str2fdir_l2_tunnel_type(res->l2_tunnel_type); 12740 12741 if (!strcmp("enable", res->en_dis)) 12742 en = 1; 12743 else 12744 en = 0; 12745 12746 RTE_ETH_FOREACH_DEV(pid) { 12747 rte_eth_dev_l2_tunnel_offload_set(pid, 12748 &entry, 12749 ETH_L2_TUNNEL_ENABLE_MASK, 12750 en); 12751 } 12752 } 12753 12754 cmdline_parse_inst_t cmd_config_l2_tunnel_en_dis_all = { 12755 .f = cmd_config_l2_tunnel_en_dis_all_parsed, 12756 .data = NULL, 12757 .help_str = "port config all l2-tunnel E-tag enable|disable", 12758 .tokens = { 12759 (void *)&cmd_config_l2_tunnel_en_dis_port, 12760 (void *)&cmd_config_l2_tunnel_en_dis_config, 12761 (void *)&cmd_config_l2_tunnel_en_dis_all_str, 12762 (void *)&cmd_config_l2_tunnel_en_dis_l2_tunnel, 12763 (void *)&cmd_config_l2_tunnel_en_dis_l2_tunnel_type, 12764 (void *)&cmd_config_l2_tunnel_en_dis_en_dis, 12765 NULL, 12766 }, 12767 }; 12768 12769 /* enable/disable l2 tunnel for a port */ 12770 static void 12771 cmd_config_l2_tunnel_en_dis_specific_parsed( 12772 void *parsed_result, 12773 __attribute__((unused)) struct cmdline *cl, 12774 __attribute__((unused)) void *data) 12775 { 12776 struct cmd_config_l2_tunnel_en_dis_result *res = 12777 parsed_result; 12778 struct rte_eth_l2_tunnel_conf entry; 12779 12780 if (port_id_is_invalid(res->id, ENABLED_WARN)) 12781 return; 12782 12783 entry.l2_tunnel_type = str2fdir_l2_tunnel_type(res->l2_tunnel_type); 12784 12785 if (!strcmp("enable", res->en_dis)) 12786 rte_eth_dev_l2_tunnel_offload_set(res->id, 12787 &entry, 12788 ETH_L2_TUNNEL_ENABLE_MASK, 12789 1); 12790 else 12791 rte_eth_dev_l2_tunnel_offload_set(res->id, 12792 &entry, 12793 ETH_L2_TUNNEL_ENABLE_MASK, 12794 0); 12795 } 12796 12797 cmdline_parse_inst_t cmd_config_l2_tunnel_en_dis_specific = { 12798 .f = cmd_config_l2_tunnel_en_dis_specific_parsed, 12799 .data = NULL, 12800 .help_str = "port config <port_id> l2-tunnel E-tag enable|disable", 12801 .tokens = { 12802 (void *)&cmd_config_l2_tunnel_en_dis_port, 12803 (void *)&cmd_config_l2_tunnel_en_dis_config, 12804 (void *)&cmd_config_l2_tunnel_en_dis_id, 12805 (void *)&cmd_config_l2_tunnel_en_dis_l2_tunnel, 12806 (void *)&cmd_config_l2_tunnel_en_dis_l2_tunnel_type, 12807 (void *)&cmd_config_l2_tunnel_en_dis_en_dis, 12808 NULL, 12809 }, 12810 }; 12811 12812 /* E-tag configuration */ 12813 12814 /* Common result structure for all E-tag configuration */ 12815 struct cmd_config_e_tag_result { 12816 cmdline_fixed_string_t e_tag; 12817 cmdline_fixed_string_t set; 12818 cmdline_fixed_string_t insertion; 12819 cmdline_fixed_string_t stripping; 12820 cmdline_fixed_string_t forwarding; 12821 cmdline_fixed_string_t filter; 12822 cmdline_fixed_string_t add; 12823 cmdline_fixed_string_t del; 12824 cmdline_fixed_string_t on; 12825 cmdline_fixed_string_t off; 12826 cmdline_fixed_string_t on_off; 12827 cmdline_fixed_string_t port_tag_id; 12828 uint32_t port_tag_id_val; 12829 cmdline_fixed_string_t e_tag_id; 12830 uint16_t e_tag_id_val; 12831 cmdline_fixed_string_t dst_pool; 12832 uint8_t dst_pool_val; 12833 cmdline_fixed_string_t port; 12834 portid_t port_id; 12835 cmdline_fixed_string_t vf; 12836 uint8_t vf_id; 12837 }; 12838 12839 /* Common CLI fields for all E-tag configuration */ 12840 cmdline_parse_token_string_t cmd_config_e_tag_e_tag = 12841 TOKEN_STRING_INITIALIZER 12842 (struct cmd_config_e_tag_result, 12843 e_tag, "E-tag"); 12844 cmdline_parse_token_string_t cmd_config_e_tag_set = 12845 TOKEN_STRING_INITIALIZER 12846 (struct cmd_config_e_tag_result, 12847 set, "set"); 12848 cmdline_parse_token_string_t cmd_config_e_tag_insertion = 12849 TOKEN_STRING_INITIALIZER 12850 (struct cmd_config_e_tag_result, 12851 insertion, "insertion"); 12852 cmdline_parse_token_string_t cmd_config_e_tag_stripping = 12853 TOKEN_STRING_INITIALIZER 12854 (struct cmd_config_e_tag_result, 12855 stripping, "stripping"); 12856 cmdline_parse_token_string_t cmd_config_e_tag_forwarding = 12857 TOKEN_STRING_INITIALIZER 12858 (struct cmd_config_e_tag_result, 12859 forwarding, "forwarding"); 12860 cmdline_parse_token_string_t cmd_config_e_tag_filter = 12861 TOKEN_STRING_INITIALIZER 12862 (struct cmd_config_e_tag_result, 12863 filter, "filter"); 12864 cmdline_parse_token_string_t cmd_config_e_tag_add = 12865 TOKEN_STRING_INITIALIZER 12866 (struct cmd_config_e_tag_result, 12867 add, "add"); 12868 cmdline_parse_token_string_t cmd_config_e_tag_del = 12869 TOKEN_STRING_INITIALIZER 12870 (struct cmd_config_e_tag_result, 12871 del, "del"); 12872 cmdline_parse_token_string_t cmd_config_e_tag_on = 12873 TOKEN_STRING_INITIALIZER 12874 (struct cmd_config_e_tag_result, 12875 on, "on"); 12876 cmdline_parse_token_string_t cmd_config_e_tag_off = 12877 TOKEN_STRING_INITIALIZER 12878 (struct cmd_config_e_tag_result, 12879 off, "off"); 12880 cmdline_parse_token_string_t cmd_config_e_tag_on_off = 12881 TOKEN_STRING_INITIALIZER 12882 (struct cmd_config_e_tag_result, 12883 on_off, "on#off"); 12884 cmdline_parse_token_string_t cmd_config_e_tag_port_tag_id = 12885 TOKEN_STRING_INITIALIZER 12886 (struct cmd_config_e_tag_result, 12887 port_tag_id, "port-tag-id"); 12888 cmdline_parse_token_num_t cmd_config_e_tag_port_tag_id_val = 12889 TOKEN_NUM_INITIALIZER 12890 (struct cmd_config_e_tag_result, 12891 port_tag_id_val, UINT32); 12892 cmdline_parse_token_string_t cmd_config_e_tag_e_tag_id = 12893 TOKEN_STRING_INITIALIZER 12894 (struct cmd_config_e_tag_result, 12895 e_tag_id, "e-tag-id"); 12896 cmdline_parse_token_num_t cmd_config_e_tag_e_tag_id_val = 12897 TOKEN_NUM_INITIALIZER 12898 (struct cmd_config_e_tag_result, 12899 e_tag_id_val, UINT16); 12900 cmdline_parse_token_string_t cmd_config_e_tag_dst_pool = 12901 TOKEN_STRING_INITIALIZER 12902 (struct cmd_config_e_tag_result, 12903 dst_pool, "dst-pool"); 12904 cmdline_parse_token_num_t cmd_config_e_tag_dst_pool_val = 12905 TOKEN_NUM_INITIALIZER 12906 (struct cmd_config_e_tag_result, 12907 dst_pool_val, UINT8); 12908 cmdline_parse_token_string_t cmd_config_e_tag_port = 12909 TOKEN_STRING_INITIALIZER 12910 (struct cmd_config_e_tag_result, 12911 port, "port"); 12912 cmdline_parse_token_num_t cmd_config_e_tag_port_id = 12913 TOKEN_NUM_INITIALIZER 12914 (struct cmd_config_e_tag_result, 12915 port_id, UINT16); 12916 cmdline_parse_token_string_t cmd_config_e_tag_vf = 12917 TOKEN_STRING_INITIALIZER 12918 (struct cmd_config_e_tag_result, 12919 vf, "vf"); 12920 cmdline_parse_token_num_t cmd_config_e_tag_vf_id = 12921 TOKEN_NUM_INITIALIZER 12922 (struct cmd_config_e_tag_result, 12923 vf_id, UINT8); 12924 12925 /* E-tag insertion configuration */ 12926 static void 12927 cmd_config_e_tag_insertion_en_parsed( 12928 void *parsed_result, 12929 __attribute__((unused)) struct cmdline *cl, 12930 __attribute__((unused)) void *data) 12931 { 12932 struct cmd_config_e_tag_result *res = 12933 parsed_result; 12934 struct rte_eth_l2_tunnel_conf entry; 12935 12936 if (port_id_is_invalid(res->port_id, ENABLED_WARN)) 12937 return; 12938 12939 entry.l2_tunnel_type = RTE_L2_TUNNEL_TYPE_E_TAG; 12940 entry.tunnel_id = res->port_tag_id_val; 12941 entry.vf_id = res->vf_id; 12942 rte_eth_dev_l2_tunnel_offload_set(res->port_id, 12943 &entry, 12944 ETH_L2_TUNNEL_INSERTION_MASK, 12945 1); 12946 } 12947 12948 static void 12949 cmd_config_e_tag_insertion_dis_parsed( 12950 void *parsed_result, 12951 __attribute__((unused)) struct cmdline *cl, 12952 __attribute__((unused)) void *data) 12953 { 12954 struct cmd_config_e_tag_result *res = 12955 parsed_result; 12956 struct rte_eth_l2_tunnel_conf entry; 12957 12958 if (port_id_is_invalid(res->port_id, ENABLED_WARN)) 12959 return; 12960 12961 entry.l2_tunnel_type = RTE_L2_TUNNEL_TYPE_E_TAG; 12962 entry.vf_id = res->vf_id; 12963 12964 rte_eth_dev_l2_tunnel_offload_set(res->port_id, 12965 &entry, 12966 ETH_L2_TUNNEL_INSERTION_MASK, 12967 0); 12968 } 12969 12970 cmdline_parse_inst_t cmd_config_e_tag_insertion_en = { 12971 .f = cmd_config_e_tag_insertion_en_parsed, 12972 .data = NULL, 12973 .help_str = "E-tag ... : E-tag insertion enable", 12974 .tokens = { 12975 (void *)&cmd_config_e_tag_e_tag, 12976 (void *)&cmd_config_e_tag_set, 12977 (void *)&cmd_config_e_tag_insertion, 12978 (void *)&cmd_config_e_tag_on, 12979 (void *)&cmd_config_e_tag_port_tag_id, 12980 (void *)&cmd_config_e_tag_port_tag_id_val, 12981 (void *)&cmd_config_e_tag_port, 12982 (void *)&cmd_config_e_tag_port_id, 12983 (void *)&cmd_config_e_tag_vf, 12984 (void *)&cmd_config_e_tag_vf_id, 12985 NULL, 12986 }, 12987 }; 12988 12989 cmdline_parse_inst_t cmd_config_e_tag_insertion_dis = { 12990 .f = cmd_config_e_tag_insertion_dis_parsed, 12991 .data = NULL, 12992 .help_str = "E-tag ... : E-tag insertion disable", 12993 .tokens = { 12994 (void *)&cmd_config_e_tag_e_tag, 12995 (void *)&cmd_config_e_tag_set, 12996 (void *)&cmd_config_e_tag_insertion, 12997 (void *)&cmd_config_e_tag_off, 12998 (void *)&cmd_config_e_tag_port, 12999 (void *)&cmd_config_e_tag_port_id, 13000 (void *)&cmd_config_e_tag_vf, 13001 (void *)&cmd_config_e_tag_vf_id, 13002 NULL, 13003 }, 13004 }; 13005 13006 /* E-tag stripping configuration */ 13007 static void 13008 cmd_config_e_tag_stripping_parsed( 13009 void *parsed_result, 13010 __attribute__((unused)) struct cmdline *cl, 13011 __attribute__((unused)) void *data) 13012 { 13013 struct cmd_config_e_tag_result *res = 13014 parsed_result; 13015 struct rte_eth_l2_tunnel_conf entry; 13016 13017 if (port_id_is_invalid(res->port_id, ENABLED_WARN)) 13018 return; 13019 13020 entry.l2_tunnel_type = RTE_L2_TUNNEL_TYPE_E_TAG; 13021 13022 if (!strcmp(res->on_off, "on")) 13023 rte_eth_dev_l2_tunnel_offload_set 13024 (res->port_id, 13025 &entry, 13026 ETH_L2_TUNNEL_STRIPPING_MASK, 13027 1); 13028 else 13029 rte_eth_dev_l2_tunnel_offload_set 13030 (res->port_id, 13031 &entry, 13032 ETH_L2_TUNNEL_STRIPPING_MASK, 13033 0); 13034 } 13035 13036 cmdline_parse_inst_t cmd_config_e_tag_stripping_en_dis = { 13037 .f = cmd_config_e_tag_stripping_parsed, 13038 .data = NULL, 13039 .help_str = "E-tag ... : E-tag stripping enable/disable", 13040 .tokens = { 13041 (void *)&cmd_config_e_tag_e_tag, 13042 (void *)&cmd_config_e_tag_set, 13043 (void *)&cmd_config_e_tag_stripping, 13044 (void *)&cmd_config_e_tag_on_off, 13045 (void *)&cmd_config_e_tag_port, 13046 (void *)&cmd_config_e_tag_port_id, 13047 NULL, 13048 }, 13049 }; 13050 13051 /* E-tag forwarding configuration */ 13052 static void 13053 cmd_config_e_tag_forwarding_parsed( 13054 void *parsed_result, 13055 __attribute__((unused)) struct cmdline *cl, 13056 __attribute__((unused)) void *data) 13057 { 13058 struct cmd_config_e_tag_result *res = parsed_result; 13059 struct rte_eth_l2_tunnel_conf entry; 13060 13061 if (port_id_is_invalid(res->port_id, ENABLED_WARN)) 13062 return; 13063 13064 entry.l2_tunnel_type = RTE_L2_TUNNEL_TYPE_E_TAG; 13065 13066 if (!strcmp(res->on_off, "on")) 13067 rte_eth_dev_l2_tunnel_offload_set 13068 (res->port_id, 13069 &entry, 13070 ETH_L2_TUNNEL_FORWARDING_MASK, 13071 1); 13072 else 13073 rte_eth_dev_l2_tunnel_offload_set 13074 (res->port_id, 13075 &entry, 13076 ETH_L2_TUNNEL_FORWARDING_MASK, 13077 0); 13078 } 13079 13080 cmdline_parse_inst_t cmd_config_e_tag_forwarding_en_dis = { 13081 .f = cmd_config_e_tag_forwarding_parsed, 13082 .data = NULL, 13083 .help_str = "E-tag ... : E-tag forwarding enable/disable", 13084 .tokens = { 13085 (void *)&cmd_config_e_tag_e_tag, 13086 (void *)&cmd_config_e_tag_set, 13087 (void *)&cmd_config_e_tag_forwarding, 13088 (void *)&cmd_config_e_tag_on_off, 13089 (void *)&cmd_config_e_tag_port, 13090 (void *)&cmd_config_e_tag_port_id, 13091 NULL, 13092 }, 13093 }; 13094 13095 /* E-tag filter configuration */ 13096 static void 13097 cmd_config_e_tag_filter_add_parsed( 13098 void *parsed_result, 13099 __attribute__((unused)) struct cmdline *cl, 13100 __attribute__((unused)) void *data) 13101 { 13102 struct cmd_config_e_tag_result *res = parsed_result; 13103 struct rte_eth_l2_tunnel_conf entry; 13104 int ret = 0; 13105 13106 if (port_id_is_invalid(res->port_id, ENABLED_WARN)) 13107 return; 13108 13109 if (res->e_tag_id_val > 0x3fff) { 13110 printf("e-tag-id must be equal or less than 0x3fff.\n"); 13111 return; 13112 } 13113 13114 ret = rte_eth_dev_filter_supported(res->port_id, 13115 RTE_ETH_FILTER_L2_TUNNEL); 13116 if (ret < 0) { 13117 printf("E-tag filter is not supported on port %u.\n", 13118 res->port_id); 13119 return; 13120 } 13121 13122 entry.l2_tunnel_type = RTE_L2_TUNNEL_TYPE_E_TAG; 13123 entry.tunnel_id = res->e_tag_id_val; 13124 entry.pool = res->dst_pool_val; 13125 13126 ret = rte_eth_dev_filter_ctrl(res->port_id, 13127 RTE_ETH_FILTER_L2_TUNNEL, 13128 RTE_ETH_FILTER_ADD, 13129 &entry); 13130 if (ret < 0) 13131 printf("E-tag filter programming error: (%s)\n", 13132 strerror(-ret)); 13133 } 13134 13135 cmdline_parse_inst_t cmd_config_e_tag_filter_add = { 13136 .f = cmd_config_e_tag_filter_add_parsed, 13137 .data = NULL, 13138 .help_str = "E-tag ... : E-tag filter add", 13139 .tokens = { 13140 (void *)&cmd_config_e_tag_e_tag, 13141 (void *)&cmd_config_e_tag_set, 13142 (void *)&cmd_config_e_tag_filter, 13143 (void *)&cmd_config_e_tag_add, 13144 (void *)&cmd_config_e_tag_e_tag_id, 13145 (void *)&cmd_config_e_tag_e_tag_id_val, 13146 (void *)&cmd_config_e_tag_dst_pool, 13147 (void *)&cmd_config_e_tag_dst_pool_val, 13148 (void *)&cmd_config_e_tag_port, 13149 (void *)&cmd_config_e_tag_port_id, 13150 NULL, 13151 }, 13152 }; 13153 13154 static void 13155 cmd_config_e_tag_filter_del_parsed( 13156 void *parsed_result, 13157 __attribute__((unused)) struct cmdline *cl, 13158 __attribute__((unused)) void *data) 13159 { 13160 struct cmd_config_e_tag_result *res = parsed_result; 13161 struct rte_eth_l2_tunnel_conf entry; 13162 int ret = 0; 13163 13164 if (port_id_is_invalid(res->port_id, ENABLED_WARN)) 13165 return; 13166 13167 if (res->e_tag_id_val > 0x3fff) { 13168 printf("e-tag-id must be less than 0x3fff.\n"); 13169 return; 13170 } 13171 13172 ret = rte_eth_dev_filter_supported(res->port_id, 13173 RTE_ETH_FILTER_L2_TUNNEL); 13174 if (ret < 0) { 13175 printf("E-tag filter is not supported on port %u.\n", 13176 res->port_id); 13177 return; 13178 } 13179 13180 entry.l2_tunnel_type = RTE_L2_TUNNEL_TYPE_E_TAG; 13181 entry.tunnel_id = res->e_tag_id_val; 13182 13183 ret = rte_eth_dev_filter_ctrl(res->port_id, 13184 RTE_ETH_FILTER_L2_TUNNEL, 13185 RTE_ETH_FILTER_DELETE, 13186 &entry); 13187 if (ret < 0) 13188 printf("E-tag filter programming error: (%s)\n", 13189 strerror(-ret)); 13190 } 13191 13192 cmdline_parse_inst_t cmd_config_e_tag_filter_del = { 13193 .f = cmd_config_e_tag_filter_del_parsed, 13194 .data = NULL, 13195 .help_str = "E-tag ... : E-tag filter delete", 13196 .tokens = { 13197 (void *)&cmd_config_e_tag_e_tag, 13198 (void *)&cmd_config_e_tag_set, 13199 (void *)&cmd_config_e_tag_filter, 13200 (void *)&cmd_config_e_tag_del, 13201 (void *)&cmd_config_e_tag_e_tag_id, 13202 (void *)&cmd_config_e_tag_e_tag_id_val, 13203 (void *)&cmd_config_e_tag_port, 13204 (void *)&cmd_config_e_tag_port_id, 13205 NULL, 13206 }, 13207 }; 13208 13209 /* vf vlan anti spoof configuration */ 13210 13211 /* Common result structure for vf vlan anti spoof */ 13212 struct cmd_vf_vlan_anti_spoof_result { 13213 cmdline_fixed_string_t set; 13214 cmdline_fixed_string_t vf; 13215 cmdline_fixed_string_t vlan; 13216 cmdline_fixed_string_t antispoof; 13217 portid_t port_id; 13218 uint32_t vf_id; 13219 cmdline_fixed_string_t on_off; 13220 }; 13221 13222 /* Common CLI fields for vf vlan anti spoof enable disable */ 13223 cmdline_parse_token_string_t cmd_vf_vlan_anti_spoof_set = 13224 TOKEN_STRING_INITIALIZER 13225 (struct cmd_vf_vlan_anti_spoof_result, 13226 set, "set"); 13227 cmdline_parse_token_string_t cmd_vf_vlan_anti_spoof_vf = 13228 TOKEN_STRING_INITIALIZER 13229 (struct cmd_vf_vlan_anti_spoof_result, 13230 vf, "vf"); 13231 cmdline_parse_token_string_t cmd_vf_vlan_anti_spoof_vlan = 13232 TOKEN_STRING_INITIALIZER 13233 (struct cmd_vf_vlan_anti_spoof_result, 13234 vlan, "vlan"); 13235 cmdline_parse_token_string_t cmd_vf_vlan_anti_spoof_antispoof = 13236 TOKEN_STRING_INITIALIZER 13237 (struct cmd_vf_vlan_anti_spoof_result, 13238 antispoof, "antispoof"); 13239 cmdline_parse_token_num_t cmd_vf_vlan_anti_spoof_port_id = 13240 TOKEN_NUM_INITIALIZER 13241 (struct cmd_vf_vlan_anti_spoof_result, 13242 port_id, UINT16); 13243 cmdline_parse_token_num_t cmd_vf_vlan_anti_spoof_vf_id = 13244 TOKEN_NUM_INITIALIZER 13245 (struct cmd_vf_vlan_anti_spoof_result, 13246 vf_id, UINT32); 13247 cmdline_parse_token_string_t cmd_vf_vlan_anti_spoof_on_off = 13248 TOKEN_STRING_INITIALIZER 13249 (struct cmd_vf_vlan_anti_spoof_result, 13250 on_off, "on#off"); 13251 13252 static void 13253 cmd_set_vf_vlan_anti_spoof_parsed( 13254 void *parsed_result, 13255 __attribute__((unused)) struct cmdline *cl, 13256 __attribute__((unused)) void *data) 13257 { 13258 struct cmd_vf_vlan_anti_spoof_result *res = parsed_result; 13259 int ret = -ENOTSUP; 13260 13261 __rte_unused int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0; 13262 13263 if (port_id_is_invalid(res->port_id, ENABLED_WARN)) 13264 return; 13265 13266 #ifdef RTE_LIBRTE_IXGBE_PMD 13267 if (ret == -ENOTSUP) 13268 ret = rte_pmd_ixgbe_set_vf_vlan_anti_spoof(res->port_id, 13269 res->vf_id, is_on); 13270 #endif 13271 #ifdef RTE_LIBRTE_I40E_PMD 13272 if (ret == -ENOTSUP) 13273 ret = rte_pmd_i40e_set_vf_vlan_anti_spoof(res->port_id, 13274 res->vf_id, is_on); 13275 #endif 13276 #ifdef RTE_LIBRTE_BNXT_PMD 13277 if (ret == -ENOTSUP) 13278 ret = rte_pmd_bnxt_set_vf_vlan_anti_spoof(res->port_id, 13279 res->vf_id, is_on); 13280 #endif 13281 13282 switch (ret) { 13283 case 0: 13284 break; 13285 case -EINVAL: 13286 printf("invalid vf_id %d\n", res->vf_id); 13287 break; 13288 case -ENODEV: 13289 printf("invalid port_id %d\n", res->port_id); 13290 break; 13291 case -ENOTSUP: 13292 printf("function not implemented\n"); 13293 break; 13294 default: 13295 printf("programming error: (%s)\n", strerror(-ret)); 13296 } 13297 } 13298 13299 cmdline_parse_inst_t cmd_set_vf_vlan_anti_spoof = { 13300 .f = cmd_set_vf_vlan_anti_spoof_parsed, 13301 .data = NULL, 13302 .help_str = "set vf vlan antispoof <port_id> <vf_id> on|off", 13303 .tokens = { 13304 (void *)&cmd_vf_vlan_anti_spoof_set, 13305 (void *)&cmd_vf_vlan_anti_spoof_vf, 13306 (void *)&cmd_vf_vlan_anti_spoof_vlan, 13307 (void *)&cmd_vf_vlan_anti_spoof_antispoof, 13308 (void *)&cmd_vf_vlan_anti_spoof_port_id, 13309 (void *)&cmd_vf_vlan_anti_spoof_vf_id, 13310 (void *)&cmd_vf_vlan_anti_spoof_on_off, 13311 NULL, 13312 }, 13313 }; 13314 13315 /* vf mac anti spoof configuration */ 13316 13317 /* Common result structure for vf mac anti spoof */ 13318 struct cmd_vf_mac_anti_spoof_result { 13319 cmdline_fixed_string_t set; 13320 cmdline_fixed_string_t vf; 13321 cmdline_fixed_string_t mac; 13322 cmdline_fixed_string_t antispoof; 13323 portid_t port_id; 13324 uint32_t vf_id; 13325 cmdline_fixed_string_t on_off; 13326 }; 13327 13328 /* Common CLI fields for vf mac anti spoof enable disable */ 13329 cmdline_parse_token_string_t cmd_vf_mac_anti_spoof_set = 13330 TOKEN_STRING_INITIALIZER 13331 (struct cmd_vf_mac_anti_spoof_result, 13332 set, "set"); 13333 cmdline_parse_token_string_t cmd_vf_mac_anti_spoof_vf = 13334 TOKEN_STRING_INITIALIZER 13335 (struct cmd_vf_mac_anti_spoof_result, 13336 vf, "vf"); 13337 cmdline_parse_token_string_t cmd_vf_mac_anti_spoof_mac = 13338 TOKEN_STRING_INITIALIZER 13339 (struct cmd_vf_mac_anti_spoof_result, 13340 mac, "mac"); 13341 cmdline_parse_token_string_t cmd_vf_mac_anti_spoof_antispoof = 13342 TOKEN_STRING_INITIALIZER 13343 (struct cmd_vf_mac_anti_spoof_result, 13344 antispoof, "antispoof"); 13345 cmdline_parse_token_num_t cmd_vf_mac_anti_spoof_port_id = 13346 TOKEN_NUM_INITIALIZER 13347 (struct cmd_vf_mac_anti_spoof_result, 13348 port_id, UINT16); 13349 cmdline_parse_token_num_t cmd_vf_mac_anti_spoof_vf_id = 13350 TOKEN_NUM_INITIALIZER 13351 (struct cmd_vf_mac_anti_spoof_result, 13352 vf_id, UINT32); 13353 cmdline_parse_token_string_t cmd_vf_mac_anti_spoof_on_off = 13354 TOKEN_STRING_INITIALIZER 13355 (struct cmd_vf_mac_anti_spoof_result, 13356 on_off, "on#off"); 13357 13358 static void 13359 cmd_set_vf_mac_anti_spoof_parsed( 13360 void *parsed_result, 13361 __attribute__((unused)) struct cmdline *cl, 13362 __attribute__((unused)) void *data) 13363 { 13364 struct cmd_vf_mac_anti_spoof_result *res = parsed_result; 13365 int ret = -ENOTSUP; 13366 13367 __rte_unused int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0; 13368 13369 if (port_id_is_invalid(res->port_id, ENABLED_WARN)) 13370 return; 13371 13372 #ifdef RTE_LIBRTE_IXGBE_PMD 13373 if (ret == -ENOTSUP) 13374 ret = rte_pmd_ixgbe_set_vf_mac_anti_spoof(res->port_id, 13375 res->vf_id, is_on); 13376 #endif 13377 #ifdef RTE_LIBRTE_I40E_PMD 13378 if (ret == -ENOTSUP) 13379 ret = rte_pmd_i40e_set_vf_mac_anti_spoof(res->port_id, 13380 res->vf_id, is_on); 13381 #endif 13382 #ifdef RTE_LIBRTE_BNXT_PMD 13383 if (ret == -ENOTSUP) 13384 ret = rte_pmd_bnxt_set_vf_mac_anti_spoof(res->port_id, 13385 res->vf_id, is_on); 13386 #endif 13387 13388 switch (ret) { 13389 case 0: 13390 break; 13391 case -EINVAL: 13392 printf("invalid vf_id %d or is_on %d\n", res->vf_id, is_on); 13393 break; 13394 case -ENODEV: 13395 printf("invalid port_id %d\n", res->port_id); 13396 break; 13397 case -ENOTSUP: 13398 printf("function not implemented\n"); 13399 break; 13400 default: 13401 printf("programming error: (%s)\n", strerror(-ret)); 13402 } 13403 } 13404 13405 cmdline_parse_inst_t cmd_set_vf_mac_anti_spoof = { 13406 .f = cmd_set_vf_mac_anti_spoof_parsed, 13407 .data = NULL, 13408 .help_str = "set vf mac antispoof <port_id> <vf_id> on|off", 13409 .tokens = { 13410 (void *)&cmd_vf_mac_anti_spoof_set, 13411 (void *)&cmd_vf_mac_anti_spoof_vf, 13412 (void *)&cmd_vf_mac_anti_spoof_mac, 13413 (void *)&cmd_vf_mac_anti_spoof_antispoof, 13414 (void *)&cmd_vf_mac_anti_spoof_port_id, 13415 (void *)&cmd_vf_mac_anti_spoof_vf_id, 13416 (void *)&cmd_vf_mac_anti_spoof_on_off, 13417 NULL, 13418 }, 13419 }; 13420 13421 /* vf vlan strip queue configuration */ 13422 13423 /* Common result structure for vf mac anti spoof */ 13424 struct cmd_vf_vlan_stripq_result { 13425 cmdline_fixed_string_t set; 13426 cmdline_fixed_string_t vf; 13427 cmdline_fixed_string_t vlan; 13428 cmdline_fixed_string_t stripq; 13429 portid_t port_id; 13430 uint16_t vf_id; 13431 cmdline_fixed_string_t on_off; 13432 }; 13433 13434 /* Common CLI fields for vf vlan strip enable disable */ 13435 cmdline_parse_token_string_t cmd_vf_vlan_stripq_set = 13436 TOKEN_STRING_INITIALIZER 13437 (struct cmd_vf_vlan_stripq_result, 13438 set, "set"); 13439 cmdline_parse_token_string_t cmd_vf_vlan_stripq_vf = 13440 TOKEN_STRING_INITIALIZER 13441 (struct cmd_vf_vlan_stripq_result, 13442 vf, "vf"); 13443 cmdline_parse_token_string_t cmd_vf_vlan_stripq_vlan = 13444 TOKEN_STRING_INITIALIZER 13445 (struct cmd_vf_vlan_stripq_result, 13446 vlan, "vlan"); 13447 cmdline_parse_token_string_t cmd_vf_vlan_stripq_stripq = 13448 TOKEN_STRING_INITIALIZER 13449 (struct cmd_vf_vlan_stripq_result, 13450 stripq, "stripq"); 13451 cmdline_parse_token_num_t cmd_vf_vlan_stripq_port_id = 13452 TOKEN_NUM_INITIALIZER 13453 (struct cmd_vf_vlan_stripq_result, 13454 port_id, UINT16); 13455 cmdline_parse_token_num_t cmd_vf_vlan_stripq_vf_id = 13456 TOKEN_NUM_INITIALIZER 13457 (struct cmd_vf_vlan_stripq_result, 13458 vf_id, UINT16); 13459 cmdline_parse_token_string_t cmd_vf_vlan_stripq_on_off = 13460 TOKEN_STRING_INITIALIZER 13461 (struct cmd_vf_vlan_stripq_result, 13462 on_off, "on#off"); 13463 13464 static void 13465 cmd_set_vf_vlan_stripq_parsed( 13466 void *parsed_result, 13467 __attribute__((unused)) struct cmdline *cl, 13468 __attribute__((unused)) void *data) 13469 { 13470 struct cmd_vf_vlan_stripq_result *res = parsed_result; 13471 int ret = -ENOTSUP; 13472 13473 __rte_unused int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0; 13474 13475 if (port_id_is_invalid(res->port_id, ENABLED_WARN)) 13476 return; 13477 13478 #ifdef RTE_LIBRTE_IXGBE_PMD 13479 if (ret == -ENOTSUP) 13480 ret = rte_pmd_ixgbe_set_vf_vlan_stripq(res->port_id, 13481 res->vf_id, is_on); 13482 #endif 13483 #ifdef RTE_LIBRTE_I40E_PMD 13484 if (ret == -ENOTSUP) 13485 ret = rte_pmd_i40e_set_vf_vlan_stripq(res->port_id, 13486 res->vf_id, is_on); 13487 #endif 13488 #ifdef RTE_LIBRTE_BNXT_PMD 13489 if (ret == -ENOTSUP) 13490 ret = rte_pmd_bnxt_set_vf_vlan_stripq(res->port_id, 13491 res->vf_id, is_on); 13492 #endif 13493 13494 switch (ret) { 13495 case 0: 13496 break; 13497 case -EINVAL: 13498 printf("invalid vf_id %d or is_on %d\n", res->vf_id, is_on); 13499 break; 13500 case -ENODEV: 13501 printf("invalid port_id %d\n", res->port_id); 13502 break; 13503 case -ENOTSUP: 13504 printf("function not implemented\n"); 13505 break; 13506 default: 13507 printf("programming error: (%s)\n", strerror(-ret)); 13508 } 13509 } 13510 13511 cmdline_parse_inst_t cmd_set_vf_vlan_stripq = { 13512 .f = cmd_set_vf_vlan_stripq_parsed, 13513 .data = NULL, 13514 .help_str = "set vf vlan stripq <port_id> <vf_id> on|off", 13515 .tokens = { 13516 (void *)&cmd_vf_vlan_stripq_set, 13517 (void *)&cmd_vf_vlan_stripq_vf, 13518 (void *)&cmd_vf_vlan_stripq_vlan, 13519 (void *)&cmd_vf_vlan_stripq_stripq, 13520 (void *)&cmd_vf_vlan_stripq_port_id, 13521 (void *)&cmd_vf_vlan_stripq_vf_id, 13522 (void *)&cmd_vf_vlan_stripq_on_off, 13523 NULL, 13524 }, 13525 }; 13526 13527 /* vf vlan insert configuration */ 13528 13529 /* Common result structure for vf vlan insert */ 13530 struct cmd_vf_vlan_insert_result { 13531 cmdline_fixed_string_t set; 13532 cmdline_fixed_string_t vf; 13533 cmdline_fixed_string_t vlan; 13534 cmdline_fixed_string_t insert; 13535 portid_t port_id; 13536 uint16_t vf_id; 13537 uint16_t vlan_id; 13538 }; 13539 13540 /* Common CLI fields for vf vlan insert enable disable */ 13541 cmdline_parse_token_string_t cmd_vf_vlan_insert_set = 13542 TOKEN_STRING_INITIALIZER 13543 (struct cmd_vf_vlan_insert_result, 13544 set, "set"); 13545 cmdline_parse_token_string_t cmd_vf_vlan_insert_vf = 13546 TOKEN_STRING_INITIALIZER 13547 (struct cmd_vf_vlan_insert_result, 13548 vf, "vf"); 13549 cmdline_parse_token_string_t cmd_vf_vlan_insert_vlan = 13550 TOKEN_STRING_INITIALIZER 13551 (struct cmd_vf_vlan_insert_result, 13552 vlan, "vlan"); 13553 cmdline_parse_token_string_t cmd_vf_vlan_insert_insert = 13554 TOKEN_STRING_INITIALIZER 13555 (struct cmd_vf_vlan_insert_result, 13556 insert, "insert"); 13557 cmdline_parse_token_num_t cmd_vf_vlan_insert_port_id = 13558 TOKEN_NUM_INITIALIZER 13559 (struct cmd_vf_vlan_insert_result, 13560 port_id, UINT16); 13561 cmdline_parse_token_num_t cmd_vf_vlan_insert_vf_id = 13562 TOKEN_NUM_INITIALIZER 13563 (struct cmd_vf_vlan_insert_result, 13564 vf_id, UINT16); 13565 cmdline_parse_token_num_t cmd_vf_vlan_insert_vlan_id = 13566 TOKEN_NUM_INITIALIZER 13567 (struct cmd_vf_vlan_insert_result, 13568 vlan_id, UINT16); 13569 13570 static void 13571 cmd_set_vf_vlan_insert_parsed( 13572 void *parsed_result, 13573 __attribute__((unused)) struct cmdline *cl, 13574 __attribute__((unused)) void *data) 13575 { 13576 struct cmd_vf_vlan_insert_result *res = parsed_result; 13577 int ret = -ENOTSUP; 13578 13579 if (port_id_is_invalid(res->port_id, ENABLED_WARN)) 13580 return; 13581 13582 #ifdef RTE_LIBRTE_IXGBE_PMD 13583 if (ret == -ENOTSUP) 13584 ret = rte_pmd_ixgbe_set_vf_vlan_insert(res->port_id, res->vf_id, 13585 res->vlan_id); 13586 #endif 13587 #ifdef RTE_LIBRTE_I40E_PMD 13588 if (ret == -ENOTSUP) 13589 ret = rte_pmd_i40e_set_vf_vlan_insert(res->port_id, res->vf_id, 13590 res->vlan_id); 13591 #endif 13592 #ifdef RTE_LIBRTE_BNXT_PMD 13593 if (ret == -ENOTSUP) 13594 ret = rte_pmd_bnxt_set_vf_vlan_insert(res->port_id, res->vf_id, 13595 res->vlan_id); 13596 #endif 13597 13598 switch (ret) { 13599 case 0: 13600 break; 13601 case -EINVAL: 13602 printf("invalid vf_id %d or vlan_id %d\n", res->vf_id, res->vlan_id); 13603 break; 13604 case -ENODEV: 13605 printf("invalid port_id %d\n", res->port_id); 13606 break; 13607 case -ENOTSUP: 13608 printf("function not implemented\n"); 13609 break; 13610 default: 13611 printf("programming error: (%s)\n", strerror(-ret)); 13612 } 13613 } 13614 13615 cmdline_parse_inst_t cmd_set_vf_vlan_insert = { 13616 .f = cmd_set_vf_vlan_insert_parsed, 13617 .data = NULL, 13618 .help_str = "set vf vlan insert <port_id> <vf_id> <vlan_id>", 13619 .tokens = { 13620 (void *)&cmd_vf_vlan_insert_set, 13621 (void *)&cmd_vf_vlan_insert_vf, 13622 (void *)&cmd_vf_vlan_insert_vlan, 13623 (void *)&cmd_vf_vlan_insert_insert, 13624 (void *)&cmd_vf_vlan_insert_port_id, 13625 (void *)&cmd_vf_vlan_insert_vf_id, 13626 (void *)&cmd_vf_vlan_insert_vlan_id, 13627 NULL, 13628 }, 13629 }; 13630 13631 /* tx loopback configuration */ 13632 13633 /* Common result structure for tx loopback */ 13634 struct cmd_tx_loopback_result { 13635 cmdline_fixed_string_t set; 13636 cmdline_fixed_string_t tx; 13637 cmdline_fixed_string_t loopback; 13638 portid_t port_id; 13639 cmdline_fixed_string_t on_off; 13640 }; 13641 13642 /* Common CLI fields for tx loopback enable disable */ 13643 cmdline_parse_token_string_t cmd_tx_loopback_set = 13644 TOKEN_STRING_INITIALIZER 13645 (struct cmd_tx_loopback_result, 13646 set, "set"); 13647 cmdline_parse_token_string_t cmd_tx_loopback_tx = 13648 TOKEN_STRING_INITIALIZER 13649 (struct cmd_tx_loopback_result, 13650 tx, "tx"); 13651 cmdline_parse_token_string_t cmd_tx_loopback_loopback = 13652 TOKEN_STRING_INITIALIZER 13653 (struct cmd_tx_loopback_result, 13654 loopback, "loopback"); 13655 cmdline_parse_token_num_t cmd_tx_loopback_port_id = 13656 TOKEN_NUM_INITIALIZER 13657 (struct cmd_tx_loopback_result, 13658 port_id, UINT16); 13659 cmdline_parse_token_string_t cmd_tx_loopback_on_off = 13660 TOKEN_STRING_INITIALIZER 13661 (struct cmd_tx_loopback_result, 13662 on_off, "on#off"); 13663 13664 static void 13665 cmd_set_tx_loopback_parsed( 13666 void *parsed_result, 13667 __attribute__((unused)) struct cmdline *cl, 13668 __attribute__((unused)) void *data) 13669 { 13670 struct cmd_tx_loopback_result *res = parsed_result; 13671 int ret = -ENOTSUP; 13672 13673 __rte_unused int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0; 13674 13675 if (port_id_is_invalid(res->port_id, ENABLED_WARN)) 13676 return; 13677 13678 #ifdef RTE_LIBRTE_IXGBE_PMD 13679 if (ret == -ENOTSUP) 13680 ret = rte_pmd_ixgbe_set_tx_loopback(res->port_id, is_on); 13681 #endif 13682 #ifdef RTE_LIBRTE_I40E_PMD 13683 if (ret == -ENOTSUP) 13684 ret = rte_pmd_i40e_set_tx_loopback(res->port_id, is_on); 13685 #endif 13686 #ifdef RTE_LIBRTE_BNXT_PMD 13687 if (ret == -ENOTSUP) 13688 ret = rte_pmd_bnxt_set_tx_loopback(res->port_id, is_on); 13689 #endif 13690 #if defined RTE_LIBRTE_DPAA_BUS && defined RTE_LIBRTE_DPAA_PMD 13691 if (ret == -ENOTSUP) 13692 ret = rte_pmd_dpaa_set_tx_loopback(res->port_id, is_on); 13693 #endif 13694 13695 switch (ret) { 13696 case 0: 13697 break; 13698 case -EINVAL: 13699 printf("invalid is_on %d\n", is_on); 13700 break; 13701 case -ENODEV: 13702 printf("invalid port_id %d\n", res->port_id); 13703 break; 13704 case -ENOTSUP: 13705 printf("function not implemented\n"); 13706 break; 13707 default: 13708 printf("programming error: (%s)\n", strerror(-ret)); 13709 } 13710 } 13711 13712 cmdline_parse_inst_t cmd_set_tx_loopback = { 13713 .f = cmd_set_tx_loopback_parsed, 13714 .data = NULL, 13715 .help_str = "set tx loopback <port_id> on|off", 13716 .tokens = { 13717 (void *)&cmd_tx_loopback_set, 13718 (void *)&cmd_tx_loopback_tx, 13719 (void *)&cmd_tx_loopback_loopback, 13720 (void *)&cmd_tx_loopback_port_id, 13721 (void *)&cmd_tx_loopback_on_off, 13722 NULL, 13723 }, 13724 }; 13725 13726 /* all queues drop enable configuration */ 13727 13728 /* Common result structure for all queues drop enable */ 13729 struct cmd_all_queues_drop_en_result { 13730 cmdline_fixed_string_t set; 13731 cmdline_fixed_string_t all; 13732 cmdline_fixed_string_t queues; 13733 cmdline_fixed_string_t drop; 13734 portid_t port_id; 13735 cmdline_fixed_string_t on_off; 13736 }; 13737 13738 /* Common CLI fields for tx loopback enable disable */ 13739 cmdline_parse_token_string_t cmd_all_queues_drop_en_set = 13740 TOKEN_STRING_INITIALIZER 13741 (struct cmd_all_queues_drop_en_result, 13742 set, "set"); 13743 cmdline_parse_token_string_t cmd_all_queues_drop_en_all = 13744 TOKEN_STRING_INITIALIZER 13745 (struct cmd_all_queues_drop_en_result, 13746 all, "all"); 13747 cmdline_parse_token_string_t cmd_all_queues_drop_en_queues = 13748 TOKEN_STRING_INITIALIZER 13749 (struct cmd_all_queues_drop_en_result, 13750 queues, "queues"); 13751 cmdline_parse_token_string_t cmd_all_queues_drop_en_drop = 13752 TOKEN_STRING_INITIALIZER 13753 (struct cmd_all_queues_drop_en_result, 13754 drop, "drop"); 13755 cmdline_parse_token_num_t cmd_all_queues_drop_en_port_id = 13756 TOKEN_NUM_INITIALIZER 13757 (struct cmd_all_queues_drop_en_result, 13758 port_id, UINT16); 13759 cmdline_parse_token_string_t cmd_all_queues_drop_en_on_off = 13760 TOKEN_STRING_INITIALIZER 13761 (struct cmd_all_queues_drop_en_result, 13762 on_off, "on#off"); 13763 13764 static void 13765 cmd_set_all_queues_drop_en_parsed( 13766 void *parsed_result, 13767 __attribute__((unused)) struct cmdline *cl, 13768 __attribute__((unused)) void *data) 13769 { 13770 struct cmd_all_queues_drop_en_result *res = parsed_result; 13771 int ret = -ENOTSUP; 13772 int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0; 13773 13774 if (port_id_is_invalid(res->port_id, ENABLED_WARN)) 13775 return; 13776 13777 #ifdef RTE_LIBRTE_IXGBE_PMD 13778 if (ret == -ENOTSUP) 13779 ret = rte_pmd_ixgbe_set_all_queues_drop_en(res->port_id, is_on); 13780 #endif 13781 #ifdef RTE_LIBRTE_BNXT_PMD 13782 if (ret == -ENOTSUP) 13783 ret = rte_pmd_bnxt_set_all_queues_drop_en(res->port_id, is_on); 13784 #endif 13785 switch (ret) { 13786 case 0: 13787 break; 13788 case -EINVAL: 13789 printf("invalid is_on %d\n", is_on); 13790 break; 13791 case -ENODEV: 13792 printf("invalid port_id %d\n", res->port_id); 13793 break; 13794 case -ENOTSUP: 13795 printf("function not implemented\n"); 13796 break; 13797 default: 13798 printf("programming error: (%s)\n", strerror(-ret)); 13799 } 13800 } 13801 13802 cmdline_parse_inst_t cmd_set_all_queues_drop_en = { 13803 .f = cmd_set_all_queues_drop_en_parsed, 13804 .data = NULL, 13805 .help_str = "set all queues drop <port_id> on|off", 13806 .tokens = { 13807 (void *)&cmd_all_queues_drop_en_set, 13808 (void *)&cmd_all_queues_drop_en_all, 13809 (void *)&cmd_all_queues_drop_en_queues, 13810 (void *)&cmd_all_queues_drop_en_drop, 13811 (void *)&cmd_all_queues_drop_en_port_id, 13812 (void *)&cmd_all_queues_drop_en_on_off, 13813 NULL, 13814 }, 13815 }; 13816 13817 /* vf split drop enable configuration */ 13818 13819 /* Common result structure for vf split drop enable */ 13820 struct cmd_vf_split_drop_en_result { 13821 cmdline_fixed_string_t set; 13822 cmdline_fixed_string_t vf; 13823 cmdline_fixed_string_t split; 13824 cmdline_fixed_string_t drop; 13825 portid_t port_id; 13826 uint16_t vf_id; 13827 cmdline_fixed_string_t on_off; 13828 }; 13829 13830 /* Common CLI fields for vf split drop enable disable */ 13831 cmdline_parse_token_string_t cmd_vf_split_drop_en_set = 13832 TOKEN_STRING_INITIALIZER 13833 (struct cmd_vf_split_drop_en_result, 13834 set, "set"); 13835 cmdline_parse_token_string_t cmd_vf_split_drop_en_vf = 13836 TOKEN_STRING_INITIALIZER 13837 (struct cmd_vf_split_drop_en_result, 13838 vf, "vf"); 13839 cmdline_parse_token_string_t cmd_vf_split_drop_en_split = 13840 TOKEN_STRING_INITIALIZER 13841 (struct cmd_vf_split_drop_en_result, 13842 split, "split"); 13843 cmdline_parse_token_string_t cmd_vf_split_drop_en_drop = 13844 TOKEN_STRING_INITIALIZER 13845 (struct cmd_vf_split_drop_en_result, 13846 drop, "drop"); 13847 cmdline_parse_token_num_t cmd_vf_split_drop_en_port_id = 13848 TOKEN_NUM_INITIALIZER 13849 (struct cmd_vf_split_drop_en_result, 13850 port_id, UINT16); 13851 cmdline_parse_token_num_t cmd_vf_split_drop_en_vf_id = 13852 TOKEN_NUM_INITIALIZER 13853 (struct cmd_vf_split_drop_en_result, 13854 vf_id, UINT16); 13855 cmdline_parse_token_string_t cmd_vf_split_drop_en_on_off = 13856 TOKEN_STRING_INITIALIZER 13857 (struct cmd_vf_split_drop_en_result, 13858 on_off, "on#off"); 13859 13860 static void 13861 cmd_set_vf_split_drop_en_parsed( 13862 void *parsed_result, 13863 __attribute__((unused)) struct cmdline *cl, 13864 __attribute__((unused)) void *data) 13865 { 13866 struct cmd_vf_split_drop_en_result *res = parsed_result; 13867 int ret = -ENOTSUP; 13868 int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0; 13869 13870 if (port_id_is_invalid(res->port_id, ENABLED_WARN)) 13871 return; 13872 13873 #ifdef RTE_LIBRTE_IXGBE_PMD 13874 ret = rte_pmd_ixgbe_set_vf_split_drop_en(res->port_id, res->vf_id, 13875 is_on); 13876 #endif 13877 switch (ret) { 13878 case 0: 13879 break; 13880 case -EINVAL: 13881 printf("invalid vf_id %d or is_on %d\n", res->vf_id, is_on); 13882 break; 13883 case -ENODEV: 13884 printf("invalid port_id %d\n", res->port_id); 13885 break; 13886 case -ENOTSUP: 13887 printf("not supported on port %d\n", res->port_id); 13888 break; 13889 default: 13890 printf("programming error: (%s)\n", strerror(-ret)); 13891 } 13892 } 13893 13894 cmdline_parse_inst_t cmd_set_vf_split_drop_en = { 13895 .f = cmd_set_vf_split_drop_en_parsed, 13896 .data = NULL, 13897 .help_str = "set vf split drop <port_id> <vf_id> on|off", 13898 .tokens = { 13899 (void *)&cmd_vf_split_drop_en_set, 13900 (void *)&cmd_vf_split_drop_en_vf, 13901 (void *)&cmd_vf_split_drop_en_split, 13902 (void *)&cmd_vf_split_drop_en_drop, 13903 (void *)&cmd_vf_split_drop_en_port_id, 13904 (void *)&cmd_vf_split_drop_en_vf_id, 13905 (void *)&cmd_vf_split_drop_en_on_off, 13906 NULL, 13907 }, 13908 }; 13909 13910 /* vf mac address configuration */ 13911 13912 /* Common result structure for vf mac address */ 13913 struct cmd_set_vf_mac_addr_result { 13914 cmdline_fixed_string_t set; 13915 cmdline_fixed_string_t vf; 13916 cmdline_fixed_string_t mac; 13917 cmdline_fixed_string_t addr; 13918 portid_t port_id; 13919 uint16_t vf_id; 13920 struct rte_ether_addr mac_addr; 13921 13922 }; 13923 13924 /* Common CLI fields for vf split drop enable disable */ 13925 cmdline_parse_token_string_t cmd_set_vf_mac_addr_set = 13926 TOKEN_STRING_INITIALIZER 13927 (struct cmd_set_vf_mac_addr_result, 13928 set, "set"); 13929 cmdline_parse_token_string_t cmd_set_vf_mac_addr_vf = 13930 TOKEN_STRING_INITIALIZER 13931 (struct cmd_set_vf_mac_addr_result, 13932 vf, "vf"); 13933 cmdline_parse_token_string_t cmd_set_vf_mac_addr_mac = 13934 TOKEN_STRING_INITIALIZER 13935 (struct cmd_set_vf_mac_addr_result, 13936 mac, "mac"); 13937 cmdline_parse_token_string_t cmd_set_vf_mac_addr_addr = 13938 TOKEN_STRING_INITIALIZER 13939 (struct cmd_set_vf_mac_addr_result, 13940 addr, "addr"); 13941 cmdline_parse_token_num_t cmd_set_vf_mac_addr_port_id = 13942 TOKEN_NUM_INITIALIZER 13943 (struct cmd_set_vf_mac_addr_result, 13944 port_id, UINT16); 13945 cmdline_parse_token_num_t cmd_set_vf_mac_addr_vf_id = 13946 TOKEN_NUM_INITIALIZER 13947 (struct cmd_set_vf_mac_addr_result, 13948 vf_id, UINT16); 13949 cmdline_parse_token_etheraddr_t cmd_set_vf_mac_addr_mac_addr = 13950 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_vf_mac_addr_result, 13951 mac_addr); 13952 13953 static void 13954 cmd_set_vf_mac_addr_parsed( 13955 void *parsed_result, 13956 __attribute__((unused)) struct cmdline *cl, 13957 __attribute__((unused)) void *data) 13958 { 13959 struct cmd_set_vf_mac_addr_result *res = parsed_result; 13960 int ret = -ENOTSUP; 13961 13962 if (port_id_is_invalid(res->port_id, ENABLED_WARN)) 13963 return; 13964 13965 #ifdef RTE_LIBRTE_IXGBE_PMD 13966 if (ret == -ENOTSUP) 13967 ret = rte_pmd_ixgbe_set_vf_mac_addr(res->port_id, res->vf_id, 13968 &res->mac_addr); 13969 #endif 13970 #ifdef RTE_LIBRTE_I40E_PMD 13971 if (ret == -ENOTSUP) 13972 ret = rte_pmd_i40e_set_vf_mac_addr(res->port_id, res->vf_id, 13973 &res->mac_addr); 13974 #endif 13975 #ifdef RTE_LIBRTE_BNXT_PMD 13976 if (ret == -ENOTSUP) 13977 ret = rte_pmd_bnxt_set_vf_mac_addr(res->port_id, res->vf_id, 13978 &res->mac_addr); 13979 #endif 13980 13981 switch (ret) { 13982 case 0: 13983 break; 13984 case -EINVAL: 13985 printf("invalid vf_id %d or mac_addr\n", res->vf_id); 13986 break; 13987 case -ENODEV: 13988 printf("invalid port_id %d\n", res->port_id); 13989 break; 13990 case -ENOTSUP: 13991 printf("function not implemented\n"); 13992 break; 13993 default: 13994 printf("programming error: (%s)\n", strerror(-ret)); 13995 } 13996 } 13997 13998 cmdline_parse_inst_t cmd_set_vf_mac_addr = { 13999 .f = cmd_set_vf_mac_addr_parsed, 14000 .data = NULL, 14001 .help_str = "set vf mac addr <port_id> <vf_id> <mac_addr>", 14002 .tokens = { 14003 (void *)&cmd_set_vf_mac_addr_set, 14004 (void *)&cmd_set_vf_mac_addr_vf, 14005 (void *)&cmd_set_vf_mac_addr_mac, 14006 (void *)&cmd_set_vf_mac_addr_addr, 14007 (void *)&cmd_set_vf_mac_addr_port_id, 14008 (void *)&cmd_set_vf_mac_addr_vf_id, 14009 (void *)&cmd_set_vf_mac_addr_mac_addr, 14010 NULL, 14011 }, 14012 }; 14013 14014 /* MACsec configuration */ 14015 14016 /* Common result structure for MACsec offload enable */ 14017 struct cmd_macsec_offload_on_result { 14018 cmdline_fixed_string_t set; 14019 cmdline_fixed_string_t macsec; 14020 cmdline_fixed_string_t offload; 14021 portid_t port_id; 14022 cmdline_fixed_string_t on; 14023 cmdline_fixed_string_t encrypt; 14024 cmdline_fixed_string_t en_on_off; 14025 cmdline_fixed_string_t replay_protect; 14026 cmdline_fixed_string_t rp_on_off; 14027 }; 14028 14029 /* Common CLI fields for MACsec offload disable */ 14030 cmdline_parse_token_string_t cmd_macsec_offload_on_set = 14031 TOKEN_STRING_INITIALIZER 14032 (struct cmd_macsec_offload_on_result, 14033 set, "set"); 14034 cmdline_parse_token_string_t cmd_macsec_offload_on_macsec = 14035 TOKEN_STRING_INITIALIZER 14036 (struct cmd_macsec_offload_on_result, 14037 macsec, "macsec"); 14038 cmdline_parse_token_string_t cmd_macsec_offload_on_offload = 14039 TOKEN_STRING_INITIALIZER 14040 (struct cmd_macsec_offload_on_result, 14041 offload, "offload"); 14042 cmdline_parse_token_num_t cmd_macsec_offload_on_port_id = 14043 TOKEN_NUM_INITIALIZER 14044 (struct cmd_macsec_offload_on_result, 14045 port_id, UINT16); 14046 cmdline_parse_token_string_t cmd_macsec_offload_on_on = 14047 TOKEN_STRING_INITIALIZER 14048 (struct cmd_macsec_offload_on_result, 14049 on, "on"); 14050 cmdline_parse_token_string_t cmd_macsec_offload_on_encrypt = 14051 TOKEN_STRING_INITIALIZER 14052 (struct cmd_macsec_offload_on_result, 14053 encrypt, "encrypt"); 14054 cmdline_parse_token_string_t cmd_macsec_offload_on_en_on_off = 14055 TOKEN_STRING_INITIALIZER 14056 (struct cmd_macsec_offload_on_result, 14057 en_on_off, "on#off"); 14058 cmdline_parse_token_string_t cmd_macsec_offload_on_replay_protect = 14059 TOKEN_STRING_INITIALIZER 14060 (struct cmd_macsec_offload_on_result, 14061 replay_protect, "replay-protect"); 14062 cmdline_parse_token_string_t cmd_macsec_offload_on_rp_on_off = 14063 TOKEN_STRING_INITIALIZER 14064 (struct cmd_macsec_offload_on_result, 14065 rp_on_off, "on#off"); 14066 14067 static void 14068 cmd_set_macsec_offload_on_parsed( 14069 void *parsed_result, 14070 __attribute__((unused)) struct cmdline *cl, 14071 __attribute__((unused)) void *data) 14072 { 14073 struct cmd_macsec_offload_on_result *res = parsed_result; 14074 int ret = -ENOTSUP; 14075 portid_t port_id = res->port_id; 14076 int en = (strcmp(res->en_on_off, "on") == 0) ? 1 : 0; 14077 int rp = (strcmp(res->rp_on_off, "on") == 0) ? 1 : 0; 14078 struct rte_eth_dev_info dev_info; 14079 14080 if (port_id_is_invalid(port_id, ENABLED_WARN)) 14081 return; 14082 if (!port_is_stopped(port_id)) { 14083 printf("Please stop port %d first\n", port_id); 14084 return; 14085 } 14086 14087 rte_eth_dev_info_get(port_id, &dev_info); 14088 if (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_MACSEC_INSERT) { 14089 #ifdef RTE_LIBRTE_IXGBE_PMD 14090 ret = rte_pmd_ixgbe_macsec_enable(port_id, en, rp); 14091 #endif 14092 } 14093 RTE_SET_USED(en); 14094 RTE_SET_USED(rp); 14095 14096 switch (ret) { 14097 case 0: 14098 ports[port_id].dev_conf.txmode.offloads |= 14099 DEV_TX_OFFLOAD_MACSEC_INSERT; 14100 cmd_reconfig_device_queue(port_id, 1, 1); 14101 break; 14102 case -ENODEV: 14103 printf("invalid port_id %d\n", port_id); 14104 break; 14105 case -ENOTSUP: 14106 printf("not supported on port %d\n", port_id); 14107 break; 14108 default: 14109 printf("programming error: (%s)\n", strerror(-ret)); 14110 } 14111 } 14112 14113 cmdline_parse_inst_t cmd_set_macsec_offload_on = { 14114 .f = cmd_set_macsec_offload_on_parsed, 14115 .data = NULL, 14116 .help_str = "set macsec offload <port_id> on " 14117 "encrypt on|off replay-protect on|off", 14118 .tokens = { 14119 (void *)&cmd_macsec_offload_on_set, 14120 (void *)&cmd_macsec_offload_on_macsec, 14121 (void *)&cmd_macsec_offload_on_offload, 14122 (void *)&cmd_macsec_offload_on_port_id, 14123 (void *)&cmd_macsec_offload_on_on, 14124 (void *)&cmd_macsec_offload_on_encrypt, 14125 (void *)&cmd_macsec_offload_on_en_on_off, 14126 (void *)&cmd_macsec_offload_on_replay_protect, 14127 (void *)&cmd_macsec_offload_on_rp_on_off, 14128 NULL, 14129 }, 14130 }; 14131 14132 /* Common result structure for MACsec offload disable */ 14133 struct cmd_macsec_offload_off_result { 14134 cmdline_fixed_string_t set; 14135 cmdline_fixed_string_t macsec; 14136 cmdline_fixed_string_t offload; 14137 portid_t port_id; 14138 cmdline_fixed_string_t off; 14139 }; 14140 14141 /* Common CLI fields for MACsec offload disable */ 14142 cmdline_parse_token_string_t cmd_macsec_offload_off_set = 14143 TOKEN_STRING_INITIALIZER 14144 (struct cmd_macsec_offload_off_result, 14145 set, "set"); 14146 cmdline_parse_token_string_t cmd_macsec_offload_off_macsec = 14147 TOKEN_STRING_INITIALIZER 14148 (struct cmd_macsec_offload_off_result, 14149 macsec, "macsec"); 14150 cmdline_parse_token_string_t cmd_macsec_offload_off_offload = 14151 TOKEN_STRING_INITIALIZER 14152 (struct cmd_macsec_offload_off_result, 14153 offload, "offload"); 14154 cmdline_parse_token_num_t cmd_macsec_offload_off_port_id = 14155 TOKEN_NUM_INITIALIZER 14156 (struct cmd_macsec_offload_off_result, 14157 port_id, UINT16); 14158 cmdline_parse_token_string_t cmd_macsec_offload_off_off = 14159 TOKEN_STRING_INITIALIZER 14160 (struct cmd_macsec_offload_off_result, 14161 off, "off"); 14162 14163 static void 14164 cmd_set_macsec_offload_off_parsed( 14165 void *parsed_result, 14166 __attribute__((unused)) struct cmdline *cl, 14167 __attribute__((unused)) void *data) 14168 { 14169 struct cmd_macsec_offload_off_result *res = parsed_result; 14170 int ret = -ENOTSUP; 14171 struct rte_eth_dev_info dev_info; 14172 portid_t port_id = res->port_id; 14173 14174 if (port_id_is_invalid(port_id, ENABLED_WARN)) 14175 return; 14176 if (!port_is_stopped(port_id)) { 14177 printf("Please stop port %d first\n", port_id); 14178 return; 14179 } 14180 14181 rte_eth_dev_info_get(port_id, &dev_info); 14182 if (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_MACSEC_INSERT) { 14183 #ifdef RTE_LIBRTE_IXGBE_PMD 14184 ret = rte_pmd_ixgbe_macsec_disable(port_id); 14185 #endif 14186 } 14187 switch (ret) { 14188 case 0: 14189 ports[port_id].dev_conf.txmode.offloads &= 14190 ~DEV_TX_OFFLOAD_MACSEC_INSERT; 14191 cmd_reconfig_device_queue(port_id, 1, 1); 14192 break; 14193 case -ENODEV: 14194 printf("invalid port_id %d\n", port_id); 14195 break; 14196 case -ENOTSUP: 14197 printf("not supported on port %d\n", port_id); 14198 break; 14199 default: 14200 printf("programming error: (%s)\n", strerror(-ret)); 14201 } 14202 } 14203 14204 cmdline_parse_inst_t cmd_set_macsec_offload_off = { 14205 .f = cmd_set_macsec_offload_off_parsed, 14206 .data = NULL, 14207 .help_str = "set macsec offload <port_id> off", 14208 .tokens = { 14209 (void *)&cmd_macsec_offload_off_set, 14210 (void *)&cmd_macsec_offload_off_macsec, 14211 (void *)&cmd_macsec_offload_off_offload, 14212 (void *)&cmd_macsec_offload_off_port_id, 14213 (void *)&cmd_macsec_offload_off_off, 14214 NULL, 14215 }, 14216 }; 14217 14218 /* Common result structure for MACsec secure connection configure */ 14219 struct cmd_macsec_sc_result { 14220 cmdline_fixed_string_t set; 14221 cmdline_fixed_string_t macsec; 14222 cmdline_fixed_string_t sc; 14223 cmdline_fixed_string_t tx_rx; 14224 portid_t port_id; 14225 struct rte_ether_addr mac; 14226 uint16_t pi; 14227 }; 14228 14229 /* Common CLI fields for MACsec secure connection configure */ 14230 cmdline_parse_token_string_t cmd_macsec_sc_set = 14231 TOKEN_STRING_INITIALIZER 14232 (struct cmd_macsec_sc_result, 14233 set, "set"); 14234 cmdline_parse_token_string_t cmd_macsec_sc_macsec = 14235 TOKEN_STRING_INITIALIZER 14236 (struct cmd_macsec_sc_result, 14237 macsec, "macsec"); 14238 cmdline_parse_token_string_t cmd_macsec_sc_sc = 14239 TOKEN_STRING_INITIALIZER 14240 (struct cmd_macsec_sc_result, 14241 sc, "sc"); 14242 cmdline_parse_token_string_t cmd_macsec_sc_tx_rx = 14243 TOKEN_STRING_INITIALIZER 14244 (struct cmd_macsec_sc_result, 14245 tx_rx, "tx#rx"); 14246 cmdline_parse_token_num_t cmd_macsec_sc_port_id = 14247 TOKEN_NUM_INITIALIZER 14248 (struct cmd_macsec_sc_result, 14249 port_id, UINT16); 14250 cmdline_parse_token_etheraddr_t cmd_macsec_sc_mac = 14251 TOKEN_ETHERADDR_INITIALIZER 14252 (struct cmd_macsec_sc_result, 14253 mac); 14254 cmdline_parse_token_num_t cmd_macsec_sc_pi = 14255 TOKEN_NUM_INITIALIZER 14256 (struct cmd_macsec_sc_result, 14257 pi, UINT16); 14258 14259 static void 14260 cmd_set_macsec_sc_parsed( 14261 void *parsed_result, 14262 __attribute__((unused)) struct cmdline *cl, 14263 __attribute__((unused)) void *data) 14264 { 14265 struct cmd_macsec_sc_result *res = parsed_result; 14266 int ret = -ENOTSUP; 14267 int is_tx = (strcmp(res->tx_rx, "tx") == 0) ? 1 : 0; 14268 14269 #ifdef RTE_LIBRTE_IXGBE_PMD 14270 ret = is_tx ? 14271 rte_pmd_ixgbe_macsec_config_txsc(res->port_id, 14272 res->mac.addr_bytes) : 14273 rte_pmd_ixgbe_macsec_config_rxsc(res->port_id, 14274 res->mac.addr_bytes, res->pi); 14275 #endif 14276 RTE_SET_USED(is_tx); 14277 14278 switch (ret) { 14279 case 0: 14280 break; 14281 case -ENODEV: 14282 printf("invalid port_id %d\n", res->port_id); 14283 break; 14284 case -ENOTSUP: 14285 printf("not supported on port %d\n", res->port_id); 14286 break; 14287 default: 14288 printf("programming error: (%s)\n", strerror(-ret)); 14289 } 14290 } 14291 14292 cmdline_parse_inst_t cmd_set_macsec_sc = { 14293 .f = cmd_set_macsec_sc_parsed, 14294 .data = NULL, 14295 .help_str = "set macsec sc tx|rx <port_id> <mac> <pi>", 14296 .tokens = { 14297 (void *)&cmd_macsec_sc_set, 14298 (void *)&cmd_macsec_sc_macsec, 14299 (void *)&cmd_macsec_sc_sc, 14300 (void *)&cmd_macsec_sc_tx_rx, 14301 (void *)&cmd_macsec_sc_port_id, 14302 (void *)&cmd_macsec_sc_mac, 14303 (void *)&cmd_macsec_sc_pi, 14304 NULL, 14305 }, 14306 }; 14307 14308 /* Common result structure for MACsec secure connection configure */ 14309 struct cmd_macsec_sa_result { 14310 cmdline_fixed_string_t set; 14311 cmdline_fixed_string_t macsec; 14312 cmdline_fixed_string_t sa; 14313 cmdline_fixed_string_t tx_rx; 14314 portid_t port_id; 14315 uint8_t idx; 14316 uint8_t an; 14317 uint32_t pn; 14318 cmdline_fixed_string_t key; 14319 }; 14320 14321 /* Common CLI fields for MACsec secure connection configure */ 14322 cmdline_parse_token_string_t cmd_macsec_sa_set = 14323 TOKEN_STRING_INITIALIZER 14324 (struct cmd_macsec_sa_result, 14325 set, "set"); 14326 cmdline_parse_token_string_t cmd_macsec_sa_macsec = 14327 TOKEN_STRING_INITIALIZER 14328 (struct cmd_macsec_sa_result, 14329 macsec, "macsec"); 14330 cmdline_parse_token_string_t cmd_macsec_sa_sa = 14331 TOKEN_STRING_INITIALIZER 14332 (struct cmd_macsec_sa_result, 14333 sa, "sa"); 14334 cmdline_parse_token_string_t cmd_macsec_sa_tx_rx = 14335 TOKEN_STRING_INITIALIZER 14336 (struct cmd_macsec_sa_result, 14337 tx_rx, "tx#rx"); 14338 cmdline_parse_token_num_t cmd_macsec_sa_port_id = 14339 TOKEN_NUM_INITIALIZER 14340 (struct cmd_macsec_sa_result, 14341 port_id, UINT16); 14342 cmdline_parse_token_num_t cmd_macsec_sa_idx = 14343 TOKEN_NUM_INITIALIZER 14344 (struct cmd_macsec_sa_result, 14345 idx, UINT8); 14346 cmdline_parse_token_num_t cmd_macsec_sa_an = 14347 TOKEN_NUM_INITIALIZER 14348 (struct cmd_macsec_sa_result, 14349 an, UINT8); 14350 cmdline_parse_token_num_t cmd_macsec_sa_pn = 14351 TOKEN_NUM_INITIALIZER 14352 (struct cmd_macsec_sa_result, 14353 pn, UINT32); 14354 cmdline_parse_token_string_t cmd_macsec_sa_key = 14355 TOKEN_STRING_INITIALIZER 14356 (struct cmd_macsec_sa_result, 14357 key, NULL); 14358 14359 static void 14360 cmd_set_macsec_sa_parsed( 14361 void *parsed_result, 14362 __attribute__((unused)) struct cmdline *cl, 14363 __attribute__((unused)) void *data) 14364 { 14365 struct cmd_macsec_sa_result *res = parsed_result; 14366 int ret = -ENOTSUP; 14367 int is_tx = (strcmp(res->tx_rx, "tx") == 0) ? 1 : 0; 14368 uint8_t key[16] = { 0 }; 14369 uint8_t xdgt0; 14370 uint8_t xdgt1; 14371 int key_len; 14372 int i; 14373 14374 key_len = strlen(res->key) / 2; 14375 if (key_len > 16) 14376 key_len = 16; 14377 14378 for (i = 0; i < key_len; i++) { 14379 xdgt0 = parse_and_check_key_hexa_digit(res->key, (i * 2)); 14380 if (xdgt0 == 0xFF) 14381 return; 14382 xdgt1 = parse_and_check_key_hexa_digit(res->key, (i * 2) + 1); 14383 if (xdgt1 == 0xFF) 14384 return; 14385 key[i] = (uint8_t) ((xdgt0 * 16) + xdgt1); 14386 } 14387 14388 #ifdef RTE_LIBRTE_IXGBE_PMD 14389 ret = is_tx ? 14390 rte_pmd_ixgbe_macsec_select_txsa(res->port_id, 14391 res->idx, res->an, res->pn, key) : 14392 rte_pmd_ixgbe_macsec_select_rxsa(res->port_id, 14393 res->idx, res->an, res->pn, key); 14394 #endif 14395 RTE_SET_USED(is_tx); 14396 RTE_SET_USED(key); 14397 14398 switch (ret) { 14399 case 0: 14400 break; 14401 case -EINVAL: 14402 printf("invalid idx %d or an %d\n", res->idx, res->an); 14403 break; 14404 case -ENODEV: 14405 printf("invalid port_id %d\n", res->port_id); 14406 break; 14407 case -ENOTSUP: 14408 printf("not supported on port %d\n", res->port_id); 14409 break; 14410 default: 14411 printf("programming error: (%s)\n", strerror(-ret)); 14412 } 14413 } 14414 14415 cmdline_parse_inst_t cmd_set_macsec_sa = { 14416 .f = cmd_set_macsec_sa_parsed, 14417 .data = NULL, 14418 .help_str = "set macsec sa tx|rx <port_id> <idx> <an> <pn> <key>", 14419 .tokens = { 14420 (void *)&cmd_macsec_sa_set, 14421 (void *)&cmd_macsec_sa_macsec, 14422 (void *)&cmd_macsec_sa_sa, 14423 (void *)&cmd_macsec_sa_tx_rx, 14424 (void *)&cmd_macsec_sa_port_id, 14425 (void *)&cmd_macsec_sa_idx, 14426 (void *)&cmd_macsec_sa_an, 14427 (void *)&cmd_macsec_sa_pn, 14428 (void *)&cmd_macsec_sa_key, 14429 NULL, 14430 }, 14431 }; 14432 14433 /* VF unicast promiscuous mode configuration */ 14434 14435 /* Common result structure for VF unicast promiscuous mode */ 14436 struct cmd_vf_promisc_result { 14437 cmdline_fixed_string_t set; 14438 cmdline_fixed_string_t vf; 14439 cmdline_fixed_string_t promisc; 14440 portid_t port_id; 14441 uint32_t vf_id; 14442 cmdline_fixed_string_t on_off; 14443 }; 14444 14445 /* Common CLI fields for VF unicast promiscuous mode enable disable */ 14446 cmdline_parse_token_string_t cmd_vf_promisc_set = 14447 TOKEN_STRING_INITIALIZER 14448 (struct cmd_vf_promisc_result, 14449 set, "set"); 14450 cmdline_parse_token_string_t cmd_vf_promisc_vf = 14451 TOKEN_STRING_INITIALIZER 14452 (struct cmd_vf_promisc_result, 14453 vf, "vf"); 14454 cmdline_parse_token_string_t cmd_vf_promisc_promisc = 14455 TOKEN_STRING_INITIALIZER 14456 (struct cmd_vf_promisc_result, 14457 promisc, "promisc"); 14458 cmdline_parse_token_num_t cmd_vf_promisc_port_id = 14459 TOKEN_NUM_INITIALIZER 14460 (struct cmd_vf_promisc_result, 14461 port_id, UINT16); 14462 cmdline_parse_token_num_t cmd_vf_promisc_vf_id = 14463 TOKEN_NUM_INITIALIZER 14464 (struct cmd_vf_promisc_result, 14465 vf_id, UINT32); 14466 cmdline_parse_token_string_t cmd_vf_promisc_on_off = 14467 TOKEN_STRING_INITIALIZER 14468 (struct cmd_vf_promisc_result, 14469 on_off, "on#off"); 14470 14471 static void 14472 cmd_set_vf_promisc_parsed( 14473 void *parsed_result, 14474 __attribute__((unused)) struct cmdline *cl, 14475 __attribute__((unused)) void *data) 14476 { 14477 struct cmd_vf_promisc_result *res = parsed_result; 14478 int ret = -ENOTSUP; 14479 14480 __rte_unused int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0; 14481 14482 if (port_id_is_invalid(res->port_id, ENABLED_WARN)) 14483 return; 14484 14485 #ifdef RTE_LIBRTE_I40E_PMD 14486 ret = rte_pmd_i40e_set_vf_unicast_promisc(res->port_id, 14487 res->vf_id, is_on); 14488 #endif 14489 14490 switch (ret) { 14491 case 0: 14492 break; 14493 case -EINVAL: 14494 printf("invalid vf_id %d\n", res->vf_id); 14495 break; 14496 case -ENODEV: 14497 printf("invalid port_id %d\n", res->port_id); 14498 break; 14499 case -ENOTSUP: 14500 printf("function not implemented\n"); 14501 break; 14502 default: 14503 printf("programming error: (%s)\n", strerror(-ret)); 14504 } 14505 } 14506 14507 cmdline_parse_inst_t cmd_set_vf_promisc = { 14508 .f = cmd_set_vf_promisc_parsed, 14509 .data = NULL, 14510 .help_str = "set vf promisc <port_id> <vf_id> on|off: " 14511 "Set unicast promiscuous mode for a VF from the PF", 14512 .tokens = { 14513 (void *)&cmd_vf_promisc_set, 14514 (void *)&cmd_vf_promisc_vf, 14515 (void *)&cmd_vf_promisc_promisc, 14516 (void *)&cmd_vf_promisc_port_id, 14517 (void *)&cmd_vf_promisc_vf_id, 14518 (void *)&cmd_vf_promisc_on_off, 14519 NULL, 14520 }, 14521 }; 14522 14523 /* VF multicast promiscuous mode configuration */ 14524 14525 /* Common result structure for VF multicast promiscuous mode */ 14526 struct cmd_vf_allmulti_result { 14527 cmdline_fixed_string_t set; 14528 cmdline_fixed_string_t vf; 14529 cmdline_fixed_string_t allmulti; 14530 portid_t port_id; 14531 uint32_t vf_id; 14532 cmdline_fixed_string_t on_off; 14533 }; 14534 14535 /* Common CLI fields for VF multicast promiscuous mode enable disable */ 14536 cmdline_parse_token_string_t cmd_vf_allmulti_set = 14537 TOKEN_STRING_INITIALIZER 14538 (struct cmd_vf_allmulti_result, 14539 set, "set"); 14540 cmdline_parse_token_string_t cmd_vf_allmulti_vf = 14541 TOKEN_STRING_INITIALIZER 14542 (struct cmd_vf_allmulti_result, 14543 vf, "vf"); 14544 cmdline_parse_token_string_t cmd_vf_allmulti_allmulti = 14545 TOKEN_STRING_INITIALIZER 14546 (struct cmd_vf_allmulti_result, 14547 allmulti, "allmulti"); 14548 cmdline_parse_token_num_t cmd_vf_allmulti_port_id = 14549 TOKEN_NUM_INITIALIZER 14550 (struct cmd_vf_allmulti_result, 14551 port_id, UINT16); 14552 cmdline_parse_token_num_t cmd_vf_allmulti_vf_id = 14553 TOKEN_NUM_INITIALIZER 14554 (struct cmd_vf_allmulti_result, 14555 vf_id, UINT32); 14556 cmdline_parse_token_string_t cmd_vf_allmulti_on_off = 14557 TOKEN_STRING_INITIALIZER 14558 (struct cmd_vf_allmulti_result, 14559 on_off, "on#off"); 14560 14561 static void 14562 cmd_set_vf_allmulti_parsed( 14563 void *parsed_result, 14564 __attribute__((unused)) struct cmdline *cl, 14565 __attribute__((unused)) void *data) 14566 { 14567 struct cmd_vf_allmulti_result *res = parsed_result; 14568 int ret = -ENOTSUP; 14569 14570 __rte_unused int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0; 14571 14572 if (port_id_is_invalid(res->port_id, ENABLED_WARN)) 14573 return; 14574 14575 #ifdef RTE_LIBRTE_I40E_PMD 14576 ret = rte_pmd_i40e_set_vf_multicast_promisc(res->port_id, 14577 res->vf_id, is_on); 14578 #endif 14579 14580 switch (ret) { 14581 case 0: 14582 break; 14583 case -EINVAL: 14584 printf("invalid vf_id %d\n", res->vf_id); 14585 break; 14586 case -ENODEV: 14587 printf("invalid port_id %d\n", res->port_id); 14588 break; 14589 case -ENOTSUP: 14590 printf("function not implemented\n"); 14591 break; 14592 default: 14593 printf("programming error: (%s)\n", strerror(-ret)); 14594 } 14595 } 14596 14597 cmdline_parse_inst_t cmd_set_vf_allmulti = { 14598 .f = cmd_set_vf_allmulti_parsed, 14599 .data = NULL, 14600 .help_str = "set vf allmulti <port_id> <vf_id> on|off: " 14601 "Set multicast promiscuous mode for a VF from the PF", 14602 .tokens = { 14603 (void *)&cmd_vf_allmulti_set, 14604 (void *)&cmd_vf_allmulti_vf, 14605 (void *)&cmd_vf_allmulti_allmulti, 14606 (void *)&cmd_vf_allmulti_port_id, 14607 (void *)&cmd_vf_allmulti_vf_id, 14608 (void *)&cmd_vf_allmulti_on_off, 14609 NULL, 14610 }, 14611 }; 14612 14613 /* vf broadcast mode configuration */ 14614 14615 /* Common result structure for vf broadcast */ 14616 struct cmd_set_vf_broadcast_result { 14617 cmdline_fixed_string_t set; 14618 cmdline_fixed_string_t vf; 14619 cmdline_fixed_string_t broadcast; 14620 portid_t port_id; 14621 uint16_t vf_id; 14622 cmdline_fixed_string_t on_off; 14623 }; 14624 14625 /* Common CLI fields for vf broadcast enable disable */ 14626 cmdline_parse_token_string_t cmd_set_vf_broadcast_set = 14627 TOKEN_STRING_INITIALIZER 14628 (struct cmd_set_vf_broadcast_result, 14629 set, "set"); 14630 cmdline_parse_token_string_t cmd_set_vf_broadcast_vf = 14631 TOKEN_STRING_INITIALIZER 14632 (struct cmd_set_vf_broadcast_result, 14633 vf, "vf"); 14634 cmdline_parse_token_string_t cmd_set_vf_broadcast_broadcast = 14635 TOKEN_STRING_INITIALIZER 14636 (struct cmd_set_vf_broadcast_result, 14637 broadcast, "broadcast"); 14638 cmdline_parse_token_num_t cmd_set_vf_broadcast_port_id = 14639 TOKEN_NUM_INITIALIZER 14640 (struct cmd_set_vf_broadcast_result, 14641 port_id, UINT16); 14642 cmdline_parse_token_num_t cmd_set_vf_broadcast_vf_id = 14643 TOKEN_NUM_INITIALIZER 14644 (struct cmd_set_vf_broadcast_result, 14645 vf_id, UINT16); 14646 cmdline_parse_token_string_t cmd_set_vf_broadcast_on_off = 14647 TOKEN_STRING_INITIALIZER 14648 (struct cmd_set_vf_broadcast_result, 14649 on_off, "on#off"); 14650 14651 static void 14652 cmd_set_vf_broadcast_parsed( 14653 void *parsed_result, 14654 __attribute__((unused)) struct cmdline *cl, 14655 __attribute__((unused)) void *data) 14656 { 14657 struct cmd_set_vf_broadcast_result *res = parsed_result; 14658 int ret = -ENOTSUP; 14659 14660 __rte_unused int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0; 14661 14662 if (port_id_is_invalid(res->port_id, ENABLED_WARN)) 14663 return; 14664 14665 #ifdef RTE_LIBRTE_I40E_PMD 14666 ret = rte_pmd_i40e_set_vf_broadcast(res->port_id, 14667 res->vf_id, is_on); 14668 #endif 14669 14670 switch (ret) { 14671 case 0: 14672 break; 14673 case -EINVAL: 14674 printf("invalid vf_id %d or is_on %d\n", res->vf_id, is_on); 14675 break; 14676 case -ENODEV: 14677 printf("invalid port_id %d\n", res->port_id); 14678 break; 14679 case -ENOTSUP: 14680 printf("function not implemented\n"); 14681 break; 14682 default: 14683 printf("programming error: (%s)\n", strerror(-ret)); 14684 } 14685 } 14686 14687 cmdline_parse_inst_t cmd_set_vf_broadcast = { 14688 .f = cmd_set_vf_broadcast_parsed, 14689 .data = NULL, 14690 .help_str = "set vf broadcast <port_id> <vf_id> on|off", 14691 .tokens = { 14692 (void *)&cmd_set_vf_broadcast_set, 14693 (void *)&cmd_set_vf_broadcast_vf, 14694 (void *)&cmd_set_vf_broadcast_broadcast, 14695 (void *)&cmd_set_vf_broadcast_port_id, 14696 (void *)&cmd_set_vf_broadcast_vf_id, 14697 (void *)&cmd_set_vf_broadcast_on_off, 14698 NULL, 14699 }, 14700 }; 14701 14702 /* vf vlan tag configuration */ 14703 14704 /* Common result structure for vf vlan tag */ 14705 struct cmd_set_vf_vlan_tag_result { 14706 cmdline_fixed_string_t set; 14707 cmdline_fixed_string_t vf; 14708 cmdline_fixed_string_t vlan; 14709 cmdline_fixed_string_t tag; 14710 portid_t port_id; 14711 uint16_t vf_id; 14712 cmdline_fixed_string_t on_off; 14713 }; 14714 14715 /* Common CLI fields for vf vlan tag enable disable */ 14716 cmdline_parse_token_string_t cmd_set_vf_vlan_tag_set = 14717 TOKEN_STRING_INITIALIZER 14718 (struct cmd_set_vf_vlan_tag_result, 14719 set, "set"); 14720 cmdline_parse_token_string_t cmd_set_vf_vlan_tag_vf = 14721 TOKEN_STRING_INITIALIZER 14722 (struct cmd_set_vf_vlan_tag_result, 14723 vf, "vf"); 14724 cmdline_parse_token_string_t cmd_set_vf_vlan_tag_vlan = 14725 TOKEN_STRING_INITIALIZER 14726 (struct cmd_set_vf_vlan_tag_result, 14727 vlan, "vlan"); 14728 cmdline_parse_token_string_t cmd_set_vf_vlan_tag_tag = 14729 TOKEN_STRING_INITIALIZER 14730 (struct cmd_set_vf_vlan_tag_result, 14731 tag, "tag"); 14732 cmdline_parse_token_num_t cmd_set_vf_vlan_tag_port_id = 14733 TOKEN_NUM_INITIALIZER 14734 (struct cmd_set_vf_vlan_tag_result, 14735 port_id, UINT16); 14736 cmdline_parse_token_num_t cmd_set_vf_vlan_tag_vf_id = 14737 TOKEN_NUM_INITIALIZER 14738 (struct cmd_set_vf_vlan_tag_result, 14739 vf_id, UINT16); 14740 cmdline_parse_token_string_t cmd_set_vf_vlan_tag_on_off = 14741 TOKEN_STRING_INITIALIZER 14742 (struct cmd_set_vf_vlan_tag_result, 14743 on_off, "on#off"); 14744 14745 static void 14746 cmd_set_vf_vlan_tag_parsed( 14747 void *parsed_result, 14748 __attribute__((unused)) struct cmdline *cl, 14749 __attribute__((unused)) void *data) 14750 { 14751 struct cmd_set_vf_vlan_tag_result *res = parsed_result; 14752 int ret = -ENOTSUP; 14753 14754 __rte_unused int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0; 14755 14756 if (port_id_is_invalid(res->port_id, ENABLED_WARN)) 14757 return; 14758 14759 #ifdef RTE_LIBRTE_I40E_PMD 14760 ret = rte_pmd_i40e_set_vf_vlan_tag(res->port_id, 14761 res->vf_id, is_on); 14762 #endif 14763 14764 switch (ret) { 14765 case 0: 14766 break; 14767 case -EINVAL: 14768 printf("invalid vf_id %d or is_on %d\n", res->vf_id, is_on); 14769 break; 14770 case -ENODEV: 14771 printf("invalid port_id %d\n", res->port_id); 14772 break; 14773 case -ENOTSUP: 14774 printf("function not implemented\n"); 14775 break; 14776 default: 14777 printf("programming error: (%s)\n", strerror(-ret)); 14778 } 14779 } 14780 14781 cmdline_parse_inst_t cmd_set_vf_vlan_tag = { 14782 .f = cmd_set_vf_vlan_tag_parsed, 14783 .data = NULL, 14784 .help_str = "set vf vlan tag <port_id> <vf_id> on|off", 14785 .tokens = { 14786 (void *)&cmd_set_vf_vlan_tag_set, 14787 (void *)&cmd_set_vf_vlan_tag_vf, 14788 (void *)&cmd_set_vf_vlan_tag_vlan, 14789 (void *)&cmd_set_vf_vlan_tag_tag, 14790 (void *)&cmd_set_vf_vlan_tag_port_id, 14791 (void *)&cmd_set_vf_vlan_tag_vf_id, 14792 (void *)&cmd_set_vf_vlan_tag_on_off, 14793 NULL, 14794 }, 14795 }; 14796 14797 /* Common definition of VF and TC TX bandwidth configuration */ 14798 struct cmd_vf_tc_bw_result { 14799 cmdline_fixed_string_t set; 14800 cmdline_fixed_string_t vf; 14801 cmdline_fixed_string_t tc; 14802 cmdline_fixed_string_t tx; 14803 cmdline_fixed_string_t min_bw; 14804 cmdline_fixed_string_t max_bw; 14805 cmdline_fixed_string_t strict_link_prio; 14806 portid_t port_id; 14807 uint16_t vf_id; 14808 uint8_t tc_no; 14809 uint32_t bw; 14810 cmdline_fixed_string_t bw_list; 14811 uint8_t tc_map; 14812 }; 14813 14814 cmdline_parse_token_string_t cmd_vf_tc_bw_set = 14815 TOKEN_STRING_INITIALIZER 14816 (struct cmd_vf_tc_bw_result, 14817 set, "set"); 14818 cmdline_parse_token_string_t cmd_vf_tc_bw_vf = 14819 TOKEN_STRING_INITIALIZER 14820 (struct cmd_vf_tc_bw_result, 14821 vf, "vf"); 14822 cmdline_parse_token_string_t cmd_vf_tc_bw_tc = 14823 TOKEN_STRING_INITIALIZER 14824 (struct cmd_vf_tc_bw_result, 14825 tc, "tc"); 14826 cmdline_parse_token_string_t cmd_vf_tc_bw_tx = 14827 TOKEN_STRING_INITIALIZER 14828 (struct cmd_vf_tc_bw_result, 14829 tx, "tx"); 14830 cmdline_parse_token_string_t cmd_vf_tc_bw_strict_link_prio = 14831 TOKEN_STRING_INITIALIZER 14832 (struct cmd_vf_tc_bw_result, 14833 strict_link_prio, "strict-link-priority"); 14834 cmdline_parse_token_string_t cmd_vf_tc_bw_min_bw = 14835 TOKEN_STRING_INITIALIZER 14836 (struct cmd_vf_tc_bw_result, 14837 min_bw, "min-bandwidth"); 14838 cmdline_parse_token_string_t cmd_vf_tc_bw_max_bw = 14839 TOKEN_STRING_INITIALIZER 14840 (struct cmd_vf_tc_bw_result, 14841 max_bw, "max-bandwidth"); 14842 cmdline_parse_token_num_t cmd_vf_tc_bw_port_id = 14843 TOKEN_NUM_INITIALIZER 14844 (struct cmd_vf_tc_bw_result, 14845 port_id, UINT16); 14846 cmdline_parse_token_num_t cmd_vf_tc_bw_vf_id = 14847 TOKEN_NUM_INITIALIZER 14848 (struct cmd_vf_tc_bw_result, 14849 vf_id, UINT16); 14850 cmdline_parse_token_num_t cmd_vf_tc_bw_tc_no = 14851 TOKEN_NUM_INITIALIZER 14852 (struct cmd_vf_tc_bw_result, 14853 tc_no, UINT8); 14854 cmdline_parse_token_num_t cmd_vf_tc_bw_bw = 14855 TOKEN_NUM_INITIALIZER 14856 (struct cmd_vf_tc_bw_result, 14857 bw, UINT32); 14858 cmdline_parse_token_string_t cmd_vf_tc_bw_bw_list = 14859 TOKEN_STRING_INITIALIZER 14860 (struct cmd_vf_tc_bw_result, 14861 bw_list, NULL); 14862 cmdline_parse_token_num_t cmd_vf_tc_bw_tc_map = 14863 TOKEN_NUM_INITIALIZER 14864 (struct cmd_vf_tc_bw_result, 14865 tc_map, UINT8); 14866 14867 /* VF max bandwidth setting */ 14868 static void 14869 cmd_vf_max_bw_parsed( 14870 void *parsed_result, 14871 __attribute__((unused)) struct cmdline *cl, 14872 __attribute__((unused)) void *data) 14873 { 14874 struct cmd_vf_tc_bw_result *res = parsed_result; 14875 int ret = -ENOTSUP; 14876 14877 if (port_id_is_invalid(res->port_id, ENABLED_WARN)) 14878 return; 14879 14880 #ifdef RTE_LIBRTE_I40E_PMD 14881 ret = rte_pmd_i40e_set_vf_max_bw(res->port_id, 14882 res->vf_id, res->bw); 14883 #endif 14884 14885 switch (ret) { 14886 case 0: 14887 break; 14888 case -EINVAL: 14889 printf("invalid vf_id %d or bandwidth %d\n", 14890 res->vf_id, res->bw); 14891 break; 14892 case -ENODEV: 14893 printf("invalid port_id %d\n", res->port_id); 14894 break; 14895 case -ENOTSUP: 14896 printf("function not implemented\n"); 14897 break; 14898 default: 14899 printf("programming error: (%s)\n", strerror(-ret)); 14900 } 14901 } 14902 14903 cmdline_parse_inst_t cmd_vf_max_bw = { 14904 .f = cmd_vf_max_bw_parsed, 14905 .data = NULL, 14906 .help_str = "set vf tx max-bandwidth <port_id> <vf_id> <bandwidth>", 14907 .tokens = { 14908 (void *)&cmd_vf_tc_bw_set, 14909 (void *)&cmd_vf_tc_bw_vf, 14910 (void *)&cmd_vf_tc_bw_tx, 14911 (void *)&cmd_vf_tc_bw_max_bw, 14912 (void *)&cmd_vf_tc_bw_port_id, 14913 (void *)&cmd_vf_tc_bw_vf_id, 14914 (void *)&cmd_vf_tc_bw_bw, 14915 NULL, 14916 }, 14917 }; 14918 14919 static int 14920 vf_tc_min_bw_parse_bw_list(uint8_t *bw_list, 14921 uint8_t *tc_num, 14922 char *str) 14923 { 14924 uint32_t size; 14925 const char *p, *p0 = str; 14926 char s[256]; 14927 char *end; 14928 char *str_fld[16]; 14929 uint16_t i; 14930 int ret; 14931 14932 p = strchr(p0, '('); 14933 if (p == NULL) { 14934 printf("The bandwidth-list should be '(bw1, bw2, ...)'\n"); 14935 return -1; 14936 } 14937 p++; 14938 p0 = strchr(p, ')'); 14939 if (p0 == NULL) { 14940 printf("The bandwidth-list should be '(bw1, bw2, ...)'\n"); 14941 return -1; 14942 } 14943 size = p0 - p; 14944 if (size >= sizeof(s)) { 14945 printf("The string size exceeds the internal buffer size\n"); 14946 return -1; 14947 } 14948 snprintf(s, sizeof(s), "%.*s", size, p); 14949 ret = rte_strsplit(s, sizeof(s), str_fld, 16, ','); 14950 if (ret <= 0) { 14951 printf("Failed to get the bandwidth list. "); 14952 return -1; 14953 } 14954 *tc_num = ret; 14955 for (i = 0; i < ret; i++) 14956 bw_list[i] = (uint8_t)strtoul(str_fld[i], &end, 0); 14957 14958 return 0; 14959 } 14960 14961 /* TC min bandwidth setting */ 14962 static void 14963 cmd_vf_tc_min_bw_parsed( 14964 void *parsed_result, 14965 __attribute__((unused)) struct cmdline *cl, 14966 __attribute__((unused)) void *data) 14967 { 14968 struct cmd_vf_tc_bw_result *res = parsed_result; 14969 uint8_t tc_num; 14970 uint8_t bw[16]; 14971 int ret = -ENOTSUP; 14972 14973 if (port_id_is_invalid(res->port_id, ENABLED_WARN)) 14974 return; 14975 14976 ret = vf_tc_min_bw_parse_bw_list(bw, &tc_num, res->bw_list); 14977 if (ret) 14978 return; 14979 14980 #ifdef RTE_LIBRTE_I40E_PMD 14981 ret = rte_pmd_i40e_set_vf_tc_bw_alloc(res->port_id, res->vf_id, 14982 tc_num, bw); 14983 #endif 14984 14985 switch (ret) { 14986 case 0: 14987 break; 14988 case -EINVAL: 14989 printf("invalid vf_id %d or bandwidth\n", res->vf_id); 14990 break; 14991 case -ENODEV: 14992 printf("invalid port_id %d\n", res->port_id); 14993 break; 14994 case -ENOTSUP: 14995 printf("function not implemented\n"); 14996 break; 14997 default: 14998 printf("programming error: (%s)\n", strerror(-ret)); 14999 } 15000 } 15001 15002 cmdline_parse_inst_t cmd_vf_tc_min_bw = { 15003 .f = cmd_vf_tc_min_bw_parsed, 15004 .data = NULL, 15005 .help_str = "set vf tc tx min-bandwidth <port_id> <vf_id>" 15006 " <bw1, bw2, ...>", 15007 .tokens = { 15008 (void *)&cmd_vf_tc_bw_set, 15009 (void *)&cmd_vf_tc_bw_vf, 15010 (void *)&cmd_vf_tc_bw_tc, 15011 (void *)&cmd_vf_tc_bw_tx, 15012 (void *)&cmd_vf_tc_bw_min_bw, 15013 (void *)&cmd_vf_tc_bw_port_id, 15014 (void *)&cmd_vf_tc_bw_vf_id, 15015 (void *)&cmd_vf_tc_bw_bw_list, 15016 NULL, 15017 }, 15018 }; 15019 15020 static void 15021 cmd_tc_min_bw_parsed( 15022 void *parsed_result, 15023 __attribute__((unused)) struct cmdline *cl, 15024 __attribute__((unused)) void *data) 15025 { 15026 struct cmd_vf_tc_bw_result *res = parsed_result; 15027 struct rte_port *port; 15028 uint8_t tc_num; 15029 uint8_t bw[16]; 15030 int ret = -ENOTSUP; 15031 15032 if (port_id_is_invalid(res->port_id, ENABLED_WARN)) 15033 return; 15034 15035 port = &ports[res->port_id]; 15036 /** Check if the port is not started **/ 15037 if (port->port_status != RTE_PORT_STOPPED) { 15038 printf("Please stop port %d first\n", res->port_id); 15039 return; 15040 } 15041 15042 ret = vf_tc_min_bw_parse_bw_list(bw, &tc_num, res->bw_list); 15043 if (ret) 15044 return; 15045 15046 #ifdef RTE_LIBRTE_IXGBE_PMD 15047 ret = rte_pmd_ixgbe_set_tc_bw_alloc(res->port_id, tc_num, bw); 15048 #endif 15049 15050 switch (ret) { 15051 case 0: 15052 break; 15053 case -EINVAL: 15054 printf("invalid bandwidth\n"); 15055 break; 15056 case -ENODEV: 15057 printf("invalid port_id %d\n", res->port_id); 15058 break; 15059 case -ENOTSUP: 15060 printf("function not implemented\n"); 15061 break; 15062 default: 15063 printf("programming error: (%s)\n", strerror(-ret)); 15064 } 15065 } 15066 15067 cmdline_parse_inst_t cmd_tc_min_bw = { 15068 .f = cmd_tc_min_bw_parsed, 15069 .data = NULL, 15070 .help_str = "set tc tx min-bandwidth <port_id> <bw1, bw2, ...>", 15071 .tokens = { 15072 (void *)&cmd_vf_tc_bw_set, 15073 (void *)&cmd_vf_tc_bw_tc, 15074 (void *)&cmd_vf_tc_bw_tx, 15075 (void *)&cmd_vf_tc_bw_min_bw, 15076 (void *)&cmd_vf_tc_bw_port_id, 15077 (void *)&cmd_vf_tc_bw_bw_list, 15078 NULL, 15079 }, 15080 }; 15081 15082 /* TC max bandwidth setting */ 15083 static void 15084 cmd_vf_tc_max_bw_parsed( 15085 void *parsed_result, 15086 __attribute__((unused)) struct cmdline *cl, 15087 __attribute__((unused)) void *data) 15088 { 15089 struct cmd_vf_tc_bw_result *res = parsed_result; 15090 int ret = -ENOTSUP; 15091 15092 if (port_id_is_invalid(res->port_id, ENABLED_WARN)) 15093 return; 15094 15095 #ifdef RTE_LIBRTE_I40E_PMD 15096 ret = rte_pmd_i40e_set_vf_tc_max_bw(res->port_id, res->vf_id, 15097 res->tc_no, res->bw); 15098 #endif 15099 15100 switch (ret) { 15101 case 0: 15102 break; 15103 case -EINVAL: 15104 printf("invalid vf_id %d, tc_no %d or bandwidth %d\n", 15105 res->vf_id, res->tc_no, res->bw); 15106 break; 15107 case -ENODEV: 15108 printf("invalid port_id %d\n", res->port_id); 15109 break; 15110 case -ENOTSUP: 15111 printf("function not implemented\n"); 15112 break; 15113 default: 15114 printf("programming error: (%s)\n", strerror(-ret)); 15115 } 15116 } 15117 15118 cmdline_parse_inst_t cmd_vf_tc_max_bw = { 15119 .f = cmd_vf_tc_max_bw_parsed, 15120 .data = NULL, 15121 .help_str = "set vf tc tx max-bandwidth <port_id> <vf_id> <tc_no>" 15122 " <bandwidth>", 15123 .tokens = { 15124 (void *)&cmd_vf_tc_bw_set, 15125 (void *)&cmd_vf_tc_bw_vf, 15126 (void *)&cmd_vf_tc_bw_tc, 15127 (void *)&cmd_vf_tc_bw_tx, 15128 (void *)&cmd_vf_tc_bw_max_bw, 15129 (void *)&cmd_vf_tc_bw_port_id, 15130 (void *)&cmd_vf_tc_bw_vf_id, 15131 (void *)&cmd_vf_tc_bw_tc_no, 15132 (void *)&cmd_vf_tc_bw_bw, 15133 NULL, 15134 }, 15135 }; 15136 15137 15138 #if defined RTE_LIBRTE_PMD_SOFTNIC && defined RTE_LIBRTE_SCHED 15139 15140 /* *** Set Port default Traffic Management Hierarchy *** */ 15141 struct cmd_set_port_tm_hierarchy_default_result { 15142 cmdline_fixed_string_t set; 15143 cmdline_fixed_string_t port; 15144 cmdline_fixed_string_t tm; 15145 cmdline_fixed_string_t hierarchy; 15146 cmdline_fixed_string_t def; 15147 portid_t port_id; 15148 }; 15149 15150 cmdline_parse_token_string_t cmd_set_port_tm_hierarchy_default_set = 15151 TOKEN_STRING_INITIALIZER( 15152 struct cmd_set_port_tm_hierarchy_default_result, set, "set"); 15153 cmdline_parse_token_string_t cmd_set_port_tm_hierarchy_default_port = 15154 TOKEN_STRING_INITIALIZER( 15155 struct cmd_set_port_tm_hierarchy_default_result, port, "port"); 15156 cmdline_parse_token_string_t cmd_set_port_tm_hierarchy_default_tm = 15157 TOKEN_STRING_INITIALIZER( 15158 struct cmd_set_port_tm_hierarchy_default_result, tm, "tm"); 15159 cmdline_parse_token_string_t cmd_set_port_tm_hierarchy_default_hierarchy = 15160 TOKEN_STRING_INITIALIZER( 15161 struct cmd_set_port_tm_hierarchy_default_result, 15162 hierarchy, "hierarchy"); 15163 cmdline_parse_token_string_t cmd_set_port_tm_hierarchy_default_default = 15164 TOKEN_STRING_INITIALIZER( 15165 struct cmd_set_port_tm_hierarchy_default_result, 15166 def, "default"); 15167 cmdline_parse_token_num_t cmd_set_port_tm_hierarchy_default_port_id = 15168 TOKEN_NUM_INITIALIZER( 15169 struct cmd_set_port_tm_hierarchy_default_result, 15170 port_id, UINT16); 15171 15172 static void cmd_set_port_tm_hierarchy_default_parsed(void *parsed_result, 15173 __attribute__((unused)) struct cmdline *cl, 15174 __attribute__((unused)) void *data) 15175 { 15176 struct cmd_set_port_tm_hierarchy_default_result *res = parsed_result; 15177 struct rte_port *p; 15178 portid_t port_id = res->port_id; 15179 15180 if (port_id_is_invalid(port_id, ENABLED_WARN)) 15181 return; 15182 15183 p = &ports[port_id]; 15184 15185 /* Forward mode: tm */ 15186 if (strcmp(cur_fwd_config.fwd_eng->fwd_mode_name, "softnic")) { 15187 printf(" softnicfwd mode not enabled(error)\n"); 15188 return; 15189 } 15190 15191 /* Set the default tm hierarchy */ 15192 p->softport.default_tm_hierarchy_enable = 1; 15193 } 15194 15195 cmdline_parse_inst_t cmd_set_port_tm_hierarchy_default = { 15196 .f = cmd_set_port_tm_hierarchy_default_parsed, 15197 .data = NULL, 15198 .help_str = "set port tm hierarchy default <port_id>", 15199 .tokens = { 15200 (void *)&cmd_set_port_tm_hierarchy_default_set, 15201 (void *)&cmd_set_port_tm_hierarchy_default_port, 15202 (void *)&cmd_set_port_tm_hierarchy_default_tm, 15203 (void *)&cmd_set_port_tm_hierarchy_default_hierarchy, 15204 (void *)&cmd_set_port_tm_hierarchy_default_default, 15205 (void *)&cmd_set_port_tm_hierarchy_default_port_id, 15206 NULL, 15207 }, 15208 }; 15209 #endif 15210 15211 /** Set VXLAN encapsulation details */ 15212 struct cmd_set_vxlan_result { 15213 cmdline_fixed_string_t set; 15214 cmdline_fixed_string_t vxlan; 15215 cmdline_fixed_string_t pos_token; 15216 cmdline_fixed_string_t ip_version; 15217 uint32_t vlan_present:1; 15218 uint32_t vni; 15219 uint16_t udp_src; 15220 uint16_t udp_dst; 15221 cmdline_ipaddr_t ip_src; 15222 cmdline_ipaddr_t ip_dst; 15223 uint16_t tci; 15224 uint8_t tos; 15225 uint8_t ttl; 15226 struct rte_ether_addr eth_src; 15227 struct rte_ether_addr eth_dst; 15228 }; 15229 15230 cmdline_parse_token_string_t cmd_set_vxlan_set = 15231 TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, set, "set"); 15232 cmdline_parse_token_string_t cmd_set_vxlan_vxlan = 15233 TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, vxlan, "vxlan"); 15234 cmdline_parse_token_string_t cmd_set_vxlan_vxlan_tos_ttl = 15235 TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, vxlan, 15236 "vxlan-tos-ttl"); 15237 cmdline_parse_token_string_t cmd_set_vxlan_vxlan_with_vlan = 15238 TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, vxlan, 15239 "vxlan-with-vlan"); 15240 cmdline_parse_token_string_t cmd_set_vxlan_ip_version = 15241 TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, pos_token, 15242 "ip-version"); 15243 cmdline_parse_token_string_t cmd_set_vxlan_ip_version_value = 15244 TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, ip_version, 15245 "ipv4#ipv6"); 15246 cmdline_parse_token_string_t cmd_set_vxlan_vni = 15247 TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, pos_token, 15248 "vni"); 15249 cmdline_parse_token_num_t cmd_set_vxlan_vni_value = 15250 TOKEN_NUM_INITIALIZER(struct cmd_set_vxlan_result, vni, UINT32); 15251 cmdline_parse_token_string_t cmd_set_vxlan_udp_src = 15252 TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, pos_token, 15253 "udp-src"); 15254 cmdline_parse_token_num_t cmd_set_vxlan_udp_src_value = 15255 TOKEN_NUM_INITIALIZER(struct cmd_set_vxlan_result, udp_src, UINT16); 15256 cmdline_parse_token_string_t cmd_set_vxlan_udp_dst = 15257 TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, pos_token, 15258 "udp-dst"); 15259 cmdline_parse_token_num_t cmd_set_vxlan_udp_dst_value = 15260 TOKEN_NUM_INITIALIZER(struct cmd_set_vxlan_result, udp_dst, UINT16); 15261 cmdline_parse_token_string_t cmd_set_vxlan_ip_tos = 15262 TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, pos_token, 15263 "ip-tos"); 15264 cmdline_parse_token_num_t cmd_set_vxlan_ip_tos_value = 15265 TOKEN_NUM_INITIALIZER(struct cmd_set_vxlan_result, tos, UINT8); 15266 cmdline_parse_token_string_t cmd_set_vxlan_ip_ttl = 15267 TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, pos_token, 15268 "ip-ttl"); 15269 cmdline_parse_token_num_t cmd_set_vxlan_ip_ttl_value = 15270 TOKEN_NUM_INITIALIZER(struct cmd_set_vxlan_result, ttl, UINT8); 15271 cmdline_parse_token_string_t cmd_set_vxlan_ip_src = 15272 TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, pos_token, 15273 "ip-src"); 15274 cmdline_parse_token_ipaddr_t cmd_set_vxlan_ip_src_value = 15275 TOKEN_IPADDR_INITIALIZER(struct cmd_set_vxlan_result, ip_src); 15276 cmdline_parse_token_string_t cmd_set_vxlan_ip_dst = 15277 TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, pos_token, 15278 "ip-dst"); 15279 cmdline_parse_token_ipaddr_t cmd_set_vxlan_ip_dst_value = 15280 TOKEN_IPADDR_INITIALIZER(struct cmd_set_vxlan_result, ip_dst); 15281 cmdline_parse_token_string_t cmd_set_vxlan_vlan = 15282 TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, pos_token, 15283 "vlan-tci"); 15284 cmdline_parse_token_num_t cmd_set_vxlan_vlan_value = 15285 TOKEN_NUM_INITIALIZER(struct cmd_set_vxlan_result, tci, UINT16); 15286 cmdline_parse_token_string_t cmd_set_vxlan_eth_src = 15287 TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, pos_token, 15288 "eth-src"); 15289 cmdline_parse_token_etheraddr_t cmd_set_vxlan_eth_src_value = 15290 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_vxlan_result, eth_src); 15291 cmdline_parse_token_string_t cmd_set_vxlan_eth_dst = 15292 TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, pos_token, 15293 "eth-dst"); 15294 cmdline_parse_token_etheraddr_t cmd_set_vxlan_eth_dst_value = 15295 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_vxlan_result, eth_dst); 15296 15297 static void cmd_set_vxlan_parsed(void *parsed_result, 15298 __attribute__((unused)) struct cmdline *cl, 15299 __attribute__((unused)) void *data) 15300 { 15301 struct cmd_set_vxlan_result *res = parsed_result; 15302 union { 15303 uint32_t vxlan_id; 15304 uint8_t vni[4]; 15305 } id = { 15306 .vxlan_id = rte_cpu_to_be_32(res->vni) & RTE_BE32(0x00ffffff), 15307 }; 15308 15309 vxlan_encap_conf.select_tos_ttl = 0; 15310 if (strcmp(res->vxlan, "vxlan") == 0) 15311 vxlan_encap_conf.select_vlan = 0; 15312 else if (strcmp(res->vxlan, "vxlan-with-vlan") == 0) 15313 vxlan_encap_conf.select_vlan = 1; 15314 else if (strcmp(res->vxlan, "vxlan-tos-ttl") == 0) { 15315 vxlan_encap_conf.select_vlan = 0; 15316 vxlan_encap_conf.select_tos_ttl = 1; 15317 } 15318 if (strcmp(res->ip_version, "ipv4") == 0) 15319 vxlan_encap_conf.select_ipv4 = 1; 15320 else if (strcmp(res->ip_version, "ipv6") == 0) 15321 vxlan_encap_conf.select_ipv4 = 0; 15322 else 15323 return; 15324 rte_memcpy(vxlan_encap_conf.vni, &id.vni[1], 3); 15325 vxlan_encap_conf.udp_src = rte_cpu_to_be_16(res->udp_src); 15326 vxlan_encap_conf.udp_dst = rte_cpu_to_be_16(res->udp_dst); 15327 vxlan_encap_conf.ip_tos = res->tos; 15328 vxlan_encap_conf.ip_ttl = res->ttl; 15329 if (vxlan_encap_conf.select_ipv4) { 15330 IPV4_ADDR_TO_UINT(res->ip_src, vxlan_encap_conf.ipv4_src); 15331 IPV4_ADDR_TO_UINT(res->ip_dst, vxlan_encap_conf.ipv4_dst); 15332 } else { 15333 IPV6_ADDR_TO_ARRAY(res->ip_src, vxlan_encap_conf.ipv6_src); 15334 IPV6_ADDR_TO_ARRAY(res->ip_dst, vxlan_encap_conf.ipv6_dst); 15335 } 15336 if (vxlan_encap_conf.select_vlan) 15337 vxlan_encap_conf.vlan_tci = rte_cpu_to_be_16(res->tci); 15338 rte_memcpy(vxlan_encap_conf.eth_src, res->eth_src.addr_bytes, 15339 RTE_ETHER_ADDR_LEN); 15340 rte_memcpy(vxlan_encap_conf.eth_dst, res->eth_dst.addr_bytes, 15341 RTE_ETHER_ADDR_LEN); 15342 } 15343 15344 cmdline_parse_inst_t cmd_set_vxlan = { 15345 .f = cmd_set_vxlan_parsed, 15346 .data = NULL, 15347 .help_str = "set vxlan ip-version ipv4|ipv6 vni <vni> udp-src" 15348 " <udp-src> udp-dst <udp-dst> ip-src <ip-src> ip-dst <ip-dst>" 15349 " eth-src <eth-src> eth-dst <eth-dst>", 15350 .tokens = { 15351 (void *)&cmd_set_vxlan_set, 15352 (void *)&cmd_set_vxlan_vxlan, 15353 (void *)&cmd_set_vxlan_ip_version, 15354 (void *)&cmd_set_vxlan_ip_version_value, 15355 (void *)&cmd_set_vxlan_vni, 15356 (void *)&cmd_set_vxlan_vni_value, 15357 (void *)&cmd_set_vxlan_udp_src, 15358 (void *)&cmd_set_vxlan_udp_src_value, 15359 (void *)&cmd_set_vxlan_udp_dst, 15360 (void *)&cmd_set_vxlan_udp_dst_value, 15361 (void *)&cmd_set_vxlan_ip_src, 15362 (void *)&cmd_set_vxlan_ip_src_value, 15363 (void *)&cmd_set_vxlan_ip_dst, 15364 (void *)&cmd_set_vxlan_ip_dst_value, 15365 (void *)&cmd_set_vxlan_eth_src, 15366 (void *)&cmd_set_vxlan_eth_src_value, 15367 (void *)&cmd_set_vxlan_eth_dst, 15368 (void *)&cmd_set_vxlan_eth_dst_value, 15369 NULL, 15370 }, 15371 }; 15372 15373 cmdline_parse_inst_t cmd_set_vxlan_tos_ttl = { 15374 .f = cmd_set_vxlan_parsed, 15375 .data = NULL, 15376 .help_str = "set vxlan-tos-ttl ip-version ipv4|ipv6 vni <vni> udp-src" 15377 " <udp-src> udp-dst <udp-dst> ip-tos <ip-tos> ip-ttl <ip-ttl>" 15378 " ip-src <ip-src> ip-dst <ip-dst> eth-src <eth-src>" 15379 " eth-dst <eth-dst>", 15380 .tokens = { 15381 (void *)&cmd_set_vxlan_set, 15382 (void *)&cmd_set_vxlan_vxlan_tos_ttl, 15383 (void *)&cmd_set_vxlan_ip_version, 15384 (void *)&cmd_set_vxlan_ip_version_value, 15385 (void *)&cmd_set_vxlan_vni, 15386 (void *)&cmd_set_vxlan_vni_value, 15387 (void *)&cmd_set_vxlan_udp_src, 15388 (void *)&cmd_set_vxlan_udp_src_value, 15389 (void *)&cmd_set_vxlan_udp_dst, 15390 (void *)&cmd_set_vxlan_udp_dst_value, 15391 (void *)&cmd_set_vxlan_ip_tos, 15392 (void *)&cmd_set_vxlan_ip_tos_value, 15393 (void *)&cmd_set_vxlan_ip_ttl, 15394 (void *)&cmd_set_vxlan_ip_ttl_value, 15395 (void *)&cmd_set_vxlan_ip_src, 15396 (void *)&cmd_set_vxlan_ip_src_value, 15397 (void *)&cmd_set_vxlan_ip_dst, 15398 (void *)&cmd_set_vxlan_ip_dst_value, 15399 (void *)&cmd_set_vxlan_eth_src, 15400 (void *)&cmd_set_vxlan_eth_src_value, 15401 (void *)&cmd_set_vxlan_eth_dst, 15402 (void *)&cmd_set_vxlan_eth_dst_value, 15403 NULL, 15404 }, 15405 }; 15406 15407 cmdline_parse_inst_t cmd_set_vxlan_with_vlan = { 15408 .f = cmd_set_vxlan_parsed, 15409 .data = NULL, 15410 .help_str = "set vxlan-with-vlan ip-version ipv4|ipv6 vni <vni>" 15411 " udp-src <udp-src> udp-dst <udp-dst> ip-src <ip-src> ip-dst" 15412 " <ip-dst> vlan-tci <vlan-tci> eth-src <eth-src> eth-dst" 15413 " <eth-dst>", 15414 .tokens = { 15415 (void *)&cmd_set_vxlan_set, 15416 (void *)&cmd_set_vxlan_vxlan_with_vlan, 15417 (void *)&cmd_set_vxlan_ip_version, 15418 (void *)&cmd_set_vxlan_ip_version_value, 15419 (void *)&cmd_set_vxlan_vni, 15420 (void *)&cmd_set_vxlan_vni_value, 15421 (void *)&cmd_set_vxlan_udp_src, 15422 (void *)&cmd_set_vxlan_udp_src_value, 15423 (void *)&cmd_set_vxlan_udp_dst, 15424 (void *)&cmd_set_vxlan_udp_dst_value, 15425 (void *)&cmd_set_vxlan_ip_src, 15426 (void *)&cmd_set_vxlan_ip_src_value, 15427 (void *)&cmd_set_vxlan_ip_dst, 15428 (void *)&cmd_set_vxlan_ip_dst_value, 15429 (void *)&cmd_set_vxlan_vlan, 15430 (void *)&cmd_set_vxlan_vlan_value, 15431 (void *)&cmd_set_vxlan_eth_src, 15432 (void *)&cmd_set_vxlan_eth_src_value, 15433 (void *)&cmd_set_vxlan_eth_dst, 15434 (void *)&cmd_set_vxlan_eth_dst_value, 15435 NULL, 15436 }, 15437 }; 15438 15439 /** Set NVGRE encapsulation details */ 15440 struct cmd_set_nvgre_result { 15441 cmdline_fixed_string_t set; 15442 cmdline_fixed_string_t nvgre; 15443 cmdline_fixed_string_t pos_token; 15444 cmdline_fixed_string_t ip_version; 15445 uint32_t tni; 15446 cmdline_ipaddr_t ip_src; 15447 cmdline_ipaddr_t ip_dst; 15448 uint16_t tci; 15449 struct rte_ether_addr eth_src; 15450 struct rte_ether_addr eth_dst; 15451 }; 15452 15453 cmdline_parse_token_string_t cmd_set_nvgre_set = 15454 TOKEN_STRING_INITIALIZER(struct cmd_set_nvgre_result, set, "set"); 15455 cmdline_parse_token_string_t cmd_set_nvgre_nvgre = 15456 TOKEN_STRING_INITIALIZER(struct cmd_set_nvgre_result, nvgre, "nvgre"); 15457 cmdline_parse_token_string_t cmd_set_nvgre_nvgre_with_vlan = 15458 TOKEN_STRING_INITIALIZER(struct cmd_set_nvgre_result, nvgre, 15459 "nvgre-with-vlan"); 15460 cmdline_parse_token_string_t cmd_set_nvgre_ip_version = 15461 TOKEN_STRING_INITIALIZER(struct cmd_set_nvgre_result, pos_token, 15462 "ip-version"); 15463 cmdline_parse_token_string_t cmd_set_nvgre_ip_version_value = 15464 TOKEN_STRING_INITIALIZER(struct cmd_set_nvgre_result, ip_version, 15465 "ipv4#ipv6"); 15466 cmdline_parse_token_string_t cmd_set_nvgre_tni = 15467 TOKEN_STRING_INITIALIZER(struct cmd_set_nvgre_result, pos_token, 15468 "tni"); 15469 cmdline_parse_token_num_t cmd_set_nvgre_tni_value = 15470 TOKEN_NUM_INITIALIZER(struct cmd_set_nvgre_result, tni, UINT32); 15471 cmdline_parse_token_string_t cmd_set_nvgre_ip_src = 15472 TOKEN_STRING_INITIALIZER(struct cmd_set_nvgre_result, pos_token, 15473 "ip-src"); 15474 cmdline_parse_token_num_t cmd_set_nvgre_ip_src_value = 15475 TOKEN_IPADDR_INITIALIZER(struct cmd_set_nvgre_result, ip_src); 15476 cmdline_parse_token_string_t cmd_set_nvgre_ip_dst = 15477 TOKEN_STRING_INITIALIZER(struct cmd_set_nvgre_result, pos_token, 15478 "ip-dst"); 15479 cmdline_parse_token_ipaddr_t cmd_set_nvgre_ip_dst_value = 15480 TOKEN_IPADDR_INITIALIZER(struct cmd_set_nvgre_result, ip_dst); 15481 cmdline_parse_token_string_t cmd_set_nvgre_vlan = 15482 TOKEN_STRING_INITIALIZER(struct cmd_set_nvgre_result, pos_token, 15483 "vlan-tci"); 15484 cmdline_parse_token_num_t cmd_set_nvgre_vlan_value = 15485 TOKEN_NUM_INITIALIZER(struct cmd_set_nvgre_result, tci, UINT16); 15486 cmdline_parse_token_string_t cmd_set_nvgre_eth_src = 15487 TOKEN_STRING_INITIALIZER(struct cmd_set_nvgre_result, pos_token, 15488 "eth-src"); 15489 cmdline_parse_token_etheraddr_t cmd_set_nvgre_eth_src_value = 15490 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_nvgre_result, eth_src); 15491 cmdline_parse_token_string_t cmd_set_nvgre_eth_dst = 15492 TOKEN_STRING_INITIALIZER(struct cmd_set_nvgre_result, pos_token, 15493 "eth-dst"); 15494 cmdline_parse_token_etheraddr_t cmd_set_nvgre_eth_dst_value = 15495 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_nvgre_result, eth_dst); 15496 15497 static void cmd_set_nvgre_parsed(void *parsed_result, 15498 __attribute__((unused)) struct cmdline *cl, 15499 __attribute__((unused)) void *data) 15500 { 15501 struct cmd_set_nvgre_result *res = parsed_result; 15502 union { 15503 uint32_t nvgre_tni; 15504 uint8_t tni[4]; 15505 } id = { 15506 .nvgre_tni = rte_cpu_to_be_32(res->tni) & RTE_BE32(0x00ffffff), 15507 }; 15508 15509 if (strcmp(res->nvgre, "nvgre") == 0) 15510 nvgre_encap_conf.select_vlan = 0; 15511 else if (strcmp(res->nvgre, "nvgre-with-vlan") == 0) 15512 nvgre_encap_conf.select_vlan = 1; 15513 if (strcmp(res->ip_version, "ipv4") == 0) 15514 nvgre_encap_conf.select_ipv4 = 1; 15515 else if (strcmp(res->ip_version, "ipv6") == 0) 15516 nvgre_encap_conf.select_ipv4 = 0; 15517 else 15518 return; 15519 rte_memcpy(nvgre_encap_conf.tni, &id.tni[1], 3); 15520 if (nvgre_encap_conf.select_ipv4) { 15521 IPV4_ADDR_TO_UINT(res->ip_src, nvgre_encap_conf.ipv4_src); 15522 IPV4_ADDR_TO_UINT(res->ip_dst, nvgre_encap_conf.ipv4_dst); 15523 } else { 15524 IPV6_ADDR_TO_ARRAY(res->ip_src, nvgre_encap_conf.ipv6_src); 15525 IPV6_ADDR_TO_ARRAY(res->ip_dst, nvgre_encap_conf.ipv6_dst); 15526 } 15527 if (nvgre_encap_conf.select_vlan) 15528 nvgre_encap_conf.vlan_tci = rte_cpu_to_be_16(res->tci); 15529 rte_memcpy(nvgre_encap_conf.eth_src, res->eth_src.addr_bytes, 15530 RTE_ETHER_ADDR_LEN); 15531 rte_memcpy(nvgre_encap_conf.eth_dst, res->eth_dst.addr_bytes, 15532 RTE_ETHER_ADDR_LEN); 15533 } 15534 15535 cmdline_parse_inst_t cmd_set_nvgre = { 15536 .f = cmd_set_nvgre_parsed, 15537 .data = NULL, 15538 .help_str = "set nvgre ip-version <ipv4|ipv6> tni <tni> ip-src" 15539 " <ip-src> ip-dst <ip-dst> eth-src <eth-src>" 15540 " eth-dst <eth-dst>", 15541 .tokens = { 15542 (void *)&cmd_set_nvgre_set, 15543 (void *)&cmd_set_nvgre_nvgre, 15544 (void *)&cmd_set_nvgre_ip_version, 15545 (void *)&cmd_set_nvgre_ip_version_value, 15546 (void *)&cmd_set_nvgre_tni, 15547 (void *)&cmd_set_nvgre_tni_value, 15548 (void *)&cmd_set_nvgre_ip_src, 15549 (void *)&cmd_set_nvgre_ip_src_value, 15550 (void *)&cmd_set_nvgre_ip_dst, 15551 (void *)&cmd_set_nvgre_ip_dst_value, 15552 (void *)&cmd_set_nvgre_eth_src, 15553 (void *)&cmd_set_nvgre_eth_src_value, 15554 (void *)&cmd_set_nvgre_eth_dst, 15555 (void *)&cmd_set_nvgre_eth_dst_value, 15556 NULL, 15557 }, 15558 }; 15559 15560 cmdline_parse_inst_t cmd_set_nvgre_with_vlan = { 15561 .f = cmd_set_nvgre_parsed, 15562 .data = NULL, 15563 .help_str = "set nvgre-with-vlan ip-version <ipv4|ipv6> tni <tni>" 15564 " ip-src <ip-src> ip-dst <ip-dst> vlan-tci <vlan-tci>" 15565 " eth-src <eth-src> eth-dst <eth-dst>", 15566 .tokens = { 15567 (void *)&cmd_set_nvgre_set, 15568 (void *)&cmd_set_nvgre_nvgre_with_vlan, 15569 (void *)&cmd_set_nvgre_ip_version, 15570 (void *)&cmd_set_nvgre_ip_version_value, 15571 (void *)&cmd_set_nvgre_tni, 15572 (void *)&cmd_set_nvgre_tni_value, 15573 (void *)&cmd_set_nvgre_ip_src, 15574 (void *)&cmd_set_nvgre_ip_src_value, 15575 (void *)&cmd_set_nvgre_ip_dst, 15576 (void *)&cmd_set_nvgre_ip_dst_value, 15577 (void *)&cmd_set_nvgre_vlan, 15578 (void *)&cmd_set_nvgre_vlan_value, 15579 (void *)&cmd_set_nvgre_eth_src, 15580 (void *)&cmd_set_nvgre_eth_src_value, 15581 (void *)&cmd_set_nvgre_eth_dst, 15582 (void *)&cmd_set_nvgre_eth_dst_value, 15583 NULL, 15584 }, 15585 }; 15586 15587 /** Set L2 encapsulation details */ 15588 struct cmd_set_l2_encap_result { 15589 cmdline_fixed_string_t set; 15590 cmdline_fixed_string_t l2_encap; 15591 cmdline_fixed_string_t pos_token; 15592 cmdline_fixed_string_t ip_version; 15593 uint32_t vlan_present:1; 15594 uint16_t tci; 15595 struct rte_ether_addr eth_src; 15596 struct rte_ether_addr eth_dst; 15597 }; 15598 15599 cmdline_parse_token_string_t cmd_set_l2_encap_set = 15600 TOKEN_STRING_INITIALIZER(struct cmd_set_l2_encap_result, set, "set"); 15601 cmdline_parse_token_string_t cmd_set_l2_encap_l2_encap = 15602 TOKEN_STRING_INITIALIZER(struct cmd_set_l2_encap_result, l2_encap, "l2_encap"); 15603 cmdline_parse_token_string_t cmd_set_l2_encap_l2_encap_with_vlan = 15604 TOKEN_STRING_INITIALIZER(struct cmd_set_l2_encap_result, l2_encap, 15605 "l2_encap-with-vlan"); 15606 cmdline_parse_token_string_t cmd_set_l2_encap_ip_version = 15607 TOKEN_STRING_INITIALIZER(struct cmd_set_l2_encap_result, pos_token, 15608 "ip-version"); 15609 cmdline_parse_token_string_t cmd_set_l2_encap_ip_version_value = 15610 TOKEN_STRING_INITIALIZER(struct cmd_set_l2_encap_result, ip_version, 15611 "ipv4#ipv6"); 15612 cmdline_parse_token_string_t cmd_set_l2_encap_vlan = 15613 TOKEN_STRING_INITIALIZER(struct cmd_set_l2_encap_result, pos_token, 15614 "vlan-tci"); 15615 cmdline_parse_token_num_t cmd_set_l2_encap_vlan_value = 15616 TOKEN_NUM_INITIALIZER(struct cmd_set_l2_encap_result, tci, UINT16); 15617 cmdline_parse_token_string_t cmd_set_l2_encap_eth_src = 15618 TOKEN_STRING_INITIALIZER(struct cmd_set_l2_encap_result, pos_token, 15619 "eth-src"); 15620 cmdline_parse_token_etheraddr_t cmd_set_l2_encap_eth_src_value = 15621 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_l2_encap_result, eth_src); 15622 cmdline_parse_token_string_t cmd_set_l2_encap_eth_dst = 15623 TOKEN_STRING_INITIALIZER(struct cmd_set_l2_encap_result, pos_token, 15624 "eth-dst"); 15625 cmdline_parse_token_etheraddr_t cmd_set_l2_encap_eth_dst_value = 15626 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_l2_encap_result, eth_dst); 15627 15628 static void cmd_set_l2_encap_parsed(void *parsed_result, 15629 __attribute__((unused)) struct cmdline *cl, 15630 __attribute__((unused)) void *data) 15631 { 15632 struct cmd_set_l2_encap_result *res = parsed_result; 15633 15634 if (strcmp(res->l2_encap, "l2_encap") == 0) 15635 l2_encap_conf.select_vlan = 0; 15636 else if (strcmp(res->l2_encap, "l2_encap-with-vlan") == 0) 15637 l2_encap_conf.select_vlan = 1; 15638 if (strcmp(res->ip_version, "ipv4") == 0) 15639 l2_encap_conf.select_ipv4 = 1; 15640 else if (strcmp(res->ip_version, "ipv6") == 0) 15641 l2_encap_conf.select_ipv4 = 0; 15642 else 15643 return; 15644 if (l2_encap_conf.select_vlan) 15645 l2_encap_conf.vlan_tci = rte_cpu_to_be_16(res->tci); 15646 rte_memcpy(l2_encap_conf.eth_src, res->eth_src.addr_bytes, 15647 RTE_ETHER_ADDR_LEN); 15648 rte_memcpy(l2_encap_conf.eth_dst, res->eth_dst.addr_bytes, 15649 RTE_ETHER_ADDR_LEN); 15650 } 15651 15652 cmdline_parse_inst_t cmd_set_l2_encap = { 15653 .f = cmd_set_l2_encap_parsed, 15654 .data = NULL, 15655 .help_str = "set l2_encap ip-version ipv4|ipv6" 15656 " eth-src <eth-src> eth-dst <eth-dst>", 15657 .tokens = { 15658 (void *)&cmd_set_l2_encap_set, 15659 (void *)&cmd_set_l2_encap_l2_encap, 15660 (void *)&cmd_set_l2_encap_ip_version, 15661 (void *)&cmd_set_l2_encap_ip_version_value, 15662 (void *)&cmd_set_l2_encap_eth_src, 15663 (void *)&cmd_set_l2_encap_eth_src_value, 15664 (void *)&cmd_set_l2_encap_eth_dst, 15665 (void *)&cmd_set_l2_encap_eth_dst_value, 15666 NULL, 15667 }, 15668 }; 15669 15670 cmdline_parse_inst_t cmd_set_l2_encap_with_vlan = { 15671 .f = cmd_set_l2_encap_parsed, 15672 .data = NULL, 15673 .help_str = "set l2_encap-with-vlan ip-version ipv4|ipv6" 15674 " vlan-tci <vlan-tci> eth-src <eth-src> eth-dst <eth-dst>", 15675 .tokens = { 15676 (void *)&cmd_set_l2_encap_set, 15677 (void *)&cmd_set_l2_encap_l2_encap_with_vlan, 15678 (void *)&cmd_set_l2_encap_ip_version, 15679 (void *)&cmd_set_l2_encap_ip_version_value, 15680 (void *)&cmd_set_l2_encap_vlan, 15681 (void *)&cmd_set_l2_encap_vlan_value, 15682 (void *)&cmd_set_l2_encap_eth_src, 15683 (void *)&cmd_set_l2_encap_eth_src_value, 15684 (void *)&cmd_set_l2_encap_eth_dst, 15685 (void *)&cmd_set_l2_encap_eth_dst_value, 15686 NULL, 15687 }, 15688 }; 15689 15690 /** Set L2 decapsulation details */ 15691 struct cmd_set_l2_decap_result { 15692 cmdline_fixed_string_t set; 15693 cmdline_fixed_string_t l2_decap; 15694 cmdline_fixed_string_t pos_token; 15695 uint32_t vlan_present:1; 15696 }; 15697 15698 cmdline_parse_token_string_t cmd_set_l2_decap_set = 15699 TOKEN_STRING_INITIALIZER(struct cmd_set_l2_decap_result, set, "set"); 15700 cmdline_parse_token_string_t cmd_set_l2_decap_l2_decap = 15701 TOKEN_STRING_INITIALIZER(struct cmd_set_l2_decap_result, l2_decap, 15702 "l2_decap"); 15703 cmdline_parse_token_string_t cmd_set_l2_decap_l2_decap_with_vlan = 15704 TOKEN_STRING_INITIALIZER(struct cmd_set_l2_decap_result, l2_decap, 15705 "l2_decap-with-vlan"); 15706 15707 static void cmd_set_l2_decap_parsed(void *parsed_result, 15708 __attribute__((unused)) struct cmdline *cl, 15709 __attribute__((unused)) void *data) 15710 { 15711 struct cmd_set_l2_decap_result *res = parsed_result; 15712 15713 if (strcmp(res->l2_decap, "l2_decap") == 0) 15714 l2_decap_conf.select_vlan = 0; 15715 else if (strcmp(res->l2_decap, "l2_decap-with-vlan") == 0) 15716 l2_decap_conf.select_vlan = 1; 15717 } 15718 15719 cmdline_parse_inst_t cmd_set_l2_decap = { 15720 .f = cmd_set_l2_decap_parsed, 15721 .data = NULL, 15722 .help_str = "set l2_decap", 15723 .tokens = { 15724 (void *)&cmd_set_l2_decap_set, 15725 (void *)&cmd_set_l2_decap_l2_decap, 15726 NULL, 15727 }, 15728 }; 15729 15730 cmdline_parse_inst_t cmd_set_l2_decap_with_vlan = { 15731 .f = cmd_set_l2_decap_parsed, 15732 .data = NULL, 15733 .help_str = "set l2_decap-with-vlan", 15734 .tokens = { 15735 (void *)&cmd_set_l2_decap_set, 15736 (void *)&cmd_set_l2_decap_l2_decap_with_vlan, 15737 NULL, 15738 }, 15739 }; 15740 15741 /** Set MPLSoGRE encapsulation details */ 15742 struct cmd_set_mplsogre_encap_result { 15743 cmdline_fixed_string_t set; 15744 cmdline_fixed_string_t mplsogre; 15745 cmdline_fixed_string_t pos_token; 15746 cmdline_fixed_string_t ip_version; 15747 uint32_t vlan_present:1; 15748 uint32_t label; 15749 cmdline_ipaddr_t ip_src; 15750 cmdline_ipaddr_t ip_dst; 15751 uint16_t tci; 15752 struct rte_ether_addr eth_src; 15753 struct rte_ether_addr eth_dst; 15754 }; 15755 15756 cmdline_parse_token_string_t cmd_set_mplsogre_encap_set = 15757 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_encap_result, set, 15758 "set"); 15759 cmdline_parse_token_string_t cmd_set_mplsogre_encap_mplsogre_encap = 15760 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_encap_result, mplsogre, 15761 "mplsogre_encap"); 15762 cmdline_parse_token_string_t cmd_set_mplsogre_encap_mplsogre_encap_with_vlan = 15763 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_encap_result, 15764 mplsogre, "mplsogre_encap-with-vlan"); 15765 cmdline_parse_token_string_t cmd_set_mplsogre_encap_ip_version = 15766 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_encap_result, 15767 pos_token, "ip-version"); 15768 cmdline_parse_token_string_t cmd_set_mplsogre_encap_ip_version_value = 15769 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_encap_result, 15770 ip_version, "ipv4#ipv6"); 15771 cmdline_parse_token_string_t cmd_set_mplsogre_encap_label = 15772 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_encap_result, 15773 pos_token, "label"); 15774 cmdline_parse_token_num_t cmd_set_mplsogre_encap_label_value = 15775 TOKEN_NUM_INITIALIZER(struct cmd_set_mplsogre_encap_result, label, 15776 UINT32); 15777 cmdline_parse_token_string_t cmd_set_mplsogre_encap_ip_src = 15778 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_encap_result, 15779 pos_token, "ip-src"); 15780 cmdline_parse_token_ipaddr_t cmd_set_mplsogre_encap_ip_src_value = 15781 TOKEN_IPADDR_INITIALIZER(struct cmd_set_mplsogre_encap_result, ip_src); 15782 cmdline_parse_token_string_t cmd_set_mplsogre_encap_ip_dst = 15783 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_encap_result, 15784 pos_token, "ip-dst"); 15785 cmdline_parse_token_ipaddr_t cmd_set_mplsogre_encap_ip_dst_value = 15786 TOKEN_IPADDR_INITIALIZER(struct cmd_set_mplsogre_encap_result, ip_dst); 15787 cmdline_parse_token_string_t cmd_set_mplsogre_encap_vlan = 15788 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_encap_result, 15789 pos_token, "vlan-tci"); 15790 cmdline_parse_token_num_t cmd_set_mplsogre_encap_vlan_value = 15791 TOKEN_NUM_INITIALIZER(struct cmd_set_mplsogre_encap_result, tci, 15792 UINT16); 15793 cmdline_parse_token_string_t cmd_set_mplsogre_encap_eth_src = 15794 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_encap_result, 15795 pos_token, "eth-src"); 15796 cmdline_parse_token_etheraddr_t cmd_set_mplsogre_encap_eth_src_value = 15797 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_mplsogre_encap_result, 15798 eth_src); 15799 cmdline_parse_token_string_t cmd_set_mplsogre_encap_eth_dst = 15800 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_encap_result, 15801 pos_token, "eth-dst"); 15802 cmdline_parse_token_etheraddr_t cmd_set_mplsogre_encap_eth_dst_value = 15803 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_mplsogre_encap_result, 15804 eth_dst); 15805 15806 static void cmd_set_mplsogre_encap_parsed(void *parsed_result, 15807 __attribute__((unused)) struct cmdline *cl, 15808 __attribute__((unused)) void *data) 15809 { 15810 struct cmd_set_mplsogre_encap_result *res = parsed_result; 15811 union { 15812 uint32_t mplsogre_label; 15813 uint8_t label[4]; 15814 } id = { 15815 .mplsogre_label = rte_cpu_to_be_32(res->label<<12), 15816 }; 15817 15818 if (strcmp(res->mplsogre, "mplsogre_encap") == 0) 15819 mplsogre_encap_conf.select_vlan = 0; 15820 else if (strcmp(res->mplsogre, "mplsogre_encap-with-vlan") == 0) 15821 mplsogre_encap_conf.select_vlan = 1; 15822 if (strcmp(res->ip_version, "ipv4") == 0) 15823 mplsogre_encap_conf.select_ipv4 = 1; 15824 else if (strcmp(res->ip_version, "ipv6") == 0) 15825 mplsogre_encap_conf.select_ipv4 = 0; 15826 else 15827 return; 15828 rte_memcpy(mplsogre_encap_conf.label, &id.label, 3); 15829 if (mplsogre_encap_conf.select_ipv4) { 15830 IPV4_ADDR_TO_UINT(res->ip_src, mplsogre_encap_conf.ipv4_src); 15831 IPV4_ADDR_TO_UINT(res->ip_dst, mplsogre_encap_conf.ipv4_dst); 15832 } else { 15833 IPV6_ADDR_TO_ARRAY(res->ip_src, mplsogre_encap_conf.ipv6_src); 15834 IPV6_ADDR_TO_ARRAY(res->ip_dst, mplsogre_encap_conf.ipv6_dst); 15835 } 15836 if (mplsogre_encap_conf.select_vlan) 15837 mplsogre_encap_conf.vlan_tci = rte_cpu_to_be_16(res->tci); 15838 rte_memcpy(mplsogre_encap_conf.eth_src, res->eth_src.addr_bytes, 15839 RTE_ETHER_ADDR_LEN); 15840 rte_memcpy(mplsogre_encap_conf.eth_dst, res->eth_dst.addr_bytes, 15841 RTE_ETHER_ADDR_LEN); 15842 } 15843 15844 cmdline_parse_inst_t cmd_set_mplsogre_encap = { 15845 .f = cmd_set_mplsogre_encap_parsed, 15846 .data = NULL, 15847 .help_str = "set mplsogre_encap ip-version ipv4|ipv6 label <label>" 15848 " ip-src <ip-src> ip-dst <ip-dst> eth-src <eth-src>" 15849 " eth-dst <eth-dst>", 15850 .tokens = { 15851 (void *)&cmd_set_mplsogre_encap_set, 15852 (void *)&cmd_set_mplsogre_encap_mplsogre_encap, 15853 (void *)&cmd_set_mplsogre_encap_ip_version, 15854 (void *)&cmd_set_mplsogre_encap_ip_version_value, 15855 (void *)&cmd_set_mplsogre_encap_label, 15856 (void *)&cmd_set_mplsogre_encap_label_value, 15857 (void *)&cmd_set_mplsogre_encap_ip_src, 15858 (void *)&cmd_set_mplsogre_encap_ip_src_value, 15859 (void *)&cmd_set_mplsogre_encap_ip_dst, 15860 (void *)&cmd_set_mplsogre_encap_ip_dst_value, 15861 (void *)&cmd_set_mplsogre_encap_eth_src, 15862 (void *)&cmd_set_mplsogre_encap_eth_src_value, 15863 (void *)&cmd_set_mplsogre_encap_eth_dst, 15864 (void *)&cmd_set_mplsogre_encap_eth_dst_value, 15865 NULL, 15866 }, 15867 }; 15868 15869 cmdline_parse_inst_t cmd_set_mplsogre_encap_with_vlan = { 15870 .f = cmd_set_mplsogre_encap_parsed, 15871 .data = NULL, 15872 .help_str = "set mplsogre_encap-with-vlan ip-version ipv4|ipv6" 15873 " label <label> ip-src <ip-src> ip-dst <ip-dst>" 15874 " vlan-tci <vlan-tci> eth-src <eth-src> eth-dst <eth-dst>", 15875 .tokens = { 15876 (void *)&cmd_set_mplsogre_encap_set, 15877 (void *)&cmd_set_mplsogre_encap_mplsogre_encap_with_vlan, 15878 (void *)&cmd_set_mplsogre_encap_ip_version, 15879 (void *)&cmd_set_mplsogre_encap_ip_version_value, 15880 (void *)&cmd_set_mplsogre_encap_label, 15881 (void *)&cmd_set_mplsogre_encap_label_value, 15882 (void *)&cmd_set_mplsogre_encap_ip_src, 15883 (void *)&cmd_set_mplsogre_encap_ip_src_value, 15884 (void *)&cmd_set_mplsogre_encap_ip_dst, 15885 (void *)&cmd_set_mplsogre_encap_ip_dst_value, 15886 (void *)&cmd_set_mplsogre_encap_vlan, 15887 (void *)&cmd_set_mplsogre_encap_vlan_value, 15888 (void *)&cmd_set_mplsogre_encap_eth_src, 15889 (void *)&cmd_set_mplsogre_encap_eth_src_value, 15890 (void *)&cmd_set_mplsogre_encap_eth_dst, 15891 (void *)&cmd_set_mplsogre_encap_eth_dst_value, 15892 NULL, 15893 }, 15894 }; 15895 15896 /** Set MPLSoGRE decapsulation details */ 15897 struct cmd_set_mplsogre_decap_result { 15898 cmdline_fixed_string_t set; 15899 cmdline_fixed_string_t mplsogre; 15900 cmdline_fixed_string_t pos_token; 15901 cmdline_fixed_string_t ip_version; 15902 uint32_t vlan_present:1; 15903 }; 15904 15905 cmdline_parse_token_string_t cmd_set_mplsogre_decap_set = 15906 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_decap_result, set, 15907 "set"); 15908 cmdline_parse_token_string_t cmd_set_mplsogre_decap_mplsogre_decap = 15909 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_decap_result, mplsogre, 15910 "mplsogre_decap"); 15911 cmdline_parse_token_string_t cmd_set_mplsogre_decap_mplsogre_decap_with_vlan = 15912 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_decap_result, 15913 mplsogre, "mplsogre_decap-with-vlan"); 15914 cmdline_parse_token_string_t cmd_set_mplsogre_decap_ip_version = 15915 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_decap_result, 15916 pos_token, "ip-version"); 15917 cmdline_parse_token_string_t cmd_set_mplsogre_decap_ip_version_value = 15918 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_decap_result, 15919 ip_version, "ipv4#ipv6"); 15920 15921 static void cmd_set_mplsogre_decap_parsed(void *parsed_result, 15922 __attribute__((unused)) struct cmdline *cl, 15923 __attribute__((unused)) void *data) 15924 { 15925 struct cmd_set_mplsogre_decap_result *res = parsed_result; 15926 15927 if (strcmp(res->mplsogre, "mplsogre_decap") == 0) 15928 mplsogre_decap_conf.select_vlan = 0; 15929 else if (strcmp(res->mplsogre, "mplsogre_decap-with-vlan") == 0) 15930 mplsogre_decap_conf.select_vlan = 1; 15931 if (strcmp(res->ip_version, "ipv4") == 0) 15932 mplsogre_decap_conf.select_ipv4 = 1; 15933 else if (strcmp(res->ip_version, "ipv6") == 0) 15934 mplsogre_decap_conf.select_ipv4 = 0; 15935 } 15936 15937 cmdline_parse_inst_t cmd_set_mplsogre_decap = { 15938 .f = cmd_set_mplsogre_decap_parsed, 15939 .data = NULL, 15940 .help_str = "set mplsogre_decap ip-version ipv4|ipv6", 15941 .tokens = { 15942 (void *)&cmd_set_mplsogre_decap_set, 15943 (void *)&cmd_set_mplsogre_decap_mplsogre_decap, 15944 (void *)&cmd_set_mplsogre_decap_ip_version, 15945 (void *)&cmd_set_mplsogre_decap_ip_version_value, 15946 NULL, 15947 }, 15948 }; 15949 15950 cmdline_parse_inst_t cmd_set_mplsogre_decap_with_vlan = { 15951 .f = cmd_set_mplsogre_decap_parsed, 15952 .data = NULL, 15953 .help_str = "set mplsogre_decap-with-vlan ip-version ipv4|ipv6", 15954 .tokens = { 15955 (void *)&cmd_set_mplsogre_decap_set, 15956 (void *)&cmd_set_mplsogre_decap_mplsogre_decap_with_vlan, 15957 (void *)&cmd_set_mplsogre_decap_ip_version, 15958 (void *)&cmd_set_mplsogre_decap_ip_version_value, 15959 NULL, 15960 }, 15961 }; 15962 15963 /** Set MPLSoUDP encapsulation details */ 15964 struct cmd_set_mplsoudp_encap_result { 15965 cmdline_fixed_string_t set; 15966 cmdline_fixed_string_t mplsoudp; 15967 cmdline_fixed_string_t pos_token; 15968 cmdline_fixed_string_t ip_version; 15969 uint32_t vlan_present:1; 15970 uint32_t label; 15971 uint16_t udp_src; 15972 uint16_t udp_dst; 15973 cmdline_ipaddr_t ip_src; 15974 cmdline_ipaddr_t ip_dst; 15975 uint16_t tci; 15976 struct rte_ether_addr eth_src; 15977 struct rte_ether_addr eth_dst; 15978 }; 15979 15980 cmdline_parse_token_string_t cmd_set_mplsoudp_encap_set = 15981 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_encap_result, set, 15982 "set"); 15983 cmdline_parse_token_string_t cmd_set_mplsoudp_encap_mplsoudp_encap = 15984 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_encap_result, mplsoudp, 15985 "mplsoudp_encap"); 15986 cmdline_parse_token_string_t cmd_set_mplsoudp_encap_mplsoudp_encap_with_vlan = 15987 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_encap_result, 15988 mplsoudp, "mplsoudp_encap-with-vlan"); 15989 cmdline_parse_token_string_t cmd_set_mplsoudp_encap_ip_version = 15990 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_encap_result, 15991 pos_token, "ip-version"); 15992 cmdline_parse_token_string_t cmd_set_mplsoudp_encap_ip_version_value = 15993 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_encap_result, 15994 ip_version, "ipv4#ipv6"); 15995 cmdline_parse_token_string_t cmd_set_mplsoudp_encap_label = 15996 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_encap_result, 15997 pos_token, "label"); 15998 cmdline_parse_token_num_t cmd_set_mplsoudp_encap_label_value = 15999 TOKEN_NUM_INITIALIZER(struct cmd_set_mplsoudp_encap_result, label, 16000 UINT32); 16001 cmdline_parse_token_string_t cmd_set_mplsoudp_encap_udp_src = 16002 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_encap_result, 16003 pos_token, "udp-src"); 16004 cmdline_parse_token_num_t cmd_set_mplsoudp_encap_udp_src_value = 16005 TOKEN_NUM_INITIALIZER(struct cmd_set_mplsoudp_encap_result, udp_src, 16006 UINT16); 16007 cmdline_parse_token_string_t cmd_set_mplsoudp_encap_udp_dst = 16008 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_encap_result, 16009 pos_token, "udp-dst"); 16010 cmdline_parse_token_num_t cmd_set_mplsoudp_encap_udp_dst_value = 16011 TOKEN_NUM_INITIALIZER(struct cmd_set_mplsoudp_encap_result, udp_dst, 16012 UINT16); 16013 cmdline_parse_token_string_t cmd_set_mplsoudp_encap_ip_src = 16014 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_encap_result, 16015 pos_token, "ip-src"); 16016 cmdline_parse_token_ipaddr_t cmd_set_mplsoudp_encap_ip_src_value = 16017 TOKEN_IPADDR_INITIALIZER(struct cmd_set_mplsoudp_encap_result, ip_src); 16018 cmdline_parse_token_string_t cmd_set_mplsoudp_encap_ip_dst = 16019 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_encap_result, 16020 pos_token, "ip-dst"); 16021 cmdline_parse_token_ipaddr_t cmd_set_mplsoudp_encap_ip_dst_value = 16022 TOKEN_IPADDR_INITIALIZER(struct cmd_set_mplsoudp_encap_result, ip_dst); 16023 cmdline_parse_token_string_t cmd_set_mplsoudp_encap_vlan = 16024 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_encap_result, 16025 pos_token, "vlan-tci"); 16026 cmdline_parse_token_num_t cmd_set_mplsoudp_encap_vlan_value = 16027 TOKEN_NUM_INITIALIZER(struct cmd_set_mplsoudp_encap_result, tci, 16028 UINT16); 16029 cmdline_parse_token_string_t cmd_set_mplsoudp_encap_eth_src = 16030 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_encap_result, 16031 pos_token, "eth-src"); 16032 cmdline_parse_token_etheraddr_t cmd_set_mplsoudp_encap_eth_src_value = 16033 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_mplsoudp_encap_result, 16034 eth_src); 16035 cmdline_parse_token_string_t cmd_set_mplsoudp_encap_eth_dst = 16036 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_encap_result, 16037 pos_token, "eth-dst"); 16038 cmdline_parse_token_etheraddr_t cmd_set_mplsoudp_encap_eth_dst_value = 16039 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_mplsoudp_encap_result, 16040 eth_dst); 16041 16042 static void cmd_set_mplsoudp_encap_parsed(void *parsed_result, 16043 __attribute__((unused)) struct cmdline *cl, 16044 __attribute__((unused)) void *data) 16045 { 16046 struct cmd_set_mplsoudp_encap_result *res = parsed_result; 16047 union { 16048 uint32_t mplsoudp_label; 16049 uint8_t label[4]; 16050 } id = { 16051 .mplsoudp_label = rte_cpu_to_be_32(res->label<<12), 16052 }; 16053 16054 if (strcmp(res->mplsoudp, "mplsoudp_encap") == 0) 16055 mplsoudp_encap_conf.select_vlan = 0; 16056 else if (strcmp(res->mplsoudp, "mplsoudp_encap-with-vlan") == 0) 16057 mplsoudp_encap_conf.select_vlan = 1; 16058 if (strcmp(res->ip_version, "ipv4") == 0) 16059 mplsoudp_encap_conf.select_ipv4 = 1; 16060 else if (strcmp(res->ip_version, "ipv6") == 0) 16061 mplsoudp_encap_conf.select_ipv4 = 0; 16062 else 16063 return; 16064 rte_memcpy(mplsoudp_encap_conf.label, &id.label, 3); 16065 mplsoudp_encap_conf.udp_src = rte_cpu_to_be_16(res->udp_src); 16066 mplsoudp_encap_conf.udp_dst = rte_cpu_to_be_16(res->udp_dst); 16067 if (mplsoudp_encap_conf.select_ipv4) { 16068 IPV4_ADDR_TO_UINT(res->ip_src, mplsoudp_encap_conf.ipv4_src); 16069 IPV4_ADDR_TO_UINT(res->ip_dst, mplsoudp_encap_conf.ipv4_dst); 16070 } else { 16071 IPV6_ADDR_TO_ARRAY(res->ip_src, mplsoudp_encap_conf.ipv6_src); 16072 IPV6_ADDR_TO_ARRAY(res->ip_dst, mplsoudp_encap_conf.ipv6_dst); 16073 } 16074 if (mplsoudp_encap_conf.select_vlan) 16075 mplsoudp_encap_conf.vlan_tci = rte_cpu_to_be_16(res->tci); 16076 rte_memcpy(mplsoudp_encap_conf.eth_src, res->eth_src.addr_bytes, 16077 RTE_ETHER_ADDR_LEN); 16078 rte_memcpy(mplsoudp_encap_conf.eth_dst, res->eth_dst.addr_bytes, 16079 RTE_ETHER_ADDR_LEN); 16080 } 16081 16082 cmdline_parse_inst_t cmd_set_mplsoudp_encap = { 16083 .f = cmd_set_mplsoudp_encap_parsed, 16084 .data = NULL, 16085 .help_str = "set mplsoudp_encap ip-version ipv4|ipv6 label <label>" 16086 " udp-src <udp-src> udp-dst <udp-dst> ip-src <ip-src>" 16087 " ip-dst <ip-dst> eth-src <eth-src> eth-dst <eth-dst>", 16088 .tokens = { 16089 (void *)&cmd_set_mplsoudp_encap_set, 16090 (void *)&cmd_set_mplsoudp_encap_mplsoudp_encap, 16091 (void *)&cmd_set_mplsoudp_encap_ip_version, 16092 (void *)&cmd_set_mplsoudp_encap_ip_version_value, 16093 (void *)&cmd_set_mplsoudp_encap_label, 16094 (void *)&cmd_set_mplsoudp_encap_label_value, 16095 (void *)&cmd_set_mplsoudp_encap_udp_src, 16096 (void *)&cmd_set_mplsoudp_encap_udp_src_value, 16097 (void *)&cmd_set_mplsoudp_encap_udp_dst, 16098 (void *)&cmd_set_mplsoudp_encap_udp_dst_value, 16099 (void *)&cmd_set_mplsoudp_encap_ip_src, 16100 (void *)&cmd_set_mplsoudp_encap_ip_src_value, 16101 (void *)&cmd_set_mplsoudp_encap_ip_dst, 16102 (void *)&cmd_set_mplsoudp_encap_ip_dst_value, 16103 (void *)&cmd_set_mplsoudp_encap_eth_src, 16104 (void *)&cmd_set_mplsoudp_encap_eth_src_value, 16105 (void *)&cmd_set_mplsoudp_encap_eth_dst, 16106 (void *)&cmd_set_mplsoudp_encap_eth_dst_value, 16107 NULL, 16108 }, 16109 }; 16110 16111 cmdline_parse_inst_t cmd_set_mplsoudp_encap_with_vlan = { 16112 .f = cmd_set_mplsoudp_encap_parsed, 16113 .data = NULL, 16114 .help_str = "set mplsoudp_encap-with-vlan ip-version ipv4|ipv6" 16115 " label <label> udp-src <udp-src> udp-dst <udp-dst>" 16116 " ip-src <ip-src> ip-dst <ip-dst> vlan-tci <vlan-tci>" 16117 " eth-src <eth-src> eth-dst <eth-dst>", 16118 .tokens = { 16119 (void *)&cmd_set_mplsoudp_encap_set, 16120 (void *)&cmd_set_mplsoudp_encap_mplsoudp_encap_with_vlan, 16121 (void *)&cmd_set_mplsoudp_encap_ip_version, 16122 (void *)&cmd_set_mplsoudp_encap_ip_version_value, 16123 (void *)&cmd_set_mplsoudp_encap_label, 16124 (void *)&cmd_set_mplsoudp_encap_label_value, 16125 (void *)&cmd_set_mplsoudp_encap_udp_src, 16126 (void *)&cmd_set_mplsoudp_encap_udp_src_value, 16127 (void *)&cmd_set_mplsoudp_encap_udp_dst, 16128 (void *)&cmd_set_mplsoudp_encap_udp_dst_value, 16129 (void *)&cmd_set_mplsoudp_encap_ip_src, 16130 (void *)&cmd_set_mplsoudp_encap_ip_src_value, 16131 (void *)&cmd_set_mplsoudp_encap_ip_dst, 16132 (void *)&cmd_set_mplsoudp_encap_ip_dst_value, 16133 (void *)&cmd_set_mplsoudp_encap_vlan, 16134 (void *)&cmd_set_mplsoudp_encap_vlan_value, 16135 (void *)&cmd_set_mplsoudp_encap_eth_src, 16136 (void *)&cmd_set_mplsoudp_encap_eth_src_value, 16137 (void *)&cmd_set_mplsoudp_encap_eth_dst, 16138 (void *)&cmd_set_mplsoudp_encap_eth_dst_value, 16139 NULL, 16140 }, 16141 }; 16142 16143 /** Set MPLSoUDP decapsulation details */ 16144 struct cmd_set_mplsoudp_decap_result { 16145 cmdline_fixed_string_t set; 16146 cmdline_fixed_string_t mplsoudp; 16147 cmdline_fixed_string_t pos_token; 16148 cmdline_fixed_string_t ip_version; 16149 uint32_t vlan_present:1; 16150 }; 16151 16152 cmdline_parse_token_string_t cmd_set_mplsoudp_decap_set = 16153 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_decap_result, set, 16154 "set"); 16155 cmdline_parse_token_string_t cmd_set_mplsoudp_decap_mplsoudp_decap = 16156 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_decap_result, mplsoudp, 16157 "mplsoudp_decap"); 16158 cmdline_parse_token_string_t cmd_set_mplsoudp_decap_mplsoudp_decap_with_vlan = 16159 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_decap_result, 16160 mplsoudp, "mplsoudp_decap-with-vlan"); 16161 cmdline_parse_token_string_t cmd_set_mplsoudp_decap_ip_version = 16162 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_decap_result, 16163 pos_token, "ip-version"); 16164 cmdline_parse_token_string_t cmd_set_mplsoudp_decap_ip_version_value = 16165 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_decap_result, 16166 ip_version, "ipv4#ipv6"); 16167 16168 static void cmd_set_mplsoudp_decap_parsed(void *parsed_result, 16169 __attribute__((unused)) struct cmdline *cl, 16170 __attribute__((unused)) void *data) 16171 { 16172 struct cmd_set_mplsoudp_decap_result *res = parsed_result; 16173 16174 if (strcmp(res->mplsoudp, "mplsoudp_decap") == 0) 16175 mplsoudp_decap_conf.select_vlan = 0; 16176 else if (strcmp(res->mplsoudp, "mplsoudp_decap-with-vlan") == 0) 16177 mplsoudp_decap_conf.select_vlan = 1; 16178 if (strcmp(res->ip_version, "ipv4") == 0) 16179 mplsoudp_decap_conf.select_ipv4 = 1; 16180 else if (strcmp(res->ip_version, "ipv6") == 0) 16181 mplsoudp_decap_conf.select_ipv4 = 0; 16182 } 16183 16184 cmdline_parse_inst_t cmd_set_mplsoudp_decap = { 16185 .f = cmd_set_mplsoudp_decap_parsed, 16186 .data = NULL, 16187 .help_str = "set mplsoudp_decap ip-version ipv4|ipv6", 16188 .tokens = { 16189 (void *)&cmd_set_mplsoudp_decap_set, 16190 (void *)&cmd_set_mplsoudp_decap_mplsoudp_decap, 16191 (void *)&cmd_set_mplsoudp_decap_ip_version, 16192 (void *)&cmd_set_mplsoudp_decap_ip_version_value, 16193 NULL, 16194 }, 16195 }; 16196 16197 cmdline_parse_inst_t cmd_set_mplsoudp_decap_with_vlan = { 16198 .f = cmd_set_mplsoudp_decap_parsed, 16199 .data = NULL, 16200 .help_str = "set mplsoudp_decap-with-vlan ip-version ipv4|ipv6", 16201 .tokens = { 16202 (void *)&cmd_set_mplsoudp_decap_set, 16203 (void *)&cmd_set_mplsoudp_decap_mplsoudp_decap_with_vlan, 16204 (void *)&cmd_set_mplsoudp_decap_ip_version, 16205 (void *)&cmd_set_mplsoudp_decap_ip_version_value, 16206 NULL, 16207 }, 16208 }; 16209 16210 /* Strict link priority scheduling mode setting */ 16211 static void 16212 cmd_strict_link_prio_parsed( 16213 void *parsed_result, 16214 __attribute__((unused)) struct cmdline *cl, 16215 __attribute__((unused)) void *data) 16216 { 16217 struct cmd_vf_tc_bw_result *res = parsed_result; 16218 int ret = -ENOTSUP; 16219 16220 if (port_id_is_invalid(res->port_id, ENABLED_WARN)) 16221 return; 16222 16223 #ifdef RTE_LIBRTE_I40E_PMD 16224 ret = rte_pmd_i40e_set_tc_strict_prio(res->port_id, res->tc_map); 16225 #endif 16226 16227 switch (ret) { 16228 case 0: 16229 break; 16230 case -EINVAL: 16231 printf("invalid tc_bitmap 0x%x\n", res->tc_map); 16232 break; 16233 case -ENODEV: 16234 printf("invalid port_id %d\n", res->port_id); 16235 break; 16236 case -ENOTSUP: 16237 printf("function not implemented\n"); 16238 break; 16239 default: 16240 printf("programming error: (%s)\n", strerror(-ret)); 16241 } 16242 } 16243 16244 cmdline_parse_inst_t cmd_strict_link_prio = { 16245 .f = cmd_strict_link_prio_parsed, 16246 .data = NULL, 16247 .help_str = "set tx strict-link-priority <port_id> <tc_bitmap>", 16248 .tokens = { 16249 (void *)&cmd_vf_tc_bw_set, 16250 (void *)&cmd_vf_tc_bw_tx, 16251 (void *)&cmd_vf_tc_bw_strict_link_prio, 16252 (void *)&cmd_vf_tc_bw_port_id, 16253 (void *)&cmd_vf_tc_bw_tc_map, 16254 NULL, 16255 }, 16256 }; 16257 16258 /* Load dynamic device personalization*/ 16259 struct cmd_ddp_add_result { 16260 cmdline_fixed_string_t ddp; 16261 cmdline_fixed_string_t add; 16262 portid_t port_id; 16263 char filepath[]; 16264 }; 16265 16266 cmdline_parse_token_string_t cmd_ddp_add_ddp = 16267 TOKEN_STRING_INITIALIZER(struct cmd_ddp_add_result, ddp, "ddp"); 16268 cmdline_parse_token_string_t cmd_ddp_add_add = 16269 TOKEN_STRING_INITIALIZER(struct cmd_ddp_add_result, add, "add"); 16270 cmdline_parse_token_num_t cmd_ddp_add_port_id = 16271 TOKEN_NUM_INITIALIZER(struct cmd_ddp_add_result, port_id, UINT16); 16272 cmdline_parse_token_string_t cmd_ddp_add_filepath = 16273 TOKEN_STRING_INITIALIZER(struct cmd_ddp_add_result, filepath, NULL); 16274 16275 static void 16276 cmd_ddp_add_parsed( 16277 void *parsed_result, 16278 __attribute__((unused)) struct cmdline *cl, 16279 __attribute__((unused)) void *data) 16280 { 16281 struct cmd_ddp_add_result *res = parsed_result; 16282 uint8_t *buff; 16283 uint32_t size; 16284 char *filepath; 16285 char *file_fld[2]; 16286 int file_num; 16287 int ret = -ENOTSUP; 16288 16289 if (!all_ports_stopped()) { 16290 printf("Please stop all ports first\n"); 16291 return; 16292 } 16293 16294 filepath = strdup(res->filepath); 16295 if (filepath == NULL) { 16296 printf("Failed to allocate memory\n"); 16297 return; 16298 } 16299 file_num = rte_strsplit(filepath, strlen(filepath), file_fld, 2, ','); 16300 16301 buff = open_file(file_fld[0], &size); 16302 if (!buff) { 16303 free((void *)filepath); 16304 return; 16305 } 16306 16307 #ifdef RTE_LIBRTE_I40E_PMD 16308 if (ret == -ENOTSUP) 16309 ret = rte_pmd_i40e_process_ddp_package(res->port_id, 16310 buff, size, 16311 RTE_PMD_I40E_PKG_OP_WR_ADD); 16312 #endif 16313 16314 if (ret == -EEXIST) 16315 printf("Profile has already existed.\n"); 16316 else if (ret < 0) 16317 printf("Failed to load profile.\n"); 16318 else if (file_num == 2) 16319 save_file(file_fld[1], buff, size); 16320 16321 close_file(buff); 16322 free((void *)filepath); 16323 } 16324 16325 cmdline_parse_inst_t cmd_ddp_add = { 16326 .f = cmd_ddp_add_parsed, 16327 .data = NULL, 16328 .help_str = "ddp add <port_id> <profile_path[,backup_profile_path]>", 16329 .tokens = { 16330 (void *)&cmd_ddp_add_ddp, 16331 (void *)&cmd_ddp_add_add, 16332 (void *)&cmd_ddp_add_port_id, 16333 (void *)&cmd_ddp_add_filepath, 16334 NULL, 16335 }, 16336 }; 16337 16338 /* Delete dynamic device personalization*/ 16339 struct cmd_ddp_del_result { 16340 cmdline_fixed_string_t ddp; 16341 cmdline_fixed_string_t del; 16342 portid_t port_id; 16343 char filepath[]; 16344 }; 16345 16346 cmdline_parse_token_string_t cmd_ddp_del_ddp = 16347 TOKEN_STRING_INITIALIZER(struct cmd_ddp_del_result, ddp, "ddp"); 16348 cmdline_parse_token_string_t cmd_ddp_del_del = 16349 TOKEN_STRING_INITIALIZER(struct cmd_ddp_del_result, del, "del"); 16350 cmdline_parse_token_num_t cmd_ddp_del_port_id = 16351 TOKEN_NUM_INITIALIZER(struct cmd_ddp_del_result, port_id, UINT16); 16352 cmdline_parse_token_string_t cmd_ddp_del_filepath = 16353 TOKEN_STRING_INITIALIZER(struct cmd_ddp_del_result, filepath, NULL); 16354 16355 static void 16356 cmd_ddp_del_parsed( 16357 void *parsed_result, 16358 __attribute__((unused)) struct cmdline *cl, 16359 __attribute__((unused)) void *data) 16360 { 16361 struct cmd_ddp_del_result *res = parsed_result; 16362 uint8_t *buff; 16363 uint32_t size; 16364 int ret = -ENOTSUP; 16365 16366 if (!all_ports_stopped()) { 16367 printf("Please stop all ports first\n"); 16368 return; 16369 } 16370 16371 buff = open_file(res->filepath, &size); 16372 if (!buff) 16373 return; 16374 16375 #ifdef RTE_LIBRTE_I40E_PMD 16376 if (ret == -ENOTSUP) 16377 ret = rte_pmd_i40e_process_ddp_package(res->port_id, 16378 buff, size, 16379 RTE_PMD_I40E_PKG_OP_WR_DEL); 16380 #endif 16381 16382 if (ret == -EACCES) 16383 printf("Profile does not exist.\n"); 16384 else if (ret < 0) 16385 printf("Failed to delete profile.\n"); 16386 16387 close_file(buff); 16388 } 16389 16390 cmdline_parse_inst_t cmd_ddp_del = { 16391 .f = cmd_ddp_del_parsed, 16392 .data = NULL, 16393 .help_str = "ddp del <port_id> <backup_profile_path>", 16394 .tokens = { 16395 (void *)&cmd_ddp_del_ddp, 16396 (void *)&cmd_ddp_del_del, 16397 (void *)&cmd_ddp_del_port_id, 16398 (void *)&cmd_ddp_del_filepath, 16399 NULL, 16400 }, 16401 }; 16402 16403 /* Get dynamic device personalization profile info */ 16404 struct cmd_ddp_info_result { 16405 cmdline_fixed_string_t ddp; 16406 cmdline_fixed_string_t get; 16407 cmdline_fixed_string_t info; 16408 char filepath[]; 16409 }; 16410 16411 cmdline_parse_token_string_t cmd_ddp_info_ddp = 16412 TOKEN_STRING_INITIALIZER(struct cmd_ddp_info_result, ddp, "ddp"); 16413 cmdline_parse_token_string_t cmd_ddp_info_get = 16414 TOKEN_STRING_INITIALIZER(struct cmd_ddp_info_result, get, "get"); 16415 cmdline_parse_token_string_t cmd_ddp_info_info = 16416 TOKEN_STRING_INITIALIZER(struct cmd_ddp_info_result, info, "info"); 16417 cmdline_parse_token_string_t cmd_ddp_info_filepath = 16418 TOKEN_STRING_INITIALIZER(struct cmd_ddp_info_result, filepath, NULL); 16419 16420 static void 16421 cmd_ddp_info_parsed( 16422 void *parsed_result, 16423 __attribute__((unused)) struct cmdline *cl, 16424 __attribute__((unused)) void *data) 16425 { 16426 struct cmd_ddp_info_result *res = parsed_result; 16427 uint8_t *pkg; 16428 uint32_t pkg_size; 16429 int ret = -ENOTSUP; 16430 #ifdef RTE_LIBRTE_I40E_PMD 16431 uint32_t i, j, n; 16432 uint8_t *buff; 16433 uint32_t buff_size = 0; 16434 struct rte_pmd_i40e_profile_info info; 16435 uint32_t dev_num = 0; 16436 struct rte_pmd_i40e_ddp_device_id *devs; 16437 uint32_t proto_num = 0; 16438 struct rte_pmd_i40e_proto_info *proto = NULL; 16439 uint32_t pctype_num = 0; 16440 struct rte_pmd_i40e_ptype_info *pctype; 16441 uint32_t ptype_num = 0; 16442 struct rte_pmd_i40e_ptype_info *ptype; 16443 uint8_t proto_id; 16444 16445 #endif 16446 16447 pkg = open_file(res->filepath, &pkg_size); 16448 if (!pkg) 16449 return; 16450 16451 #ifdef RTE_LIBRTE_I40E_PMD 16452 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size, 16453 (uint8_t *)&info, sizeof(info), 16454 RTE_PMD_I40E_PKG_INFO_GLOBAL_HEADER); 16455 if (!ret) { 16456 printf("Global Track id: 0x%x\n", info.track_id); 16457 printf("Global Version: %d.%d.%d.%d\n", 16458 info.version.major, 16459 info.version.minor, 16460 info.version.update, 16461 info.version.draft); 16462 printf("Global Package name: %s\n\n", info.name); 16463 } 16464 16465 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size, 16466 (uint8_t *)&info, sizeof(info), 16467 RTE_PMD_I40E_PKG_INFO_HEADER); 16468 if (!ret) { 16469 printf("i40e Profile Track id: 0x%x\n", info.track_id); 16470 printf("i40e Profile Version: %d.%d.%d.%d\n", 16471 info.version.major, 16472 info.version.minor, 16473 info.version.update, 16474 info.version.draft); 16475 printf("i40e Profile name: %s\n\n", info.name); 16476 } 16477 16478 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size, 16479 (uint8_t *)&buff_size, sizeof(buff_size), 16480 RTE_PMD_I40E_PKG_INFO_GLOBAL_NOTES_SIZE); 16481 if (!ret && buff_size) { 16482 buff = (uint8_t *)malloc(buff_size); 16483 if (buff) { 16484 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size, 16485 buff, buff_size, 16486 RTE_PMD_I40E_PKG_INFO_GLOBAL_NOTES); 16487 if (!ret) 16488 printf("Package Notes:\n%s\n\n", buff); 16489 free(buff); 16490 } 16491 } 16492 16493 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size, 16494 (uint8_t *)&dev_num, sizeof(dev_num), 16495 RTE_PMD_I40E_PKG_INFO_DEVID_NUM); 16496 if (!ret && dev_num) { 16497 buff_size = dev_num * sizeof(struct rte_pmd_i40e_ddp_device_id); 16498 devs = (struct rte_pmd_i40e_ddp_device_id *)malloc(buff_size); 16499 if (devs) { 16500 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size, 16501 (uint8_t *)devs, buff_size, 16502 RTE_PMD_I40E_PKG_INFO_DEVID_LIST); 16503 if (!ret) { 16504 printf("List of supported devices:\n"); 16505 for (i = 0; i < dev_num; i++) { 16506 printf(" %04X:%04X %04X:%04X\n", 16507 devs[i].vendor_dev_id >> 16, 16508 devs[i].vendor_dev_id & 0xFFFF, 16509 devs[i].sub_vendor_dev_id >> 16, 16510 devs[i].sub_vendor_dev_id & 0xFFFF); 16511 } 16512 printf("\n"); 16513 } 16514 free(devs); 16515 } 16516 } 16517 16518 /* get information about protocols and packet types */ 16519 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size, 16520 (uint8_t *)&proto_num, sizeof(proto_num), 16521 RTE_PMD_I40E_PKG_INFO_PROTOCOL_NUM); 16522 if (ret || !proto_num) 16523 goto no_print_return; 16524 16525 buff_size = proto_num * sizeof(struct rte_pmd_i40e_proto_info); 16526 proto = (struct rte_pmd_i40e_proto_info *)malloc(buff_size); 16527 if (!proto) 16528 goto no_print_return; 16529 16530 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size, (uint8_t *)proto, 16531 buff_size, 16532 RTE_PMD_I40E_PKG_INFO_PROTOCOL_LIST); 16533 if (!ret) { 16534 printf("List of used protocols:\n"); 16535 for (i = 0; i < proto_num; i++) 16536 printf(" %2u: %s\n", proto[i].proto_id, 16537 proto[i].name); 16538 printf("\n"); 16539 } 16540 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size, 16541 (uint8_t *)&pctype_num, sizeof(pctype_num), 16542 RTE_PMD_I40E_PKG_INFO_PCTYPE_NUM); 16543 if (ret || !pctype_num) 16544 goto no_print_pctypes; 16545 16546 buff_size = pctype_num * sizeof(struct rte_pmd_i40e_ptype_info); 16547 pctype = (struct rte_pmd_i40e_ptype_info *)malloc(buff_size); 16548 if (!pctype) 16549 goto no_print_pctypes; 16550 16551 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size, (uint8_t *)pctype, 16552 buff_size, 16553 RTE_PMD_I40E_PKG_INFO_PCTYPE_LIST); 16554 if (ret) { 16555 free(pctype); 16556 goto no_print_pctypes; 16557 } 16558 16559 printf("List of defined packet classification types:\n"); 16560 for (i = 0; i < pctype_num; i++) { 16561 printf(" %2u:", pctype[i].ptype_id); 16562 for (j = 0; j < RTE_PMD_I40E_PROTO_NUM; j++) { 16563 proto_id = pctype[i].protocols[j]; 16564 if (proto_id != RTE_PMD_I40E_PROTO_UNUSED) { 16565 for (n = 0; n < proto_num; n++) { 16566 if (proto[n].proto_id == proto_id) { 16567 printf(" %s", proto[n].name); 16568 break; 16569 } 16570 } 16571 } 16572 } 16573 printf("\n"); 16574 } 16575 printf("\n"); 16576 free(pctype); 16577 16578 no_print_pctypes: 16579 16580 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size, (uint8_t *)&ptype_num, 16581 sizeof(ptype_num), 16582 RTE_PMD_I40E_PKG_INFO_PTYPE_NUM); 16583 if (ret || !ptype_num) 16584 goto no_print_return; 16585 16586 buff_size = ptype_num * sizeof(struct rte_pmd_i40e_ptype_info); 16587 ptype = (struct rte_pmd_i40e_ptype_info *)malloc(buff_size); 16588 if (!ptype) 16589 goto no_print_return; 16590 16591 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size, (uint8_t *)ptype, 16592 buff_size, 16593 RTE_PMD_I40E_PKG_INFO_PTYPE_LIST); 16594 if (ret) { 16595 free(ptype); 16596 goto no_print_return; 16597 } 16598 printf("List of defined packet types:\n"); 16599 for (i = 0; i < ptype_num; i++) { 16600 printf(" %2u:", ptype[i].ptype_id); 16601 for (j = 0; j < RTE_PMD_I40E_PROTO_NUM; j++) { 16602 proto_id = ptype[i].protocols[j]; 16603 if (proto_id != RTE_PMD_I40E_PROTO_UNUSED) { 16604 for (n = 0; n < proto_num; n++) { 16605 if (proto[n].proto_id == proto_id) { 16606 printf(" %s", proto[n].name); 16607 break; 16608 } 16609 } 16610 } 16611 } 16612 printf("\n"); 16613 } 16614 free(ptype); 16615 printf("\n"); 16616 16617 ret = 0; 16618 no_print_return: 16619 if (proto) 16620 free(proto); 16621 #endif 16622 if (ret == -ENOTSUP) 16623 printf("Function not supported in PMD driver\n"); 16624 close_file(pkg); 16625 } 16626 16627 cmdline_parse_inst_t cmd_ddp_get_info = { 16628 .f = cmd_ddp_info_parsed, 16629 .data = NULL, 16630 .help_str = "ddp get info <profile_path>", 16631 .tokens = { 16632 (void *)&cmd_ddp_info_ddp, 16633 (void *)&cmd_ddp_info_get, 16634 (void *)&cmd_ddp_info_info, 16635 (void *)&cmd_ddp_info_filepath, 16636 NULL, 16637 }, 16638 }; 16639 16640 /* Get dynamic device personalization profile info list*/ 16641 #define PROFILE_INFO_SIZE 48 16642 #define MAX_PROFILE_NUM 16 16643 16644 struct cmd_ddp_get_list_result { 16645 cmdline_fixed_string_t ddp; 16646 cmdline_fixed_string_t get; 16647 cmdline_fixed_string_t list; 16648 portid_t port_id; 16649 }; 16650 16651 cmdline_parse_token_string_t cmd_ddp_get_list_ddp = 16652 TOKEN_STRING_INITIALIZER(struct cmd_ddp_get_list_result, ddp, "ddp"); 16653 cmdline_parse_token_string_t cmd_ddp_get_list_get = 16654 TOKEN_STRING_INITIALIZER(struct cmd_ddp_get_list_result, get, "get"); 16655 cmdline_parse_token_string_t cmd_ddp_get_list_list = 16656 TOKEN_STRING_INITIALIZER(struct cmd_ddp_get_list_result, list, "list"); 16657 cmdline_parse_token_num_t cmd_ddp_get_list_port_id = 16658 TOKEN_NUM_INITIALIZER(struct cmd_ddp_get_list_result, port_id, UINT16); 16659 16660 static void 16661 cmd_ddp_get_list_parsed( 16662 __attribute__((unused)) void *parsed_result, 16663 __attribute__((unused)) struct cmdline *cl, 16664 __attribute__((unused)) void *data) 16665 { 16666 #ifdef RTE_LIBRTE_I40E_PMD 16667 struct cmd_ddp_get_list_result *res = parsed_result; 16668 struct rte_pmd_i40e_profile_list *p_list; 16669 struct rte_pmd_i40e_profile_info *p_info; 16670 uint32_t p_num; 16671 uint32_t size; 16672 uint32_t i; 16673 #endif 16674 int ret = -ENOTSUP; 16675 16676 #ifdef RTE_LIBRTE_I40E_PMD 16677 size = PROFILE_INFO_SIZE * MAX_PROFILE_NUM + 4; 16678 p_list = (struct rte_pmd_i40e_profile_list *)malloc(size); 16679 if (!p_list) 16680 printf("%s: Failed to malloc buffer\n", __func__); 16681 16682 if (ret == -ENOTSUP) 16683 ret = rte_pmd_i40e_get_ddp_list(res->port_id, 16684 (uint8_t *)p_list, size); 16685 16686 if (!ret) { 16687 p_num = p_list->p_count; 16688 printf("Profile number is: %d\n\n", p_num); 16689 16690 for (i = 0; i < p_num; i++) { 16691 p_info = &p_list->p_info[i]; 16692 printf("Profile %d:\n", i); 16693 printf("Track id: 0x%x\n", p_info->track_id); 16694 printf("Version: %d.%d.%d.%d\n", 16695 p_info->version.major, 16696 p_info->version.minor, 16697 p_info->version.update, 16698 p_info->version.draft); 16699 printf("Profile name: %s\n\n", p_info->name); 16700 } 16701 } 16702 16703 free(p_list); 16704 #endif 16705 16706 if (ret < 0) 16707 printf("Failed to get ddp list\n"); 16708 } 16709 16710 cmdline_parse_inst_t cmd_ddp_get_list = { 16711 .f = cmd_ddp_get_list_parsed, 16712 .data = NULL, 16713 .help_str = "ddp get list <port_id>", 16714 .tokens = { 16715 (void *)&cmd_ddp_get_list_ddp, 16716 (void *)&cmd_ddp_get_list_get, 16717 (void *)&cmd_ddp_get_list_list, 16718 (void *)&cmd_ddp_get_list_port_id, 16719 NULL, 16720 }, 16721 }; 16722 16723 /* Configure input set */ 16724 struct cmd_cfg_input_set_result { 16725 cmdline_fixed_string_t port; 16726 cmdline_fixed_string_t cfg; 16727 portid_t port_id; 16728 cmdline_fixed_string_t pctype; 16729 uint8_t pctype_id; 16730 cmdline_fixed_string_t inset_type; 16731 cmdline_fixed_string_t opt; 16732 cmdline_fixed_string_t field; 16733 uint8_t field_idx; 16734 }; 16735 16736 static void 16737 cmd_cfg_input_set_parsed( 16738 __attribute__((unused)) void *parsed_result, 16739 __attribute__((unused)) struct cmdline *cl, 16740 __attribute__((unused)) void *data) 16741 { 16742 #ifdef RTE_LIBRTE_I40E_PMD 16743 struct cmd_cfg_input_set_result *res = parsed_result; 16744 enum rte_pmd_i40e_inset_type inset_type = INSET_NONE; 16745 struct rte_pmd_i40e_inset inset; 16746 #endif 16747 int ret = -ENOTSUP; 16748 16749 if (!all_ports_stopped()) { 16750 printf("Please stop all ports first\n"); 16751 return; 16752 } 16753 16754 #ifdef RTE_LIBRTE_I40E_PMD 16755 if (!strcmp(res->inset_type, "hash_inset")) 16756 inset_type = INSET_HASH; 16757 else if (!strcmp(res->inset_type, "fdir_inset")) 16758 inset_type = INSET_FDIR; 16759 else if (!strcmp(res->inset_type, "fdir_flx_inset")) 16760 inset_type = INSET_FDIR_FLX; 16761 ret = rte_pmd_i40e_inset_get(res->port_id, res->pctype_id, 16762 &inset, inset_type); 16763 if (ret) { 16764 printf("Failed to get input set.\n"); 16765 return; 16766 } 16767 16768 if (!strcmp(res->opt, "get")) { 16769 ret = rte_pmd_i40e_inset_field_get(inset.inset, 16770 res->field_idx); 16771 if (ret) 16772 printf("Field index %d is enabled.\n", res->field_idx); 16773 else 16774 printf("Field index %d is disabled.\n", res->field_idx); 16775 return; 16776 } else if (!strcmp(res->opt, "set")) 16777 ret = rte_pmd_i40e_inset_field_set(&inset.inset, 16778 res->field_idx); 16779 else if (!strcmp(res->opt, "clear")) 16780 ret = rte_pmd_i40e_inset_field_clear(&inset.inset, 16781 res->field_idx); 16782 if (ret) { 16783 printf("Failed to configure input set field.\n"); 16784 return; 16785 } 16786 16787 ret = rte_pmd_i40e_inset_set(res->port_id, res->pctype_id, 16788 &inset, inset_type); 16789 if (ret) { 16790 printf("Failed to set input set.\n"); 16791 return; 16792 } 16793 #endif 16794 16795 if (ret == -ENOTSUP) 16796 printf("Function not supported\n"); 16797 } 16798 16799 cmdline_parse_token_string_t cmd_cfg_input_set_port = 16800 TOKEN_STRING_INITIALIZER(struct cmd_cfg_input_set_result, 16801 port, "port"); 16802 cmdline_parse_token_string_t cmd_cfg_input_set_cfg = 16803 TOKEN_STRING_INITIALIZER(struct cmd_cfg_input_set_result, 16804 cfg, "config"); 16805 cmdline_parse_token_num_t cmd_cfg_input_set_port_id = 16806 TOKEN_NUM_INITIALIZER(struct cmd_cfg_input_set_result, 16807 port_id, UINT16); 16808 cmdline_parse_token_string_t cmd_cfg_input_set_pctype = 16809 TOKEN_STRING_INITIALIZER(struct cmd_cfg_input_set_result, 16810 pctype, "pctype"); 16811 cmdline_parse_token_num_t cmd_cfg_input_set_pctype_id = 16812 TOKEN_NUM_INITIALIZER(struct cmd_cfg_input_set_result, 16813 pctype_id, UINT8); 16814 cmdline_parse_token_string_t cmd_cfg_input_set_inset_type = 16815 TOKEN_STRING_INITIALIZER(struct cmd_cfg_input_set_result, 16816 inset_type, 16817 "hash_inset#fdir_inset#fdir_flx_inset"); 16818 cmdline_parse_token_string_t cmd_cfg_input_set_opt = 16819 TOKEN_STRING_INITIALIZER(struct cmd_cfg_input_set_result, 16820 opt, "get#set#clear"); 16821 cmdline_parse_token_string_t cmd_cfg_input_set_field = 16822 TOKEN_STRING_INITIALIZER(struct cmd_cfg_input_set_result, 16823 field, "field"); 16824 cmdline_parse_token_num_t cmd_cfg_input_set_field_idx = 16825 TOKEN_NUM_INITIALIZER(struct cmd_cfg_input_set_result, 16826 field_idx, UINT8); 16827 16828 cmdline_parse_inst_t cmd_cfg_input_set = { 16829 .f = cmd_cfg_input_set_parsed, 16830 .data = NULL, 16831 .help_str = "port config <port_id> pctype <pctype_id> hash_inset|" 16832 "fdir_inset|fdir_flx_inset get|set|clear field <field_idx>", 16833 .tokens = { 16834 (void *)&cmd_cfg_input_set_port, 16835 (void *)&cmd_cfg_input_set_cfg, 16836 (void *)&cmd_cfg_input_set_port_id, 16837 (void *)&cmd_cfg_input_set_pctype, 16838 (void *)&cmd_cfg_input_set_pctype_id, 16839 (void *)&cmd_cfg_input_set_inset_type, 16840 (void *)&cmd_cfg_input_set_opt, 16841 (void *)&cmd_cfg_input_set_field, 16842 (void *)&cmd_cfg_input_set_field_idx, 16843 NULL, 16844 }, 16845 }; 16846 16847 /* Clear input set */ 16848 struct cmd_clear_input_set_result { 16849 cmdline_fixed_string_t port; 16850 cmdline_fixed_string_t cfg; 16851 portid_t port_id; 16852 cmdline_fixed_string_t pctype; 16853 uint8_t pctype_id; 16854 cmdline_fixed_string_t inset_type; 16855 cmdline_fixed_string_t clear; 16856 cmdline_fixed_string_t all; 16857 }; 16858 16859 static void 16860 cmd_clear_input_set_parsed( 16861 __attribute__((unused)) void *parsed_result, 16862 __attribute__((unused)) struct cmdline *cl, 16863 __attribute__((unused)) void *data) 16864 { 16865 #ifdef RTE_LIBRTE_I40E_PMD 16866 struct cmd_clear_input_set_result *res = parsed_result; 16867 enum rte_pmd_i40e_inset_type inset_type = INSET_NONE; 16868 struct rte_pmd_i40e_inset inset; 16869 #endif 16870 int ret = -ENOTSUP; 16871 16872 if (!all_ports_stopped()) { 16873 printf("Please stop all ports first\n"); 16874 return; 16875 } 16876 16877 #ifdef RTE_LIBRTE_I40E_PMD 16878 if (!strcmp(res->inset_type, "hash_inset")) 16879 inset_type = INSET_HASH; 16880 else if (!strcmp(res->inset_type, "fdir_inset")) 16881 inset_type = INSET_FDIR; 16882 else if (!strcmp(res->inset_type, "fdir_flx_inset")) 16883 inset_type = INSET_FDIR_FLX; 16884 16885 memset(&inset, 0, sizeof(inset)); 16886 16887 ret = rte_pmd_i40e_inset_set(res->port_id, res->pctype_id, 16888 &inset, inset_type); 16889 if (ret) { 16890 printf("Failed to clear input set.\n"); 16891 return; 16892 } 16893 16894 #endif 16895 16896 if (ret == -ENOTSUP) 16897 printf("Function not supported\n"); 16898 } 16899 16900 cmdline_parse_token_string_t cmd_clear_input_set_port = 16901 TOKEN_STRING_INITIALIZER(struct cmd_clear_input_set_result, 16902 port, "port"); 16903 cmdline_parse_token_string_t cmd_clear_input_set_cfg = 16904 TOKEN_STRING_INITIALIZER(struct cmd_clear_input_set_result, 16905 cfg, "config"); 16906 cmdline_parse_token_num_t cmd_clear_input_set_port_id = 16907 TOKEN_NUM_INITIALIZER(struct cmd_clear_input_set_result, 16908 port_id, UINT16); 16909 cmdline_parse_token_string_t cmd_clear_input_set_pctype = 16910 TOKEN_STRING_INITIALIZER(struct cmd_clear_input_set_result, 16911 pctype, "pctype"); 16912 cmdline_parse_token_num_t cmd_clear_input_set_pctype_id = 16913 TOKEN_NUM_INITIALIZER(struct cmd_clear_input_set_result, 16914 pctype_id, UINT8); 16915 cmdline_parse_token_string_t cmd_clear_input_set_inset_type = 16916 TOKEN_STRING_INITIALIZER(struct cmd_clear_input_set_result, 16917 inset_type, 16918 "hash_inset#fdir_inset#fdir_flx_inset"); 16919 cmdline_parse_token_string_t cmd_clear_input_set_clear = 16920 TOKEN_STRING_INITIALIZER(struct cmd_clear_input_set_result, 16921 clear, "clear"); 16922 cmdline_parse_token_string_t cmd_clear_input_set_all = 16923 TOKEN_STRING_INITIALIZER(struct cmd_clear_input_set_result, 16924 all, "all"); 16925 16926 cmdline_parse_inst_t cmd_clear_input_set = { 16927 .f = cmd_clear_input_set_parsed, 16928 .data = NULL, 16929 .help_str = "port config <port_id> pctype <pctype_id> hash_inset|" 16930 "fdir_inset|fdir_flx_inset clear all", 16931 .tokens = { 16932 (void *)&cmd_clear_input_set_port, 16933 (void *)&cmd_clear_input_set_cfg, 16934 (void *)&cmd_clear_input_set_port_id, 16935 (void *)&cmd_clear_input_set_pctype, 16936 (void *)&cmd_clear_input_set_pctype_id, 16937 (void *)&cmd_clear_input_set_inset_type, 16938 (void *)&cmd_clear_input_set_clear, 16939 (void *)&cmd_clear_input_set_all, 16940 NULL, 16941 }, 16942 }; 16943 16944 /* show vf stats */ 16945 16946 /* Common result structure for show vf stats */ 16947 struct cmd_show_vf_stats_result { 16948 cmdline_fixed_string_t show; 16949 cmdline_fixed_string_t vf; 16950 cmdline_fixed_string_t stats; 16951 portid_t port_id; 16952 uint16_t vf_id; 16953 }; 16954 16955 /* Common CLI fields show vf stats*/ 16956 cmdline_parse_token_string_t cmd_show_vf_stats_show = 16957 TOKEN_STRING_INITIALIZER 16958 (struct cmd_show_vf_stats_result, 16959 show, "show"); 16960 cmdline_parse_token_string_t cmd_show_vf_stats_vf = 16961 TOKEN_STRING_INITIALIZER 16962 (struct cmd_show_vf_stats_result, 16963 vf, "vf"); 16964 cmdline_parse_token_string_t cmd_show_vf_stats_stats = 16965 TOKEN_STRING_INITIALIZER 16966 (struct cmd_show_vf_stats_result, 16967 stats, "stats"); 16968 cmdline_parse_token_num_t cmd_show_vf_stats_port_id = 16969 TOKEN_NUM_INITIALIZER 16970 (struct cmd_show_vf_stats_result, 16971 port_id, UINT16); 16972 cmdline_parse_token_num_t cmd_show_vf_stats_vf_id = 16973 TOKEN_NUM_INITIALIZER 16974 (struct cmd_show_vf_stats_result, 16975 vf_id, UINT16); 16976 16977 static void 16978 cmd_show_vf_stats_parsed( 16979 void *parsed_result, 16980 __attribute__((unused)) struct cmdline *cl, 16981 __attribute__((unused)) void *data) 16982 { 16983 struct cmd_show_vf_stats_result *res = parsed_result; 16984 struct rte_eth_stats stats; 16985 int ret = -ENOTSUP; 16986 static const char *nic_stats_border = "########################"; 16987 16988 if (port_id_is_invalid(res->port_id, ENABLED_WARN)) 16989 return; 16990 16991 memset(&stats, 0, sizeof(stats)); 16992 16993 #ifdef RTE_LIBRTE_I40E_PMD 16994 if (ret == -ENOTSUP) 16995 ret = rte_pmd_i40e_get_vf_stats(res->port_id, 16996 res->vf_id, 16997 &stats); 16998 #endif 16999 #ifdef RTE_LIBRTE_BNXT_PMD 17000 if (ret == -ENOTSUP) 17001 ret = rte_pmd_bnxt_get_vf_stats(res->port_id, 17002 res->vf_id, 17003 &stats); 17004 #endif 17005 17006 switch (ret) { 17007 case 0: 17008 break; 17009 case -EINVAL: 17010 printf("invalid vf_id %d\n", res->vf_id); 17011 break; 17012 case -ENODEV: 17013 printf("invalid port_id %d\n", res->port_id); 17014 break; 17015 case -ENOTSUP: 17016 printf("function not implemented\n"); 17017 break; 17018 default: 17019 printf("programming error: (%s)\n", strerror(-ret)); 17020 } 17021 17022 printf("\n %s NIC statistics for port %-2d vf %-2d %s\n", 17023 nic_stats_border, res->port_id, res->vf_id, nic_stats_border); 17024 17025 printf(" RX-packets: %-10"PRIu64" RX-missed: %-10"PRIu64" RX-bytes: " 17026 "%-"PRIu64"\n", 17027 stats.ipackets, stats.imissed, stats.ibytes); 17028 printf(" RX-errors: %-"PRIu64"\n", stats.ierrors); 17029 printf(" RX-nombuf: %-10"PRIu64"\n", 17030 stats.rx_nombuf); 17031 printf(" TX-packets: %-10"PRIu64" TX-errors: %-10"PRIu64" TX-bytes: " 17032 "%-"PRIu64"\n", 17033 stats.opackets, stats.oerrors, stats.obytes); 17034 17035 printf(" %s############################%s\n", 17036 nic_stats_border, nic_stats_border); 17037 } 17038 17039 cmdline_parse_inst_t cmd_show_vf_stats = { 17040 .f = cmd_show_vf_stats_parsed, 17041 .data = NULL, 17042 .help_str = "show vf stats <port_id> <vf_id>", 17043 .tokens = { 17044 (void *)&cmd_show_vf_stats_show, 17045 (void *)&cmd_show_vf_stats_vf, 17046 (void *)&cmd_show_vf_stats_stats, 17047 (void *)&cmd_show_vf_stats_port_id, 17048 (void *)&cmd_show_vf_stats_vf_id, 17049 NULL, 17050 }, 17051 }; 17052 17053 /* clear vf stats */ 17054 17055 /* Common result structure for clear vf stats */ 17056 struct cmd_clear_vf_stats_result { 17057 cmdline_fixed_string_t clear; 17058 cmdline_fixed_string_t vf; 17059 cmdline_fixed_string_t stats; 17060 portid_t port_id; 17061 uint16_t vf_id; 17062 }; 17063 17064 /* Common CLI fields clear vf stats*/ 17065 cmdline_parse_token_string_t cmd_clear_vf_stats_clear = 17066 TOKEN_STRING_INITIALIZER 17067 (struct cmd_clear_vf_stats_result, 17068 clear, "clear"); 17069 cmdline_parse_token_string_t cmd_clear_vf_stats_vf = 17070 TOKEN_STRING_INITIALIZER 17071 (struct cmd_clear_vf_stats_result, 17072 vf, "vf"); 17073 cmdline_parse_token_string_t cmd_clear_vf_stats_stats = 17074 TOKEN_STRING_INITIALIZER 17075 (struct cmd_clear_vf_stats_result, 17076 stats, "stats"); 17077 cmdline_parse_token_num_t cmd_clear_vf_stats_port_id = 17078 TOKEN_NUM_INITIALIZER 17079 (struct cmd_clear_vf_stats_result, 17080 port_id, UINT16); 17081 cmdline_parse_token_num_t cmd_clear_vf_stats_vf_id = 17082 TOKEN_NUM_INITIALIZER 17083 (struct cmd_clear_vf_stats_result, 17084 vf_id, UINT16); 17085 17086 static void 17087 cmd_clear_vf_stats_parsed( 17088 void *parsed_result, 17089 __attribute__((unused)) struct cmdline *cl, 17090 __attribute__((unused)) void *data) 17091 { 17092 struct cmd_clear_vf_stats_result *res = parsed_result; 17093 int ret = -ENOTSUP; 17094 17095 if (port_id_is_invalid(res->port_id, ENABLED_WARN)) 17096 return; 17097 17098 #ifdef RTE_LIBRTE_I40E_PMD 17099 if (ret == -ENOTSUP) 17100 ret = rte_pmd_i40e_reset_vf_stats(res->port_id, 17101 res->vf_id); 17102 #endif 17103 #ifdef RTE_LIBRTE_BNXT_PMD 17104 if (ret == -ENOTSUP) 17105 ret = rte_pmd_bnxt_reset_vf_stats(res->port_id, 17106 res->vf_id); 17107 #endif 17108 17109 switch (ret) { 17110 case 0: 17111 break; 17112 case -EINVAL: 17113 printf("invalid vf_id %d\n", res->vf_id); 17114 break; 17115 case -ENODEV: 17116 printf("invalid port_id %d\n", res->port_id); 17117 break; 17118 case -ENOTSUP: 17119 printf("function not implemented\n"); 17120 break; 17121 default: 17122 printf("programming error: (%s)\n", strerror(-ret)); 17123 } 17124 } 17125 17126 cmdline_parse_inst_t cmd_clear_vf_stats = { 17127 .f = cmd_clear_vf_stats_parsed, 17128 .data = NULL, 17129 .help_str = "clear vf stats <port_id> <vf_id>", 17130 .tokens = { 17131 (void *)&cmd_clear_vf_stats_clear, 17132 (void *)&cmd_clear_vf_stats_vf, 17133 (void *)&cmd_clear_vf_stats_stats, 17134 (void *)&cmd_clear_vf_stats_port_id, 17135 (void *)&cmd_clear_vf_stats_vf_id, 17136 NULL, 17137 }, 17138 }; 17139 17140 /* port config pctype mapping reset */ 17141 17142 /* Common result structure for port config pctype mapping reset */ 17143 struct cmd_pctype_mapping_reset_result { 17144 cmdline_fixed_string_t port; 17145 cmdline_fixed_string_t config; 17146 portid_t port_id; 17147 cmdline_fixed_string_t pctype; 17148 cmdline_fixed_string_t mapping; 17149 cmdline_fixed_string_t reset; 17150 }; 17151 17152 /* Common CLI fields for port config pctype mapping reset*/ 17153 cmdline_parse_token_string_t cmd_pctype_mapping_reset_port = 17154 TOKEN_STRING_INITIALIZER 17155 (struct cmd_pctype_mapping_reset_result, 17156 port, "port"); 17157 cmdline_parse_token_string_t cmd_pctype_mapping_reset_config = 17158 TOKEN_STRING_INITIALIZER 17159 (struct cmd_pctype_mapping_reset_result, 17160 config, "config"); 17161 cmdline_parse_token_num_t cmd_pctype_mapping_reset_port_id = 17162 TOKEN_NUM_INITIALIZER 17163 (struct cmd_pctype_mapping_reset_result, 17164 port_id, UINT16); 17165 cmdline_parse_token_string_t cmd_pctype_mapping_reset_pctype = 17166 TOKEN_STRING_INITIALIZER 17167 (struct cmd_pctype_mapping_reset_result, 17168 pctype, "pctype"); 17169 cmdline_parse_token_string_t cmd_pctype_mapping_reset_mapping = 17170 TOKEN_STRING_INITIALIZER 17171 (struct cmd_pctype_mapping_reset_result, 17172 mapping, "mapping"); 17173 cmdline_parse_token_string_t cmd_pctype_mapping_reset_reset = 17174 TOKEN_STRING_INITIALIZER 17175 (struct cmd_pctype_mapping_reset_result, 17176 reset, "reset"); 17177 17178 static void 17179 cmd_pctype_mapping_reset_parsed( 17180 void *parsed_result, 17181 __attribute__((unused)) struct cmdline *cl, 17182 __attribute__((unused)) void *data) 17183 { 17184 struct cmd_pctype_mapping_reset_result *res = parsed_result; 17185 int ret = -ENOTSUP; 17186 17187 if (port_id_is_invalid(res->port_id, ENABLED_WARN)) 17188 return; 17189 17190 #ifdef RTE_LIBRTE_I40E_PMD 17191 ret = rte_pmd_i40e_flow_type_mapping_reset(res->port_id); 17192 #endif 17193 17194 switch (ret) { 17195 case 0: 17196 break; 17197 case -ENODEV: 17198 printf("invalid port_id %d\n", res->port_id); 17199 break; 17200 case -ENOTSUP: 17201 printf("function not implemented\n"); 17202 break; 17203 default: 17204 printf("programming error: (%s)\n", strerror(-ret)); 17205 } 17206 } 17207 17208 cmdline_parse_inst_t cmd_pctype_mapping_reset = { 17209 .f = cmd_pctype_mapping_reset_parsed, 17210 .data = NULL, 17211 .help_str = "port config <port_id> pctype mapping reset", 17212 .tokens = { 17213 (void *)&cmd_pctype_mapping_reset_port, 17214 (void *)&cmd_pctype_mapping_reset_config, 17215 (void *)&cmd_pctype_mapping_reset_port_id, 17216 (void *)&cmd_pctype_mapping_reset_pctype, 17217 (void *)&cmd_pctype_mapping_reset_mapping, 17218 (void *)&cmd_pctype_mapping_reset_reset, 17219 NULL, 17220 }, 17221 }; 17222 17223 /* show port pctype mapping */ 17224 17225 /* Common result structure for show port pctype mapping */ 17226 struct cmd_pctype_mapping_get_result { 17227 cmdline_fixed_string_t show; 17228 cmdline_fixed_string_t port; 17229 portid_t port_id; 17230 cmdline_fixed_string_t pctype; 17231 cmdline_fixed_string_t mapping; 17232 }; 17233 17234 /* Common CLI fields for pctype mapping get */ 17235 cmdline_parse_token_string_t cmd_pctype_mapping_get_show = 17236 TOKEN_STRING_INITIALIZER 17237 (struct cmd_pctype_mapping_get_result, 17238 show, "show"); 17239 cmdline_parse_token_string_t cmd_pctype_mapping_get_port = 17240 TOKEN_STRING_INITIALIZER 17241 (struct cmd_pctype_mapping_get_result, 17242 port, "port"); 17243 cmdline_parse_token_num_t cmd_pctype_mapping_get_port_id = 17244 TOKEN_NUM_INITIALIZER 17245 (struct cmd_pctype_mapping_get_result, 17246 port_id, UINT16); 17247 cmdline_parse_token_string_t cmd_pctype_mapping_get_pctype = 17248 TOKEN_STRING_INITIALIZER 17249 (struct cmd_pctype_mapping_get_result, 17250 pctype, "pctype"); 17251 cmdline_parse_token_string_t cmd_pctype_mapping_get_mapping = 17252 TOKEN_STRING_INITIALIZER 17253 (struct cmd_pctype_mapping_get_result, 17254 mapping, "mapping"); 17255 17256 static void 17257 cmd_pctype_mapping_get_parsed( 17258 void *parsed_result, 17259 __attribute__((unused)) struct cmdline *cl, 17260 __attribute__((unused)) void *data) 17261 { 17262 struct cmd_pctype_mapping_get_result *res = parsed_result; 17263 int ret = -ENOTSUP; 17264 #ifdef RTE_LIBRTE_I40E_PMD 17265 struct rte_pmd_i40e_flow_type_mapping 17266 mapping[RTE_PMD_I40E_FLOW_TYPE_MAX]; 17267 int i, j, first_pctype; 17268 #endif 17269 17270 if (port_id_is_invalid(res->port_id, ENABLED_WARN)) 17271 return; 17272 17273 #ifdef RTE_LIBRTE_I40E_PMD 17274 ret = rte_pmd_i40e_flow_type_mapping_get(res->port_id, mapping); 17275 #endif 17276 17277 switch (ret) { 17278 case 0: 17279 break; 17280 case -ENODEV: 17281 printf("invalid port_id %d\n", res->port_id); 17282 return; 17283 case -ENOTSUP: 17284 printf("function not implemented\n"); 17285 return; 17286 default: 17287 printf("programming error: (%s)\n", strerror(-ret)); 17288 return; 17289 } 17290 17291 #ifdef RTE_LIBRTE_I40E_PMD 17292 for (i = 0; i < RTE_PMD_I40E_FLOW_TYPE_MAX; i++) { 17293 if (mapping[i].pctype != 0ULL) { 17294 first_pctype = 1; 17295 17296 printf("pctype: "); 17297 for (j = 0; j < RTE_PMD_I40E_PCTYPE_MAX; j++) { 17298 if (mapping[i].pctype & (1ULL << j)) { 17299 printf(first_pctype ? 17300 "%02d" : ",%02d", j); 17301 first_pctype = 0; 17302 } 17303 } 17304 printf(" -> flowtype: %02d\n", mapping[i].flow_type); 17305 } 17306 } 17307 #endif 17308 } 17309 17310 cmdline_parse_inst_t cmd_pctype_mapping_get = { 17311 .f = cmd_pctype_mapping_get_parsed, 17312 .data = NULL, 17313 .help_str = "show port <port_id> pctype mapping", 17314 .tokens = { 17315 (void *)&cmd_pctype_mapping_get_show, 17316 (void *)&cmd_pctype_mapping_get_port, 17317 (void *)&cmd_pctype_mapping_get_port_id, 17318 (void *)&cmd_pctype_mapping_get_pctype, 17319 (void *)&cmd_pctype_mapping_get_mapping, 17320 NULL, 17321 }, 17322 }; 17323 17324 /* port config pctype mapping update */ 17325 17326 /* Common result structure for port config pctype mapping update */ 17327 struct cmd_pctype_mapping_update_result { 17328 cmdline_fixed_string_t port; 17329 cmdline_fixed_string_t config; 17330 portid_t port_id; 17331 cmdline_fixed_string_t pctype; 17332 cmdline_fixed_string_t mapping; 17333 cmdline_fixed_string_t update; 17334 cmdline_fixed_string_t pctype_list; 17335 uint16_t flow_type; 17336 }; 17337 17338 /* Common CLI fields for pctype mapping update*/ 17339 cmdline_parse_token_string_t cmd_pctype_mapping_update_port = 17340 TOKEN_STRING_INITIALIZER 17341 (struct cmd_pctype_mapping_update_result, 17342 port, "port"); 17343 cmdline_parse_token_string_t cmd_pctype_mapping_update_config = 17344 TOKEN_STRING_INITIALIZER 17345 (struct cmd_pctype_mapping_update_result, 17346 config, "config"); 17347 cmdline_parse_token_num_t cmd_pctype_mapping_update_port_id = 17348 TOKEN_NUM_INITIALIZER 17349 (struct cmd_pctype_mapping_update_result, 17350 port_id, UINT16); 17351 cmdline_parse_token_string_t cmd_pctype_mapping_update_pctype = 17352 TOKEN_STRING_INITIALIZER 17353 (struct cmd_pctype_mapping_update_result, 17354 pctype, "pctype"); 17355 cmdline_parse_token_string_t cmd_pctype_mapping_update_mapping = 17356 TOKEN_STRING_INITIALIZER 17357 (struct cmd_pctype_mapping_update_result, 17358 mapping, "mapping"); 17359 cmdline_parse_token_string_t cmd_pctype_mapping_update_update = 17360 TOKEN_STRING_INITIALIZER 17361 (struct cmd_pctype_mapping_update_result, 17362 update, "update"); 17363 cmdline_parse_token_string_t cmd_pctype_mapping_update_pc_type = 17364 TOKEN_STRING_INITIALIZER 17365 (struct cmd_pctype_mapping_update_result, 17366 pctype_list, NULL); 17367 cmdline_parse_token_num_t cmd_pctype_mapping_update_flow_type = 17368 TOKEN_NUM_INITIALIZER 17369 (struct cmd_pctype_mapping_update_result, 17370 flow_type, UINT16); 17371 17372 static void 17373 cmd_pctype_mapping_update_parsed( 17374 void *parsed_result, 17375 __attribute__((unused)) struct cmdline *cl, 17376 __attribute__((unused)) void *data) 17377 { 17378 struct cmd_pctype_mapping_update_result *res = parsed_result; 17379 int ret = -ENOTSUP; 17380 #ifdef RTE_LIBRTE_I40E_PMD 17381 struct rte_pmd_i40e_flow_type_mapping mapping; 17382 unsigned int i; 17383 unsigned int nb_item; 17384 unsigned int pctype_list[RTE_PMD_I40E_PCTYPE_MAX]; 17385 #endif 17386 17387 if (port_id_is_invalid(res->port_id, ENABLED_WARN)) 17388 return; 17389 17390 #ifdef RTE_LIBRTE_I40E_PMD 17391 nb_item = parse_item_list(res->pctype_list, "pctypes", 17392 RTE_PMD_I40E_PCTYPE_MAX, pctype_list, 1); 17393 mapping.flow_type = res->flow_type; 17394 for (i = 0, mapping.pctype = 0ULL; i < nb_item; i++) 17395 mapping.pctype |= (1ULL << pctype_list[i]); 17396 ret = rte_pmd_i40e_flow_type_mapping_update(res->port_id, 17397 &mapping, 17398 1, 17399 0); 17400 #endif 17401 17402 switch (ret) { 17403 case 0: 17404 break; 17405 case -EINVAL: 17406 printf("invalid pctype or flow type\n"); 17407 break; 17408 case -ENODEV: 17409 printf("invalid port_id %d\n", res->port_id); 17410 break; 17411 case -ENOTSUP: 17412 printf("function not implemented\n"); 17413 break; 17414 default: 17415 printf("programming error: (%s)\n", strerror(-ret)); 17416 } 17417 } 17418 17419 cmdline_parse_inst_t cmd_pctype_mapping_update = { 17420 .f = cmd_pctype_mapping_update_parsed, 17421 .data = NULL, 17422 .help_str = "port config <port_id> pctype mapping update" 17423 " <pctype_id_0,[pctype_id_1]*> <flowtype_id>", 17424 .tokens = { 17425 (void *)&cmd_pctype_mapping_update_port, 17426 (void *)&cmd_pctype_mapping_update_config, 17427 (void *)&cmd_pctype_mapping_update_port_id, 17428 (void *)&cmd_pctype_mapping_update_pctype, 17429 (void *)&cmd_pctype_mapping_update_mapping, 17430 (void *)&cmd_pctype_mapping_update_update, 17431 (void *)&cmd_pctype_mapping_update_pc_type, 17432 (void *)&cmd_pctype_mapping_update_flow_type, 17433 NULL, 17434 }, 17435 }; 17436 17437 /* ptype mapping get */ 17438 17439 /* Common result structure for ptype mapping get */ 17440 struct cmd_ptype_mapping_get_result { 17441 cmdline_fixed_string_t ptype; 17442 cmdline_fixed_string_t mapping; 17443 cmdline_fixed_string_t get; 17444 portid_t port_id; 17445 uint8_t valid_only; 17446 }; 17447 17448 /* Common CLI fields for ptype mapping get */ 17449 cmdline_parse_token_string_t cmd_ptype_mapping_get_ptype = 17450 TOKEN_STRING_INITIALIZER 17451 (struct cmd_ptype_mapping_get_result, 17452 ptype, "ptype"); 17453 cmdline_parse_token_string_t cmd_ptype_mapping_get_mapping = 17454 TOKEN_STRING_INITIALIZER 17455 (struct cmd_ptype_mapping_get_result, 17456 mapping, "mapping"); 17457 cmdline_parse_token_string_t cmd_ptype_mapping_get_get = 17458 TOKEN_STRING_INITIALIZER 17459 (struct cmd_ptype_mapping_get_result, 17460 get, "get"); 17461 cmdline_parse_token_num_t cmd_ptype_mapping_get_port_id = 17462 TOKEN_NUM_INITIALIZER 17463 (struct cmd_ptype_mapping_get_result, 17464 port_id, UINT16); 17465 cmdline_parse_token_num_t cmd_ptype_mapping_get_valid_only = 17466 TOKEN_NUM_INITIALIZER 17467 (struct cmd_ptype_mapping_get_result, 17468 valid_only, UINT8); 17469 17470 static void 17471 cmd_ptype_mapping_get_parsed( 17472 void *parsed_result, 17473 __attribute__((unused)) struct cmdline *cl, 17474 __attribute__((unused)) void *data) 17475 { 17476 struct cmd_ptype_mapping_get_result *res = parsed_result; 17477 int ret = -ENOTSUP; 17478 #ifdef RTE_LIBRTE_I40E_PMD 17479 int max_ptype_num = 256; 17480 struct rte_pmd_i40e_ptype_mapping mapping[max_ptype_num]; 17481 uint16_t count; 17482 int i; 17483 #endif 17484 17485 if (port_id_is_invalid(res->port_id, ENABLED_WARN)) 17486 return; 17487 17488 #ifdef RTE_LIBRTE_I40E_PMD 17489 ret = rte_pmd_i40e_ptype_mapping_get(res->port_id, 17490 mapping, 17491 max_ptype_num, 17492 &count, 17493 res->valid_only); 17494 #endif 17495 17496 switch (ret) { 17497 case 0: 17498 break; 17499 case -ENODEV: 17500 printf("invalid port_id %d\n", res->port_id); 17501 break; 17502 case -ENOTSUP: 17503 printf("function not implemented\n"); 17504 break; 17505 default: 17506 printf("programming error: (%s)\n", strerror(-ret)); 17507 } 17508 17509 #ifdef RTE_LIBRTE_I40E_PMD 17510 if (!ret) { 17511 for (i = 0; i < count; i++) 17512 printf("%3d\t0x%08x\n", 17513 mapping[i].hw_ptype, mapping[i].sw_ptype); 17514 } 17515 #endif 17516 } 17517 17518 cmdline_parse_inst_t cmd_ptype_mapping_get = { 17519 .f = cmd_ptype_mapping_get_parsed, 17520 .data = NULL, 17521 .help_str = "ptype mapping get <port_id> <valid_only>", 17522 .tokens = { 17523 (void *)&cmd_ptype_mapping_get_ptype, 17524 (void *)&cmd_ptype_mapping_get_mapping, 17525 (void *)&cmd_ptype_mapping_get_get, 17526 (void *)&cmd_ptype_mapping_get_port_id, 17527 (void *)&cmd_ptype_mapping_get_valid_only, 17528 NULL, 17529 }, 17530 }; 17531 17532 /* ptype mapping replace */ 17533 17534 /* Common result structure for ptype mapping replace */ 17535 struct cmd_ptype_mapping_replace_result { 17536 cmdline_fixed_string_t ptype; 17537 cmdline_fixed_string_t mapping; 17538 cmdline_fixed_string_t replace; 17539 portid_t port_id; 17540 uint32_t target; 17541 uint8_t mask; 17542 uint32_t pkt_type; 17543 }; 17544 17545 /* Common CLI fields for ptype mapping replace */ 17546 cmdline_parse_token_string_t cmd_ptype_mapping_replace_ptype = 17547 TOKEN_STRING_INITIALIZER 17548 (struct cmd_ptype_mapping_replace_result, 17549 ptype, "ptype"); 17550 cmdline_parse_token_string_t cmd_ptype_mapping_replace_mapping = 17551 TOKEN_STRING_INITIALIZER 17552 (struct cmd_ptype_mapping_replace_result, 17553 mapping, "mapping"); 17554 cmdline_parse_token_string_t cmd_ptype_mapping_replace_replace = 17555 TOKEN_STRING_INITIALIZER 17556 (struct cmd_ptype_mapping_replace_result, 17557 replace, "replace"); 17558 cmdline_parse_token_num_t cmd_ptype_mapping_replace_port_id = 17559 TOKEN_NUM_INITIALIZER 17560 (struct cmd_ptype_mapping_replace_result, 17561 port_id, UINT16); 17562 cmdline_parse_token_num_t cmd_ptype_mapping_replace_target = 17563 TOKEN_NUM_INITIALIZER 17564 (struct cmd_ptype_mapping_replace_result, 17565 target, UINT32); 17566 cmdline_parse_token_num_t cmd_ptype_mapping_replace_mask = 17567 TOKEN_NUM_INITIALIZER 17568 (struct cmd_ptype_mapping_replace_result, 17569 mask, UINT8); 17570 cmdline_parse_token_num_t cmd_ptype_mapping_replace_pkt_type = 17571 TOKEN_NUM_INITIALIZER 17572 (struct cmd_ptype_mapping_replace_result, 17573 pkt_type, UINT32); 17574 17575 static void 17576 cmd_ptype_mapping_replace_parsed( 17577 void *parsed_result, 17578 __attribute__((unused)) struct cmdline *cl, 17579 __attribute__((unused)) void *data) 17580 { 17581 struct cmd_ptype_mapping_replace_result *res = parsed_result; 17582 int ret = -ENOTSUP; 17583 17584 if (port_id_is_invalid(res->port_id, ENABLED_WARN)) 17585 return; 17586 17587 #ifdef RTE_LIBRTE_I40E_PMD 17588 ret = rte_pmd_i40e_ptype_mapping_replace(res->port_id, 17589 res->target, 17590 res->mask, 17591 res->pkt_type); 17592 #endif 17593 17594 switch (ret) { 17595 case 0: 17596 break; 17597 case -EINVAL: 17598 printf("invalid ptype 0x%8x or 0x%8x\n", 17599 res->target, res->pkt_type); 17600 break; 17601 case -ENODEV: 17602 printf("invalid port_id %d\n", res->port_id); 17603 break; 17604 case -ENOTSUP: 17605 printf("function not implemented\n"); 17606 break; 17607 default: 17608 printf("programming error: (%s)\n", strerror(-ret)); 17609 } 17610 } 17611 17612 cmdline_parse_inst_t cmd_ptype_mapping_replace = { 17613 .f = cmd_ptype_mapping_replace_parsed, 17614 .data = NULL, 17615 .help_str = 17616 "ptype mapping replace <port_id> <target> <mask> <pkt_type>", 17617 .tokens = { 17618 (void *)&cmd_ptype_mapping_replace_ptype, 17619 (void *)&cmd_ptype_mapping_replace_mapping, 17620 (void *)&cmd_ptype_mapping_replace_replace, 17621 (void *)&cmd_ptype_mapping_replace_port_id, 17622 (void *)&cmd_ptype_mapping_replace_target, 17623 (void *)&cmd_ptype_mapping_replace_mask, 17624 (void *)&cmd_ptype_mapping_replace_pkt_type, 17625 NULL, 17626 }, 17627 }; 17628 17629 /* ptype mapping reset */ 17630 17631 /* Common result structure for ptype mapping reset */ 17632 struct cmd_ptype_mapping_reset_result { 17633 cmdline_fixed_string_t ptype; 17634 cmdline_fixed_string_t mapping; 17635 cmdline_fixed_string_t reset; 17636 portid_t port_id; 17637 }; 17638 17639 /* Common CLI fields for ptype mapping reset*/ 17640 cmdline_parse_token_string_t cmd_ptype_mapping_reset_ptype = 17641 TOKEN_STRING_INITIALIZER 17642 (struct cmd_ptype_mapping_reset_result, 17643 ptype, "ptype"); 17644 cmdline_parse_token_string_t cmd_ptype_mapping_reset_mapping = 17645 TOKEN_STRING_INITIALIZER 17646 (struct cmd_ptype_mapping_reset_result, 17647 mapping, "mapping"); 17648 cmdline_parse_token_string_t cmd_ptype_mapping_reset_reset = 17649 TOKEN_STRING_INITIALIZER 17650 (struct cmd_ptype_mapping_reset_result, 17651 reset, "reset"); 17652 cmdline_parse_token_num_t cmd_ptype_mapping_reset_port_id = 17653 TOKEN_NUM_INITIALIZER 17654 (struct cmd_ptype_mapping_reset_result, 17655 port_id, UINT16); 17656 17657 static void 17658 cmd_ptype_mapping_reset_parsed( 17659 void *parsed_result, 17660 __attribute__((unused)) struct cmdline *cl, 17661 __attribute__((unused)) void *data) 17662 { 17663 struct cmd_ptype_mapping_reset_result *res = parsed_result; 17664 int ret = -ENOTSUP; 17665 17666 if (port_id_is_invalid(res->port_id, ENABLED_WARN)) 17667 return; 17668 17669 #ifdef RTE_LIBRTE_I40E_PMD 17670 ret = rte_pmd_i40e_ptype_mapping_reset(res->port_id); 17671 #endif 17672 17673 switch (ret) { 17674 case 0: 17675 break; 17676 case -ENODEV: 17677 printf("invalid port_id %d\n", res->port_id); 17678 break; 17679 case -ENOTSUP: 17680 printf("function not implemented\n"); 17681 break; 17682 default: 17683 printf("programming error: (%s)\n", strerror(-ret)); 17684 } 17685 } 17686 17687 cmdline_parse_inst_t cmd_ptype_mapping_reset = { 17688 .f = cmd_ptype_mapping_reset_parsed, 17689 .data = NULL, 17690 .help_str = "ptype mapping reset <port_id>", 17691 .tokens = { 17692 (void *)&cmd_ptype_mapping_reset_ptype, 17693 (void *)&cmd_ptype_mapping_reset_mapping, 17694 (void *)&cmd_ptype_mapping_reset_reset, 17695 (void *)&cmd_ptype_mapping_reset_port_id, 17696 NULL, 17697 }, 17698 }; 17699 17700 /* ptype mapping update */ 17701 17702 /* Common result structure for ptype mapping update */ 17703 struct cmd_ptype_mapping_update_result { 17704 cmdline_fixed_string_t ptype; 17705 cmdline_fixed_string_t mapping; 17706 cmdline_fixed_string_t reset; 17707 portid_t port_id; 17708 uint8_t hw_ptype; 17709 uint32_t sw_ptype; 17710 }; 17711 17712 /* Common CLI fields for ptype mapping update*/ 17713 cmdline_parse_token_string_t cmd_ptype_mapping_update_ptype = 17714 TOKEN_STRING_INITIALIZER 17715 (struct cmd_ptype_mapping_update_result, 17716 ptype, "ptype"); 17717 cmdline_parse_token_string_t cmd_ptype_mapping_update_mapping = 17718 TOKEN_STRING_INITIALIZER 17719 (struct cmd_ptype_mapping_update_result, 17720 mapping, "mapping"); 17721 cmdline_parse_token_string_t cmd_ptype_mapping_update_update = 17722 TOKEN_STRING_INITIALIZER 17723 (struct cmd_ptype_mapping_update_result, 17724 reset, "update"); 17725 cmdline_parse_token_num_t cmd_ptype_mapping_update_port_id = 17726 TOKEN_NUM_INITIALIZER 17727 (struct cmd_ptype_mapping_update_result, 17728 port_id, UINT16); 17729 cmdline_parse_token_num_t cmd_ptype_mapping_update_hw_ptype = 17730 TOKEN_NUM_INITIALIZER 17731 (struct cmd_ptype_mapping_update_result, 17732 hw_ptype, UINT8); 17733 cmdline_parse_token_num_t cmd_ptype_mapping_update_sw_ptype = 17734 TOKEN_NUM_INITIALIZER 17735 (struct cmd_ptype_mapping_update_result, 17736 sw_ptype, UINT32); 17737 17738 static void 17739 cmd_ptype_mapping_update_parsed( 17740 void *parsed_result, 17741 __attribute__((unused)) struct cmdline *cl, 17742 __attribute__((unused)) void *data) 17743 { 17744 struct cmd_ptype_mapping_update_result *res = parsed_result; 17745 int ret = -ENOTSUP; 17746 #ifdef RTE_LIBRTE_I40E_PMD 17747 struct rte_pmd_i40e_ptype_mapping mapping; 17748 #endif 17749 if (port_id_is_invalid(res->port_id, ENABLED_WARN)) 17750 return; 17751 17752 #ifdef RTE_LIBRTE_I40E_PMD 17753 mapping.hw_ptype = res->hw_ptype; 17754 mapping.sw_ptype = res->sw_ptype; 17755 ret = rte_pmd_i40e_ptype_mapping_update(res->port_id, 17756 &mapping, 17757 1, 17758 0); 17759 #endif 17760 17761 switch (ret) { 17762 case 0: 17763 break; 17764 case -EINVAL: 17765 printf("invalid ptype 0x%8x\n", res->sw_ptype); 17766 break; 17767 case -ENODEV: 17768 printf("invalid port_id %d\n", res->port_id); 17769 break; 17770 case -ENOTSUP: 17771 printf("function not implemented\n"); 17772 break; 17773 default: 17774 printf("programming error: (%s)\n", strerror(-ret)); 17775 } 17776 } 17777 17778 cmdline_parse_inst_t cmd_ptype_mapping_update = { 17779 .f = cmd_ptype_mapping_update_parsed, 17780 .data = NULL, 17781 .help_str = "ptype mapping update <port_id> <hw_ptype> <sw_ptype>", 17782 .tokens = { 17783 (void *)&cmd_ptype_mapping_update_ptype, 17784 (void *)&cmd_ptype_mapping_update_mapping, 17785 (void *)&cmd_ptype_mapping_update_update, 17786 (void *)&cmd_ptype_mapping_update_port_id, 17787 (void *)&cmd_ptype_mapping_update_hw_ptype, 17788 (void *)&cmd_ptype_mapping_update_sw_ptype, 17789 NULL, 17790 }, 17791 }; 17792 17793 /* Common result structure for file commands */ 17794 struct cmd_cmdfile_result { 17795 cmdline_fixed_string_t load; 17796 cmdline_fixed_string_t filename; 17797 }; 17798 17799 /* Common CLI fields for file commands */ 17800 cmdline_parse_token_string_t cmd_load_cmdfile = 17801 TOKEN_STRING_INITIALIZER(struct cmd_cmdfile_result, load, "load"); 17802 cmdline_parse_token_string_t cmd_load_cmdfile_filename = 17803 TOKEN_STRING_INITIALIZER(struct cmd_cmdfile_result, filename, NULL); 17804 17805 static void 17806 cmd_load_from_file_parsed( 17807 void *parsed_result, 17808 __attribute__((unused)) struct cmdline *cl, 17809 __attribute__((unused)) void *data) 17810 { 17811 struct cmd_cmdfile_result *res = parsed_result; 17812 17813 cmdline_read_from_file(res->filename); 17814 } 17815 17816 cmdline_parse_inst_t cmd_load_from_file = { 17817 .f = cmd_load_from_file_parsed, 17818 .data = NULL, 17819 .help_str = "load <filename>", 17820 .tokens = { 17821 (void *)&cmd_load_cmdfile, 17822 (void *)&cmd_load_cmdfile_filename, 17823 NULL, 17824 }, 17825 }; 17826 17827 /* Get Rx offloads capabilities */ 17828 struct cmd_rx_offload_get_capa_result { 17829 cmdline_fixed_string_t show; 17830 cmdline_fixed_string_t port; 17831 portid_t port_id; 17832 cmdline_fixed_string_t rx_offload; 17833 cmdline_fixed_string_t capabilities; 17834 }; 17835 17836 cmdline_parse_token_string_t cmd_rx_offload_get_capa_show = 17837 TOKEN_STRING_INITIALIZER 17838 (struct cmd_rx_offload_get_capa_result, 17839 show, "show"); 17840 cmdline_parse_token_string_t cmd_rx_offload_get_capa_port = 17841 TOKEN_STRING_INITIALIZER 17842 (struct cmd_rx_offload_get_capa_result, 17843 port, "port"); 17844 cmdline_parse_token_num_t cmd_rx_offload_get_capa_port_id = 17845 TOKEN_NUM_INITIALIZER 17846 (struct cmd_rx_offload_get_capa_result, 17847 port_id, UINT16); 17848 cmdline_parse_token_string_t cmd_rx_offload_get_capa_rx_offload = 17849 TOKEN_STRING_INITIALIZER 17850 (struct cmd_rx_offload_get_capa_result, 17851 rx_offload, "rx_offload"); 17852 cmdline_parse_token_string_t cmd_rx_offload_get_capa_capabilities = 17853 TOKEN_STRING_INITIALIZER 17854 (struct cmd_rx_offload_get_capa_result, 17855 capabilities, "capabilities"); 17856 17857 static void 17858 print_rx_offloads(uint64_t offloads) 17859 { 17860 uint64_t single_offload; 17861 int begin; 17862 int end; 17863 int bit; 17864 17865 if (offloads == 0) 17866 return; 17867 17868 begin = __builtin_ctzll(offloads); 17869 end = sizeof(offloads) * CHAR_BIT - __builtin_clzll(offloads); 17870 17871 single_offload = 1ULL << begin; 17872 for (bit = begin; bit < end; bit++) { 17873 if (offloads & single_offload) 17874 printf(" %s", 17875 rte_eth_dev_rx_offload_name(single_offload)); 17876 single_offload <<= 1; 17877 } 17878 } 17879 17880 static void 17881 cmd_rx_offload_get_capa_parsed( 17882 void *parsed_result, 17883 __attribute__((unused)) struct cmdline *cl, 17884 __attribute__((unused)) void *data) 17885 { 17886 struct cmd_rx_offload_get_capa_result *res = parsed_result; 17887 struct rte_eth_dev_info dev_info; 17888 portid_t port_id = res->port_id; 17889 uint64_t queue_offloads; 17890 uint64_t port_offloads; 17891 17892 rte_eth_dev_info_get(port_id, &dev_info); 17893 queue_offloads = dev_info.rx_queue_offload_capa; 17894 port_offloads = dev_info.rx_offload_capa ^ queue_offloads; 17895 17896 printf("Rx Offloading Capabilities of port %d :\n", port_id); 17897 printf(" Per Queue :"); 17898 print_rx_offloads(queue_offloads); 17899 17900 printf("\n"); 17901 printf(" Per Port :"); 17902 print_rx_offloads(port_offloads); 17903 printf("\n\n"); 17904 } 17905 17906 cmdline_parse_inst_t cmd_rx_offload_get_capa = { 17907 .f = cmd_rx_offload_get_capa_parsed, 17908 .data = NULL, 17909 .help_str = "show port <port_id> rx_offload capabilities", 17910 .tokens = { 17911 (void *)&cmd_rx_offload_get_capa_show, 17912 (void *)&cmd_rx_offload_get_capa_port, 17913 (void *)&cmd_rx_offload_get_capa_port_id, 17914 (void *)&cmd_rx_offload_get_capa_rx_offload, 17915 (void *)&cmd_rx_offload_get_capa_capabilities, 17916 NULL, 17917 } 17918 }; 17919 17920 /* Get Rx offloads configuration */ 17921 struct cmd_rx_offload_get_configuration_result { 17922 cmdline_fixed_string_t show; 17923 cmdline_fixed_string_t port; 17924 portid_t port_id; 17925 cmdline_fixed_string_t rx_offload; 17926 cmdline_fixed_string_t configuration; 17927 }; 17928 17929 cmdline_parse_token_string_t cmd_rx_offload_get_configuration_show = 17930 TOKEN_STRING_INITIALIZER 17931 (struct cmd_rx_offload_get_configuration_result, 17932 show, "show"); 17933 cmdline_parse_token_string_t cmd_rx_offload_get_configuration_port = 17934 TOKEN_STRING_INITIALIZER 17935 (struct cmd_rx_offload_get_configuration_result, 17936 port, "port"); 17937 cmdline_parse_token_num_t cmd_rx_offload_get_configuration_port_id = 17938 TOKEN_NUM_INITIALIZER 17939 (struct cmd_rx_offload_get_configuration_result, 17940 port_id, UINT16); 17941 cmdline_parse_token_string_t cmd_rx_offload_get_configuration_rx_offload = 17942 TOKEN_STRING_INITIALIZER 17943 (struct cmd_rx_offload_get_configuration_result, 17944 rx_offload, "rx_offload"); 17945 cmdline_parse_token_string_t cmd_rx_offload_get_configuration_configuration = 17946 TOKEN_STRING_INITIALIZER 17947 (struct cmd_rx_offload_get_configuration_result, 17948 configuration, "configuration"); 17949 17950 static void 17951 cmd_rx_offload_get_configuration_parsed( 17952 void *parsed_result, 17953 __attribute__((unused)) struct cmdline *cl, 17954 __attribute__((unused)) void *data) 17955 { 17956 struct cmd_rx_offload_get_configuration_result *res = parsed_result; 17957 struct rte_eth_dev_info dev_info; 17958 portid_t port_id = res->port_id; 17959 struct rte_port *port = &ports[port_id]; 17960 uint64_t port_offloads; 17961 uint64_t queue_offloads; 17962 uint16_t nb_rx_queues; 17963 int q; 17964 17965 printf("Rx Offloading Configuration of port %d :\n", port_id); 17966 17967 port_offloads = port->dev_conf.rxmode.offloads; 17968 printf(" Port :"); 17969 print_rx_offloads(port_offloads); 17970 printf("\n"); 17971 17972 rte_eth_dev_info_get(port_id, &dev_info); 17973 nb_rx_queues = dev_info.nb_rx_queues; 17974 for (q = 0; q < nb_rx_queues; q++) { 17975 queue_offloads = port->rx_conf[q].offloads; 17976 printf(" Queue[%2d] :", q); 17977 print_rx_offloads(queue_offloads); 17978 printf("\n"); 17979 } 17980 printf("\n"); 17981 } 17982 17983 cmdline_parse_inst_t cmd_rx_offload_get_configuration = { 17984 .f = cmd_rx_offload_get_configuration_parsed, 17985 .data = NULL, 17986 .help_str = "show port <port_id> rx_offload configuration", 17987 .tokens = { 17988 (void *)&cmd_rx_offload_get_configuration_show, 17989 (void *)&cmd_rx_offload_get_configuration_port, 17990 (void *)&cmd_rx_offload_get_configuration_port_id, 17991 (void *)&cmd_rx_offload_get_configuration_rx_offload, 17992 (void *)&cmd_rx_offload_get_configuration_configuration, 17993 NULL, 17994 } 17995 }; 17996 17997 /* Enable/Disable a per port offloading */ 17998 struct cmd_config_per_port_rx_offload_result { 17999 cmdline_fixed_string_t port; 18000 cmdline_fixed_string_t config; 18001 portid_t port_id; 18002 cmdline_fixed_string_t rx_offload; 18003 cmdline_fixed_string_t offload; 18004 cmdline_fixed_string_t on_off; 18005 }; 18006 18007 cmdline_parse_token_string_t cmd_config_per_port_rx_offload_result_port = 18008 TOKEN_STRING_INITIALIZER 18009 (struct cmd_config_per_port_rx_offload_result, 18010 port, "port"); 18011 cmdline_parse_token_string_t cmd_config_per_port_rx_offload_result_config = 18012 TOKEN_STRING_INITIALIZER 18013 (struct cmd_config_per_port_rx_offload_result, 18014 config, "config"); 18015 cmdline_parse_token_num_t cmd_config_per_port_rx_offload_result_port_id = 18016 TOKEN_NUM_INITIALIZER 18017 (struct cmd_config_per_port_rx_offload_result, 18018 port_id, UINT16); 18019 cmdline_parse_token_string_t cmd_config_per_port_rx_offload_result_rx_offload = 18020 TOKEN_STRING_INITIALIZER 18021 (struct cmd_config_per_port_rx_offload_result, 18022 rx_offload, "rx_offload"); 18023 cmdline_parse_token_string_t cmd_config_per_port_rx_offload_result_offload = 18024 TOKEN_STRING_INITIALIZER 18025 (struct cmd_config_per_port_rx_offload_result, 18026 offload, "vlan_strip#ipv4_cksum#udp_cksum#tcp_cksum#tcp_lro#" 18027 "qinq_strip#outer_ipv4_cksum#macsec_strip#" 18028 "header_split#vlan_filter#vlan_extend#jumbo_frame#" 18029 "crc_strip#scatter#timestamp#security#keep_crc"); 18030 cmdline_parse_token_string_t cmd_config_per_port_rx_offload_result_on_off = 18031 TOKEN_STRING_INITIALIZER 18032 (struct cmd_config_per_port_rx_offload_result, 18033 on_off, "on#off"); 18034 18035 static uint64_t 18036 search_rx_offload(const char *name) 18037 { 18038 uint64_t single_offload; 18039 const char *single_name; 18040 int found = 0; 18041 unsigned int bit; 18042 18043 single_offload = 1; 18044 for (bit = 0; bit < sizeof(single_offload) * CHAR_BIT; bit++) { 18045 single_name = rte_eth_dev_rx_offload_name(single_offload); 18046 if (!strcasecmp(single_name, name)) { 18047 found = 1; 18048 break; 18049 } 18050 single_offload <<= 1; 18051 } 18052 18053 if (found) 18054 return single_offload; 18055 18056 return 0; 18057 } 18058 18059 static void 18060 cmd_config_per_port_rx_offload_parsed(void *parsed_result, 18061 __attribute__((unused)) struct cmdline *cl, 18062 __attribute__((unused)) void *data) 18063 { 18064 struct cmd_config_per_port_rx_offload_result *res = parsed_result; 18065 portid_t port_id = res->port_id; 18066 struct rte_eth_dev_info dev_info; 18067 struct rte_port *port = &ports[port_id]; 18068 uint64_t single_offload; 18069 uint16_t nb_rx_queues; 18070 int q; 18071 18072 if (port->port_status != RTE_PORT_STOPPED) { 18073 printf("Error: Can't config offload when Port %d " 18074 "is not stopped\n", port_id); 18075 return; 18076 } 18077 18078 single_offload = search_rx_offload(res->offload); 18079 if (single_offload == 0) { 18080 printf("Unknown offload name: %s\n", res->offload); 18081 return; 18082 } 18083 18084 rte_eth_dev_info_get(port_id, &dev_info); 18085 nb_rx_queues = dev_info.nb_rx_queues; 18086 if (!strcmp(res->on_off, "on")) { 18087 port->dev_conf.rxmode.offloads |= single_offload; 18088 for (q = 0; q < nb_rx_queues; q++) 18089 port->rx_conf[q].offloads |= single_offload; 18090 } else { 18091 port->dev_conf.rxmode.offloads &= ~single_offload; 18092 for (q = 0; q < nb_rx_queues; q++) 18093 port->rx_conf[q].offloads &= ~single_offload; 18094 } 18095 18096 cmd_reconfig_device_queue(port_id, 1, 1); 18097 } 18098 18099 cmdline_parse_inst_t cmd_config_per_port_rx_offload = { 18100 .f = cmd_config_per_port_rx_offload_parsed, 18101 .data = NULL, 18102 .help_str = "port config <port_id> rx_offload vlan_strip|ipv4_cksum|" 18103 "udp_cksum|tcp_cksum|tcp_lro|qinq_strip|outer_ipv4_cksum|" 18104 "macsec_strip|header_split|vlan_filter|vlan_extend|" 18105 "jumbo_frame|crc_strip|scatter|timestamp|security|keep_crc " 18106 "on|off", 18107 .tokens = { 18108 (void *)&cmd_config_per_port_rx_offload_result_port, 18109 (void *)&cmd_config_per_port_rx_offload_result_config, 18110 (void *)&cmd_config_per_port_rx_offload_result_port_id, 18111 (void *)&cmd_config_per_port_rx_offload_result_rx_offload, 18112 (void *)&cmd_config_per_port_rx_offload_result_offload, 18113 (void *)&cmd_config_per_port_rx_offload_result_on_off, 18114 NULL, 18115 } 18116 }; 18117 18118 /* Enable/Disable a per queue offloading */ 18119 struct cmd_config_per_queue_rx_offload_result { 18120 cmdline_fixed_string_t port; 18121 portid_t port_id; 18122 cmdline_fixed_string_t rxq; 18123 uint16_t queue_id; 18124 cmdline_fixed_string_t rx_offload; 18125 cmdline_fixed_string_t offload; 18126 cmdline_fixed_string_t on_off; 18127 }; 18128 18129 cmdline_parse_token_string_t cmd_config_per_queue_rx_offload_result_port = 18130 TOKEN_STRING_INITIALIZER 18131 (struct cmd_config_per_queue_rx_offload_result, 18132 port, "port"); 18133 cmdline_parse_token_num_t cmd_config_per_queue_rx_offload_result_port_id = 18134 TOKEN_NUM_INITIALIZER 18135 (struct cmd_config_per_queue_rx_offload_result, 18136 port_id, UINT16); 18137 cmdline_parse_token_string_t cmd_config_per_queue_rx_offload_result_rxq = 18138 TOKEN_STRING_INITIALIZER 18139 (struct cmd_config_per_queue_rx_offload_result, 18140 rxq, "rxq"); 18141 cmdline_parse_token_num_t cmd_config_per_queue_rx_offload_result_queue_id = 18142 TOKEN_NUM_INITIALIZER 18143 (struct cmd_config_per_queue_rx_offload_result, 18144 queue_id, UINT16); 18145 cmdline_parse_token_string_t cmd_config_per_queue_rx_offload_result_rxoffload = 18146 TOKEN_STRING_INITIALIZER 18147 (struct cmd_config_per_queue_rx_offload_result, 18148 rx_offload, "rx_offload"); 18149 cmdline_parse_token_string_t cmd_config_per_queue_rx_offload_result_offload = 18150 TOKEN_STRING_INITIALIZER 18151 (struct cmd_config_per_queue_rx_offload_result, 18152 offload, "vlan_strip#ipv4_cksum#udp_cksum#tcp_cksum#tcp_lro#" 18153 "qinq_strip#outer_ipv4_cksum#macsec_strip#" 18154 "header_split#vlan_filter#vlan_extend#jumbo_frame#" 18155 "crc_strip#scatter#timestamp#security#keep_crc"); 18156 cmdline_parse_token_string_t cmd_config_per_queue_rx_offload_result_on_off = 18157 TOKEN_STRING_INITIALIZER 18158 (struct cmd_config_per_queue_rx_offload_result, 18159 on_off, "on#off"); 18160 18161 static void 18162 cmd_config_per_queue_rx_offload_parsed(void *parsed_result, 18163 __attribute__((unused)) struct cmdline *cl, 18164 __attribute__((unused)) void *data) 18165 { 18166 struct cmd_config_per_queue_rx_offload_result *res = parsed_result; 18167 struct rte_eth_dev_info dev_info; 18168 portid_t port_id = res->port_id; 18169 uint16_t queue_id = res->queue_id; 18170 struct rte_port *port = &ports[port_id]; 18171 uint64_t single_offload; 18172 18173 if (port->port_status != RTE_PORT_STOPPED) { 18174 printf("Error: Can't config offload when Port %d " 18175 "is not stopped\n", port_id); 18176 return; 18177 } 18178 18179 rte_eth_dev_info_get(port_id, &dev_info); 18180 if (queue_id >= dev_info.nb_rx_queues) { 18181 printf("Error: input queue_id should be 0 ... " 18182 "%d\n", dev_info.nb_rx_queues - 1); 18183 return; 18184 } 18185 18186 single_offload = search_rx_offload(res->offload); 18187 if (single_offload == 0) { 18188 printf("Unknown offload name: %s\n", res->offload); 18189 return; 18190 } 18191 18192 if (!strcmp(res->on_off, "on")) 18193 port->rx_conf[queue_id].offloads |= single_offload; 18194 else 18195 port->rx_conf[queue_id].offloads &= ~single_offload; 18196 18197 cmd_reconfig_device_queue(port_id, 1, 1); 18198 } 18199 18200 cmdline_parse_inst_t cmd_config_per_queue_rx_offload = { 18201 .f = cmd_config_per_queue_rx_offload_parsed, 18202 .data = NULL, 18203 .help_str = "port <port_id> rxq <queue_id> rx_offload " 18204 "vlan_strip|ipv4_cksum|" 18205 "udp_cksum|tcp_cksum|tcp_lro|qinq_strip|outer_ipv4_cksum|" 18206 "macsec_strip|header_split|vlan_filter|vlan_extend|" 18207 "jumbo_frame|crc_strip|scatter|timestamp|security|keep_crc " 18208 "on|off", 18209 .tokens = { 18210 (void *)&cmd_config_per_queue_rx_offload_result_port, 18211 (void *)&cmd_config_per_queue_rx_offload_result_port_id, 18212 (void *)&cmd_config_per_queue_rx_offload_result_rxq, 18213 (void *)&cmd_config_per_queue_rx_offload_result_queue_id, 18214 (void *)&cmd_config_per_queue_rx_offload_result_rxoffload, 18215 (void *)&cmd_config_per_queue_rx_offload_result_offload, 18216 (void *)&cmd_config_per_queue_rx_offload_result_on_off, 18217 NULL, 18218 } 18219 }; 18220 18221 /* Get Tx offloads capabilities */ 18222 struct cmd_tx_offload_get_capa_result { 18223 cmdline_fixed_string_t show; 18224 cmdline_fixed_string_t port; 18225 portid_t port_id; 18226 cmdline_fixed_string_t tx_offload; 18227 cmdline_fixed_string_t capabilities; 18228 }; 18229 18230 cmdline_parse_token_string_t cmd_tx_offload_get_capa_show = 18231 TOKEN_STRING_INITIALIZER 18232 (struct cmd_tx_offload_get_capa_result, 18233 show, "show"); 18234 cmdline_parse_token_string_t cmd_tx_offload_get_capa_port = 18235 TOKEN_STRING_INITIALIZER 18236 (struct cmd_tx_offload_get_capa_result, 18237 port, "port"); 18238 cmdline_parse_token_num_t cmd_tx_offload_get_capa_port_id = 18239 TOKEN_NUM_INITIALIZER 18240 (struct cmd_tx_offload_get_capa_result, 18241 port_id, UINT16); 18242 cmdline_parse_token_string_t cmd_tx_offload_get_capa_tx_offload = 18243 TOKEN_STRING_INITIALIZER 18244 (struct cmd_tx_offload_get_capa_result, 18245 tx_offload, "tx_offload"); 18246 cmdline_parse_token_string_t cmd_tx_offload_get_capa_capabilities = 18247 TOKEN_STRING_INITIALIZER 18248 (struct cmd_tx_offload_get_capa_result, 18249 capabilities, "capabilities"); 18250 18251 static void 18252 print_tx_offloads(uint64_t offloads) 18253 { 18254 uint64_t single_offload; 18255 int begin; 18256 int end; 18257 int bit; 18258 18259 if (offloads == 0) 18260 return; 18261 18262 begin = __builtin_ctzll(offloads); 18263 end = sizeof(offloads) * CHAR_BIT - __builtin_clzll(offloads); 18264 18265 single_offload = 1ULL << begin; 18266 for (bit = begin; bit < end; bit++) { 18267 if (offloads & single_offload) 18268 printf(" %s", 18269 rte_eth_dev_tx_offload_name(single_offload)); 18270 single_offload <<= 1; 18271 } 18272 } 18273 18274 static void 18275 cmd_tx_offload_get_capa_parsed( 18276 void *parsed_result, 18277 __attribute__((unused)) struct cmdline *cl, 18278 __attribute__((unused)) void *data) 18279 { 18280 struct cmd_tx_offload_get_capa_result *res = parsed_result; 18281 struct rte_eth_dev_info dev_info; 18282 portid_t port_id = res->port_id; 18283 uint64_t queue_offloads; 18284 uint64_t port_offloads; 18285 18286 rte_eth_dev_info_get(port_id, &dev_info); 18287 queue_offloads = dev_info.tx_queue_offload_capa; 18288 port_offloads = dev_info.tx_offload_capa ^ queue_offloads; 18289 18290 printf("Tx Offloading Capabilities of port %d :\n", port_id); 18291 printf(" Per Queue :"); 18292 print_tx_offloads(queue_offloads); 18293 18294 printf("\n"); 18295 printf(" Per Port :"); 18296 print_tx_offloads(port_offloads); 18297 printf("\n\n"); 18298 } 18299 18300 cmdline_parse_inst_t cmd_tx_offload_get_capa = { 18301 .f = cmd_tx_offload_get_capa_parsed, 18302 .data = NULL, 18303 .help_str = "show port <port_id> tx_offload capabilities", 18304 .tokens = { 18305 (void *)&cmd_tx_offload_get_capa_show, 18306 (void *)&cmd_tx_offload_get_capa_port, 18307 (void *)&cmd_tx_offload_get_capa_port_id, 18308 (void *)&cmd_tx_offload_get_capa_tx_offload, 18309 (void *)&cmd_tx_offload_get_capa_capabilities, 18310 NULL, 18311 } 18312 }; 18313 18314 /* Get Tx offloads configuration */ 18315 struct cmd_tx_offload_get_configuration_result { 18316 cmdline_fixed_string_t show; 18317 cmdline_fixed_string_t port; 18318 portid_t port_id; 18319 cmdline_fixed_string_t tx_offload; 18320 cmdline_fixed_string_t configuration; 18321 }; 18322 18323 cmdline_parse_token_string_t cmd_tx_offload_get_configuration_show = 18324 TOKEN_STRING_INITIALIZER 18325 (struct cmd_tx_offload_get_configuration_result, 18326 show, "show"); 18327 cmdline_parse_token_string_t cmd_tx_offload_get_configuration_port = 18328 TOKEN_STRING_INITIALIZER 18329 (struct cmd_tx_offload_get_configuration_result, 18330 port, "port"); 18331 cmdline_parse_token_num_t cmd_tx_offload_get_configuration_port_id = 18332 TOKEN_NUM_INITIALIZER 18333 (struct cmd_tx_offload_get_configuration_result, 18334 port_id, UINT16); 18335 cmdline_parse_token_string_t cmd_tx_offload_get_configuration_tx_offload = 18336 TOKEN_STRING_INITIALIZER 18337 (struct cmd_tx_offload_get_configuration_result, 18338 tx_offload, "tx_offload"); 18339 cmdline_parse_token_string_t cmd_tx_offload_get_configuration_configuration = 18340 TOKEN_STRING_INITIALIZER 18341 (struct cmd_tx_offload_get_configuration_result, 18342 configuration, "configuration"); 18343 18344 static void 18345 cmd_tx_offload_get_configuration_parsed( 18346 void *parsed_result, 18347 __attribute__((unused)) struct cmdline *cl, 18348 __attribute__((unused)) void *data) 18349 { 18350 struct cmd_tx_offload_get_configuration_result *res = parsed_result; 18351 struct rte_eth_dev_info dev_info; 18352 portid_t port_id = res->port_id; 18353 struct rte_port *port = &ports[port_id]; 18354 uint64_t port_offloads; 18355 uint64_t queue_offloads; 18356 uint16_t nb_tx_queues; 18357 int q; 18358 18359 printf("Tx Offloading Configuration of port %d :\n", port_id); 18360 18361 port_offloads = port->dev_conf.txmode.offloads; 18362 printf(" Port :"); 18363 print_tx_offloads(port_offloads); 18364 printf("\n"); 18365 18366 rte_eth_dev_info_get(port_id, &dev_info); 18367 nb_tx_queues = dev_info.nb_tx_queues; 18368 for (q = 0; q < nb_tx_queues; q++) { 18369 queue_offloads = port->tx_conf[q].offloads; 18370 printf(" Queue[%2d] :", q); 18371 print_tx_offloads(queue_offloads); 18372 printf("\n"); 18373 } 18374 printf("\n"); 18375 } 18376 18377 cmdline_parse_inst_t cmd_tx_offload_get_configuration = { 18378 .f = cmd_tx_offload_get_configuration_parsed, 18379 .data = NULL, 18380 .help_str = "show port <port_id> tx_offload configuration", 18381 .tokens = { 18382 (void *)&cmd_tx_offload_get_configuration_show, 18383 (void *)&cmd_tx_offload_get_configuration_port, 18384 (void *)&cmd_tx_offload_get_configuration_port_id, 18385 (void *)&cmd_tx_offload_get_configuration_tx_offload, 18386 (void *)&cmd_tx_offload_get_configuration_configuration, 18387 NULL, 18388 } 18389 }; 18390 18391 /* Enable/Disable a per port offloading */ 18392 struct cmd_config_per_port_tx_offload_result { 18393 cmdline_fixed_string_t port; 18394 cmdline_fixed_string_t config; 18395 portid_t port_id; 18396 cmdline_fixed_string_t tx_offload; 18397 cmdline_fixed_string_t offload; 18398 cmdline_fixed_string_t on_off; 18399 }; 18400 18401 cmdline_parse_token_string_t cmd_config_per_port_tx_offload_result_port = 18402 TOKEN_STRING_INITIALIZER 18403 (struct cmd_config_per_port_tx_offload_result, 18404 port, "port"); 18405 cmdline_parse_token_string_t cmd_config_per_port_tx_offload_result_config = 18406 TOKEN_STRING_INITIALIZER 18407 (struct cmd_config_per_port_tx_offload_result, 18408 config, "config"); 18409 cmdline_parse_token_num_t cmd_config_per_port_tx_offload_result_port_id = 18410 TOKEN_NUM_INITIALIZER 18411 (struct cmd_config_per_port_tx_offload_result, 18412 port_id, UINT16); 18413 cmdline_parse_token_string_t cmd_config_per_port_tx_offload_result_tx_offload = 18414 TOKEN_STRING_INITIALIZER 18415 (struct cmd_config_per_port_tx_offload_result, 18416 tx_offload, "tx_offload"); 18417 cmdline_parse_token_string_t cmd_config_per_port_tx_offload_result_offload = 18418 TOKEN_STRING_INITIALIZER 18419 (struct cmd_config_per_port_tx_offload_result, 18420 offload, "vlan_insert#ipv4_cksum#udp_cksum#tcp_cksum#" 18421 "sctp_cksum#tcp_tso#udp_tso#outer_ipv4_cksum#" 18422 "qinq_insert#vxlan_tnl_tso#gre_tnl_tso#" 18423 "ipip_tnl_tso#geneve_tnl_tso#macsec_insert#" 18424 "mt_lockfree#multi_segs#mbuf_fast_free#security#" 18425 "match_metadata"); 18426 cmdline_parse_token_string_t cmd_config_per_port_tx_offload_result_on_off = 18427 TOKEN_STRING_INITIALIZER 18428 (struct cmd_config_per_port_tx_offload_result, 18429 on_off, "on#off"); 18430 18431 static uint64_t 18432 search_tx_offload(const char *name) 18433 { 18434 uint64_t single_offload; 18435 const char *single_name; 18436 int found = 0; 18437 unsigned int bit; 18438 18439 single_offload = 1; 18440 for (bit = 0; bit < sizeof(single_offload) * CHAR_BIT; bit++) { 18441 single_name = rte_eth_dev_tx_offload_name(single_offload); 18442 if (single_name == NULL) 18443 break; 18444 if (!strcasecmp(single_name, name)) { 18445 found = 1; 18446 break; 18447 } else if (!strcasecmp(single_name, "UNKNOWN")) 18448 break; 18449 single_offload <<= 1; 18450 } 18451 18452 if (found) 18453 return single_offload; 18454 18455 return 0; 18456 } 18457 18458 static void 18459 cmd_config_per_port_tx_offload_parsed(void *parsed_result, 18460 __attribute__((unused)) struct cmdline *cl, 18461 __attribute__((unused)) void *data) 18462 { 18463 struct cmd_config_per_port_tx_offload_result *res = parsed_result; 18464 portid_t port_id = res->port_id; 18465 struct rte_eth_dev_info dev_info; 18466 struct rte_port *port = &ports[port_id]; 18467 uint64_t single_offload; 18468 uint16_t nb_tx_queues; 18469 int q; 18470 18471 if (port->port_status != RTE_PORT_STOPPED) { 18472 printf("Error: Can't config offload when Port %d " 18473 "is not stopped\n", port_id); 18474 return; 18475 } 18476 18477 single_offload = search_tx_offload(res->offload); 18478 if (single_offload == 0) { 18479 printf("Unknown offload name: %s\n", res->offload); 18480 return; 18481 } 18482 18483 rte_eth_dev_info_get(port_id, &dev_info); 18484 nb_tx_queues = dev_info.nb_tx_queues; 18485 if (!strcmp(res->on_off, "on")) { 18486 port->dev_conf.txmode.offloads |= single_offload; 18487 for (q = 0; q < nb_tx_queues; q++) 18488 port->tx_conf[q].offloads |= single_offload; 18489 } else { 18490 port->dev_conf.txmode.offloads &= ~single_offload; 18491 for (q = 0; q < nb_tx_queues; q++) 18492 port->tx_conf[q].offloads &= ~single_offload; 18493 } 18494 18495 cmd_reconfig_device_queue(port_id, 1, 1); 18496 } 18497 18498 cmdline_parse_inst_t cmd_config_per_port_tx_offload = { 18499 .f = cmd_config_per_port_tx_offload_parsed, 18500 .data = NULL, 18501 .help_str = "port config <port_id> tx_offload " 18502 "vlan_insert|ipv4_cksum|udp_cksum|tcp_cksum|" 18503 "sctp_cksum|tcp_tso|udp_tso|outer_ipv4_cksum|" 18504 "qinq_insert|vxlan_tnl_tso|gre_tnl_tso|" 18505 "ipip_tnl_tso|geneve_tnl_tso|macsec_insert|" 18506 "mt_lockfree|multi_segs|mbuf_fast_free|security|" 18507 "match_metadata on|off", 18508 .tokens = { 18509 (void *)&cmd_config_per_port_tx_offload_result_port, 18510 (void *)&cmd_config_per_port_tx_offload_result_config, 18511 (void *)&cmd_config_per_port_tx_offload_result_port_id, 18512 (void *)&cmd_config_per_port_tx_offload_result_tx_offload, 18513 (void *)&cmd_config_per_port_tx_offload_result_offload, 18514 (void *)&cmd_config_per_port_tx_offload_result_on_off, 18515 NULL, 18516 } 18517 }; 18518 18519 /* Enable/Disable a per queue offloading */ 18520 struct cmd_config_per_queue_tx_offload_result { 18521 cmdline_fixed_string_t port; 18522 portid_t port_id; 18523 cmdline_fixed_string_t txq; 18524 uint16_t queue_id; 18525 cmdline_fixed_string_t tx_offload; 18526 cmdline_fixed_string_t offload; 18527 cmdline_fixed_string_t on_off; 18528 }; 18529 18530 cmdline_parse_token_string_t cmd_config_per_queue_tx_offload_result_port = 18531 TOKEN_STRING_INITIALIZER 18532 (struct cmd_config_per_queue_tx_offload_result, 18533 port, "port"); 18534 cmdline_parse_token_num_t cmd_config_per_queue_tx_offload_result_port_id = 18535 TOKEN_NUM_INITIALIZER 18536 (struct cmd_config_per_queue_tx_offload_result, 18537 port_id, UINT16); 18538 cmdline_parse_token_string_t cmd_config_per_queue_tx_offload_result_txq = 18539 TOKEN_STRING_INITIALIZER 18540 (struct cmd_config_per_queue_tx_offload_result, 18541 txq, "txq"); 18542 cmdline_parse_token_num_t cmd_config_per_queue_tx_offload_result_queue_id = 18543 TOKEN_NUM_INITIALIZER 18544 (struct cmd_config_per_queue_tx_offload_result, 18545 queue_id, UINT16); 18546 cmdline_parse_token_string_t cmd_config_per_queue_tx_offload_result_txoffload = 18547 TOKEN_STRING_INITIALIZER 18548 (struct cmd_config_per_queue_tx_offload_result, 18549 tx_offload, "tx_offload"); 18550 cmdline_parse_token_string_t cmd_config_per_queue_tx_offload_result_offload = 18551 TOKEN_STRING_INITIALIZER 18552 (struct cmd_config_per_queue_tx_offload_result, 18553 offload, "vlan_insert#ipv4_cksum#udp_cksum#tcp_cksum#" 18554 "sctp_cksum#tcp_tso#udp_tso#outer_ipv4_cksum#" 18555 "qinq_insert#vxlan_tnl_tso#gre_tnl_tso#" 18556 "ipip_tnl_tso#geneve_tnl_tso#macsec_insert#" 18557 "mt_lockfree#multi_segs#mbuf_fast_free#security"); 18558 cmdline_parse_token_string_t cmd_config_per_queue_tx_offload_result_on_off = 18559 TOKEN_STRING_INITIALIZER 18560 (struct cmd_config_per_queue_tx_offload_result, 18561 on_off, "on#off"); 18562 18563 static void 18564 cmd_config_per_queue_tx_offload_parsed(void *parsed_result, 18565 __attribute__((unused)) struct cmdline *cl, 18566 __attribute__((unused)) void *data) 18567 { 18568 struct cmd_config_per_queue_tx_offload_result *res = parsed_result; 18569 struct rte_eth_dev_info dev_info; 18570 portid_t port_id = res->port_id; 18571 uint16_t queue_id = res->queue_id; 18572 struct rte_port *port = &ports[port_id]; 18573 uint64_t single_offload; 18574 18575 if (port->port_status != RTE_PORT_STOPPED) { 18576 printf("Error: Can't config offload when Port %d " 18577 "is not stopped\n", port_id); 18578 return; 18579 } 18580 18581 rte_eth_dev_info_get(port_id, &dev_info); 18582 if (queue_id >= dev_info.nb_tx_queues) { 18583 printf("Error: input queue_id should be 0 ... " 18584 "%d\n", dev_info.nb_tx_queues - 1); 18585 return; 18586 } 18587 18588 single_offload = search_tx_offload(res->offload); 18589 if (single_offload == 0) { 18590 printf("Unknown offload name: %s\n", res->offload); 18591 return; 18592 } 18593 18594 if (!strcmp(res->on_off, "on")) 18595 port->tx_conf[queue_id].offloads |= single_offload; 18596 else 18597 port->tx_conf[queue_id].offloads &= ~single_offload; 18598 18599 cmd_reconfig_device_queue(port_id, 1, 1); 18600 } 18601 18602 cmdline_parse_inst_t cmd_config_per_queue_tx_offload = { 18603 .f = cmd_config_per_queue_tx_offload_parsed, 18604 .data = NULL, 18605 .help_str = "port <port_id> txq <queue_id> tx_offload " 18606 "vlan_insert|ipv4_cksum|udp_cksum|tcp_cksum|" 18607 "sctp_cksum|tcp_tso|udp_tso|outer_ipv4_cksum|" 18608 "qinq_insert|vxlan_tnl_tso|gre_tnl_tso|" 18609 "ipip_tnl_tso|geneve_tnl_tso|macsec_insert|" 18610 "mt_lockfree|multi_segs|mbuf_fast_free|security " 18611 "on|off", 18612 .tokens = { 18613 (void *)&cmd_config_per_queue_tx_offload_result_port, 18614 (void *)&cmd_config_per_queue_tx_offload_result_port_id, 18615 (void *)&cmd_config_per_queue_tx_offload_result_txq, 18616 (void *)&cmd_config_per_queue_tx_offload_result_queue_id, 18617 (void *)&cmd_config_per_queue_tx_offload_result_txoffload, 18618 (void *)&cmd_config_per_queue_tx_offload_result_offload, 18619 (void *)&cmd_config_per_queue_tx_offload_result_on_off, 18620 NULL, 18621 } 18622 }; 18623 18624 /* *** configure tx_metadata for specific port *** */ 18625 struct cmd_config_tx_metadata_specific_result { 18626 cmdline_fixed_string_t port; 18627 cmdline_fixed_string_t keyword; 18628 uint16_t port_id; 18629 cmdline_fixed_string_t item; 18630 uint32_t value; 18631 }; 18632 18633 static void 18634 cmd_config_tx_metadata_specific_parsed(void *parsed_result, 18635 __attribute__((unused)) struct cmdline *cl, 18636 __attribute__((unused)) void *data) 18637 { 18638 struct cmd_config_tx_metadata_specific_result *res = parsed_result; 18639 18640 if (port_id_is_invalid(res->port_id, ENABLED_WARN)) 18641 return; 18642 ports[res->port_id].tx_metadata = rte_cpu_to_be_32(res->value); 18643 /* Add/remove callback to insert valid metadata in every Tx packet. */ 18644 if (ports[res->port_id].tx_metadata) 18645 add_tx_md_callback(res->port_id); 18646 else 18647 remove_tx_md_callback(res->port_id); 18648 } 18649 18650 cmdline_parse_token_string_t cmd_config_tx_metadata_specific_port = 18651 TOKEN_STRING_INITIALIZER(struct cmd_config_tx_metadata_specific_result, 18652 port, "port"); 18653 cmdline_parse_token_string_t cmd_config_tx_metadata_specific_keyword = 18654 TOKEN_STRING_INITIALIZER(struct cmd_config_tx_metadata_specific_result, 18655 keyword, "config"); 18656 cmdline_parse_token_num_t cmd_config_tx_metadata_specific_id = 18657 TOKEN_NUM_INITIALIZER(struct cmd_config_tx_metadata_specific_result, 18658 port_id, UINT16); 18659 cmdline_parse_token_string_t cmd_config_tx_metadata_specific_item = 18660 TOKEN_STRING_INITIALIZER(struct cmd_config_tx_metadata_specific_result, 18661 item, "tx_metadata"); 18662 cmdline_parse_token_num_t cmd_config_tx_metadata_specific_value = 18663 TOKEN_NUM_INITIALIZER(struct cmd_config_tx_metadata_specific_result, 18664 value, UINT32); 18665 18666 cmdline_parse_inst_t cmd_config_tx_metadata_specific = { 18667 .f = cmd_config_tx_metadata_specific_parsed, 18668 .data = NULL, 18669 .help_str = "port config <port_id> tx_metadata <value>", 18670 .tokens = { 18671 (void *)&cmd_config_tx_metadata_specific_port, 18672 (void *)&cmd_config_tx_metadata_specific_keyword, 18673 (void *)&cmd_config_tx_metadata_specific_id, 18674 (void *)&cmd_config_tx_metadata_specific_item, 18675 (void *)&cmd_config_tx_metadata_specific_value, 18676 NULL, 18677 }, 18678 }; 18679 18680 /* *** display tx_metadata per port configuration *** */ 18681 struct cmd_show_tx_metadata_result { 18682 cmdline_fixed_string_t cmd_show; 18683 cmdline_fixed_string_t cmd_port; 18684 cmdline_fixed_string_t cmd_keyword; 18685 portid_t cmd_pid; 18686 }; 18687 18688 static void 18689 cmd_show_tx_metadata_parsed(void *parsed_result, 18690 __attribute__((unused)) struct cmdline *cl, 18691 __attribute__((unused)) void *data) 18692 { 18693 struct cmd_show_tx_metadata_result *res = parsed_result; 18694 18695 if (!rte_eth_dev_is_valid_port(res->cmd_pid)) { 18696 printf("invalid port id %u\n", res->cmd_pid); 18697 return; 18698 } 18699 if (!strcmp(res->cmd_keyword, "tx_metadata")) { 18700 printf("Port %u tx_metadata: %u\n", res->cmd_pid, 18701 rte_be_to_cpu_32(ports[res->cmd_pid].tx_metadata)); 18702 } 18703 } 18704 18705 cmdline_parse_token_string_t cmd_show_tx_metadata_show = 18706 TOKEN_STRING_INITIALIZER(struct cmd_show_tx_metadata_result, 18707 cmd_show, "show"); 18708 cmdline_parse_token_string_t cmd_show_tx_metadata_port = 18709 TOKEN_STRING_INITIALIZER(struct cmd_show_tx_metadata_result, 18710 cmd_port, "port"); 18711 cmdline_parse_token_num_t cmd_show_tx_metadata_pid = 18712 TOKEN_NUM_INITIALIZER(struct cmd_show_tx_metadata_result, 18713 cmd_pid, UINT16); 18714 cmdline_parse_token_string_t cmd_show_tx_metadata_keyword = 18715 TOKEN_STRING_INITIALIZER(struct cmd_show_tx_metadata_result, 18716 cmd_keyword, "tx_metadata"); 18717 18718 cmdline_parse_inst_t cmd_show_tx_metadata = { 18719 .f = cmd_show_tx_metadata_parsed, 18720 .data = NULL, 18721 .help_str = "show port <port_id> tx_metadata", 18722 .tokens = { 18723 (void *)&cmd_show_tx_metadata_show, 18724 (void *)&cmd_show_tx_metadata_port, 18725 (void *)&cmd_show_tx_metadata_pid, 18726 (void *)&cmd_show_tx_metadata_keyword, 18727 NULL, 18728 }, 18729 }; 18730 18731 /* ******************************************************************************** */ 18732 18733 /* list of instructions */ 18734 cmdline_parse_ctx_t main_ctx[] = { 18735 (cmdline_parse_inst_t *)&cmd_help_brief, 18736 (cmdline_parse_inst_t *)&cmd_help_long, 18737 (cmdline_parse_inst_t *)&cmd_quit, 18738 (cmdline_parse_inst_t *)&cmd_load_from_file, 18739 (cmdline_parse_inst_t *)&cmd_showport, 18740 (cmdline_parse_inst_t *)&cmd_showqueue, 18741 (cmdline_parse_inst_t *)&cmd_showportall, 18742 (cmdline_parse_inst_t *)&cmd_showdevice, 18743 (cmdline_parse_inst_t *)&cmd_showcfg, 18744 (cmdline_parse_inst_t *)&cmd_showfwdall, 18745 (cmdline_parse_inst_t *)&cmd_start, 18746 (cmdline_parse_inst_t *)&cmd_start_tx_first, 18747 (cmdline_parse_inst_t *)&cmd_start_tx_first_n, 18748 (cmdline_parse_inst_t *)&cmd_set_link_up, 18749 (cmdline_parse_inst_t *)&cmd_set_link_down, 18750 (cmdline_parse_inst_t *)&cmd_reset, 18751 (cmdline_parse_inst_t *)&cmd_set_numbers, 18752 (cmdline_parse_inst_t *)&cmd_set_log, 18753 (cmdline_parse_inst_t *)&cmd_set_txpkts, 18754 (cmdline_parse_inst_t *)&cmd_set_txsplit, 18755 (cmdline_parse_inst_t *)&cmd_set_fwd_list, 18756 (cmdline_parse_inst_t *)&cmd_set_fwd_mask, 18757 (cmdline_parse_inst_t *)&cmd_set_fwd_mode, 18758 (cmdline_parse_inst_t *)&cmd_set_fwd_retry_mode, 18759 (cmdline_parse_inst_t *)&cmd_set_burst_tx_retry, 18760 (cmdline_parse_inst_t *)&cmd_set_promisc_mode_one, 18761 (cmdline_parse_inst_t *)&cmd_set_promisc_mode_all, 18762 (cmdline_parse_inst_t *)&cmd_set_allmulti_mode_one, 18763 (cmdline_parse_inst_t *)&cmd_set_allmulti_mode_all, 18764 (cmdline_parse_inst_t *)&cmd_set_flush_rx, 18765 (cmdline_parse_inst_t *)&cmd_set_link_check, 18766 (cmdline_parse_inst_t *)&cmd_set_bypass_mode, 18767 (cmdline_parse_inst_t *)&cmd_set_bypass_event, 18768 (cmdline_parse_inst_t *)&cmd_set_bypass_timeout, 18769 (cmdline_parse_inst_t *)&cmd_show_bypass_config, 18770 #ifdef RTE_LIBRTE_PMD_BOND 18771 (cmdline_parse_inst_t *) &cmd_set_bonding_mode, 18772 (cmdline_parse_inst_t *) &cmd_show_bonding_config, 18773 (cmdline_parse_inst_t *) &cmd_set_bonding_primary, 18774 (cmdline_parse_inst_t *) &cmd_add_bonding_slave, 18775 (cmdline_parse_inst_t *) &cmd_remove_bonding_slave, 18776 (cmdline_parse_inst_t *) &cmd_create_bonded_device, 18777 (cmdline_parse_inst_t *) &cmd_set_bond_mac_addr, 18778 (cmdline_parse_inst_t *) &cmd_set_balance_xmit_policy, 18779 (cmdline_parse_inst_t *) &cmd_set_bond_mon_period, 18780 (cmdline_parse_inst_t *) &cmd_set_lacp_dedicated_queues, 18781 (cmdline_parse_inst_t *) &cmd_set_bonding_agg_mode_policy, 18782 #endif 18783 (cmdline_parse_inst_t *)&cmd_vlan_offload, 18784 (cmdline_parse_inst_t *)&cmd_vlan_tpid, 18785 (cmdline_parse_inst_t *)&cmd_rx_vlan_filter_all, 18786 (cmdline_parse_inst_t *)&cmd_rx_vlan_filter, 18787 (cmdline_parse_inst_t *)&cmd_tx_vlan_set, 18788 (cmdline_parse_inst_t *)&cmd_tx_vlan_set_qinq, 18789 (cmdline_parse_inst_t *)&cmd_tx_vlan_reset, 18790 (cmdline_parse_inst_t *)&cmd_tx_vlan_set_pvid, 18791 (cmdline_parse_inst_t *)&cmd_csum_set, 18792 (cmdline_parse_inst_t *)&cmd_csum_show, 18793 (cmdline_parse_inst_t *)&cmd_csum_tunnel, 18794 (cmdline_parse_inst_t *)&cmd_tso_set, 18795 (cmdline_parse_inst_t *)&cmd_tso_show, 18796 (cmdline_parse_inst_t *)&cmd_tunnel_tso_set, 18797 (cmdline_parse_inst_t *)&cmd_tunnel_tso_show, 18798 (cmdline_parse_inst_t *)&cmd_gro_enable, 18799 (cmdline_parse_inst_t *)&cmd_gro_flush, 18800 (cmdline_parse_inst_t *)&cmd_gro_show, 18801 (cmdline_parse_inst_t *)&cmd_gso_enable, 18802 (cmdline_parse_inst_t *)&cmd_gso_size, 18803 (cmdline_parse_inst_t *)&cmd_gso_show, 18804 (cmdline_parse_inst_t *)&cmd_link_flow_control_set, 18805 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_rx, 18806 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_tx, 18807 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_hw, 18808 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_lw, 18809 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_pt, 18810 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_xon, 18811 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_macfwd, 18812 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_autoneg, 18813 (cmdline_parse_inst_t *)&cmd_priority_flow_control_set, 18814 (cmdline_parse_inst_t *)&cmd_config_dcb, 18815 (cmdline_parse_inst_t *)&cmd_read_reg, 18816 (cmdline_parse_inst_t *)&cmd_read_reg_bit_field, 18817 (cmdline_parse_inst_t *)&cmd_read_reg_bit, 18818 (cmdline_parse_inst_t *)&cmd_write_reg, 18819 (cmdline_parse_inst_t *)&cmd_write_reg_bit_field, 18820 (cmdline_parse_inst_t *)&cmd_write_reg_bit, 18821 (cmdline_parse_inst_t *)&cmd_read_rxd_txd, 18822 (cmdline_parse_inst_t *)&cmd_stop, 18823 (cmdline_parse_inst_t *)&cmd_mac_addr, 18824 (cmdline_parse_inst_t *)&cmd_set_fwd_eth_peer, 18825 (cmdline_parse_inst_t *)&cmd_set_qmap, 18826 (cmdline_parse_inst_t *)&cmd_set_xstats_hide_zero, 18827 (cmdline_parse_inst_t *)&cmd_operate_port, 18828 (cmdline_parse_inst_t *)&cmd_operate_specific_port, 18829 (cmdline_parse_inst_t *)&cmd_operate_attach_port, 18830 (cmdline_parse_inst_t *)&cmd_operate_detach_port, 18831 (cmdline_parse_inst_t *)&cmd_operate_detach_device, 18832 (cmdline_parse_inst_t *)&cmd_set_port_setup_on, 18833 (cmdline_parse_inst_t *)&cmd_config_speed_all, 18834 (cmdline_parse_inst_t *)&cmd_config_speed_specific, 18835 (cmdline_parse_inst_t *)&cmd_config_loopback_all, 18836 (cmdline_parse_inst_t *)&cmd_config_loopback_specific, 18837 (cmdline_parse_inst_t *)&cmd_config_rx_tx, 18838 (cmdline_parse_inst_t *)&cmd_config_mtu, 18839 (cmdline_parse_inst_t *)&cmd_config_max_pkt_len, 18840 (cmdline_parse_inst_t *)&cmd_config_rx_mode_flag, 18841 (cmdline_parse_inst_t *)&cmd_config_rss, 18842 (cmdline_parse_inst_t *)&cmd_config_rxtx_ring_size, 18843 (cmdline_parse_inst_t *)&cmd_config_rxtx_queue, 18844 (cmdline_parse_inst_t *)&cmd_config_deferred_start_rxtx_queue, 18845 (cmdline_parse_inst_t *)&cmd_setup_rxtx_queue, 18846 (cmdline_parse_inst_t *)&cmd_config_rss_reta, 18847 (cmdline_parse_inst_t *)&cmd_showport_reta, 18848 (cmdline_parse_inst_t *)&cmd_config_burst, 18849 (cmdline_parse_inst_t *)&cmd_config_thresh, 18850 (cmdline_parse_inst_t *)&cmd_config_threshold, 18851 (cmdline_parse_inst_t *)&cmd_set_uc_hash_filter, 18852 (cmdline_parse_inst_t *)&cmd_set_uc_all_hash_filter, 18853 (cmdline_parse_inst_t *)&cmd_vf_mac_addr_filter, 18854 (cmdline_parse_inst_t *)&cmd_set_vf_macvlan_filter, 18855 (cmdline_parse_inst_t *)&cmd_queue_rate_limit, 18856 (cmdline_parse_inst_t *)&cmd_tunnel_filter, 18857 (cmdline_parse_inst_t *)&cmd_tunnel_udp_config, 18858 (cmdline_parse_inst_t *)&cmd_global_config, 18859 (cmdline_parse_inst_t *)&cmd_set_mirror_mask, 18860 (cmdline_parse_inst_t *)&cmd_set_mirror_link, 18861 (cmdline_parse_inst_t *)&cmd_reset_mirror_rule, 18862 (cmdline_parse_inst_t *)&cmd_showport_rss_hash, 18863 (cmdline_parse_inst_t *)&cmd_showport_rss_hash_key, 18864 (cmdline_parse_inst_t *)&cmd_config_rss_hash_key, 18865 (cmdline_parse_inst_t *)&cmd_dump, 18866 (cmdline_parse_inst_t *)&cmd_dump_one, 18867 (cmdline_parse_inst_t *)&cmd_ethertype_filter, 18868 (cmdline_parse_inst_t *)&cmd_syn_filter, 18869 (cmdline_parse_inst_t *)&cmd_2tuple_filter, 18870 (cmdline_parse_inst_t *)&cmd_5tuple_filter, 18871 (cmdline_parse_inst_t *)&cmd_flex_filter, 18872 (cmdline_parse_inst_t *)&cmd_add_del_ip_flow_director, 18873 (cmdline_parse_inst_t *)&cmd_add_del_udp_flow_director, 18874 (cmdline_parse_inst_t *)&cmd_add_del_sctp_flow_director, 18875 (cmdline_parse_inst_t *)&cmd_add_del_l2_flow_director, 18876 (cmdline_parse_inst_t *)&cmd_add_del_mac_vlan_flow_director, 18877 (cmdline_parse_inst_t *)&cmd_add_del_tunnel_flow_director, 18878 (cmdline_parse_inst_t *)&cmd_add_del_raw_flow_director, 18879 (cmdline_parse_inst_t *)&cmd_flush_flow_director, 18880 (cmdline_parse_inst_t *)&cmd_set_flow_director_ip_mask, 18881 (cmdline_parse_inst_t *)&cmd_set_flow_director_mac_vlan_mask, 18882 (cmdline_parse_inst_t *)&cmd_set_flow_director_tunnel_mask, 18883 (cmdline_parse_inst_t *)&cmd_set_flow_director_flex_mask, 18884 (cmdline_parse_inst_t *)&cmd_set_flow_director_flex_payload, 18885 (cmdline_parse_inst_t *)&cmd_get_sym_hash_ena_per_port, 18886 (cmdline_parse_inst_t *)&cmd_set_sym_hash_ena_per_port, 18887 (cmdline_parse_inst_t *)&cmd_get_hash_global_config, 18888 (cmdline_parse_inst_t *)&cmd_set_hash_global_config, 18889 (cmdline_parse_inst_t *)&cmd_set_hash_input_set, 18890 (cmdline_parse_inst_t *)&cmd_set_fdir_input_set, 18891 (cmdline_parse_inst_t *)&cmd_flow, 18892 (cmdline_parse_inst_t *)&cmd_show_port_meter_cap, 18893 (cmdline_parse_inst_t *)&cmd_add_port_meter_profile_srtcm, 18894 (cmdline_parse_inst_t *)&cmd_add_port_meter_profile_trtcm, 18895 (cmdline_parse_inst_t *)&cmd_del_port_meter_profile, 18896 (cmdline_parse_inst_t *)&cmd_create_port_meter, 18897 (cmdline_parse_inst_t *)&cmd_enable_port_meter, 18898 (cmdline_parse_inst_t *)&cmd_disable_port_meter, 18899 (cmdline_parse_inst_t *)&cmd_del_port_meter, 18900 (cmdline_parse_inst_t *)&cmd_set_port_meter_profile, 18901 (cmdline_parse_inst_t *)&cmd_set_port_meter_dscp_table, 18902 (cmdline_parse_inst_t *)&cmd_set_port_meter_policer_action, 18903 (cmdline_parse_inst_t *)&cmd_set_port_meter_stats_mask, 18904 (cmdline_parse_inst_t *)&cmd_show_port_meter_stats, 18905 (cmdline_parse_inst_t *)&cmd_mcast_addr, 18906 (cmdline_parse_inst_t *)&cmd_config_l2_tunnel_eth_type_all, 18907 (cmdline_parse_inst_t *)&cmd_config_l2_tunnel_eth_type_specific, 18908 (cmdline_parse_inst_t *)&cmd_config_l2_tunnel_en_dis_all, 18909 (cmdline_parse_inst_t *)&cmd_config_l2_tunnel_en_dis_specific, 18910 (cmdline_parse_inst_t *)&cmd_config_e_tag_insertion_en, 18911 (cmdline_parse_inst_t *)&cmd_config_e_tag_insertion_dis, 18912 (cmdline_parse_inst_t *)&cmd_config_e_tag_stripping_en_dis, 18913 (cmdline_parse_inst_t *)&cmd_config_e_tag_forwarding_en_dis, 18914 (cmdline_parse_inst_t *)&cmd_config_e_tag_filter_add, 18915 (cmdline_parse_inst_t *)&cmd_config_e_tag_filter_del, 18916 (cmdline_parse_inst_t *)&cmd_set_vf_vlan_anti_spoof, 18917 (cmdline_parse_inst_t *)&cmd_set_vf_mac_anti_spoof, 18918 (cmdline_parse_inst_t *)&cmd_set_vf_vlan_stripq, 18919 (cmdline_parse_inst_t *)&cmd_set_vf_vlan_insert, 18920 (cmdline_parse_inst_t *)&cmd_set_tx_loopback, 18921 (cmdline_parse_inst_t *)&cmd_set_all_queues_drop_en, 18922 (cmdline_parse_inst_t *)&cmd_set_vf_split_drop_en, 18923 (cmdline_parse_inst_t *)&cmd_set_macsec_offload_on, 18924 (cmdline_parse_inst_t *)&cmd_set_macsec_offload_off, 18925 (cmdline_parse_inst_t *)&cmd_set_macsec_sc, 18926 (cmdline_parse_inst_t *)&cmd_set_macsec_sa, 18927 (cmdline_parse_inst_t *)&cmd_set_vf_traffic, 18928 (cmdline_parse_inst_t *)&cmd_set_vf_rxmode, 18929 (cmdline_parse_inst_t *)&cmd_vf_rate_limit, 18930 (cmdline_parse_inst_t *)&cmd_vf_rxvlan_filter, 18931 (cmdline_parse_inst_t *)&cmd_set_vf_mac_addr, 18932 (cmdline_parse_inst_t *)&cmd_set_vf_promisc, 18933 (cmdline_parse_inst_t *)&cmd_set_vf_allmulti, 18934 (cmdline_parse_inst_t *)&cmd_set_vf_broadcast, 18935 (cmdline_parse_inst_t *)&cmd_set_vf_vlan_tag, 18936 (cmdline_parse_inst_t *)&cmd_vf_max_bw, 18937 (cmdline_parse_inst_t *)&cmd_vf_tc_min_bw, 18938 (cmdline_parse_inst_t *)&cmd_vf_tc_max_bw, 18939 (cmdline_parse_inst_t *)&cmd_strict_link_prio, 18940 (cmdline_parse_inst_t *)&cmd_tc_min_bw, 18941 #if defined RTE_LIBRTE_PMD_SOFTNIC && defined RTE_LIBRTE_SCHED 18942 (cmdline_parse_inst_t *)&cmd_set_port_tm_hierarchy_default, 18943 #endif 18944 (cmdline_parse_inst_t *)&cmd_set_vxlan, 18945 (cmdline_parse_inst_t *)&cmd_set_vxlan_tos_ttl, 18946 (cmdline_parse_inst_t *)&cmd_set_vxlan_with_vlan, 18947 (cmdline_parse_inst_t *)&cmd_set_nvgre, 18948 (cmdline_parse_inst_t *)&cmd_set_nvgre_with_vlan, 18949 (cmdline_parse_inst_t *)&cmd_set_l2_encap, 18950 (cmdline_parse_inst_t *)&cmd_set_l2_encap_with_vlan, 18951 (cmdline_parse_inst_t *)&cmd_set_l2_decap, 18952 (cmdline_parse_inst_t *)&cmd_set_l2_decap_with_vlan, 18953 (cmdline_parse_inst_t *)&cmd_set_mplsogre_encap, 18954 (cmdline_parse_inst_t *)&cmd_set_mplsogre_encap_with_vlan, 18955 (cmdline_parse_inst_t *)&cmd_set_mplsogre_decap, 18956 (cmdline_parse_inst_t *)&cmd_set_mplsogre_decap_with_vlan, 18957 (cmdline_parse_inst_t *)&cmd_set_mplsoudp_encap, 18958 (cmdline_parse_inst_t *)&cmd_set_mplsoudp_encap_with_vlan, 18959 (cmdline_parse_inst_t *)&cmd_set_mplsoudp_decap, 18960 (cmdline_parse_inst_t *)&cmd_set_mplsoudp_decap_with_vlan, 18961 (cmdline_parse_inst_t *)&cmd_ddp_add, 18962 (cmdline_parse_inst_t *)&cmd_ddp_del, 18963 (cmdline_parse_inst_t *)&cmd_ddp_get_list, 18964 (cmdline_parse_inst_t *)&cmd_ddp_get_info, 18965 (cmdline_parse_inst_t *)&cmd_cfg_input_set, 18966 (cmdline_parse_inst_t *)&cmd_clear_input_set, 18967 (cmdline_parse_inst_t *)&cmd_show_vf_stats, 18968 (cmdline_parse_inst_t *)&cmd_clear_vf_stats, 18969 (cmdline_parse_inst_t *)&cmd_ptype_mapping_get, 18970 (cmdline_parse_inst_t *)&cmd_ptype_mapping_replace, 18971 (cmdline_parse_inst_t *)&cmd_ptype_mapping_reset, 18972 (cmdline_parse_inst_t *)&cmd_ptype_mapping_update, 18973 18974 (cmdline_parse_inst_t *)&cmd_pctype_mapping_get, 18975 (cmdline_parse_inst_t *)&cmd_pctype_mapping_reset, 18976 (cmdline_parse_inst_t *)&cmd_pctype_mapping_update, 18977 (cmdline_parse_inst_t *)&cmd_queue_region, 18978 (cmdline_parse_inst_t *)&cmd_region_flowtype, 18979 (cmdline_parse_inst_t *)&cmd_user_priority_region, 18980 (cmdline_parse_inst_t *)&cmd_flush_queue_region, 18981 (cmdline_parse_inst_t *)&cmd_show_queue_region_info_all, 18982 (cmdline_parse_inst_t *)&cmd_show_port_tm_cap, 18983 (cmdline_parse_inst_t *)&cmd_show_port_tm_level_cap, 18984 (cmdline_parse_inst_t *)&cmd_show_port_tm_node_cap, 18985 (cmdline_parse_inst_t *)&cmd_show_port_tm_node_type, 18986 (cmdline_parse_inst_t *)&cmd_show_port_tm_node_stats, 18987 (cmdline_parse_inst_t *)&cmd_add_port_tm_node_shaper_profile, 18988 (cmdline_parse_inst_t *)&cmd_del_port_tm_node_shaper_profile, 18989 (cmdline_parse_inst_t *)&cmd_add_port_tm_node_shared_shaper, 18990 (cmdline_parse_inst_t *)&cmd_del_port_tm_node_shared_shaper, 18991 (cmdline_parse_inst_t *)&cmd_add_port_tm_node_wred_profile, 18992 (cmdline_parse_inst_t *)&cmd_del_port_tm_node_wred_profile, 18993 (cmdline_parse_inst_t *)&cmd_set_port_tm_node_shaper_profile, 18994 (cmdline_parse_inst_t *)&cmd_add_port_tm_nonleaf_node, 18995 (cmdline_parse_inst_t *)&cmd_add_port_tm_leaf_node, 18996 (cmdline_parse_inst_t *)&cmd_del_port_tm_node, 18997 (cmdline_parse_inst_t *)&cmd_set_port_tm_node_parent, 18998 (cmdline_parse_inst_t *)&cmd_suspend_port_tm_node, 18999 (cmdline_parse_inst_t *)&cmd_resume_port_tm_node, 19000 (cmdline_parse_inst_t *)&cmd_port_tm_hierarchy_commit, 19001 (cmdline_parse_inst_t *)&cmd_port_tm_mark_ip_ecn, 19002 (cmdline_parse_inst_t *)&cmd_port_tm_mark_ip_dscp, 19003 (cmdline_parse_inst_t *)&cmd_port_tm_mark_vlan_dei, 19004 (cmdline_parse_inst_t *)&cmd_cfg_tunnel_udp_port, 19005 (cmdline_parse_inst_t *)&cmd_rx_offload_get_capa, 19006 (cmdline_parse_inst_t *)&cmd_rx_offload_get_configuration, 19007 (cmdline_parse_inst_t *)&cmd_config_per_port_rx_offload, 19008 (cmdline_parse_inst_t *)&cmd_config_per_queue_rx_offload, 19009 (cmdline_parse_inst_t *)&cmd_tx_offload_get_capa, 19010 (cmdline_parse_inst_t *)&cmd_tx_offload_get_configuration, 19011 (cmdline_parse_inst_t *)&cmd_config_per_port_tx_offload, 19012 (cmdline_parse_inst_t *)&cmd_config_per_queue_tx_offload, 19013 #ifdef RTE_LIBRTE_BPF 19014 (cmdline_parse_inst_t *)&cmd_operate_bpf_ld_parse, 19015 (cmdline_parse_inst_t *)&cmd_operate_bpf_unld_parse, 19016 #endif 19017 (cmdline_parse_inst_t *)&cmd_config_tx_metadata_specific, 19018 (cmdline_parse_inst_t *)&cmd_show_tx_metadata, 19019 (cmdline_parse_inst_t *)&cmd_set_raw, 19020 NULL, 19021 }; 19022 19023 /* read cmdline commands from file */ 19024 void 19025 cmdline_read_from_file(const char *filename) 19026 { 19027 struct cmdline *cl; 19028 19029 cl = cmdline_file_new(main_ctx, "testpmd> ", filename); 19030 if (cl == NULL) { 19031 printf("Failed to create file based cmdline context: %s\n", 19032 filename); 19033 return; 19034 } 19035 19036 cmdline_interact(cl); 19037 cmdline_quit(cl); 19038 19039 cmdline_free(cl); 19040 19041 printf("Read CLI commands from %s\n", filename); 19042 } 19043 19044 /* prompt function, called from main on MASTER lcore */ 19045 void 19046 prompt(void) 19047 { 19048 /* initialize non-constant commands */ 19049 cmd_set_fwd_mode_init(); 19050 cmd_set_fwd_retry_mode_init(); 19051 19052 testpmd_cl = cmdline_stdin_new(main_ctx, "testpmd> "); 19053 if (testpmd_cl == NULL) 19054 return; 19055 cmdline_interact(testpmd_cl); 19056 cmdline_stdin_exit(testpmd_cl); 19057 } 19058 19059 void 19060 prompt_exit(void) 19061 { 19062 if (testpmd_cl != NULL) 19063 cmdline_quit(testpmd_cl); 19064 } 19065 19066 static void 19067 cmd_reconfig_device_queue(portid_t id, uint8_t dev, uint8_t queue) 19068 { 19069 if (id == (portid_t)RTE_PORT_ALL) { 19070 portid_t pid; 19071 19072 RTE_ETH_FOREACH_DEV(pid) { 19073 /* check if need_reconfig has been set to 1 */ 19074 if (ports[pid].need_reconfig == 0) 19075 ports[pid].need_reconfig = dev; 19076 /* check if need_reconfig_queues has been set to 1 */ 19077 if (ports[pid].need_reconfig_queues == 0) 19078 ports[pid].need_reconfig_queues = queue; 19079 } 19080 } else if (!port_id_is_invalid(id, DISABLED_WARN)) { 19081 /* check if need_reconfig has been set to 1 */ 19082 if (ports[id].need_reconfig == 0) 19083 ports[id].need_reconfig = dev; 19084 /* check if need_reconfig_queues has been set to 1 */ 19085 if (ports[id].need_reconfig_queues == 0) 19086 ports[id].need_reconfig_queues = queue; 19087 } 19088 } 19089