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_eth_ctrl.h> 48 #include <rte_flow.h> 49 #include <rte_gro.h> 50 51 #include <cmdline_rdline.h> 52 #include <cmdline_parse.h> 53 #include <cmdline_parse_num.h> 54 #include <cmdline_parse_string.h> 55 #include <cmdline_parse_ipaddr.h> 56 #include <cmdline_parse_etheraddr.h> 57 #include <cmdline_socket.h> 58 #include <cmdline.h> 59 #ifdef RTE_LIBRTE_PMD_BOND 60 #include <rte_eth_bond.h> 61 #include <rte_eth_bond_8023ad.h> 62 #endif 63 #if defined RTE_LIBRTE_DPAA_BUS && defined RTE_LIBRTE_DPAA_PMD 64 #include <rte_pmd_dpaa.h> 65 #endif 66 #ifdef RTE_LIBRTE_IXGBE_PMD 67 #include <rte_pmd_ixgbe.h> 68 #endif 69 #ifdef RTE_LIBRTE_I40E_PMD 70 #include <rte_pmd_i40e.h> 71 #endif 72 #ifdef RTE_LIBRTE_BNXT_PMD 73 #include <rte_pmd_bnxt.h> 74 #endif 75 #include "testpmd.h" 76 #include "cmdline_mtr.h" 77 #include "cmdline_tm.h" 78 #include "bpf_cmd.h" 79 80 static struct cmdline *testpmd_cl; 81 82 static void cmd_reconfig_device_queue(portid_t id, uint8_t dev, uint8_t queue); 83 84 /* *** Help command with introduction. *** */ 85 struct cmd_help_brief_result { 86 cmdline_fixed_string_t help; 87 }; 88 89 static void cmd_help_brief_parsed(__attribute__((unused)) void *parsed_result, 90 struct cmdline *cl, 91 __attribute__((unused)) void *data) 92 { 93 cmdline_printf( 94 cl, 95 "\n" 96 "Help is available for the following sections:\n\n" 97 " help control : Start and stop forwarding.\n" 98 " help display : Displaying port, stats and config " 99 "information.\n" 100 " help config : Configuration information.\n" 101 " help ports : Configuring ports.\n" 102 " help registers : Reading and setting port registers.\n" 103 " help filters : Filters configuration help.\n" 104 " help traffic_management : Traffic Management commmands.\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 } 242 243 if (show_all || !strcmp(res->section, "config")) { 244 cmdline_printf( 245 cl, 246 "\n" 247 "Configuration:\n" 248 "--------------\n" 249 "Configuration changes only become active when" 250 " forwarding is started/restarted.\n\n" 251 252 "set default\n" 253 " Reset forwarding to the default configuration.\n\n" 254 255 "set verbose (level)\n" 256 " Set the debug verbosity level X.\n\n" 257 258 "set log global|(type) (level)\n" 259 " Set the log level.\n\n" 260 261 "set nbport (num)\n" 262 " Set number of ports.\n\n" 263 264 "set nbcore (num)\n" 265 " Set number of cores.\n\n" 266 267 "set coremask (mask)\n" 268 " Set the forwarding cores hexadecimal mask.\n\n" 269 270 "set portmask (mask)\n" 271 " Set the forwarding ports hexadecimal mask.\n\n" 272 273 "set burst (num)\n" 274 " Set number of packets per burst.\n\n" 275 276 "set burst tx delay (microseconds) retry (num)\n" 277 " Set the transmit delay time and number of retries," 278 " effective when retry is enabled.\n\n" 279 280 "set txpkts (x[,y]*)\n" 281 " Set the length of each segment of TXONLY" 282 " and optionally CSUM packets.\n\n" 283 284 "set txsplit (off|on|rand)\n" 285 " Set the split policy for the TX packets." 286 " Right now only applicable for CSUM and TXONLY" 287 " modes\n\n" 288 289 "set corelist (x[,y]*)\n" 290 " Set the list of forwarding cores.\n\n" 291 292 "set portlist (x[,y]*)\n" 293 " Set the list of forwarding ports.\n\n" 294 295 "set port setup on (iterator|event)\n" 296 " Select how attached port is retrieved for setup.\n\n" 297 298 "set tx loopback (port_id) (on|off)\n" 299 " Enable or disable tx loopback.\n\n" 300 301 "set all queues drop (port_id) (on|off)\n" 302 " Set drop enable bit for all queues.\n\n" 303 304 "set vf split drop (port_id) (vf_id) (on|off)\n" 305 " Set split drop enable bit for a VF from the PF.\n\n" 306 307 "set vf mac antispoof (port_id) (vf_id) (on|off).\n" 308 " Set MAC antispoof for a VF from the PF.\n\n" 309 310 "set macsec offload (port_id) on encrypt (on|off) replay-protect (on|off)\n" 311 " Enable MACsec offload.\n\n" 312 313 "set macsec offload (port_id) off\n" 314 " Disable MACsec offload.\n\n" 315 316 "set macsec sc (tx|rx) (port_id) (mac) (pi)\n" 317 " Configure MACsec secure connection (SC).\n\n" 318 319 "set macsec sa (tx|rx) (port_id) (idx) (an) (pn) (key)\n" 320 " Configure MACsec secure association (SA).\n\n" 321 322 "set vf broadcast (port_id) (vf_id) (on|off)\n" 323 " Set VF broadcast for a VF from the PF.\n\n" 324 325 "vlan set strip (on|off) (port_id)\n" 326 " Set the VLAN strip on a port.\n\n" 327 328 "vlan set stripq (on|off) (port_id,queue_id)\n" 329 " Set the VLAN strip for a queue on a port.\n\n" 330 331 "set vf vlan stripq (port_id) (vf_id) (on|off)\n" 332 " Set the VLAN strip for all queues in a pool for a VF from the PF.\n\n" 333 334 "set vf vlan insert (port_id) (vf_id) (vlan_id)\n" 335 " Set VLAN insert for a VF from the PF.\n\n" 336 337 "set vf vlan antispoof (port_id) (vf_id) (on|off)\n" 338 " Set VLAN antispoof for a VF from the PF.\n\n" 339 340 "set vf vlan tag (port_id) (vf_id) (on|off)\n" 341 " Set VLAN tag for a VF from the PF.\n\n" 342 343 "set vf tx max-bandwidth (port_id) (vf_id) (bandwidth)\n" 344 " Set a VF's max bandwidth(Mbps).\n\n" 345 346 "set vf tc tx min-bandwidth (port_id) (vf_id) (bw1, bw2, ...)\n" 347 " Set all TCs' min bandwidth(%%) on a VF.\n\n" 348 349 "set vf tc tx max-bandwidth (port_id) (vf_id) (tc_no) (bandwidth)\n" 350 " Set a TC's max bandwidth(Mbps) on a VF.\n\n" 351 352 "set tx strict-link-priority (port_id) (tc_bitmap)\n" 353 " Set some TCs' strict link priority mode on a physical port.\n\n" 354 355 "set tc tx min-bandwidth (port_id) (bw1, bw2, ...)\n" 356 " Set all TCs' min bandwidth(%%) for all PF and VFs.\n\n" 357 358 "vlan set filter (on|off) (port_id)\n" 359 " Set the VLAN filter on a port.\n\n" 360 361 "vlan set qinq (on|off) (port_id)\n" 362 " Set the VLAN QinQ (extended queue in queue)" 363 " on a port.\n\n" 364 365 "vlan set (inner|outer) tpid (value) (port_id)\n" 366 " Set the VLAN TPID for Packet Filtering on" 367 " a port\n\n" 368 369 "rx_vlan add (vlan_id|all) (port_id)\n" 370 " Add a vlan_id, or all identifiers, to the set" 371 " of VLAN identifiers filtered by port_id.\n\n" 372 373 "rx_vlan rm (vlan_id|all) (port_id)\n" 374 " Remove a vlan_id, or all identifiers, from the set" 375 " of VLAN identifiers filtered by port_id.\n\n" 376 377 "rx_vlan add (vlan_id) port (port_id) vf (vf_mask)\n" 378 " Add a vlan_id, to the set of VLAN identifiers" 379 "filtered for VF(s) from port_id.\n\n" 380 381 "rx_vlan rm (vlan_id) port (port_id) vf (vf_mask)\n" 382 " Remove a vlan_id, to the set of VLAN identifiers" 383 "filtered for VF(s) from port_id.\n\n" 384 385 "tunnel_filter add (port_id) (outer_mac) (inner_mac) (ip_addr) " 386 "(inner_vlan) (vxlan|nvgre|ipingre) (imac-ivlan|imac-ivlan-tenid|" 387 "imac-tenid|imac|omac-imac-tenid|oip|iip) (tenant_id) (queue_id)\n" 388 " add a tunnel filter of a port.\n\n" 389 390 "tunnel_filter rm (port_id) (outer_mac) (inner_mac) (ip_addr) " 391 "(inner_vlan) (vxlan|nvgre|ipingre) (imac-ivlan|imac-ivlan-tenid|" 392 "imac-tenid|imac|omac-imac-tenid|oip|iip) (tenant_id) (queue_id)\n" 393 " remove a tunnel filter of a port.\n\n" 394 395 "rx_vxlan_port add (udp_port) (port_id)\n" 396 " Add an UDP port for VXLAN packet filter on a port\n\n" 397 398 "rx_vxlan_port rm (udp_port) (port_id)\n" 399 " Remove an UDP port for VXLAN packet filter on a port\n\n" 400 401 "tx_vlan set (port_id) vlan_id[, vlan_id_outer]\n" 402 " Set hardware insertion of VLAN IDs (single or double VLAN " 403 "depends on the number of VLAN IDs) in packets sent on a port.\n\n" 404 405 "tx_vlan set pvid port_id vlan_id (on|off)\n" 406 " Set port based TX VLAN insertion.\n\n" 407 408 "tx_vlan reset (port_id)\n" 409 " Disable hardware insertion of a VLAN header in" 410 " packets sent on a port.\n\n" 411 412 "csum set (ip|udp|tcp|sctp|outer-ip|outer-udp) (hw|sw) (port_id)\n" 413 " Select hardware or software calculation of the" 414 " checksum when transmitting a packet using the" 415 " csum forward engine.\n" 416 " ip|udp|tcp|sctp always concern the inner layer.\n" 417 " outer-ip concerns the outer IP layer in" 418 " outer-udp concerns the outer UDP layer in" 419 " case the packet is recognized as a tunnel packet by" 420 " the forward engine (vxlan, gre and ipip are supported)\n" 421 " Please check the NIC datasheet for HW limits.\n\n" 422 423 "csum parse-tunnel (on|off) (tx_port_id)\n" 424 " If disabled, treat tunnel packets as non-tunneled" 425 " packets (treat inner headers as payload). The port\n" 426 " argument is the port used for TX in csum forward" 427 " engine.\n\n" 428 429 "csum show (port_id)\n" 430 " Display tx checksum offload configuration\n\n" 431 432 "tso set (segsize) (portid)\n" 433 " Enable TCP Segmentation Offload in csum forward" 434 " engine.\n" 435 " Please check the NIC datasheet for HW limits.\n\n" 436 437 "tso show (portid)" 438 " Display the status of TCP Segmentation Offload.\n\n" 439 440 "set port (port_id) gro on|off\n" 441 " Enable or disable Generic Receive Offload in" 442 " csum forwarding engine.\n\n" 443 444 "show port (port_id) gro\n" 445 " Display GRO configuration.\n\n" 446 447 "set gro flush (cycles)\n" 448 " Set the cycle to flush GROed packets from" 449 " reassembly tables.\n\n" 450 451 "set port (port_id) gso (on|off)" 452 " Enable or disable Generic Segmentation Offload in" 453 " csum forwarding engine.\n\n" 454 455 "set gso segsz (length)\n" 456 " Set max packet length for output GSO segments," 457 " including packet header and payload.\n\n" 458 459 "show port (port_id) gso\n" 460 " Show GSO configuration.\n\n" 461 462 "set fwd (%s)\n" 463 " Set packet forwarding mode.\n\n" 464 465 "mac_addr add (port_id) (XX:XX:XX:XX:XX:XX)\n" 466 " Add a MAC address on port_id.\n\n" 467 468 "mac_addr remove (port_id) (XX:XX:XX:XX:XX:XX)\n" 469 " Remove a MAC address from port_id.\n\n" 470 471 "mac_addr set (port_id) (XX:XX:XX:XX:XX:XX)\n" 472 " Set the default MAC address for port_id.\n\n" 473 474 "mac_addr add port (port_id) vf (vf_id) (mac_address)\n" 475 " Add a MAC address for a VF on the port.\n\n" 476 477 "set vf mac addr (port_id) (vf_id) (XX:XX:XX:XX:XX:XX)\n" 478 " Set the MAC address for a VF from the PF.\n\n" 479 480 "set eth-peer (port_id) (peer_addr)\n" 481 " set the peer address for certain port.\n\n" 482 483 "set port (port_id) uta (mac_address|all) (on|off)\n" 484 " Add/Remove a or all unicast hash filter(s)" 485 "from port X.\n\n" 486 487 "set promisc (port_id|all) (on|off)\n" 488 " Set the promiscuous mode on port_id, or all.\n\n" 489 490 "set allmulti (port_id|all) (on|off)\n" 491 " Set the allmulti mode on port_id, or all.\n\n" 492 493 "set vf promisc (port_id) (vf_id) (on|off)\n" 494 " Set unicast promiscuous mode for a VF from the PF.\n\n" 495 496 "set vf allmulti (port_id) (vf_id) (on|off)\n" 497 " Set multicast promiscuous mode for a VF from the PF.\n\n" 498 499 "set flow_ctrl rx (on|off) tx (on|off) (high_water)" 500 " (low_water) (pause_time) (send_xon) mac_ctrl_frame_fwd" 501 " (on|off) autoneg (on|off) (port_id)\n" 502 "set flow_ctrl rx (on|off) (portid)\n" 503 "set flow_ctrl tx (on|off) (portid)\n" 504 "set flow_ctrl high_water (high_water) (portid)\n" 505 "set flow_ctrl low_water (low_water) (portid)\n" 506 "set flow_ctrl pause_time (pause_time) (portid)\n" 507 "set flow_ctrl send_xon (send_xon) (portid)\n" 508 "set flow_ctrl mac_ctrl_frame_fwd (on|off) (portid)\n" 509 "set flow_ctrl autoneg (on|off) (port_id)\n" 510 " Set the link flow control parameter on a port.\n\n" 511 512 "set pfc_ctrl rx (on|off) tx (on|off) (high_water)" 513 " (low_water) (pause_time) (priority) (port_id)\n" 514 " Set the priority flow control parameter on a" 515 " port.\n\n" 516 517 "set stat_qmap (tx|rx) (port_id) (queue_id) (qmapping)\n" 518 " Set statistics mapping (qmapping 0..15) for RX/TX" 519 " queue on port.\n" 520 " e.g., 'set stat_qmap rx 0 2 5' sets rx queue 2" 521 " on port 0 to mapping 5.\n\n" 522 523 "set xstats-hide-zero on|off\n" 524 " Set the option to hide the zero values" 525 " for xstats display.\n" 526 527 "set port (port_id) vf (vf_id) rx|tx on|off\n" 528 " Enable/Disable a VF receive/tranmit from a port\n\n" 529 530 "set port (port_id) vf (vf_id) (mac_addr)" 531 " (exact-mac#exact-mac-vlan#hashmac|hashmac-vlan) on|off\n" 532 " Add/Remove unicast or multicast MAC addr filter" 533 " for a VF.\n\n" 534 535 "set port (port_id) vf (vf_id) rxmode (AUPE|ROPE|BAM" 536 "|MPE) (on|off)\n" 537 " AUPE:accepts untagged VLAN;" 538 "ROPE:accept unicast hash\n\n" 539 " BAM:accepts broadcast packets;" 540 "MPE:accepts all multicast packets\n\n" 541 " Enable/Disable a VF receive mode of a port\n\n" 542 543 "set port (port_id) queue (queue_id) rate (rate_num)\n" 544 " Set rate limit for a queue of a port\n\n" 545 546 "set port (port_id) vf (vf_id) rate (rate_num) " 547 "queue_mask (queue_mask_value)\n" 548 " Set rate limit for queues in VF of a port\n\n" 549 550 "set port (port_id) mirror-rule (rule_id)" 551 " (pool-mirror-up|pool-mirror-down|vlan-mirror)" 552 " (poolmask|vlanid[,vlanid]*) dst-pool (pool_id) (on|off)\n" 553 " Set pool or vlan type mirror rule on a port.\n" 554 " e.g., 'set port 0 mirror-rule 0 vlan-mirror 0,1" 555 " dst-pool 0 on' enable mirror traffic with vlan 0,1" 556 " to pool 0.\n\n" 557 558 "set port (port_id) mirror-rule (rule_id)" 559 " (uplink-mirror|downlink-mirror) dst-pool" 560 " (pool_id) (on|off)\n" 561 " Set uplink or downlink type mirror rule on a port.\n" 562 " e.g., 'set port 0 mirror-rule 0 uplink-mirror dst-pool" 563 " 0 on' enable mirror income traffic to pool 0.\n\n" 564 565 "reset port (port_id) mirror-rule (rule_id)\n" 566 " Reset a mirror rule.\n\n" 567 568 "set flush_rx (on|off)\n" 569 " Flush (default) or don't flush RX streams before" 570 " forwarding. Mainly used with PCAP drivers.\n\n" 571 572 "set bypass mode (normal|bypass|isolate) (port_id)\n" 573 " Set the bypass mode for the lowest port on bypass enabled" 574 " NIC.\n\n" 575 576 "set bypass event (timeout|os_on|os_off|power_on|power_off) " 577 "mode (normal|bypass|isolate) (port_id)\n" 578 " Set the event required to initiate specified bypass mode for" 579 " the lowest port on a bypass enabled NIC where:\n" 580 " timeout = enable bypass after watchdog timeout.\n" 581 " os_on = enable bypass when OS/board is powered on.\n" 582 " os_off = enable bypass when OS/board is powered off.\n" 583 " power_on = enable bypass when power supply is turned on.\n" 584 " power_off = enable bypass when power supply is turned off." 585 "\n\n" 586 587 "set bypass timeout (0|1.5|2|3|4|8|16|32)\n" 588 " Set the bypass watchdog timeout to 'n' seconds" 589 " where 0 = instant.\n\n" 590 591 "show bypass config (port_id)\n" 592 " Show the bypass configuration for a bypass enabled NIC" 593 " using the lowest port on the NIC.\n\n" 594 595 #ifdef RTE_LIBRTE_PMD_BOND 596 "create bonded device (mode) (socket)\n" 597 " Create a new bonded device with specific bonding mode and socket.\n\n" 598 599 "add bonding slave (slave_id) (port_id)\n" 600 " Add a slave device to a bonded device.\n\n" 601 602 "remove bonding slave (slave_id) (port_id)\n" 603 " Remove a slave device from a bonded device.\n\n" 604 605 "set bonding mode (value) (port_id)\n" 606 " Set the bonding mode on a bonded device.\n\n" 607 608 "set bonding primary (slave_id) (port_id)\n" 609 " Set the primary slave for a bonded device.\n\n" 610 611 "show bonding config (port_id)\n" 612 " Show the bonding config for port_id.\n\n" 613 614 "set bonding mac_addr (port_id) (address)\n" 615 " Set the MAC address of a bonded device.\n\n" 616 617 "set bonding mode IEEE802.3AD aggregator policy (port_id) (agg_name)" 618 " Set Aggregation mode for IEEE802.3AD (mode 4)" 619 620 "set bonding xmit_balance_policy (port_id) (l2|l23|l34)\n" 621 " Set the transmit balance policy for bonded device running in balance mode.\n\n" 622 623 "set bonding mon_period (port_id) (value)\n" 624 " Set the bonding link status monitoring polling period in ms.\n\n" 625 626 "set bonding lacp dedicated_queues <port_id> (enable|disable)\n" 627 " Enable/disable dedicated queues for LACP control traffic.\n\n" 628 629 #endif 630 "set link-up port (port_id)\n" 631 " Set link up for a port.\n\n" 632 633 "set link-down port (port_id)\n" 634 " Set link down for a port.\n\n" 635 636 "E-tag set insertion on port-tag-id (value)" 637 " port (port_id) vf (vf_id)\n" 638 " Enable E-tag insertion for a VF on a port\n\n" 639 640 "E-tag set insertion off port (port_id) vf (vf_id)\n" 641 " Disable E-tag insertion for a VF on a port\n\n" 642 643 "E-tag set stripping (on|off) port (port_id)\n" 644 " Enable/disable E-tag stripping on a port\n\n" 645 646 "E-tag set forwarding (on|off) port (port_id)\n" 647 " Enable/disable E-tag based forwarding" 648 " on a port\n\n" 649 650 "E-tag set filter add e-tag-id (value) dst-pool" 651 " (pool_id) port (port_id)\n" 652 " Add an E-tag forwarding filter on a port\n\n" 653 654 "E-tag set filter del e-tag-id (value) port (port_id)\n" 655 " Delete an E-tag forwarding filter on a port\n\n" 656 657 "ddp add (port_id) (profile_path[,backup_profile_path])\n" 658 " Load a profile package on a port\n\n" 659 660 "ddp del (port_id) (backup_profile_path)\n" 661 " Delete a profile package from a port\n\n" 662 663 "ptype mapping get (port_id) (valid_only)\n" 664 " Get ptype mapping on a port\n\n" 665 666 "ptype mapping replace (port_id) (target) (mask) (pky_type)\n" 667 " Replace target with the pkt_type in ptype mapping\n\n" 668 669 "ptype mapping reset (port_id)\n" 670 " Reset ptype mapping on a port\n\n" 671 672 "ptype mapping update (port_id) (hw_ptype) (sw_ptype)\n" 673 " Update a ptype mapping item on a port\n\n" 674 675 "set port (port_id) queue-region region_id (value) " 676 "queue_start_index (value) queue_num (value)\n" 677 " Set a queue region on a port\n\n" 678 679 "set port (port_id) queue-region region_id (value) " 680 "flowtype (value)\n" 681 " Set a flowtype region index on a port\n\n" 682 683 "set port (port_id) queue-region UP (value) region_id (value)\n" 684 " Set the mapping of User Priority to " 685 "queue region on a port\n\n" 686 687 "set port (port_id) queue-region flush (on|off)\n" 688 " flush all queue region related configuration\n\n" 689 690 "show port meter cap (port_id)\n" 691 " Show port meter capability information\n\n" 692 693 "add port meter profile srtcm_rfc2697 (port_id) (profile_id) (cir) (cbs) (ebs)\n" 694 " meter profile add - srtcm rfc 2697\n\n" 695 696 "add port meter profile trtcm_rfc2698 (port_id) (profile_id) (cir) (pir) (cbs) (pbs)\n" 697 " meter profile add - trtcm rfc 2698\n\n" 698 699 "add port meter profile trtcm_rfc4115 (port_id) (profile_id) (cir) (eir) (cbs) (ebs)\n" 700 " meter profile add - trtcm rfc 4115\n\n" 701 702 "del port meter profile (port_id) (profile_id)\n" 703 " meter profile delete\n\n" 704 705 "create port meter (port_id) (mtr_id) (profile_id) (meter_enable)\n" 706 "(g_action) (y_action) (r_action) (stats_mask) (shared)\n" 707 "(use_pre_meter_color) [(dscp_tbl_entry0) (dscp_tbl_entry1)...\n" 708 "(dscp_tbl_entry63)]\n" 709 " meter create\n\n" 710 711 "enable port meter (port_id) (mtr_id)\n" 712 " meter enable\n\n" 713 714 "disable port meter (port_id) (mtr_id)\n" 715 " meter disable\n\n" 716 717 "del port meter (port_id) (mtr_id)\n" 718 " meter delete\n\n" 719 720 "set port meter profile (port_id) (mtr_id) (profile_id)\n" 721 " meter update meter profile\n\n" 722 723 "set port meter dscp table (port_id) (mtr_id) [(dscp_tbl_entry0)\n" 724 "(dscp_tbl_entry1)...(dscp_tbl_entry63)]\n" 725 " update meter dscp table entries\n\n" 726 727 "set port meter policer action (port_id) (mtr_id) (action_mask)\n" 728 "(action0) [(action1) (action2)]\n" 729 " meter update policer action\n\n" 730 731 "set port meter stats mask (port_id) (mtr_id) (stats_mask)\n" 732 " meter update stats\n\n" 733 734 "show port (port_id) queue-region\n" 735 " show all queue region related configuration info\n\n" 736 737 "vxlan ip-version (ipv4|ipv6) vni (vni) udp-src" 738 " (udp-src) udp-dst (udp-dst) ip-src (ip-src) ip-dst" 739 " (ip-dst) eth-src (eth-src) eth-dst (eth-dst)\n" 740 " Configure the VXLAN encapsulation for flows.\n\n" 741 742 "vxlan-with-vlan ip-version (ipv4|ipv6) vni (vni)" 743 " udp-src (udp-src) udp-dst (udp-dst) ip-src (ip-src)" 744 " ip-dst (ip-dst) vlan-tci (vlan-tci) eth-src (eth-src)" 745 " eth-dst (eth-dst)\n" 746 " Configure the VXLAN encapsulation for flows.\n\n" 747 748 "nvgre ip-version (ipv4|ipv6) tni (tni) ip-src" 749 " (ip-src) ip-dst (ip-dst) eth-src (eth-src) eth-dst" 750 " (eth-dst)\n" 751 " Configure the NVGRE encapsulation for flows.\n\n" 752 753 "nvgre-with-vlan ip-version (ipv4|ipv6) tni (tni)" 754 " ip-src (ip-src) ip-dst (ip-dst) vlan-tci (vlan-tci)" 755 " eth-src (eth-src) eth-dst (eth-dst)\n" 756 " Configure the NVGRE encapsulation for flows.\n\n" 757 758 , list_pkt_forwarding_modes() 759 ); 760 } 761 762 if (show_all || !strcmp(res->section, "ports")) { 763 764 cmdline_printf( 765 cl, 766 "\n" 767 "Port Operations:\n" 768 "----------------\n\n" 769 770 "port start (port_id|all)\n" 771 " Start all ports or port_id.\n\n" 772 773 "port stop (port_id|all)\n" 774 " Stop all ports or port_id.\n\n" 775 776 "port close (port_id|all)\n" 777 " Close all ports or port_id.\n\n" 778 779 "port attach (ident)\n" 780 " Attach physical or virtual dev by pci address or virtual device name\n\n" 781 782 "port detach (port_id)\n" 783 " Detach physical or virtual dev by port_id\n\n" 784 785 "port config (port_id|all)" 786 " speed (10|100|1000|10000|25000|40000|50000|100000|auto)" 787 " duplex (half|full|auto)\n" 788 " Set speed and duplex for all ports or port_id\n\n" 789 790 "port config (port_id|all) loopback (mode)\n" 791 " Set loopback mode for all ports or port_id\n\n" 792 793 "port config all (rxq|txq|rxd|txd) (value)\n" 794 " Set number for rxq/txq/rxd/txd.\n\n" 795 796 "port config all max-pkt-len (value)\n" 797 " Set the max packet length.\n\n" 798 799 "port config all (crc-strip|scatter|rx-cksum|rx-timestamp|hw-vlan|hw-vlan-filter|" 800 "hw-vlan-strip|hw-vlan-extend|drop-en)" 801 " (on|off)\n" 802 " Set crc-strip/scatter/rx-checksum/hardware-vlan/drop_en" 803 " for ports.\n\n" 804 805 "port config all rss (all|default|ip|tcp|udp|sctp|" 806 "ether|port|vxlan|geneve|nvgre|none|<flowtype_id>)\n" 807 " Set the RSS mode.\n\n" 808 809 "port config port-id rss reta (hash,queue)[,(hash,queue)]\n" 810 " Set the RSS redirection table.\n\n" 811 812 "port config (port_id) dcb vt (on|off) (traffic_class)" 813 " pfc (on|off)\n" 814 " Set the DCB mode.\n\n" 815 816 "port config all burst (value)\n" 817 " Set the number of packets per burst.\n\n" 818 819 "port config all (txpt|txht|txwt|rxpt|rxht|rxwt)" 820 " (value)\n" 821 " Set the ring prefetch/host/writeback threshold" 822 " for tx/rx queue.\n\n" 823 824 "port config all (txfreet|txrst|rxfreet) (value)\n" 825 " Set free threshold for rx/tx, or set" 826 " tx rs bit threshold.\n\n" 827 "port config mtu X value\n" 828 " Set the MTU of port X to a given value\n\n" 829 830 "port config (port_id) (rxq|txq) (queue_id) ring_size (value)\n" 831 " Set a rx/tx queue's ring size configuration, the new" 832 " value will take effect after command that (re-)start the port" 833 " or command that setup the specific queue\n\n" 834 835 "port (port_id) (rxq|txq) (queue_id) (start|stop)\n" 836 " Start/stop a rx/tx queue of port X. Only take effect" 837 " when port X is started\n\n" 838 839 "port (port_id) (rxq|txq) (queue_id) deferred_start (on|off)\n" 840 " Switch on/off a deferred start of port X rx/tx queue. Only" 841 " take effect when port X is stopped.\n\n" 842 843 "port (port_id) (rxq|txq) (queue_id) setup\n" 844 " Setup a rx/tx queue of port X.\n\n" 845 846 "port config (port_id|all) l2-tunnel E-tag ether-type" 847 " (value)\n" 848 " Set the value of E-tag ether-type.\n\n" 849 850 "port config (port_id|all) l2-tunnel E-tag" 851 " (enable|disable)\n" 852 " Enable/disable the E-tag support.\n\n" 853 854 "port config (port_id) pctype mapping reset\n" 855 " Reset flow type to pctype mapping on a port\n\n" 856 857 "port config (port_id) pctype mapping update" 858 " (pctype_id_0[,pctype_id_1]*) (flow_type_id)\n" 859 " Update a flow type to pctype mapping item on a port\n\n" 860 861 "port config (port_id) pctype (pctype_id) hash_inset|" 862 "fdir_inset|fdir_flx_inset get|set|clear field\n" 863 " (field_idx)\n" 864 " Configure RSS|FDIR|FDIR_FLX input set for some pctype\n\n" 865 866 "port config (port_id) pctype (pctype_id) hash_inset|" 867 "fdir_inset|fdir_flx_inset clear all" 868 " Clear RSS|FDIR|FDIR_FLX input set completely for some pctype\n\n" 869 870 "port config (port_id) udp_tunnel_port add|rm vxlan|geneve (udp_port)\n\n" 871 " Add/remove UDP tunnel port for tunneling offload\n\n" 872 873 "port config <port_id> rx_offload vlan_strip|" 874 "ipv4_cksum|udp_cksum|tcp_cksum|tcp_lro|qinq_strip|" 875 "outer_ipv4_cksum|macsec_strip|header_split|" 876 "vlan_filter|vlan_extend|jumbo_frame|crc_strip|" 877 "scatter|timestamp|security|keep_crc on|off\n" 878 " Enable or disable a per port Rx offloading" 879 " on all Rx queues of a port\n\n" 880 881 "port (port_id) rxq (queue_id) rx_offload vlan_strip|" 882 "ipv4_cksum|udp_cksum|tcp_cksum|tcp_lro|qinq_strip|" 883 "outer_ipv4_cksum|macsec_strip|header_split|" 884 "vlan_filter|vlan_extend|jumbo_frame|crc_strip|" 885 "scatter|timestamp|security|keep_crc on|off\n" 886 " Enable or disable a per queue Rx offloading" 887 " only on a specific Rx queue\n\n" 888 889 "port config (port_id) tx_offload vlan_insert|" 890 "ipv4_cksum|udp_cksum|tcp_cksum|sctp_cksum|tcp_tso|" 891 "udp_tso|outer_ipv4_cksum|qinq_insert|vxlan_tnl_tso|" 892 "gre_tnl_tso|ipip_tnl_tso|geneve_tnl_tso|" 893 "macsec_insert|mt_lockfree|multi_segs|mbuf_fast_free|" 894 "security|match_metadata on|off\n" 895 " Enable or disable a per port Tx offloading" 896 " on all Tx queues of a port\n\n" 897 898 "port (port_id) txq (queue_id) tx_offload vlan_insert|" 899 "ipv4_cksum|udp_cksum|tcp_cksum|sctp_cksum|tcp_tso|" 900 "udp_tso|outer_ipv4_cksum|qinq_insert|vxlan_tnl_tso|" 901 "gre_tnl_tso|ipip_tnl_tso|geneve_tnl_tso|macsec_insert" 902 "|mt_lockfree|multi_segs|mbuf_fast_free|security" 903 " on|off\n" 904 " Enable or disable a per queue Tx offloading" 905 " only on a specific Tx queue\n\n" 906 907 "bpf-load rx|tx (port) (queue) (J|M|B) (file_name)\n" 908 " Load an eBPF program as a callback" 909 " for particular RX/TX queue\n\n" 910 911 "bpf-unload rx|tx (port) (queue)\n" 912 " Unload previously loaded eBPF program" 913 " for particular RX/TX queue\n\n" 914 915 "port config (port_id) tx_metadata (value)\n" 916 " Set Tx metadata value per port. Testpmd will add this value" 917 " to any Tx packet sent from this port\n\n" 918 ); 919 } 920 921 if (show_all || !strcmp(res->section, "registers")) { 922 923 cmdline_printf( 924 cl, 925 "\n" 926 "Registers:\n" 927 "----------\n\n" 928 929 "read reg (port_id) (address)\n" 930 " Display value of a port register.\n\n" 931 932 "read regfield (port_id) (address) (bit_x) (bit_y)\n" 933 " Display a port register bit field.\n\n" 934 935 "read regbit (port_id) (address) (bit_x)\n" 936 " Display a single port register bit.\n\n" 937 938 "write reg (port_id) (address) (value)\n" 939 " Set value of a port register.\n\n" 940 941 "write regfield (port_id) (address) (bit_x) (bit_y)" 942 " (value)\n" 943 " Set bit field of a port register.\n\n" 944 945 "write regbit (port_id) (address) (bit_x) (value)\n" 946 " Set single bit value of a port register.\n\n" 947 ); 948 } 949 if (show_all || !strcmp(res->section, "filters")) { 950 951 cmdline_printf( 952 cl, 953 "\n" 954 "filters:\n" 955 "--------\n\n" 956 957 "ethertype_filter (port_id) (add|del)" 958 " (mac_addr|mac_ignr) (mac_address) ethertype" 959 " (ether_type) (drop|fwd) queue (queue_id)\n" 960 " Add/Del an ethertype filter.\n\n" 961 962 "2tuple_filter (port_id) (add|del)" 963 " dst_port (dst_port_value) protocol (protocol_value)" 964 " mask (mask_value) tcp_flags (tcp_flags_value)" 965 " priority (prio_value) queue (queue_id)\n" 966 " Add/Del a 2tuple filter.\n\n" 967 968 "5tuple_filter (port_id) (add|del)" 969 " dst_ip (dst_address) src_ip (src_address)" 970 " dst_port (dst_port_value) src_port (src_port_value)" 971 " protocol (protocol_value)" 972 " mask (mask_value) tcp_flags (tcp_flags_value)" 973 " priority (prio_value) queue (queue_id)\n" 974 " Add/Del a 5tuple filter.\n\n" 975 976 "syn_filter (port_id) (add|del) priority (high|low) queue (queue_id)" 977 " Add/Del syn filter.\n\n" 978 979 "flex_filter (port_id) (add|del) len (len_value)" 980 " bytes (bytes_value) mask (mask_value)" 981 " priority (prio_value) queue (queue_id)\n" 982 " Add/Del a flex filter.\n\n" 983 984 "flow_director_filter (port_id) mode IP (add|del|update)" 985 " flow (ipv4-other|ipv4-frag|ipv6-other|ipv6-frag)" 986 " src (src_ip_address) dst (dst_ip_address)" 987 " tos (tos_value) proto (proto_value) ttl (ttl_value)" 988 " vlan (vlan_value) flexbytes (flexbytes_value)" 989 " (drop|fwd) pf|vf(vf_id) queue (queue_id)" 990 " fd_id (fd_id_value)\n" 991 " Add/Del an IP type flow director filter.\n\n" 992 993 "flow_director_filter (port_id) mode IP (add|del|update)" 994 " flow (ipv4-tcp|ipv4-udp|ipv6-tcp|ipv6-udp)" 995 " src (src_ip_address) (src_port)" 996 " dst (dst_ip_address) (dst_port)" 997 " tos (tos_value) ttl (ttl_value)" 998 " vlan (vlan_value) flexbytes (flexbytes_value)" 999 " (drop|fwd) pf|vf(vf_id) queue (queue_id)" 1000 " fd_id (fd_id_value)\n" 1001 " Add/Del an UDP/TCP type flow director filter.\n\n" 1002 1003 "flow_director_filter (port_id) mode IP (add|del|update)" 1004 " flow (ipv4-sctp|ipv6-sctp)" 1005 " src (src_ip_address) (src_port)" 1006 " dst (dst_ip_address) (dst_port)" 1007 " tag (verification_tag) " 1008 " tos (tos_value) ttl (ttl_value)" 1009 " vlan (vlan_value)" 1010 " flexbytes (flexbytes_value) (drop|fwd)" 1011 " pf|vf(vf_id) queue (queue_id) fd_id (fd_id_value)\n" 1012 " Add/Del a SCTP type flow director filter.\n\n" 1013 1014 "flow_director_filter (port_id) mode IP (add|del|update)" 1015 " flow l2_payload ether (ethertype)" 1016 " flexbytes (flexbytes_value) (drop|fwd)" 1017 " pf|vf(vf_id) queue (queue_id) fd_id (fd_id_value)\n" 1018 " Add/Del a l2 payload type flow director filter.\n\n" 1019 1020 "flow_director_filter (port_id) mode MAC-VLAN (add|del|update)" 1021 " mac (mac_address) vlan (vlan_value)" 1022 " flexbytes (flexbytes_value) (drop|fwd)" 1023 " queue (queue_id) fd_id (fd_id_value)\n" 1024 " Add/Del a MAC-VLAN flow director filter.\n\n" 1025 1026 "flow_director_filter (port_id) mode Tunnel (add|del|update)" 1027 " mac (mac_address) vlan (vlan_value)" 1028 " tunnel (NVGRE|VxLAN) tunnel-id (tunnel_id_value)" 1029 " flexbytes (flexbytes_value) (drop|fwd)" 1030 " queue (queue_id) fd_id (fd_id_value)\n" 1031 " Add/Del a Tunnel flow director filter.\n\n" 1032 1033 "flow_director_filter (port_id) mode raw (add|del|update)" 1034 " flow (flow_id) (drop|fwd) queue (queue_id)" 1035 " fd_id (fd_id_value) packet (packet file name)\n" 1036 " Add/Del a raw type flow director filter.\n\n" 1037 1038 "flush_flow_director (port_id)\n" 1039 " Flush all flow director entries of a device.\n\n" 1040 1041 "flow_director_mask (port_id) mode IP vlan (vlan_value)" 1042 " src_mask (ipv4_src) (ipv6_src) (src_port)" 1043 " dst_mask (ipv4_dst) (ipv6_dst) (dst_port)\n" 1044 " Set flow director IP mask.\n\n" 1045 1046 "flow_director_mask (port_id) mode MAC-VLAN" 1047 " vlan (vlan_value)\n" 1048 " Set flow director MAC-VLAN mask.\n\n" 1049 1050 "flow_director_mask (port_id) mode Tunnel" 1051 " vlan (vlan_value) mac (mac_value)" 1052 " tunnel-type (tunnel_type_value)" 1053 " tunnel-id (tunnel_id_value)\n" 1054 " Set flow director Tunnel mask.\n\n" 1055 1056 "flow_director_flex_mask (port_id)" 1057 " flow (none|ipv4-other|ipv4-frag|ipv4-tcp|ipv4-udp|ipv4-sctp|" 1058 "ipv6-other|ipv6-frag|ipv6-tcp|ipv6-udp|ipv6-sctp|l2_payload|all)" 1059 " (mask)\n" 1060 " Configure mask of flex payload.\n\n" 1061 1062 "flow_director_flex_payload (port_id)" 1063 " (raw|l2|l3|l4) (config)\n" 1064 " Configure flex payload selection.\n\n" 1065 1066 "get_sym_hash_ena_per_port (port_id)\n" 1067 " get symmetric hash enable configuration per port.\n\n" 1068 1069 "set_sym_hash_ena_per_port (port_id) (enable|disable)\n" 1070 " set symmetric hash enable configuration per port" 1071 " to enable or disable.\n\n" 1072 1073 "get_hash_global_config (port_id)\n" 1074 " Get the global configurations of hash filters.\n\n" 1075 1076 "set_hash_global_config (port_id) (toeplitz|simple_xor|default)" 1077 " (ipv4|ipv4-frag|ipv4-tcp|ipv4-udp|ipv4-sctp|ipv4-other|ipv6|" 1078 "ipv6-frag|ipv6-tcp|ipv6-udp|ipv6-sctp|ipv6-other|l2_payload)" 1079 " (enable|disable)\n" 1080 " Set the global configurations of hash filters.\n\n" 1081 1082 "set_hash_input_set (port_id) (ipv4|ipv4-frag|" 1083 "ipv4-tcp|ipv4-udp|ipv4-sctp|ipv4-other|ipv6|" 1084 "ipv6-frag|ipv6-tcp|ipv6-udp|ipv6-sctp|ipv6-other|" 1085 "l2_payload|<flowtype_id>) (ovlan|ivlan|src-ipv4|dst-ipv4|" 1086 "src-ipv6|dst-ipv6|ipv4-tos|ipv4-proto|ipv6-tc|" 1087 "ipv6-next-header|udp-src-port|udp-dst-port|" 1088 "tcp-src-port|tcp-dst-port|sctp-src-port|" 1089 "sctp-dst-port|sctp-veri-tag|udp-key|gre-key|fld-1st|" 1090 "fld-2nd|fld-3rd|fld-4th|fld-5th|fld-6th|fld-7th|" 1091 "fld-8th|none) (select|add)\n" 1092 " Set the input set for hash.\n\n" 1093 1094 "set_fdir_input_set (port_id) " 1095 "(ipv4-frag|ipv4-tcp|ipv4-udp|ipv4-sctp|ipv4-other|" 1096 "ipv6-frag|ipv6-tcp|ipv6-udp|ipv6-sctp|ipv6-other|" 1097 "l2_payload) (ivlan|ethertype|src-ipv4|dst-ipv4|src-ipv6|" 1098 "dst-ipv6|ipv4-tos|ipv4-proto|ipv4-ttl|ipv6-tc|" 1099 "ipv6-next-header|ipv6-hop-limits|udp-src-port|" 1100 "udp-dst-port|tcp-src-port|tcp-dst-port|" 1101 "sctp-src-port|sctp-dst-port|sctp-veri-tag|none)" 1102 " (select|add)\n" 1103 " Set the input set for FDir.\n\n" 1104 1105 "flow validate {port_id}" 1106 " [group {group_id}] [priority {level}]" 1107 " [ingress] [egress]" 1108 " pattern {item} [/ {item} [...]] / end" 1109 " actions {action} [/ {action} [...]] / end\n" 1110 " Check whether a flow rule can be created.\n\n" 1111 1112 "flow create {port_id}" 1113 " [group {group_id}] [priority {level}]" 1114 " [ingress] [egress]" 1115 " pattern {item} [/ {item} [...]] / end" 1116 " actions {action} [/ {action} [...]] / end\n" 1117 " Create a flow rule.\n\n" 1118 1119 "flow destroy {port_id} rule {rule_id} [...]\n" 1120 " Destroy specific flow rules.\n\n" 1121 1122 "flow flush {port_id}\n" 1123 " Destroy all flow rules.\n\n" 1124 1125 "flow query {port_id} {rule_id} {action}\n" 1126 " Query an existing flow rule.\n\n" 1127 1128 "flow list {port_id} [group {group_id}] [...]\n" 1129 " List existing flow rules sorted by priority," 1130 " filtered by group identifiers.\n\n" 1131 1132 "flow isolate {port_id} {boolean}\n" 1133 " Restrict ingress traffic to the defined" 1134 " flow rules\n\n" 1135 ); 1136 } 1137 1138 if (show_all || !strcmp(res->section, "traffic_management")) { 1139 cmdline_printf( 1140 cl, 1141 "\n" 1142 "Traffic Management:\n" 1143 "--------------\n" 1144 "show port tm cap (port_id)\n" 1145 " Display the port TM capability.\n\n" 1146 1147 "show port tm level cap (port_id) (level_id)\n" 1148 " Display the port TM hierarchical level capability.\n\n" 1149 1150 "show port tm node cap (port_id) (node_id)\n" 1151 " Display the port TM node capability.\n\n" 1152 1153 "show port tm node type (port_id) (node_id)\n" 1154 " Display the port TM node type.\n\n" 1155 1156 "show port tm node stats (port_id) (node_id) (clear)\n" 1157 " Display the port TM node stats.\n\n" 1158 1159 #if defined RTE_LIBRTE_PMD_SOFTNIC && defined RTE_LIBRTE_SCHED 1160 "set port tm hierarchy default (port_id)\n" 1161 " Set default traffic Management hierarchy on a port\n\n" 1162 #endif 1163 1164 "add port tm node shaper profile (port_id) (shaper_profile_id)" 1165 " (cmit_tb_rate) (cmit_tb_size) (peak_tb_rate) (peak_tb_size)" 1166 " (packet_length_adjust)\n" 1167 " Add port tm node private shaper profile.\n\n" 1168 1169 "del port tm node shaper profile (port_id) (shaper_profile_id)\n" 1170 " Delete port tm node private shaper profile.\n\n" 1171 1172 "add port tm node shared shaper (port_id) (shared_shaper_id)" 1173 " (shaper_profile_id)\n" 1174 " Add/update port tm node shared shaper.\n\n" 1175 1176 "del port tm node shared shaper (port_id) (shared_shaper_id)\n" 1177 " Delete port tm node shared shaper.\n\n" 1178 1179 "set port tm node shaper profile (port_id) (node_id)" 1180 " (shaper_profile_id)\n" 1181 " Set port tm node shaper profile.\n\n" 1182 1183 "add port tm node wred profile (port_id) (wred_profile_id)" 1184 " (color_g) (min_th_g) (max_th_g) (maxp_inv_g) (wq_log2_g)" 1185 " (color_y) (min_th_y) (max_th_y) (maxp_inv_y) (wq_log2_y)" 1186 " (color_r) (min_th_r) (max_th_r) (maxp_inv_r) (wq_log2_r)\n" 1187 " Add port tm node wred profile.\n\n" 1188 1189 "del port tm node wred profile (port_id) (wred_profile_id)\n" 1190 " Delete port tm node wred profile.\n\n" 1191 1192 "add port tm nonleaf node (port_id) (node_id) (parent_node_id)" 1193 " (priority) (weight) (level_id) (shaper_profile_id)" 1194 " (n_sp_priorities) (stats_mask) (n_shared_shapers)" 1195 " [(shared_shaper_id_0) (shared_shaper_id_1)...]\n" 1196 " Add port tm nonleaf node.\n\n" 1197 1198 "add port tm leaf node (port_id) (node_id) (parent_node_id)" 1199 " (priority) (weight) (level_id) (shaper_profile_id)" 1200 " (cman_mode) (wred_profile_id) (stats_mask) (n_shared_shapers)" 1201 " [(shared_shaper_id_0) (shared_shaper_id_1)...]\n" 1202 " Add port tm leaf node.\n\n" 1203 1204 "del port tm node (port_id) (node_id)\n" 1205 " Delete port tm node.\n\n" 1206 1207 "set port tm node parent (port_id) (node_id) (parent_node_id)" 1208 " (priority) (weight)\n" 1209 " Set port tm node parent.\n\n" 1210 1211 "suspend port tm node (port_id) (node_id)" 1212 " Suspend tm node.\n\n" 1213 1214 "resume port tm node (port_id) (node_id)" 1215 " Resume tm node.\n\n" 1216 1217 "port tm hierarchy commit (port_id) (clean_on_fail)\n" 1218 " Commit tm hierarchy.\n\n" 1219 1220 "set port tm mark ip_ecn (port) (green) (yellow)" 1221 " (red)\n" 1222 " Enables/Disables the traffic management marking" 1223 " for IP ECN (Explicit Congestion Notification)" 1224 " packets on a given port\n\n" 1225 1226 "set port tm mark ip_dscp (port) (green) (yellow)" 1227 " (red)\n" 1228 " Enables/Disables the traffic management marking" 1229 " on the port for IP dscp packets\n\n" 1230 1231 "set port tm mark vlan_dei (port) (green) (yellow)" 1232 " (red)\n" 1233 " Enables/Disables the traffic management marking" 1234 " on the port for VLAN packets with DEI enabled\n\n" 1235 ); 1236 } 1237 1238 } 1239 1240 cmdline_parse_token_string_t cmd_help_long_help = 1241 TOKEN_STRING_INITIALIZER(struct cmd_help_long_result, help, "help"); 1242 1243 cmdline_parse_token_string_t cmd_help_long_section = 1244 TOKEN_STRING_INITIALIZER(struct cmd_help_long_result, section, 1245 "all#control#display#config#" 1246 "ports#registers#filters#traffic_management"); 1247 1248 cmdline_parse_inst_t cmd_help_long = { 1249 .f = cmd_help_long_parsed, 1250 .data = NULL, 1251 .help_str = "help all|control|display|config|ports|register|" 1252 "filters|traffic_management: " 1253 "Show help", 1254 .tokens = { 1255 (void *)&cmd_help_long_help, 1256 (void *)&cmd_help_long_section, 1257 NULL, 1258 }, 1259 }; 1260 1261 1262 /* *** start/stop/close all ports *** */ 1263 struct cmd_operate_port_result { 1264 cmdline_fixed_string_t keyword; 1265 cmdline_fixed_string_t name; 1266 cmdline_fixed_string_t value; 1267 }; 1268 1269 static void cmd_operate_port_parsed(void *parsed_result, 1270 __attribute__((unused)) struct cmdline *cl, 1271 __attribute__((unused)) void *data) 1272 { 1273 struct cmd_operate_port_result *res = parsed_result; 1274 1275 if (!strcmp(res->name, "start")) 1276 start_port(RTE_PORT_ALL); 1277 else if (!strcmp(res->name, "stop")) 1278 stop_port(RTE_PORT_ALL); 1279 else if (!strcmp(res->name, "close")) 1280 close_port(RTE_PORT_ALL); 1281 else if (!strcmp(res->name, "reset")) 1282 reset_port(RTE_PORT_ALL); 1283 else 1284 printf("Unknown parameter\n"); 1285 } 1286 1287 cmdline_parse_token_string_t cmd_operate_port_all_cmd = 1288 TOKEN_STRING_INITIALIZER(struct cmd_operate_port_result, keyword, 1289 "port"); 1290 cmdline_parse_token_string_t cmd_operate_port_all_port = 1291 TOKEN_STRING_INITIALIZER(struct cmd_operate_port_result, name, 1292 "start#stop#close#reset"); 1293 cmdline_parse_token_string_t cmd_operate_port_all_all = 1294 TOKEN_STRING_INITIALIZER(struct cmd_operate_port_result, value, "all"); 1295 1296 cmdline_parse_inst_t cmd_operate_port = { 1297 .f = cmd_operate_port_parsed, 1298 .data = NULL, 1299 .help_str = "port start|stop|close all: Start/Stop/Close/Reset all ports", 1300 .tokens = { 1301 (void *)&cmd_operate_port_all_cmd, 1302 (void *)&cmd_operate_port_all_port, 1303 (void *)&cmd_operate_port_all_all, 1304 NULL, 1305 }, 1306 }; 1307 1308 /* *** start/stop/close specific port *** */ 1309 struct cmd_operate_specific_port_result { 1310 cmdline_fixed_string_t keyword; 1311 cmdline_fixed_string_t name; 1312 uint8_t value; 1313 }; 1314 1315 static void cmd_operate_specific_port_parsed(void *parsed_result, 1316 __attribute__((unused)) struct cmdline *cl, 1317 __attribute__((unused)) void *data) 1318 { 1319 struct cmd_operate_specific_port_result *res = parsed_result; 1320 1321 if (!strcmp(res->name, "start")) 1322 start_port(res->value); 1323 else if (!strcmp(res->name, "stop")) 1324 stop_port(res->value); 1325 else if (!strcmp(res->name, "close")) 1326 close_port(res->value); 1327 else if (!strcmp(res->name, "reset")) 1328 reset_port(res->value); 1329 else 1330 printf("Unknown parameter\n"); 1331 } 1332 1333 cmdline_parse_token_string_t cmd_operate_specific_port_cmd = 1334 TOKEN_STRING_INITIALIZER(struct cmd_operate_specific_port_result, 1335 keyword, "port"); 1336 cmdline_parse_token_string_t cmd_operate_specific_port_port = 1337 TOKEN_STRING_INITIALIZER(struct cmd_operate_specific_port_result, 1338 name, "start#stop#close#reset"); 1339 cmdline_parse_token_num_t cmd_operate_specific_port_id = 1340 TOKEN_NUM_INITIALIZER(struct cmd_operate_specific_port_result, 1341 value, UINT8); 1342 1343 cmdline_parse_inst_t cmd_operate_specific_port = { 1344 .f = cmd_operate_specific_port_parsed, 1345 .data = NULL, 1346 .help_str = "port start|stop|close <port_id>: Start/Stop/Close/Reset port_id", 1347 .tokens = { 1348 (void *)&cmd_operate_specific_port_cmd, 1349 (void *)&cmd_operate_specific_port_port, 1350 (void *)&cmd_operate_specific_port_id, 1351 NULL, 1352 }, 1353 }; 1354 1355 /* *** enable port setup (after attach) via iterator or event *** */ 1356 struct cmd_set_port_setup_on_result { 1357 cmdline_fixed_string_t set; 1358 cmdline_fixed_string_t port; 1359 cmdline_fixed_string_t setup; 1360 cmdline_fixed_string_t on; 1361 cmdline_fixed_string_t mode; 1362 }; 1363 1364 static void cmd_set_port_setup_on_parsed(void *parsed_result, 1365 __attribute__((unused)) struct cmdline *cl, 1366 __attribute__((unused)) void *data) 1367 { 1368 struct cmd_set_port_setup_on_result *res = parsed_result; 1369 1370 if (strcmp(res->mode, "event") == 0) 1371 setup_on_probe_event = true; 1372 else if (strcmp(res->mode, "iterator") == 0) 1373 setup_on_probe_event = false; 1374 else 1375 printf("Unknown mode\n"); 1376 } 1377 1378 cmdline_parse_token_string_t cmd_set_port_setup_on_set = 1379 TOKEN_STRING_INITIALIZER(struct cmd_set_port_setup_on_result, 1380 set, "set"); 1381 cmdline_parse_token_string_t cmd_set_port_setup_on_port = 1382 TOKEN_STRING_INITIALIZER(struct cmd_set_port_setup_on_result, 1383 port, "port"); 1384 cmdline_parse_token_string_t cmd_set_port_setup_on_setup = 1385 TOKEN_STRING_INITIALIZER(struct cmd_set_port_setup_on_result, 1386 setup, "setup"); 1387 cmdline_parse_token_string_t cmd_set_port_setup_on_on = 1388 TOKEN_STRING_INITIALIZER(struct cmd_set_port_setup_on_result, 1389 on, "on"); 1390 cmdline_parse_token_string_t cmd_set_port_setup_on_mode = 1391 TOKEN_STRING_INITIALIZER(struct cmd_set_port_setup_on_result, 1392 mode, "iterator#event"); 1393 1394 cmdline_parse_inst_t cmd_set_port_setup_on = { 1395 .f = cmd_set_port_setup_on_parsed, 1396 .data = NULL, 1397 .help_str = "set port setup on iterator|event", 1398 .tokens = { 1399 (void *)&cmd_set_port_setup_on_set, 1400 (void *)&cmd_set_port_setup_on_port, 1401 (void *)&cmd_set_port_setup_on_setup, 1402 (void *)&cmd_set_port_setup_on_on, 1403 (void *)&cmd_set_port_setup_on_mode, 1404 NULL, 1405 }, 1406 }; 1407 1408 /* *** attach a specified port *** */ 1409 struct cmd_operate_attach_port_result { 1410 cmdline_fixed_string_t port; 1411 cmdline_fixed_string_t keyword; 1412 cmdline_fixed_string_t identifier; 1413 }; 1414 1415 static void cmd_operate_attach_port_parsed(void *parsed_result, 1416 __attribute__((unused)) struct cmdline *cl, 1417 __attribute__((unused)) void *data) 1418 { 1419 struct cmd_operate_attach_port_result *res = parsed_result; 1420 1421 if (!strcmp(res->keyword, "attach")) 1422 attach_port(res->identifier); 1423 else 1424 printf("Unknown parameter\n"); 1425 } 1426 1427 cmdline_parse_token_string_t cmd_operate_attach_port_port = 1428 TOKEN_STRING_INITIALIZER(struct cmd_operate_attach_port_result, 1429 port, "port"); 1430 cmdline_parse_token_string_t cmd_operate_attach_port_keyword = 1431 TOKEN_STRING_INITIALIZER(struct cmd_operate_attach_port_result, 1432 keyword, "attach"); 1433 cmdline_parse_token_string_t cmd_operate_attach_port_identifier = 1434 TOKEN_STRING_INITIALIZER(struct cmd_operate_attach_port_result, 1435 identifier, NULL); 1436 1437 cmdline_parse_inst_t cmd_operate_attach_port = { 1438 .f = cmd_operate_attach_port_parsed, 1439 .data = NULL, 1440 .help_str = "port attach <identifier>: " 1441 "(identifier: pci address or virtual dev name)", 1442 .tokens = { 1443 (void *)&cmd_operate_attach_port_port, 1444 (void *)&cmd_operate_attach_port_keyword, 1445 (void *)&cmd_operate_attach_port_identifier, 1446 NULL, 1447 }, 1448 }; 1449 1450 /* *** detach a specified port *** */ 1451 struct cmd_operate_detach_port_result { 1452 cmdline_fixed_string_t port; 1453 cmdline_fixed_string_t keyword; 1454 portid_t port_id; 1455 }; 1456 1457 static void cmd_operate_detach_port_parsed(void *parsed_result, 1458 __attribute__((unused)) struct cmdline *cl, 1459 __attribute__((unused)) void *data) 1460 { 1461 struct cmd_operate_detach_port_result *res = parsed_result; 1462 1463 if (!strcmp(res->keyword, "detach")) 1464 detach_port_device(res->port_id); 1465 else 1466 printf("Unknown parameter\n"); 1467 } 1468 1469 cmdline_parse_token_string_t cmd_operate_detach_port_port = 1470 TOKEN_STRING_INITIALIZER(struct cmd_operate_detach_port_result, 1471 port, "port"); 1472 cmdline_parse_token_string_t cmd_operate_detach_port_keyword = 1473 TOKEN_STRING_INITIALIZER(struct cmd_operate_detach_port_result, 1474 keyword, "detach"); 1475 cmdline_parse_token_num_t cmd_operate_detach_port_port_id = 1476 TOKEN_NUM_INITIALIZER(struct cmd_operate_detach_port_result, 1477 port_id, UINT16); 1478 1479 cmdline_parse_inst_t cmd_operate_detach_port = { 1480 .f = cmd_operate_detach_port_parsed, 1481 .data = NULL, 1482 .help_str = "port detach <port_id>", 1483 .tokens = { 1484 (void *)&cmd_operate_detach_port_port, 1485 (void *)&cmd_operate_detach_port_keyword, 1486 (void *)&cmd_operate_detach_port_port_id, 1487 NULL, 1488 }, 1489 }; 1490 1491 /* *** configure speed for all ports *** */ 1492 struct cmd_config_speed_all { 1493 cmdline_fixed_string_t port; 1494 cmdline_fixed_string_t keyword; 1495 cmdline_fixed_string_t all; 1496 cmdline_fixed_string_t item1; 1497 cmdline_fixed_string_t item2; 1498 cmdline_fixed_string_t value1; 1499 cmdline_fixed_string_t value2; 1500 }; 1501 1502 static int 1503 parse_and_check_speed_duplex(char *speedstr, char *duplexstr, uint32_t *speed) 1504 { 1505 1506 int duplex; 1507 1508 if (!strcmp(duplexstr, "half")) { 1509 duplex = ETH_LINK_HALF_DUPLEX; 1510 } else if (!strcmp(duplexstr, "full")) { 1511 duplex = ETH_LINK_FULL_DUPLEX; 1512 } else if (!strcmp(duplexstr, "auto")) { 1513 duplex = ETH_LINK_FULL_DUPLEX; 1514 } else { 1515 printf("Unknown duplex parameter\n"); 1516 return -1; 1517 } 1518 1519 if (!strcmp(speedstr, "10")) { 1520 *speed = (duplex == ETH_LINK_HALF_DUPLEX) ? 1521 ETH_LINK_SPEED_10M_HD : ETH_LINK_SPEED_10M; 1522 } else if (!strcmp(speedstr, "100")) { 1523 *speed = (duplex == ETH_LINK_HALF_DUPLEX) ? 1524 ETH_LINK_SPEED_100M_HD : ETH_LINK_SPEED_100M; 1525 } else { 1526 if (duplex != ETH_LINK_FULL_DUPLEX) { 1527 printf("Invalid speed/duplex parameters\n"); 1528 return -1; 1529 } 1530 if (!strcmp(speedstr, "1000")) { 1531 *speed = ETH_LINK_SPEED_1G; 1532 } else if (!strcmp(speedstr, "10000")) { 1533 *speed = ETH_LINK_SPEED_10G; 1534 } else if (!strcmp(speedstr, "25000")) { 1535 *speed = ETH_LINK_SPEED_25G; 1536 } else if (!strcmp(speedstr, "40000")) { 1537 *speed = ETH_LINK_SPEED_40G; 1538 } else if (!strcmp(speedstr, "50000")) { 1539 *speed = ETH_LINK_SPEED_50G; 1540 } else if (!strcmp(speedstr, "100000")) { 1541 *speed = ETH_LINK_SPEED_100G; 1542 } else if (!strcmp(speedstr, "auto")) { 1543 *speed = ETH_LINK_SPEED_AUTONEG; 1544 } else { 1545 printf("Unknown speed parameter\n"); 1546 return -1; 1547 } 1548 } 1549 1550 return 0; 1551 } 1552 1553 static void 1554 cmd_config_speed_all_parsed(void *parsed_result, 1555 __attribute__((unused)) struct cmdline *cl, 1556 __attribute__((unused)) void *data) 1557 { 1558 struct cmd_config_speed_all *res = parsed_result; 1559 uint32_t link_speed; 1560 portid_t pid; 1561 1562 if (!all_ports_stopped()) { 1563 printf("Please stop all ports first\n"); 1564 return; 1565 } 1566 1567 if (parse_and_check_speed_duplex(res->value1, res->value2, 1568 &link_speed) < 0) 1569 return; 1570 1571 RTE_ETH_FOREACH_DEV(pid) { 1572 ports[pid].dev_conf.link_speeds = link_speed; 1573 } 1574 1575 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1); 1576 } 1577 1578 cmdline_parse_token_string_t cmd_config_speed_all_port = 1579 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_all, port, "port"); 1580 cmdline_parse_token_string_t cmd_config_speed_all_keyword = 1581 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_all, keyword, 1582 "config"); 1583 cmdline_parse_token_string_t cmd_config_speed_all_all = 1584 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_all, all, "all"); 1585 cmdline_parse_token_string_t cmd_config_speed_all_item1 = 1586 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_all, item1, "speed"); 1587 cmdline_parse_token_string_t cmd_config_speed_all_value1 = 1588 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_all, value1, 1589 "10#100#1000#10000#25000#40000#50000#100000#auto"); 1590 cmdline_parse_token_string_t cmd_config_speed_all_item2 = 1591 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_all, item2, "duplex"); 1592 cmdline_parse_token_string_t cmd_config_speed_all_value2 = 1593 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_all, value2, 1594 "half#full#auto"); 1595 1596 cmdline_parse_inst_t cmd_config_speed_all = { 1597 .f = cmd_config_speed_all_parsed, 1598 .data = NULL, 1599 .help_str = "port config all speed " 1600 "10|100|1000|10000|25000|40000|50000|100000|auto duplex " 1601 "half|full|auto", 1602 .tokens = { 1603 (void *)&cmd_config_speed_all_port, 1604 (void *)&cmd_config_speed_all_keyword, 1605 (void *)&cmd_config_speed_all_all, 1606 (void *)&cmd_config_speed_all_item1, 1607 (void *)&cmd_config_speed_all_value1, 1608 (void *)&cmd_config_speed_all_item2, 1609 (void *)&cmd_config_speed_all_value2, 1610 NULL, 1611 }, 1612 }; 1613 1614 /* *** configure speed for specific port *** */ 1615 struct cmd_config_speed_specific { 1616 cmdline_fixed_string_t port; 1617 cmdline_fixed_string_t keyword; 1618 portid_t id; 1619 cmdline_fixed_string_t item1; 1620 cmdline_fixed_string_t item2; 1621 cmdline_fixed_string_t value1; 1622 cmdline_fixed_string_t value2; 1623 }; 1624 1625 static void 1626 cmd_config_speed_specific_parsed(void *parsed_result, 1627 __attribute__((unused)) struct cmdline *cl, 1628 __attribute__((unused)) void *data) 1629 { 1630 struct cmd_config_speed_specific *res = parsed_result; 1631 uint32_t link_speed; 1632 1633 if (!all_ports_stopped()) { 1634 printf("Please stop all ports first\n"); 1635 return; 1636 } 1637 1638 if (port_id_is_invalid(res->id, ENABLED_WARN)) 1639 return; 1640 1641 if (parse_and_check_speed_duplex(res->value1, res->value2, 1642 &link_speed) < 0) 1643 return; 1644 1645 ports[res->id].dev_conf.link_speeds = link_speed; 1646 1647 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1); 1648 } 1649 1650 1651 cmdline_parse_token_string_t cmd_config_speed_specific_port = 1652 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_specific, port, 1653 "port"); 1654 cmdline_parse_token_string_t cmd_config_speed_specific_keyword = 1655 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_specific, keyword, 1656 "config"); 1657 cmdline_parse_token_num_t cmd_config_speed_specific_id = 1658 TOKEN_NUM_INITIALIZER(struct cmd_config_speed_specific, id, UINT16); 1659 cmdline_parse_token_string_t cmd_config_speed_specific_item1 = 1660 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_specific, item1, 1661 "speed"); 1662 cmdline_parse_token_string_t cmd_config_speed_specific_value1 = 1663 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_specific, value1, 1664 "10#100#1000#10000#25000#40000#50000#100000#auto"); 1665 cmdline_parse_token_string_t cmd_config_speed_specific_item2 = 1666 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_specific, item2, 1667 "duplex"); 1668 cmdline_parse_token_string_t cmd_config_speed_specific_value2 = 1669 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_specific, value2, 1670 "half#full#auto"); 1671 1672 cmdline_parse_inst_t cmd_config_speed_specific = { 1673 .f = cmd_config_speed_specific_parsed, 1674 .data = NULL, 1675 .help_str = "port config <port_id> speed " 1676 "10|100|1000|10000|25000|40000|50000|100000|auto duplex " 1677 "half|full|auto", 1678 .tokens = { 1679 (void *)&cmd_config_speed_specific_port, 1680 (void *)&cmd_config_speed_specific_keyword, 1681 (void *)&cmd_config_speed_specific_id, 1682 (void *)&cmd_config_speed_specific_item1, 1683 (void *)&cmd_config_speed_specific_value1, 1684 (void *)&cmd_config_speed_specific_item2, 1685 (void *)&cmd_config_speed_specific_value2, 1686 NULL, 1687 }, 1688 }; 1689 1690 /* *** configure loopback for all ports *** */ 1691 struct cmd_config_loopback_all { 1692 cmdline_fixed_string_t port; 1693 cmdline_fixed_string_t keyword; 1694 cmdline_fixed_string_t all; 1695 cmdline_fixed_string_t item; 1696 uint32_t mode; 1697 }; 1698 1699 static void 1700 cmd_config_loopback_all_parsed(void *parsed_result, 1701 __attribute__((unused)) struct cmdline *cl, 1702 __attribute__((unused)) void *data) 1703 { 1704 struct cmd_config_loopback_all *res = parsed_result; 1705 portid_t pid; 1706 1707 if (!all_ports_stopped()) { 1708 printf("Please stop all ports first\n"); 1709 return; 1710 } 1711 1712 RTE_ETH_FOREACH_DEV(pid) { 1713 ports[pid].dev_conf.lpbk_mode = res->mode; 1714 } 1715 1716 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1); 1717 } 1718 1719 cmdline_parse_token_string_t cmd_config_loopback_all_port = 1720 TOKEN_STRING_INITIALIZER(struct cmd_config_loopback_all, port, "port"); 1721 cmdline_parse_token_string_t cmd_config_loopback_all_keyword = 1722 TOKEN_STRING_INITIALIZER(struct cmd_config_loopback_all, keyword, 1723 "config"); 1724 cmdline_parse_token_string_t cmd_config_loopback_all_all = 1725 TOKEN_STRING_INITIALIZER(struct cmd_config_loopback_all, all, "all"); 1726 cmdline_parse_token_string_t cmd_config_loopback_all_item = 1727 TOKEN_STRING_INITIALIZER(struct cmd_config_loopback_all, item, 1728 "loopback"); 1729 cmdline_parse_token_num_t cmd_config_loopback_all_mode = 1730 TOKEN_NUM_INITIALIZER(struct cmd_config_loopback_all, mode, UINT32); 1731 1732 cmdline_parse_inst_t cmd_config_loopback_all = { 1733 .f = cmd_config_loopback_all_parsed, 1734 .data = NULL, 1735 .help_str = "port config all loopback <mode>", 1736 .tokens = { 1737 (void *)&cmd_config_loopback_all_port, 1738 (void *)&cmd_config_loopback_all_keyword, 1739 (void *)&cmd_config_loopback_all_all, 1740 (void *)&cmd_config_loopback_all_item, 1741 (void *)&cmd_config_loopback_all_mode, 1742 NULL, 1743 }, 1744 }; 1745 1746 /* *** configure loopback for specific port *** */ 1747 struct cmd_config_loopback_specific { 1748 cmdline_fixed_string_t port; 1749 cmdline_fixed_string_t keyword; 1750 uint16_t port_id; 1751 cmdline_fixed_string_t item; 1752 uint32_t mode; 1753 }; 1754 1755 static void 1756 cmd_config_loopback_specific_parsed(void *parsed_result, 1757 __attribute__((unused)) struct cmdline *cl, 1758 __attribute__((unused)) void *data) 1759 { 1760 struct cmd_config_loopback_specific *res = parsed_result; 1761 1762 if (port_id_is_invalid(res->port_id, ENABLED_WARN)) 1763 return; 1764 1765 if (!port_is_stopped(res->port_id)) { 1766 printf("Please stop port %u first\n", res->port_id); 1767 return; 1768 } 1769 1770 ports[res->port_id].dev_conf.lpbk_mode = res->mode; 1771 1772 cmd_reconfig_device_queue(res->port_id, 1, 1); 1773 } 1774 1775 1776 cmdline_parse_token_string_t cmd_config_loopback_specific_port = 1777 TOKEN_STRING_INITIALIZER(struct cmd_config_loopback_specific, port, 1778 "port"); 1779 cmdline_parse_token_string_t cmd_config_loopback_specific_keyword = 1780 TOKEN_STRING_INITIALIZER(struct cmd_config_loopback_specific, keyword, 1781 "config"); 1782 cmdline_parse_token_num_t cmd_config_loopback_specific_id = 1783 TOKEN_NUM_INITIALIZER(struct cmd_config_loopback_specific, port_id, 1784 UINT16); 1785 cmdline_parse_token_string_t cmd_config_loopback_specific_item = 1786 TOKEN_STRING_INITIALIZER(struct cmd_config_loopback_specific, item, 1787 "loopback"); 1788 cmdline_parse_token_num_t cmd_config_loopback_specific_mode = 1789 TOKEN_NUM_INITIALIZER(struct cmd_config_loopback_specific, mode, 1790 UINT32); 1791 1792 cmdline_parse_inst_t cmd_config_loopback_specific = { 1793 .f = cmd_config_loopback_specific_parsed, 1794 .data = NULL, 1795 .help_str = "port config <port_id> loopback <mode>", 1796 .tokens = { 1797 (void *)&cmd_config_loopback_specific_port, 1798 (void *)&cmd_config_loopback_specific_keyword, 1799 (void *)&cmd_config_loopback_specific_id, 1800 (void *)&cmd_config_loopback_specific_item, 1801 (void *)&cmd_config_loopback_specific_mode, 1802 NULL, 1803 }, 1804 }; 1805 1806 /* *** configure txq/rxq, txd/rxd *** */ 1807 struct cmd_config_rx_tx { 1808 cmdline_fixed_string_t port; 1809 cmdline_fixed_string_t keyword; 1810 cmdline_fixed_string_t all; 1811 cmdline_fixed_string_t name; 1812 uint16_t value; 1813 }; 1814 1815 static void 1816 cmd_config_rx_tx_parsed(void *parsed_result, 1817 __attribute__((unused)) struct cmdline *cl, 1818 __attribute__((unused)) void *data) 1819 { 1820 struct cmd_config_rx_tx *res = parsed_result; 1821 1822 if (!all_ports_stopped()) { 1823 printf("Please stop all ports first\n"); 1824 return; 1825 } 1826 if (!strcmp(res->name, "rxq")) { 1827 if (!res->value && !nb_txq) { 1828 printf("Warning: Either rx or tx queues should be non zero\n"); 1829 return; 1830 } 1831 if (check_nb_rxq(res->value) != 0) 1832 return; 1833 nb_rxq = res->value; 1834 } 1835 else if (!strcmp(res->name, "txq")) { 1836 if (!res->value && !nb_rxq) { 1837 printf("Warning: Either rx or tx queues should be non zero\n"); 1838 return; 1839 } 1840 if (check_nb_txq(res->value) != 0) 1841 return; 1842 nb_txq = res->value; 1843 } 1844 else if (!strcmp(res->name, "rxd")) { 1845 if (res->value <= 0 || res->value > RTE_TEST_RX_DESC_MAX) { 1846 printf("rxd %d invalid - must be > 0 && <= %d\n", 1847 res->value, RTE_TEST_RX_DESC_MAX); 1848 return; 1849 } 1850 nb_rxd = res->value; 1851 } else if (!strcmp(res->name, "txd")) { 1852 if (res->value <= 0 || res->value > RTE_TEST_TX_DESC_MAX) { 1853 printf("txd %d invalid - must be > 0 && <= %d\n", 1854 res->value, RTE_TEST_TX_DESC_MAX); 1855 return; 1856 } 1857 nb_txd = res->value; 1858 } else { 1859 printf("Unknown parameter\n"); 1860 return; 1861 } 1862 1863 fwd_config_setup(); 1864 1865 init_port_config(); 1866 1867 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1); 1868 } 1869 1870 cmdline_parse_token_string_t cmd_config_rx_tx_port = 1871 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_tx, port, "port"); 1872 cmdline_parse_token_string_t cmd_config_rx_tx_keyword = 1873 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_tx, keyword, "config"); 1874 cmdline_parse_token_string_t cmd_config_rx_tx_all = 1875 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_tx, all, "all"); 1876 cmdline_parse_token_string_t cmd_config_rx_tx_name = 1877 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_tx, name, 1878 "rxq#txq#rxd#txd"); 1879 cmdline_parse_token_num_t cmd_config_rx_tx_value = 1880 TOKEN_NUM_INITIALIZER(struct cmd_config_rx_tx, value, UINT16); 1881 1882 cmdline_parse_inst_t cmd_config_rx_tx = { 1883 .f = cmd_config_rx_tx_parsed, 1884 .data = NULL, 1885 .help_str = "port config all rxq|txq|rxd|txd <value>", 1886 .tokens = { 1887 (void *)&cmd_config_rx_tx_port, 1888 (void *)&cmd_config_rx_tx_keyword, 1889 (void *)&cmd_config_rx_tx_all, 1890 (void *)&cmd_config_rx_tx_name, 1891 (void *)&cmd_config_rx_tx_value, 1892 NULL, 1893 }, 1894 }; 1895 1896 /* *** config max packet length *** */ 1897 struct cmd_config_max_pkt_len_result { 1898 cmdline_fixed_string_t port; 1899 cmdline_fixed_string_t keyword; 1900 cmdline_fixed_string_t all; 1901 cmdline_fixed_string_t name; 1902 uint32_t value; 1903 }; 1904 1905 static void 1906 cmd_config_max_pkt_len_parsed(void *parsed_result, 1907 __attribute__((unused)) struct cmdline *cl, 1908 __attribute__((unused)) void *data) 1909 { 1910 struct cmd_config_max_pkt_len_result *res = parsed_result; 1911 portid_t pid; 1912 1913 if (!all_ports_stopped()) { 1914 printf("Please stop all ports first\n"); 1915 return; 1916 } 1917 1918 RTE_ETH_FOREACH_DEV(pid) { 1919 struct rte_port *port = &ports[pid]; 1920 uint64_t rx_offloads = port->dev_conf.rxmode.offloads; 1921 1922 if (!strcmp(res->name, "max-pkt-len")) { 1923 if (res->value < ETHER_MIN_LEN) { 1924 printf("max-pkt-len can not be less than %d\n", 1925 ETHER_MIN_LEN); 1926 return; 1927 } 1928 if (res->value == port->dev_conf.rxmode.max_rx_pkt_len) 1929 return; 1930 1931 port->dev_conf.rxmode.max_rx_pkt_len = res->value; 1932 if (res->value > ETHER_MAX_LEN) 1933 rx_offloads |= DEV_RX_OFFLOAD_JUMBO_FRAME; 1934 else 1935 rx_offloads &= ~DEV_RX_OFFLOAD_JUMBO_FRAME; 1936 port->dev_conf.rxmode.offloads = rx_offloads; 1937 } else { 1938 printf("Unknown parameter\n"); 1939 return; 1940 } 1941 } 1942 1943 init_port_config(); 1944 1945 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1); 1946 } 1947 1948 cmdline_parse_token_string_t cmd_config_max_pkt_len_port = 1949 TOKEN_STRING_INITIALIZER(struct cmd_config_max_pkt_len_result, port, 1950 "port"); 1951 cmdline_parse_token_string_t cmd_config_max_pkt_len_keyword = 1952 TOKEN_STRING_INITIALIZER(struct cmd_config_max_pkt_len_result, keyword, 1953 "config"); 1954 cmdline_parse_token_string_t cmd_config_max_pkt_len_all = 1955 TOKEN_STRING_INITIALIZER(struct cmd_config_max_pkt_len_result, all, 1956 "all"); 1957 cmdline_parse_token_string_t cmd_config_max_pkt_len_name = 1958 TOKEN_STRING_INITIALIZER(struct cmd_config_max_pkt_len_result, name, 1959 "max-pkt-len"); 1960 cmdline_parse_token_num_t cmd_config_max_pkt_len_value = 1961 TOKEN_NUM_INITIALIZER(struct cmd_config_max_pkt_len_result, value, 1962 UINT32); 1963 1964 cmdline_parse_inst_t cmd_config_max_pkt_len = { 1965 .f = cmd_config_max_pkt_len_parsed, 1966 .data = NULL, 1967 .help_str = "port config all max-pkt-len <value>", 1968 .tokens = { 1969 (void *)&cmd_config_max_pkt_len_port, 1970 (void *)&cmd_config_max_pkt_len_keyword, 1971 (void *)&cmd_config_max_pkt_len_all, 1972 (void *)&cmd_config_max_pkt_len_name, 1973 (void *)&cmd_config_max_pkt_len_value, 1974 NULL, 1975 }, 1976 }; 1977 1978 /* *** configure port MTU *** */ 1979 struct cmd_config_mtu_result { 1980 cmdline_fixed_string_t port; 1981 cmdline_fixed_string_t keyword; 1982 cmdline_fixed_string_t mtu; 1983 portid_t port_id; 1984 uint16_t value; 1985 }; 1986 1987 static void 1988 cmd_config_mtu_parsed(void *parsed_result, 1989 __attribute__((unused)) struct cmdline *cl, 1990 __attribute__((unused)) void *data) 1991 { 1992 struct cmd_config_mtu_result *res = parsed_result; 1993 1994 if (res->value < ETHER_MIN_LEN) { 1995 printf("mtu cannot be less than %d\n", ETHER_MIN_LEN); 1996 return; 1997 } 1998 port_mtu_set(res->port_id, res->value); 1999 } 2000 2001 cmdline_parse_token_string_t cmd_config_mtu_port = 2002 TOKEN_STRING_INITIALIZER(struct cmd_config_mtu_result, port, 2003 "port"); 2004 cmdline_parse_token_string_t cmd_config_mtu_keyword = 2005 TOKEN_STRING_INITIALIZER(struct cmd_config_mtu_result, keyword, 2006 "config"); 2007 cmdline_parse_token_string_t cmd_config_mtu_mtu = 2008 TOKEN_STRING_INITIALIZER(struct cmd_config_mtu_result, keyword, 2009 "mtu"); 2010 cmdline_parse_token_num_t cmd_config_mtu_port_id = 2011 TOKEN_NUM_INITIALIZER(struct cmd_config_mtu_result, port_id, UINT16); 2012 cmdline_parse_token_num_t cmd_config_mtu_value = 2013 TOKEN_NUM_INITIALIZER(struct cmd_config_mtu_result, value, UINT16); 2014 2015 cmdline_parse_inst_t cmd_config_mtu = { 2016 .f = cmd_config_mtu_parsed, 2017 .data = NULL, 2018 .help_str = "port config mtu <port_id> <value>", 2019 .tokens = { 2020 (void *)&cmd_config_mtu_port, 2021 (void *)&cmd_config_mtu_keyword, 2022 (void *)&cmd_config_mtu_mtu, 2023 (void *)&cmd_config_mtu_port_id, 2024 (void *)&cmd_config_mtu_value, 2025 NULL, 2026 }, 2027 }; 2028 2029 /* *** configure rx mode *** */ 2030 struct cmd_config_rx_mode_flag { 2031 cmdline_fixed_string_t port; 2032 cmdline_fixed_string_t keyword; 2033 cmdline_fixed_string_t all; 2034 cmdline_fixed_string_t name; 2035 cmdline_fixed_string_t value; 2036 }; 2037 2038 static void 2039 cmd_config_rx_mode_flag_parsed(void *parsed_result, 2040 __attribute__((unused)) struct cmdline *cl, 2041 __attribute__((unused)) void *data) 2042 { 2043 struct cmd_config_rx_mode_flag *res = parsed_result; 2044 portid_t pid; 2045 2046 if (!all_ports_stopped()) { 2047 printf("Please stop all ports first\n"); 2048 return; 2049 } 2050 2051 RTE_ETH_FOREACH_DEV(pid) { 2052 struct rte_port *port; 2053 uint64_t rx_offloads; 2054 2055 port = &ports[pid]; 2056 rx_offloads = port->dev_conf.rxmode.offloads; 2057 if (!strcmp(res->name, "crc-strip")) { 2058 if (!strcmp(res->value, "on")) { 2059 rx_offloads &= ~DEV_RX_OFFLOAD_KEEP_CRC; 2060 } else if (!strcmp(res->value, "off")) { 2061 rx_offloads |= DEV_RX_OFFLOAD_KEEP_CRC; 2062 } else { 2063 printf("Unknown parameter\n"); 2064 return; 2065 } 2066 } else if (!strcmp(res->name, "scatter")) { 2067 if (!strcmp(res->value, "on")) { 2068 rx_offloads |= DEV_RX_OFFLOAD_SCATTER; 2069 } else if (!strcmp(res->value, "off")) { 2070 rx_offloads &= ~DEV_RX_OFFLOAD_SCATTER; 2071 } else { 2072 printf("Unknown parameter\n"); 2073 return; 2074 } 2075 } else if (!strcmp(res->name, "rx-cksum")) { 2076 if (!strcmp(res->value, "on")) 2077 rx_offloads |= DEV_RX_OFFLOAD_CHECKSUM; 2078 else if (!strcmp(res->value, "off")) 2079 rx_offloads &= ~DEV_RX_OFFLOAD_CHECKSUM; 2080 else { 2081 printf("Unknown parameter\n"); 2082 return; 2083 } 2084 } else if (!strcmp(res->name, "rx-timestamp")) { 2085 if (!strcmp(res->value, "on")) 2086 rx_offloads |= DEV_RX_OFFLOAD_TIMESTAMP; 2087 else if (!strcmp(res->value, "off")) 2088 rx_offloads &= ~DEV_RX_OFFLOAD_TIMESTAMP; 2089 else { 2090 printf("Unknown parameter\n"); 2091 return; 2092 } 2093 } else if (!strcmp(res->name, "hw-vlan")) { 2094 if (!strcmp(res->value, "on")) { 2095 rx_offloads |= (DEV_RX_OFFLOAD_VLAN_FILTER | 2096 DEV_RX_OFFLOAD_VLAN_STRIP); 2097 } else if (!strcmp(res->value, "off")) { 2098 rx_offloads &= ~(DEV_RX_OFFLOAD_VLAN_FILTER | 2099 DEV_RX_OFFLOAD_VLAN_STRIP); 2100 } else { 2101 printf("Unknown parameter\n"); 2102 return; 2103 } 2104 } else if (!strcmp(res->name, "hw-vlan-filter")) { 2105 if (!strcmp(res->value, "on")) 2106 rx_offloads |= DEV_RX_OFFLOAD_VLAN_FILTER; 2107 else if (!strcmp(res->value, "off")) 2108 rx_offloads &= ~DEV_RX_OFFLOAD_VLAN_FILTER; 2109 else { 2110 printf("Unknown parameter\n"); 2111 return; 2112 } 2113 } else if (!strcmp(res->name, "hw-vlan-strip")) { 2114 if (!strcmp(res->value, "on")) 2115 rx_offloads |= DEV_RX_OFFLOAD_VLAN_STRIP; 2116 else if (!strcmp(res->value, "off")) 2117 rx_offloads &= ~DEV_RX_OFFLOAD_VLAN_STRIP; 2118 else { 2119 printf("Unknown parameter\n"); 2120 return; 2121 } 2122 } else if (!strcmp(res->name, "hw-vlan-extend")) { 2123 if (!strcmp(res->value, "on")) 2124 rx_offloads |= DEV_RX_OFFLOAD_VLAN_EXTEND; 2125 else if (!strcmp(res->value, "off")) 2126 rx_offloads &= ~DEV_RX_OFFLOAD_VLAN_EXTEND; 2127 else { 2128 printf("Unknown parameter\n"); 2129 return; 2130 } 2131 } else if (!strcmp(res->name, "drop-en")) { 2132 if (!strcmp(res->value, "on")) 2133 rx_drop_en = 1; 2134 else if (!strcmp(res->value, "off")) 2135 rx_drop_en = 0; 2136 else { 2137 printf("Unknown parameter\n"); 2138 return; 2139 } 2140 } else { 2141 printf("Unknown parameter\n"); 2142 return; 2143 } 2144 port->dev_conf.rxmode.offloads = rx_offloads; 2145 } 2146 2147 init_port_config(); 2148 2149 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1); 2150 } 2151 2152 cmdline_parse_token_string_t cmd_config_rx_mode_flag_port = 2153 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_mode_flag, port, "port"); 2154 cmdline_parse_token_string_t cmd_config_rx_mode_flag_keyword = 2155 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_mode_flag, keyword, 2156 "config"); 2157 cmdline_parse_token_string_t cmd_config_rx_mode_flag_all = 2158 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_mode_flag, all, "all"); 2159 cmdline_parse_token_string_t cmd_config_rx_mode_flag_name = 2160 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_mode_flag, name, 2161 "crc-strip#scatter#rx-cksum#rx-timestamp#hw-vlan#" 2162 "hw-vlan-filter#hw-vlan-strip#hw-vlan-extend"); 2163 cmdline_parse_token_string_t cmd_config_rx_mode_flag_value = 2164 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_mode_flag, value, 2165 "on#off"); 2166 2167 cmdline_parse_inst_t cmd_config_rx_mode_flag = { 2168 .f = cmd_config_rx_mode_flag_parsed, 2169 .data = NULL, 2170 .help_str = "port config all crc-strip|scatter|rx-cksum|rx-timestamp|hw-vlan|" 2171 "hw-vlan-filter|hw-vlan-strip|hw-vlan-extend on|off", 2172 .tokens = { 2173 (void *)&cmd_config_rx_mode_flag_port, 2174 (void *)&cmd_config_rx_mode_flag_keyword, 2175 (void *)&cmd_config_rx_mode_flag_all, 2176 (void *)&cmd_config_rx_mode_flag_name, 2177 (void *)&cmd_config_rx_mode_flag_value, 2178 NULL, 2179 }, 2180 }; 2181 2182 /* *** configure rss *** */ 2183 struct cmd_config_rss { 2184 cmdline_fixed_string_t port; 2185 cmdline_fixed_string_t keyword; 2186 cmdline_fixed_string_t all; 2187 cmdline_fixed_string_t name; 2188 cmdline_fixed_string_t value; 2189 }; 2190 2191 static void 2192 cmd_config_rss_parsed(void *parsed_result, 2193 __attribute__((unused)) struct cmdline *cl, 2194 __attribute__((unused)) void *data) 2195 { 2196 struct cmd_config_rss *res = parsed_result; 2197 struct rte_eth_rss_conf rss_conf = { .rss_key_len = 0, }; 2198 struct rte_eth_dev_info dev_info = { .flow_type_rss_offloads = 0, }; 2199 int use_default = 0; 2200 int all_updated = 1; 2201 int diag; 2202 uint16_t i; 2203 2204 if (!strcmp(res->value, "all")) 2205 rss_conf.rss_hf = ETH_RSS_IP | ETH_RSS_TCP | 2206 ETH_RSS_UDP | ETH_RSS_SCTP | 2207 ETH_RSS_L2_PAYLOAD; 2208 else if (!strcmp(res->value, "ip")) 2209 rss_conf.rss_hf = ETH_RSS_IP; 2210 else if (!strcmp(res->value, "udp")) 2211 rss_conf.rss_hf = ETH_RSS_UDP; 2212 else if (!strcmp(res->value, "tcp")) 2213 rss_conf.rss_hf = ETH_RSS_TCP; 2214 else if (!strcmp(res->value, "sctp")) 2215 rss_conf.rss_hf = ETH_RSS_SCTP; 2216 else if (!strcmp(res->value, "ether")) 2217 rss_conf.rss_hf = ETH_RSS_L2_PAYLOAD; 2218 else if (!strcmp(res->value, "port")) 2219 rss_conf.rss_hf = ETH_RSS_PORT; 2220 else if (!strcmp(res->value, "vxlan")) 2221 rss_conf.rss_hf = ETH_RSS_VXLAN; 2222 else if (!strcmp(res->value, "geneve")) 2223 rss_conf.rss_hf = ETH_RSS_GENEVE; 2224 else if (!strcmp(res->value, "nvgre")) 2225 rss_conf.rss_hf = ETH_RSS_NVGRE; 2226 else if (!strcmp(res->value, "none")) 2227 rss_conf.rss_hf = 0; 2228 else if (!strcmp(res->value, "default")) 2229 use_default = 1; 2230 else if (isdigit(res->value[0]) && atoi(res->value) > 0 && 2231 atoi(res->value) < 64) 2232 rss_conf.rss_hf = 1ULL << atoi(res->value); 2233 else { 2234 printf("Unknown parameter\n"); 2235 return; 2236 } 2237 rss_conf.rss_key = NULL; 2238 /* Update global configuration for RSS types. */ 2239 RTE_ETH_FOREACH_DEV(i) { 2240 struct rte_eth_rss_conf local_rss_conf; 2241 2242 rte_eth_dev_info_get(i, &dev_info); 2243 if (use_default) 2244 rss_conf.rss_hf = dev_info.flow_type_rss_offloads; 2245 2246 local_rss_conf = rss_conf; 2247 local_rss_conf.rss_hf = rss_conf.rss_hf & 2248 dev_info.flow_type_rss_offloads; 2249 if (local_rss_conf.rss_hf != rss_conf.rss_hf) { 2250 printf("Port %u modified RSS hash function based on hardware support," 2251 "requested:%#"PRIx64" configured:%#"PRIx64"\n", 2252 i, rss_conf.rss_hf, local_rss_conf.rss_hf); 2253 } 2254 diag = rte_eth_dev_rss_hash_update(i, &local_rss_conf); 2255 if (diag < 0) { 2256 all_updated = 0; 2257 printf("Configuration of RSS hash at ethernet port %d " 2258 "failed with error (%d): %s.\n", 2259 i, -diag, strerror(-diag)); 2260 } 2261 } 2262 if (all_updated && !use_default) 2263 rss_hf = rss_conf.rss_hf; 2264 } 2265 2266 cmdline_parse_token_string_t cmd_config_rss_port = 2267 TOKEN_STRING_INITIALIZER(struct cmd_config_rss, port, "port"); 2268 cmdline_parse_token_string_t cmd_config_rss_keyword = 2269 TOKEN_STRING_INITIALIZER(struct cmd_config_rss, keyword, "config"); 2270 cmdline_parse_token_string_t cmd_config_rss_all = 2271 TOKEN_STRING_INITIALIZER(struct cmd_config_rss, all, "all"); 2272 cmdline_parse_token_string_t cmd_config_rss_name = 2273 TOKEN_STRING_INITIALIZER(struct cmd_config_rss, name, "rss"); 2274 cmdline_parse_token_string_t cmd_config_rss_value = 2275 TOKEN_STRING_INITIALIZER(struct cmd_config_rss, value, NULL); 2276 2277 cmdline_parse_inst_t cmd_config_rss = { 2278 .f = cmd_config_rss_parsed, 2279 .data = NULL, 2280 .help_str = "port config all rss " 2281 "all|default|ip|tcp|udp|sctp|ether|port|vxlan|geneve|nvgre|none|<flowtype_id>", 2282 .tokens = { 2283 (void *)&cmd_config_rss_port, 2284 (void *)&cmd_config_rss_keyword, 2285 (void *)&cmd_config_rss_all, 2286 (void *)&cmd_config_rss_name, 2287 (void *)&cmd_config_rss_value, 2288 NULL, 2289 }, 2290 }; 2291 2292 /* *** configure rss hash key *** */ 2293 struct cmd_config_rss_hash_key { 2294 cmdline_fixed_string_t port; 2295 cmdline_fixed_string_t config; 2296 portid_t port_id; 2297 cmdline_fixed_string_t rss_hash_key; 2298 cmdline_fixed_string_t rss_type; 2299 cmdline_fixed_string_t key; 2300 }; 2301 2302 static uint8_t 2303 hexa_digit_to_value(char hexa_digit) 2304 { 2305 if ((hexa_digit >= '0') && (hexa_digit <= '9')) 2306 return (uint8_t) (hexa_digit - '0'); 2307 if ((hexa_digit >= 'a') && (hexa_digit <= 'f')) 2308 return (uint8_t) ((hexa_digit - 'a') + 10); 2309 if ((hexa_digit >= 'A') && (hexa_digit <= 'F')) 2310 return (uint8_t) ((hexa_digit - 'A') + 10); 2311 /* Invalid hexa digit */ 2312 return 0xFF; 2313 } 2314 2315 static uint8_t 2316 parse_and_check_key_hexa_digit(char *key, int idx) 2317 { 2318 uint8_t hexa_v; 2319 2320 hexa_v = hexa_digit_to_value(key[idx]); 2321 if (hexa_v == 0xFF) 2322 printf("invalid key: character %c at position %d is not a " 2323 "valid hexa digit\n", key[idx], idx); 2324 return hexa_v; 2325 } 2326 2327 static void 2328 cmd_config_rss_hash_key_parsed(void *parsed_result, 2329 __attribute__((unused)) struct cmdline *cl, 2330 __attribute__((unused)) void *data) 2331 { 2332 struct cmd_config_rss_hash_key *res = parsed_result; 2333 uint8_t hash_key[RSS_HASH_KEY_LENGTH]; 2334 uint8_t xdgt0; 2335 uint8_t xdgt1; 2336 int i; 2337 struct rte_eth_dev_info dev_info; 2338 uint8_t hash_key_size; 2339 uint32_t key_len; 2340 2341 memset(&dev_info, 0, sizeof(dev_info)); 2342 rte_eth_dev_info_get(res->port_id, &dev_info); 2343 if (dev_info.hash_key_size > 0 && 2344 dev_info.hash_key_size <= sizeof(hash_key)) 2345 hash_key_size = dev_info.hash_key_size; 2346 else { 2347 printf("dev_info did not provide a valid hash key size\n"); 2348 return; 2349 } 2350 /* Check the length of the RSS hash key */ 2351 key_len = strlen(res->key); 2352 if (key_len != (hash_key_size * 2)) { 2353 printf("key length: %d invalid - key must be a string of %d" 2354 " hexa-decimal numbers\n", 2355 (int) key_len, hash_key_size * 2); 2356 return; 2357 } 2358 /* Translate RSS hash key into binary representation */ 2359 for (i = 0; i < hash_key_size; i++) { 2360 xdgt0 = parse_and_check_key_hexa_digit(res->key, (i * 2)); 2361 if (xdgt0 == 0xFF) 2362 return; 2363 xdgt1 = parse_and_check_key_hexa_digit(res->key, (i * 2) + 1); 2364 if (xdgt1 == 0xFF) 2365 return; 2366 hash_key[i] = (uint8_t) ((xdgt0 * 16) + xdgt1); 2367 } 2368 port_rss_hash_key_update(res->port_id, res->rss_type, hash_key, 2369 hash_key_size); 2370 } 2371 2372 cmdline_parse_token_string_t cmd_config_rss_hash_key_port = 2373 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_hash_key, port, "port"); 2374 cmdline_parse_token_string_t cmd_config_rss_hash_key_config = 2375 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_hash_key, config, 2376 "config"); 2377 cmdline_parse_token_num_t cmd_config_rss_hash_key_port_id = 2378 TOKEN_NUM_INITIALIZER(struct cmd_config_rss_hash_key, port_id, UINT16); 2379 cmdline_parse_token_string_t cmd_config_rss_hash_key_rss_hash_key = 2380 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_hash_key, 2381 rss_hash_key, "rss-hash-key"); 2382 cmdline_parse_token_string_t cmd_config_rss_hash_key_rss_type = 2383 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_hash_key, rss_type, 2384 "ipv4#ipv4-frag#ipv4-tcp#ipv4-udp#ipv4-sctp#" 2385 "ipv4-other#ipv6#ipv6-frag#ipv6-tcp#ipv6-udp#" 2386 "ipv6-sctp#ipv6-other#l2-payload#ipv6-ex#" 2387 "ipv6-tcp-ex#ipv6-udp-ex"); 2388 cmdline_parse_token_string_t cmd_config_rss_hash_key_value = 2389 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_hash_key, key, NULL); 2390 2391 cmdline_parse_inst_t cmd_config_rss_hash_key = { 2392 .f = cmd_config_rss_hash_key_parsed, 2393 .data = NULL, 2394 .help_str = "port config <port_id> rss-hash-key " 2395 "ipv4|ipv4-frag|ipv4-tcp|ipv4-udp|ipv4-sctp|ipv4-other|" 2396 "ipv6|ipv6-frag|ipv6-tcp|ipv6-udp|ipv6-sctp|ipv6-other|" 2397 "l2-payload|ipv6-ex|ipv6-tcp-ex|ipv6-udp-ex " 2398 "<string of hex digits (variable length, NIC dependent)>", 2399 .tokens = { 2400 (void *)&cmd_config_rss_hash_key_port, 2401 (void *)&cmd_config_rss_hash_key_config, 2402 (void *)&cmd_config_rss_hash_key_port_id, 2403 (void *)&cmd_config_rss_hash_key_rss_hash_key, 2404 (void *)&cmd_config_rss_hash_key_rss_type, 2405 (void *)&cmd_config_rss_hash_key_value, 2406 NULL, 2407 }, 2408 }; 2409 2410 /* *** configure port rxq/txq ring size *** */ 2411 struct cmd_config_rxtx_ring_size { 2412 cmdline_fixed_string_t port; 2413 cmdline_fixed_string_t config; 2414 portid_t portid; 2415 cmdline_fixed_string_t rxtxq; 2416 uint16_t qid; 2417 cmdline_fixed_string_t rsize; 2418 uint16_t size; 2419 }; 2420 2421 static void 2422 cmd_config_rxtx_ring_size_parsed(void *parsed_result, 2423 __attribute__((unused)) struct cmdline *cl, 2424 __attribute__((unused)) void *data) 2425 { 2426 struct cmd_config_rxtx_ring_size *res = parsed_result; 2427 struct rte_port *port; 2428 uint8_t isrx; 2429 2430 if (port_id_is_invalid(res->portid, ENABLED_WARN)) 2431 return; 2432 2433 if (res->portid == (portid_t)RTE_PORT_ALL) { 2434 printf("Invalid port id\n"); 2435 return; 2436 } 2437 2438 port = &ports[res->portid]; 2439 2440 if (!strcmp(res->rxtxq, "rxq")) 2441 isrx = 1; 2442 else if (!strcmp(res->rxtxq, "txq")) 2443 isrx = 0; 2444 else { 2445 printf("Unknown parameter\n"); 2446 return; 2447 } 2448 2449 if (isrx && rx_queue_id_is_invalid(res->qid)) 2450 return; 2451 else if (!isrx && tx_queue_id_is_invalid(res->qid)) 2452 return; 2453 2454 if (isrx && res->size != 0 && res->size <= rx_free_thresh) { 2455 printf("Invalid rx ring_size, must > rx_free_thresh: %d\n", 2456 rx_free_thresh); 2457 return; 2458 } 2459 2460 if (isrx) 2461 port->nb_rx_desc[res->qid] = res->size; 2462 else 2463 port->nb_tx_desc[res->qid] = res->size; 2464 2465 cmd_reconfig_device_queue(res->portid, 0, 1); 2466 } 2467 2468 cmdline_parse_token_string_t cmd_config_rxtx_ring_size_port = 2469 TOKEN_STRING_INITIALIZER(struct cmd_config_rxtx_ring_size, 2470 port, "port"); 2471 cmdline_parse_token_string_t cmd_config_rxtx_ring_size_config = 2472 TOKEN_STRING_INITIALIZER(struct cmd_config_rxtx_ring_size, 2473 config, "config"); 2474 cmdline_parse_token_num_t cmd_config_rxtx_ring_size_portid = 2475 TOKEN_NUM_INITIALIZER(struct cmd_config_rxtx_ring_size, 2476 portid, UINT16); 2477 cmdline_parse_token_string_t cmd_config_rxtx_ring_size_rxtxq = 2478 TOKEN_STRING_INITIALIZER(struct cmd_config_rxtx_ring_size, 2479 rxtxq, "rxq#txq"); 2480 cmdline_parse_token_num_t cmd_config_rxtx_ring_size_qid = 2481 TOKEN_NUM_INITIALIZER(struct cmd_config_rxtx_ring_size, 2482 qid, UINT16); 2483 cmdline_parse_token_string_t cmd_config_rxtx_ring_size_rsize = 2484 TOKEN_STRING_INITIALIZER(struct cmd_config_rxtx_ring_size, 2485 rsize, "ring_size"); 2486 cmdline_parse_token_num_t cmd_config_rxtx_ring_size_size = 2487 TOKEN_NUM_INITIALIZER(struct cmd_config_rxtx_ring_size, 2488 size, UINT16); 2489 2490 cmdline_parse_inst_t cmd_config_rxtx_ring_size = { 2491 .f = cmd_config_rxtx_ring_size_parsed, 2492 .data = NULL, 2493 .help_str = "port config <port_id> rxq|txq <queue_id> ring_size <value>", 2494 .tokens = { 2495 (void *)&cmd_config_rxtx_ring_size_port, 2496 (void *)&cmd_config_rxtx_ring_size_config, 2497 (void *)&cmd_config_rxtx_ring_size_portid, 2498 (void *)&cmd_config_rxtx_ring_size_rxtxq, 2499 (void *)&cmd_config_rxtx_ring_size_qid, 2500 (void *)&cmd_config_rxtx_ring_size_rsize, 2501 (void *)&cmd_config_rxtx_ring_size_size, 2502 NULL, 2503 }, 2504 }; 2505 2506 /* *** configure port rxq/txq start/stop *** */ 2507 struct cmd_config_rxtx_queue { 2508 cmdline_fixed_string_t port; 2509 portid_t portid; 2510 cmdline_fixed_string_t rxtxq; 2511 uint16_t qid; 2512 cmdline_fixed_string_t opname; 2513 }; 2514 2515 static void 2516 cmd_config_rxtx_queue_parsed(void *parsed_result, 2517 __attribute__((unused)) struct cmdline *cl, 2518 __attribute__((unused)) void *data) 2519 { 2520 struct cmd_config_rxtx_queue *res = parsed_result; 2521 uint8_t isrx; 2522 uint8_t isstart; 2523 int ret = 0; 2524 2525 if (test_done == 0) { 2526 printf("Please stop forwarding first\n"); 2527 return; 2528 } 2529 2530 if (port_id_is_invalid(res->portid, ENABLED_WARN)) 2531 return; 2532 2533 if (port_is_started(res->portid) != 1) { 2534 printf("Please start port %u first\n", res->portid); 2535 return; 2536 } 2537 2538 if (!strcmp(res->rxtxq, "rxq")) 2539 isrx = 1; 2540 else if (!strcmp(res->rxtxq, "txq")) 2541 isrx = 0; 2542 else { 2543 printf("Unknown parameter\n"); 2544 return; 2545 } 2546 2547 if (isrx && rx_queue_id_is_invalid(res->qid)) 2548 return; 2549 else if (!isrx && tx_queue_id_is_invalid(res->qid)) 2550 return; 2551 2552 if (!strcmp(res->opname, "start")) 2553 isstart = 1; 2554 else if (!strcmp(res->opname, "stop")) 2555 isstart = 0; 2556 else { 2557 printf("Unknown parameter\n"); 2558 return; 2559 } 2560 2561 if (isstart && isrx) 2562 ret = rte_eth_dev_rx_queue_start(res->portid, res->qid); 2563 else if (!isstart && isrx) 2564 ret = rte_eth_dev_rx_queue_stop(res->portid, res->qid); 2565 else if (isstart && !isrx) 2566 ret = rte_eth_dev_tx_queue_start(res->portid, res->qid); 2567 else 2568 ret = rte_eth_dev_tx_queue_stop(res->portid, res->qid); 2569 2570 if (ret == -ENOTSUP) 2571 printf("Function not supported in PMD driver\n"); 2572 } 2573 2574 cmdline_parse_token_string_t cmd_config_rxtx_queue_port = 2575 TOKEN_STRING_INITIALIZER(struct cmd_config_rxtx_queue, port, "port"); 2576 cmdline_parse_token_num_t cmd_config_rxtx_queue_portid = 2577 TOKEN_NUM_INITIALIZER(struct cmd_config_rxtx_queue, portid, UINT16); 2578 cmdline_parse_token_string_t cmd_config_rxtx_queue_rxtxq = 2579 TOKEN_STRING_INITIALIZER(struct cmd_config_rxtx_queue, rxtxq, "rxq#txq"); 2580 cmdline_parse_token_num_t cmd_config_rxtx_queue_qid = 2581 TOKEN_NUM_INITIALIZER(struct cmd_config_rxtx_queue, qid, UINT16); 2582 cmdline_parse_token_string_t cmd_config_rxtx_queue_opname = 2583 TOKEN_STRING_INITIALIZER(struct cmd_config_rxtx_queue, opname, 2584 "start#stop"); 2585 2586 cmdline_parse_inst_t cmd_config_rxtx_queue = { 2587 .f = cmd_config_rxtx_queue_parsed, 2588 .data = NULL, 2589 .help_str = "port <port_id> rxq|txq <queue_id> start|stop", 2590 .tokens = { 2591 (void *)&cmd_config_rxtx_queue_port, 2592 (void *)&cmd_config_rxtx_queue_portid, 2593 (void *)&cmd_config_rxtx_queue_rxtxq, 2594 (void *)&cmd_config_rxtx_queue_qid, 2595 (void *)&cmd_config_rxtx_queue_opname, 2596 NULL, 2597 }, 2598 }; 2599 2600 /* *** configure port rxq/txq deferred start on/off *** */ 2601 struct cmd_config_deferred_start_rxtx_queue { 2602 cmdline_fixed_string_t port; 2603 portid_t port_id; 2604 cmdline_fixed_string_t rxtxq; 2605 uint16_t qid; 2606 cmdline_fixed_string_t opname; 2607 cmdline_fixed_string_t state; 2608 }; 2609 2610 static void 2611 cmd_config_deferred_start_rxtx_queue_parsed(void *parsed_result, 2612 __attribute__((unused)) struct cmdline *cl, 2613 __attribute__((unused)) void *data) 2614 { 2615 struct cmd_config_deferred_start_rxtx_queue *res = parsed_result; 2616 struct rte_port *port; 2617 uint8_t isrx; 2618 uint8_t ison; 2619 uint8_t needreconfig = 0; 2620 2621 if (port_id_is_invalid(res->port_id, ENABLED_WARN)) 2622 return; 2623 2624 if (port_is_started(res->port_id) != 0) { 2625 printf("Please stop port %u first\n", res->port_id); 2626 return; 2627 } 2628 2629 port = &ports[res->port_id]; 2630 2631 isrx = !strcmp(res->rxtxq, "rxq"); 2632 2633 if (isrx && rx_queue_id_is_invalid(res->qid)) 2634 return; 2635 else if (!isrx && tx_queue_id_is_invalid(res->qid)) 2636 return; 2637 2638 ison = !strcmp(res->state, "on"); 2639 2640 if (isrx && port->rx_conf[res->qid].rx_deferred_start != ison) { 2641 port->rx_conf[res->qid].rx_deferred_start = ison; 2642 needreconfig = 1; 2643 } else if (!isrx && port->tx_conf[res->qid].tx_deferred_start != ison) { 2644 port->tx_conf[res->qid].tx_deferred_start = ison; 2645 needreconfig = 1; 2646 } 2647 2648 if (needreconfig) 2649 cmd_reconfig_device_queue(res->port_id, 0, 1); 2650 } 2651 2652 cmdline_parse_token_string_t cmd_config_deferred_start_rxtx_queue_port = 2653 TOKEN_STRING_INITIALIZER(struct cmd_config_deferred_start_rxtx_queue, 2654 port, "port"); 2655 cmdline_parse_token_num_t cmd_config_deferred_start_rxtx_queue_port_id = 2656 TOKEN_NUM_INITIALIZER(struct cmd_config_deferred_start_rxtx_queue, 2657 port_id, UINT16); 2658 cmdline_parse_token_string_t cmd_config_deferred_start_rxtx_queue_rxtxq = 2659 TOKEN_STRING_INITIALIZER(struct cmd_config_deferred_start_rxtx_queue, 2660 rxtxq, "rxq#txq"); 2661 cmdline_parse_token_num_t cmd_config_deferred_start_rxtx_queue_qid = 2662 TOKEN_NUM_INITIALIZER(struct cmd_config_deferred_start_rxtx_queue, 2663 qid, UINT16); 2664 cmdline_parse_token_string_t cmd_config_deferred_start_rxtx_queue_opname = 2665 TOKEN_STRING_INITIALIZER(struct cmd_config_deferred_start_rxtx_queue, 2666 opname, "deferred_start"); 2667 cmdline_parse_token_string_t cmd_config_deferred_start_rxtx_queue_state = 2668 TOKEN_STRING_INITIALIZER(struct cmd_config_deferred_start_rxtx_queue, 2669 state, "on#off"); 2670 2671 cmdline_parse_inst_t cmd_config_deferred_start_rxtx_queue = { 2672 .f = cmd_config_deferred_start_rxtx_queue_parsed, 2673 .data = NULL, 2674 .help_str = "port <port_id> rxq|txq <queue_id> deferred_start on|off", 2675 .tokens = { 2676 (void *)&cmd_config_deferred_start_rxtx_queue_port, 2677 (void *)&cmd_config_deferred_start_rxtx_queue_port_id, 2678 (void *)&cmd_config_deferred_start_rxtx_queue_rxtxq, 2679 (void *)&cmd_config_deferred_start_rxtx_queue_qid, 2680 (void *)&cmd_config_deferred_start_rxtx_queue_opname, 2681 (void *)&cmd_config_deferred_start_rxtx_queue_state, 2682 NULL, 2683 }, 2684 }; 2685 2686 /* *** configure port rxq/txq setup *** */ 2687 struct cmd_setup_rxtx_queue { 2688 cmdline_fixed_string_t port; 2689 portid_t portid; 2690 cmdline_fixed_string_t rxtxq; 2691 uint16_t qid; 2692 cmdline_fixed_string_t setup; 2693 }; 2694 2695 /* Common CLI fields for queue setup */ 2696 cmdline_parse_token_string_t cmd_setup_rxtx_queue_port = 2697 TOKEN_STRING_INITIALIZER(struct cmd_setup_rxtx_queue, port, "port"); 2698 cmdline_parse_token_num_t cmd_setup_rxtx_queue_portid = 2699 TOKEN_NUM_INITIALIZER(struct cmd_setup_rxtx_queue, portid, UINT16); 2700 cmdline_parse_token_string_t cmd_setup_rxtx_queue_rxtxq = 2701 TOKEN_STRING_INITIALIZER(struct cmd_setup_rxtx_queue, rxtxq, "rxq#txq"); 2702 cmdline_parse_token_num_t cmd_setup_rxtx_queue_qid = 2703 TOKEN_NUM_INITIALIZER(struct cmd_setup_rxtx_queue, qid, UINT16); 2704 cmdline_parse_token_string_t cmd_setup_rxtx_queue_setup = 2705 TOKEN_STRING_INITIALIZER(struct cmd_setup_rxtx_queue, setup, "setup"); 2706 2707 static void 2708 cmd_setup_rxtx_queue_parsed( 2709 void *parsed_result, 2710 __attribute__((unused)) struct cmdline *cl, 2711 __attribute__((unused)) void *data) 2712 { 2713 struct cmd_setup_rxtx_queue *res = parsed_result; 2714 struct rte_port *port; 2715 struct rte_mempool *mp; 2716 unsigned int socket_id; 2717 uint8_t isrx = 0; 2718 int ret; 2719 2720 if (port_id_is_invalid(res->portid, ENABLED_WARN)) 2721 return; 2722 2723 if (res->portid == (portid_t)RTE_PORT_ALL) { 2724 printf("Invalid port id\n"); 2725 return; 2726 } 2727 2728 if (!strcmp(res->rxtxq, "rxq")) 2729 isrx = 1; 2730 else if (!strcmp(res->rxtxq, "txq")) 2731 isrx = 0; 2732 else { 2733 printf("Unknown parameter\n"); 2734 return; 2735 } 2736 2737 if (isrx && rx_queue_id_is_invalid(res->qid)) { 2738 printf("Invalid rx queue\n"); 2739 return; 2740 } else if (!isrx && tx_queue_id_is_invalid(res->qid)) { 2741 printf("Invalid tx queue\n"); 2742 return; 2743 } 2744 2745 port = &ports[res->portid]; 2746 if (isrx) { 2747 socket_id = rxring_numa[res->portid]; 2748 if (!numa_support || socket_id == NUMA_NO_CONFIG) 2749 socket_id = port->socket_id; 2750 2751 mp = mbuf_pool_find(socket_id); 2752 if (mp == NULL) { 2753 printf("Failed to setup RX queue: " 2754 "No mempool allocation" 2755 " on the socket %d\n", 2756 rxring_numa[res->portid]); 2757 return; 2758 } 2759 ret = rte_eth_rx_queue_setup(res->portid, 2760 res->qid, 2761 port->nb_rx_desc[res->qid], 2762 socket_id, 2763 &port->rx_conf[res->qid], 2764 mp); 2765 if (ret) 2766 printf("Failed to setup RX queue\n"); 2767 } else { 2768 socket_id = txring_numa[res->portid]; 2769 if (!numa_support || socket_id == NUMA_NO_CONFIG) 2770 socket_id = port->socket_id; 2771 2772 ret = rte_eth_tx_queue_setup(res->portid, 2773 res->qid, 2774 port->nb_tx_desc[res->qid], 2775 socket_id, 2776 &port->tx_conf[res->qid]); 2777 if (ret) 2778 printf("Failed to setup TX queue\n"); 2779 } 2780 } 2781 2782 cmdline_parse_inst_t cmd_setup_rxtx_queue = { 2783 .f = cmd_setup_rxtx_queue_parsed, 2784 .data = NULL, 2785 .help_str = "port <port_id> rxq|txq <queue_idx> setup", 2786 .tokens = { 2787 (void *)&cmd_setup_rxtx_queue_port, 2788 (void *)&cmd_setup_rxtx_queue_portid, 2789 (void *)&cmd_setup_rxtx_queue_rxtxq, 2790 (void *)&cmd_setup_rxtx_queue_qid, 2791 (void *)&cmd_setup_rxtx_queue_setup, 2792 NULL, 2793 }, 2794 }; 2795 2796 2797 /* *** Configure RSS RETA *** */ 2798 struct cmd_config_rss_reta { 2799 cmdline_fixed_string_t port; 2800 cmdline_fixed_string_t keyword; 2801 portid_t port_id; 2802 cmdline_fixed_string_t name; 2803 cmdline_fixed_string_t list_name; 2804 cmdline_fixed_string_t list_of_items; 2805 }; 2806 2807 static int 2808 parse_reta_config(const char *str, 2809 struct rte_eth_rss_reta_entry64 *reta_conf, 2810 uint16_t nb_entries) 2811 { 2812 int i; 2813 unsigned size; 2814 uint16_t hash_index, idx, shift; 2815 uint16_t nb_queue; 2816 char s[256]; 2817 const char *p, *p0 = str; 2818 char *end; 2819 enum fieldnames { 2820 FLD_HASH_INDEX = 0, 2821 FLD_QUEUE, 2822 _NUM_FLD 2823 }; 2824 unsigned long int_fld[_NUM_FLD]; 2825 char *str_fld[_NUM_FLD]; 2826 2827 while ((p = strchr(p0,'(')) != NULL) { 2828 ++p; 2829 if((p0 = strchr(p,')')) == NULL) 2830 return -1; 2831 2832 size = p0 - p; 2833 if(size >= sizeof(s)) 2834 return -1; 2835 2836 snprintf(s, sizeof(s), "%.*s", size, p); 2837 if (rte_strsplit(s, sizeof(s), str_fld, _NUM_FLD, ',') != _NUM_FLD) 2838 return -1; 2839 for (i = 0; i < _NUM_FLD; i++) { 2840 errno = 0; 2841 int_fld[i] = strtoul(str_fld[i], &end, 0); 2842 if (errno != 0 || end == str_fld[i] || 2843 int_fld[i] > 65535) 2844 return -1; 2845 } 2846 2847 hash_index = (uint16_t)int_fld[FLD_HASH_INDEX]; 2848 nb_queue = (uint16_t)int_fld[FLD_QUEUE]; 2849 2850 if (hash_index >= nb_entries) { 2851 printf("Invalid RETA hash index=%d\n", hash_index); 2852 return -1; 2853 } 2854 2855 idx = hash_index / RTE_RETA_GROUP_SIZE; 2856 shift = hash_index % RTE_RETA_GROUP_SIZE; 2857 reta_conf[idx].mask |= (1ULL << shift); 2858 reta_conf[idx].reta[shift] = nb_queue; 2859 } 2860 2861 return 0; 2862 } 2863 2864 static void 2865 cmd_set_rss_reta_parsed(void *parsed_result, 2866 __attribute__((unused)) struct cmdline *cl, 2867 __attribute__((unused)) void *data) 2868 { 2869 int ret; 2870 struct rte_eth_dev_info dev_info; 2871 struct rte_eth_rss_reta_entry64 reta_conf[8]; 2872 struct cmd_config_rss_reta *res = parsed_result; 2873 2874 memset(&dev_info, 0, sizeof(dev_info)); 2875 rte_eth_dev_info_get(res->port_id, &dev_info); 2876 if (dev_info.reta_size == 0) { 2877 printf("Redirection table size is 0 which is " 2878 "invalid for RSS\n"); 2879 return; 2880 } else 2881 printf("The reta size of port %d is %u\n", 2882 res->port_id, dev_info.reta_size); 2883 if (dev_info.reta_size > ETH_RSS_RETA_SIZE_512) { 2884 printf("Currently do not support more than %u entries of " 2885 "redirection table\n", ETH_RSS_RETA_SIZE_512); 2886 return; 2887 } 2888 2889 memset(reta_conf, 0, sizeof(reta_conf)); 2890 if (!strcmp(res->list_name, "reta")) { 2891 if (parse_reta_config(res->list_of_items, reta_conf, 2892 dev_info.reta_size)) { 2893 printf("Invalid RSS Redirection Table " 2894 "config entered\n"); 2895 return; 2896 } 2897 ret = rte_eth_dev_rss_reta_update(res->port_id, 2898 reta_conf, dev_info.reta_size); 2899 if (ret != 0) 2900 printf("Bad redirection table parameter, " 2901 "return code = %d \n", ret); 2902 } 2903 } 2904 2905 cmdline_parse_token_string_t cmd_config_rss_reta_port = 2906 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_reta, port, "port"); 2907 cmdline_parse_token_string_t cmd_config_rss_reta_keyword = 2908 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_reta, keyword, "config"); 2909 cmdline_parse_token_num_t cmd_config_rss_reta_port_id = 2910 TOKEN_NUM_INITIALIZER(struct cmd_config_rss_reta, port_id, UINT16); 2911 cmdline_parse_token_string_t cmd_config_rss_reta_name = 2912 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_reta, name, "rss"); 2913 cmdline_parse_token_string_t cmd_config_rss_reta_list_name = 2914 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_reta, list_name, "reta"); 2915 cmdline_parse_token_string_t cmd_config_rss_reta_list_of_items = 2916 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_reta, list_of_items, 2917 NULL); 2918 cmdline_parse_inst_t cmd_config_rss_reta = { 2919 .f = cmd_set_rss_reta_parsed, 2920 .data = NULL, 2921 .help_str = "port config <port_id> rss reta <hash,queue[,hash,queue]*>", 2922 .tokens = { 2923 (void *)&cmd_config_rss_reta_port, 2924 (void *)&cmd_config_rss_reta_keyword, 2925 (void *)&cmd_config_rss_reta_port_id, 2926 (void *)&cmd_config_rss_reta_name, 2927 (void *)&cmd_config_rss_reta_list_name, 2928 (void *)&cmd_config_rss_reta_list_of_items, 2929 NULL, 2930 }, 2931 }; 2932 2933 /* *** SHOW PORT RETA INFO *** */ 2934 struct cmd_showport_reta { 2935 cmdline_fixed_string_t show; 2936 cmdline_fixed_string_t port; 2937 portid_t port_id; 2938 cmdline_fixed_string_t rss; 2939 cmdline_fixed_string_t reta; 2940 uint16_t size; 2941 cmdline_fixed_string_t list_of_items; 2942 }; 2943 2944 static int 2945 showport_parse_reta_config(struct rte_eth_rss_reta_entry64 *conf, 2946 uint16_t nb_entries, 2947 char *str) 2948 { 2949 uint32_t size; 2950 const char *p, *p0 = str; 2951 char s[256]; 2952 char *end; 2953 char *str_fld[8]; 2954 uint16_t i; 2955 uint16_t num = (nb_entries + RTE_RETA_GROUP_SIZE - 1) / 2956 RTE_RETA_GROUP_SIZE; 2957 int ret; 2958 2959 p = strchr(p0, '('); 2960 if (p == NULL) 2961 return -1; 2962 p++; 2963 p0 = strchr(p, ')'); 2964 if (p0 == NULL) 2965 return -1; 2966 size = p0 - p; 2967 if (size >= sizeof(s)) { 2968 printf("The string size exceeds the internal buffer size\n"); 2969 return -1; 2970 } 2971 snprintf(s, sizeof(s), "%.*s", size, p); 2972 ret = rte_strsplit(s, sizeof(s), str_fld, num, ','); 2973 if (ret <= 0 || ret != num) { 2974 printf("The bits of masks do not match the number of " 2975 "reta entries: %u\n", num); 2976 return -1; 2977 } 2978 for (i = 0; i < ret; i++) 2979 conf[i].mask = (uint64_t)strtoul(str_fld[i], &end, 0); 2980 2981 return 0; 2982 } 2983 2984 static void 2985 cmd_showport_reta_parsed(void *parsed_result, 2986 __attribute__((unused)) struct cmdline *cl, 2987 __attribute__((unused)) void *data) 2988 { 2989 struct cmd_showport_reta *res = parsed_result; 2990 struct rte_eth_rss_reta_entry64 reta_conf[8]; 2991 struct rte_eth_dev_info dev_info; 2992 uint16_t max_reta_size; 2993 2994 memset(&dev_info, 0, sizeof(dev_info)); 2995 rte_eth_dev_info_get(res->port_id, &dev_info); 2996 max_reta_size = RTE_MIN(dev_info.reta_size, ETH_RSS_RETA_SIZE_512); 2997 if (res->size == 0 || res->size > max_reta_size) { 2998 printf("Invalid redirection table size: %u (1-%u)\n", 2999 res->size, max_reta_size); 3000 return; 3001 } 3002 3003 memset(reta_conf, 0, sizeof(reta_conf)); 3004 if (showport_parse_reta_config(reta_conf, res->size, 3005 res->list_of_items) < 0) { 3006 printf("Invalid string: %s for reta masks\n", 3007 res->list_of_items); 3008 return; 3009 } 3010 port_rss_reta_info(res->port_id, reta_conf, res->size); 3011 } 3012 3013 cmdline_parse_token_string_t cmd_showport_reta_show = 3014 TOKEN_STRING_INITIALIZER(struct cmd_showport_reta, show, "show"); 3015 cmdline_parse_token_string_t cmd_showport_reta_port = 3016 TOKEN_STRING_INITIALIZER(struct cmd_showport_reta, port, "port"); 3017 cmdline_parse_token_num_t cmd_showport_reta_port_id = 3018 TOKEN_NUM_INITIALIZER(struct cmd_showport_reta, port_id, UINT16); 3019 cmdline_parse_token_string_t cmd_showport_reta_rss = 3020 TOKEN_STRING_INITIALIZER(struct cmd_showport_reta, rss, "rss"); 3021 cmdline_parse_token_string_t cmd_showport_reta_reta = 3022 TOKEN_STRING_INITIALIZER(struct cmd_showport_reta, reta, "reta"); 3023 cmdline_parse_token_num_t cmd_showport_reta_size = 3024 TOKEN_NUM_INITIALIZER(struct cmd_showport_reta, size, UINT16); 3025 cmdline_parse_token_string_t cmd_showport_reta_list_of_items = 3026 TOKEN_STRING_INITIALIZER(struct cmd_showport_reta, 3027 list_of_items, NULL); 3028 3029 cmdline_parse_inst_t cmd_showport_reta = { 3030 .f = cmd_showport_reta_parsed, 3031 .data = NULL, 3032 .help_str = "show port <port_id> rss reta <size> <mask0[,mask1]*>", 3033 .tokens = { 3034 (void *)&cmd_showport_reta_show, 3035 (void *)&cmd_showport_reta_port, 3036 (void *)&cmd_showport_reta_port_id, 3037 (void *)&cmd_showport_reta_rss, 3038 (void *)&cmd_showport_reta_reta, 3039 (void *)&cmd_showport_reta_size, 3040 (void *)&cmd_showport_reta_list_of_items, 3041 NULL, 3042 }, 3043 }; 3044 3045 /* *** Show RSS hash configuration *** */ 3046 struct cmd_showport_rss_hash { 3047 cmdline_fixed_string_t show; 3048 cmdline_fixed_string_t port; 3049 portid_t port_id; 3050 cmdline_fixed_string_t rss_hash; 3051 cmdline_fixed_string_t rss_type; 3052 cmdline_fixed_string_t key; /* optional argument */ 3053 }; 3054 3055 static void cmd_showport_rss_hash_parsed(void *parsed_result, 3056 __attribute__((unused)) struct cmdline *cl, 3057 void *show_rss_key) 3058 { 3059 struct cmd_showport_rss_hash *res = parsed_result; 3060 3061 port_rss_hash_conf_show(res->port_id, show_rss_key != NULL); 3062 } 3063 3064 cmdline_parse_token_string_t cmd_showport_rss_hash_show = 3065 TOKEN_STRING_INITIALIZER(struct cmd_showport_rss_hash, show, "show"); 3066 cmdline_parse_token_string_t cmd_showport_rss_hash_port = 3067 TOKEN_STRING_INITIALIZER(struct cmd_showport_rss_hash, port, "port"); 3068 cmdline_parse_token_num_t cmd_showport_rss_hash_port_id = 3069 TOKEN_NUM_INITIALIZER(struct cmd_showport_rss_hash, port_id, UINT16); 3070 cmdline_parse_token_string_t cmd_showport_rss_hash_rss_hash = 3071 TOKEN_STRING_INITIALIZER(struct cmd_showport_rss_hash, rss_hash, 3072 "rss-hash"); 3073 cmdline_parse_token_string_t cmd_showport_rss_hash_rss_key = 3074 TOKEN_STRING_INITIALIZER(struct cmd_showport_rss_hash, key, "key"); 3075 3076 cmdline_parse_inst_t cmd_showport_rss_hash = { 3077 .f = cmd_showport_rss_hash_parsed, 3078 .data = NULL, 3079 .help_str = "show port <port_id> rss-hash", 3080 .tokens = { 3081 (void *)&cmd_showport_rss_hash_show, 3082 (void *)&cmd_showport_rss_hash_port, 3083 (void *)&cmd_showport_rss_hash_port_id, 3084 (void *)&cmd_showport_rss_hash_rss_hash, 3085 NULL, 3086 }, 3087 }; 3088 3089 cmdline_parse_inst_t cmd_showport_rss_hash_key = { 3090 .f = cmd_showport_rss_hash_parsed, 3091 .data = (void *)1, 3092 .help_str = "show port <port_id> rss-hash key", 3093 .tokens = { 3094 (void *)&cmd_showport_rss_hash_show, 3095 (void *)&cmd_showport_rss_hash_port, 3096 (void *)&cmd_showport_rss_hash_port_id, 3097 (void *)&cmd_showport_rss_hash_rss_hash, 3098 (void *)&cmd_showport_rss_hash_rss_key, 3099 NULL, 3100 }, 3101 }; 3102 3103 /* *** Configure DCB *** */ 3104 struct cmd_config_dcb { 3105 cmdline_fixed_string_t port; 3106 cmdline_fixed_string_t config; 3107 portid_t port_id; 3108 cmdline_fixed_string_t dcb; 3109 cmdline_fixed_string_t vt; 3110 cmdline_fixed_string_t vt_en; 3111 uint8_t num_tcs; 3112 cmdline_fixed_string_t pfc; 3113 cmdline_fixed_string_t pfc_en; 3114 }; 3115 3116 static void 3117 cmd_config_dcb_parsed(void *parsed_result, 3118 __attribute__((unused)) struct cmdline *cl, 3119 __attribute__((unused)) void *data) 3120 { 3121 struct cmd_config_dcb *res = parsed_result; 3122 portid_t port_id = res->port_id; 3123 struct rte_port *port; 3124 uint8_t pfc_en; 3125 int ret; 3126 3127 port = &ports[port_id]; 3128 /** Check if the port is not started **/ 3129 if (port->port_status != RTE_PORT_STOPPED) { 3130 printf("Please stop port %d first\n", port_id); 3131 return; 3132 } 3133 3134 if ((res->num_tcs != ETH_4_TCS) && (res->num_tcs != ETH_8_TCS)) { 3135 printf("The invalid number of traffic class," 3136 " only 4 or 8 allowed.\n"); 3137 return; 3138 } 3139 3140 if (nb_fwd_lcores < res->num_tcs) { 3141 printf("nb_cores shouldn't be less than number of TCs.\n"); 3142 return; 3143 } 3144 if (!strncmp(res->pfc_en, "on", 2)) 3145 pfc_en = 1; 3146 else 3147 pfc_en = 0; 3148 3149 /* DCB in VT mode */ 3150 if (!strncmp(res->vt_en, "on", 2)) 3151 ret = init_port_dcb_config(port_id, DCB_VT_ENABLED, 3152 (enum rte_eth_nb_tcs)res->num_tcs, 3153 pfc_en); 3154 else 3155 ret = init_port_dcb_config(port_id, DCB_ENABLED, 3156 (enum rte_eth_nb_tcs)res->num_tcs, 3157 pfc_en); 3158 3159 3160 if (ret != 0) { 3161 printf("Cannot initialize network ports.\n"); 3162 return; 3163 } 3164 3165 cmd_reconfig_device_queue(port_id, 1, 1); 3166 } 3167 3168 cmdline_parse_token_string_t cmd_config_dcb_port = 3169 TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, port, "port"); 3170 cmdline_parse_token_string_t cmd_config_dcb_config = 3171 TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, config, "config"); 3172 cmdline_parse_token_num_t cmd_config_dcb_port_id = 3173 TOKEN_NUM_INITIALIZER(struct cmd_config_dcb, port_id, UINT16); 3174 cmdline_parse_token_string_t cmd_config_dcb_dcb = 3175 TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, dcb, "dcb"); 3176 cmdline_parse_token_string_t cmd_config_dcb_vt = 3177 TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, vt, "vt"); 3178 cmdline_parse_token_string_t cmd_config_dcb_vt_en = 3179 TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, vt_en, "on#off"); 3180 cmdline_parse_token_num_t cmd_config_dcb_num_tcs = 3181 TOKEN_NUM_INITIALIZER(struct cmd_config_dcb, num_tcs, UINT8); 3182 cmdline_parse_token_string_t cmd_config_dcb_pfc= 3183 TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, pfc, "pfc"); 3184 cmdline_parse_token_string_t cmd_config_dcb_pfc_en = 3185 TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, pfc_en, "on#off"); 3186 3187 cmdline_parse_inst_t cmd_config_dcb = { 3188 .f = cmd_config_dcb_parsed, 3189 .data = NULL, 3190 .help_str = "port config <port-id> dcb vt on|off <num_tcs> pfc on|off", 3191 .tokens = { 3192 (void *)&cmd_config_dcb_port, 3193 (void *)&cmd_config_dcb_config, 3194 (void *)&cmd_config_dcb_port_id, 3195 (void *)&cmd_config_dcb_dcb, 3196 (void *)&cmd_config_dcb_vt, 3197 (void *)&cmd_config_dcb_vt_en, 3198 (void *)&cmd_config_dcb_num_tcs, 3199 (void *)&cmd_config_dcb_pfc, 3200 (void *)&cmd_config_dcb_pfc_en, 3201 NULL, 3202 }, 3203 }; 3204 3205 /* *** configure number of packets per burst *** */ 3206 struct cmd_config_burst { 3207 cmdline_fixed_string_t port; 3208 cmdline_fixed_string_t keyword; 3209 cmdline_fixed_string_t all; 3210 cmdline_fixed_string_t name; 3211 uint16_t value; 3212 }; 3213 3214 static void 3215 cmd_config_burst_parsed(void *parsed_result, 3216 __attribute__((unused)) struct cmdline *cl, 3217 __attribute__((unused)) void *data) 3218 { 3219 struct cmd_config_burst *res = parsed_result; 3220 struct rte_eth_dev_info dev_info; 3221 uint16_t rec_nb_pkts; 3222 3223 if (!all_ports_stopped()) { 3224 printf("Please stop all ports first\n"); 3225 return; 3226 } 3227 3228 if (!strcmp(res->name, "burst")) { 3229 if (res->value == 0) { 3230 /* If user gives a value of zero, query the PMD for 3231 * its recommended Rx burst size. Testpmd uses a single 3232 * size for all ports, so assume all ports are the same 3233 * NIC model and use the values from Port 0. 3234 */ 3235 rte_eth_dev_info_get(0, &dev_info); 3236 rec_nb_pkts = dev_info.default_rxportconf.burst_size; 3237 3238 if (rec_nb_pkts == 0) { 3239 printf("PMD does not recommend a burst size.\n" 3240 "User provided value must be between" 3241 " 1 and %d\n", MAX_PKT_BURST); 3242 return; 3243 } else if (rec_nb_pkts > MAX_PKT_BURST) { 3244 printf("PMD recommended burst size of %d" 3245 " exceeds maximum value of %d\n", 3246 rec_nb_pkts, MAX_PKT_BURST); 3247 return; 3248 } 3249 printf("Using PMD-provided burst value of %d\n", 3250 rec_nb_pkts); 3251 nb_pkt_per_burst = rec_nb_pkts; 3252 } else if (res->value > MAX_PKT_BURST) { 3253 printf("burst must be >= 1 && <= %d\n", MAX_PKT_BURST); 3254 return; 3255 } else 3256 nb_pkt_per_burst = res->value; 3257 } else { 3258 printf("Unknown parameter\n"); 3259 return; 3260 } 3261 3262 init_port_config(); 3263 3264 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1); 3265 } 3266 3267 cmdline_parse_token_string_t cmd_config_burst_port = 3268 TOKEN_STRING_INITIALIZER(struct cmd_config_burst, port, "port"); 3269 cmdline_parse_token_string_t cmd_config_burst_keyword = 3270 TOKEN_STRING_INITIALIZER(struct cmd_config_burst, keyword, "config"); 3271 cmdline_parse_token_string_t cmd_config_burst_all = 3272 TOKEN_STRING_INITIALIZER(struct cmd_config_burst, all, "all"); 3273 cmdline_parse_token_string_t cmd_config_burst_name = 3274 TOKEN_STRING_INITIALIZER(struct cmd_config_burst, name, "burst"); 3275 cmdline_parse_token_num_t cmd_config_burst_value = 3276 TOKEN_NUM_INITIALIZER(struct cmd_config_burst, value, UINT16); 3277 3278 cmdline_parse_inst_t cmd_config_burst = { 3279 .f = cmd_config_burst_parsed, 3280 .data = NULL, 3281 .help_str = "port config all burst <value>", 3282 .tokens = { 3283 (void *)&cmd_config_burst_port, 3284 (void *)&cmd_config_burst_keyword, 3285 (void *)&cmd_config_burst_all, 3286 (void *)&cmd_config_burst_name, 3287 (void *)&cmd_config_burst_value, 3288 NULL, 3289 }, 3290 }; 3291 3292 /* *** configure rx/tx queues *** */ 3293 struct cmd_config_thresh { 3294 cmdline_fixed_string_t port; 3295 cmdline_fixed_string_t keyword; 3296 cmdline_fixed_string_t all; 3297 cmdline_fixed_string_t name; 3298 uint8_t value; 3299 }; 3300 3301 static void 3302 cmd_config_thresh_parsed(void *parsed_result, 3303 __attribute__((unused)) struct cmdline *cl, 3304 __attribute__((unused)) void *data) 3305 { 3306 struct cmd_config_thresh *res = parsed_result; 3307 3308 if (!all_ports_stopped()) { 3309 printf("Please stop all ports first\n"); 3310 return; 3311 } 3312 3313 if (!strcmp(res->name, "txpt")) 3314 tx_pthresh = res->value; 3315 else if(!strcmp(res->name, "txht")) 3316 tx_hthresh = res->value; 3317 else if(!strcmp(res->name, "txwt")) 3318 tx_wthresh = res->value; 3319 else if(!strcmp(res->name, "rxpt")) 3320 rx_pthresh = res->value; 3321 else if(!strcmp(res->name, "rxht")) 3322 rx_hthresh = res->value; 3323 else if(!strcmp(res->name, "rxwt")) 3324 rx_wthresh = res->value; 3325 else { 3326 printf("Unknown parameter\n"); 3327 return; 3328 } 3329 3330 init_port_config(); 3331 3332 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1); 3333 } 3334 3335 cmdline_parse_token_string_t cmd_config_thresh_port = 3336 TOKEN_STRING_INITIALIZER(struct cmd_config_thresh, port, "port"); 3337 cmdline_parse_token_string_t cmd_config_thresh_keyword = 3338 TOKEN_STRING_INITIALIZER(struct cmd_config_thresh, keyword, "config"); 3339 cmdline_parse_token_string_t cmd_config_thresh_all = 3340 TOKEN_STRING_INITIALIZER(struct cmd_config_thresh, all, "all"); 3341 cmdline_parse_token_string_t cmd_config_thresh_name = 3342 TOKEN_STRING_INITIALIZER(struct cmd_config_thresh, name, 3343 "txpt#txht#txwt#rxpt#rxht#rxwt"); 3344 cmdline_parse_token_num_t cmd_config_thresh_value = 3345 TOKEN_NUM_INITIALIZER(struct cmd_config_thresh, value, UINT8); 3346 3347 cmdline_parse_inst_t cmd_config_thresh = { 3348 .f = cmd_config_thresh_parsed, 3349 .data = NULL, 3350 .help_str = "port config all txpt|txht|txwt|rxpt|rxht|rxwt <value>", 3351 .tokens = { 3352 (void *)&cmd_config_thresh_port, 3353 (void *)&cmd_config_thresh_keyword, 3354 (void *)&cmd_config_thresh_all, 3355 (void *)&cmd_config_thresh_name, 3356 (void *)&cmd_config_thresh_value, 3357 NULL, 3358 }, 3359 }; 3360 3361 /* *** configure free/rs threshold *** */ 3362 struct cmd_config_threshold { 3363 cmdline_fixed_string_t port; 3364 cmdline_fixed_string_t keyword; 3365 cmdline_fixed_string_t all; 3366 cmdline_fixed_string_t name; 3367 uint16_t value; 3368 }; 3369 3370 static void 3371 cmd_config_threshold_parsed(void *parsed_result, 3372 __attribute__((unused)) struct cmdline *cl, 3373 __attribute__((unused)) void *data) 3374 { 3375 struct cmd_config_threshold *res = parsed_result; 3376 3377 if (!all_ports_stopped()) { 3378 printf("Please stop all ports first\n"); 3379 return; 3380 } 3381 3382 if (!strcmp(res->name, "txfreet")) 3383 tx_free_thresh = res->value; 3384 else if (!strcmp(res->name, "txrst")) 3385 tx_rs_thresh = res->value; 3386 else if (!strcmp(res->name, "rxfreet")) 3387 rx_free_thresh = res->value; 3388 else { 3389 printf("Unknown parameter\n"); 3390 return; 3391 } 3392 3393 init_port_config(); 3394 3395 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1); 3396 } 3397 3398 cmdline_parse_token_string_t cmd_config_threshold_port = 3399 TOKEN_STRING_INITIALIZER(struct cmd_config_threshold, port, "port"); 3400 cmdline_parse_token_string_t cmd_config_threshold_keyword = 3401 TOKEN_STRING_INITIALIZER(struct cmd_config_threshold, keyword, 3402 "config"); 3403 cmdline_parse_token_string_t cmd_config_threshold_all = 3404 TOKEN_STRING_INITIALIZER(struct cmd_config_threshold, all, "all"); 3405 cmdline_parse_token_string_t cmd_config_threshold_name = 3406 TOKEN_STRING_INITIALIZER(struct cmd_config_threshold, name, 3407 "txfreet#txrst#rxfreet"); 3408 cmdline_parse_token_num_t cmd_config_threshold_value = 3409 TOKEN_NUM_INITIALIZER(struct cmd_config_threshold, value, UINT16); 3410 3411 cmdline_parse_inst_t cmd_config_threshold = { 3412 .f = cmd_config_threshold_parsed, 3413 .data = NULL, 3414 .help_str = "port config all txfreet|txrst|rxfreet <value>", 3415 .tokens = { 3416 (void *)&cmd_config_threshold_port, 3417 (void *)&cmd_config_threshold_keyword, 3418 (void *)&cmd_config_threshold_all, 3419 (void *)&cmd_config_threshold_name, 3420 (void *)&cmd_config_threshold_value, 3421 NULL, 3422 }, 3423 }; 3424 3425 /* *** stop *** */ 3426 struct cmd_stop_result { 3427 cmdline_fixed_string_t stop; 3428 }; 3429 3430 static void cmd_stop_parsed(__attribute__((unused)) void *parsed_result, 3431 __attribute__((unused)) struct cmdline *cl, 3432 __attribute__((unused)) void *data) 3433 { 3434 stop_packet_forwarding(); 3435 } 3436 3437 cmdline_parse_token_string_t cmd_stop_stop = 3438 TOKEN_STRING_INITIALIZER(struct cmd_stop_result, stop, "stop"); 3439 3440 cmdline_parse_inst_t cmd_stop = { 3441 .f = cmd_stop_parsed, 3442 .data = NULL, 3443 .help_str = "stop: Stop packet forwarding", 3444 .tokens = { 3445 (void *)&cmd_stop_stop, 3446 NULL, 3447 }, 3448 }; 3449 3450 /* *** SET CORELIST and PORTLIST CONFIGURATION *** */ 3451 3452 unsigned int 3453 parse_item_list(char* str, const char* item_name, unsigned int max_items, 3454 unsigned int *parsed_items, int check_unique_values) 3455 { 3456 unsigned int nb_item; 3457 unsigned int value; 3458 unsigned int i; 3459 unsigned int j; 3460 int value_ok; 3461 char c; 3462 3463 /* 3464 * First parse all items in the list and store their value. 3465 */ 3466 value = 0; 3467 nb_item = 0; 3468 value_ok = 0; 3469 for (i = 0; i < strnlen(str, STR_TOKEN_SIZE); i++) { 3470 c = str[i]; 3471 if ((c >= '0') && (c <= '9')) { 3472 value = (unsigned int) (value * 10 + (c - '0')); 3473 value_ok = 1; 3474 continue; 3475 } 3476 if (c != ',') { 3477 printf("character %c is not a decimal digit\n", c); 3478 return 0; 3479 } 3480 if (! value_ok) { 3481 printf("No valid value before comma\n"); 3482 return 0; 3483 } 3484 if (nb_item < max_items) { 3485 parsed_items[nb_item] = value; 3486 value_ok = 0; 3487 value = 0; 3488 } 3489 nb_item++; 3490 } 3491 if (nb_item >= max_items) { 3492 printf("Number of %s = %u > %u (maximum items)\n", 3493 item_name, nb_item + 1, max_items); 3494 return 0; 3495 } 3496 parsed_items[nb_item++] = value; 3497 if (! check_unique_values) 3498 return nb_item; 3499 3500 /* 3501 * Then, check that all values in the list are differents. 3502 * No optimization here... 3503 */ 3504 for (i = 0; i < nb_item; i++) { 3505 for (j = i + 1; j < nb_item; j++) { 3506 if (parsed_items[j] == parsed_items[i]) { 3507 printf("duplicated %s %u at index %u and %u\n", 3508 item_name, parsed_items[i], i, j); 3509 return 0; 3510 } 3511 } 3512 } 3513 return nb_item; 3514 } 3515 3516 struct cmd_set_list_result { 3517 cmdline_fixed_string_t cmd_keyword; 3518 cmdline_fixed_string_t list_name; 3519 cmdline_fixed_string_t list_of_items; 3520 }; 3521 3522 static void cmd_set_list_parsed(void *parsed_result, 3523 __attribute__((unused)) struct cmdline *cl, 3524 __attribute__((unused)) void *data) 3525 { 3526 struct cmd_set_list_result *res; 3527 union { 3528 unsigned int lcorelist[RTE_MAX_LCORE]; 3529 unsigned int portlist[RTE_MAX_ETHPORTS]; 3530 } parsed_items; 3531 unsigned int nb_item; 3532 3533 if (test_done == 0) { 3534 printf("Please stop forwarding first\n"); 3535 return; 3536 } 3537 3538 res = parsed_result; 3539 if (!strcmp(res->list_name, "corelist")) { 3540 nb_item = parse_item_list(res->list_of_items, "core", 3541 RTE_MAX_LCORE, 3542 parsed_items.lcorelist, 1); 3543 if (nb_item > 0) { 3544 set_fwd_lcores_list(parsed_items.lcorelist, nb_item); 3545 fwd_config_setup(); 3546 } 3547 return; 3548 } 3549 if (!strcmp(res->list_name, "portlist")) { 3550 nb_item = parse_item_list(res->list_of_items, "port", 3551 RTE_MAX_ETHPORTS, 3552 parsed_items.portlist, 1); 3553 if (nb_item > 0) { 3554 set_fwd_ports_list(parsed_items.portlist, nb_item); 3555 fwd_config_setup(); 3556 } 3557 } 3558 } 3559 3560 cmdline_parse_token_string_t cmd_set_list_keyword = 3561 TOKEN_STRING_INITIALIZER(struct cmd_set_list_result, cmd_keyword, 3562 "set"); 3563 cmdline_parse_token_string_t cmd_set_list_name = 3564 TOKEN_STRING_INITIALIZER(struct cmd_set_list_result, list_name, 3565 "corelist#portlist"); 3566 cmdline_parse_token_string_t cmd_set_list_of_items = 3567 TOKEN_STRING_INITIALIZER(struct cmd_set_list_result, list_of_items, 3568 NULL); 3569 3570 cmdline_parse_inst_t cmd_set_fwd_list = { 3571 .f = cmd_set_list_parsed, 3572 .data = NULL, 3573 .help_str = "set corelist|portlist <list0[,list1]*>", 3574 .tokens = { 3575 (void *)&cmd_set_list_keyword, 3576 (void *)&cmd_set_list_name, 3577 (void *)&cmd_set_list_of_items, 3578 NULL, 3579 }, 3580 }; 3581 3582 /* *** SET COREMASK and PORTMASK CONFIGURATION *** */ 3583 3584 struct cmd_setmask_result { 3585 cmdline_fixed_string_t set; 3586 cmdline_fixed_string_t mask; 3587 uint64_t hexavalue; 3588 }; 3589 3590 static void cmd_set_mask_parsed(void *parsed_result, 3591 __attribute__((unused)) struct cmdline *cl, 3592 __attribute__((unused)) void *data) 3593 { 3594 struct cmd_setmask_result *res = parsed_result; 3595 3596 if (test_done == 0) { 3597 printf("Please stop forwarding first\n"); 3598 return; 3599 } 3600 if (!strcmp(res->mask, "coremask")) { 3601 set_fwd_lcores_mask(res->hexavalue); 3602 fwd_config_setup(); 3603 } else if (!strcmp(res->mask, "portmask")) { 3604 set_fwd_ports_mask(res->hexavalue); 3605 fwd_config_setup(); 3606 } 3607 } 3608 3609 cmdline_parse_token_string_t cmd_setmask_set = 3610 TOKEN_STRING_INITIALIZER(struct cmd_setmask_result, set, "set"); 3611 cmdline_parse_token_string_t cmd_setmask_mask = 3612 TOKEN_STRING_INITIALIZER(struct cmd_setmask_result, mask, 3613 "coremask#portmask"); 3614 cmdline_parse_token_num_t cmd_setmask_value = 3615 TOKEN_NUM_INITIALIZER(struct cmd_setmask_result, hexavalue, UINT64); 3616 3617 cmdline_parse_inst_t cmd_set_fwd_mask = { 3618 .f = cmd_set_mask_parsed, 3619 .data = NULL, 3620 .help_str = "set coremask|portmask <hexadecimal value>", 3621 .tokens = { 3622 (void *)&cmd_setmask_set, 3623 (void *)&cmd_setmask_mask, 3624 (void *)&cmd_setmask_value, 3625 NULL, 3626 }, 3627 }; 3628 3629 /* 3630 * SET NBPORT, NBCORE, PACKET BURST, and VERBOSE LEVEL CONFIGURATION 3631 */ 3632 struct cmd_set_result { 3633 cmdline_fixed_string_t set; 3634 cmdline_fixed_string_t what; 3635 uint16_t value; 3636 }; 3637 3638 static void cmd_set_parsed(void *parsed_result, 3639 __attribute__((unused)) struct cmdline *cl, 3640 __attribute__((unused)) void *data) 3641 { 3642 struct cmd_set_result *res = parsed_result; 3643 if (!strcmp(res->what, "nbport")) { 3644 set_fwd_ports_number(res->value); 3645 fwd_config_setup(); 3646 } else if (!strcmp(res->what, "nbcore")) { 3647 set_fwd_lcores_number(res->value); 3648 fwd_config_setup(); 3649 } else if (!strcmp(res->what, "burst")) 3650 set_nb_pkt_per_burst(res->value); 3651 else if (!strcmp(res->what, "verbose")) 3652 set_verbose_level(res->value); 3653 } 3654 3655 cmdline_parse_token_string_t cmd_set_set = 3656 TOKEN_STRING_INITIALIZER(struct cmd_set_result, set, "set"); 3657 cmdline_parse_token_string_t cmd_set_what = 3658 TOKEN_STRING_INITIALIZER(struct cmd_set_result, what, 3659 "nbport#nbcore#burst#verbose"); 3660 cmdline_parse_token_num_t cmd_set_value = 3661 TOKEN_NUM_INITIALIZER(struct cmd_set_result, value, UINT16); 3662 3663 cmdline_parse_inst_t cmd_set_numbers = { 3664 .f = cmd_set_parsed, 3665 .data = NULL, 3666 .help_str = "set nbport|nbcore|burst|verbose <value>", 3667 .tokens = { 3668 (void *)&cmd_set_set, 3669 (void *)&cmd_set_what, 3670 (void *)&cmd_set_value, 3671 NULL, 3672 }, 3673 }; 3674 3675 /* *** SET LOG LEVEL CONFIGURATION *** */ 3676 3677 struct cmd_set_log_result { 3678 cmdline_fixed_string_t set; 3679 cmdline_fixed_string_t log; 3680 cmdline_fixed_string_t type; 3681 uint32_t level; 3682 }; 3683 3684 static void 3685 cmd_set_log_parsed(void *parsed_result, 3686 __attribute__((unused)) struct cmdline *cl, 3687 __attribute__((unused)) void *data) 3688 { 3689 struct cmd_set_log_result *res; 3690 int ret; 3691 3692 res = parsed_result; 3693 if (!strcmp(res->type, "global")) 3694 rte_log_set_global_level(res->level); 3695 else { 3696 ret = rte_log_set_level_regexp(res->type, res->level); 3697 if (ret < 0) 3698 printf("Unable to set log level\n"); 3699 } 3700 } 3701 3702 cmdline_parse_token_string_t cmd_set_log_set = 3703 TOKEN_STRING_INITIALIZER(struct cmd_set_log_result, set, "set"); 3704 cmdline_parse_token_string_t cmd_set_log_log = 3705 TOKEN_STRING_INITIALIZER(struct cmd_set_log_result, log, "log"); 3706 cmdline_parse_token_string_t cmd_set_log_type = 3707 TOKEN_STRING_INITIALIZER(struct cmd_set_log_result, type, NULL); 3708 cmdline_parse_token_num_t cmd_set_log_level = 3709 TOKEN_NUM_INITIALIZER(struct cmd_set_log_result, level, UINT32); 3710 3711 cmdline_parse_inst_t cmd_set_log = { 3712 .f = cmd_set_log_parsed, 3713 .data = NULL, 3714 .help_str = "set log global|<type> <level>", 3715 .tokens = { 3716 (void *)&cmd_set_log_set, 3717 (void *)&cmd_set_log_log, 3718 (void *)&cmd_set_log_type, 3719 (void *)&cmd_set_log_level, 3720 NULL, 3721 }, 3722 }; 3723 3724 /* *** SET SEGMENT LENGTHS OF TXONLY PACKETS *** */ 3725 3726 struct cmd_set_txpkts_result { 3727 cmdline_fixed_string_t cmd_keyword; 3728 cmdline_fixed_string_t txpkts; 3729 cmdline_fixed_string_t seg_lengths; 3730 }; 3731 3732 static void 3733 cmd_set_txpkts_parsed(void *parsed_result, 3734 __attribute__((unused)) struct cmdline *cl, 3735 __attribute__((unused)) void *data) 3736 { 3737 struct cmd_set_txpkts_result *res; 3738 unsigned seg_lengths[RTE_MAX_SEGS_PER_PKT]; 3739 unsigned int nb_segs; 3740 3741 res = parsed_result; 3742 nb_segs = parse_item_list(res->seg_lengths, "segment lengths", 3743 RTE_MAX_SEGS_PER_PKT, seg_lengths, 0); 3744 if (nb_segs > 0) 3745 set_tx_pkt_segments(seg_lengths, nb_segs); 3746 } 3747 3748 cmdline_parse_token_string_t cmd_set_txpkts_keyword = 3749 TOKEN_STRING_INITIALIZER(struct cmd_set_txpkts_result, 3750 cmd_keyword, "set"); 3751 cmdline_parse_token_string_t cmd_set_txpkts_name = 3752 TOKEN_STRING_INITIALIZER(struct cmd_set_txpkts_result, 3753 txpkts, "txpkts"); 3754 cmdline_parse_token_string_t cmd_set_txpkts_lengths = 3755 TOKEN_STRING_INITIALIZER(struct cmd_set_txpkts_result, 3756 seg_lengths, NULL); 3757 3758 cmdline_parse_inst_t cmd_set_txpkts = { 3759 .f = cmd_set_txpkts_parsed, 3760 .data = NULL, 3761 .help_str = "set txpkts <len0[,len1]*>", 3762 .tokens = { 3763 (void *)&cmd_set_txpkts_keyword, 3764 (void *)&cmd_set_txpkts_name, 3765 (void *)&cmd_set_txpkts_lengths, 3766 NULL, 3767 }, 3768 }; 3769 3770 /* *** SET COPY AND SPLIT POLICY ON TX PACKETS *** */ 3771 3772 struct cmd_set_txsplit_result { 3773 cmdline_fixed_string_t cmd_keyword; 3774 cmdline_fixed_string_t txsplit; 3775 cmdline_fixed_string_t mode; 3776 }; 3777 3778 static void 3779 cmd_set_txsplit_parsed(void *parsed_result, 3780 __attribute__((unused)) struct cmdline *cl, 3781 __attribute__((unused)) void *data) 3782 { 3783 struct cmd_set_txsplit_result *res; 3784 3785 res = parsed_result; 3786 set_tx_pkt_split(res->mode); 3787 } 3788 3789 cmdline_parse_token_string_t cmd_set_txsplit_keyword = 3790 TOKEN_STRING_INITIALIZER(struct cmd_set_txsplit_result, 3791 cmd_keyword, "set"); 3792 cmdline_parse_token_string_t cmd_set_txsplit_name = 3793 TOKEN_STRING_INITIALIZER(struct cmd_set_txsplit_result, 3794 txsplit, "txsplit"); 3795 cmdline_parse_token_string_t cmd_set_txsplit_mode = 3796 TOKEN_STRING_INITIALIZER(struct cmd_set_txsplit_result, 3797 mode, NULL); 3798 3799 cmdline_parse_inst_t cmd_set_txsplit = { 3800 .f = cmd_set_txsplit_parsed, 3801 .data = NULL, 3802 .help_str = "set txsplit on|off|rand", 3803 .tokens = { 3804 (void *)&cmd_set_txsplit_keyword, 3805 (void *)&cmd_set_txsplit_name, 3806 (void *)&cmd_set_txsplit_mode, 3807 NULL, 3808 }, 3809 }; 3810 3811 /* *** ADD/REMOVE ALL VLAN IDENTIFIERS TO/FROM A PORT VLAN RX FILTER *** */ 3812 struct cmd_rx_vlan_filter_all_result { 3813 cmdline_fixed_string_t rx_vlan; 3814 cmdline_fixed_string_t what; 3815 cmdline_fixed_string_t all; 3816 portid_t port_id; 3817 }; 3818 3819 static void 3820 cmd_rx_vlan_filter_all_parsed(void *parsed_result, 3821 __attribute__((unused)) struct cmdline *cl, 3822 __attribute__((unused)) void *data) 3823 { 3824 struct cmd_rx_vlan_filter_all_result *res = parsed_result; 3825 3826 if (!strcmp(res->what, "add")) 3827 rx_vlan_all_filter_set(res->port_id, 1); 3828 else 3829 rx_vlan_all_filter_set(res->port_id, 0); 3830 } 3831 3832 cmdline_parse_token_string_t cmd_rx_vlan_filter_all_rx_vlan = 3833 TOKEN_STRING_INITIALIZER(struct cmd_rx_vlan_filter_all_result, 3834 rx_vlan, "rx_vlan"); 3835 cmdline_parse_token_string_t cmd_rx_vlan_filter_all_what = 3836 TOKEN_STRING_INITIALIZER(struct cmd_rx_vlan_filter_all_result, 3837 what, "add#rm"); 3838 cmdline_parse_token_string_t cmd_rx_vlan_filter_all_all = 3839 TOKEN_STRING_INITIALIZER(struct cmd_rx_vlan_filter_all_result, 3840 all, "all"); 3841 cmdline_parse_token_num_t cmd_rx_vlan_filter_all_portid = 3842 TOKEN_NUM_INITIALIZER(struct cmd_rx_vlan_filter_all_result, 3843 port_id, UINT16); 3844 3845 cmdline_parse_inst_t cmd_rx_vlan_filter_all = { 3846 .f = cmd_rx_vlan_filter_all_parsed, 3847 .data = NULL, 3848 .help_str = "rx_vlan add|rm all <port_id>: " 3849 "Add/Remove all identifiers to/from the set of VLAN " 3850 "identifiers filtered by a port", 3851 .tokens = { 3852 (void *)&cmd_rx_vlan_filter_all_rx_vlan, 3853 (void *)&cmd_rx_vlan_filter_all_what, 3854 (void *)&cmd_rx_vlan_filter_all_all, 3855 (void *)&cmd_rx_vlan_filter_all_portid, 3856 NULL, 3857 }, 3858 }; 3859 3860 /* *** VLAN OFFLOAD SET ON A PORT *** */ 3861 struct cmd_vlan_offload_result { 3862 cmdline_fixed_string_t vlan; 3863 cmdline_fixed_string_t set; 3864 cmdline_fixed_string_t vlan_type; 3865 cmdline_fixed_string_t what; 3866 cmdline_fixed_string_t on; 3867 cmdline_fixed_string_t port_id; 3868 }; 3869 3870 static void 3871 cmd_vlan_offload_parsed(void *parsed_result, 3872 __attribute__((unused)) struct cmdline *cl, 3873 __attribute__((unused)) void *data) 3874 { 3875 int on; 3876 struct cmd_vlan_offload_result *res = parsed_result; 3877 char *str; 3878 int i, len = 0; 3879 portid_t port_id = 0; 3880 unsigned int tmp; 3881 3882 str = res->port_id; 3883 len = strnlen(str, STR_TOKEN_SIZE); 3884 i = 0; 3885 /* Get port_id first */ 3886 while(i < len){ 3887 if(str[i] == ',') 3888 break; 3889 3890 i++; 3891 } 3892 str[i]='\0'; 3893 tmp = strtoul(str, NULL, 0); 3894 /* If port_id greater that what portid_t can represent, return */ 3895 if(tmp >= RTE_MAX_ETHPORTS) 3896 return; 3897 port_id = (portid_t)tmp; 3898 3899 if (!strcmp(res->on, "on")) 3900 on = 1; 3901 else 3902 on = 0; 3903 3904 if (!strcmp(res->what, "strip")) 3905 rx_vlan_strip_set(port_id, on); 3906 else if(!strcmp(res->what, "stripq")){ 3907 uint16_t queue_id = 0; 3908 3909 /* No queue_id, return */ 3910 if(i + 1 >= len) { 3911 printf("must specify (port,queue_id)\n"); 3912 return; 3913 } 3914 tmp = strtoul(str + i + 1, NULL, 0); 3915 /* If queue_id greater that what 16-bits can represent, return */ 3916 if(tmp > 0xffff) 3917 return; 3918 3919 queue_id = (uint16_t)tmp; 3920 rx_vlan_strip_set_on_queue(port_id, queue_id, on); 3921 } 3922 else if (!strcmp(res->what, "filter")) 3923 rx_vlan_filter_set(port_id, on); 3924 else 3925 vlan_extend_set(port_id, on); 3926 3927 return; 3928 } 3929 3930 cmdline_parse_token_string_t cmd_vlan_offload_vlan = 3931 TOKEN_STRING_INITIALIZER(struct cmd_vlan_offload_result, 3932 vlan, "vlan"); 3933 cmdline_parse_token_string_t cmd_vlan_offload_set = 3934 TOKEN_STRING_INITIALIZER(struct cmd_vlan_offload_result, 3935 set, "set"); 3936 cmdline_parse_token_string_t cmd_vlan_offload_what = 3937 TOKEN_STRING_INITIALIZER(struct cmd_vlan_offload_result, 3938 what, "strip#filter#qinq#stripq"); 3939 cmdline_parse_token_string_t cmd_vlan_offload_on = 3940 TOKEN_STRING_INITIALIZER(struct cmd_vlan_offload_result, 3941 on, "on#off"); 3942 cmdline_parse_token_string_t cmd_vlan_offload_portid = 3943 TOKEN_STRING_INITIALIZER(struct cmd_vlan_offload_result, 3944 port_id, NULL); 3945 3946 cmdline_parse_inst_t cmd_vlan_offload = { 3947 .f = cmd_vlan_offload_parsed, 3948 .data = NULL, 3949 .help_str = "vlan set strip|filter|qinq|stripq on|off " 3950 "<port_id[,queue_id]>: " 3951 "Filter/Strip for rx side qinq(extended) for both rx/tx sides", 3952 .tokens = { 3953 (void *)&cmd_vlan_offload_vlan, 3954 (void *)&cmd_vlan_offload_set, 3955 (void *)&cmd_vlan_offload_what, 3956 (void *)&cmd_vlan_offload_on, 3957 (void *)&cmd_vlan_offload_portid, 3958 NULL, 3959 }, 3960 }; 3961 3962 /* *** VLAN TPID SET ON A PORT *** */ 3963 struct cmd_vlan_tpid_result { 3964 cmdline_fixed_string_t vlan; 3965 cmdline_fixed_string_t set; 3966 cmdline_fixed_string_t vlan_type; 3967 cmdline_fixed_string_t what; 3968 uint16_t tp_id; 3969 portid_t port_id; 3970 }; 3971 3972 static void 3973 cmd_vlan_tpid_parsed(void *parsed_result, 3974 __attribute__((unused)) struct cmdline *cl, 3975 __attribute__((unused)) void *data) 3976 { 3977 struct cmd_vlan_tpid_result *res = parsed_result; 3978 enum rte_vlan_type vlan_type; 3979 3980 if (!strcmp(res->vlan_type, "inner")) 3981 vlan_type = ETH_VLAN_TYPE_INNER; 3982 else if (!strcmp(res->vlan_type, "outer")) 3983 vlan_type = ETH_VLAN_TYPE_OUTER; 3984 else { 3985 printf("Unknown vlan type\n"); 3986 return; 3987 } 3988 vlan_tpid_set(res->port_id, vlan_type, res->tp_id); 3989 } 3990 3991 cmdline_parse_token_string_t cmd_vlan_tpid_vlan = 3992 TOKEN_STRING_INITIALIZER(struct cmd_vlan_tpid_result, 3993 vlan, "vlan"); 3994 cmdline_parse_token_string_t cmd_vlan_tpid_set = 3995 TOKEN_STRING_INITIALIZER(struct cmd_vlan_tpid_result, 3996 set, "set"); 3997 cmdline_parse_token_string_t cmd_vlan_type = 3998 TOKEN_STRING_INITIALIZER(struct cmd_vlan_tpid_result, 3999 vlan_type, "inner#outer"); 4000 cmdline_parse_token_string_t cmd_vlan_tpid_what = 4001 TOKEN_STRING_INITIALIZER(struct cmd_vlan_tpid_result, 4002 what, "tpid"); 4003 cmdline_parse_token_num_t cmd_vlan_tpid_tpid = 4004 TOKEN_NUM_INITIALIZER(struct cmd_vlan_tpid_result, 4005 tp_id, UINT16); 4006 cmdline_parse_token_num_t cmd_vlan_tpid_portid = 4007 TOKEN_NUM_INITIALIZER(struct cmd_vlan_tpid_result, 4008 port_id, UINT16); 4009 4010 cmdline_parse_inst_t cmd_vlan_tpid = { 4011 .f = cmd_vlan_tpid_parsed, 4012 .data = NULL, 4013 .help_str = "vlan set inner|outer tpid <tp_id> <port_id>: " 4014 "Set the VLAN Ether type", 4015 .tokens = { 4016 (void *)&cmd_vlan_tpid_vlan, 4017 (void *)&cmd_vlan_tpid_set, 4018 (void *)&cmd_vlan_type, 4019 (void *)&cmd_vlan_tpid_what, 4020 (void *)&cmd_vlan_tpid_tpid, 4021 (void *)&cmd_vlan_tpid_portid, 4022 NULL, 4023 }, 4024 }; 4025 4026 /* *** ADD/REMOVE A VLAN IDENTIFIER TO/FROM A PORT VLAN RX FILTER *** */ 4027 struct cmd_rx_vlan_filter_result { 4028 cmdline_fixed_string_t rx_vlan; 4029 cmdline_fixed_string_t what; 4030 uint16_t vlan_id; 4031 portid_t port_id; 4032 }; 4033 4034 static void 4035 cmd_rx_vlan_filter_parsed(void *parsed_result, 4036 __attribute__((unused)) struct cmdline *cl, 4037 __attribute__((unused)) void *data) 4038 { 4039 struct cmd_rx_vlan_filter_result *res = parsed_result; 4040 4041 if (!strcmp(res->what, "add")) 4042 rx_vft_set(res->port_id, res->vlan_id, 1); 4043 else 4044 rx_vft_set(res->port_id, res->vlan_id, 0); 4045 } 4046 4047 cmdline_parse_token_string_t cmd_rx_vlan_filter_rx_vlan = 4048 TOKEN_STRING_INITIALIZER(struct cmd_rx_vlan_filter_result, 4049 rx_vlan, "rx_vlan"); 4050 cmdline_parse_token_string_t cmd_rx_vlan_filter_what = 4051 TOKEN_STRING_INITIALIZER(struct cmd_rx_vlan_filter_result, 4052 what, "add#rm"); 4053 cmdline_parse_token_num_t cmd_rx_vlan_filter_vlanid = 4054 TOKEN_NUM_INITIALIZER(struct cmd_rx_vlan_filter_result, 4055 vlan_id, UINT16); 4056 cmdline_parse_token_num_t cmd_rx_vlan_filter_portid = 4057 TOKEN_NUM_INITIALIZER(struct cmd_rx_vlan_filter_result, 4058 port_id, UINT16); 4059 4060 cmdline_parse_inst_t cmd_rx_vlan_filter = { 4061 .f = cmd_rx_vlan_filter_parsed, 4062 .data = NULL, 4063 .help_str = "rx_vlan add|rm <vlan_id> <port_id>: " 4064 "Add/Remove a VLAN identifier to/from the set of VLAN " 4065 "identifiers filtered by a port", 4066 .tokens = { 4067 (void *)&cmd_rx_vlan_filter_rx_vlan, 4068 (void *)&cmd_rx_vlan_filter_what, 4069 (void *)&cmd_rx_vlan_filter_vlanid, 4070 (void *)&cmd_rx_vlan_filter_portid, 4071 NULL, 4072 }, 4073 }; 4074 4075 /* *** ENABLE HARDWARE INSERTION OF VLAN HEADER IN TX PACKETS *** */ 4076 struct cmd_tx_vlan_set_result { 4077 cmdline_fixed_string_t tx_vlan; 4078 cmdline_fixed_string_t set; 4079 portid_t port_id; 4080 uint16_t vlan_id; 4081 }; 4082 4083 static void 4084 cmd_tx_vlan_set_parsed(void *parsed_result, 4085 __attribute__((unused)) struct cmdline *cl, 4086 __attribute__((unused)) void *data) 4087 { 4088 struct cmd_tx_vlan_set_result *res = parsed_result; 4089 4090 if (!port_is_stopped(res->port_id)) { 4091 printf("Please stop port %d first\n", res->port_id); 4092 return; 4093 } 4094 4095 tx_vlan_set(res->port_id, res->vlan_id); 4096 4097 cmd_reconfig_device_queue(res->port_id, 1, 1); 4098 } 4099 4100 cmdline_parse_token_string_t cmd_tx_vlan_set_tx_vlan = 4101 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_result, 4102 tx_vlan, "tx_vlan"); 4103 cmdline_parse_token_string_t cmd_tx_vlan_set_set = 4104 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_result, 4105 set, "set"); 4106 cmdline_parse_token_num_t cmd_tx_vlan_set_portid = 4107 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_result, 4108 port_id, UINT16); 4109 cmdline_parse_token_num_t cmd_tx_vlan_set_vlanid = 4110 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_result, 4111 vlan_id, UINT16); 4112 4113 cmdline_parse_inst_t cmd_tx_vlan_set = { 4114 .f = cmd_tx_vlan_set_parsed, 4115 .data = NULL, 4116 .help_str = "tx_vlan set <port_id> <vlan_id>: " 4117 "Enable hardware insertion of a single VLAN header " 4118 "with a given TAG Identifier in packets sent on a port", 4119 .tokens = { 4120 (void *)&cmd_tx_vlan_set_tx_vlan, 4121 (void *)&cmd_tx_vlan_set_set, 4122 (void *)&cmd_tx_vlan_set_portid, 4123 (void *)&cmd_tx_vlan_set_vlanid, 4124 NULL, 4125 }, 4126 }; 4127 4128 /* *** ENABLE HARDWARE INSERTION OF Double VLAN HEADER IN TX PACKETS *** */ 4129 struct cmd_tx_vlan_set_qinq_result { 4130 cmdline_fixed_string_t tx_vlan; 4131 cmdline_fixed_string_t set; 4132 portid_t port_id; 4133 uint16_t vlan_id; 4134 uint16_t vlan_id_outer; 4135 }; 4136 4137 static void 4138 cmd_tx_vlan_set_qinq_parsed(void *parsed_result, 4139 __attribute__((unused)) struct cmdline *cl, 4140 __attribute__((unused)) void *data) 4141 { 4142 struct cmd_tx_vlan_set_qinq_result *res = parsed_result; 4143 4144 if (!port_is_stopped(res->port_id)) { 4145 printf("Please stop port %d first\n", res->port_id); 4146 return; 4147 } 4148 4149 tx_qinq_set(res->port_id, res->vlan_id, res->vlan_id_outer); 4150 4151 cmd_reconfig_device_queue(res->port_id, 1, 1); 4152 } 4153 4154 cmdline_parse_token_string_t cmd_tx_vlan_set_qinq_tx_vlan = 4155 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_qinq_result, 4156 tx_vlan, "tx_vlan"); 4157 cmdline_parse_token_string_t cmd_tx_vlan_set_qinq_set = 4158 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_qinq_result, 4159 set, "set"); 4160 cmdline_parse_token_num_t cmd_tx_vlan_set_qinq_portid = 4161 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_qinq_result, 4162 port_id, UINT16); 4163 cmdline_parse_token_num_t cmd_tx_vlan_set_qinq_vlanid = 4164 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_qinq_result, 4165 vlan_id, UINT16); 4166 cmdline_parse_token_num_t cmd_tx_vlan_set_qinq_vlanid_outer = 4167 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_qinq_result, 4168 vlan_id_outer, UINT16); 4169 4170 cmdline_parse_inst_t cmd_tx_vlan_set_qinq = { 4171 .f = cmd_tx_vlan_set_qinq_parsed, 4172 .data = NULL, 4173 .help_str = "tx_vlan set <port_id> <vlan_id> <outer_vlan_id>: " 4174 "Enable hardware insertion of double VLAN header " 4175 "with given TAG Identifiers in packets sent on a port", 4176 .tokens = { 4177 (void *)&cmd_tx_vlan_set_qinq_tx_vlan, 4178 (void *)&cmd_tx_vlan_set_qinq_set, 4179 (void *)&cmd_tx_vlan_set_qinq_portid, 4180 (void *)&cmd_tx_vlan_set_qinq_vlanid, 4181 (void *)&cmd_tx_vlan_set_qinq_vlanid_outer, 4182 NULL, 4183 }, 4184 }; 4185 4186 /* *** ENABLE/DISABLE PORT BASED TX VLAN INSERTION *** */ 4187 struct cmd_tx_vlan_set_pvid_result { 4188 cmdline_fixed_string_t tx_vlan; 4189 cmdline_fixed_string_t set; 4190 cmdline_fixed_string_t pvid; 4191 portid_t port_id; 4192 uint16_t vlan_id; 4193 cmdline_fixed_string_t mode; 4194 }; 4195 4196 static void 4197 cmd_tx_vlan_set_pvid_parsed(void *parsed_result, 4198 __attribute__((unused)) struct cmdline *cl, 4199 __attribute__((unused)) void *data) 4200 { 4201 struct cmd_tx_vlan_set_pvid_result *res = parsed_result; 4202 4203 if (strcmp(res->mode, "on") == 0) 4204 tx_vlan_pvid_set(res->port_id, res->vlan_id, 1); 4205 else 4206 tx_vlan_pvid_set(res->port_id, res->vlan_id, 0); 4207 } 4208 4209 cmdline_parse_token_string_t cmd_tx_vlan_set_pvid_tx_vlan = 4210 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_pvid_result, 4211 tx_vlan, "tx_vlan"); 4212 cmdline_parse_token_string_t cmd_tx_vlan_set_pvid_set = 4213 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_pvid_result, 4214 set, "set"); 4215 cmdline_parse_token_string_t cmd_tx_vlan_set_pvid_pvid = 4216 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_pvid_result, 4217 pvid, "pvid"); 4218 cmdline_parse_token_num_t cmd_tx_vlan_set_pvid_port_id = 4219 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_pvid_result, 4220 port_id, UINT16); 4221 cmdline_parse_token_num_t cmd_tx_vlan_set_pvid_vlan_id = 4222 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_pvid_result, 4223 vlan_id, UINT16); 4224 cmdline_parse_token_string_t cmd_tx_vlan_set_pvid_mode = 4225 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_pvid_result, 4226 mode, "on#off"); 4227 4228 cmdline_parse_inst_t cmd_tx_vlan_set_pvid = { 4229 .f = cmd_tx_vlan_set_pvid_parsed, 4230 .data = NULL, 4231 .help_str = "tx_vlan set pvid <port_id> <vlan_id> on|off", 4232 .tokens = { 4233 (void *)&cmd_tx_vlan_set_pvid_tx_vlan, 4234 (void *)&cmd_tx_vlan_set_pvid_set, 4235 (void *)&cmd_tx_vlan_set_pvid_pvid, 4236 (void *)&cmd_tx_vlan_set_pvid_port_id, 4237 (void *)&cmd_tx_vlan_set_pvid_vlan_id, 4238 (void *)&cmd_tx_vlan_set_pvid_mode, 4239 NULL, 4240 }, 4241 }; 4242 4243 /* *** DISABLE HARDWARE INSERTION OF VLAN HEADER IN TX PACKETS *** */ 4244 struct cmd_tx_vlan_reset_result { 4245 cmdline_fixed_string_t tx_vlan; 4246 cmdline_fixed_string_t reset; 4247 portid_t port_id; 4248 }; 4249 4250 static void 4251 cmd_tx_vlan_reset_parsed(void *parsed_result, 4252 __attribute__((unused)) struct cmdline *cl, 4253 __attribute__((unused)) void *data) 4254 { 4255 struct cmd_tx_vlan_reset_result *res = parsed_result; 4256 4257 if (!port_is_stopped(res->port_id)) { 4258 printf("Please stop port %d first\n", res->port_id); 4259 return; 4260 } 4261 4262 tx_vlan_reset(res->port_id); 4263 4264 cmd_reconfig_device_queue(res->port_id, 1, 1); 4265 } 4266 4267 cmdline_parse_token_string_t cmd_tx_vlan_reset_tx_vlan = 4268 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_reset_result, 4269 tx_vlan, "tx_vlan"); 4270 cmdline_parse_token_string_t cmd_tx_vlan_reset_reset = 4271 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_reset_result, 4272 reset, "reset"); 4273 cmdline_parse_token_num_t cmd_tx_vlan_reset_portid = 4274 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_reset_result, 4275 port_id, UINT16); 4276 4277 cmdline_parse_inst_t cmd_tx_vlan_reset = { 4278 .f = cmd_tx_vlan_reset_parsed, 4279 .data = NULL, 4280 .help_str = "tx_vlan reset <port_id>: Disable hardware insertion of a " 4281 "VLAN header in packets sent on a port", 4282 .tokens = { 4283 (void *)&cmd_tx_vlan_reset_tx_vlan, 4284 (void *)&cmd_tx_vlan_reset_reset, 4285 (void *)&cmd_tx_vlan_reset_portid, 4286 NULL, 4287 }, 4288 }; 4289 4290 4291 /* *** ENABLE HARDWARE INSERTION OF CHECKSUM IN TX PACKETS *** */ 4292 struct cmd_csum_result { 4293 cmdline_fixed_string_t csum; 4294 cmdline_fixed_string_t mode; 4295 cmdline_fixed_string_t proto; 4296 cmdline_fixed_string_t hwsw; 4297 portid_t port_id; 4298 }; 4299 4300 static void 4301 csum_show(int port_id) 4302 { 4303 struct rte_eth_dev_info dev_info; 4304 uint64_t tx_offloads; 4305 4306 tx_offloads = ports[port_id].dev_conf.txmode.offloads; 4307 printf("Parse tunnel is %s\n", 4308 (ports[port_id].parse_tunnel) ? "on" : "off"); 4309 printf("IP checksum offload is %s\n", 4310 (tx_offloads & DEV_TX_OFFLOAD_IPV4_CKSUM) ? "hw" : "sw"); 4311 printf("UDP checksum offload is %s\n", 4312 (tx_offloads & DEV_TX_OFFLOAD_UDP_CKSUM) ? "hw" : "sw"); 4313 printf("TCP checksum offload is %s\n", 4314 (tx_offloads & DEV_TX_OFFLOAD_TCP_CKSUM) ? "hw" : "sw"); 4315 printf("SCTP checksum offload is %s\n", 4316 (tx_offloads & DEV_TX_OFFLOAD_SCTP_CKSUM) ? "hw" : "sw"); 4317 printf("Outer-Ip checksum offload is %s\n", 4318 (tx_offloads & DEV_TX_OFFLOAD_OUTER_IPV4_CKSUM) ? "hw" : "sw"); 4319 printf("Outer-Udp checksum offload is %s\n", 4320 (tx_offloads & DEV_TX_OFFLOAD_OUTER_UDP_CKSUM) ? "hw" : "sw"); 4321 4322 /* display warnings if configuration is not supported by the NIC */ 4323 rte_eth_dev_info_get(port_id, &dev_info); 4324 if ((tx_offloads & DEV_TX_OFFLOAD_IPV4_CKSUM) && 4325 (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_IPV4_CKSUM) == 0) { 4326 printf("Warning: hardware IP checksum enabled but not " 4327 "supported by port %d\n", port_id); 4328 } 4329 if ((tx_offloads & DEV_TX_OFFLOAD_UDP_CKSUM) && 4330 (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_UDP_CKSUM) == 0) { 4331 printf("Warning: hardware UDP checksum enabled but not " 4332 "supported by port %d\n", port_id); 4333 } 4334 if ((tx_offloads & DEV_TX_OFFLOAD_TCP_CKSUM) && 4335 (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_TCP_CKSUM) == 0) { 4336 printf("Warning: hardware TCP checksum enabled but not " 4337 "supported by port %d\n", port_id); 4338 } 4339 if ((tx_offloads & DEV_TX_OFFLOAD_SCTP_CKSUM) && 4340 (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_SCTP_CKSUM) == 0) { 4341 printf("Warning: hardware SCTP checksum enabled but not " 4342 "supported by port %d\n", port_id); 4343 } 4344 if ((tx_offloads & DEV_TX_OFFLOAD_OUTER_IPV4_CKSUM) && 4345 (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_OUTER_IPV4_CKSUM) == 0) { 4346 printf("Warning: hardware outer IP checksum enabled but not " 4347 "supported by port %d\n", port_id); 4348 } 4349 if ((tx_offloads & DEV_TX_OFFLOAD_OUTER_UDP_CKSUM) && 4350 (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_OUTER_UDP_CKSUM) 4351 == 0) { 4352 printf("Warning: hardware outer UDP checksum enabled but not " 4353 "supported by port %d\n", port_id); 4354 } 4355 } 4356 4357 static void 4358 cmd_csum_parsed(void *parsed_result, 4359 __attribute__((unused)) struct cmdline *cl, 4360 __attribute__((unused)) void *data) 4361 { 4362 struct cmd_csum_result *res = parsed_result; 4363 int hw = 0; 4364 uint64_t csum_offloads = 0; 4365 struct rte_eth_dev_info dev_info; 4366 4367 if (port_id_is_invalid(res->port_id, ENABLED_WARN)) { 4368 printf("invalid port %d\n", res->port_id); 4369 return; 4370 } 4371 if (!port_is_stopped(res->port_id)) { 4372 printf("Please stop port %d first\n", res->port_id); 4373 return; 4374 } 4375 4376 rte_eth_dev_info_get(res->port_id, &dev_info); 4377 if (!strcmp(res->mode, "set")) { 4378 4379 if (!strcmp(res->hwsw, "hw")) 4380 hw = 1; 4381 4382 if (!strcmp(res->proto, "ip")) { 4383 if (hw == 0 || (dev_info.tx_offload_capa & 4384 DEV_TX_OFFLOAD_IPV4_CKSUM)) { 4385 csum_offloads |= DEV_TX_OFFLOAD_IPV4_CKSUM; 4386 } else { 4387 printf("IP checksum offload is not supported " 4388 "by port %u\n", res->port_id); 4389 } 4390 } else if (!strcmp(res->proto, "udp")) { 4391 if (hw == 0 || (dev_info.tx_offload_capa & 4392 DEV_TX_OFFLOAD_UDP_CKSUM)) { 4393 csum_offloads |= DEV_TX_OFFLOAD_UDP_CKSUM; 4394 } else { 4395 printf("UDP checksum offload is not supported " 4396 "by port %u\n", res->port_id); 4397 } 4398 } else if (!strcmp(res->proto, "tcp")) { 4399 if (hw == 0 || (dev_info.tx_offload_capa & 4400 DEV_TX_OFFLOAD_TCP_CKSUM)) { 4401 csum_offloads |= DEV_TX_OFFLOAD_TCP_CKSUM; 4402 } else { 4403 printf("TCP checksum offload is not supported " 4404 "by port %u\n", res->port_id); 4405 } 4406 } else if (!strcmp(res->proto, "sctp")) { 4407 if (hw == 0 || (dev_info.tx_offload_capa & 4408 DEV_TX_OFFLOAD_SCTP_CKSUM)) { 4409 csum_offloads |= DEV_TX_OFFLOAD_SCTP_CKSUM; 4410 } else { 4411 printf("SCTP checksum offload is not supported " 4412 "by port %u\n", res->port_id); 4413 } 4414 } else if (!strcmp(res->proto, "outer-ip")) { 4415 if (hw == 0 || (dev_info.tx_offload_capa & 4416 DEV_TX_OFFLOAD_OUTER_IPV4_CKSUM)) { 4417 csum_offloads |= 4418 DEV_TX_OFFLOAD_OUTER_IPV4_CKSUM; 4419 } else { 4420 printf("Outer IP checksum offload is not " 4421 "supported by port %u\n", res->port_id); 4422 } 4423 } else if (!strcmp(res->proto, "outer-udp")) { 4424 if (hw == 0 || (dev_info.tx_offload_capa & 4425 DEV_TX_OFFLOAD_OUTER_UDP_CKSUM)) { 4426 csum_offloads |= 4427 DEV_TX_OFFLOAD_OUTER_UDP_CKSUM; 4428 } else { 4429 printf("Outer UDP checksum offload is not " 4430 "supported by port %u\n", res->port_id); 4431 } 4432 } 4433 4434 if (hw) { 4435 ports[res->port_id].dev_conf.txmode.offloads |= 4436 csum_offloads; 4437 } else { 4438 ports[res->port_id].dev_conf.txmode.offloads &= 4439 (~csum_offloads); 4440 } 4441 } 4442 csum_show(res->port_id); 4443 4444 cmd_reconfig_device_queue(res->port_id, 1, 1); 4445 } 4446 4447 cmdline_parse_token_string_t cmd_csum_csum = 4448 TOKEN_STRING_INITIALIZER(struct cmd_csum_result, 4449 csum, "csum"); 4450 cmdline_parse_token_string_t cmd_csum_mode = 4451 TOKEN_STRING_INITIALIZER(struct cmd_csum_result, 4452 mode, "set"); 4453 cmdline_parse_token_string_t cmd_csum_proto = 4454 TOKEN_STRING_INITIALIZER(struct cmd_csum_result, 4455 proto, "ip#tcp#udp#sctp#outer-ip#outer-udp"); 4456 cmdline_parse_token_string_t cmd_csum_hwsw = 4457 TOKEN_STRING_INITIALIZER(struct cmd_csum_result, 4458 hwsw, "hw#sw"); 4459 cmdline_parse_token_num_t cmd_csum_portid = 4460 TOKEN_NUM_INITIALIZER(struct cmd_csum_result, 4461 port_id, UINT16); 4462 4463 cmdline_parse_inst_t cmd_csum_set = { 4464 .f = cmd_csum_parsed, 4465 .data = NULL, 4466 .help_str = "csum set ip|tcp|udp|sctp|outer-ip|outer-udp hw|sw <port_id>: " 4467 "Enable/Disable hardware calculation of L3/L4 checksum when " 4468 "using csum forward engine", 4469 .tokens = { 4470 (void *)&cmd_csum_csum, 4471 (void *)&cmd_csum_mode, 4472 (void *)&cmd_csum_proto, 4473 (void *)&cmd_csum_hwsw, 4474 (void *)&cmd_csum_portid, 4475 NULL, 4476 }, 4477 }; 4478 4479 cmdline_parse_token_string_t cmd_csum_mode_show = 4480 TOKEN_STRING_INITIALIZER(struct cmd_csum_result, 4481 mode, "show"); 4482 4483 cmdline_parse_inst_t cmd_csum_show = { 4484 .f = cmd_csum_parsed, 4485 .data = NULL, 4486 .help_str = "csum show <port_id>: Show checksum offload configuration", 4487 .tokens = { 4488 (void *)&cmd_csum_csum, 4489 (void *)&cmd_csum_mode_show, 4490 (void *)&cmd_csum_portid, 4491 NULL, 4492 }, 4493 }; 4494 4495 /* Enable/disable tunnel parsing */ 4496 struct cmd_csum_tunnel_result { 4497 cmdline_fixed_string_t csum; 4498 cmdline_fixed_string_t parse; 4499 cmdline_fixed_string_t onoff; 4500 portid_t port_id; 4501 }; 4502 4503 static void 4504 cmd_csum_tunnel_parsed(void *parsed_result, 4505 __attribute__((unused)) struct cmdline *cl, 4506 __attribute__((unused)) void *data) 4507 { 4508 struct cmd_csum_tunnel_result *res = parsed_result; 4509 4510 if (port_id_is_invalid(res->port_id, ENABLED_WARN)) 4511 return; 4512 4513 if (!strcmp(res->onoff, "on")) 4514 ports[res->port_id].parse_tunnel = 1; 4515 else 4516 ports[res->port_id].parse_tunnel = 0; 4517 4518 csum_show(res->port_id); 4519 } 4520 4521 cmdline_parse_token_string_t cmd_csum_tunnel_csum = 4522 TOKEN_STRING_INITIALIZER(struct cmd_csum_tunnel_result, 4523 csum, "csum"); 4524 cmdline_parse_token_string_t cmd_csum_tunnel_parse = 4525 TOKEN_STRING_INITIALIZER(struct cmd_csum_tunnel_result, 4526 parse, "parse-tunnel"); 4527 cmdline_parse_token_string_t cmd_csum_tunnel_onoff = 4528 TOKEN_STRING_INITIALIZER(struct cmd_csum_tunnel_result, 4529 onoff, "on#off"); 4530 cmdline_parse_token_num_t cmd_csum_tunnel_portid = 4531 TOKEN_NUM_INITIALIZER(struct cmd_csum_tunnel_result, 4532 port_id, UINT16); 4533 4534 cmdline_parse_inst_t cmd_csum_tunnel = { 4535 .f = cmd_csum_tunnel_parsed, 4536 .data = NULL, 4537 .help_str = "csum parse-tunnel on|off <port_id>: " 4538 "Enable/Disable parsing of tunnels for csum engine", 4539 .tokens = { 4540 (void *)&cmd_csum_tunnel_csum, 4541 (void *)&cmd_csum_tunnel_parse, 4542 (void *)&cmd_csum_tunnel_onoff, 4543 (void *)&cmd_csum_tunnel_portid, 4544 NULL, 4545 }, 4546 }; 4547 4548 /* *** ENABLE HARDWARE SEGMENTATION IN TX NON-TUNNELED PACKETS *** */ 4549 struct cmd_tso_set_result { 4550 cmdline_fixed_string_t tso; 4551 cmdline_fixed_string_t mode; 4552 uint16_t tso_segsz; 4553 portid_t port_id; 4554 }; 4555 4556 static void 4557 cmd_tso_set_parsed(void *parsed_result, 4558 __attribute__((unused)) struct cmdline *cl, 4559 __attribute__((unused)) void *data) 4560 { 4561 struct cmd_tso_set_result *res = parsed_result; 4562 struct rte_eth_dev_info dev_info; 4563 4564 if (port_id_is_invalid(res->port_id, ENABLED_WARN)) 4565 return; 4566 if (!port_is_stopped(res->port_id)) { 4567 printf("Please stop port %d first\n", res->port_id); 4568 return; 4569 } 4570 4571 if (!strcmp(res->mode, "set")) 4572 ports[res->port_id].tso_segsz = res->tso_segsz; 4573 4574 rte_eth_dev_info_get(res->port_id, &dev_info); 4575 if ((ports[res->port_id].tso_segsz != 0) && 4576 (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_TCP_TSO) == 0) { 4577 printf("Error: TSO is not supported by port %d\n", 4578 res->port_id); 4579 return; 4580 } 4581 4582 if (ports[res->port_id].tso_segsz == 0) { 4583 ports[res->port_id].dev_conf.txmode.offloads &= 4584 ~DEV_TX_OFFLOAD_TCP_TSO; 4585 printf("TSO for non-tunneled packets is disabled\n"); 4586 } else { 4587 ports[res->port_id].dev_conf.txmode.offloads |= 4588 DEV_TX_OFFLOAD_TCP_TSO; 4589 printf("TSO segment size for non-tunneled packets is %d\n", 4590 ports[res->port_id].tso_segsz); 4591 } 4592 4593 /* display warnings if configuration is not supported by the NIC */ 4594 rte_eth_dev_info_get(res->port_id, &dev_info); 4595 if ((ports[res->port_id].tso_segsz != 0) && 4596 (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_TCP_TSO) == 0) { 4597 printf("Warning: TSO enabled but not " 4598 "supported by port %d\n", res->port_id); 4599 } 4600 4601 cmd_reconfig_device_queue(res->port_id, 1, 1); 4602 } 4603 4604 cmdline_parse_token_string_t cmd_tso_set_tso = 4605 TOKEN_STRING_INITIALIZER(struct cmd_tso_set_result, 4606 tso, "tso"); 4607 cmdline_parse_token_string_t cmd_tso_set_mode = 4608 TOKEN_STRING_INITIALIZER(struct cmd_tso_set_result, 4609 mode, "set"); 4610 cmdline_parse_token_num_t cmd_tso_set_tso_segsz = 4611 TOKEN_NUM_INITIALIZER(struct cmd_tso_set_result, 4612 tso_segsz, UINT16); 4613 cmdline_parse_token_num_t cmd_tso_set_portid = 4614 TOKEN_NUM_INITIALIZER(struct cmd_tso_set_result, 4615 port_id, UINT16); 4616 4617 cmdline_parse_inst_t cmd_tso_set = { 4618 .f = cmd_tso_set_parsed, 4619 .data = NULL, 4620 .help_str = "tso set <tso_segsz> <port_id>: " 4621 "Set TSO segment size of non-tunneled packets for csum engine " 4622 "(0 to disable)", 4623 .tokens = { 4624 (void *)&cmd_tso_set_tso, 4625 (void *)&cmd_tso_set_mode, 4626 (void *)&cmd_tso_set_tso_segsz, 4627 (void *)&cmd_tso_set_portid, 4628 NULL, 4629 }, 4630 }; 4631 4632 cmdline_parse_token_string_t cmd_tso_show_mode = 4633 TOKEN_STRING_INITIALIZER(struct cmd_tso_set_result, 4634 mode, "show"); 4635 4636 4637 cmdline_parse_inst_t cmd_tso_show = { 4638 .f = cmd_tso_set_parsed, 4639 .data = NULL, 4640 .help_str = "tso show <port_id>: " 4641 "Show TSO segment size of non-tunneled packets for csum engine", 4642 .tokens = { 4643 (void *)&cmd_tso_set_tso, 4644 (void *)&cmd_tso_show_mode, 4645 (void *)&cmd_tso_set_portid, 4646 NULL, 4647 }, 4648 }; 4649 4650 /* *** ENABLE HARDWARE SEGMENTATION IN TX TUNNELED PACKETS *** */ 4651 struct cmd_tunnel_tso_set_result { 4652 cmdline_fixed_string_t tso; 4653 cmdline_fixed_string_t mode; 4654 uint16_t tso_segsz; 4655 portid_t port_id; 4656 }; 4657 4658 static struct rte_eth_dev_info 4659 check_tunnel_tso_nic_support(portid_t port_id) 4660 { 4661 struct rte_eth_dev_info dev_info; 4662 4663 rte_eth_dev_info_get(port_id, &dev_info); 4664 if (!(dev_info.tx_offload_capa & DEV_TX_OFFLOAD_VXLAN_TNL_TSO)) 4665 printf("Warning: VXLAN TUNNEL TSO not supported therefore " 4666 "not enabled for port %d\n", port_id); 4667 if (!(dev_info.tx_offload_capa & DEV_TX_OFFLOAD_GRE_TNL_TSO)) 4668 printf("Warning: GRE TUNNEL TSO not supported therefore " 4669 "not enabled for port %d\n", port_id); 4670 if (!(dev_info.tx_offload_capa & DEV_TX_OFFLOAD_IPIP_TNL_TSO)) 4671 printf("Warning: IPIP TUNNEL TSO not supported therefore " 4672 "not enabled for port %d\n", port_id); 4673 if (!(dev_info.tx_offload_capa & DEV_TX_OFFLOAD_GENEVE_TNL_TSO)) 4674 printf("Warning: GENEVE TUNNEL TSO not supported therefore " 4675 "not enabled for port %d\n", port_id); 4676 if (!(dev_info.tx_offload_capa & DEV_TX_OFFLOAD_IP_TNL_TSO)) 4677 printf("Warning: IP TUNNEL TSO not supported therefore " 4678 "not enabled for port %d\n", port_id); 4679 if (!(dev_info.tx_offload_capa & DEV_TX_OFFLOAD_UDP_TNL_TSO)) 4680 printf("Warning: UDP TUNNEL TSO not supported therefore " 4681 "not enabled for port %d\n", port_id); 4682 return dev_info; 4683 } 4684 4685 static void 4686 cmd_tunnel_tso_set_parsed(void *parsed_result, 4687 __attribute__((unused)) struct cmdline *cl, 4688 __attribute__((unused)) void *data) 4689 { 4690 struct cmd_tunnel_tso_set_result *res = parsed_result; 4691 struct rte_eth_dev_info dev_info; 4692 4693 if (port_id_is_invalid(res->port_id, ENABLED_WARN)) 4694 return; 4695 if (!port_is_stopped(res->port_id)) { 4696 printf("Please stop port %d first\n", res->port_id); 4697 return; 4698 } 4699 4700 if (!strcmp(res->mode, "set")) 4701 ports[res->port_id].tunnel_tso_segsz = res->tso_segsz; 4702 4703 dev_info = check_tunnel_tso_nic_support(res->port_id); 4704 if (ports[res->port_id].tunnel_tso_segsz == 0) { 4705 ports[res->port_id].dev_conf.txmode.offloads &= 4706 ~(DEV_TX_OFFLOAD_VXLAN_TNL_TSO | 4707 DEV_TX_OFFLOAD_GRE_TNL_TSO | 4708 DEV_TX_OFFLOAD_IPIP_TNL_TSO | 4709 DEV_TX_OFFLOAD_GENEVE_TNL_TSO | 4710 DEV_TX_OFFLOAD_IP_TNL_TSO | 4711 DEV_TX_OFFLOAD_UDP_TNL_TSO); 4712 printf("TSO for tunneled packets is disabled\n"); 4713 } else { 4714 uint64_t tso_offloads = (DEV_TX_OFFLOAD_VXLAN_TNL_TSO | 4715 DEV_TX_OFFLOAD_GRE_TNL_TSO | 4716 DEV_TX_OFFLOAD_IPIP_TNL_TSO | 4717 DEV_TX_OFFLOAD_GENEVE_TNL_TSO | 4718 DEV_TX_OFFLOAD_IP_TNL_TSO | 4719 DEV_TX_OFFLOAD_UDP_TNL_TSO); 4720 4721 ports[res->port_id].dev_conf.txmode.offloads |= 4722 (tso_offloads & dev_info.tx_offload_capa); 4723 printf("TSO segment size for tunneled packets is %d\n", 4724 ports[res->port_id].tunnel_tso_segsz); 4725 4726 /* Below conditions are needed to make it work: 4727 * (1) tunnel TSO is supported by the NIC; 4728 * (2) "csum parse_tunnel" must be set so that tunneled pkts 4729 * are recognized; 4730 * (3) for tunneled pkts with outer L3 of IPv4, 4731 * "csum set outer-ip" must be set to hw, because after tso, 4732 * total_len of outer IP header is changed, and the checksum 4733 * of outer IP header calculated by sw should be wrong; that 4734 * is not necessary for IPv6 tunneled pkts because there's no 4735 * checksum in IP header anymore. 4736 */ 4737 4738 if (!ports[res->port_id].parse_tunnel) 4739 printf("Warning: csum parse_tunnel must be set " 4740 "so that tunneled packets are recognized\n"); 4741 if (!(ports[res->port_id].dev_conf.txmode.offloads & 4742 DEV_TX_OFFLOAD_OUTER_IPV4_CKSUM)) 4743 printf("Warning: csum set outer-ip must be set to hw " 4744 "if outer L3 is IPv4; not necessary for IPv6\n"); 4745 } 4746 4747 cmd_reconfig_device_queue(res->port_id, 1, 1); 4748 } 4749 4750 cmdline_parse_token_string_t cmd_tunnel_tso_set_tso = 4751 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_tso_set_result, 4752 tso, "tunnel_tso"); 4753 cmdline_parse_token_string_t cmd_tunnel_tso_set_mode = 4754 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_tso_set_result, 4755 mode, "set"); 4756 cmdline_parse_token_num_t cmd_tunnel_tso_set_tso_segsz = 4757 TOKEN_NUM_INITIALIZER(struct cmd_tunnel_tso_set_result, 4758 tso_segsz, UINT16); 4759 cmdline_parse_token_num_t cmd_tunnel_tso_set_portid = 4760 TOKEN_NUM_INITIALIZER(struct cmd_tunnel_tso_set_result, 4761 port_id, UINT16); 4762 4763 cmdline_parse_inst_t cmd_tunnel_tso_set = { 4764 .f = cmd_tunnel_tso_set_parsed, 4765 .data = NULL, 4766 .help_str = "tunnel_tso set <tso_segsz> <port_id>: " 4767 "Set TSO segment size of tunneled packets for csum engine " 4768 "(0 to disable)", 4769 .tokens = { 4770 (void *)&cmd_tunnel_tso_set_tso, 4771 (void *)&cmd_tunnel_tso_set_mode, 4772 (void *)&cmd_tunnel_tso_set_tso_segsz, 4773 (void *)&cmd_tunnel_tso_set_portid, 4774 NULL, 4775 }, 4776 }; 4777 4778 cmdline_parse_token_string_t cmd_tunnel_tso_show_mode = 4779 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_tso_set_result, 4780 mode, "show"); 4781 4782 4783 cmdline_parse_inst_t cmd_tunnel_tso_show = { 4784 .f = cmd_tunnel_tso_set_parsed, 4785 .data = NULL, 4786 .help_str = "tunnel_tso show <port_id> " 4787 "Show TSO segment size of tunneled packets for csum engine", 4788 .tokens = { 4789 (void *)&cmd_tunnel_tso_set_tso, 4790 (void *)&cmd_tunnel_tso_show_mode, 4791 (void *)&cmd_tunnel_tso_set_portid, 4792 NULL, 4793 }, 4794 }; 4795 4796 /* *** SET GRO FOR A PORT *** */ 4797 struct cmd_gro_enable_result { 4798 cmdline_fixed_string_t cmd_set; 4799 cmdline_fixed_string_t cmd_port; 4800 cmdline_fixed_string_t cmd_keyword; 4801 cmdline_fixed_string_t cmd_onoff; 4802 portid_t cmd_pid; 4803 }; 4804 4805 static void 4806 cmd_gro_enable_parsed(void *parsed_result, 4807 __attribute__((unused)) struct cmdline *cl, 4808 __attribute__((unused)) void *data) 4809 { 4810 struct cmd_gro_enable_result *res; 4811 4812 res = parsed_result; 4813 if (!strcmp(res->cmd_keyword, "gro")) 4814 setup_gro(res->cmd_onoff, res->cmd_pid); 4815 } 4816 4817 cmdline_parse_token_string_t cmd_gro_enable_set = 4818 TOKEN_STRING_INITIALIZER(struct cmd_gro_enable_result, 4819 cmd_set, "set"); 4820 cmdline_parse_token_string_t cmd_gro_enable_port = 4821 TOKEN_STRING_INITIALIZER(struct cmd_gro_enable_result, 4822 cmd_keyword, "port"); 4823 cmdline_parse_token_num_t cmd_gro_enable_pid = 4824 TOKEN_NUM_INITIALIZER(struct cmd_gro_enable_result, 4825 cmd_pid, UINT16); 4826 cmdline_parse_token_string_t cmd_gro_enable_keyword = 4827 TOKEN_STRING_INITIALIZER(struct cmd_gro_enable_result, 4828 cmd_keyword, "gro"); 4829 cmdline_parse_token_string_t cmd_gro_enable_onoff = 4830 TOKEN_STRING_INITIALIZER(struct cmd_gro_enable_result, 4831 cmd_onoff, "on#off"); 4832 4833 cmdline_parse_inst_t cmd_gro_enable = { 4834 .f = cmd_gro_enable_parsed, 4835 .data = NULL, 4836 .help_str = "set port <port_id> gro on|off", 4837 .tokens = { 4838 (void *)&cmd_gro_enable_set, 4839 (void *)&cmd_gro_enable_port, 4840 (void *)&cmd_gro_enable_pid, 4841 (void *)&cmd_gro_enable_keyword, 4842 (void *)&cmd_gro_enable_onoff, 4843 NULL, 4844 }, 4845 }; 4846 4847 /* *** DISPLAY GRO CONFIGURATION *** */ 4848 struct cmd_gro_show_result { 4849 cmdline_fixed_string_t cmd_show; 4850 cmdline_fixed_string_t cmd_port; 4851 cmdline_fixed_string_t cmd_keyword; 4852 portid_t cmd_pid; 4853 }; 4854 4855 static void 4856 cmd_gro_show_parsed(void *parsed_result, 4857 __attribute__((unused)) struct cmdline *cl, 4858 __attribute__((unused)) void *data) 4859 { 4860 struct cmd_gro_show_result *res; 4861 4862 res = parsed_result; 4863 if (!strcmp(res->cmd_keyword, "gro")) 4864 show_gro(res->cmd_pid); 4865 } 4866 4867 cmdline_parse_token_string_t cmd_gro_show_show = 4868 TOKEN_STRING_INITIALIZER(struct cmd_gro_show_result, 4869 cmd_show, "show"); 4870 cmdline_parse_token_string_t cmd_gro_show_port = 4871 TOKEN_STRING_INITIALIZER(struct cmd_gro_show_result, 4872 cmd_port, "port"); 4873 cmdline_parse_token_num_t cmd_gro_show_pid = 4874 TOKEN_NUM_INITIALIZER(struct cmd_gro_show_result, 4875 cmd_pid, UINT16); 4876 cmdline_parse_token_string_t cmd_gro_show_keyword = 4877 TOKEN_STRING_INITIALIZER(struct cmd_gro_show_result, 4878 cmd_keyword, "gro"); 4879 4880 cmdline_parse_inst_t cmd_gro_show = { 4881 .f = cmd_gro_show_parsed, 4882 .data = NULL, 4883 .help_str = "show port <port_id> gro", 4884 .tokens = { 4885 (void *)&cmd_gro_show_show, 4886 (void *)&cmd_gro_show_port, 4887 (void *)&cmd_gro_show_pid, 4888 (void *)&cmd_gro_show_keyword, 4889 NULL, 4890 }, 4891 }; 4892 4893 /* *** SET FLUSH CYCLES FOR GRO *** */ 4894 struct cmd_gro_flush_result { 4895 cmdline_fixed_string_t cmd_set; 4896 cmdline_fixed_string_t cmd_keyword; 4897 cmdline_fixed_string_t cmd_flush; 4898 uint8_t cmd_cycles; 4899 }; 4900 4901 static void 4902 cmd_gro_flush_parsed(void *parsed_result, 4903 __attribute__((unused)) struct cmdline *cl, 4904 __attribute__((unused)) void *data) 4905 { 4906 struct cmd_gro_flush_result *res; 4907 4908 res = parsed_result; 4909 if ((!strcmp(res->cmd_keyword, "gro")) && 4910 (!strcmp(res->cmd_flush, "flush"))) 4911 setup_gro_flush_cycles(res->cmd_cycles); 4912 } 4913 4914 cmdline_parse_token_string_t cmd_gro_flush_set = 4915 TOKEN_STRING_INITIALIZER(struct cmd_gro_flush_result, 4916 cmd_set, "set"); 4917 cmdline_parse_token_string_t cmd_gro_flush_keyword = 4918 TOKEN_STRING_INITIALIZER(struct cmd_gro_flush_result, 4919 cmd_keyword, "gro"); 4920 cmdline_parse_token_string_t cmd_gro_flush_flush = 4921 TOKEN_STRING_INITIALIZER(struct cmd_gro_flush_result, 4922 cmd_flush, "flush"); 4923 cmdline_parse_token_num_t cmd_gro_flush_cycles = 4924 TOKEN_NUM_INITIALIZER(struct cmd_gro_flush_result, 4925 cmd_cycles, UINT8); 4926 4927 cmdline_parse_inst_t cmd_gro_flush = { 4928 .f = cmd_gro_flush_parsed, 4929 .data = NULL, 4930 .help_str = "set gro flush <cycles>", 4931 .tokens = { 4932 (void *)&cmd_gro_flush_set, 4933 (void *)&cmd_gro_flush_keyword, 4934 (void *)&cmd_gro_flush_flush, 4935 (void *)&cmd_gro_flush_cycles, 4936 NULL, 4937 }, 4938 }; 4939 4940 /* *** ENABLE/DISABLE GSO *** */ 4941 struct cmd_gso_enable_result { 4942 cmdline_fixed_string_t cmd_set; 4943 cmdline_fixed_string_t cmd_port; 4944 cmdline_fixed_string_t cmd_keyword; 4945 cmdline_fixed_string_t cmd_mode; 4946 portid_t cmd_pid; 4947 }; 4948 4949 static void 4950 cmd_gso_enable_parsed(void *parsed_result, 4951 __attribute__((unused)) struct cmdline *cl, 4952 __attribute__((unused)) void *data) 4953 { 4954 struct cmd_gso_enable_result *res; 4955 4956 res = parsed_result; 4957 if (!strcmp(res->cmd_keyword, "gso")) 4958 setup_gso(res->cmd_mode, res->cmd_pid); 4959 } 4960 4961 cmdline_parse_token_string_t cmd_gso_enable_set = 4962 TOKEN_STRING_INITIALIZER(struct cmd_gso_enable_result, 4963 cmd_set, "set"); 4964 cmdline_parse_token_string_t cmd_gso_enable_port = 4965 TOKEN_STRING_INITIALIZER(struct cmd_gso_enable_result, 4966 cmd_port, "port"); 4967 cmdline_parse_token_string_t cmd_gso_enable_keyword = 4968 TOKEN_STRING_INITIALIZER(struct cmd_gso_enable_result, 4969 cmd_keyword, "gso"); 4970 cmdline_parse_token_string_t cmd_gso_enable_mode = 4971 TOKEN_STRING_INITIALIZER(struct cmd_gso_enable_result, 4972 cmd_mode, "on#off"); 4973 cmdline_parse_token_num_t cmd_gso_enable_pid = 4974 TOKEN_NUM_INITIALIZER(struct cmd_gso_enable_result, 4975 cmd_pid, UINT16); 4976 4977 cmdline_parse_inst_t cmd_gso_enable = { 4978 .f = cmd_gso_enable_parsed, 4979 .data = NULL, 4980 .help_str = "set port <port_id> gso on|off", 4981 .tokens = { 4982 (void *)&cmd_gso_enable_set, 4983 (void *)&cmd_gso_enable_port, 4984 (void *)&cmd_gso_enable_pid, 4985 (void *)&cmd_gso_enable_keyword, 4986 (void *)&cmd_gso_enable_mode, 4987 NULL, 4988 }, 4989 }; 4990 4991 /* *** SET MAX PACKET LENGTH FOR GSO SEGMENTS *** */ 4992 struct cmd_gso_size_result { 4993 cmdline_fixed_string_t cmd_set; 4994 cmdline_fixed_string_t cmd_keyword; 4995 cmdline_fixed_string_t cmd_segsz; 4996 uint16_t cmd_size; 4997 }; 4998 4999 static void 5000 cmd_gso_size_parsed(void *parsed_result, 5001 __attribute__((unused)) struct cmdline *cl, 5002 __attribute__((unused)) void *data) 5003 { 5004 struct cmd_gso_size_result *res = parsed_result; 5005 5006 if (test_done == 0) { 5007 printf("Before setting GSO segsz, please first" 5008 " stop fowarding\n"); 5009 return; 5010 } 5011 5012 if (!strcmp(res->cmd_keyword, "gso") && 5013 !strcmp(res->cmd_segsz, "segsz")) { 5014 if (res->cmd_size < RTE_GSO_SEG_SIZE_MIN) 5015 printf("gso_size should be larger than %zu." 5016 " Please input a legal value\n", 5017 RTE_GSO_SEG_SIZE_MIN); 5018 else 5019 gso_max_segment_size = res->cmd_size; 5020 } 5021 } 5022 5023 cmdline_parse_token_string_t cmd_gso_size_set = 5024 TOKEN_STRING_INITIALIZER(struct cmd_gso_size_result, 5025 cmd_set, "set"); 5026 cmdline_parse_token_string_t cmd_gso_size_keyword = 5027 TOKEN_STRING_INITIALIZER(struct cmd_gso_size_result, 5028 cmd_keyword, "gso"); 5029 cmdline_parse_token_string_t cmd_gso_size_segsz = 5030 TOKEN_STRING_INITIALIZER(struct cmd_gso_size_result, 5031 cmd_segsz, "segsz"); 5032 cmdline_parse_token_num_t cmd_gso_size_size = 5033 TOKEN_NUM_INITIALIZER(struct cmd_gso_size_result, 5034 cmd_size, UINT16); 5035 5036 cmdline_parse_inst_t cmd_gso_size = { 5037 .f = cmd_gso_size_parsed, 5038 .data = NULL, 5039 .help_str = "set gso segsz <length>", 5040 .tokens = { 5041 (void *)&cmd_gso_size_set, 5042 (void *)&cmd_gso_size_keyword, 5043 (void *)&cmd_gso_size_segsz, 5044 (void *)&cmd_gso_size_size, 5045 NULL, 5046 }, 5047 }; 5048 5049 /* *** SHOW GSO CONFIGURATION *** */ 5050 struct cmd_gso_show_result { 5051 cmdline_fixed_string_t cmd_show; 5052 cmdline_fixed_string_t cmd_port; 5053 cmdline_fixed_string_t cmd_keyword; 5054 portid_t cmd_pid; 5055 }; 5056 5057 static void 5058 cmd_gso_show_parsed(void *parsed_result, 5059 __attribute__((unused)) struct cmdline *cl, 5060 __attribute__((unused)) void *data) 5061 { 5062 struct cmd_gso_show_result *res = parsed_result; 5063 5064 if (!rte_eth_dev_is_valid_port(res->cmd_pid)) { 5065 printf("invalid port id %u\n", res->cmd_pid); 5066 return; 5067 } 5068 if (!strcmp(res->cmd_keyword, "gso")) { 5069 if (gso_ports[res->cmd_pid].enable) { 5070 printf("Max GSO'd packet size: %uB\n" 5071 "Supported GSO types: TCP/IPv4, " 5072 "UDP/IPv4, VxLAN with inner " 5073 "TCP/IPv4 packet, GRE with inner " 5074 "TCP/IPv4 packet\n", 5075 gso_max_segment_size); 5076 } else 5077 printf("GSO is not enabled on Port %u\n", res->cmd_pid); 5078 } 5079 } 5080 5081 cmdline_parse_token_string_t cmd_gso_show_show = 5082 TOKEN_STRING_INITIALIZER(struct cmd_gso_show_result, 5083 cmd_show, "show"); 5084 cmdline_parse_token_string_t cmd_gso_show_port = 5085 TOKEN_STRING_INITIALIZER(struct cmd_gso_show_result, 5086 cmd_port, "port"); 5087 cmdline_parse_token_string_t cmd_gso_show_keyword = 5088 TOKEN_STRING_INITIALIZER(struct cmd_gso_show_result, 5089 cmd_keyword, "gso"); 5090 cmdline_parse_token_num_t cmd_gso_show_pid = 5091 TOKEN_NUM_INITIALIZER(struct cmd_gso_show_result, 5092 cmd_pid, UINT16); 5093 5094 cmdline_parse_inst_t cmd_gso_show = { 5095 .f = cmd_gso_show_parsed, 5096 .data = NULL, 5097 .help_str = "show port <port_id> gso", 5098 .tokens = { 5099 (void *)&cmd_gso_show_show, 5100 (void *)&cmd_gso_show_port, 5101 (void *)&cmd_gso_show_pid, 5102 (void *)&cmd_gso_show_keyword, 5103 NULL, 5104 }, 5105 }; 5106 5107 /* *** ENABLE/DISABLE FLUSH ON RX STREAMS *** */ 5108 struct cmd_set_flush_rx { 5109 cmdline_fixed_string_t set; 5110 cmdline_fixed_string_t flush_rx; 5111 cmdline_fixed_string_t mode; 5112 }; 5113 5114 static void 5115 cmd_set_flush_rx_parsed(void *parsed_result, 5116 __attribute__((unused)) struct cmdline *cl, 5117 __attribute__((unused)) void *data) 5118 { 5119 struct cmd_set_flush_rx *res = parsed_result; 5120 no_flush_rx = (uint8_t)((strcmp(res->mode, "on") == 0) ? 0 : 1); 5121 } 5122 5123 cmdline_parse_token_string_t cmd_setflushrx_set = 5124 TOKEN_STRING_INITIALIZER(struct cmd_set_flush_rx, 5125 set, "set"); 5126 cmdline_parse_token_string_t cmd_setflushrx_flush_rx = 5127 TOKEN_STRING_INITIALIZER(struct cmd_set_flush_rx, 5128 flush_rx, "flush_rx"); 5129 cmdline_parse_token_string_t cmd_setflushrx_mode = 5130 TOKEN_STRING_INITIALIZER(struct cmd_set_flush_rx, 5131 mode, "on#off"); 5132 5133 5134 cmdline_parse_inst_t cmd_set_flush_rx = { 5135 .f = cmd_set_flush_rx_parsed, 5136 .help_str = "set flush_rx on|off: Enable/Disable flush on rx streams", 5137 .data = NULL, 5138 .tokens = { 5139 (void *)&cmd_setflushrx_set, 5140 (void *)&cmd_setflushrx_flush_rx, 5141 (void *)&cmd_setflushrx_mode, 5142 NULL, 5143 }, 5144 }; 5145 5146 /* *** ENABLE/DISABLE LINK STATUS CHECK *** */ 5147 struct cmd_set_link_check { 5148 cmdline_fixed_string_t set; 5149 cmdline_fixed_string_t link_check; 5150 cmdline_fixed_string_t mode; 5151 }; 5152 5153 static void 5154 cmd_set_link_check_parsed(void *parsed_result, 5155 __attribute__((unused)) struct cmdline *cl, 5156 __attribute__((unused)) void *data) 5157 { 5158 struct cmd_set_link_check *res = parsed_result; 5159 no_link_check = (uint8_t)((strcmp(res->mode, "on") == 0) ? 0 : 1); 5160 } 5161 5162 cmdline_parse_token_string_t cmd_setlinkcheck_set = 5163 TOKEN_STRING_INITIALIZER(struct cmd_set_link_check, 5164 set, "set"); 5165 cmdline_parse_token_string_t cmd_setlinkcheck_link_check = 5166 TOKEN_STRING_INITIALIZER(struct cmd_set_link_check, 5167 link_check, "link_check"); 5168 cmdline_parse_token_string_t cmd_setlinkcheck_mode = 5169 TOKEN_STRING_INITIALIZER(struct cmd_set_link_check, 5170 mode, "on#off"); 5171 5172 5173 cmdline_parse_inst_t cmd_set_link_check = { 5174 .f = cmd_set_link_check_parsed, 5175 .help_str = "set link_check on|off: Enable/Disable link status check " 5176 "when starting/stopping a port", 5177 .data = NULL, 5178 .tokens = { 5179 (void *)&cmd_setlinkcheck_set, 5180 (void *)&cmd_setlinkcheck_link_check, 5181 (void *)&cmd_setlinkcheck_mode, 5182 NULL, 5183 }, 5184 }; 5185 5186 /* *** SET NIC BYPASS MODE *** */ 5187 struct cmd_set_bypass_mode_result { 5188 cmdline_fixed_string_t set; 5189 cmdline_fixed_string_t bypass; 5190 cmdline_fixed_string_t mode; 5191 cmdline_fixed_string_t value; 5192 portid_t port_id; 5193 }; 5194 5195 static void 5196 cmd_set_bypass_mode_parsed(void *parsed_result, 5197 __attribute__((unused)) struct cmdline *cl, 5198 __attribute__((unused)) void *data) 5199 { 5200 struct cmd_set_bypass_mode_result *res = parsed_result; 5201 portid_t port_id = res->port_id; 5202 int32_t rc = -EINVAL; 5203 5204 #if defined RTE_LIBRTE_IXGBE_PMD && defined RTE_LIBRTE_IXGBE_BYPASS 5205 uint32_t bypass_mode = RTE_PMD_IXGBE_BYPASS_MODE_NORMAL; 5206 5207 if (!strcmp(res->value, "bypass")) 5208 bypass_mode = RTE_PMD_IXGBE_BYPASS_MODE_BYPASS; 5209 else if (!strcmp(res->value, "isolate")) 5210 bypass_mode = RTE_PMD_IXGBE_BYPASS_MODE_ISOLATE; 5211 else 5212 bypass_mode = RTE_PMD_IXGBE_BYPASS_MODE_NORMAL; 5213 5214 /* Set the bypass mode for the relevant port. */ 5215 rc = rte_pmd_ixgbe_bypass_state_set(port_id, &bypass_mode); 5216 #endif 5217 if (rc != 0) 5218 printf("\t Failed to set bypass mode for port = %d.\n", port_id); 5219 } 5220 5221 cmdline_parse_token_string_t cmd_setbypass_mode_set = 5222 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_mode_result, 5223 set, "set"); 5224 cmdline_parse_token_string_t cmd_setbypass_mode_bypass = 5225 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_mode_result, 5226 bypass, "bypass"); 5227 cmdline_parse_token_string_t cmd_setbypass_mode_mode = 5228 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_mode_result, 5229 mode, "mode"); 5230 cmdline_parse_token_string_t cmd_setbypass_mode_value = 5231 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_mode_result, 5232 value, "normal#bypass#isolate"); 5233 cmdline_parse_token_num_t cmd_setbypass_mode_port = 5234 TOKEN_NUM_INITIALIZER(struct cmd_set_bypass_mode_result, 5235 port_id, UINT16); 5236 5237 cmdline_parse_inst_t cmd_set_bypass_mode = { 5238 .f = cmd_set_bypass_mode_parsed, 5239 .help_str = "set bypass mode normal|bypass|isolate <port_id>: " 5240 "Set the NIC bypass mode for port_id", 5241 .data = NULL, 5242 .tokens = { 5243 (void *)&cmd_setbypass_mode_set, 5244 (void *)&cmd_setbypass_mode_bypass, 5245 (void *)&cmd_setbypass_mode_mode, 5246 (void *)&cmd_setbypass_mode_value, 5247 (void *)&cmd_setbypass_mode_port, 5248 NULL, 5249 }, 5250 }; 5251 5252 /* *** SET NIC BYPASS EVENT *** */ 5253 struct cmd_set_bypass_event_result { 5254 cmdline_fixed_string_t set; 5255 cmdline_fixed_string_t bypass; 5256 cmdline_fixed_string_t event; 5257 cmdline_fixed_string_t event_value; 5258 cmdline_fixed_string_t mode; 5259 cmdline_fixed_string_t mode_value; 5260 portid_t port_id; 5261 }; 5262 5263 static void 5264 cmd_set_bypass_event_parsed(void *parsed_result, 5265 __attribute__((unused)) struct cmdline *cl, 5266 __attribute__((unused)) void *data) 5267 { 5268 int32_t rc = -EINVAL; 5269 struct cmd_set_bypass_event_result *res = parsed_result; 5270 portid_t port_id = res->port_id; 5271 5272 #if defined RTE_LIBRTE_IXGBE_PMD && defined RTE_LIBRTE_IXGBE_BYPASS 5273 uint32_t bypass_event = RTE_PMD_IXGBE_BYPASS_EVENT_NONE; 5274 uint32_t bypass_mode = RTE_PMD_IXGBE_BYPASS_MODE_NORMAL; 5275 5276 if (!strcmp(res->event_value, "timeout")) 5277 bypass_event = RTE_PMD_IXGBE_BYPASS_EVENT_TIMEOUT; 5278 else if (!strcmp(res->event_value, "os_on")) 5279 bypass_event = RTE_PMD_IXGBE_BYPASS_EVENT_OS_ON; 5280 else if (!strcmp(res->event_value, "os_off")) 5281 bypass_event = RTE_PMD_IXGBE_BYPASS_EVENT_OS_OFF; 5282 else if (!strcmp(res->event_value, "power_on")) 5283 bypass_event = RTE_PMD_IXGBE_BYPASS_EVENT_POWER_ON; 5284 else if (!strcmp(res->event_value, "power_off")) 5285 bypass_event = RTE_PMD_IXGBE_BYPASS_EVENT_POWER_OFF; 5286 else 5287 bypass_event = RTE_PMD_IXGBE_BYPASS_EVENT_NONE; 5288 5289 if (!strcmp(res->mode_value, "bypass")) 5290 bypass_mode = RTE_PMD_IXGBE_BYPASS_MODE_BYPASS; 5291 else if (!strcmp(res->mode_value, "isolate")) 5292 bypass_mode = RTE_PMD_IXGBE_BYPASS_MODE_ISOLATE; 5293 else 5294 bypass_mode = RTE_PMD_IXGBE_BYPASS_MODE_NORMAL; 5295 5296 /* Set the watchdog timeout. */ 5297 if (bypass_event == RTE_PMD_IXGBE_BYPASS_EVENT_TIMEOUT) { 5298 5299 rc = -EINVAL; 5300 if (RTE_PMD_IXGBE_BYPASS_TMT_VALID(bypass_timeout)) { 5301 rc = rte_pmd_ixgbe_bypass_wd_timeout_store(port_id, 5302 bypass_timeout); 5303 } 5304 if (rc != 0) { 5305 printf("Failed to set timeout value %u " 5306 "for port %d, errto code: %d.\n", 5307 bypass_timeout, port_id, rc); 5308 } 5309 } 5310 5311 /* Set the bypass event to transition to bypass mode. */ 5312 rc = rte_pmd_ixgbe_bypass_event_store(port_id, bypass_event, 5313 bypass_mode); 5314 #endif 5315 5316 if (rc != 0) 5317 printf("\t Failed to set bypass event for port = %d.\n", 5318 port_id); 5319 } 5320 5321 cmdline_parse_token_string_t cmd_setbypass_event_set = 5322 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_event_result, 5323 set, "set"); 5324 cmdline_parse_token_string_t cmd_setbypass_event_bypass = 5325 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_event_result, 5326 bypass, "bypass"); 5327 cmdline_parse_token_string_t cmd_setbypass_event_event = 5328 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_event_result, 5329 event, "event"); 5330 cmdline_parse_token_string_t cmd_setbypass_event_event_value = 5331 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_event_result, 5332 event_value, "none#timeout#os_off#os_on#power_on#power_off"); 5333 cmdline_parse_token_string_t cmd_setbypass_event_mode = 5334 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_event_result, 5335 mode, "mode"); 5336 cmdline_parse_token_string_t cmd_setbypass_event_mode_value = 5337 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_event_result, 5338 mode_value, "normal#bypass#isolate"); 5339 cmdline_parse_token_num_t cmd_setbypass_event_port = 5340 TOKEN_NUM_INITIALIZER(struct cmd_set_bypass_event_result, 5341 port_id, UINT16); 5342 5343 cmdline_parse_inst_t cmd_set_bypass_event = { 5344 .f = cmd_set_bypass_event_parsed, 5345 .help_str = "set bypass event none|timeout|os_on|os_off|power_on|" 5346 "power_off mode normal|bypass|isolate <port_id>: " 5347 "Set the NIC bypass event mode for port_id", 5348 .data = NULL, 5349 .tokens = { 5350 (void *)&cmd_setbypass_event_set, 5351 (void *)&cmd_setbypass_event_bypass, 5352 (void *)&cmd_setbypass_event_event, 5353 (void *)&cmd_setbypass_event_event_value, 5354 (void *)&cmd_setbypass_event_mode, 5355 (void *)&cmd_setbypass_event_mode_value, 5356 (void *)&cmd_setbypass_event_port, 5357 NULL, 5358 }, 5359 }; 5360 5361 5362 /* *** SET NIC BYPASS TIMEOUT *** */ 5363 struct cmd_set_bypass_timeout_result { 5364 cmdline_fixed_string_t set; 5365 cmdline_fixed_string_t bypass; 5366 cmdline_fixed_string_t timeout; 5367 cmdline_fixed_string_t value; 5368 }; 5369 5370 static void 5371 cmd_set_bypass_timeout_parsed(void *parsed_result, 5372 __attribute__((unused)) struct cmdline *cl, 5373 __attribute__((unused)) void *data) 5374 { 5375 __rte_unused struct cmd_set_bypass_timeout_result *res = parsed_result; 5376 5377 #if defined RTE_LIBRTE_IXGBE_PMD && defined RTE_LIBRTE_IXGBE_BYPASS 5378 if (!strcmp(res->value, "1.5")) 5379 bypass_timeout = RTE_PMD_IXGBE_BYPASS_TMT_1_5_SEC; 5380 else if (!strcmp(res->value, "2")) 5381 bypass_timeout = RTE_PMD_IXGBE_BYPASS_TMT_2_SEC; 5382 else if (!strcmp(res->value, "3")) 5383 bypass_timeout = RTE_PMD_IXGBE_BYPASS_TMT_3_SEC; 5384 else if (!strcmp(res->value, "4")) 5385 bypass_timeout = RTE_PMD_IXGBE_BYPASS_TMT_4_SEC; 5386 else if (!strcmp(res->value, "8")) 5387 bypass_timeout = RTE_PMD_IXGBE_BYPASS_TMT_8_SEC; 5388 else if (!strcmp(res->value, "16")) 5389 bypass_timeout = RTE_PMD_IXGBE_BYPASS_TMT_16_SEC; 5390 else if (!strcmp(res->value, "32")) 5391 bypass_timeout = RTE_PMD_IXGBE_BYPASS_TMT_32_SEC; 5392 else 5393 bypass_timeout = RTE_PMD_IXGBE_BYPASS_TMT_OFF; 5394 #endif 5395 } 5396 5397 cmdline_parse_token_string_t cmd_setbypass_timeout_set = 5398 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_timeout_result, 5399 set, "set"); 5400 cmdline_parse_token_string_t cmd_setbypass_timeout_bypass = 5401 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_timeout_result, 5402 bypass, "bypass"); 5403 cmdline_parse_token_string_t cmd_setbypass_timeout_timeout = 5404 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_timeout_result, 5405 timeout, "timeout"); 5406 cmdline_parse_token_string_t cmd_setbypass_timeout_value = 5407 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_timeout_result, 5408 value, "0#1.5#2#3#4#8#16#32"); 5409 5410 cmdline_parse_inst_t cmd_set_bypass_timeout = { 5411 .f = cmd_set_bypass_timeout_parsed, 5412 .help_str = "set bypass timeout 0|1.5|2|3|4|8|16|32: " 5413 "Set the NIC bypass watchdog timeout in seconds", 5414 .data = NULL, 5415 .tokens = { 5416 (void *)&cmd_setbypass_timeout_set, 5417 (void *)&cmd_setbypass_timeout_bypass, 5418 (void *)&cmd_setbypass_timeout_timeout, 5419 (void *)&cmd_setbypass_timeout_value, 5420 NULL, 5421 }, 5422 }; 5423 5424 /* *** SHOW NIC BYPASS MODE *** */ 5425 struct cmd_show_bypass_config_result { 5426 cmdline_fixed_string_t show; 5427 cmdline_fixed_string_t bypass; 5428 cmdline_fixed_string_t config; 5429 portid_t port_id; 5430 }; 5431 5432 static void 5433 cmd_show_bypass_config_parsed(void *parsed_result, 5434 __attribute__((unused)) struct cmdline *cl, 5435 __attribute__((unused)) void *data) 5436 { 5437 struct cmd_show_bypass_config_result *res = parsed_result; 5438 portid_t port_id = res->port_id; 5439 int rc = -EINVAL; 5440 #if defined RTE_LIBRTE_IXGBE_PMD && defined RTE_LIBRTE_IXGBE_BYPASS 5441 uint32_t event_mode; 5442 uint32_t bypass_mode; 5443 uint32_t timeout = bypass_timeout; 5444 int i; 5445 5446 static const char * const timeouts[RTE_PMD_IXGBE_BYPASS_TMT_NUM] = 5447 {"off", "1.5", "2", "3", "4", "8", "16", "32"}; 5448 static const char * const modes[RTE_PMD_IXGBE_BYPASS_MODE_NUM] = 5449 {"UNKNOWN", "normal", "bypass", "isolate"}; 5450 static const char * const events[RTE_PMD_IXGBE_BYPASS_EVENT_NUM] = { 5451 "NONE", 5452 "OS/board on", 5453 "power supply on", 5454 "OS/board off", 5455 "power supply off", 5456 "timeout"}; 5457 int num_events = (sizeof events) / (sizeof events[0]); 5458 5459 /* Display the bypass mode.*/ 5460 if (rte_pmd_ixgbe_bypass_state_show(port_id, &bypass_mode) != 0) { 5461 printf("\tFailed to get bypass mode for port = %d\n", port_id); 5462 return; 5463 } 5464 else { 5465 if (!RTE_PMD_IXGBE_BYPASS_MODE_VALID(bypass_mode)) 5466 bypass_mode = RTE_PMD_IXGBE_BYPASS_MODE_NONE; 5467 5468 printf("\tbypass mode = %s\n", modes[bypass_mode]); 5469 } 5470 5471 /* Display the bypass timeout.*/ 5472 if (!RTE_PMD_IXGBE_BYPASS_TMT_VALID(timeout)) 5473 timeout = RTE_PMD_IXGBE_BYPASS_TMT_OFF; 5474 5475 printf("\tbypass timeout = %s\n", timeouts[timeout]); 5476 5477 /* Display the bypass events and associated modes. */ 5478 for (i = RTE_PMD_IXGBE_BYPASS_EVENT_START; i < num_events; i++) { 5479 5480 if (rte_pmd_ixgbe_bypass_event_show(port_id, i, &event_mode)) { 5481 printf("\tFailed to get bypass mode for event = %s\n", 5482 events[i]); 5483 } else { 5484 if (!RTE_PMD_IXGBE_BYPASS_MODE_VALID(event_mode)) 5485 event_mode = RTE_PMD_IXGBE_BYPASS_MODE_NONE; 5486 5487 printf("\tbypass event: %-16s = %s\n", events[i], 5488 modes[event_mode]); 5489 } 5490 } 5491 #endif 5492 if (rc != 0) 5493 printf("\tFailed to get bypass configuration for port = %d\n", 5494 port_id); 5495 } 5496 5497 cmdline_parse_token_string_t cmd_showbypass_config_show = 5498 TOKEN_STRING_INITIALIZER(struct cmd_show_bypass_config_result, 5499 show, "show"); 5500 cmdline_parse_token_string_t cmd_showbypass_config_bypass = 5501 TOKEN_STRING_INITIALIZER(struct cmd_show_bypass_config_result, 5502 bypass, "bypass"); 5503 cmdline_parse_token_string_t cmd_showbypass_config_config = 5504 TOKEN_STRING_INITIALIZER(struct cmd_show_bypass_config_result, 5505 config, "config"); 5506 cmdline_parse_token_num_t cmd_showbypass_config_port = 5507 TOKEN_NUM_INITIALIZER(struct cmd_show_bypass_config_result, 5508 port_id, UINT16); 5509 5510 cmdline_parse_inst_t cmd_show_bypass_config = { 5511 .f = cmd_show_bypass_config_parsed, 5512 .help_str = "show bypass config <port_id>: " 5513 "Show the NIC bypass config for port_id", 5514 .data = NULL, 5515 .tokens = { 5516 (void *)&cmd_showbypass_config_show, 5517 (void *)&cmd_showbypass_config_bypass, 5518 (void *)&cmd_showbypass_config_config, 5519 (void *)&cmd_showbypass_config_port, 5520 NULL, 5521 }, 5522 }; 5523 5524 #ifdef RTE_LIBRTE_PMD_BOND 5525 /* *** SET BONDING MODE *** */ 5526 struct cmd_set_bonding_mode_result { 5527 cmdline_fixed_string_t set; 5528 cmdline_fixed_string_t bonding; 5529 cmdline_fixed_string_t mode; 5530 uint8_t value; 5531 portid_t port_id; 5532 }; 5533 5534 static void cmd_set_bonding_mode_parsed(void *parsed_result, 5535 __attribute__((unused)) struct cmdline *cl, 5536 __attribute__((unused)) void *data) 5537 { 5538 struct cmd_set_bonding_mode_result *res = parsed_result; 5539 portid_t port_id = res->port_id; 5540 5541 /* Set the bonding mode for the relevant port. */ 5542 if (0 != rte_eth_bond_mode_set(port_id, res->value)) 5543 printf("\t Failed to set bonding mode for port = %d.\n", port_id); 5544 } 5545 5546 cmdline_parse_token_string_t cmd_setbonding_mode_set = 5547 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_mode_result, 5548 set, "set"); 5549 cmdline_parse_token_string_t cmd_setbonding_mode_bonding = 5550 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_mode_result, 5551 bonding, "bonding"); 5552 cmdline_parse_token_string_t cmd_setbonding_mode_mode = 5553 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_mode_result, 5554 mode, "mode"); 5555 cmdline_parse_token_num_t cmd_setbonding_mode_value = 5556 TOKEN_NUM_INITIALIZER(struct cmd_set_bonding_mode_result, 5557 value, UINT8); 5558 cmdline_parse_token_num_t cmd_setbonding_mode_port = 5559 TOKEN_NUM_INITIALIZER(struct cmd_set_bonding_mode_result, 5560 port_id, UINT16); 5561 5562 cmdline_parse_inst_t cmd_set_bonding_mode = { 5563 .f = cmd_set_bonding_mode_parsed, 5564 .help_str = "set bonding mode <mode_value> <port_id>: " 5565 "Set the bonding mode for port_id", 5566 .data = NULL, 5567 .tokens = { 5568 (void *) &cmd_setbonding_mode_set, 5569 (void *) &cmd_setbonding_mode_bonding, 5570 (void *) &cmd_setbonding_mode_mode, 5571 (void *) &cmd_setbonding_mode_value, 5572 (void *) &cmd_setbonding_mode_port, 5573 NULL 5574 } 5575 }; 5576 5577 /* *** SET BONDING SLOW_QUEUE SW/HW *** */ 5578 struct cmd_set_bonding_lacp_dedicated_queues_result { 5579 cmdline_fixed_string_t set; 5580 cmdline_fixed_string_t bonding; 5581 cmdline_fixed_string_t lacp; 5582 cmdline_fixed_string_t dedicated_queues; 5583 portid_t port_id; 5584 cmdline_fixed_string_t mode; 5585 }; 5586 5587 static void cmd_set_bonding_lacp_dedicated_queues_parsed(void *parsed_result, 5588 __attribute__((unused)) struct cmdline *cl, 5589 __attribute__((unused)) void *data) 5590 { 5591 struct cmd_set_bonding_lacp_dedicated_queues_result *res = parsed_result; 5592 portid_t port_id = res->port_id; 5593 struct rte_port *port; 5594 5595 port = &ports[port_id]; 5596 5597 /** Check if the port is not started **/ 5598 if (port->port_status != RTE_PORT_STOPPED) { 5599 printf("Please stop port %d first\n", port_id); 5600 return; 5601 } 5602 5603 if (!strcmp(res->mode, "enable")) { 5604 if (rte_eth_bond_8023ad_dedicated_queues_enable(port_id) == 0) 5605 printf("Dedicate queues for LACP control packets" 5606 " enabled\n"); 5607 else 5608 printf("Enabling dedicate queues for LACP control " 5609 "packets on port %d failed\n", port_id); 5610 } else if (!strcmp(res->mode, "disable")) { 5611 if (rte_eth_bond_8023ad_dedicated_queues_disable(port_id) == 0) 5612 printf("Dedicated queues for LACP control packets " 5613 "disabled\n"); 5614 else 5615 printf("Disabling dedicated queues for LACP control " 5616 "traffic on port %d failed\n", port_id); 5617 } 5618 } 5619 5620 cmdline_parse_token_string_t cmd_setbonding_lacp_dedicated_queues_set = 5621 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_lacp_dedicated_queues_result, 5622 set, "set"); 5623 cmdline_parse_token_string_t cmd_setbonding_lacp_dedicated_queues_bonding = 5624 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_lacp_dedicated_queues_result, 5625 bonding, "bonding"); 5626 cmdline_parse_token_string_t cmd_setbonding_lacp_dedicated_queues_lacp = 5627 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_lacp_dedicated_queues_result, 5628 lacp, "lacp"); 5629 cmdline_parse_token_string_t cmd_setbonding_lacp_dedicated_queues_dedicated_queues = 5630 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_lacp_dedicated_queues_result, 5631 dedicated_queues, "dedicated_queues"); 5632 cmdline_parse_token_num_t cmd_setbonding_lacp_dedicated_queues_port_id = 5633 TOKEN_NUM_INITIALIZER(struct cmd_set_bonding_lacp_dedicated_queues_result, 5634 port_id, UINT16); 5635 cmdline_parse_token_string_t cmd_setbonding_lacp_dedicated_queues_mode = 5636 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_lacp_dedicated_queues_result, 5637 mode, "enable#disable"); 5638 5639 cmdline_parse_inst_t cmd_set_lacp_dedicated_queues = { 5640 .f = cmd_set_bonding_lacp_dedicated_queues_parsed, 5641 .help_str = "set bonding lacp dedicated_queues <port_id> " 5642 "enable|disable: " 5643 "Enable/disable dedicated queues for LACP control traffic for port_id", 5644 .data = NULL, 5645 .tokens = { 5646 (void *)&cmd_setbonding_lacp_dedicated_queues_set, 5647 (void *)&cmd_setbonding_lacp_dedicated_queues_bonding, 5648 (void *)&cmd_setbonding_lacp_dedicated_queues_lacp, 5649 (void *)&cmd_setbonding_lacp_dedicated_queues_dedicated_queues, 5650 (void *)&cmd_setbonding_lacp_dedicated_queues_port_id, 5651 (void *)&cmd_setbonding_lacp_dedicated_queues_mode, 5652 NULL 5653 } 5654 }; 5655 5656 /* *** SET BALANCE XMIT POLICY *** */ 5657 struct cmd_set_bonding_balance_xmit_policy_result { 5658 cmdline_fixed_string_t set; 5659 cmdline_fixed_string_t bonding; 5660 cmdline_fixed_string_t balance_xmit_policy; 5661 portid_t port_id; 5662 cmdline_fixed_string_t policy; 5663 }; 5664 5665 static void cmd_set_bonding_balance_xmit_policy_parsed(void *parsed_result, 5666 __attribute__((unused)) struct cmdline *cl, 5667 __attribute__((unused)) void *data) 5668 { 5669 struct cmd_set_bonding_balance_xmit_policy_result *res = parsed_result; 5670 portid_t port_id = res->port_id; 5671 uint8_t policy; 5672 5673 if (!strcmp(res->policy, "l2")) { 5674 policy = BALANCE_XMIT_POLICY_LAYER2; 5675 } else if (!strcmp(res->policy, "l23")) { 5676 policy = BALANCE_XMIT_POLICY_LAYER23; 5677 } else if (!strcmp(res->policy, "l34")) { 5678 policy = BALANCE_XMIT_POLICY_LAYER34; 5679 } else { 5680 printf("\t Invalid xmit policy selection"); 5681 return; 5682 } 5683 5684 /* Set the bonding mode for the relevant port. */ 5685 if (0 != rte_eth_bond_xmit_policy_set(port_id, policy)) { 5686 printf("\t Failed to set bonding balance xmit policy for port = %d.\n", 5687 port_id); 5688 } 5689 } 5690 5691 cmdline_parse_token_string_t cmd_setbonding_balance_xmit_policy_set = 5692 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_balance_xmit_policy_result, 5693 set, "set"); 5694 cmdline_parse_token_string_t cmd_setbonding_balance_xmit_policy_bonding = 5695 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_balance_xmit_policy_result, 5696 bonding, "bonding"); 5697 cmdline_parse_token_string_t cmd_setbonding_balance_xmit_policy_balance_xmit_policy = 5698 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_balance_xmit_policy_result, 5699 balance_xmit_policy, "balance_xmit_policy"); 5700 cmdline_parse_token_num_t cmd_setbonding_balance_xmit_policy_port = 5701 TOKEN_NUM_INITIALIZER(struct cmd_set_bonding_balance_xmit_policy_result, 5702 port_id, UINT16); 5703 cmdline_parse_token_string_t cmd_setbonding_balance_xmit_policy_policy = 5704 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_balance_xmit_policy_result, 5705 policy, "l2#l23#l34"); 5706 5707 cmdline_parse_inst_t cmd_set_balance_xmit_policy = { 5708 .f = cmd_set_bonding_balance_xmit_policy_parsed, 5709 .help_str = "set bonding balance_xmit_policy <port_id> " 5710 "l2|l23|l34: " 5711 "Set the bonding balance_xmit_policy for port_id", 5712 .data = NULL, 5713 .tokens = { 5714 (void *)&cmd_setbonding_balance_xmit_policy_set, 5715 (void *)&cmd_setbonding_balance_xmit_policy_bonding, 5716 (void *)&cmd_setbonding_balance_xmit_policy_balance_xmit_policy, 5717 (void *)&cmd_setbonding_balance_xmit_policy_port, 5718 (void *)&cmd_setbonding_balance_xmit_policy_policy, 5719 NULL 5720 } 5721 }; 5722 5723 /* *** SHOW NIC BONDING CONFIGURATION *** */ 5724 struct cmd_show_bonding_config_result { 5725 cmdline_fixed_string_t show; 5726 cmdline_fixed_string_t bonding; 5727 cmdline_fixed_string_t config; 5728 portid_t port_id; 5729 }; 5730 5731 static void cmd_show_bonding_config_parsed(void *parsed_result, 5732 __attribute__((unused)) struct cmdline *cl, 5733 __attribute__((unused)) void *data) 5734 { 5735 struct cmd_show_bonding_config_result *res = parsed_result; 5736 int bonding_mode, agg_mode; 5737 portid_t slaves[RTE_MAX_ETHPORTS]; 5738 int num_slaves, num_active_slaves; 5739 int primary_id; 5740 int i; 5741 portid_t port_id = res->port_id; 5742 5743 /* Display the bonding mode.*/ 5744 bonding_mode = rte_eth_bond_mode_get(port_id); 5745 if (bonding_mode < 0) { 5746 printf("\tFailed to get bonding mode for port = %d\n", port_id); 5747 return; 5748 } else 5749 printf("\tBonding mode: %d\n", bonding_mode); 5750 5751 if (bonding_mode == BONDING_MODE_BALANCE) { 5752 int balance_xmit_policy; 5753 5754 balance_xmit_policy = rte_eth_bond_xmit_policy_get(port_id); 5755 if (balance_xmit_policy < 0) { 5756 printf("\tFailed to get balance xmit policy for port = %d\n", 5757 port_id); 5758 return; 5759 } else { 5760 printf("\tBalance Xmit Policy: "); 5761 5762 switch (balance_xmit_policy) { 5763 case BALANCE_XMIT_POLICY_LAYER2: 5764 printf("BALANCE_XMIT_POLICY_LAYER2"); 5765 break; 5766 case BALANCE_XMIT_POLICY_LAYER23: 5767 printf("BALANCE_XMIT_POLICY_LAYER23"); 5768 break; 5769 case BALANCE_XMIT_POLICY_LAYER34: 5770 printf("BALANCE_XMIT_POLICY_LAYER34"); 5771 break; 5772 } 5773 printf("\n"); 5774 } 5775 } 5776 5777 if (bonding_mode == BONDING_MODE_8023AD) { 5778 agg_mode = rte_eth_bond_8023ad_agg_selection_get(port_id); 5779 printf("\tIEEE802.3AD Aggregator Mode: "); 5780 switch (agg_mode) { 5781 case AGG_BANDWIDTH: 5782 printf("bandwidth"); 5783 break; 5784 case AGG_STABLE: 5785 printf("stable"); 5786 break; 5787 case AGG_COUNT: 5788 printf("count"); 5789 break; 5790 } 5791 printf("\n"); 5792 } 5793 5794 num_slaves = rte_eth_bond_slaves_get(port_id, slaves, RTE_MAX_ETHPORTS); 5795 5796 if (num_slaves < 0) { 5797 printf("\tFailed to get slave list for port = %d\n", port_id); 5798 return; 5799 } 5800 if (num_slaves > 0) { 5801 printf("\tSlaves (%d): [", num_slaves); 5802 for (i = 0; i < num_slaves - 1; i++) 5803 printf("%d ", slaves[i]); 5804 5805 printf("%d]\n", slaves[num_slaves - 1]); 5806 } else { 5807 printf("\tSlaves: []\n"); 5808 5809 } 5810 5811 num_active_slaves = rte_eth_bond_active_slaves_get(port_id, slaves, 5812 RTE_MAX_ETHPORTS); 5813 5814 if (num_active_slaves < 0) { 5815 printf("\tFailed to get active slave list for port = %d\n", port_id); 5816 return; 5817 } 5818 if (num_active_slaves > 0) { 5819 printf("\tActive Slaves (%d): [", num_active_slaves); 5820 for (i = 0; i < num_active_slaves - 1; i++) 5821 printf("%d ", slaves[i]); 5822 5823 printf("%d]\n", slaves[num_active_slaves - 1]); 5824 5825 } else { 5826 printf("\tActive Slaves: []\n"); 5827 5828 } 5829 5830 primary_id = rte_eth_bond_primary_get(port_id); 5831 if (primary_id < 0) { 5832 printf("\tFailed to get primary slave for port = %d\n", port_id); 5833 return; 5834 } else 5835 printf("\tPrimary: [%d]\n", primary_id); 5836 5837 } 5838 5839 cmdline_parse_token_string_t cmd_showbonding_config_show = 5840 TOKEN_STRING_INITIALIZER(struct cmd_show_bonding_config_result, 5841 show, "show"); 5842 cmdline_parse_token_string_t cmd_showbonding_config_bonding = 5843 TOKEN_STRING_INITIALIZER(struct cmd_show_bonding_config_result, 5844 bonding, "bonding"); 5845 cmdline_parse_token_string_t cmd_showbonding_config_config = 5846 TOKEN_STRING_INITIALIZER(struct cmd_show_bonding_config_result, 5847 config, "config"); 5848 cmdline_parse_token_num_t cmd_showbonding_config_port = 5849 TOKEN_NUM_INITIALIZER(struct cmd_show_bonding_config_result, 5850 port_id, UINT16); 5851 5852 cmdline_parse_inst_t cmd_show_bonding_config = { 5853 .f = cmd_show_bonding_config_parsed, 5854 .help_str = "show bonding config <port_id>: " 5855 "Show the bonding config for port_id", 5856 .data = NULL, 5857 .tokens = { 5858 (void *)&cmd_showbonding_config_show, 5859 (void *)&cmd_showbonding_config_bonding, 5860 (void *)&cmd_showbonding_config_config, 5861 (void *)&cmd_showbonding_config_port, 5862 NULL 5863 } 5864 }; 5865 5866 /* *** SET BONDING PRIMARY *** */ 5867 struct cmd_set_bonding_primary_result { 5868 cmdline_fixed_string_t set; 5869 cmdline_fixed_string_t bonding; 5870 cmdline_fixed_string_t primary; 5871 portid_t slave_id; 5872 portid_t port_id; 5873 }; 5874 5875 static void cmd_set_bonding_primary_parsed(void *parsed_result, 5876 __attribute__((unused)) struct cmdline *cl, 5877 __attribute__((unused)) void *data) 5878 { 5879 struct cmd_set_bonding_primary_result *res = parsed_result; 5880 portid_t master_port_id = res->port_id; 5881 portid_t slave_port_id = res->slave_id; 5882 5883 /* Set the primary slave for a bonded device. */ 5884 if (0 != rte_eth_bond_primary_set(master_port_id, slave_port_id)) { 5885 printf("\t Failed to set primary slave for port = %d.\n", 5886 master_port_id); 5887 return; 5888 } 5889 init_port_config(); 5890 } 5891 5892 cmdline_parse_token_string_t cmd_setbonding_primary_set = 5893 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_primary_result, 5894 set, "set"); 5895 cmdline_parse_token_string_t cmd_setbonding_primary_bonding = 5896 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_primary_result, 5897 bonding, "bonding"); 5898 cmdline_parse_token_string_t cmd_setbonding_primary_primary = 5899 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_primary_result, 5900 primary, "primary"); 5901 cmdline_parse_token_num_t cmd_setbonding_primary_slave = 5902 TOKEN_NUM_INITIALIZER(struct cmd_set_bonding_primary_result, 5903 slave_id, UINT16); 5904 cmdline_parse_token_num_t cmd_setbonding_primary_port = 5905 TOKEN_NUM_INITIALIZER(struct cmd_set_bonding_primary_result, 5906 port_id, UINT16); 5907 5908 cmdline_parse_inst_t cmd_set_bonding_primary = { 5909 .f = cmd_set_bonding_primary_parsed, 5910 .help_str = "set bonding primary <slave_id> <port_id>: " 5911 "Set the primary slave for port_id", 5912 .data = NULL, 5913 .tokens = { 5914 (void *)&cmd_setbonding_primary_set, 5915 (void *)&cmd_setbonding_primary_bonding, 5916 (void *)&cmd_setbonding_primary_primary, 5917 (void *)&cmd_setbonding_primary_slave, 5918 (void *)&cmd_setbonding_primary_port, 5919 NULL 5920 } 5921 }; 5922 5923 /* *** ADD SLAVE *** */ 5924 struct cmd_add_bonding_slave_result { 5925 cmdline_fixed_string_t add; 5926 cmdline_fixed_string_t bonding; 5927 cmdline_fixed_string_t slave; 5928 portid_t slave_id; 5929 portid_t port_id; 5930 }; 5931 5932 static void cmd_add_bonding_slave_parsed(void *parsed_result, 5933 __attribute__((unused)) struct cmdline *cl, 5934 __attribute__((unused)) void *data) 5935 { 5936 struct cmd_add_bonding_slave_result *res = parsed_result; 5937 portid_t master_port_id = res->port_id; 5938 portid_t slave_port_id = res->slave_id; 5939 5940 /* add the slave for a bonded device. */ 5941 if (0 != rte_eth_bond_slave_add(master_port_id, slave_port_id)) { 5942 printf("\t Failed to add slave %d to master port = %d.\n", 5943 slave_port_id, master_port_id); 5944 return; 5945 } 5946 init_port_config(); 5947 set_port_slave_flag(slave_port_id); 5948 } 5949 5950 cmdline_parse_token_string_t cmd_addbonding_slave_add = 5951 TOKEN_STRING_INITIALIZER(struct cmd_add_bonding_slave_result, 5952 add, "add"); 5953 cmdline_parse_token_string_t cmd_addbonding_slave_bonding = 5954 TOKEN_STRING_INITIALIZER(struct cmd_add_bonding_slave_result, 5955 bonding, "bonding"); 5956 cmdline_parse_token_string_t cmd_addbonding_slave_slave = 5957 TOKEN_STRING_INITIALIZER(struct cmd_add_bonding_slave_result, 5958 slave, "slave"); 5959 cmdline_parse_token_num_t cmd_addbonding_slave_slaveid = 5960 TOKEN_NUM_INITIALIZER(struct cmd_add_bonding_slave_result, 5961 slave_id, UINT16); 5962 cmdline_parse_token_num_t cmd_addbonding_slave_port = 5963 TOKEN_NUM_INITIALIZER(struct cmd_add_bonding_slave_result, 5964 port_id, UINT16); 5965 5966 cmdline_parse_inst_t cmd_add_bonding_slave = { 5967 .f = cmd_add_bonding_slave_parsed, 5968 .help_str = "add bonding slave <slave_id> <port_id>: " 5969 "Add a slave device to a bonded device", 5970 .data = NULL, 5971 .tokens = { 5972 (void *)&cmd_addbonding_slave_add, 5973 (void *)&cmd_addbonding_slave_bonding, 5974 (void *)&cmd_addbonding_slave_slave, 5975 (void *)&cmd_addbonding_slave_slaveid, 5976 (void *)&cmd_addbonding_slave_port, 5977 NULL 5978 } 5979 }; 5980 5981 /* *** REMOVE SLAVE *** */ 5982 struct cmd_remove_bonding_slave_result { 5983 cmdline_fixed_string_t remove; 5984 cmdline_fixed_string_t bonding; 5985 cmdline_fixed_string_t slave; 5986 portid_t slave_id; 5987 portid_t port_id; 5988 }; 5989 5990 static void cmd_remove_bonding_slave_parsed(void *parsed_result, 5991 __attribute__((unused)) struct cmdline *cl, 5992 __attribute__((unused)) void *data) 5993 { 5994 struct cmd_remove_bonding_slave_result *res = parsed_result; 5995 portid_t master_port_id = res->port_id; 5996 portid_t slave_port_id = res->slave_id; 5997 5998 /* remove the slave from a bonded device. */ 5999 if (0 != rte_eth_bond_slave_remove(master_port_id, slave_port_id)) { 6000 printf("\t Failed to remove slave %d from master port = %d.\n", 6001 slave_port_id, master_port_id); 6002 return; 6003 } 6004 init_port_config(); 6005 clear_port_slave_flag(slave_port_id); 6006 } 6007 6008 cmdline_parse_token_string_t cmd_removebonding_slave_remove = 6009 TOKEN_STRING_INITIALIZER(struct cmd_remove_bonding_slave_result, 6010 remove, "remove"); 6011 cmdline_parse_token_string_t cmd_removebonding_slave_bonding = 6012 TOKEN_STRING_INITIALIZER(struct cmd_remove_bonding_slave_result, 6013 bonding, "bonding"); 6014 cmdline_parse_token_string_t cmd_removebonding_slave_slave = 6015 TOKEN_STRING_INITIALIZER(struct cmd_remove_bonding_slave_result, 6016 slave, "slave"); 6017 cmdline_parse_token_num_t cmd_removebonding_slave_slaveid = 6018 TOKEN_NUM_INITIALIZER(struct cmd_remove_bonding_slave_result, 6019 slave_id, UINT16); 6020 cmdline_parse_token_num_t cmd_removebonding_slave_port = 6021 TOKEN_NUM_INITIALIZER(struct cmd_remove_bonding_slave_result, 6022 port_id, UINT16); 6023 6024 cmdline_parse_inst_t cmd_remove_bonding_slave = { 6025 .f = cmd_remove_bonding_slave_parsed, 6026 .help_str = "remove bonding slave <slave_id> <port_id>: " 6027 "Remove a slave device from a bonded device", 6028 .data = NULL, 6029 .tokens = { 6030 (void *)&cmd_removebonding_slave_remove, 6031 (void *)&cmd_removebonding_slave_bonding, 6032 (void *)&cmd_removebonding_slave_slave, 6033 (void *)&cmd_removebonding_slave_slaveid, 6034 (void *)&cmd_removebonding_slave_port, 6035 NULL 6036 } 6037 }; 6038 6039 /* *** CREATE BONDED DEVICE *** */ 6040 struct cmd_create_bonded_device_result { 6041 cmdline_fixed_string_t create; 6042 cmdline_fixed_string_t bonded; 6043 cmdline_fixed_string_t device; 6044 uint8_t mode; 6045 uint8_t socket; 6046 }; 6047 6048 static int bond_dev_num = 0; 6049 6050 static void cmd_create_bonded_device_parsed(void *parsed_result, 6051 __attribute__((unused)) struct cmdline *cl, 6052 __attribute__((unused)) void *data) 6053 { 6054 struct cmd_create_bonded_device_result *res = parsed_result; 6055 char ethdev_name[RTE_ETH_NAME_MAX_LEN]; 6056 int port_id; 6057 6058 if (test_done == 0) { 6059 printf("Please stop forwarding first\n"); 6060 return; 6061 } 6062 6063 snprintf(ethdev_name, RTE_ETH_NAME_MAX_LEN, "net_bonding_testpmd_%d", 6064 bond_dev_num++); 6065 6066 /* Create a new bonded device. */ 6067 port_id = rte_eth_bond_create(ethdev_name, res->mode, res->socket); 6068 if (port_id < 0) { 6069 printf("\t Failed to create bonded device.\n"); 6070 return; 6071 } else { 6072 printf("Created new bonded device %s on (port %d).\n", ethdev_name, 6073 port_id); 6074 6075 /* Update number of ports */ 6076 nb_ports = rte_eth_dev_count_avail(); 6077 reconfig(port_id, res->socket); 6078 rte_eth_promiscuous_enable(port_id); 6079 ports[port_id].need_setup = 0; 6080 ports[port_id].port_status = RTE_PORT_STOPPED; 6081 } 6082 6083 } 6084 6085 cmdline_parse_token_string_t cmd_createbonded_device_create = 6086 TOKEN_STRING_INITIALIZER(struct cmd_create_bonded_device_result, 6087 create, "create"); 6088 cmdline_parse_token_string_t cmd_createbonded_device_bonded = 6089 TOKEN_STRING_INITIALIZER(struct cmd_create_bonded_device_result, 6090 bonded, "bonded"); 6091 cmdline_parse_token_string_t cmd_createbonded_device_device = 6092 TOKEN_STRING_INITIALIZER(struct cmd_create_bonded_device_result, 6093 device, "device"); 6094 cmdline_parse_token_num_t cmd_createbonded_device_mode = 6095 TOKEN_NUM_INITIALIZER(struct cmd_create_bonded_device_result, 6096 mode, UINT8); 6097 cmdline_parse_token_num_t cmd_createbonded_device_socket = 6098 TOKEN_NUM_INITIALIZER(struct cmd_create_bonded_device_result, 6099 socket, UINT8); 6100 6101 cmdline_parse_inst_t cmd_create_bonded_device = { 6102 .f = cmd_create_bonded_device_parsed, 6103 .help_str = "create bonded device <mode> <socket>: " 6104 "Create a new bonded device with specific bonding mode and socket", 6105 .data = NULL, 6106 .tokens = { 6107 (void *)&cmd_createbonded_device_create, 6108 (void *)&cmd_createbonded_device_bonded, 6109 (void *)&cmd_createbonded_device_device, 6110 (void *)&cmd_createbonded_device_mode, 6111 (void *)&cmd_createbonded_device_socket, 6112 NULL 6113 } 6114 }; 6115 6116 /* *** SET MAC ADDRESS IN BONDED DEVICE *** */ 6117 struct cmd_set_bond_mac_addr_result { 6118 cmdline_fixed_string_t set; 6119 cmdline_fixed_string_t bonding; 6120 cmdline_fixed_string_t mac_addr; 6121 uint16_t port_num; 6122 struct ether_addr address; 6123 }; 6124 6125 static void cmd_set_bond_mac_addr_parsed(void *parsed_result, 6126 __attribute__((unused)) struct cmdline *cl, 6127 __attribute__((unused)) void *data) 6128 { 6129 struct cmd_set_bond_mac_addr_result *res = parsed_result; 6130 int ret; 6131 6132 if (port_id_is_invalid(res->port_num, ENABLED_WARN)) 6133 return; 6134 6135 ret = rte_eth_bond_mac_address_set(res->port_num, &res->address); 6136 6137 /* check the return value and print it if is < 0 */ 6138 if (ret < 0) 6139 printf("set_bond_mac_addr error: (%s)\n", strerror(-ret)); 6140 } 6141 6142 cmdline_parse_token_string_t cmd_set_bond_mac_addr_set = 6143 TOKEN_STRING_INITIALIZER(struct cmd_set_bond_mac_addr_result, set, "set"); 6144 cmdline_parse_token_string_t cmd_set_bond_mac_addr_bonding = 6145 TOKEN_STRING_INITIALIZER(struct cmd_set_bond_mac_addr_result, bonding, 6146 "bonding"); 6147 cmdline_parse_token_string_t cmd_set_bond_mac_addr_mac = 6148 TOKEN_STRING_INITIALIZER(struct cmd_set_bond_mac_addr_result, mac_addr, 6149 "mac_addr"); 6150 cmdline_parse_token_num_t cmd_set_bond_mac_addr_portnum = 6151 TOKEN_NUM_INITIALIZER(struct cmd_set_bond_mac_addr_result, 6152 port_num, UINT16); 6153 cmdline_parse_token_etheraddr_t cmd_set_bond_mac_addr_addr = 6154 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_bond_mac_addr_result, address); 6155 6156 cmdline_parse_inst_t cmd_set_bond_mac_addr = { 6157 .f = cmd_set_bond_mac_addr_parsed, 6158 .data = (void *) 0, 6159 .help_str = "set bonding mac_addr <port_id> <mac_addr>", 6160 .tokens = { 6161 (void *)&cmd_set_bond_mac_addr_set, 6162 (void *)&cmd_set_bond_mac_addr_bonding, 6163 (void *)&cmd_set_bond_mac_addr_mac, 6164 (void *)&cmd_set_bond_mac_addr_portnum, 6165 (void *)&cmd_set_bond_mac_addr_addr, 6166 NULL 6167 } 6168 }; 6169 6170 6171 /* *** SET LINK STATUS MONITORING POLLING PERIOD ON BONDED DEVICE *** */ 6172 struct cmd_set_bond_mon_period_result { 6173 cmdline_fixed_string_t set; 6174 cmdline_fixed_string_t bonding; 6175 cmdline_fixed_string_t mon_period; 6176 uint16_t port_num; 6177 uint32_t period_ms; 6178 }; 6179 6180 static void cmd_set_bond_mon_period_parsed(void *parsed_result, 6181 __attribute__((unused)) struct cmdline *cl, 6182 __attribute__((unused)) void *data) 6183 { 6184 struct cmd_set_bond_mon_period_result *res = parsed_result; 6185 int ret; 6186 6187 ret = rte_eth_bond_link_monitoring_set(res->port_num, res->period_ms); 6188 6189 /* check the return value and print it if is < 0 */ 6190 if (ret < 0) 6191 printf("set_bond_mac_addr error: (%s)\n", strerror(-ret)); 6192 } 6193 6194 cmdline_parse_token_string_t cmd_set_bond_mon_period_set = 6195 TOKEN_STRING_INITIALIZER(struct cmd_set_bond_mon_period_result, 6196 set, "set"); 6197 cmdline_parse_token_string_t cmd_set_bond_mon_period_bonding = 6198 TOKEN_STRING_INITIALIZER(struct cmd_set_bond_mon_period_result, 6199 bonding, "bonding"); 6200 cmdline_parse_token_string_t cmd_set_bond_mon_period_mon_period = 6201 TOKEN_STRING_INITIALIZER(struct cmd_set_bond_mon_period_result, 6202 mon_period, "mon_period"); 6203 cmdline_parse_token_num_t cmd_set_bond_mon_period_portnum = 6204 TOKEN_NUM_INITIALIZER(struct cmd_set_bond_mon_period_result, 6205 port_num, UINT16); 6206 cmdline_parse_token_num_t cmd_set_bond_mon_period_period_ms = 6207 TOKEN_NUM_INITIALIZER(struct cmd_set_bond_mon_period_result, 6208 period_ms, UINT32); 6209 6210 cmdline_parse_inst_t cmd_set_bond_mon_period = { 6211 .f = cmd_set_bond_mon_period_parsed, 6212 .data = (void *) 0, 6213 .help_str = "set bonding mon_period <port_id> <period_ms>", 6214 .tokens = { 6215 (void *)&cmd_set_bond_mon_period_set, 6216 (void *)&cmd_set_bond_mon_period_bonding, 6217 (void *)&cmd_set_bond_mon_period_mon_period, 6218 (void *)&cmd_set_bond_mon_period_portnum, 6219 (void *)&cmd_set_bond_mon_period_period_ms, 6220 NULL 6221 } 6222 }; 6223 6224 6225 6226 struct cmd_set_bonding_agg_mode_policy_result { 6227 cmdline_fixed_string_t set; 6228 cmdline_fixed_string_t bonding; 6229 cmdline_fixed_string_t agg_mode; 6230 uint16_t port_num; 6231 cmdline_fixed_string_t policy; 6232 }; 6233 6234 6235 static void 6236 cmd_set_bonding_agg_mode(void *parsed_result, 6237 __attribute__((unused)) struct cmdline *cl, 6238 __attribute__((unused)) void *data) 6239 { 6240 struct cmd_set_bonding_agg_mode_policy_result *res = parsed_result; 6241 uint8_t policy = AGG_BANDWIDTH; 6242 6243 if (!strcmp(res->policy, "bandwidth")) 6244 policy = AGG_BANDWIDTH; 6245 else if (!strcmp(res->policy, "stable")) 6246 policy = AGG_STABLE; 6247 else if (!strcmp(res->policy, "count")) 6248 policy = AGG_COUNT; 6249 6250 rte_eth_bond_8023ad_agg_selection_set(res->port_num, policy); 6251 } 6252 6253 6254 cmdline_parse_token_string_t cmd_set_bonding_agg_mode_set = 6255 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_agg_mode_policy_result, 6256 set, "set"); 6257 cmdline_parse_token_string_t cmd_set_bonding_agg_mode_bonding = 6258 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_agg_mode_policy_result, 6259 bonding, "bonding"); 6260 6261 cmdline_parse_token_string_t cmd_set_bonding_agg_mode_agg_mode = 6262 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_agg_mode_policy_result, 6263 agg_mode, "agg_mode"); 6264 6265 cmdline_parse_token_num_t cmd_set_bonding_agg_mode_portnum = 6266 TOKEN_NUM_INITIALIZER(struct cmd_set_bonding_agg_mode_policy_result, 6267 port_num, UINT16); 6268 6269 cmdline_parse_token_string_t cmd_set_bonding_agg_mode_policy_string = 6270 TOKEN_STRING_INITIALIZER( 6271 struct cmd_set_bonding_balance_xmit_policy_result, 6272 policy, "stable#bandwidth#count"); 6273 6274 cmdline_parse_inst_t cmd_set_bonding_agg_mode_policy = { 6275 .f = cmd_set_bonding_agg_mode, 6276 .data = (void *) 0, 6277 .help_str = "set bonding mode IEEE802.3AD aggregator policy <port_id> <agg_name>", 6278 .tokens = { 6279 (void *)&cmd_set_bonding_agg_mode_set, 6280 (void *)&cmd_set_bonding_agg_mode_bonding, 6281 (void *)&cmd_set_bonding_agg_mode_agg_mode, 6282 (void *)&cmd_set_bonding_agg_mode_portnum, 6283 (void *)&cmd_set_bonding_agg_mode_policy_string, 6284 NULL 6285 } 6286 }; 6287 6288 6289 #endif /* RTE_LIBRTE_PMD_BOND */ 6290 6291 /* *** SET FORWARDING MODE *** */ 6292 struct cmd_set_fwd_mode_result { 6293 cmdline_fixed_string_t set; 6294 cmdline_fixed_string_t fwd; 6295 cmdline_fixed_string_t mode; 6296 }; 6297 6298 static void cmd_set_fwd_mode_parsed(void *parsed_result, 6299 __attribute__((unused)) struct cmdline *cl, 6300 __attribute__((unused)) void *data) 6301 { 6302 struct cmd_set_fwd_mode_result *res = parsed_result; 6303 6304 retry_enabled = 0; 6305 set_pkt_forwarding_mode(res->mode); 6306 } 6307 6308 cmdline_parse_token_string_t cmd_setfwd_set = 6309 TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_mode_result, set, "set"); 6310 cmdline_parse_token_string_t cmd_setfwd_fwd = 6311 TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_mode_result, fwd, "fwd"); 6312 cmdline_parse_token_string_t cmd_setfwd_mode = 6313 TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_mode_result, mode, 6314 "" /* defined at init */); 6315 6316 cmdline_parse_inst_t cmd_set_fwd_mode = { 6317 .f = cmd_set_fwd_mode_parsed, 6318 .data = NULL, 6319 .help_str = NULL, /* defined at init */ 6320 .tokens = { 6321 (void *)&cmd_setfwd_set, 6322 (void *)&cmd_setfwd_fwd, 6323 (void *)&cmd_setfwd_mode, 6324 NULL, 6325 }, 6326 }; 6327 6328 static void cmd_set_fwd_mode_init(void) 6329 { 6330 char *modes, *c; 6331 static char token[128]; 6332 static char help[256]; 6333 cmdline_parse_token_string_t *token_struct; 6334 6335 modes = list_pkt_forwarding_modes(); 6336 snprintf(help, sizeof(help), "set fwd %s: " 6337 "Set packet forwarding mode", modes); 6338 cmd_set_fwd_mode.help_str = help; 6339 6340 /* string token separator is # */ 6341 for (c = token; *modes != '\0'; modes++) 6342 if (*modes == '|') 6343 *c++ = '#'; 6344 else 6345 *c++ = *modes; 6346 token_struct = (cmdline_parse_token_string_t*)cmd_set_fwd_mode.tokens[2]; 6347 token_struct->string_data.str = token; 6348 } 6349 6350 /* *** SET RETRY FORWARDING MODE *** */ 6351 struct cmd_set_fwd_retry_mode_result { 6352 cmdline_fixed_string_t set; 6353 cmdline_fixed_string_t fwd; 6354 cmdline_fixed_string_t mode; 6355 cmdline_fixed_string_t retry; 6356 }; 6357 6358 static void cmd_set_fwd_retry_mode_parsed(void *parsed_result, 6359 __attribute__((unused)) struct cmdline *cl, 6360 __attribute__((unused)) void *data) 6361 { 6362 struct cmd_set_fwd_retry_mode_result *res = parsed_result; 6363 6364 retry_enabled = 1; 6365 set_pkt_forwarding_mode(res->mode); 6366 } 6367 6368 cmdline_parse_token_string_t cmd_setfwd_retry_set = 6369 TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_retry_mode_result, 6370 set, "set"); 6371 cmdline_parse_token_string_t cmd_setfwd_retry_fwd = 6372 TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_retry_mode_result, 6373 fwd, "fwd"); 6374 cmdline_parse_token_string_t cmd_setfwd_retry_mode = 6375 TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_retry_mode_result, 6376 mode, 6377 "" /* defined at init */); 6378 cmdline_parse_token_string_t cmd_setfwd_retry_retry = 6379 TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_retry_mode_result, 6380 retry, "retry"); 6381 6382 cmdline_parse_inst_t cmd_set_fwd_retry_mode = { 6383 .f = cmd_set_fwd_retry_mode_parsed, 6384 .data = NULL, 6385 .help_str = NULL, /* defined at init */ 6386 .tokens = { 6387 (void *)&cmd_setfwd_retry_set, 6388 (void *)&cmd_setfwd_retry_fwd, 6389 (void *)&cmd_setfwd_retry_mode, 6390 (void *)&cmd_setfwd_retry_retry, 6391 NULL, 6392 }, 6393 }; 6394 6395 static void cmd_set_fwd_retry_mode_init(void) 6396 { 6397 char *modes, *c; 6398 static char token[128]; 6399 static char help[256]; 6400 cmdline_parse_token_string_t *token_struct; 6401 6402 modes = list_pkt_forwarding_retry_modes(); 6403 snprintf(help, sizeof(help), "set fwd %s retry: " 6404 "Set packet forwarding mode with retry", modes); 6405 cmd_set_fwd_retry_mode.help_str = help; 6406 6407 /* string token separator is # */ 6408 for (c = token; *modes != '\0'; modes++) 6409 if (*modes == '|') 6410 *c++ = '#'; 6411 else 6412 *c++ = *modes; 6413 token_struct = (cmdline_parse_token_string_t *) 6414 cmd_set_fwd_retry_mode.tokens[2]; 6415 token_struct->string_data.str = token; 6416 } 6417 6418 /* *** SET BURST TX DELAY TIME RETRY NUMBER *** */ 6419 struct cmd_set_burst_tx_retry_result { 6420 cmdline_fixed_string_t set; 6421 cmdline_fixed_string_t burst; 6422 cmdline_fixed_string_t tx; 6423 cmdline_fixed_string_t delay; 6424 uint32_t time; 6425 cmdline_fixed_string_t retry; 6426 uint32_t retry_num; 6427 }; 6428 6429 static void cmd_set_burst_tx_retry_parsed(void *parsed_result, 6430 __attribute__((unused)) struct cmdline *cl, 6431 __attribute__((unused)) void *data) 6432 { 6433 struct cmd_set_burst_tx_retry_result *res = parsed_result; 6434 6435 if (!strcmp(res->set, "set") && !strcmp(res->burst, "burst") 6436 && !strcmp(res->tx, "tx")) { 6437 if (!strcmp(res->delay, "delay")) 6438 burst_tx_delay_time = res->time; 6439 if (!strcmp(res->retry, "retry")) 6440 burst_tx_retry_num = res->retry_num; 6441 } 6442 6443 } 6444 6445 cmdline_parse_token_string_t cmd_set_burst_tx_retry_set = 6446 TOKEN_STRING_INITIALIZER(struct cmd_set_burst_tx_retry_result, set, "set"); 6447 cmdline_parse_token_string_t cmd_set_burst_tx_retry_burst = 6448 TOKEN_STRING_INITIALIZER(struct cmd_set_burst_tx_retry_result, burst, 6449 "burst"); 6450 cmdline_parse_token_string_t cmd_set_burst_tx_retry_tx = 6451 TOKEN_STRING_INITIALIZER(struct cmd_set_burst_tx_retry_result, tx, "tx"); 6452 cmdline_parse_token_string_t cmd_set_burst_tx_retry_delay = 6453 TOKEN_STRING_INITIALIZER(struct cmd_set_burst_tx_retry_result, delay, "delay"); 6454 cmdline_parse_token_num_t cmd_set_burst_tx_retry_time = 6455 TOKEN_NUM_INITIALIZER(struct cmd_set_burst_tx_retry_result, time, UINT32); 6456 cmdline_parse_token_string_t cmd_set_burst_tx_retry_retry = 6457 TOKEN_STRING_INITIALIZER(struct cmd_set_burst_tx_retry_result, retry, "retry"); 6458 cmdline_parse_token_num_t cmd_set_burst_tx_retry_retry_num = 6459 TOKEN_NUM_INITIALIZER(struct cmd_set_burst_tx_retry_result, retry_num, UINT32); 6460 6461 cmdline_parse_inst_t cmd_set_burst_tx_retry = { 6462 .f = cmd_set_burst_tx_retry_parsed, 6463 .help_str = "set burst tx delay <delay_usec> retry <num_retry>", 6464 .tokens = { 6465 (void *)&cmd_set_burst_tx_retry_set, 6466 (void *)&cmd_set_burst_tx_retry_burst, 6467 (void *)&cmd_set_burst_tx_retry_tx, 6468 (void *)&cmd_set_burst_tx_retry_delay, 6469 (void *)&cmd_set_burst_tx_retry_time, 6470 (void *)&cmd_set_burst_tx_retry_retry, 6471 (void *)&cmd_set_burst_tx_retry_retry_num, 6472 NULL, 6473 }, 6474 }; 6475 6476 /* *** SET PROMISC MODE *** */ 6477 struct cmd_set_promisc_mode_result { 6478 cmdline_fixed_string_t set; 6479 cmdline_fixed_string_t promisc; 6480 cmdline_fixed_string_t port_all; /* valid if "allports" argument == 1 */ 6481 uint16_t port_num; /* valid if "allports" argument == 0 */ 6482 cmdline_fixed_string_t mode; 6483 }; 6484 6485 static void cmd_set_promisc_mode_parsed(void *parsed_result, 6486 __attribute__((unused)) struct cmdline *cl, 6487 void *allports) 6488 { 6489 struct cmd_set_promisc_mode_result *res = parsed_result; 6490 int enable; 6491 portid_t i; 6492 6493 if (!strcmp(res->mode, "on")) 6494 enable = 1; 6495 else 6496 enable = 0; 6497 6498 /* all ports */ 6499 if (allports) { 6500 RTE_ETH_FOREACH_DEV(i) { 6501 if (enable) 6502 rte_eth_promiscuous_enable(i); 6503 else 6504 rte_eth_promiscuous_disable(i); 6505 } 6506 } 6507 else { 6508 if (enable) 6509 rte_eth_promiscuous_enable(res->port_num); 6510 else 6511 rte_eth_promiscuous_disable(res->port_num); 6512 } 6513 } 6514 6515 cmdline_parse_token_string_t cmd_setpromisc_set = 6516 TOKEN_STRING_INITIALIZER(struct cmd_set_promisc_mode_result, set, "set"); 6517 cmdline_parse_token_string_t cmd_setpromisc_promisc = 6518 TOKEN_STRING_INITIALIZER(struct cmd_set_promisc_mode_result, promisc, 6519 "promisc"); 6520 cmdline_parse_token_string_t cmd_setpromisc_portall = 6521 TOKEN_STRING_INITIALIZER(struct cmd_set_promisc_mode_result, port_all, 6522 "all"); 6523 cmdline_parse_token_num_t cmd_setpromisc_portnum = 6524 TOKEN_NUM_INITIALIZER(struct cmd_set_promisc_mode_result, port_num, 6525 UINT16); 6526 cmdline_parse_token_string_t cmd_setpromisc_mode = 6527 TOKEN_STRING_INITIALIZER(struct cmd_set_promisc_mode_result, mode, 6528 "on#off"); 6529 6530 cmdline_parse_inst_t cmd_set_promisc_mode_all = { 6531 .f = cmd_set_promisc_mode_parsed, 6532 .data = (void *)1, 6533 .help_str = "set promisc all on|off: Set promisc mode for all ports", 6534 .tokens = { 6535 (void *)&cmd_setpromisc_set, 6536 (void *)&cmd_setpromisc_promisc, 6537 (void *)&cmd_setpromisc_portall, 6538 (void *)&cmd_setpromisc_mode, 6539 NULL, 6540 }, 6541 }; 6542 6543 cmdline_parse_inst_t cmd_set_promisc_mode_one = { 6544 .f = cmd_set_promisc_mode_parsed, 6545 .data = (void *)0, 6546 .help_str = "set promisc <port_id> on|off: Set promisc mode on port_id", 6547 .tokens = { 6548 (void *)&cmd_setpromisc_set, 6549 (void *)&cmd_setpromisc_promisc, 6550 (void *)&cmd_setpromisc_portnum, 6551 (void *)&cmd_setpromisc_mode, 6552 NULL, 6553 }, 6554 }; 6555 6556 /* *** SET ALLMULTI MODE *** */ 6557 struct cmd_set_allmulti_mode_result { 6558 cmdline_fixed_string_t set; 6559 cmdline_fixed_string_t allmulti; 6560 cmdline_fixed_string_t port_all; /* valid if "allports" argument == 1 */ 6561 uint16_t port_num; /* valid if "allports" argument == 0 */ 6562 cmdline_fixed_string_t mode; 6563 }; 6564 6565 static void cmd_set_allmulti_mode_parsed(void *parsed_result, 6566 __attribute__((unused)) struct cmdline *cl, 6567 void *allports) 6568 { 6569 struct cmd_set_allmulti_mode_result *res = parsed_result; 6570 int enable; 6571 portid_t i; 6572 6573 if (!strcmp(res->mode, "on")) 6574 enable = 1; 6575 else 6576 enable = 0; 6577 6578 /* all ports */ 6579 if (allports) { 6580 RTE_ETH_FOREACH_DEV(i) { 6581 if (enable) 6582 rte_eth_allmulticast_enable(i); 6583 else 6584 rte_eth_allmulticast_disable(i); 6585 } 6586 } 6587 else { 6588 if (enable) 6589 rte_eth_allmulticast_enable(res->port_num); 6590 else 6591 rte_eth_allmulticast_disable(res->port_num); 6592 } 6593 } 6594 6595 cmdline_parse_token_string_t cmd_setallmulti_set = 6596 TOKEN_STRING_INITIALIZER(struct cmd_set_allmulti_mode_result, set, "set"); 6597 cmdline_parse_token_string_t cmd_setallmulti_allmulti = 6598 TOKEN_STRING_INITIALIZER(struct cmd_set_allmulti_mode_result, allmulti, 6599 "allmulti"); 6600 cmdline_parse_token_string_t cmd_setallmulti_portall = 6601 TOKEN_STRING_INITIALIZER(struct cmd_set_allmulti_mode_result, port_all, 6602 "all"); 6603 cmdline_parse_token_num_t cmd_setallmulti_portnum = 6604 TOKEN_NUM_INITIALIZER(struct cmd_set_allmulti_mode_result, port_num, 6605 UINT16); 6606 cmdline_parse_token_string_t cmd_setallmulti_mode = 6607 TOKEN_STRING_INITIALIZER(struct cmd_set_allmulti_mode_result, mode, 6608 "on#off"); 6609 6610 cmdline_parse_inst_t cmd_set_allmulti_mode_all = { 6611 .f = cmd_set_allmulti_mode_parsed, 6612 .data = (void *)1, 6613 .help_str = "set allmulti all on|off: Set allmulti mode for all ports", 6614 .tokens = { 6615 (void *)&cmd_setallmulti_set, 6616 (void *)&cmd_setallmulti_allmulti, 6617 (void *)&cmd_setallmulti_portall, 6618 (void *)&cmd_setallmulti_mode, 6619 NULL, 6620 }, 6621 }; 6622 6623 cmdline_parse_inst_t cmd_set_allmulti_mode_one = { 6624 .f = cmd_set_allmulti_mode_parsed, 6625 .data = (void *)0, 6626 .help_str = "set allmulti <port_id> on|off: " 6627 "Set allmulti mode on port_id", 6628 .tokens = { 6629 (void *)&cmd_setallmulti_set, 6630 (void *)&cmd_setallmulti_allmulti, 6631 (void *)&cmd_setallmulti_portnum, 6632 (void *)&cmd_setallmulti_mode, 6633 NULL, 6634 }, 6635 }; 6636 6637 /* *** SETUP ETHERNET LINK FLOW CONTROL *** */ 6638 struct cmd_link_flow_ctrl_set_result { 6639 cmdline_fixed_string_t set; 6640 cmdline_fixed_string_t flow_ctrl; 6641 cmdline_fixed_string_t rx; 6642 cmdline_fixed_string_t rx_lfc_mode; 6643 cmdline_fixed_string_t tx; 6644 cmdline_fixed_string_t tx_lfc_mode; 6645 cmdline_fixed_string_t mac_ctrl_frame_fwd; 6646 cmdline_fixed_string_t mac_ctrl_frame_fwd_mode; 6647 cmdline_fixed_string_t autoneg_str; 6648 cmdline_fixed_string_t autoneg; 6649 cmdline_fixed_string_t hw_str; 6650 uint32_t high_water; 6651 cmdline_fixed_string_t lw_str; 6652 uint32_t low_water; 6653 cmdline_fixed_string_t pt_str; 6654 uint16_t pause_time; 6655 cmdline_fixed_string_t xon_str; 6656 uint16_t send_xon; 6657 portid_t port_id; 6658 }; 6659 6660 cmdline_parse_token_string_t cmd_lfc_set_set = 6661 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result, 6662 set, "set"); 6663 cmdline_parse_token_string_t cmd_lfc_set_flow_ctrl = 6664 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result, 6665 flow_ctrl, "flow_ctrl"); 6666 cmdline_parse_token_string_t cmd_lfc_set_rx = 6667 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result, 6668 rx, "rx"); 6669 cmdline_parse_token_string_t cmd_lfc_set_rx_mode = 6670 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result, 6671 rx_lfc_mode, "on#off"); 6672 cmdline_parse_token_string_t cmd_lfc_set_tx = 6673 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result, 6674 tx, "tx"); 6675 cmdline_parse_token_string_t cmd_lfc_set_tx_mode = 6676 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result, 6677 tx_lfc_mode, "on#off"); 6678 cmdline_parse_token_string_t cmd_lfc_set_high_water_str = 6679 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result, 6680 hw_str, "high_water"); 6681 cmdline_parse_token_num_t cmd_lfc_set_high_water = 6682 TOKEN_NUM_INITIALIZER(struct cmd_link_flow_ctrl_set_result, 6683 high_water, UINT32); 6684 cmdline_parse_token_string_t cmd_lfc_set_low_water_str = 6685 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result, 6686 lw_str, "low_water"); 6687 cmdline_parse_token_num_t cmd_lfc_set_low_water = 6688 TOKEN_NUM_INITIALIZER(struct cmd_link_flow_ctrl_set_result, 6689 low_water, UINT32); 6690 cmdline_parse_token_string_t cmd_lfc_set_pause_time_str = 6691 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result, 6692 pt_str, "pause_time"); 6693 cmdline_parse_token_num_t cmd_lfc_set_pause_time = 6694 TOKEN_NUM_INITIALIZER(struct cmd_link_flow_ctrl_set_result, 6695 pause_time, UINT16); 6696 cmdline_parse_token_string_t cmd_lfc_set_send_xon_str = 6697 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result, 6698 xon_str, "send_xon"); 6699 cmdline_parse_token_num_t cmd_lfc_set_send_xon = 6700 TOKEN_NUM_INITIALIZER(struct cmd_link_flow_ctrl_set_result, 6701 send_xon, UINT16); 6702 cmdline_parse_token_string_t cmd_lfc_set_mac_ctrl_frame_fwd_mode = 6703 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result, 6704 mac_ctrl_frame_fwd, "mac_ctrl_frame_fwd"); 6705 cmdline_parse_token_string_t cmd_lfc_set_mac_ctrl_frame_fwd = 6706 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result, 6707 mac_ctrl_frame_fwd_mode, "on#off"); 6708 cmdline_parse_token_string_t cmd_lfc_set_autoneg_str = 6709 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result, 6710 autoneg_str, "autoneg"); 6711 cmdline_parse_token_string_t cmd_lfc_set_autoneg = 6712 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result, 6713 autoneg, "on#off"); 6714 cmdline_parse_token_num_t cmd_lfc_set_portid = 6715 TOKEN_NUM_INITIALIZER(struct cmd_link_flow_ctrl_set_result, 6716 port_id, UINT16); 6717 6718 /* forward declaration */ 6719 static void 6720 cmd_link_flow_ctrl_set_parsed(void *parsed_result, struct cmdline *cl, 6721 void *data); 6722 6723 cmdline_parse_inst_t cmd_link_flow_control_set = { 6724 .f = cmd_link_flow_ctrl_set_parsed, 6725 .data = NULL, 6726 .help_str = "set flow_ctrl rx on|off tx on|off <high_water> " 6727 "<low_water> <pause_time> <send_xon> mac_ctrl_frame_fwd on|off " 6728 "autoneg on|off <port_id>: Configure the Ethernet flow control", 6729 .tokens = { 6730 (void *)&cmd_lfc_set_set, 6731 (void *)&cmd_lfc_set_flow_ctrl, 6732 (void *)&cmd_lfc_set_rx, 6733 (void *)&cmd_lfc_set_rx_mode, 6734 (void *)&cmd_lfc_set_tx, 6735 (void *)&cmd_lfc_set_tx_mode, 6736 (void *)&cmd_lfc_set_high_water, 6737 (void *)&cmd_lfc_set_low_water, 6738 (void *)&cmd_lfc_set_pause_time, 6739 (void *)&cmd_lfc_set_send_xon, 6740 (void *)&cmd_lfc_set_mac_ctrl_frame_fwd_mode, 6741 (void *)&cmd_lfc_set_mac_ctrl_frame_fwd, 6742 (void *)&cmd_lfc_set_autoneg_str, 6743 (void *)&cmd_lfc_set_autoneg, 6744 (void *)&cmd_lfc_set_portid, 6745 NULL, 6746 }, 6747 }; 6748 6749 cmdline_parse_inst_t cmd_link_flow_control_set_rx = { 6750 .f = cmd_link_flow_ctrl_set_parsed, 6751 .data = (void *)&cmd_link_flow_control_set_rx, 6752 .help_str = "set flow_ctrl rx on|off <port_id>: " 6753 "Change rx flow control parameter", 6754 .tokens = { 6755 (void *)&cmd_lfc_set_set, 6756 (void *)&cmd_lfc_set_flow_ctrl, 6757 (void *)&cmd_lfc_set_rx, 6758 (void *)&cmd_lfc_set_rx_mode, 6759 (void *)&cmd_lfc_set_portid, 6760 NULL, 6761 }, 6762 }; 6763 6764 cmdline_parse_inst_t cmd_link_flow_control_set_tx = { 6765 .f = cmd_link_flow_ctrl_set_parsed, 6766 .data = (void *)&cmd_link_flow_control_set_tx, 6767 .help_str = "set flow_ctrl tx on|off <port_id>: " 6768 "Change tx flow control parameter", 6769 .tokens = { 6770 (void *)&cmd_lfc_set_set, 6771 (void *)&cmd_lfc_set_flow_ctrl, 6772 (void *)&cmd_lfc_set_tx, 6773 (void *)&cmd_lfc_set_tx_mode, 6774 (void *)&cmd_lfc_set_portid, 6775 NULL, 6776 }, 6777 }; 6778 6779 cmdline_parse_inst_t cmd_link_flow_control_set_hw = { 6780 .f = cmd_link_flow_ctrl_set_parsed, 6781 .data = (void *)&cmd_link_flow_control_set_hw, 6782 .help_str = "set flow_ctrl high_water <value> <port_id>: " 6783 "Change high water flow control parameter", 6784 .tokens = { 6785 (void *)&cmd_lfc_set_set, 6786 (void *)&cmd_lfc_set_flow_ctrl, 6787 (void *)&cmd_lfc_set_high_water_str, 6788 (void *)&cmd_lfc_set_high_water, 6789 (void *)&cmd_lfc_set_portid, 6790 NULL, 6791 }, 6792 }; 6793 6794 cmdline_parse_inst_t cmd_link_flow_control_set_lw = { 6795 .f = cmd_link_flow_ctrl_set_parsed, 6796 .data = (void *)&cmd_link_flow_control_set_lw, 6797 .help_str = "set flow_ctrl low_water <value> <port_id>: " 6798 "Change low water flow control parameter", 6799 .tokens = { 6800 (void *)&cmd_lfc_set_set, 6801 (void *)&cmd_lfc_set_flow_ctrl, 6802 (void *)&cmd_lfc_set_low_water_str, 6803 (void *)&cmd_lfc_set_low_water, 6804 (void *)&cmd_lfc_set_portid, 6805 NULL, 6806 }, 6807 }; 6808 6809 cmdline_parse_inst_t cmd_link_flow_control_set_pt = { 6810 .f = cmd_link_flow_ctrl_set_parsed, 6811 .data = (void *)&cmd_link_flow_control_set_pt, 6812 .help_str = "set flow_ctrl pause_time <value> <port_id>: " 6813 "Change pause time flow control parameter", 6814 .tokens = { 6815 (void *)&cmd_lfc_set_set, 6816 (void *)&cmd_lfc_set_flow_ctrl, 6817 (void *)&cmd_lfc_set_pause_time_str, 6818 (void *)&cmd_lfc_set_pause_time, 6819 (void *)&cmd_lfc_set_portid, 6820 NULL, 6821 }, 6822 }; 6823 6824 cmdline_parse_inst_t cmd_link_flow_control_set_xon = { 6825 .f = cmd_link_flow_ctrl_set_parsed, 6826 .data = (void *)&cmd_link_flow_control_set_xon, 6827 .help_str = "set flow_ctrl send_xon <value> <port_id>: " 6828 "Change send_xon flow control parameter", 6829 .tokens = { 6830 (void *)&cmd_lfc_set_set, 6831 (void *)&cmd_lfc_set_flow_ctrl, 6832 (void *)&cmd_lfc_set_send_xon_str, 6833 (void *)&cmd_lfc_set_send_xon, 6834 (void *)&cmd_lfc_set_portid, 6835 NULL, 6836 }, 6837 }; 6838 6839 cmdline_parse_inst_t cmd_link_flow_control_set_macfwd = { 6840 .f = cmd_link_flow_ctrl_set_parsed, 6841 .data = (void *)&cmd_link_flow_control_set_macfwd, 6842 .help_str = "set flow_ctrl mac_ctrl_frame_fwd on|off <port_id>: " 6843 "Change mac ctrl fwd flow control parameter", 6844 .tokens = { 6845 (void *)&cmd_lfc_set_set, 6846 (void *)&cmd_lfc_set_flow_ctrl, 6847 (void *)&cmd_lfc_set_mac_ctrl_frame_fwd_mode, 6848 (void *)&cmd_lfc_set_mac_ctrl_frame_fwd, 6849 (void *)&cmd_lfc_set_portid, 6850 NULL, 6851 }, 6852 }; 6853 6854 cmdline_parse_inst_t cmd_link_flow_control_set_autoneg = { 6855 .f = cmd_link_flow_ctrl_set_parsed, 6856 .data = (void *)&cmd_link_flow_control_set_autoneg, 6857 .help_str = "set flow_ctrl autoneg on|off <port_id>: " 6858 "Change autoneg flow control parameter", 6859 .tokens = { 6860 (void *)&cmd_lfc_set_set, 6861 (void *)&cmd_lfc_set_flow_ctrl, 6862 (void *)&cmd_lfc_set_autoneg_str, 6863 (void *)&cmd_lfc_set_autoneg, 6864 (void *)&cmd_lfc_set_portid, 6865 NULL, 6866 }, 6867 }; 6868 6869 static void 6870 cmd_link_flow_ctrl_set_parsed(void *parsed_result, 6871 __attribute__((unused)) struct cmdline *cl, 6872 void *data) 6873 { 6874 struct cmd_link_flow_ctrl_set_result *res = parsed_result; 6875 cmdline_parse_inst_t *cmd = data; 6876 struct rte_eth_fc_conf fc_conf; 6877 int rx_fc_en = 0; 6878 int tx_fc_en = 0; 6879 int ret; 6880 6881 /* 6882 * Rx on/off, flow control is enabled/disabled on RX side. This can indicate 6883 * the RTE_FC_TX_PAUSE, Transmit pause frame at the Rx side. 6884 * Tx on/off, flow control is enabled/disabled on TX side. This can indicate 6885 * the RTE_FC_RX_PAUSE, Respond to the pause frame at the Tx side. 6886 */ 6887 static enum rte_eth_fc_mode rx_tx_onoff_2_lfc_mode[2][2] = { 6888 {RTE_FC_NONE, RTE_FC_TX_PAUSE}, {RTE_FC_RX_PAUSE, RTE_FC_FULL} 6889 }; 6890 6891 /* Partial command line, retrieve current configuration */ 6892 if (cmd) { 6893 ret = rte_eth_dev_flow_ctrl_get(res->port_id, &fc_conf); 6894 if (ret != 0) { 6895 printf("cannot get current flow ctrl parameters, return" 6896 "code = %d\n", ret); 6897 return; 6898 } 6899 6900 if ((fc_conf.mode == RTE_FC_RX_PAUSE) || 6901 (fc_conf.mode == RTE_FC_FULL)) 6902 rx_fc_en = 1; 6903 if ((fc_conf.mode == RTE_FC_TX_PAUSE) || 6904 (fc_conf.mode == RTE_FC_FULL)) 6905 tx_fc_en = 1; 6906 } 6907 6908 if (!cmd || cmd == &cmd_link_flow_control_set_rx) 6909 rx_fc_en = (!strcmp(res->rx_lfc_mode, "on")) ? 1 : 0; 6910 6911 if (!cmd || cmd == &cmd_link_flow_control_set_tx) 6912 tx_fc_en = (!strcmp(res->tx_lfc_mode, "on")) ? 1 : 0; 6913 6914 fc_conf.mode = rx_tx_onoff_2_lfc_mode[rx_fc_en][tx_fc_en]; 6915 6916 if (!cmd || cmd == &cmd_link_flow_control_set_hw) 6917 fc_conf.high_water = res->high_water; 6918 6919 if (!cmd || cmd == &cmd_link_flow_control_set_lw) 6920 fc_conf.low_water = res->low_water; 6921 6922 if (!cmd || cmd == &cmd_link_flow_control_set_pt) 6923 fc_conf.pause_time = res->pause_time; 6924 6925 if (!cmd || cmd == &cmd_link_flow_control_set_xon) 6926 fc_conf.send_xon = res->send_xon; 6927 6928 if (!cmd || cmd == &cmd_link_flow_control_set_macfwd) { 6929 if (!strcmp(res->mac_ctrl_frame_fwd_mode, "on")) 6930 fc_conf.mac_ctrl_frame_fwd = 1; 6931 else 6932 fc_conf.mac_ctrl_frame_fwd = 0; 6933 } 6934 6935 if (!cmd || cmd == &cmd_link_flow_control_set_autoneg) 6936 fc_conf.autoneg = (!strcmp(res->autoneg, "on")) ? 1 : 0; 6937 6938 ret = rte_eth_dev_flow_ctrl_set(res->port_id, &fc_conf); 6939 if (ret != 0) 6940 printf("bad flow contrl parameter, return code = %d \n", ret); 6941 } 6942 6943 /* *** SETUP ETHERNET PRIORITY FLOW CONTROL *** */ 6944 struct cmd_priority_flow_ctrl_set_result { 6945 cmdline_fixed_string_t set; 6946 cmdline_fixed_string_t pfc_ctrl; 6947 cmdline_fixed_string_t rx; 6948 cmdline_fixed_string_t rx_pfc_mode; 6949 cmdline_fixed_string_t tx; 6950 cmdline_fixed_string_t tx_pfc_mode; 6951 uint32_t high_water; 6952 uint32_t low_water; 6953 uint16_t pause_time; 6954 uint8_t priority; 6955 portid_t port_id; 6956 }; 6957 6958 static void 6959 cmd_priority_flow_ctrl_set_parsed(void *parsed_result, 6960 __attribute__((unused)) struct cmdline *cl, 6961 __attribute__((unused)) void *data) 6962 { 6963 struct cmd_priority_flow_ctrl_set_result *res = parsed_result; 6964 struct rte_eth_pfc_conf pfc_conf; 6965 int rx_fc_enable, tx_fc_enable; 6966 int ret; 6967 6968 /* 6969 * Rx on/off, flow control is enabled/disabled on RX side. This can indicate 6970 * the RTE_FC_TX_PAUSE, Transmit pause frame at the Rx side. 6971 * Tx on/off, flow control is enabled/disabled on TX side. This can indicate 6972 * the RTE_FC_RX_PAUSE, Respond to the pause frame at the Tx side. 6973 */ 6974 static enum rte_eth_fc_mode rx_tx_onoff_2_pfc_mode[2][2] = { 6975 {RTE_FC_NONE, RTE_FC_RX_PAUSE}, {RTE_FC_TX_PAUSE, RTE_FC_FULL} 6976 }; 6977 6978 rx_fc_enable = (!strncmp(res->rx_pfc_mode, "on",2)) ? 1 : 0; 6979 tx_fc_enable = (!strncmp(res->tx_pfc_mode, "on",2)) ? 1 : 0; 6980 pfc_conf.fc.mode = rx_tx_onoff_2_pfc_mode[rx_fc_enable][tx_fc_enable]; 6981 pfc_conf.fc.high_water = res->high_water; 6982 pfc_conf.fc.low_water = res->low_water; 6983 pfc_conf.fc.pause_time = res->pause_time; 6984 pfc_conf.priority = res->priority; 6985 6986 ret = rte_eth_dev_priority_flow_ctrl_set(res->port_id, &pfc_conf); 6987 if (ret != 0) 6988 printf("bad priority flow contrl parameter, return code = %d \n", ret); 6989 } 6990 6991 cmdline_parse_token_string_t cmd_pfc_set_set = 6992 TOKEN_STRING_INITIALIZER(struct cmd_priority_flow_ctrl_set_result, 6993 set, "set"); 6994 cmdline_parse_token_string_t cmd_pfc_set_flow_ctrl = 6995 TOKEN_STRING_INITIALIZER(struct cmd_priority_flow_ctrl_set_result, 6996 pfc_ctrl, "pfc_ctrl"); 6997 cmdline_parse_token_string_t cmd_pfc_set_rx = 6998 TOKEN_STRING_INITIALIZER(struct cmd_priority_flow_ctrl_set_result, 6999 rx, "rx"); 7000 cmdline_parse_token_string_t cmd_pfc_set_rx_mode = 7001 TOKEN_STRING_INITIALIZER(struct cmd_priority_flow_ctrl_set_result, 7002 rx_pfc_mode, "on#off"); 7003 cmdline_parse_token_string_t cmd_pfc_set_tx = 7004 TOKEN_STRING_INITIALIZER(struct cmd_priority_flow_ctrl_set_result, 7005 tx, "tx"); 7006 cmdline_parse_token_string_t cmd_pfc_set_tx_mode = 7007 TOKEN_STRING_INITIALIZER(struct cmd_priority_flow_ctrl_set_result, 7008 tx_pfc_mode, "on#off"); 7009 cmdline_parse_token_num_t cmd_pfc_set_high_water = 7010 TOKEN_NUM_INITIALIZER(struct cmd_priority_flow_ctrl_set_result, 7011 high_water, UINT32); 7012 cmdline_parse_token_num_t cmd_pfc_set_low_water = 7013 TOKEN_NUM_INITIALIZER(struct cmd_priority_flow_ctrl_set_result, 7014 low_water, UINT32); 7015 cmdline_parse_token_num_t cmd_pfc_set_pause_time = 7016 TOKEN_NUM_INITIALIZER(struct cmd_priority_flow_ctrl_set_result, 7017 pause_time, UINT16); 7018 cmdline_parse_token_num_t cmd_pfc_set_priority = 7019 TOKEN_NUM_INITIALIZER(struct cmd_priority_flow_ctrl_set_result, 7020 priority, UINT8); 7021 cmdline_parse_token_num_t cmd_pfc_set_portid = 7022 TOKEN_NUM_INITIALIZER(struct cmd_priority_flow_ctrl_set_result, 7023 port_id, UINT16); 7024 7025 cmdline_parse_inst_t cmd_priority_flow_control_set = { 7026 .f = cmd_priority_flow_ctrl_set_parsed, 7027 .data = NULL, 7028 .help_str = "set pfc_ctrl rx on|off tx on|off <high_water> <low_water> " 7029 "<pause_time> <priority> <port_id>: " 7030 "Configure the Ethernet priority flow control", 7031 .tokens = { 7032 (void *)&cmd_pfc_set_set, 7033 (void *)&cmd_pfc_set_flow_ctrl, 7034 (void *)&cmd_pfc_set_rx, 7035 (void *)&cmd_pfc_set_rx_mode, 7036 (void *)&cmd_pfc_set_tx, 7037 (void *)&cmd_pfc_set_tx_mode, 7038 (void *)&cmd_pfc_set_high_water, 7039 (void *)&cmd_pfc_set_low_water, 7040 (void *)&cmd_pfc_set_pause_time, 7041 (void *)&cmd_pfc_set_priority, 7042 (void *)&cmd_pfc_set_portid, 7043 NULL, 7044 }, 7045 }; 7046 7047 /* *** RESET CONFIGURATION *** */ 7048 struct cmd_reset_result { 7049 cmdline_fixed_string_t reset; 7050 cmdline_fixed_string_t def; 7051 }; 7052 7053 static void cmd_reset_parsed(__attribute__((unused)) void *parsed_result, 7054 struct cmdline *cl, 7055 __attribute__((unused)) void *data) 7056 { 7057 cmdline_printf(cl, "Reset to default forwarding configuration...\n"); 7058 set_def_fwd_config(); 7059 } 7060 7061 cmdline_parse_token_string_t cmd_reset_set = 7062 TOKEN_STRING_INITIALIZER(struct cmd_reset_result, reset, "set"); 7063 cmdline_parse_token_string_t cmd_reset_def = 7064 TOKEN_STRING_INITIALIZER(struct cmd_reset_result, def, 7065 "default"); 7066 7067 cmdline_parse_inst_t cmd_reset = { 7068 .f = cmd_reset_parsed, 7069 .data = NULL, 7070 .help_str = "set default: Reset default forwarding configuration", 7071 .tokens = { 7072 (void *)&cmd_reset_set, 7073 (void *)&cmd_reset_def, 7074 NULL, 7075 }, 7076 }; 7077 7078 /* *** START FORWARDING *** */ 7079 struct cmd_start_result { 7080 cmdline_fixed_string_t start; 7081 }; 7082 7083 cmdline_parse_token_string_t cmd_start_start = 7084 TOKEN_STRING_INITIALIZER(struct cmd_start_result, start, "start"); 7085 7086 static void cmd_start_parsed(__attribute__((unused)) void *parsed_result, 7087 __attribute__((unused)) struct cmdline *cl, 7088 __attribute__((unused)) void *data) 7089 { 7090 start_packet_forwarding(0); 7091 } 7092 7093 cmdline_parse_inst_t cmd_start = { 7094 .f = cmd_start_parsed, 7095 .data = NULL, 7096 .help_str = "start: Start packet forwarding", 7097 .tokens = { 7098 (void *)&cmd_start_start, 7099 NULL, 7100 }, 7101 }; 7102 7103 /* *** START FORWARDING WITH ONE TX BURST FIRST *** */ 7104 struct cmd_start_tx_first_result { 7105 cmdline_fixed_string_t start; 7106 cmdline_fixed_string_t tx_first; 7107 }; 7108 7109 static void 7110 cmd_start_tx_first_parsed(__attribute__((unused)) void *parsed_result, 7111 __attribute__((unused)) struct cmdline *cl, 7112 __attribute__((unused)) void *data) 7113 { 7114 start_packet_forwarding(1); 7115 } 7116 7117 cmdline_parse_token_string_t cmd_start_tx_first_start = 7118 TOKEN_STRING_INITIALIZER(struct cmd_start_tx_first_result, start, 7119 "start"); 7120 cmdline_parse_token_string_t cmd_start_tx_first_tx_first = 7121 TOKEN_STRING_INITIALIZER(struct cmd_start_tx_first_result, 7122 tx_first, "tx_first"); 7123 7124 cmdline_parse_inst_t cmd_start_tx_first = { 7125 .f = cmd_start_tx_first_parsed, 7126 .data = NULL, 7127 .help_str = "start tx_first: Start packet forwarding, " 7128 "after sending 1 burst of packets", 7129 .tokens = { 7130 (void *)&cmd_start_tx_first_start, 7131 (void *)&cmd_start_tx_first_tx_first, 7132 NULL, 7133 }, 7134 }; 7135 7136 /* *** START FORWARDING WITH N TX BURST FIRST *** */ 7137 struct cmd_start_tx_first_n_result { 7138 cmdline_fixed_string_t start; 7139 cmdline_fixed_string_t tx_first; 7140 uint32_t tx_num; 7141 }; 7142 7143 static void 7144 cmd_start_tx_first_n_parsed(void *parsed_result, 7145 __attribute__((unused)) struct cmdline *cl, 7146 __attribute__((unused)) void *data) 7147 { 7148 struct cmd_start_tx_first_n_result *res = parsed_result; 7149 7150 start_packet_forwarding(res->tx_num); 7151 } 7152 7153 cmdline_parse_token_string_t cmd_start_tx_first_n_start = 7154 TOKEN_STRING_INITIALIZER(struct cmd_start_tx_first_n_result, 7155 start, "start"); 7156 cmdline_parse_token_string_t cmd_start_tx_first_n_tx_first = 7157 TOKEN_STRING_INITIALIZER(struct cmd_start_tx_first_n_result, 7158 tx_first, "tx_first"); 7159 cmdline_parse_token_num_t cmd_start_tx_first_n_tx_num = 7160 TOKEN_NUM_INITIALIZER(struct cmd_start_tx_first_n_result, 7161 tx_num, UINT32); 7162 7163 cmdline_parse_inst_t cmd_start_tx_first_n = { 7164 .f = cmd_start_tx_first_n_parsed, 7165 .data = NULL, 7166 .help_str = "start tx_first <num>: " 7167 "packet forwarding, after sending <num> bursts of packets", 7168 .tokens = { 7169 (void *)&cmd_start_tx_first_n_start, 7170 (void *)&cmd_start_tx_first_n_tx_first, 7171 (void *)&cmd_start_tx_first_n_tx_num, 7172 NULL, 7173 }, 7174 }; 7175 7176 /* *** SET LINK UP *** */ 7177 struct cmd_set_link_up_result { 7178 cmdline_fixed_string_t set; 7179 cmdline_fixed_string_t link_up; 7180 cmdline_fixed_string_t port; 7181 portid_t port_id; 7182 }; 7183 7184 cmdline_parse_token_string_t cmd_set_link_up_set = 7185 TOKEN_STRING_INITIALIZER(struct cmd_set_link_up_result, set, "set"); 7186 cmdline_parse_token_string_t cmd_set_link_up_link_up = 7187 TOKEN_STRING_INITIALIZER(struct cmd_set_link_up_result, link_up, 7188 "link-up"); 7189 cmdline_parse_token_string_t cmd_set_link_up_port = 7190 TOKEN_STRING_INITIALIZER(struct cmd_set_link_up_result, port, "port"); 7191 cmdline_parse_token_num_t cmd_set_link_up_port_id = 7192 TOKEN_NUM_INITIALIZER(struct cmd_set_link_up_result, port_id, UINT16); 7193 7194 static void cmd_set_link_up_parsed(__attribute__((unused)) void *parsed_result, 7195 __attribute__((unused)) struct cmdline *cl, 7196 __attribute__((unused)) void *data) 7197 { 7198 struct cmd_set_link_up_result *res = parsed_result; 7199 dev_set_link_up(res->port_id); 7200 } 7201 7202 cmdline_parse_inst_t cmd_set_link_up = { 7203 .f = cmd_set_link_up_parsed, 7204 .data = NULL, 7205 .help_str = "set link-up port <port id>", 7206 .tokens = { 7207 (void *)&cmd_set_link_up_set, 7208 (void *)&cmd_set_link_up_link_up, 7209 (void *)&cmd_set_link_up_port, 7210 (void *)&cmd_set_link_up_port_id, 7211 NULL, 7212 }, 7213 }; 7214 7215 /* *** SET LINK DOWN *** */ 7216 struct cmd_set_link_down_result { 7217 cmdline_fixed_string_t set; 7218 cmdline_fixed_string_t link_down; 7219 cmdline_fixed_string_t port; 7220 portid_t port_id; 7221 }; 7222 7223 cmdline_parse_token_string_t cmd_set_link_down_set = 7224 TOKEN_STRING_INITIALIZER(struct cmd_set_link_down_result, set, "set"); 7225 cmdline_parse_token_string_t cmd_set_link_down_link_down = 7226 TOKEN_STRING_INITIALIZER(struct cmd_set_link_down_result, link_down, 7227 "link-down"); 7228 cmdline_parse_token_string_t cmd_set_link_down_port = 7229 TOKEN_STRING_INITIALIZER(struct cmd_set_link_down_result, port, "port"); 7230 cmdline_parse_token_num_t cmd_set_link_down_port_id = 7231 TOKEN_NUM_INITIALIZER(struct cmd_set_link_down_result, port_id, UINT16); 7232 7233 static void cmd_set_link_down_parsed( 7234 __attribute__((unused)) void *parsed_result, 7235 __attribute__((unused)) struct cmdline *cl, 7236 __attribute__((unused)) void *data) 7237 { 7238 struct cmd_set_link_down_result *res = parsed_result; 7239 dev_set_link_down(res->port_id); 7240 } 7241 7242 cmdline_parse_inst_t cmd_set_link_down = { 7243 .f = cmd_set_link_down_parsed, 7244 .data = NULL, 7245 .help_str = "set link-down port <port id>", 7246 .tokens = { 7247 (void *)&cmd_set_link_down_set, 7248 (void *)&cmd_set_link_down_link_down, 7249 (void *)&cmd_set_link_down_port, 7250 (void *)&cmd_set_link_down_port_id, 7251 NULL, 7252 }, 7253 }; 7254 7255 /* *** SHOW CFG *** */ 7256 struct cmd_showcfg_result { 7257 cmdline_fixed_string_t show; 7258 cmdline_fixed_string_t cfg; 7259 cmdline_fixed_string_t what; 7260 }; 7261 7262 static void cmd_showcfg_parsed(void *parsed_result, 7263 __attribute__((unused)) struct cmdline *cl, 7264 __attribute__((unused)) void *data) 7265 { 7266 struct cmd_showcfg_result *res = parsed_result; 7267 if (!strcmp(res->what, "rxtx")) 7268 rxtx_config_display(); 7269 else if (!strcmp(res->what, "cores")) 7270 fwd_lcores_config_display(); 7271 else if (!strcmp(res->what, "fwd")) 7272 pkt_fwd_config_display(&cur_fwd_config); 7273 else if (!strcmp(res->what, "txpkts")) 7274 show_tx_pkt_segments(); 7275 } 7276 7277 cmdline_parse_token_string_t cmd_showcfg_show = 7278 TOKEN_STRING_INITIALIZER(struct cmd_showcfg_result, show, "show"); 7279 cmdline_parse_token_string_t cmd_showcfg_port = 7280 TOKEN_STRING_INITIALIZER(struct cmd_showcfg_result, cfg, "config"); 7281 cmdline_parse_token_string_t cmd_showcfg_what = 7282 TOKEN_STRING_INITIALIZER(struct cmd_showcfg_result, what, 7283 "rxtx#cores#fwd#txpkts"); 7284 7285 cmdline_parse_inst_t cmd_showcfg = { 7286 .f = cmd_showcfg_parsed, 7287 .data = NULL, 7288 .help_str = "show config rxtx|cores|fwd|txpkts", 7289 .tokens = { 7290 (void *)&cmd_showcfg_show, 7291 (void *)&cmd_showcfg_port, 7292 (void *)&cmd_showcfg_what, 7293 NULL, 7294 }, 7295 }; 7296 7297 /* *** SHOW ALL PORT INFO *** */ 7298 struct cmd_showportall_result { 7299 cmdline_fixed_string_t show; 7300 cmdline_fixed_string_t port; 7301 cmdline_fixed_string_t what; 7302 cmdline_fixed_string_t all; 7303 }; 7304 7305 static void cmd_showportall_parsed(void *parsed_result, 7306 __attribute__((unused)) struct cmdline *cl, 7307 __attribute__((unused)) void *data) 7308 { 7309 portid_t i; 7310 7311 struct cmd_showportall_result *res = parsed_result; 7312 if (!strcmp(res->show, "clear")) { 7313 if (!strcmp(res->what, "stats")) 7314 RTE_ETH_FOREACH_DEV(i) 7315 nic_stats_clear(i); 7316 else if (!strcmp(res->what, "xstats")) 7317 RTE_ETH_FOREACH_DEV(i) 7318 nic_xstats_clear(i); 7319 } else if (!strcmp(res->what, "info")) 7320 RTE_ETH_FOREACH_DEV(i) 7321 port_infos_display(i); 7322 else if (!strcmp(res->what, "summary")) { 7323 port_summary_header_display(); 7324 RTE_ETH_FOREACH_DEV(i) 7325 port_summary_display(i); 7326 } 7327 else if (!strcmp(res->what, "stats")) 7328 RTE_ETH_FOREACH_DEV(i) 7329 nic_stats_display(i); 7330 else if (!strcmp(res->what, "xstats")) 7331 RTE_ETH_FOREACH_DEV(i) 7332 nic_xstats_display(i); 7333 else if (!strcmp(res->what, "fdir")) 7334 RTE_ETH_FOREACH_DEV(i) 7335 fdir_get_infos(i); 7336 else if (!strcmp(res->what, "stat_qmap")) 7337 RTE_ETH_FOREACH_DEV(i) 7338 nic_stats_mapping_display(i); 7339 else if (!strcmp(res->what, "dcb_tc")) 7340 RTE_ETH_FOREACH_DEV(i) 7341 port_dcb_info_display(i); 7342 else if (!strcmp(res->what, "cap")) 7343 RTE_ETH_FOREACH_DEV(i) 7344 port_offload_cap_display(i); 7345 } 7346 7347 cmdline_parse_token_string_t cmd_showportall_show = 7348 TOKEN_STRING_INITIALIZER(struct cmd_showportall_result, show, 7349 "show#clear"); 7350 cmdline_parse_token_string_t cmd_showportall_port = 7351 TOKEN_STRING_INITIALIZER(struct cmd_showportall_result, port, "port"); 7352 cmdline_parse_token_string_t cmd_showportall_what = 7353 TOKEN_STRING_INITIALIZER(struct cmd_showportall_result, what, 7354 "info#summary#stats#xstats#fdir#stat_qmap#dcb_tc#cap"); 7355 cmdline_parse_token_string_t cmd_showportall_all = 7356 TOKEN_STRING_INITIALIZER(struct cmd_showportall_result, all, "all"); 7357 cmdline_parse_inst_t cmd_showportall = { 7358 .f = cmd_showportall_parsed, 7359 .data = NULL, 7360 .help_str = "show|clear port " 7361 "info|summary|stats|xstats|fdir|stat_qmap|dcb_tc|cap all", 7362 .tokens = { 7363 (void *)&cmd_showportall_show, 7364 (void *)&cmd_showportall_port, 7365 (void *)&cmd_showportall_what, 7366 (void *)&cmd_showportall_all, 7367 NULL, 7368 }, 7369 }; 7370 7371 /* *** SHOW PORT INFO *** */ 7372 struct cmd_showport_result { 7373 cmdline_fixed_string_t show; 7374 cmdline_fixed_string_t port; 7375 cmdline_fixed_string_t what; 7376 uint16_t portnum; 7377 }; 7378 7379 static void cmd_showport_parsed(void *parsed_result, 7380 __attribute__((unused)) struct cmdline *cl, 7381 __attribute__((unused)) void *data) 7382 { 7383 struct cmd_showport_result *res = parsed_result; 7384 if (!strcmp(res->show, "clear")) { 7385 if (!strcmp(res->what, "stats")) 7386 nic_stats_clear(res->portnum); 7387 else if (!strcmp(res->what, "xstats")) 7388 nic_xstats_clear(res->portnum); 7389 } else if (!strcmp(res->what, "info")) 7390 port_infos_display(res->portnum); 7391 else if (!strcmp(res->what, "summary")) { 7392 port_summary_header_display(); 7393 port_summary_display(res->portnum); 7394 } 7395 else if (!strcmp(res->what, "stats")) 7396 nic_stats_display(res->portnum); 7397 else if (!strcmp(res->what, "xstats")) 7398 nic_xstats_display(res->portnum); 7399 else if (!strcmp(res->what, "fdir")) 7400 fdir_get_infos(res->portnum); 7401 else if (!strcmp(res->what, "stat_qmap")) 7402 nic_stats_mapping_display(res->portnum); 7403 else if (!strcmp(res->what, "dcb_tc")) 7404 port_dcb_info_display(res->portnum); 7405 else if (!strcmp(res->what, "cap")) 7406 port_offload_cap_display(res->portnum); 7407 } 7408 7409 cmdline_parse_token_string_t cmd_showport_show = 7410 TOKEN_STRING_INITIALIZER(struct cmd_showport_result, show, 7411 "show#clear"); 7412 cmdline_parse_token_string_t cmd_showport_port = 7413 TOKEN_STRING_INITIALIZER(struct cmd_showport_result, port, "port"); 7414 cmdline_parse_token_string_t cmd_showport_what = 7415 TOKEN_STRING_INITIALIZER(struct cmd_showport_result, what, 7416 "info#summary#stats#xstats#fdir#stat_qmap#dcb_tc#cap"); 7417 cmdline_parse_token_num_t cmd_showport_portnum = 7418 TOKEN_NUM_INITIALIZER(struct cmd_showport_result, portnum, UINT16); 7419 7420 cmdline_parse_inst_t cmd_showport = { 7421 .f = cmd_showport_parsed, 7422 .data = NULL, 7423 .help_str = "show|clear port " 7424 "info|summary|stats|xstats|fdir|stat_qmap|dcb_tc|cap " 7425 "<port_id>", 7426 .tokens = { 7427 (void *)&cmd_showport_show, 7428 (void *)&cmd_showport_port, 7429 (void *)&cmd_showport_what, 7430 (void *)&cmd_showport_portnum, 7431 NULL, 7432 }, 7433 }; 7434 7435 /* *** SHOW QUEUE INFO *** */ 7436 struct cmd_showqueue_result { 7437 cmdline_fixed_string_t show; 7438 cmdline_fixed_string_t type; 7439 cmdline_fixed_string_t what; 7440 uint16_t portnum; 7441 uint16_t queuenum; 7442 }; 7443 7444 static void 7445 cmd_showqueue_parsed(void *parsed_result, 7446 __attribute__((unused)) struct cmdline *cl, 7447 __attribute__((unused)) void *data) 7448 { 7449 struct cmd_showqueue_result *res = parsed_result; 7450 7451 if (!strcmp(res->type, "rxq")) 7452 rx_queue_infos_display(res->portnum, res->queuenum); 7453 else if (!strcmp(res->type, "txq")) 7454 tx_queue_infos_display(res->portnum, res->queuenum); 7455 } 7456 7457 cmdline_parse_token_string_t cmd_showqueue_show = 7458 TOKEN_STRING_INITIALIZER(struct cmd_showqueue_result, show, "show"); 7459 cmdline_parse_token_string_t cmd_showqueue_type = 7460 TOKEN_STRING_INITIALIZER(struct cmd_showqueue_result, type, "rxq#txq"); 7461 cmdline_parse_token_string_t cmd_showqueue_what = 7462 TOKEN_STRING_INITIALIZER(struct cmd_showqueue_result, what, "info"); 7463 cmdline_parse_token_num_t cmd_showqueue_portnum = 7464 TOKEN_NUM_INITIALIZER(struct cmd_showqueue_result, portnum, UINT16); 7465 cmdline_parse_token_num_t cmd_showqueue_queuenum = 7466 TOKEN_NUM_INITIALIZER(struct cmd_showqueue_result, queuenum, UINT16); 7467 7468 cmdline_parse_inst_t cmd_showqueue = { 7469 .f = cmd_showqueue_parsed, 7470 .data = NULL, 7471 .help_str = "show rxq|txq info <port_id> <queue_id>", 7472 .tokens = { 7473 (void *)&cmd_showqueue_show, 7474 (void *)&cmd_showqueue_type, 7475 (void *)&cmd_showqueue_what, 7476 (void *)&cmd_showqueue_portnum, 7477 (void *)&cmd_showqueue_queuenum, 7478 NULL, 7479 }, 7480 }; 7481 7482 /* *** READ PORT REGISTER *** */ 7483 struct cmd_read_reg_result { 7484 cmdline_fixed_string_t read; 7485 cmdline_fixed_string_t reg; 7486 portid_t port_id; 7487 uint32_t reg_off; 7488 }; 7489 7490 static void 7491 cmd_read_reg_parsed(void *parsed_result, 7492 __attribute__((unused)) struct cmdline *cl, 7493 __attribute__((unused)) void *data) 7494 { 7495 struct cmd_read_reg_result *res = parsed_result; 7496 port_reg_display(res->port_id, res->reg_off); 7497 } 7498 7499 cmdline_parse_token_string_t cmd_read_reg_read = 7500 TOKEN_STRING_INITIALIZER(struct cmd_read_reg_result, read, "read"); 7501 cmdline_parse_token_string_t cmd_read_reg_reg = 7502 TOKEN_STRING_INITIALIZER(struct cmd_read_reg_result, reg, "reg"); 7503 cmdline_parse_token_num_t cmd_read_reg_port_id = 7504 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_result, port_id, UINT16); 7505 cmdline_parse_token_num_t cmd_read_reg_reg_off = 7506 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_result, reg_off, UINT32); 7507 7508 cmdline_parse_inst_t cmd_read_reg = { 7509 .f = cmd_read_reg_parsed, 7510 .data = NULL, 7511 .help_str = "read reg <port_id> <reg_off>", 7512 .tokens = { 7513 (void *)&cmd_read_reg_read, 7514 (void *)&cmd_read_reg_reg, 7515 (void *)&cmd_read_reg_port_id, 7516 (void *)&cmd_read_reg_reg_off, 7517 NULL, 7518 }, 7519 }; 7520 7521 /* *** READ PORT REGISTER BIT FIELD *** */ 7522 struct cmd_read_reg_bit_field_result { 7523 cmdline_fixed_string_t read; 7524 cmdline_fixed_string_t regfield; 7525 portid_t port_id; 7526 uint32_t reg_off; 7527 uint8_t bit1_pos; 7528 uint8_t bit2_pos; 7529 }; 7530 7531 static void 7532 cmd_read_reg_bit_field_parsed(void *parsed_result, 7533 __attribute__((unused)) struct cmdline *cl, 7534 __attribute__((unused)) void *data) 7535 { 7536 struct cmd_read_reg_bit_field_result *res = parsed_result; 7537 port_reg_bit_field_display(res->port_id, res->reg_off, 7538 res->bit1_pos, res->bit2_pos); 7539 } 7540 7541 cmdline_parse_token_string_t cmd_read_reg_bit_field_read = 7542 TOKEN_STRING_INITIALIZER(struct cmd_read_reg_bit_field_result, read, 7543 "read"); 7544 cmdline_parse_token_string_t cmd_read_reg_bit_field_regfield = 7545 TOKEN_STRING_INITIALIZER(struct cmd_read_reg_bit_field_result, 7546 regfield, "regfield"); 7547 cmdline_parse_token_num_t cmd_read_reg_bit_field_port_id = 7548 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_field_result, port_id, 7549 UINT16); 7550 cmdline_parse_token_num_t cmd_read_reg_bit_field_reg_off = 7551 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_field_result, reg_off, 7552 UINT32); 7553 cmdline_parse_token_num_t cmd_read_reg_bit_field_bit1_pos = 7554 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_field_result, bit1_pos, 7555 UINT8); 7556 cmdline_parse_token_num_t cmd_read_reg_bit_field_bit2_pos = 7557 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_field_result, bit2_pos, 7558 UINT8); 7559 7560 cmdline_parse_inst_t cmd_read_reg_bit_field = { 7561 .f = cmd_read_reg_bit_field_parsed, 7562 .data = NULL, 7563 .help_str = "read regfield <port_id> <reg_off> <bit_x> <bit_y>: " 7564 "Read register bit field between bit_x and bit_y included", 7565 .tokens = { 7566 (void *)&cmd_read_reg_bit_field_read, 7567 (void *)&cmd_read_reg_bit_field_regfield, 7568 (void *)&cmd_read_reg_bit_field_port_id, 7569 (void *)&cmd_read_reg_bit_field_reg_off, 7570 (void *)&cmd_read_reg_bit_field_bit1_pos, 7571 (void *)&cmd_read_reg_bit_field_bit2_pos, 7572 NULL, 7573 }, 7574 }; 7575 7576 /* *** READ PORT REGISTER BIT *** */ 7577 struct cmd_read_reg_bit_result { 7578 cmdline_fixed_string_t read; 7579 cmdline_fixed_string_t regbit; 7580 portid_t port_id; 7581 uint32_t reg_off; 7582 uint8_t bit_pos; 7583 }; 7584 7585 static void 7586 cmd_read_reg_bit_parsed(void *parsed_result, 7587 __attribute__((unused)) struct cmdline *cl, 7588 __attribute__((unused)) void *data) 7589 { 7590 struct cmd_read_reg_bit_result *res = parsed_result; 7591 port_reg_bit_display(res->port_id, res->reg_off, res->bit_pos); 7592 } 7593 7594 cmdline_parse_token_string_t cmd_read_reg_bit_read = 7595 TOKEN_STRING_INITIALIZER(struct cmd_read_reg_bit_result, read, "read"); 7596 cmdline_parse_token_string_t cmd_read_reg_bit_regbit = 7597 TOKEN_STRING_INITIALIZER(struct cmd_read_reg_bit_result, 7598 regbit, "regbit"); 7599 cmdline_parse_token_num_t cmd_read_reg_bit_port_id = 7600 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_result, port_id, UINT16); 7601 cmdline_parse_token_num_t cmd_read_reg_bit_reg_off = 7602 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_result, reg_off, UINT32); 7603 cmdline_parse_token_num_t cmd_read_reg_bit_bit_pos = 7604 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_result, bit_pos, UINT8); 7605 7606 cmdline_parse_inst_t cmd_read_reg_bit = { 7607 .f = cmd_read_reg_bit_parsed, 7608 .data = NULL, 7609 .help_str = "read regbit <port_id> <reg_off> <bit_x>: 0 <= bit_x <= 31", 7610 .tokens = { 7611 (void *)&cmd_read_reg_bit_read, 7612 (void *)&cmd_read_reg_bit_regbit, 7613 (void *)&cmd_read_reg_bit_port_id, 7614 (void *)&cmd_read_reg_bit_reg_off, 7615 (void *)&cmd_read_reg_bit_bit_pos, 7616 NULL, 7617 }, 7618 }; 7619 7620 /* *** WRITE PORT REGISTER *** */ 7621 struct cmd_write_reg_result { 7622 cmdline_fixed_string_t write; 7623 cmdline_fixed_string_t reg; 7624 portid_t port_id; 7625 uint32_t reg_off; 7626 uint32_t value; 7627 }; 7628 7629 static void 7630 cmd_write_reg_parsed(void *parsed_result, 7631 __attribute__((unused)) struct cmdline *cl, 7632 __attribute__((unused)) void *data) 7633 { 7634 struct cmd_write_reg_result *res = parsed_result; 7635 port_reg_set(res->port_id, res->reg_off, res->value); 7636 } 7637 7638 cmdline_parse_token_string_t cmd_write_reg_write = 7639 TOKEN_STRING_INITIALIZER(struct cmd_write_reg_result, write, "write"); 7640 cmdline_parse_token_string_t cmd_write_reg_reg = 7641 TOKEN_STRING_INITIALIZER(struct cmd_write_reg_result, reg, "reg"); 7642 cmdline_parse_token_num_t cmd_write_reg_port_id = 7643 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_result, port_id, UINT16); 7644 cmdline_parse_token_num_t cmd_write_reg_reg_off = 7645 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_result, reg_off, UINT32); 7646 cmdline_parse_token_num_t cmd_write_reg_value = 7647 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_result, value, UINT32); 7648 7649 cmdline_parse_inst_t cmd_write_reg = { 7650 .f = cmd_write_reg_parsed, 7651 .data = NULL, 7652 .help_str = "write reg <port_id> <reg_off> <reg_value>", 7653 .tokens = { 7654 (void *)&cmd_write_reg_write, 7655 (void *)&cmd_write_reg_reg, 7656 (void *)&cmd_write_reg_port_id, 7657 (void *)&cmd_write_reg_reg_off, 7658 (void *)&cmd_write_reg_value, 7659 NULL, 7660 }, 7661 }; 7662 7663 /* *** WRITE PORT REGISTER BIT FIELD *** */ 7664 struct cmd_write_reg_bit_field_result { 7665 cmdline_fixed_string_t write; 7666 cmdline_fixed_string_t regfield; 7667 portid_t port_id; 7668 uint32_t reg_off; 7669 uint8_t bit1_pos; 7670 uint8_t bit2_pos; 7671 uint32_t value; 7672 }; 7673 7674 static void 7675 cmd_write_reg_bit_field_parsed(void *parsed_result, 7676 __attribute__((unused)) struct cmdline *cl, 7677 __attribute__((unused)) void *data) 7678 { 7679 struct cmd_write_reg_bit_field_result *res = parsed_result; 7680 port_reg_bit_field_set(res->port_id, res->reg_off, 7681 res->bit1_pos, res->bit2_pos, res->value); 7682 } 7683 7684 cmdline_parse_token_string_t cmd_write_reg_bit_field_write = 7685 TOKEN_STRING_INITIALIZER(struct cmd_write_reg_bit_field_result, write, 7686 "write"); 7687 cmdline_parse_token_string_t cmd_write_reg_bit_field_regfield = 7688 TOKEN_STRING_INITIALIZER(struct cmd_write_reg_bit_field_result, 7689 regfield, "regfield"); 7690 cmdline_parse_token_num_t cmd_write_reg_bit_field_port_id = 7691 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_field_result, port_id, 7692 UINT16); 7693 cmdline_parse_token_num_t cmd_write_reg_bit_field_reg_off = 7694 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_field_result, reg_off, 7695 UINT32); 7696 cmdline_parse_token_num_t cmd_write_reg_bit_field_bit1_pos = 7697 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_field_result, bit1_pos, 7698 UINT8); 7699 cmdline_parse_token_num_t cmd_write_reg_bit_field_bit2_pos = 7700 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_field_result, bit2_pos, 7701 UINT8); 7702 cmdline_parse_token_num_t cmd_write_reg_bit_field_value = 7703 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_field_result, value, 7704 UINT32); 7705 7706 cmdline_parse_inst_t cmd_write_reg_bit_field = { 7707 .f = cmd_write_reg_bit_field_parsed, 7708 .data = NULL, 7709 .help_str = "write regfield <port_id> <reg_off> <bit_x> <bit_y> " 7710 "<reg_value>: " 7711 "Set register bit field between bit_x and bit_y included", 7712 .tokens = { 7713 (void *)&cmd_write_reg_bit_field_write, 7714 (void *)&cmd_write_reg_bit_field_regfield, 7715 (void *)&cmd_write_reg_bit_field_port_id, 7716 (void *)&cmd_write_reg_bit_field_reg_off, 7717 (void *)&cmd_write_reg_bit_field_bit1_pos, 7718 (void *)&cmd_write_reg_bit_field_bit2_pos, 7719 (void *)&cmd_write_reg_bit_field_value, 7720 NULL, 7721 }, 7722 }; 7723 7724 /* *** WRITE PORT REGISTER BIT *** */ 7725 struct cmd_write_reg_bit_result { 7726 cmdline_fixed_string_t write; 7727 cmdline_fixed_string_t regbit; 7728 portid_t port_id; 7729 uint32_t reg_off; 7730 uint8_t bit_pos; 7731 uint8_t value; 7732 }; 7733 7734 static void 7735 cmd_write_reg_bit_parsed(void *parsed_result, 7736 __attribute__((unused)) struct cmdline *cl, 7737 __attribute__((unused)) void *data) 7738 { 7739 struct cmd_write_reg_bit_result *res = parsed_result; 7740 port_reg_bit_set(res->port_id, res->reg_off, res->bit_pos, res->value); 7741 } 7742 7743 cmdline_parse_token_string_t cmd_write_reg_bit_write = 7744 TOKEN_STRING_INITIALIZER(struct cmd_write_reg_bit_result, write, 7745 "write"); 7746 cmdline_parse_token_string_t cmd_write_reg_bit_regbit = 7747 TOKEN_STRING_INITIALIZER(struct cmd_write_reg_bit_result, 7748 regbit, "regbit"); 7749 cmdline_parse_token_num_t cmd_write_reg_bit_port_id = 7750 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_result, port_id, UINT16); 7751 cmdline_parse_token_num_t cmd_write_reg_bit_reg_off = 7752 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_result, reg_off, UINT32); 7753 cmdline_parse_token_num_t cmd_write_reg_bit_bit_pos = 7754 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_result, bit_pos, UINT8); 7755 cmdline_parse_token_num_t cmd_write_reg_bit_value = 7756 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_result, value, UINT8); 7757 7758 cmdline_parse_inst_t cmd_write_reg_bit = { 7759 .f = cmd_write_reg_bit_parsed, 7760 .data = NULL, 7761 .help_str = "write regbit <port_id> <reg_off> <bit_x> 0|1: " 7762 "0 <= bit_x <= 31", 7763 .tokens = { 7764 (void *)&cmd_write_reg_bit_write, 7765 (void *)&cmd_write_reg_bit_regbit, 7766 (void *)&cmd_write_reg_bit_port_id, 7767 (void *)&cmd_write_reg_bit_reg_off, 7768 (void *)&cmd_write_reg_bit_bit_pos, 7769 (void *)&cmd_write_reg_bit_value, 7770 NULL, 7771 }, 7772 }; 7773 7774 /* *** READ A RING DESCRIPTOR OF A PORT RX/TX QUEUE *** */ 7775 struct cmd_read_rxd_txd_result { 7776 cmdline_fixed_string_t read; 7777 cmdline_fixed_string_t rxd_txd; 7778 portid_t port_id; 7779 uint16_t queue_id; 7780 uint16_t desc_id; 7781 }; 7782 7783 static void 7784 cmd_read_rxd_txd_parsed(void *parsed_result, 7785 __attribute__((unused)) struct cmdline *cl, 7786 __attribute__((unused)) void *data) 7787 { 7788 struct cmd_read_rxd_txd_result *res = parsed_result; 7789 7790 if (!strcmp(res->rxd_txd, "rxd")) 7791 rx_ring_desc_display(res->port_id, res->queue_id, res->desc_id); 7792 else if (!strcmp(res->rxd_txd, "txd")) 7793 tx_ring_desc_display(res->port_id, res->queue_id, res->desc_id); 7794 } 7795 7796 cmdline_parse_token_string_t cmd_read_rxd_txd_read = 7797 TOKEN_STRING_INITIALIZER(struct cmd_read_rxd_txd_result, read, "read"); 7798 cmdline_parse_token_string_t cmd_read_rxd_txd_rxd_txd = 7799 TOKEN_STRING_INITIALIZER(struct cmd_read_rxd_txd_result, rxd_txd, 7800 "rxd#txd"); 7801 cmdline_parse_token_num_t cmd_read_rxd_txd_port_id = 7802 TOKEN_NUM_INITIALIZER(struct cmd_read_rxd_txd_result, port_id, UINT16); 7803 cmdline_parse_token_num_t cmd_read_rxd_txd_queue_id = 7804 TOKEN_NUM_INITIALIZER(struct cmd_read_rxd_txd_result, queue_id, UINT16); 7805 cmdline_parse_token_num_t cmd_read_rxd_txd_desc_id = 7806 TOKEN_NUM_INITIALIZER(struct cmd_read_rxd_txd_result, desc_id, UINT16); 7807 7808 cmdline_parse_inst_t cmd_read_rxd_txd = { 7809 .f = cmd_read_rxd_txd_parsed, 7810 .data = NULL, 7811 .help_str = "read rxd|txd <port_id> <queue_id> <desc_id>", 7812 .tokens = { 7813 (void *)&cmd_read_rxd_txd_read, 7814 (void *)&cmd_read_rxd_txd_rxd_txd, 7815 (void *)&cmd_read_rxd_txd_port_id, 7816 (void *)&cmd_read_rxd_txd_queue_id, 7817 (void *)&cmd_read_rxd_txd_desc_id, 7818 NULL, 7819 }, 7820 }; 7821 7822 /* *** QUIT *** */ 7823 struct cmd_quit_result { 7824 cmdline_fixed_string_t quit; 7825 }; 7826 7827 static void cmd_quit_parsed(__attribute__((unused)) void *parsed_result, 7828 struct cmdline *cl, 7829 __attribute__((unused)) void *data) 7830 { 7831 cmdline_quit(cl); 7832 } 7833 7834 cmdline_parse_token_string_t cmd_quit_quit = 7835 TOKEN_STRING_INITIALIZER(struct cmd_quit_result, quit, "quit"); 7836 7837 cmdline_parse_inst_t cmd_quit = { 7838 .f = cmd_quit_parsed, 7839 .data = NULL, 7840 .help_str = "quit: Exit application", 7841 .tokens = { 7842 (void *)&cmd_quit_quit, 7843 NULL, 7844 }, 7845 }; 7846 7847 /* *** ADD/REMOVE MAC ADDRESS FROM A PORT *** */ 7848 struct cmd_mac_addr_result { 7849 cmdline_fixed_string_t mac_addr_cmd; 7850 cmdline_fixed_string_t what; 7851 uint16_t port_num; 7852 struct ether_addr address; 7853 }; 7854 7855 static void cmd_mac_addr_parsed(void *parsed_result, 7856 __attribute__((unused)) struct cmdline *cl, 7857 __attribute__((unused)) void *data) 7858 { 7859 struct cmd_mac_addr_result *res = parsed_result; 7860 int ret; 7861 7862 if (strcmp(res->what, "add") == 0) 7863 ret = rte_eth_dev_mac_addr_add(res->port_num, &res->address, 0); 7864 else if (strcmp(res->what, "set") == 0) 7865 ret = rte_eth_dev_default_mac_addr_set(res->port_num, 7866 &res->address); 7867 else 7868 ret = rte_eth_dev_mac_addr_remove(res->port_num, &res->address); 7869 7870 /* check the return value and print it if is < 0 */ 7871 if(ret < 0) 7872 printf("mac_addr_cmd error: (%s)\n", strerror(-ret)); 7873 7874 } 7875 7876 cmdline_parse_token_string_t cmd_mac_addr_cmd = 7877 TOKEN_STRING_INITIALIZER(struct cmd_mac_addr_result, mac_addr_cmd, 7878 "mac_addr"); 7879 cmdline_parse_token_string_t cmd_mac_addr_what = 7880 TOKEN_STRING_INITIALIZER(struct cmd_mac_addr_result, what, 7881 "add#remove#set"); 7882 cmdline_parse_token_num_t cmd_mac_addr_portnum = 7883 TOKEN_NUM_INITIALIZER(struct cmd_mac_addr_result, port_num, 7884 UINT16); 7885 cmdline_parse_token_etheraddr_t cmd_mac_addr_addr = 7886 TOKEN_ETHERADDR_INITIALIZER(struct cmd_mac_addr_result, address); 7887 7888 cmdline_parse_inst_t cmd_mac_addr = { 7889 .f = cmd_mac_addr_parsed, 7890 .data = (void *)0, 7891 .help_str = "mac_addr add|remove|set <port_id> <mac_addr>: " 7892 "Add/Remove/Set MAC address on port_id", 7893 .tokens = { 7894 (void *)&cmd_mac_addr_cmd, 7895 (void *)&cmd_mac_addr_what, 7896 (void *)&cmd_mac_addr_portnum, 7897 (void *)&cmd_mac_addr_addr, 7898 NULL, 7899 }, 7900 }; 7901 7902 /* *** SET THE PEER ADDRESS FOR CERTAIN PORT *** */ 7903 struct cmd_eth_peer_result { 7904 cmdline_fixed_string_t set; 7905 cmdline_fixed_string_t eth_peer; 7906 portid_t port_id; 7907 cmdline_fixed_string_t peer_addr; 7908 }; 7909 7910 static void cmd_set_eth_peer_parsed(void *parsed_result, 7911 __attribute__((unused)) struct cmdline *cl, 7912 __attribute__((unused)) void *data) 7913 { 7914 struct cmd_eth_peer_result *res = parsed_result; 7915 7916 if (test_done == 0) { 7917 printf("Please stop forwarding first\n"); 7918 return; 7919 } 7920 if (!strcmp(res->eth_peer, "eth-peer")) { 7921 set_fwd_eth_peer(res->port_id, res->peer_addr); 7922 fwd_config_setup(); 7923 } 7924 } 7925 cmdline_parse_token_string_t cmd_eth_peer_set = 7926 TOKEN_STRING_INITIALIZER(struct cmd_eth_peer_result, set, "set"); 7927 cmdline_parse_token_string_t cmd_eth_peer = 7928 TOKEN_STRING_INITIALIZER(struct cmd_eth_peer_result, eth_peer, "eth-peer"); 7929 cmdline_parse_token_num_t cmd_eth_peer_port_id = 7930 TOKEN_NUM_INITIALIZER(struct cmd_eth_peer_result, port_id, UINT16); 7931 cmdline_parse_token_string_t cmd_eth_peer_addr = 7932 TOKEN_STRING_INITIALIZER(struct cmd_eth_peer_result, peer_addr, NULL); 7933 7934 cmdline_parse_inst_t cmd_set_fwd_eth_peer = { 7935 .f = cmd_set_eth_peer_parsed, 7936 .data = NULL, 7937 .help_str = "set eth-peer <port_id> <peer_mac>", 7938 .tokens = { 7939 (void *)&cmd_eth_peer_set, 7940 (void *)&cmd_eth_peer, 7941 (void *)&cmd_eth_peer_port_id, 7942 (void *)&cmd_eth_peer_addr, 7943 NULL, 7944 }, 7945 }; 7946 7947 /* *** CONFIGURE QUEUE STATS COUNTER MAPPINGS *** */ 7948 struct cmd_set_qmap_result { 7949 cmdline_fixed_string_t set; 7950 cmdline_fixed_string_t qmap; 7951 cmdline_fixed_string_t what; 7952 portid_t port_id; 7953 uint16_t queue_id; 7954 uint8_t map_value; 7955 }; 7956 7957 static void 7958 cmd_set_qmap_parsed(void *parsed_result, 7959 __attribute__((unused)) struct cmdline *cl, 7960 __attribute__((unused)) void *data) 7961 { 7962 struct cmd_set_qmap_result *res = parsed_result; 7963 int is_rx = (strcmp(res->what, "tx") == 0) ? 0 : 1; 7964 7965 set_qmap(res->port_id, (uint8_t)is_rx, res->queue_id, res->map_value); 7966 } 7967 7968 cmdline_parse_token_string_t cmd_setqmap_set = 7969 TOKEN_STRING_INITIALIZER(struct cmd_set_qmap_result, 7970 set, "set"); 7971 cmdline_parse_token_string_t cmd_setqmap_qmap = 7972 TOKEN_STRING_INITIALIZER(struct cmd_set_qmap_result, 7973 qmap, "stat_qmap"); 7974 cmdline_parse_token_string_t cmd_setqmap_what = 7975 TOKEN_STRING_INITIALIZER(struct cmd_set_qmap_result, 7976 what, "tx#rx"); 7977 cmdline_parse_token_num_t cmd_setqmap_portid = 7978 TOKEN_NUM_INITIALIZER(struct cmd_set_qmap_result, 7979 port_id, UINT16); 7980 cmdline_parse_token_num_t cmd_setqmap_queueid = 7981 TOKEN_NUM_INITIALIZER(struct cmd_set_qmap_result, 7982 queue_id, UINT16); 7983 cmdline_parse_token_num_t cmd_setqmap_mapvalue = 7984 TOKEN_NUM_INITIALIZER(struct cmd_set_qmap_result, 7985 map_value, UINT8); 7986 7987 cmdline_parse_inst_t cmd_set_qmap = { 7988 .f = cmd_set_qmap_parsed, 7989 .data = NULL, 7990 .help_str = "set stat_qmap rx|tx <port_id> <queue_id> <map_value>: " 7991 "Set statistics mapping value on tx|rx queue_id of port_id", 7992 .tokens = { 7993 (void *)&cmd_setqmap_set, 7994 (void *)&cmd_setqmap_qmap, 7995 (void *)&cmd_setqmap_what, 7996 (void *)&cmd_setqmap_portid, 7997 (void *)&cmd_setqmap_queueid, 7998 (void *)&cmd_setqmap_mapvalue, 7999 NULL, 8000 }, 8001 }; 8002 8003 /* *** SET OPTION TO HIDE ZERO VALUES FOR XSTATS DISPLAY *** */ 8004 struct cmd_set_xstats_hide_zero_result { 8005 cmdline_fixed_string_t keyword; 8006 cmdline_fixed_string_t name; 8007 cmdline_fixed_string_t on_off; 8008 }; 8009 8010 static void 8011 cmd_set_xstats_hide_zero_parsed(void *parsed_result, 8012 __attribute__((unused)) struct cmdline *cl, 8013 __attribute__((unused)) void *data) 8014 { 8015 struct cmd_set_xstats_hide_zero_result *res; 8016 uint16_t on_off = 0; 8017 8018 res = parsed_result; 8019 on_off = !strcmp(res->on_off, "on") ? 1 : 0; 8020 set_xstats_hide_zero(on_off); 8021 } 8022 8023 cmdline_parse_token_string_t cmd_set_xstats_hide_zero_keyword = 8024 TOKEN_STRING_INITIALIZER(struct cmd_set_xstats_hide_zero_result, 8025 keyword, "set"); 8026 cmdline_parse_token_string_t cmd_set_xstats_hide_zero_name = 8027 TOKEN_STRING_INITIALIZER(struct cmd_set_xstats_hide_zero_result, 8028 name, "xstats-hide-zero"); 8029 cmdline_parse_token_string_t cmd_set_xstats_hide_zero_on_off = 8030 TOKEN_STRING_INITIALIZER(struct cmd_set_xstats_hide_zero_result, 8031 on_off, "on#off"); 8032 8033 cmdline_parse_inst_t cmd_set_xstats_hide_zero = { 8034 .f = cmd_set_xstats_hide_zero_parsed, 8035 .data = NULL, 8036 .help_str = "set xstats-hide-zero on|off", 8037 .tokens = { 8038 (void *)&cmd_set_xstats_hide_zero_keyword, 8039 (void *)&cmd_set_xstats_hide_zero_name, 8040 (void *)&cmd_set_xstats_hide_zero_on_off, 8041 NULL, 8042 }, 8043 }; 8044 8045 /* *** CONFIGURE UNICAST HASH TABLE *** */ 8046 struct cmd_set_uc_hash_table { 8047 cmdline_fixed_string_t set; 8048 cmdline_fixed_string_t port; 8049 portid_t port_id; 8050 cmdline_fixed_string_t what; 8051 struct ether_addr address; 8052 cmdline_fixed_string_t mode; 8053 }; 8054 8055 static void 8056 cmd_set_uc_hash_parsed(void *parsed_result, 8057 __attribute__((unused)) struct cmdline *cl, 8058 __attribute__((unused)) void *data) 8059 { 8060 int ret=0; 8061 struct cmd_set_uc_hash_table *res = parsed_result; 8062 8063 int is_on = (strcmp(res->mode, "on") == 0) ? 1 : 0; 8064 8065 if (strcmp(res->what, "uta") == 0) 8066 ret = rte_eth_dev_uc_hash_table_set(res->port_id, 8067 &res->address,(uint8_t)is_on); 8068 if (ret < 0) 8069 printf("bad unicast hash table parameter, return code = %d \n", ret); 8070 8071 } 8072 8073 cmdline_parse_token_string_t cmd_set_uc_hash_set = 8074 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_hash_table, 8075 set, "set"); 8076 cmdline_parse_token_string_t cmd_set_uc_hash_port = 8077 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_hash_table, 8078 port, "port"); 8079 cmdline_parse_token_num_t cmd_set_uc_hash_portid = 8080 TOKEN_NUM_INITIALIZER(struct cmd_set_uc_hash_table, 8081 port_id, UINT16); 8082 cmdline_parse_token_string_t cmd_set_uc_hash_what = 8083 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_hash_table, 8084 what, "uta"); 8085 cmdline_parse_token_etheraddr_t cmd_set_uc_hash_mac = 8086 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_uc_hash_table, 8087 address); 8088 cmdline_parse_token_string_t cmd_set_uc_hash_mode = 8089 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_hash_table, 8090 mode, "on#off"); 8091 8092 cmdline_parse_inst_t cmd_set_uc_hash_filter = { 8093 .f = cmd_set_uc_hash_parsed, 8094 .data = NULL, 8095 .help_str = "set port <port_id> uta <mac_addr> on|off)", 8096 .tokens = { 8097 (void *)&cmd_set_uc_hash_set, 8098 (void *)&cmd_set_uc_hash_port, 8099 (void *)&cmd_set_uc_hash_portid, 8100 (void *)&cmd_set_uc_hash_what, 8101 (void *)&cmd_set_uc_hash_mac, 8102 (void *)&cmd_set_uc_hash_mode, 8103 NULL, 8104 }, 8105 }; 8106 8107 struct cmd_set_uc_all_hash_table { 8108 cmdline_fixed_string_t set; 8109 cmdline_fixed_string_t port; 8110 portid_t port_id; 8111 cmdline_fixed_string_t what; 8112 cmdline_fixed_string_t value; 8113 cmdline_fixed_string_t mode; 8114 }; 8115 8116 static void 8117 cmd_set_uc_all_hash_parsed(void *parsed_result, 8118 __attribute__((unused)) struct cmdline *cl, 8119 __attribute__((unused)) void *data) 8120 { 8121 int ret=0; 8122 struct cmd_set_uc_all_hash_table *res = parsed_result; 8123 8124 int is_on = (strcmp(res->mode, "on") == 0) ? 1 : 0; 8125 8126 if ((strcmp(res->what, "uta") == 0) && 8127 (strcmp(res->value, "all") == 0)) 8128 ret = rte_eth_dev_uc_all_hash_table_set(res->port_id,(uint8_t) is_on); 8129 if (ret < 0) 8130 printf("bad unicast hash table parameter," 8131 "return code = %d \n", ret); 8132 } 8133 8134 cmdline_parse_token_string_t cmd_set_uc_all_hash_set = 8135 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_all_hash_table, 8136 set, "set"); 8137 cmdline_parse_token_string_t cmd_set_uc_all_hash_port = 8138 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_all_hash_table, 8139 port, "port"); 8140 cmdline_parse_token_num_t cmd_set_uc_all_hash_portid = 8141 TOKEN_NUM_INITIALIZER(struct cmd_set_uc_all_hash_table, 8142 port_id, UINT16); 8143 cmdline_parse_token_string_t cmd_set_uc_all_hash_what = 8144 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_all_hash_table, 8145 what, "uta"); 8146 cmdline_parse_token_string_t cmd_set_uc_all_hash_value = 8147 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_all_hash_table, 8148 value,"all"); 8149 cmdline_parse_token_string_t cmd_set_uc_all_hash_mode = 8150 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_all_hash_table, 8151 mode, "on#off"); 8152 8153 cmdline_parse_inst_t cmd_set_uc_all_hash_filter = { 8154 .f = cmd_set_uc_all_hash_parsed, 8155 .data = NULL, 8156 .help_str = "set port <port_id> uta all on|off", 8157 .tokens = { 8158 (void *)&cmd_set_uc_all_hash_set, 8159 (void *)&cmd_set_uc_all_hash_port, 8160 (void *)&cmd_set_uc_all_hash_portid, 8161 (void *)&cmd_set_uc_all_hash_what, 8162 (void *)&cmd_set_uc_all_hash_value, 8163 (void *)&cmd_set_uc_all_hash_mode, 8164 NULL, 8165 }, 8166 }; 8167 8168 /* *** CONFIGURE MACVLAN FILTER FOR VF(s) *** */ 8169 struct cmd_set_vf_macvlan_filter { 8170 cmdline_fixed_string_t set; 8171 cmdline_fixed_string_t port; 8172 portid_t port_id; 8173 cmdline_fixed_string_t vf; 8174 uint8_t vf_id; 8175 struct ether_addr address; 8176 cmdline_fixed_string_t filter_type; 8177 cmdline_fixed_string_t mode; 8178 }; 8179 8180 static void 8181 cmd_set_vf_macvlan_parsed(void *parsed_result, 8182 __attribute__((unused)) struct cmdline *cl, 8183 __attribute__((unused)) void *data) 8184 { 8185 int is_on, ret = 0; 8186 struct cmd_set_vf_macvlan_filter *res = parsed_result; 8187 struct rte_eth_mac_filter filter; 8188 8189 memset(&filter, 0, sizeof(struct rte_eth_mac_filter)); 8190 8191 rte_memcpy(&filter.mac_addr, &res->address, ETHER_ADDR_LEN); 8192 8193 /* set VF MAC filter */ 8194 filter.is_vf = 1; 8195 8196 /* set VF ID */ 8197 filter.dst_id = res->vf_id; 8198 8199 if (!strcmp(res->filter_type, "exact-mac")) 8200 filter.filter_type = RTE_MAC_PERFECT_MATCH; 8201 else if (!strcmp(res->filter_type, "exact-mac-vlan")) 8202 filter.filter_type = RTE_MACVLAN_PERFECT_MATCH; 8203 else if (!strcmp(res->filter_type, "hashmac")) 8204 filter.filter_type = RTE_MAC_HASH_MATCH; 8205 else if (!strcmp(res->filter_type, "hashmac-vlan")) 8206 filter.filter_type = RTE_MACVLAN_HASH_MATCH; 8207 8208 is_on = (strcmp(res->mode, "on") == 0) ? 1 : 0; 8209 8210 if (is_on) 8211 ret = rte_eth_dev_filter_ctrl(res->port_id, 8212 RTE_ETH_FILTER_MACVLAN, 8213 RTE_ETH_FILTER_ADD, 8214 &filter); 8215 else 8216 ret = rte_eth_dev_filter_ctrl(res->port_id, 8217 RTE_ETH_FILTER_MACVLAN, 8218 RTE_ETH_FILTER_DELETE, 8219 &filter); 8220 8221 if (ret < 0) 8222 printf("bad set MAC hash parameter, return code = %d\n", ret); 8223 8224 } 8225 8226 cmdline_parse_token_string_t cmd_set_vf_macvlan_set = 8227 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_macvlan_filter, 8228 set, "set"); 8229 cmdline_parse_token_string_t cmd_set_vf_macvlan_port = 8230 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_macvlan_filter, 8231 port, "port"); 8232 cmdline_parse_token_num_t cmd_set_vf_macvlan_portid = 8233 TOKEN_NUM_INITIALIZER(struct cmd_set_vf_macvlan_filter, 8234 port_id, UINT16); 8235 cmdline_parse_token_string_t cmd_set_vf_macvlan_vf = 8236 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_macvlan_filter, 8237 vf, "vf"); 8238 cmdline_parse_token_num_t cmd_set_vf_macvlan_vf_id = 8239 TOKEN_NUM_INITIALIZER(struct cmd_set_vf_macvlan_filter, 8240 vf_id, UINT8); 8241 cmdline_parse_token_etheraddr_t cmd_set_vf_macvlan_mac = 8242 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_vf_macvlan_filter, 8243 address); 8244 cmdline_parse_token_string_t cmd_set_vf_macvlan_filter_type = 8245 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_macvlan_filter, 8246 filter_type, "exact-mac#exact-mac-vlan" 8247 "#hashmac#hashmac-vlan"); 8248 cmdline_parse_token_string_t cmd_set_vf_macvlan_mode = 8249 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_macvlan_filter, 8250 mode, "on#off"); 8251 8252 cmdline_parse_inst_t cmd_set_vf_macvlan_filter = { 8253 .f = cmd_set_vf_macvlan_parsed, 8254 .data = NULL, 8255 .help_str = "set port <port_id> vf <vf_id> <mac_addr> " 8256 "exact-mac|exact-mac-vlan|hashmac|hashmac-vlan on|off: " 8257 "Exact match rule: exact match of MAC or MAC and VLAN; " 8258 "hash match rule: hash match of MAC and exact match of VLAN", 8259 .tokens = { 8260 (void *)&cmd_set_vf_macvlan_set, 8261 (void *)&cmd_set_vf_macvlan_port, 8262 (void *)&cmd_set_vf_macvlan_portid, 8263 (void *)&cmd_set_vf_macvlan_vf, 8264 (void *)&cmd_set_vf_macvlan_vf_id, 8265 (void *)&cmd_set_vf_macvlan_mac, 8266 (void *)&cmd_set_vf_macvlan_filter_type, 8267 (void *)&cmd_set_vf_macvlan_mode, 8268 NULL, 8269 }, 8270 }; 8271 8272 /* *** CONFIGURE VF TRAFFIC CONTROL *** */ 8273 struct cmd_set_vf_traffic { 8274 cmdline_fixed_string_t set; 8275 cmdline_fixed_string_t port; 8276 portid_t port_id; 8277 cmdline_fixed_string_t vf; 8278 uint8_t vf_id; 8279 cmdline_fixed_string_t what; 8280 cmdline_fixed_string_t mode; 8281 }; 8282 8283 static void 8284 cmd_set_vf_traffic_parsed(void *parsed_result, 8285 __attribute__((unused)) struct cmdline *cl, 8286 __attribute__((unused)) void *data) 8287 { 8288 struct cmd_set_vf_traffic *res = parsed_result; 8289 int is_rx = (strcmp(res->what, "rx") == 0) ? 1 : 0; 8290 int is_on = (strcmp(res->mode, "on") == 0) ? 1 : 0; 8291 8292 set_vf_traffic(res->port_id, (uint8_t)is_rx, res->vf_id,(uint8_t) is_on); 8293 } 8294 8295 cmdline_parse_token_string_t cmd_setvf_traffic_set = 8296 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_traffic, 8297 set, "set"); 8298 cmdline_parse_token_string_t cmd_setvf_traffic_port = 8299 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_traffic, 8300 port, "port"); 8301 cmdline_parse_token_num_t cmd_setvf_traffic_portid = 8302 TOKEN_NUM_INITIALIZER(struct cmd_set_vf_traffic, 8303 port_id, UINT16); 8304 cmdline_parse_token_string_t cmd_setvf_traffic_vf = 8305 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_traffic, 8306 vf, "vf"); 8307 cmdline_parse_token_num_t cmd_setvf_traffic_vfid = 8308 TOKEN_NUM_INITIALIZER(struct cmd_set_vf_traffic, 8309 vf_id, UINT8); 8310 cmdline_parse_token_string_t cmd_setvf_traffic_what = 8311 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_traffic, 8312 what, "tx#rx"); 8313 cmdline_parse_token_string_t cmd_setvf_traffic_mode = 8314 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_traffic, 8315 mode, "on#off"); 8316 8317 cmdline_parse_inst_t cmd_set_vf_traffic = { 8318 .f = cmd_set_vf_traffic_parsed, 8319 .data = NULL, 8320 .help_str = "set port <port_id> vf <vf_id> rx|tx on|off", 8321 .tokens = { 8322 (void *)&cmd_setvf_traffic_set, 8323 (void *)&cmd_setvf_traffic_port, 8324 (void *)&cmd_setvf_traffic_portid, 8325 (void *)&cmd_setvf_traffic_vf, 8326 (void *)&cmd_setvf_traffic_vfid, 8327 (void *)&cmd_setvf_traffic_what, 8328 (void *)&cmd_setvf_traffic_mode, 8329 NULL, 8330 }, 8331 }; 8332 8333 /* *** CONFIGURE VF RECEIVE MODE *** */ 8334 struct cmd_set_vf_rxmode { 8335 cmdline_fixed_string_t set; 8336 cmdline_fixed_string_t port; 8337 portid_t port_id; 8338 cmdline_fixed_string_t vf; 8339 uint8_t vf_id; 8340 cmdline_fixed_string_t what; 8341 cmdline_fixed_string_t mode; 8342 cmdline_fixed_string_t on; 8343 }; 8344 8345 static void 8346 cmd_set_vf_rxmode_parsed(void *parsed_result, 8347 __attribute__((unused)) struct cmdline *cl, 8348 __attribute__((unused)) void *data) 8349 { 8350 int ret = -ENOTSUP; 8351 uint16_t rx_mode = 0; 8352 struct cmd_set_vf_rxmode *res = parsed_result; 8353 8354 int is_on = (strcmp(res->on, "on") == 0) ? 1 : 0; 8355 if (!strcmp(res->what,"rxmode")) { 8356 if (!strcmp(res->mode, "AUPE")) 8357 rx_mode |= ETH_VMDQ_ACCEPT_UNTAG; 8358 else if (!strcmp(res->mode, "ROPE")) 8359 rx_mode |= ETH_VMDQ_ACCEPT_HASH_UC; 8360 else if (!strcmp(res->mode, "BAM")) 8361 rx_mode |= ETH_VMDQ_ACCEPT_BROADCAST; 8362 else if (!strncmp(res->mode, "MPE",3)) 8363 rx_mode |= ETH_VMDQ_ACCEPT_MULTICAST; 8364 } 8365 8366 RTE_SET_USED(is_on); 8367 8368 #ifdef RTE_LIBRTE_IXGBE_PMD 8369 if (ret == -ENOTSUP) 8370 ret = rte_pmd_ixgbe_set_vf_rxmode(res->port_id, res->vf_id, 8371 rx_mode, (uint8_t)is_on); 8372 #endif 8373 #ifdef RTE_LIBRTE_BNXT_PMD 8374 if (ret == -ENOTSUP) 8375 ret = rte_pmd_bnxt_set_vf_rxmode(res->port_id, res->vf_id, 8376 rx_mode, (uint8_t)is_on); 8377 #endif 8378 if (ret < 0) 8379 printf("bad VF receive mode parameter, return code = %d \n", 8380 ret); 8381 } 8382 8383 cmdline_parse_token_string_t cmd_set_vf_rxmode_set = 8384 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_rxmode, 8385 set, "set"); 8386 cmdline_parse_token_string_t cmd_set_vf_rxmode_port = 8387 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_rxmode, 8388 port, "port"); 8389 cmdline_parse_token_num_t cmd_set_vf_rxmode_portid = 8390 TOKEN_NUM_INITIALIZER(struct cmd_set_vf_rxmode, 8391 port_id, UINT16); 8392 cmdline_parse_token_string_t cmd_set_vf_rxmode_vf = 8393 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_rxmode, 8394 vf, "vf"); 8395 cmdline_parse_token_num_t cmd_set_vf_rxmode_vfid = 8396 TOKEN_NUM_INITIALIZER(struct cmd_set_vf_rxmode, 8397 vf_id, UINT8); 8398 cmdline_parse_token_string_t cmd_set_vf_rxmode_what = 8399 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_rxmode, 8400 what, "rxmode"); 8401 cmdline_parse_token_string_t cmd_set_vf_rxmode_mode = 8402 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_rxmode, 8403 mode, "AUPE#ROPE#BAM#MPE"); 8404 cmdline_parse_token_string_t cmd_set_vf_rxmode_on = 8405 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_rxmode, 8406 on, "on#off"); 8407 8408 cmdline_parse_inst_t cmd_set_vf_rxmode = { 8409 .f = cmd_set_vf_rxmode_parsed, 8410 .data = NULL, 8411 .help_str = "set port <port_id> vf <vf_id> rxmode " 8412 "AUPE|ROPE|BAM|MPE on|off", 8413 .tokens = { 8414 (void *)&cmd_set_vf_rxmode_set, 8415 (void *)&cmd_set_vf_rxmode_port, 8416 (void *)&cmd_set_vf_rxmode_portid, 8417 (void *)&cmd_set_vf_rxmode_vf, 8418 (void *)&cmd_set_vf_rxmode_vfid, 8419 (void *)&cmd_set_vf_rxmode_what, 8420 (void *)&cmd_set_vf_rxmode_mode, 8421 (void *)&cmd_set_vf_rxmode_on, 8422 NULL, 8423 }, 8424 }; 8425 8426 /* *** ADD MAC ADDRESS FILTER FOR A VF OF A PORT *** */ 8427 struct cmd_vf_mac_addr_result { 8428 cmdline_fixed_string_t mac_addr_cmd; 8429 cmdline_fixed_string_t what; 8430 cmdline_fixed_string_t port; 8431 uint16_t port_num; 8432 cmdline_fixed_string_t vf; 8433 uint8_t vf_num; 8434 struct ether_addr address; 8435 }; 8436 8437 static void cmd_vf_mac_addr_parsed(void *parsed_result, 8438 __attribute__((unused)) struct cmdline *cl, 8439 __attribute__((unused)) void *data) 8440 { 8441 struct cmd_vf_mac_addr_result *res = parsed_result; 8442 int ret = -ENOTSUP; 8443 8444 if (strcmp(res->what, "add") != 0) 8445 return; 8446 8447 #ifdef RTE_LIBRTE_I40E_PMD 8448 if (ret == -ENOTSUP) 8449 ret = rte_pmd_i40e_add_vf_mac_addr(res->port_num, res->vf_num, 8450 &res->address); 8451 #endif 8452 #ifdef RTE_LIBRTE_BNXT_PMD 8453 if (ret == -ENOTSUP) 8454 ret = rte_pmd_bnxt_mac_addr_add(res->port_num, &res->address, 8455 res->vf_num); 8456 #endif 8457 8458 if(ret < 0) 8459 printf("vf_mac_addr_cmd error: (%s)\n", strerror(-ret)); 8460 8461 } 8462 8463 cmdline_parse_token_string_t cmd_vf_mac_addr_cmd = 8464 TOKEN_STRING_INITIALIZER(struct cmd_vf_mac_addr_result, 8465 mac_addr_cmd,"mac_addr"); 8466 cmdline_parse_token_string_t cmd_vf_mac_addr_what = 8467 TOKEN_STRING_INITIALIZER(struct cmd_vf_mac_addr_result, 8468 what,"add"); 8469 cmdline_parse_token_string_t cmd_vf_mac_addr_port = 8470 TOKEN_STRING_INITIALIZER(struct cmd_vf_mac_addr_result, 8471 port,"port"); 8472 cmdline_parse_token_num_t cmd_vf_mac_addr_portnum = 8473 TOKEN_NUM_INITIALIZER(struct cmd_vf_mac_addr_result, 8474 port_num, UINT16); 8475 cmdline_parse_token_string_t cmd_vf_mac_addr_vf = 8476 TOKEN_STRING_INITIALIZER(struct cmd_vf_mac_addr_result, 8477 vf,"vf"); 8478 cmdline_parse_token_num_t cmd_vf_mac_addr_vfnum = 8479 TOKEN_NUM_INITIALIZER(struct cmd_vf_mac_addr_result, 8480 vf_num, UINT8); 8481 cmdline_parse_token_etheraddr_t cmd_vf_mac_addr_addr = 8482 TOKEN_ETHERADDR_INITIALIZER(struct cmd_vf_mac_addr_result, 8483 address); 8484 8485 cmdline_parse_inst_t cmd_vf_mac_addr_filter = { 8486 .f = cmd_vf_mac_addr_parsed, 8487 .data = (void *)0, 8488 .help_str = "mac_addr add port <port_id> vf <vf_id> <mac_addr>: " 8489 "Add MAC address filtering for a VF on port_id", 8490 .tokens = { 8491 (void *)&cmd_vf_mac_addr_cmd, 8492 (void *)&cmd_vf_mac_addr_what, 8493 (void *)&cmd_vf_mac_addr_port, 8494 (void *)&cmd_vf_mac_addr_portnum, 8495 (void *)&cmd_vf_mac_addr_vf, 8496 (void *)&cmd_vf_mac_addr_vfnum, 8497 (void *)&cmd_vf_mac_addr_addr, 8498 NULL, 8499 }, 8500 }; 8501 8502 /* *** ADD/REMOVE A VLAN IDENTIFIER TO/FROM A PORT VLAN RX FILTER *** */ 8503 struct cmd_vf_rx_vlan_filter { 8504 cmdline_fixed_string_t rx_vlan; 8505 cmdline_fixed_string_t what; 8506 uint16_t vlan_id; 8507 cmdline_fixed_string_t port; 8508 portid_t port_id; 8509 cmdline_fixed_string_t vf; 8510 uint64_t vf_mask; 8511 }; 8512 8513 static void 8514 cmd_vf_rx_vlan_filter_parsed(void *parsed_result, 8515 __attribute__((unused)) struct cmdline *cl, 8516 __attribute__((unused)) void *data) 8517 { 8518 struct cmd_vf_rx_vlan_filter *res = parsed_result; 8519 int ret = -ENOTSUP; 8520 8521 __rte_unused int is_add = (strcmp(res->what, "add") == 0) ? 1 : 0; 8522 8523 #ifdef RTE_LIBRTE_IXGBE_PMD 8524 if (ret == -ENOTSUP) 8525 ret = rte_pmd_ixgbe_set_vf_vlan_filter(res->port_id, 8526 res->vlan_id, res->vf_mask, is_add); 8527 #endif 8528 #ifdef RTE_LIBRTE_I40E_PMD 8529 if (ret == -ENOTSUP) 8530 ret = rte_pmd_i40e_set_vf_vlan_filter(res->port_id, 8531 res->vlan_id, res->vf_mask, is_add); 8532 #endif 8533 #ifdef RTE_LIBRTE_BNXT_PMD 8534 if (ret == -ENOTSUP) 8535 ret = rte_pmd_bnxt_set_vf_vlan_filter(res->port_id, 8536 res->vlan_id, res->vf_mask, is_add); 8537 #endif 8538 8539 switch (ret) { 8540 case 0: 8541 break; 8542 case -EINVAL: 8543 printf("invalid vlan_id %d or vf_mask %"PRIu64"\n", 8544 res->vlan_id, res->vf_mask); 8545 break; 8546 case -ENODEV: 8547 printf("invalid port_id %d\n", res->port_id); 8548 break; 8549 case -ENOTSUP: 8550 printf("function not implemented or supported\n"); 8551 break; 8552 default: 8553 printf("programming error: (%s)\n", strerror(-ret)); 8554 } 8555 } 8556 8557 cmdline_parse_token_string_t cmd_vf_rx_vlan_filter_rx_vlan = 8558 TOKEN_STRING_INITIALIZER(struct cmd_vf_rx_vlan_filter, 8559 rx_vlan, "rx_vlan"); 8560 cmdline_parse_token_string_t cmd_vf_rx_vlan_filter_what = 8561 TOKEN_STRING_INITIALIZER(struct cmd_vf_rx_vlan_filter, 8562 what, "add#rm"); 8563 cmdline_parse_token_num_t cmd_vf_rx_vlan_filter_vlanid = 8564 TOKEN_NUM_INITIALIZER(struct cmd_vf_rx_vlan_filter, 8565 vlan_id, UINT16); 8566 cmdline_parse_token_string_t cmd_vf_rx_vlan_filter_port = 8567 TOKEN_STRING_INITIALIZER(struct cmd_vf_rx_vlan_filter, 8568 port, "port"); 8569 cmdline_parse_token_num_t cmd_vf_rx_vlan_filter_portid = 8570 TOKEN_NUM_INITIALIZER(struct cmd_vf_rx_vlan_filter, 8571 port_id, UINT16); 8572 cmdline_parse_token_string_t cmd_vf_rx_vlan_filter_vf = 8573 TOKEN_STRING_INITIALIZER(struct cmd_vf_rx_vlan_filter, 8574 vf, "vf"); 8575 cmdline_parse_token_num_t cmd_vf_rx_vlan_filter_vf_mask = 8576 TOKEN_NUM_INITIALIZER(struct cmd_vf_rx_vlan_filter, 8577 vf_mask, UINT64); 8578 8579 cmdline_parse_inst_t cmd_vf_rxvlan_filter = { 8580 .f = cmd_vf_rx_vlan_filter_parsed, 8581 .data = NULL, 8582 .help_str = "rx_vlan add|rm <vlan_id> port <port_id> vf <vf_mask>: " 8583 "(vf_mask = hexadecimal VF mask)", 8584 .tokens = { 8585 (void *)&cmd_vf_rx_vlan_filter_rx_vlan, 8586 (void *)&cmd_vf_rx_vlan_filter_what, 8587 (void *)&cmd_vf_rx_vlan_filter_vlanid, 8588 (void *)&cmd_vf_rx_vlan_filter_port, 8589 (void *)&cmd_vf_rx_vlan_filter_portid, 8590 (void *)&cmd_vf_rx_vlan_filter_vf, 8591 (void *)&cmd_vf_rx_vlan_filter_vf_mask, 8592 NULL, 8593 }, 8594 }; 8595 8596 /* *** SET RATE LIMIT FOR A QUEUE OF A PORT *** */ 8597 struct cmd_queue_rate_limit_result { 8598 cmdline_fixed_string_t set; 8599 cmdline_fixed_string_t port; 8600 uint16_t port_num; 8601 cmdline_fixed_string_t queue; 8602 uint8_t queue_num; 8603 cmdline_fixed_string_t rate; 8604 uint16_t rate_num; 8605 }; 8606 8607 static void cmd_queue_rate_limit_parsed(void *parsed_result, 8608 __attribute__((unused)) struct cmdline *cl, 8609 __attribute__((unused)) void *data) 8610 { 8611 struct cmd_queue_rate_limit_result *res = parsed_result; 8612 int ret = 0; 8613 8614 if ((strcmp(res->set, "set") == 0) && (strcmp(res->port, "port") == 0) 8615 && (strcmp(res->queue, "queue") == 0) 8616 && (strcmp(res->rate, "rate") == 0)) 8617 ret = set_queue_rate_limit(res->port_num, res->queue_num, 8618 res->rate_num); 8619 if (ret < 0) 8620 printf("queue_rate_limit_cmd error: (%s)\n", strerror(-ret)); 8621 8622 } 8623 8624 cmdline_parse_token_string_t cmd_queue_rate_limit_set = 8625 TOKEN_STRING_INITIALIZER(struct cmd_queue_rate_limit_result, 8626 set, "set"); 8627 cmdline_parse_token_string_t cmd_queue_rate_limit_port = 8628 TOKEN_STRING_INITIALIZER(struct cmd_queue_rate_limit_result, 8629 port, "port"); 8630 cmdline_parse_token_num_t cmd_queue_rate_limit_portnum = 8631 TOKEN_NUM_INITIALIZER(struct cmd_queue_rate_limit_result, 8632 port_num, UINT16); 8633 cmdline_parse_token_string_t cmd_queue_rate_limit_queue = 8634 TOKEN_STRING_INITIALIZER(struct cmd_queue_rate_limit_result, 8635 queue, "queue"); 8636 cmdline_parse_token_num_t cmd_queue_rate_limit_queuenum = 8637 TOKEN_NUM_INITIALIZER(struct cmd_queue_rate_limit_result, 8638 queue_num, UINT8); 8639 cmdline_parse_token_string_t cmd_queue_rate_limit_rate = 8640 TOKEN_STRING_INITIALIZER(struct cmd_queue_rate_limit_result, 8641 rate, "rate"); 8642 cmdline_parse_token_num_t cmd_queue_rate_limit_ratenum = 8643 TOKEN_NUM_INITIALIZER(struct cmd_queue_rate_limit_result, 8644 rate_num, UINT16); 8645 8646 cmdline_parse_inst_t cmd_queue_rate_limit = { 8647 .f = cmd_queue_rate_limit_parsed, 8648 .data = (void *)0, 8649 .help_str = "set port <port_id> queue <queue_id> rate <rate_value>: " 8650 "Set rate limit for a queue on port_id", 8651 .tokens = { 8652 (void *)&cmd_queue_rate_limit_set, 8653 (void *)&cmd_queue_rate_limit_port, 8654 (void *)&cmd_queue_rate_limit_portnum, 8655 (void *)&cmd_queue_rate_limit_queue, 8656 (void *)&cmd_queue_rate_limit_queuenum, 8657 (void *)&cmd_queue_rate_limit_rate, 8658 (void *)&cmd_queue_rate_limit_ratenum, 8659 NULL, 8660 }, 8661 }; 8662 8663 /* *** SET RATE LIMIT FOR A VF OF A PORT *** */ 8664 struct cmd_vf_rate_limit_result { 8665 cmdline_fixed_string_t set; 8666 cmdline_fixed_string_t port; 8667 uint16_t port_num; 8668 cmdline_fixed_string_t vf; 8669 uint8_t vf_num; 8670 cmdline_fixed_string_t rate; 8671 uint16_t rate_num; 8672 cmdline_fixed_string_t q_msk; 8673 uint64_t q_msk_val; 8674 }; 8675 8676 static void cmd_vf_rate_limit_parsed(void *parsed_result, 8677 __attribute__((unused)) struct cmdline *cl, 8678 __attribute__((unused)) void *data) 8679 { 8680 struct cmd_vf_rate_limit_result *res = parsed_result; 8681 int ret = 0; 8682 8683 if ((strcmp(res->set, "set") == 0) && (strcmp(res->port, "port") == 0) 8684 && (strcmp(res->vf, "vf") == 0) 8685 && (strcmp(res->rate, "rate") == 0) 8686 && (strcmp(res->q_msk, "queue_mask") == 0)) 8687 ret = set_vf_rate_limit(res->port_num, res->vf_num, 8688 res->rate_num, res->q_msk_val); 8689 if (ret < 0) 8690 printf("vf_rate_limit_cmd error: (%s)\n", strerror(-ret)); 8691 8692 } 8693 8694 cmdline_parse_token_string_t cmd_vf_rate_limit_set = 8695 TOKEN_STRING_INITIALIZER(struct cmd_vf_rate_limit_result, 8696 set, "set"); 8697 cmdline_parse_token_string_t cmd_vf_rate_limit_port = 8698 TOKEN_STRING_INITIALIZER(struct cmd_vf_rate_limit_result, 8699 port, "port"); 8700 cmdline_parse_token_num_t cmd_vf_rate_limit_portnum = 8701 TOKEN_NUM_INITIALIZER(struct cmd_vf_rate_limit_result, 8702 port_num, UINT16); 8703 cmdline_parse_token_string_t cmd_vf_rate_limit_vf = 8704 TOKEN_STRING_INITIALIZER(struct cmd_vf_rate_limit_result, 8705 vf, "vf"); 8706 cmdline_parse_token_num_t cmd_vf_rate_limit_vfnum = 8707 TOKEN_NUM_INITIALIZER(struct cmd_vf_rate_limit_result, 8708 vf_num, UINT8); 8709 cmdline_parse_token_string_t cmd_vf_rate_limit_rate = 8710 TOKEN_STRING_INITIALIZER(struct cmd_vf_rate_limit_result, 8711 rate, "rate"); 8712 cmdline_parse_token_num_t cmd_vf_rate_limit_ratenum = 8713 TOKEN_NUM_INITIALIZER(struct cmd_vf_rate_limit_result, 8714 rate_num, UINT16); 8715 cmdline_parse_token_string_t cmd_vf_rate_limit_q_msk = 8716 TOKEN_STRING_INITIALIZER(struct cmd_vf_rate_limit_result, 8717 q_msk, "queue_mask"); 8718 cmdline_parse_token_num_t cmd_vf_rate_limit_q_msk_val = 8719 TOKEN_NUM_INITIALIZER(struct cmd_vf_rate_limit_result, 8720 q_msk_val, UINT64); 8721 8722 cmdline_parse_inst_t cmd_vf_rate_limit = { 8723 .f = cmd_vf_rate_limit_parsed, 8724 .data = (void *)0, 8725 .help_str = "set port <port_id> vf <vf_id> rate <rate_value> " 8726 "queue_mask <queue_mask_value>: " 8727 "Set rate limit for queues of VF on port_id", 8728 .tokens = { 8729 (void *)&cmd_vf_rate_limit_set, 8730 (void *)&cmd_vf_rate_limit_port, 8731 (void *)&cmd_vf_rate_limit_portnum, 8732 (void *)&cmd_vf_rate_limit_vf, 8733 (void *)&cmd_vf_rate_limit_vfnum, 8734 (void *)&cmd_vf_rate_limit_rate, 8735 (void *)&cmd_vf_rate_limit_ratenum, 8736 (void *)&cmd_vf_rate_limit_q_msk, 8737 (void *)&cmd_vf_rate_limit_q_msk_val, 8738 NULL, 8739 }, 8740 }; 8741 8742 /* *** ADD TUNNEL FILTER OF A PORT *** */ 8743 struct cmd_tunnel_filter_result { 8744 cmdline_fixed_string_t cmd; 8745 cmdline_fixed_string_t what; 8746 portid_t port_id; 8747 struct ether_addr outer_mac; 8748 struct ether_addr inner_mac; 8749 cmdline_ipaddr_t ip_value; 8750 uint16_t inner_vlan; 8751 cmdline_fixed_string_t tunnel_type; 8752 cmdline_fixed_string_t filter_type; 8753 uint32_t tenant_id; 8754 uint16_t queue_num; 8755 }; 8756 8757 static void 8758 cmd_tunnel_filter_parsed(void *parsed_result, 8759 __attribute__((unused)) struct cmdline *cl, 8760 __attribute__((unused)) void *data) 8761 { 8762 struct cmd_tunnel_filter_result *res = parsed_result; 8763 struct rte_eth_tunnel_filter_conf tunnel_filter_conf; 8764 int ret = 0; 8765 8766 memset(&tunnel_filter_conf, 0, sizeof(tunnel_filter_conf)); 8767 8768 ether_addr_copy(&res->outer_mac, &tunnel_filter_conf.outer_mac); 8769 ether_addr_copy(&res->inner_mac, &tunnel_filter_conf.inner_mac); 8770 tunnel_filter_conf.inner_vlan = res->inner_vlan; 8771 8772 if (res->ip_value.family == AF_INET) { 8773 tunnel_filter_conf.ip_addr.ipv4_addr = 8774 res->ip_value.addr.ipv4.s_addr; 8775 tunnel_filter_conf.ip_type = RTE_TUNNEL_IPTYPE_IPV4; 8776 } else { 8777 memcpy(&(tunnel_filter_conf.ip_addr.ipv6_addr), 8778 &(res->ip_value.addr.ipv6), 8779 sizeof(struct in6_addr)); 8780 tunnel_filter_conf.ip_type = RTE_TUNNEL_IPTYPE_IPV6; 8781 } 8782 8783 if (!strcmp(res->filter_type, "imac-ivlan")) 8784 tunnel_filter_conf.filter_type = RTE_TUNNEL_FILTER_IMAC_IVLAN; 8785 else if (!strcmp(res->filter_type, "imac-ivlan-tenid")) 8786 tunnel_filter_conf.filter_type = 8787 RTE_TUNNEL_FILTER_IMAC_IVLAN_TENID; 8788 else if (!strcmp(res->filter_type, "imac-tenid")) 8789 tunnel_filter_conf.filter_type = RTE_TUNNEL_FILTER_IMAC_TENID; 8790 else if (!strcmp(res->filter_type, "imac")) 8791 tunnel_filter_conf.filter_type = ETH_TUNNEL_FILTER_IMAC; 8792 else if (!strcmp(res->filter_type, "omac-imac-tenid")) 8793 tunnel_filter_conf.filter_type = 8794 RTE_TUNNEL_FILTER_OMAC_TENID_IMAC; 8795 else if (!strcmp(res->filter_type, "oip")) 8796 tunnel_filter_conf.filter_type = ETH_TUNNEL_FILTER_OIP; 8797 else if (!strcmp(res->filter_type, "iip")) 8798 tunnel_filter_conf.filter_type = ETH_TUNNEL_FILTER_IIP; 8799 else { 8800 printf("The filter type is not supported"); 8801 return; 8802 } 8803 8804 if (!strcmp(res->tunnel_type, "vxlan")) 8805 tunnel_filter_conf.tunnel_type = RTE_TUNNEL_TYPE_VXLAN; 8806 else if (!strcmp(res->tunnel_type, "nvgre")) 8807 tunnel_filter_conf.tunnel_type = RTE_TUNNEL_TYPE_NVGRE; 8808 else if (!strcmp(res->tunnel_type, "ipingre")) 8809 tunnel_filter_conf.tunnel_type = RTE_TUNNEL_TYPE_IP_IN_GRE; 8810 else { 8811 printf("The tunnel type %s not supported.\n", res->tunnel_type); 8812 return; 8813 } 8814 8815 tunnel_filter_conf.tenant_id = res->tenant_id; 8816 tunnel_filter_conf.queue_id = res->queue_num; 8817 if (!strcmp(res->what, "add")) 8818 ret = rte_eth_dev_filter_ctrl(res->port_id, 8819 RTE_ETH_FILTER_TUNNEL, 8820 RTE_ETH_FILTER_ADD, 8821 &tunnel_filter_conf); 8822 else 8823 ret = rte_eth_dev_filter_ctrl(res->port_id, 8824 RTE_ETH_FILTER_TUNNEL, 8825 RTE_ETH_FILTER_DELETE, 8826 &tunnel_filter_conf); 8827 if (ret < 0) 8828 printf("cmd_tunnel_filter_parsed error: (%s)\n", 8829 strerror(-ret)); 8830 8831 } 8832 cmdline_parse_token_string_t cmd_tunnel_filter_cmd = 8833 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_filter_result, 8834 cmd, "tunnel_filter"); 8835 cmdline_parse_token_string_t cmd_tunnel_filter_what = 8836 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_filter_result, 8837 what, "add#rm"); 8838 cmdline_parse_token_num_t cmd_tunnel_filter_port_id = 8839 TOKEN_NUM_INITIALIZER(struct cmd_tunnel_filter_result, 8840 port_id, UINT16); 8841 cmdline_parse_token_etheraddr_t cmd_tunnel_filter_outer_mac = 8842 TOKEN_ETHERADDR_INITIALIZER(struct cmd_tunnel_filter_result, 8843 outer_mac); 8844 cmdline_parse_token_etheraddr_t cmd_tunnel_filter_inner_mac = 8845 TOKEN_ETHERADDR_INITIALIZER(struct cmd_tunnel_filter_result, 8846 inner_mac); 8847 cmdline_parse_token_num_t cmd_tunnel_filter_innner_vlan = 8848 TOKEN_NUM_INITIALIZER(struct cmd_tunnel_filter_result, 8849 inner_vlan, UINT16); 8850 cmdline_parse_token_ipaddr_t cmd_tunnel_filter_ip_value = 8851 TOKEN_IPADDR_INITIALIZER(struct cmd_tunnel_filter_result, 8852 ip_value); 8853 cmdline_parse_token_string_t cmd_tunnel_filter_tunnel_type = 8854 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_filter_result, 8855 tunnel_type, "vxlan#nvgre#ipingre"); 8856 8857 cmdline_parse_token_string_t cmd_tunnel_filter_filter_type = 8858 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_filter_result, 8859 filter_type, "oip#iip#imac-ivlan#imac-ivlan-tenid#imac-tenid#" 8860 "imac#omac-imac-tenid"); 8861 cmdline_parse_token_num_t cmd_tunnel_filter_tenant_id = 8862 TOKEN_NUM_INITIALIZER(struct cmd_tunnel_filter_result, 8863 tenant_id, UINT32); 8864 cmdline_parse_token_num_t cmd_tunnel_filter_queue_num = 8865 TOKEN_NUM_INITIALIZER(struct cmd_tunnel_filter_result, 8866 queue_num, UINT16); 8867 8868 cmdline_parse_inst_t cmd_tunnel_filter = { 8869 .f = cmd_tunnel_filter_parsed, 8870 .data = (void *)0, 8871 .help_str = "tunnel_filter add|rm <port_id> <outer_mac> <inner_mac> " 8872 "<ip> <inner_vlan> vxlan|nvgre|ipingre oip|iip|imac-ivlan|" 8873 "imac-ivlan-tenid|imac-tenid|imac|omac-imac-tenid <tenant_id> " 8874 "<queue_id>: Add/Rm tunnel filter of a port", 8875 .tokens = { 8876 (void *)&cmd_tunnel_filter_cmd, 8877 (void *)&cmd_tunnel_filter_what, 8878 (void *)&cmd_tunnel_filter_port_id, 8879 (void *)&cmd_tunnel_filter_outer_mac, 8880 (void *)&cmd_tunnel_filter_inner_mac, 8881 (void *)&cmd_tunnel_filter_ip_value, 8882 (void *)&cmd_tunnel_filter_innner_vlan, 8883 (void *)&cmd_tunnel_filter_tunnel_type, 8884 (void *)&cmd_tunnel_filter_filter_type, 8885 (void *)&cmd_tunnel_filter_tenant_id, 8886 (void *)&cmd_tunnel_filter_queue_num, 8887 NULL, 8888 }, 8889 }; 8890 8891 /* *** CONFIGURE TUNNEL UDP PORT *** */ 8892 struct cmd_tunnel_udp_config { 8893 cmdline_fixed_string_t cmd; 8894 cmdline_fixed_string_t what; 8895 uint16_t udp_port; 8896 portid_t port_id; 8897 }; 8898 8899 static void 8900 cmd_tunnel_udp_config_parsed(void *parsed_result, 8901 __attribute__((unused)) struct cmdline *cl, 8902 __attribute__((unused)) void *data) 8903 { 8904 struct cmd_tunnel_udp_config *res = parsed_result; 8905 struct rte_eth_udp_tunnel tunnel_udp; 8906 int ret; 8907 8908 tunnel_udp.udp_port = res->udp_port; 8909 8910 if (!strcmp(res->cmd, "rx_vxlan_port")) 8911 tunnel_udp.prot_type = RTE_TUNNEL_TYPE_VXLAN; 8912 8913 if (!strcmp(res->what, "add")) 8914 ret = rte_eth_dev_udp_tunnel_port_add(res->port_id, 8915 &tunnel_udp); 8916 else 8917 ret = rte_eth_dev_udp_tunnel_port_delete(res->port_id, 8918 &tunnel_udp); 8919 8920 if (ret < 0) 8921 printf("udp tunneling add error: (%s)\n", strerror(-ret)); 8922 } 8923 8924 cmdline_parse_token_string_t cmd_tunnel_udp_config_cmd = 8925 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_udp_config, 8926 cmd, "rx_vxlan_port"); 8927 cmdline_parse_token_string_t cmd_tunnel_udp_config_what = 8928 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_udp_config, 8929 what, "add#rm"); 8930 cmdline_parse_token_num_t cmd_tunnel_udp_config_udp_port = 8931 TOKEN_NUM_INITIALIZER(struct cmd_tunnel_udp_config, 8932 udp_port, UINT16); 8933 cmdline_parse_token_num_t cmd_tunnel_udp_config_port_id = 8934 TOKEN_NUM_INITIALIZER(struct cmd_tunnel_udp_config, 8935 port_id, UINT16); 8936 8937 cmdline_parse_inst_t cmd_tunnel_udp_config = { 8938 .f = cmd_tunnel_udp_config_parsed, 8939 .data = (void *)0, 8940 .help_str = "rx_vxlan_port add|rm <udp_port> <port_id>: " 8941 "Add/Remove a tunneling UDP port filter", 8942 .tokens = { 8943 (void *)&cmd_tunnel_udp_config_cmd, 8944 (void *)&cmd_tunnel_udp_config_what, 8945 (void *)&cmd_tunnel_udp_config_udp_port, 8946 (void *)&cmd_tunnel_udp_config_port_id, 8947 NULL, 8948 }, 8949 }; 8950 8951 struct cmd_config_tunnel_udp_port { 8952 cmdline_fixed_string_t port; 8953 cmdline_fixed_string_t config; 8954 portid_t port_id; 8955 cmdline_fixed_string_t udp_tunnel_port; 8956 cmdline_fixed_string_t action; 8957 cmdline_fixed_string_t tunnel_type; 8958 uint16_t udp_port; 8959 }; 8960 8961 static void 8962 cmd_cfg_tunnel_udp_port_parsed(void *parsed_result, 8963 __attribute__((unused)) struct cmdline *cl, 8964 __attribute__((unused)) void *data) 8965 { 8966 struct cmd_config_tunnel_udp_port *res = parsed_result; 8967 struct rte_eth_udp_tunnel tunnel_udp; 8968 int ret = 0; 8969 8970 if (port_id_is_invalid(res->port_id, ENABLED_WARN)) 8971 return; 8972 8973 tunnel_udp.udp_port = res->udp_port; 8974 8975 if (!strcmp(res->tunnel_type, "vxlan")) { 8976 tunnel_udp.prot_type = RTE_TUNNEL_TYPE_VXLAN; 8977 } else if (!strcmp(res->tunnel_type, "geneve")) { 8978 tunnel_udp.prot_type = RTE_TUNNEL_TYPE_GENEVE; 8979 } else { 8980 printf("Invalid tunnel type\n"); 8981 return; 8982 } 8983 8984 if (!strcmp(res->action, "add")) 8985 ret = rte_eth_dev_udp_tunnel_port_add(res->port_id, 8986 &tunnel_udp); 8987 else 8988 ret = rte_eth_dev_udp_tunnel_port_delete(res->port_id, 8989 &tunnel_udp); 8990 8991 if (ret < 0) 8992 printf("udp tunneling port add error: (%s)\n", strerror(-ret)); 8993 } 8994 8995 cmdline_parse_token_string_t cmd_config_tunnel_udp_port_port = 8996 TOKEN_STRING_INITIALIZER(struct cmd_config_tunnel_udp_port, port, 8997 "port"); 8998 cmdline_parse_token_string_t cmd_config_tunnel_udp_port_config = 8999 TOKEN_STRING_INITIALIZER(struct cmd_config_tunnel_udp_port, config, 9000 "config"); 9001 cmdline_parse_token_num_t cmd_config_tunnel_udp_port_port_id = 9002 TOKEN_NUM_INITIALIZER(struct cmd_config_tunnel_udp_port, port_id, 9003 UINT16); 9004 cmdline_parse_token_string_t cmd_config_tunnel_udp_port_tunnel_port = 9005 TOKEN_STRING_INITIALIZER(struct cmd_config_tunnel_udp_port, 9006 udp_tunnel_port, 9007 "udp_tunnel_port"); 9008 cmdline_parse_token_string_t cmd_config_tunnel_udp_port_action = 9009 TOKEN_STRING_INITIALIZER(struct cmd_config_tunnel_udp_port, action, 9010 "add#rm"); 9011 cmdline_parse_token_string_t cmd_config_tunnel_udp_port_tunnel_type = 9012 TOKEN_STRING_INITIALIZER(struct cmd_config_tunnel_udp_port, tunnel_type, 9013 "vxlan#geneve"); 9014 cmdline_parse_token_num_t cmd_config_tunnel_udp_port_value = 9015 TOKEN_NUM_INITIALIZER(struct cmd_config_tunnel_udp_port, udp_port, 9016 UINT16); 9017 9018 cmdline_parse_inst_t cmd_cfg_tunnel_udp_port = { 9019 .f = cmd_cfg_tunnel_udp_port_parsed, 9020 .data = NULL, 9021 .help_str = "port config <port_id> udp_tunnel_port add|rm vxlan|geneve <udp_port>", 9022 .tokens = { 9023 (void *)&cmd_config_tunnel_udp_port_port, 9024 (void *)&cmd_config_tunnel_udp_port_config, 9025 (void *)&cmd_config_tunnel_udp_port_port_id, 9026 (void *)&cmd_config_tunnel_udp_port_tunnel_port, 9027 (void *)&cmd_config_tunnel_udp_port_action, 9028 (void *)&cmd_config_tunnel_udp_port_tunnel_type, 9029 (void *)&cmd_config_tunnel_udp_port_value, 9030 NULL, 9031 }, 9032 }; 9033 9034 /* *** GLOBAL CONFIG *** */ 9035 struct cmd_global_config_result { 9036 cmdline_fixed_string_t cmd; 9037 portid_t port_id; 9038 cmdline_fixed_string_t cfg_type; 9039 uint8_t len; 9040 }; 9041 9042 static void 9043 cmd_global_config_parsed(void *parsed_result, 9044 __attribute__((unused)) struct cmdline *cl, 9045 __attribute__((unused)) void *data) 9046 { 9047 struct cmd_global_config_result *res = parsed_result; 9048 struct rte_eth_global_cfg conf; 9049 int ret; 9050 9051 memset(&conf, 0, sizeof(conf)); 9052 conf.cfg_type = RTE_ETH_GLOBAL_CFG_TYPE_GRE_KEY_LEN; 9053 conf.cfg.gre_key_len = res->len; 9054 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_NONE, 9055 RTE_ETH_FILTER_SET, &conf); 9056 if (ret != 0) 9057 printf("Global config error\n"); 9058 } 9059 9060 cmdline_parse_token_string_t cmd_global_config_cmd = 9061 TOKEN_STRING_INITIALIZER(struct cmd_global_config_result, cmd, 9062 "global_config"); 9063 cmdline_parse_token_num_t cmd_global_config_port_id = 9064 TOKEN_NUM_INITIALIZER(struct cmd_global_config_result, port_id, 9065 UINT16); 9066 cmdline_parse_token_string_t cmd_global_config_type = 9067 TOKEN_STRING_INITIALIZER(struct cmd_global_config_result, 9068 cfg_type, "gre-key-len"); 9069 cmdline_parse_token_num_t cmd_global_config_gre_key_len = 9070 TOKEN_NUM_INITIALIZER(struct cmd_global_config_result, 9071 len, UINT8); 9072 9073 cmdline_parse_inst_t cmd_global_config = { 9074 .f = cmd_global_config_parsed, 9075 .data = (void *)NULL, 9076 .help_str = "global_config <port_id> gre-key-len <key_len>", 9077 .tokens = { 9078 (void *)&cmd_global_config_cmd, 9079 (void *)&cmd_global_config_port_id, 9080 (void *)&cmd_global_config_type, 9081 (void *)&cmd_global_config_gre_key_len, 9082 NULL, 9083 }, 9084 }; 9085 9086 /* *** CONFIGURE VM MIRROR VLAN/POOL RULE *** */ 9087 struct cmd_set_mirror_mask_result { 9088 cmdline_fixed_string_t set; 9089 cmdline_fixed_string_t port; 9090 portid_t port_id; 9091 cmdline_fixed_string_t mirror; 9092 uint8_t rule_id; 9093 cmdline_fixed_string_t what; 9094 cmdline_fixed_string_t value; 9095 cmdline_fixed_string_t dstpool; 9096 uint8_t dstpool_id; 9097 cmdline_fixed_string_t on; 9098 }; 9099 9100 cmdline_parse_token_string_t cmd_mirror_mask_set = 9101 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result, 9102 set, "set"); 9103 cmdline_parse_token_string_t cmd_mirror_mask_port = 9104 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result, 9105 port, "port"); 9106 cmdline_parse_token_num_t cmd_mirror_mask_portid = 9107 TOKEN_NUM_INITIALIZER(struct cmd_set_mirror_mask_result, 9108 port_id, UINT16); 9109 cmdline_parse_token_string_t cmd_mirror_mask_mirror = 9110 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result, 9111 mirror, "mirror-rule"); 9112 cmdline_parse_token_num_t cmd_mirror_mask_ruleid = 9113 TOKEN_NUM_INITIALIZER(struct cmd_set_mirror_mask_result, 9114 rule_id, UINT8); 9115 cmdline_parse_token_string_t cmd_mirror_mask_what = 9116 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result, 9117 what, "pool-mirror-up#pool-mirror-down" 9118 "#vlan-mirror"); 9119 cmdline_parse_token_string_t cmd_mirror_mask_value = 9120 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result, 9121 value, NULL); 9122 cmdline_parse_token_string_t cmd_mirror_mask_dstpool = 9123 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result, 9124 dstpool, "dst-pool"); 9125 cmdline_parse_token_num_t cmd_mirror_mask_poolid = 9126 TOKEN_NUM_INITIALIZER(struct cmd_set_mirror_mask_result, 9127 dstpool_id, UINT8); 9128 cmdline_parse_token_string_t cmd_mirror_mask_on = 9129 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result, 9130 on, "on#off"); 9131 9132 static void 9133 cmd_set_mirror_mask_parsed(void *parsed_result, 9134 __attribute__((unused)) struct cmdline *cl, 9135 __attribute__((unused)) void *data) 9136 { 9137 int ret,nb_item,i; 9138 struct cmd_set_mirror_mask_result *res = parsed_result; 9139 struct rte_eth_mirror_conf mr_conf; 9140 9141 memset(&mr_conf, 0, sizeof(struct rte_eth_mirror_conf)); 9142 9143 unsigned int vlan_list[ETH_MIRROR_MAX_VLANS]; 9144 9145 mr_conf.dst_pool = res->dstpool_id; 9146 9147 if (!strcmp(res->what, "pool-mirror-up")) { 9148 mr_conf.pool_mask = strtoull(res->value, NULL, 16); 9149 mr_conf.rule_type = ETH_MIRROR_VIRTUAL_POOL_UP; 9150 } else if (!strcmp(res->what, "pool-mirror-down")) { 9151 mr_conf.pool_mask = strtoull(res->value, NULL, 16); 9152 mr_conf.rule_type = ETH_MIRROR_VIRTUAL_POOL_DOWN; 9153 } else if (!strcmp(res->what, "vlan-mirror")) { 9154 mr_conf.rule_type = ETH_MIRROR_VLAN; 9155 nb_item = parse_item_list(res->value, "vlan", 9156 ETH_MIRROR_MAX_VLANS, vlan_list, 1); 9157 if (nb_item <= 0) 9158 return; 9159 9160 for (i = 0; i < nb_item; i++) { 9161 if (vlan_list[i] > ETHER_MAX_VLAN_ID) { 9162 printf("Invalid vlan_id: must be < 4096\n"); 9163 return; 9164 } 9165 9166 mr_conf.vlan.vlan_id[i] = (uint16_t)vlan_list[i]; 9167 mr_conf.vlan.vlan_mask |= 1ULL << i; 9168 } 9169 } 9170 9171 if (!strcmp(res->on, "on")) 9172 ret = rte_eth_mirror_rule_set(res->port_id, &mr_conf, 9173 res->rule_id, 1); 9174 else 9175 ret = rte_eth_mirror_rule_set(res->port_id, &mr_conf, 9176 res->rule_id, 0); 9177 if (ret < 0) 9178 printf("mirror rule add error: (%s)\n", strerror(-ret)); 9179 } 9180 9181 cmdline_parse_inst_t cmd_set_mirror_mask = { 9182 .f = cmd_set_mirror_mask_parsed, 9183 .data = NULL, 9184 .help_str = "set port <port_id> mirror-rule <rule_id> " 9185 "pool-mirror-up|pool-mirror-down|vlan-mirror " 9186 "<pool_mask|vlan_id[,vlan_id]*> dst-pool <pool_id> on|off", 9187 .tokens = { 9188 (void *)&cmd_mirror_mask_set, 9189 (void *)&cmd_mirror_mask_port, 9190 (void *)&cmd_mirror_mask_portid, 9191 (void *)&cmd_mirror_mask_mirror, 9192 (void *)&cmd_mirror_mask_ruleid, 9193 (void *)&cmd_mirror_mask_what, 9194 (void *)&cmd_mirror_mask_value, 9195 (void *)&cmd_mirror_mask_dstpool, 9196 (void *)&cmd_mirror_mask_poolid, 9197 (void *)&cmd_mirror_mask_on, 9198 NULL, 9199 }, 9200 }; 9201 9202 /* *** CONFIGURE VM MIRROR UPLINK/DOWNLINK RULE *** */ 9203 struct cmd_set_mirror_link_result { 9204 cmdline_fixed_string_t set; 9205 cmdline_fixed_string_t port; 9206 portid_t port_id; 9207 cmdline_fixed_string_t mirror; 9208 uint8_t rule_id; 9209 cmdline_fixed_string_t what; 9210 cmdline_fixed_string_t dstpool; 9211 uint8_t dstpool_id; 9212 cmdline_fixed_string_t on; 9213 }; 9214 9215 cmdline_parse_token_string_t cmd_mirror_link_set = 9216 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_link_result, 9217 set, "set"); 9218 cmdline_parse_token_string_t cmd_mirror_link_port = 9219 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_link_result, 9220 port, "port"); 9221 cmdline_parse_token_num_t cmd_mirror_link_portid = 9222 TOKEN_NUM_INITIALIZER(struct cmd_set_mirror_link_result, 9223 port_id, UINT16); 9224 cmdline_parse_token_string_t cmd_mirror_link_mirror = 9225 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_link_result, 9226 mirror, "mirror-rule"); 9227 cmdline_parse_token_num_t cmd_mirror_link_ruleid = 9228 TOKEN_NUM_INITIALIZER(struct cmd_set_mirror_link_result, 9229 rule_id, UINT8); 9230 cmdline_parse_token_string_t cmd_mirror_link_what = 9231 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_link_result, 9232 what, "uplink-mirror#downlink-mirror"); 9233 cmdline_parse_token_string_t cmd_mirror_link_dstpool = 9234 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_link_result, 9235 dstpool, "dst-pool"); 9236 cmdline_parse_token_num_t cmd_mirror_link_poolid = 9237 TOKEN_NUM_INITIALIZER(struct cmd_set_mirror_link_result, 9238 dstpool_id, UINT8); 9239 cmdline_parse_token_string_t cmd_mirror_link_on = 9240 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_link_result, 9241 on, "on#off"); 9242 9243 static void 9244 cmd_set_mirror_link_parsed(void *parsed_result, 9245 __attribute__((unused)) struct cmdline *cl, 9246 __attribute__((unused)) void *data) 9247 { 9248 int ret; 9249 struct cmd_set_mirror_link_result *res = parsed_result; 9250 struct rte_eth_mirror_conf mr_conf; 9251 9252 memset(&mr_conf, 0, sizeof(struct rte_eth_mirror_conf)); 9253 if (!strcmp(res->what, "uplink-mirror")) 9254 mr_conf.rule_type = ETH_MIRROR_UPLINK_PORT; 9255 else 9256 mr_conf.rule_type = ETH_MIRROR_DOWNLINK_PORT; 9257 9258 mr_conf.dst_pool = res->dstpool_id; 9259 9260 if (!strcmp(res->on, "on")) 9261 ret = rte_eth_mirror_rule_set(res->port_id, &mr_conf, 9262 res->rule_id, 1); 9263 else 9264 ret = rte_eth_mirror_rule_set(res->port_id, &mr_conf, 9265 res->rule_id, 0); 9266 9267 /* check the return value and print it if is < 0 */ 9268 if (ret < 0) 9269 printf("mirror rule add error: (%s)\n", strerror(-ret)); 9270 9271 } 9272 9273 cmdline_parse_inst_t cmd_set_mirror_link = { 9274 .f = cmd_set_mirror_link_parsed, 9275 .data = NULL, 9276 .help_str = "set port <port_id> mirror-rule <rule_id> " 9277 "uplink-mirror|downlink-mirror dst-pool <pool_id> on|off", 9278 .tokens = { 9279 (void *)&cmd_mirror_link_set, 9280 (void *)&cmd_mirror_link_port, 9281 (void *)&cmd_mirror_link_portid, 9282 (void *)&cmd_mirror_link_mirror, 9283 (void *)&cmd_mirror_link_ruleid, 9284 (void *)&cmd_mirror_link_what, 9285 (void *)&cmd_mirror_link_dstpool, 9286 (void *)&cmd_mirror_link_poolid, 9287 (void *)&cmd_mirror_link_on, 9288 NULL, 9289 }, 9290 }; 9291 9292 /* *** RESET VM MIRROR RULE *** */ 9293 struct cmd_rm_mirror_rule_result { 9294 cmdline_fixed_string_t reset; 9295 cmdline_fixed_string_t port; 9296 portid_t port_id; 9297 cmdline_fixed_string_t mirror; 9298 uint8_t rule_id; 9299 }; 9300 9301 cmdline_parse_token_string_t cmd_rm_mirror_rule_reset = 9302 TOKEN_STRING_INITIALIZER(struct cmd_rm_mirror_rule_result, 9303 reset, "reset"); 9304 cmdline_parse_token_string_t cmd_rm_mirror_rule_port = 9305 TOKEN_STRING_INITIALIZER(struct cmd_rm_mirror_rule_result, 9306 port, "port"); 9307 cmdline_parse_token_num_t cmd_rm_mirror_rule_portid = 9308 TOKEN_NUM_INITIALIZER(struct cmd_rm_mirror_rule_result, 9309 port_id, UINT16); 9310 cmdline_parse_token_string_t cmd_rm_mirror_rule_mirror = 9311 TOKEN_STRING_INITIALIZER(struct cmd_rm_mirror_rule_result, 9312 mirror, "mirror-rule"); 9313 cmdline_parse_token_num_t cmd_rm_mirror_rule_ruleid = 9314 TOKEN_NUM_INITIALIZER(struct cmd_rm_mirror_rule_result, 9315 rule_id, UINT8); 9316 9317 static void 9318 cmd_reset_mirror_rule_parsed(void *parsed_result, 9319 __attribute__((unused)) struct cmdline *cl, 9320 __attribute__((unused)) void *data) 9321 { 9322 int ret; 9323 struct cmd_set_mirror_link_result *res = parsed_result; 9324 /* check rule_id */ 9325 ret = rte_eth_mirror_rule_reset(res->port_id,res->rule_id); 9326 if(ret < 0) 9327 printf("mirror rule remove error: (%s)\n", strerror(-ret)); 9328 } 9329 9330 cmdline_parse_inst_t cmd_reset_mirror_rule = { 9331 .f = cmd_reset_mirror_rule_parsed, 9332 .data = NULL, 9333 .help_str = "reset port <port_id> mirror-rule <rule_id>", 9334 .tokens = { 9335 (void *)&cmd_rm_mirror_rule_reset, 9336 (void *)&cmd_rm_mirror_rule_port, 9337 (void *)&cmd_rm_mirror_rule_portid, 9338 (void *)&cmd_rm_mirror_rule_mirror, 9339 (void *)&cmd_rm_mirror_rule_ruleid, 9340 NULL, 9341 }, 9342 }; 9343 9344 /* ******************************************************************************** */ 9345 9346 struct cmd_dump_result { 9347 cmdline_fixed_string_t dump; 9348 }; 9349 9350 static void 9351 dump_struct_sizes(void) 9352 { 9353 #define DUMP_SIZE(t) printf("sizeof(" #t ") = %u\n", (unsigned)sizeof(t)); 9354 DUMP_SIZE(struct rte_mbuf); 9355 DUMP_SIZE(struct rte_mempool); 9356 DUMP_SIZE(struct rte_ring); 9357 #undef DUMP_SIZE 9358 } 9359 9360 static void cmd_dump_parsed(void *parsed_result, 9361 __attribute__((unused)) struct cmdline *cl, 9362 __attribute__((unused)) void *data) 9363 { 9364 struct cmd_dump_result *res = parsed_result; 9365 9366 if (!strcmp(res->dump, "dump_physmem")) 9367 rte_dump_physmem_layout(stdout); 9368 else if (!strcmp(res->dump, "dump_memzone")) 9369 rte_memzone_dump(stdout); 9370 else if (!strcmp(res->dump, "dump_struct_sizes")) 9371 dump_struct_sizes(); 9372 else if (!strcmp(res->dump, "dump_ring")) 9373 rte_ring_list_dump(stdout); 9374 else if (!strcmp(res->dump, "dump_mempool")) 9375 rte_mempool_list_dump(stdout); 9376 else if (!strcmp(res->dump, "dump_devargs")) 9377 rte_devargs_dump(stdout); 9378 else if (!strcmp(res->dump, "dump_log_types")) 9379 rte_log_dump(stdout); 9380 } 9381 9382 cmdline_parse_token_string_t cmd_dump_dump = 9383 TOKEN_STRING_INITIALIZER(struct cmd_dump_result, dump, 9384 "dump_physmem#" 9385 "dump_memzone#" 9386 "dump_struct_sizes#" 9387 "dump_ring#" 9388 "dump_mempool#" 9389 "dump_devargs#" 9390 "dump_log_types"); 9391 9392 cmdline_parse_inst_t cmd_dump = { 9393 .f = cmd_dump_parsed, /* function to call */ 9394 .data = NULL, /* 2nd arg of func */ 9395 .help_str = "Dump status", 9396 .tokens = { /* token list, NULL terminated */ 9397 (void *)&cmd_dump_dump, 9398 NULL, 9399 }, 9400 }; 9401 9402 /* ******************************************************************************** */ 9403 9404 struct cmd_dump_one_result { 9405 cmdline_fixed_string_t dump; 9406 cmdline_fixed_string_t name; 9407 }; 9408 9409 static void cmd_dump_one_parsed(void *parsed_result, struct cmdline *cl, 9410 __attribute__((unused)) void *data) 9411 { 9412 struct cmd_dump_one_result *res = parsed_result; 9413 9414 if (!strcmp(res->dump, "dump_ring")) { 9415 struct rte_ring *r; 9416 r = rte_ring_lookup(res->name); 9417 if (r == NULL) { 9418 cmdline_printf(cl, "Cannot find ring\n"); 9419 return; 9420 } 9421 rte_ring_dump(stdout, r); 9422 } else if (!strcmp(res->dump, "dump_mempool")) { 9423 struct rte_mempool *mp; 9424 mp = rte_mempool_lookup(res->name); 9425 if (mp == NULL) { 9426 cmdline_printf(cl, "Cannot find mempool\n"); 9427 return; 9428 } 9429 rte_mempool_dump(stdout, mp); 9430 } 9431 } 9432 9433 cmdline_parse_token_string_t cmd_dump_one_dump = 9434 TOKEN_STRING_INITIALIZER(struct cmd_dump_one_result, dump, 9435 "dump_ring#dump_mempool"); 9436 9437 cmdline_parse_token_string_t cmd_dump_one_name = 9438 TOKEN_STRING_INITIALIZER(struct cmd_dump_one_result, name, NULL); 9439 9440 cmdline_parse_inst_t cmd_dump_one = { 9441 .f = cmd_dump_one_parsed, /* function to call */ 9442 .data = NULL, /* 2nd arg of func */ 9443 .help_str = "dump_ring|dump_mempool <name>: Dump one ring/mempool", 9444 .tokens = { /* token list, NULL terminated */ 9445 (void *)&cmd_dump_one_dump, 9446 (void *)&cmd_dump_one_name, 9447 NULL, 9448 }, 9449 }; 9450 9451 /* *** Add/Del syn filter *** */ 9452 struct cmd_syn_filter_result { 9453 cmdline_fixed_string_t filter; 9454 portid_t port_id; 9455 cmdline_fixed_string_t ops; 9456 cmdline_fixed_string_t priority; 9457 cmdline_fixed_string_t high; 9458 cmdline_fixed_string_t queue; 9459 uint16_t queue_id; 9460 }; 9461 9462 static void 9463 cmd_syn_filter_parsed(void *parsed_result, 9464 __attribute__((unused)) struct cmdline *cl, 9465 __attribute__((unused)) void *data) 9466 { 9467 struct cmd_syn_filter_result *res = parsed_result; 9468 struct rte_eth_syn_filter syn_filter; 9469 int ret = 0; 9470 9471 ret = rte_eth_dev_filter_supported(res->port_id, 9472 RTE_ETH_FILTER_SYN); 9473 if (ret < 0) { 9474 printf("syn filter is not supported on port %u.\n", 9475 res->port_id); 9476 return; 9477 } 9478 9479 memset(&syn_filter, 0, sizeof(syn_filter)); 9480 9481 if (!strcmp(res->ops, "add")) { 9482 if (!strcmp(res->high, "high")) 9483 syn_filter.hig_pri = 1; 9484 else 9485 syn_filter.hig_pri = 0; 9486 9487 syn_filter.queue = res->queue_id; 9488 ret = rte_eth_dev_filter_ctrl(res->port_id, 9489 RTE_ETH_FILTER_SYN, 9490 RTE_ETH_FILTER_ADD, 9491 &syn_filter); 9492 } else 9493 ret = rte_eth_dev_filter_ctrl(res->port_id, 9494 RTE_ETH_FILTER_SYN, 9495 RTE_ETH_FILTER_DELETE, 9496 &syn_filter); 9497 9498 if (ret < 0) 9499 printf("syn filter programming error: (%s)\n", 9500 strerror(-ret)); 9501 } 9502 9503 cmdline_parse_token_string_t cmd_syn_filter_filter = 9504 TOKEN_STRING_INITIALIZER(struct cmd_syn_filter_result, 9505 filter, "syn_filter"); 9506 cmdline_parse_token_num_t cmd_syn_filter_port_id = 9507 TOKEN_NUM_INITIALIZER(struct cmd_syn_filter_result, 9508 port_id, UINT16); 9509 cmdline_parse_token_string_t cmd_syn_filter_ops = 9510 TOKEN_STRING_INITIALIZER(struct cmd_syn_filter_result, 9511 ops, "add#del"); 9512 cmdline_parse_token_string_t cmd_syn_filter_priority = 9513 TOKEN_STRING_INITIALIZER(struct cmd_syn_filter_result, 9514 priority, "priority"); 9515 cmdline_parse_token_string_t cmd_syn_filter_high = 9516 TOKEN_STRING_INITIALIZER(struct cmd_syn_filter_result, 9517 high, "high#low"); 9518 cmdline_parse_token_string_t cmd_syn_filter_queue = 9519 TOKEN_STRING_INITIALIZER(struct cmd_syn_filter_result, 9520 queue, "queue"); 9521 cmdline_parse_token_num_t cmd_syn_filter_queue_id = 9522 TOKEN_NUM_INITIALIZER(struct cmd_syn_filter_result, 9523 queue_id, UINT16); 9524 9525 cmdline_parse_inst_t cmd_syn_filter = { 9526 .f = cmd_syn_filter_parsed, 9527 .data = NULL, 9528 .help_str = "syn_filter <port_id> add|del priority high|low queue " 9529 "<queue_id>: Add/Delete syn filter", 9530 .tokens = { 9531 (void *)&cmd_syn_filter_filter, 9532 (void *)&cmd_syn_filter_port_id, 9533 (void *)&cmd_syn_filter_ops, 9534 (void *)&cmd_syn_filter_priority, 9535 (void *)&cmd_syn_filter_high, 9536 (void *)&cmd_syn_filter_queue, 9537 (void *)&cmd_syn_filter_queue_id, 9538 NULL, 9539 }, 9540 }; 9541 9542 /* *** queue region set *** */ 9543 struct cmd_queue_region_result { 9544 cmdline_fixed_string_t set; 9545 cmdline_fixed_string_t port; 9546 portid_t port_id; 9547 cmdline_fixed_string_t cmd; 9548 cmdline_fixed_string_t region; 9549 uint8_t region_id; 9550 cmdline_fixed_string_t queue_start_index; 9551 uint8_t queue_id; 9552 cmdline_fixed_string_t queue_num; 9553 uint8_t queue_num_value; 9554 }; 9555 9556 static void 9557 cmd_queue_region_parsed(void *parsed_result, 9558 __attribute__((unused)) struct cmdline *cl, 9559 __attribute__((unused)) void *data) 9560 { 9561 struct cmd_queue_region_result *res = parsed_result; 9562 int ret = -ENOTSUP; 9563 #ifdef RTE_LIBRTE_I40E_PMD 9564 struct rte_pmd_i40e_queue_region_conf region_conf; 9565 enum rte_pmd_i40e_queue_region_op op_type; 9566 #endif 9567 9568 if (port_id_is_invalid(res->port_id, ENABLED_WARN)) 9569 return; 9570 9571 #ifdef RTE_LIBRTE_I40E_PMD 9572 memset(®ion_conf, 0, sizeof(region_conf)); 9573 op_type = RTE_PMD_I40E_RSS_QUEUE_REGION_SET; 9574 region_conf.region_id = res->region_id; 9575 region_conf.queue_num = res->queue_num_value; 9576 region_conf.queue_start_index = res->queue_id; 9577 9578 ret = rte_pmd_i40e_rss_queue_region_conf(res->port_id, 9579 op_type, ®ion_conf); 9580 #endif 9581 9582 switch (ret) { 9583 case 0: 9584 break; 9585 case -ENOTSUP: 9586 printf("function not implemented or supported\n"); 9587 break; 9588 default: 9589 printf("queue region config error: (%s)\n", strerror(-ret)); 9590 } 9591 } 9592 9593 cmdline_parse_token_string_t cmd_queue_region_set = 9594 TOKEN_STRING_INITIALIZER(struct cmd_queue_region_result, 9595 set, "set"); 9596 cmdline_parse_token_string_t cmd_queue_region_port = 9597 TOKEN_STRING_INITIALIZER(struct cmd_queue_region_result, port, "port"); 9598 cmdline_parse_token_num_t cmd_queue_region_port_id = 9599 TOKEN_NUM_INITIALIZER(struct cmd_queue_region_result, 9600 port_id, UINT16); 9601 cmdline_parse_token_string_t cmd_queue_region_cmd = 9602 TOKEN_STRING_INITIALIZER(struct cmd_queue_region_result, 9603 cmd, "queue-region"); 9604 cmdline_parse_token_string_t cmd_queue_region_id = 9605 TOKEN_STRING_INITIALIZER(struct cmd_queue_region_result, 9606 region, "region_id"); 9607 cmdline_parse_token_num_t cmd_queue_region_index = 9608 TOKEN_NUM_INITIALIZER(struct cmd_queue_region_result, 9609 region_id, UINT8); 9610 cmdline_parse_token_string_t cmd_queue_region_queue_start_index = 9611 TOKEN_STRING_INITIALIZER(struct cmd_queue_region_result, 9612 queue_start_index, "queue_start_index"); 9613 cmdline_parse_token_num_t cmd_queue_region_queue_id = 9614 TOKEN_NUM_INITIALIZER(struct cmd_queue_region_result, 9615 queue_id, UINT8); 9616 cmdline_parse_token_string_t cmd_queue_region_queue_num = 9617 TOKEN_STRING_INITIALIZER(struct cmd_queue_region_result, 9618 queue_num, "queue_num"); 9619 cmdline_parse_token_num_t cmd_queue_region_queue_num_value = 9620 TOKEN_NUM_INITIALIZER(struct cmd_queue_region_result, 9621 queue_num_value, UINT8); 9622 9623 cmdline_parse_inst_t cmd_queue_region = { 9624 .f = cmd_queue_region_parsed, 9625 .data = NULL, 9626 .help_str = "set port <port_id> queue-region region_id <value> " 9627 "queue_start_index <value> queue_num <value>: Set a queue region", 9628 .tokens = { 9629 (void *)&cmd_queue_region_set, 9630 (void *)&cmd_queue_region_port, 9631 (void *)&cmd_queue_region_port_id, 9632 (void *)&cmd_queue_region_cmd, 9633 (void *)&cmd_queue_region_id, 9634 (void *)&cmd_queue_region_index, 9635 (void *)&cmd_queue_region_queue_start_index, 9636 (void *)&cmd_queue_region_queue_id, 9637 (void *)&cmd_queue_region_queue_num, 9638 (void *)&cmd_queue_region_queue_num_value, 9639 NULL, 9640 }, 9641 }; 9642 9643 /* *** queue region and flowtype set *** */ 9644 struct cmd_region_flowtype_result { 9645 cmdline_fixed_string_t set; 9646 cmdline_fixed_string_t port; 9647 portid_t port_id; 9648 cmdline_fixed_string_t cmd; 9649 cmdline_fixed_string_t region; 9650 uint8_t region_id; 9651 cmdline_fixed_string_t flowtype; 9652 uint8_t flowtype_id; 9653 }; 9654 9655 static void 9656 cmd_region_flowtype_parsed(void *parsed_result, 9657 __attribute__((unused)) struct cmdline *cl, 9658 __attribute__((unused)) void *data) 9659 { 9660 struct cmd_region_flowtype_result *res = parsed_result; 9661 int ret = -ENOTSUP; 9662 #ifdef RTE_LIBRTE_I40E_PMD 9663 struct rte_pmd_i40e_queue_region_conf region_conf; 9664 enum rte_pmd_i40e_queue_region_op op_type; 9665 #endif 9666 9667 if (port_id_is_invalid(res->port_id, ENABLED_WARN)) 9668 return; 9669 9670 #ifdef RTE_LIBRTE_I40E_PMD 9671 memset(®ion_conf, 0, sizeof(region_conf)); 9672 9673 op_type = RTE_PMD_I40E_RSS_QUEUE_REGION_FLOWTYPE_SET; 9674 region_conf.region_id = res->region_id; 9675 region_conf.hw_flowtype = res->flowtype_id; 9676 9677 ret = rte_pmd_i40e_rss_queue_region_conf(res->port_id, 9678 op_type, ®ion_conf); 9679 #endif 9680 9681 switch (ret) { 9682 case 0: 9683 break; 9684 case -ENOTSUP: 9685 printf("function not implemented or supported\n"); 9686 break; 9687 default: 9688 printf("region flowtype config error: (%s)\n", strerror(-ret)); 9689 } 9690 } 9691 9692 cmdline_parse_token_string_t cmd_region_flowtype_set = 9693 TOKEN_STRING_INITIALIZER(struct cmd_region_flowtype_result, 9694 set, "set"); 9695 cmdline_parse_token_string_t cmd_region_flowtype_port = 9696 TOKEN_STRING_INITIALIZER(struct cmd_region_flowtype_result, 9697 port, "port"); 9698 cmdline_parse_token_num_t cmd_region_flowtype_port_index = 9699 TOKEN_NUM_INITIALIZER(struct cmd_region_flowtype_result, 9700 port_id, UINT16); 9701 cmdline_parse_token_string_t cmd_region_flowtype_cmd = 9702 TOKEN_STRING_INITIALIZER(struct cmd_region_flowtype_result, 9703 cmd, "queue-region"); 9704 cmdline_parse_token_string_t cmd_region_flowtype_index = 9705 TOKEN_STRING_INITIALIZER(struct cmd_region_flowtype_result, 9706 region, "region_id"); 9707 cmdline_parse_token_num_t cmd_region_flowtype_id = 9708 TOKEN_NUM_INITIALIZER(struct cmd_region_flowtype_result, 9709 region_id, UINT8); 9710 cmdline_parse_token_string_t cmd_region_flowtype_flow_index = 9711 TOKEN_STRING_INITIALIZER(struct cmd_region_flowtype_result, 9712 flowtype, "flowtype"); 9713 cmdline_parse_token_num_t cmd_region_flowtype_flow_id = 9714 TOKEN_NUM_INITIALIZER(struct cmd_region_flowtype_result, 9715 flowtype_id, UINT8); 9716 cmdline_parse_inst_t cmd_region_flowtype = { 9717 .f = cmd_region_flowtype_parsed, 9718 .data = NULL, 9719 .help_str = "set port <port_id> queue-region region_id <value> " 9720 "flowtype <value>: Set a flowtype region index", 9721 .tokens = { 9722 (void *)&cmd_region_flowtype_set, 9723 (void *)&cmd_region_flowtype_port, 9724 (void *)&cmd_region_flowtype_port_index, 9725 (void *)&cmd_region_flowtype_cmd, 9726 (void *)&cmd_region_flowtype_index, 9727 (void *)&cmd_region_flowtype_id, 9728 (void *)&cmd_region_flowtype_flow_index, 9729 (void *)&cmd_region_flowtype_flow_id, 9730 NULL, 9731 }, 9732 }; 9733 9734 /* *** User Priority (UP) to queue region (region_id) set *** */ 9735 struct cmd_user_priority_region_result { 9736 cmdline_fixed_string_t set; 9737 cmdline_fixed_string_t port; 9738 portid_t port_id; 9739 cmdline_fixed_string_t cmd; 9740 cmdline_fixed_string_t user_priority; 9741 uint8_t user_priority_id; 9742 cmdline_fixed_string_t region; 9743 uint8_t region_id; 9744 }; 9745 9746 static void 9747 cmd_user_priority_region_parsed(void *parsed_result, 9748 __attribute__((unused)) struct cmdline *cl, 9749 __attribute__((unused)) void *data) 9750 { 9751 struct cmd_user_priority_region_result *res = parsed_result; 9752 int ret = -ENOTSUP; 9753 #ifdef RTE_LIBRTE_I40E_PMD 9754 struct rte_pmd_i40e_queue_region_conf region_conf; 9755 enum rte_pmd_i40e_queue_region_op op_type; 9756 #endif 9757 9758 if (port_id_is_invalid(res->port_id, ENABLED_WARN)) 9759 return; 9760 9761 #ifdef RTE_LIBRTE_I40E_PMD 9762 memset(®ion_conf, 0, sizeof(region_conf)); 9763 op_type = RTE_PMD_I40E_RSS_QUEUE_REGION_USER_PRIORITY_SET; 9764 region_conf.user_priority = res->user_priority_id; 9765 region_conf.region_id = res->region_id; 9766 9767 ret = rte_pmd_i40e_rss_queue_region_conf(res->port_id, 9768 op_type, ®ion_conf); 9769 #endif 9770 9771 switch (ret) { 9772 case 0: 9773 break; 9774 case -ENOTSUP: 9775 printf("function not implemented or supported\n"); 9776 break; 9777 default: 9778 printf("user_priority region config error: (%s)\n", 9779 strerror(-ret)); 9780 } 9781 } 9782 9783 cmdline_parse_token_string_t cmd_user_priority_region_set = 9784 TOKEN_STRING_INITIALIZER(struct cmd_user_priority_region_result, 9785 set, "set"); 9786 cmdline_parse_token_string_t cmd_user_priority_region_port = 9787 TOKEN_STRING_INITIALIZER(struct cmd_user_priority_region_result, 9788 port, "port"); 9789 cmdline_parse_token_num_t cmd_user_priority_region_port_index = 9790 TOKEN_NUM_INITIALIZER(struct cmd_user_priority_region_result, 9791 port_id, UINT16); 9792 cmdline_parse_token_string_t cmd_user_priority_region_cmd = 9793 TOKEN_STRING_INITIALIZER(struct cmd_user_priority_region_result, 9794 cmd, "queue-region"); 9795 cmdline_parse_token_string_t cmd_user_priority_region_UP = 9796 TOKEN_STRING_INITIALIZER(struct cmd_user_priority_region_result, 9797 user_priority, "UP"); 9798 cmdline_parse_token_num_t cmd_user_priority_region_UP_id = 9799 TOKEN_NUM_INITIALIZER(struct cmd_user_priority_region_result, 9800 user_priority_id, UINT8); 9801 cmdline_parse_token_string_t cmd_user_priority_region_region = 9802 TOKEN_STRING_INITIALIZER(struct cmd_user_priority_region_result, 9803 region, "region_id"); 9804 cmdline_parse_token_num_t cmd_user_priority_region_region_id = 9805 TOKEN_NUM_INITIALIZER(struct cmd_user_priority_region_result, 9806 region_id, UINT8); 9807 9808 cmdline_parse_inst_t cmd_user_priority_region = { 9809 .f = cmd_user_priority_region_parsed, 9810 .data = NULL, 9811 .help_str = "set port <port_id> queue-region UP <value> " 9812 "region_id <value>: Set the mapping of User Priority (UP) " 9813 "to queue region (region_id) ", 9814 .tokens = { 9815 (void *)&cmd_user_priority_region_set, 9816 (void *)&cmd_user_priority_region_port, 9817 (void *)&cmd_user_priority_region_port_index, 9818 (void *)&cmd_user_priority_region_cmd, 9819 (void *)&cmd_user_priority_region_UP, 9820 (void *)&cmd_user_priority_region_UP_id, 9821 (void *)&cmd_user_priority_region_region, 9822 (void *)&cmd_user_priority_region_region_id, 9823 NULL, 9824 }, 9825 }; 9826 9827 /* *** flush all queue region related configuration *** */ 9828 struct cmd_flush_queue_region_result { 9829 cmdline_fixed_string_t set; 9830 cmdline_fixed_string_t port; 9831 portid_t port_id; 9832 cmdline_fixed_string_t cmd; 9833 cmdline_fixed_string_t flush; 9834 cmdline_fixed_string_t what; 9835 }; 9836 9837 static void 9838 cmd_flush_queue_region_parsed(void *parsed_result, 9839 __attribute__((unused)) struct cmdline *cl, 9840 __attribute__((unused)) void *data) 9841 { 9842 struct cmd_flush_queue_region_result *res = parsed_result; 9843 int ret = -ENOTSUP; 9844 #ifdef RTE_LIBRTE_I40E_PMD 9845 struct rte_pmd_i40e_queue_region_conf region_conf; 9846 enum rte_pmd_i40e_queue_region_op op_type; 9847 #endif 9848 9849 if (port_id_is_invalid(res->port_id, ENABLED_WARN)) 9850 return; 9851 9852 #ifdef RTE_LIBRTE_I40E_PMD 9853 memset(®ion_conf, 0, sizeof(region_conf)); 9854 9855 if (strcmp(res->what, "on") == 0) 9856 op_type = RTE_PMD_I40E_RSS_QUEUE_REGION_ALL_FLUSH_ON; 9857 else 9858 op_type = RTE_PMD_I40E_RSS_QUEUE_REGION_ALL_FLUSH_OFF; 9859 9860 ret = rte_pmd_i40e_rss_queue_region_conf(res->port_id, 9861 op_type, ®ion_conf); 9862 #endif 9863 9864 switch (ret) { 9865 case 0: 9866 break; 9867 case -ENOTSUP: 9868 printf("function not implemented or supported\n"); 9869 break; 9870 default: 9871 printf("queue region config flush error: (%s)\n", 9872 strerror(-ret)); 9873 } 9874 } 9875 9876 cmdline_parse_token_string_t cmd_flush_queue_region_set = 9877 TOKEN_STRING_INITIALIZER(struct cmd_flush_queue_region_result, 9878 set, "set"); 9879 cmdline_parse_token_string_t cmd_flush_queue_region_port = 9880 TOKEN_STRING_INITIALIZER(struct cmd_flush_queue_region_result, 9881 port, "port"); 9882 cmdline_parse_token_num_t cmd_flush_queue_region_port_index = 9883 TOKEN_NUM_INITIALIZER(struct cmd_flush_queue_region_result, 9884 port_id, UINT16); 9885 cmdline_parse_token_string_t cmd_flush_queue_region_cmd = 9886 TOKEN_STRING_INITIALIZER(struct cmd_flush_queue_region_result, 9887 cmd, "queue-region"); 9888 cmdline_parse_token_string_t cmd_flush_queue_region_flush = 9889 TOKEN_STRING_INITIALIZER(struct cmd_flush_queue_region_result, 9890 flush, "flush"); 9891 cmdline_parse_token_string_t cmd_flush_queue_region_what = 9892 TOKEN_STRING_INITIALIZER(struct cmd_flush_queue_region_result, 9893 what, "on#off"); 9894 9895 cmdline_parse_inst_t cmd_flush_queue_region = { 9896 .f = cmd_flush_queue_region_parsed, 9897 .data = NULL, 9898 .help_str = "set port <port_id> queue-region flush on|off" 9899 ": flush all queue region related configuration", 9900 .tokens = { 9901 (void *)&cmd_flush_queue_region_set, 9902 (void *)&cmd_flush_queue_region_port, 9903 (void *)&cmd_flush_queue_region_port_index, 9904 (void *)&cmd_flush_queue_region_cmd, 9905 (void *)&cmd_flush_queue_region_flush, 9906 (void *)&cmd_flush_queue_region_what, 9907 NULL, 9908 }, 9909 }; 9910 9911 /* *** get all queue region related configuration info *** */ 9912 struct cmd_show_queue_region_info { 9913 cmdline_fixed_string_t show; 9914 cmdline_fixed_string_t port; 9915 portid_t port_id; 9916 cmdline_fixed_string_t cmd; 9917 }; 9918 9919 static void 9920 cmd_show_queue_region_info_parsed(void *parsed_result, 9921 __attribute__((unused)) struct cmdline *cl, 9922 __attribute__((unused)) void *data) 9923 { 9924 struct cmd_show_queue_region_info *res = parsed_result; 9925 int ret = -ENOTSUP; 9926 #ifdef RTE_LIBRTE_I40E_PMD 9927 struct rte_pmd_i40e_queue_regions rte_pmd_regions; 9928 enum rte_pmd_i40e_queue_region_op op_type; 9929 #endif 9930 9931 if (port_id_is_invalid(res->port_id, ENABLED_WARN)) 9932 return; 9933 9934 #ifdef RTE_LIBRTE_I40E_PMD 9935 memset(&rte_pmd_regions, 0, sizeof(rte_pmd_regions)); 9936 9937 op_type = RTE_PMD_I40E_RSS_QUEUE_REGION_INFO_GET; 9938 9939 ret = rte_pmd_i40e_rss_queue_region_conf(res->port_id, 9940 op_type, &rte_pmd_regions); 9941 9942 port_queue_region_info_display(res->port_id, &rte_pmd_regions); 9943 #endif 9944 9945 switch (ret) { 9946 case 0: 9947 break; 9948 case -ENOTSUP: 9949 printf("function not implemented or supported\n"); 9950 break; 9951 default: 9952 printf("queue region config info show error: (%s)\n", 9953 strerror(-ret)); 9954 } 9955 } 9956 9957 cmdline_parse_token_string_t cmd_show_queue_region_info_get = 9958 TOKEN_STRING_INITIALIZER(struct cmd_show_queue_region_info, 9959 show, "show"); 9960 cmdline_parse_token_string_t cmd_show_queue_region_info_port = 9961 TOKEN_STRING_INITIALIZER(struct cmd_show_queue_region_info, 9962 port, "port"); 9963 cmdline_parse_token_num_t cmd_show_queue_region_info_port_index = 9964 TOKEN_NUM_INITIALIZER(struct cmd_show_queue_region_info, 9965 port_id, UINT16); 9966 cmdline_parse_token_string_t cmd_show_queue_region_info_cmd = 9967 TOKEN_STRING_INITIALIZER(struct cmd_show_queue_region_info, 9968 cmd, "queue-region"); 9969 9970 cmdline_parse_inst_t cmd_show_queue_region_info_all = { 9971 .f = cmd_show_queue_region_info_parsed, 9972 .data = NULL, 9973 .help_str = "show port <port_id> queue-region" 9974 ": show all queue region related configuration info", 9975 .tokens = { 9976 (void *)&cmd_show_queue_region_info_get, 9977 (void *)&cmd_show_queue_region_info_port, 9978 (void *)&cmd_show_queue_region_info_port_index, 9979 (void *)&cmd_show_queue_region_info_cmd, 9980 NULL, 9981 }, 9982 }; 9983 9984 /* *** ADD/REMOVE A 2tuple FILTER *** */ 9985 struct cmd_2tuple_filter_result { 9986 cmdline_fixed_string_t filter; 9987 portid_t port_id; 9988 cmdline_fixed_string_t ops; 9989 cmdline_fixed_string_t dst_port; 9990 uint16_t dst_port_value; 9991 cmdline_fixed_string_t protocol; 9992 uint8_t protocol_value; 9993 cmdline_fixed_string_t mask; 9994 uint8_t mask_value; 9995 cmdline_fixed_string_t tcp_flags; 9996 uint8_t tcp_flags_value; 9997 cmdline_fixed_string_t priority; 9998 uint8_t priority_value; 9999 cmdline_fixed_string_t queue; 10000 uint16_t queue_id; 10001 }; 10002 10003 static void 10004 cmd_2tuple_filter_parsed(void *parsed_result, 10005 __attribute__((unused)) struct cmdline *cl, 10006 __attribute__((unused)) void *data) 10007 { 10008 struct rte_eth_ntuple_filter filter; 10009 struct cmd_2tuple_filter_result *res = parsed_result; 10010 int ret = 0; 10011 10012 ret = rte_eth_dev_filter_supported(res->port_id, RTE_ETH_FILTER_NTUPLE); 10013 if (ret < 0) { 10014 printf("ntuple filter is not supported on port %u.\n", 10015 res->port_id); 10016 return; 10017 } 10018 10019 memset(&filter, 0, sizeof(struct rte_eth_ntuple_filter)); 10020 10021 filter.flags = RTE_2TUPLE_FLAGS; 10022 filter.dst_port_mask = (res->mask_value & 0x02) ? UINT16_MAX : 0; 10023 filter.proto_mask = (res->mask_value & 0x01) ? UINT8_MAX : 0; 10024 filter.proto = res->protocol_value; 10025 filter.priority = res->priority_value; 10026 if (res->tcp_flags_value != 0 && filter.proto != IPPROTO_TCP) { 10027 printf("nonzero tcp_flags is only meaningful" 10028 " when protocol is TCP.\n"); 10029 return; 10030 } 10031 if (res->tcp_flags_value > TCP_FLAG_ALL) { 10032 printf("invalid TCP flags.\n"); 10033 return; 10034 } 10035 10036 if (res->tcp_flags_value != 0) { 10037 filter.flags |= RTE_NTUPLE_FLAGS_TCP_FLAG; 10038 filter.tcp_flags = res->tcp_flags_value; 10039 } 10040 10041 /* need convert to big endian. */ 10042 filter.dst_port = rte_cpu_to_be_16(res->dst_port_value); 10043 filter.queue = res->queue_id; 10044 10045 if (!strcmp(res->ops, "add")) 10046 ret = rte_eth_dev_filter_ctrl(res->port_id, 10047 RTE_ETH_FILTER_NTUPLE, 10048 RTE_ETH_FILTER_ADD, 10049 &filter); 10050 else 10051 ret = rte_eth_dev_filter_ctrl(res->port_id, 10052 RTE_ETH_FILTER_NTUPLE, 10053 RTE_ETH_FILTER_DELETE, 10054 &filter); 10055 if (ret < 0) 10056 printf("2tuple filter programming error: (%s)\n", 10057 strerror(-ret)); 10058 10059 } 10060 10061 cmdline_parse_token_string_t cmd_2tuple_filter_filter = 10062 TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result, 10063 filter, "2tuple_filter"); 10064 cmdline_parse_token_num_t cmd_2tuple_filter_port_id = 10065 TOKEN_NUM_INITIALIZER(struct cmd_2tuple_filter_result, 10066 port_id, UINT16); 10067 cmdline_parse_token_string_t cmd_2tuple_filter_ops = 10068 TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result, 10069 ops, "add#del"); 10070 cmdline_parse_token_string_t cmd_2tuple_filter_dst_port = 10071 TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result, 10072 dst_port, "dst_port"); 10073 cmdline_parse_token_num_t cmd_2tuple_filter_dst_port_value = 10074 TOKEN_NUM_INITIALIZER(struct cmd_2tuple_filter_result, 10075 dst_port_value, UINT16); 10076 cmdline_parse_token_string_t cmd_2tuple_filter_protocol = 10077 TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result, 10078 protocol, "protocol"); 10079 cmdline_parse_token_num_t cmd_2tuple_filter_protocol_value = 10080 TOKEN_NUM_INITIALIZER(struct cmd_2tuple_filter_result, 10081 protocol_value, UINT8); 10082 cmdline_parse_token_string_t cmd_2tuple_filter_mask = 10083 TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result, 10084 mask, "mask"); 10085 cmdline_parse_token_num_t cmd_2tuple_filter_mask_value = 10086 TOKEN_NUM_INITIALIZER(struct cmd_2tuple_filter_result, 10087 mask_value, INT8); 10088 cmdline_parse_token_string_t cmd_2tuple_filter_tcp_flags = 10089 TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result, 10090 tcp_flags, "tcp_flags"); 10091 cmdline_parse_token_num_t cmd_2tuple_filter_tcp_flags_value = 10092 TOKEN_NUM_INITIALIZER(struct cmd_2tuple_filter_result, 10093 tcp_flags_value, UINT8); 10094 cmdline_parse_token_string_t cmd_2tuple_filter_priority = 10095 TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result, 10096 priority, "priority"); 10097 cmdline_parse_token_num_t cmd_2tuple_filter_priority_value = 10098 TOKEN_NUM_INITIALIZER(struct cmd_2tuple_filter_result, 10099 priority_value, UINT8); 10100 cmdline_parse_token_string_t cmd_2tuple_filter_queue = 10101 TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result, 10102 queue, "queue"); 10103 cmdline_parse_token_num_t cmd_2tuple_filter_queue_id = 10104 TOKEN_NUM_INITIALIZER(struct cmd_2tuple_filter_result, 10105 queue_id, UINT16); 10106 10107 cmdline_parse_inst_t cmd_2tuple_filter = { 10108 .f = cmd_2tuple_filter_parsed, 10109 .data = NULL, 10110 .help_str = "2tuple_filter <port_id> add|del dst_port <value> protocol " 10111 "<value> mask <value> tcp_flags <value> priority <value> queue " 10112 "<queue_id>: Add a 2tuple filter", 10113 .tokens = { 10114 (void *)&cmd_2tuple_filter_filter, 10115 (void *)&cmd_2tuple_filter_port_id, 10116 (void *)&cmd_2tuple_filter_ops, 10117 (void *)&cmd_2tuple_filter_dst_port, 10118 (void *)&cmd_2tuple_filter_dst_port_value, 10119 (void *)&cmd_2tuple_filter_protocol, 10120 (void *)&cmd_2tuple_filter_protocol_value, 10121 (void *)&cmd_2tuple_filter_mask, 10122 (void *)&cmd_2tuple_filter_mask_value, 10123 (void *)&cmd_2tuple_filter_tcp_flags, 10124 (void *)&cmd_2tuple_filter_tcp_flags_value, 10125 (void *)&cmd_2tuple_filter_priority, 10126 (void *)&cmd_2tuple_filter_priority_value, 10127 (void *)&cmd_2tuple_filter_queue, 10128 (void *)&cmd_2tuple_filter_queue_id, 10129 NULL, 10130 }, 10131 }; 10132 10133 /* *** ADD/REMOVE A 5tuple FILTER *** */ 10134 struct cmd_5tuple_filter_result { 10135 cmdline_fixed_string_t filter; 10136 portid_t port_id; 10137 cmdline_fixed_string_t ops; 10138 cmdline_fixed_string_t dst_ip; 10139 cmdline_ipaddr_t dst_ip_value; 10140 cmdline_fixed_string_t src_ip; 10141 cmdline_ipaddr_t src_ip_value; 10142 cmdline_fixed_string_t dst_port; 10143 uint16_t dst_port_value; 10144 cmdline_fixed_string_t src_port; 10145 uint16_t src_port_value; 10146 cmdline_fixed_string_t protocol; 10147 uint8_t protocol_value; 10148 cmdline_fixed_string_t mask; 10149 uint8_t mask_value; 10150 cmdline_fixed_string_t tcp_flags; 10151 uint8_t tcp_flags_value; 10152 cmdline_fixed_string_t priority; 10153 uint8_t priority_value; 10154 cmdline_fixed_string_t queue; 10155 uint16_t queue_id; 10156 }; 10157 10158 static void 10159 cmd_5tuple_filter_parsed(void *parsed_result, 10160 __attribute__((unused)) struct cmdline *cl, 10161 __attribute__((unused)) void *data) 10162 { 10163 struct rte_eth_ntuple_filter filter; 10164 struct cmd_5tuple_filter_result *res = parsed_result; 10165 int ret = 0; 10166 10167 ret = rte_eth_dev_filter_supported(res->port_id, RTE_ETH_FILTER_NTUPLE); 10168 if (ret < 0) { 10169 printf("ntuple filter is not supported on port %u.\n", 10170 res->port_id); 10171 return; 10172 } 10173 10174 memset(&filter, 0, sizeof(struct rte_eth_ntuple_filter)); 10175 10176 filter.flags = RTE_5TUPLE_FLAGS; 10177 filter.dst_ip_mask = (res->mask_value & 0x10) ? UINT32_MAX : 0; 10178 filter.src_ip_mask = (res->mask_value & 0x08) ? UINT32_MAX : 0; 10179 filter.dst_port_mask = (res->mask_value & 0x04) ? UINT16_MAX : 0; 10180 filter.src_port_mask = (res->mask_value & 0x02) ? UINT16_MAX : 0; 10181 filter.proto_mask = (res->mask_value & 0x01) ? UINT8_MAX : 0; 10182 filter.proto = res->protocol_value; 10183 filter.priority = res->priority_value; 10184 if (res->tcp_flags_value != 0 && filter.proto != IPPROTO_TCP) { 10185 printf("nonzero tcp_flags is only meaningful" 10186 " when protocol is TCP.\n"); 10187 return; 10188 } 10189 if (res->tcp_flags_value > TCP_FLAG_ALL) { 10190 printf("invalid TCP flags.\n"); 10191 return; 10192 } 10193 10194 if (res->tcp_flags_value != 0) { 10195 filter.flags |= RTE_NTUPLE_FLAGS_TCP_FLAG; 10196 filter.tcp_flags = res->tcp_flags_value; 10197 } 10198 10199 if (res->dst_ip_value.family == AF_INET) 10200 /* no need to convert, already big endian. */ 10201 filter.dst_ip = res->dst_ip_value.addr.ipv4.s_addr; 10202 else { 10203 if (filter.dst_ip_mask == 0) { 10204 printf("can not support ipv6 involved compare.\n"); 10205 return; 10206 } 10207 filter.dst_ip = 0; 10208 } 10209 10210 if (res->src_ip_value.family == AF_INET) 10211 /* no need to convert, already big endian. */ 10212 filter.src_ip = res->src_ip_value.addr.ipv4.s_addr; 10213 else { 10214 if (filter.src_ip_mask == 0) { 10215 printf("can not support ipv6 involved compare.\n"); 10216 return; 10217 } 10218 filter.src_ip = 0; 10219 } 10220 /* need convert to big endian. */ 10221 filter.dst_port = rte_cpu_to_be_16(res->dst_port_value); 10222 filter.src_port = rte_cpu_to_be_16(res->src_port_value); 10223 filter.queue = res->queue_id; 10224 10225 if (!strcmp(res->ops, "add")) 10226 ret = rte_eth_dev_filter_ctrl(res->port_id, 10227 RTE_ETH_FILTER_NTUPLE, 10228 RTE_ETH_FILTER_ADD, 10229 &filter); 10230 else 10231 ret = rte_eth_dev_filter_ctrl(res->port_id, 10232 RTE_ETH_FILTER_NTUPLE, 10233 RTE_ETH_FILTER_DELETE, 10234 &filter); 10235 if (ret < 0) 10236 printf("5tuple filter programming error: (%s)\n", 10237 strerror(-ret)); 10238 } 10239 10240 cmdline_parse_token_string_t cmd_5tuple_filter_filter = 10241 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result, 10242 filter, "5tuple_filter"); 10243 cmdline_parse_token_num_t cmd_5tuple_filter_port_id = 10244 TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result, 10245 port_id, UINT16); 10246 cmdline_parse_token_string_t cmd_5tuple_filter_ops = 10247 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result, 10248 ops, "add#del"); 10249 cmdline_parse_token_string_t cmd_5tuple_filter_dst_ip = 10250 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result, 10251 dst_ip, "dst_ip"); 10252 cmdline_parse_token_ipaddr_t cmd_5tuple_filter_dst_ip_value = 10253 TOKEN_IPADDR_INITIALIZER(struct cmd_5tuple_filter_result, 10254 dst_ip_value); 10255 cmdline_parse_token_string_t cmd_5tuple_filter_src_ip = 10256 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result, 10257 src_ip, "src_ip"); 10258 cmdline_parse_token_ipaddr_t cmd_5tuple_filter_src_ip_value = 10259 TOKEN_IPADDR_INITIALIZER(struct cmd_5tuple_filter_result, 10260 src_ip_value); 10261 cmdline_parse_token_string_t cmd_5tuple_filter_dst_port = 10262 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result, 10263 dst_port, "dst_port"); 10264 cmdline_parse_token_num_t cmd_5tuple_filter_dst_port_value = 10265 TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result, 10266 dst_port_value, UINT16); 10267 cmdline_parse_token_string_t cmd_5tuple_filter_src_port = 10268 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result, 10269 src_port, "src_port"); 10270 cmdline_parse_token_num_t cmd_5tuple_filter_src_port_value = 10271 TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result, 10272 src_port_value, UINT16); 10273 cmdline_parse_token_string_t cmd_5tuple_filter_protocol = 10274 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result, 10275 protocol, "protocol"); 10276 cmdline_parse_token_num_t cmd_5tuple_filter_protocol_value = 10277 TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result, 10278 protocol_value, UINT8); 10279 cmdline_parse_token_string_t cmd_5tuple_filter_mask = 10280 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result, 10281 mask, "mask"); 10282 cmdline_parse_token_num_t cmd_5tuple_filter_mask_value = 10283 TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result, 10284 mask_value, INT8); 10285 cmdline_parse_token_string_t cmd_5tuple_filter_tcp_flags = 10286 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result, 10287 tcp_flags, "tcp_flags"); 10288 cmdline_parse_token_num_t cmd_5tuple_filter_tcp_flags_value = 10289 TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result, 10290 tcp_flags_value, UINT8); 10291 cmdline_parse_token_string_t cmd_5tuple_filter_priority = 10292 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result, 10293 priority, "priority"); 10294 cmdline_parse_token_num_t cmd_5tuple_filter_priority_value = 10295 TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result, 10296 priority_value, UINT8); 10297 cmdline_parse_token_string_t cmd_5tuple_filter_queue = 10298 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result, 10299 queue, "queue"); 10300 cmdline_parse_token_num_t cmd_5tuple_filter_queue_id = 10301 TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result, 10302 queue_id, UINT16); 10303 10304 cmdline_parse_inst_t cmd_5tuple_filter = { 10305 .f = cmd_5tuple_filter_parsed, 10306 .data = NULL, 10307 .help_str = "5tuple_filter <port_id> add|del dst_ip <value> " 10308 "src_ip <value> dst_port <value> src_port <value> " 10309 "protocol <value> mask <value> tcp_flags <value> " 10310 "priority <value> queue <queue_id>: Add/Del a 5tuple filter", 10311 .tokens = { 10312 (void *)&cmd_5tuple_filter_filter, 10313 (void *)&cmd_5tuple_filter_port_id, 10314 (void *)&cmd_5tuple_filter_ops, 10315 (void *)&cmd_5tuple_filter_dst_ip, 10316 (void *)&cmd_5tuple_filter_dst_ip_value, 10317 (void *)&cmd_5tuple_filter_src_ip, 10318 (void *)&cmd_5tuple_filter_src_ip_value, 10319 (void *)&cmd_5tuple_filter_dst_port, 10320 (void *)&cmd_5tuple_filter_dst_port_value, 10321 (void *)&cmd_5tuple_filter_src_port, 10322 (void *)&cmd_5tuple_filter_src_port_value, 10323 (void *)&cmd_5tuple_filter_protocol, 10324 (void *)&cmd_5tuple_filter_protocol_value, 10325 (void *)&cmd_5tuple_filter_mask, 10326 (void *)&cmd_5tuple_filter_mask_value, 10327 (void *)&cmd_5tuple_filter_tcp_flags, 10328 (void *)&cmd_5tuple_filter_tcp_flags_value, 10329 (void *)&cmd_5tuple_filter_priority, 10330 (void *)&cmd_5tuple_filter_priority_value, 10331 (void *)&cmd_5tuple_filter_queue, 10332 (void *)&cmd_5tuple_filter_queue_id, 10333 NULL, 10334 }, 10335 }; 10336 10337 /* *** ADD/REMOVE A flex FILTER *** */ 10338 struct cmd_flex_filter_result { 10339 cmdline_fixed_string_t filter; 10340 cmdline_fixed_string_t ops; 10341 portid_t port_id; 10342 cmdline_fixed_string_t len; 10343 uint8_t len_value; 10344 cmdline_fixed_string_t bytes; 10345 cmdline_fixed_string_t bytes_value; 10346 cmdline_fixed_string_t mask; 10347 cmdline_fixed_string_t mask_value; 10348 cmdline_fixed_string_t priority; 10349 uint8_t priority_value; 10350 cmdline_fixed_string_t queue; 10351 uint16_t queue_id; 10352 }; 10353 10354 static int xdigit2val(unsigned char c) 10355 { 10356 int val; 10357 if (isdigit(c)) 10358 val = c - '0'; 10359 else if (isupper(c)) 10360 val = c - 'A' + 10; 10361 else 10362 val = c - 'a' + 10; 10363 return val; 10364 } 10365 10366 static void 10367 cmd_flex_filter_parsed(void *parsed_result, 10368 __attribute__((unused)) struct cmdline *cl, 10369 __attribute__((unused)) void *data) 10370 { 10371 int ret = 0; 10372 struct rte_eth_flex_filter filter; 10373 struct cmd_flex_filter_result *res = parsed_result; 10374 char *bytes_ptr, *mask_ptr; 10375 uint16_t len, i, j = 0; 10376 char c; 10377 int val; 10378 uint8_t byte = 0; 10379 10380 if (res->len_value > RTE_FLEX_FILTER_MAXLEN) { 10381 printf("the len exceed the max length 128\n"); 10382 return; 10383 } 10384 memset(&filter, 0, sizeof(struct rte_eth_flex_filter)); 10385 filter.len = res->len_value; 10386 filter.priority = res->priority_value; 10387 filter.queue = res->queue_id; 10388 bytes_ptr = res->bytes_value; 10389 mask_ptr = res->mask_value; 10390 10391 /* translate bytes string to array. */ 10392 if (bytes_ptr[0] == '0' && ((bytes_ptr[1] == 'x') || 10393 (bytes_ptr[1] == 'X'))) 10394 bytes_ptr += 2; 10395 len = strnlen(bytes_ptr, res->len_value * 2); 10396 if (len == 0 || (len % 8 != 0)) { 10397 printf("please check len and bytes input\n"); 10398 return; 10399 } 10400 for (i = 0; i < len; i++) { 10401 c = bytes_ptr[i]; 10402 if (isxdigit(c) == 0) { 10403 /* invalid characters. */ 10404 printf("invalid input\n"); 10405 return; 10406 } 10407 val = xdigit2val(c); 10408 if (i % 2) { 10409 byte |= val; 10410 filter.bytes[j] = byte; 10411 printf("bytes[%d]:%02x ", j, filter.bytes[j]); 10412 j++; 10413 byte = 0; 10414 } else 10415 byte |= val << 4; 10416 } 10417 printf("\n"); 10418 /* translate mask string to uint8_t array. */ 10419 if (mask_ptr[0] == '0' && ((mask_ptr[1] == 'x') || 10420 (mask_ptr[1] == 'X'))) 10421 mask_ptr += 2; 10422 len = strnlen(mask_ptr, (res->len_value + 3) / 4); 10423 if (len == 0) { 10424 printf("invalid input\n"); 10425 return; 10426 } 10427 j = 0; 10428 byte = 0; 10429 for (i = 0; i < len; i++) { 10430 c = mask_ptr[i]; 10431 if (isxdigit(c) == 0) { 10432 /* invalid characters. */ 10433 printf("invalid input\n"); 10434 return; 10435 } 10436 val = xdigit2val(c); 10437 if (i % 2) { 10438 byte |= val; 10439 filter.mask[j] = byte; 10440 printf("mask[%d]:%02x ", j, filter.mask[j]); 10441 j++; 10442 byte = 0; 10443 } else 10444 byte |= val << 4; 10445 } 10446 printf("\n"); 10447 10448 if (!strcmp(res->ops, "add")) 10449 ret = rte_eth_dev_filter_ctrl(res->port_id, 10450 RTE_ETH_FILTER_FLEXIBLE, 10451 RTE_ETH_FILTER_ADD, 10452 &filter); 10453 else 10454 ret = rte_eth_dev_filter_ctrl(res->port_id, 10455 RTE_ETH_FILTER_FLEXIBLE, 10456 RTE_ETH_FILTER_DELETE, 10457 &filter); 10458 10459 if (ret < 0) 10460 printf("flex filter setting error: (%s)\n", strerror(-ret)); 10461 } 10462 10463 cmdline_parse_token_string_t cmd_flex_filter_filter = 10464 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result, 10465 filter, "flex_filter"); 10466 cmdline_parse_token_num_t cmd_flex_filter_port_id = 10467 TOKEN_NUM_INITIALIZER(struct cmd_flex_filter_result, 10468 port_id, UINT16); 10469 cmdline_parse_token_string_t cmd_flex_filter_ops = 10470 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result, 10471 ops, "add#del"); 10472 cmdline_parse_token_string_t cmd_flex_filter_len = 10473 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result, 10474 len, "len"); 10475 cmdline_parse_token_num_t cmd_flex_filter_len_value = 10476 TOKEN_NUM_INITIALIZER(struct cmd_flex_filter_result, 10477 len_value, UINT8); 10478 cmdline_parse_token_string_t cmd_flex_filter_bytes = 10479 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result, 10480 bytes, "bytes"); 10481 cmdline_parse_token_string_t cmd_flex_filter_bytes_value = 10482 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result, 10483 bytes_value, NULL); 10484 cmdline_parse_token_string_t cmd_flex_filter_mask = 10485 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result, 10486 mask, "mask"); 10487 cmdline_parse_token_string_t cmd_flex_filter_mask_value = 10488 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result, 10489 mask_value, NULL); 10490 cmdline_parse_token_string_t cmd_flex_filter_priority = 10491 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result, 10492 priority, "priority"); 10493 cmdline_parse_token_num_t cmd_flex_filter_priority_value = 10494 TOKEN_NUM_INITIALIZER(struct cmd_flex_filter_result, 10495 priority_value, UINT8); 10496 cmdline_parse_token_string_t cmd_flex_filter_queue = 10497 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result, 10498 queue, "queue"); 10499 cmdline_parse_token_num_t cmd_flex_filter_queue_id = 10500 TOKEN_NUM_INITIALIZER(struct cmd_flex_filter_result, 10501 queue_id, UINT16); 10502 cmdline_parse_inst_t cmd_flex_filter = { 10503 .f = cmd_flex_filter_parsed, 10504 .data = NULL, 10505 .help_str = "flex_filter <port_id> add|del len <value> bytes " 10506 "<value> mask <value> priority <value> queue <queue_id>: " 10507 "Add/Del a flex filter", 10508 .tokens = { 10509 (void *)&cmd_flex_filter_filter, 10510 (void *)&cmd_flex_filter_port_id, 10511 (void *)&cmd_flex_filter_ops, 10512 (void *)&cmd_flex_filter_len, 10513 (void *)&cmd_flex_filter_len_value, 10514 (void *)&cmd_flex_filter_bytes, 10515 (void *)&cmd_flex_filter_bytes_value, 10516 (void *)&cmd_flex_filter_mask, 10517 (void *)&cmd_flex_filter_mask_value, 10518 (void *)&cmd_flex_filter_priority, 10519 (void *)&cmd_flex_filter_priority_value, 10520 (void *)&cmd_flex_filter_queue, 10521 (void *)&cmd_flex_filter_queue_id, 10522 NULL, 10523 }, 10524 }; 10525 10526 /* *** Filters Control *** */ 10527 10528 /* *** deal with ethertype filter *** */ 10529 struct cmd_ethertype_filter_result { 10530 cmdline_fixed_string_t filter; 10531 portid_t port_id; 10532 cmdline_fixed_string_t ops; 10533 cmdline_fixed_string_t mac; 10534 struct ether_addr mac_addr; 10535 cmdline_fixed_string_t ethertype; 10536 uint16_t ethertype_value; 10537 cmdline_fixed_string_t drop; 10538 cmdline_fixed_string_t queue; 10539 uint16_t queue_id; 10540 }; 10541 10542 cmdline_parse_token_string_t cmd_ethertype_filter_filter = 10543 TOKEN_STRING_INITIALIZER(struct cmd_ethertype_filter_result, 10544 filter, "ethertype_filter"); 10545 cmdline_parse_token_num_t cmd_ethertype_filter_port_id = 10546 TOKEN_NUM_INITIALIZER(struct cmd_ethertype_filter_result, 10547 port_id, UINT16); 10548 cmdline_parse_token_string_t cmd_ethertype_filter_ops = 10549 TOKEN_STRING_INITIALIZER(struct cmd_ethertype_filter_result, 10550 ops, "add#del"); 10551 cmdline_parse_token_string_t cmd_ethertype_filter_mac = 10552 TOKEN_STRING_INITIALIZER(struct cmd_ethertype_filter_result, 10553 mac, "mac_addr#mac_ignr"); 10554 cmdline_parse_token_etheraddr_t cmd_ethertype_filter_mac_addr = 10555 TOKEN_ETHERADDR_INITIALIZER(struct cmd_ethertype_filter_result, 10556 mac_addr); 10557 cmdline_parse_token_string_t cmd_ethertype_filter_ethertype = 10558 TOKEN_STRING_INITIALIZER(struct cmd_ethertype_filter_result, 10559 ethertype, "ethertype"); 10560 cmdline_parse_token_num_t cmd_ethertype_filter_ethertype_value = 10561 TOKEN_NUM_INITIALIZER(struct cmd_ethertype_filter_result, 10562 ethertype_value, UINT16); 10563 cmdline_parse_token_string_t cmd_ethertype_filter_drop = 10564 TOKEN_STRING_INITIALIZER(struct cmd_ethertype_filter_result, 10565 drop, "drop#fwd"); 10566 cmdline_parse_token_string_t cmd_ethertype_filter_queue = 10567 TOKEN_STRING_INITIALIZER(struct cmd_ethertype_filter_result, 10568 queue, "queue"); 10569 cmdline_parse_token_num_t cmd_ethertype_filter_queue_id = 10570 TOKEN_NUM_INITIALIZER(struct cmd_ethertype_filter_result, 10571 queue_id, UINT16); 10572 10573 static void 10574 cmd_ethertype_filter_parsed(void *parsed_result, 10575 __attribute__((unused)) struct cmdline *cl, 10576 __attribute__((unused)) void *data) 10577 { 10578 struct cmd_ethertype_filter_result *res = parsed_result; 10579 struct rte_eth_ethertype_filter filter; 10580 int ret = 0; 10581 10582 ret = rte_eth_dev_filter_supported(res->port_id, 10583 RTE_ETH_FILTER_ETHERTYPE); 10584 if (ret < 0) { 10585 printf("ethertype filter is not supported on port %u.\n", 10586 res->port_id); 10587 return; 10588 } 10589 10590 memset(&filter, 0, sizeof(filter)); 10591 if (!strcmp(res->mac, "mac_addr")) { 10592 filter.flags |= RTE_ETHTYPE_FLAGS_MAC; 10593 rte_memcpy(&filter.mac_addr, &res->mac_addr, 10594 sizeof(struct ether_addr)); 10595 } 10596 if (!strcmp(res->drop, "drop")) 10597 filter.flags |= RTE_ETHTYPE_FLAGS_DROP; 10598 filter.ether_type = res->ethertype_value; 10599 filter.queue = res->queue_id; 10600 10601 if (!strcmp(res->ops, "add")) 10602 ret = rte_eth_dev_filter_ctrl(res->port_id, 10603 RTE_ETH_FILTER_ETHERTYPE, 10604 RTE_ETH_FILTER_ADD, 10605 &filter); 10606 else 10607 ret = rte_eth_dev_filter_ctrl(res->port_id, 10608 RTE_ETH_FILTER_ETHERTYPE, 10609 RTE_ETH_FILTER_DELETE, 10610 &filter); 10611 if (ret < 0) 10612 printf("ethertype filter programming error: (%s)\n", 10613 strerror(-ret)); 10614 } 10615 10616 cmdline_parse_inst_t cmd_ethertype_filter = { 10617 .f = cmd_ethertype_filter_parsed, 10618 .data = NULL, 10619 .help_str = "ethertype_filter <port_id> add|del mac_addr|mac_ignr " 10620 "<mac_addr> ethertype <value> drop|fw queue <queue_id>: " 10621 "Add or delete an ethertype filter entry", 10622 .tokens = { 10623 (void *)&cmd_ethertype_filter_filter, 10624 (void *)&cmd_ethertype_filter_port_id, 10625 (void *)&cmd_ethertype_filter_ops, 10626 (void *)&cmd_ethertype_filter_mac, 10627 (void *)&cmd_ethertype_filter_mac_addr, 10628 (void *)&cmd_ethertype_filter_ethertype, 10629 (void *)&cmd_ethertype_filter_ethertype_value, 10630 (void *)&cmd_ethertype_filter_drop, 10631 (void *)&cmd_ethertype_filter_queue, 10632 (void *)&cmd_ethertype_filter_queue_id, 10633 NULL, 10634 }, 10635 }; 10636 10637 /* *** deal with flow director filter *** */ 10638 struct cmd_flow_director_result { 10639 cmdline_fixed_string_t flow_director_filter; 10640 portid_t port_id; 10641 cmdline_fixed_string_t mode; 10642 cmdline_fixed_string_t mode_value; 10643 cmdline_fixed_string_t ops; 10644 cmdline_fixed_string_t flow; 10645 cmdline_fixed_string_t flow_type; 10646 cmdline_fixed_string_t ether; 10647 uint16_t ether_type; 10648 cmdline_fixed_string_t src; 10649 cmdline_ipaddr_t ip_src; 10650 uint16_t port_src; 10651 cmdline_fixed_string_t dst; 10652 cmdline_ipaddr_t ip_dst; 10653 uint16_t port_dst; 10654 cmdline_fixed_string_t verify_tag; 10655 uint32_t verify_tag_value; 10656 cmdline_fixed_string_t tos; 10657 uint8_t tos_value; 10658 cmdline_fixed_string_t proto; 10659 uint8_t proto_value; 10660 cmdline_fixed_string_t ttl; 10661 uint8_t ttl_value; 10662 cmdline_fixed_string_t vlan; 10663 uint16_t vlan_value; 10664 cmdline_fixed_string_t flexbytes; 10665 cmdline_fixed_string_t flexbytes_value; 10666 cmdline_fixed_string_t pf_vf; 10667 cmdline_fixed_string_t drop; 10668 cmdline_fixed_string_t queue; 10669 uint16_t queue_id; 10670 cmdline_fixed_string_t fd_id; 10671 uint32_t fd_id_value; 10672 cmdline_fixed_string_t mac; 10673 struct ether_addr mac_addr; 10674 cmdline_fixed_string_t tunnel; 10675 cmdline_fixed_string_t tunnel_type; 10676 cmdline_fixed_string_t tunnel_id; 10677 uint32_t tunnel_id_value; 10678 cmdline_fixed_string_t packet; 10679 char filepath[]; 10680 }; 10681 10682 static inline int 10683 parse_flexbytes(const char *q_arg, uint8_t *flexbytes, uint16_t max_num) 10684 { 10685 char s[256]; 10686 const char *p, *p0 = q_arg; 10687 char *end; 10688 unsigned long int_fld; 10689 char *str_fld[max_num]; 10690 int i; 10691 unsigned size; 10692 int ret = -1; 10693 10694 p = strchr(p0, '('); 10695 if (p == NULL) 10696 return -1; 10697 ++p; 10698 p0 = strchr(p, ')'); 10699 if (p0 == NULL) 10700 return -1; 10701 10702 size = p0 - p; 10703 if (size >= sizeof(s)) 10704 return -1; 10705 10706 snprintf(s, sizeof(s), "%.*s", size, p); 10707 ret = rte_strsplit(s, sizeof(s), str_fld, max_num, ','); 10708 if (ret < 0 || ret > max_num) 10709 return -1; 10710 for (i = 0; i < ret; i++) { 10711 errno = 0; 10712 int_fld = strtoul(str_fld[i], &end, 0); 10713 if (errno != 0 || *end != '\0' || int_fld > UINT8_MAX) 10714 return -1; 10715 flexbytes[i] = (uint8_t)int_fld; 10716 } 10717 return ret; 10718 } 10719 10720 static uint16_t 10721 str2flowtype(char *string) 10722 { 10723 uint8_t i = 0; 10724 static const struct { 10725 char str[32]; 10726 uint16_t type; 10727 } flowtype_str[] = { 10728 {"raw", RTE_ETH_FLOW_RAW}, 10729 {"ipv4", RTE_ETH_FLOW_IPV4}, 10730 {"ipv4-frag", RTE_ETH_FLOW_FRAG_IPV4}, 10731 {"ipv4-tcp", RTE_ETH_FLOW_NONFRAG_IPV4_TCP}, 10732 {"ipv4-udp", RTE_ETH_FLOW_NONFRAG_IPV4_UDP}, 10733 {"ipv4-sctp", RTE_ETH_FLOW_NONFRAG_IPV4_SCTP}, 10734 {"ipv4-other", RTE_ETH_FLOW_NONFRAG_IPV4_OTHER}, 10735 {"ipv6", RTE_ETH_FLOW_IPV6}, 10736 {"ipv6-frag", RTE_ETH_FLOW_FRAG_IPV6}, 10737 {"ipv6-tcp", RTE_ETH_FLOW_NONFRAG_IPV6_TCP}, 10738 {"ipv6-udp", RTE_ETH_FLOW_NONFRAG_IPV6_UDP}, 10739 {"ipv6-sctp", RTE_ETH_FLOW_NONFRAG_IPV6_SCTP}, 10740 {"ipv6-other", RTE_ETH_FLOW_NONFRAG_IPV6_OTHER}, 10741 {"l2_payload", RTE_ETH_FLOW_L2_PAYLOAD}, 10742 }; 10743 10744 for (i = 0; i < RTE_DIM(flowtype_str); i++) { 10745 if (!strcmp(flowtype_str[i].str, string)) 10746 return flowtype_str[i].type; 10747 } 10748 10749 if (isdigit(string[0]) && atoi(string) > 0 && atoi(string) < 64) 10750 return (uint16_t)atoi(string); 10751 10752 return RTE_ETH_FLOW_UNKNOWN; 10753 } 10754 10755 static enum rte_eth_fdir_tunnel_type 10756 str2fdir_tunneltype(char *string) 10757 { 10758 uint8_t i = 0; 10759 10760 static const struct { 10761 char str[32]; 10762 enum rte_eth_fdir_tunnel_type type; 10763 } tunneltype_str[] = { 10764 {"NVGRE", RTE_FDIR_TUNNEL_TYPE_NVGRE}, 10765 {"VxLAN", RTE_FDIR_TUNNEL_TYPE_VXLAN}, 10766 }; 10767 10768 for (i = 0; i < RTE_DIM(tunneltype_str); i++) { 10769 if (!strcmp(tunneltype_str[i].str, string)) 10770 return tunneltype_str[i].type; 10771 } 10772 return RTE_FDIR_TUNNEL_TYPE_UNKNOWN; 10773 } 10774 10775 #define IPV4_ADDR_TO_UINT(ip_addr, ip) \ 10776 do { \ 10777 if ((ip_addr).family == AF_INET) \ 10778 (ip) = (ip_addr).addr.ipv4.s_addr; \ 10779 else { \ 10780 printf("invalid parameter.\n"); \ 10781 return; \ 10782 } \ 10783 } while (0) 10784 10785 #define IPV6_ADDR_TO_ARRAY(ip_addr, ip) \ 10786 do { \ 10787 if ((ip_addr).family == AF_INET6) \ 10788 rte_memcpy(&(ip), \ 10789 &((ip_addr).addr.ipv6), \ 10790 sizeof(struct in6_addr)); \ 10791 else { \ 10792 printf("invalid parameter.\n"); \ 10793 return; \ 10794 } \ 10795 } while (0) 10796 10797 static void 10798 cmd_flow_director_filter_parsed(void *parsed_result, 10799 __attribute__((unused)) struct cmdline *cl, 10800 __attribute__((unused)) void *data) 10801 { 10802 struct cmd_flow_director_result *res = parsed_result; 10803 struct rte_eth_fdir_filter entry; 10804 uint8_t flexbytes[RTE_ETH_FDIR_MAX_FLEXLEN]; 10805 char *end; 10806 unsigned long vf_id; 10807 int ret = 0; 10808 10809 ret = rte_eth_dev_filter_supported(res->port_id, RTE_ETH_FILTER_FDIR); 10810 if (ret < 0) { 10811 printf("flow director is not supported on port %u.\n", 10812 res->port_id); 10813 return; 10814 } 10815 memset(flexbytes, 0, sizeof(flexbytes)); 10816 memset(&entry, 0, sizeof(struct rte_eth_fdir_filter)); 10817 10818 if (fdir_conf.mode == RTE_FDIR_MODE_PERFECT_MAC_VLAN) { 10819 if (strcmp(res->mode_value, "MAC-VLAN")) { 10820 printf("Please set mode to MAC-VLAN.\n"); 10821 return; 10822 } 10823 } else if (fdir_conf.mode == RTE_FDIR_MODE_PERFECT_TUNNEL) { 10824 if (strcmp(res->mode_value, "Tunnel")) { 10825 printf("Please set mode to Tunnel.\n"); 10826 return; 10827 } 10828 } else { 10829 if (!strcmp(res->mode_value, "raw")) { 10830 #ifdef RTE_LIBRTE_I40E_PMD 10831 struct rte_pmd_i40e_flow_type_mapping 10832 mapping[RTE_PMD_I40E_FLOW_TYPE_MAX]; 10833 struct rte_pmd_i40e_pkt_template_conf conf; 10834 uint16_t flow_type = str2flowtype(res->flow_type); 10835 uint16_t i, port = res->port_id; 10836 uint8_t add; 10837 10838 memset(&conf, 0, sizeof(conf)); 10839 10840 if (flow_type == RTE_ETH_FLOW_UNKNOWN) { 10841 printf("Invalid flow type specified.\n"); 10842 return; 10843 } 10844 ret = rte_pmd_i40e_flow_type_mapping_get(res->port_id, 10845 mapping); 10846 if (ret) 10847 return; 10848 if (mapping[flow_type].pctype == 0ULL) { 10849 printf("Invalid flow type specified.\n"); 10850 return; 10851 } 10852 for (i = 0; i < RTE_PMD_I40E_PCTYPE_MAX; i++) { 10853 if (mapping[flow_type].pctype & (1ULL << i)) { 10854 conf.input.pctype = i; 10855 break; 10856 } 10857 } 10858 10859 conf.input.packet = open_file(res->filepath, 10860 &conf.input.length); 10861 if (!conf.input.packet) 10862 return; 10863 if (!strcmp(res->drop, "drop")) 10864 conf.action.behavior = 10865 RTE_PMD_I40E_PKT_TEMPLATE_REJECT; 10866 else 10867 conf.action.behavior = 10868 RTE_PMD_I40E_PKT_TEMPLATE_ACCEPT; 10869 conf.action.report_status = 10870 RTE_PMD_I40E_PKT_TEMPLATE_REPORT_ID; 10871 conf.action.rx_queue = res->queue_id; 10872 conf.soft_id = res->fd_id_value; 10873 add = strcmp(res->ops, "del") ? 1 : 0; 10874 ret = rte_pmd_i40e_flow_add_del_packet_template(port, 10875 &conf, 10876 add); 10877 if (ret < 0) 10878 printf("flow director config error: (%s)\n", 10879 strerror(-ret)); 10880 close_file(conf.input.packet); 10881 #endif 10882 return; 10883 } else if (strcmp(res->mode_value, "IP")) { 10884 printf("Please set mode to IP or raw.\n"); 10885 return; 10886 } 10887 entry.input.flow_type = str2flowtype(res->flow_type); 10888 } 10889 10890 ret = parse_flexbytes(res->flexbytes_value, 10891 flexbytes, 10892 RTE_ETH_FDIR_MAX_FLEXLEN); 10893 if (ret < 0) { 10894 printf("error: Cannot parse flexbytes input.\n"); 10895 return; 10896 } 10897 10898 switch (entry.input.flow_type) { 10899 case RTE_ETH_FLOW_FRAG_IPV4: 10900 case RTE_ETH_FLOW_NONFRAG_IPV4_OTHER: 10901 entry.input.flow.ip4_flow.proto = res->proto_value; 10902 /* fall-through */ 10903 case RTE_ETH_FLOW_NONFRAG_IPV4_UDP: 10904 case RTE_ETH_FLOW_NONFRAG_IPV4_TCP: 10905 IPV4_ADDR_TO_UINT(res->ip_dst, 10906 entry.input.flow.ip4_flow.dst_ip); 10907 IPV4_ADDR_TO_UINT(res->ip_src, 10908 entry.input.flow.ip4_flow.src_ip); 10909 entry.input.flow.ip4_flow.tos = res->tos_value; 10910 entry.input.flow.ip4_flow.ttl = res->ttl_value; 10911 /* need convert to big endian. */ 10912 entry.input.flow.udp4_flow.dst_port = 10913 rte_cpu_to_be_16(res->port_dst); 10914 entry.input.flow.udp4_flow.src_port = 10915 rte_cpu_to_be_16(res->port_src); 10916 break; 10917 case RTE_ETH_FLOW_NONFRAG_IPV4_SCTP: 10918 IPV4_ADDR_TO_UINT(res->ip_dst, 10919 entry.input.flow.sctp4_flow.ip.dst_ip); 10920 IPV4_ADDR_TO_UINT(res->ip_src, 10921 entry.input.flow.sctp4_flow.ip.src_ip); 10922 entry.input.flow.ip4_flow.tos = res->tos_value; 10923 entry.input.flow.ip4_flow.ttl = res->ttl_value; 10924 /* need convert to big endian. */ 10925 entry.input.flow.sctp4_flow.dst_port = 10926 rte_cpu_to_be_16(res->port_dst); 10927 entry.input.flow.sctp4_flow.src_port = 10928 rte_cpu_to_be_16(res->port_src); 10929 entry.input.flow.sctp4_flow.verify_tag = 10930 rte_cpu_to_be_32(res->verify_tag_value); 10931 break; 10932 case RTE_ETH_FLOW_FRAG_IPV6: 10933 case RTE_ETH_FLOW_NONFRAG_IPV6_OTHER: 10934 entry.input.flow.ipv6_flow.proto = res->proto_value; 10935 /* fall-through */ 10936 case RTE_ETH_FLOW_NONFRAG_IPV6_UDP: 10937 case RTE_ETH_FLOW_NONFRAG_IPV6_TCP: 10938 IPV6_ADDR_TO_ARRAY(res->ip_dst, 10939 entry.input.flow.ipv6_flow.dst_ip); 10940 IPV6_ADDR_TO_ARRAY(res->ip_src, 10941 entry.input.flow.ipv6_flow.src_ip); 10942 entry.input.flow.ipv6_flow.tc = res->tos_value; 10943 entry.input.flow.ipv6_flow.hop_limits = res->ttl_value; 10944 /* need convert to big endian. */ 10945 entry.input.flow.udp6_flow.dst_port = 10946 rte_cpu_to_be_16(res->port_dst); 10947 entry.input.flow.udp6_flow.src_port = 10948 rte_cpu_to_be_16(res->port_src); 10949 break; 10950 case RTE_ETH_FLOW_NONFRAG_IPV6_SCTP: 10951 IPV6_ADDR_TO_ARRAY(res->ip_dst, 10952 entry.input.flow.sctp6_flow.ip.dst_ip); 10953 IPV6_ADDR_TO_ARRAY(res->ip_src, 10954 entry.input.flow.sctp6_flow.ip.src_ip); 10955 entry.input.flow.ipv6_flow.tc = res->tos_value; 10956 entry.input.flow.ipv6_flow.hop_limits = res->ttl_value; 10957 /* need convert to big endian. */ 10958 entry.input.flow.sctp6_flow.dst_port = 10959 rte_cpu_to_be_16(res->port_dst); 10960 entry.input.flow.sctp6_flow.src_port = 10961 rte_cpu_to_be_16(res->port_src); 10962 entry.input.flow.sctp6_flow.verify_tag = 10963 rte_cpu_to_be_32(res->verify_tag_value); 10964 break; 10965 case RTE_ETH_FLOW_L2_PAYLOAD: 10966 entry.input.flow.l2_flow.ether_type = 10967 rte_cpu_to_be_16(res->ether_type); 10968 break; 10969 default: 10970 break; 10971 } 10972 10973 if (fdir_conf.mode == RTE_FDIR_MODE_PERFECT_MAC_VLAN) 10974 rte_memcpy(&entry.input.flow.mac_vlan_flow.mac_addr, 10975 &res->mac_addr, 10976 sizeof(struct ether_addr)); 10977 10978 if (fdir_conf.mode == RTE_FDIR_MODE_PERFECT_TUNNEL) { 10979 rte_memcpy(&entry.input.flow.tunnel_flow.mac_addr, 10980 &res->mac_addr, 10981 sizeof(struct ether_addr)); 10982 entry.input.flow.tunnel_flow.tunnel_type = 10983 str2fdir_tunneltype(res->tunnel_type); 10984 entry.input.flow.tunnel_flow.tunnel_id = 10985 rte_cpu_to_be_32(res->tunnel_id_value); 10986 } 10987 10988 rte_memcpy(entry.input.flow_ext.flexbytes, 10989 flexbytes, 10990 RTE_ETH_FDIR_MAX_FLEXLEN); 10991 10992 entry.input.flow_ext.vlan_tci = rte_cpu_to_be_16(res->vlan_value); 10993 10994 entry.action.flex_off = 0; /*use 0 by default */ 10995 if (!strcmp(res->drop, "drop")) 10996 entry.action.behavior = RTE_ETH_FDIR_REJECT; 10997 else 10998 entry.action.behavior = RTE_ETH_FDIR_ACCEPT; 10999 11000 if (fdir_conf.mode != RTE_FDIR_MODE_PERFECT_MAC_VLAN && 11001 fdir_conf.mode != RTE_FDIR_MODE_PERFECT_TUNNEL) { 11002 if (!strcmp(res->pf_vf, "pf")) 11003 entry.input.flow_ext.is_vf = 0; 11004 else if (!strncmp(res->pf_vf, "vf", 2)) { 11005 struct rte_eth_dev_info dev_info; 11006 11007 memset(&dev_info, 0, sizeof(dev_info)); 11008 rte_eth_dev_info_get(res->port_id, &dev_info); 11009 errno = 0; 11010 vf_id = strtoul(res->pf_vf + 2, &end, 10); 11011 if (errno != 0 || *end != '\0' || 11012 vf_id >= dev_info.max_vfs) { 11013 printf("invalid parameter %s.\n", res->pf_vf); 11014 return; 11015 } 11016 entry.input.flow_ext.is_vf = 1; 11017 entry.input.flow_ext.dst_id = (uint16_t)vf_id; 11018 } else { 11019 printf("invalid parameter %s.\n", res->pf_vf); 11020 return; 11021 } 11022 } 11023 11024 /* set to report FD ID by default */ 11025 entry.action.report_status = RTE_ETH_FDIR_REPORT_ID; 11026 entry.action.rx_queue = res->queue_id; 11027 entry.soft_id = res->fd_id_value; 11028 if (!strcmp(res->ops, "add")) 11029 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_FDIR, 11030 RTE_ETH_FILTER_ADD, &entry); 11031 else if (!strcmp(res->ops, "del")) 11032 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_FDIR, 11033 RTE_ETH_FILTER_DELETE, &entry); 11034 else 11035 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_FDIR, 11036 RTE_ETH_FILTER_UPDATE, &entry); 11037 if (ret < 0) 11038 printf("flow director programming error: (%s)\n", 11039 strerror(-ret)); 11040 } 11041 11042 cmdline_parse_token_string_t cmd_flow_director_filter = 11043 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result, 11044 flow_director_filter, "flow_director_filter"); 11045 cmdline_parse_token_num_t cmd_flow_director_port_id = 11046 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result, 11047 port_id, UINT16); 11048 cmdline_parse_token_string_t cmd_flow_director_ops = 11049 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result, 11050 ops, "add#del#update"); 11051 cmdline_parse_token_string_t cmd_flow_director_flow = 11052 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result, 11053 flow, "flow"); 11054 cmdline_parse_token_string_t cmd_flow_director_flow_type = 11055 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result, 11056 flow_type, NULL); 11057 cmdline_parse_token_string_t cmd_flow_director_ether = 11058 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result, 11059 ether, "ether"); 11060 cmdline_parse_token_num_t cmd_flow_director_ether_type = 11061 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result, 11062 ether_type, UINT16); 11063 cmdline_parse_token_string_t cmd_flow_director_src = 11064 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result, 11065 src, "src"); 11066 cmdline_parse_token_ipaddr_t cmd_flow_director_ip_src = 11067 TOKEN_IPADDR_INITIALIZER(struct cmd_flow_director_result, 11068 ip_src); 11069 cmdline_parse_token_num_t cmd_flow_director_port_src = 11070 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result, 11071 port_src, UINT16); 11072 cmdline_parse_token_string_t cmd_flow_director_dst = 11073 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result, 11074 dst, "dst"); 11075 cmdline_parse_token_ipaddr_t cmd_flow_director_ip_dst = 11076 TOKEN_IPADDR_INITIALIZER(struct cmd_flow_director_result, 11077 ip_dst); 11078 cmdline_parse_token_num_t cmd_flow_director_port_dst = 11079 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result, 11080 port_dst, UINT16); 11081 cmdline_parse_token_string_t cmd_flow_director_verify_tag = 11082 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result, 11083 verify_tag, "verify_tag"); 11084 cmdline_parse_token_num_t cmd_flow_director_verify_tag_value = 11085 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result, 11086 verify_tag_value, UINT32); 11087 cmdline_parse_token_string_t cmd_flow_director_tos = 11088 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result, 11089 tos, "tos"); 11090 cmdline_parse_token_num_t cmd_flow_director_tos_value = 11091 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result, 11092 tos_value, UINT8); 11093 cmdline_parse_token_string_t cmd_flow_director_proto = 11094 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result, 11095 proto, "proto"); 11096 cmdline_parse_token_num_t cmd_flow_director_proto_value = 11097 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result, 11098 proto_value, UINT8); 11099 cmdline_parse_token_string_t cmd_flow_director_ttl = 11100 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result, 11101 ttl, "ttl"); 11102 cmdline_parse_token_num_t cmd_flow_director_ttl_value = 11103 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result, 11104 ttl_value, UINT8); 11105 cmdline_parse_token_string_t cmd_flow_director_vlan = 11106 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result, 11107 vlan, "vlan"); 11108 cmdline_parse_token_num_t cmd_flow_director_vlan_value = 11109 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result, 11110 vlan_value, UINT16); 11111 cmdline_parse_token_string_t cmd_flow_director_flexbytes = 11112 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result, 11113 flexbytes, "flexbytes"); 11114 cmdline_parse_token_string_t cmd_flow_director_flexbytes_value = 11115 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result, 11116 flexbytes_value, NULL); 11117 cmdline_parse_token_string_t cmd_flow_director_drop = 11118 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result, 11119 drop, "drop#fwd"); 11120 cmdline_parse_token_string_t cmd_flow_director_pf_vf = 11121 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result, 11122 pf_vf, NULL); 11123 cmdline_parse_token_string_t cmd_flow_director_queue = 11124 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result, 11125 queue, "queue"); 11126 cmdline_parse_token_num_t cmd_flow_director_queue_id = 11127 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result, 11128 queue_id, UINT16); 11129 cmdline_parse_token_string_t cmd_flow_director_fd_id = 11130 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result, 11131 fd_id, "fd_id"); 11132 cmdline_parse_token_num_t cmd_flow_director_fd_id_value = 11133 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result, 11134 fd_id_value, UINT32); 11135 11136 cmdline_parse_token_string_t cmd_flow_director_mode = 11137 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result, 11138 mode, "mode"); 11139 cmdline_parse_token_string_t cmd_flow_director_mode_ip = 11140 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result, 11141 mode_value, "IP"); 11142 cmdline_parse_token_string_t cmd_flow_director_mode_mac_vlan = 11143 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result, 11144 mode_value, "MAC-VLAN"); 11145 cmdline_parse_token_string_t cmd_flow_director_mode_tunnel = 11146 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result, 11147 mode_value, "Tunnel"); 11148 cmdline_parse_token_string_t cmd_flow_director_mode_raw = 11149 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result, 11150 mode_value, "raw"); 11151 cmdline_parse_token_string_t cmd_flow_director_mac = 11152 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result, 11153 mac, "mac"); 11154 cmdline_parse_token_etheraddr_t cmd_flow_director_mac_addr = 11155 TOKEN_ETHERADDR_INITIALIZER(struct cmd_flow_director_result, 11156 mac_addr); 11157 cmdline_parse_token_string_t cmd_flow_director_tunnel = 11158 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result, 11159 tunnel, "tunnel"); 11160 cmdline_parse_token_string_t cmd_flow_director_tunnel_type = 11161 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result, 11162 tunnel_type, "NVGRE#VxLAN"); 11163 cmdline_parse_token_string_t cmd_flow_director_tunnel_id = 11164 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result, 11165 tunnel_id, "tunnel-id"); 11166 cmdline_parse_token_num_t cmd_flow_director_tunnel_id_value = 11167 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result, 11168 tunnel_id_value, UINT32); 11169 cmdline_parse_token_string_t cmd_flow_director_packet = 11170 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result, 11171 packet, "packet"); 11172 cmdline_parse_token_string_t cmd_flow_director_filepath = 11173 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result, 11174 filepath, NULL); 11175 11176 cmdline_parse_inst_t cmd_add_del_ip_flow_director = { 11177 .f = cmd_flow_director_filter_parsed, 11178 .data = NULL, 11179 .help_str = "flow_director_filter <port_id> mode IP add|del|update flow" 11180 " ipv4-other|ipv4-frag|ipv4-tcp|ipv4-udp|ipv4-sctp|" 11181 "ipv6-other|ipv6-frag|ipv6-tcp|ipv6-udp|ipv6-sctp|" 11182 "l2_payload src <src_ip> dst <dst_ip> tos <tos_value> " 11183 "proto <proto_value> ttl <ttl_value> vlan <vlan_value> " 11184 "flexbytes <flexbyte_values> drop|fw <pf_vf> queue <queue_id> " 11185 "fd_id <fd_id_value>: " 11186 "Add or delete an ip flow director entry on NIC", 11187 .tokens = { 11188 (void *)&cmd_flow_director_filter, 11189 (void *)&cmd_flow_director_port_id, 11190 (void *)&cmd_flow_director_mode, 11191 (void *)&cmd_flow_director_mode_ip, 11192 (void *)&cmd_flow_director_ops, 11193 (void *)&cmd_flow_director_flow, 11194 (void *)&cmd_flow_director_flow_type, 11195 (void *)&cmd_flow_director_src, 11196 (void *)&cmd_flow_director_ip_src, 11197 (void *)&cmd_flow_director_dst, 11198 (void *)&cmd_flow_director_ip_dst, 11199 (void *)&cmd_flow_director_tos, 11200 (void *)&cmd_flow_director_tos_value, 11201 (void *)&cmd_flow_director_proto, 11202 (void *)&cmd_flow_director_proto_value, 11203 (void *)&cmd_flow_director_ttl, 11204 (void *)&cmd_flow_director_ttl_value, 11205 (void *)&cmd_flow_director_vlan, 11206 (void *)&cmd_flow_director_vlan_value, 11207 (void *)&cmd_flow_director_flexbytes, 11208 (void *)&cmd_flow_director_flexbytes_value, 11209 (void *)&cmd_flow_director_drop, 11210 (void *)&cmd_flow_director_pf_vf, 11211 (void *)&cmd_flow_director_queue, 11212 (void *)&cmd_flow_director_queue_id, 11213 (void *)&cmd_flow_director_fd_id, 11214 (void *)&cmd_flow_director_fd_id_value, 11215 NULL, 11216 }, 11217 }; 11218 11219 cmdline_parse_inst_t cmd_add_del_udp_flow_director = { 11220 .f = cmd_flow_director_filter_parsed, 11221 .data = NULL, 11222 .help_str = "flow_director_filter ... : Add or delete an udp/tcp flow " 11223 "director entry on NIC", 11224 .tokens = { 11225 (void *)&cmd_flow_director_filter, 11226 (void *)&cmd_flow_director_port_id, 11227 (void *)&cmd_flow_director_mode, 11228 (void *)&cmd_flow_director_mode_ip, 11229 (void *)&cmd_flow_director_ops, 11230 (void *)&cmd_flow_director_flow, 11231 (void *)&cmd_flow_director_flow_type, 11232 (void *)&cmd_flow_director_src, 11233 (void *)&cmd_flow_director_ip_src, 11234 (void *)&cmd_flow_director_port_src, 11235 (void *)&cmd_flow_director_dst, 11236 (void *)&cmd_flow_director_ip_dst, 11237 (void *)&cmd_flow_director_port_dst, 11238 (void *)&cmd_flow_director_tos, 11239 (void *)&cmd_flow_director_tos_value, 11240 (void *)&cmd_flow_director_ttl, 11241 (void *)&cmd_flow_director_ttl_value, 11242 (void *)&cmd_flow_director_vlan, 11243 (void *)&cmd_flow_director_vlan_value, 11244 (void *)&cmd_flow_director_flexbytes, 11245 (void *)&cmd_flow_director_flexbytes_value, 11246 (void *)&cmd_flow_director_drop, 11247 (void *)&cmd_flow_director_pf_vf, 11248 (void *)&cmd_flow_director_queue, 11249 (void *)&cmd_flow_director_queue_id, 11250 (void *)&cmd_flow_director_fd_id, 11251 (void *)&cmd_flow_director_fd_id_value, 11252 NULL, 11253 }, 11254 }; 11255 11256 cmdline_parse_inst_t cmd_add_del_sctp_flow_director = { 11257 .f = cmd_flow_director_filter_parsed, 11258 .data = NULL, 11259 .help_str = "flow_director_filter ... : Add or delete a sctp flow " 11260 "director entry on NIC", 11261 .tokens = { 11262 (void *)&cmd_flow_director_filter, 11263 (void *)&cmd_flow_director_port_id, 11264 (void *)&cmd_flow_director_mode, 11265 (void *)&cmd_flow_director_mode_ip, 11266 (void *)&cmd_flow_director_ops, 11267 (void *)&cmd_flow_director_flow, 11268 (void *)&cmd_flow_director_flow_type, 11269 (void *)&cmd_flow_director_src, 11270 (void *)&cmd_flow_director_ip_src, 11271 (void *)&cmd_flow_director_port_src, 11272 (void *)&cmd_flow_director_dst, 11273 (void *)&cmd_flow_director_ip_dst, 11274 (void *)&cmd_flow_director_port_dst, 11275 (void *)&cmd_flow_director_verify_tag, 11276 (void *)&cmd_flow_director_verify_tag_value, 11277 (void *)&cmd_flow_director_tos, 11278 (void *)&cmd_flow_director_tos_value, 11279 (void *)&cmd_flow_director_ttl, 11280 (void *)&cmd_flow_director_ttl_value, 11281 (void *)&cmd_flow_director_vlan, 11282 (void *)&cmd_flow_director_vlan_value, 11283 (void *)&cmd_flow_director_flexbytes, 11284 (void *)&cmd_flow_director_flexbytes_value, 11285 (void *)&cmd_flow_director_drop, 11286 (void *)&cmd_flow_director_pf_vf, 11287 (void *)&cmd_flow_director_queue, 11288 (void *)&cmd_flow_director_queue_id, 11289 (void *)&cmd_flow_director_fd_id, 11290 (void *)&cmd_flow_director_fd_id_value, 11291 NULL, 11292 }, 11293 }; 11294 11295 cmdline_parse_inst_t cmd_add_del_l2_flow_director = { 11296 .f = cmd_flow_director_filter_parsed, 11297 .data = NULL, 11298 .help_str = "flow_director_filter ... : Add or delete a L2 flow " 11299 "director entry on NIC", 11300 .tokens = { 11301 (void *)&cmd_flow_director_filter, 11302 (void *)&cmd_flow_director_port_id, 11303 (void *)&cmd_flow_director_mode, 11304 (void *)&cmd_flow_director_mode_ip, 11305 (void *)&cmd_flow_director_ops, 11306 (void *)&cmd_flow_director_flow, 11307 (void *)&cmd_flow_director_flow_type, 11308 (void *)&cmd_flow_director_ether, 11309 (void *)&cmd_flow_director_ether_type, 11310 (void *)&cmd_flow_director_flexbytes, 11311 (void *)&cmd_flow_director_flexbytes_value, 11312 (void *)&cmd_flow_director_drop, 11313 (void *)&cmd_flow_director_pf_vf, 11314 (void *)&cmd_flow_director_queue, 11315 (void *)&cmd_flow_director_queue_id, 11316 (void *)&cmd_flow_director_fd_id, 11317 (void *)&cmd_flow_director_fd_id_value, 11318 NULL, 11319 }, 11320 }; 11321 11322 cmdline_parse_inst_t cmd_add_del_mac_vlan_flow_director = { 11323 .f = cmd_flow_director_filter_parsed, 11324 .data = NULL, 11325 .help_str = "flow_director_filter ... : Add or delete a MAC VLAN flow " 11326 "director entry on NIC", 11327 .tokens = { 11328 (void *)&cmd_flow_director_filter, 11329 (void *)&cmd_flow_director_port_id, 11330 (void *)&cmd_flow_director_mode, 11331 (void *)&cmd_flow_director_mode_mac_vlan, 11332 (void *)&cmd_flow_director_ops, 11333 (void *)&cmd_flow_director_mac, 11334 (void *)&cmd_flow_director_mac_addr, 11335 (void *)&cmd_flow_director_vlan, 11336 (void *)&cmd_flow_director_vlan_value, 11337 (void *)&cmd_flow_director_flexbytes, 11338 (void *)&cmd_flow_director_flexbytes_value, 11339 (void *)&cmd_flow_director_drop, 11340 (void *)&cmd_flow_director_queue, 11341 (void *)&cmd_flow_director_queue_id, 11342 (void *)&cmd_flow_director_fd_id, 11343 (void *)&cmd_flow_director_fd_id_value, 11344 NULL, 11345 }, 11346 }; 11347 11348 cmdline_parse_inst_t cmd_add_del_tunnel_flow_director = { 11349 .f = cmd_flow_director_filter_parsed, 11350 .data = NULL, 11351 .help_str = "flow_director_filter ... : Add or delete a tunnel flow " 11352 "director entry on NIC", 11353 .tokens = { 11354 (void *)&cmd_flow_director_filter, 11355 (void *)&cmd_flow_director_port_id, 11356 (void *)&cmd_flow_director_mode, 11357 (void *)&cmd_flow_director_mode_tunnel, 11358 (void *)&cmd_flow_director_ops, 11359 (void *)&cmd_flow_director_mac, 11360 (void *)&cmd_flow_director_mac_addr, 11361 (void *)&cmd_flow_director_vlan, 11362 (void *)&cmd_flow_director_vlan_value, 11363 (void *)&cmd_flow_director_tunnel, 11364 (void *)&cmd_flow_director_tunnel_type, 11365 (void *)&cmd_flow_director_tunnel_id, 11366 (void *)&cmd_flow_director_tunnel_id_value, 11367 (void *)&cmd_flow_director_flexbytes, 11368 (void *)&cmd_flow_director_flexbytes_value, 11369 (void *)&cmd_flow_director_drop, 11370 (void *)&cmd_flow_director_queue, 11371 (void *)&cmd_flow_director_queue_id, 11372 (void *)&cmd_flow_director_fd_id, 11373 (void *)&cmd_flow_director_fd_id_value, 11374 NULL, 11375 }, 11376 }; 11377 11378 cmdline_parse_inst_t cmd_add_del_raw_flow_director = { 11379 .f = cmd_flow_director_filter_parsed, 11380 .data = NULL, 11381 .help_str = "flow_director_filter ... : Add or delete a raw flow " 11382 "director entry on NIC", 11383 .tokens = { 11384 (void *)&cmd_flow_director_filter, 11385 (void *)&cmd_flow_director_port_id, 11386 (void *)&cmd_flow_director_mode, 11387 (void *)&cmd_flow_director_mode_raw, 11388 (void *)&cmd_flow_director_ops, 11389 (void *)&cmd_flow_director_flow, 11390 (void *)&cmd_flow_director_flow_type, 11391 (void *)&cmd_flow_director_drop, 11392 (void *)&cmd_flow_director_queue, 11393 (void *)&cmd_flow_director_queue_id, 11394 (void *)&cmd_flow_director_fd_id, 11395 (void *)&cmd_flow_director_fd_id_value, 11396 (void *)&cmd_flow_director_packet, 11397 (void *)&cmd_flow_director_filepath, 11398 NULL, 11399 }, 11400 }; 11401 11402 struct cmd_flush_flow_director_result { 11403 cmdline_fixed_string_t flush_flow_director; 11404 portid_t port_id; 11405 }; 11406 11407 cmdline_parse_token_string_t cmd_flush_flow_director_flush = 11408 TOKEN_STRING_INITIALIZER(struct cmd_flush_flow_director_result, 11409 flush_flow_director, "flush_flow_director"); 11410 cmdline_parse_token_num_t cmd_flush_flow_director_port_id = 11411 TOKEN_NUM_INITIALIZER(struct cmd_flush_flow_director_result, 11412 port_id, UINT16); 11413 11414 static void 11415 cmd_flush_flow_director_parsed(void *parsed_result, 11416 __attribute__((unused)) struct cmdline *cl, 11417 __attribute__((unused)) void *data) 11418 { 11419 struct cmd_flow_director_result *res = parsed_result; 11420 int ret = 0; 11421 11422 ret = rte_eth_dev_filter_supported(res->port_id, RTE_ETH_FILTER_FDIR); 11423 if (ret < 0) { 11424 printf("flow director is not supported on port %u.\n", 11425 res->port_id); 11426 return; 11427 } 11428 11429 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_FDIR, 11430 RTE_ETH_FILTER_FLUSH, NULL); 11431 if (ret < 0) 11432 printf("flow director table flushing error: (%s)\n", 11433 strerror(-ret)); 11434 } 11435 11436 cmdline_parse_inst_t cmd_flush_flow_director = { 11437 .f = cmd_flush_flow_director_parsed, 11438 .data = NULL, 11439 .help_str = "flush_flow_director <port_id>: " 11440 "Flush all flow director entries of a device on NIC", 11441 .tokens = { 11442 (void *)&cmd_flush_flow_director_flush, 11443 (void *)&cmd_flush_flow_director_port_id, 11444 NULL, 11445 }, 11446 }; 11447 11448 /* *** deal with flow director mask *** */ 11449 struct cmd_flow_director_mask_result { 11450 cmdline_fixed_string_t flow_director_mask; 11451 portid_t port_id; 11452 cmdline_fixed_string_t mode; 11453 cmdline_fixed_string_t mode_value; 11454 cmdline_fixed_string_t vlan; 11455 uint16_t vlan_mask; 11456 cmdline_fixed_string_t src_mask; 11457 cmdline_ipaddr_t ipv4_src; 11458 cmdline_ipaddr_t ipv6_src; 11459 uint16_t port_src; 11460 cmdline_fixed_string_t dst_mask; 11461 cmdline_ipaddr_t ipv4_dst; 11462 cmdline_ipaddr_t ipv6_dst; 11463 uint16_t port_dst; 11464 cmdline_fixed_string_t mac; 11465 uint8_t mac_addr_byte_mask; 11466 cmdline_fixed_string_t tunnel_id; 11467 uint32_t tunnel_id_mask; 11468 cmdline_fixed_string_t tunnel_type; 11469 uint8_t tunnel_type_mask; 11470 }; 11471 11472 static void 11473 cmd_flow_director_mask_parsed(void *parsed_result, 11474 __attribute__((unused)) struct cmdline *cl, 11475 __attribute__((unused)) void *data) 11476 { 11477 struct cmd_flow_director_mask_result *res = parsed_result; 11478 struct rte_eth_fdir_masks *mask; 11479 struct rte_port *port; 11480 11481 port = &ports[res->port_id]; 11482 /** Check if the port is not started **/ 11483 if (port->port_status != RTE_PORT_STOPPED) { 11484 printf("Please stop port %d first\n", res->port_id); 11485 return; 11486 } 11487 11488 mask = &port->dev_conf.fdir_conf.mask; 11489 11490 if (fdir_conf.mode == RTE_FDIR_MODE_PERFECT_MAC_VLAN) { 11491 if (strcmp(res->mode_value, "MAC-VLAN")) { 11492 printf("Please set mode to MAC-VLAN.\n"); 11493 return; 11494 } 11495 11496 mask->vlan_tci_mask = rte_cpu_to_be_16(res->vlan_mask); 11497 } else if (fdir_conf.mode == RTE_FDIR_MODE_PERFECT_TUNNEL) { 11498 if (strcmp(res->mode_value, "Tunnel")) { 11499 printf("Please set mode to Tunnel.\n"); 11500 return; 11501 } 11502 11503 mask->vlan_tci_mask = rte_cpu_to_be_16(res->vlan_mask); 11504 mask->mac_addr_byte_mask = res->mac_addr_byte_mask; 11505 mask->tunnel_id_mask = rte_cpu_to_be_32(res->tunnel_id_mask); 11506 mask->tunnel_type_mask = res->tunnel_type_mask; 11507 } else { 11508 if (strcmp(res->mode_value, "IP")) { 11509 printf("Please set mode to IP.\n"); 11510 return; 11511 } 11512 11513 mask->vlan_tci_mask = rte_cpu_to_be_16(res->vlan_mask); 11514 IPV4_ADDR_TO_UINT(res->ipv4_src, mask->ipv4_mask.src_ip); 11515 IPV4_ADDR_TO_UINT(res->ipv4_dst, mask->ipv4_mask.dst_ip); 11516 IPV6_ADDR_TO_ARRAY(res->ipv6_src, mask->ipv6_mask.src_ip); 11517 IPV6_ADDR_TO_ARRAY(res->ipv6_dst, mask->ipv6_mask.dst_ip); 11518 mask->src_port_mask = rte_cpu_to_be_16(res->port_src); 11519 mask->dst_port_mask = rte_cpu_to_be_16(res->port_dst); 11520 } 11521 11522 cmd_reconfig_device_queue(res->port_id, 1, 1); 11523 } 11524 11525 cmdline_parse_token_string_t cmd_flow_director_mask = 11526 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result, 11527 flow_director_mask, "flow_director_mask"); 11528 cmdline_parse_token_num_t cmd_flow_director_mask_port_id = 11529 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_mask_result, 11530 port_id, UINT16); 11531 cmdline_parse_token_string_t cmd_flow_director_mask_vlan = 11532 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result, 11533 vlan, "vlan"); 11534 cmdline_parse_token_num_t cmd_flow_director_mask_vlan_value = 11535 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_mask_result, 11536 vlan_mask, UINT16); 11537 cmdline_parse_token_string_t cmd_flow_director_mask_src = 11538 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result, 11539 src_mask, "src_mask"); 11540 cmdline_parse_token_ipaddr_t cmd_flow_director_mask_ipv4_src = 11541 TOKEN_IPADDR_INITIALIZER(struct cmd_flow_director_mask_result, 11542 ipv4_src); 11543 cmdline_parse_token_ipaddr_t cmd_flow_director_mask_ipv6_src = 11544 TOKEN_IPADDR_INITIALIZER(struct cmd_flow_director_mask_result, 11545 ipv6_src); 11546 cmdline_parse_token_num_t cmd_flow_director_mask_port_src = 11547 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_mask_result, 11548 port_src, UINT16); 11549 cmdline_parse_token_string_t cmd_flow_director_mask_dst = 11550 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result, 11551 dst_mask, "dst_mask"); 11552 cmdline_parse_token_ipaddr_t cmd_flow_director_mask_ipv4_dst = 11553 TOKEN_IPADDR_INITIALIZER(struct cmd_flow_director_mask_result, 11554 ipv4_dst); 11555 cmdline_parse_token_ipaddr_t cmd_flow_director_mask_ipv6_dst = 11556 TOKEN_IPADDR_INITIALIZER(struct cmd_flow_director_mask_result, 11557 ipv6_dst); 11558 cmdline_parse_token_num_t cmd_flow_director_mask_port_dst = 11559 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_mask_result, 11560 port_dst, UINT16); 11561 11562 cmdline_parse_token_string_t cmd_flow_director_mask_mode = 11563 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result, 11564 mode, "mode"); 11565 cmdline_parse_token_string_t cmd_flow_director_mask_mode_ip = 11566 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result, 11567 mode_value, "IP"); 11568 cmdline_parse_token_string_t cmd_flow_director_mask_mode_mac_vlan = 11569 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result, 11570 mode_value, "MAC-VLAN"); 11571 cmdline_parse_token_string_t cmd_flow_director_mask_mode_tunnel = 11572 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result, 11573 mode_value, "Tunnel"); 11574 cmdline_parse_token_string_t cmd_flow_director_mask_mac = 11575 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result, 11576 mac, "mac"); 11577 cmdline_parse_token_num_t cmd_flow_director_mask_mac_value = 11578 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_mask_result, 11579 mac_addr_byte_mask, UINT8); 11580 cmdline_parse_token_string_t cmd_flow_director_mask_tunnel_type = 11581 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result, 11582 tunnel_type, "tunnel-type"); 11583 cmdline_parse_token_num_t cmd_flow_director_mask_tunnel_type_value = 11584 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_mask_result, 11585 tunnel_type_mask, UINT8); 11586 cmdline_parse_token_string_t cmd_flow_director_mask_tunnel_id = 11587 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result, 11588 tunnel_id, "tunnel-id"); 11589 cmdline_parse_token_num_t cmd_flow_director_mask_tunnel_id_value = 11590 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_mask_result, 11591 tunnel_id_mask, UINT32); 11592 11593 cmdline_parse_inst_t cmd_set_flow_director_ip_mask = { 11594 .f = cmd_flow_director_mask_parsed, 11595 .data = NULL, 11596 .help_str = "flow_director_mask ... : " 11597 "Set IP mode flow director's mask on NIC", 11598 .tokens = { 11599 (void *)&cmd_flow_director_mask, 11600 (void *)&cmd_flow_director_mask_port_id, 11601 (void *)&cmd_flow_director_mask_mode, 11602 (void *)&cmd_flow_director_mask_mode_ip, 11603 (void *)&cmd_flow_director_mask_vlan, 11604 (void *)&cmd_flow_director_mask_vlan_value, 11605 (void *)&cmd_flow_director_mask_src, 11606 (void *)&cmd_flow_director_mask_ipv4_src, 11607 (void *)&cmd_flow_director_mask_ipv6_src, 11608 (void *)&cmd_flow_director_mask_port_src, 11609 (void *)&cmd_flow_director_mask_dst, 11610 (void *)&cmd_flow_director_mask_ipv4_dst, 11611 (void *)&cmd_flow_director_mask_ipv6_dst, 11612 (void *)&cmd_flow_director_mask_port_dst, 11613 NULL, 11614 }, 11615 }; 11616 11617 cmdline_parse_inst_t cmd_set_flow_director_mac_vlan_mask = { 11618 .f = cmd_flow_director_mask_parsed, 11619 .data = NULL, 11620 .help_str = "flow_director_mask ... : Set MAC VLAN mode " 11621 "flow director's mask on NIC", 11622 .tokens = { 11623 (void *)&cmd_flow_director_mask, 11624 (void *)&cmd_flow_director_mask_port_id, 11625 (void *)&cmd_flow_director_mask_mode, 11626 (void *)&cmd_flow_director_mask_mode_mac_vlan, 11627 (void *)&cmd_flow_director_mask_vlan, 11628 (void *)&cmd_flow_director_mask_vlan_value, 11629 NULL, 11630 }, 11631 }; 11632 11633 cmdline_parse_inst_t cmd_set_flow_director_tunnel_mask = { 11634 .f = cmd_flow_director_mask_parsed, 11635 .data = NULL, 11636 .help_str = "flow_director_mask ... : Set tunnel mode " 11637 "flow director's mask on NIC", 11638 .tokens = { 11639 (void *)&cmd_flow_director_mask, 11640 (void *)&cmd_flow_director_mask_port_id, 11641 (void *)&cmd_flow_director_mask_mode, 11642 (void *)&cmd_flow_director_mask_mode_tunnel, 11643 (void *)&cmd_flow_director_mask_vlan, 11644 (void *)&cmd_flow_director_mask_vlan_value, 11645 (void *)&cmd_flow_director_mask_mac, 11646 (void *)&cmd_flow_director_mask_mac_value, 11647 (void *)&cmd_flow_director_mask_tunnel_type, 11648 (void *)&cmd_flow_director_mask_tunnel_type_value, 11649 (void *)&cmd_flow_director_mask_tunnel_id, 11650 (void *)&cmd_flow_director_mask_tunnel_id_value, 11651 NULL, 11652 }, 11653 }; 11654 11655 /* *** deal with flow director mask on flexible payload *** */ 11656 struct cmd_flow_director_flex_mask_result { 11657 cmdline_fixed_string_t flow_director_flexmask; 11658 portid_t port_id; 11659 cmdline_fixed_string_t flow; 11660 cmdline_fixed_string_t flow_type; 11661 cmdline_fixed_string_t mask; 11662 }; 11663 11664 static void 11665 cmd_flow_director_flex_mask_parsed(void *parsed_result, 11666 __attribute__((unused)) struct cmdline *cl, 11667 __attribute__((unused)) void *data) 11668 { 11669 struct cmd_flow_director_flex_mask_result *res = parsed_result; 11670 struct rte_eth_fdir_info fdir_info; 11671 struct rte_eth_fdir_flex_mask flex_mask; 11672 struct rte_port *port; 11673 uint64_t flow_type_mask; 11674 uint16_t i; 11675 int ret; 11676 11677 port = &ports[res->port_id]; 11678 /** Check if the port is not started **/ 11679 if (port->port_status != RTE_PORT_STOPPED) { 11680 printf("Please stop port %d first\n", res->port_id); 11681 return; 11682 } 11683 11684 memset(&flex_mask, 0, sizeof(struct rte_eth_fdir_flex_mask)); 11685 ret = parse_flexbytes(res->mask, 11686 flex_mask.mask, 11687 RTE_ETH_FDIR_MAX_FLEXLEN); 11688 if (ret < 0) { 11689 printf("error: Cannot parse mask input.\n"); 11690 return; 11691 } 11692 11693 memset(&fdir_info, 0, sizeof(fdir_info)); 11694 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_FDIR, 11695 RTE_ETH_FILTER_INFO, &fdir_info); 11696 if (ret < 0) { 11697 printf("Cannot get FDir filter info\n"); 11698 return; 11699 } 11700 11701 if (!strcmp(res->flow_type, "none")) { 11702 /* means don't specify the flow type */ 11703 flex_mask.flow_type = RTE_ETH_FLOW_UNKNOWN; 11704 for (i = 0; i < RTE_ETH_FLOW_MAX; i++) 11705 memset(&port->dev_conf.fdir_conf.flex_conf.flex_mask[i], 11706 0, sizeof(struct rte_eth_fdir_flex_mask)); 11707 port->dev_conf.fdir_conf.flex_conf.nb_flexmasks = 1; 11708 rte_memcpy(&port->dev_conf.fdir_conf.flex_conf.flex_mask[0], 11709 &flex_mask, 11710 sizeof(struct rte_eth_fdir_flex_mask)); 11711 cmd_reconfig_device_queue(res->port_id, 1, 1); 11712 return; 11713 } 11714 flow_type_mask = fdir_info.flow_types_mask[0]; 11715 if (!strcmp(res->flow_type, "all")) { 11716 if (!flow_type_mask) { 11717 printf("No flow type supported\n"); 11718 return; 11719 } 11720 for (i = RTE_ETH_FLOW_UNKNOWN; i < RTE_ETH_FLOW_MAX; i++) { 11721 if (flow_type_mask & (1ULL << i)) { 11722 flex_mask.flow_type = i; 11723 fdir_set_flex_mask(res->port_id, &flex_mask); 11724 } 11725 } 11726 cmd_reconfig_device_queue(res->port_id, 1, 1); 11727 return; 11728 } 11729 flex_mask.flow_type = str2flowtype(res->flow_type); 11730 if (!(flow_type_mask & (1ULL << flex_mask.flow_type))) { 11731 printf("Flow type %s not supported on port %d\n", 11732 res->flow_type, res->port_id); 11733 return; 11734 } 11735 fdir_set_flex_mask(res->port_id, &flex_mask); 11736 cmd_reconfig_device_queue(res->port_id, 1, 1); 11737 } 11738 11739 cmdline_parse_token_string_t cmd_flow_director_flexmask = 11740 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_flex_mask_result, 11741 flow_director_flexmask, 11742 "flow_director_flex_mask"); 11743 cmdline_parse_token_num_t cmd_flow_director_flexmask_port_id = 11744 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_flex_mask_result, 11745 port_id, UINT16); 11746 cmdline_parse_token_string_t cmd_flow_director_flexmask_flow = 11747 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_flex_mask_result, 11748 flow, "flow"); 11749 cmdline_parse_token_string_t cmd_flow_director_flexmask_flow_type = 11750 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_flex_mask_result, 11751 flow_type, "none#ipv4-other#ipv4-frag#ipv4-tcp#ipv4-udp#ipv4-sctp#" 11752 "ipv6-other#ipv6-frag#ipv6-tcp#ipv6-udp#ipv6-sctp#l2_payload#all"); 11753 cmdline_parse_token_string_t cmd_flow_director_flexmask_mask = 11754 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_flex_mask_result, 11755 mask, NULL); 11756 11757 cmdline_parse_inst_t cmd_set_flow_director_flex_mask = { 11758 .f = cmd_flow_director_flex_mask_parsed, 11759 .data = NULL, 11760 .help_str = "flow_director_flex_mask ... : " 11761 "Set flow director's flex mask on NIC", 11762 .tokens = { 11763 (void *)&cmd_flow_director_flexmask, 11764 (void *)&cmd_flow_director_flexmask_port_id, 11765 (void *)&cmd_flow_director_flexmask_flow, 11766 (void *)&cmd_flow_director_flexmask_flow_type, 11767 (void *)&cmd_flow_director_flexmask_mask, 11768 NULL, 11769 }, 11770 }; 11771 11772 /* *** deal with flow director flexible payload configuration *** */ 11773 struct cmd_flow_director_flexpayload_result { 11774 cmdline_fixed_string_t flow_director_flexpayload; 11775 portid_t port_id; 11776 cmdline_fixed_string_t payload_layer; 11777 cmdline_fixed_string_t payload_cfg; 11778 }; 11779 11780 static inline int 11781 parse_offsets(const char *q_arg, uint16_t *offsets, uint16_t max_num) 11782 { 11783 char s[256]; 11784 const char *p, *p0 = q_arg; 11785 char *end; 11786 unsigned long int_fld; 11787 char *str_fld[max_num]; 11788 int i; 11789 unsigned size; 11790 int ret = -1; 11791 11792 p = strchr(p0, '('); 11793 if (p == NULL) 11794 return -1; 11795 ++p; 11796 p0 = strchr(p, ')'); 11797 if (p0 == NULL) 11798 return -1; 11799 11800 size = p0 - p; 11801 if (size >= sizeof(s)) 11802 return -1; 11803 11804 snprintf(s, sizeof(s), "%.*s", size, p); 11805 ret = rte_strsplit(s, sizeof(s), str_fld, max_num, ','); 11806 if (ret < 0 || ret > max_num) 11807 return -1; 11808 for (i = 0; i < ret; i++) { 11809 errno = 0; 11810 int_fld = strtoul(str_fld[i], &end, 0); 11811 if (errno != 0 || *end != '\0' || int_fld > UINT16_MAX) 11812 return -1; 11813 offsets[i] = (uint16_t)int_fld; 11814 } 11815 return ret; 11816 } 11817 11818 static void 11819 cmd_flow_director_flxpld_parsed(void *parsed_result, 11820 __attribute__((unused)) struct cmdline *cl, 11821 __attribute__((unused)) void *data) 11822 { 11823 struct cmd_flow_director_flexpayload_result *res = parsed_result; 11824 struct rte_eth_flex_payload_cfg flex_cfg; 11825 struct rte_port *port; 11826 int ret = 0; 11827 11828 port = &ports[res->port_id]; 11829 /** Check if the port is not started **/ 11830 if (port->port_status != RTE_PORT_STOPPED) { 11831 printf("Please stop port %d first\n", res->port_id); 11832 return; 11833 } 11834 11835 memset(&flex_cfg, 0, sizeof(struct rte_eth_flex_payload_cfg)); 11836 11837 if (!strcmp(res->payload_layer, "raw")) 11838 flex_cfg.type = RTE_ETH_RAW_PAYLOAD; 11839 else if (!strcmp(res->payload_layer, "l2")) 11840 flex_cfg.type = RTE_ETH_L2_PAYLOAD; 11841 else if (!strcmp(res->payload_layer, "l3")) 11842 flex_cfg.type = RTE_ETH_L3_PAYLOAD; 11843 else if (!strcmp(res->payload_layer, "l4")) 11844 flex_cfg.type = RTE_ETH_L4_PAYLOAD; 11845 11846 ret = parse_offsets(res->payload_cfg, flex_cfg.src_offset, 11847 RTE_ETH_FDIR_MAX_FLEXLEN); 11848 if (ret < 0) { 11849 printf("error: Cannot parse flex payload input.\n"); 11850 return; 11851 } 11852 11853 fdir_set_flex_payload(res->port_id, &flex_cfg); 11854 cmd_reconfig_device_queue(res->port_id, 1, 1); 11855 } 11856 11857 cmdline_parse_token_string_t cmd_flow_director_flexpayload = 11858 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_flexpayload_result, 11859 flow_director_flexpayload, 11860 "flow_director_flex_payload"); 11861 cmdline_parse_token_num_t cmd_flow_director_flexpayload_port_id = 11862 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_flexpayload_result, 11863 port_id, UINT16); 11864 cmdline_parse_token_string_t cmd_flow_director_flexpayload_payload_layer = 11865 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_flexpayload_result, 11866 payload_layer, "raw#l2#l3#l4"); 11867 cmdline_parse_token_string_t cmd_flow_director_flexpayload_payload_cfg = 11868 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_flexpayload_result, 11869 payload_cfg, NULL); 11870 11871 cmdline_parse_inst_t cmd_set_flow_director_flex_payload = { 11872 .f = cmd_flow_director_flxpld_parsed, 11873 .data = NULL, 11874 .help_str = "flow_director_flexpayload ... : " 11875 "Set flow director's flex payload on NIC", 11876 .tokens = { 11877 (void *)&cmd_flow_director_flexpayload, 11878 (void *)&cmd_flow_director_flexpayload_port_id, 11879 (void *)&cmd_flow_director_flexpayload_payload_layer, 11880 (void *)&cmd_flow_director_flexpayload_payload_cfg, 11881 NULL, 11882 }, 11883 }; 11884 11885 /* Generic flow interface command. */ 11886 extern cmdline_parse_inst_t cmd_flow; 11887 11888 /* *** Classification Filters Control *** */ 11889 /* *** Get symmetric hash enable per port *** */ 11890 struct cmd_get_sym_hash_ena_per_port_result { 11891 cmdline_fixed_string_t get_sym_hash_ena_per_port; 11892 portid_t port_id; 11893 }; 11894 11895 static void 11896 cmd_get_sym_hash_per_port_parsed(void *parsed_result, 11897 __rte_unused struct cmdline *cl, 11898 __rte_unused void *data) 11899 { 11900 struct cmd_get_sym_hash_ena_per_port_result *res = parsed_result; 11901 struct rte_eth_hash_filter_info info; 11902 int ret; 11903 11904 if (rte_eth_dev_filter_supported(res->port_id, 11905 RTE_ETH_FILTER_HASH) < 0) { 11906 printf("RTE_ETH_FILTER_HASH not supported on port: %d\n", 11907 res->port_id); 11908 return; 11909 } 11910 11911 memset(&info, 0, sizeof(info)); 11912 info.info_type = RTE_ETH_HASH_FILTER_SYM_HASH_ENA_PER_PORT; 11913 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_HASH, 11914 RTE_ETH_FILTER_GET, &info); 11915 11916 if (ret < 0) { 11917 printf("Cannot get symmetric hash enable per port " 11918 "on port %u\n", res->port_id); 11919 return; 11920 } 11921 11922 printf("Symmetric hash is %s on port %u\n", info.info.enable ? 11923 "enabled" : "disabled", res->port_id); 11924 } 11925 11926 cmdline_parse_token_string_t cmd_get_sym_hash_ena_per_port_all = 11927 TOKEN_STRING_INITIALIZER(struct cmd_get_sym_hash_ena_per_port_result, 11928 get_sym_hash_ena_per_port, "get_sym_hash_ena_per_port"); 11929 cmdline_parse_token_num_t cmd_get_sym_hash_ena_per_port_port_id = 11930 TOKEN_NUM_INITIALIZER(struct cmd_get_sym_hash_ena_per_port_result, 11931 port_id, UINT16); 11932 11933 cmdline_parse_inst_t cmd_get_sym_hash_ena_per_port = { 11934 .f = cmd_get_sym_hash_per_port_parsed, 11935 .data = NULL, 11936 .help_str = "get_sym_hash_ena_per_port <port_id>", 11937 .tokens = { 11938 (void *)&cmd_get_sym_hash_ena_per_port_all, 11939 (void *)&cmd_get_sym_hash_ena_per_port_port_id, 11940 NULL, 11941 }, 11942 }; 11943 11944 /* *** Set symmetric hash enable per port *** */ 11945 struct cmd_set_sym_hash_ena_per_port_result { 11946 cmdline_fixed_string_t set_sym_hash_ena_per_port; 11947 cmdline_fixed_string_t enable; 11948 portid_t port_id; 11949 }; 11950 11951 static void 11952 cmd_set_sym_hash_per_port_parsed(void *parsed_result, 11953 __rte_unused struct cmdline *cl, 11954 __rte_unused void *data) 11955 { 11956 struct cmd_set_sym_hash_ena_per_port_result *res = parsed_result; 11957 struct rte_eth_hash_filter_info info; 11958 int ret; 11959 11960 if (rte_eth_dev_filter_supported(res->port_id, 11961 RTE_ETH_FILTER_HASH) < 0) { 11962 printf("RTE_ETH_FILTER_HASH not supported on port: %d\n", 11963 res->port_id); 11964 return; 11965 } 11966 11967 memset(&info, 0, sizeof(info)); 11968 info.info_type = RTE_ETH_HASH_FILTER_SYM_HASH_ENA_PER_PORT; 11969 if (!strcmp(res->enable, "enable")) 11970 info.info.enable = 1; 11971 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_HASH, 11972 RTE_ETH_FILTER_SET, &info); 11973 if (ret < 0) { 11974 printf("Cannot set symmetric hash enable per port on " 11975 "port %u\n", res->port_id); 11976 return; 11977 } 11978 printf("Symmetric hash has been set to %s on port %u\n", 11979 res->enable, res->port_id); 11980 } 11981 11982 cmdline_parse_token_string_t cmd_set_sym_hash_ena_per_port_all = 11983 TOKEN_STRING_INITIALIZER(struct cmd_set_sym_hash_ena_per_port_result, 11984 set_sym_hash_ena_per_port, "set_sym_hash_ena_per_port"); 11985 cmdline_parse_token_num_t cmd_set_sym_hash_ena_per_port_port_id = 11986 TOKEN_NUM_INITIALIZER(struct cmd_set_sym_hash_ena_per_port_result, 11987 port_id, UINT16); 11988 cmdline_parse_token_string_t cmd_set_sym_hash_ena_per_port_enable = 11989 TOKEN_STRING_INITIALIZER(struct cmd_set_sym_hash_ena_per_port_result, 11990 enable, "enable#disable"); 11991 11992 cmdline_parse_inst_t cmd_set_sym_hash_ena_per_port = { 11993 .f = cmd_set_sym_hash_per_port_parsed, 11994 .data = NULL, 11995 .help_str = "set_sym_hash_ena_per_port <port_id> enable|disable", 11996 .tokens = { 11997 (void *)&cmd_set_sym_hash_ena_per_port_all, 11998 (void *)&cmd_set_sym_hash_ena_per_port_port_id, 11999 (void *)&cmd_set_sym_hash_ena_per_port_enable, 12000 NULL, 12001 }, 12002 }; 12003 12004 /* Get global config of hash function */ 12005 struct cmd_get_hash_global_config_result { 12006 cmdline_fixed_string_t get_hash_global_config; 12007 portid_t port_id; 12008 }; 12009 12010 static char * 12011 flowtype_to_str(uint16_t ftype) 12012 { 12013 uint16_t i; 12014 static struct { 12015 char str[16]; 12016 uint16_t ftype; 12017 } ftype_table[] = { 12018 {"ipv4", RTE_ETH_FLOW_IPV4}, 12019 {"ipv4-frag", RTE_ETH_FLOW_FRAG_IPV4}, 12020 {"ipv4-tcp", RTE_ETH_FLOW_NONFRAG_IPV4_TCP}, 12021 {"ipv4-udp", RTE_ETH_FLOW_NONFRAG_IPV4_UDP}, 12022 {"ipv4-sctp", RTE_ETH_FLOW_NONFRAG_IPV4_SCTP}, 12023 {"ipv4-other", RTE_ETH_FLOW_NONFRAG_IPV4_OTHER}, 12024 {"ipv6", RTE_ETH_FLOW_IPV6}, 12025 {"ipv6-frag", RTE_ETH_FLOW_FRAG_IPV6}, 12026 {"ipv6-tcp", RTE_ETH_FLOW_NONFRAG_IPV6_TCP}, 12027 {"ipv6-udp", RTE_ETH_FLOW_NONFRAG_IPV6_UDP}, 12028 {"ipv6-sctp", RTE_ETH_FLOW_NONFRAG_IPV6_SCTP}, 12029 {"ipv6-other", RTE_ETH_FLOW_NONFRAG_IPV6_OTHER}, 12030 {"l2_payload", RTE_ETH_FLOW_L2_PAYLOAD}, 12031 {"port", RTE_ETH_FLOW_PORT}, 12032 {"vxlan", RTE_ETH_FLOW_VXLAN}, 12033 {"geneve", RTE_ETH_FLOW_GENEVE}, 12034 {"nvgre", RTE_ETH_FLOW_NVGRE}, 12035 }; 12036 12037 for (i = 0; i < RTE_DIM(ftype_table); i++) { 12038 if (ftype_table[i].ftype == ftype) 12039 return ftype_table[i].str; 12040 } 12041 12042 return NULL; 12043 } 12044 12045 static void 12046 cmd_get_hash_global_config_parsed(void *parsed_result, 12047 __rte_unused struct cmdline *cl, 12048 __rte_unused void *data) 12049 { 12050 struct cmd_get_hash_global_config_result *res = parsed_result; 12051 struct rte_eth_hash_filter_info info; 12052 uint32_t idx, offset; 12053 uint16_t i; 12054 char *str; 12055 int ret; 12056 12057 if (rte_eth_dev_filter_supported(res->port_id, 12058 RTE_ETH_FILTER_HASH) < 0) { 12059 printf("RTE_ETH_FILTER_HASH not supported on port %d\n", 12060 res->port_id); 12061 return; 12062 } 12063 12064 memset(&info, 0, sizeof(info)); 12065 info.info_type = RTE_ETH_HASH_FILTER_GLOBAL_CONFIG; 12066 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_HASH, 12067 RTE_ETH_FILTER_GET, &info); 12068 if (ret < 0) { 12069 printf("Cannot get hash global configurations by port %d\n", 12070 res->port_id); 12071 return; 12072 } 12073 12074 switch (info.info.global_conf.hash_func) { 12075 case RTE_ETH_HASH_FUNCTION_TOEPLITZ: 12076 printf("Hash function is Toeplitz\n"); 12077 break; 12078 case RTE_ETH_HASH_FUNCTION_SIMPLE_XOR: 12079 printf("Hash function is Simple XOR\n"); 12080 break; 12081 default: 12082 printf("Unknown hash function\n"); 12083 break; 12084 } 12085 12086 for (i = 0; i < RTE_ETH_FLOW_MAX; i++) { 12087 idx = i / UINT64_BIT; 12088 offset = i % UINT64_BIT; 12089 if (!(info.info.global_conf.valid_bit_mask[idx] & 12090 (1ULL << offset))) 12091 continue; 12092 str = flowtype_to_str(i); 12093 if (!str) 12094 continue; 12095 printf("Symmetric hash is %s globally for flow type %s " 12096 "by port %d\n", 12097 ((info.info.global_conf.sym_hash_enable_mask[idx] & 12098 (1ULL << offset)) ? "enabled" : "disabled"), str, 12099 res->port_id); 12100 } 12101 } 12102 12103 cmdline_parse_token_string_t cmd_get_hash_global_config_all = 12104 TOKEN_STRING_INITIALIZER(struct cmd_get_hash_global_config_result, 12105 get_hash_global_config, "get_hash_global_config"); 12106 cmdline_parse_token_num_t cmd_get_hash_global_config_port_id = 12107 TOKEN_NUM_INITIALIZER(struct cmd_get_hash_global_config_result, 12108 port_id, UINT16); 12109 12110 cmdline_parse_inst_t cmd_get_hash_global_config = { 12111 .f = cmd_get_hash_global_config_parsed, 12112 .data = NULL, 12113 .help_str = "get_hash_global_config <port_id>", 12114 .tokens = { 12115 (void *)&cmd_get_hash_global_config_all, 12116 (void *)&cmd_get_hash_global_config_port_id, 12117 NULL, 12118 }, 12119 }; 12120 12121 /* Set global config of hash function */ 12122 struct cmd_set_hash_global_config_result { 12123 cmdline_fixed_string_t set_hash_global_config; 12124 portid_t port_id; 12125 cmdline_fixed_string_t hash_func; 12126 cmdline_fixed_string_t flow_type; 12127 cmdline_fixed_string_t enable; 12128 }; 12129 12130 static void 12131 cmd_set_hash_global_config_parsed(void *parsed_result, 12132 __rte_unused struct cmdline *cl, 12133 __rte_unused void *data) 12134 { 12135 struct cmd_set_hash_global_config_result *res = parsed_result; 12136 struct rte_eth_hash_filter_info info; 12137 uint32_t ftype, idx, offset; 12138 int ret; 12139 12140 if (rte_eth_dev_filter_supported(res->port_id, 12141 RTE_ETH_FILTER_HASH) < 0) { 12142 printf("RTE_ETH_FILTER_HASH not supported on port %d\n", 12143 res->port_id); 12144 return; 12145 } 12146 memset(&info, 0, sizeof(info)); 12147 info.info_type = RTE_ETH_HASH_FILTER_GLOBAL_CONFIG; 12148 if (!strcmp(res->hash_func, "toeplitz")) 12149 info.info.global_conf.hash_func = 12150 RTE_ETH_HASH_FUNCTION_TOEPLITZ; 12151 else if (!strcmp(res->hash_func, "simple_xor")) 12152 info.info.global_conf.hash_func = 12153 RTE_ETH_HASH_FUNCTION_SIMPLE_XOR; 12154 else if (!strcmp(res->hash_func, "default")) 12155 info.info.global_conf.hash_func = 12156 RTE_ETH_HASH_FUNCTION_DEFAULT; 12157 12158 ftype = str2flowtype(res->flow_type); 12159 idx = ftype / UINT64_BIT; 12160 offset = ftype % UINT64_BIT; 12161 info.info.global_conf.valid_bit_mask[idx] |= (1ULL << offset); 12162 if (!strcmp(res->enable, "enable")) 12163 info.info.global_conf.sym_hash_enable_mask[idx] |= 12164 (1ULL << offset); 12165 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_HASH, 12166 RTE_ETH_FILTER_SET, &info); 12167 if (ret < 0) 12168 printf("Cannot set global hash configurations by port %d\n", 12169 res->port_id); 12170 else 12171 printf("Global hash configurations have been set " 12172 "successfully by port %d\n", res->port_id); 12173 } 12174 12175 cmdline_parse_token_string_t cmd_set_hash_global_config_all = 12176 TOKEN_STRING_INITIALIZER(struct cmd_set_hash_global_config_result, 12177 set_hash_global_config, "set_hash_global_config"); 12178 cmdline_parse_token_num_t cmd_set_hash_global_config_port_id = 12179 TOKEN_NUM_INITIALIZER(struct cmd_set_hash_global_config_result, 12180 port_id, UINT16); 12181 cmdline_parse_token_string_t cmd_set_hash_global_config_hash_func = 12182 TOKEN_STRING_INITIALIZER(struct cmd_set_hash_global_config_result, 12183 hash_func, "toeplitz#simple_xor#default"); 12184 cmdline_parse_token_string_t cmd_set_hash_global_config_flow_type = 12185 TOKEN_STRING_INITIALIZER(struct cmd_set_hash_global_config_result, 12186 flow_type, 12187 "ipv4#ipv4-frag#ipv4-tcp#ipv4-udp#ipv4-sctp#ipv4-other#ipv6#" 12188 "ipv6-frag#ipv6-tcp#ipv6-udp#ipv6-sctp#ipv6-other#l2_payload"); 12189 cmdline_parse_token_string_t cmd_set_hash_global_config_enable = 12190 TOKEN_STRING_INITIALIZER(struct cmd_set_hash_global_config_result, 12191 enable, "enable#disable"); 12192 12193 cmdline_parse_inst_t cmd_set_hash_global_config = { 12194 .f = cmd_set_hash_global_config_parsed, 12195 .data = NULL, 12196 .help_str = "set_hash_global_config <port_id> " 12197 "toeplitz|simple_xor|default " 12198 "ipv4|ipv4-frag|ipv4-tcp|ipv4-udp|ipv4-sctp|ipv4-other|" 12199 "ipv6|ipv6-frag|ipv6-tcp|ipv6-udp|ipv6-sctp|ipv6-other|" 12200 "l2_payload enable|disable", 12201 .tokens = { 12202 (void *)&cmd_set_hash_global_config_all, 12203 (void *)&cmd_set_hash_global_config_port_id, 12204 (void *)&cmd_set_hash_global_config_hash_func, 12205 (void *)&cmd_set_hash_global_config_flow_type, 12206 (void *)&cmd_set_hash_global_config_enable, 12207 NULL, 12208 }, 12209 }; 12210 12211 /* Set hash input set */ 12212 struct cmd_set_hash_input_set_result { 12213 cmdline_fixed_string_t set_hash_input_set; 12214 portid_t port_id; 12215 cmdline_fixed_string_t flow_type; 12216 cmdline_fixed_string_t inset_field; 12217 cmdline_fixed_string_t select; 12218 }; 12219 12220 static enum rte_eth_input_set_field 12221 str2inset(char *string) 12222 { 12223 uint16_t i; 12224 12225 static const struct { 12226 char str[32]; 12227 enum rte_eth_input_set_field inset; 12228 } inset_table[] = { 12229 {"ethertype", RTE_ETH_INPUT_SET_L2_ETHERTYPE}, 12230 {"ovlan", RTE_ETH_INPUT_SET_L2_OUTER_VLAN}, 12231 {"ivlan", RTE_ETH_INPUT_SET_L2_INNER_VLAN}, 12232 {"src-ipv4", RTE_ETH_INPUT_SET_L3_SRC_IP4}, 12233 {"dst-ipv4", RTE_ETH_INPUT_SET_L3_DST_IP4}, 12234 {"ipv4-tos", RTE_ETH_INPUT_SET_L3_IP4_TOS}, 12235 {"ipv4-proto", RTE_ETH_INPUT_SET_L3_IP4_PROTO}, 12236 {"ipv4-ttl", RTE_ETH_INPUT_SET_L3_IP4_TTL}, 12237 {"src-ipv6", RTE_ETH_INPUT_SET_L3_SRC_IP6}, 12238 {"dst-ipv6", RTE_ETH_INPUT_SET_L3_DST_IP6}, 12239 {"ipv6-tc", RTE_ETH_INPUT_SET_L3_IP6_TC}, 12240 {"ipv6-next-header", RTE_ETH_INPUT_SET_L3_IP6_NEXT_HEADER}, 12241 {"ipv6-hop-limits", RTE_ETH_INPUT_SET_L3_IP6_HOP_LIMITS}, 12242 {"udp-src-port", RTE_ETH_INPUT_SET_L4_UDP_SRC_PORT}, 12243 {"udp-dst-port", RTE_ETH_INPUT_SET_L4_UDP_DST_PORT}, 12244 {"tcp-src-port", RTE_ETH_INPUT_SET_L4_TCP_SRC_PORT}, 12245 {"tcp-dst-port", RTE_ETH_INPUT_SET_L4_TCP_DST_PORT}, 12246 {"sctp-src-port", RTE_ETH_INPUT_SET_L4_SCTP_SRC_PORT}, 12247 {"sctp-dst-port", RTE_ETH_INPUT_SET_L4_SCTP_DST_PORT}, 12248 {"sctp-veri-tag", RTE_ETH_INPUT_SET_L4_SCTP_VERIFICATION_TAG}, 12249 {"udp-key", RTE_ETH_INPUT_SET_TUNNEL_L4_UDP_KEY}, 12250 {"gre-key", RTE_ETH_INPUT_SET_TUNNEL_GRE_KEY}, 12251 {"fld-1st", RTE_ETH_INPUT_SET_FLEX_PAYLOAD_1ST_WORD}, 12252 {"fld-2nd", RTE_ETH_INPUT_SET_FLEX_PAYLOAD_2ND_WORD}, 12253 {"fld-3rd", RTE_ETH_INPUT_SET_FLEX_PAYLOAD_3RD_WORD}, 12254 {"fld-4th", RTE_ETH_INPUT_SET_FLEX_PAYLOAD_4TH_WORD}, 12255 {"fld-5th", RTE_ETH_INPUT_SET_FLEX_PAYLOAD_5TH_WORD}, 12256 {"fld-6th", RTE_ETH_INPUT_SET_FLEX_PAYLOAD_6TH_WORD}, 12257 {"fld-7th", RTE_ETH_INPUT_SET_FLEX_PAYLOAD_7TH_WORD}, 12258 {"fld-8th", RTE_ETH_INPUT_SET_FLEX_PAYLOAD_8TH_WORD}, 12259 {"none", RTE_ETH_INPUT_SET_NONE}, 12260 }; 12261 12262 for (i = 0; i < RTE_DIM(inset_table); i++) { 12263 if (!strcmp(string, inset_table[i].str)) 12264 return inset_table[i].inset; 12265 } 12266 12267 return RTE_ETH_INPUT_SET_UNKNOWN; 12268 } 12269 12270 static void 12271 cmd_set_hash_input_set_parsed(void *parsed_result, 12272 __rte_unused struct cmdline *cl, 12273 __rte_unused void *data) 12274 { 12275 struct cmd_set_hash_input_set_result *res = parsed_result; 12276 struct rte_eth_hash_filter_info info; 12277 12278 memset(&info, 0, sizeof(info)); 12279 info.info_type = RTE_ETH_HASH_FILTER_INPUT_SET_SELECT; 12280 info.info.input_set_conf.flow_type = str2flowtype(res->flow_type); 12281 info.info.input_set_conf.field[0] = str2inset(res->inset_field); 12282 info.info.input_set_conf.inset_size = 1; 12283 if (!strcmp(res->select, "select")) 12284 info.info.input_set_conf.op = RTE_ETH_INPUT_SET_SELECT; 12285 else if (!strcmp(res->select, "add")) 12286 info.info.input_set_conf.op = RTE_ETH_INPUT_SET_ADD; 12287 rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_HASH, 12288 RTE_ETH_FILTER_SET, &info); 12289 } 12290 12291 cmdline_parse_token_string_t cmd_set_hash_input_set_cmd = 12292 TOKEN_STRING_INITIALIZER(struct cmd_set_hash_input_set_result, 12293 set_hash_input_set, "set_hash_input_set"); 12294 cmdline_parse_token_num_t cmd_set_hash_input_set_port_id = 12295 TOKEN_NUM_INITIALIZER(struct cmd_set_hash_input_set_result, 12296 port_id, UINT16); 12297 cmdline_parse_token_string_t cmd_set_hash_input_set_flow_type = 12298 TOKEN_STRING_INITIALIZER(struct cmd_set_hash_input_set_result, 12299 flow_type, NULL); 12300 cmdline_parse_token_string_t cmd_set_hash_input_set_field = 12301 TOKEN_STRING_INITIALIZER(struct cmd_set_hash_input_set_result, 12302 inset_field, 12303 "ovlan#ivlan#src-ipv4#dst-ipv4#src-ipv6#dst-ipv6#" 12304 "ipv4-tos#ipv4-proto#ipv6-tc#ipv6-next-header#udp-src-port#" 12305 "udp-dst-port#tcp-src-port#tcp-dst-port#sctp-src-port#" 12306 "sctp-dst-port#sctp-veri-tag#udp-key#gre-key#fld-1st#" 12307 "fld-2nd#fld-3rd#fld-4th#fld-5th#fld-6th#fld-7th#" 12308 "fld-8th#none"); 12309 cmdline_parse_token_string_t cmd_set_hash_input_set_select = 12310 TOKEN_STRING_INITIALIZER(struct cmd_set_hash_input_set_result, 12311 select, "select#add"); 12312 12313 cmdline_parse_inst_t cmd_set_hash_input_set = { 12314 .f = cmd_set_hash_input_set_parsed, 12315 .data = NULL, 12316 .help_str = "set_hash_input_set <port_id> " 12317 "ipv4-frag|ipv4-tcp|ipv4-udp|ipv4-sctp|ipv4-other|" 12318 "ipv6-frag|ipv6-tcp|ipv6-udp|ipv6-sctp|ipv6-other|l2_payload|<flowtype_id> " 12319 "ovlan|ivlan|src-ipv4|dst-ipv4|src-ipv6|dst-ipv6|ipv4-tos|ipv4-proto|" 12320 "ipv6-tc|ipv6-next-header|udp-src-port|udp-dst-port|tcp-src-port|" 12321 "tcp-dst-port|sctp-src-port|sctp-dst-port|sctp-veri-tag|udp-key|" 12322 "gre-key|fld-1st|fld-2nd|fld-3rd|fld-4th|fld-5th|fld-6th|" 12323 "fld-7th|fld-8th|none select|add", 12324 .tokens = { 12325 (void *)&cmd_set_hash_input_set_cmd, 12326 (void *)&cmd_set_hash_input_set_port_id, 12327 (void *)&cmd_set_hash_input_set_flow_type, 12328 (void *)&cmd_set_hash_input_set_field, 12329 (void *)&cmd_set_hash_input_set_select, 12330 NULL, 12331 }, 12332 }; 12333 12334 /* Set flow director input set */ 12335 struct cmd_set_fdir_input_set_result { 12336 cmdline_fixed_string_t set_fdir_input_set; 12337 portid_t port_id; 12338 cmdline_fixed_string_t flow_type; 12339 cmdline_fixed_string_t inset_field; 12340 cmdline_fixed_string_t select; 12341 }; 12342 12343 static void 12344 cmd_set_fdir_input_set_parsed(void *parsed_result, 12345 __rte_unused struct cmdline *cl, 12346 __rte_unused void *data) 12347 { 12348 struct cmd_set_fdir_input_set_result *res = parsed_result; 12349 struct rte_eth_fdir_filter_info info; 12350 12351 memset(&info, 0, sizeof(info)); 12352 info.info_type = RTE_ETH_FDIR_FILTER_INPUT_SET_SELECT; 12353 info.info.input_set_conf.flow_type = str2flowtype(res->flow_type); 12354 info.info.input_set_conf.field[0] = str2inset(res->inset_field); 12355 info.info.input_set_conf.inset_size = 1; 12356 if (!strcmp(res->select, "select")) 12357 info.info.input_set_conf.op = RTE_ETH_INPUT_SET_SELECT; 12358 else if (!strcmp(res->select, "add")) 12359 info.info.input_set_conf.op = RTE_ETH_INPUT_SET_ADD; 12360 rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_FDIR, 12361 RTE_ETH_FILTER_SET, &info); 12362 } 12363 12364 cmdline_parse_token_string_t cmd_set_fdir_input_set_cmd = 12365 TOKEN_STRING_INITIALIZER(struct cmd_set_fdir_input_set_result, 12366 set_fdir_input_set, "set_fdir_input_set"); 12367 cmdline_parse_token_num_t cmd_set_fdir_input_set_port_id = 12368 TOKEN_NUM_INITIALIZER(struct cmd_set_fdir_input_set_result, 12369 port_id, UINT16); 12370 cmdline_parse_token_string_t cmd_set_fdir_input_set_flow_type = 12371 TOKEN_STRING_INITIALIZER(struct cmd_set_fdir_input_set_result, 12372 flow_type, 12373 "ipv4-frag#ipv4-tcp#ipv4-udp#ipv4-sctp#ipv4-other#" 12374 "ipv6-frag#ipv6-tcp#ipv6-udp#ipv6-sctp#ipv6-other#l2_payload"); 12375 cmdline_parse_token_string_t cmd_set_fdir_input_set_field = 12376 TOKEN_STRING_INITIALIZER(struct cmd_set_fdir_input_set_result, 12377 inset_field, 12378 "ivlan#ethertype#src-ipv4#dst-ipv4#src-ipv6#dst-ipv6#" 12379 "ipv4-tos#ipv4-proto#ipv4-ttl#ipv6-tc#ipv6-next-header#" 12380 "ipv6-hop-limits#udp-src-port#udp-dst-port#" 12381 "tcp-src-port#tcp-dst-port#sctp-src-port#sctp-dst-port#" 12382 "sctp-veri-tag#none"); 12383 cmdline_parse_token_string_t cmd_set_fdir_input_set_select = 12384 TOKEN_STRING_INITIALIZER(struct cmd_set_fdir_input_set_result, 12385 select, "select#add"); 12386 12387 cmdline_parse_inst_t cmd_set_fdir_input_set = { 12388 .f = cmd_set_fdir_input_set_parsed, 12389 .data = NULL, 12390 .help_str = "set_fdir_input_set <port_id> " 12391 "ipv4-frag|ipv4-tcp|ipv4-udp|ipv4-sctp|ipv4-other|" 12392 "ipv6-frag|ipv6-tcp|ipv6-udp|ipv6-sctp|ipv6-other|l2_payload " 12393 "ivlan|ethertype|src-ipv4|dst-ipv4|src-ipv6|dst-ipv6|" 12394 "ipv4-tos|ipv4-proto|ipv4-ttl|ipv6-tc|ipv6-next-header|" 12395 "ipv6-hop-limits|udp-src-port|udp-dst-port|" 12396 "tcp-src-port|tcp-dst-port|sctp-src-port|sctp-dst-port|" 12397 "sctp-veri-tag|none select|add", 12398 .tokens = { 12399 (void *)&cmd_set_fdir_input_set_cmd, 12400 (void *)&cmd_set_fdir_input_set_port_id, 12401 (void *)&cmd_set_fdir_input_set_flow_type, 12402 (void *)&cmd_set_fdir_input_set_field, 12403 (void *)&cmd_set_fdir_input_set_select, 12404 NULL, 12405 }, 12406 }; 12407 12408 /* *** ADD/REMOVE A MULTICAST MAC ADDRESS TO/FROM A PORT *** */ 12409 struct cmd_mcast_addr_result { 12410 cmdline_fixed_string_t mcast_addr_cmd; 12411 cmdline_fixed_string_t what; 12412 uint16_t port_num; 12413 struct ether_addr mc_addr; 12414 }; 12415 12416 static void cmd_mcast_addr_parsed(void *parsed_result, 12417 __attribute__((unused)) struct cmdline *cl, 12418 __attribute__((unused)) void *data) 12419 { 12420 struct cmd_mcast_addr_result *res = parsed_result; 12421 12422 if (!is_multicast_ether_addr(&res->mc_addr)) { 12423 printf("Invalid multicast addr %02X:%02X:%02X:%02X:%02X:%02X\n", 12424 res->mc_addr.addr_bytes[0], res->mc_addr.addr_bytes[1], 12425 res->mc_addr.addr_bytes[2], res->mc_addr.addr_bytes[3], 12426 res->mc_addr.addr_bytes[4], res->mc_addr.addr_bytes[5]); 12427 return; 12428 } 12429 if (strcmp(res->what, "add") == 0) 12430 mcast_addr_add(res->port_num, &res->mc_addr); 12431 else 12432 mcast_addr_remove(res->port_num, &res->mc_addr); 12433 } 12434 12435 cmdline_parse_token_string_t cmd_mcast_addr_cmd = 12436 TOKEN_STRING_INITIALIZER(struct cmd_mcast_addr_result, 12437 mcast_addr_cmd, "mcast_addr"); 12438 cmdline_parse_token_string_t cmd_mcast_addr_what = 12439 TOKEN_STRING_INITIALIZER(struct cmd_mcast_addr_result, what, 12440 "add#remove"); 12441 cmdline_parse_token_num_t cmd_mcast_addr_portnum = 12442 TOKEN_NUM_INITIALIZER(struct cmd_mcast_addr_result, port_num, UINT16); 12443 cmdline_parse_token_etheraddr_t cmd_mcast_addr_addr = 12444 TOKEN_ETHERADDR_INITIALIZER(struct cmd_mac_addr_result, address); 12445 12446 cmdline_parse_inst_t cmd_mcast_addr = { 12447 .f = cmd_mcast_addr_parsed, 12448 .data = (void *)0, 12449 .help_str = "mcast_addr add|remove <port_id> <mcast_addr>: " 12450 "Add/Remove multicast MAC address on port_id", 12451 .tokens = { 12452 (void *)&cmd_mcast_addr_cmd, 12453 (void *)&cmd_mcast_addr_what, 12454 (void *)&cmd_mcast_addr_portnum, 12455 (void *)&cmd_mcast_addr_addr, 12456 NULL, 12457 }, 12458 }; 12459 12460 /* l2 tunnel config 12461 * only support E-tag now. 12462 */ 12463 12464 /* Ether type config */ 12465 struct cmd_config_l2_tunnel_eth_type_result { 12466 cmdline_fixed_string_t port; 12467 cmdline_fixed_string_t config; 12468 cmdline_fixed_string_t all; 12469 portid_t id; 12470 cmdline_fixed_string_t l2_tunnel; 12471 cmdline_fixed_string_t l2_tunnel_type; 12472 cmdline_fixed_string_t eth_type; 12473 uint16_t eth_type_val; 12474 }; 12475 12476 cmdline_parse_token_string_t cmd_config_l2_tunnel_eth_type_port = 12477 TOKEN_STRING_INITIALIZER 12478 (struct cmd_config_l2_tunnel_eth_type_result, 12479 port, "port"); 12480 cmdline_parse_token_string_t cmd_config_l2_tunnel_eth_type_config = 12481 TOKEN_STRING_INITIALIZER 12482 (struct cmd_config_l2_tunnel_eth_type_result, 12483 config, "config"); 12484 cmdline_parse_token_string_t cmd_config_l2_tunnel_eth_type_all_str = 12485 TOKEN_STRING_INITIALIZER 12486 (struct cmd_config_l2_tunnel_eth_type_result, 12487 all, "all"); 12488 cmdline_parse_token_num_t cmd_config_l2_tunnel_eth_type_id = 12489 TOKEN_NUM_INITIALIZER 12490 (struct cmd_config_l2_tunnel_eth_type_result, 12491 id, UINT16); 12492 cmdline_parse_token_string_t cmd_config_l2_tunnel_eth_type_l2_tunnel = 12493 TOKEN_STRING_INITIALIZER 12494 (struct cmd_config_l2_tunnel_eth_type_result, 12495 l2_tunnel, "l2-tunnel"); 12496 cmdline_parse_token_string_t cmd_config_l2_tunnel_eth_type_l2_tunnel_type = 12497 TOKEN_STRING_INITIALIZER 12498 (struct cmd_config_l2_tunnel_eth_type_result, 12499 l2_tunnel_type, "E-tag"); 12500 cmdline_parse_token_string_t cmd_config_l2_tunnel_eth_type_eth_type = 12501 TOKEN_STRING_INITIALIZER 12502 (struct cmd_config_l2_tunnel_eth_type_result, 12503 eth_type, "ether-type"); 12504 cmdline_parse_token_num_t cmd_config_l2_tunnel_eth_type_eth_type_val = 12505 TOKEN_NUM_INITIALIZER 12506 (struct cmd_config_l2_tunnel_eth_type_result, 12507 eth_type_val, UINT16); 12508 12509 static enum rte_eth_tunnel_type 12510 str2fdir_l2_tunnel_type(char *string) 12511 { 12512 uint32_t i = 0; 12513 12514 static const struct { 12515 char str[32]; 12516 enum rte_eth_tunnel_type type; 12517 } l2_tunnel_type_str[] = { 12518 {"E-tag", RTE_L2_TUNNEL_TYPE_E_TAG}, 12519 }; 12520 12521 for (i = 0; i < RTE_DIM(l2_tunnel_type_str); i++) { 12522 if (!strcmp(l2_tunnel_type_str[i].str, string)) 12523 return l2_tunnel_type_str[i].type; 12524 } 12525 return RTE_TUNNEL_TYPE_NONE; 12526 } 12527 12528 /* ether type config for all ports */ 12529 static void 12530 cmd_config_l2_tunnel_eth_type_all_parsed 12531 (void *parsed_result, 12532 __attribute__((unused)) struct cmdline *cl, 12533 __attribute__((unused)) void *data) 12534 { 12535 struct cmd_config_l2_tunnel_eth_type_result *res = parsed_result; 12536 struct rte_eth_l2_tunnel_conf entry; 12537 portid_t pid; 12538 12539 entry.l2_tunnel_type = str2fdir_l2_tunnel_type(res->l2_tunnel_type); 12540 entry.ether_type = res->eth_type_val; 12541 12542 RTE_ETH_FOREACH_DEV(pid) { 12543 rte_eth_dev_l2_tunnel_eth_type_conf(pid, &entry); 12544 } 12545 } 12546 12547 cmdline_parse_inst_t cmd_config_l2_tunnel_eth_type_all = { 12548 .f = cmd_config_l2_tunnel_eth_type_all_parsed, 12549 .data = NULL, 12550 .help_str = "port config all l2-tunnel E-tag ether-type <value>", 12551 .tokens = { 12552 (void *)&cmd_config_l2_tunnel_eth_type_port, 12553 (void *)&cmd_config_l2_tunnel_eth_type_config, 12554 (void *)&cmd_config_l2_tunnel_eth_type_all_str, 12555 (void *)&cmd_config_l2_tunnel_eth_type_l2_tunnel, 12556 (void *)&cmd_config_l2_tunnel_eth_type_l2_tunnel_type, 12557 (void *)&cmd_config_l2_tunnel_eth_type_eth_type, 12558 (void *)&cmd_config_l2_tunnel_eth_type_eth_type_val, 12559 NULL, 12560 }, 12561 }; 12562 12563 /* ether type config for a specific port */ 12564 static void 12565 cmd_config_l2_tunnel_eth_type_specific_parsed( 12566 void *parsed_result, 12567 __attribute__((unused)) struct cmdline *cl, 12568 __attribute__((unused)) void *data) 12569 { 12570 struct cmd_config_l2_tunnel_eth_type_result *res = 12571 parsed_result; 12572 struct rte_eth_l2_tunnel_conf entry; 12573 12574 if (port_id_is_invalid(res->id, ENABLED_WARN)) 12575 return; 12576 12577 entry.l2_tunnel_type = str2fdir_l2_tunnel_type(res->l2_tunnel_type); 12578 entry.ether_type = res->eth_type_val; 12579 12580 rte_eth_dev_l2_tunnel_eth_type_conf(res->id, &entry); 12581 } 12582 12583 cmdline_parse_inst_t cmd_config_l2_tunnel_eth_type_specific = { 12584 .f = cmd_config_l2_tunnel_eth_type_specific_parsed, 12585 .data = NULL, 12586 .help_str = "port config <port_id> l2-tunnel E-tag ether-type <value>", 12587 .tokens = { 12588 (void *)&cmd_config_l2_tunnel_eth_type_port, 12589 (void *)&cmd_config_l2_tunnel_eth_type_config, 12590 (void *)&cmd_config_l2_tunnel_eth_type_id, 12591 (void *)&cmd_config_l2_tunnel_eth_type_l2_tunnel, 12592 (void *)&cmd_config_l2_tunnel_eth_type_l2_tunnel_type, 12593 (void *)&cmd_config_l2_tunnel_eth_type_eth_type, 12594 (void *)&cmd_config_l2_tunnel_eth_type_eth_type_val, 12595 NULL, 12596 }, 12597 }; 12598 12599 /* Enable/disable l2 tunnel */ 12600 struct cmd_config_l2_tunnel_en_dis_result { 12601 cmdline_fixed_string_t port; 12602 cmdline_fixed_string_t config; 12603 cmdline_fixed_string_t all; 12604 portid_t id; 12605 cmdline_fixed_string_t l2_tunnel; 12606 cmdline_fixed_string_t l2_tunnel_type; 12607 cmdline_fixed_string_t en_dis; 12608 }; 12609 12610 cmdline_parse_token_string_t cmd_config_l2_tunnel_en_dis_port = 12611 TOKEN_STRING_INITIALIZER 12612 (struct cmd_config_l2_tunnel_en_dis_result, 12613 port, "port"); 12614 cmdline_parse_token_string_t cmd_config_l2_tunnel_en_dis_config = 12615 TOKEN_STRING_INITIALIZER 12616 (struct cmd_config_l2_tunnel_en_dis_result, 12617 config, "config"); 12618 cmdline_parse_token_string_t cmd_config_l2_tunnel_en_dis_all_str = 12619 TOKEN_STRING_INITIALIZER 12620 (struct cmd_config_l2_tunnel_en_dis_result, 12621 all, "all"); 12622 cmdline_parse_token_num_t cmd_config_l2_tunnel_en_dis_id = 12623 TOKEN_NUM_INITIALIZER 12624 (struct cmd_config_l2_tunnel_en_dis_result, 12625 id, UINT16); 12626 cmdline_parse_token_string_t cmd_config_l2_tunnel_en_dis_l2_tunnel = 12627 TOKEN_STRING_INITIALIZER 12628 (struct cmd_config_l2_tunnel_en_dis_result, 12629 l2_tunnel, "l2-tunnel"); 12630 cmdline_parse_token_string_t cmd_config_l2_tunnel_en_dis_l2_tunnel_type = 12631 TOKEN_STRING_INITIALIZER 12632 (struct cmd_config_l2_tunnel_en_dis_result, 12633 l2_tunnel_type, "E-tag"); 12634 cmdline_parse_token_string_t cmd_config_l2_tunnel_en_dis_en_dis = 12635 TOKEN_STRING_INITIALIZER 12636 (struct cmd_config_l2_tunnel_en_dis_result, 12637 en_dis, "enable#disable"); 12638 12639 /* enable/disable l2 tunnel for all ports */ 12640 static void 12641 cmd_config_l2_tunnel_en_dis_all_parsed( 12642 void *parsed_result, 12643 __attribute__((unused)) struct cmdline *cl, 12644 __attribute__((unused)) void *data) 12645 { 12646 struct cmd_config_l2_tunnel_en_dis_result *res = parsed_result; 12647 struct rte_eth_l2_tunnel_conf entry; 12648 portid_t pid; 12649 uint8_t en; 12650 12651 entry.l2_tunnel_type = str2fdir_l2_tunnel_type(res->l2_tunnel_type); 12652 12653 if (!strcmp("enable", res->en_dis)) 12654 en = 1; 12655 else 12656 en = 0; 12657 12658 RTE_ETH_FOREACH_DEV(pid) { 12659 rte_eth_dev_l2_tunnel_offload_set(pid, 12660 &entry, 12661 ETH_L2_TUNNEL_ENABLE_MASK, 12662 en); 12663 } 12664 } 12665 12666 cmdline_parse_inst_t cmd_config_l2_tunnel_en_dis_all = { 12667 .f = cmd_config_l2_tunnel_en_dis_all_parsed, 12668 .data = NULL, 12669 .help_str = "port config all l2-tunnel E-tag enable|disable", 12670 .tokens = { 12671 (void *)&cmd_config_l2_tunnel_en_dis_port, 12672 (void *)&cmd_config_l2_tunnel_en_dis_config, 12673 (void *)&cmd_config_l2_tunnel_en_dis_all_str, 12674 (void *)&cmd_config_l2_tunnel_en_dis_l2_tunnel, 12675 (void *)&cmd_config_l2_tunnel_en_dis_l2_tunnel_type, 12676 (void *)&cmd_config_l2_tunnel_en_dis_en_dis, 12677 NULL, 12678 }, 12679 }; 12680 12681 /* enable/disable l2 tunnel for a port */ 12682 static void 12683 cmd_config_l2_tunnel_en_dis_specific_parsed( 12684 void *parsed_result, 12685 __attribute__((unused)) struct cmdline *cl, 12686 __attribute__((unused)) void *data) 12687 { 12688 struct cmd_config_l2_tunnel_en_dis_result *res = 12689 parsed_result; 12690 struct rte_eth_l2_tunnel_conf entry; 12691 12692 if (port_id_is_invalid(res->id, ENABLED_WARN)) 12693 return; 12694 12695 entry.l2_tunnel_type = str2fdir_l2_tunnel_type(res->l2_tunnel_type); 12696 12697 if (!strcmp("enable", res->en_dis)) 12698 rte_eth_dev_l2_tunnel_offload_set(res->id, 12699 &entry, 12700 ETH_L2_TUNNEL_ENABLE_MASK, 12701 1); 12702 else 12703 rte_eth_dev_l2_tunnel_offload_set(res->id, 12704 &entry, 12705 ETH_L2_TUNNEL_ENABLE_MASK, 12706 0); 12707 } 12708 12709 cmdline_parse_inst_t cmd_config_l2_tunnel_en_dis_specific = { 12710 .f = cmd_config_l2_tunnel_en_dis_specific_parsed, 12711 .data = NULL, 12712 .help_str = "port config <port_id> l2-tunnel E-tag enable|disable", 12713 .tokens = { 12714 (void *)&cmd_config_l2_tunnel_en_dis_port, 12715 (void *)&cmd_config_l2_tunnel_en_dis_config, 12716 (void *)&cmd_config_l2_tunnel_en_dis_id, 12717 (void *)&cmd_config_l2_tunnel_en_dis_l2_tunnel, 12718 (void *)&cmd_config_l2_tunnel_en_dis_l2_tunnel_type, 12719 (void *)&cmd_config_l2_tunnel_en_dis_en_dis, 12720 NULL, 12721 }, 12722 }; 12723 12724 /* E-tag configuration */ 12725 12726 /* Common result structure for all E-tag configuration */ 12727 struct cmd_config_e_tag_result { 12728 cmdline_fixed_string_t e_tag; 12729 cmdline_fixed_string_t set; 12730 cmdline_fixed_string_t insertion; 12731 cmdline_fixed_string_t stripping; 12732 cmdline_fixed_string_t forwarding; 12733 cmdline_fixed_string_t filter; 12734 cmdline_fixed_string_t add; 12735 cmdline_fixed_string_t del; 12736 cmdline_fixed_string_t on; 12737 cmdline_fixed_string_t off; 12738 cmdline_fixed_string_t on_off; 12739 cmdline_fixed_string_t port_tag_id; 12740 uint32_t port_tag_id_val; 12741 cmdline_fixed_string_t e_tag_id; 12742 uint16_t e_tag_id_val; 12743 cmdline_fixed_string_t dst_pool; 12744 uint8_t dst_pool_val; 12745 cmdline_fixed_string_t port; 12746 portid_t port_id; 12747 cmdline_fixed_string_t vf; 12748 uint8_t vf_id; 12749 }; 12750 12751 /* Common CLI fields for all E-tag configuration */ 12752 cmdline_parse_token_string_t cmd_config_e_tag_e_tag = 12753 TOKEN_STRING_INITIALIZER 12754 (struct cmd_config_e_tag_result, 12755 e_tag, "E-tag"); 12756 cmdline_parse_token_string_t cmd_config_e_tag_set = 12757 TOKEN_STRING_INITIALIZER 12758 (struct cmd_config_e_tag_result, 12759 set, "set"); 12760 cmdline_parse_token_string_t cmd_config_e_tag_insertion = 12761 TOKEN_STRING_INITIALIZER 12762 (struct cmd_config_e_tag_result, 12763 insertion, "insertion"); 12764 cmdline_parse_token_string_t cmd_config_e_tag_stripping = 12765 TOKEN_STRING_INITIALIZER 12766 (struct cmd_config_e_tag_result, 12767 stripping, "stripping"); 12768 cmdline_parse_token_string_t cmd_config_e_tag_forwarding = 12769 TOKEN_STRING_INITIALIZER 12770 (struct cmd_config_e_tag_result, 12771 forwarding, "forwarding"); 12772 cmdline_parse_token_string_t cmd_config_e_tag_filter = 12773 TOKEN_STRING_INITIALIZER 12774 (struct cmd_config_e_tag_result, 12775 filter, "filter"); 12776 cmdline_parse_token_string_t cmd_config_e_tag_add = 12777 TOKEN_STRING_INITIALIZER 12778 (struct cmd_config_e_tag_result, 12779 add, "add"); 12780 cmdline_parse_token_string_t cmd_config_e_tag_del = 12781 TOKEN_STRING_INITIALIZER 12782 (struct cmd_config_e_tag_result, 12783 del, "del"); 12784 cmdline_parse_token_string_t cmd_config_e_tag_on = 12785 TOKEN_STRING_INITIALIZER 12786 (struct cmd_config_e_tag_result, 12787 on, "on"); 12788 cmdline_parse_token_string_t cmd_config_e_tag_off = 12789 TOKEN_STRING_INITIALIZER 12790 (struct cmd_config_e_tag_result, 12791 off, "off"); 12792 cmdline_parse_token_string_t cmd_config_e_tag_on_off = 12793 TOKEN_STRING_INITIALIZER 12794 (struct cmd_config_e_tag_result, 12795 on_off, "on#off"); 12796 cmdline_parse_token_string_t cmd_config_e_tag_port_tag_id = 12797 TOKEN_STRING_INITIALIZER 12798 (struct cmd_config_e_tag_result, 12799 port_tag_id, "port-tag-id"); 12800 cmdline_parse_token_num_t cmd_config_e_tag_port_tag_id_val = 12801 TOKEN_NUM_INITIALIZER 12802 (struct cmd_config_e_tag_result, 12803 port_tag_id_val, UINT32); 12804 cmdline_parse_token_string_t cmd_config_e_tag_e_tag_id = 12805 TOKEN_STRING_INITIALIZER 12806 (struct cmd_config_e_tag_result, 12807 e_tag_id, "e-tag-id"); 12808 cmdline_parse_token_num_t cmd_config_e_tag_e_tag_id_val = 12809 TOKEN_NUM_INITIALIZER 12810 (struct cmd_config_e_tag_result, 12811 e_tag_id_val, UINT16); 12812 cmdline_parse_token_string_t cmd_config_e_tag_dst_pool = 12813 TOKEN_STRING_INITIALIZER 12814 (struct cmd_config_e_tag_result, 12815 dst_pool, "dst-pool"); 12816 cmdline_parse_token_num_t cmd_config_e_tag_dst_pool_val = 12817 TOKEN_NUM_INITIALIZER 12818 (struct cmd_config_e_tag_result, 12819 dst_pool_val, UINT8); 12820 cmdline_parse_token_string_t cmd_config_e_tag_port = 12821 TOKEN_STRING_INITIALIZER 12822 (struct cmd_config_e_tag_result, 12823 port, "port"); 12824 cmdline_parse_token_num_t cmd_config_e_tag_port_id = 12825 TOKEN_NUM_INITIALIZER 12826 (struct cmd_config_e_tag_result, 12827 port_id, UINT16); 12828 cmdline_parse_token_string_t cmd_config_e_tag_vf = 12829 TOKEN_STRING_INITIALIZER 12830 (struct cmd_config_e_tag_result, 12831 vf, "vf"); 12832 cmdline_parse_token_num_t cmd_config_e_tag_vf_id = 12833 TOKEN_NUM_INITIALIZER 12834 (struct cmd_config_e_tag_result, 12835 vf_id, UINT8); 12836 12837 /* E-tag insertion configuration */ 12838 static void 12839 cmd_config_e_tag_insertion_en_parsed( 12840 void *parsed_result, 12841 __attribute__((unused)) struct cmdline *cl, 12842 __attribute__((unused)) void *data) 12843 { 12844 struct cmd_config_e_tag_result *res = 12845 parsed_result; 12846 struct rte_eth_l2_tunnel_conf entry; 12847 12848 if (port_id_is_invalid(res->port_id, ENABLED_WARN)) 12849 return; 12850 12851 entry.l2_tunnel_type = RTE_L2_TUNNEL_TYPE_E_TAG; 12852 entry.tunnel_id = res->port_tag_id_val; 12853 entry.vf_id = res->vf_id; 12854 rte_eth_dev_l2_tunnel_offload_set(res->port_id, 12855 &entry, 12856 ETH_L2_TUNNEL_INSERTION_MASK, 12857 1); 12858 } 12859 12860 static void 12861 cmd_config_e_tag_insertion_dis_parsed( 12862 void *parsed_result, 12863 __attribute__((unused)) struct cmdline *cl, 12864 __attribute__((unused)) void *data) 12865 { 12866 struct cmd_config_e_tag_result *res = 12867 parsed_result; 12868 struct rte_eth_l2_tunnel_conf entry; 12869 12870 if (port_id_is_invalid(res->port_id, ENABLED_WARN)) 12871 return; 12872 12873 entry.l2_tunnel_type = RTE_L2_TUNNEL_TYPE_E_TAG; 12874 entry.vf_id = res->vf_id; 12875 12876 rte_eth_dev_l2_tunnel_offload_set(res->port_id, 12877 &entry, 12878 ETH_L2_TUNNEL_INSERTION_MASK, 12879 0); 12880 } 12881 12882 cmdline_parse_inst_t cmd_config_e_tag_insertion_en = { 12883 .f = cmd_config_e_tag_insertion_en_parsed, 12884 .data = NULL, 12885 .help_str = "E-tag ... : E-tag insertion enable", 12886 .tokens = { 12887 (void *)&cmd_config_e_tag_e_tag, 12888 (void *)&cmd_config_e_tag_set, 12889 (void *)&cmd_config_e_tag_insertion, 12890 (void *)&cmd_config_e_tag_on, 12891 (void *)&cmd_config_e_tag_port_tag_id, 12892 (void *)&cmd_config_e_tag_port_tag_id_val, 12893 (void *)&cmd_config_e_tag_port, 12894 (void *)&cmd_config_e_tag_port_id, 12895 (void *)&cmd_config_e_tag_vf, 12896 (void *)&cmd_config_e_tag_vf_id, 12897 NULL, 12898 }, 12899 }; 12900 12901 cmdline_parse_inst_t cmd_config_e_tag_insertion_dis = { 12902 .f = cmd_config_e_tag_insertion_dis_parsed, 12903 .data = NULL, 12904 .help_str = "E-tag ... : E-tag insertion disable", 12905 .tokens = { 12906 (void *)&cmd_config_e_tag_e_tag, 12907 (void *)&cmd_config_e_tag_set, 12908 (void *)&cmd_config_e_tag_insertion, 12909 (void *)&cmd_config_e_tag_off, 12910 (void *)&cmd_config_e_tag_port, 12911 (void *)&cmd_config_e_tag_port_id, 12912 (void *)&cmd_config_e_tag_vf, 12913 (void *)&cmd_config_e_tag_vf_id, 12914 NULL, 12915 }, 12916 }; 12917 12918 /* E-tag stripping configuration */ 12919 static void 12920 cmd_config_e_tag_stripping_parsed( 12921 void *parsed_result, 12922 __attribute__((unused)) struct cmdline *cl, 12923 __attribute__((unused)) void *data) 12924 { 12925 struct cmd_config_e_tag_result *res = 12926 parsed_result; 12927 struct rte_eth_l2_tunnel_conf entry; 12928 12929 if (port_id_is_invalid(res->port_id, ENABLED_WARN)) 12930 return; 12931 12932 entry.l2_tunnel_type = RTE_L2_TUNNEL_TYPE_E_TAG; 12933 12934 if (!strcmp(res->on_off, "on")) 12935 rte_eth_dev_l2_tunnel_offload_set 12936 (res->port_id, 12937 &entry, 12938 ETH_L2_TUNNEL_STRIPPING_MASK, 12939 1); 12940 else 12941 rte_eth_dev_l2_tunnel_offload_set 12942 (res->port_id, 12943 &entry, 12944 ETH_L2_TUNNEL_STRIPPING_MASK, 12945 0); 12946 } 12947 12948 cmdline_parse_inst_t cmd_config_e_tag_stripping_en_dis = { 12949 .f = cmd_config_e_tag_stripping_parsed, 12950 .data = NULL, 12951 .help_str = "E-tag ... : E-tag stripping enable/disable", 12952 .tokens = { 12953 (void *)&cmd_config_e_tag_e_tag, 12954 (void *)&cmd_config_e_tag_set, 12955 (void *)&cmd_config_e_tag_stripping, 12956 (void *)&cmd_config_e_tag_on_off, 12957 (void *)&cmd_config_e_tag_port, 12958 (void *)&cmd_config_e_tag_port_id, 12959 NULL, 12960 }, 12961 }; 12962 12963 /* E-tag forwarding configuration */ 12964 static void 12965 cmd_config_e_tag_forwarding_parsed( 12966 void *parsed_result, 12967 __attribute__((unused)) struct cmdline *cl, 12968 __attribute__((unused)) void *data) 12969 { 12970 struct cmd_config_e_tag_result *res = parsed_result; 12971 struct rte_eth_l2_tunnel_conf entry; 12972 12973 if (port_id_is_invalid(res->port_id, ENABLED_WARN)) 12974 return; 12975 12976 entry.l2_tunnel_type = RTE_L2_TUNNEL_TYPE_E_TAG; 12977 12978 if (!strcmp(res->on_off, "on")) 12979 rte_eth_dev_l2_tunnel_offload_set 12980 (res->port_id, 12981 &entry, 12982 ETH_L2_TUNNEL_FORWARDING_MASK, 12983 1); 12984 else 12985 rte_eth_dev_l2_tunnel_offload_set 12986 (res->port_id, 12987 &entry, 12988 ETH_L2_TUNNEL_FORWARDING_MASK, 12989 0); 12990 } 12991 12992 cmdline_parse_inst_t cmd_config_e_tag_forwarding_en_dis = { 12993 .f = cmd_config_e_tag_forwarding_parsed, 12994 .data = NULL, 12995 .help_str = "E-tag ... : E-tag forwarding enable/disable", 12996 .tokens = { 12997 (void *)&cmd_config_e_tag_e_tag, 12998 (void *)&cmd_config_e_tag_set, 12999 (void *)&cmd_config_e_tag_forwarding, 13000 (void *)&cmd_config_e_tag_on_off, 13001 (void *)&cmd_config_e_tag_port, 13002 (void *)&cmd_config_e_tag_port_id, 13003 NULL, 13004 }, 13005 }; 13006 13007 /* E-tag filter configuration */ 13008 static void 13009 cmd_config_e_tag_filter_add_parsed( 13010 void *parsed_result, 13011 __attribute__((unused)) struct cmdline *cl, 13012 __attribute__((unused)) void *data) 13013 { 13014 struct cmd_config_e_tag_result *res = parsed_result; 13015 struct rte_eth_l2_tunnel_conf entry; 13016 int ret = 0; 13017 13018 if (port_id_is_invalid(res->port_id, ENABLED_WARN)) 13019 return; 13020 13021 if (res->e_tag_id_val > 0x3fff) { 13022 printf("e-tag-id must be equal or less than 0x3fff.\n"); 13023 return; 13024 } 13025 13026 ret = rte_eth_dev_filter_supported(res->port_id, 13027 RTE_ETH_FILTER_L2_TUNNEL); 13028 if (ret < 0) { 13029 printf("E-tag filter is not supported on port %u.\n", 13030 res->port_id); 13031 return; 13032 } 13033 13034 entry.l2_tunnel_type = RTE_L2_TUNNEL_TYPE_E_TAG; 13035 entry.tunnel_id = res->e_tag_id_val; 13036 entry.pool = res->dst_pool_val; 13037 13038 ret = rte_eth_dev_filter_ctrl(res->port_id, 13039 RTE_ETH_FILTER_L2_TUNNEL, 13040 RTE_ETH_FILTER_ADD, 13041 &entry); 13042 if (ret < 0) 13043 printf("E-tag filter programming error: (%s)\n", 13044 strerror(-ret)); 13045 } 13046 13047 cmdline_parse_inst_t cmd_config_e_tag_filter_add = { 13048 .f = cmd_config_e_tag_filter_add_parsed, 13049 .data = NULL, 13050 .help_str = "E-tag ... : E-tag filter add", 13051 .tokens = { 13052 (void *)&cmd_config_e_tag_e_tag, 13053 (void *)&cmd_config_e_tag_set, 13054 (void *)&cmd_config_e_tag_filter, 13055 (void *)&cmd_config_e_tag_add, 13056 (void *)&cmd_config_e_tag_e_tag_id, 13057 (void *)&cmd_config_e_tag_e_tag_id_val, 13058 (void *)&cmd_config_e_tag_dst_pool, 13059 (void *)&cmd_config_e_tag_dst_pool_val, 13060 (void *)&cmd_config_e_tag_port, 13061 (void *)&cmd_config_e_tag_port_id, 13062 NULL, 13063 }, 13064 }; 13065 13066 static void 13067 cmd_config_e_tag_filter_del_parsed( 13068 void *parsed_result, 13069 __attribute__((unused)) struct cmdline *cl, 13070 __attribute__((unused)) void *data) 13071 { 13072 struct cmd_config_e_tag_result *res = parsed_result; 13073 struct rte_eth_l2_tunnel_conf entry; 13074 int ret = 0; 13075 13076 if (port_id_is_invalid(res->port_id, ENABLED_WARN)) 13077 return; 13078 13079 if (res->e_tag_id_val > 0x3fff) { 13080 printf("e-tag-id must be less than 0x3fff.\n"); 13081 return; 13082 } 13083 13084 ret = rte_eth_dev_filter_supported(res->port_id, 13085 RTE_ETH_FILTER_L2_TUNNEL); 13086 if (ret < 0) { 13087 printf("E-tag filter is not supported on port %u.\n", 13088 res->port_id); 13089 return; 13090 } 13091 13092 entry.l2_tunnel_type = RTE_L2_TUNNEL_TYPE_E_TAG; 13093 entry.tunnel_id = res->e_tag_id_val; 13094 13095 ret = rte_eth_dev_filter_ctrl(res->port_id, 13096 RTE_ETH_FILTER_L2_TUNNEL, 13097 RTE_ETH_FILTER_DELETE, 13098 &entry); 13099 if (ret < 0) 13100 printf("E-tag filter programming error: (%s)\n", 13101 strerror(-ret)); 13102 } 13103 13104 cmdline_parse_inst_t cmd_config_e_tag_filter_del = { 13105 .f = cmd_config_e_tag_filter_del_parsed, 13106 .data = NULL, 13107 .help_str = "E-tag ... : E-tag filter delete", 13108 .tokens = { 13109 (void *)&cmd_config_e_tag_e_tag, 13110 (void *)&cmd_config_e_tag_set, 13111 (void *)&cmd_config_e_tag_filter, 13112 (void *)&cmd_config_e_tag_del, 13113 (void *)&cmd_config_e_tag_e_tag_id, 13114 (void *)&cmd_config_e_tag_e_tag_id_val, 13115 (void *)&cmd_config_e_tag_port, 13116 (void *)&cmd_config_e_tag_port_id, 13117 NULL, 13118 }, 13119 }; 13120 13121 /* vf vlan anti spoof configuration */ 13122 13123 /* Common result structure for vf vlan anti spoof */ 13124 struct cmd_vf_vlan_anti_spoof_result { 13125 cmdline_fixed_string_t set; 13126 cmdline_fixed_string_t vf; 13127 cmdline_fixed_string_t vlan; 13128 cmdline_fixed_string_t antispoof; 13129 portid_t port_id; 13130 uint32_t vf_id; 13131 cmdline_fixed_string_t on_off; 13132 }; 13133 13134 /* Common CLI fields for vf vlan anti spoof enable disable */ 13135 cmdline_parse_token_string_t cmd_vf_vlan_anti_spoof_set = 13136 TOKEN_STRING_INITIALIZER 13137 (struct cmd_vf_vlan_anti_spoof_result, 13138 set, "set"); 13139 cmdline_parse_token_string_t cmd_vf_vlan_anti_spoof_vf = 13140 TOKEN_STRING_INITIALIZER 13141 (struct cmd_vf_vlan_anti_spoof_result, 13142 vf, "vf"); 13143 cmdline_parse_token_string_t cmd_vf_vlan_anti_spoof_vlan = 13144 TOKEN_STRING_INITIALIZER 13145 (struct cmd_vf_vlan_anti_spoof_result, 13146 vlan, "vlan"); 13147 cmdline_parse_token_string_t cmd_vf_vlan_anti_spoof_antispoof = 13148 TOKEN_STRING_INITIALIZER 13149 (struct cmd_vf_vlan_anti_spoof_result, 13150 antispoof, "antispoof"); 13151 cmdline_parse_token_num_t cmd_vf_vlan_anti_spoof_port_id = 13152 TOKEN_NUM_INITIALIZER 13153 (struct cmd_vf_vlan_anti_spoof_result, 13154 port_id, UINT16); 13155 cmdline_parse_token_num_t cmd_vf_vlan_anti_spoof_vf_id = 13156 TOKEN_NUM_INITIALIZER 13157 (struct cmd_vf_vlan_anti_spoof_result, 13158 vf_id, UINT32); 13159 cmdline_parse_token_string_t cmd_vf_vlan_anti_spoof_on_off = 13160 TOKEN_STRING_INITIALIZER 13161 (struct cmd_vf_vlan_anti_spoof_result, 13162 on_off, "on#off"); 13163 13164 static void 13165 cmd_set_vf_vlan_anti_spoof_parsed( 13166 void *parsed_result, 13167 __attribute__((unused)) struct cmdline *cl, 13168 __attribute__((unused)) void *data) 13169 { 13170 struct cmd_vf_vlan_anti_spoof_result *res = parsed_result; 13171 int ret = -ENOTSUP; 13172 13173 __rte_unused int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0; 13174 13175 if (port_id_is_invalid(res->port_id, ENABLED_WARN)) 13176 return; 13177 13178 #ifdef RTE_LIBRTE_IXGBE_PMD 13179 if (ret == -ENOTSUP) 13180 ret = rte_pmd_ixgbe_set_vf_vlan_anti_spoof(res->port_id, 13181 res->vf_id, is_on); 13182 #endif 13183 #ifdef RTE_LIBRTE_I40E_PMD 13184 if (ret == -ENOTSUP) 13185 ret = rte_pmd_i40e_set_vf_vlan_anti_spoof(res->port_id, 13186 res->vf_id, is_on); 13187 #endif 13188 #ifdef RTE_LIBRTE_BNXT_PMD 13189 if (ret == -ENOTSUP) 13190 ret = rte_pmd_bnxt_set_vf_vlan_anti_spoof(res->port_id, 13191 res->vf_id, is_on); 13192 #endif 13193 13194 switch (ret) { 13195 case 0: 13196 break; 13197 case -EINVAL: 13198 printf("invalid vf_id %d\n", res->vf_id); 13199 break; 13200 case -ENODEV: 13201 printf("invalid port_id %d\n", res->port_id); 13202 break; 13203 case -ENOTSUP: 13204 printf("function not implemented\n"); 13205 break; 13206 default: 13207 printf("programming error: (%s)\n", strerror(-ret)); 13208 } 13209 } 13210 13211 cmdline_parse_inst_t cmd_set_vf_vlan_anti_spoof = { 13212 .f = cmd_set_vf_vlan_anti_spoof_parsed, 13213 .data = NULL, 13214 .help_str = "set vf vlan antispoof <port_id> <vf_id> on|off", 13215 .tokens = { 13216 (void *)&cmd_vf_vlan_anti_spoof_set, 13217 (void *)&cmd_vf_vlan_anti_spoof_vf, 13218 (void *)&cmd_vf_vlan_anti_spoof_vlan, 13219 (void *)&cmd_vf_vlan_anti_spoof_antispoof, 13220 (void *)&cmd_vf_vlan_anti_spoof_port_id, 13221 (void *)&cmd_vf_vlan_anti_spoof_vf_id, 13222 (void *)&cmd_vf_vlan_anti_spoof_on_off, 13223 NULL, 13224 }, 13225 }; 13226 13227 /* vf mac anti spoof configuration */ 13228 13229 /* Common result structure for vf mac anti spoof */ 13230 struct cmd_vf_mac_anti_spoof_result { 13231 cmdline_fixed_string_t set; 13232 cmdline_fixed_string_t vf; 13233 cmdline_fixed_string_t mac; 13234 cmdline_fixed_string_t antispoof; 13235 portid_t port_id; 13236 uint32_t vf_id; 13237 cmdline_fixed_string_t on_off; 13238 }; 13239 13240 /* Common CLI fields for vf mac anti spoof enable disable */ 13241 cmdline_parse_token_string_t cmd_vf_mac_anti_spoof_set = 13242 TOKEN_STRING_INITIALIZER 13243 (struct cmd_vf_mac_anti_spoof_result, 13244 set, "set"); 13245 cmdline_parse_token_string_t cmd_vf_mac_anti_spoof_vf = 13246 TOKEN_STRING_INITIALIZER 13247 (struct cmd_vf_mac_anti_spoof_result, 13248 vf, "vf"); 13249 cmdline_parse_token_string_t cmd_vf_mac_anti_spoof_mac = 13250 TOKEN_STRING_INITIALIZER 13251 (struct cmd_vf_mac_anti_spoof_result, 13252 mac, "mac"); 13253 cmdline_parse_token_string_t cmd_vf_mac_anti_spoof_antispoof = 13254 TOKEN_STRING_INITIALIZER 13255 (struct cmd_vf_mac_anti_spoof_result, 13256 antispoof, "antispoof"); 13257 cmdline_parse_token_num_t cmd_vf_mac_anti_spoof_port_id = 13258 TOKEN_NUM_INITIALIZER 13259 (struct cmd_vf_mac_anti_spoof_result, 13260 port_id, UINT16); 13261 cmdline_parse_token_num_t cmd_vf_mac_anti_spoof_vf_id = 13262 TOKEN_NUM_INITIALIZER 13263 (struct cmd_vf_mac_anti_spoof_result, 13264 vf_id, UINT32); 13265 cmdline_parse_token_string_t cmd_vf_mac_anti_spoof_on_off = 13266 TOKEN_STRING_INITIALIZER 13267 (struct cmd_vf_mac_anti_spoof_result, 13268 on_off, "on#off"); 13269 13270 static void 13271 cmd_set_vf_mac_anti_spoof_parsed( 13272 void *parsed_result, 13273 __attribute__((unused)) struct cmdline *cl, 13274 __attribute__((unused)) void *data) 13275 { 13276 struct cmd_vf_mac_anti_spoof_result *res = parsed_result; 13277 int ret = -ENOTSUP; 13278 13279 __rte_unused int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0; 13280 13281 if (port_id_is_invalid(res->port_id, ENABLED_WARN)) 13282 return; 13283 13284 #ifdef RTE_LIBRTE_IXGBE_PMD 13285 if (ret == -ENOTSUP) 13286 ret = rte_pmd_ixgbe_set_vf_mac_anti_spoof(res->port_id, 13287 res->vf_id, is_on); 13288 #endif 13289 #ifdef RTE_LIBRTE_I40E_PMD 13290 if (ret == -ENOTSUP) 13291 ret = rte_pmd_i40e_set_vf_mac_anti_spoof(res->port_id, 13292 res->vf_id, is_on); 13293 #endif 13294 #ifdef RTE_LIBRTE_BNXT_PMD 13295 if (ret == -ENOTSUP) 13296 ret = rte_pmd_bnxt_set_vf_mac_anti_spoof(res->port_id, 13297 res->vf_id, is_on); 13298 #endif 13299 13300 switch (ret) { 13301 case 0: 13302 break; 13303 case -EINVAL: 13304 printf("invalid vf_id %d or is_on %d\n", res->vf_id, is_on); 13305 break; 13306 case -ENODEV: 13307 printf("invalid port_id %d\n", res->port_id); 13308 break; 13309 case -ENOTSUP: 13310 printf("function not implemented\n"); 13311 break; 13312 default: 13313 printf("programming error: (%s)\n", strerror(-ret)); 13314 } 13315 } 13316 13317 cmdline_parse_inst_t cmd_set_vf_mac_anti_spoof = { 13318 .f = cmd_set_vf_mac_anti_spoof_parsed, 13319 .data = NULL, 13320 .help_str = "set vf mac antispoof <port_id> <vf_id> on|off", 13321 .tokens = { 13322 (void *)&cmd_vf_mac_anti_spoof_set, 13323 (void *)&cmd_vf_mac_anti_spoof_vf, 13324 (void *)&cmd_vf_mac_anti_spoof_mac, 13325 (void *)&cmd_vf_mac_anti_spoof_antispoof, 13326 (void *)&cmd_vf_mac_anti_spoof_port_id, 13327 (void *)&cmd_vf_mac_anti_spoof_vf_id, 13328 (void *)&cmd_vf_mac_anti_spoof_on_off, 13329 NULL, 13330 }, 13331 }; 13332 13333 /* vf vlan strip queue configuration */ 13334 13335 /* Common result structure for vf mac anti spoof */ 13336 struct cmd_vf_vlan_stripq_result { 13337 cmdline_fixed_string_t set; 13338 cmdline_fixed_string_t vf; 13339 cmdline_fixed_string_t vlan; 13340 cmdline_fixed_string_t stripq; 13341 portid_t port_id; 13342 uint16_t vf_id; 13343 cmdline_fixed_string_t on_off; 13344 }; 13345 13346 /* Common CLI fields for vf vlan strip enable disable */ 13347 cmdline_parse_token_string_t cmd_vf_vlan_stripq_set = 13348 TOKEN_STRING_INITIALIZER 13349 (struct cmd_vf_vlan_stripq_result, 13350 set, "set"); 13351 cmdline_parse_token_string_t cmd_vf_vlan_stripq_vf = 13352 TOKEN_STRING_INITIALIZER 13353 (struct cmd_vf_vlan_stripq_result, 13354 vf, "vf"); 13355 cmdline_parse_token_string_t cmd_vf_vlan_stripq_vlan = 13356 TOKEN_STRING_INITIALIZER 13357 (struct cmd_vf_vlan_stripq_result, 13358 vlan, "vlan"); 13359 cmdline_parse_token_string_t cmd_vf_vlan_stripq_stripq = 13360 TOKEN_STRING_INITIALIZER 13361 (struct cmd_vf_vlan_stripq_result, 13362 stripq, "stripq"); 13363 cmdline_parse_token_num_t cmd_vf_vlan_stripq_port_id = 13364 TOKEN_NUM_INITIALIZER 13365 (struct cmd_vf_vlan_stripq_result, 13366 port_id, UINT16); 13367 cmdline_parse_token_num_t cmd_vf_vlan_stripq_vf_id = 13368 TOKEN_NUM_INITIALIZER 13369 (struct cmd_vf_vlan_stripq_result, 13370 vf_id, UINT16); 13371 cmdline_parse_token_string_t cmd_vf_vlan_stripq_on_off = 13372 TOKEN_STRING_INITIALIZER 13373 (struct cmd_vf_vlan_stripq_result, 13374 on_off, "on#off"); 13375 13376 static void 13377 cmd_set_vf_vlan_stripq_parsed( 13378 void *parsed_result, 13379 __attribute__((unused)) struct cmdline *cl, 13380 __attribute__((unused)) void *data) 13381 { 13382 struct cmd_vf_vlan_stripq_result *res = parsed_result; 13383 int ret = -ENOTSUP; 13384 13385 __rte_unused int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0; 13386 13387 if (port_id_is_invalid(res->port_id, ENABLED_WARN)) 13388 return; 13389 13390 #ifdef RTE_LIBRTE_IXGBE_PMD 13391 if (ret == -ENOTSUP) 13392 ret = rte_pmd_ixgbe_set_vf_vlan_stripq(res->port_id, 13393 res->vf_id, is_on); 13394 #endif 13395 #ifdef RTE_LIBRTE_I40E_PMD 13396 if (ret == -ENOTSUP) 13397 ret = rte_pmd_i40e_set_vf_vlan_stripq(res->port_id, 13398 res->vf_id, is_on); 13399 #endif 13400 #ifdef RTE_LIBRTE_BNXT_PMD 13401 if (ret == -ENOTSUP) 13402 ret = rte_pmd_bnxt_set_vf_vlan_stripq(res->port_id, 13403 res->vf_id, is_on); 13404 #endif 13405 13406 switch (ret) { 13407 case 0: 13408 break; 13409 case -EINVAL: 13410 printf("invalid vf_id %d or is_on %d\n", res->vf_id, is_on); 13411 break; 13412 case -ENODEV: 13413 printf("invalid port_id %d\n", res->port_id); 13414 break; 13415 case -ENOTSUP: 13416 printf("function not implemented\n"); 13417 break; 13418 default: 13419 printf("programming error: (%s)\n", strerror(-ret)); 13420 } 13421 } 13422 13423 cmdline_parse_inst_t cmd_set_vf_vlan_stripq = { 13424 .f = cmd_set_vf_vlan_stripq_parsed, 13425 .data = NULL, 13426 .help_str = "set vf vlan stripq <port_id> <vf_id> on|off", 13427 .tokens = { 13428 (void *)&cmd_vf_vlan_stripq_set, 13429 (void *)&cmd_vf_vlan_stripq_vf, 13430 (void *)&cmd_vf_vlan_stripq_vlan, 13431 (void *)&cmd_vf_vlan_stripq_stripq, 13432 (void *)&cmd_vf_vlan_stripq_port_id, 13433 (void *)&cmd_vf_vlan_stripq_vf_id, 13434 (void *)&cmd_vf_vlan_stripq_on_off, 13435 NULL, 13436 }, 13437 }; 13438 13439 /* vf vlan insert configuration */ 13440 13441 /* Common result structure for vf vlan insert */ 13442 struct cmd_vf_vlan_insert_result { 13443 cmdline_fixed_string_t set; 13444 cmdline_fixed_string_t vf; 13445 cmdline_fixed_string_t vlan; 13446 cmdline_fixed_string_t insert; 13447 portid_t port_id; 13448 uint16_t vf_id; 13449 uint16_t vlan_id; 13450 }; 13451 13452 /* Common CLI fields for vf vlan insert enable disable */ 13453 cmdline_parse_token_string_t cmd_vf_vlan_insert_set = 13454 TOKEN_STRING_INITIALIZER 13455 (struct cmd_vf_vlan_insert_result, 13456 set, "set"); 13457 cmdline_parse_token_string_t cmd_vf_vlan_insert_vf = 13458 TOKEN_STRING_INITIALIZER 13459 (struct cmd_vf_vlan_insert_result, 13460 vf, "vf"); 13461 cmdline_parse_token_string_t cmd_vf_vlan_insert_vlan = 13462 TOKEN_STRING_INITIALIZER 13463 (struct cmd_vf_vlan_insert_result, 13464 vlan, "vlan"); 13465 cmdline_parse_token_string_t cmd_vf_vlan_insert_insert = 13466 TOKEN_STRING_INITIALIZER 13467 (struct cmd_vf_vlan_insert_result, 13468 insert, "insert"); 13469 cmdline_parse_token_num_t cmd_vf_vlan_insert_port_id = 13470 TOKEN_NUM_INITIALIZER 13471 (struct cmd_vf_vlan_insert_result, 13472 port_id, UINT16); 13473 cmdline_parse_token_num_t cmd_vf_vlan_insert_vf_id = 13474 TOKEN_NUM_INITIALIZER 13475 (struct cmd_vf_vlan_insert_result, 13476 vf_id, UINT16); 13477 cmdline_parse_token_num_t cmd_vf_vlan_insert_vlan_id = 13478 TOKEN_NUM_INITIALIZER 13479 (struct cmd_vf_vlan_insert_result, 13480 vlan_id, UINT16); 13481 13482 static void 13483 cmd_set_vf_vlan_insert_parsed( 13484 void *parsed_result, 13485 __attribute__((unused)) struct cmdline *cl, 13486 __attribute__((unused)) void *data) 13487 { 13488 struct cmd_vf_vlan_insert_result *res = parsed_result; 13489 int ret = -ENOTSUP; 13490 13491 if (port_id_is_invalid(res->port_id, ENABLED_WARN)) 13492 return; 13493 13494 #ifdef RTE_LIBRTE_IXGBE_PMD 13495 if (ret == -ENOTSUP) 13496 ret = rte_pmd_ixgbe_set_vf_vlan_insert(res->port_id, res->vf_id, 13497 res->vlan_id); 13498 #endif 13499 #ifdef RTE_LIBRTE_I40E_PMD 13500 if (ret == -ENOTSUP) 13501 ret = rte_pmd_i40e_set_vf_vlan_insert(res->port_id, res->vf_id, 13502 res->vlan_id); 13503 #endif 13504 #ifdef RTE_LIBRTE_BNXT_PMD 13505 if (ret == -ENOTSUP) 13506 ret = rte_pmd_bnxt_set_vf_vlan_insert(res->port_id, res->vf_id, 13507 res->vlan_id); 13508 #endif 13509 13510 switch (ret) { 13511 case 0: 13512 break; 13513 case -EINVAL: 13514 printf("invalid vf_id %d or vlan_id %d\n", res->vf_id, res->vlan_id); 13515 break; 13516 case -ENODEV: 13517 printf("invalid port_id %d\n", res->port_id); 13518 break; 13519 case -ENOTSUP: 13520 printf("function not implemented\n"); 13521 break; 13522 default: 13523 printf("programming error: (%s)\n", strerror(-ret)); 13524 } 13525 } 13526 13527 cmdline_parse_inst_t cmd_set_vf_vlan_insert = { 13528 .f = cmd_set_vf_vlan_insert_parsed, 13529 .data = NULL, 13530 .help_str = "set vf vlan insert <port_id> <vf_id> <vlan_id>", 13531 .tokens = { 13532 (void *)&cmd_vf_vlan_insert_set, 13533 (void *)&cmd_vf_vlan_insert_vf, 13534 (void *)&cmd_vf_vlan_insert_vlan, 13535 (void *)&cmd_vf_vlan_insert_insert, 13536 (void *)&cmd_vf_vlan_insert_port_id, 13537 (void *)&cmd_vf_vlan_insert_vf_id, 13538 (void *)&cmd_vf_vlan_insert_vlan_id, 13539 NULL, 13540 }, 13541 }; 13542 13543 /* tx loopback configuration */ 13544 13545 /* Common result structure for tx loopback */ 13546 struct cmd_tx_loopback_result { 13547 cmdline_fixed_string_t set; 13548 cmdline_fixed_string_t tx; 13549 cmdline_fixed_string_t loopback; 13550 portid_t port_id; 13551 cmdline_fixed_string_t on_off; 13552 }; 13553 13554 /* Common CLI fields for tx loopback enable disable */ 13555 cmdline_parse_token_string_t cmd_tx_loopback_set = 13556 TOKEN_STRING_INITIALIZER 13557 (struct cmd_tx_loopback_result, 13558 set, "set"); 13559 cmdline_parse_token_string_t cmd_tx_loopback_tx = 13560 TOKEN_STRING_INITIALIZER 13561 (struct cmd_tx_loopback_result, 13562 tx, "tx"); 13563 cmdline_parse_token_string_t cmd_tx_loopback_loopback = 13564 TOKEN_STRING_INITIALIZER 13565 (struct cmd_tx_loopback_result, 13566 loopback, "loopback"); 13567 cmdline_parse_token_num_t cmd_tx_loopback_port_id = 13568 TOKEN_NUM_INITIALIZER 13569 (struct cmd_tx_loopback_result, 13570 port_id, UINT16); 13571 cmdline_parse_token_string_t cmd_tx_loopback_on_off = 13572 TOKEN_STRING_INITIALIZER 13573 (struct cmd_tx_loopback_result, 13574 on_off, "on#off"); 13575 13576 static void 13577 cmd_set_tx_loopback_parsed( 13578 void *parsed_result, 13579 __attribute__((unused)) struct cmdline *cl, 13580 __attribute__((unused)) void *data) 13581 { 13582 struct cmd_tx_loopback_result *res = parsed_result; 13583 int ret = -ENOTSUP; 13584 13585 __rte_unused int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0; 13586 13587 if (port_id_is_invalid(res->port_id, ENABLED_WARN)) 13588 return; 13589 13590 #ifdef RTE_LIBRTE_IXGBE_PMD 13591 if (ret == -ENOTSUP) 13592 ret = rte_pmd_ixgbe_set_tx_loopback(res->port_id, is_on); 13593 #endif 13594 #ifdef RTE_LIBRTE_I40E_PMD 13595 if (ret == -ENOTSUP) 13596 ret = rte_pmd_i40e_set_tx_loopback(res->port_id, is_on); 13597 #endif 13598 #ifdef RTE_LIBRTE_BNXT_PMD 13599 if (ret == -ENOTSUP) 13600 ret = rte_pmd_bnxt_set_tx_loopback(res->port_id, is_on); 13601 #endif 13602 #if defined RTE_LIBRTE_DPAA_BUS && defined RTE_LIBRTE_DPAA_PMD 13603 if (ret == -ENOTSUP) 13604 ret = rte_pmd_dpaa_set_tx_loopback(res->port_id, is_on); 13605 #endif 13606 13607 switch (ret) { 13608 case 0: 13609 break; 13610 case -EINVAL: 13611 printf("invalid is_on %d\n", is_on); 13612 break; 13613 case -ENODEV: 13614 printf("invalid port_id %d\n", res->port_id); 13615 break; 13616 case -ENOTSUP: 13617 printf("function not implemented\n"); 13618 break; 13619 default: 13620 printf("programming error: (%s)\n", strerror(-ret)); 13621 } 13622 } 13623 13624 cmdline_parse_inst_t cmd_set_tx_loopback = { 13625 .f = cmd_set_tx_loopback_parsed, 13626 .data = NULL, 13627 .help_str = "set tx loopback <port_id> on|off", 13628 .tokens = { 13629 (void *)&cmd_tx_loopback_set, 13630 (void *)&cmd_tx_loopback_tx, 13631 (void *)&cmd_tx_loopback_loopback, 13632 (void *)&cmd_tx_loopback_port_id, 13633 (void *)&cmd_tx_loopback_on_off, 13634 NULL, 13635 }, 13636 }; 13637 13638 /* all queues drop enable configuration */ 13639 13640 /* Common result structure for all queues drop enable */ 13641 struct cmd_all_queues_drop_en_result { 13642 cmdline_fixed_string_t set; 13643 cmdline_fixed_string_t all; 13644 cmdline_fixed_string_t queues; 13645 cmdline_fixed_string_t drop; 13646 portid_t port_id; 13647 cmdline_fixed_string_t on_off; 13648 }; 13649 13650 /* Common CLI fields for tx loopback enable disable */ 13651 cmdline_parse_token_string_t cmd_all_queues_drop_en_set = 13652 TOKEN_STRING_INITIALIZER 13653 (struct cmd_all_queues_drop_en_result, 13654 set, "set"); 13655 cmdline_parse_token_string_t cmd_all_queues_drop_en_all = 13656 TOKEN_STRING_INITIALIZER 13657 (struct cmd_all_queues_drop_en_result, 13658 all, "all"); 13659 cmdline_parse_token_string_t cmd_all_queues_drop_en_queues = 13660 TOKEN_STRING_INITIALIZER 13661 (struct cmd_all_queues_drop_en_result, 13662 queues, "queues"); 13663 cmdline_parse_token_string_t cmd_all_queues_drop_en_drop = 13664 TOKEN_STRING_INITIALIZER 13665 (struct cmd_all_queues_drop_en_result, 13666 drop, "drop"); 13667 cmdline_parse_token_num_t cmd_all_queues_drop_en_port_id = 13668 TOKEN_NUM_INITIALIZER 13669 (struct cmd_all_queues_drop_en_result, 13670 port_id, UINT16); 13671 cmdline_parse_token_string_t cmd_all_queues_drop_en_on_off = 13672 TOKEN_STRING_INITIALIZER 13673 (struct cmd_all_queues_drop_en_result, 13674 on_off, "on#off"); 13675 13676 static void 13677 cmd_set_all_queues_drop_en_parsed( 13678 void *parsed_result, 13679 __attribute__((unused)) struct cmdline *cl, 13680 __attribute__((unused)) void *data) 13681 { 13682 struct cmd_all_queues_drop_en_result *res = parsed_result; 13683 int ret = -ENOTSUP; 13684 int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0; 13685 13686 if (port_id_is_invalid(res->port_id, ENABLED_WARN)) 13687 return; 13688 13689 #ifdef RTE_LIBRTE_IXGBE_PMD 13690 if (ret == -ENOTSUP) 13691 ret = rte_pmd_ixgbe_set_all_queues_drop_en(res->port_id, is_on); 13692 #endif 13693 #ifdef RTE_LIBRTE_BNXT_PMD 13694 if (ret == -ENOTSUP) 13695 ret = rte_pmd_bnxt_set_all_queues_drop_en(res->port_id, is_on); 13696 #endif 13697 switch (ret) { 13698 case 0: 13699 break; 13700 case -EINVAL: 13701 printf("invalid is_on %d\n", is_on); 13702 break; 13703 case -ENODEV: 13704 printf("invalid port_id %d\n", res->port_id); 13705 break; 13706 case -ENOTSUP: 13707 printf("function not implemented\n"); 13708 break; 13709 default: 13710 printf("programming error: (%s)\n", strerror(-ret)); 13711 } 13712 } 13713 13714 cmdline_parse_inst_t cmd_set_all_queues_drop_en = { 13715 .f = cmd_set_all_queues_drop_en_parsed, 13716 .data = NULL, 13717 .help_str = "set all queues drop <port_id> on|off", 13718 .tokens = { 13719 (void *)&cmd_all_queues_drop_en_set, 13720 (void *)&cmd_all_queues_drop_en_all, 13721 (void *)&cmd_all_queues_drop_en_queues, 13722 (void *)&cmd_all_queues_drop_en_drop, 13723 (void *)&cmd_all_queues_drop_en_port_id, 13724 (void *)&cmd_all_queues_drop_en_on_off, 13725 NULL, 13726 }, 13727 }; 13728 13729 /* vf split drop enable configuration */ 13730 13731 /* Common result structure for vf split drop enable */ 13732 struct cmd_vf_split_drop_en_result { 13733 cmdline_fixed_string_t set; 13734 cmdline_fixed_string_t vf; 13735 cmdline_fixed_string_t split; 13736 cmdline_fixed_string_t drop; 13737 portid_t port_id; 13738 uint16_t vf_id; 13739 cmdline_fixed_string_t on_off; 13740 }; 13741 13742 /* Common CLI fields for vf split drop enable disable */ 13743 cmdline_parse_token_string_t cmd_vf_split_drop_en_set = 13744 TOKEN_STRING_INITIALIZER 13745 (struct cmd_vf_split_drop_en_result, 13746 set, "set"); 13747 cmdline_parse_token_string_t cmd_vf_split_drop_en_vf = 13748 TOKEN_STRING_INITIALIZER 13749 (struct cmd_vf_split_drop_en_result, 13750 vf, "vf"); 13751 cmdline_parse_token_string_t cmd_vf_split_drop_en_split = 13752 TOKEN_STRING_INITIALIZER 13753 (struct cmd_vf_split_drop_en_result, 13754 split, "split"); 13755 cmdline_parse_token_string_t cmd_vf_split_drop_en_drop = 13756 TOKEN_STRING_INITIALIZER 13757 (struct cmd_vf_split_drop_en_result, 13758 drop, "drop"); 13759 cmdline_parse_token_num_t cmd_vf_split_drop_en_port_id = 13760 TOKEN_NUM_INITIALIZER 13761 (struct cmd_vf_split_drop_en_result, 13762 port_id, UINT16); 13763 cmdline_parse_token_num_t cmd_vf_split_drop_en_vf_id = 13764 TOKEN_NUM_INITIALIZER 13765 (struct cmd_vf_split_drop_en_result, 13766 vf_id, UINT16); 13767 cmdline_parse_token_string_t cmd_vf_split_drop_en_on_off = 13768 TOKEN_STRING_INITIALIZER 13769 (struct cmd_vf_split_drop_en_result, 13770 on_off, "on#off"); 13771 13772 static void 13773 cmd_set_vf_split_drop_en_parsed( 13774 void *parsed_result, 13775 __attribute__((unused)) struct cmdline *cl, 13776 __attribute__((unused)) void *data) 13777 { 13778 struct cmd_vf_split_drop_en_result *res = parsed_result; 13779 int ret = -ENOTSUP; 13780 int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0; 13781 13782 if (port_id_is_invalid(res->port_id, ENABLED_WARN)) 13783 return; 13784 13785 #ifdef RTE_LIBRTE_IXGBE_PMD 13786 ret = rte_pmd_ixgbe_set_vf_split_drop_en(res->port_id, res->vf_id, 13787 is_on); 13788 #endif 13789 switch (ret) { 13790 case 0: 13791 break; 13792 case -EINVAL: 13793 printf("invalid vf_id %d or is_on %d\n", res->vf_id, is_on); 13794 break; 13795 case -ENODEV: 13796 printf("invalid port_id %d\n", res->port_id); 13797 break; 13798 case -ENOTSUP: 13799 printf("not supported on port %d\n", res->port_id); 13800 break; 13801 default: 13802 printf("programming error: (%s)\n", strerror(-ret)); 13803 } 13804 } 13805 13806 cmdline_parse_inst_t cmd_set_vf_split_drop_en = { 13807 .f = cmd_set_vf_split_drop_en_parsed, 13808 .data = NULL, 13809 .help_str = "set vf split drop <port_id> <vf_id> on|off", 13810 .tokens = { 13811 (void *)&cmd_vf_split_drop_en_set, 13812 (void *)&cmd_vf_split_drop_en_vf, 13813 (void *)&cmd_vf_split_drop_en_split, 13814 (void *)&cmd_vf_split_drop_en_drop, 13815 (void *)&cmd_vf_split_drop_en_port_id, 13816 (void *)&cmd_vf_split_drop_en_vf_id, 13817 (void *)&cmd_vf_split_drop_en_on_off, 13818 NULL, 13819 }, 13820 }; 13821 13822 /* vf mac address configuration */ 13823 13824 /* Common result structure for vf mac address */ 13825 struct cmd_set_vf_mac_addr_result { 13826 cmdline_fixed_string_t set; 13827 cmdline_fixed_string_t vf; 13828 cmdline_fixed_string_t mac; 13829 cmdline_fixed_string_t addr; 13830 portid_t port_id; 13831 uint16_t vf_id; 13832 struct ether_addr mac_addr; 13833 13834 }; 13835 13836 /* Common CLI fields for vf split drop enable disable */ 13837 cmdline_parse_token_string_t cmd_set_vf_mac_addr_set = 13838 TOKEN_STRING_INITIALIZER 13839 (struct cmd_set_vf_mac_addr_result, 13840 set, "set"); 13841 cmdline_parse_token_string_t cmd_set_vf_mac_addr_vf = 13842 TOKEN_STRING_INITIALIZER 13843 (struct cmd_set_vf_mac_addr_result, 13844 vf, "vf"); 13845 cmdline_parse_token_string_t cmd_set_vf_mac_addr_mac = 13846 TOKEN_STRING_INITIALIZER 13847 (struct cmd_set_vf_mac_addr_result, 13848 mac, "mac"); 13849 cmdline_parse_token_string_t cmd_set_vf_mac_addr_addr = 13850 TOKEN_STRING_INITIALIZER 13851 (struct cmd_set_vf_mac_addr_result, 13852 addr, "addr"); 13853 cmdline_parse_token_num_t cmd_set_vf_mac_addr_port_id = 13854 TOKEN_NUM_INITIALIZER 13855 (struct cmd_set_vf_mac_addr_result, 13856 port_id, UINT16); 13857 cmdline_parse_token_num_t cmd_set_vf_mac_addr_vf_id = 13858 TOKEN_NUM_INITIALIZER 13859 (struct cmd_set_vf_mac_addr_result, 13860 vf_id, UINT16); 13861 cmdline_parse_token_etheraddr_t cmd_set_vf_mac_addr_mac_addr = 13862 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_vf_mac_addr_result, 13863 mac_addr); 13864 13865 static void 13866 cmd_set_vf_mac_addr_parsed( 13867 void *parsed_result, 13868 __attribute__((unused)) struct cmdline *cl, 13869 __attribute__((unused)) void *data) 13870 { 13871 struct cmd_set_vf_mac_addr_result *res = parsed_result; 13872 int ret = -ENOTSUP; 13873 13874 if (port_id_is_invalid(res->port_id, ENABLED_WARN)) 13875 return; 13876 13877 #ifdef RTE_LIBRTE_IXGBE_PMD 13878 if (ret == -ENOTSUP) 13879 ret = rte_pmd_ixgbe_set_vf_mac_addr(res->port_id, res->vf_id, 13880 &res->mac_addr); 13881 #endif 13882 #ifdef RTE_LIBRTE_I40E_PMD 13883 if (ret == -ENOTSUP) 13884 ret = rte_pmd_i40e_set_vf_mac_addr(res->port_id, res->vf_id, 13885 &res->mac_addr); 13886 #endif 13887 #ifdef RTE_LIBRTE_BNXT_PMD 13888 if (ret == -ENOTSUP) 13889 ret = rte_pmd_bnxt_set_vf_mac_addr(res->port_id, res->vf_id, 13890 &res->mac_addr); 13891 #endif 13892 13893 switch (ret) { 13894 case 0: 13895 break; 13896 case -EINVAL: 13897 printf("invalid vf_id %d or mac_addr\n", res->vf_id); 13898 break; 13899 case -ENODEV: 13900 printf("invalid port_id %d\n", res->port_id); 13901 break; 13902 case -ENOTSUP: 13903 printf("function not implemented\n"); 13904 break; 13905 default: 13906 printf("programming error: (%s)\n", strerror(-ret)); 13907 } 13908 } 13909 13910 cmdline_parse_inst_t cmd_set_vf_mac_addr = { 13911 .f = cmd_set_vf_mac_addr_parsed, 13912 .data = NULL, 13913 .help_str = "set vf mac addr <port_id> <vf_id> <mac_addr>", 13914 .tokens = { 13915 (void *)&cmd_set_vf_mac_addr_set, 13916 (void *)&cmd_set_vf_mac_addr_vf, 13917 (void *)&cmd_set_vf_mac_addr_mac, 13918 (void *)&cmd_set_vf_mac_addr_addr, 13919 (void *)&cmd_set_vf_mac_addr_port_id, 13920 (void *)&cmd_set_vf_mac_addr_vf_id, 13921 (void *)&cmd_set_vf_mac_addr_mac_addr, 13922 NULL, 13923 }, 13924 }; 13925 13926 /* MACsec configuration */ 13927 13928 /* Common result structure for MACsec offload enable */ 13929 struct cmd_macsec_offload_on_result { 13930 cmdline_fixed_string_t set; 13931 cmdline_fixed_string_t macsec; 13932 cmdline_fixed_string_t offload; 13933 portid_t port_id; 13934 cmdline_fixed_string_t on; 13935 cmdline_fixed_string_t encrypt; 13936 cmdline_fixed_string_t en_on_off; 13937 cmdline_fixed_string_t replay_protect; 13938 cmdline_fixed_string_t rp_on_off; 13939 }; 13940 13941 /* Common CLI fields for MACsec offload disable */ 13942 cmdline_parse_token_string_t cmd_macsec_offload_on_set = 13943 TOKEN_STRING_INITIALIZER 13944 (struct cmd_macsec_offload_on_result, 13945 set, "set"); 13946 cmdline_parse_token_string_t cmd_macsec_offload_on_macsec = 13947 TOKEN_STRING_INITIALIZER 13948 (struct cmd_macsec_offload_on_result, 13949 macsec, "macsec"); 13950 cmdline_parse_token_string_t cmd_macsec_offload_on_offload = 13951 TOKEN_STRING_INITIALIZER 13952 (struct cmd_macsec_offload_on_result, 13953 offload, "offload"); 13954 cmdline_parse_token_num_t cmd_macsec_offload_on_port_id = 13955 TOKEN_NUM_INITIALIZER 13956 (struct cmd_macsec_offload_on_result, 13957 port_id, UINT16); 13958 cmdline_parse_token_string_t cmd_macsec_offload_on_on = 13959 TOKEN_STRING_INITIALIZER 13960 (struct cmd_macsec_offload_on_result, 13961 on, "on"); 13962 cmdline_parse_token_string_t cmd_macsec_offload_on_encrypt = 13963 TOKEN_STRING_INITIALIZER 13964 (struct cmd_macsec_offload_on_result, 13965 encrypt, "encrypt"); 13966 cmdline_parse_token_string_t cmd_macsec_offload_on_en_on_off = 13967 TOKEN_STRING_INITIALIZER 13968 (struct cmd_macsec_offload_on_result, 13969 en_on_off, "on#off"); 13970 cmdline_parse_token_string_t cmd_macsec_offload_on_replay_protect = 13971 TOKEN_STRING_INITIALIZER 13972 (struct cmd_macsec_offload_on_result, 13973 replay_protect, "replay-protect"); 13974 cmdline_parse_token_string_t cmd_macsec_offload_on_rp_on_off = 13975 TOKEN_STRING_INITIALIZER 13976 (struct cmd_macsec_offload_on_result, 13977 rp_on_off, "on#off"); 13978 13979 static void 13980 cmd_set_macsec_offload_on_parsed( 13981 void *parsed_result, 13982 __attribute__((unused)) struct cmdline *cl, 13983 __attribute__((unused)) void *data) 13984 { 13985 struct cmd_macsec_offload_on_result *res = parsed_result; 13986 int ret = -ENOTSUP; 13987 portid_t port_id = res->port_id; 13988 int en = (strcmp(res->en_on_off, "on") == 0) ? 1 : 0; 13989 int rp = (strcmp(res->rp_on_off, "on") == 0) ? 1 : 0; 13990 struct rte_eth_dev_info dev_info; 13991 13992 if (port_id_is_invalid(port_id, ENABLED_WARN)) 13993 return; 13994 if (!port_is_stopped(port_id)) { 13995 printf("Please stop port %d first\n", port_id); 13996 return; 13997 } 13998 13999 rte_eth_dev_info_get(port_id, &dev_info); 14000 if (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_MACSEC_INSERT) { 14001 #ifdef RTE_LIBRTE_IXGBE_PMD 14002 ret = rte_pmd_ixgbe_macsec_enable(port_id, en, rp); 14003 #endif 14004 } 14005 RTE_SET_USED(en); 14006 RTE_SET_USED(rp); 14007 14008 switch (ret) { 14009 case 0: 14010 ports[port_id].dev_conf.txmode.offloads |= 14011 DEV_TX_OFFLOAD_MACSEC_INSERT; 14012 cmd_reconfig_device_queue(port_id, 1, 1); 14013 break; 14014 case -ENODEV: 14015 printf("invalid port_id %d\n", port_id); 14016 break; 14017 case -ENOTSUP: 14018 printf("not supported on port %d\n", port_id); 14019 break; 14020 default: 14021 printf("programming error: (%s)\n", strerror(-ret)); 14022 } 14023 } 14024 14025 cmdline_parse_inst_t cmd_set_macsec_offload_on = { 14026 .f = cmd_set_macsec_offload_on_parsed, 14027 .data = NULL, 14028 .help_str = "set macsec offload <port_id> on " 14029 "encrypt on|off replay-protect on|off", 14030 .tokens = { 14031 (void *)&cmd_macsec_offload_on_set, 14032 (void *)&cmd_macsec_offload_on_macsec, 14033 (void *)&cmd_macsec_offload_on_offload, 14034 (void *)&cmd_macsec_offload_on_port_id, 14035 (void *)&cmd_macsec_offload_on_on, 14036 (void *)&cmd_macsec_offload_on_encrypt, 14037 (void *)&cmd_macsec_offload_on_en_on_off, 14038 (void *)&cmd_macsec_offload_on_replay_protect, 14039 (void *)&cmd_macsec_offload_on_rp_on_off, 14040 NULL, 14041 }, 14042 }; 14043 14044 /* Common result structure for MACsec offload disable */ 14045 struct cmd_macsec_offload_off_result { 14046 cmdline_fixed_string_t set; 14047 cmdline_fixed_string_t macsec; 14048 cmdline_fixed_string_t offload; 14049 portid_t port_id; 14050 cmdline_fixed_string_t off; 14051 }; 14052 14053 /* Common CLI fields for MACsec offload disable */ 14054 cmdline_parse_token_string_t cmd_macsec_offload_off_set = 14055 TOKEN_STRING_INITIALIZER 14056 (struct cmd_macsec_offload_off_result, 14057 set, "set"); 14058 cmdline_parse_token_string_t cmd_macsec_offload_off_macsec = 14059 TOKEN_STRING_INITIALIZER 14060 (struct cmd_macsec_offload_off_result, 14061 macsec, "macsec"); 14062 cmdline_parse_token_string_t cmd_macsec_offload_off_offload = 14063 TOKEN_STRING_INITIALIZER 14064 (struct cmd_macsec_offload_off_result, 14065 offload, "offload"); 14066 cmdline_parse_token_num_t cmd_macsec_offload_off_port_id = 14067 TOKEN_NUM_INITIALIZER 14068 (struct cmd_macsec_offload_off_result, 14069 port_id, UINT16); 14070 cmdline_parse_token_string_t cmd_macsec_offload_off_off = 14071 TOKEN_STRING_INITIALIZER 14072 (struct cmd_macsec_offload_off_result, 14073 off, "off"); 14074 14075 static void 14076 cmd_set_macsec_offload_off_parsed( 14077 void *parsed_result, 14078 __attribute__((unused)) struct cmdline *cl, 14079 __attribute__((unused)) void *data) 14080 { 14081 struct cmd_macsec_offload_off_result *res = parsed_result; 14082 int ret = -ENOTSUP; 14083 struct rte_eth_dev_info dev_info; 14084 portid_t port_id = res->port_id; 14085 14086 if (port_id_is_invalid(port_id, ENABLED_WARN)) 14087 return; 14088 if (!port_is_stopped(port_id)) { 14089 printf("Please stop port %d first\n", port_id); 14090 return; 14091 } 14092 14093 rte_eth_dev_info_get(port_id, &dev_info); 14094 if (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_MACSEC_INSERT) { 14095 #ifdef RTE_LIBRTE_IXGBE_PMD 14096 ret = rte_pmd_ixgbe_macsec_disable(port_id); 14097 #endif 14098 } 14099 switch (ret) { 14100 case 0: 14101 ports[port_id].dev_conf.txmode.offloads &= 14102 ~DEV_TX_OFFLOAD_MACSEC_INSERT; 14103 cmd_reconfig_device_queue(port_id, 1, 1); 14104 break; 14105 case -ENODEV: 14106 printf("invalid port_id %d\n", port_id); 14107 break; 14108 case -ENOTSUP: 14109 printf("not supported on port %d\n", port_id); 14110 break; 14111 default: 14112 printf("programming error: (%s)\n", strerror(-ret)); 14113 } 14114 } 14115 14116 cmdline_parse_inst_t cmd_set_macsec_offload_off = { 14117 .f = cmd_set_macsec_offload_off_parsed, 14118 .data = NULL, 14119 .help_str = "set macsec offload <port_id> off", 14120 .tokens = { 14121 (void *)&cmd_macsec_offload_off_set, 14122 (void *)&cmd_macsec_offload_off_macsec, 14123 (void *)&cmd_macsec_offload_off_offload, 14124 (void *)&cmd_macsec_offload_off_port_id, 14125 (void *)&cmd_macsec_offload_off_off, 14126 NULL, 14127 }, 14128 }; 14129 14130 /* Common result structure for MACsec secure connection configure */ 14131 struct cmd_macsec_sc_result { 14132 cmdline_fixed_string_t set; 14133 cmdline_fixed_string_t macsec; 14134 cmdline_fixed_string_t sc; 14135 cmdline_fixed_string_t tx_rx; 14136 portid_t port_id; 14137 struct ether_addr mac; 14138 uint16_t pi; 14139 }; 14140 14141 /* Common CLI fields for MACsec secure connection configure */ 14142 cmdline_parse_token_string_t cmd_macsec_sc_set = 14143 TOKEN_STRING_INITIALIZER 14144 (struct cmd_macsec_sc_result, 14145 set, "set"); 14146 cmdline_parse_token_string_t cmd_macsec_sc_macsec = 14147 TOKEN_STRING_INITIALIZER 14148 (struct cmd_macsec_sc_result, 14149 macsec, "macsec"); 14150 cmdline_parse_token_string_t cmd_macsec_sc_sc = 14151 TOKEN_STRING_INITIALIZER 14152 (struct cmd_macsec_sc_result, 14153 sc, "sc"); 14154 cmdline_parse_token_string_t cmd_macsec_sc_tx_rx = 14155 TOKEN_STRING_INITIALIZER 14156 (struct cmd_macsec_sc_result, 14157 tx_rx, "tx#rx"); 14158 cmdline_parse_token_num_t cmd_macsec_sc_port_id = 14159 TOKEN_NUM_INITIALIZER 14160 (struct cmd_macsec_sc_result, 14161 port_id, UINT16); 14162 cmdline_parse_token_etheraddr_t cmd_macsec_sc_mac = 14163 TOKEN_ETHERADDR_INITIALIZER 14164 (struct cmd_macsec_sc_result, 14165 mac); 14166 cmdline_parse_token_num_t cmd_macsec_sc_pi = 14167 TOKEN_NUM_INITIALIZER 14168 (struct cmd_macsec_sc_result, 14169 pi, UINT16); 14170 14171 static void 14172 cmd_set_macsec_sc_parsed( 14173 void *parsed_result, 14174 __attribute__((unused)) struct cmdline *cl, 14175 __attribute__((unused)) void *data) 14176 { 14177 struct cmd_macsec_sc_result *res = parsed_result; 14178 int ret = -ENOTSUP; 14179 int is_tx = (strcmp(res->tx_rx, "tx") == 0) ? 1 : 0; 14180 14181 #ifdef RTE_LIBRTE_IXGBE_PMD 14182 ret = is_tx ? 14183 rte_pmd_ixgbe_macsec_config_txsc(res->port_id, 14184 res->mac.addr_bytes) : 14185 rte_pmd_ixgbe_macsec_config_rxsc(res->port_id, 14186 res->mac.addr_bytes, res->pi); 14187 #endif 14188 RTE_SET_USED(is_tx); 14189 14190 switch (ret) { 14191 case 0: 14192 break; 14193 case -ENODEV: 14194 printf("invalid port_id %d\n", res->port_id); 14195 break; 14196 case -ENOTSUP: 14197 printf("not supported on port %d\n", res->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_sc = { 14205 .f = cmd_set_macsec_sc_parsed, 14206 .data = NULL, 14207 .help_str = "set macsec sc tx|rx <port_id> <mac> <pi>", 14208 .tokens = { 14209 (void *)&cmd_macsec_sc_set, 14210 (void *)&cmd_macsec_sc_macsec, 14211 (void *)&cmd_macsec_sc_sc, 14212 (void *)&cmd_macsec_sc_tx_rx, 14213 (void *)&cmd_macsec_sc_port_id, 14214 (void *)&cmd_macsec_sc_mac, 14215 (void *)&cmd_macsec_sc_pi, 14216 NULL, 14217 }, 14218 }; 14219 14220 /* Common result structure for MACsec secure connection configure */ 14221 struct cmd_macsec_sa_result { 14222 cmdline_fixed_string_t set; 14223 cmdline_fixed_string_t macsec; 14224 cmdline_fixed_string_t sa; 14225 cmdline_fixed_string_t tx_rx; 14226 portid_t port_id; 14227 uint8_t idx; 14228 uint8_t an; 14229 uint32_t pn; 14230 cmdline_fixed_string_t key; 14231 }; 14232 14233 /* Common CLI fields for MACsec secure connection configure */ 14234 cmdline_parse_token_string_t cmd_macsec_sa_set = 14235 TOKEN_STRING_INITIALIZER 14236 (struct cmd_macsec_sa_result, 14237 set, "set"); 14238 cmdline_parse_token_string_t cmd_macsec_sa_macsec = 14239 TOKEN_STRING_INITIALIZER 14240 (struct cmd_macsec_sa_result, 14241 macsec, "macsec"); 14242 cmdline_parse_token_string_t cmd_macsec_sa_sa = 14243 TOKEN_STRING_INITIALIZER 14244 (struct cmd_macsec_sa_result, 14245 sa, "sa"); 14246 cmdline_parse_token_string_t cmd_macsec_sa_tx_rx = 14247 TOKEN_STRING_INITIALIZER 14248 (struct cmd_macsec_sa_result, 14249 tx_rx, "tx#rx"); 14250 cmdline_parse_token_num_t cmd_macsec_sa_port_id = 14251 TOKEN_NUM_INITIALIZER 14252 (struct cmd_macsec_sa_result, 14253 port_id, UINT16); 14254 cmdline_parse_token_num_t cmd_macsec_sa_idx = 14255 TOKEN_NUM_INITIALIZER 14256 (struct cmd_macsec_sa_result, 14257 idx, UINT8); 14258 cmdline_parse_token_num_t cmd_macsec_sa_an = 14259 TOKEN_NUM_INITIALIZER 14260 (struct cmd_macsec_sa_result, 14261 an, UINT8); 14262 cmdline_parse_token_num_t cmd_macsec_sa_pn = 14263 TOKEN_NUM_INITIALIZER 14264 (struct cmd_macsec_sa_result, 14265 pn, UINT32); 14266 cmdline_parse_token_string_t cmd_macsec_sa_key = 14267 TOKEN_STRING_INITIALIZER 14268 (struct cmd_macsec_sa_result, 14269 key, NULL); 14270 14271 static void 14272 cmd_set_macsec_sa_parsed( 14273 void *parsed_result, 14274 __attribute__((unused)) struct cmdline *cl, 14275 __attribute__((unused)) void *data) 14276 { 14277 struct cmd_macsec_sa_result *res = parsed_result; 14278 int ret = -ENOTSUP; 14279 int is_tx = (strcmp(res->tx_rx, "tx") == 0) ? 1 : 0; 14280 uint8_t key[16] = { 0 }; 14281 uint8_t xdgt0; 14282 uint8_t xdgt1; 14283 int key_len; 14284 int i; 14285 14286 key_len = strlen(res->key) / 2; 14287 if (key_len > 16) 14288 key_len = 16; 14289 14290 for (i = 0; i < key_len; i++) { 14291 xdgt0 = parse_and_check_key_hexa_digit(res->key, (i * 2)); 14292 if (xdgt0 == 0xFF) 14293 return; 14294 xdgt1 = parse_and_check_key_hexa_digit(res->key, (i * 2) + 1); 14295 if (xdgt1 == 0xFF) 14296 return; 14297 key[i] = (uint8_t) ((xdgt0 * 16) + xdgt1); 14298 } 14299 14300 #ifdef RTE_LIBRTE_IXGBE_PMD 14301 ret = is_tx ? 14302 rte_pmd_ixgbe_macsec_select_txsa(res->port_id, 14303 res->idx, res->an, res->pn, key) : 14304 rte_pmd_ixgbe_macsec_select_rxsa(res->port_id, 14305 res->idx, res->an, res->pn, key); 14306 #endif 14307 RTE_SET_USED(is_tx); 14308 RTE_SET_USED(key); 14309 14310 switch (ret) { 14311 case 0: 14312 break; 14313 case -EINVAL: 14314 printf("invalid idx %d or an %d\n", res->idx, res->an); 14315 break; 14316 case -ENODEV: 14317 printf("invalid port_id %d\n", res->port_id); 14318 break; 14319 case -ENOTSUP: 14320 printf("not supported on port %d\n", res->port_id); 14321 break; 14322 default: 14323 printf("programming error: (%s)\n", strerror(-ret)); 14324 } 14325 } 14326 14327 cmdline_parse_inst_t cmd_set_macsec_sa = { 14328 .f = cmd_set_macsec_sa_parsed, 14329 .data = NULL, 14330 .help_str = "set macsec sa tx|rx <port_id> <idx> <an> <pn> <key>", 14331 .tokens = { 14332 (void *)&cmd_macsec_sa_set, 14333 (void *)&cmd_macsec_sa_macsec, 14334 (void *)&cmd_macsec_sa_sa, 14335 (void *)&cmd_macsec_sa_tx_rx, 14336 (void *)&cmd_macsec_sa_port_id, 14337 (void *)&cmd_macsec_sa_idx, 14338 (void *)&cmd_macsec_sa_an, 14339 (void *)&cmd_macsec_sa_pn, 14340 (void *)&cmd_macsec_sa_key, 14341 NULL, 14342 }, 14343 }; 14344 14345 /* VF unicast promiscuous mode configuration */ 14346 14347 /* Common result structure for VF unicast promiscuous mode */ 14348 struct cmd_vf_promisc_result { 14349 cmdline_fixed_string_t set; 14350 cmdline_fixed_string_t vf; 14351 cmdline_fixed_string_t promisc; 14352 portid_t port_id; 14353 uint32_t vf_id; 14354 cmdline_fixed_string_t on_off; 14355 }; 14356 14357 /* Common CLI fields for VF unicast promiscuous mode enable disable */ 14358 cmdline_parse_token_string_t cmd_vf_promisc_set = 14359 TOKEN_STRING_INITIALIZER 14360 (struct cmd_vf_promisc_result, 14361 set, "set"); 14362 cmdline_parse_token_string_t cmd_vf_promisc_vf = 14363 TOKEN_STRING_INITIALIZER 14364 (struct cmd_vf_promisc_result, 14365 vf, "vf"); 14366 cmdline_parse_token_string_t cmd_vf_promisc_promisc = 14367 TOKEN_STRING_INITIALIZER 14368 (struct cmd_vf_promisc_result, 14369 promisc, "promisc"); 14370 cmdline_parse_token_num_t cmd_vf_promisc_port_id = 14371 TOKEN_NUM_INITIALIZER 14372 (struct cmd_vf_promisc_result, 14373 port_id, UINT16); 14374 cmdline_parse_token_num_t cmd_vf_promisc_vf_id = 14375 TOKEN_NUM_INITIALIZER 14376 (struct cmd_vf_promisc_result, 14377 vf_id, UINT32); 14378 cmdline_parse_token_string_t cmd_vf_promisc_on_off = 14379 TOKEN_STRING_INITIALIZER 14380 (struct cmd_vf_promisc_result, 14381 on_off, "on#off"); 14382 14383 static void 14384 cmd_set_vf_promisc_parsed( 14385 void *parsed_result, 14386 __attribute__((unused)) struct cmdline *cl, 14387 __attribute__((unused)) void *data) 14388 { 14389 struct cmd_vf_promisc_result *res = parsed_result; 14390 int ret = -ENOTSUP; 14391 14392 __rte_unused int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0; 14393 14394 if (port_id_is_invalid(res->port_id, ENABLED_WARN)) 14395 return; 14396 14397 #ifdef RTE_LIBRTE_I40E_PMD 14398 ret = rte_pmd_i40e_set_vf_unicast_promisc(res->port_id, 14399 res->vf_id, is_on); 14400 #endif 14401 14402 switch (ret) { 14403 case 0: 14404 break; 14405 case -EINVAL: 14406 printf("invalid vf_id %d\n", res->vf_id); 14407 break; 14408 case -ENODEV: 14409 printf("invalid port_id %d\n", res->port_id); 14410 break; 14411 case -ENOTSUP: 14412 printf("function not implemented\n"); 14413 break; 14414 default: 14415 printf("programming error: (%s)\n", strerror(-ret)); 14416 } 14417 } 14418 14419 cmdline_parse_inst_t cmd_set_vf_promisc = { 14420 .f = cmd_set_vf_promisc_parsed, 14421 .data = NULL, 14422 .help_str = "set vf promisc <port_id> <vf_id> on|off: " 14423 "Set unicast promiscuous mode for a VF from the PF", 14424 .tokens = { 14425 (void *)&cmd_vf_promisc_set, 14426 (void *)&cmd_vf_promisc_vf, 14427 (void *)&cmd_vf_promisc_promisc, 14428 (void *)&cmd_vf_promisc_port_id, 14429 (void *)&cmd_vf_promisc_vf_id, 14430 (void *)&cmd_vf_promisc_on_off, 14431 NULL, 14432 }, 14433 }; 14434 14435 /* VF multicast promiscuous mode configuration */ 14436 14437 /* Common result structure for VF multicast promiscuous mode */ 14438 struct cmd_vf_allmulti_result { 14439 cmdline_fixed_string_t set; 14440 cmdline_fixed_string_t vf; 14441 cmdline_fixed_string_t allmulti; 14442 portid_t port_id; 14443 uint32_t vf_id; 14444 cmdline_fixed_string_t on_off; 14445 }; 14446 14447 /* Common CLI fields for VF multicast promiscuous mode enable disable */ 14448 cmdline_parse_token_string_t cmd_vf_allmulti_set = 14449 TOKEN_STRING_INITIALIZER 14450 (struct cmd_vf_allmulti_result, 14451 set, "set"); 14452 cmdline_parse_token_string_t cmd_vf_allmulti_vf = 14453 TOKEN_STRING_INITIALIZER 14454 (struct cmd_vf_allmulti_result, 14455 vf, "vf"); 14456 cmdline_parse_token_string_t cmd_vf_allmulti_allmulti = 14457 TOKEN_STRING_INITIALIZER 14458 (struct cmd_vf_allmulti_result, 14459 allmulti, "allmulti"); 14460 cmdline_parse_token_num_t cmd_vf_allmulti_port_id = 14461 TOKEN_NUM_INITIALIZER 14462 (struct cmd_vf_allmulti_result, 14463 port_id, UINT16); 14464 cmdline_parse_token_num_t cmd_vf_allmulti_vf_id = 14465 TOKEN_NUM_INITIALIZER 14466 (struct cmd_vf_allmulti_result, 14467 vf_id, UINT32); 14468 cmdline_parse_token_string_t cmd_vf_allmulti_on_off = 14469 TOKEN_STRING_INITIALIZER 14470 (struct cmd_vf_allmulti_result, 14471 on_off, "on#off"); 14472 14473 static void 14474 cmd_set_vf_allmulti_parsed( 14475 void *parsed_result, 14476 __attribute__((unused)) struct cmdline *cl, 14477 __attribute__((unused)) void *data) 14478 { 14479 struct cmd_vf_allmulti_result *res = parsed_result; 14480 int ret = -ENOTSUP; 14481 14482 __rte_unused int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0; 14483 14484 if (port_id_is_invalid(res->port_id, ENABLED_WARN)) 14485 return; 14486 14487 #ifdef RTE_LIBRTE_I40E_PMD 14488 ret = rte_pmd_i40e_set_vf_multicast_promisc(res->port_id, 14489 res->vf_id, is_on); 14490 #endif 14491 14492 switch (ret) { 14493 case 0: 14494 break; 14495 case -EINVAL: 14496 printf("invalid vf_id %d\n", res->vf_id); 14497 break; 14498 case -ENODEV: 14499 printf("invalid port_id %d\n", res->port_id); 14500 break; 14501 case -ENOTSUP: 14502 printf("function not implemented\n"); 14503 break; 14504 default: 14505 printf("programming error: (%s)\n", strerror(-ret)); 14506 } 14507 } 14508 14509 cmdline_parse_inst_t cmd_set_vf_allmulti = { 14510 .f = cmd_set_vf_allmulti_parsed, 14511 .data = NULL, 14512 .help_str = "set vf allmulti <port_id> <vf_id> on|off: " 14513 "Set multicast promiscuous mode for a VF from the PF", 14514 .tokens = { 14515 (void *)&cmd_vf_allmulti_set, 14516 (void *)&cmd_vf_allmulti_vf, 14517 (void *)&cmd_vf_allmulti_allmulti, 14518 (void *)&cmd_vf_allmulti_port_id, 14519 (void *)&cmd_vf_allmulti_vf_id, 14520 (void *)&cmd_vf_allmulti_on_off, 14521 NULL, 14522 }, 14523 }; 14524 14525 /* vf broadcast mode configuration */ 14526 14527 /* Common result structure for vf broadcast */ 14528 struct cmd_set_vf_broadcast_result { 14529 cmdline_fixed_string_t set; 14530 cmdline_fixed_string_t vf; 14531 cmdline_fixed_string_t broadcast; 14532 portid_t port_id; 14533 uint16_t vf_id; 14534 cmdline_fixed_string_t on_off; 14535 }; 14536 14537 /* Common CLI fields for vf broadcast enable disable */ 14538 cmdline_parse_token_string_t cmd_set_vf_broadcast_set = 14539 TOKEN_STRING_INITIALIZER 14540 (struct cmd_set_vf_broadcast_result, 14541 set, "set"); 14542 cmdline_parse_token_string_t cmd_set_vf_broadcast_vf = 14543 TOKEN_STRING_INITIALIZER 14544 (struct cmd_set_vf_broadcast_result, 14545 vf, "vf"); 14546 cmdline_parse_token_string_t cmd_set_vf_broadcast_broadcast = 14547 TOKEN_STRING_INITIALIZER 14548 (struct cmd_set_vf_broadcast_result, 14549 broadcast, "broadcast"); 14550 cmdline_parse_token_num_t cmd_set_vf_broadcast_port_id = 14551 TOKEN_NUM_INITIALIZER 14552 (struct cmd_set_vf_broadcast_result, 14553 port_id, UINT16); 14554 cmdline_parse_token_num_t cmd_set_vf_broadcast_vf_id = 14555 TOKEN_NUM_INITIALIZER 14556 (struct cmd_set_vf_broadcast_result, 14557 vf_id, UINT16); 14558 cmdline_parse_token_string_t cmd_set_vf_broadcast_on_off = 14559 TOKEN_STRING_INITIALIZER 14560 (struct cmd_set_vf_broadcast_result, 14561 on_off, "on#off"); 14562 14563 static void 14564 cmd_set_vf_broadcast_parsed( 14565 void *parsed_result, 14566 __attribute__((unused)) struct cmdline *cl, 14567 __attribute__((unused)) void *data) 14568 { 14569 struct cmd_set_vf_broadcast_result *res = parsed_result; 14570 int ret = -ENOTSUP; 14571 14572 __rte_unused int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0; 14573 14574 if (port_id_is_invalid(res->port_id, ENABLED_WARN)) 14575 return; 14576 14577 #ifdef RTE_LIBRTE_I40E_PMD 14578 ret = rte_pmd_i40e_set_vf_broadcast(res->port_id, 14579 res->vf_id, is_on); 14580 #endif 14581 14582 switch (ret) { 14583 case 0: 14584 break; 14585 case -EINVAL: 14586 printf("invalid vf_id %d or is_on %d\n", res->vf_id, is_on); 14587 break; 14588 case -ENODEV: 14589 printf("invalid port_id %d\n", res->port_id); 14590 break; 14591 case -ENOTSUP: 14592 printf("function not implemented\n"); 14593 break; 14594 default: 14595 printf("programming error: (%s)\n", strerror(-ret)); 14596 } 14597 } 14598 14599 cmdline_parse_inst_t cmd_set_vf_broadcast = { 14600 .f = cmd_set_vf_broadcast_parsed, 14601 .data = NULL, 14602 .help_str = "set vf broadcast <port_id> <vf_id> on|off", 14603 .tokens = { 14604 (void *)&cmd_set_vf_broadcast_set, 14605 (void *)&cmd_set_vf_broadcast_vf, 14606 (void *)&cmd_set_vf_broadcast_broadcast, 14607 (void *)&cmd_set_vf_broadcast_port_id, 14608 (void *)&cmd_set_vf_broadcast_vf_id, 14609 (void *)&cmd_set_vf_broadcast_on_off, 14610 NULL, 14611 }, 14612 }; 14613 14614 /* vf vlan tag configuration */ 14615 14616 /* Common result structure for vf vlan tag */ 14617 struct cmd_set_vf_vlan_tag_result { 14618 cmdline_fixed_string_t set; 14619 cmdline_fixed_string_t vf; 14620 cmdline_fixed_string_t vlan; 14621 cmdline_fixed_string_t tag; 14622 portid_t port_id; 14623 uint16_t vf_id; 14624 cmdline_fixed_string_t on_off; 14625 }; 14626 14627 /* Common CLI fields for vf vlan tag enable disable */ 14628 cmdline_parse_token_string_t cmd_set_vf_vlan_tag_set = 14629 TOKEN_STRING_INITIALIZER 14630 (struct cmd_set_vf_vlan_tag_result, 14631 set, "set"); 14632 cmdline_parse_token_string_t cmd_set_vf_vlan_tag_vf = 14633 TOKEN_STRING_INITIALIZER 14634 (struct cmd_set_vf_vlan_tag_result, 14635 vf, "vf"); 14636 cmdline_parse_token_string_t cmd_set_vf_vlan_tag_vlan = 14637 TOKEN_STRING_INITIALIZER 14638 (struct cmd_set_vf_vlan_tag_result, 14639 vlan, "vlan"); 14640 cmdline_parse_token_string_t cmd_set_vf_vlan_tag_tag = 14641 TOKEN_STRING_INITIALIZER 14642 (struct cmd_set_vf_vlan_tag_result, 14643 tag, "tag"); 14644 cmdline_parse_token_num_t cmd_set_vf_vlan_tag_port_id = 14645 TOKEN_NUM_INITIALIZER 14646 (struct cmd_set_vf_vlan_tag_result, 14647 port_id, UINT16); 14648 cmdline_parse_token_num_t cmd_set_vf_vlan_tag_vf_id = 14649 TOKEN_NUM_INITIALIZER 14650 (struct cmd_set_vf_vlan_tag_result, 14651 vf_id, UINT16); 14652 cmdline_parse_token_string_t cmd_set_vf_vlan_tag_on_off = 14653 TOKEN_STRING_INITIALIZER 14654 (struct cmd_set_vf_vlan_tag_result, 14655 on_off, "on#off"); 14656 14657 static void 14658 cmd_set_vf_vlan_tag_parsed( 14659 void *parsed_result, 14660 __attribute__((unused)) struct cmdline *cl, 14661 __attribute__((unused)) void *data) 14662 { 14663 struct cmd_set_vf_vlan_tag_result *res = parsed_result; 14664 int ret = -ENOTSUP; 14665 14666 __rte_unused int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0; 14667 14668 if (port_id_is_invalid(res->port_id, ENABLED_WARN)) 14669 return; 14670 14671 #ifdef RTE_LIBRTE_I40E_PMD 14672 ret = rte_pmd_i40e_set_vf_vlan_tag(res->port_id, 14673 res->vf_id, is_on); 14674 #endif 14675 14676 switch (ret) { 14677 case 0: 14678 break; 14679 case -EINVAL: 14680 printf("invalid vf_id %d or is_on %d\n", res->vf_id, is_on); 14681 break; 14682 case -ENODEV: 14683 printf("invalid port_id %d\n", res->port_id); 14684 break; 14685 case -ENOTSUP: 14686 printf("function not implemented\n"); 14687 break; 14688 default: 14689 printf("programming error: (%s)\n", strerror(-ret)); 14690 } 14691 } 14692 14693 cmdline_parse_inst_t cmd_set_vf_vlan_tag = { 14694 .f = cmd_set_vf_vlan_tag_parsed, 14695 .data = NULL, 14696 .help_str = "set vf vlan tag <port_id> <vf_id> on|off", 14697 .tokens = { 14698 (void *)&cmd_set_vf_vlan_tag_set, 14699 (void *)&cmd_set_vf_vlan_tag_vf, 14700 (void *)&cmd_set_vf_vlan_tag_vlan, 14701 (void *)&cmd_set_vf_vlan_tag_tag, 14702 (void *)&cmd_set_vf_vlan_tag_port_id, 14703 (void *)&cmd_set_vf_vlan_tag_vf_id, 14704 (void *)&cmd_set_vf_vlan_tag_on_off, 14705 NULL, 14706 }, 14707 }; 14708 14709 /* Common definition of VF and TC TX bandwidth configuration */ 14710 struct cmd_vf_tc_bw_result { 14711 cmdline_fixed_string_t set; 14712 cmdline_fixed_string_t vf; 14713 cmdline_fixed_string_t tc; 14714 cmdline_fixed_string_t tx; 14715 cmdline_fixed_string_t min_bw; 14716 cmdline_fixed_string_t max_bw; 14717 cmdline_fixed_string_t strict_link_prio; 14718 portid_t port_id; 14719 uint16_t vf_id; 14720 uint8_t tc_no; 14721 uint32_t bw; 14722 cmdline_fixed_string_t bw_list; 14723 uint8_t tc_map; 14724 }; 14725 14726 cmdline_parse_token_string_t cmd_vf_tc_bw_set = 14727 TOKEN_STRING_INITIALIZER 14728 (struct cmd_vf_tc_bw_result, 14729 set, "set"); 14730 cmdline_parse_token_string_t cmd_vf_tc_bw_vf = 14731 TOKEN_STRING_INITIALIZER 14732 (struct cmd_vf_tc_bw_result, 14733 vf, "vf"); 14734 cmdline_parse_token_string_t cmd_vf_tc_bw_tc = 14735 TOKEN_STRING_INITIALIZER 14736 (struct cmd_vf_tc_bw_result, 14737 tc, "tc"); 14738 cmdline_parse_token_string_t cmd_vf_tc_bw_tx = 14739 TOKEN_STRING_INITIALIZER 14740 (struct cmd_vf_tc_bw_result, 14741 tx, "tx"); 14742 cmdline_parse_token_string_t cmd_vf_tc_bw_strict_link_prio = 14743 TOKEN_STRING_INITIALIZER 14744 (struct cmd_vf_tc_bw_result, 14745 strict_link_prio, "strict-link-priority"); 14746 cmdline_parse_token_string_t cmd_vf_tc_bw_min_bw = 14747 TOKEN_STRING_INITIALIZER 14748 (struct cmd_vf_tc_bw_result, 14749 min_bw, "min-bandwidth"); 14750 cmdline_parse_token_string_t cmd_vf_tc_bw_max_bw = 14751 TOKEN_STRING_INITIALIZER 14752 (struct cmd_vf_tc_bw_result, 14753 max_bw, "max-bandwidth"); 14754 cmdline_parse_token_num_t cmd_vf_tc_bw_port_id = 14755 TOKEN_NUM_INITIALIZER 14756 (struct cmd_vf_tc_bw_result, 14757 port_id, UINT16); 14758 cmdline_parse_token_num_t cmd_vf_tc_bw_vf_id = 14759 TOKEN_NUM_INITIALIZER 14760 (struct cmd_vf_tc_bw_result, 14761 vf_id, UINT16); 14762 cmdline_parse_token_num_t cmd_vf_tc_bw_tc_no = 14763 TOKEN_NUM_INITIALIZER 14764 (struct cmd_vf_tc_bw_result, 14765 tc_no, UINT8); 14766 cmdline_parse_token_num_t cmd_vf_tc_bw_bw = 14767 TOKEN_NUM_INITIALIZER 14768 (struct cmd_vf_tc_bw_result, 14769 bw, UINT32); 14770 cmdline_parse_token_string_t cmd_vf_tc_bw_bw_list = 14771 TOKEN_STRING_INITIALIZER 14772 (struct cmd_vf_tc_bw_result, 14773 bw_list, NULL); 14774 cmdline_parse_token_num_t cmd_vf_tc_bw_tc_map = 14775 TOKEN_NUM_INITIALIZER 14776 (struct cmd_vf_tc_bw_result, 14777 tc_map, UINT8); 14778 14779 /* VF max bandwidth setting */ 14780 static void 14781 cmd_vf_max_bw_parsed( 14782 void *parsed_result, 14783 __attribute__((unused)) struct cmdline *cl, 14784 __attribute__((unused)) void *data) 14785 { 14786 struct cmd_vf_tc_bw_result *res = parsed_result; 14787 int ret = -ENOTSUP; 14788 14789 if (port_id_is_invalid(res->port_id, ENABLED_WARN)) 14790 return; 14791 14792 #ifdef RTE_LIBRTE_I40E_PMD 14793 ret = rte_pmd_i40e_set_vf_max_bw(res->port_id, 14794 res->vf_id, res->bw); 14795 #endif 14796 14797 switch (ret) { 14798 case 0: 14799 break; 14800 case -EINVAL: 14801 printf("invalid vf_id %d or bandwidth %d\n", 14802 res->vf_id, res->bw); 14803 break; 14804 case -ENODEV: 14805 printf("invalid port_id %d\n", res->port_id); 14806 break; 14807 case -ENOTSUP: 14808 printf("function not implemented\n"); 14809 break; 14810 default: 14811 printf("programming error: (%s)\n", strerror(-ret)); 14812 } 14813 } 14814 14815 cmdline_parse_inst_t cmd_vf_max_bw = { 14816 .f = cmd_vf_max_bw_parsed, 14817 .data = NULL, 14818 .help_str = "set vf tx max-bandwidth <port_id> <vf_id> <bandwidth>", 14819 .tokens = { 14820 (void *)&cmd_vf_tc_bw_set, 14821 (void *)&cmd_vf_tc_bw_vf, 14822 (void *)&cmd_vf_tc_bw_tx, 14823 (void *)&cmd_vf_tc_bw_max_bw, 14824 (void *)&cmd_vf_tc_bw_port_id, 14825 (void *)&cmd_vf_tc_bw_vf_id, 14826 (void *)&cmd_vf_tc_bw_bw, 14827 NULL, 14828 }, 14829 }; 14830 14831 static int 14832 vf_tc_min_bw_parse_bw_list(uint8_t *bw_list, 14833 uint8_t *tc_num, 14834 char *str) 14835 { 14836 uint32_t size; 14837 const char *p, *p0 = str; 14838 char s[256]; 14839 char *end; 14840 char *str_fld[16]; 14841 uint16_t i; 14842 int ret; 14843 14844 p = strchr(p0, '('); 14845 if (p == NULL) { 14846 printf("The bandwidth-list should be '(bw1, bw2, ...)'\n"); 14847 return -1; 14848 } 14849 p++; 14850 p0 = strchr(p, ')'); 14851 if (p0 == NULL) { 14852 printf("The bandwidth-list should be '(bw1, bw2, ...)'\n"); 14853 return -1; 14854 } 14855 size = p0 - p; 14856 if (size >= sizeof(s)) { 14857 printf("The string size exceeds the internal buffer size\n"); 14858 return -1; 14859 } 14860 snprintf(s, sizeof(s), "%.*s", size, p); 14861 ret = rte_strsplit(s, sizeof(s), str_fld, 16, ','); 14862 if (ret <= 0) { 14863 printf("Failed to get the bandwidth list. "); 14864 return -1; 14865 } 14866 *tc_num = ret; 14867 for (i = 0; i < ret; i++) 14868 bw_list[i] = (uint8_t)strtoul(str_fld[i], &end, 0); 14869 14870 return 0; 14871 } 14872 14873 /* TC min bandwidth setting */ 14874 static void 14875 cmd_vf_tc_min_bw_parsed( 14876 void *parsed_result, 14877 __attribute__((unused)) struct cmdline *cl, 14878 __attribute__((unused)) void *data) 14879 { 14880 struct cmd_vf_tc_bw_result *res = parsed_result; 14881 uint8_t tc_num; 14882 uint8_t bw[16]; 14883 int ret = -ENOTSUP; 14884 14885 if (port_id_is_invalid(res->port_id, ENABLED_WARN)) 14886 return; 14887 14888 ret = vf_tc_min_bw_parse_bw_list(bw, &tc_num, res->bw_list); 14889 if (ret) 14890 return; 14891 14892 #ifdef RTE_LIBRTE_I40E_PMD 14893 ret = rte_pmd_i40e_set_vf_tc_bw_alloc(res->port_id, res->vf_id, 14894 tc_num, bw); 14895 #endif 14896 14897 switch (ret) { 14898 case 0: 14899 break; 14900 case -EINVAL: 14901 printf("invalid vf_id %d or bandwidth\n", res->vf_id); 14902 break; 14903 case -ENODEV: 14904 printf("invalid port_id %d\n", res->port_id); 14905 break; 14906 case -ENOTSUP: 14907 printf("function not implemented\n"); 14908 break; 14909 default: 14910 printf("programming error: (%s)\n", strerror(-ret)); 14911 } 14912 } 14913 14914 cmdline_parse_inst_t cmd_vf_tc_min_bw = { 14915 .f = cmd_vf_tc_min_bw_parsed, 14916 .data = NULL, 14917 .help_str = "set vf tc tx min-bandwidth <port_id> <vf_id>" 14918 " <bw1, bw2, ...>", 14919 .tokens = { 14920 (void *)&cmd_vf_tc_bw_set, 14921 (void *)&cmd_vf_tc_bw_vf, 14922 (void *)&cmd_vf_tc_bw_tc, 14923 (void *)&cmd_vf_tc_bw_tx, 14924 (void *)&cmd_vf_tc_bw_min_bw, 14925 (void *)&cmd_vf_tc_bw_port_id, 14926 (void *)&cmd_vf_tc_bw_vf_id, 14927 (void *)&cmd_vf_tc_bw_bw_list, 14928 NULL, 14929 }, 14930 }; 14931 14932 static void 14933 cmd_tc_min_bw_parsed( 14934 void *parsed_result, 14935 __attribute__((unused)) struct cmdline *cl, 14936 __attribute__((unused)) void *data) 14937 { 14938 struct cmd_vf_tc_bw_result *res = parsed_result; 14939 struct rte_port *port; 14940 uint8_t tc_num; 14941 uint8_t bw[16]; 14942 int ret = -ENOTSUP; 14943 14944 if (port_id_is_invalid(res->port_id, ENABLED_WARN)) 14945 return; 14946 14947 port = &ports[res->port_id]; 14948 /** Check if the port is not started **/ 14949 if (port->port_status != RTE_PORT_STOPPED) { 14950 printf("Please stop port %d first\n", res->port_id); 14951 return; 14952 } 14953 14954 ret = vf_tc_min_bw_parse_bw_list(bw, &tc_num, res->bw_list); 14955 if (ret) 14956 return; 14957 14958 #ifdef RTE_LIBRTE_IXGBE_PMD 14959 ret = rte_pmd_ixgbe_set_tc_bw_alloc(res->port_id, tc_num, bw); 14960 #endif 14961 14962 switch (ret) { 14963 case 0: 14964 break; 14965 case -EINVAL: 14966 printf("invalid bandwidth\n"); 14967 break; 14968 case -ENODEV: 14969 printf("invalid port_id %d\n", res->port_id); 14970 break; 14971 case -ENOTSUP: 14972 printf("function not implemented\n"); 14973 break; 14974 default: 14975 printf("programming error: (%s)\n", strerror(-ret)); 14976 } 14977 } 14978 14979 cmdline_parse_inst_t cmd_tc_min_bw = { 14980 .f = cmd_tc_min_bw_parsed, 14981 .data = NULL, 14982 .help_str = "set tc tx min-bandwidth <port_id> <bw1, bw2, ...>", 14983 .tokens = { 14984 (void *)&cmd_vf_tc_bw_set, 14985 (void *)&cmd_vf_tc_bw_tc, 14986 (void *)&cmd_vf_tc_bw_tx, 14987 (void *)&cmd_vf_tc_bw_min_bw, 14988 (void *)&cmd_vf_tc_bw_port_id, 14989 (void *)&cmd_vf_tc_bw_bw_list, 14990 NULL, 14991 }, 14992 }; 14993 14994 /* TC max bandwidth setting */ 14995 static void 14996 cmd_vf_tc_max_bw_parsed( 14997 void *parsed_result, 14998 __attribute__((unused)) struct cmdline *cl, 14999 __attribute__((unused)) void *data) 15000 { 15001 struct cmd_vf_tc_bw_result *res = parsed_result; 15002 int ret = -ENOTSUP; 15003 15004 if (port_id_is_invalid(res->port_id, ENABLED_WARN)) 15005 return; 15006 15007 #ifdef RTE_LIBRTE_I40E_PMD 15008 ret = rte_pmd_i40e_set_vf_tc_max_bw(res->port_id, res->vf_id, 15009 res->tc_no, res->bw); 15010 #endif 15011 15012 switch (ret) { 15013 case 0: 15014 break; 15015 case -EINVAL: 15016 printf("invalid vf_id %d, tc_no %d or bandwidth %d\n", 15017 res->vf_id, res->tc_no, res->bw); 15018 break; 15019 case -ENODEV: 15020 printf("invalid port_id %d\n", res->port_id); 15021 break; 15022 case -ENOTSUP: 15023 printf("function not implemented\n"); 15024 break; 15025 default: 15026 printf("programming error: (%s)\n", strerror(-ret)); 15027 } 15028 } 15029 15030 cmdline_parse_inst_t cmd_vf_tc_max_bw = { 15031 .f = cmd_vf_tc_max_bw_parsed, 15032 .data = NULL, 15033 .help_str = "set vf tc tx max-bandwidth <port_id> <vf_id> <tc_no>" 15034 " <bandwidth>", 15035 .tokens = { 15036 (void *)&cmd_vf_tc_bw_set, 15037 (void *)&cmd_vf_tc_bw_vf, 15038 (void *)&cmd_vf_tc_bw_tc, 15039 (void *)&cmd_vf_tc_bw_tx, 15040 (void *)&cmd_vf_tc_bw_max_bw, 15041 (void *)&cmd_vf_tc_bw_port_id, 15042 (void *)&cmd_vf_tc_bw_vf_id, 15043 (void *)&cmd_vf_tc_bw_tc_no, 15044 (void *)&cmd_vf_tc_bw_bw, 15045 NULL, 15046 }, 15047 }; 15048 15049 15050 #if defined RTE_LIBRTE_PMD_SOFTNIC && defined RTE_LIBRTE_SCHED 15051 15052 /* *** Set Port default Traffic Management Hierarchy *** */ 15053 struct cmd_set_port_tm_hierarchy_default_result { 15054 cmdline_fixed_string_t set; 15055 cmdline_fixed_string_t port; 15056 cmdline_fixed_string_t tm; 15057 cmdline_fixed_string_t hierarchy; 15058 cmdline_fixed_string_t def; 15059 portid_t port_id; 15060 }; 15061 15062 cmdline_parse_token_string_t cmd_set_port_tm_hierarchy_default_set = 15063 TOKEN_STRING_INITIALIZER( 15064 struct cmd_set_port_tm_hierarchy_default_result, set, "set"); 15065 cmdline_parse_token_string_t cmd_set_port_tm_hierarchy_default_port = 15066 TOKEN_STRING_INITIALIZER( 15067 struct cmd_set_port_tm_hierarchy_default_result, port, "port"); 15068 cmdline_parse_token_string_t cmd_set_port_tm_hierarchy_default_tm = 15069 TOKEN_STRING_INITIALIZER( 15070 struct cmd_set_port_tm_hierarchy_default_result, tm, "tm"); 15071 cmdline_parse_token_string_t cmd_set_port_tm_hierarchy_default_hierarchy = 15072 TOKEN_STRING_INITIALIZER( 15073 struct cmd_set_port_tm_hierarchy_default_result, 15074 hierarchy, "hierarchy"); 15075 cmdline_parse_token_string_t cmd_set_port_tm_hierarchy_default_default = 15076 TOKEN_STRING_INITIALIZER( 15077 struct cmd_set_port_tm_hierarchy_default_result, 15078 def, "default"); 15079 cmdline_parse_token_num_t cmd_set_port_tm_hierarchy_default_port_id = 15080 TOKEN_NUM_INITIALIZER( 15081 struct cmd_set_port_tm_hierarchy_default_result, 15082 port_id, UINT16); 15083 15084 static void cmd_set_port_tm_hierarchy_default_parsed(void *parsed_result, 15085 __attribute__((unused)) struct cmdline *cl, 15086 __attribute__((unused)) void *data) 15087 { 15088 struct cmd_set_port_tm_hierarchy_default_result *res = parsed_result; 15089 struct rte_port *p; 15090 portid_t port_id = res->port_id; 15091 15092 if (port_id_is_invalid(port_id, ENABLED_WARN)) 15093 return; 15094 15095 p = &ports[port_id]; 15096 15097 /* Forward mode: tm */ 15098 if (strcmp(cur_fwd_config.fwd_eng->fwd_mode_name, "softnic")) { 15099 printf(" softnicfwd mode not enabled(error)\n"); 15100 return; 15101 } 15102 15103 /* Set the default tm hierarchy */ 15104 p->softport.default_tm_hierarchy_enable = 1; 15105 } 15106 15107 cmdline_parse_inst_t cmd_set_port_tm_hierarchy_default = { 15108 .f = cmd_set_port_tm_hierarchy_default_parsed, 15109 .data = NULL, 15110 .help_str = "set port tm hierarchy default <port_id>", 15111 .tokens = { 15112 (void *)&cmd_set_port_tm_hierarchy_default_set, 15113 (void *)&cmd_set_port_tm_hierarchy_default_port, 15114 (void *)&cmd_set_port_tm_hierarchy_default_tm, 15115 (void *)&cmd_set_port_tm_hierarchy_default_hierarchy, 15116 (void *)&cmd_set_port_tm_hierarchy_default_default, 15117 (void *)&cmd_set_port_tm_hierarchy_default_port_id, 15118 NULL, 15119 }, 15120 }; 15121 #endif 15122 15123 /** Set VXLAN encapsulation details */ 15124 struct cmd_set_vxlan_result { 15125 cmdline_fixed_string_t set; 15126 cmdline_fixed_string_t vxlan; 15127 cmdline_fixed_string_t pos_token; 15128 cmdline_fixed_string_t ip_version; 15129 uint32_t vlan_present:1; 15130 uint32_t vni; 15131 uint16_t udp_src; 15132 uint16_t udp_dst; 15133 cmdline_ipaddr_t ip_src; 15134 cmdline_ipaddr_t ip_dst; 15135 uint16_t tci; 15136 struct ether_addr eth_src; 15137 struct ether_addr eth_dst; 15138 }; 15139 15140 cmdline_parse_token_string_t cmd_set_vxlan_set = 15141 TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, set, "set"); 15142 cmdline_parse_token_string_t cmd_set_vxlan_vxlan = 15143 TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, vxlan, "vxlan"); 15144 cmdline_parse_token_string_t cmd_set_vxlan_vxlan_with_vlan = 15145 TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, vxlan, 15146 "vxlan-with-vlan"); 15147 cmdline_parse_token_string_t cmd_set_vxlan_ip_version = 15148 TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, pos_token, 15149 "ip-version"); 15150 cmdline_parse_token_string_t cmd_set_vxlan_ip_version_value = 15151 TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, ip_version, 15152 "ipv4#ipv6"); 15153 cmdline_parse_token_string_t cmd_set_vxlan_vni = 15154 TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, pos_token, 15155 "vni"); 15156 cmdline_parse_token_num_t cmd_set_vxlan_vni_value = 15157 TOKEN_NUM_INITIALIZER(struct cmd_set_vxlan_result, vni, UINT32); 15158 cmdline_parse_token_string_t cmd_set_vxlan_udp_src = 15159 TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, pos_token, 15160 "udp-src"); 15161 cmdline_parse_token_num_t cmd_set_vxlan_udp_src_value = 15162 TOKEN_NUM_INITIALIZER(struct cmd_set_vxlan_result, udp_src, UINT16); 15163 cmdline_parse_token_string_t cmd_set_vxlan_udp_dst = 15164 TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, pos_token, 15165 "udp-dst"); 15166 cmdline_parse_token_num_t cmd_set_vxlan_udp_dst_value = 15167 TOKEN_NUM_INITIALIZER(struct cmd_set_vxlan_result, udp_dst, UINT16); 15168 cmdline_parse_token_string_t cmd_set_vxlan_ip_src = 15169 TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, pos_token, 15170 "ip-src"); 15171 cmdline_parse_token_ipaddr_t cmd_set_vxlan_ip_src_value = 15172 TOKEN_IPADDR_INITIALIZER(struct cmd_set_vxlan_result, ip_src); 15173 cmdline_parse_token_string_t cmd_set_vxlan_ip_dst = 15174 TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, pos_token, 15175 "ip-dst"); 15176 cmdline_parse_token_ipaddr_t cmd_set_vxlan_ip_dst_value = 15177 TOKEN_IPADDR_INITIALIZER(struct cmd_set_vxlan_result, ip_dst); 15178 cmdline_parse_token_string_t cmd_set_vxlan_vlan = 15179 TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, pos_token, 15180 "vlan-tci"); 15181 cmdline_parse_token_num_t cmd_set_vxlan_vlan_value = 15182 TOKEN_NUM_INITIALIZER(struct cmd_set_vxlan_result, tci, UINT16); 15183 cmdline_parse_token_string_t cmd_set_vxlan_eth_src = 15184 TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, pos_token, 15185 "eth-src"); 15186 cmdline_parse_token_etheraddr_t cmd_set_vxlan_eth_src_value = 15187 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_vxlan_result, eth_src); 15188 cmdline_parse_token_string_t cmd_set_vxlan_eth_dst = 15189 TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, pos_token, 15190 "eth-dst"); 15191 cmdline_parse_token_etheraddr_t cmd_set_vxlan_eth_dst_value = 15192 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_vxlan_result, eth_dst); 15193 15194 static void cmd_set_vxlan_parsed(void *parsed_result, 15195 __attribute__((unused)) struct cmdline *cl, 15196 __attribute__((unused)) void *data) 15197 { 15198 struct cmd_set_vxlan_result *res = parsed_result; 15199 union { 15200 uint32_t vxlan_id; 15201 uint8_t vni[4]; 15202 } id = { 15203 .vxlan_id = rte_cpu_to_be_32(res->vni) & RTE_BE32(0x00ffffff), 15204 }; 15205 15206 if (strcmp(res->vxlan, "vxlan") == 0) 15207 vxlan_encap_conf.select_vlan = 0; 15208 else if (strcmp(res->vxlan, "vxlan-with-vlan") == 0) 15209 vxlan_encap_conf.select_vlan = 1; 15210 if (strcmp(res->ip_version, "ipv4") == 0) 15211 vxlan_encap_conf.select_ipv4 = 1; 15212 else if (strcmp(res->ip_version, "ipv6") == 0) 15213 vxlan_encap_conf.select_ipv4 = 0; 15214 else 15215 return; 15216 rte_memcpy(vxlan_encap_conf.vni, &id.vni[1], 3); 15217 vxlan_encap_conf.udp_src = rte_cpu_to_be_16(res->udp_src); 15218 vxlan_encap_conf.udp_dst = rte_cpu_to_be_16(res->udp_dst); 15219 if (vxlan_encap_conf.select_ipv4) { 15220 IPV4_ADDR_TO_UINT(res->ip_src, vxlan_encap_conf.ipv4_src); 15221 IPV4_ADDR_TO_UINT(res->ip_dst, vxlan_encap_conf.ipv4_dst); 15222 } else { 15223 IPV6_ADDR_TO_ARRAY(res->ip_src, vxlan_encap_conf.ipv6_src); 15224 IPV6_ADDR_TO_ARRAY(res->ip_dst, vxlan_encap_conf.ipv6_dst); 15225 } 15226 if (vxlan_encap_conf.select_vlan) 15227 vxlan_encap_conf.vlan_tci = rte_cpu_to_be_16(res->tci); 15228 rte_memcpy(vxlan_encap_conf.eth_src, res->eth_src.addr_bytes, 15229 ETHER_ADDR_LEN); 15230 rte_memcpy(vxlan_encap_conf.eth_dst, res->eth_dst.addr_bytes, 15231 ETHER_ADDR_LEN); 15232 } 15233 15234 cmdline_parse_inst_t cmd_set_vxlan = { 15235 .f = cmd_set_vxlan_parsed, 15236 .data = NULL, 15237 .help_str = "set vxlan ip-version ipv4|ipv6 vni <vni> udp-src" 15238 " <udp-src> udp-dst <udp-dst> ip-src <ip-src> ip-dst <ip-dst>" 15239 " eth-src <eth-src> eth-dst <eth-dst>", 15240 .tokens = { 15241 (void *)&cmd_set_vxlan_set, 15242 (void *)&cmd_set_vxlan_vxlan, 15243 (void *)&cmd_set_vxlan_ip_version, 15244 (void *)&cmd_set_vxlan_ip_version_value, 15245 (void *)&cmd_set_vxlan_vni, 15246 (void *)&cmd_set_vxlan_vni_value, 15247 (void *)&cmd_set_vxlan_udp_src, 15248 (void *)&cmd_set_vxlan_udp_src_value, 15249 (void *)&cmd_set_vxlan_udp_dst, 15250 (void *)&cmd_set_vxlan_udp_dst_value, 15251 (void *)&cmd_set_vxlan_ip_src, 15252 (void *)&cmd_set_vxlan_ip_src_value, 15253 (void *)&cmd_set_vxlan_ip_dst, 15254 (void *)&cmd_set_vxlan_ip_dst_value, 15255 (void *)&cmd_set_vxlan_eth_src, 15256 (void *)&cmd_set_vxlan_eth_src_value, 15257 (void *)&cmd_set_vxlan_eth_dst, 15258 (void *)&cmd_set_vxlan_eth_dst_value, 15259 NULL, 15260 }, 15261 }; 15262 15263 cmdline_parse_inst_t cmd_set_vxlan_with_vlan = { 15264 .f = cmd_set_vxlan_parsed, 15265 .data = NULL, 15266 .help_str = "set vxlan-with-vlan ip-version ipv4|ipv6 vni <vni>" 15267 " udp-src <udp-src> udp-dst <udp-dst> ip-src <ip-src> ip-dst" 15268 " <ip-dst> vlan-tci <vlan-tci> eth-src <eth-src> eth-dst" 15269 " <eth-dst>", 15270 .tokens = { 15271 (void *)&cmd_set_vxlan_set, 15272 (void *)&cmd_set_vxlan_vxlan_with_vlan, 15273 (void *)&cmd_set_vxlan_ip_version, 15274 (void *)&cmd_set_vxlan_ip_version_value, 15275 (void *)&cmd_set_vxlan_vni, 15276 (void *)&cmd_set_vxlan_vni_value, 15277 (void *)&cmd_set_vxlan_udp_src, 15278 (void *)&cmd_set_vxlan_udp_src_value, 15279 (void *)&cmd_set_vxlan_udp_dst, 15280 (void *)&cmd_set_vxlan_udp_dst_value, 15281 (void *)&cmd_set_vxlan_ip_src, 15282 (void *)&cmd_set_vxlan_ip_src_value, 15283 (void *)&cmd_set_vxlan_ip_dst, 15284 (void *)&cmd_set_vxlan_ip_dst_value, 15285 (void *)&cmd_set_vxlan_vlan, 15286 (void *)&cmd_set_vxlan_vlan_value, 15287 (void *)&cmd_set_vxlan_eth_src, 15288 (void *)&cmd_set_vxlan_eth_src_value, 15289 (void *)&cmd_set_vxlan_eth_dst, 15290 (void *)&cmd_set_vxlan_eth_dst_value, 15291 NULL, 15292 }, 15293 }; 15294 15295 /** Set NVGRE encapsulation details */ 15296 struct cmd_set_nvgre_result { 15297 cmdline_fixed_string_t set; 15298 cmdline_fixed_string_t nvgre; 15299 cmdline_fixed_string_t pos_token; 15300 cmdline_fixed_string_t ip_version; 15301 uint32_t tni; 15302 cmdline_ipaddr_t ip_src; 15303 cmdline_ipaddr_t ip_dst; 15304 uint16_t tci; 15305 struct ether_addr eth_src; 15306 struct ether_addr eth_dst; 15307 }; 15308 15309 cmdline_parse_token_string_t cmd_set_nvgre_set = 15310 TOKEN_STRING_INITIALIZER(struct cmd_set_nvgre_result, set, "set"); 15311 cmdline_parse_token_string_t cmd_set_nvgre_nvgre = 15312 TOKEN_STRING_INITIALIZER(struct cmd_set_nvgre_result, nvgre, "nvgre"); 15313 cmdline_parse_token_string_t cmd_set_nvgre_nvgre_with_vlan = 15314 TOKEN_STRING_INITIALIZER(struct cmd_set_nvgre_result, nvgre, 15315 "nvgre-with-vlan"); 15316 cmdline_parse_token_string_t cmd_set_nvgre_ip_version = 15317 TOKEN_STRING_INITIALIZER(struct cmd_set_nvgre_result, pos_token, 15318 "ip-version"); 15319 cmdline_parse_token_string_t cmd_set_nvgre_ip_version_value = 15320 TOKEN_STRING_INITIALIZER(struct cmd_set_nvgre_result, ip_version, 15321 "ipv4#ipv6"); 15322 cmdline_parse_token_string_t cmd_set_nvgre_tni = 15323 TOKEN_STRING_INITIALIZER(struct cmd_set_nvgre_result, pos_token, 15324 "tni"); 15325 cmdline_parse_token_num_t cmd_set_nvgre_tni_value = 15326 TOKEN_NUM_INITIALIZER(struct cmd_set_nvgre_result, tni, UINT32); 15327 cmdline_parse_token_string_t cmd_set_nvgre_ip_src = 15328 TOKEN_STRING_INITIALIZER(struct cmd_set_nvgre_result, pos_token, 15329 "ip-src"); 15330 cmdline_parse_token_num_t cmd_set_nvgre_ip_src_value = 15331 TOKEN_IPADDR_INITIALIZER(struct cmd_set_nvgre_result, ip_src); 15332 cmdline_parse_token_string_t cmd_set_nvgre_ip_dst = 15333 TOKEN_STRING_INITIALIZER(struct cmd_set_nvgre_result, pos_token, 15334 "ip-dst"); 15335 cmdline_parse_token_ipaddr_t cmd_set_nvgre_ip_dst_value = 15336 TOKEN_IPADDR_INITIALIZER(struct cmd_set_nvgre_result, ip_dst); 15337 cmdline_parse_token_string_t cmd_set_nvgre_vlan = 15338 TOKEN_STRING_INITIALIZER(struct cmd_set_nvgre_result, pos_token, 15339 "vlan-tci"); 15340 cmdline_parse_token_num_t cmd_set_nvgre_vlan_value = 15341 TOKEN_NUM_INITIALIZER(struct cmd_set_nvgre_result, tci, UINT16); 15342 cmdline_parse_token_string_t cmd_set_nvgre_eth_src = 15343 TOKEN_STRING_INITIALIZER(struct cmd_set_nvgre_result, pos_token, 15344 "eth-src"); 15345 cmdline_parse_token_etheraddr_t cmd_set_nvgre_eth_src_value = 15346 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_nvgre_result, eth_src); 15347 cmdline_parse_token_string_t cmd_set_nvgre_eth_dst = 15348 TOKEN_STRING_INITIALIZER(struct cmd_set_nvgre_result, pos_token, 15349 "eth-dst"); 15350 cmdline_parse_token_etheraddr_t cmd_set_nvgre_eth_dst_value = 15351 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_nvgre_result, eth_dst); 15352 15353 static void cmd_set_nvgre_parsed(void *parsed_result, 15354 __attribute__((unused)) struct cmdline *cl, 15355 __attribute__((unused)) void *data) 15356 { 15357 struct cmd_set_nvgre_result *res = parsed_result; 15358 union { 15359 uint32_t nvgre_tni; 15360 uint8_t tni[4]; 15361 } id = { 15362 .nvgre_tni = rte_cpu_to_be_32(res->tni) & RTE_BE32(0x00ffffff), 15363 }; 15364 15365 if (strcmp(res->nvgre, "nvgre") == 0) 15366 nvgre_encap_conf.select_vlan = 0; 15367 else if (strcmp(res->nvgre, "nvgre-with-vlan") == 0) 15368 nvgre_encap_conf.select_vlan = 1; 15369 if (strcmp(res->ip_version, "ipv4") == 0) 15370 nvgre_encap_conf.select_ipv4 = 1; 15371 else if (strcmp(res->ip_version, "ipv6") == 0) 15372 nvgre_encap_conf.select_ipv4 = 0; 15373 else 15374 return; 15375 rte_memcpy(nvgre_encap_conf.tni, &id.tni[1], 3); 15376 if (nvgre_encap_conf.select_ipv4) { 15377 IPV4_ADDR_TO_UINT(res->ip_src, nvgre_encap_conf.ipv4_src); 15378 IPV4_ADDR_TO_UINT(res->ip_dst, nvgre_encap_conf.ipv4_dst); 15379 } else { 15380 IPV6_ADDR_TO_ARRAY(res->ip_src, nvgre_encap_conf.ipv6_src); 15381 IPV6_ADDR_TO_ARRAY(res->ip_dst, nvgre_encap_conf.ipv6_dst); 15382 } 15383 if (nvgre_encap_conf.select_vlan) 15384 nvgre_encap_conf.vlan_tci = rte_cpu_to_be_16(res->tci); 15385 rte_memcpy(nvgre_encap_conf.eth_src, res->eth_src.addr_bytes, 15386 ETHER_ADDR_LEN); 15387 rte_memcpy(nvgre_encap_conf.eth_dst, res->eth_dst.addr_bytes, 15388 ETHER_ADDR_LEN); 15389 } 15390 15391 cmdline_parse_inst_t cmd_set_nvgre = { 15392 .f = cmd_set_nvgre_parsed, 15393 .data = NULL, 15394 .help_str = "set nvgre ip-version <ipv4|ipv6> tni <tni> ip-src" 15395 " <ip-src> ip-dst <ip-dst> eth-src <eth-src>" 15396 " eth-dst <eth-dst>", 15397 .tokens = { 15398 (void *)&cmd_set_nvgre_set, 15399 (void *)&cmd_set_nvgre_nvgre, 15400 (void *)&cmd_set_nvgre_ip_version, 15401 (void *)&cmd_set_nvgre_ip_version_value, 15402 (void *)&cmd_set_nvgre_tni, 15403 (void *)&cmd_set_nvgre_tni_value, 15404 (void *)&cmd_set_nvgre_ip_src, 15405 (void *)&cmd_set_nvgre_ip_src_value, 15406 (void *)&cmd_set_nvgre_ip_dst, 15407 (void *)&cmd_set_nvgre_ip_dst_value, 15408 (void *)&cmd_set_nvgre_eth_src, 15409 (void *)&cmd_set_nvgre_eth_src_value, 15410 (void *)&cmd_set_nvgre_eth_dst, 15411 (void *)&cmd_set_nvgre_eth_dst_value, 15412 NULL, 15413 }, 15414 }; 15415 15416 cmdline_parse_inst_t cmd_set_nvgre_with_vlan = { 15417 .f = cmd_set_nvgre_parsed, 15418 .data = NULL, 15419 .help_str = "set nvgre-with-vlan ip-version <ipv4|ipv6> tni <tni>" 15420 " ip-src <ip-src> ip-dst <ip-dst> vlan-tci <vlan-tci>" 15421 " eth-src <eth-src> eth-dst <eth-dst>", 15422 .tokens = { 15423 (void *)&cmd_set_nvgre_set, 15424 (void *)&cmd_set_nvgre_nvgre_with_vlan, 15425 (void *)&cmd_set_nvgre_ip_version, 15426 (void *)&cmd_set_nvgre_ip_version_value, 15427 (void *)&cmd_set_nvgre_tni, 15428 (void *)&cmd_set_nvgre_tni_value, 15429 (void *)&cmd_set_nvgre_ip_src, 15430 (void *)&cmd_set_nvgre_ip_src_value, 15431 (void *)&cmd_set_nvgre_ip_dst, 15432 (void *)&cmd_set_nvgre_ip_dst_value, 15433 (void *)&cmd_set_nvgre_vlan, 15434 (void *)&cmd_set_nvgre_vlan_value, 15435 (void *)&cmd_set_nvgre_eth_src, 15436 (void *)&cmd_set_nvgre_eth_src_value, 15437 (void *)&cmd_set_nvgre_eth_dst, 15438 (void *)&cmd_set_nvgre_eth_dst_value, 15439 NULL, 15440 }, 15441 }; 15442 15443 /** Set L2 encapsulation details */ 15444 struct cmd_set_l2_encap_result { 15445 cmdline_fixed_string_t set; 15446 cmdline_fixed_string_t l2_encap; 15447 cmdline_fixed_string_t pos_token; 15448 cmdline_fixed_string_t ip_version; 15449 uint32_t vlan_present:1; 15450 uint16_t tci; 15451 struct ether_addr eth_src; 15452 struct ether_addr eth_dst; 15453 }; 15454 15455 cmdline_parse_token_string_t cmd_set_l2_encap_set = 15456 TOKEN_STRING_INITIALIZER(struct cmd_set_l2_encap_result, set, "set"); 15457 cmdline_parse_token_string_t cmd_set_l2_encap_l2_encap = 15458 TOKEN_STRING_INITIALIZER(struct cmd_set_l2_encap_result, l2_encap, "l2_encap"); 15459 cmdline_parse_token_string_t cmd_set_l2_encap_l2_encap_with_vlan = 15460 TOKEN_STRING_INITIALIZER(struct cmd_set_l2_encap_result, l2_encap, 15461 "l2_encap-with-vlan"); 15462 cmdline_parse_token_string_t cmd_set_l2_encap_ip_version = 15463 TOKEN_STRING_INITIALIZER(struct cmd_set_l2_encap_result, pos_token, 15464 "ip-version"); 15465 cmdline_parse_token_string_t cmd_set_l2_encap_ip_version_value = 15466 TOKEN_STRING_INITIALIZER(struct cmd_set_l2_encap_result, ip_version, 15467 "ipv4#ipv6"); 15468 cmdline_parse_token_string_t cmd_set_l2_encap_vlan = 15469 TOKEN_STRING_INITIALIZER(struct cmd_set_l2_encap_result, pos_token, 15470 "vlan-tci"); 15471 cmdline_parse_token_num_t cmd_set_l2_encap_vlan_value = 15472 TOKEN_NUM_INITIALIZER(struct cmd_set_l2_encap_result, tci, UINT16); 15473 cmdline_parse_token_string_t cmd_set_l2_encap_eth_src = 15474 TOKEN_STRING_INITIALIZER(struct cmd_set_l2_encap_result, pos_token, 15475 "eth-src"); 15476 cmdline_parse_token_etheraddr_t cmd_set_l2_encap_eth_src_value = 15477 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_l2_encap_result, eth_src); 15478 cmdline_parse_token_string_t cmd_set_l2_encap_eth_dst = 15479 TOKEN_STRING_INITIALIZER(struct cmd_set_l2_encap_result, pos_token, 15480 "eth-dst"); 15481 cmdline_parse_token_etheraddr_t cmd_set_l2_encap_eth_dst_value = 15482 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_l2_encap_result, eth_dst); 15483 15484 static void cmd_set_l2_encap_parsed(void *parsed_result, 15485 __attribute__((unused)) struct cmdline *cl, 15486 __attribute__((unused)) void *data) 15487 { 15488 struct cmd_set_l2_encap_result *res = parsed_result; 15489 15490 if (strcmp(res->l2_encap, "l2_encap") == 0) 15491 l2_encap_conf.select_vlan = 0; 15492 else if (strcmp(res->l2_encap, "l2_encap-with-vlan") == 0) 15493 l2_encap_conf.select_vlan = 1; 15494 if (strcmp(res->ip_version, "ipv4") == 0) 15495 l2_encap_conf.select_ipv4 = 1; 15496 else if (strcmp(res->ip_version, "ipv6") == 0) 15497 l2_encap_conf.select_ipv4 = 0; 15498 else 15499 return; 15500 if (l2_encap_conf.select_vlan) 15501 l2_encap_conf.vlan_tci = rte_cpu_to_be_16(res->tci); 15502 rte_memcpy(l2_encap_conf.eth_src, res->eth_src.addr_bytes, 15503 ETHER_ADDR_LEN); 15504 rte_memcpy(l2_encap_conf.eth_dst, res->eth_dst.addr_bytes, 15505 ETHER_ADDR_LEN); 15506 } 15507 15508 cmdline_parse_inst_t cmd_set_l2_encap = { 15509 .f = cmd_set_l2_encap_parsed, 15510 .data = NULL, 15511 .help_str = "set l2_encap ip-version ipv4|ipv6" 15512 " eth-src <eth-src> eth-dst <eth-dst>", 15513 .tokens = { 15514 (void *)&cmd_set_l2_encap_set, 15515 (void *)&cmd_set_l2_encap_l2_encap, 15516 (void *)&cmd_set_l2_encap_ip_version, 15517 (void *)&cmd_set_l2_encap_ip_version_value, 15518 (void *)&cmd_set_l2_encap_eth_src, 15519 (void *)&cmd_set_l2_encap_eth_src_value, 15520 (void *)&cmd_set_l2_encap_eth_dst, 15521 (void *)&cmd_set_l2_encap_eth_dst_value, 15522 NULL, 15523 }, 15524 }; 15525 15526 cmdline_parse_inst_t cmd_set_l2_encap_with_vlan = { 15527 .f = cmd_set_l2_encap_parsed, 15528 .data = NULL, 15529 .help_str = "set l2_encap-with-vlan ip-version ipv4|ipv6" 15530 " vlan-tci <vlan-tci> eth-src <eth-src> eth-dst <eth-dst>", 15531 .tokens = { 15532 (void *)&cmd_set_l2_encap_set, 15533 (void *)&cmd_set_l2_encap_l2_encap_with_vlan, 15534 (void *)&cmd_set_l2_encap_ip_version, 15535 (void *)&cmd_set_l2_encap_ip_version_value, 15536 (void *)&cmd_set_l2_encap_vlan, 15537 (void *)&cmd_set_l2_encap_vlan_value, 15538 (void *)&cmd_set_l2_encap_eth_src, 15539 (void *)&cmd_set_l2_encap_eth_src_value, 15540 (void *)&cmd_set_l2_encap_eth_dst, 15541 (void *)&cmd_set_l2_encap_eth_dst_value, 15542 NULL, 15543 }, 15544 }; 15545 15546 /** Set L2 decapsulation details */ 15547 struct cmd_set_l2_decap_result { 15548 cmdline_fixed_string_t set; 15549 cmdline_fixed_string_t l2_decap; 15550 cmdline_fixed_string_t pos_token; 15551 uint32_t vlan_present:1; 15552 }; 15553 15554 cmdline_parse_token_string_t cmd_set_l2_decap_set = 15555 TOKEN_STRING_INITIALIZER(struct cmd_set_l2_decap_result, set, "set"); 15556 cmdline_parse_token_string_t cmd_set_l2_decap_l2_decap = 15557 TOKEN_STRING_INITIALIZER(struct cmd_set_l2_decap_result, l2_decap, 15558 "l2_decap"); 15559 cmdline_parse_token_string_t cmd_set_l2_decap_l2_decap_with_vlan = 15560 TOKEN_STRING_INITIALIZER(struct cmd_set_l2_decap_result, l2_decap, 15561 "l2_decap-with-vlan"); 15562 15563 static void cmd_set_l2_decap_parsed(void *parsed_result, 15564 __attribute__((unused)) struct cmdline *cl, 15565 __attribute__((unused)) void *data) 15566 { 15567 struct cmd_set_l2_decap_result *res = parsed_result; 15568 15569 if (strcmp(res->l2_decap, "l2_decap") == 0) 15570 l2_decap_conf.select_vlan = 0; 15571 else if (strcmp(res->l2_decap, "l2_decap-with-vlan") == 0) 15572 l2_decap_conf.select_vlan = 1; 15573 } 15574 15575 cmdline_parse_inst_t cmd_set_l2_decap = { 15576 .f = cmd_set_l2_decap_parsed, 15577 .data = NULL, 15578 .help_str = "set l2_decap", 15579 .tokens = { 15580 (void *)&cmd_set_l2_decap_set, 15581 (void *)&cmd_set_l2_decap_l2_decap, 15582 NULL, 15583 }, 15584 }; 15585 15586 cmdline_parse_inst_t cmd_set_l2_decap_with_vlan = { 15587 .f = cmd_set_l2_decap_parsed, 15588 .data = NULL, 15589 .help_str = "set l2_decap-with-vlan", 15590 .tokens = { 15591 (void *)&cmd_set_l2_decap_set, 15592 (void *)&cmd_set_l2_decap_l2_decap_with_vlan, 15593 NULL, 15594 }, 15595 }; 15596 15597 /** Set MPLSoGRE encapsulation details */ 15598 struct cmd_set_mplsogre_encap_result { 15599 cmdline_fixed_string_t set; 15600 cmdline_fixed_string_t mplsogre; 15601 cmdline_fixed_string_t pos_token; 15602 cmdline_fixed_string_t ip_version; 15603 uint32_t vlan_present:1; 15604 uint32_t label; 15605 cmdline_ipaddr_t ip_src; 15606 cmdline_ipaddr_t ip_dst; 15607 uint16_t tci; 15608 struct ether_addr eth_src; 15609 struct ether_addr eth_dst; 15610 }; 15611 15612 cmdline_parse_token_string_t cmd_set_mplsogre_encap_set = 15613 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_encap_result, set, 15614 "set"); 15615 cmdline_parse_token_string_t cmd_set_mplsogre_encap_mplsogre_encap = 15616 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_encap_result, mplsogre, 15617 "mplsogre_encap"); 15618 cmdline_parse_token_string_t cmd_set_mplsogre_encap_mplsogre_encap_with_vlan = 15619 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_encap_result, 15620 mplsogre, "mplsogre_encap-with-vlan"); 15621 cmdline_parse_token_string_t cmd_set_mplsogre_encap_ip_version = 15622 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_encap_result, 15623 pos_token, "ip-version"); 15624 cmdline_parse_token_string_t cmd_set_mplsogre_encap_ip_version_value = 15625 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_encap_result, 15626 ip_version, "ipv4#ipv6"); 15627 cmdline_parse_token_string_t cmd_set_mplsogre_encap_label = 15628 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_encap_result, 15629 pos_token, "label"); 15630 cmdline_parse_token_num_t cmd_set_mplsogre_encap_label_value = 15631 TOKEN_NUM_INITIALIZER(struct cmd_set_mplsogre_encap_result, label, 15632 UINT32); 15633 cmdline_parse_token_string_t cmd_set_mplsogre_encap_ip_src = 15634 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_encap_result, 15635 pos_token, "ip-src"); 15636 cmdline_parse_token_ipaddr_t cmd_set_mplsogre_encap_ip_src_value = 15637 TOKEN_IPADDR_INITIALIZER(struct cmd_set_mplsogre_encap_result, ip_src); 15638 cmdline_parse_token_string_t cmd_set_mplsogre_encap_ip_dst = 15639 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_encap_result, 15640 pos_token, "ip-dst"); 15641 cmdline_parse_token_ipaddr_t cmd_set_mplsogre_encap_ip_dst_value = 15642 TOKEN_IPADDR_INITIALIZER(struct cmd_set_mplsogre_encap_result, ip_dst); 15643 cmdline_parse_token_string_t cmd_set_mplsogre_encap_vlan = 15644 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_encap_result, 15645 pos_token, "vlan-tci"); 15646 cmdline_parse_token_num_t cmd_set_mplsogre_encap_vlan_value = 15647 TOKEN_NUM_INITIALIZER(struct cmd_set_mplsogre_encap_result, tci, 15648 UINT16); 15649 cmdline_parse_token_string_t cmd_set_mplsogre_encap_eth_src = 15650 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_encap_result, 15651 pos_token, "eth-src"); 15652 cmdline_parse_token_etheraddr_t cmd_set_mplsogre_encap_eth_src_value = 15653 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_mplsogre_encap_result, 15654 eth_src); 15655 cmdline_parse_token_string_t cmd_set_mplsogre_encap_eth_dst = 15656 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_encap_result, 15657 pos_token, "eth-dst"); 15658 cmdline_parse_token_etheraddr_t cmd_set_mplsogre_encap_eth_dst_value = 15659 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_mplsogre_encap_result, 15660 eth_dst); 15661 15662 static void cmd_set_mplsogre_encap_parsed(void *parsed_result, 15663 __attribute__((unused)) struct cmdline *cl, 15664 __attribute__((unused)) void *data) 15665 { 15666 struct cmd_set_mplsogre_encap_result *res = parsed_result; 15667 union { 15668 uint32_t mplsogre_label; 15669 uint8_t label[4]; 15670 } id = { 15671 .mplsogre_label = rte_cpu_to_be_32(res->label<<12), 15672 }; 15673 15674 if (strcmp(res->mplsogre, "mplsogre_encap") == 0) 15675 mplsogre_encap_conf.select_vlan = 0; 15676 else if (strcmp(res->mplsogre, "mplsogre_encap-with-vlan") == 0) 15677 mplsogre_encap_conf.select_vlan = 1; 15678 if (strcmp(res->ip_version, "ipv4") == 0) 15679 mplsogre_encap_conf.select_ipv4 = 1; 15680 else if (strcmp(res->ip_version, "ipv6") == 0) 15681 mplsogre_encap_conf.select_ipv4 = 0; 15682 else 15683 return; 15684 rte_memcpy(mplsogre_encap_conf.label, &id.label, 3); 15685 if (mplsogre_encap_conf.select_ipv4) { 15686 IPV4_ADDR_TO_UINT(res->ip_src, mplsogre_encap_conf.ipv4_src); 15687 IPV4_ADDR_TO_UINT(res->ip_dst, mplsogre_encap_conf.ipv4_dst); 15688 } else { 15689 IPV6_ADDR_TO_ARRAY(res->ip_src, mplsogre_encap_conf.ipv6_src); 15690 IPV6_ADDR_TO_ARRAY(res->ip_dst, mplsogre_encap_conf.ipv6_dst); 15691 } 15692 if (mplsogre_encap_conf.select_vlan) 15693 mplsogre_encap_conf.vlan_tci = rte_cpu_to_be_16(res->tci); 15694 rte_memcpy(mplsogre_encap_conf.eth_src, res->eth_src.addr_bytes, 15695 ETHER_ADDR_LEN); 15696 rte_memcpy(mplsogre_encap_conf.eth_dst, res->eth_dst.addr_bytes, 15697 ETHER_ADDR_LEN); 15698 } 15699 15700 cmdline_parse_inst_t cmd_set_mplsogre_encap = { 15701 .f = cmd_set_mplsogre_encap_parsed, 15702 .data = NULL, 15703 .help_str = "set mplsogre_encap ip-version ipv4|ipv6 label <label>" 15704 " ip-src <ip-src> ip-dst <ip-dst> eth-src <eth-src>" 15705 " eth-dst <eth-dst>", 15706 .tokens = { 15707 (void *)&cmd_set_mplsogre_encap_set, 15708 (void *)&cmd_set_mplsogre_encap_mplsogre_encap, 15709 (void *)&cmd_set_mplsogre_encap_ip_version, 15710 (void *)&cmd_set_mplsogre_encap_ip_version_value, 15711 (void *)&cmd_set_mplsogre_encap_label, 15712 (void *)&cmd_set_mplsogre_encap_label_value, 15713 (void *)&cmd_set_mplsogre_encap_ip_src, 15714 (void *)&cmd_set_mplsogre_encap_ip_src_value, 15715 (void *)&cmd_set_mplsogre_encap_ip_dst, 15716 (void *)&cmd_set_mplsogre_encap_ip_dst_value, 15717 (void *)&cmd_set_mplsogre_encap_eth_src, 15718 (void *)&cmd_set_mplsogre_encap_eth_src_value, 15719 (void *)&cmd_set_mplsogre_encap_eth_dst, 15720 (void *)&cmd_set_mplsogre_encap_eth_dst_value, 15721 NULL, 15722 }, 15723 }; 15724 15725 cmdline_parse_inst_t cmd_set_mplsogre_encap_with_vlan = { 15726 .f = cmd_set_mplsogre_encap_parsed, 15727 .data = NULL, 15728 .help_str = "set mplsogre_encap-with-vlan ip-version ipv4|ipv6" 15729 " label <label> ip-src <ip-src> ip-dst <ip-dst>" 15730 " vlan-tci <vlan-tci> eth-src <eth-src> eth-dst <eth-dst>", 15731 .tokens = { 15732 (void *)&cmd_set_mplsogre_encap_set, 15733 (void *)&cmd_set_mplsogre_encap_mplsogre_encap_with_vlan, 15734 (void *)&cmd_set_mplsogre_encap_ip_version, 15735 (void *)&cmd_set_mplsogre_encap_ip_version_value, 15736 (void *)&cmd_set_mplsogre_encap_label, 15737 (void *)&cmd_set_mplsogre_encap_label_value, 15738 (void *)&cmd_set_mplsogre_encap_ip_src, 15739 (void *)&cmd_set_mplsogre_encap_ip_src_value, 15740 (void *)&cmd_set_mplsogre_encap_ip_dst, 15741 (void *)&cmd_set_mplsogre_encap_ip_dst_value, 15742 (void *)&cmd_set_mplsogre_encap_vlan, 15743 (void *)&cmd_set_mplsogre_encap_vlan_value, 15744 (void *)&cmd_set_mplsogre_encap_eth_src, 15745 (void *)&cmd_set_mplsogre_encap_eth_src_value, 15746 (void *)&cmd_set_mplsogre_encap_eth_dst, 15747 (void *)&cmd_set_mplsogre_encap_eth_dst_value, 15748 NULL, 15749 }, 15750 }; 15751 15752 /** Set MPLSoGRE decapsulation details */ 15753 struct cmd_set_mplsogre_decap_result { 15754 cmdline_fixed_string_t set; 15755 cmdline_fixed_string_t mplsogre; 15756 cmdline_fixed_string_t pos_token; 15757 cmdline_fixed_string_t ip_version; 15758 uint32_t vlan_present:1; 15759 }; 15760 15761 cmdline_parse_token_string_t cmd_set_mplsogre_decap_set = 15762 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_decap_result, set, 15763 "set"); 15764 cmdline_parse_token_string_t cmd_set_mplsogre_decap_mplsogre_decap = 15765 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_decap_result, mplsogre, 15766 "mplsogre_decap"); 15767 cmdline_parse_token_string_t cmd_set_mplsogre_decap_mplsogre_decap_with_vlan = 15768 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_decap_result, 15769 mplsogre, "mplsogre_decap-with-vlan"); 15770 cmdline_parse_token_string_t cmd_set_mplsogre_decap_ip_version = 15771 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_decap_result, 15772 pos_token, "ip-version"); 15773 cmdline_parse_token_string_t cmd_set_mplsogre_decap_ip_version_value = 15774 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_decap_result, 15775 ip_version, "ipv4#ipv6"); 15776 15777 static void cmd_set_mplsogre_decap_parsed(void *parsed_result, 15778 __attribute__((unused)) struct cmdline *cl, 15779 __attribute__((unused)) void *data) 15780 { 15781 struct cmd_set_mplsogre_decap_result *res = parsed_result; 15782 15783 if (strcmp(res->mplsogre, "mplsogre_decap") == 0) 15784 mplsogre_decap_conf.select_vlan = 0; 15785 else if (strcmp(res->mplsogre, "mplsogre_decap-with-vlan") == 0) 15786 mplsogre_decap_conf.select_vlan = 1; 15787 if (strcmp(res->ip_version, "ipv4") == 0) 15788 mplsogre_decap_conf.select_ipv4 = 1; 15789 else if (strcmp(res->ip_version, "ipv6") == 0) 15790 mplsogre_decap_conf.select_ipv4 = 0; 15791 } 15792 15793 cmdline_parse_inst_t cmd_set_mplsogre_decap = { 15794 .f = cmd_set_mplsogre_decap_parsed, 15795 .data = NULL, 15796 .help_str = "set mplsogre_decap ip-version ipv4|ipv6", 15797 .tokens = { 15798 (void *)&cmd_set_mplsogre_decap_set, 15799 (void *)&cmd_set_mplsogre_decap_mplsogre_decap, 15800 (void *)&cmd_set_mplsogre_decap_ip_version, 15801 (void *)&cmd_set_mplsogre_decap_ip_version_value, 15802 NULL, 15803 }, 15804 }; 15805 15806 cmdline_parse_inst_t cmd_set_mplsogre_decap_with_vlan = { 15807 .f = cmd_set_mplsogre_decap_parsed, 15808 .data = NULL, 15809 .help_str = "set mplsogre_decap-with-vlan ip-version ipv4|ipv6", 15810 .tokens = { 15811 (void *)&cmd_set_mplsogre_decap_set, 15812 (void *)&cmd_set_mplsogre_decap_mplsogre_decap_with_vlan, 15813 (void *)&cmd_set_mplsogre_decap_ip_version, 15814 (void *)&cmd_set_mplsogre_decap_ip_version_value, 15815 NULL, 15816 }, 15817 }; 15818 15819 /** Set MPLSoUDP encapsulation details */ 15820 struct cmd_set_mplsoudp_encap_result { 15821 cmdline_fixed_string_t set; 15822 cmdline_fixed_string_t mplsoudp; 15823 cmdline_fixed_string_t pos_token; 15824 cmdline_fixed_string_t ip_version; 15825 uint32_t vlan_present:1; 15826 uint32_t label; 15827 uint16_t udp_src; 15828 uint16_t udp_dst; 15829 cmdline_ipaddr_t ip_src; 15830 cmdline_ipaddr_t ip_dst; 15831 uint16_t tci; 15832 struct ether_addr eth_src; 15833 struct ether_addr eth_dst; 15834 }; 15835 15836 cmdline_parse_token_string_t cmd_set_mplsoudp_encap_set = 15837 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_encap_result, set, 15838 "set"); 15839 cmdline_parse_token_string_t cmd_set_mplsoudp_encap_mplsoudp_encap = 15840 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_encap_result, mplsoudp, 15841 "mplsoudp_encap"); 15842 cmdline_parse_token_string_t cmd_set_mplsoudp_encap_mplsoudp_encap_with_vlan = 15843 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_encap_result, 15844 mplsoudp, "mplsoudp_encap-with-vlan"); 15845 cmdline_parse_token_string_t cmd_set_mplsoudp_encap_ip_version = 15846 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_encap_result, 15847 pos_token, "ip-version"); 15848 cmdline_parse_token_string_t cmd_set_mplsoudp_encap_ip_version_value = 15849 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_encap_result, 15850 ip_version, "ipv4#ipv6"); 15851 cmdline_parse_token_string_t cmd_set_mplsoudp_encap_label = 15852 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_encap_result, 15853 pos_token, "label"); 15854 cmdline_parse_token_num_t cmd_set_mplsoudp_encap_label_value = 15855 TOKEN_NUM_INITIALIZER(struct cmd_set_mplsoudp_encap_result, label, 15856 UINT32); 15857 cmdline_parse_token_string_t cmd_set_mplsoudp_encap_udp_src = 15858 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_encap_result, 15859 pos_token, "udp-src"); 15860 cmdline_parse_token_num_t cmd_set_mplsoudp_encap_udp_src_value = 15861 TOKEN_NUM_INITIALIZER(struct cmd_set_mplsoudp_encap_result, udp_src, 15862 UINT16); 15863 cmdline_parse_token_string_t cmd_set_mplsoudp_encap_udp_dst = 15864 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_encap_result, 15865 pos_token, "udp-dst"); 15866 cmdline_parse_token_num_t cmd_set_mplsoudp_encap_udp_dst_value = 15867 TOKEN_NUM_INITIALIZER(struct cmd_set_mplsoudp_encap_result, udp_dst, 15868 UINT16); 15869 cmdline_parse_token_string_t cmd_set_mplsoudp_encap_ip_src = 15870 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_encap_result, 15871 pos_token, "ip-src"); 15872 cmdline_parse_token_ipaddr_t cmd_set_mplsoudp_encap_ip_src_value = 15873 TOKEN_IPADDR_INITIALIZER(struct cmd_set_mplsoudp_encap_result, ip_src); 15874 cmdline_parse_token_string_t cmd_set_mplsoudp_encap_ip_dst = 15875 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_encap_result, 15876 pos_token, "ip-dst"); 15877 cmdline_parse_token_ipaddr_t cmd_set_mplsoudp_encap_ip_dst_value = 15878 TOKEN_IPADDR_INITIALIZER(struct cmd_set_mplsoudp_encap_result, ip_dst); 15879 cmdline_parse_token_string_t cmd_set_mplsoudp_encap_vlan = 15880 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_encap_result, 15881 pos_token, "vlan-tci"); 15882 cmdline_parse_token_num_t cmd_set_mplsoudp_encap_vlan_value = 15883 TOKEN_NUM_INITIALIZER(struct cmd_set_mplsoudp_encap_result, tci, 15884 UINT16); 15885 cmdline_parse_token_string_t cmd_set_mplsoudp_encap_eth_src = 15886 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_encap_result, 15887 pos_token, "eth-src"); 15888 cmdline_parse_token_etheraddr_t cmd_set_mplsoudp_encap_eth_src_value = 15889 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_mplsoudp_encap_result, 15890 eth_src); 15891 cmdline_parse_token_string_t cmd_set_mplsoudp_encap_eth_dst = 15892 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_encap_result, 15893 pos_token, "eth-dst"); 15894 cmdline_parse_token_etheraddr_t cmd_set_mplsoudp_encap_eth_dst_value = 15895 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_mplsoudp_encap_result, 15896 eth_dst); 15897 15898 static void cmd_set_mplsoudp_encap_parsed(void *parsed_result, 15899 __attribute__((unused)) struct cmdline *cl, 15900 __attribute__((unused)) void *data) 15901 { 15902 struct cmd_set_mplsoudp_encap_result *res = parsed_result; 15903 union { 15904 uint32_t mplsoudp_label; 15905 uint8_t label[4]; 15906 } id = { 15907 .mplsoudp_label = rte_cpu_to_be_32(res->label<<12), 15908 }; 15909 15910 if (strcmp(res->mplsoudp, "mplsoudp_encap") == 0) 15911 mplsoudp_encap_conf.select_vlan = 0; 15912 else if (strcmp(res->mplsoudp, "mplsoudp_encap-with-vlan") == 0) 15913 mplsoudp_encap_conf.select_vlan = 1; 15914 if (strcmp(res->ip_version, "ipv4") == 0) 15915 mplsoudp_encap_conf.select_ipv4 = 1; 15916 else if (strcmp(res->ip_version, "ipv6") == 0) 15917 mplsoudp_encap_conf.select_ipv4 = 0; 15918 else 15919 return; 15920 rte_memcpy(mplsoudp_encap_conf.label, &id.label, 3); 15921 mplsoudp_encap_conf.udp_src = rte_cpu_to_be_16(res->udp_src); 15922 mplsoudp_encap_conf.udp_dst = rte_cpu_to_be_16(res->udp_dst); 15923 if (mplsoudp_encap_conf.select_ipv4) { 15924 IPV4_ADDR_TO_UINT(res->ip_src, mplsoudp_encap_conf.ipv4_src); 15925 IPV4_ADDR_TO_UINT(res->ip_dst, mplsoudp_encap_conf.ipv4_dst); 15926 } else { 15927 IPV6_ADDR_TO_ARRAY(res->ip_src, mplsoudp_encap_conf.ipv6_src); 15928 IPV6_ADDR_TO_ARRAY(res->ip_dst, mplsoudp_encap_conf.ipv6_dst); 15929 } 15930 if (mplsoudp_encap_conf.select_vlan) 15931 mplsoudp_encap_conf.vlan_tci = rte_cpu_to_be_16(res->tci); 15932 rte_memcpy(mplsoudp_encap_conf.eth_src, res->eth_src.addr_bytes, 15933 ETHER_ADDR_LEN); 15934 rte_memcpy(mplsoudp_encap_conf.eth_dst, res->eth_dst.addr_bytes, 15935 ETHER_ADDR_LEN); 15936 } 15937 15938 cmdline_parse_inst_t cmd_set_mplsoudp_encap = { 15939 .f = cmd_set_mplsoudp_encap_parsed, 15940 .data = NULL, 15941 .help_str = "set mplsoudp_encap ip-version ipv4|ipv6 label <label>" 15942 " udp-src <udp-src> udp-dst <udp-dst> ip-src <ip-src>" 15943 " ip-dst <ip-dst> eth-src <eth-src> eth-dst <eth-dst>", 15944 .tokens = { 15945 (void *)&cmd_set_mplsoudp_encap_set, 15946 (void *)&cmd_set_mplsoudp_encap_mplsoudp_encap, 15947 (void *)&cmd_set_mplsoudp_encap_ip_version, 15948 (void *)&cmd_set_mplsoudp_encap_ip_version_value, 15949 (void *)&cmd_set_mplsoudp_encap_label, 15950 (void *)&cmd_set_mplsoudp_encap_label_value, 15951 (void *)&cmd_set_mplsoudp_encap_udp_src, 15952 (void *)&cmd_set_mplsoudp_encap_udp_src_value, 15953 (void *)&cmd_set_mplsoudp_encap_udp_dst, 15954 (void *)&cmd_set_mplsoudp_encap_udp_dst_value, 15955 (void *)&cmd_set_mplsoudp_encap_ip_src, 15956 (void *)&cmd_set_mplsoudp_encap_ip_src_value, 15957 (void *)&cmd_set_mplsoudp_encap_ip_dst, 15958 (void *)&cmd_set_mplsoudp_encap_ip_dst_value, 15959 (void *)&cmd_set_mplsoudp_encap_eth_src, 15960 (void *)&cmd_set_mplsoudp_encap_eth_src_value, 15961 (void *)&cmd_set_mplsoudp_encap_eth_dst, 15962 (void *)&cmd_set_mplsoudp_encap_eth_dst_value, 15963 NULL, 15964 }, 15965 }; 15966 15967 cmdline_parse_inst_t cmd_set_mplsoudp_encap_with_vlan = { 15968 .f = cmd_set_mplsoudp_encap_parsed, 15969 .data = NULL, 15970 .help_str = "set mplsoudp_encap-with-vlan ip-version ipv4|ipv6" 15971 " label <label> udp-src <udp-src> udp-dst <udp-dst>" 15972 " ip-src <ip-src> ip-dst <ip-dst> vlan-tci <vlan-tci>" 15973 " eth-src <eth-src> eth-dst <eth-dst>", 15974 .tokens = { 15975 (void *)&cmd_set_mplsoudp_encap_set, 15976 (void *)&cmd_set_mplsoudp_encap_mplsoudp_encap_with_vlan, 15977 (void *)&cmd_set_mplsoudp_encap_ip_version, 15978 (void *)&cmd_set_mplsoudp_encap_ip_version_value, 15979 (void *)&cmd_set_mplsoudp_encap_label, 15980 (void *)&cmd_set_mplsoudp_encap_label_value, 15981 (void *)&cmd_set_mplsoudp_encap_udp_src, 15982 (void *)&cmd_set_mplsoudp_encap_udp_src_value, 15983 (void *)&cmd_set_mplsoudp_encap_udp_dst, 15984 (void *)&cmd_set_mplsoudp_encap_udp_dst_value, 15985 (void *)&cmd_set_mplsoudp_encap_ip_src, 15986 (void *)&cmd_set_mplsoudp_encap_ip_src_value, 15987 (void *)&cmd_set_mplsoudp_encap_ip_dst, 15988 (void *)&cmd_set_mplsoudp_encap_ip_dst_value, 15989 (void *)&cmd_set_mplsoudp_encap_vlan, 15990 (void *)&cmd_set_mplsoudp_encap_vlan_value, 15991 (void *)&cmd_set_mplsoudp_encap_eth_src, 15992 (void *)&cmd_set_mplsoudp_encap_eth_src_value, 15993 (void *)&cmd_set_mplsoudp_encap_eth_dst, 15994 (void *)&cmd_set_mplsoudp_encap_eth_dst_value, 15995 NULL, 15996 }, 15997 }; 15998 15999 /** Set MPLSoUDP decapsulation details */ 16000 struct cmd_set_mplsoudp_decap_result { 16001 cmdline_fixed_string_t set; 16002 cmdline_fixed_string_t mplsoudp; 16003 cmdline_fixed_string_t pos_token; 16004 cmdline_fixed_string_t ip_version; 16005 uint32_t vlan_present:1; 16006 }; 16007 16008 cmdline_parse_token_string_t cmd_set_mplsoudp_decap_set = 16009 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_decap_result, set, 16010 "set"); 16011 cmdline_parse_token_string_t cmd_set_mplsoudp_decap_mplsoudp_decap = 16012 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_decap_result, mplsoudp, 16013 "mplsoudp_decap"); 16014 cmdline_parse_token_string_t cmd_set_mplsoudp_decap_mplsoudp_decap_with_vlan = 16015 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_decap_result, 16016 mplsoudp, "mplsoudp_decap-with-vlan"); 16017 cmdline_parse_token_string_t cmd_set_mplsoudp_decap_ip_version = 16018 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_decap_result, 16019 pos_token, "ip-version"); 16020 cmdline_parse_token_string_t cmd_set_mplsoudp_decap_ip_version_value = 16021 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_decap_result, 16022 ip_version, "ipv4#ipv6"); 16023 16024 static void cmd_set_mplsoudp_decap_parsed(void *parsed_result, 16025 __attribute__((unused)) struct cmdline *cl, 16026 __attribute__((unused)) void *data) 16027 { 16028 struct cmd_set_mplsoudp_decap_result *res = parsed_result; 16029 16030 if (strcmp(res->mplsoudp, "mplsoudp_decap") == 0) 16031 mplsoudp_decap_conf.select_vlan = 0; 16032 else if (strcmp(res->mplsoudp, "mplsoudp_decap-with-vlan") == 0) 16033 mplsoudp_decap_conf.select_vlan = 1; 16034 if (strcmp(res->ip_version, "ipv4") == 0) 16035 mplsoudp_decap_conf.select_ipv4 = 1; 16036 else if (strcmp(res->ip_version, "ipv6") == 0) 16037 mplsoudp_decap_conf.select_ipv4 = 0; 16038 } 16039 16040 cmdline_parse_inst_t cmd_set_mplsoudp_decap = { 16041 .f = cmd_set_mplsoudp_decap_parsed, 16042 .data = NULL, 16043 .help_str = "set mplsoudp_decap ip-version ipv4|ipv6", 16044 .tokens = { 16045 (void *)&cmd_set_mplsoudp_decap_set, 16046 (void *)&cmd_set_mplsoudp_decap_mplsoudp_decap, 16047 (void *)&cmd_set_mplsoudp_decap_ip_version, 16048 (void *)&cmd_set_mplsoudp_decap_ip_version_value, 16049 NULL, 16050 }, 16051 }; 16052 16053 cmdline_parse_inst_t cmd_set_mplsoudp_decap_with_vlan = { 16054 .f = cmd_set_mplsoudp_decap_parsed, 16055 .data = NULL, 16056 .help_str = "set mplsoudp_decap-with-vlan ip-version ipv4|ipv6", 16057 .tokens = { 16058 (void *)&cmd_set_mplsoudp_decap_set, 16059 (void *)&cmd_set_mplsoudp_decap_mplsoudp_decap_with_vlan, 16060 (void *)&cmd_set_mplsoudp_decap_ip_version, 16061 (void *)&cmd_set_mplsoudp_decap_ip_version_value, 16062 NULL, 16063 }, 16064 }; 16065 16066 /* Strict link priority scheduling mode setting */ 16067 static void 16068 cmd_strict_link_prio_parsed( 16069 void *parsed_result, 16070 __attribute__((unused)) struct cmdline *cl, 16071 __attribute__((unused)) void *data) 16072 { 16073 struct cmd_vf_tc_bw_result *res = parsed_result; 16074 int ret = -ENOTSUP; 16075 16076 if (port_id_is_invalid(res->port_id, ENABLED_WARN)) 16077 return; 16078 16079 #ifdef RTE_LIBRTE_I40E_PMD 16080 ret = rte_pmd_i40e_set_tc_strict_prio(res->port_id, res->tc_map); 16081 #endif 16082 16083 switch (ret) { 16084 case 0: 16085 break; 16086 case -EINVAL: 16087 printf("invalid tc_bitmap 0x%x\n", res->tc_map); 16088 break; 16089 case -ENODEV: 16090 printf("invalid port_id %d\n", res->port_id); 16091 break; 16092 case -ENOTSUP: 16093 printf("function not implemented\n"); 16094 break; 16095 default: 16096 printf("programming error: (%s)\n", strerror(-ret)); 16097 } 16098 } 16099 16100 cmdline_parse_inst_t cmd_strict_link_prio = { 16101 .f = cmd_strict_link_prio_parsed, 16102 .data = NULL, 16103 .help_str = "set tx strict-link-priority <port_id> <tc_bitmap>", 16104 .tokens = { 16105 (void *)&cmd_vf_tc_bw_set, 16106 (void *)&cmd_vf_tc_bw_tx, 16107 (void *)&cmd_vf_tc_bw_strict_link_prio, 16108 (void *)&cmd_vf_tc_bw_port_id, 16109 (void *)&cmd_vf_tc_bw_tc_map, 16110 NULL, 16111 }, 16112 }; 16113 16114 /* Load dynamic device personalization*/ 16115 struct cmd_ddp_add_result { 16116 cmdline_fixed_string_t ddp; 16117 cmdline_fixed_string_t add; 16118 portid_t port_id; 16119 char filepath[]; 16120 }; 16121 16122 cmdline_parse_token_string_t cmd_ddp_add_ddp = 16123 TOKEN_STRING_INITIALIZER(struct cmd_ddp_add_result, ddp, "ddp"); 16124 cmdline_parse_token_string_t cmd_ddp_add_add = 16125 TOKEN_STRING_INITIALIZER(struct cmd_ddp_add_result, add, "add"); 16126 cmdline_parse_token_num_t cmd_ddp_add_port_id = 16127 TOKEN_NUM_INITIALIZER(struct cmd_ddp_add_result, port_id, UINT16); 16128 cmdline_parse_token_string_t cmd_ddp_add_filepath = 16129 TOKEN_STRING_INITIALIZER(struct cmd_ddp_add_result, filepath, NULL); 16130 16131 static void 16132 cmd_ddp_add_parsed( 16133 void *parsed_result, 16134 __attribute__((unused)) struct cmdline *cl, 16135 __attribute__((unused)) void *data) 16136 { 16137 struct cmd_ddp_add_result *res = parsed_result; 16138 uint8_t *buff; 16139 uint32_t size; 16140 char *filepath; 16141 char *file_fld[2]; 16142 int file_num; 16143 int ret = -ENOTSUP; 16144 16145 if (!all_ports_stopped()) { 16146 printf("Please stop all ports first\n"); 16147 return; 16148 } 16149 16150 filepath = strdup(res->filepath); 16151 if (filepath == NULL) { 16152 printf("Failed to allocate memory\n"); 16153 return; 16154 } 16155 file_num = rte_strsplit(filepath, strlen(filepath), file_fld, 2, ','); 16156 16157 buff = open_file(file_fld[0], &size); 16158 if (!buff) { 16159 free((void *)filepath); 16160 return; 16161 } 16162 16163 #ifdef RTE_LIBRTE_I40E_PMD 16164 if (ret == -ENOTSUP) 16165 ret = rte_pmd_i40e_process_ddp_package(res->port_id, 16166 buff, size, 16167 RTE_PMD_I40E_PKG_OP_WR_ADD); 16168 #endif 16169 16170 if (ret == -EEXIST) 16171 printf("Profile has already existed.\n"); 16172 else if (ret < 0) 16173 printf("Failed to load profile.\n"); 16174 else if (file_num == 2) 16175 save_file(file_fld[1], buff, size); 16176 16177 close_file(buff); 16178 free((void *)filepath); 16179 } 16180 16181 cmdline_parse_inst_t cmd_ddp_add = { 16182 .f = cmd_ddp_add_parsed, 16183 .data = NULL, 16184 .help_str = "ddp add <port_id> <profile_path[,backup_profile_path]>", 16185 .tokens = { 16186 (void *)&cmd_ddp_add_ddp, 16187 (void *)&cmd_ddp_add_add, 16188 (void *)&cmd_ddp_add_port_id, 16189 (void *)&cmd_ddp_add_filepath, 16190 NULL, 16191 }, 16192 }; 16193 16194 /* Delete dynamic device personalization*/ 16195 struct cmd_ddp_del_result { 16196 cmdline_fixed_string_t ddp; 16197 cmdline_fixed_string_t del; 16198 portid_t port_id; 16199 char filepath[]; 16200 }; 16201 16202 cmdline_parse_token_string_t cmd_ddp_del_ddp = 16203 TOKEN_STRING_INITIALIZER(struct cmd_ddp_del_result, ddp, "ddp"); 16204 cmdline_parse_token_string_t cmd_ddp_del_del = 16205 TOKEN_STRING_INITIALIZER(struct cmd_ddp_del_result, del, "del"); 16206 cmdline_parse_token_num_t cmd_ddp_del_port_id = 16207 TOKEN_NUM_INITIALIZER(struct cmd_ddp_del_result, port_id, UINT16); 16208 cmdline_parse_token_string_t cmd_ddp_del_filepath = 16209 TOKEN_STRING_INITIALIZER(struct cmd_ddp_del_result, filepath, NULL); 16210 16211 static void 16212 cmd_ddp_del_parsed( 16213 void *parsed_result, 16214 __attribute__((unused)) struct cmdline *cl, 16215 __attribute__((unused)) void *data) 16216 { 16217 struct cmd_ddp_del_result *res = parsed_result; 16218 uint8_t *buff; 16219 uint32_t size; 16220 int ret = -ENOTSUP; 16221 16222 if (!all_ports_stopped()) { 16223 printf("Please stop all ports first\n"); 16224 return; 16225 } 16226 16227 buff = open_file(res->filepath, &size); 16228 if (!buff) 16229 return; 16230 16231 #ifdef RTE_LIBRTE_I40E_PMD 16232 if (ret == -ENOTSUP) 16233 ret = rte_pmd_i40e_process_ddp_package(res->port_id, 16234 buff, size, 16235 RTE_PMD_I40E_PKG_OP_WR_DEL); 16236 #endif 16237 16238 if (ret == -EACCES) 16239 printf("Profile does not exist.\n"); 16240 else if (ret < 0) 16241 printf("Failed to delete profile.\n"); 16242 16243 close_file(buff); 16244 } 16245 16246 cmdline_parse_inst_t cmd_ddp_del = { 16247 .f = cmd_ddp_del_parsed, 16248 .data = NULL, 16249 .help_str = "ddp del <port_id> <backup_profile_path>", 16250 .tokens = { 16251 (void *)&cmd_ddp_del_ddp, 16252 (void *)&cmd_ddp_del_del, 16253 (void *)&cmd_ddp_del_port_id, 16254 (void *)&cmd_ddp_del_filepath, 16255 NULL, 16256 }, 16257 }; 16258 16259 /* Get dynamic device personalization profile info */ 16260 struct cmd_ddp_info_result { 16261 cmdline_fixed_string_t ddp; 16262 cmdline_fixed_string_t get; 16263 cmdline_fixed_string_t info; 16264 char filepath[]; 16265 }; 16266 16267 cmdline_parse_token_string_t cmd_ddp_info_ddp = 16268 TOKEN_STRING_INITIALIZER(struct cmd_ddp_info_result, ddp, "ddp"); 16269 cmdline_parse_token_string_t cmd_ddp_info_get = 16270 TOKEN_STRING_INITIALIZER(struct cmd_ddp_info_result, get, "get"); 16271 cmdline_parse_token_string_t cmd_ddp_info_info = 16272 TOKEN_STRING_INITIALIZER(struct cmd_ddp_info_result, info, "info"); 16273 cmdline_parse_token_string_t cmd_ddp_info_filepath = 16274 TOKEN_STRING_INITIALIZER(struct cmd_ddp_info_result, filepath, NULL); 16275 16276 static void 16277 cmd_ddp_info_parsed( 16278 void *parsed_result, 16279 __attribute__((unused)) struct cmdline *cl, 16280 __attribute__((unused)) void *data) 16281 { 16282 struct cmd_ddp_info_result *res = parsed_result; 16283 uint8_t *pkg; 16284 uint32_t pkg_size; 16285 int ret = -ENOTSUP; 16286 #ifdef RTE_LIBRTE_I40E_PMD 16287 uint32_t i, j, n; 16288 uint8_t *buff; 16289 uint32_t buff_size = 0; 16290 struct rte_pmd_i40e_profile_info info; 16291 uint32_t dev_num = 0; 16292 struct rte_pmd_i40e_ddp_device_id *devs; 16293 uint32_t proto_num = 0; 16294 struct rte_pmd_i40e_proto_info *proto = NULL; 16295 uint32_t pctype_num = 0; 16296 struct rte_pmd_i40e_ptype_info *pctype; 16297 uint32_t ptype_num = 0; 16298 struct rte_pmd_i40e_ptype_info *ptype; 16299 uint8_t proto_id; 16300 16301 #endif 16302 16303 pkg = open_file(res->filepath, &pkg_size); 16304 if (!pkg) 16305 return; 16306 16307 #ifdef RTE_LIBRTE_I40E_PMD 16308 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size, 16309 (uint8_t *)&info, sizeof(info), 16310 RTE_PMD_I40E_PKG_INFO_GLOBAL_HEADER); 16311 if (!ret) { 16312 printf("Global Track id: 0x%x\n", info.track_id); 16313 printf("Global Version: %d.%d.%d.%d\n", 16314 info.version.major, 16315 info.version.minor, 16316 info.version.update, 16317 info.version.draft); 16318 printf("Global Package name: %s\n\n", info.name); 16319 } 16320 16321 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size, 16322 (uint8_t *)&info, sizeof(info), 16323 RTE_PMD_I40E_PKG_INFO_HEADER); 16324 if (!ret) { 16325 printf("i40e Profile Track id: 0x%x\n", info.track_id); 16326 printf("i40e Profile Version: %d.%d.%d.%d\n", 16327 info.version.major, 16328 info.version.minor, 16329 info.version.update, 16330 info.version.draft); 16331 printf("i40e Profile name: %s\n\n", info.name); 16332 } 16333 16334 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size, 16335 (uint8_t *)&buff_size, sizeof(buff_size), 16336 RTE_PMD_I40E_PKG_INFO_GLOBAL_NOTES_SIZE); 16337 if (!ret && buff_size) { 16338 buff = (uint8_t *)malloc(buff_size); 16339 if (buff) { 16340 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size, 16341 buff, buff_size, 16342 RTE_PMD_I40E_PKG_INFO_GLOBAL_NOTES); 16343 if (!ret) 16344 printf("Package Notes:\n%s\n\n", buff); 16345 free(buff); 16346 } 16347 } 16348 16349 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size, 16350 (uint8_t *)&dev_num, sizeof(dev_num), 16351 RTE_PMD_I40E_PKG_INFO_DEVID_NUM); 16352 if (!ret && dev_num) { 16353 buff_size = dev_num * sizeof(struct rte_pmd_i40e_ddp_device_id); 16354 devs = (struct rte_pmd_i40e_ddp_device_id *)malloc(buff_size); 16355 if (devs) { 16356 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size, 16357 (uint8_t *)devs, buff_size, 16358 RTE_PMD_I40E_PKG_INFO_DEVID_LIST); 16359 if (!ret) { 16360 printf("List of supported devices:\n"); 16361 for (i = 0; i < dev_num; i++) { 16362 printf(" %04X:%04X %04X:%04X\n", 16363 devs[i].vendor_dev_id >> 16, 16364 devs[i].vendor_dev_id & 0xFFFF, 16365 devs[i].sub_vendor_dev_id >> 16, 16366 devs[i].sub_vendor_dev_id & 0xFFFF); 16367 } 16368 printf("\n"); 16369 } 16370 free(devs); 16371 } 16372 } 16373 16374 /* get information about protocols and packet types */ 16375 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size, 16376 (uint8_t *)&proto_num, sizeof(proto_num), 16377 RTE_PMD_I40E_PKG_INFO_PROTOCOL_NUM); 16378 if (ret || !proto_num) 16379 goto no_print_return; 16380 16381 buff_size = proto_num * sizeof(struct rte_pmd_i40e_proto_info); 16382 proto = (struct rte_pmd_i40e_proto_info *)malloc(buff_size); 16383 if (!proto) 16384 goto no_print_return; 16385 16386 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size, (uint8_t *)proto, 16387 buff_size, 16388 RTE_PMD_I40E_PKG_INFO_PROTOCOL_LIST); 16389 if (!ret) { 16390 printf("List of used protocols:\n"); 16391 for (i = 0; i < proto_num; i++) 16392 printf(" %2u: %s\n", proto[i].proto_id, 16393 proto[i].name); 16394 printf("\n"); 16395 } 16396 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size, 16397 (uint8_t *)&pctype_num, sizeof(pctype_num), 16398 RTE_PMD_I40E_PKG_INFO_PCTYPE_NUM); 16399 if (ret || !pctype_num) 16400 goto no_print_pctypes; 16401 16402 buff_size = pctype_num * sizeof(struct rte_pmd_i40e_ptype_info); 16403 pctype = (struct rte_pmd_i40e_ptype_info *)malloc(buff_size); 16404 if (!pctype) 16405 goto no_print_pctypes; 16406 16407 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size, (uint8_t *)pctype, 16408 buff_size, 16409 RTE_PMD_I40E_PKG_INFO_PCTYPE_LIST); 16410 if (ret) { 16411 free(pctype); 16412 goto no_print_pctypes; 16413 } 16414 16415 printf("List of defined packet classification types:\n"); 16416 for (i = 0; i < pctype_num; i++) { 16417 printf(" %2u:", pctype[i].ptype_id); 16418 for (j = 0; j < RTE_PMD_I40E_PROTO_NUM; j++) { 16419 proto_id = pctype[i].protocols[j]; 16420 if (proto_id != RTE_PMD_I40E_PROTO_UNUSED) { 16421 for (n = 0; n < proto_num; n++) { 16422 if (proto[n].proto_id == proto_id) { 16423 printf(" %s", proto[n].name); 16424 break; 16425 } 16426 } 16427 } 16428 } 16429 printf("\n"); 16430 } 16431 printf("\n"); 16432 free(pctype); 16433 16434 no_print_pctypes: 16435 16436 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size, (uint8_t *)&ptype_num, 16437 sizeof(ptype_num), 16438 RTE_PMD_I40E_PKG_INFO_PTYPE_NUM); 16439 if (ret || !ptype_num) 16440 goto no_print_return; 16441 16442 buff_size = ptype_num * sizeof(struct rte_pmd_i40e_ptype_info); 16443 ptype = (struct rte_pmd_i40e_ptype_info *)malloc(buff_size); 16444 if (!ptype) 16445 goto no_print_return; 16446 16447 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size, (uint8_t *)ptype, 16448 buff_size, 16449 RTE_PMD_I40E_PKG_INFO_PTYPE_LIST); 16450 if (ret) { 16451 free(ptype); 16452 goto no_print_return; 16453 } 16454 printf("List of defined packet types:\n"); 16455 for (i = 0; i < ptype_num; i++) { 16456 printf(" %2u:", ptype[i].ptype_id); 16457 for (j = 0; j < RTE_PMD_I40E_PROTO_NUM; j++) { 16458 proto_id = ptype[i].protocols[j]; 16459 if (proto_id != RTE_PMD_I40E_PROTO_UNUSED) { 16460 for (n = 0; n < proto_num; n++) { 16461 if (proto[n].proto_id == proto_id) { 16462 printf(" %s", proto[n].name); 16463 break; 16464 } 16465 } 16466 } 16467 } 16468 printf("\n"); 16469 } 16470 free(ptype); 16471 printf("\n"); 16472 16473 ret = 0; 16474 no_print_return: 16475 if (proto) 16476 free(proto); 16477 #endif 16478 if (ret == -ENOTSUP) 16479 printf("Function not supported in PMD driver\n"); 16480 close_file(pkg); 16481 } 16482 16483 cmdline_parse_inst_t cmd_ddp_get_info = { 16484 .f = cmd_ddp_info_parsed, 16485 .data = NULL, 16486 .help_str = "ddp get info <profile_path>", 16487 .tokens = { 16488 (void *)&cmd_ddp_info_ddp, 16489 (void *)&cmd_ddp_info_get, 16490 (void *)&cmd_ddp_info_info, 16491 (void *)&cmd_ddp_info_filepath, 16492 NULL, 16493 }, 16494 }; 16495 16496 /* Get dynamic device personalization profile info list*/ 16497 #define PROFILE_INFO_SIZE 48 16498 #define MAX_PROFILE_NUM 16 16499 16500 struct cmd_ddp_get_list_result { 16501 cmdline_fixed_string_t ddp; 16502 cmdline_fixed_string_t get; 16503 cmdline_fixed_string_t list; 16504 portid_t port_id; 16505 }; 16506 16507 cmdline_parse_token_string_t cmd_ddp_get_list_ddp = 16508 TOKEN_STRING_INITIALIZER(struct cmd_ddp_get_list_result, ddp, "ddp"); 16509 cmdline_parse_token_string_t cmd_ddp_get_list_get = 16510 TOKEN_STRING_INITIALIZER(struct cmd_ddp_get_list_result, get, "get"); 16511 cmdline_parse_token_string_t cmd_ddp_get_list_list = 16512 TOKEN_STRING_INITIALIZER(struct cmd_ddp_get_list_result, list, "list"); 16513 cmdline_parse_token_num_t cmd_ddp_get_list_port_id = 16514 TOKEN_NUM_INITIALIZER(struct cmd_ddp_get_list_result, port_id, UINT16); 16515 16516 static void 16517 cmd_ddp_get_list_parsed( 16518 __attribute__((unused)) void *parsed_result, 16519 __attribute__((unused)) struct cmdline *cl, 16520 __attribute__((unused)) void *data) 16521 { 16522 #ifdef RTE_LIBRTE_I40E_PMD 16523 struct cmd_ddp_get_list_result *res = parsed_result; 16524 struct rte_pmd_i40e_profile_list *p_list; 16525 struct rte_pmd_i40e_profile_info *p_info; 16526 uint32_t p_num; 16527 uint32_t size; 16528 uint32_t i; 16529 #endif 16530 int ret = -ENOTSUP; 16531 16532 #ifdef RTE_LIBRTE_I40E_PMD 16533 size = PROFILE_INFO_SIZE * MAX_PROFILE_NUM + 4; 16534 p_list = (struct rte_pmd_i40e_profile_list *)malloc(size); 16535 if (!p_list) 16536 printf("%s: Failed to malloc buffer\n", __func__); 16537 16538 if (ret == -ENOTSUP) 16539 ret = rte_pmd_i40e_get_ddp_list(res->port_id, 16540 (uint8_t *)p_list, size); 16541 16542 if (!ret) { 16543 p_num = p_list->p_count; 16544 printf("Profile number is: %d\n\n", p_num); 16545 16546 for (i = 0; i < p_num; i++) { 16547 p_info = &p_list->p_info[i]; 16548 printf("Profile %d:\n", i); 16549 printf("Track id: 0x%x\n", p_info->track_id); 16550 printf("Version: %d.%d.%d.%d\n", 16551 p_info->version.major, 16552 p_info->version.minor, 16553 p_info->version.update, 16554 p_info->version.draft); 16555 printf("Profile name: %s\n\n", p_info->name); 16556 } 16557 } 16558 16559 free(p_list); 16560 #endif 16561 16562 if (ret < 0) 16563 printf("Failed to get ddp list\n"); 16564 } 16565 16566 cmdline_parse_inst_t cmd_ddp_get_list = { 16567 .f = cmd_ddp_get_list_parsed, 16568 .data = NULL, 16569 .help_str = "ddp get list <port_id>", 16570 .tokens = { 16571 (void *)&cmd_ddp_get_list_ddp, 16572 (void *)&cmd_ddp_get_list_get, 16573 (void *)&cmd_ddp_get_list_list, 16574 (void *)&cmd_ddp_get_list_port_id, 16575 NULL, 16576 }, 16577 }; 16578 16579 /* Configure input set */ 16580 struct cmd_cfg_input_set_result { 16581 cmdline_fixed_string_t port; 16582 cmdline_fixed_string_t cfg; 16583 portid_t port_id; 16584 cmdline_fixed_string_t pctype; 16585 uint8_t pctype_id; 16586 cmdline_fixed_string_t inset_type; 16587 cmdline_fixed_string_t opt; 16588 cmdline_fixed_string_t field; 16589 uint8_t field_idx; 16590 }; 16591 16592 static void 16593 cmd_cfg_input_set_parsed( 16594 __attribute__((unused)) void *parsed_result, 16595 __attribute__((unused)) struct cmdline *cl, 16596 __attribute__((unused)) void *data) 16597 { 16598 #ifdef RTE_LIBRTE_I40E_PMD 16599 struct cmd_cfg_input_set_result *res = parsed_result; 16600 enum rte_pmd_i40e_inset_type inset_type = INSET_NONE; 16601 struct rte_pmd_i40e_inset inset; 16602 #endif 16603 int ret = -ENOTSUP; 16604 16605 if (!all_ports_stopped()) { 16606 printf("Please stop all ports first\n"); 16607 return; 16608 } 16609 16610 #ifdef RTE_LIBRTE_I40E_PMD 16611 if (!strcmp(res->inset_type, "hash_inset")) 16612 inset_type = INSET_HASH; 16613 else if (!strcmp(res->inset_type, "fdir_inset")) 16614 inset_type = INSET_FDIR; 16615 else if (!strcmp(res->inset_type, "fdir_flx_inset")) 16616 inset_type = INSET_FDIR_FLX; 16617 ret = rte_pmd_i40e_inset_get(res->port_id, res->pctype_id, 16618 &inset, inset_type); 16619 if (ret) { 16620 printf("Failed to get input set.\n"); 16621 return; 16622 } 16623 16624 if (!strcmp(res->opt, "get")) { 16625 ret = rte_pmd_i40e_inset_field_get(inset.inset, 16626 res->field_idx); 16627 if (ret) 16628 printf("Field index %d is enabled.\n", res->field_idx); 16629 else 16630 printf("Field index %d is disabled.\n", res->field_idx); 16631 return; 16632 } else if (!strcmp(res->opt, "set")) 16633 ret = rte_pmd_i40e_inset_field_set(&inset.inset, 16634 res->field_idx); 16635 else if (!strcmp(res->opt, "clear")) 16636 ret = rte_pmd_i40e_inset_field_clear(&inset.inset, 16637 res->field_idx); 16638 if (ret) { 16639 printf("Failed to configure input set field.\n"); 16640 return; 16641 } 16642 16643 ret = rte_pmd_i40e_inset_set(res->port_id, res->pctype_id, 16644 &inset, inset_type); 16645 if (ret) { 16646 printf("Failed to set input set.\n"); 16647 return; 16648 } 16649 #endif 16650 16651 if (ret == -ENOTSUP) 16652 printf("Function not supported\n"); 16653 } 16654 16655 cmdline_parse_token_string_t cmd_cfg_input_set_port = 16656 TOKEN_STRING_INITIALIZER(struct cmd_cfg_input_set_result, 16657 port, "port"); 16658 cmdline_parse_token_string_t cmd_cfg_input_set_cfg = 16659 TOKEN_STRING_INITIALIZER(struct cmd_cfg_input_set_result, 16660 cfg, "config"); 16661 cmdline_parse_token_num_t cmd_cfg_input_set_port_id = 16662 TOKEN_NUM_INITIALIZER(struct cmd_cfg_input_set_result, 16663 port_id, UINT16); 16664 cmdline_parse_token_string_t cmd_cfg_input_set_pctype = 16665 TOKEN_STRING_INITIALIZER(struct cmd_cfg_input_set_result, 16666 pctype, "pctype"); 16667 cmdline_parse_token_num_t cmd_cfg_input_set_pctype_id = 16668 TOKEN_NUM_INITIALIZER(struct cmd_cfg_input_set_result, 16669 pctype_id, UINT8); 16670 cmdline_parse_token_string_t cmd_cfg_input_set_inset_type = 16671 TOKEN_STRING_INITIALIZER(struct cmd_cfg_input_set_result, 16672 inset_type, 16673 "hash_inset#fdir_inset#fdir_flx_inset"); 16674 cmdline_parse_token_string_t cmd_cfg_input_set_opt = 16675 TOKEN_STRING_INITIALIZER(struct cmd_cfg_input_set_result, 16676 opt, "get#set#clear"); 16677 cmdline_parse_token_string_t cmd_cfg_input_set_field = 16678 TOKEN_STRING_INITIALIZER(struct cmd_cfg_input_set_result, 16679 field, "field"); 16680 cmdline_parse_token_num_t cmd_cfg_input_set_field_idx = 16681 TOKEN_NUM_INITIALIZER(struct cmd_cfg_input_set_result, 16682 field_idx, UINT8); 16683 16684 cmdline_parse_inst_t cmd_cfg_input_set = { 16685 .f = cmd_cfg_input_set_parsed, 16686 .data = NULL, 16687 .help_str = "port config <port_id> pctype <pctype_id> hash_inset|" 16688 "fdir_inset|fdir_flx_inset get|set|clear field <field_idx>", 16689 .tokens = { 16690 (void *)&cmd_cfg_input_set_port, 16691 (void *)&cmd_cfg_input_set_cfg, 16692 (void *)&cmd_cfg_input_set_port_id, 16693 (void *)&cmd_cfg_input_set_pctype, 16694 (void *)&cmd_cfg_input_set_pctype_id, 16695 (void *)&cmd_cfg_input_set_inset_type, 16696 (void *)&cmd_cfg_input_set_opt, 16697 (void *)&cmd_cfg_input_set_field, 16698 (void *)&cmd_cfg_input_set_field_idx, 16699 NULL, 16700 }, 16701 }; 16702 16703 /* Clear input set */ 16704 struct cmd_clear_input_set_result { 16705 cmdline_fixed_string_t port; 16706 cmdline_fixed_string_t cfg; 16707 portid_t port_id; 16708 cmdline_fixed_string_t pctype; 16709 uint8_t pctype_id; 16710 cmdline_fixed_string_t inset_type; 16711 cmdline_fixed_string_t clear; 16712 cmdline_fixed_string_t all; 16713 }; 16714 16715 static void 16716 cmd_clear_input_set_parsed( 16717 __attribute__((unused)) void *parsed_result, 16718 __attribute__((unused)) struct cmdline *cl, 16719 __attribute__((unused)) void *data) 16720 { 16721 #ifdef RTE_LIBRTE_I40E_PMD 16722 struct cmd_clear_input_set_result *res = parsed_result; 16723 enum rte_pmd_i40e_inset_type inset_type = INSET_NONE; 16724 struct rte_pmd_i40e_inset inset; 16725 #endif 16726 int ret = -ENOTSUP; 16727 16728 if (!all_ports_stopped()) { 16729 printf("Please stop all ports first\n"); 16730 return; 16731 } 16732 16733 #ifdef RTE_LIBRTE_I40E_PMD 16734 if (!strcmp(res->inset_type, "hash_inset")) 16735 inset_type = INSET_HASH; 16736 else if (!strcmp(res->inset_type, "fdir_inset")) 16737 inset_type = INSET_FDIR; 16738 else if (!strcmp(res->inset_type, "fdir_flx_inset")) 16739 inset_type = INSET_FDIR_FLX; 16740 16741 memset(&inset, 0, sizeof(inset)); 16742 16743 ret = rte_pmd_i40e_inset_set(res->port_id, res->pctype_id, 16744 &inset, inset_type); 16745 if (ret) { 16746 printf("Failed to clear input set.\n"); 16747 return; 16748 } 16749 16750 #endif 16751 16752 if (ret == -ENOTSUP) 16753 printf("Function not supported\n"); 16754 } 16755 16756 cmdline_parse_token_string_t cmd_clear_input_set_port = 16757 TOKEN_STRING_INITIALIZER(struct cmd_clear_input_set_result, 16758 port, "port"); 16759 cmdline_parse_token_string_t cmd_clear_input_set_cfg = 16760 TOKEN_STRING_INITIALIZER(struct cmd_clear_input_set_result, 16761 cfg, "config"); 16762 cmdline_parse_token_num_t cmd_clear_input_set_port_id = 16763 TOKEN_NUM_INITIALIZER(struct cmd_clear_input_set_result, 16764 port_id, UINT16); 16765 cmdline_parse_token_string_t cmd_clear_input_set_pctype = 16766 TOKEN_STRING_INITIALIZER(struct cmd_clear_input_set_result, 16767 pctype, "pctype"); 16768 cmdline_parse_token_num_t cmd_clear_input_set_pctype_id = 16769 TOKEN_NUM_INITIALIZER(struct cmd_clear_input_set_result, 16770 pctype_id, UINT8); 16771 cmdline_parse_token_string_t cmd_clear_input_set_inset_type = 16772 TOKEN_STRING_INITIALIZER(struct cmd_clear_input_set_result, 16773 inset_type, 16774 "hash_inset#fdir_inset#fdir_flx_inset"); 16775 cmdline_parse_token_string_t cmd_clear_input_set_clear = 16776 TOKEN_STRING_INITIALIZER(struct cmd_clear_input_set_result, 16777 clear, "clear"); 16778 cmdline_parse_token_string_t cmd_clear_input_set_all = 16779 TOKEN_STRING_INITIALIZER(struct cmd_clear_input_set_result, 16780 all, "all"); 16781 16782 cmdline_parse_inst_t cmd_clear_input_set = { 16783 .f = cmd_clear_input_set_parsed, 16784 .data = NULL, 16785 .help_str = "port config <port_id> pctype <pctype_id> hash_inset|" 16786 "fdir_inset|fdir_flx_inset clear all", 16787 .tokens = { 16788 (void *)&cmd_clear_input_set_port, 16789 (void *)&cmd_clear_input_set_cfg, 16790 (void *)&cmd_clear_input_set_port_id, 16791 (void *)&cmd_clear_input_set_pctype, 16792 (void *)&cmd_clear_input_set_pctype_id, 16793 (void *)&cmd_clear_input_set_inset_type, 16794 (void *)&cmd_clear_input_set_clear, 16795 (void *)&cmd_clear_input_set_all, 16796 NULL, 16797 }, 16798 }; 16799 16800 /* show vf stats */ 16801 16802 /* Common result structure for show vf stats */ 16803 struct cmd_show_vf_stats_result { 16804 cmdline_fixed_string_t show; 16805 cmdline_fixed_string_t vf; 16806 cmdline_fixed_string_t stats; 16807 portid_t port_id; 16808 uint16_t vf_id; 16809 }; 16810 16811 /* Common CLI fields show vf stats*/ 16812 cmdline_parse_token_string_t cmd_show_vf_stats_show = 16813 TOKEN_STRING_INITIALIZER 16814 (struct cmd_show_vf_stats_result, 16815 show, "show"); 16816 cmdline_parse_token_string_t cmd_show_vf_stats_vf = 16817 TOKEN_STRING_INITIALIZER 16818 (struct cmd_show_vf_stats_result, 16819 vf, "vf"); 16820 cmdline_parse_token_string_t cmd_show_vf_stats_stats = 16821 TOKEN_STRING_INITIALIZER 16822 (struct cmd_show_vf_stats_result, 16823 stats, "stats"); 16824 cmdline_parse_token_num_t cmd_show_vf_stats_port_id = 16825 TOKEN_NUM_INITIALIZER 16826 (struct cmd_show_vf_stats_result, 16827 port_id, UINT16); 16828 cmdline_parse_token_num_t cmd_show_vf_stats_vf_id = 16829 TOKEN_NUM_INITIALIZER 16830 (struct cmd_show_vf_stats_result, 16831 vf_id, UINT16); 16832 16833 static void 16834 cmd_show_vf_stats_parsed( 16835 void *parsed_result, 16836 __attribute__((unused)) struct cmdline *cl, 16837 __attribute__((unused)) void *data) 16838 { 16839 struct cmd_show_vf_stats_result *res = parsed_result; 16840 struct rte_eth_stats stats; 16841 int ret = -ENOTSUP; 16842 static const char *nic_stats_border = "########################"; 16843 16844 if (port_id_is_invalid(res->port_id, ENABLED_WARN)) 16845 return; 16846 16847 memset(&stats, 0, sizeof(stats)); 16848 16849 #ifdef RTE_LIBRTE_I40E_PMD 16850 if (ret == -ENOTSUP) 16851 ret = rte_pmd_i40e_get_vf_stats(res->port_id, 16852 res->vf_id, 16853 &stats); 16854 #endif 16855 #ifdef RTE_LIBRTE_BNXT_PMD 16856 if (ret == -ENOTSUP) 16857 ret = rte_pmd_bnxt_get_vf_stats(res->port_id, 16858 res->vf_id, 16859 &stats); 16860 #endif 16861 16862 switch (ret) { 16863 case 0: 16864 break; 16865 case -EINVAL: 16866 printf("invalid vf_id %d\n", res->vf_id); 16867 break; 16868 case -ENODEV: 16869 printf("invalid port_id %d\n", res->port_id); 16870 break; 16871 case -ENOTSUP: 16872 printf("function not implemented\n"); 16873 break; 16874 default: 16875 printf("programming error: (%s)\n", strerror(-ret)); 16876 } 16877 16878 printf("\n %s NIC statistics for port %-2d vf %-2d %s\n", 16879 nic_stats_border, res->port_id, res->vf_id, nic_stats_border); 16880 16881 printf(" RX-packets: %-10"PRIu64" RX-missed: %-10"PRIu64" RX-bytes: " 16882 "%-"PRIu64"\n", 16883 stats.ipackets, stats.imissed, stats.ibytes); 16884 printf(" RX-errors: %-"PRIu64"\n", stats.ierrors); 16885 printf(" RX-nombuf: %-10"PRIu64"\n", 16886 stats.rx_nombuf); 16887 printf(" TX-packets: %-10"PRIu64" TX-errors: %-10"PRIu64" TX-bytes: " 16888 "%-"PRIu64"\n", 16889 stats.opackets, stats.oerrors, stats.obytes); 16890 16891 printf(" %s############################%s\n", 16892 nic_stats_border, nic_stats_border); 16893 } 16894 16895 cmdline_parse_inst_t cmd_show_vf_stats = { 16896 .f = cmd_show_vf_stats_parsed, 16897 .data = NULL, 16898 .help_str = "show vf stats <port_id> <vf_id>", 16899 .tokens = { 16900 (void *)&cmd_show_vf_stats_show, 16901 (void *)&cmd_show_vf_stats_vf, 16902 (void *)&cmd_show_vf_stats_stats, 16903 (void *)&cmd_show_vf_stats_port_id, 16904 (void *)&cmd_show_vf_stats_vf_id, 16905 NULL, 16906 }, 16907 }; 16908 16909 /* clear vf stats */ 16910 16911 /* Common result structure for clear vf stats */ 16912 struct cmd_clear_vf_stats_result { 16913 cmdline_fixed_string_t clear; 16914 cmdline_fixed_string_t vf; 16915 cmdline_fixed_string_t stats; 16916 portid_t port_id; 16917 uint16_t vf_id; 16918 }; 16919 16920 /* Common CLI fields clear vf stats*/ 16921 cmdline_parse_token_string_t cmd_clear_vf_stats_clear = 16922 TOKEN_STRING_INITIALIZER 16923 (struct cmd_clear_vf_stats_result, 16924 clear, "clear"); 16925 cmdline_parse_token_string_t cmd_clear_vf_stats_vf = 16926 TOKEN_STRING_INITIALIZER 16927 (struct cmd_clear_vf_stats_result, 16928 vf, "vf"); 16929 cmdline_parse_token_string_t cmd_clear_vf_stats_stats = 16930 TOKEN_STRING_INITIALIZER 16931 (struct cmd_clear_vf_stats_result, 16932 stats, "stats"); 16933 cmdline_parse_token_num_t cmd_clear_vf_stats_port_id = 16934 TOKEN_NUM_INITIALIZER 16935 (struct cmd_clear_vf_stats_result, 16936 port_id, UINT16); 16937 cmdline_parse_token_num_t cmd_clear_vf_stats_vf_id = 16938 TOKEN_NUM_INITIALIZER 16939 (struct cmd_clear_vf_stats_result, 16940 vf_id, UINT16); 16941 16942 static void 16943 cmd_clear_vf_stats_parsed( 16944 void *parsed_result, 16945 __attribute__((unused)) struct cmdline *cl, 16946 __attribute__((unused)) void *data) 16947 { 16948 struct cmd_clear_vf_stats_result *res = parsed_result; 16949 int ret = -ENOTSUP; 16950 16951 if (port_id_is_invalid(res->port_id, ENABLED_WARN)) 16952 return; 16953 16954 #ifdef RTE_LIBRTE_I40E_PMD 16955 if (ret == -ENOTSUP) 16956 ret = rte_pmd_i40e_reset_vf_stats(res->port_id, 16957 res->vf_id); 16958 #endif 16959 #ifdef RTE_LIBRTE_BNXT_PMD 16960 if (ret == -ENOTSUP) 16961 ret = rte_pmd_bnxt_reset_vf_stats(res->port_id, 16962 res->vf_id); 16963 #endif 16964 16965 switch (ret) { 16966 case 0: 16967 break; 16968 case -EINVAL: 16969 printf("invalid vf_id %d\n", res->vf_id); 16970 break; 16971 case -ENODEV: 16972 printf("invalid port_id %d\n", res->port_id); 16973 break; 16974 case -ENOTSUP: 16975 printf("function not implemented\n"); 16976 break; 16977 default: 16978 printf("programming error: (%s)\n", strerror(-ret)); 16979 } 16980 } 16981 16982 cmdline_parse_inst_t cmd_clear_vf_stats = { 16983 .f = cmd_clear_vf_stats_parsed, 16984 .data = NULL, 16985 .help_str = "clear vf stats <port_id> <vf_id>", 16986 .tokens = { 16987 (void *)&cmd_clear_vf_stats_clear, 16988 (void *)&cmd_clear_vf_stats_vf, 16989 (void *)&cmd_clear_vf_stats_stats, 16990 (void *)&cmd_clear_vf_stats_port_id, 16991 (void *)&cmd_clear_vf_stats_vf_id, 16992 NULL, 16993 }, 16994 }; 16995 16996 /* port config pctype mapping reset */ 16997 16998 /* Common result structure for port config pctype mapping reset */ 16999 struct cmd_pctype_mapping_reset_result { 17000 cmdline_fixed_string_t port; 17001 cmdline_fixed_string_t config; 17002 portid_t port_id; 17003 cmdline_fixed_string_t pctype; 17004 cmdline_fixed_string_t mapping; 17005 cmdline_fixed_string_t reset; 17006 }; 17007 17008 /* Common CLI fields for port config pctype mapping reset*/ 17009 cmdline_parse_token_string_t cmd_pctype_mapping_reset_port = 17010 TOKEN_STRING_INITIALIZER 17011 (struct cmd_pctype_mapping_reset_result, 17012 port, "port"); 17013 cmdline_parse_token_string_t cmd_pctype_mapping_reset_config = 17014 TOKEN_STRING_INITIALIZER 17015 (struct cmd_pctype_mapping_reset_result, 17016 config, "config"); 17017 cmdline_parse_token_num_t cmd_pctype_mapping_reset_port_id = 17018 TOKEN_NUM_INITIALIZER 17019 (struct cmd_pctype_mapping_reset_result, 17020 port_id, UINT16); 17021 cmdline_parse_token_string_t cmd_pctype_mapping_reset_pctype = 17022 TOKEN_STRING_INITIALIZER 17023 (struct cmd_pctype_mapping_reset_result, 17024 pctype, "pctype"); 17025 cmdline_parse_token_string_t cmd_pctype_mapping_reset_mapping = 17026 TOKEN_STRING_INITIALIZER 17027 (struct cmd_pctype_mapping_reset_result, 17028 mapping, "mapping"); 17029 cmdline_parse_token_string_t cmd_pctype_mapping_reset_reset = 17030 TOKEN_STRING_INITIALIZER 17031 (struct cmd_pctype_mapping_reset_result, 17032 reset, "reset"); 17033 17034 static void 17035 cmd_pctype_mapping_reset_parsed( 17036 void *parsed_result, 17037 __attribute__((unused)) struct cmdline *cl, 17038 __attribute__((unused)) void *data) 17039 { 17040 struct cmd_pctype_mapping_reset_result *res = parsed_result; 17041 int ret = -ENOTSUP; 17042 17043 if (port_id_is_invalid(res->port_id, ENABLED_WARN)) 17044 return; 17045 17046 #ifdef RTE_LIBRTE_I40E_PMD 17047 ret = rte_pmd_i40e_flow_type_mapping_reset(res->port_id); 17048 #endif 17049 17050 switch (ret) { 17051 case 0: 17052 break; 17053 case -ENODEV: 17054 printf("invalid port_id %d\n", res->port_id); 17055 break; 17056 case -ENOTSUP: 17057 printf("function not implemented\n"); 17058 break; 17059 default: 17060 printf("programming error: (%s)\n", strerror(-ret)); 17061 } 17062 } 17063 17064 cmdline_parse_inst_t cmd_pctype_mapping_reset = { 17065 .f = cmd_pctype_mapping_reset_parsed, 17066 .data = NULL, 17067 .help_str = "port config <port_id> pctype mapping reset", 17068 .tokens = { 17069 (void *)&cmd_pctype_mapping_reset_port, 17070 (void *)&cmd_pctype_mapping_reset_config, 17071 (void *)&cmd_pctype_mapping_reset_port_id, 17072 (void *)&cmd_pctype_mapping_reset_pctype, 17073 (void *)&cmd_pctype_mapping_reset_mapping, 17074 (void *)&cmd_pctype_mapping_reset_reset, 17075 NULL, 17076 }, 17077 }; 17078 17079 /* show port pctype mapping */ 17080 17081 /* Common result structure for show port pctype mapping */ 17082 struct cmd_pctype_mapping_get_result { 17083 cmdline_fixed_string_t show; 17084 cmdline_fixed_string_t port; 17085 portid_t port_id; 17086 cmdline_fixed_string_t pctype; 17087 cmdline_fixed_string_t mapping; 17088 }; 17089 17090 /* Common CLI fields for pctype mapping get */ 17091 cmdline_parse_token_string_t cmd_pctype_mapping_get_show = 17092 TOKEN_STRING_INITIALIZER 17093 (struct cmd_pctype_mapping_get_result, 17094 show, "show"); 17095 cmdline_parse_token_string_t cmd_pctype_mapping_get_port = 17096 TOKEN_STRING_INITIALIZER 17097 (struct cmd_pctype_mapping_get_result, 17098 port, "port"); 17099 cmdline_parse_token_num_t cmd_pctype_mapping_get_port_id = 17100 TOKEN_NUM_INITIALIZER 17101 (struct cmd_pctype_mapping_get_result, 17102 port_id, UINT16); 17103 cmdline_parse_token_string_t cmd_pctype_mapping_get_pctype = 17104 TOKEN_STRING_INITIALIZER 17105 (struct cmd_pctype_mapping_get_result, 17106 pctype, "pctype"); 17107 cmdline_parse_token_string_t cmd_pctype_mapping_get_mapping = 17108 TOKEN_STRING_INITIALIZER 17109 (struct cmd_pctype_mapping_get_result, 17110 mapping, "mapping"); 17111 17112 static void 17113 cmd_pctype_mapping_get_parsed( 17114 void *parsed_result, 17115 __attribute__((unused)) struct cmdline *cl, 17116 __attribute__((unused)) void *data) 17117 { 17118 struct cmd_pctype_mapping_get_result *res = parsed_result; 17119 int ret = -ENOTSUP; 17120 #ifdef RTE_LIBRTE_I40E_PMD 17121 struct rte_pmd_i40e_flow_type_mapping 17122 mapping[RTE_PMD_I40E_FLOW_TYPE_MAX]; 17123 int i, j, first_pctype; 17124 #endif 17125 17126 if (port_id_is_invalid(res->port_id, ENABLED_WARN)) 17127 return; 17128 17129 #ifdef RTE_LIBRTE_I40E_PMD 17130 ret = rte_pmd_i40e_flow_type_mapping_get(res->port_id, mapping); 17131 #endif 17132 17133 switch (ret) { 17134 case 0: 17135 break; 17136 case -ENODEV: 17137 printf("invalid port_id %d\n", res->port_id); 17138 return; 17139 case -ENOTSUP: 17140 printf("function not implemented\n"); 17141 return; 17142 default: 17143 printf("programming error: (%s)\n", strerror(-ret)); 17144 return; 17145 } 17146 17147 #ifdef RTE_LIBRTE_I40E_PMD 17148 for (i = 0; i < RTE_PMD_I40E_FLOW_TYPE_MAX; i++) { 17149 if (mapping[i].pctype != 0ULL) { 17150 first_pctype = 1; 17151 17152 printf("pctype: "); 17153 for (j = 0; j < RTE_PMD_I40E_PCTYPE_MAX; j++) { 17154 if (mapping[i].pctype & (1ULL << j)) { 17155 printf(first_pctype ? 17156 "%02d" : ",%02d", j); 17157 first_pctype = 0; 17158 } 17159 } 17160 printf(" -> flowtype: %02d\n", mapping[i].flow_type); 17161 } 17162 } 17163 #endif 17164 } 17165 17166 cmdline_parse_inst_t cmd_pctype_mapping_get = { 17167 .f = cmd_pctype_mapping_get_parsed, 17168 .data = NULL, 17169 .help_str = "show port <port_id> pctype mapping", 17170 .tokens = { 17171 (void *)&cmd_pctype_mapping_get_show, 17172 (void *)&cmd_pctype_mapping_get_port, 17173 (void *)&cmd_pctype_mapping_get_port_id, 17174 (void *)&cmd_pctype_mapping_get_pctype, 17175 (void *)&cmd_pctype_mapping_get_mapping, 17176 NULL, 17177 }, 17178 }; 17179 17180 /* port config pctype mapping update */ 17181 17182 /* Common result structure for port config pctype mapping update */ 17183 struct cmd_pctype_mapping_update_result { 17184 cmdline_fixed_string_t port; 17185 cmdline_fixed_string_t config; 17186 portid_t port_id; 17187 cmdline_fixed_string_t pctype; 17188 cmdline_fixed_string_t mapping; 17189 cmdline_fixed_string_t update; 17190 cmdline_fixed_string_t pctype_list; 17191 uint16_t flow_type; 17192 }; 17193 17194 /* Common CLI fields for pctype mapping update*/ 17195 cmdline_parse_token_string_t cmd_pctype_mapping_update_port = 17196 TOKEN_STRING_INITIALIZER 17197 (struct cmd_pctype_mapping_update_result, 17198 port, "port"); 17199 cmdline_parse_token_string_t cmd_pctype_mapping_update_config = 17200 TOKEN_STRING_INITIALIZER 17201 (struct cmd_pctype_mapping_update_result, 17202 config, "config"); 17203 cmdline_parse_token_num_t cmd_pctype_mapping_update_port_id = 17204 TOKEN_NUM_INITIALIZER 17205 (struct cmd_pctype_mapping_update_result, 17206 port_id, UINT16); 17207 cmdline_parse_token_string_t cmd_pctype_mapping_update_pctype = 17208 TOKEN_STRING_INITIALIZER 17209 (struct cmd_pctype_mapping_update_result, 17210 pctype, "pctype"); 17211 cmdline_parse_token_string_t cmd_pctype_mapping_update_mapping = 17212 TOKEN_STRING_INITIALIZER 17213 (struct cmd_pctype_mapping_update_result, 17214 mapping, "mapping"); 17215 cmdline_parse_token_string_t cmd_pctype_mapping_update_update = 17216 TOKEN_STRING_INITIALIZER 17217 (struct cmd_pctype_mapping_update_result, 17218 update, "update"); 17219 cmdline_parse_token_string_t cmd_pctype_mapping_update_pc_type = 17220 TOKEN_STRING_INITIALIZER 17221 (struct cmd_pctype_mapping_update_result, 17222 pctype_list, NULL); 17223 cmdline_parse_token_num_t cmd_pctype_mapping_update_flow_type = 17224 TOKEN_NUM_INITIALIZER 17225 (struct cmd_pctype_mapping_update_result, 17226 flow_type, UINT16); 17227 17228 static void 17229 cmd_pctype_mapping_update_parsed( 17230 void *parsed_result, 17231 __attribute__((unused)) struct cmdline *cl, 17232 __attribute__((unused)) void *data) 17233 { 17234 struct cmd_pctype_mapping_update_result *res = parsed_result; 17235 int ret = -ENOTSUP; 17236 #ifdef RTE_LIBRTE_I40E_PMD 17237 struct rte_pmd_i40e_flow_type_mapping mapping; 17238 unsigned int i; 17239 unsigned int nb_item; 17240 unsigned int pctype_list[RTE_PMD_I40E_PCTYPE_MAX]; 17241 #endif 17242 17243 if (port_id_is_invalid(res->port_id, ENABLED_WARN)) 17244 return; 17245 17246 #ifdef RTE_LIBRTE_I40E_PMD 17247 nb_item = parse_item_list(res->pctype_list, "pctypes", 17248 RTE_PMD_I40E_PCTYPE_MAX, pctype_list, 1); 17249 mapping.flow_type = res->flow_type; 17250 for (i = 0, mapping.pctype = 0ULL; i < nb_item; i++) 17251 mapping.pctype |= (1ULL << pctype_list[i]); 17252 ret = rte_pmd_i40e_flow_type_mapping_update(res->port_id, 17253 &mapping, 17254 1, 17255 0); 17256 #endif 17257 17258 switch (ret) { 17259 case 0: 17260 break; 17261 case -EINVAL: 17262 printf("invalid pctype or flow type\n"); 17263 break; 17264 case -ENODEV: 17265 printf("invalid port_id %d\n", res->port_id); 17266 break; 17267 case -ENOTSUP: 17268 printf("function not implemented\n"); 17269 break; 17270 default: 17271 printf("programming error: (%s)\n", strerror(-ret)); 17272 } 17273 } 17274 17275 cmdline_parse_inst_t cmd_pctype_mapping_update = { 17276 .f = cmd_pctype_mapping_update_parsed, 17277 .data = NULL, 17278 .help_str = "port config <port_id> pctype mapping update" 17279 " <pctype_id_0,[pctype_id_1]*> <flowtype_id>", 17280 .tokens = { 17281 (void *)&cmd_pctype_mapping_update_port, 17282 (void *)&cmd_pctype_mapping_update_config, 17283 (void *)&cmd_pctype_mapping_update_port_id, 17284 (void *)&cmd_pctype_mapping_update_pctype, 17285 (void *)&cmd_pctype_mapping_update_mapping, 17286 (void *)&cmd_pctype_mapping_update_update, 17287 (void *)&cmd_pctype_mapping_update_pc_type, 17288 (void *)&cmd_pctype_mapping_update_flow_type, 17289 NULL, 17290 }, 17291 }; 17292 17293 /* ptype mapping get */ 17294 17295 /* Common result structure for ptype mapping get */ 17296 struct cmd_ptype_mapping_get_result { 17297 cmdline_fixed_string_t ptype; 17298 cmdline_fixed_string_t mapping; 17299 cmdline_fixed_string_t get; 17300 portid_t port_id; 17301 uint8_t valid_only; 17302 }; 17303 17304 /* Common CLI fields for ptype mapping get */ 17305 cmdline_parse_token_string_t cmd_ptype_mapping_get_ptype = 17306 TOKEN_STRING_INITIALIZER 17307 (struct cmd_ptype_mapping_get_result, 17308 ptype, "ptype"); 17309 cmdline_parse_token_string_t cmd_ptype_mapping_get_mapping = 17310 TOKEN_STRING_INITIALIZER 17311 (struct cmd_ptype_mapping_get_result, 17312 mapping, "mapping"); 17313 cmdline_parse_token_string_t cmd_ptype_mapping_get_get = 17314 TOKEN_STRING_INITIALIZER 17315 (struct cmd_ptype_mapping_get_result, 17316 get, "get"); 17317 cmdline_parse_token_num_t cmd_ptype_mapping_get_port_id = 17318 TOKEN_NUM_INITIALIZER 17319 (struct cmd_ptype_mapping_get_result, 17320 port_id, UINT16); 17321 cmdline_parse_token_num_t cmd_ptype_mapping_get_valid_only = 17322 TOKEN_NUM_INITIALIZER 17323 (struct cmd_ptype_mapping_get_result, 17324 valid_only, UINT8); 17325 17326 static void 17327 cmd_ptype_mapping_get_parsed( 17328 void *parsed_result, 17329 __attribute__((unused)) struct cmdline *cl, 17330 __attribute__((unused)) void *data) 17331 { 17332 struct cmd_ptype_mapping_get_result *res = parsed_result; 17333 int ret = -ENOTSUP; 17334 #ifdef RTE_LIBRTE_I40E_PMD 17335 int max_ptype_num = 256; 17336 struct rte_pmd_i40e_ptype_mapping mapping[max_ptype_num]; 17337 uint16_t count; 17338 int i; 17339 #endif 17340 17341 if (port_id_is_invalid(res->port_id, ENABLED_WARN)) 17342 return; 17343 17344 #ifdef RTE_LIBRTE_I40E_PMD 17345 ret = rte_pmd_i40e_ptype_mapping_get(res->port_id, 17346 mapping, 17347 max_ptype_num, 17348 &count, 17349 res->valid_only); 17350 #endif 17351 17352 switch (ret) { 17353 case 0: 17354 break; 17355 case -ENODEV: 17356 printf("invalid port_id %d\n", res->port_id); 17357 break; 17358 case -ENOTSUP: 17359 printf("function not implemented\n"); 17360 break; 17361 default: 17362 printf("programming error: (%s)\n", strerror(-ret)); 17363 } 17364 17365 #ifdef RTE_LIBRTE_I40E_PMD 17366 if (!ret) { 17367 for (i = 0; i < count; i++) 17368 printf("%3d\t0x%08x\n", 17369 mapping[i].hw_ptype, mapping[i].sw_ptype); 17370 } 17371 #endif 17372 } 17373 17374 cmdline_parse_inst_t cmd_ptype_mapping_get = { 17375 .f = cmd_ptype_mapping_get_parsed, 17376 .data = NULL, 17377 .help_str = "ptype mapping get <port_id> <valid_only>", 17378 .tokens = { 17379 (void *)&cmd_ptype_mapping_get_ptype, 17380 (void *)&cmd_ptype_mapping_get_mapping, 17381 (void *)&cmd_ptype_mapping_get_get, 17382 (void *)&cmd_ptype_mapping_get_port_id, 17383 (void *)&cmd_ptype_mapping_get_valid_only, 17384 NULL, 17385 }, 17386 }; 17387 17388 /* ptype mapping replace */ 17389 17390 /* Common result structure for ptype mapping replace */ 17391 struct cmd_ptype_mapping_replace_result { 17392 cmdline_fixed_string_t ptype; 17393 cmdline_fixed_string_t mapping; 17394 cmdline_fixed_string_t replace; 17395 portid_t port_id; 17396 uint32_t target; 17397 uint8_t mask; 17398 uint32_t pkt_type; 17399 }; 17400 17401 /* Common CLI fields for ptype mapping replace */ 17402 cmdline_parse_token_string_t cmd_ptype_mapping_replace_ptype = 17403 TOKEN_STRING_INITIALIZER 17404 (struct cmd_ptype_mapping_replace_result, 17405 ptype, "ptype"); 17406 cmdline_parse_token_string_t cmd_ptype_mapping_replace_mapping = 17407 TOKEN_STRING_INITIALIZER 17408 (struct cmd_ptype_mapping_replace_result, 17409 mapping, "mapping"); 17410 cmdline_parse_token_string_t cmd_ptype_mapping_replace_replace = 17411 TOKEN_STRING_INITIALIZER 17412 (struct cmd_ptype_mapping_replace_result, 17413 replace, "replace"); 17414 cmdline_parse_token_num_t cmd_ptype_mapping_replace_port_id = 17415 TOKEN_NUM_INITIALIZER 17416 (struct cmd_ptype_mapping_replace_result, 17417 port_id, UINT16); 17418 cmdline_parse_token_num_t cmd_ptype_mapping_replace_target = 17419 TOKEN_NUM_INITIALIZER 17420 (struct cmd_ptype_mapping_replace_result, 17421 target, UINT32); 17422 cmdline_parse_token_num_t cmd_ptype_mapping_replace_mask = 17423 TOKEN_NUM_INITIALIZER 17424 (struct cmd_ptype_mapping_replace_result, 17425 mask, UINT8); 17426 cmdline_parse_token_num_t cmd_ptype_mapping_replace_pkt_type = 17427 TOKEN_NUM_INITIALIZER 17428 (struct cmd_ptype_mapping_replace_result, 17429 pkt_type, UINT32); 17430 17431 static void 17432 cmd_ptype_mapping_replace_parsed( 17433 void *parsed_result, 17434 __attribute__((unused)) struct cmdline *cl, 17435 __attribute__((unused)) void *data) 17436 { 17437 struct cmd_ptype_mapping_replace_result *res = parsed_result; 17438 int ret = -ENOTSUP; 17439 17440 if (port_id_is_invalid(res->port_id, ENABLED_WARN)) 17441 return; 17442 17443 #ifdef RTE_LIBRTE_I40E_PMD 17444 ret = rte_pmd_i40e_ptype_mapping_replace(res->port_id, 17445 res->target, 17446 res->mask, 17447 res->pkt_type); 17448 #endif 17449 17450 switch (ret) { 17451 case 0: 17452 break; 17453 case -EINVAL: 17454 printf("invalid ptype 0x%8x or 0x%8x\n", 17455 res->target, res->pkt_type); 17456 break; 17457 case -ENODEV: 17458 printf("invalid port_id %d\n", res->port_id); 17459 break; 17460 case -ENOTSUP: 17461 printf("function not implemented\n"); 17462 break; 17463 default: 17464 printf("programming error: (%s)\n", strerror(-ret)); 17465 } 17466 } 17467 17468 cmdline_parse_inst_t cmd_ptype_mapping_replace = { 17469 .f = cmd_ptype_mapping_replace_parsed, 17470 .data = NULL, 17471 .help_str = 17472 "ptype mapping replace <port_id> <target> <mask> <pkt_type>", 17473 .tokens = { 17474 (void *)&cmd_ptype_mapping_replace_ptype, 17475 (void *)&cmd_ptype_mapping_replace_mapping, 17476 (void *)&cmd_ptype_mapping_replace_replace, 17477 (void *)&cmd_ptype_mapping_replace_port_id, 17478 (void *)&cmd_ptype_mapping_replace_target, 17479 (void *)&cmd_ptype_mapping_replace_mask, 17480 (void *)&cmd_ptype_mapping_replace_pkt_type, 17481 NULL, 17482 }, 17483 }; 17484 17485 /* ptype mapping reset */ 17486 17487 /* Common result structure for ptype mapping reset */ 17488 struct cmd_ptype_mapping_reset_result { 17489 cmdline_fixed_string_t ptype; 17490 cmdline_fixed_string_t mapping; 17491 cmdline_fixed_string_t reset; 17492 portid_t port_id; 17493 }; 17494 17495 /* Common CLI fields for ptype mapping reset*/ 17496 cmdline_parse_token_string_t cmd_ptype_mapping_reset_ptype = 17497 TOKEN_STRING_INITIALIZER 17498 (struct cmd_ptype_mapping_reset_result, 17499 ptype, "ptype"); 17500 cmdline_parse_token_string_t cmd_ptype_mapping_reset_mapping = 17501 TOKEN_STRING_INITIALIZER 17502 (struct cmd_ptype_mapping_reset_result, 17503 mapping, "mapping"); 17504 cmdline_parse_token_string_t cmd_ptype_mapping_reset_reset = 17505 TOKEN_STRING_INITIALIZER 17506 (struct cmd_ptype_mapping_reset_result, 17507 reset, "reset"); 17508 cmdline_parse_token_num_t cmd_ptype_mapping_reset_port_id = 17509 TOKEN_NUM_INITIALIZER 17510 (struct cmd_ptype_mapping_reset_result, 17511 port_id, UINT16); 17512 17513 static void 17514 cmd_ptype_mapping_reset_parsed( 17515 void *parsed_result, 17516 __attribute__((unused)) struct cmdline *cl, 17517 __attribute__((unused)) void *data) 17518 { 17519 struct cmd_ptype_mapping_reset_result *res = parsed_result; 17520 int ret = -ENOTSUP; 17521 17522 if (port_id_is_invalid(res->port_id, ENABLED_WARN)) 17523 return; 17524 17525 #ifdef RTE_LIBRTE_I40E_PMD 17526 ret = rte_pmd_i40e_ptype_mapping_reset(res->port_id); 17527 #endif 17528 17529 switch (ret) { 17530 case 0: 17531 break; 17532 case -ENODEV: 17533 printf("invalid port_id %d\n", res->port_id); 17534 break; 17535 case -ENOTSUP: 17536 printf("function not implemented\n"); 17537 break; 17538 default: 17539 printf("programming error: (%s)\n", strerror(-ret)); 17540 } 17541 } 17542 17543 cmdline_parse_inst_t cmd_ptype_mapping_reset = { 17544 .f = cmd_ptype_mapping_reset_parsed, 17545 .data = NULL, 17546 .help_str = "ptype mapping reset <port_id>", 17547 .tokens = { 17548 (void *)&cmd_ptype_mapping_reset_ptype, 17549 (void *)&cmd_ptype_mapping_reset_mapping, 17550 (void *)&cmd_ptype_mapping_reset_reset, 17551 (void *)&cmd_ptype_mapping_reset_port_id, 17552 NULL, 17553 }, 17554 }; 17555 17556 /* ptype mapping update */ 17557 17558 /* Common result structure for ptype mapping update */ 17559 struct cmd_ptype_mapping_update_result { 17560 cmdline_fixed_string_t ptype; 17561 cmdline_fixed_string_t mapping; 17562 cmdline_fixed_string_t reset; 17563 portid_t port_id; 17564 uint8_t hw_ptype; 17565 uint32_t sw_ptype; 17566 }; 17567 17568 /* Common CLI fields for ptype mapping update*/ 17569 cmdline_parse_token_string_t cmd_ptype_mapping_update_ptype = 17570 TOKEN_STRING_INITIALIZER 17571 (struct cmd_ptype_mapping_update_result, 17572 ptype, "ptype"); 17573 cmdline_parse_token_string_t cmd_ptype_mapping_update_mapping = 17574 TOKEN_STRING_INITIALIZER 17575 (struct cmd_ptype_mapping_update_result, 17576 mapping, "mapping"); 17577 cmdline_parse_token_string_t cmd_ptype_mapping_update_update = 17578 TOKEN_STRING_INITIALIZER 17579 (struct cmd_ptype_mapping_update_result, 17580 reset, "update"); 17581 cmdline_parse_token_num_t cmd_ptype_mapping_update_port_id = 17582 TOKEN_NUM_INITIALIZER 17583 (struct cmd_ptype_mapping_update_result, 17584 port_id, UINT16); 17585 cmdline_parse_token_num_t cmd_ptype_mapping_update_hw_ptype = 17586 TOKEN_NUM_INITIALIZER 17587 (struct cmd_ptype_mapping_update_result, 17588 hw_ptype, UINT8); 17589 cmdline_parse_token_num_t cmd_ptype_mapping_update_sw_ptype = 17590 TOKEN_NUM_INITIALIZER 17591 (struct cmd_ptype_mapping_update_result, 17592 sw_ptype, UINT32); 17593 17594 static void 17595 cmd_ptype_mapping_update_parsed( 17596 void *parsed_result, 17597 __attribute__((unused)) struct cmdline *cl, 17598 __attribute__((unused)) void *data) 17599 { 17600 struct cmd_ptype_mapping_update_result *res = parsed_result; 17601 int ret = -ENOTSUP; 17602 #ifdef RTE_LIBRTE_I40E_PMD 17603 struct rte_pmd_i40e_ptype_mapping mapping; 17604 #endif 17605 if (port_id_is_invalid(res->port_id, ENABLED_WARN)) 17606 return; 17607 17608 #ifdef RTE_LIBRTE_I40E_PMD 17609 mapping.hw_ptype = res->hw_ptype; 17610 mapping.sw_ptype = res->sw_ptype; 17611 ret = rte_pmd_i40e_ptype_mapping_update(res->port_id, 17612 &mapping, 17613 1, 17614 0); 17615 #endif 17616 17617 switch (ret) { 17618 case 0: 17619 break; 17620 case -EINVAL: 17621 printf("invalid ptype 0x%8x\n", res->sw_ptype); 17622 break; 17623 case -ENODEV: 17624 printf("invalid port_id %d\n", res->port_id); 17625 break; 17626 case -ENOTSUP: 17627 printf("function not implemented\n"); 17628 break; 17629 default: 17630 printf("programming error: (%s)\n", strerror(-ret)); 17631 } 17632 } 17633 17634 cmdline_parse_inst_t cmd_ptype_mapping_update = { 17635 .f = cmd_ptype_mapping_update_parsed, 17636 .data = NULL, 17637 .help_str = "ptype mapping update <port_id> <hw_ptype> <sw_ptype>", 17638 .tokens = { 17639 (void *)&cmd_ptype_mapping_update_ptype, 17640 (void *)&cmd_ptype_mapping_update_mapping, 17641 (void *)&cmd_ptype_mapping_update_update, 17642 (void *)&cmd_ptype_mapping_update_port_id, 17643 (void *)&cmd_ptype_mapping_update_hw_ptype, 17644 (void *)&cmd_ptype_mapping_update_sw_ptype, 17645 NULL, 17646 }, 17647 }; 17648 17649 /* Common result structure for file commands */ 17650 struct cmd_cmdfile_result { 17651 cmdline_fixed_string_t load; 17652 cmdline_fixed_string_t filename; 17653 }; 17654 17655 /* Common CLI fields for file commands */ 17656 cmdline_parse_token_string_t cmd_load_cmdfile = 17657 TOKEN_STRING_INITIALIZER(struct cmd_cmdfile_result, load, "load"); 17658 cmdline_parse_token_string_t cmd_load_cmdfile_filename = 17659 TOKEN_STRING_INITIALIZER(struct cmd_cmdfile_result, filename, NULL); 17660 17661 static void 17662 cmd_load_from_file_parsed( 17663 void *parsed_result, 17664 __attribute__((unused)) struct cmdline *cl, 17665 __attribute__((unused)) void *data) 17666 { 17667 struct cmd_cmdfile_result *res = parsed_result; 17668 17669 cmdline_read_from_file(res->filename); 17670 } 17671 17672 cmdline_parse_inst_t cmd_load_from_file = { 17673 .f = cmd_load_from_file_parsed, 17674 .data = NULL, 17675 .help_str = "load <filename>", 17676 .tokens = { 17677 (void *)&cmd_load_cmdfile, 17678 (void *)&cmd_load_cmdfile_filename, 17679 NULL, 17680 }, 17681 }; 17682 17683 /* Get Rx offloads capabilities */ 17684 struct cmd_rx_offload_get_capa_result { 17685 cmdline_fixed_string_t show; 17686 cmdline_fixed_string_t port; 17687 portid_t port_id; 17688 cmdline_fixed_string_t rx_offload; 17689 cmdline_fixed_string_t capabilities; 17690 }; 17691 17692 cmdline_parse_token_string_t cmd_rx_offload_get_capa_show = 17693 TOKEN_STRING_INITIALIZER 17694 (struct cmd_rx_offload_get_capa_result, 17695 show, "show"); 17696 cmdline_parse_token_string_t cmd_rx_offload_get_capa_port = 17697 TOKEN_STRING_INITIALIZER 17698 (struct cmd_rx_offload_get_capa_result, 17699 port, "port"); 17700 cmdline_parse_token_num_t cmd_rx_offload_get_capa_port_id = 17701 TOKEN_NUM_INITIALIZER 17702 (struct cmd_rx_offload_get_capa_result, 17703 port_id, UINT16); 17704 cmdline_parse_token_string_t cmd_rx_offload_get_capa_rx_offload = 17705 TOKEN_STRING_INITIALIZER 17706 (struct cmd_rx_offload_get_capa_result, 17707 rx_offload, "rx_offload"); 17708 cmdline_parse_token_string_t cmd_rx_offload_get_capa_capabilities = 17709 TOKEN_STRING_INITIALIZER 17710 (struct cmd_rx_offload_get_capa_result, 17711 capabilities, "capabilities"); 17712 17713 static void 17714 print_rx_offloads(uint64_t offloads) 17715 { 17716 uint64_t single_offload; 17717 int begin; 17718 int end; 17719 int bit; 17720 17721 if (offloads == 0) 17722 return; 17723 17724 begin = __builtin_ctzll(offloads); 17725 end = sizeof(offloads) * CHAR_BIT - __builtin_clzll(offloads); 17726 17727 single_offload = 1ULL << begin; 17728 for (bit = begin; bit < end; bit++) { 17729 if (offloads & single_offload) 17730 printf(" %s", 17731 rte_eth_dev_rx_offload_name(single_offload)); 17732 single_offload <<= 1; 17733 } 17734 } 17735 17736 static void 17737 cmd_rx_offload_get_capa_parsed( 17738 void *parsed_result, 17739 __attribute__((unused)) struct cmdline *cl, 17740 __attribute__((unused)) void *data) 17741 { 17742 struct cmd_rx_offload_get_capa_result *res = parsed_result; 17743 struct rte_eth_dev_info dev_info; 17744 portid_t port_id = res->port_id; 17745 uint64_t queue_offloads; 17746 uint64_t port_offloads; 17747 17748 rte_eth_dev_info_get(port_id, &dev_info); 17749 queue_offloads = dev_info.rx_queue_offload_capa; 17750 port_offloads = dev_info.rx_offload_capa ^ queue_offloads; 17751 17752 printf("Rx Offloading Capabilities of port %d :\n", port_id); 17753 printf(" Per Queue :"); 17754 print_rx_offloads(queue_offloads); 17755 17756 printf("\n"); 17757 printf(" Per Port :"); 17758 print_rx_offloads(port_offloads); 17759 printf("\n\n"); 17760 } 17761 17762 cmdline_parse_inst_t cmd_rx_offload_get_capa = { 17763 .f = cmd_rx_offload_get_capa_parsed, 17764 .data = NULL, 17765 .help_str = "show port <port_id> rx_offload capabilities", 17766 .tokens = { 17767 (void *)&cmd_rx_offload_get_capa_show, 17768 (void *)&cmd_rx_offload_get_capa_port, 17769 (void *)&cmd_rx_offload_get_capa_port_id, 17770 (void *)&cmd_rx_offload_get_capa_rx_offload, 17771 (void *)&cmd_rx_offload_get_capa_capabilities, 17772 NULL, 17773 } 17774 }; 17775 17776 /* Get Rx offloads configuration */ 17777 struct cmd_rx_offload_get_configuration_result { 17778 cmdline_fixed_string_t show; 17779 cmdline_fixed_string_t port; 17780 portid_t port_id; 17781 cmdline_fixed_string_t rx_offload; 17782 cmdline_fixed_string_t configuration; 17783 }; 17784 17785 cmdline_parse_token_string_t cmd_rx_offload_get_configuration_show = 17786 TOKEN_STRING_INITIALIZER 17787 (struct cmd_rx_offload_get_configuration_result, 17788 show, "show"); 17789 cmdline_parse_token_string_t cmd_rx_offload_get_configuration_port = 17790 TOKEN_STRING_INITIALIZER 17791 (struct cmd_rx_offload_get_configuration_result, 17792 port, "port"); 17793 cmdline_parse_token_num_t cmd_rx_offload_get_configuration_port_id = 17794 TOKEN_NUM_INITIALIZER 17795 (struct cmd_rx_offload_get_configuration_result, 17796 port_id, UINT16); 17797 cmdline_parse_token_string_t cmd_rx_offload_get_configuration_rx_offload = 17798 TOKEN_STRING_INITIALIZER 17799 (struct cmd_rx_offload_get_configuration_result, 17800 rx_offload, "rx_offload"); 17801 cmdline_parse_token_string_t cmd_rx_offload_get_configuration_configuration = 17802 TOKEN_STRING_INITIALIZER 17803 (struct cmd_rx_offload_get_configuration_result, 17804 configuration, "configuration"); 17805 17806 static void 17807 cmd_rx_offload_get_configuration_parsed( 17808 void *parsed_result, 17809 __attribute__((unused)) struct cmdline *cl, 17810 __attribute__((unused)) void *data) 17811 { 17812 struct cmd_rx_offload_get_configuration_result *res = parsed_result; 17813 struct rte_eth_dev_info dev_info; 17814 portid_t port_id = res->port_id; 17815 struct rte_port *port = &ports[port_id]; 17816 uint64_t port_offloads; 17817 uint64_t queue_offloads; 17818 uint16_t nb_rx_queues; 17819 int q; 17820 17821 printf("Rx Offloading Configuration of port %d :\n", port_id); 17822 17823 port_offloads = port->dev_conf.rxmode.offloads; 17824 printf(" Port :"); 17825 print_rx_offloads(port_offloads); 17826 printf("\n"); 17827 17828 rte_eth_dev_info_get(port_id, &dev_info); 17829 nb_rx_queues = dev_info.nb_rx_queues; 17830 for (q = 0; q < nb_rx_queues; q++) { 17831 queue_offloads = port->rx_conf[q].offloads; 17832 printf(" Queue[%2d] :", q); 17833 print_rx_offloads(queue_offloads); 17834 printf("\n"); 17835 } 17836 printf("\n"); 17837 } 17838 17839 cmdline_parse_inst_t cmd_rx_offload_get_configuration = { 17840 .f = cmd_rx_offload_get_configuration_parsed, 17841 .data = NULL, 17842 .help_str = "show port <port_id> rx_offload configuration", 17843 .tokens = { 17844 (void *)&cmd_rx_offload_get_configuration_show, 17845 (void *)&cmd_rx_offload_get_configuration_port, 17846 (void *)&cmd_rx_offload_get_configuration_port_id, 17847 (void *)&cmd_rx_offload_get_configuration_rx_offload, 17848 (void *)&cmd_rx_offload_get_configuration_configuration, 17849 NULL, 17850 } 17851 }; 17852 17853 /* Enable/Disable a per port offloading */ 17854 struct cmd_config_per_port_rx_offload_result { 17855 cmdline_fixed_string_t port; 17856 cmdline_fixed_string_t config; 17857 portid_t port_id; 17858 cmdline_fixed_string_t rx_offload; 17859 cmdline_fixed_string_t offload; 17860 cmdline_fixed_string_t on_off; 17861 }; 17862 17863 cmdline_parse_token_string_t cmd_config_per_port_rx_offload_result_port = 17864 TOKEN_STRING_INITIALIZER 17865 (struct cmd_config_per_port_rx_offload_result, 17866 port, "port"); 17867 cmdline_parse_token_string_t cmd_config_per_port_rx_offload_result_config = 17868 TOKEN_STRING_INITIALIZER 17869 (struct cmd_config_per_port_rx_offload_result, 17870 config, "config"); 17871 cmdline_parse_token_num_t cmd_config_per_port_rx_offload_result_port_id = 17872 TOKEN_NUM_INITIALIZER 17873 (struct cmd_config_per_port_rx_offload_result, 17874 port_id, UINT16); 17875 cmdline_parse_token_string_t cmd_config_per_port_rx_offload_result_rx_offload = 17876 TOKEN_STRING_INITIALIZER 17877 (struct cmd_config_per_port_rx_offload_result, 17878 rx_offload, "rx_offload"); 17879 cmdline_parse_token_string_t cmd_config_per_port_rx_offload_result_offload = 17880 TOKEN_STRING_INITIALIZER 17881 (struct cmd_config_per_port_rx_offload_result, 17882 offload, "vlan_strip#ipv4_cksum#udp_cksum#tcp_cksum#tcp_lro#" 17883 "qinq_strip#outer_ipv4_cksum#macsec_strip#" 17884 "header_split#vlan_filter#vlan_extend#jumbo_frame#" 17885 "crc_strip#scatter#timestamp#security#keep_crc"); 17886 cmdline_parse_token_string_t cmd_config_per_port_rx_offload_result_on_off = 17887 TOKEN_STRING_INITIALIZER 17888 (struct cmd_config_per_port_rx_offload_result, 17889 on_off, "on#off"); 17890 17891 static uint64_t 17892 search_rx_offload(const char *name) 17893 { 17894 uint64_t single_offload; 17895 const char *single_name; 17896 int found = 0; 17897 unsigned int bit; 17898 17899 single_offload = 1; 17900 for (bit = 0; bit < sizeof(single_offload) * CHAR_BIT; bit++) { 17901 single_name = rte_eth_dev_rx_offload_name(single_offload); 17902 if (!strcasecmp(single_name, name)) { 17903 found = 1; 17904 break; 17905 } 17906 single_offload <<= 1; 17907 } 17908 17909 if (found) 17910 return single_offload; 17911 17912 return 0; 17913 } 17914 17915 static void 17916 cmd_config_per_port_rx_offload_parsed(void *parsed_result, 17917 __attribute__((unused)) struct cmdline *cl, 17918 __attribute__((unused)) void *data) 17919 { 17920 struct cmd_config_per_port_rx_offload_result *res = parsed_result; 17921 portid_t port_id = res->port_id; 17922 struct rte_eth_dev_info dev_info; 17923 struct rte_port *port = &ports[port_id]; 17924 uint64_t single_offload; 17925 uint16_t nb_rx_queues; 17926 int q; 17927 17928 if (port->port_status != RTE_PORT_STOPPED) { 17929 printf("Error: Can't config offload when Port %d " 17930 "is not stopped\n", port_id); 17931 return; 17932 } 17933 17934 single_offload = search_rx_offload(res->offload); 17935 if (single_offload == 0) { 17936 printf("Unknown offload name: %s\n", res->offload); 17937 return; 17938 } 17939 17940 rte_eth_dev_info_get(port_id, &dev_info); 17941 nb_rx_queues = dev_info.nb_rx_queues; 17942 if (!strcmp(res->on_off, "on")) { 17943 port->dev_conf.rxmode.offloads |= single_offload; 17944 for (q = 0; q < nb_rx_queues; q++) 17945 port->rx_conf[q].offloads |= single_offload; 17946 } else { 17947 port->dev_conf.rxmode.offloads &= ~single_offload; 17948 for (q = 0; q < nb_rx_queues; q++) 17949 port->rx_conf[q].offloads &= ~single_offload; 17950 } 17951 17952 cmd_reconfig_device_queue(port_id, 1, 1); 17953 } 17954 17955 cmdline_parse_inst_t cmd_config_per_port_rx_offload = { 17956 .f = cmd_config_per_port_rx_offload_parsed, 17957 .data = NULL, 17958 .help_str = "port config <port_id> rx_offload vlan_strip|ipv4_cksum|" 17959 "udp_cksum|tcp_cksum|tcp_lro|qinq_strip|outer_ipv4_cksum|" 17960 "macsec_strip|header_split|vlan_filter|vlan_extend|" 17961 "jumbo_frame|crc_strip|scatter|timestamp|security|keep_crc " 17962 "on|off", 17963 .tokens = { 17964 (void *)&cmd_config_per_port_rx_offload_result_port, 17965 (void *)&cmd_config_per_port_rx_offload_result_config, 17966 (void *)&cmd_config_per_port_rx_offload_result_port_id, 17967 (void *)&cmd_config_per_port_rx_offload_result_rx_offload, 17968 (void *)&cmd_config_per_port_rx_offload_result_offload, 17969 (void *)&cmd_config_per_port_rx_offload_result_on_off, 17970 NULL, 17971 } 17972 }; 17973 17974 /* Enable/Disable a per queue offloading */ 17975 struct cmd_config_per_queue_rx_offload_result { 17976 cmdline_fixed_string_t port; 17977 portid_t port_id; 17978 cmdline_fixed_string_t rxq; 17979 uint16_t queue_id; 17980 cmdline_fixed_string_t rx_offload; 17981 cmdline_fixed_string_t offload; 17982 cmdline_fixed_string_t on_off; 17983 }; 17984 17985 cmdline_parse_token_string_t cmd_config_per_queue_rx_offload_result_port = 17986 TOKEN_STRING_INITIALIZER 17987 (struct cmd_config_per_queue_rx_offload_result, 17988 port, "port"); 17989 cmdline_parse_token_num_t cmd_config_per_queue_rx_offload_result_port_id = 17990 TOKEN_NUM_INITIALIZER 17991 (struct cmd_config_per_queue_rx_offload_result, 17992 port_id, UINT16); 17993 cmdline_parse_token_string_t cmd_config_per_queue_rx_offload_result_rxq = 17994 TOKEN_STRING_INITIALIZER 17995 (struct cmd_config_per_queue_rx_offload_result, 17996 rxq, "rxq"); 17997 cmdline_parse_token_num_t cmd_config_per_queue_rx_offload_result_queue_id = 17998 TOKEN_NUM_INITIALIZER 17999 (struct cmd_config_per_queue_rx_offload_result, 18000 queue_id, UINT16); 18001 cmdline_parse_token_string_t cmd_config_per_queue_rx_offload_result_rxoffload = 18002 TOKEN_STRING_INITIALIZER 18003 (struct cmd_config_per_queue_rx_offload_result, 18004 rx_offload, "rx_offload"); 18005 cmdline_parse_token_string_t cmd_config_per_queue_rx_offload_result_offload = 18006 TOKEN_STRING_INITIALIZER 18007 (struct cmd_config_per_queue_rx_offload_result, 18008 offload, "vlan_strip#ipv4_cksum#udp_cksum#tcp_cksum#tcp_lro#" 18009 "qinq_strip#outer_ipv4_cksum#macsec_strip#" 18010 "header_split#vlan_filter#vlan_extend#jumbo_frame#" 18011 "crc_strip#scatter#timestamp#security#keep_crc"); 18012 cmdline_parse_token_string_t cmd_config_per_queue_rx_offload_result_on_off = 18013 TOKEN_STRING_INITIALIZER 18014 (struct cmd_config_per_queue_rx_offload_result, 18015 on_off, "on#off"); 18016 18017 static void 18018 cmd_config_per_queue_rx_offload_parsed(void *parsed_result, 18019 __attribute__((unused)) struct cmdline *cl, 18020 __attribute__((unused)) void *data) 18021 { 18022 struct cmd_config_per_queue_rx_offload_result *res = parsed_result; 18023 struct rte_eth_dev_info dev_info; 18024 portid_t port_id = res->port_id; 18025 uint16_t queue_id = res->queue_id; 18026 struct rte_port *port = &ports[port_id]; 18027 uint64_t single_offload; 18028 18029 if (port->port_status != RTE_PORT_STOPPED) { 18030 printf("Error: Can't config offload when Port %d " 18031 "is not stopped\n", port_id); 18032 return; 18033 } 18034 18035 rte_eth_dev_info_get(port_id, &dev_info); 18036 if (queue_id >= dev_info.nb_rx_queues) { 18037 printf("Error: input queue_id should be 0 ... " 18038 "%d\n", dev_info.nb_rx_queues - 1); 18039 return; 18040 } 18041 18042 single_offload = search_rx_offload(res->offload); 18043 if (single_offload == 0) { 18044 printf("Unknown offload name: %s\n", res->offload); 18045 return; 18046 } 18047 18048 if (!strcmp(res->on_off, "on")) 18049 port->rx_conf[queue_id].offloads |= single_offload; 18050 else 18051 port->rx_conf[queue_id].offloads &= ~single_offload; 18052 18053 cmd_reconfig_device_queue(port_id, 1, 1); 18054 } 18055 18056 cmdline_parse_inst_t cmd_config_per_queue_rx_offload = { 18057 .f = cmd_config_per_queue_rx_offload_parsed, 18058 .data = NULL, 18059 .help_str = "port <port_id> rxq <queue_id> rx_offload " 18060 "vlan_strip|ipv4_cksum|" 18061 "udp_cksum|tcp_cksum|tcp_lro|qinq_strip|outer_ipv4_cksum|" 18062 "macsec_strip|header_split|vlan_filter|vlan_extend|" 18063 "jumbo_frame|crc_strip|scatter|timestamp|security|keep_crc " 18064 "on|off", 18065 .tokens = { 18066 (void *)&cmd_config_per_queue_rx_offload_result_port, 18067 (void *)&cmd_config_per_queue_rx_offload_result_port_id, 18068 (void *)&cmd_config_per_queue_rx_offload_result_rxq, 18069 (void *)&cmd_config_per_queue_rx_offload_result_queue_id, 18070 (void *)&cmd_config_per_queue_rx_offload_result_rxoffload, 18071 (void *)&cmd_config_per_queue_rx_offload_result_offload, 18072 (void *)&cmd_config_per_queue_rx_offload_result_on_off, 18073 NULL, 18074 } 18075 }; 18076 18077 /* Get Tx offloads capabilities */ 18078 struct cmd_tx_offload_get_capa_result { 18079 cmdline_fixed_string_t show; 18080 cmdline_fixed_string_t port; 18081 portid_t port_id; 18082 cmdline_fixed_string_t tx_offload; 18083 cmdline_fixed_string_t capabilities; 18084 }; 18085 18086 cmdline_parse_token_string_t cmd_tx_offload_get_capa_show = 18087 TOKEN_STRING_INITIALIZER 18088 (struct cmd_tx_offload_get_capa_result, 18089 show, "show"); 18090 cmdline_parse_token_string_t cmd_tx_offload_get_capa_port = 18091 TOKEN_STRING_INITIALIZER 18092 (struct cmd_tx_offload_get_capa_result, 18093 port, "port"); 18094 cmdline_parse_token_num_t cmd_tx_offload_get_capa_port_id = 18095 TOKEN_NUM_INITIALIZER 18096 (struct cmd_tx_offload_get_capa_result, 18097 port_id, UINT16); 18098 cmdline_parse_token_string_t cmd_tx_offload_get_capa_tx_offload = 18099 TOKEN_STRING_INITIALIZER 18100 (struct cmd_tx_offload_get_capa_result, 18101 tx_offload, "tx_offload"); 18102 cmdline_parse_token_string_t cmd_tx_offload_get_capa_capabilities = 18103 TOKEN_STRING_INITIALIZER 18104 (struct cmd_tx_offload_get_capa_result, 18105 capabilities, "capabilities"); 18106 18107 static void 18108 print_tx_offloads(uint64_t offloads) 18109 { 18110 uint64_t single_offload; 18111 int begin; 18112 int end; 18113 int bit; 18114 18115 if (offloads == 0) 18116 return; 18117 18118 begin = __builtin_ctzll(offloads); 18119 end = sizeof(offloads) * CHAR_BIT - __builtin_clzll(offloads); 18120 18121 single_offload = 1ULL << begin; 18122 for (bit = begin; bit < end; bit++) { 18123 if (offloads & single_offload) 18124 printf(" %s", 18125 rte_eth_dev_tx_offload_name(single_offload)); 18126 single_offload <<= 1; 18127 } 18128 } 18129 18130 static void 18131 cmd_tx_offload_get_capa_parsed( 18132 void *parsed_result, 18133 __attribute__((unused)) struct cmdline *cl, 18134 __attribute__((unused)) void *data) 18135 { 18136 struct cmd_tx_offload_get_capa_result *res = parsed_result; 18137 struct rte_eth_dev_info dev_info; 18138 portid_t port_id = res->port_id; 18139 uint64_t queue_offloads; 18140 uint64_t port_offloads; 18141 18142 rte_eth_dev_info_get(port_id, &dev_info); 18143 queue_offloads = dev_info.tx_queue_offload_capa; 18144 port_offloads = dev_info.tx_offload_capa ^ queue_offloads; 18145 18146 printf("Tx Offloading Capabilities of port %d :\n", port_id); 18147 printf(" Per Queue :"); 18148 print_tx_offloads(queue_offloads); 18149 18150 printf("\n"); 18151 printf(" Per Port :"); 18152 print_tx_offloads(port_offloads); 18153 printf("\n\n"); 18154 } 18155 18156 cmdline_parse_inst_t cmd_tx_offload_get_capa = { 18157 .f = cmd_tx_offload_get_capa_parsed, 18158 .data = NULL, 18159 .help_str = "show port <port_id> tx_offload capabilities", 18160 .tokens = { 18161 (void *)&cmd_tx_offload_get_capa_show, 18162 (void *)&cmd_tx_offload_get_capa_port, 18163 (void *)&cmd_tx_offload_get_capa_port_id, 18164 (void *)&cmd_tx_offload_get_capa_tx_offload, 18165 (void *)&cmd_tx_offload_get_capa_capabilities, 18166 NULL, 18167 } 18168 }; 18169 18170 /* Get Tx offloads configuration */ 18171 struct cmd_tx_offload_get_configuration_result { 18172 cmdline_fixed_string_t show; 18173 cmdline_fixed_string_t port; 18174 portid_t port_id; 18175 cmdline_fixed_string_t tx_offload; 18176 cmdline_fixed_string_t configuration; 18177 }; 18178 18179 cmdline_parse_token_string_t cmd_tx_offload_get_configuration_show = 18180 TOKEN_STRING_INITIALIZER 18181 (struct cmd_tx_offload_get_configuration_result, 18182 show, "show"); 18183 cmdline_parse_token_string_t cmd_tx_offload_get_configuration_port = 18184 TOKEN_STRING_INITIALIZER 18185 (struct cmd_tx_offload_get_configuration_result, 18186 port, "port"); 18187 cmdline_parse_token_num_t cmd_tx_offload_get_configuration_port_id = 18188 TOKEN_NUM_INITIALIZER 18189 (struct cmd_tx_offload_get_configuration_result, 18190 port_id, UINT16); 18191 cmdline_parse_token_string_t cmd_tx_offload_get_configuration_tx_offload = 18192 TOKEN_STRING_INITIALIZER 18193 (struct cmd_tx_offload_get_configuration_result, 18194 tx_offload, "tx_offload"); 18195 cmdline_parse_token_string_t cmd_tx_offload_get_configuration_configuration = 18196 TOKEN_STRING_INITIALIZER 18197 (struct cmd_tx_offload_get_configuration_result, 18198 configuration, "configuration"); 18199 18200 static void 18201 cmd_tx_offload_get_configuration_parsed( 18202 void *parsed_result, 18203 __attribute__((unused)) struct cmdline *cl, 18204 __attribute__((unused)) void *data) 18205 { 18206 struct cmd_tx_offload_get_configuration_result *res = parsed_result; 18207 struct rte_eth_dev_info dev_info; 18208 portid_t port_id = res->port_id; 18209 struct rte_port *port = &ports[port_id]; 18210 uint64_t port_offloads; 18211 uint64_t queue_offloads; 18212 uint16_t nb_tx_queues; 18213 int q; 18214 18215 printf("Tx Offloading Configuration of port %d :\n", port_id); 18216 18217 port_offloads = port->dev_conf.txmode.offloads; 18218 printf(" Port :"); 18219 print_tx_offloads(port_offloads); 18220 printf("\n"); 18221 18222 rte_eth_dev_info_get(port_id, &dev_info); 18223 nb_tx_queues = dev_info.nb_tx_queues; 18224 for (q = 0; q < nb_tx_queues; q++) { 18225 queue_offloads = port->tx_conf[q].offloads; 18226 printf(" Queue[%2d] :", q); 18227 print_tx_offloads(queue_offloads); 18228 printf("\n"); 18229 } 18230 printf("\n"); 18231 } 18232 18233 cmdline_parse_inst_t cmd_tx_offload_get_configuration = { 18234 .f = cmd_tx_offload_get_configuration_parsed, 18235 .data = NULL, 18236 .help_str = "show port <port_id> tx_offload configuration", 18237 .tokens = { 18238 (void *)&cmd_tx_offload_get_configuration_show, 18239 (void *)&cmd_tx_offload_get_configuration_port, 18240 (void *)&cmd_tx_offload_get_configuration_port_id, 18241 (void *)&cmd_tx_offload_get_configuration_tx_offload, 18242 (void *)&cmd_tx_offload_get_configuration_configuration, 18243 NULL, 18244 } 18245 }; 18246 18247 /* Enable/Disable a per port offloading */ 18248 struct cmd_config_per_port_tx_offload_result { 18249 cmdline_fixed_string_t port; 18250 cmdline_fixed_string_t config; 18251 portid_t port_id; 18252 cmdline_fixed_string_t tx_offload; 18253 cmdline_fixed_string_t offload; 18254 cmdline_fixed_string_t on_off; 18255 }; 18256 18257 cmdline_parse_token_string_t cmd_config_per_port_tx_offload_result_port = 18258 TOKEN_STRING_INITIALIZER 18259 (struct cmd_config_per_port_tx_offload_result, 18260 port, "port"); 18261 cmdline_parse_token_string_t cmd_config_per_port_tx_offload_result_config = 18262 TOKEN_STRING_INITIALIZER 18263 (struct cmd_config_per_port_tx_offload_result, 18264 config, "config"); 18265 cmdline_parse_token_num_t cmd_config_per_port_tx_offload_result_port_id = 18266 TOKEN_NUM_INITIALIZER 18267 (struct cmd_config_per_port_tx_offload_result, 18268 port_id, UINT16); 18269 cmdline_parse_token_string_t cmd_config_per_port_tx_offload_result_tx_offload = 18270 TOKEN_STRING_INITIALIZER 18271 (struct cmd_config_per_port_tx_offload_result, 18272 tx_offload, "tx_offload"); 18273 cmdline_parse_token_string_t cmd_config_per_port_tx_offload_result_offload = 18274 TOKEN_STRING_INITIALIZER 18275 (struct cmd_config_per_port_tx_offload_result, 18276 offload, "vlan_insert#ipv4_cksum#udp_cksum#tcp_cksum#" 18277 "sctp_cksum#tcp_tso#udp_tso#outer_ipv4_cksum#" 18278 "qinq_insert#vxlan_tnl_tso#gre_tnl_tso#" 18279 "ipip_tnl_tso#geneve_tnl_tso#macsec_insert#" 18280 "mt_lockfree#multi_segs#mbuf_fast_free#security#" 18281 "match_metadata"); 18282 cmdline_parse_token_string_t cmd_config_per_port_tx_offload_result_on_off = 18283 TOKEN_STRING_INITIALIZER 18284 (struct cmd_config_per_port_tx_offload_result, 18285 on_off, "on#off"); 18286 18287 static uint64_t 18288 search_tx_offload(const char *name) 18289 { 18290 uint64_t single_offload; 18291 const char *single_name; 18292 int found = 0; 18293 unsigned int bit; 18294 18295 single_offload = 1; 18296 for (bit = 0; bit < sizeof(single_offload) * CHAR_BIT; bit++) { 18297 single_name = rte_eth_dev_tx_offload_name(single_offload); 18298 if (single_name == NULL) 18299 break; 18300 if (!strcasecmp(single_name, name)) { 18301 found = 1; 18302 break; 18303 } else if (!strcasecmp(single_name, "UNKNOWN")) 18304 break; 18305 single_offload <<= 1; 18306 } 18307 18308 if (found) 18309 return single_offload; 18310 18311 return 0; 18312 } 18313 18314 static void 18315 cmd_config_per_port_tx_offload_parsed(void *parsed_result, 18316 __attribute__((unused)) struct cmdline *cl, 18317 __attribute__((unused)) void *data) 18318 { 18319 struct cmd_config_per_port_tx_offload_result *res = parsed_result; 18320 portid_t port_id = res->port_id; 18321 struct rte_eth_dev_info dev_info; 18322 struct rte_port *port = &ports[port_id]; 18323 uint64_t single_offload; 18324 uint16_t nb_tx_queues; 18325 int q; 18326 18327 if (port->port_status != RTE_PORT_STOPPED) { 18328 printf("Error: Can't config offload when Port %d " 18329 "is not stopped\n", port_id); 18330 return; 18331 } 18332 18333 single_offload = search_tx_offload(res->offload); 18334 if (single_offload == 0) { 18335 printf("Unknown offload name: %s\n", res->offload); 18336 return; 18337 } 18338 18339 rte_eth_dev_info_get(port_id, &dev_info); 18340 nb_tx_queues = dev_info.nb_tx_queues; 18341 if (!strcmp(res->on_off, "on")) { 18342 port->dev_conf.txmode.offloads |= single_offload; 18343 for (q = 0; q < nb_tx_queues; q++) 18344 port->tx_conf[q].offloads |= single_offload; 18345 } else { 18346 port->dev_conf.txmode.offloads &= ~single_offload; 18347 for (q = 0; q < nb_tx_queues; q++) 18348 port->tx_conf[q].offloads &= ~single_offload; 18349 } 18350 18351 cmd_reconfig_device_queue(port_id, 1, 1); 18352 } 18353 18354 cmdline_parse_inst_t cmd_config_per_port_tx_offload = { 18355 .f = cmd_config_per_port_tx_offload_parsed, 18356 .data = NULL, 18357 .help_str = "port config <port_id> tx_offload " 18358 "vlan_insert|ipv4_cksum|udp_cksum|tcp_cksum|" 18359 "sctp_cksum|tcp_tso|udp_tso|outer_ipv4_cksum|" 18360 "qinq_insert|vxlan_tnl_tso|gre_tnl_tso|" 18361 "ipip_tnl_tso|geneve_tnl_tso|macsec_insert|" 18362 "mt_lockfree|multi_segs|mbuf_fast_free|security|" 18363 "match_metadata on|off", 18364 .tokens = { 18365 (void *)&cmd_config_per_port_tx_offload_result_port, 18366 (void *)&cmd_config_per_port_tx_offload_result_config, 18367 (void *)&cmd_config_per_port_tx_offload_result_port_id, 18368 (void *)&cmd_config_per_port_tx_offload_result_tx_offload, 18369 (void *)&cmd_config_per_port_tx_offload_result_offload, 18370 (void *)&cmd_config_per_port_tx_offload_result_on_off, 18371 NULL, 18372 } 18373 }; 18374 18375 /* Enable/Disable a per queue offloading */ 18376 struct cmd_config_per_queue_tx_offload_result { 18377 cmdline_fixed_string_t port; 18378 portid_t port_id; 18379 cmdline_fixed_string_t txq; 18380 uint16_t queue_id; 18381 cmdline_fixed_string_t tx_offload; 18382 cmdline_fixed_string_t offload; 18383 cmdline_fixed_string_t on_off; 18384 }; 18385 18386 cmdline_parse_token_string_t cmd_config_per_queue_tx_offload_result_port = 18387 TOKEN_STRING_INITIALIZER 18388 (struct cmd_config_per_queue_tx_offload_result, 18389 port, "port"); 18390 cmdline_parse_token_num_t cmd_config_per_queue_tx_offload_result_port_id = 18391 TOKEN_NUM_INITIALIZER 18392 (struct cmd_config_per_queue_tx_offload_result, 18393 port_id, UINT16); 18394 cmdline_parse_token_string_t cmd_config_per_queue_tx_offload_result_txq = 18395 TOKEN_STRING_INITIALIZER 18396 (struct cmd_config_per_queue_tx_offload_result, 18397 txq, "txq"); 18398 cmdline_parse_token_num_t cmd_config_per_queue_tx_offload_result_queue_id = 18399 TOKEN_NUM_INITIALIZER 18400 (struct cmd_config_per_queue_tx_offload_result, 18401 queue_id, UINT16); 18402 cmdline_parse_token_string_t cmd_config_per_queue_tx_offload_result_txoffload = 18403 TOKEN_STRING_INITIALIZER 18404 (struct cmd_config_per_queue_tx_offload_result, 18405 tx_offload, "tx_offload"); 18406 cmdline_parse_token_string_t cmd_config_per_queue_tx_offload_result_offload = 18407 TOKEN_STRING_INITIALIZER 18408 (struct cmd_config_per_queue_tx_offload_result, 18409 offload, "vlan_insert#ipv4_cksum#udp_cksum#tcp_cksum#" 18410 "sctp_cksum#tcp_tso#udp_tso#outer_ipv4_cksum#" 18411 "qinq_insert#vxlan_tnl_tso#gre_tnl_tso#" 18412 "ipip_tnl_tso#geneve_tnl_tso#macsec_insert#" 18413 "mt_lockfree#multi_segs#mbuf_fast_free#security"); 18414 cmdline_parse_token_string_t cmd_config_per_queue_tx_offload_result_on_off = 18415 TOKEN_STRING_INITIALIZER 18416 (struct cmd_config_per_queue_tx_offload_result, 18417 on_off, "on#off"); 18418 18419 static void 18420 cmd_config_per_queue_tx_offload_parsed(void *parsed_result, 18421 __attribute__((unused)) struct cmdline *cl, 18422 __attribute__((unused)) void *data) 18423 { 18424 struct cmd_config_per_queue_tx_offload_result *res = parsed_result; 18425 struct rte_eth_dev_info dev_info; 18426 portid_t port_id = res->port_id; 18427 uint16_t queue_id = res->queue_id; 18428 struct rte_port *port = &ports[port_id]; 18429 uint64_t single_offload; 18430 18431 if (port->port_status != RTE_PORT_STOPPED) { 18432 printf("Error: Can't config offload when Port %d " 18433 "is not stopped\n", port_id); 18434 return; 18435 } 18436 18437 rte_eth_dev_info_get(port_id, &dev_info); 18438 if (queue_id >= dev_info.nb_tx_queues) { 18439 printf("Error: input queue_id should be 0 ... " 18440 "%d\n", dev_info.nb_tx_queues - 1); 18441 return; 18442 } 18443 18444 single_offload = search_tx_offload(res->offload); 18445 if (single_offload == 0) { 18446 printf("Unknown offload name: %s\n", res->offload); 18447 return; 18448 } 18449 18450 if (!strcmp(res->on_off, "on")) 18451 port->tx_conf[queue_id].offloads |= single_offload; 18452 else 18453 port->tx_conf[queue_id].offloads &= ~single_offload; 18454 18455 cmd_reconfig_device_queue(port_id, 1, 1); 18456 } 18457 18458 cmdline_parse_inst_t cmd_config_per_queue_tx_offload = { 18459 .f = cmd_config_per_queue_tx_offload_parsed, 18460 .data = NULL, 18461 .help_str = "port <port_id> txq <queue_id> tx_offload " 18462 "vlan_insert|ipv4_cksum|udp_cksum|tcp_cksum|" 18463 "sctp_cksum|tcp_tso|udp_tso|outer_ipv4_cksum|" 18464 "qinq_insert|vxlan_tnl_tso|gre_tnl_tso|" 18465 "ipip_tnl_tso|geneve_tnl_tso|macsec_insert|" 18466 "mt_lockfree|multi_segs|mbuf_fast_free|security " 18467 "on|off", 18468 .tokens = { 18469 (void *)&cmd_config_per_queue_tx_offload_result_port, 18470 (void *)&cmd_config_per_queue_tx_offload_result_port_id, 18471 (void *)&cmd_config_per_queue_tx_offload_result_txq, 18472 (void *)&cmd_config_per_queue_tx_offload_result_queue_id, 18473 (void *)&cmd_config_per_queue_tx_offload_result_txoffload, 18474 (void *)&cmd_config_per_queue_tx_offload_result_offload, 18475 (void *)&cmd_config_per_queue_tx_offload_result_on_off, 18476 NULL, 18477 } 18478 }; 18479 18480 /* *** configure tx_metadata for specific port *** */ 18481 struct cmd_config_tx_metadata_specific_result { 18482 cmdline_fixed_string_t port; 18483 cmdline_fixed_string_t keyword; 18484 uint16_t port_id; 18485 cmdline_fixed_string_t item; 18486 uint32_t value; 18487 }; 18488 18489 static void 18490 cmd_config_tx_metadata_specific_parsed(void *parsed_result, 18491 __attribute__((unused)) struct cmdline *cl, 18492 __attribute__((unused)) void *data) 18493 { 18494 struct cmd_config_tx_metadata_specific_result *res = parsed_result; 18495 18496 if (port_id_is_invalid(res->port_id, ENABLED_WARN)) 18497 return; 18498 ports[res->port_id].tx_metadata = rte_cpu_to_be_32(res->value); 18499 /* Add/remove callback to insert valid metadata in every Tx packet. */ 18500 if (ports[res->port_id].tx_metadata) 18501 add_tx_md_callback(res->port_id); 18502 else 18503 remove_tx_md_callback(res->port_id); 18504 } 18505 18506 cmdline_parse_token_string_t cmd_config_tx_metadata_specific_port = 18507 TOKEN_STRING_INITIALIZER(struct cmd_config_tx_metadata_specific_result, 18508 port, "port"); 18509 cmdline_parse_token_string_t cmd_config_tx_metadata_specific_keyword = 18510 TOKEN_STRING_INITIALIZER(struct cmd_config_tx_metadata_specific_result, 18511 keyword, "config"); 18512 cmdline_parse_token_num_t cmd_config_tx_metadata_specific_id = 18513 TOKEN_NUM_INITIALIZER(struct cmd_config_tx_metadata_specific_result, 18514 port_id, UINT16); 18515 cmdline_parse_token_string_t cmd_config_tx_metadata_specific_item = 18516 TOKEN_STRING_INITIALIZER(struct cmd_config_tx_metadata_specific_result, 18517 item, "tx_metadata"); 18518 cmdline_parse_token_num_t cmd_config_tx_metadata_specific_value = 18519 TOKEN_NUM_INITIALIZER(struct cmd_config_tx_metadata_specific_result, 18520 value, UINT32); 18521 18522 cmdline_parse_inst_t cmd_config_tx_metadata_specific = { 18523 .f = cmd_config_tx_metadata_specific_parsed, 18524 .data = NULL, 18525 .help_str = "port config <port_id> tx_metadata <value>", 18526 .tokens = { 18527 (void *)&cmd_config_tx_metadata_specific_port, 18528 (void *)&cmd_config_tx_metadata_specific_keyword, 18529 (void *)&cmd_config_tx_metadata_specific_id, 18530 (void *)&cmd_config_tx_metadata_specific_item, 18531 (void *)&cmd_config_tx_metadata_specific_value, 18532 NULL, 18533 }, 18534 }; 18535 18536 /* *** display tx_metadata per port configuration *** */ 18537 struct cmd_show_tx_metadata_result { 18538 cmdline_fixed_string_t cmd_show; 18539 cmdline_fixed_string_t cmd_port; 18540 cmdline_fixed_string_t cmd_keyword; 18541 portid_t cmd_pid; 18542 }; 18543 18544 static void 18545 cmd_show_tx_metadata_parsed(void *parsed_result, 18546 __attribute__((unused)) struct cmdline *cl, 18547 __attribute__((unused)) void *data) 18548 { 18549 struct cmd_show_tx_metadata_result *res = parsed_result; 18550 18551 if (!rte_eth_dev_is_valid_port(res->cmd_pid)) { 18552 printf("invalid port id %u\n", res->cmd_pid); 18553 return; 18554 } 18555 if (!strcmp(res->cmd_keyword, "tx_metadata")) { 18556 printf("Port %u tx_metadata: %u\n", res->cmd_pid, 18557 rte_be_to_cpu_32(ports[res->cmd_pid].tx_metadata)); 18558 } 18559 } 18560 18561 cmdline_parse_token_string_t cmd_show_tx_metadata_show = 18562 TOKEN_STRING_INITIALIZER(struct cmd_show_tx_metadata_result, 18563 cmd_show, "show"); 18564 cmdline_parse_token_string_t cmd_show_tx_metadata_port = 18565 TOKEN_STRING_INITIALIZER(struct cmd_show_tx_metadata_result, 18566 cmd_port, "port"); 18567 cmdline_parse_token_num_t cmd_show_tx_metadata_pid = 18568 TOKEN_NUM_INITIALIZER(struct cmd_show_tx_metadata_result, 18569 cmd_pid, UINT16); 18570 cmdline_parse_token_string_t cmd_show_tx_metadata_keyword = 18571 TOKEN_STRING_INITIALIZER(struct cmd_show_tx_metadata_result, 18572 cmd_keyword, "tx_metadata"); 18573 18574 cmdline_parse_inst_t cmd_show_tx_metadata = { 18575 .f = cmd_show_tx_metadata_parsed, 18576 .data = NULL, 18577 .help_str = "show port <port_id> tx_metadata", 18578 .tokens = { 18579 (void *)&cmd_show_tx_metadata_show, 18580 (void *)&cmd_show_tx_metadata_port, 18581 (void *)&cmd_show_tx_metadata_pid, 18582 (void *)&cmd_show_tx_metadata_keyword, 18583 NULL, 18584 }, 18585 }; 18586 18587 /* ******************************************************************************** */ 18588 18589 /* list of instructions */ 18590 cmdline_parse_ctx_t main_ctx[] = { 18591 (cmdline_parse_inst_t *)&cmd_help_brief, 18592 (cmdline_parse_inst_t *)&cmd_help_long, 18593 (cmdline_parse_inst_t *)&cmd_quit, 18594 (cmdline_parse_inst_t *)&cmd_load_from_file, 18595 (cmdline_parse_inst_t *)&cmd_showport, 18596 (cmdline_parse_inst_t *)&cmd_showqueue, 18597 (cmdline_parse_inst_t *)&cmd_showportall, 18598 (cmdline_parse_inst_t *)&cmd_showcfg, 18599 (cmdline_parse_inst_t *)&cmd_start, 18600 (cmdline_parse_inst_t *)&cmd_start_tx_first, 18601 (cmdline_parse_inst_t *)&cmd_start_tx_first_n, 18602 (cmdline_parse_inst_t *)&cmd_set_link_up, 18603 (cmdline_parse_inst_t *)&cmd_set_link_down, 18604 (cmdline_parse_inst_t *)&cmd_reset, 18605 (cmdline_parse_inst_t *)&cmd_set_numbers, 18606 (cmdline_parse_inst_t *)&cmd_set_log, 18607 (cmdline_parse_inst_t *)&cmd_set_txpkts, 18608 (cmdline_parse_inst_t *)&cmd_set_txsplit, 18609 (cmdline_parse_inst_t *)&cmd_set_fwd_list, 18610 (cmdline_parse_inst_t *)&cmd_set_fwd_mask, 18611 (cmdline_parse_inst_t *)&cmd_set_fwd_mode, 18612 (cmdline_parse_inst_t *)&cmd_set_fwd_retry_mode, 18613 (cmdline_parse_inst_t *)&cmd_set_burst_tx_retry, 18614 (cmdline_parse_inst_t *)&cmd_set_promisc_mode_one, 18615 (cmdline_parse_inst_t *)&cmd_set_promisc_mode_all, 18616 (cmdline_parse_inst_t *)&cmd_set_allmulti_mode_one, 18617 (cmdline_parse_inst_t *)&cmd_set_allmulti_mode_all, 18618 (cmdline_parse_inst_t *)&cmd_set_flush_rx, 18619 (cmdline_parse_inst_t *)&cmd_set_link_check, 18620 (cmdline_parse_inst_t *)&cmd_set_bypass_mode, 18621 (cmdline_parse_inst_t *)&cmd_set_bypass_event, 18622 (cmdline_parse_inst_t *)&cmd_set_bypass_timeout, 18623 (cmdline_parse_inst_t *)&cmd_show_bypass_config, 18624 #ifdef RTE_LIBRTE_PMD_BOND 18625 (cmdline_parse_inst_t *) &cmd_set_bonding_mode, 18626 (cmdline_parse_inst_t *) &cmd_show_bonding_config, 18627 (cmdline_parse_inst_t *) &cmd_set_bonding_primary, 18628 (cmdline_parse_inst_t *) &cmd_add_bonding_slave, 18629 (cmdline_parse_inst_t *) &cmd_remove_bonding_slave, 18630 (cmdline_parse_inst_t *) &cmd_create_bonded_device, 18631 (cmdline_parse_inst_t *) &cmd_set_bond_mac_addr, 18632 (cmdline_parse_inst_t *) &cmd_set_balance_xmit_policy, 18633 (cmdline_parse_inst_t *) &cmd_set_bond_mon_period, 18634 (cmdline_parse_inst_t *) &cmd_set_lacp_dedicated_queues, 18635 (cmdline_parse_inst_t *) &cmd_set_bonding_agg_mode_policy, 18636 #endif 18637 (cmdline_parse_inst_t *)&cmd_vlan_offload, 18638 (cmdline_parse_inst_t *)&cmd_vlan_tpid, 18639 (cmdline_parse_inst_t *)&cmd_rx_vlan_filter_all, 18640 (cmdline_parse_inst_t *)&cmd_rx_vlan_filter, 18641 (cmdline_parse_inst_t *)&cmd_tx_vlan_set, 18642 (cmdline_parse_inst_t *)&cmd_tx_vlan_set_qinq, 18643 (cmdline_parse_inst_t *)&cmd_tx_vlan_reset, 18644 (cmdline_parse_inst_t *)&cmd_tx_vlan_set_pvid, 18645 (cmdline_parse_inst_t *)&cmd_csum_set, 18646 (cmdline_parse_inst_t *)&cmd_csum_show, 18647 (cmdline_parse_inst_t *)&cmd_csum_tunnel, 18648 (cmdline_parse_inst_t *)&cmd_tso_set, 18649 (cmdline_parse_inst_t *)&cmd_tso_show, 18650 (cmdline_parse_inst_t *)&cmd_tunnel_tso_set, 18651 (cmdline_parse_inst_t *)&cmd_tunnel_tso_show, 18652 (cmdline_parse_inst_t *)&cmd_gro_enable, 18653 (cmdline_parse_inst_t *)&cmd_gro_flush, 18654 (cmdline_parse_inst_t *)&cmd_gro_show, 18655 (cmdline_parse_inst_t *)&cmd_gso_enable, 18656 (cmdline_parse_inst_t *)&cmd_gso_size, 18657 (cmdline_parse_inst_t *)&cmd_gso_show, 18658 (cmdline_parse_inst_t *)&cmd_link_flow_control_set, 18659 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_rx, 18660 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_tx, 18661 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_hw, 18662 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_lw, 18663 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_pt, 18664 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_xon, 18665 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_macfwd, 18666 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_autoneg, 18667 (cmdline_parse_inst_t *)&cmd_priority_flow_control_set, 18668 (cmdline_parse_inst_t *)&cmd_config_dcb, 18669 (cmdline_parse_inst_t *)&cmd_read_reg, 18670 (cmdline_parse_inst_t *)&cmd_read_reg_bit_field, 18671 (cmdline_parse_inst_t *)&cmd_read_reg_bit, 18672 (cmdline_parse_inst_t *)&cmd_write_reg, 18673 (cmdline_parse_inst_t *)&cmd_write_reg_bit_field, 18674 (cmdline_parse_inst_t *)&cmd_write_reg_bit, 18675 (cmdline_parse_inst_t *)&cmd_read_rxd_txd, 18676 (cmdline_parse_inst_t *)&cmd_stop, 18677 (cmdline_parse_inst_t *)&cmd_mac_addr, 18678 (cmdline_parse_inst_t *)&cmd_set_fwd_eth_peer, 18679 (cmdline_parse_inst_t *)&cmd_set_qmap, 18680 (cmdline_parse_inst_t *)&cmd_set_xstats_hide_zero, 18681 (cmdline_parse_inst_t *)&cmd_operate_port, 18682 (cmdline_parse_inst_t *)&cmd_operate_specific_port, 18683 (cmdline_parse_inst_t *)&cmd_operate_attach_port, 18684 (cmdline_parse_inst_t *)&cmd_operate_detach_port, 18685 (cmdline_parse_inst_t *)&cmd_set_port_setup_on, 18686 (cmdline_parse_inst_t *)&cmd_config_speed_all, 18687 (cmdline_parse_inst_t *)&cmd_config_speed_specific, 18688 (cmdline_parse_inst_t *)&cmd_config_loopback_all, 18689 (cmdline_parse_inst_t *)&cmd_config_loopback_specific, 18690 (cmdline_parse_inst_t *)&cmd_config_rx_tx, 18691 (cmdline_parse_inst_t *)&cmd_config_mtu, 18692 (cmdline_parse_inst_t *)&cmd_config_max_pkt_len, 18693 (cmdline_parse_inst_t *)&cmd_config_rx_mode_flag, 18694 (cmdline_parse_inst_t *)&cmd_config_rss, 18695 (cmdline_parse_inst_t *)&cmd_config_rxtx_ring_size, 18696 (cmdline_parse_inst_t *)&cmd_config_rxtx_queue, 18697 (cmdline_parse_inst_t *)&cmd_config_deferred_start_rxtx_queue, 18698 (cmdline_parse_inst_t *)&cmd_setup_rxtx_queue, 18699 (cmdline_parse_inst_t *)&cmd_config_rss_reta, 18700 (cmdline_parse_inst_t *)&cmd_showport_reta, 18701 (cmdline_parse_inst_t *)&cmd_config_burst, 18702 (cmdline_parse_inst_t *)&cmd_config_thresh, 18703 (cmdline_parse_inst_t *)&cmd_config_threshold, 18704 (cmdline_parse_inst_t *)&cmd_set_uc_hash_filter, 18705 (cmdline_parse_inst_t *)&cmd_set_uc_all_hash_filter, 18706 (cmdline_parse_inst_t *)&cmd_vf_mac_addr_filter, 18707 (cmdline_parse_inst_t *)&cmd_set_vf_macvlan_filter, 18708 (cmdline_parse_inst_t *)&cmd_queue_rate_limit, 18709 (cmdline_parse_inst_t *)&cmd_tunnel_filter, 18710 (cmdline_parse_inst_t *)&cmd_tunnel_udp_config, 18711 (cmdline_parse_inst_t *)&cmd_global_config, 18712 (cmdline_parse_inst_t *)&cmd_set_mirror_mask, 18713 (cmdline_parse_inst_t *)&cmd_set_mirror_link, 18714 (cmdline_parse_inst_t *)&cmd_reset_mirror_rule, 18715 (cmdline_parse_inst_t *)&cmd_showport_rss_hash, 18716 (cmdline_parse_inst_t *)&cmd_showport_rss_hash_key, 18717 (cmdline_parse_inst_t *)&cmd_config_rss_hash_key, 18718 (cmdline_parse_inst_t *)&cmd_dump, 18719 (cmdline_parse_inst_t *)&cmd_dump_one, 18720 (cmdline_parse_inst_t *)&cmd_ethertype_filter, 18721 (cmdline_parse_inst_t *)&cmd_syn_filter, 18722 (cmdline_parse_inst_t *)&cmd_2tuple_filter, 18723 (cmdline_parse_inst_t *)&cmd_5tuple_filter, 18724 (cmdline_parse_inst_t *)&cmd_flex_filter, 18725 (cmdline_parse_inst_t *)&cmd_add_del_ip_flow_director, 18726 (cmdline_parse_inst_t *)&cmd_add_del_udp_flow_director, 18727 (cmdline_parse_inst_t *)&cmd_add_del_sctp_flow_director, 18728 (cmdline_parse_inst_t *)&cmd_add_del_l2_flow_director, 18729 (cmdline_parse_inst_t *)&cmd_add_del_mac_vlan_flow_director, 18730 (cmdline_parse_inst_t *)&cmd_add_del_tunnel_flow_director, 18731 (cmdline_parse_inst_t *)&cmd_add_del_raw_flow_director, 18732 (cmdline_parse_inst_t *)&cmd_flush_flow_director, 18733 (cmdline_parse_inst_t *)&cmd_set_flow_director_ip_mask, 18734 (cmdline_parse_inst_t *)&cmd_set_flow_director_mac_vlan_mask, 18735 (cmdline_parse_inst_t *)&cmd_set_flow_director_tunnel_mask, 18736 (cmdline_parse_inst_t *)&cmd_set_flow_director_flex_mask, 18737 (cmdline_parse_inst_t *)&cmd_set_flow_director_flex_payload, 18738 (cmdline_parse_inst_t *)&cmd_get_sym_hash_ena_per_port, 18739 (cmdline_parse_inst_t *)&cmd_set_sym_hash_ena_per_port, 18740 (cmdline_parse_inst_t *)&cmd_get_hash_global_config, 18741 (cmdline_parse_inst_t *)&cmd_set_hash_global_config, 18742 (cmdline_parse_inst_t *)&cmd_set_hash_input_set, 18743 (cmdline_parse_inst_t *)&cmd_set_fdir_input_set, 18744 (cmdline_parse_inst_t *)&cmd_flow, 18745 (cmdline_parse_inst_t *)&cmd_show_port_meter_cap, 18746 (cmdline_parse_inst_t *)&cmd_add_port_meter_profile_srtcm, 18747 (cmdline_parse_inst_t *)&cmd_add_port_meter_profile_trtcm, 18748 (cmdline_parse_inst_t *)&cmd_del_port_meter_profile, 18749 (cmdline_parse_inst_t *)&cmd_create_port_meter, 18750 (cmdline_parse_inst_t *)&cmd_enable_port_meter, 18751 (cmdline_parse_inst_t *)&cmd_disable_port_meter, 18752 (cmdline_parse_inst_t *)&cmd_del_port_meter, 18753 (cmdline_parse_inst_t *)&cmd_set_port_meter_profile, 18754 (cmdline_parse_inst_t *)&cmd_set_port_meter_dscp_table, 18755 (cmdline_parse_inst_t *)&cmd_set_port_meter_policer_action, 18756 (cmdline_parse_inst_t *)&cmd_set_port_meter_stats_mask, 18757 (cmdline_parse_inst_t *)&cmd_show_port_meter_stats, 18758 (cmdline_parse_inst_t *)&cmd_mcast_addr, 18759 (cmdline_parse_inst_t *)&cmd_config_l2_tunnel_eth_type_all, 18760 (cmdline_parse_inst_t *)&cmd_config_l2_tunnel_eth_type_specific, 18761 (cmdline_parse_inst_t *)&cmd_config_l2_tunnel_en_dis_all, 18762 (cmdline_parse_inst_t *)&cmd_config_l2_tunnel_en_dis_specific, 18763 (cmdline_parse_inst_t *)&cmd_config_e_tag_insertion_en, 18764 (cmdline_parse_inst_t *)&cmd_config_e_tag_insertion_dis, 18765 (cmdline_parse_inst_t *)&cmd_config_e_tag_stripping_en_dis, 18766 (cmdline_parse_inst_t *)&cmd_config_e_tag_forwarding_en_dis, 18767 (cmdline_parse_inst_t *)&cmd_config_e_tag_filter_add, 18768 (cmdline_parse_inst_t *)&cmd_config_e_tag_filter_del, 18769 (cmdline_parse_inst_t *)&cmd_set_vf_vlan_anti_spoof, 18770 (cmdline_parse_inst_t *)&cmd_set_vf_mac_anti_spoof, 18771 (cmdline_parse_inst_t *)&cmd_set_vf_vlan_stripq, 18772 (cmdline_parse_inst_t *)&cmd_set_vf_vlan_insert, 18773 (cmdline_parse_inst_t *)&cmd_set_tx_loopback, 18774 (cmdline_parse_inst_t *)&cmd_set_all_queues_drop_en, 18775 (cmdline_parse_inst_t *)&cmd_set_vf_split_drop_en, 18776 (cmdline_parse_inst_t *)&cmd_set_macsec_offload_on, 18777 (cmdline_parse_inst_t *)&cmd_set_macsec_offload_off, 18778 (cmdline_parse_inst_t *)&cmd_set_macsec_sc, 18779 (cmdline_parse_inst_t *)&cmd_set_macsec_sa, 18780 (cmdline_parse_inst_t *)&cmd_set_vf_traffic, 18781 (cmdline_parse_inst_t *)&cmd_set_vf_rxmode, 18782 (cmdline_parse_inst_t *)&cmd_vf_rate_limit, 18783 (cmdline_parse_inst_t *)&cmd_vf_rxvlan_filter, 18784 (cmdline_parse_inst_t *)&cmd_set_vf_mac_addr, 18785 (cmdline_parse_inst_t *)&cmd_set_vf_promisc, 18786 (cmdline_parse_inst_t *)&cmd_set_vf_allmulti, 18787 (cmdline_parse_inst_t *)&cmd_set_vf_broadcast, 18788 (cmdline_parse_inst_t *)&cmd_set_vf_vlan_tag, 18789 (cmdline_parse_inst_t *)&cmd_vf_max_bw, 18790 (cmdline_parse_inst_t *)&cmd_vf_tc_min_bw, 18791 (cmdline_parse_inst_t *)&cmd_vf_tc_max_bw, 18792 (cmdline_parse_inst_t *)&cmd_strict_link_prio, 18793 (cmdline_parse_inst_t *)&cmd_tc_min_bw, 18794 #if defined RTE_LIBRTE_PMD_SOFTNIC && defined RTE_LIBRTE_SCHED 18795 (cmdline_parse_inst_t *)&cmd_set_port_tm_hierarchy_default, 18796 #endif 18797 (cmdline_parse_inst_t *)&cmd_set_vxlan, 18798 (cmdline_parse_inst_t *)&cmd_set_vxlan_with_vlan, 18799 (cmdline_parse_inst_t *)&cmd_set_nvgre, 18800 (cmdline_parse_inst_t *)&cmd_set_nvgre_with_vlan, 18801 (cmdline_parse_inst_t *)&cmd_set_l2_encap, 18802 (cmdline_parse_inst_t *)&cmd_set_l2_encap_with_vlan, 18803 (cmdline_parse_inst_t *)&cmd_set_l2_decap, 18804 (cmdline_parse_inst_t *)&cmd_set_l2_decap_with_vlan, 18805 (cmdline_parse_inst_t *)&cmd_set_mplsogre_encap, 18806 (cmdline_parse_inst_t *)&cmd_set_mplsogre_encap_with_vlan, 18807 (cmdline_parse_inst_t *)&cmd_set_mplsogre_decap, 18808 (cmdline_parse_inst_t *)&cmd_set_mplsogre_decap_with_vlan, 18809 (cmdline_parse_inst_t *)&cmd_set_mplsoudp_encap, 18810 (cmdline_parse_inst_t *)&cmd_set_mplsoudp_encap_with_vlan, 18811 (cmdline_parse_inst_t *)&cmd_set_mplsoudp_decap, 18812 (cmdline_parse_inst_t *)&cmd_set_mplsoudp_decap_with_vlan, 18813 (cmdline_parse_inst_t *)&cmd_ddp_add, 18814 (cmdline_parse_inst_t *)&cmd_ddp_del, 18815 (cmdline_parse_inst_t *)&cmd_ddp_get_list, 18816 (cmdline_parse_inst_t *)&cmd_ddp_get_info, 18817 (cmdline_parse_inst_t *)&cmd_cfg_input_set, 18818 (cmdline_parse_inst_t *)&cmd_clear_input_set, 18819 (cmdline_parse_inst_t *)&cmd_show_vf_stats, 18820 (cmdline_parse_inst_t *)&cmd_clear_vf_stats, 18821 (cmdline_parse_inst_t *)&cmd_ptype_mapping_get, 18822 (cmdline_parse_inst_t *)&cmd_ptype_mapping_replace, 18823 (cmdline_parse_inst_t *)&cmd_ptype_mapping_reset, 18824 (cmdline_parse_inst_t *)&cmd_ptype_mapping_update, 18825 18826 (cmdline_parse_inst_t *)&cmd_pctype_mapping_get, 18827 (cmdline_parse_inst_t *)&cmd_pctype_mapping_reset, 18828 (cmdline_parse_inst_t *)&cmd_pctype_mapping_update, 18829 (cmdline_parse_inst_t *)&cmd_queue_region, 18830 (cmdline_parse_inst_t *)&cmd_region_flowtype, 18831 (cmdline_parse_inst_t *)&cmd_user_priority_region, 18832 (cmdline_parse_inst_t *)&cmd_flush_queue_region, 18833 (cmdline_parse_inst_t *)&cmd_show_queue_region_info_all, 18834 (cmdline_parse_inst_t *)&cmd_show_port_tm_cap, 18835 (cmdline_parse_inst_t *)&cmd_show_port_tm_level_cap, 18836 (cmdline_parse_inst_t *)&cmd_show_port_tm_node_cap, 18837 (cmdline_parse_inst_t *)&cmd_show_port_tm_node_type, 18838 (cmdline_parse_inst_t *)&cmd_show_port_tm_node_stats, 18839 (cmdline_parse_inst_t *)&cmd_add_port_tm_node_shaper_profile, 18840 (cmdline_parse_inst_t *)&cmd_del_port_tm_node_shaper_profile, 18841 (cmdline_parse_inst_t *)&cmd_add_port_tm_node_shared_shaper, 18842 (cmdline_parse_inst_t *)&cmd_del_port_tm_node_shared_shaper, 18843 (cmdline_parse_inst_t *)&cmd_add_port_tm_node_wred_profile, 18844 (cmdline_parse_inst_t *)&cmd_del_port_tm_node_wred_profile, 18845 (cmdline_parse_inst_t *)&cmd_set_port_tm_node_shaper_profile, 18846 (cmdline_parse_inst_t *)&cmd_add_port_tm_nonleaf_node, 18847 (cmdline_parse_inst_t *)&cmd_add_port_tm_leaf_node, 18848 (cmdline_parse_inst_t *)&cmd_del_port_tm_node, 18849 (cmdline_parse_inst_t *)&cmd_set_port_tm_node_parent, 18850 (cmdline_parse_inst_t *)&cmd_suspend_port_tm_node, 18851 (cmdline_parse_inst_t *)&cmd_resume_port_tm_node, 18852 (cmdline_parse_inst_t *)&cmd_port_tm_hierarchy_commit, 18853 (cmdline_parse_inst_t *)&cmd_port_tm_mark_ip_ecn, 18854 (cmdline_parse_inst_t *)&cmd_port_tm_mark_ip_dscp, 18855 (cmdline_parse_inst_t *)&cmd_port_tm_mark_vlan_dei, 18856 (cmdline_parse_inst_t *)&cmd_cfg_tunnel_udp_port, 18857 (cmdline_parse_inst_t *)&cmd_rx_offload_get_capa, 18858 (cmdline_parse_inst_t *)&cmd_rx_offload_get_configuration, 18859 (cmdline_parse_inst_t *)&cmd_config_per_port_rx_offload, 18860 (cmdline_parse_inst_t *)&cmd_config_per_queue_rx_offload, 18861 (cmdline_parse_inst_t *)&cmd_tx_offload_get_capa, 18862 (cmdline_parse_inst_t *)&cmd_tx_offload_get_configuration, 18863 (cmdline_parse_inst_t *)&cmd_config_per_port_tx_offload, 18864 (cmdline_parse_inst_t *)&cmd_config_per_queue_tx_offload, 18865 #ifdef RTE_LIBRTE_BPF 18866 (cmdline_parse_inst_t *)&cmd_operate_bpf_ld_parse, 18867 (cmdline_parse_inst_t *)&cmd_operate_bpf_unld_parse, 18868 #endif 18869 (cmdline_parse_inst_t *)&cmd_config_tx_metadata_specific, 18870 (cmdline_parse_inst_t *)&cmd_show_tx_metadata, 18871 NULL, 18872 }; 18873 18874 /* read cmdline commands from file */ 18875 void 18876 cmdline_read_from_file(const char *filename) 18877 { 18878 struct cmdline *cl; 18879 18880 cl = cmdline_file_new(main_ctx, "testpmd> ", filename); 18881 if (cl == NULL) { 18882 printf("Failed to create file based cmdline context: %s\n", 18883 filename); 18884 return; 18885 } 18886 18887 cmdline_interact(cl); 18888 cmdline_quit(cl); 18889 18890 cmdline_free(cl); 18891 18892 printf("Read CLI commands from %s\n", filename); 18893 } 18894 18895 /* prompt function, called from main on MASTER lcore */ 18896 void 18897 prompt(void) 18898 { 18899 /* initialize non-constant commands */ 18900 cmd_set_fwd_mode_init(); 18901 cmd_set_fwd_retry_mode_init(); 18902 18903 testpmd_cl = cmdline_stdin_new(main_ctx, "testpmd> "); 18904 if (testpmd_cl == NULL) 18905 return; 18906 cmdline_interact(testpmd_cl); 18907 cmdline_stdin_exit(testpmd_cl); 18908 } 18909 18910 void 18911 prompt_exit(void) 18912 { 18913 if (testpmd_cl != NULL) 18914 cmdline_quit(testpmd_cl); 18915 } 18916 18917 static void 18918 cmd_reconfig_device_queue(portid_t id, uint8_t dev, uint8_t queue) 18919 { 18920 if (id == (portid_t)RTE_PORT_ALL) { 18921 portid_t pid; 18922 18923 RTE_ETH_FOREACH_DEV(pid) { 18924 /* check if need_reconfig has been set to 1 */ 18925 if (ports[pid].need_reconfig == 0) 18926 ports[pid].need_reconfig = dev; 18927 /* check if need_reconfig_queues has been set to 1 */ 18928 if (ports[pid].need_reconfig_queues == 0) 18929 ports[pid].need_reconfig_queues = queue; 18930 } 18931 } else if (!port_id_is_invalid(id, DISABLED_WARN)) { 18932 /* check if need_reconfig has been set to 1 */ 18933 if (ports[id].need_reconfig == 0) 18934 ports[id].need_reconfig = dev; 18935 /* check if need_reconfig_queues has been set to 1 */ 18936 if (ports[id].need_reconfig_queues == 0) 18937 ports[id].need_reconfig_queues = queue; 18938 } 18939 } 18940