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 int k; 2046 2047 if (!all_ports_stopped()) { 2048 printf("Please stop all ports first\n"); 2049 return; 2050 } 2051 2052 RTE_ETH_FOREACH_DEV(pid) { 2053 struct rte_port *port; 2054 uint64_t rx_offloads; 2055 2056 port = &ports[pid]; 2057 rx_offloads = port->dev_conf.rxmode.offloads; 2058 if (!strcmp(res->name, "crc-strip")) { 2059 if (!strcmp(res->value, "on")) { 2060 rx_offloads &= ~DEV_RX_OFFLOAD_KEEP_CRC; 2061 } else if (!strcmp(res->value, "off")) { 2062 rx_offloads |= DEV_RX_OFFLOAD_KEEP_CRC; 2063 } else { 2064 printf("Unknown parameter\n"); 2065 return; 2066 } 2067 } else if (!strcmp(res->name, "scatter")) { 2068 if (!strcmp(res->value, "on")) { 2069 rx_offloads |= DEV_RX_OFFLOAD_SCATTER; 2070 } else if (!strcmp(res->value, "off")) { 2071 rx_offloads &= ~DEV_RX_OFFLOAD_SCATTER; 2072 } else { 2073 printf("Unknown parameter\n"); 2074 return; 2075 } 2076 } else if (!strcmp(res->name, "rx-cksum")) { 2077 if (!strcmp(res->value, "on")) 2078 rx_offloads |= DEV_RX_OFFLOAD_CHECKSUM; 2079 else if (!strcmp(res->value, "off")) 2080 rx_offloads &= ~DEV_RX_OFFLOAD_CHECKSUM; 2081 else { 2082 printf("Unknown parameter\n"); 2083 return; 2084 } 2085 } else if (!strcmp(res->name, "rx-timestamp")) { 2086 if (!strcmp(res->value, "on")) 2087 rx_offloads |= DEV_RX_OFFLOAD_TIMESTAMP; 2088 else if (!strcmp(res->value, "off")) 2089 rx_offloads &= ~DEV_RX_OFFLOAD_TIMESTAMP; 2090 else { 2091 printf("Unknown parameter\n"); 2092 return; 2093 } 2094 } else if (!strcmp(res->name, "hw-vlan")) { 2095 if (!strcmp(res->value, "on")) { 2096 rx_offloads |= (DEV_RX_OFFLOAD_VLAN_FILTER | 2097 DEV_RX_OFFLOAD_VLAN_STRIP); 2098 } else if (!strcmp(res->value, "off")) { 2099 rx_offloads &= ~(DEV_RX_OFFLOAD_VLAN_FILTER | 2100 DEV_RX_OFFLOAD_VLAN_STRIP); 2101 } else { 2102 printf("Unknown parameter\n"); 2103 return; 2104 } 2105 } else if (!strcmp(res->name, "hw-vlan-filter")) { 2106 if (!strcmp(res->value, "on")) 2107 rx_offloads |= DEV_RX_OFFLOAD_VLAN_FILTER; 2108 else if (!strcmp(res->value, "off")) 2109 rx_offloads &= ~DEV_RX_OFFLOAD_VLAN_FILTER; 2110 else { 2111 printf("Unknown parameter\n"); 2112 return; 2113 } 2114 } else if (!strcmp(res->name, "hw-vlan-strip")) { 2115 if (!strcmp(res->value, "on")) 2116 rx_offloads |= DEV_RX_OFFLOAD_VLAN_STRIP; 2117 else if (!strcmp(res->value, "off")) 2118 rx_offloads &= ~DEV_RX_OFFLOAD_VLAN_STRIP; 2119 else { 2120 printf("Unknown parameter\n"); 2121 return; 2122 } 2123 } else if (!strcmp(res->name, "hw-vlan-extend")) { 2124 if (!strcmp(res->value, "on")) 2125 rx_offloads |= DEV_RX_OFFLOAD_VLAN_EXTEND; 2126 else if (!strcmp(res->value, "off")) 2127 rx_offloads &= ~DEV_RX_OFFLOAD_VLAN_EXTEND; 2128 else { 2129 printf("Unknown parameter\n"); 2130 return; 2131 } 2132 } else if (!strcmp(res->name, "drop-en")) { 2133 if (!strcmp(res->value, "on")) 2134 rx_drop_en = 1; 2135 else if (!strcmp(res->value, "off")) 2136 rx_drop_en = 0; 2137 else { 2138 printf("Unknown parameter\n"); 2139 return; 2140 } 2141 } else { 2142 printf("Unknown parameter\n"); 2143 return; 2144 } 2145 port->dev_conf.rxmode.offloads = rx_offloads; 2146 /* Apply Rx offloads configuration */ 2147 for (k = 0; k < port->dev_info.max_rx_queues; k++) 2148 port->rx_conf[k].offloads = 2149 port->dev_conf.rxmode.offloads; 2150 } 2151 2152 init_port_config(); 2153 2154 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1); 2155 } 2156 2157 cmdline_parse_token_string_t cmd_config_rx_mode_flag_port = 2158 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_mode_flag, port, "port"); 2159 cmdline_parse_token_string_t cmd_config_rx_mode_flag_keyword = 2160 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_mode_flag, keyword, 2161 "config"); 2162 cmdline_parse_token_string_t cmd_config_rx_mode_flag_all = 2163 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_mode_flag, all, "all"); 2164 cmdline_parse_token_string_t cmd_config_rx_mode_flag_name = 2165 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_mode_flag, name, 2166 "crc-strip#scatter#rx-cksum#rx-timestamp#hw-vlan#" 2167 "hw-vlan-filter#hw-vlan-strip#hw-vlan-extend"); 2168 cmdline_parse_token_string_t cmd_config_rx_mode_flag_value = 2169 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_mode_flag, value, 2170 "on#off"); 2171 2172 cmdline_parse_inst_t cmd_config_rx_mode_flag = { 2173 .f = cmd_config_rx_mode_flag_parsed, 2174 .data = NULL, 2175 .help_str = "port config all crc-strip|scatter|rx-cksum|rx-timestamp|hw-vlan|" 2176 "hw-vlan-filter|hw-vlan-strip|hw-vlan-extend on|off", 2177 .tokens = { 2178 (void *)&cmd_config_rx_mode_flag_port, 2179 (void *)&cmd_config_rx_mode_flag_keyword, 2180 (void *)&cmd_config_rx_mode_flag_all, 2181 (void *)&cmd_config_rx_mode_flag_name, 2182 (void *)&cmd_config_rx_mode_flag_value, 2183 NULL, 2184 }, 2185 }; 2186 2187 /* *** configure rss *** */ 2188 struct cmd_config_rss { 2189 cmdline_fixed_string_t port; 2190 cmdline_fixed_string_t keyword; 2191 cmdline_fixed_string_t all; 2192 cmdline_fixed_string_t name; 2193 cmdline_fixed_string_t value; 2194 }; 2195 2196 static void 2197 cmd_config_rss_parsed(void *parsed_result, 2198 __attribute__((unused)) struct cmdline *cl, 2199 __attribute__((unused)) void *data) 2200 { 2201 struct cmd_config_rss *res = parsed_result; 2202 struct rte_eth_rss_conf rss_conf = { .rss_key_len = 0, }; 2203 struct rte_eth_dev_info dev_info = { .flow_type_rss_offloads = 0, }; 2204 int use_default = 0; 2205 int all_updated = 1; 2206 int diag; 2207 uint16_t i; 2208 2209 if (!strcmp(res->value, "all")) 2210 rss_conf.rss_hf = ETH_RSS_IP | ETH_RSS_TCP | 2211 ETH_RSS_UDP | ETH_RSS_SCTP | 2212 ETH_RSS_L2_PAYLOAD; 2213 else if (!strcmp(res->value, "ip")) 2214 rss_conf.rss_hf = ETH_RSS_IP; 2215 else if (!strcmp(res->value, "udp")) 2216 rss_conf.rss_hf = ETH_RSS_UDP; 2217 else if (!strcmp(res->value, "tcp")) 2218 rss_conf.rss_hf = ETH_RSS_TCP; 2219 else if (!strcmp(res->value, "sctp")) 2220 rss_conf.rss_hf = ETH_RSS_SCTP; 2221 else if (!strcmp(res->value, "ether")) 2222 rss_conf.rss_hf = ETH_RSS_L2_PAYLOAD; 2223 else if (!strcmp(res->value, "port")) 2224 rss_conf.rss_hf = ETH_RSS_PORT; 2225 else if (!strcmp(res->value, "vxlan")) 2226 rss_conf.rss_hf = ETH_RSS_VXLAN; 2227 else if (!strcmp(res->value, "geneve")) 2228 rss_conf.rss_hf = ETH_RSS_GENEVE; 2229 else if (!strcmp(res->value, "nvgre")) 2230 rss_conf.rss_hf = ETH_RSS_NVGRE; 2231 else if (!strcmp(res->value, "none")) 2232 rss_conf.rss_hf = 0; 2233 else if (!strcmp(res->value, "default")) 2234 use_default = 1; 2235 else if (isdigit(res->value[0]) && atoi(res->value) > 0 && 2236 atoi(res->value) < 64) 2237 rss_conf.rss_hf = 1ULL << atoi(res->value); 2238 else { 2239 printf("Unknown parameter\n"); 2240 return; 2241 } 2242 rss_conf.rss_key = NULL; 2243 /* Update global configuration for RSS types. */ 2244 RTE_ETH_FOREACH_DEV(i) { 2245 struct rte_eth_rss_conf local_rss_conf; 2246 2247 rte_eth_dev_info_get(i, &dev_info); 2248 if (use_default) 2249 rss_conf.rss_hf = dev_info.flow_type_rss_offloads; 2250 2251 local_rss_conf = rss_conf; 2252 local_rss_conf.rss_hf = rss_conf.rss_hf & 2253 dev_info.flow_type_rss_offloads; 2254 if (local_rss_conf.rss_hf != rss_conf.rss_hf) { 2255 printf("Port %u modified RSS hash function based on hardware support," 2256 "requested:%#"PRIx64" configured:%#"PRIx64"\n", 2257 i, rss_conf.rss_hf, local_rss_conf.rss_hf); 2258 } 2259 diag = rte_eth_dev_rss_hash_update(i, &local_rss_conf); 2260 if (diag < 0) { 2261 all_updated = 0; 2262 printf("Configuration of RSS hash at ethernet port %d " 2263 "failed with error (%d): %s.\n", 2264 i, -diag, strerror(-diag)); 2265 } 2266 } 2267 if (all_updated && !use_default) 2268 rss_hf = rss_conf.rss_hf; 2269 } 2270 2271 cmdline_parse_token_string_t cmd_config_rss_port = 2272 TOKEN_STRING_INITIALIZER(struct cmd_config_rss, port, "port"); 2273 cmdline_parse_token_string_t cmd_config_rss_keyword = 2274 TOKEN_STRING_INITIALIZER(struct cmd_config_rss, keyword, "config"); 2275 cmdline_parse_token_string_t cmd_config_rss_all = 2276 TOKEN_STRING_INITIALIZER(struct cmd_config_rss, all, "all"); 2277 cmdline_parse_token_string_t cmd_config_rss_name = 2278 TOKEN_STRING_INITIALIZER(struct cmd_config_rss, name, "rss"); 2279 cmdline_parse_token_string_t cmd_config_rss_value = 2280 TOKEN_STRING_INITIALIZER(struct cmd_config_rss, value, NULL); 2281 2282 cmdline_parse_inst_t cmd_config_rss = { 2283 .f = cmd_config_rss_parsed, 2284 .data = NULL, 2285 .help_str = "port config all rss " 2286 "all|default|ip|tcp|udp|sctp|ether|port|vxlan|geneve|nvgre|none|<flowtype_id>", 2287 .tokens = { 2288 (void *)&cmd_config_rss_port, 2289 (void *)&cmd_config_rss_keyword, 2290 (void *)&cmd_config_rss_all, 2291 (void *)&cmd_config_rss_name, 2292 (void *)&cmd_config_rss_value, 2293 NULL, 2294 }, 2295 }; 2296 2297 /* *** configure rss hash key *** */ 2298 struct cmd_config_rss_hash_key { 2299 cmdline_fixed_string_t port; 2300 cmdline_fixed_string_t config; 2301 portid_t port_id; 2302 cmdline_fixed_string_t rss_hash_key; 2303 cmdline_fixed_string_t rss_type; 2304 cmdline_fixed_string_t key; 2305 }; 2306 2307 static uint8_t 2308 hexa_digit_to_value(char hexa_digit) 2309 { 2310 if ((hexa_digit >= '0') && (hexa_digit <= '9')) 2311 return (uint8_t) (hexa_digit - '0'); 2312 if ((hexa_digit >= 'a') && (hexa_digit <= 'f')) 2313 return (uint8_t) ((hexa_digit - 'a') + 10); 2314 if ((hexa_digit >= 'A') && (hexa_digit <= 'F')) 2315 return (uint8_t) ((hexa_digit - 'A') + 10); 2316 /* Invalid hexa digit */ 2317 return 0xFF; 2318 } 2319 2320 static uint8_t 2321 parse_and_check_key_hexa_digit(char *key, int idx) 2322 { 2323 uint8_t hexa_v; 2324 2325 hexa_v = hexa_digit_to_value(key[idx]); 2326 if (hexa_v == 0xFF) 2327 printf("invalid key: character %c at position %d is not a " 2328 "valid hexa digit\n", key[idx], idx); 2329 return hexa_v; 2330 } 2331 2332 static void 2333 cmd_config_rss_hash_key_parsed(void *parsed_result, 2334 __attribute__((unused)) struct cmdline *cl, 2335 __attribute__((unused)) void *data) 2336 { 2337 struct cmd_config_rss_hash_key *res = parsed_result; 2338 uint8_t hash_key[RSS_HASH_KEY_LENGTH]; 2339 uint8_t xdgt0; 2340 uint8_t xdgt1; 2341 int i; 2342 struct rte_eth_dev_info dev_info; 2343 uint8_t hash_key_size; 2344 uint32_t key_len; 2345 2346 memset(&dev_info, 0, sizeof(dev_info)); 2347 rte_eth_dev_info_get(res->port_id, &dev_info); 2348 if (dev_info.hash_key_size > 0 && 2349 dev_info.hash_key_size <= sizeof(hash_key)) 2350 hash_key_size = dev_info.hash_key_size; 2351 else { 2352 printf("dev_info did not provide a valid hash key size\n"); 2353 return; 2354 } 2355 /* Check the length of the RSS hash key */ 2356 key_len = strlen(res->key); 2357 if (key_len != (hash_key_size * 2)) { 2358 printf("key length: %d invalid - key must be a string of %d" 2359 " hexa-decimal numbers\n", 2360 (int) key_len, hash_key_size * 2); 2361 return; 2362 } 2363 /* Translate RSS hash key into binary representation */ 2364 for (i = 0; i < hash_key_size; i++) { 2365 xdgt0 = parse_and_check_key_hexa_digit(res->key, (i * 2)); 2366 if (xdgt0 == 0xFF) 2367 return; 2368 xdgt1 = parse_and_check_key_hexa_digit(res->key, (i * 2) + 1); 2369 if (xdgt1 == 0xFF) 2370 return; 2371 hash_key[i] = (uint8_t) ((xdgt0 * 16) + xdgt1); 2372 } 2373 port_rss_hash_key_update(res->port_id, res->rss_type, hash_key, 2374 hash_key_size); 2375 } 2376 2377 cmdline_parse_token_string_t cmd_config_rss_hash_key_port = 2378 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_hash_key, port, "port"); 2379 cmdline_parse_token_string_t cmd_config_rss_hash_key_config = 2380 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_hash_key, config, 2381 "config"); 2382 cmdline_parse_token_num_t cmd_config_rss_hash_key_port_id = 2383 TOKEN_NUM_INITIALIZER(struct cmd_config_rss_hash_key, port_id, UINT16); 2384 cmdline_parse_token_string_t cmd_config_rss_hash_key_rss_hash_key = 2385 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_hash_key, 2386 rss_hash_key, "rss-hash-key"); 2387 cmdline_parse_token_string_t cmd_config_rss_hash_key_rss_type = 2388 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_hash_key, rss_type, 2389 "ipv4#ipv4-frag#ipv4-tcp#ipv4-udp#ipv4-sctp#" 2390 "ipv4-other#ipv6#ipv6-frag#ipv6-tcp#ipv6-udp#" 2391 "ipv6-sctp#ipv6-other#l2-payload#ipv6-ex#" 2392 "ipv6-tcp-ex#ipv6-udp-ex"); 2393 cmdline_parse_token_string_t cmd_config_rss_hash_key_value = 2394 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_hash_key, key, NULL); 2395 2396 cmdline_parse_inst_t cmd_config_rss_hash_key = { 2397 .f = cmd_config_rss_hash_key_parsed, 2398 .data = NULL, 2399 .help_str = "port config <port_id> rss-hash-key " 2400 "ipv4|ipv4-frag|ipv4-tcp|ipv4-udp|ipv4-sctp|ipv4-other|" 2401 "ipv6|ipv6-frag|ipv6-tcp|ipv6-udp|ipv6-sctp|ipv6-other|" 2402 "l2-payload|ipv6-ex|ipv6-tcp-ex|ipv6-udp-ex " 2403 "<string of hex digits (variable length, NIC dependent)>", 2404 .tokens = { 2405 (void *)&cmd_config_rss_hash_key_port, 2406 (void *)&cmd_config_rss_hash_key_config, 2407 (void *)&cmd_config_rss_hash_key_port_id, 2408 (void *)&cmd_config_rss_hash_key_rss_hash_key, 2409 (void *)&cmd_config_rss_hash_key_rss_type, 2410 (void *)&cmd_config_rss_hash_key_value, 2411 NULL, 2412 }, 2413 }; 2414 2415 /* *** configure port rxq/txq ring size *** */ 2416 struct cmd_config_rxtx_ring_size { 2417 cmdline_fixed_string_t port; 2418 cmdline_fixed_string_t config; 2419 portid_t portid; 2420 cmdline_fixed_string_t rxtxq; 2421 uint16_t qid; 2422 cmdline_fixed_string_t rsize; 2423 uint16_t size; 2424 }; 2425 2426 static void 2427 cmd_config_rxtx_ring_size_parsed(void *parsed_result, 2428 __attribute__((unused)) struct cmdline *cl, 2429 __attribute__((unused)) void *data) 2430 { 2431 struct cmd_config_rxtx_ring_size *res = parsed_result; 2432 struct rte_port *port; 2433 uint8_t isrx; 2434 2435 if (port_id_is_invalid(res->portid, ENABLED_WARN)) 2436 return; 2437 2438 if (res->portid == (portid_t)RTE_PORT_ALL) { 2439 printf("Invalid port id\n"); 2440 return; 2441 } 2442 2443 port = &ports[res->portid]; 2444 2445 if (!strcmp(res->rxtxq, "rxq")) 2446 isrx = 1; 2447 else if (!strcmp(res->rxtxq, "txq")) 2448 isrx = 0; 2449 else { 2450 printf("Unknown parameter\n"); 2451 return; 2452 } 2453 2454 if (isrx && rx_queue_id_is_invalid(res->qid)) 2455 return; 2456 else if (!isrx && tx_queue_id_is_invalid(res->qid)) 2457 return; 2458 2459 if (isrx && res->size != 0 && res->size <= rx_free_thresh) { 2460 printf("Invalid rx ring_size, must > rx_free_thresh: %d\n", 2461 rx_free_thresh); 2462 return; 2463 } 2464 2465 if (isrx) 2466 port->nb_rx_desc[res->qid] = res->size; 2467 else 2468 port->nb_tx_desc[res->qid] = res->size; 2469 2470 cmd_reconfig_device_queue(res->portid, 0, 1); 2471 } 2472 2473 cmdline_parse_token_string_t cmd_config_rxtx_ring_size_port = 2474 TOKEN_STRING_INITIALIZER(struct cmd_config_rxtx_ring_size, 2475 port, "port"); 2476 cmdline_parse_token_string_t cmd_config_rxtx_ring_size_config = 2477 TOKEN_STRING_INITIALIZER(struct cmd_config_rxtx_ring_size, 2478 config, "config"); 2479 cmdline_parse_token_num_t cmd_config_rxtx_ring_size_portid = 2480 TOKEN_NUM_INITIALIZER(struct cmd_config_rxtx_ring_size, 2481 portid, UINT16); 2482 cmdline_parse_token_string_t cmd_config_rxtx_ring_size_rxtxq = 2483 TOKEN_STRING_INITIALIZER(struct cmd_config_rxtx_ring_size, 2484 rxtxq, "rxq#txq"); 2485 cmdline_parse_token_num_t cmd_config_rxtx_ring_size_qid = 2486 TOKEN_NUM_INITIALIZER(struct cmd_config_rxtx_ring_size, 2487 qid, UINT16); 2488 cmdline_parse_token_string_t cmd_config_rxtx_ring_size_rsize = 2489 TOKEN_STRING_INITIALIZER(struct cmd_config_rxtx_ring_size, 2490 rsize, "ring_size"); 2491 cmdline_parse_token_num_t cmd_config_rxtx_ring_size_size = 2492 TOKEN_NUM_INITIALIZER(struct cmd_config_rxtx_ring_size, 2493 size, UINT16); 2494 2495 cmdline_parse_inst_t cmd_config_rxtx_ring_size = { 2496 .f = cmd_config_rxtx_ring_size_parsed, 2497 .data = NULL, 2498 .help_str = "port config <port_id> rxq|txq <queue_id> ring_size <value>", 2499 .tokens = { 2500 (void *)&cmd_config_rxtx_ring_size_port, 2501 (void *)&cmd_config_rxtx_ring_size_config, 2502 (void *)&cmd_config_rxtx_ring_size_portid, 2503 (void *)&cmd_config_rxtx_ring_size_rxtxq, 2504 (void *)&cmd_config_rxtx_ring_size_qid, 2505 (void *)&cmd_config_rxtx_ring_size_rsize, 2506 (void *)&cmd_config_rxtx_ring_size_size, 2507 NULL, 2508 }, 2509 }; 2510 2511 /* *** configure port rxq/txq start/stop *** */ 2512 struct cmd_config_rxtx_queue { 2513 cmdline_fixed_string_t port; 2514 portid_t portid; 2515 cmdline_fixed_string_t rxtxq; 2516 uint16_t qid; 2517 cmdline_fixed_string_t opname; 2518 }; 2519 2520 static void 2521 cmd_config_rxtx_queue_parsed(void *parsed_result, 2522 __attribute__((unused)) struct cmdline *cl, 2523 __attribute__((unused)) void *data) 2524 { 2525 struct cmd_config_rxtx_queue *res = parsed_result; 2526 uint8_t isrx; 2527 uint8_t isstart; 2528 int ret = 0; 2529 2530 if (test_done == 0) { 2531 printf("Please stop forwarding first\n"); 2532 return; 2533 } 2534 2535 if (port_id_is_invalid(res->portid, ENABLED_WARN)) 2536 return; 2537 2538 if (port_is_started(res->portid) != 1) { 2539 printf("Please start port %u first\n", res->portid); 2540 return; 2541 } 2542 2543 if (!strcmp(res->rxtxq, "rxq")) 2544 isrx = 1; 2545 else if (!strcmp(res->rxtxq, "txq")) 2546 isrx = 0; 2547 else { 2548 printf("Unknown parameter\n"); 2549 return; 2550 } 2551 2552 if (isrx && rx_queue_id_is_invalid(res->qid)) 2553 return; 2554 else if (!isrx && tx_queue_id_is_invalid(res->qid)) 2555 return; 2556 2557 if (!strcmp(res->opname, "start")) 2558 isstart = 1; 2559 else if (!strcmp(res->opname, "stop")) 2560 isstart = 0; 2561 else { 2562 printf("Unknown parameter\n"); 2563 return; 2564 } 2565 2566 if (isstart && isrx) 2567 ret = rte_eth_dev_rx_queue_start(res->portid, res->qid); 2568 else if (!isstart && isrx) 2569 ret = rte_eth_dev_rx_queue_stop(res->portid, res->qid); 2570 else if (isstart && !isrx) 2571 ret = rte_eth_dev_tx_queue_start(res->portid, res->qid); 2572 else 2573 ret = rte_eth_dev_tx_queue_stop(res->portid, res->qid); 2574 2575 if (ret == -ENOTSUP) 2576 printf("Function not supported in PMD driver\n"); 2577 } 2578 2579 cmdline_parse_token_string_t cmd_config_rxtx_queue_port = 2580 TOKEN_STRING_INITIALIZER(struct cmd_config_rxtx_queue, port, "port"); 2581 cmdline_parse_token_num_t cmd_config_rxtx_queue_portid = 2582 TOKEN_NUM_INITIALIZER(struct cmd_config_rxtx_queue, portid, UINT16); 2583 cmdline_parse_token_string_t cmd_config_rxtx_queue_rxtxq = 2584 TOKEN_STRING_INITIALIZER(struct cmd_config_rxtx_queue, rxtxq, "rxq#txq"); 2585 cmdline_parse_token_num_t cmd_config_rxtx_queue_qid = 2586 TOKEN_NUM_INITIALIZER(struct cmd_config_rxtx_queue, qid, UINT16); 2587 cmdline_parse_token_string_t cmd_config_rxtx_queue_opname = 2588 TOKEN_STRING_INITIALIZER(struct cmd_config_rxtx_queue, opname, 2589 "start#stop"); 2590 2591 cmdline_parse_inst_t cmd_config_rxtx_queue = { 2592 .f = cmd_config_rxtx_queue_parsed, 2593 .data = NULL, 2594 .help_str = "port <port_id> rxq|txq <queue_id> start|stop", 2595 .tokens = { 2596 (void *)&cmd_config_rxtx_queue_port, 2597 (void *)&cmd_config_rxtx_queue_portid, 2598 (void *)&cmd_config_rxtx_queue_rxtxq, 2599 (void *)&cmd_config_rxtx_queue_qid, 2600 (void *)&cmd_config_rxtx_queue_opname, 2601 NULL, 2602 }, 2603 }; 2604 2605 /* *** configure port rxq/txq deferred start on/off *** */ 2606 struct cmd_config_deferred_start_rxtx_queue { 2607 cmdline_fixed_string_t port; 2608 portid_t port_id; 2609 cmdline_fixed_string_t rxtxq; 2610 uint16_t qid; 2611 cmdline_fixed_string_t opname; 2612 cmdline_fixed_string_t state; 2613 }; 2614 2615 static void 2616 cmd_config_deferred_start_rxtx_queue_parsed(void *parsed_result, 2617 __attribute__((unused)) struct cmdline *cl, 2618 __attribute__((unused)) void *data) 2619 { 2620 struct cmd_config_deferred_start_rxtx_queue *res = parsed_result; 2621 struct rte_port *port; 2622 uint8_t isrx; 2623 uint8_t ison; 2624 uint8_t needreconfig = 0; 2625 2626 if (port_id_is_invalid(res->port_id, ENABLED_WARN)) 2627 return; 2628 2629 if (port_is_started(res->port_id) != 0) { 2630 printf("Please stop port %u first\n", res->port_id); 2631 return; 2632 } 2633 2634 port = &ports[res->port_id]; 2635 2636 isrx = !strcmp(res->rxtxq, "rxq"); 2637 2638 if (isrx && rx_queue_id_is_invalid(res->qid)) 2639 return; 2640 else if (!isrx && tx_queue_id_is_invalid(res->qid)) 2641 return; 2642 2643 ison = !strcmp(res->state, "on"); 2644 2645 if (isrx && port->rx_conf[res->qid].rx_deferred_start != ison) { 2646 port->rx_conf[res->qid].rx_deferred_start = ison; 2647 needreconfig = 1; 2648 } else if (!isrx && port->tx_conf[res->qid].tx_deferred_start != ison) { 2649 port->tx_conf[res->qid].tx_deferred_start = ison; 2650 needreconfig = 1; 2651 } 2652 2653 if (needreconfig) 2654 cmd_reconfig_device_queue(res->port_id, 0, 1); 2655 } 2656 2657 cmdline_parse_token_string_t cmd_config_deferred_start_rxtx_queue_port = 2658 TOKEN_STRING_INITIALIZER(struct cmd_config_deferred_start_rxtx_queue, 2659 port, "port"); 2660 cmdline_parse_token_num_t cmd_config_deferred_start_rxtx_queue_port_id = 2661 TOKEN_NUM_INITIALIZER(struct cmd_config_deferred_start_rxtx_queue, 2662 port_id, UINT16); 2663 cmdline_parse_token_string_t cmd_config_deferred_start_rxtx_queue_rxtxq = 2664 TOKEN_STRING_INITIALIZER(struct cmd_config_deferred_start_rxtx_queue, 2665 rxtxq, "rxq#txq"); 2666 cmdline_parse_token_num_t cmd_config_deferred_start_rxtx_queue_qid = 2667 TOKEN_NUM_INITIALIZER(struct cmd_config_deferred_start_rxtx_queue, 2668 qid, UINT16); 2669 cmdline_parse_token_string_t cmd_config_deferred_start_rxtx_queue_opname = 2670 TOKEN_STRING_INITIALIZER(struct cmd_config_deferred_start_rxtx_queue, 2671 opname, "deferred_start"); 2672 cmdline_parse_token_string_t cmd_config_deferred_start_rxtx_queue_state = 2673 TOKEN_STRING_INITIALIZER(struct cmd_config_deferred_start_rxtx_queue, 2674 state, "on#off"); 2675 2676 cmdline_parse_inst_t cmd_config_deferred_start_rxtx_queue = { 2677 .f = cmd_config_deferred_start_rxtx_queue_parsed, 2678 .data = NULL, 2679 .help_str = "port <port_id> rxq|txq <queue_id> deferred_start on|off", 2680 .tokens = { 2681 (void *)&cmd_config_deferred_start_rxtx_queue_port, 2682 (void *)&cmd_config_deferred_start_rxtx_queue_port_id, 2683 (void *)&cmd_config_deferred_start_rxtx_queue_rxtxq, 2684 (void *)&cmd_config_deferred_start_rxtx_queue_qid, 2685 (void *)&cmd_config_deferred_start_rxtx_queue_opname, 2686 (void *)&cmd_config_deferred_start_rxtx_queue_state, 2687 NULL, 2688 }, 2689 }; 2690 2691 /* *** configure port rxq/txq setup *** */ 2692 struct cmd_setup_rxtx_queue { 2693 cmdline_fixed_string_t port; 2694 portid_t portid; 2695 cmdline_fixed_string_t rxtxq; 2696 uint16_t qid; 2697 cmdline_fixed_string_t setup; 2698 }; 2699 2700 /* Common CLI fields for queue setup */ 2701 cmdline_parse_token_string_t cmd_setup_rxtx_queue_port = 2702 TOKEN_STRING_INITIALIZER(struct cmd_setup_rxtx_queue, port, "port"); 2703 cmdline_parse_token_num_t cmd_setup_rxtx_queue_portid = 2704 TOKEN_NUM_INITIALIZER(struct cmd_setup_rxtx_queue, portid, UINT16); 2705 cmdline_parse_token_string_t cmd_setup_rxtx_queue_rxtxq = 2706 TOKEN_STRING_INITIALIZER(struct cmd_setup_rxtx_queue, rxtxq, "rxq#txq"); 2707 cmdline_parse_token_num_t cmd_setup_rxtx_queue_qid = 2708 TOKEN_NUM_INITIALIZER(struct cmd_setup_rxtx_queue, qid, UINT16); 2709 cmdline_parse_token_string_t cmd_setup_rxtx_queue_setup = 2710 TOKEN_STRING_INITIALIZER(struct cmd_setup_rxtx_queue, setup, "setup"); 2711 2712 static void 2713 cmd_setup_rxtx_queue_parsed( 2714 void *parsed_result, 2715 __attribute__((unused)) struct cmdline *cl, 2716 __attribute__((unused)) void *data) 2717 { 2718 struct cmd_setup_rxtx_queue *res = parsed_result; 2719 struct rte_port *port; 2720 struct rte_mempool *mp; 2721 unsigned int socket_id; 2722 uint8_t isrx = 0; 2723 int ret; 2724 2725 if (port_id_is_invalid(res->portid, ENABLED_WARN)) 2726 return; 2727 2728 if (res->portid == (portid_t)RTE_PORT_ALL) { 2729 printf("Invalid port id\n"); 2730 return; 2731 } 2732 2733 if (!strcmp(res->rxtxq, "rxq")) 2734 isrx = 1; 2735 else if (!strcmp(res->rxtxq, "txq")) 2736 isrx = 0; 2737 else { 2738 printf("Unknown parameter\n"); 2739 return; 2740 } 2741 2742 if (isrx && rx_queue_id_is_invalid(res->qid)) { 2743 printf("Invalid rx queue\n"); 2744 return; 2745 } else if (!isrx && tx_queue_id_is_invalid(res->qid)) { 2746 printf("Invalid tx queue\n"); 2747 return; 2748 } 2749 2750 port = &ports[res->portid]; 2751 if (isrx) { 2752 socket_id = rxring_numa[res->portid]; 2753 if (!numa_support || socket_id == NUMA_NO_CONFIG) 2754 socket_id = port->socket_id; 2755 2756 mp = mbuf_pool_find(socket_id); 2757 if (mp == NULL) { 2758 printf("Failed to setup RX queue: " 2759 "No mempool allocation" 2760 " on the socket %d\n", 2761 rxring_numa[res->portid]); 2762 return; 2763 } 2764 ret = rte_eth_rx_queue_setup(res->portid, 2765 res->qid, 2766 port->nb_rx_desc[res->qid], 2767 socket_id, 2768 &port->rx_conf[res->qid], 2769 mp); 2770 if (ret) 2771 printf("Failed to setup RX queue\n"); 2772 } else { 2773 socket_id = txring_numa[res->portid]; 2774 if (!numa_support || socket_id == NUMA_NO_CONFIG) 2775 socket_id = port->socket_id; 2776 2777 ret = rte_eth_tx_queue_setup(res->portid, 2778 res->qid, 2779 port->nb_tx_desc[res->qid], 2780 socket_id, 2781 &port->tx_conf[res->qid]); 2782 if (ret) 2783 printf("Failed to setup TX queue\n"); 2784 } 2785 } 2786 2787 cmdline_parse_inst_t cmd_setup_rxtx_queue = { 2788 .f = cmd_setup_rxtx_queue_parsed, 2789 .data = NULL, 2790 .help_str = "port <port_id> rxq|txq <queue_idx> setup", 2791 .tokens = { 2792 (void *)&cmd_setup_rxtx_queue_port, 2793 (void *)&cmd_setup_rxtx_queue_portid, 2794 (void *)&cmd_setup_rxtx_queue_rxtxq, 2795 (void *)&cmd_setup_rxtx_queue_qid, 2796 (void *)&cmd_setup_rxtx_queue_setup, 2797 NULL, 2798 }, 2799 }; 2800 2801 2802 /* *** Configure RSS RETA *** */ 2803 struct cmd_config_rss_reta { 2804 cmdline_fixed_string_t port; 2805 cmdline_fixed_string_t keyword; 2806 portid_t port_id; 2807 cmdline_fixed_string_t name; 2808 cmdline_fixed_string_t list_name; 2809 cmdline_fixed_string_t list_of_items; 2810 }; 2811 2812 static int 2813 parse_reta_config(const char *str, 2814 struct rte_eth_rss_reta_entry64 *reta_conf, 2815 uint16_t nb_entries) 2816 { 2817 int i; 2818 unsigned size; 2819 uint16_t hash_index, idx, shift; 2820 uint16_t nb_queue; 2821 char s[256]; 2822 const char *p, *p0 = str; 2823 char *end; 2824 enum fieldnames { 2825 FLD_HASH_INDEX = 0, 2826 FLD_QUEUE, 2827 _NUM_FLD 2828 }; 2829 unsigned long int_fld[_NUM_FLD]; 2830 char *str_fld[_NUM_FLD]; 2831 2832 while ((p = strchr(p0,'(')) != NULL) { 2833 ++p; 2834 if((p0 = strchr(p,')')) == NULL) 2835 return -1; 2836 2837 size = p0 - p; 2838 if(size >= sizeof(s)) 2839 return -1; 2840 2841 snprintf(s, sizeof(s), "%.*s", size, p); 2842 if (rte_strsplit(s, sizeof(s), str_fld, _NUM_FLD, ',') != _NUM_FLD) 2843 return -1; 2844 for (i = 0; i < _NUM_FLD; i++) { 2845 errno = 0; 2846 int_fld[i] = strtoul(str_fld[i], &end, 0); 2847 if (errno != 0 || end == str_fld[i] || 2848 int_fld[i] > 65535) 2849 return -1; 2850 } 2851 2852 hash_index = (uint16_t)int_fld[FLD_HASH_INDEX]; 2853 nb_queue = (uint16_t)int_fld[FLD_QUEUE]; 2854 2855 if (hash_index >= nb_entries) { 2856 printf("Invalid RETA hash index=%d\n", hash_index); 2857 return -1; 2858 } 2859 2860 idx = hash_index / RTE_RETA_GROUP_SIZE; 2861 shift = hash_index % RTE_RETA_GROUP_SIZE; 2862 reta_conf[idx].mask |= (1ULL << shift); 2863 reta_conf[idx].reta[shift] = nb_queue; 2864 } 2865 2866 return 0; 2867 } 2868 2869 static void 2870 cmd_set_rss_reta_parsed(void *parsed_result, 2871 __attribute__((unused)) struct cmdline *cl, 2872 __attribute__((unused)) void *data) 2873 { 2874 int ret; 2875 struct rte_eth_dev_info dev_info; 2876 struct rte_eth_rss_reta_entry64 reta_conf[8]; 2877 struct cmd_config_rss_reta *res = parsed_result; 2878 2879 memset(&dev_info, 0, sizeof(dev_info)); 2880 rte_eth_dev_info_get(res->port_id, &dev_info); 2881 if (dev_info.reta_size == 0) { 2882 printf("Redirection table size is 0 which is " 2883 "invalid for RSS\n"); 2884 return; 2885 } else 2886 printf("The reta size of port %d is %u\n", 2887 res->port_id, dev_info.reta_size); 2888 if (dev_info.reta_size > ETH_RSS_RETA_SIZE_512) { 2889 printf("Currently do not support more than %u entries of " 2890 "redirection table\n", ETH_RSS_RETA_SIZE_512); 2891 return; 2892 } 2893 2894 memset(reta_conf, 0, sizeof(reta_conf)); 2895 if (!strcmp(res->list_name, "reta")) { 2896 if (parse_reta_config(res->list_of_items, reta_conf, 2897 dev_info.reta_size)) { 2898 printf("Invalid RSS Redirection Table " 2899 "config entered\n"); 2900 return; 2901 } 2902 ret = rte_eth_dev_rss_reta_update(res->port_id, 2903 reta_conf, dev_info.reta_size); 2904 if (ret != 0) 2905 printf("Bad redirection table parameter, " 2906 "return code = %d \n", ret); 2907 } 2908 } 2909 2910 cmdline_parse_token_string_t cmd_config_rss_reta_port = 2911 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_reta, port, "port"); 2912 cmdline_parse_token_string_t cmd_config_rss_reta_keyword = 2913 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_reta, keyword, "config"); 2914 cmdline_parse_token_num_t cmd_config_rss_reta_port_id = 2915 TOKEN_NUM_INITIALIZER(struct cmd_config_rss_reta, port_id, UINT16); 2916 cmdline_parse_token_string_t cmd_config_rss_reta_name = 2917 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_reta, name, "rss"); 2918 cmdline_parse_token_string_t cmd_config_rss_reta_list_name = 2919 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_reta, list_name, "reta"); 2920 cmdline_parse_token_string_t cmd_config_rss_reta_list_of_items = 2921 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_reta, list_of_items, 2922 NULL); 2923 cmdline_parse_inst_t cmd_config_rss_reta = { 2924 .f = cmd_set_rss_reta_parsed, 2925 .data = NULL, 2926 .help_str = "port config <port_id> rss reta <hash,queue[,hash,queue]*>", 2927 .tokens = { 2928 (void *)&cmd_config_rss_reta_port, 2929 (void *)&cmd_config_rss_reta_keyword, 2930 (void *)&cmd_config_rss_reta_port_id, 2931 (void *)&cmd_config_rss_reta_name, 2932 (void *)&cmd_config_rss_reta_list_name, 2933 (void *)&cmd_config_rss_reta_list_of_items, 2934 NULL, 2935 }, 2936 }; 2937 2938 /* *** SHOW PORT RETA INFO *** */ 2939 struct cmd_showport_reta { 2940 cmdline_fixed_string_t show; 2941 cmdline_fixed_string_t port; 2942 portid_t port_id; 2943 cmdline_fixed_string_t rss; 2944 cmdline_fixed_string_t reta; 2945 uint16_t size; 2946 cmdline_fixed_string_t list_of_items; 2947 }; 2948 2949 static int 2950 showport_parse_reta_config(struct rte_eth_rss_reta_entry64 *conf, 2951 uint16_t nb_entries, 2952 char *str) 2953 { 2954 uint32_t size; 2955 const char *p, *p0 = str; 2956 char s[256]; 2957 char *end; 2958 char *str_fld[8]; 2959 uint16_t i; 2960 uint16_t num = (nb_entries + RTE_RETA_GROUP_SIZE - 1) / 2961 RTE_RETA_GROUP_SIZE; 2962 int ret; 2963 2964 p = strchr(p0, '('); 2965 if (p == NULL) 2966 return -1; 2967 p++; 2968 p0 = strchr(p, ')'); 2969 if (p0 == NULL) 2970 return -1; 2971 size = p0 - p; 2972 if (size >= sizeof(s)) { 2973 printf("The string size exceeds the internal buffer size\n"); 2974 return -1; 2975 } 2976 snprintf(s, sizeof(s), "%.*s", size, p); 2977 ret = rte_strsplit(s, sizeof(s), str_fld, num, ','); 2978 if (ret <= 0 || ret != num) { 2979 printf("The bits of masks do not match the number of " 2980 "reta entries: %u\n", num); 2981 return -1; 2982 } 2983 for (i = 0; i < ret; i++) 2984 conf[i].mask = (uint64_t)strtoul(str_fld[i], &end, 0); 2985 2986 return 0; 2987 } 2988 2989 static void 2990 cmd_showport_reta_parsed(void *parsed_result, 2991 __attribute__((unused)) struct cmdline *cl, 2992 __attribute__((unused)) void *data) 2993 { 2994 struct cmd_showport_reta *res = parsed_result; 2995 struct rte_eth_rss_reta_entry64 reta_conf[8]; 2996 struct rte_eth_dev_info dev_info; 2997 uint16_t max_reta_size; 2998 2999 memset(&dev_info, 0, sizeof(dev_info)); 3000 rte_eth_dev_info_get(res->port_id, &dev_info); 3001 max_reta_size = RTE_MIN(dev_info.reta_size, ETH_RSS_RETA_SIZE_512); 3002 if (res->size == 0 || res->size > max_reta_size) { 3003 printf("Invalid redirection table size: %u (1-%u)\n", 3004 res->size, max_reta_size); 3005 return; 3006 } 3007 3008 memset(reta_conf, 0, sizeof(reta_conf)); 3009 if (showport_parse_reta_config(reta_conf, res->size, 3010 res->list_of_items) < 0) { 3011 printf("Invalid string: %s for reta masks\n", 3012 res->list_of_items); 3013 return; 3014 } 3015 port_rss_reta_info(res->port_id, reta_conf, res->size); 3016 } 3017 3018 cmdline_parse_token_string_t cmd_showport_reta_show = 3019 TOKEN_STRING_INITIALIZER(struct cmd_showport_reta, show, "show"); 3020 cmdline_parse_token_string_t cmd_showport_reta_port = 3021 TOKEN_STRING_INITIALIZER(struct cmd_showport_reta, port, "port"); 3022 cmdline_parse_token_num_t cmd_showport_reta_port_id = 3023 TOKEN_NUM_INITIALIZER(struct cmd_showport_reta, port_id, UINT16); 3024 cmdline_parse_token_string_t cmd_showport_reta_rss = 3025 TOKEN_STRING_INITIALIZER(struct cmd_showport_reta, rss, "rss"); 3026 cmdline_parse_token_string_t cmd_showport_reta_reta = 3027 TOKEN_STRING_INITIALIZER(struct cmd_showport_reta, reta, "reta"); 3028 cmdline_parse_token_num_t cmd_showport_reta_size = 3029 TOKEN_NUM_INITIALIZER(struct cmd_showport_reta, size, UINT16); 3030 cmdline_parse_token_string_t cmd_showport_reta_list_of_items = 3031 TOKEN_STRING_INITIALIZER(struct cmd_showport_reta, 3032 list_of_items, NULL); 3033 3034 cmdline_parse_inst_t cmd_showport_reta = { 3035 .f = cmd_showport_reta_parsed, 3036 .data = NULL, 3037 .help_str = "show port <port_id> rss reta <size> <mask0[,mask1]*>", 3038 .tokens = { 3039 (void *)&cmd_showport_reta_show, 3040 (void *)&cmd_showport_reta_port, 3041 (void *)&cmd_showport_reta_port_id, 3042 (void *)&cmd_showport_reta_rss, 3043 (void *)&cmd_showport_reta_reta, 3044 (void *)&cmd_showport_reta_size, 3045 (void *)&cmd_showport_reta_list_of_items, 3046 NULL, 3047 }, 3048 }; 3049 3050 /* *** Show RSS hash configuration *** */ 3051 struct cmd_showport_rss_hash { 3052 cmdline_fixed_string_t show; 3053 cmdline_fixed_string_t port; 3054 portid_t port_id; 3055 cmdline_fixed_string_t rss_hash; 3056 cmdline_fixed_string_t rss_type; 3057 cmdline_fixed_string_t key; /* optional argument */ 3058 }; 3059 3060 static void cmd_showport_rss_hash_parsed(void *parsed_result, 3061 __attribute__((unused)) struct cmdline *cl, 3062 void *show_rss_key) 3063 { 3064 struct cmd_showport_rss_hash *res = parsed_result; 3065 3066 port_rss_hash_conf_show(res->port_id, show_rss_key != NULL); 3067 } 3068 3069 cmdline_parse_token_string_t cmd_showport_rss_hash_show = 3070 TOKEN_STRING_INITIALIZER(struct cmd_showport_rss_hash, show, "show"); 3071 cmdline_parse_token_string_t cmd_showport_rss_hash_port = 3072 TOKEN_STRING_INITIALIZER(struct cmd_showport_rss_hash, port, "port"); 3073 cmdline_parse_token_num_t cmd_showport_rss_hash_port_id = 3074 TOKEN_NUM_INITIALIZER(struct cmd_showport_rss_hash, port_id, UINT16); 3075 cmdline_parse_token_string_t cmd_showport_rss_hash_rss_hash = 3076 TOKEN_STRING_INITIALIZER(struct cmd_showport_rss_hash, rss_hash, 3077 "rss-hash"); 3078 cmdline_parse_token_string_t cmd_showport_rss_hash_rss_key = 3079 TOKEN_STRING_INITIALIZER(struct cmd_showport_rss_hash, key, "key"); 3080 3081 cmdline_parse_inst_t cmd_showport_rss_hash = { 3082 .f = cmd_showport_rss_hash_parsed, 3083 .data = NULL, 3084 .help_str = "show port <port_id> rss-hash", 3085 .tokens = { 3086 (void *)&cmd_showport_rss_hash_show, 3087 (void *)&cmd_showport_rss_hash_port, 3088 (void *)&cmd_showport_rss_hash_port_id, 3089 (void *)&cmd_showport_rss_hash_rss_hash, 3090 NULL, 3091 }, 3092 }; 3093 3094 cmdline_parse_inst_t cmd_showport_rss_hash_key = { 3095 .f = cmd_showport_rss_hash_parsed, 3096 .data = (void *)1, 3097 .help_str = "show port <port_id> rss-hash key", 3098 .tokens = { 3099 (void *)&cmd_showport_rss_hash_show, 3100 (void *)&cmd_showport_rss_hash_port, 3101 (void *)&cmd_showport_rss_hash_port_id, 3102 (void *)&cmd_showport_rss_hash_rss_hash, 3103 (void *)&cmd_showport_rss_hash_rss_key, 3104 NULL, 3105 }, 3106 }; 3107 3108 /* *** Configure DCB *** */ 3109 struct cmd_config_dcb { 3110 cmdline_fixed_string_t port; 3111 cmdline_fixed_string_t config; 3112 portid_t port_id; 3113 cmdline_fixed_string_t dcb; 3114 cmdline_fixed_string_t vt; 3115 cmdline_fixed_string_t vt_en; 3116 uint8_t num_tcs; 3117 cmdline_fixed_string_t pfc; 3118 cmdline_fixed_string_t pfc_en; 3119 }; 3120 3121 static void 3122 cmd_config_dcb_parsed(void *parsed_result, 3123 __attribute__((unused)) struct cmdline *cl, 3124 __attribute__((unused)) void *data) 3125 { 3126 struct cmd_config_dcb *res = parsed_result; 3127 portid_t port_id = res->port_id; 3128 struct rte_port *port; 3129 uint8_t pfc_en; 3130 int ret; 3131 3132 port = &ports[port_id]; 3133 /** Check if the port is not started **/ 3134 if (port->port_status != RTE_PORT_STOPPED) { 3135 printf("Please stop port %d first\n", port_id); 3136 return; 3137 } 3138 3139 if ((res->num_tcs != ETH_4_TCS) && (res->num_tcs != ETH_8_TCS)) { 3140 printf("The invalid number of traffic class," 3141 " only 4 or 8 allowed.\n"); 3142 return; 3143 } 3144 3145 if (nb_fwd_lcores < res->num_tcs) { 3146 printf("nb_cores shouldn't be less than number of TCs.\n"); 3147 return; 3148 } 3149 if (!strncmp(res->pfc_en, "on", 2)) 3150 pfc_en = 1; 3151 else 3152 pfc_en = 0; 3153 3154 /* DCB in VT mode */ 3155 if (!strncmp(res->vt_en, "on", 2)) 3156 ret = init_port_dcb_config(port_id, DCB_VT_ENABLED, 3157 (enum rte_eth_nb_tcs)res->num_tcs, 3158 pfc_en); 3159 else 3160 ret = init_port_dcb_config(port_id, DCB_ENABLED, 3161 (enum rte_eth_nb_tcs)res->num_tcs, 3162 pfc_en); 3163 3164 3165 if (ret != 0) { 3166 printf("Cannot initialize network ports.\n"); 3167 return; 3168 } 3169 3170 cmd_reconfig_device_queue(port_id, 1, 1); 3171 } 3172 3173 cmdline_parse_token_string_t cmd_config_dcb_port = 3174 TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, port, "port"); 3175 cmdline_parse_token_string_t cmd_config_dcb_config = 3176 TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, config, "config"); 3177 cmdline_parse_token_num_t cmd_config_dcb_port_id = 3178 TOKEN_NUM_INITIALIZER(struct cmd_config_dcb, port_id, UINT16); 3179 cmdline_parse_token_string_t cmd_config_dcb_dcb = 3180 TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, dcb, "dcb"); 3181 cmdline_parse_token_string_t cmd_config_dcb_vt = 3182 TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, vt, "vt"); 3183 cmdline_parse_token_string_t cmd_config_dcb_vt_en = 3184 TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, vt_en, "on#off"); 3185 cmdline_parse_token_num_t cmd_config_dcb_num_tcs = 3186 TOKEN_NUM_INITIALIZER(struct cmd_config_dcb, num_tcs, UINT8); 3187 cmdline_parse_token_string_t cmd_config_dcb_pfc= 3188 TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, pfc, "pfc"); 3189 cmdline_parse_token_string_t cmd_config_dcb_pfc_en = 3190 TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, pfc_en, "on#off"); 3191 3192 cmdline_parse_inst_t cmd_config_dcb = { 3193 .f = cmd_config_dcb_parsed, 3194 .data = NULL, 3195 .help_str = "port config <port-id> dcb vt on|off <num_tcs> pfc on|off", 3196 .tokens = { 3197 (void *)&cmd_config_dcb_port, 3198 (void *)&cmd_config_dcb_config, 3199 (void *)&cmd_config_dcb_port_id, 3200 (void *)&cmd_config_dcb_dcb, 3201 (void *)&cmd_config_dcb_vt, 3202 (void *)&cmd_config_dcb_vt_en, 3203 (void *)&cmd_config_dcb_num_tcs, 3204 (void *)&cmd_config_dcb_pfc, 3205 (void *)&cmd_config_dcb_pfc_en, 3206 NULL, 3207 }, 3208 }; 3209 3210 /* *** configure number of packets per burst *** */ 3211 struct cmd_config_burst { 3212 cmdline_fixed_string_t port; 3213 cmdline_fixed_string_t keyword; 3214 cmdline_fixed_string_t all; 3215 cmdline_fixed_string_t name; 3216 uint16_t value; 3217 }; 3218 3219 static void 3220 cmd_config_burst_parsed(void *parsed_result, 3221 __attribute__((unused)) struct cmdline *cl, 3222 __attribute__((unused)) void *data) 3223 { 3224 struct cmd_config_burst *res = parsed_result; 3225 struct rte_eth_dev_info dev_info; 3226 uint16_t rec_nb_pkts; 3227 3228 if (!all_ports_stopped()) { 3229 printf("Please stop all ports first\n"); 3230 return; 3231 } 3232 3233 if (!strcmp(res->name, "burst")) { 3234 if (res->value == 0) { 3235 /* If user gives a value of zero, query the PMD for 3236 * its recommended Rx burst size. Testpmd uses a single 3237 * size for all ports, so assume all ports are the same 3238 * NIC model and use the values from Port 0. 3239 */ 3240 rte_eth_dev_info_get(0, &dev_info); 3241 rec_nb_pkts = dev_info.default_rxportconf.burst_size; 3242 3243 if (rec_nb_pkts == 0) { 3244 printf("PMD does not recommend a burst size.\n" 3245 "User provided value must be between" 3246 " 1 and %d\n", MAX_PKT_BURST); 3247 return; 3248 } else if (rec_nb_pkts > MAX_PKT_BURST) { 3249 printf("PMD recommended burst size of %d" 3250 " exceeds maximum value of %d\n", 3251 rec_nb_pkts, MAX_PKT_BURST); 3252 return; 3253 } 3254 printf("Using PMD-provided burst value of %d\n", 3255 rec_nb_pkts); 3256 nb_pkt_per_burst = rec_nb_pkts; 3257 } else if (res->value > MAX_PKT_BURST) { 3258 printf("burst must be >= 1 && <= %d\n", MAX_PKT_BURST); 3259 return; 3260 } else 3261 nb_pkt_per_burst = res->value; 3262 } else { 3263 printf("Unknown parameter\n"); 3264 return; 3265 } 3266 3267 init_port_config(); 3268 3269 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1); 3270 } 3271 3272 cmdline_parse_token_string_t cmd_config_burst_port = 3273 TOKEN_STRING_INITIALIZER(struct cmd_config_burst, port, "port"); 3274 cmdline_parse_token_string_t cmd_config_burst_keyword = 3275 TOKEN_STRING_INITIALIZER(struct cmd_config_burst, keyword, "config"); 3276 cmdline_parse_token_string_t cmd_config_burst_all = 3277 TOKEN_STRING_INITIALIZER(struct cmd_config_burst, all, "all"); 3278 cmdline_parse_token_string_t cmd_config_burst_name = 3279 TOKEN_STRING_INITIALIZER(struct cmd_config_burst, name, "burst"); 3280 cmdline_parse_token_num_t cmd_config_burst_value = 3281 TOKEN_NUM_INITIALIZER(struct cmd_config_burst, value, UINT16); 3282 3283 cmdline_parse_inst_t cmd_config_burst = { 3284 .f = cmd_config_burst_parsed, 3285 .data = NULL, 3286 .help_str = "port config all burst <value>", 3287 .tokens = { 3288 (void *)&cmd_config_burst_port, 3289 (void *)&cmd_config_burst_keyword, 3290 (void *)&cmd_config_burst_all, 3291 (void *)&cmd_config_burst_name, 3292 (void *)&cmd_config_burst_value, 3293 NULL, 3294 }, 3295 }; 3296 3297 /* *** configure rx/tx queues *** */ 3298 struct cmd_config_thresh { 3299 cmdline_fixed_string_t port; 3300 cmdline_fixed_string_t keyword; 3301 cmdline_fixed_string_t all; 3302 cmdline_fixed_string_t name; 3303 uint8_t value; 3304 }; 3305 3306 static void 3307 cmd_config_thresh_parsed(void *parsed_result, 3308 __attribute__((unused)) struct cmdline *cl, 3309 __attribute__((unused)) void *data) 3310 { 3311 struct cmd_config_thresh *res = parsed_result; 3312 3313 if (!all_ports_stopped()) { 3314 printf("Please stop all ports first\n"); 3315 return; 3316 } 3317 3318 if (!strcmp(res->name, "txpt")) 3319 tx_pthresh = res->value; 3320 else if(!strcmp(res->name, "txht")) 3321 tx_hthresh = res->value; 3322 else if(!strcmp(res->name, "txwt")) 3323 tx_wthresh = res->value; 3324 else if(!strcmp(res->name, "rxpt")) 3325 rx_pthresh = res->value; 3326 else if(!strcmp(res->name, "rxht")) 3327 rx_hthresh = res->value; 3328 else if(!strcmp(res->name, "rxwt")) 3329 rx_wthresh = res->value; 3330 else { 3331 printf("Unknown parameter\n"); 3332 return; 3333 } 3334 3335 init_port_config(); 3336 3337 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1); 3338 } 3339 3340 cmdline_parse_token_string_t cmd_config_thresh_port = 3341 TOKEN_STRING_INITIALIZER(struct cmd_config_thresh, port, "port"); 3342 cmdline_parse_token_string_t cmd_config_thresh_keyword = 3343 TOKEN_STRING_INITIALIZER(struct cmd_config_thresh, keyword, "config"); 3344 cmdline_parse_token_string_t cmd_config_thresh_all = 3345 TOKEN_STRING_INITIALIZER(struct cmd_config_thresh, all, "all"); 3346 cmdline_parse_token_string_t cmd_config_thresh_name = 3347 TOKEN_STRING_INITIALIZER(struct cmd_config_thresh, name, 3348 "txpt#txht#txwt#rxpt#rxht#rxwt"); 3349 cmdline_parse_token_num_t cmd_config_thresh_value = 3350 TOKEN_NUM_INITIALIZER(struct cmd_config_thresh, value, UINT8); 3351 3352 cmdline_parse_inst_t cmd_config_thresh = { 3353 .f = cmd_config_thresh_parsed, 3354 .data = NULL, 3355 .help_str = "port config all txpt|txht|txwt|rxpt|rxht|rxwt <value>", 3356 .tokens = { 3357 (void *)&cmd_config_thresh_port, 3358 (void *)&cmd_config_thresh_keyword, 3359 (void *)&cmd_config_thresh_all, 3360 (void *)&cmd_config_thresh_name, 3361 (void *)&cmd_config_thresh_value, 3362 NULL, 3363 }, 3364 }; 3365 3366 /* *** configure free/rs threshold *** */ 3367 struct cmd_config_threshold { 3368 cmdline_fixed_string_t port; 3369 cmdline_fixed_string_t keyword; 3370 cmdline_fixed_string_t all; 3371 cmdline_fixed_string_t name; 3372 uint16_t value; 3373 }; 3374 3375 static void 3376 cmd_config_threshold_parsed(void *parsed_result, 3377 __attribute__((unused)) struct cmdline *cl, 3378 __attribute__((unused)) void *data) 3379 { 3380 struct cmd_config_threshold *res = parsed_result; 3381 3382 if (!all_ports_stopped()) { 3383 printf("Please stop all ports first\n"); 3384 return; 3385 } 3386 3387 if (!strcmp(res->name, "txfreet")) 3388 tx_free_thresh = res->value; 3389 else if (!strcmp(res->name, "txrst")) 3390 tx_rs_thresh = res->value; 3391 else if (!strcmp(res->name, "rxfreet")) 3392 rx_free_thresh = res->value; 3393 else { 3394 printf("Unknown parameter\n"); 3395 return; 3396 } 3397 3398 init_port_config(); 3399 3400 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1); 3401 } 3402 3403 cmdline_parse_token_string_t cmd_config_threshold_port = 3404 TOKEN_STRING_INITIALIZER(struct cmd_config_threshold, port, "port"); 3405 cmdline_parse_token_string_t cmd_config_threshold_keyword = 3406 TOKEN_STRING_INITIALIZER(struct cmd_config_threshold, keyword, 3407 "config"); 3408 cmdline_parse_token_string_t cmd_config_threshold_all = 3409 TOKEN_STRING_INITIALIZER(struct cmd_config_threshold, all, "all"); 3410 cmdline_parse_token_string_t cmd_config_threshold_name = 3411 TOKEN_STRING_INITIALIZER(struct cmd_config_threshold, name, 3412 "txfreet#txrst#rxfreet"); 3413 cmdline_parse_token_num_t cmd_config_threshold_value = 3414 TOKEN_NUM_INITIALIZER(struct cmd_config_threshold, value, UINT16); 3415 3416 cmdline_parse_inst_t cmd_config_threshold = { 3417 .f = cmd_config_threshold_parsed, 3418 .data = NULL, 3419 .help_str = "port config all txfreet|txrst|rxfreet <value>", 3420 .tokens = { 3421 (void *)&cmd_config_threshold_port, 3422 (void *)&cmd_config_threshold_keyword, 3423 (void *)&cmd_config_threshold_all, 3424 (void *)&cmd_config_threshold_name, 3425 (void *)&cmd_config_threshold_value, 3426 NULL, 3427 }, 3428 }; 3429 3430 /* *** stop *** */ 3431 struct cmd_stop_result { 3432 cmdline_fixed_string_t stop; 3433 }; 3434 3435 static void cmd_stop_parsed(__attribute__((unused)) void *parsed_result, 3436 __attribute__((unused)) struct cmdline *cl, 3437 __attribute__((unused)) void *data) 3438 { 3439 stop_packet_forwarding(); 3440 } 3441 3442 cmdline_parse_token_string_t cmd_stop_stop = 3443 TOKEN_STRING_INITIALIZER(struct cmd_stop_result, stop, "stop"); 3444 3445 cmdline_parse_inst_t cmd_stop = { 3446 .f = cmd_stop_parsed, 3447 .data = NULL, 3448 .help_str = "stop: Stop packet forwarding", 3449 .tokens = { 3450 (void *)&cmd_stop_stop, 3451 NULL, 3452 }, 3453 }; 3454 3455 /* *** SET CORELIST and PORTLIST CONFIGURATION *** */ 3456 3457 unsigned int 3458 parse_item_list(char* str, const char* item_name, unsigned int max_items, 3459 unsigned int *parsed_items, int check_unique_values) 3460 { 3461 unsigned int nb_item; 3462 unsigned int value; 3463 unsigned int i; 3464 unsigned int j; 3465 int value_ok; 3466 char c; 3467 3468 /* 3469 * First parse all items in the list and store their value. 3470 */ 3471 value = 0; 3472 nb_item = 0; 3473 value_ok = 0; 3474 for (i = 0; i < strnlen(str, STR_TOKEN_SIZE); i++) { 3475 c = str[i]; 3476 if ((c >= '0') && (c <= '9')) { 3477 value = (unsigned int) (value * 10 + (c - '0')); 3478 value_ok = 1; 3479 continue; 3480 } 3481 if (c != ',') { 3482 printf("character %c is not a decimal digit\n", c); 3483 return 0; 3484 } 3485 if (! value_ok) { 3486 printf("No valid value before comma\n"); 3487 return 0; 3488 } 3489 if (nb_item < max_items) { 3490 parsed_items[nb_item] = value; 3491 value_ok = 0; 3492 value = 0; 3493 } 3494 nb_item++; 3495 } 3496 if (nb_item >= max_items) { 3497 printf("Number of %s = %u > %u (maximum items)\n", 3498 item_name, nb_item + 1, max_items); 3499 return 0; 3500 } 3501 parsed_items[nb_item++] = value; 3502 if (! check_unique_values) 3503 return nb_item; 3504 3505 /* 3506 * Then, check that all values in the list are differents. 3507 * No optimization here... 3508 */ 3509 for (i = 0; i < nb_item; i++) { 3510 for (j = i + 1; j < nb_item; j++) { 3511 if (parsed_items[j] == parsed_items[i]) { 3512 printf("duplicated %s %u at index %u and %u\n", 3513 item_name, parsed_items[i], i, j); 3514 return 0; 3515 } 3516 } 3517 } 3518 return nb_item; 3519 } 3520 3521 struct cmd_set_list_result { 3522 cmdline_fixed_string_t cmd_keyword; 3523 cmdline_fixed_string_t list_name; 3524 cmdline_fixed_string_t list_of_items; 3525 }; 3526 3527 static void cmd_set_list_parsed(void *parsed_result, 3528 __attribute__((unused)) struct cmdline *cl, 3529 __attribute__((unused)) void *data) 3530 { 3531 struct cmd_set_list_result *res; 3532 union { 3533 unsigned int lcorelist[RTE_MAX_LCORE]; 3534 unsigned int portlist[RTE_MAX_ETHPORTS]; 3535 } parsed_items; 3536 unsigned int nb_item; 3537 3538 if (test_done == 0) { 3539 printf("Please stop forwarding first\n"); 3540 return; 3541 } 3542 3543 res = parsed_result; 3544 if (!strcmp(res->list_name, "corelist")) { 3545 nb_item = parse_item_list(res->list_of_items, "core", 3546 RTE_MAX_LCORE, 3547 parsed_items.lcorelist, 1); 3548 if (nb_item > 0) { 3549 set_fwd_lcores_list(parsed_items.lcorelist, nb_item); 3550 fwd_config_setup(); 3551 } 3552 return; 3553 } 3554 if (!strcmp(res->list_name, "portlist")) { 3555 nb_item = parse_item_list(res->list_of_items, "port", 3556 RTE_MAX_ETHPORTS, 3557 parsed_items.portlist, 1); 3558 if (nb_item > 0) { 3559 set_fwd_ports_list(parsed_items.portlist, nb_item); 3560 fwd_config_setup(); 3561 } 3562 } 3563 } 3564 3565 cmdline_parse_token_string_t cmd_set_list_keyword = 3566 TOKEN_STRING_INITIALIZER(struct cmd_set_list_result, cmd_keyword, 3567 "set"); 3568 cmdline_parse_token_string_t cmd_set_list_name = 3569 TOKEN_STRING_INITIALIZER(struct cmd_set_list_result, list_name, 3570 "corelist#portlist"); 3571 cmdline_parse_token_string_t cmd_set_list_of_items = 3572 TOKEN_STRING_INITIALIZER(struct cmd_set_list_result, list_of_items, 3573 NULL); 3574 3575 cmdline_parse_inst_t cmd_set_fwd_list = { 3576 .f = cmd_set_list_parsed, 3577 .data = NULL, 3578 .help_str = "set corelist|portlist <list0[,list1]*>", 3579 .tokens = { 3580 (void *)&cmd_set_list_keyword, 3581 (void *)&cmd_set_list_name, 3582 (void *)&cmd_set_list_of_items, 3583 NULL, 3584 }, 3585 }; 3586 3587 /* *** SET COREMASK and PORTMASK CONFIGURATION *** */ 3588 3589 struct cmd_setmask_result { 3590 cmdline_fixed_string_t set; 3591 cmdline_fixed_string_t mask; 3592 uint64_t hexavalue; 3593 }; 3594 3595 static void cmd_set_mask_parsed(void *parsed_result, 3596 __attribute__((unused)) struct cmdline *cl, 3597 __attribute__((unused)) void *data) 3598 { 3599 struct cmd_setmask_result *res = parsed_result; 3600 3601 if (test_done == 0) { 3602 printf("Please stop forwarding first\n"); 3603 return; 3604 } 3605 if (!strcmp(res->mask, "coremask")) { 3606 set_fwd_lcores_mask(res->hexavalue); 3607 fwd_config_setup(); 3608 } else if (!strcmp(res->mask, "portmask")) { 3609 set_fwd_ports_mask(res->hexavalue); 3610 fwd_config_setup(); 3611 } 3612 } 3613 3614 cmdline_parse_token_string_t cmd_setmask_set = 3615 TOKEN_STRING_INITIALIZER(struct cmd_setmask_result, set, "set"); 3616 cmdline_parse_token_string_t cmd_setmask_mask = 3617 TOKEN_STRING_INITIALIZER(struct cmd_setmask_result, mask, 3618 "coremask#portmask"); 3619 cmdline_parse_token_num_t cmd_setmask_value = 3620 TOKEN_NUM_INITIALIZER(struct cmd_setmask_result, hexavalue, UINT64); 3621 3622 cmdline_parse_inst_t cmd_set_fwd_mask = { 3623 .f = cmd_set_mask_parsed, 3624 .data = NULL, 3625 .help_str = "set coremask|portmask <hexadecimal value>", 3626 .tokens = { 3627 (void *)&cmd_setmask_set, 3628 (void *)&cmd_setmask_mask, 3629 (void *)&cmd_setmask_value, 3630 NULL, 3631 }, 3632 }; 3633 3634 /* 3635 * SET NBPORT, NBCORE, PACKET BURST, and VERBOSE LEVEL CONFIGURATION 3636 */ 3637 struct cmd_set_result { 3638 cmdline_fixed_string_t set; 3639 cmdline_fixed_string_t what; 3640 uint16_t value; 3641 }; 3642 3643 static void cmd_set_parsed(void *parsed_result, 3644 __attribute__((unused)) struct cmdline *cl, 3645 __attribute__((unused)) void *data) 3646 { 3647 struct cmd_set_result *res = parsed_result; 3648 if (!strcmp(res->what, "nbport")) { 3649 set_fwd_ports_number(res->value); 3650 fwd_config_setup(); 3651 } else if (!strcmp(res->what, "nbcore")) { 3652 set_fwd_lcores_number(res->value); 3653 fwd_config_setup(); 3654 } else if (!strcmp(res->what, "burst")) 3655 set_nb_pkt_per_burst(res->value); 3656 else if (!strcmp(res->what, "verbose")) 3657 set_verbose_level(res->value); 3658 } 3659 3660 cmdline_parse_token_string_t cmd_set_set = 3661 TOKEN_STRING_INITIALIZER(struct cmd_set_result, set, "set"); 3662 cmdline_parse_token_string_t cmd_set_what = 3663 TOKEN_STRING_INITIALIZER(struct cmd_set_result, what, 3664 "nbport#nbcore#burst#verbose"); 3665 cmdline_parse_token_num_t cmd_set_value = 3666 TOKEN_NUM_INITIALIZER(struct cmd_set_result, value, UINT16); 3667 3668 cmdline_parse_inst_t cmd_set_numbers = { 3669 .f = cmd_set_parsed, 3670 .data = NULL, 3671 .help_str = "set nbport|nbcore|burst|verbose <value>", 3672 .tokens = { 3673 (void *)&cmd_set_set, 3674 (void *)&cmd_set_what, 3675 (void *)&cmd_set_value, 3676 NULL, 3677 }, 3678 }; 3679 3680 /* *** SET LOG LEVEL CONFIGURATION *** */ 3681 3682 struct cmd_set_log_result { 3683 cmdline_fixed_string_t set; 3684 cmdline_fixed_string_t log; 3685 cmdline_fixed_string_t type; 3686 uint32_t level; 3687 }; 3688 3689 static void 3690 cmd_set_log_parsed(void *parsed_result, 3691 __attribute__((unused)) struct cmdline *cl, 3692 __attribute__((unused)) void *data) 3693 { 3694 struct cmd_set_log_result *res; 3695 int ret; 3696 3697 res = parsed_result; 3698 if (!strcmp(res->type, "global")) 3699 rte_log_set_global_level(res->level); 3700 else { 3701 ret = rte_log_set_level_regexp(res->type, res->level); 3702 if (ret < 0) 3703 printf("Unable to set log level\n"); 3704 } 3705 } 3706 3707 cmdline_parse_token_string_t cmd_set_log_set = 3708 TOKEN_STRING_INITIALIZER(struct cmd_set_log_result, set, "set"); 3709 cmdline_parse_token_string_t cmd_set_log_log = 3710 TOKEN_STRING_INITIALIZER(struct cmd_set_log_result, log, "log"); 3711 cmdline_parse_token_string_t cmd_set_log_type = 3712 TOKEN_STRING_INITIALIZER(struct cmd_set_log_result, type, NULL); 3713 cmdline_parse_token_num_t cmd_set_log_level = 3714 TOKEN_NUM_INITIALIZER(struct cmd_set_log_result, level, UINT32); 3715 3716 cmdline_parse_inst_t cmd_set_log = { 3717 .f = cmd_set_log_parsed, 3718 .data = NULL, 3719 .help_str = "set log global|<type> <level>", 3720 .tokens = { 3721 (void *)&cmd_set_log_set, 3722 (void *)&cmd_set_log_log, 3723 (void *)&cmd_set_log_type, 3724 (void *)&cmd_set_log_level, 3725 NULL, 3726 }, 3727 }; 3728 3729 /* *** SET SEGMENT LENGTHS OF TXONLY PACKETS *** */ 3730 3731 struct cmd_set_txpkts_result { 3732 cmdline_fixed_string_t cmd_keyword; 3733 cmdline_fixed_string_t txpkts; 3734 cmdline_fixed_string_t seg_lengths; 3735 }; 3736 3737 static void 3738 cmd_set_txpkts_parsed(void *parsed_result, 3739 __attribute__((unused)) struct cmdline *cl, 3740 __attribute__((unused)) void *data) 3741 { 3742 struct cmd_set_txpkts_result *res; 3743 unsigned seg_lengths[RTE_MAX_SEGS_PER_PKT]; 3744 unsigned int nb_segs; 3745 3746 res = parsed_result; 3747 nb_segs = parse_item_list(res->seg_lengths, "segment lengths", 3748 RTE_MAX_SEGS_PER_PKT, seg_lengths, 0); 3749 if (nb_segs > 0) 3750 set_tx_pkt_segments(seg_lengths, nb_segs); 3751 } 3752 3753 cmdline_parse_token_string_t cmd_set_txpkts_keyword = 3754 TOKEN_STRING_INITIALIZER(struct cmd_set_txpkts_result, 3755 cmd_keyword, "set"); 3756 cmdline_parse_token_string_t cmd_set_txpkts_name = 3757 TOKEN_STRING_INITIALIZER(struct cmd_set_txpkts_result, 3758 txpkts, "txpkts"); 3759 cmdline_parse_token_string_t cmd_set_txpkts_lengths = 3760 TOKEN_STRING_INITIALIZER(struct cmd_set_txpkts_result, 3761 seg_lengths, NULL); 3762 3763 cmdline_parse_inst_t cmd_set_txpkts = { 3764 .f = cmd_set_txpkts_parsed, 3765 .data = NULL, 3766 .help_str = "set txpkts <len0[,len1]*>", 3767 .tokens = { 3768 (void *)&cmd_set_txpkts_keyword, 3769 (void *)&cmd_set_txpkts_name, 3770 (void *)&cmd_set_txpkts_lengths, 3771 NULL, 3772 }, 3773 }; 3774 3775 /* *** SET COPY AND SPLIT POLICY ON TX PACKETS *** */ 3776 3777 struct cmd_set_txsplit_result { 3778 cmdline_fixed_string_t cmd_keyword; 3779 cmdline_fixed_string_t txsplit; 3780 cmdline_fixed_string_t mode; 3781 }; 3782 3783 static void 3784 cmd_set_txsplit_parsed(void *parsed_result, 3785 __attribute__((unused)) struct cmdline *cl, 3786 __attribute__((unused)) void *data) 3787 { 3788 struct cmd_set_txsplit_result *res; 3789 3790 res = parsed_result; 3791 set_tx_pkt_split(res->mode); 3792 } 3793 3794 cmdline_parse_token_string_t cmd_set_txsplit_keyword = 3795 TOKEN_STRING_INITIALIZER(struct cmd_set_txsplit_result, 3796 cmd_keyword, "set"); 3797 cmdline_parse_token_string_t cmd_set_txsplit_name = 3798 TOKEN_STRING_INITIALIZER(struct cmd_set_txsplit_result, 3799 txsplit, "txsplit"); 3800 cmdline_parse_token_string_t cmd_set_txsplit_mode = 3801 TOKEN_STRING_INITIALIZER(struct cmd_set_txsplit_result, 3802 mode, NULL); 3803 3804 cmdline_parse_inst_t cmd_set_txsplit = { 3805 .f = cmd_set_txsplit_parsed, 3806 .data = NULL, 3807 .help_str = "set txsplit on|off|rand", 3808 .tokens = { 3809 (void *)&cmd_set_txsplit_keyword, 3810 (void *)&cmd_set_txsplit_name, 3811 (void *)&cmd_set_txsplit_mode, 3812 NULL, 3813 }, 3814 }; 3815 3816 /* *** ADD/REMOVE ALL VLAN IDENTIFIERS TO/FROM A PORT VLAN RX FILTER *** */ 3817 struct cmd_rx_vlan_filter_all_result { 3818 cmdline_fixed_string_t rx_vlan; 3819 cmdline_fixed_string_t what; 3820 cmdline_fixed_string_t all; 3821 portid_t port_id; 3822 }; 3823 3824 static void 3825 cmd_rx_vlan_filter_all_parsed(void *parsed_result, 3826 __attribute__((unused)) struct cmdline *cl, 3827 __attribute__((unused)) void *data) 3828 { 3829 struct cmd_rx_vlan_filter_all_result *res = parsed_result; 3830 3831 if (!strcmp(res->what, "add")) 3832 rx_vlan_all_filter_set(res->port_id, 1); 3833 else 3834 rx_vlan_all_filter_set(res->port_id, 0); 3835 } 3836 3837 cmdline_parse_token_string_t cmd_rx_vlan_filter_all_rx_vlan = 3838 TOKEN_STRING_INITIALIZER(struct cmd_rx_vlan_filter_all_result, 3839 rx_vlan, "rx_vlan"); 3840 cmdline_parse_token_string_t cmd_rx_vlan_filter_all_what = 3841 TOKEN_STRING_INITIALIZER(struct cmd_rx_vlan_filter_all_result, 3842 what, "add#rm"); 3843 cmdline_parse_token_string_t cmd_rx_vlan_filter_all_all = 3844 TOKEN_STRING_INITIALIZER(struct cmd_rx_vlan_filter_all_result, 3845 all, "all"); 3846 cmdline_parse_token_num_t cmd_rx_vlan_filter_all_portid = 3847 TOKEN_NUM_INITIALIZER(struct cmd_rx_vlan_filter_all_result, 3848 port_id, UINT16); 3849 3850 cmdline_parse_inst_t cmd_rx_vlan_filter_all = { 3851 .f = cmd_rx_vlan_filter_all_parsed, 3852 .data = NULL, 3853 .help_str = "rx_vlan add|rm all <port_id>: " 3854 "Add/Remove all identifiers to/from the set of VLAN " 3855 "identifiers filtered by a port", 3856 .tokens = { 3857 (void *)&cmd_rx_vlan_filter_all_rx_vlan, 3858 (void *)&cmd_rx_vlan_filter_all_what, 3859 (void *)&cmd_rx_vlan_filter_all_all, 3860 (void *)&cmd_rx_vlan_filter_all_portid, 3861 NULL, 3862 }, 3863 }; 3864 3865 /* *** VLAN OFFLOAD SET ON A PORT *** */ 3866 struct cmd_vlan_offload_result { 3867 cmdline_fixed_string_t vlan; 3868 cmdline_fixed_string_t set; 3869 cmdline_fixed_string_t vlan_type; 3870 cmdline_fixed_string_t what; 3871 cmdline_fixed_string_t on; 3872 cmdline_fixed_string_t port_id; 3873 }; 3874 3875 static void 3876 cmd_vlan_offload_parsed(void *parsed_result, 3877 __attribute__((unused)) struct cmdline *cl, 3878 __attribute__((unused)) void *data) 3879 { 3880 int on; 3881 struct cmd_vlan_offload_result *res = parsed_result; 3882 char *str; 3883 int i, len = 0; 3884 portid_t port_id = 0; 3885 unsigned int tmp; 3886 3887 str = res->port_id; 3888 len = strnlen(str, STR_TOKEN_SIZE); 3889 i = 0; 3890 /* Get port_id first */ 3891 while(i < len){ 3892 if(str[i] == ',') 3893 break; 3894 3895 i++; 3896 } 3897 str[i]='\0'; 3898 tmp = strtoul(str, NULL, 0); 3899 /* If port_id greater that what portid_t can represent, return */ 3900 if(tmp >= RTE_MAX_ETHPORTS) 3901 return; 3902 port_id = (portid_t)tmp; 3903 3904 if (!strcmp(res->on, "on")) 3905 on = 1; 3906 else 3907 on = 0; 3908 3909 if (!strcmp(res->what, "strip")) 3910 rx_vlan_strip_set(port_id, on); 3911 else if(!strcmp(res->what, "stripq")){ 3912 uint16_t queue_id = 0; 3913 3914 /* No queue_id, return */ 3915 if(i + 1 >= len) { 3916 printf("must specify (port,queue_id)\n"); 3917 return; 3918 } 3919 tmp = strtoul(str + i + 1, NULL, 0); 3920 /* If queue_id greater that what 16-bits can represent, return */ 3921 if(tmp > 0xffff) 3922 return; 3923 3924 queue_id = (uint16_t)tmp; 3925 rx_vlan_strip_set_on_queue(port_id, queue_id, on); 3926 } 3927 else if (!strcmp(res->what, "filter")) 3928 rx_vlan_filter_set(port_id, on); 3929 else 3930 vlan_extend_set(port_id, on); 3931 3932 return; 3933 } 3934 3935 cmdline_parse_token_string_t cmd_vlan_offload_vlan = 3936 TOKEN_STRING_INITIALIZER(struct cmd_vlan_offload_result, 3937 vlan, "vlan"); 3938 cmdline_parse_token_string_t cmd_vlan_offload_set = 3939 TOKEN_STRING_INITIALIZER(struct cmd_vlan_offload_result, 3940 set, "set"); 3941 cmdline_parse_token_string_t cmd_vlan_offload_what = 3942 TOKEN_STRING_INITIALIZER(struct cmd_vlan_offload_result, 3943 what, "strip#filter#qinq#stripq"); 3944 cmdline_parse_token_string_t cmd_vlan_offload_on = 3945 TOKEN_STRING_INITIALIZER(struct cmd_vlan_offload_result, 3946 on, "on#off"); 3947 cmdline_parse_token_string_t cmd_vlan_offload_portid = 3948 TOKEN_STRING_INITIALIZER(struct cmd_vlan_offload_result, 3949 port_id, NULL); 3950 3951 cmdline_parse_inst_t cmd_vlan_offload = { 3952 .f = cmd_vlan_offload_parsed, 3953 .data = NULL, 3954 .help_str = "vlan set strip|filter|qinq|stripq on|off " 3955 "<port_id[,queue_id]>: " 3956 "Filter/Strip for rx side qinq(extended) for both rx/tx sides", 3957 .tokens = { 3958 (void *)&cmd_vlan_offload_vlan, 3959 (void *)&cmd_vlan_offload_set, 3960 (void *)&cmd_vlan_offload_what, 3961 (void *)&cmd_vlan_offload_on, 3962 (void *)&cmd_vlan_offload_portid, 3963 NULL, 3964 }, 3965 }; 3966 3967 /* *** VLAN TPID SET ON A PORT *** */ 3968 struct cmd_vlan_tpid_result { 3969 cmdline_fixed_string_t vlan; 3970 cmdline_fixed_string_t set; 3971 cmdline_fixed_string_t vlan_type; 3972 cmdline_fixed_string_t what; 3973 uint16_t tp_id; 3974 portid_t port_id; 3975 }; 3976 3977 static void 3978 cmd_vlan_tpid_parsed(void *parsed_result, 3979 __attribute__((unused)) struct cmdline *cl, 3980 __attribute__((unused)) void *data) 3981 { 3982 struct cmd_vlan_tpid_result *res = parsed_result; 3983 enum rte_vlan_type vlan_type; 3984 3985 if (!strcmp(res->vlan_type, "inner")) 3986 vlan_type = ETH_VLAN_TYPE_INNER; 3987 else if (!strcmp(res->vlan_type, "outer")) 3988 vlan_type = ETH_VLAN_TYPE_OUTER; 3989 else { 3990 printf("Unknown vlan type\n"); 3991 return; 3992 } 3993 vlan_tpid_set(res->port_id, vlan_type, res->tp_id); 3994 } 3995 3996 cmdline_parse_token_string_t cmd_vlan_tpid_vlan = 3997 TOKEN_STRING_INITIALIZER(struct cmd_vlan_tpid_result, 3998 vlan, "vlan"); 3999 cmdline_parse_token_string_t cmd_vlan_tpid_set = 4000 TOKEN_STRING_INITIALIZER(struct cmd_vlan_tpid_result, 4001 set, "set"); 4002 cmdline_parse_token_string_t cmd_vlan_type = 4003 TOKEN_STRING_INITIALIZER(struct cmd_vlan_tpid_result, 4004 vlan_type, "inner#outer"); 4005 cmdline_parse_token_string_t cmd_vlan_tpid_what = 4006 TOKEN_STRING_INITIALIZER(struct cmd_vlan_tpid_result, 4007 what, "tpid"); 4008 cmdline_parse_token_num_t cmd_vlan_tpid_tpid = 4009 TOKEN_NUM_INITIALIZER(struct cmd_vlan_tpid_result, 4010 tp_id, UINT16); 4011 cmdline_parse_token_num_t cmd_vlan_tpid_portid = 4012 TOKEN_NUM_INITIALIZER(struct cmd_vlan_tpid_result, 4013 port_id, UINT16); 4014 4015 cmdline_parse_inst_t cmd_vlan_tpid = { 4016 .f = cmd_vlan_tpid_parsed, 4017 .data = NULL, 4018 .help_str = "vlan set inner|outer tpid <tp_id> <port_id>: " 4019 "Set the VLAN Ether type", 4020 .tokens = { 4021 (void *)&cmd_vlan_tpid_vlan, 4022 (void *)&cmd_vlan_tpid_set, 4023 (void *)&cmd_vlan_type, 4024 (void *)&cmd_vlan_tpid_what, 4025 (void *)&cmd_vlan_tpid_tpid, 4026 (void *)&cmd_vlan_tpid_portid, 4027 NULL, 4028 }, 4029 }; 4030 4031 /* *** ADD/REMOVE A VLAN IDENTIFIER TO/FROM A PORT VLAN RX FILTER *** */ 4032 struct cmd_rx_vlan_filter_result { 4033 cmdline_fixed_string_t rx_vlan; 4034 cmdline_fixed_string_t what; 4035 uint16_t vlan_id; 4036 portid_t port_id; 4037 }; 4038 4039 static void 4040 cmd_rx_vlan_filter_parsed(void *parsed_result, 4041 __attribute__((unused)) struct cmdline *cl, 4042 __attribute__((unused)) void *data) 4043 { 4044 struct cmd_rx_vlan_filter_result *res = parsed_result; 4045 4046 if (!strcmp(res->what, "add")) 4047 rx_vft_set(res->port_id, res->vlan_id, 1); 4048 else 4049 rx_vft_set(res->port_id, res->vlan_id, 0); 4050 } 4051 4052 cmdline_parse_token_string_t cmd_rx_vlan_filter_rx_vlan = 4053 TOKEN_STRING_INITIALIZER(struct cmd_rx_vlan_filter_result, 4054 rx_vlan, "rx_vlan"); 4055 cmdline_parse_token_string_t cmd_rx_vlan_filter_what = 4056 TOKEN_STRING_INITIALIZER(struct cmd_rx_vlan_filter_result, 4057 what, "add#rm"); 4058 cmdline_parse_token_num_t cmd_rx_vlan_filter_vlanid = 4059 TOKEN_NUM_INITIALIZER(struct cmd_rx_vlan_filter_result, 4060 vlan_id, UINT16); 4061 cmdline_parse_token_num_t cmd_rx_vlan_filter_portid = 4062 TOKEN_NUM_INITIALIZER(struct cmd_rx_vlan_filter_result, 4063 port_id, UINT16); 4064 4065 cmdline_parse_inst_t cmd_rx_vlan_filter = { 4066 .f = cmd_rx_vlan_filter_parsed, 4067 .data = NULL, 4068 .help_str = "rx_vlan add|rm <vlan_id> <port_id>: " 4069 "Add/Remove a VLAN identifier to/from the set of VLAN " 4070 "identifiers filtered by a port", 4071 .tokens = { 4072 (void *)&cmd_rx_vlan_filter_rx_vlan, 4073 (void *)&cmd_rx_vlan_filter_what, 4074 (void *)&cmd_rx_vlan_filter_vlanid, 4075 (void *)&cmd_rx_vlan_filter_portid, 4076 NULL, 4077 }, 4078 }; 4079 4080 /* *** ENABLE HARDWARE INSERTION OF VLAN HEADER IN TX PACKETS *** */ 4081 struct cmd_tx_vlan_set_result { 4082 cmdline_fixed_string_t tx_vlan; 4083 cmdline_fixed_string_t set; 4084 portid_t port_id; 4085 uint16_t vlan_id; 4086 }; 4087 4088 static void 4089 cmd_tx_vlan_set_parsed(void *parsed_result, 4090 __attribute__((unused)) struct cmdline *cl, 4091 __attribute__((unused)) void *data) 4092 { 4093 struct cmd_tx_vlan_set_result *res = parsed_result; 4094 4095 if (!port_is_stopped(res->port_id)) { 4096 printf("Please stop port %d first\n", res->port_id); 4097 return; 4098 } 4099 4100 tx_vlan_set(res->port_id, res->vlan_id); 4101 4102 cmd_reconfig_device_queue(res->port_id, 1, 1); 4103 } 4104 4105 cmdline_parse_token_string_t cmd_tx_vlan_set_tx_vlan = 4106 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_result, 4107 tx_vlan, "tx_vlan"); 4108 cmdline_parse_token_string_t cmd_tx_vlan_set_set = 4109 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_result, 4110 set, "set"); 4111 cmdline_parse_token_num_t cmd_tx_vlan_set_portid = 4112 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_result, 4113 port_id, UINT16); 4114 cmdline_parse_token_num_t cmd_tx_vlan_set_vlanid = 4115 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_result, 4116 vlan_id, UINT16); 4117 4118 cmdline_parse_inst_t cmd_tx_vlan_set = { 4119 .f = cmd_tx_vlan_set_parsed, 4120 .data = NULL, 4121 .help_str = "tx_vlan set <port_id> <vlan_id>: " 4122 "Enable hardware insertion of a single VLAN header " 4123 "with a given TAG Identifier in packets sent on a port", 4124 .tokens = { 4125 (void *)&cmd_tx_vlan_set_tx_vlan, 4126 (void *)&cmd_tx_vlan_set_set, 4127 (void *)&cmd_tx_vlan_set_portid, 4128 (void *)&cmd_tx_vlan_set_vlanid, 4129 NULL, 4130 }, 4131 }; 4132 4133 /* *** ENABLE HARDWARE INSERTION OF Double VLAN HEADER IN TX PACKETS *** */ 4134 struct cmd_tx_vlan_set_qinq_result { 4135 cmdline_fixed_string_t tx_vlan; 4136 cmdline_fixed_string_t set; 4137 portid_t port_id; 4138 uint16_t vlan_id; 4139 uint16_t vlan_id_outer; 4140 }; 4141 4142 static void 4143 cmd_tx_vlan_set_qinq_parsed(void *parsed_result, 4144 __attribute__((unused)) struct cmdline *cl, 4145 __attribute__((unused)) void *data) 4146 { 4147 struct cmd_tx_vlan_set_qinq_result *res = parsed_result; 4148 4149 if (!port_is_stopped(res->port_id)) { 4150 printf("Please stop port %d first\n", res->port_id); 4151 return; 4152 } 4153 4154 tx_qinq_set(res->port_id, res->vlan_id, res->vlan_id_outer); 4155 4156 cmd_reconfig_device_queue(res->port_id, 1, 1); 4157 } 4158 4159 cmdline_parse_token_string_t cmd_tx_vlan_set_qinq_tx_vlan = 4160 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_qinq_result, 4161 tx_vlan, "tx_vlan"); 4162 cmdline_parse_token_string_t cmd_tx_vlan_set_qinq_set = 4163 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_qinq_result, 4164 set, "set"); 4165 cmdline_parse_token_num_t cmd_tx_vlan_set_qinq_portid = 4166 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_qinq_result, 4167 port_id, UINT16); 4168 cmdline_parse_token_num_t cmd_tx_vlan_set_qinq_vlanid = 4169 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_qinq_result, 4170 vlan_id, UINT16); 4171 cmdline_parse_token_num_t cmd_tx_vlan_set_qinq_vlanid_outer = 4172 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_qinq_result, 4173 vlan_id_outer, UINT16); 4174 4175 cmdline_parse_inst_t cmd_tx_vlan_set_qinq = { 4176 .f = cmd_tx_vlan_set_qinq_parsed, 4177 .data = NULL, 4178 .help_str = "tx_vlan set <port_id> <vlan_id> <outer_vlan_id>: " 4179 "Enable hardware insertion of double VLAN header " 4180 "with given TAG Identifiers in packets sent on a port", 4181 .tokens = { 4182 (void *)&cmd_tx_vlan_set_qinq_tx_vlan, 4183 (void *)&cmd_tx_vlan_set_qinq_set, 4184 (void *)&cmd_tx_vlan_set_qinq_portid, 4185 (void *)&cmd_tx_vlan_set_qinq_vlanid, 4186 (void *)&cmd_tx_vlan_set_qinq_vlanid_outer, 4187 NULL, 4188 }, 4189 }; 4190 4191 /* *** ENABLE/DISABLE PORT BASED TX VLAN INSERTION *** */ 4192 struct cmd_tx_vlan_set_pvid_result { 4193 cmdline_fixed_string_t tx_vlan; 4194 cmdline_fixed_string_t set; 4195 cmdline_fixed_string_t pvid; 4196 portid_t port_id; 4197 uint16_t vlan_id; 4198 cmdline_fixed_string_t mode; 4199 }; 4200 4201 static void 4202 cmd_tx_vlan_set_pvid_parsed(void *parsed_result, 4203 __attribute__((unused)) struct cmdline *cl, 4204 __attribute__((unused)) void *data) 4205 { 4206 struct cmd_tx_vlan_set_pvid_result *res = parsed_result; 4207 4208 if (strcmp(res->mode, "on") == 0) 4209 tx_vlan_pvid_set(res->port_id, res->vlan_id, 1); 4210 else 4211 tx_vlan_pvid_set(res->port_id, res->vlan_id, 0); 4212 } 4213 4214 cmdline_parse_token_string_t cmd_tx_vlan_set_pvid_tx_vlan = 4215 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_pvid_result, 4216 tx_vlan, "tx_vlan"); 4217 cmdline_parse_token_string_t cmd_tx_vlan_set_pvid_set = 4218 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_pvid_result, 4219 set, "set"); 4220 cmdline_parse_token_string_t cmd_tx_vlan_set_pvid_pvid = 4221 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_pvid_result, 4222 pvid, "pvid"); 4223 cmdline_parse_token_num_t cmd_tx_vlan_set_pvid_port_id = 4224 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_pvid_result, 4225 port_id, UINT16); 4226 cmdline_parse_token_num_t cmd_tx_vlan_set_pvid_vlan_id = 4227 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_pvid_result, 4228 vlan_id, UINT16); 4229 cmdline_parse_token_string_t cmd_tx_vlan_set_pvid_mode = 4230 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_pvid_result, 4231 mode, "on#off"); 4232 4233 cmdline_parse_inst_t cmd_tx_vlan_set_pvid = { 4234 .f = cmd_tx_vlan_set_pvid_parsed, 4235 .data = NULL, 4236 .help_str = "tx_vlan set pvid <port_id> <vlan_id> on|off", 4237 .tokens = { 4238 (void *)&cmd_tx_vlan_set_pvid_tx_vlan, 4239 (void *)&cmd_tx_vlan_set_pvid_set, 4240 (void *)&cmd_tx_vlan_set_pvid_pvid, 4241 (void *)&cmd_tx_vlan_set_pvid_port_id, 4242 (void *)&cmd_tx_vlan_set_pvid_vlan_id, 4243 (void *)&cmd_tx_vlan_set_pvid_mode, 4244 NULL, 4245 }, 4246 }; 4247 4248 /* *** DISABLE HARDWARE INSERTION OF VLAN HEADER IN TX PACKETS *** */ 4249 struct cmd_tx_vlan_reset_result { 4250 cmdline_fixed_string_t tx_vlan; 4251 cmdline_fixed_string_t reset; 4252 portid_t port_id; 4253 }; 4254 4255 static void 4256 cmd_tx_vlan_reset_parsed(void *parsed_result, 4257 __attribute__((unused)) struct cmdline *cl, 4258 __attribute__((unused)) void *data) 4259 { 4260 struct cmd_tx_vlan_reset_result *res = parsed_result; 4261 4262 if (!port_is_stopped(res->port_id)) { 4263 printf("Please stop port %d first\n", res->port_id); 4264 return; 4265 } 4266 4267 tx_vlan_reset(res->port_id); 4268 4269 cmd_reconfig_device_queue(res->port_id, 1, 1); 4270 } 4271 4272 cmdline_parse_token_string_t cmd_tx_vlan_reset_tx_vlan = 4273 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_reset_result, 4274 tx_vlan, "tx_vlan"); 4275 cmdline_parse_token_string_t cmd_tx_vlan_reset_reset = 4276 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_reset_result, 4277 reset, "reset"); 4278 cmdline_parse_token_num_t cmd_tx_vlan_reset_portid = 4279 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_reset_result, 4280 port_id, UINT16); 4281 4282 cmdline_parse_inst_t cmd_tx_vlan_reset = { 4283 .f = cmd_tx_vlan_reset_parsed, 4284 .data = NULL, 4285 .help_str = "tx_vlan reset <port_id>: Disable hardware insertion of a " 4286 "VLAN header in packets sent on a port", 4287 .tokens = { 4288 (void *)&cmd_tx_vlan_reset_tx_vlan, 4289 (void *)&cmd_tx_vlan_reset_reset, 4290 (void *)&cmd_tx_vlan_reset_portid, 4291 NULL, 4292 }, 4293 }; 4294 4295 4296 /* *** ENABLE HARDWARE INSERTION OF CHECKSUM IN TX PACKETS *** */ 4297 struct cmd_csum_result { 4298 cmdline_fixed_string_t csum; 4299 cmdline_fixed_string_t mode; 4300 cmdline_fixed_string_t proto; 4301 cmdline_fixed_string_t hwsw; 4302 portid_t port_id; 4303 }; 4304 4305 static void 4306 csum_show(int port_id) 4307 { 4308 struct rte_eth_dev_info dev_info; 4309 uint64_t tx_offloads; 4310 4311 tx_offloads = ports[port_id].dev_conf.txmode.offloads; 4312 printf("Parse tunnel is %s\n", 4313 (ports[port_id].parse_tunnel) ? "on" : "off"); 4314 printf("IP checksum offload is %s\n", 4315 (tx_offloads & DEV_TX_OFFLOAD_IPV4_CKSUM) ? "hw" : "sw"); 4316 printf("UDP checksum offload is %s\n", 4317 (tx_offloads & DEV_TX_OFFLOAD_UDP_CKSUM) ? "hw" : "sw"); 4318 printf("TCP checksum offload is %s\n", 4319 (tx_offloads & DEV_TX_OFFLOAD_TCP_CKSUM) ? "hw" : "sw"); 4320 printf("SCTP checksum offload is %s\n", 4321 (tx_offloads & DEV_TX_OFFLOAD_SCTP_CKSUM) ? "hw" : "sw"); 4322 printf("Outer-Ip checksum offload is %s\n", 4323 (tx_offloads & DEV_TX_OFFLOAD_OUTER_IPV4_CKSUM) ? "hw" : "sw"); 4324 printf("Outer-Udp checksum offload is %s\n", 4325 (tx_offloads & DEV_TX_OFFLOAD_OUTER_UDP_CKSUM) ? "hw" : "sw"); 4326 4327 /* display warnings if configuration is not supported by the NIC */ 4328 rte_eth_dev_info_get(port_id, &dev_info); 4329 if ((tx_offloads & DEV_TX_OFFLOAD_IPV4_CKSUM) && 4330 (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_IPV4_CKSUM) == 0) { 4331 printf("Warning: hardware IP checksum enabled but not " 4332 "supported by port %d\n", port_id); 4333 } 4334 if ((tx_offloads & DEV_TX_OFFLOAD_UDP_CKSUM) && 4335 (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_UDP_CKSUM) == 0) { 4336 printf("Warning: hardware UDP checksum enabled but not " 4337 "supported by port %d\n", port_id); 4338 } 4339 if ((tx_offloads & DEV_TX_OFFLOAD_TCP_CKSUM) && 4340 (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_TCP_CKSUM) == 0) { 4341 printf("Warning: hardware TCP checksum enabled but not " 4342 "supported by port %d\n", port_id); 4343 } 4344 if ((tx_offloads & DEV_TX_OFFLOAD_SCTP_CKSUM) && 4345 (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_SCTP_CKSUM) == 0) { 4346 printf("Warning: hardware SCTP checksum enabled but not " 4347 "supported by port %d\n", port_id); 4348 } 4349 if ((tx_offloads & DEV_TX_OFFLOAD_OUTER_IPV4_CKSUM) && 4350 (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_OUTER_IPV4_CKSUM) == 0) { 4351 printf("Warning: hardware outer IP checksum enabled but not " 4352 "supported by port %d\n", port_id); 4353 } 4354 if ((tx_offloads & DEV_TX_OFFLOAD_OUTER_UDP_CKSUM) && 4355 (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_OUTER_UDP_CKSUM) 4356 == 0) { 4357 printf("Warning: hardware outer UDP checksum enabled but not " 4358 "supported by port %d\n", port_id); 4359 } 4360 } 4361 4362 static void 4363 cmd_config_queue_tx_offloads(struct rte_port *port) 4364 { 4365 int k; 4366 4367 /* Apply queue tx offloads configuration */ 4368 for (k = 0; k < port->dev_info.max_rx_queues; k++) 4369 port->tx_conf[k].offloads = 4370 port->dev_conf.txmode.offloads; 4371 } 4372 4373 static void 4374 cmd_csum_parsed(void *parsed_result, 4375 __attribute__((unused)) struct cmdline *cl, 4376 __attribute__((unused)) void *data) 4377 { 4378 struct cmd_csum_result *res = parsed_result; 4379 int hw = 0; 4380 uint64_t csum_offloads = 0; 4381 struct rte_eth_dev_info dev_info; 4382 4383 if (port_id_is_invalid(res->port_id, ENABLED_WARN)) { 4384 printf("invalid port %d\n", res->port_id); 4385 return; 4386 } 4387 if (!port_is_stopped(res->port_id)) { 4388 printf("Please stop port %d first\n", res->port_id); 4389 return; 4390 } 4391 4392 rte_eth_dev_info_get(res->port_id, &dev_info); 4393 if (!strcmp(res->mode, "set")) { 4394 4395 if (!strcmp(res->hwsw, "hw")) 4396 hw = 1; 4397 4398 if (!strcmp(res->proto, "ip")) { 4399 if (hw == 0 || (dev_info.tx_offload_capa & 4400 DEV_TX_OFFLOAD_IPV4_CKSUM)) { 4401 csum_offloads |= DEV_TX_OFFLOAD_IPV4_CKSUM; 4402 } else { 4403 printf("IP checksum offload is not supported " 4404 "by port %u\n", res->port_id); 4405 } 4406 } else if (!strcmp(res->proto, "udp")) { 4407 if (hw == 0 || (dev_info.tx_offload_capa & 4408 DEV_TX_OFFLOAD_UDP_CKSUM)) { 4409 csum_offloads |= DEV_TX_OFFLOAD_UDP_CKSUM; 4410 } else { 4411 printf("UDP checksum offload is not supported " 4412 "by port %u\n", res->port_id); 4413 } 4414 } else if (!strcmp(res->proto, "tcp")) { 4415 if (hw == 0 || (dev_info.tx_offload_capa & 4416 DEV_TX_OFFLOAD_TCP_CKSUM)) { 4417 csum_offloads |= DEV_TX_OFFLOAD_TCP_CKSUM; 4418 } else { 4419 printf("TCP checksum offload is not supported " 4420 "by port %u\n", res->port_id); 4421 } 4422 } else if (!strcmp(res->proto, "sctp")) { 4423 if (hw == 0 || (dev_info.tx_offload_capa & 4424 DEV_TX_OFFLOAD_SCTP_CKSUM)) { 4425 csum_offloads |= DEV_TX_OFFLOAD_SCTP_CKSUM; 4426 } else { 4427 printf("SCTP checksum offload is not supported " 4428 "by port %u\n", res->port_id); 4429 } 4430 } else if (!strcmp(res->proto, "outer-ip")) { 4431 if (hw == 0 || (dev_info.tx_offload_capa & 4432 DEV_TX_OFFLOAD_OUTER_IPV4_CKSUM)) { 4433 csum_offloads |= 4434 DEV_TX_OFFLOAD_OUTER_IPV4_CKSUM; 4435 } else { 4436 printf("Outer IP checksum offload is not " 4437 "supported by port %u\n", res->port_id); 4438 } 4439 } else if (!strcmp(res->proto, "outer-udp")) { 4440 if (hw == 0 || (dev_info.tx_offload_capa & 4441 DEV_TX_OFFLOAD_OUTER_UDP_CKSUM)) { 4442 csum_offloads |= 4443 DEV_TX_OFFLOAD_OUTER_UDP_CKSUM; 4444 } else { 4445 printf("Outer UDP checksum offload is not " 4446 "supported by port %u\n", res->port_id); 4447 } 4448 } 4449 4450 if (hw) { 4451 ports[res->port_id].dev_conf.txmode.offloads |= 4452 csum_offloads; 4453 } else { 4454 ports[res->port_id].dev_conf.txmode.offloads &= 4455 (~csum_offloads); 4456 } 4457 cmd_config_queue_tx_offloads(&ports[res->port_id]); 4458 } 4459 csum_show(res->port_id); 4460 4461 cmd_reconfig_device_queue(res->port_id, 1, 1); 4462 } 4463 4464 cmdline_parse_token_string_t cmd_csum_csum = 4465 TOKEN_STRING_INITIALIZER(struct cmd_csum_result, 4466 csum, "csum"); 4467 cmdline_parse_token_string_t cmd_csum_mode = 4468 TOKEN_STRING_INITIALIZER(struct cmd_csum_result, 4469 mode, "set"); 4470 cmdline_parse_token_string_t cmd_csum_proto = 4471 TOKEN_STRING_INITIALIZER(struct cmd_csum_result, 4472 proto, "ip#tcp#udp#sctp#outer-ip#outer-udp"); 4473 cmdline_parse_token_string_t cmd_csum_hwsw = 4474 TOKEN_STRING_INITIALIZER(struct cmd_csum_result, 4475 hwsw, "hw#sw"); 4476 cmdline_parse_token_num_t cmd_csum_portid = 4477 TOKEN_NUM_INITIALIZER(struct cmd_csum_result, 4478 port_id, UINT16); 4479 4480 cmdline_parse_inst_t cmd_csum_set = { 4481 .f = cmd_csum_parsed, 4482 .data = NULL, 4483 .help_str = "csum set ip|tcp|udp|sctp|outer-ip|outer-udp hw|sw <port_id>: " 4484 "Enable/Disable hardware calculation of L3/L4 checksum when " 4485 "using csum forward engine", 4486 .tokens = { 4487 (void *)&cmd_csum_csum, 4488 (void *)&cmd_csum_mode, 4489 (void *)&cmd_csum_proto, 4490 (void *)&cmd_csum_hwsw, 4491 (void *)&cmd_csum_portid, 4492 NULL, 4493 }, 4494 }; 4495 4496 cmdline_parse_token_string_t cmd_csum_mode_show = 4497 TOKEN_STRING_INITIALIZER(struct cmd_csum_result, 4498 mode, "show"); 4499 4500 cmdline_parse_inst_t cmd_csum_show = { 4501 .f = cmd_csum_parsed, 4502 .data = NULL, 4503 .help_str = "csum show <port_id>: Show checksum offload configuration", 4504 .tokens = { 4505 (void *)&cmd_csum_csum, 4506 (void *)&cmd_csum_mode_show, 4507 (void *)&cmd_csum_portid, 4508 NULL, 4509 }, 4510 }; 4511 4512 /* Enable/disable tunnel parsing */ 4513 struct cmd_csum_tunnel_result { 4514 cmdline_fixed_string_t csum; 4515 cmdline_fixed_string_t parse; 4516 cmdline_fixed_string_t onoff; 4517 portid_t port_id; 4518 }; 4519 4520 static void 4521 cmd_csum_tunnel_parsed(void *parsed_result, 4522 __attribute__((unused)) struct cmdline *cl, 4523 __attribute__((unused)) void *data) 4524 { 4525 struct cmd_csum_tunnel_result *res = parsed_result; 4526 4527 if (port_id_is_invalid(res->port_id, ENABLED_WARN)) 4528 return; 4529 4530 if (!strcmp(res->onoff, "on")) 4531 ports[res->port_id].parse_tunnel = 1; 4532 else 4533 ports[res->port_id].parse_tunnel = 0; 4534 4535 csum_show(res->port_id); 4536 } 4537 4538 cmdline_parse_token_string_t cmd_csum_tunnel_csum = 4539 TOKEN_STRING_INITIALIZER(struct cmd_csum_tunnel_result, 4540 csum, "csum"); 4541 cmdline_parse_token_string_t cmd_csum_tunnel_parse = 4542 TOKEN_STRING_INITIALIZER(struct cmd_csum_tunnel_result, 4543 parse, "parse-tunnel"); 4544 cmdline_parse_token_string_t cmd_csum_tunnel_onoff = 4545 TOKEN_STRING_INITIALIZER(struct cmd_csum_tunnel_result, 4546 onoff, "on#off"); 4547 cmdline_parse_token_num_t cmd_csum_tunnel_portid = 4548 TOKEN_NUM_INITIALIZER(struct cmd_csum_tunnel_result, 4549 port_id, UINT16); 4550 4551 cmdline_parse_inst_t cmd_csum_tunnel = { 4552 .f = cmd_csum_tunnel_parsed, 4553 .data = NULL, 4554 .help_str = "csum parse-tunnel on|off <port_id>: " 4555 "Enable/Disable parsing of tunnels for csum engine", 4556 .tokens = { 4557 (void *)&cmd_csum_tunnel_csum, 4558 (void *)&cmd_csum_tunnel_parse, 4559 (void *)&cmd_csum_tunnel_onoff, 4560 (void *)&cmd_csum_tunnel_portid, 4561 NULL, 4562 }, 4563 }; 4564 4565 /* *** ENABLE HARDWARE SEGMENTATION IN TX NON-TUNNELED PACKETS *** */ 4566 struct cmd_tso_set_result { 4567 cmdline_fixed_string_t tso; 4568 cmdline_fixed_string_t mode; 4569 uint16_t tso_segsz; 4570 portid_t port_id; 4571 }; 4572 4573 static void 4574 cmd_tso_set_parsed(void *parsed_result, 4575 __attribute__((unused)) struct cmdline *cl, 4576 __attribute__((unused)) void *data) 4577 { 4578 struct cmd_tso_set_result *res = parsed_result; 4579 struct rte_eth_dev_info dev_info; 4580 4581 if (port_id_is_invalid(res->port_id, ENABLED_WARN)) 4582 return; 4583 if (!port_is_stopped(res->port_id)) { 4584 printf("Please stop port %d first\n", res->port_id); 4585 return; 4586 } 4587 4588 if (!strcmp(res->mode, "set")) 4589 ports[res->port_id].tso_segsz = res->tso_segsz; 4590 4591 rte_eth_dev_info_get(res->port_id, &dev_info); 4592 if ((ports[res->port_id].tso_segsz != 0) && 4593 (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_TCP_TSO) == 0) { 4594 printf("Error: TSO is not supported by port %d\n", 4595 res->port_id); 4596 return; 4597 } 4598 4599 if (ports[res->port_id].tso_segsz == 0) { 4600 ports[res->port_id].dev_conf.txmode.offloads &= 4601 ~DEV_TX_OFFLOAD_TCP_TSO; 4602 printf("TSO for non-tunneled packets is disabled\n"); 4603 } else { 4604 ports[res->port_id].dev_conf.txmode.offloads |= 4605 DEV_TX_OFFLOAD_TCP_TSO; 4606 printf("TSO segment size for non-tunneled packets is %d\n", 4607 ports[res->port_id].tso_segsz); 4608 } 4609 cmd_config_queue_tx_offloads(&ports[res->port_id]); 4610 4611 /* display warnings if configuration is not supported by the NIC */ 4612 rte_eth_dev_info_get(res->port_id, &dev_info); 4613 if ((ports[res->port_id].tso_segsz != 0) && 4614 (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_TCP_TSO) == 0) { 4615 printf("Warning: TSO enabled but not " 4616 "supported by port %d\n", res->port_id); 4617 } 4618 4619 cmd_reconfig_device_queue(res->port_id, 1, 1); 4620 } 4621 4622 cmdline_parse_token_string_t cmd_tso_set_tso = 4623 TOKEN_STRING_INITIALIZER(struct cmd_tso_set_result, 4624 tso, "tso"); 4625 cmdline_parse_token_string_t cmd_tso_set_mode = 4626 TOKEN_STRING_INITIALIZER(struct cmd_tso_set_result, 4627 mode, "set"); 4628 cmdline_parse_token_num_t cmd_tso_set_tso_segsz = 4629 TOKEN_NUM_INITIALIZER(struct cmd_tso_set_result, 4630 tso_segsz, UINT16); 4631 cmdline_parse_token_num_t cmd_tso_set_portid = 4632 TOKEN_NUM_INITIALIZER(struct cmd_tso_set_result, 4633 port_id, UINT16); 4634 4635 cmdline_parse_inst_t cmd_tso_set = { 4636 .f = cmd_tso_set_parsed, 4637 .data = NULL, 4638 .help_str = "tso set <tso_segsz> <port_id>: " 4639 "Set TSO segment size of non-tunneled packets for csum engine " 4640 "(0 to disable)", 4641 .tokens = { 4642 (void *)&cmd_tso_set_tso, 4643 (void *)&cmd_tso_set_mode, 4644 (void *)&cmd_tso_set_tso_segsz, 4645 (void *)&cmd_tso_set_portid, 4646 NULL, 4647 }, 4648 }; 4649 4650 cmdline_parse_token_string_t cmd_tso_show_mode = 4651 TOKEN_STRING_INITIALIZER(struct cmd_tso_set_result, 4652 mode, "show"); 4653 4654 4655 cmdline_parse_inst_t cmd_tso_show = { 4656 .f = cmd_tso_set_parsed, 4657 .data = NULL, 4658 .help_str = "tso show <port_id>: " 4659 "Show TSO segment size of non-tunneled packets for csum engine", 4660 .tokens = { 4661 (void *)&cmd_tso_set_tso, 4662 (void *)&cmd_tso_show_mode, 4663 (void *)&cmd_tso_set_portid, 4664 NULL, 4665 }, 4666 }; 4667 4668 /* *** ENABLE HARDWARE SEGMENTATION IN TX TUNNELED PACKETS *** */ 4669 struct cmd_tunnel_tso_set_result { 4670 cmdline_fixed_string_t tso; 4671 cmdline_fixed_string_t mode; 4672 uint16_t tso_segsz; 4673 portid_t port_id; 4674 }; 4675 4676 static struct rte_eth_dev_info 4677 check_tunnel_tso_nic_support(portid_t port_id) 4678 { 4679 struct rte_eth_dev_info dev_info; 4680 4681 rte_eth_dev_info_get(port_id, &dev_info); 4682 if (!(dev_info.tx_offload_capa & DEV_TX_OFFLOAD_VXLAN_TNL_TSO)) 4683 printf("Warning: VXLAN TUNNEL TSO not supported therefore " 4684 "not enabled for port %d\n", port_id); 4685 if (!(dev_info.tx_offload_capa & DEV_TX_OFFLOAD_GRE_TNL_TSO)) 4686 printf("Warning: GRE TUNNEL TSO not supported therefore " 4687 "not enabled for port %d\n", port_id); 4688 if (!(dev_info.tx_offload_capa & DEV_TX_OFFLOAD_IPIP_TNL_TSO)) 4689 printf("Warning: IPIP TUNNEL TSO not supported therefore " 4690 "not enabled for port %d\n", port_id); 4691 if (!(dev_info.tx_offload_capa & DEV_TX_OFFLOAD_GENEVE_TNL_TSO)) 4692 printf("Warning: GENEVE TUNNEL TSO not supported therefore " 4693 "not enabled for port %d\n", port_id); 4694 if (!(dev_info.tx_offload_capa & DEV_TX_OFFLOAD_IP_TNL_TSO)) 4695 printf("Warning: IP TUNNEL TSO not supported therefore " 4696 "not enabled for port %d\n", port_id); 4697 if (!(dev_info.tx_offload_capa & DEV_TX_OFFLOAD_UDP_TNL_TSO)) 4698 printf("Warning: UDP TUNNEL TSO not supported therefore " 4699 "not enabled for port %d\n", port_id); 4700 return dev_info; 4701 } 4702 4703 static void 4704 cmd_tunnel_tso_set_parsed(void *parsed_result, 4705 __attribute__((unused)) struct cmdline *cl, 4706 __attribute__((unused)) void *data) 4707 { 4708 struct cmd_tunnel_tso_set_result *res = parsed_result; 4709 struct rte_eth_dev_info dev_info; 4710 4711 if (port_id_is_invalid(res->port_id, ENABLED_WARN)) 4712 return; 4713 if (!port_is_stopped(res->port_id)) { 4714 printf("Please stop port %d first\n", res->port_id); 4715 return; 4716 } 4717 4718 if (!strcmp(res->mode, "set")) 4719 ports[res->port_id].tunnel_tso_segsz = res->tso_segsz; 4720 4721 dev_info = check_tunnel_tso_nic_support(res->port_id); 4722 if (ports[res->port_id].tunnel_tso_segsz == 0) { 4723 ports[res->port_id].dev_conf.txmode.offloads &= 4724 ~(DEV_TX_OFFLOAD_VXLAN_TNL_TSO | 4725 DEV_TX_OFFLOAD_GRE_TNL_TSO | 4726 DEV_TX_OFFLOAD_IPIP_TNL_TSO | 4727 DEV_TX_OFFLOAD_GENEVE_TNL_TSO | 4728 DEV_TX_OFFLOAD_IP_TNL_TSO | 4729 DEV_TX_OFFLOAD_UDP_TNL_TSO); 4730 printf("TSO for tunneled packets is disabled\n"); 4731 } else { 4732 uint64_t tso_offloads = (DEV_TX_OFFLOAD_VXLAN_TNL_TSO | 4733 DEV_TX_OFFLOAD_GRE_TNL_TSO | 4734 DEV_TX_OFFLOAD_IPIP_TNL_TSO | 4735 DEV_TX_OFFLOAD_GENEVE_TNL_TSO | 4736 DEV_TX_OFFLOAD_IP_TNL_TSO | 4737 DEV_TX_OFFLOAD_UDP_TNL_TSO); 4738 4739 ports[res->port_id].dev_conf.txmode.offloads |= 4740 (tso_offloads & dev_info.tx_offload_capa); 4741 printf("TSO segment size for tunneled packets is %d\n", 4742 ports[res->port_id].tunnel_tso_segsz); 4743 4744 /* Below conditions are needed to make it work: 4745 * (1) tunnel TSO is supported by the NIC; 4746 * (2) "csum parse_tunnel" must be set so that tunneled pkts 4747 * are recognized; 4748 * (3) for tunneled pkts with outer L3 of IPv4, 4749 * "csum set outer-ip" must be set to hw, because after tso, 4750 * total_len of outer IP header is changed, and the checksum 4751 * of outer IP header calculated by sw should be wrong; that 4752 * is not necessary for IPv6 tunneled pkts because there's no 4753 * checksum in IP header anymore. 4754 */ 4755 4756 if (!ports[res->port_id].parse_tunnel) 4757 printf("Warning: csum parse_tunnel must be set " 4758 "so that tunneled packets are recognized\n"); 4759 if (!(ports[res->port_id].dev_conf.txmode.offloads & 4760 DEV_TX_OFFLOAD_OUTER_IPV4_CKSUM)) 4761 printf("Warning: csum set outer-ip must be set to hw " 4762 "if outer L3 is IPv4; not necessary for IPv6\n"); 4763 } 4764 4765 cmd_config_queue_tx_offloads(&ports[res->port_id]); 4766 cmd_reconfig_device_queue(res->port_id, 1, 1); 4767 } 4768 4769 cmdline_parse_token_string_t cmd_tunnel_tso_set_tso = 4770 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_tso_set_result, 4771 tso, "tunnel_tso"); 4772 cmdline_parse_token_string_t cmd_tunnel_tso_set_mode = 4773 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_tso_set_result, 4774 mode, "set"); 4775 cmdline_parse_token_num_t cmd_tunnel_tso_set_tso_segsz = 4776 TOKEN_NUM_INITIALIZER(struct cmd_tunnel_tso_set_result, 4777 tso_segsz, UINT16); 4778 cmdline_parse_token_num_t cmd_tunnel_tso_set_portid = 4779 TOKEN_NUM_INITIALIZER(struct cmd_tunnel_tso_set_result, 4780 port_id, UINT16); 4781 4782 cmdline_parse_inst_t cmd_tunnel_tso_set = { 4783 .f = cmd_tunnel_tso_set_parsed, 4784 .data = NULL, 4785 .help_str = "tunnel_tso set <tso_segsz> <port_id>: " 4786 "Set TSO segment size of tunneled packets for csum engine " 4787 "(0 to disable)", 4788 .tokens = { 4789 (void *)&cmd_tunnel_tso_set_tso, 4790 (void *)&cmd_tunnel_tso_set_mode, 4791 (void *)&cmd_tunnel_tso_set_tso_segsz, 4792 (void *)&cmd_tunnel_tso_set_portid, 4793 NULL, 4794 }, 4795 }; 4796 4797 cmdline_parse_token_string_t cmd_tunnel_tso_show_mode = 4798 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_tso_set_result, 4799 mode, "show"); 4800 4801 4802 cmdline_parse_inst_t cmd_tunnel_tso_show = { 4803 .f = cmd_tunnel_tso_set_parsed, 4804 .data = NULL, 4805 .help_str = "tunnel_tso show <port_id> " 4806 "Show TSO segment size of tunneled packets for csum engine", 4807 .tokens = { 4808 (void *)&cmd_tunnel_tso_set_tso, 4809 (void *)&cmd_tunnel_tso_show_mode, 4810 (void *)&cmd_tunnel_tso_set_portid, 4811 NULL, 4812 }, 4813 }; 4814 4815 /* *** SET GRO FOR A PORT *** */ 4816 struct cmd_gro_enable_result { 4817 cmdline_fixed_string_t cmd_set; 4818 cmdline_fixed_string_t cmd_port; 4819 cmdline_fixed_string_t cmd_keyword; 4820 cmdline_fixed_string_t cmd_onoff; 4821 portid_t cmd_pid; 4822 }; 4823 4824 static void 4825 cmd_gro_enable_parsed(void *parsed_result, 4826 __attribute__((unused)) struct cmdline *cl, 4827 __attribute__((unused)) void *data) 4828 { 4829 struct cmd_gro_enable_result *res; 4830 4831 res = parsed_result; 4832 if (!strcmp(res->cmd_keyword, "gro")) 4833 setup_gro(res->cmd_onoff, res->cmd_pid); 4834 } 4835 4836 cmdline_parse_token_string_t cmd_gro_enable_set = 4837 TOKEN_STRING_INITIALIZER(struct cmd_gro_enable_result, 4838 cmd_set, "set"); 4839 cmdline_parse_token_string_t cmd_gro_enable_port = 4840 TOKEN_STRING_INITIALIZER(struct cmd_gro_enable_result, 4841 cmd_keyword, "port"); 4842 cmdline_parse_token_num_t cmd_gro_enable_pid = 4843 TOKEN_NUM_INITIALIZER(struct cmd_gro_enable_result, 4844 cmd_pid, UINT16); 4845 cmdline_parse_token_string_t cmd_gro_enable_keyword = 4846 TOKEN_STRING_INITIALIZER(struct cmd_gro_enable_result, 4847 cmd_keyword, "gro"); 4848 cmdline_parse_token_string_t cmd_gro_enable_onoff = 4849 TOKEN_STRING_INITIALIZER(struct cmd_gro_enable_result, 4850 cmd_onoff, "on#off"); 4851 4852 cmdline_parse_inst_t cmd_gro_enable = { 4853 .f = cmd_gro_enable_parsed, 4854 .data = NULL, 4855 .help_str = "set port <port_id> gro on|off", 4856 .tokens = { 4857 (void *)&cmd_gro_enable_set, 4858 (void *)&cmd_gro_enable_port, 4859 (void *)&cmd_gro_enable_pid, 4860 (void *)&cmd_gro_enable_keyword, 4861 (void *)&cmd_gro_enable_onoff, 4862 NULL, 4863 }, 4864 }; 4865 4866 /* *** DISPLAY GRO CONFIGURATION *** */ 4867 struct cmd_gro_show_result { 4868 cmdline_fixed_string_t cmd_show; 4869 cmdline_fixed_string_t cmd_port; 4870 cmdline_fixed_string_t cmd_keyword; 4871 portid_t cmd_pid; 4872 }; 4873 4874 static void 4875 cmd_gro_show_parsed(void *parsed_result, 4876 __attribute__((unused)) struct cmdline *cl, 4877 __attribute__((unused)) void *data) 4878 { 4879 struct cmd_gro_show_result *res; 4880 4881 res = parsed_result; 4882 if (!strcmp(res->cmd_keyword, "gro")) 4883 show_gro(res->cmd_pid); 4884 } 4885 4886 cmdline_parse_token_string_t cmd_gro_show_show = 4887 TOKEN_STRING_INITIALIZER(struct cmd_gro_show_result, 4888 cmd_show, "show"); 4889 cmdline_parse_token_string_t cmd_gro_show_port = 4890 TOKEN_STRING_INITIALIZER(struct cmd_gro_show_result, 4891 cmd_port, "port"); 4892 cmdline_parse_token_num_t cmd_gro_show_pid = 4893 TOKEN_NUM_INITIALIZER(struct cmd_gro_show_result, 4894 cmd_pid, UINT16); 4895 cmdline_parse_token_string_t cmd_gro_show_keyword = 4896 TOKEN_STRING_INITIALIZER(struct cmd_gro_show_result, 4897 cmd_keyword, "gro"); 4898 4899 cmdline_parse_inst_t cmd_gro_show = { 4900 .f = cmd_gro_show_parsed, 4901 .data = NULL, 4902 .help_str = "show port <port_id> gro", 4903 .tokens = { 4904 (void *)&cmd_gro_show_show, 4905 (void *)&cmd_gro_show_port, 4906 (void *)&cmd_gro_show_pid, 4907 (void *)&cmd_gro_show_keyword, 4908 NULL, 4909 }, 4910 }; 4911 4912 /* *** SET FLUSH CYCLES FOR GRO *** */ 4913 struct cmd_gro_flush_result { 4914 cmdline_fixed_string_t cmd_set; 4915 cmdline_fixed_string_t cmd_keyword; 4916 cmdline_fixed_string_t cmd_flush; 4917 uint8_t cmd_cycles; 4918 }; 4919 4920 static void 4921 cmd_gro_flush_parsed(void *parsed_result, 4922 __attribute__((unused)) struct cmdline *cl, 4923 __attribute__((unused)) void *data) 4924 { 4925 struct cmd_gro_flush_result *res; 4926 4927 res = parsed_result; 4928 if ((!strcmp(res->cmd_keyword, "gro")) && 4929 (!strcmp(res->cmd_flush, "flush"))) 4930 setup_gro_flush_cycles(res->cmd_cycles); 4931 } 4932 4933 cmdline_parse_token_string_t cmd_gro_flush_set = 4934 TOKEN_STRING_INITIALIZER(struct cmd_gro_flush_result, 4935 cmd_set, "set"); 4936 cmdline_parse_token_string_t cmd_gro_flush_keyword = 4937 TOKEN_STRING_INITIALIZER(struct cmd_gro_flush_result, 4938 cmd_keyword, "gro"); 4939 cmdline_parse_token_string_t cmd_gro_flush_flush = 4940 TOKEN_STRING_INITIALIZER(struct cmd_gro_flush_result, 4941 cmd_flush, "flush"); 4942 cmdline_parse_token_num_t cmd_gro_flush_cycles = 4943 TOKEN_NUM_INITIALIZER(struct cmd_gro_flush_result, 4944 cmd_cycles, UINT8); 4945 4946 cmdline_parse_inst_t cmd_gro_flush = { 4947 .f = cmd_gro_flush_parsed, 4948 .data = NULL, 4949 .help_str = "set gro flush <cycles>", 4950 .tokens = { 4951 (void *)&cmd_gro_flush_set, 4952 (void *)&cmd_gro_flush_keyword, 4953 (void *)&cmd_gro_flush_flush, 4954 (void *)&cmd_gro_flush_cycles, 4955 NULL, 4956 }, 4957 }; 4958 4959 /* *** ENABLE/DISABLE GSO *** */ 4960 struct cmd_gso_enable_result { 4961 cmdline_fixed_string_t cmd_set; 4962 cmdline_fixed_string_t cmd_port; 4963 cmdline_fixed_string_t cmd_keyword; 4964 cmdline_fixed_string_t cmd_mode; 4965 portid_t cmd_pid; 4966 }; 4967 4968 static void 4969 cmd_gso_enable_parsed(void *parsed_result, 4970 __attribute__((unused)) struct cmdline *cl, 4971 __attribute__((unused)) void *data) 4972 { 4973 struct cmd_gso_enable_result *res; 4974 4975 res = parsed_result; 4976 if (!strcmp(res->cmd_keyword, "gso")) 4977 setup_gso(res->cmd_mode, res->cmd_pid); 4978 } 4979 4980 cmdline_parse_token_string_t cmd_gso_enable_set = 4981 TOKEN_STRING_INITIALIZER(struct cmd_gso_enable_result, 4982 cmd_set, "set"); 4983 cmdline_parse_token_string_t cmd_gso_enable_port = 4984 TOKEN_STRING_INITIALIZER(struct cmd_gso_enable_result, 4985 cmd_port, "port"); 4986 cmdline_parse_token_string_t cmd_gso_enable_keyword = 4987 TOKEN_STRING_INITIALIZER(struct cmd_gso_enable_result, 4988 cmd_keyword, "gso"); 4989 cmdline_parse_token_string_t cmd_gso_enable_mode = 4990 TOKEN_STRING_INITIALIZER(struct cmd_gso_enable_result, 4991 cmd_mode, "on#off"); 4992 cmdline_parse_token_num_t cmd_gso_enable_pid = 4993 TOKEN_NUM_INITIALIZER(struct cmd_gso_enable_result, 4994 cmd_pid, UINT16); 4995 4996 cmdline_parse_inst_t cmd_gso_enable = { 4997 .f = cmd_gso_enable_parsed, 4998 .data = NULL, 4999 .help_str = "set port <port_id> gso on|off", 5000 .tokens = { 5001 (void *)&cmd_gso_enable_set, 5002 (void *)&cmd_gso_enable_port, 5003 (void *)&cmd_gso_enable_pid, 5004 (void *)&cmd_gso_enable_keyword, 5005 (void *)&cmd_gso_enable_mode, 5006 NULL, 5007 }, 5008 }; 5009 5010 /* *** SET MAX PACKET LENGTH FOR GSO SEGMENTS *** */ 5011 struct cmd_gso_size_result { 5012 cmdline_fixed_string_t cmd_set; 5013 cmdline_fixed_string_t cmd_keyword; 5014 cmdline_fixed_string_t cmd_segsz; 5015 uint16_t cmd_size; 5016 }; 5017 5018 static void 5019 cmd_gso_size_parsed(void *parsed_result, 5020 __attribute__((unused)) struct cmdline *cl, 5021 __attribute__((unused)) void *data) 5022 { 5023 struct cmd_gso_size_result *res = parsed_result; 5024 5025 if (test_done == 0) { 5026 printf("Before setting GSO segsz, please first" 5027 " stop fowarding\n"); 5028 return; 5029 } 5030 5031 if (!strcmp(res->cmd_keyword, "gso") && 5032 !strcmp(res->cmd_segsz, "segsz")) { 5033 if (res->cmd_size < RTE_GSO_SEG_SIZE_MIN) 5034 printf("gso_size should be larger than %zu." 5035 " Please input a legal value\n", 5036 RTE_GSO_SEG_SIZE_MIN); 5037 else 5038 gso_max_segment_size = res->cmd_size; 5039 } 5040 } 5041 5042 cmdline_parse_token_string_t cmd_gso_size_set = 5043 TOKEN_STRING_INITIALIZER(struct cmd_gso_size_result, 5044 cmd_set, "set"); 5045 cmdline_parse_token_string_t cmd_gso_size_keyword = 5046 TOKEN_STRING_INITIALIZER(struct cmd_gso_size_result, 5047 cmd_keyword, "gso"); 5048 cmdline_parse_token_string_t cmd_gso_size_segsz = 5049 TOKEN_STRING_INITIALIZER(struct cmd_gso_size_result, 5050 cmd_segsz, "segsz"); 5051 cmdline_parse_token_num_t cmd_gso_size_size = 5052 TOKEN_NUM_INITIALIZER(struct cmd_gso_size_result, 5053 cmd_size, UINT16); 5054 5055 cmdline_parse_inst_t cmd_gso_size = { 5056 .f = cmd_gso_size_parsed, 5057 .data = NULL, 5058 .help_str = "set gso segsz <length>", 5059 .tokens = { 5060 (void *)&cmd_gso_size_set, 5061 (void *)&cmd_gso_size_keyword, 5062 (void *)&cmd_gso_size_segsz, 5063 (void *)&cmd_gso_size_size, 5064 NULL, 5065 }, 5066 }; 5067 5068 /* *** SHOW GSO CONFIGURATION *** */ 5069 struct cmd_gso_show_result { 5070 cmdline_fixed_string_t cmd_show; 5071 cmdline_fixed_string_t cmd_port; 5072 cmdline_fixed_string_t cmd_keyword; 5073 portid_t cmd_pid; 5074 }; 5075 5076 static void 5077 cmd_gso_show_parsed(void *parsed_result, 5078 __attribute__((unused)) struct cmdline *cl, 5079 __attribute__((unused)) void *data) 5080 { 5081 struct cmd_gso_show_result *res = parsed_result; 5082 5083 if (!rte_eth_dev_is_valid_port(res->cmd_pid)) { 5084 printf("invalid port id %u\n", res->cmd_pid); 5085 return; 5086 } 5087 if (!strcmp(res->cmd_keyword, "gso")) { 5088 if (gso_ports[res->cmd_pid].enable) { 5089 printf("Max GSO'd packet size: %uB\n" 5090 "Supported GSO types: TCP/IPv4, " 5091 "UDP/IPv4, VxLAN with inner " 5092 "TCP/IPv4 packet, GRE with inner " 5093 "TCP/IPv4 packet\n", 5094 gso_max_segment_size); 5095 } else 5096 printf("GSO is not enabled on Port %u\n", res->cmd_pid); 5097 } 5098 } 5099 5100 cmdline_parse_token_string_t cmd_gso_show_show = 5101 TOKEN_STRING_INITIALIZER(struct cmd_gso_show_result, 5102 cmd_show, "show"); 5103 cmdline_parse_token_string_t cmd_gso_show_port = 5104 TOKEN_STRING_INITIALIZER(struct cmd_gso_show_result, 5105 cmd_port, "port"); 5106 cmdline_parse_token_string_t cmd_gso_show_keyword = 5107 TOKEN_STRING_INITIALIZER(struct cmd_gso_show_result, 5108 cmd_keyword, "gso"); 5109 cmdline_parse_token_num_t cmd_gso_show_pid = 5110 TOKEN_NUM_INITIALIZER(struct cmd_gso_show_result, 5111 cmd_pid, UINT16); 5112 5113 cmdline_parse_inst_t cmd_gso_show = { 5114 .f = cmd_gso_show_parsed, 5115 .data = NULL, 5116 .help_str = "show port <port_id> gso", 5117 .tokens = { 5118 (void *)&cmd_gso_show_show, 5119 (void *)&cmd_gso_show_port, 5120 (void *)&cmd_gso_show_pid, 5121 (void *)&cmd_gso_show_keyword, 5122 NULL, 5123 }, 5124 }; 5125 5126 /* *** ENABLE/DISABLE FLUSH ON RX STREAMS *** */ 5127 struct cmd_set_flush_rx { 5128 cmdline_fixed_string_t set; 5129 cmdline_fixed_string_t flush_rx; 5130 cmdline_fixed_string_t mode; 5131 }; 5132 5133 static void 5134 cmd_set_flush_rx_parsed(void *parsed_result, 5135 __attribute__((unused)) struct cmdline *cl, 5136 __attribute__((unused)) void *data) 5137 { 5138 struct cmd_set_flush_rx *res = parsed_result; 5139 no_flush_rx = (uint8_t)((strcmp(res->mode, "on") == 0) ? 0 : 1); 5140 } 5141 5142 cmdline_parse_token_string_t cmd_setflushrx_set = 5143 TOKEN_STRING_INITIALIZER(struct cmd_set_flush_rx, 5144 set, "set"); 5145 cmdline_parse_token_string_t cmd_setflushrx_flush_rx = 5146 TOKEN_STRING_INITIALIZER(struct cmd_set_flush_rx, 5147 flush_rx, "flush_rx"); 5148 cmdline_parse_token_string_t cmd_setflushrx_mode = 5149 TOKEN_STRING_INITIALIZER(struct cmd_set_flush_rx, 5150 mode, "on#off"); 5151 5152 5153 cmdline_parse_inst_t cmd_set_flush_rx = { 5154 .f = cmd_set_flush_rx_parsed, 5155 .help_str = "set flush_rx on|off: Enable/Disable flush on rx streams", 5156 .data = NULL, 5157 .tokens = { 5158 (void *)&cmd_setflushrx_set, 5159 (void *)&cmd_setflushrx_flush_rx, 5160 (void *)&cmd_setflushrx_mode, 5161 NULL, 5162 }, 5163 }; 5164 5165 /* *** ENABLE/DISABLE LINK STATUS CHECK *** */ 5166 struct cmd_set_link_check { 5167 cmdline_fixed_string_t set; 5168 cmdline_fixed_string_t link_check; 5169 cmdline_fixed_string_t mode; 5170 }; 5171 5172 static void 5173 cmd_set_link_check_parsed(void *parsed_result, 5174 __attribute__((unused)) struct cmdline *cl, 5175 __attribute__((unused)) void *data) 5176 { 5177 struct cmd_set_link_check *res = parsed_result; 5178 no_link_check = (uint8_t)((strcmp(res->mode, "on") == 0) ? 0 : 1); 5179 } 5180 5181 cmdline_parse_token_string_t cmd_setlinkcheck_set = 5182 TOKEN_STRING_INITIALIZER(struct cmd_set_link_check, 5183 set, "set"); 5184 cmdline_parse_token_string_t cmd_setlinkcheck_link_check = 5185 TOKEN_STRING_INITIALIZER(struct cmd_set_link_check, 5186 link_check, "link_check"); 5187 cmdline_parse_token_string_t cmd_setlinkcheck_mode = 5188 TOKEN_STRING_INITIALIZER(struct cmd_set_link_check, 5189 mode, "on#off"); 5190 5191 5192 cmdline_parse_inst_t cmd_set_link_check = { 5193 .f = cmd_set_link_check_parsed, 5194 .help_str = "set link_check on|off: Enable/Disable link status check " 5195 "when starting/stopping a port", 5196 .data = NULL, 5197 .tokens = { 5198 (void *)&cmd_setlinkcheck_set, 5199 (void *)&cmd_setlinkcheck_link_check, 5200 (void *)&cmd_setlinkcheck_mode, 5201 NULL, 5202 }, 5203 }; 5204 5205 /* *** SET NIC BYPASS MODE *** */ 5206 struct cmd_set_bypass_mode_result { 5207 cmdline_fixed_string_t set; 5208 cmdline_fixed_string_t bypass; 5209 cmdline_fixed_string_t mode; 5210 cmdline_fixed_string_t value; 5211 portid_t port_id; 5212 }; 5213 5214 static void 5215 cmd_set_bypass_mode_parsed(void *parsed_result, 5216 __attribute__((unused)) struct cmdline *cl, 5217 __attribute__((unused)) void *data) 5218 { 5219 struct cmd_set_bypass_mode_result *res = parsed_result; 5220 portid_t port_id = res->port_id; 5221 int32_t rc = -EINVAL; 5222 5223 #if defined RTE_LIBRTE_IXGBE_PMD && defined RTE_LIBRTE_IXGBE_BYPASS 5224 uint32_t bypass_mode = RTE_PMD_IXGBE_BYPASS_MODE_NORMAL; 5225 5226 if (!strcmp(res->value, "bypass")) 5227 bypass_mode = RTE_PMD_IXGBE_BYPASS_MODE_BYPASS; 5228 else if (!strcmp(res->value, "isolate")) 5229 bypass_mode = RTE_PMD_IXGBE_BYPASS_MODE_ISOLATE; 5230 else 5231 bypass_mode = RTE_PMD_IXGBE_BYPASS_MODE_NORMAL; 5232 5233 /* Set the bypass mode for the relevant port. */ 5234 rc = rte_pmd_ixgbe_bypass_state_set(port_id, &bypass_mode); 5235 #endif 5236 if (rc != 0) 5237 printf("\t Failed to set bypass mode for port = %d.\n", port_id); 5238 } 5239 5240 cmdline_parse_token_string_t cmd_setbypass_mode_set = 5241 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_mode_result, 5242 set, "set"); 5243 cmdline_parse_token_string_t cmd_setbypass_mode_bypass = 5244 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_mode_result, 5245 bypass, "bypass"); 5246 cmdline_parse_token_string_t cmd_setbypass_mode_mode = 5247 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_mode_result, 5248 mode, "mode"); 5249 cmdline_parse_token_string_t cmd_setbypass_mode_value = 5250 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_mode_result, 5251 value, "normal#bypass#isolate"); 5252 cmdline_parse_token_num_t cmd_setbypass_mode_port = 5253 TOKEN_NUM_INITIALIZER(struct cmd_set_bypass_mode_result, 5254 port_id, UINT16); 5255 5256 cmdline_parse_inst_t cmd_set_bypass_mode = { 5257 .f = cmd_set_bypass_mode_parsed, 5258 .help_str = "set bypass mode normal|bypass|isolate <port_id>: " 5259 "Set the NIC bypass mode for port_id", 5260 .data = NULL, 5261 .tokens = { 5262 (void *)&cmd_setbypass_mode_set, 5263 (void *)&cmd_setbypass_mode_bypass, 5264 (void *)&cmd_setbypass_mode_mode, 5265 (void *)&cmd_setbypass_mode_value, 5266 (void *)&cmd_setbypass_mode_port, 5267 NULL, 5268 }, 5269 }; 5270 5271 /* *** SET NIC BYPASS EVENT *** */ 5272 struct cmd_set_bypass_event_result { 5273 cmdline_fixed_string_t set; 5274 cmdline_fixed_string_t bypass; 5275 cmdline_fixed_string_t event; 5276 cmdline_fixed_string_t event_value; 5277 cmdline_fixed_string_t mode; 5278 cmdline_fixed_string_t mode_value; 5279 portid_t port_id; 5280 }; 5281 5282 static void 5283 cmd_set_bypass_event_parsed(void *parsed_result, 5284 __attribute__((unused)) struct cmdline *cl, 5285 __attribute__((unused)) void *data) 5286 { 5287 int32_t rc = -EINVAL; 5288 struct cmd_set_bypass_event_result *res = parsed_result; 5289 portid_t port_id = res->port_id; 5290 5291 #if defined RTE_LIBRTE_IXGBE_PMD && defined RTE_LIBRTE_IXGBE_BYPASS 5292 uint32_t bypass_event = RTE_PMD_IXGBE_BYPASS_EVENT_NONE; 5293 uint32_t bypass_mode = RTE_PMD_IXGBE_BYPASS_MODE_NORMAL; 5294 5295 if (!strcmp(res->event_value, "timeout")) 5296 bypass_event = RTE_PMD_IXGBE_BYPASS_EVENT_TIMEOUT; 5297 else if (!strcmp(res->event_value, "os_on")) 5298 bypass_event = RTE_PMD_IXGBE_BYPASS_EVENT_OS_ON; 5299 else if (!strcmp(res->event_value, "os_off")) 5300 bypass_event = RTE_PMD_IXGBE_BYPASS_EVENT_OS_OFF; 5301 else if (!strcmp(res->event_value, "power_on")) 5302 bypass_event = RTE_PMD_IXGBE_BYPASS_EVENT_POWER_ON; 5303 else if (!strcmp(res->event_value, "power_off")) 5304 bypass_event = RTE_PMD_IXGBE_BYPASS_EVENT_POWER_OFF; 5305 else 5306 bypass_event = RTE_PMD_IXGBE_BYPASS_EVENT_NONE; 5307 5308 if (!strcmp(res->mode_value, "bypass")) 5309 bypass_mode = RTE_PMD_IXGBE_BYPASS_MODE_BYPASS; 5310 else if (!strcmp(res->mode_value, "isolate")) 5311 bypass_mode = RTE_PMD_IXGBE_BYPASS_MODE_ISOLATE; 5312 else 5313 bypass_mode = RTE_PMD_IXGBE_BYPASS_MODE_NORMAL; 5314 5315 /* Set the watchdog timeout. */ 5316 if (bypass_event == RTE_PMD_IXGBE_BYPASS_EVENT_TIMEOUT) { 5317 5318 rc = -EINVAL; 5319 if (RTE_PMD_IXGBE_BYPASS_TMT_VALID(bypass_timeout)) { 5320 rc = rte_pmd_ixgbe_bypass_wd_timeout_store(port_id, 5321 bypass_timeout); 5322 } 5323 if (rc != 0) { 5324 printf("Failed to set timeout value %u " 5325 "for port %d, errto code: %d.\n", 5326 bypass_timeout, port_id, rc); 5327 } 5328 } 5329 5330 /* Set the bypass event to transition to bypass mode. */ 5331 rc = rte_pmd_ixgbe_bypass_event_store(port_id, bypass_event, 5332 bypass_mode); 5333 #endif 5334 5335 if (rc != 0) 5336 printf("\t Failed to set bypass event for port = %d.\n", 5337 port_id); 5338 } 5339 5340 cmdline_parse_token_string_t cmd_setbypass_event_set = 5341 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_event_result, 5342 set, "set"); 5343 cmdline_parse_token_string_t cmd_setbypass_event_bypass = 5344 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_event_result, 5345 bypass, "bypass"); 5346 cmdline_parse_token_string_t cmd_setbypass_event_event = 5347 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_event_result, 5348 event, "event"); 5349 cmdline_parse_token_string_t cmd_setbypass_event_event_value = 5350 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_event_result, 5351 event_value, "none#timeout#os_off#os_on#power_on#power_off"); 5352 cmdline_parse_token_string_t cmd_setbypass_event_mode = 5353 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_event_result, 5354 mode, "mode"); 5355 cmdline_parse_token_string_t cmd_setbypass_event_mode_value = 5356 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_event_result, 5357 mode_value, "normal#bypass#isolate"); 5358 cmdline_parse_token_num_t cmd_setbypass_event_port = 5359 TOKEN_NUM_INITIALIZER(struct cmd_set_bypass_event_result, 5360 port_id, UINT16); 5361 5362 cmdline_parse_inst_t cmd_set_bypass_event = { 5363 .f = cmd_set_bypass_event_parsed, 5364 .help_str = "set bypass event none|timeout|os_on|os_off|power_on|" 5365 "power_off mode normal|bypass|isolate <port_id>: " 5366 "Set the NIC bypass event mode for port_id", 5367 .data = NULL, 5368 .tokens = { 5369 (void *)&cmd_setbypass_event_set, 5370 (void *)&cmd_setbypass_event_bypass, 5371 (void *)&cmd_setbypass_event_event, 5372 (void *)&cmd_setbypass_event_event_value, 5373 (void *)&cmd_setbypass_event_mode, 5374 (void *)&cmd_setbypass_event_mode_value, 5375 (void *)&cmd_setbypass_event_port, 5376 NULL, 5377 }, 5378 }; 5379 5380 5381 /* *** SET NIC BYPASS TIMEOUT *** */ 5382 struct cmd_set_bypass_timeout_result { 5383 cmdline_fixed_string_t set; 5384 cmdline_fixed_string_t bypass; 5385 cmdline_fixed_string_t timeout; 5386 cmdline_fixed_string_t value; 5387 }; 5388 5389 static void 5390 cmd_set_bypass_timeout_parsed(void *parsed_result, 5391 __attribute__((unused)) struct cmdline *cl, 5392 __attribute__((unused)) void *data) 5393 { 5394 __rte_unused struct cmd_set_bypass_timeout_result *res = parsed_result; 5395 5396 #if defined RTE_LIBRTE_IXGBE_PMD && defined RTE_LIBRTE_IXGBE_BYPASS 5397 if (!strcmp(res->value, "1.5")) 5398 bypass_timeout = RTE_PMD_IXGBE_BYPASS_TMT_1_5_SEC; 5399 else if (!strcmp(res->value, "2")) 5400 bypass_timeout = RTE_PMD_IXGBE_BYPASS_TMT_2_SEC; 5401 else if (!strcmp(res->value, "3")) 5402 bypass_timeout = RTE_PMD_IXGBE_BYPASS_TMT_3_SEC; 5403 else if (!strcmp(res->value, "4")) 5404 bypass_timeout = RTE_PMD_IXGBE_BYPASS_TMT_4_SEC; 5405 else if (!strcmp(res->value, "8")) 5406 bypass_timeout = RTE_PMD_IXGBE_BYPASS_TMT_8_SEC; 5407 else if (!strcmp(res->value, "16")) 5408 bypass_timeout = RTE_PMD_IXGBE_BYPASS_TMT_16_SEC; 5409 else if (!strcmp(res->value, "32")) 5410 bypass_timeout = RTE_PMD_IXGBE_BYPASS_TMT_32_SEC; 5411 else 5412 bypass_timeout = RTE_PMD_IXGBE_BYPASS_TMT_OFF; 5413 #endif 5414 } 5415 5416 cmdline_parse_token_string_t cmd_setbypass_timeout_set = 5417 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_timeout_result, 5418 set, "set"); 5419 cmdline_parse_token_string_t cmd_setbypass_timeout_bypass = 5420 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_timeout_result, 5421 bypass, "bypass"); 5422 cmdline_parse_token_string_t cmd_setbypass_timeout_timeout = 5423 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_timeout_result, 5424 timeout, "timeout"); 5425 cmdline_parse_token_string_t cmd_setbypass_timeout_value = 5426 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_timeout_result, 5427 value, "0#1.5#2#3#4#8#16#32"); 5428 5429 cmdline_parse_inst_t cmd_set_bypass_timeout = { 5430 .f = cmd_set_bypass_timeout_parsed, 5431 .help_str = "set bypass timeout 0|1.5|2|3|4|8|16|32: " 5432 "Set the NIC bypass watchdog timeout in seconds", 5433 .data = NULL, 5434 .tokens = { 5435 (void *)&cmd_setbypass_timeout_set, 5436 (void *)&cmd_setbypass_timeout_bypass, 5437 (void *)&cmd_setbypass_timeout_timeout, 5438 (void *)&cmd_setbypass_timeout_value, 5439 NULL, 5440 }, 5441 }; 5442 5443 /* *** SHOW NIC BYPASS MODE *** */ 5444 struct cmd_show_bypass_config_result { 5445 cmdline_fixed_string_t show; 5446 cmdline_fixed_string_t bypass; 5447 cmdline_fixed_string_t config; 5448 portid_t port_id; 5449 }; 5450 5451 static void 5452 cmd_show_bypass_config_parsed(void *parsed_result, 5453 __attribute__((unused)) struct cmdline *cl, 5454 __attribute__((unused)) void *data) 5455 { 5456 struct cmd_show_bypass_config_result *res = parsed_result; 5457 portid_t port_id = res->port_id; 5458 int rc = -EINVAL; 5459 #if defined RTE_LIBRTE_IXGBE_PMD && defined RTE_LIBRTE_IXGBE_BYPASS 5460 uint32_t event_mode; 5461 uint32_t bypass_mode; 5462 uint32_t timeout = bypass_timeout; 5463 int i; 5464 5465 static const char * const timeouts[RTE_PMD_IXGBE_BYPASS_TMT_NUM] = 5466 {"off", "1.5", "2", "3", "4", "8", "16", "32"}; 5467 static const char * const modes[RTE_PMD_IXGBE_BYPASS_MODE_NUM] = 5468 {"UNKNOWN", "normal", "bypass", "isolate"}; 5469 static const char * const events[RTE_PMD_IXGBE_BYPASS_EVENT_NUM] = { 5470 "NONE", 5471 "OS/board on", 5472 "power supply on", 5473 "OS/board off", 5474 "power supply off", 5475 "timeout"}; 5476 int num_events = (sizeof events) / (sizeof events[0]); 5477 5478 /* Display the bypass mode.*/ 5479 if (rte_pmd_ixgbe_bypass_state_show(port_id, &bypass_mode) != 0) { 5480 printf("\tFailed to get bypass mode for port = %d\n", port_id); 5481 return; 5482 } 5483 else { 5484 if (!RTE_PMD_IXGBE_BYPASS_MODE_VALID(bypass_mode)) 5485 bypass_mode = RTE_PMD_IXGBE_BYPASS_MODE_NONE; 5486 5487 printf("\tbypass mode = %s\n", modes[bypass_mode]); 5488 } 5489 5490 /* Display the bypass timeout.*/ 5491 if (!RTE_PMD_IXGBE_BYPASS_TMT_VALID(timeout)) 5492 timeout = RTE_PMD_IXGBE_BYPASS_TMT_OFF; 5493 5494 printf("\tbypass timeout = %s\n", timeouts[timeout]); 5495 5496 /* Display the bypass events and associated modes. */ 5497 for (i = RTE_PMD_IXGBE_BYPASS_EVENT_START; i < num_events; i++) { 5498 5499 if (rte_pmd_ixgbe_bypass_event_show(port_id, i, &event_mode)) { 5500 printf("\tFailed to get bypass mode for event = %s\n", 5501 events[i]); 5502 } else { 5503 if (!RTE_PMD_IXGBE_BYPASS_MODE_VALID(event_mode)) 5504 event_mode = RTE_PMD_IXGBE_BYPASS_MODE_NONE; 5505 5506 printf("\tbypass event: %-16s = %s\n", events[i], 5507 modes[event_mode]); 5508 } 5509 } 5510 #endif 5511 if (rc != 0) 5512 printf("\tFailed to get bypass configuration for port = %d\n", 5513 port_id); 5514 } 5515 5516 cmdline_parse_token_string_t cmd_showbypass_config_show = 5517 TOKEN_STRING_INITIALIZER(struct cmd_show_bypass_config_result, 5518 show, "show"); 5519 cmdline_parse_token_string_t cmd_showbypass_config_bypass = 5520 TOKEN_STRING_INITIALIZER(struct cmd_show_bypass_config_result, 5521 bypass, "bypass"); 5522 cmdline_parse_token_string_t cmd_showbypass_config_config = 5523 TOKEN_STRING_INITIALIZER(struct cmd_show_bypass_config_result, 5524 config, "config"); 5525 cmdline_parse_token_num_t cmd_showbypass_config_port = 5526 TOKEN_NUM_INITIALIZER(struct cmd_show_bypass_config_result, 5527 port_id, UINT16); 5528 5529 cmdline_parse_inst_t cmd_show_bypass_config = { 5530 .f = cmd_show_bypass_config_parsed, 5531 .help_str = "show bypass config <port_id>: " 5532 "Show the NIC bypass config for port_id", 5533 .data = NULL, 5534 .tokens = { 5535 (void *)&cmd_showbypass_config_show, 5536 (void *)&cmd_showbypass_config_bypass, 5537 (void *)&cmd_showbypass_config_config, 5538 (void *)&cmd_showbypass_config_port, 5539 NULL, 5540 }, 5541 }; 5542 5543 #ifdef RTE_LIBRTE_PMD_BOND 5544 /* *** SET BONDING MODE *** */ 5545 struct cmd_set_bonding_mode_result { 5546 cmdline_fixed_string_t set; 5547 cmdline_fixed_string_t bonding; 5548 cmdline_fixed_string_t mode; 5549 uint8_t value; 5550 portid_t port_id; 5551 }; 5552 5553 static void cmd_set_bonding_mode_parsed(void *parsed_result, 5554 __attribute__((unused)) struct cmdline *cl, 5555 __attribute__((unused)) void *data) 5556 { 5557 struct cmd_set_bonding_mode_result *res = parsed_result; 5558 portid_t port_id = res->port_id; 5559 5560 /* Set the bonding mode for the relevant port. */ 5561 if (0 != rte_eth_bond_mode_set(port_id, res->value)) 5562 printf("\t Failed to set bonding mode for port = %d.\n", port_id); 5563 } 5564 5565 cmdline_parse_token_string_t cmd_setbonding_mode_set = 5566 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_mode_result, 5567 set, "set"); 5568 cmdline_parse_token_string_t cmd_setbonding_mode_bonding = 5569 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_mode_result, 5570 bonding, "bonding"); 5571 cmdline_parse_token_string_t cmd_setbonding_mode_mode = 5572 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_mode_result, 5573 mode, "mode"); 5574 cmdline_parse_token_num_t cmd_setbonding_mode_value = 5575 TOKEN_NUM_INITIALIZER(struct cmd_set_bonding_mode_result, 5576 value, UINT8); 5577 cmdline_parse_token_num_t cmd_setbonding_mode_port = 5578 TOKEN_NUM_INITIALIZER(struct cmd_set_bonding_mode_result, 5579 port_id, UINT16); 5580 5581 cmdline_parse_inst_t cmd_set_bonding_mode = { 5582 .f = cmd_set_bonding_mode_parsed, 5583 .help_str = "set bonding mode <mode_value> <port_id>: " 5584 "Set the bonding mode for port_id", 5585 .data = NULL, 5586 .tokens = { 5587 (void *) &cmd_setbonding_mode_set, 5588 (void *) &cmd_setbonding_mode_bonding, 5589 (void *) &cmd_setbonding_mode_mode, 5590 (void *) &cmd_setbonding_mode_value, 5591 (void *) &cmd_setbonding_mode_port, 5592 NULL 5593 } 5594 }; 5595 5596 /* *** SET BONDING SLOW_QUEUE SW/HW *** */ 5597 struct cmd_set_bonding_lacp_dedicated_queues_result { 5598 cmdline_fixed_string_t set; 5599 cmdline_fixed_string_t bonding; 5600 cmdline_fixed_string_t lacp; 5601 cmdline_fixed_string_t dedicated_queues; 5602 portid_t port_id; 5603 cmdline_fixed_string_t mode; 5604 }; 5605 5606 static void cmd_set_bonding_lacp_dedicated_queues_parsed(void *parsed_result, 5607 __attribute__((unused)) struct cmdline *cl, 5608 __attribute__((unused)) void *data) 5609 { 5610 struct cmd_set_bonding_lacp_dedicated_queues_result *res = parsed_result; 5611 portid_t port_id = res->port_id; 5612 struct rte_port *port; 5613 5614 port = &ports[port_id]; 5615 5616 /** Check if the port is not started **/ 5617 if (port->port_status != RTE_PORT_STOPPED) { 5618 printf("Please stop port %d first\n", port_id); 5619 return; 5620 } 5621 5622 if (!strcmp(res->mode, "enable")) { 5623 if (rte_eth_bond_8023ad_dedicated_queues_enable(port_id) == 0) 5624 printf("Dedicate queues for LACP control packets" 5625 " enabled\n"); 5626 else 5627 printf("Enabling dedicate queues for LACP control " 5628 "packets on port %d failed\n", port_id); 5629 } else if (!strcmp(res->mode, "disable")) { 5630 if (rte_eth_bond_8023ad_dedicated_queues_disable(port_id) == 0) 5631 printf("Dedicated queues for LACP control packets " 5632 "disabled\n"); 5633 else 5634 printf("Disabling dedicated queues for LACP control " 5635 "traffic on port %d failed\n", port_id); 5636 } 5637 } 5638 5639 cmdline_parse_token_string_t cmd_setbonding_lacp_dedicated_queues_set = 5640 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_lacp_dedicated_queues_result, 5641 set, "set"); 5642 cmdline_parse_token_string_t cmd_setbonding_lacp_dedicated_queues_bonding = 5643 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_lacp_dedicated_queues_result, 5644 bonding, "bonding"); 5645 cmdline_parse_token_string_t cmd_setbonding_lacp_dedicated_queues_lacp = 5646 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_lacp_dedicated_queues_result, 5647 lacp, "lacp"); 5648 cmdline_parse_token_string_t cmd_setbonding_lacp_dedicated_queues_dedicated_queues = 5649 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_lacp_dedicated_queues_result, 5650 dedicated_queues, "dedicated_queues"); 5651 cmdline_parse_token_num_t cmd_setbonding_lacp_dedicated_queues_port_id = 5652 TOKEN_NUM_INITIALIZER(struct cmd_set_bonding_lacp_dedicated_queues_result, 5653 port_id, UINT16); 5654 cmdline_parse_token_string_t cmd_setbonding_lacp_dedicated_queues_mode = 5655 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_lacp_dedicated_queues_result, 5656 mode, "enable#disable"); 5657 5658 cmdline_parse_inst_t cmd_set_lacp_dedicated_queues = { 5659 .f = cmd_set_bonding_lacp_dedicated_queues_parsed, 5660 .help_str = "set bonding lacp dedicated_queues <port_id> " 5661 "enable|disable: " 5662 "Enable/disable dedicated queues for LACP control traffic for port_id", 5663 .data = NULL, 5664 .tokens = { 5665 (void *)&cmd_setbonding_lacp_dedicated_queues_set, 5666 (void *)&cmd_setbonding_lacp_dedicated_queues_bonding, 5667 (void *)&cmd_setbonding_lacp_dedicated_queues_lacp, 5668 (void *)&cmd_setbonding_lacp_dedicated_queues_dedicated_queues, 5669 (void *)&cmd_setbonding_lacp_dedicated_queues_port_id, 5670 (void *)&cmd_setbonding_lacp_dedicated_queues_mode, 5671 NULL 5672 } 5673 }; 5674 5675 /* *** SET BALANCE XMIT POLICY *** */ 5676 struct cmd_set_bonding_balance_xmit_policy_result { 5677 cmdline_fixed_string_t set; 5678 cmdline_fixed_string_t bonding; 5679 cmdline_fixed_string_t balance_xmit_policy; 5680 portid_t port_id; 5681 cmdline_fixed_string_t policy; 5682 }; 5683 5684 static void cmd_set_bonding_balance_xmit_policy_parsed(void *parsed_result, 5685 __attribute__((unused)) struct cmdline *cl, 5686 __attribute__((unused)) void *data) 5687 { 5688 struct cmd_set_bonding_balance_xmit_policy_result *res = parsed_result; 5689 portid_t port_id = res->port_id; 5690 uint8_t policy; 5691 5692 if (!strcmp(res->policy, "l2")) { 5693 policy = BALANCE_XMIT_POLICY_LAYER2; 5694 } else if (!strcmp(res->policy, "l23")) { 5695 policy = BALANCE_XMIT_POLICY_LAYER23; 5696 } else if (!strcmp(res->policy, "l34")) { 5697 policy = BALANCE_XMIT_POLICY_LAYER34; 5698 } else { 5699 printf("\t Invalid xmit policy selection"); 5700 return; 5701 } 5702 5703 /* Set the bonding mode for the relevant port. */ 5704 if (0 != rte_eth_bond_xmit_policy_set(port_id, policy)) { 5705 printf("\t Failed to set bonding balance xmit policy for port = %d.\n", 5706 port_id); 5707 } 5708 } 5709 5710 cmdline_parse_token_string_t cmd_setbonding_balance_xmit_policy_set = 5711 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_balance_xmit_policy_result, 5712 set, "set"); 5713 cmdline_parse_token_string_t cmd_setbonding_balance_xmit_policy_bonding = 5714 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_balance_xmit_policy_result, 5715 bonding, "bonding"); 5716 cmdline_parse_token_string_t cmd_setbonding_balance_xmit_policy_balance_xmit_policy = 5717 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_balance_xmit_policy_result, 5718 balance_xmit_policy, "balance_xmit_policy"); 5719 cmdline_parse_token_num_t cmd_setbonding_balance_xmit_policy_port = 5720 TOKEN_NUM_INITIALIZER(struct cmd_set_bonding_balance_xmit_policy_result, 5721 port_id, UINT16); 5722 cmdline_parse_token_string_t cmd_setbonding_balance_xmit_policy_policy = 5723 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_balance_xmit_policy_result, 5724 policy, "l2#l23#l34"); 5725 5726 cmdline_parse_inst_t cmd_set_balance_xmit_policy = { 5727 .f = cmd_set_bonding_balance_xmit_policy_parsed, 5728 .help_str = "set bonding balance_xmit_policy <port_id> " 5729 "l2|l23|l34: " 5730 "Set the bonding balance_xmit_policy for port_id", 5731 .data = NULL, 5732 .tokens = { 5733 (void *)&cmd_setbonding_balance_xmit_policy_set, 5734 (void *)&cmd_setbonding_balance_xmit_policy_bonding, 5735 (void *)&cmd_setbonding_balance_xmit_policy_balance_xmit_policy, 5736 (void *)&cmd_setbonding_balance_xmit_policy_port, 5737 (void *)&cmd_setbonding_balance_xmit_policy_policy, 5738 NULL 5739 } 5740 }; 5741 5742 /* *** SHOW NIC BONDING CONFIGURATION *** */ 5743 struct cmd_show_bonding_config_result { 5744 cmdline_fixed_string_t show; 5745 cmdline_fixed_string_t bonding; 5746 cmdline_fixed_string_t config; 5747 portid_t port_id; 5748 }; 5749 5750 static void cmd_show_bonding_config_parsed(void *parsed_result, 5751 __attribute__((unused)) struct cmdline *cl, 5752 __attribute__((unused)) void *data) 5753 { 5754 struct cmd_show_bonding_config_result *res = parsed_result; 5755 int bonding_mode, agg_mode; 5756 portid_t slaves[RTE_MAX_ETHPORTS]; 5757 int num_slaves, num_active_slaves; 5758 int primary_id; 5759 int i; 5760 portid_t port_id = res->port_id; 5761 5762 /* Display the bonding mode.*/ 5763 bonding_mode = rte_eth_bond_mode_get(port_id); 5764 if (bonding_mode < 0) { 5765 printf("\tFailed to get bonding mode for port = %d\n", port_id); 5766 return; 5767 } else 5768 printf("\tBonding mode: %d\n", bonding_mode); 5769 5770 if (bonding_mode == BONDING_MODE_BALANCE) { 5771 int balance_xmit_policy; 5772 5773 balance_xmit_policy = rte_eth_bond_xmit_policy_get(port_id); 5774 if (balance_xmit_policy < 0) { 5775 printf("\tFailed to get balance xmit policy for port = %d\n", 5776 port_id); 5777 return; 5778 } else { 5779 printf("\tBalance Xmit Policy: "); 5780 5781 switch (balance_xmit_policy) { 5782 case BALANCE_XMIT_POLICY_LAYER2: 5783 printf("BALANCE_XMIT_POLICY_LAYER2"); 5784 break; 5785 case BALANCE_XMIT_POLICY_LAYER23: 5786 printf("BALANCE_XMIT_POLICY_LAYER23"); 5787 break; 5788 case BALANCE_XMIT_POLICY_LAYER34: 5789 printf("BALANCE_XMIT_POLICY_LAYER34"); 5790 break; 5791 } 5792 printf("\n"); 5793 } 5794 } 5795 5796 if (bonding_mode == BONDING_MODE_8023AD) { 5797 agg_mode = rte_eth_bond_8023ad_agg_selection_get(port_id); 5798 printf("\tIEEE802.3AD Aggregator Mode: "); 5799 switch (agg_mode) { 5800 case AGG_BANDWIDTH: 5801 printf("bandwidth"); 5802 break; 5803 case AGG_STABLE: 5804 printf("stable"); 5805 break; 5806 case AGG_COUNT: 5807 printf("count"); 5808 break; 5809 } 5810 printf("\n"); 5811 } 5812 5813 num_slaves = rte_eth_bond_slaves_get(port_id, slaves, RTE_MAX_ETHPORTS); 5814 5815 if (num_slaves < 0) { 5816 printf("\tFailed to get slave list for port = %d\n", port_id); 5817 return; 5818 } 5819 if (num_slaves > 0) { 5820 printf("\tSlaves (%d): [", num_slaves); 5821 for (i = 0; i < num_slaves - 1; i++) 5822 printf("%d ", slaves[i]); 5823 5824 printf("%d]\n", slaves[num_slaves - 1]); 5825 } else { 5826 printf("\tSlaves: []\n"); 5827 5828 } 5829 5830 num_active_slaves = rte_eth_bond_active_slaves_get(port_id, slaves, 5831 RTE_MAX_ETHPORTS); 5832 5833 if (num_active_slaves < 0) { 5834 printf("\tFailed to get active slave list for port = %d\n", port_id); 5835 return; 5836 } 5837 if (num_active_slaves > 0) { 5838 printf("\tActive Slaves (%d): [", num_active_slaves); 5839 for (i = 0; i < num_active_slaves - 1; i++) 5840 printf("%d ", slaves[i]); 5841 5842 printf("%d]\n", slaves[num_active_slaves - 1]); 5843 5844 } else { 5845 printf("\tActive Slaves: []\n"); 5846 5847 } 5848 5849 primary_id = rte_eth_bond_primary_get(port_id); 5850 if (primary_id < 0) { 5851 printf("\tFailed to get primary slave for port = %d\n", port_id); 5852 return; 5853 } else 5854 printf("\tPrimary: [%d]\n", primary_id); 5855 5856 } 5857 5858 cmdline_parse_token_string_t cmd_showbonding_config_show = 5859 TOKEN_STRING_INITIALIZER(struct cmd_show_bonding_config_result, 5860 show, "show"); 5861 cmdline_parse_token_string_t cmd_showbonding_config_bonding = 5862 TOKEN_STRING_INITIALIZER(struct cmd_show_bonding_config_result, 5863 bonding, "bonding"); 5864 cmdline_parse_token_string_t cmd_showbonding_config_config = 5865 TOKEN_STRING_INITIALIZER(struct cmd_show_bonding_config_result, 5866 config, "config"); 5867 cmdline_parse_token_num_t cmd_showbonding_config_port = 5868 TOKEN_NUM_INITIALIZER(struct cmd_show_bonding_config_result, 5869 port_id, UINT16); 5870 5871 cmdline_parse_inst_t cmd_show_bonding_config = { 5872 .f = cmd_show_bonding_config_parsed, 5873 .help_str = "show bonding config <port_id>: " 5874 "Show the bonding config for port_id", 5875 .data = NULL, 5876 .tokens = { 5877 (void *)&cmd_showbonding_config_show, 5878 (void *)&cmd_showbonding_config_bonding, 5879 (void *)&cmd_showbonding_config_config, 5880 (void *)&cmd_showbonding_config_port, 5881 NULL 5882 } 5883 }; 5884 5885 /* *** SET BONDING PRIMARY *** */ 5886 struct cmd_set_bonding_primary_result { 5887 cmdline_fixed_string_t set; 5888 cmdline_fixed_string_t bonding; 5889 cmdline_fixed_string_t primary; 5890 portid_t slave_id; 5891 portid_t port_id; 5892 }; 5893 5894 static void cmd_set_bonding_primary_parsed(void *parsed_result, 5895 __attribute__((unused)) struct cmdline *cl, 5896 __attribute__((unused)) void *data) 5897 { 5898 struct cmd_set_bonding_primary_result *res = parsed_result; 5899 portid_t master_port_id = res->port_id; 5900 portid_t slave_port_id = res->slave_id; 5901 5902 /* Set the primary slave for a bonded device. */ 5903 if (0 != rte_eth_bond_primary_set(master_port_id, slave_port_id)) { 5904 printf("\t Failed to set primary slave for port = %d.\n", 5905 master_port_id); 5906 return; 5907 } 5908 init_port_config(); 5909 } 5910 5911 cmdline_parse_token_string_t cmd_setbonding_primary_set = 5912 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_primary_result, 5913 set, "set"); 5914 cmdline_parse_token_string_t cmd_setbonding_primary_bonding = 5915 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_primary_result, 5916 bonding, "bonding"); 5917 cmdline_parse_token_string_t cmd_setbonding_primary_primary = 5918 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_primary_result, 5919 primary, "primary"); 5920 cmdline_parse_token_num_t cmd_setbonding_primary_slave = 5921 TOKEN_NUM_INITIALIZER(struct cmd_set_bonding_primary_result, 5922 slave_id, UINT16); 5923 cmdline_parse_token_num_t cmd_setbonding_primary_port = 5924 TOKEN_NUM_INITIALIZER(struct cmd_set_bonding_primary_result, 5925 port_id, UINT16); 5926 5927 cmdline_parse_inst_t cmd_set_bonding_primary = { 5928 .f = cmd_set_bonding_primary_parsed, 5929 .help_str = "set bonding primary <slave_id> <port_id>: " 5930 "Set the primary slave for port_id", 5931 .data = NULL, 5932 .tokens = { 5933 (void *)&cmd_setbonding_primary_set, 5934 (void *)&cmd_setbonding_primary_bonding, 5935 (void *)&cmd_setbonding_primary_primary, 5936 (void *)&cmd_setbonding_primary_slave, 5937 (void *)&cmd_setbonding_primary_port, 5938 NULL 5939 } 5940 }; 5941 5942 /* *** ADD SLAVE *** */ 5943 struct cmd_add_bonding_slave_result { 5944 cmdline_fixed_string_t add; 5945 cmdline_fixed_string_t bonding; 5946 cmdline_fixed_string_t slave; 5947 portid_t slave_id; 5948 portid_t port_id; 5949 }; 5950 5951 static void cmd_add_bonding_slave_parsed(void *parsed_result, 5952 __attribute__((unused)) struct cmdline *cl, 5953 __attribute__((unused)) void *data) 5954 { 5955 struct cmd_add_bonding_slave_result *res = parsed_result; 5956 portid_t master_port_id = res->port_id; 5957 portid_t slave_port_id = res->slave_id; 5958 5959 /* add the slave for a bonded device. */ 5960 if (0 != rte_eth_bond_slave_add(master_port_id, slave_port_id)) { 5961 printf("\t Failed to add slave %d to master port = %d.\n", 5962 slave_port_id, master_port_id); 5963 return; 5964 } 5965 init_port_config(); 5966 set_port_slave_flag(slave_port_id); 5967 } 5968 5969 cmdline_parse_token_string_t cmd_addbonding_slave_add = 5970 TOKEN_STRING_INITIALIZER(struct cmd_add_bonding_slave_result, 5971 add, "add"); 5972 cmdline_parse_token_string_t cmd_addbonding_slave_bonding = 5973 TOKEN_STRING_INITIALIZER(struct cmd_add_bonding_slave_result, 5974 bonding, "bonding"); 5975 cmdline_parse_token_string_t cmd_addbonding_slave_slave = 5976 TOKEN_STRING_INITIALIZER(struct cmd_add_bonding_slave_result, 5977 slave, "slave"); 5978 cmdline_parse_token_num_t cmd_addbonding_slave_slaveid = 5979 TOKEN_NUM_INITIALIZER(struct cmd_add_bonding_slave_result, 5980 slave_id, UINT16); 5981 cmdline_parse_token_num_t cmd_addbonding_slave_port = 5982 TOKEN_NUM_INITIALIZER(struct cmd_add_bonding_slave_result, 5983 port_id, UINT16); 5984 5985 cmdline_parse_inst_t cmd_add_bonding_slave = { 5986 .f = cmd_add_bonding_slave_parsed, 5987 .help_str = "add bonding slave <slave_id> <port_id>: " 5988 "Add a slave device to a bonded device", 5989 .data = NULL, 5990 .tokens = { 5991 (void *)&cmd_addbonding_slave_add, 5992 (void *)&cmd_addbonding_slave_bonding, 5993 (void *)&cmd_addbonding_slave_slave, 5994 (void *)&cmd_addbonding_slave_slaveid, 5995 (void *)&cmd_addbonding_slave_port, 5996 NULL 5997 } 5998 }; 5999 6000 /* *** REMOVE SLAVE *** */ 6001 struct cmd_remove_bonding_slave_result { 6002 cmdline_fixed_string_t remove; 6003 cmdline_fixed_string_t bonding; 6004 cmdline_fixed_string_t slave; 6005 portid_t slave_id; 6006 portid_t port_id; 6007 }; 6008 6009 static void cmd_remove_bonding_slave_parsed(void *parsed_result, 6010 __attribute__((unused)) struct cmdline *cl, 6011 __attribute__((unused)) void *data) 6012 { 6013 struct cmd_remove_bonding_slave_result *res = parsed_result; 6014 portid_t master_port_id = res->port_id; 6015 portid_t slave_port_id = res->slave_id; 6016 6017 /* remove the slave from a bonded device. */ 6018 if (0 != rte_eth_bond_slave_remove(master_port_id, slave_port_id)) { 6019 printf("\t Failed to remove slave %d from master port = %d.\n", 6020 slave_port_id, master_port_id); 6021 return; 6022 } 6023 init_port_config(); 6024 clear_port_slave_flag(slave_port_id); 6025 } 6026 6027 cmdline_parse_token_string_t cmd_removebonding_slave_remove = 6028 TOKEN_STRING_INITIALIZER(struct cmd_remove_bonding_slave_result, 6029 remove, "remove"); 6030 cmdline_parse_token_string_t cmd_removebonding_slave_bonding = 6031 TOKEN_STRING_INITIALIZER(struct cmd_remove_bonding_slave_result, 6032 bonding, "bonding"); 6033 cmdline_parse_token_string_t cmd_removebonding_slave_slave = 6034 TOKEN_STRING_INITIALIZER(struct cmd_remove_bonding_slave_result, 6035 slave, "slave"); 6036 cmdline_parse_token_num_t cmd_removebonding_slave_slaveid = 6037 TOKEN_NUM_INITIALIZER(struct cmd_remove_bonding_slave_result, 6038 slave_id, UINT16); 6039 cmdline_parse_token_num_t cmd_removebonding_slave_port = 6040 TOKEN_NUM_INITIALIZER(struct cmd_remove_bonding_slave_result, 6041 port_id, UINT16); 6042 6043 cmdline_parse_inst_t cmd_remove_bonding_slave = { 6044 .f = cmd_remove_bonding_slave_parsed, 6045 .help_str = "remove bonding slave <slave_id> <port_id>: " 6046 "Remove a slave device from a bonded device", 6047 .data = NULL, 6048 .tokens = { 6049 (void *)&cmd_removebonding_slave_remove, 6050 (void *)&cmd_removebonding_slave_bonding, 6051 (void *)&cmd_removebonding_slave_slave, 6052 (void *)&cmd_removebonding_slave_slaveid, 6053 (void *)&cmd_removebonding_slave_port, 6054 NULL 6055 } 6056 }; 6057 6058 /* *** CREATE BONDED DEVICE *** */ 6059 struct cmd_create_bonded_device_result { 6060 cmdline_fixed_string_t create; 6061 cmdline_fixed_string_t bonded; 6062 cmdline_fixed_string_t device; 6063 uint8_t mode; 6064 uint8_t socket; 6065 }; 6066 6067 static int bond_dev_num = 0; 6068 6069 static void cmd_create_bonded_device_parsed(void *parsed_result, 6070 __attribute__((unused)) struct cmdline *cl, 6071 __attribute__((unused)) void *data) 6072 { 6073 struct cmd_create_bonded_device_result *res = parsed_result; 6074 char ethdev_name[RTE_ETH_NAME_MAX_LEN]; 6075 int port_id; 6076 6077 if (test_done == 0) { 6078 printf("Please stop forwarding first\n"); 6079 return; 6080 } 6081 6082 snprintf(ethdev_name, RTE_ETH_NAME_MAX_LEN, "net_bonding_testpmd_%d", 6083 bond_dev_num++); 6084 6085 /* Create a new bonded device. */ 6086 port_id = rte_eth_bond_create(ethdev_name, res->mode, res->socket); 6087 if (port_id < 0) { 6088 printf("\t Failed to create bonded device.\n"); 6089 return; 6090 } else { 6091 printf("Created new bonded device %s on (port %d).\n", ethdev_name, 6092 port_id); 6093 6094 /* Update number of ports */ 6095 nb_ports = rte_eth_dev_count_avail(); 6096 reconfig(port_id, res->socket); 6097 rte_eth_promiscuous_enable(port_id); 6098 ports[port_id].need_setup = 0; 6099 ports[port_id].port_status = RTE_PORT_STOPPED; 6100 } 6101 6102 } 6103 6104 cmdline_parse_token_string_t cmd_createbonded_device_create = 6105 TOKEN_STRING_INITIALIZER(struct cmd_create_bonded_device_result, 6106 create, "create"); 6107 cmdline_parse_token_string_t cmd_createbonded_device_bonded = 6108 TOKEN_STRING_INITIALIZER(struct cmd_create_bonded_device_result, 6109 bonded, "bonded"); 6110 cmdline_parse_token_string_t cmd_createbonded_device_device = 6111 TOKEN_STRING_INITIALIZER(struct cmd_create_bonded_device_result, 6112 device, "device"); 6113 cmdline_parse_token_num_t cmd_createbonded_device_mode = 6114 TOKEN_NUM_INITIALIZER(struct cmd_create_bonded_device_result, 6115 mode, UINT8); 6116 cmdline_parse_token_num_t cmd_createbonded_device_socket = 6117 TOKEN_NUM_INITIALIZER(struct cmd_create_bonded_device_result, 6118 socket, UINT8); 6119 6120 cmdline_parse_inst_t cmd_create_bonded_device = { 6121 .f = cmd_create_bonded_device_parsed, 6122 .help_str = "create bonded device <mode> <socket>: " 6123 "Create a new bonded device with specific bonding mode and socket", 6124 .data = NULL, 6125 .tokens = { 6126 (void *)&cmd_createbonded_device_create, 6127 (void *)&cmd_createbonded_device_bonded, 6128 (void *)&cmd_createbonded_device_device, 6129 (void *)&cmd_createbonded_device_mode, 6130 (void *)&cmd_createbonded_device_socket, 6131 NULL 6132 } 6133 }; 6134 6135 /* *** SET MAC ADDRESS IN BONDED DEVICE *** */ 6136 struct cmd_set_bond_mac_addr_result { 6137 cmdline_fixed_string_t set; 6138 cmdline_fixed_string_t bonding; 6139 cmdline_fixed_string_t mac_addr; 6140 uint16_t port_num; 6141 struct ether_addr address; 6142 }; 6143 6144 static void cmd_set_bond_mac_addr_parsed(void *parsed_result, 6145 __attribute__((unused)) struct cmdline *cl, 6146 __attribute__((unused)) void *data) 6147 { 6148 struct cmd_set_bond_mac_addr_result *res = parsed_result; 6149 int ret; 6150 6151 if (port_id_is_invalid(res->port_num, ENABLED_WARN)) 6152 return; 6153 6154 ret = rte_eth_bond_mac_address_set(res->port_num, &res->address); 6155 6156 /* check the return value and print it if is < 0 */ 6157 if (ret < 0) 6158 printf("set_bond_mac_addr error: (%s)\n", strerror(-ret)); 6159 } 6160 6161 cmdline_parse_token_string_t cmd_set_bond_mac_addr_set = 6162 TOKEN_STRING_INITIALIZER(struct cmd_set_bond_mac_addr_result, set, "set"); 6163 cmdline_parse_token_string_t cmd_set_bond_mac_addr_bonding = 6164 TOKEN_STRING_INITIALIZER(struct cmd_set_bond_mac_addr_result, bonding, 6165 "bonding"); 6166 cmdline_parse_token_string_t cmd_set_bond_mac_addr_mac = 6167 TOKEN_STRING_INITIALIZER(struct cmd_set_bond_mac_addr_result, mac_addr, 6168 "mac_addr"); 6169 cmdline_parse_token_num_t cmd_set_bond_mac_addr_portnum = 6170 TOKEN_NUM_INITIALIZER(struct cmd_set_bond_mac_addr_result, 6171 port_num, UINT16); 6172 cmdline_parse_token_etheraddr_t cmd_set_bond_mac_addr_addr = 6173 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_bond_mac_addr_result, address); 6174 6175 cmdline_parse_inst_t cmd_set_bond_mac_addr = { 6176 .f = cmd_set_bond_mac_addr_parsed, 6177 .data = (void *) 0, 6178 .help_str = "set bonding mac_addr <port_id> <mac_addr>", 6179 .tokens = { 6180 (void *)&cmd_set_bond_mac_addr_set, 6181 (void *)&cmd_set_bond_mac_addr_bonding, 6182 (void *)&cmd_set_bond_mac_addr_mac, 6183 (void *)&cmd_set_bond_mac_addr_portnum, 6184 (void *)&cmd_set_bond_mac_addr_addr, 6185 NULL 6186 } 6187 }; 6188 6189 6190 /* *** SET LINK STATUS MONITORING POLLING PERIOD ON BONDED DEVICE *** */ 6191 struct cmd_set_bond_mon_period_result { 6192 cmdline_fixed_string_t set; 6193 cmdline_fixed_string_t bonding; 6194 cmdline_fixed_string_t mon_period; 6195 uint16_t port_num; 6196 uint32_t period_ms; 6197 }; 6198 6199 static void cmd_set_bond_mon_period_parsed(void *parsed_result, 6200 __attribute__((unused)) struct cmdline *cl, 6201 __attribute__((unused)) void *data) 6202 { 6203 struct cmd_set_bond_mon_period_result *res = parsed_result; 6204 int ret; 6205 6206 ret = rte_eth_bond_link_monitoring_set(res->port_num, res->period_ms); 6207 6208 /* check the return value and print it if is < 0 */ 6209 if (ret < 0) 6210 printf("set_bond_mac_addr error: (%s)\n", strerror(-ret)); 6211 } 6212 6213 cmdline_parse_token_string_t cmd_set_bond_mon_period_set = 6214 TOKEN_STRING_INITIALIZER(struct cmd_set_bond_mon_period_result, 6215 set, "set"); 6216 cmdline_parse_token_string_t cmd_set_bond_mon_period_bonding = 6217 TOKEN_STRING_INITIALIZER(struct cmd_set_bond_mon_period_result, 6218 bonding, "bonding"); 6219 cmdline_parse_token_string_t cmd_set_bond_mon_period_mon_period = 6220 TOKEN_STRING_INITIALIZER(struct cmd_set_bond_mon_period_result, 6221 mon_period, "mon_period"); 6222 cmdline_parse_token_num_t cmd_set_bond_mon_period_portnum = 6223 TOKEN_NUM_INITIALIZER(struct cmd_set_bond_mon_period_result, 6224 port_num, UINT16); 6225 cmdline_parse_token_num_t cmd_set_bond_mon_period_period_ms = 6226 TOKEN_NUM_INITIALIZER(struct cmd_set_bond_mon_period_result, 6227 period_ms, UINT32); 6228 6229 cmdline_parse_inst_t cmd_set_bond_mon_period = { 6230 .f = cmd_set_bond_mon_period_parsed, 6231 .data = (void *) 0, 6232 .help_str = "set bonding mon_period <port_id> <period_ms>", 6233 .tokens = { 6234 (void *)&cmd_set_bond_mon_period_set, 6235 (void *)&cmd_set_bond_mon_period_bonding, 6236 (void *)&cmd_set_bond_mon_period_mon_period, 6237 (void *)&cmd_set_bond_mon_period_portnum, 6238 (void *)&cmd_set_bond_mon_period_period_ms, 6239 NULL 6240 } 6241 }; 6242 6243 6244 6245 struct cmd_set_bonding_agg_mode_policy_result { 6246 cmdline_fixed_string_t set; 6247 cmdline_fixed_string_t bonding; 6248 cmdline_fixed_string_t agg_mode; 6249 uint16_t port_num; 6250 cmdline_fixed_string_t policy; 6251 }; 6252 6253 6254 static void 6255 cmd_set_bonding_agg_mode(void *parsed_result, 6256 __attribute__((unused)) struct cmdline *cl, 6257 __attribute__((unused)) void *data) 6258 { 6259 struct cmd_set_bonding_agg_mode_policy_result *res = parsed_result; 6260 uint8_t policy = AGG_BANDWIDTH; 6261 6262 if (!strcmp(res->policy, "bandwidth")) 6263 policy = AGG_BANDWIDTH; 6264 else if (!strcmp(res->policy, "stable")) 6265 policy = AGG_STABLE; 6266 else if (!strcmp(res->policy, "count")) 6267 policy = AGG_COUNT; 6268 6269 rte_eth_bond_8023ad_agg_selection_set(res->port_num, policy); 6270 } 6271 6272 6273 cmdline_parse_token_string_t cmd_set_bonding_agg_mode_set = 6274 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_agg_mode_policy_result, 6275 set, "set"); 6276 cmdline_parse_token_string_t cmd_set_bonding_agg_mode_bonding = 6277 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_agg_mode_policy_result, 6278 bonding, "bonding"); 6279 6280 cmdline_parse_token_string_t cmd_set_bonding_agg_mode_agg_mode = 6281 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_agg_mode_policy_result, 6282 agg_mode, "agg_mode"); 6283 6284 cmdline_parse_token_num_t cmd_set_bonding_agg_mode_portnum = 6285 TOKEN_NUM_INITIALIZER(struct cmd_set_bonding_agg_mode_policy_result, 6286 port_num, UINT16); 6287 6288 cmdline_parse_token_string_t cmd_set_bonding_agg_mode_policy_string = 6289 TOKEN_STRING_INITIALIZER( 6290 struct cmd_set_bonding_balance_xmit_policy_result, 6291 policy, "stable#bandwidth#count"); 6292 6293 cmdline_parse_inst_t cmd_set_bonding_agg_mode_policy = { 6294 .f = cmd_set_bonding_agg_mode, 6295 .data = (void *) 0, 6296 .help_str = "set bonding mode IEEE802.3AD aggregator policy <port_id> <agg_name>", 6297 .tokens = { 6298 (void *)&cmd_set_bonding_agg_mode_set, 6299 (void *)&cmd_set_bonding_agg_mode_bonding, 6300 (void *)&cmd_set_bonding_agg_mode_agg_mode, 6301 (void *)&cmd_set_bonding_agg_mode_portnum, 6302 (void *)&cmd_set_bonding_agg_mode_policy_string, 6303 NULL 6304 } 6305 }; 6306 6307 6308 #endif /* RTE_LIBRTE_PMD_BOND */ 6309 6310 /* *** SET FORWARDING MODE *** */ 6311 struct cmd_set_fwd_mode_result { 6312 cmdline_fixed_string_t set; 6313 cmdline_fixed_string_t fwd; 6314 cmdline_fixed_string_t mode; 6315 }; 6316 6317 static void cmd_set_fwd_mode_parsed(void *parsed_result, 6318 __attribute__((unused)) struct cmdline *cl, 6319 __attribute__((unused)) void *data) 6320 { 6321 struct cmd_set_fwd_mode_result *res = parsed_result; 6322 6323 retry_enabled = 0; 6324 set_pkt_forwarding_mode(res->mode); 6325 } 6326 6327 cmdline_parse_token_string_t cmd_setfwd_set = 6328 TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_mode_result, set, "set"); 6329 cmdline_parse_token_string_t cmd_setfwd_fwd = 6330 TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_mode_result, fwd, "fwd"); 6331 cmdline_parse_token_string_t cmd_setfwd_mode = 6332 TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_mode_result, mode, 6333 "" /* defined at init */); 6334 6335 cmdline_parse_inst_t cmd_set_fwd_mode = { 6336 .f = cmd_set_fwd_mode_parsed, 6337 .data = NULL, 6338 .help_str = NULL, /* defined at init */ 6339 .tokens = { 6340 (void *)&cmd_setfwd_set, 6341 (void *)&cmd_setfwd_fwd, 6342 (void *)&cmd_setfwd_mode, 6343 NULL, 6344 }, 6345 }; 6346 6347 static void cmd_set_fwd_mode_init(void) 6348 { 6349 char *modes, *c; 6350 static char token[128]; 6351 static char help[256]; 6352 cmdline_parse_token_string_t *token_struct; 6353 6354 modes = list_pkt_forwarding_modes(); 6355 snprintf(help, sizeof(help), "set fwd %s: " 6356 "Set packet forwarding mode", modes); 6357 cmd_set_fwd_mode.help_str = help; 6358 6359 /* string token separator is # */ 6360 for (c = token; *modes != '\0'; modes++) 6361 if (*modes == '|') 6362 *c++ = '#'; 6363 else 6364 *c++ = *modes; 6365 token_struct = (cmdline_parse_token_string_t*)cmd_set_fwd_mode.tokens[2]; 6366 token_struct->string_data.str = token; 6367 } 6368 6369 /* *** SET RETRY FORWARDING MODE *** */ 6370 struct cmd_set_fwd_retry_mode_result { 6371 cmdline_fixed_string_t set; 6372 cmdline_fixed_string_t fwd; 6373 cmdline_fixed_string_t mode; 6374 cmdline_fixed_string_t retry; 6375 }; 6376 6377 static void cmd_set_fwd_retry_mode_parsed(void *parsed_result, 6378 __attribute__((unused)) struct cmdline *cl, 6379 __attribute__((unused)) void *data) 6380 { 6381 struct cmd_set_fwd_retry_mode_result *res = parsed_result; 6382 6383 retry_enabled = 1; 6384 set_pkt_forwarding_mode(res->mode); 6385 } 6386 6387 cmdline_parse_token_string_t cmd_setfwd_retry_set = 6388 TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_retry_mode_result, 6389 set, "set"); 6390 cmdline_parse_token_string_t cmd_setfwd_retry_fwd = 6391 TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_retry_mode_result, 6392 fwd, "fwd"); 6393 cmdline_parse_token_string_t cmd_setfwd_retry_mode = 6394 TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_retry_mode_result, 6395 mode, 6396 "" /* defined at init */); 6397 cmdline_parse_token_string_t cmd_setfwd_retry_retry = 6398 TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_retry_mode_result, 6399 retry, "retry"); 6400 6401 cmdline_parse_inst_t cmd_set_fwd_retry_mode = { 6402 .f = cmd_set_fwd_retry_mode_parsed, 6403 .data = NULL, 6404 .help_str = NULL, /* defined at init */ 6405 .tokens = { 6406 (void *)&cmd_setfwd_retry_set, 6407 (void *)&cmd_setfwd_retry_fwd, 6408 (void *)&cmd_setfwd_retry_mode, 6409 (void *)&cmd_setfwd_retry_retry, 6410 NULL, 6411 }, 6412 }; 6413 6414 static void cmd_set_fwd_retry_mode_init(void) 6415 { 6416 char *modes, *c; 6417 static char token[128]; 6418 static char help[256]; 6419 cmdline_parse_token_string_t *token_struct; 6420 6421 modes = list_pkt_forwarding_retry_modes(); 6422 snprintf(help, sizeof(help), "set fwd %s retry: " 6423 "Set packet forwarding mode with retry", modes); 6424 cmd_set_fwd_retry_mode.help_str = help; 6425 6426 /* string token separator is # */ 6427 for (c = token; *modes != '\0'; modes++) 6428 if (*modes == '|') 6429 *c++ = '#'; 6430 else 6431 *c++ = *modes; 6432 token_struct = (cmdline_parse_token_string_t *) 6433 cmd_set_fwd_retry_mode.tokens[2]; 6434 token_struct->string_data.str = token; 6435 } 6436 6437 /* *** SET BURST TX DELAY TIME RETRY NUMBER *** */ 6438 struct cmd_set_burst_tx_retry_result { 6439 cmdline_fixed_string_t set; 6440 cmdline_fixed_string_t burst; 6441 cmdline_fixed_string_t tx; 6442 cmdline_fixed_string_t delay; 6443 uint32_t time; 6444 cmdline_fixed_string_t retry; 6445 uint32_t retry_num; 6446 }; 6447 6448 static void cmd_set_burst_tx_retry_parsed(void *parsed_result, 6449 __attribute__((unused)) struct cmdline *cl, 6450 __attribute__((unused)) void *data) 6451 { 6452 struct cmd_set_burst_tx_retry_result *res = parsed_result; 6453 6454 if (!strcmp(res->set, "set") && !strcmp(res->burst, "burst") 6455 && !strcmp(res->tx, "tx")) { 6456 if (!strcmp(res->delay, "delay")) 6457 burst_tx_delay_time = res->time; 6458 if (!strcmp(res->retry, "retry")) 6459 burst_tx_retry_num = res->retry_num; 6460 } 6461 6462 } 6463 6464 cmdline_parse_token_string_t cmd_set_burst_tx_retry_set = 6465 TOKEN_STRING_INITIALIZER(struct cmd_set_burst_tx_retry_result, set, "set"); 6466 cmdline_parse_token_string_t cmd_set_burst_tx_retry_burst = 6467 TOKEN_STRING_INITIALIZER(struct cmd_set_burst_tx_retry_result, burst, 6468 "burst"); 6469 cmdline_parse_token_string_t cmd_set_burst_tx_retry_tx = 6470 TOKEN_STRING_INITIALIZER(struct cmd_set_burst_tx_retry_result, tx, "tx"); 6471 cmdline_parse_token_string_t cmd_set_burst_tx_retry_delay = 6472 TOKEN_STRING_INITIALIZER(struct cmd_set_burst_tx_retry_result, delay, "delay"); 6473 cmdline_parse_token_num_t cmd_set_burst_tx_retry_time = 6474 TOKEN_NUM_INITIALIZER(struct cmd_set_burst_tx_retry_result, time, UINT32); 6475 cmdline_parse_token_string_t cmd_set_burst_tx_retry_retry = 6476 TOKEN_STRING_INITIALIZER(struct cmd_set_burst_tx_retry_result, retry, "retry"); 6477 cmdline_parse_token_num_t cmd_set_burst_tx_retry_retry_num = 6478 TOKEN_NUM_INITIALIZER(struct cmd_set_burst_tx_retry_result, retry_num, UINT32); 6479 6480 cmdline_parse_inst_t cmd_set_burst_tx_retry = { 6481 .f = cmd_set_burst_tx_retry_parsed, 6482 .help_str = "set burst tx delay <delay_usec> retry <num_retry>", 6483 .tokens = { 6484 (void *)&cmd_set_burst_tx_retry_set, 6485 (void *)&cmd_set_burst_tx_retry_burst, 6486 (void *)&cmd_set_burst_tx_retry_tx, 6487 (void *)&cmd_set_burst_tx_retry_delay, 6488 (void *)&cmd_set_burst_tx_retry_time, 6489 (void *)&cmd_set_burst_tx_retry_retry, 6490 (void *)&cmd_set_burst_tx_retry_retry_num, 6491 NULL, 6492 }, 6493 }; 6494 6495 /* *** SET PROMISC MODE *** */ 6496 struct cmd_set_promisc_mode_result { 6497 cmdline_fixed_string_t set; 6498 cmdline_fixed_string_t promisc; 6499 cmdline_fixed_string_t port_all; /* valid if "allports" argument == 1 */ 6500 uint16_t port_num; /* valid if "allports" argument == 0 */ 6501 cmdline_fixed_string_t mode; 6502 }; 6503 6504 static void cmd_set_promisc_mode_parsed(void *parsed_result, 6505 __attribute__((unused)) struct cmdline *cl, 6506 void *allports) 6507 { 6508 struct cmd_set_promisc_mode_result *res = parsed_result; 6509 int enable; 6510 portid_t i; 6511 6512 if (!strcmp(res->mode, "on")) 6513 enable = 1; 6514 else 6515 enable = 0; 6516 6517 /* all ports */ 6518 if (allports) { 6519 RTE_ETH_FOREACH_DEV(i) { 6520 if (enable) 6521 rte_eth_promiscuous_enable(i); 6522 else 6523 rte_eth_promiscuous_disable(i); 6524 } 6525 } 6526 else { 6527 if (enable) 6528 rte_eth_promiscuous_enable(res->port_num); 6529 else 6530 rte_eth_promiscuous_disable(res->port_num); 6531 } 6532 } 6533 6534 cmdline_parse_token_string_t cmd_setpromisc_set = 6535 TOKEN_STRING_INITIALIZER(struct cmd_set_promisc_mode_result, set, "set"); 6536 cmdline_parse_token_string_t cmd_setpromisc_promisc = 6537 TOKEN_STRING_INITIALIZER(struct cmd_set_promisc_mode_result, promisc, 6538 "promisc"); 6539 cmdline_parse_token_string_t cmd_setpromisc_portall = 6540 TOKEN_STRING_INITIALIZER(struct cmd_set_promisc_mode_result, port_all, 6541 "all"); 6542 cmdline_parse_token_num_t cmd_setpromisc_portnum = 6543 TOKEN_NUM_INITIALIZER(struct cmd_set_promisc_mode_result, port_num, 6544 UINT16); 6545 cmdline_parse_token_string_t cmd_setpromisc_mode = 6546 TOKEN_STRING_INITIALIZER(struct cmd_set_promisc_mode_result, mode, 6547 "on#off"); 6548 6549 cmdline_parse_inst_t cmd_set_promisc_mode_all = { 6550 .f = cmd_set_promisc_mode_parsed, 6551 .data = (void *)1, 6552 .help_str = "set promisc all on|off: Set promisc mode for all ports", 6553 .tokens = { 6554 (void *)&cmd_setpromisc_set, 6555 (void *)&cmd_setpromisc_promisc, 6556 (void *)&cmd_setpromisc_portall, 6557 (void *)&cmd_setpromisc_mode, 6558 NULL, 6559 }, 6560 }; 6561 6562 cmdline_parse_inst_t cmd_set_promisc_mode_one = { 6563 .f = cmd_set_promisc_mode_parsed, 6564 .data = (void *)0, 6565 .help_str = "set promisc <port_id> on|off: Set promisc mode on port_id", 6566 .tokens = { 6567 (void *)&cmd_setpromisc_set, 6568 (void *)&cmd_setpromisc_promisc, 6569 (void *)&cmd_setpromisc_portnum, 6570 (void *)&cmd_setpromisc_mode, 6571 NULL, 6572 }, 6573 }; 6574 6575 /* *** SET ALLMULTI MODE *** */ 6576 struct cmd_set_allmulti_mode_result { 6577 cmdline_fixed_string_t set; 6578 cmdline_fixed_string_t allmulti; 6579 cmdline_fixed_string_t port_all; /* valid if "allports" argument == 1 */ 6580 uint16_t port_num; /* valid if "allports" argument == 0 */ 6581 cmdline_fixed_string_t mode; 6582 }; 6583 6584 static void cmd_set_allmulti_mode_parsed(void *parsed_result, 6585 __attribute__((unused)) struct cmdline *cl, 6586 void *allports) 6587 { 6588 struct cmd_set_allmulti_mode_result *res = parsed_result; 6589 int enable; 6590 portid_t i; 6591 6592 if (!strcmp(res->mode, "on")) 6593 enable = 1; 6594 else 6595 enable = 0; 6596 6597 /* all ports */ 6598 if (allports) { 6599 RTE_ETH_FOREACH_DEV(i) { 6600 if (enable) 6601 rte_eth_allmulticast_enable(i); 6602 else 6603 rte_eth_allmulticast_disable(i); 6604 } 6605 } 6606 else { 6607 if (enable) 6608 rte_eth_allmulticast_enable(res->port_num); 6609 else 6610 rte_eth_allmulticast_disable(res->port_num); 6611 } 6612 } 6613 6614 cmdline_parse_token_string_t cmd_setallmulti_set = 6615 TOKEN_STRING_INITIALIZER(struct cmd_set_allmulti_mode_result, set, "set"); 6616 cmdline_parse_token_string_t cmd_setallmulti_allmulti = 6617 TOKEN_STRING_INITIALIZER(struct cmd_set_allmulti_mode_result, allmulti, 6618 "allmulti"); 6619 cmdline_parse_token_string_t cmd_setallmulti_portall = 6620 TOKEN_STRING_INITIALIZER(struct cmd_set_allmulti_mode_result, port_all, 6621 "all"); 6622 cmdline_parse_token_num_t cmd_setallmulti_portnum = 6623 TOKEN_NUM_INITIALIZER(struct cmd_set_allmulti_mode_result, port_num, 6624 UINT16); 6625 cmdline_parse_token_string_t cmd_setallmulti_mode = 6626 TOKEN_STRING_INITIALIZER(struct cmd_set_allmulti_mode_result, mode, 6627 "on#off"); 6628 6629 cmdline_parse_inst_t cmd_set_allmulti_mode_all = { 6630 .f = cmd_set_allmulti_mode_parsed, 6631 .data = (void *)1, 6632 .help_str = "set allmulti all on|off: Set allmulti mode for all ports", 6633 .tokens = { 6634 (void *)&cmd_setallmulti_set, 6635 (void *)&cmd_setallmulti_allmulti, 6636 (void *)&cmd_setallmulti_portall, 6637 (void *)&cmd_setallmulti_mode, 6638 NULL, 6639 }, 6640 }; 6641 6642 cmdline_parse_inst_t cmd_set_allmulti_mode_one = { 6643 .f = cmd_set_allmulti_mode_parsed, 6644 .data = (void *)0, 6645 .help_str = "set allmulti <port_id> on|off: " 6646 "Set allmulti mode on port_id", 6647 .tokens = { 6648 (void *)&cmd_setallmulti_set, 6649 (void *)&cmd_setallmulti_allmulti, 6650 (void *)&cmd_setallmulti_portnum, 6651 (void *)&cmd_setallmulti_mode, 6652 NULL, 6653 }, 6654 }; 6655 6656 /* *** SETUP ETHERNET LINK FLOW CONTROL *** */ 6657 struct cmd_link_flow_ctrl_set_result { 6658 cmdline_fixed_string_t set; 6659 cmdline_fixed_string_t flow_ctrl; 6660 cmdline_fixed_string_t rx; 6661 cmdline_fixed_string_t rx_lfc_mode; 6662 cmdline_fixed_string_t tx; 6663 cmdline_fixed_string_t tx_lfc_mode; 6664 cmdline_fixed_string_t mac_ctrl_frame_fwd; 6665 cmdline_fixed_string_t mac_ctrl_frame_fwd_mode; 6666 cmdline_fixed_string_t autoneg_str; 6667 cmdline_fixed_string_t autoneg; 6668 cmdline_fixed_string_t hw_str; 6669 uint32_t high_water; 6670 cmdline_fixed_string_t lw_str; 6671 uint32_t low_water; 6672 cmdline_fixed_string_t pt_str; 6673 uint16_t pause_time; 6674 cmdline_fixed_string_t xon_str; 6675 uint16_t send_xon; 6676 portid_t port_id; 6677 }; 6678 6679 cmdline_parse_token_string_t cmd_lfc_set_set = 6680 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result, 6681 set, "set"); 6682 cmdline_parse_token_string_t cmd_lfc_set_flow_ctrl = 6683 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result, 6684 flow_ctrl, "flow_ctrl"); 6685 cmdline_parse_token_string_t cmd_lfc_set_rx = 6686 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result, 6687 rx, "rx"); 6688 cmdline_parse_token_string_t cmd_lfc_set_rx_mode = 6689 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result, 6690 rx_lfc_mode, "on#off"); 6691 cmdline_parse_token_string_t cmd_lfc_set_tx = 6692 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result, 6693 tx, "tx"); 6694 cmdline_parse_token_string_t cmd_lfc_set_tx_mode = 6695 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result, 6696 tx_lfc_mode, "on#off"); 6697 cmdline_parse_token_string_t cmd_lfc_set_high_water_str = 6698 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result, 6699 hw_str, "high_water"); 6700 cmdline_parse_token_num_t cmd_lfc_set_high_water = 6701 TOKEN_NUM_INITIALIZER(struct cmd_link_flow_ctrl_set_result, 6702 high_water, UINT32); 6703 cmdline_parse_token_string_t cmd_lfc_set_low_water_str = 6704 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result, 6705 lw_str, "low_water"); 6706 cmdline_parse_token_num_t cmd_lfc_set_low_water = 6707 TOKEN_NUM_INITIALIZER(struct cmd_link_flow_ctrl_set_result, 6708 low_water, UINT32); 6709 cmdline_parse_token_string_t cmd_lfc_set_pause_time_str = 6710 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result, 6711 pt_str, "pause_time"); 6712 cmdline_parse_token_num_t cmd_lfc_set_pause_time = 6713 TOKEN_NUM_INITIALIZER(struct cmd_link_flow_ctrl_set_result, 6714 pause_time, UINT16); 6715 cmdline_parse_token_string_t cmd_lfc_set_send_xon_str = 6716 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result, 6717 xon_str, "send_xon"); 6718 cmdline_parse_token_num_t cmd_lfc_set_send_xon = 6719 TOKEN_NUM_INITIALIZER(struct cmd_link_flow_ctrl_set_result, 6720 send_xon, UINT16); 6721 cmdline_parse_token_string_t cmd_lfc_set_mac_ctrl_frame_fwd_mode = 6722 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result, 6723 mac_ctrl_frame_fwd, "mac_ctrl_frame_fwd"); 6724 cmdline_parse_token_string_t cmd_lfc_set_mac_ctrl_frame_fwd = 6725 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result, 6726 mac_ctrl_frame_fwd_mode, "on#off"); 6727 cmdline_parse_token_string_t cmd_lfc_set_autoneg_str = 6728 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result, 6729 autoneg_str, "autoneg"); 6730 cmdline_parse_token_string_t cmd_lfc_set_autoneg = 6731 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result, 6732 autoneg, "on#off"); 6733 cmdline_parse_token_num_t cmd_lfc_set_portid = 6734 TOKEN_NUM_INITIALIZER(struct cmd_link_flow_ctrl_set_result, 6735 port_id, UINT16); 6736 6737 /* forward declaration */ 6738 static void 6739 cmd_link_flow_ctrl_set_parsed(void *parsed_result, struct cmdline *cl, 6740 void *data); 6741 6742 cmdline_parse_inst_t cmd_link_flow_control_set = { 6743 .f = cmd_link_flow_ctrl_set_parsed, 6744 .data = NULL, 6745 .help_str = "set flow_ctrl rx on|off tx on|off <high_water> " 6746 "<low_water> <pause_time> <send_xon> mac_ctrl_frame_fwd on|off " 6747 "autoneg on|off <port_id>: Configure the Ethernet flow control", 6748 .tokens = { 6749 (void *)&cmd_lfc_set_set, 6750 (void *)&cmd_lfc_set_flow_ctrl, 6751 (void *)&cmd_lfc_set_rx, 6752 (void *)&cmd_lfc_set_rx_mode, 6753 (void *)&cmd_lfc_set_tx, 6754 (void *)&cmd_lfc_set_tx_mode, 6755 (void *)&cmd_lfc_set_high_water, 6756 (void *)&cmd_lfc_set_low_water, 6757 (void *)&cmd_lfc_set_pause_time, 6758 (void *)&cmd_lfc_set_send_xon, 6759 (void *)&cmd_lfc_set_mac_ctrl_frame_fwd_mode, 6760 (void *)&cmd_lfc_set_mac_ctrl_frame_fwd, 6761 (void *)&cmd_lfc_set_autoneg_str, 6762 (void *)&cmd_lfc_set_autoneg, 6763 (void *)&cmd_lfc_set_portid, 6764 NULL, 6765 }, 6766 }; 6767 6768 cmdline_parse_inst_t cmd_link_flow_control_set_rx = { 6769 .f = cmd_link_flow_ctrl_set_parsed, 6770 .data = (void *)&cmd_link_flow_control_set_rx, 6771 .help_str = "set flow_ctrl rx on|off <port_id>: " 6772 "Change rx flow control parameter", 6773 .tokens = { 6774 (void *)&cmd_lfc_set_set, 6775 (void *)&cmd_lfc_set_flow_ctrl, 6776 (void *)&cmd_lfc_set_rx, 6777 (void *)&cmd_lfc_set_rx_mode, 6778 (void *)&cmd_lfc_set_portid, 6779 NULL, 6780 }, 6781 }; 6782 6783 cmdline_parse_inst_t cmd_link_flow_control_set_tx = { 6784 .f = cmd_link_flow_ctrl_set_parsed, 6785 .data = (void *)&cmd_link_flow_control_set_tx, 6786 .help_str = "set flow_ctrl tx on|off <port_id>: " 6787 "Change tx flow control parameter", 6788 .tokens = { 6789 (void *)&cmd_lfc_set_set, 6790 (void *)&cmd_lfc_set_flow_ctrl, 6791 (void *)&cmd_lfc_set_tx, 6792 (void *)&cmd_lfc_set_tx_mode, 6793 (void *)&cmd_lfc_set_portid, 6794 NULL, 6795 }, 6796 }; 6797 6798 cmdline_parse_inst_t cmd_link_flow_control_set_hw = { 6799 .f = cmd_link_flow_ctrl_set_parsed, 6800 .data = (void *)&cmd_link_flow_control_set_hw, 6801 .help_str = "set flow_ctrl high_water <value> <port_id>: " 6802 "Change high water flow control parameter", 6803 .tokens = { 6804 (void *)&cmd_lfc_set_set, 6805 (void *)&cmd_lfc_set_flow_ctrl, 6806 (void *)&cmd_lfc_set_high_water_str, 6807 (void *)&cmd_lfc_set_high_water, 6808 (void *)&cmd_lfc_set_portid, 6809 NULL, 6810 }, 6811 }; 6812 6813 cmdline_parse_inst_t cmd_link_flow_control_set_lw = { 6814 .f = cmd_link_flow_ctrl_set_parsed, 6815 .data = (void *)&cmd_link_flow_control_set_lw, 6816 .help_str = "set flow_ctrl low_water <value> <port_id>: " 6817 "Change low water flow control parameter", 6818 .tokens = { 6819 (void *)&cmd_lfc_set_set, 6820 (void *)&cmd_lfc_set_flow_ctrl, 6821 (void *)&cmd_lfc_set_low_water_str, 6822 (void *)&cmd_lfc_set_low_water, 6823 (void *)&cmd_lfc_set_portid, 6824 NULL, 6825 }, 6826 }; 6827 6828 cmdline_parse_inst_t cmd_link_flow_control_set_pt = { 6829 .f = cmd_link_flow_ctrl_set_parsed, 6830 .data = (void *)&cmd_link_flow_control_set_pt, 6831 .help_str = "set flow_ctrl pause_time <value> <port_id>: " 6832 "Change pause time flow control parameter", 6833 .tokens = { 6834 (void *)&cmd_lfc_set_set, 6835 (void *)&cmd_lfc_set_flow_ctrl, 6836 (void *)&cmd_lfc_set_pause_time_str, 6837 (void *)&cmd_lfc_set_pause_time, 6838 (void *)&cmd_lfc_set_portid, 6839 NULL, 6840 }, 6841 }; 6842 6843 cmdline_parse_inst_t cmd_link_flow_control_set_xon = { 6844 .f = cmd_link_flow_ctrl_set_parsed, 6845 .data = (void *)&cmd_link_flow_control_set_xon, 6846 .help_str = "set flow_ctrl send_xon <value> <port_id>: " 6847 "Change send_xon flow control parameter", 6848 .tokens = { 6849 (void *)&cmd_lfc_set_set, 6850 (void *)&cmd_lfc_set_flow_ctrl, 6851 (void *)&cmd_lfc_set_send_xon_str, 6852 (void *)&cmd_lfc_set_send_xon, 6853 (void *)&cmd_lfc_set_portid, 6854 NULL, 6855 }, 6856 }; 6857 6858 cmdline_parse_inst_t cmd_link_flow_control_set_macfwd = { 6859 .f = cmd_link_flow_ctrl_set_parsed, 6860 .data = (void *)&cmd_link_flow_control_set_macfwd, 6861 .help_str = "set flow_ctrl mac_ctrl_frame_fwd on|off <port_id>: " 6862 "Change mac ctrl fwd flow control parameter", 6863 .tokens = { 6864 (void *)&cmd_lfc_set_set, 6865 (void *)&cmd_lfc_set_flow_ctrl, 6866 (void *)&cmd_lfc_set_mac_ctrl_frame_fwd_mode, 6867 (void *)&cmd_lfc_set_mac_ctrl_frame_fwd, 6868 (void *)&cmd_lfc_set_portid, 6869 NULL, 6870 }, 6871 }; 6872 6873 cmdline_parse_inst_t cmd_link_flow_control_set_autoneg = { 6874 .f = cmd_link_flow_ctrl_set_parsed, 6875 .data = (void *)&cmd_link_flow_control_set_autoneg, 6876 .help_str = "set flow_ctrl autoneg on|off <port_id>: " 6877 "Change autoneg flow control parameter", 6878 .tokens = { 6879 (void *)&cmd_lfc_set_set, 6880 (void *)&cmd_lfc_set_flow_ctrl, 6881 (void *)&cmd_lfc_set_autoneg_str, 6882 (void *)&cmd_lfc_set_autoneg, 6883 (void *)&cmd_lfc_set_portid, 6884 NULL, 6885 }, 6886 }; 6887 6888 static void 6889 cmd_link_flow_ctrl_set_parsed(void *parsed_result, 6890 __attribute__((unused)) struct cmdline *cl, 6891 void *data) 6892 { 6893 struct cmd_link_flow_ctrl_set_result *res = parsed_result; 6894 cmdline_parse_inst_t *cmd = data; 6895 struct rte_eth_fc_conf fc_conf; 6896 int rx_fc_en = 0; 6897 int tx_fc_en = 0; 6898 int ret; 6899 6900 /* 6901 * Rx on/off, flow control is enabled/disabled on RX side. This can indicate 6902 * the RTE_FC_TX_PAUSE, Transmit pause frame at the Rx side. 6903 * Tx on/off, flow control is enabled/disabled on TX side. This can indicate 6904 * the RTE_FC_RX_PAUSE, Respond to the pause frame at the Tx side. 6905 */ 6906 static enum rte_eth_fc_mode rx_tx_onoff_2_lfc_mode[2][2] = { 6907 {RTE_FC_NONE, RTE_FC_TX_PAUSE}, {RTE_FC_RX_PAUSE, RTE_FC_FULL} 6908 }; 6909 6910 /* Partial command line, retrieve current configuration */ 6911 if (cmd) { 6912 ret = rte_eth_dev_flow_ctrl_get(res->port_id, &fc_conf); 6913 if (ret != 0) { 6914 printf("cannot get current flow ctrl parameters, return" 6915 "code = %d\n", ret); 6916 return; 6917 } 6918 6919 if ((fc_conf.mode == RTE_FC_RX_PAUSE) || 6920 (fc_conf.mode == RTE_FC_FULL)) 6921 rx_fc_en = 1; 6922 if ((fc_conf.mode == RTE_FC_TX_PAUSE) || 6923 (fc_conf.mode == RTE_FC_FULL)) 6924 tx_fc_en = 1; 6925 } 6926 6927 if (!cmd || cmd == &cmd_link_flow_control_set_rx) 6928 rx_fc_en = (!strcmp(res->rx_lfc_mode, "on")) ? 1 : 0; 6929 6930 if (!cmd || cmd == &cmd_link_flow_control_set_tx) 6931 tx_fc_en = (!strcmp(res->tx_lfc_mode, "on")) ? 1 : 0; 6932 6933 fc_conf.mode = rx_tx_onoff_2_lfc_mode[rx_fc_en][tx_fc_en]; 6934 6935 if (!cmd || cmd == &cmd_link_flow_control_set_hw) 6936 fc_conf.high_water = res->high_water; 6937 6938 if (!cmd || cmd == &cmd_link_flow_control_set_lw) 6939 fc_conf.low_water = res->low_water; 6940 6941 if (!cmd || cmd == &cmd_link_flow_control_set_pt) 6942 fc_conf.pause_time = res->pause_time; 6943 6944 if (!cmd || cmd == &cmd_link_flow_control_set_xon) 6945 fc_conf.send_xon = res->send_xon; 6946 6947 if (!cmd || cmd == &cmd_link_flow_control_set_macfwd) { 6948 if (!strcmp(res->mac_ctrl_frame_fwd_mode, "on")) 6949 fc_conf.mac_ctrl_frame_fwd = 1; 6950 else 6951 fc_conf.mac_ctrl_frame_fwd = 0; 6952 } 6953 6954 if (!cmd || cmd == &cmd_link_flow_control_set_autoneg) 6955 fc_conf.autoneg = (!strcmp(res->autoneg, "on")) ? 1 : 0; 6956 6957 ret = rte_eth_dev_flow_ctrl_set(res->port_id, &fc_conf); 6958 if (ret != 0) 6959 printf("bad flow contrl parameter, return code = %d \n", ret); 6960 } 6961 6962 /* *** SETUP ETHERNET PRIORITY FLOW CONTROL *** */ 6963 struct cmd_priority_flow_ctrl_set_result { 6964 cmdline_fixed_string_t set; 6965 cmdline_fixed_string_t pfc_ctrl; 6966 cmdline_fixed_string_t rx; 6967 cmdline_fixed_string_t rx_pfc_mode; 6968 cmdline_fixed_string_t tx; 6969 cmdline_fixed_string_t tx_pfc_mode; 6970 uint32_t high_water; 6971 uint32_t low_water; 6972 uint16_t pause_time; 6973 uint8_t priority; 6974 portid_t port_id; 6975 }; 6976 6977 static void 6978 cmd_priority_flow_ctrl_set_parsed(void *parsed_result, 6979 __attribute__((unused)) struct cmdline *cl, 6980 __attribute__((unused)) void *data) 6981 { 6982 struct cmd_priority_flow_ctrl_set_result *res = parsed_result; 6983 struct rte_eth_pfc_conf pfc_conf; 6984 int rx_fc_enable, tx_fc_enable; 6985 int ret; 6986 6987 /* 6988 * Rx on/off, flow control is enabled/disabled on RX side. This can indicate 6989 * the RTE_FC_TX_PAUSE, Transmit pause frame at the Rx side. 6990 * Tx on/off, flow control is enabled/disabled on TX side. This can indicate 6991 * the RTE_FC_RX_PAUSE, Respond to the pause frame at the Tx side. 6992 */ 6993 static enum rte_eth_fc_mode rx_tx_onoff_2_pfc_mode[2][2] = { 6994 {RTE_FC_NONE, RTE_FC_RX_PAUSE}, {RTE_FC_TX_PAUSE, RTE_FC_FULL} 6995 }; 6996 6997 rx_fc_enable = (!strncmp(res->rx_pfc_mode, "on",2)) ? 1 : 0; 6998 tx_fc_enable = (!strncmp(res->tx_pfc_mode, "on",2)) ? 1 : 0; 6999 pfc_conf.fc.mode = rx_tx_onoff_2_pfc_mode[rx_fc_enable][tx_fc_enable]; 7000 pfc_conf.fc.high_water = res->high_water; 7001 pfc_conf.fc.low_water = res->low_water; 7002 pfc_conf.fc.pause_time = res->pause_time; 7003 pfc_conf.priority = res->priority; 7004 7005 ret = rte_eth_dev_priority_flow_ctrl_set(res->port_id, &pfc_conf); 7006 if (ret != 0) 7007 printf("bad priority flow contrl parameter, return code = %d \n", ret); 7008 } 7009 7010 cmdline_parse_token_string_t cmd_pfc_set_set = 7011 TOKEN_STRING_INITIALIZER(struct cmd_priority_flow_ctrl_set_result, 7012 set, "set"); 7013 cmdline_parse_token_string_t cmd_pfc_set_flow_ctrl = 7014 TOKEN_STRING_INITIALIZER(struct cmd_priority_flow_ctrl_set_result, 7015 pfc_ctrl, "pfc_ctrl"); 7016 cmdline_parse_token_string_t cmd_pfc_set_rx = 7017 TOKEN_STRING_INITIALIZER(struct cmd_priority_flow_ctrl_set_result, 7018 rx, "rx"); 7019 cmdline_parse_token_string_t cmd_pfc_set_rx_mode = 7020 TOKEN_STRING_INITIALIZER(struct cmd_priority_flow_ctrl_set_result, 7021 rx_pfc_mode, "on#off"); 7022 cmdline_parse_token_string_t cmd_pfc_set_tx = 7023 TOKEN_STRING_INITIALIZER(struct cmd_priority_flow_ctrl_set_result, 7024 tx, "tx"); 7025 cmdline_parse_token_string_t cmd_pfc_set_tx_mode = 7026 TOKEN_STRING_INITIALIZER(struct cmd_priority_flow_ctrl_set_result, 7027 tx_pfc_mode, "on#off"); 7028 cmdline_parse_token_num_t cmd_pfc_set_high_water = 7029 TOKEN_NUM_INITIALIZER(struct cmd_priority_flow_ctrl_set_result, 7030 high_water, UINT32); 7031 cmdline_parse_token_num_t cmd_pfc_set_low_water = 7032 TOKEN_NUM_INITIALIZER(struct cmd_priority_flow_ctrl_set_result, 7033 low_water, UINT32); 7034 cmdline_parse_token_num_t cmd_pfc_set_pause_time = 7035 TOKEN_NUM_INITIALIZER(struct cmd_priority_flow_ctrl_set_result, 7036 pause_time, UINT16); 7037 cmdline_parse_token_num_t cmd_pfc_set_priority = 7038 TOKEN_NUM_INITIALIZER(struct cmd_priority_flow_ctrl_set_result, 7039 priority, UINT8); 7040 cmdline_parse_token_num_t cmd_pfc_set_portid = 7041 TOKEN_NUM_INITIALIZER(struct cmd_priority_flow_ctrl_set_result, 7042 port_id, UINT16); 7043 7044 cmdline_parse_inst_t cmd_priority_flow_control_set = { 7045 .f = cmd_priority_flow_ctrl_set_parsed, 7046 .data = NULL, 7047 .help_str = "set pfc_ctrl rx on|off tx on|off <high_water> <low_water> " 7048 "<pause_time> <priority> <port_id>: " 7049 "Configure the Ethernet priority flow control", 7050 .tokens = { 7051 (void *)&cmd_pfc_set_set, 7052 (void *)&cmd_pfc_set_flow_ctrl, 7053 (void *)&cmd_pfc_set_rx, 7054 (void *)&cmd_pfc_set_rx_mode, 7055 (void *)&cmd_pfc_set_tx, 7056 (void *)&cmd_pfc_set_tx_mode, 7057 (void *)&cmd_pfc_set_high_water, 7058 (void *)&cmd_pfc_set_low_water, 7059 (void *)&cmd_pfc_set_pause_time, 7060 (void *)&cmd_pfc_set_priority, 7061 (void *)&cmd_pfc_set_portid, 7062 NULL, 7063 }, 7064 }; 7065 7066 /* *** RESET CONFIGURATION *** */ 7067 struct cmd_reset_result { 7068 cmdline_fixed_string_t reset; 7069 cmdline_fixed_string_t def; 7070 }; 7071 7072 static void cmd_reset_parsed(__attribute__((unused)) void *parsed_result, 7073 struct cmdline *cl, 7074 __attribute__((unused)) void *data) 7075 { 7076 cmdline_printf(cl, "Reset to default forwarding configuration...\n"); 7077 set_def_fwd_config(); 7078 } 7079 7080 cmdline_parse_token_string_t cmd_reset_set = 7081 TOKEN_STRING_INITIALIZER(struct cmd_reset_result, reset, "set"); 7082 cmdline_parse_token_string_t cmd_reset_def = 7083 TOKEN_STRING_INITIALIZER(struct cmd_reset_result, def, 7084 "default"); 7085 7086 cmdline_parse_inst_t cmd_reset = { 7087 .f = cmd_reset_parsed, 7088 .data = NULL, 7089 .help_str = "set default: Reset default forwarding configuration", 7090 .tokens = { 7091 (void *)&cmd_reset_set, 7092 (void *)&cmd_reset_def, 7093 NULL, 7094 }, 7095 }; 7096 7097 /* *** START FORWARDING *** */ 7098 struct cmd_start_result { 7099 cmdline_fixed_string_t start; 7100 }; 7101 7102 cmdline_parse_token_string_t cmd_start_start = 7103 TOKEN_STRING_INITIALIZER(struct cmd_start_result, start, "start"); 7104 7105 static void cmd_start_parsed(__attribute__((unused)) void *parsed_result, 7106 __attribute__((unused)) struct cmdline *cl, 7107 __attribute__((unused)) void *data) 7108 { 7109 start_packet_forwarding(0); 7110 } 7111 7112 cmdline_parse_inst_t cmd_start = { 7113 .f = cmd_start_parsed, 7114 .data = NULL, 7115 .help_str = "start: Start packet forwarding", 7116 .tokens = { 7117 (void *)&cmd_start_start, 7118 NULL, 7119 }, 7120 }; 7121 7122 /* *** START FORWARDING WITH ONE TX BURST FIRST *** */ 7123 struct cmd_start_tx_first_result { 7124 cmdline_fixed_string_t start; 7125 cmdline_fixed_string_t tx_first; 7126 }; 7127 7128 static void 7129 cmd_start_tx_first_parsed(__attribute__((unused)) void *parsed_result, 7130 __attribute__((unused)) struct cmdline *cl, 7131 __attribute__((unused)) void *data) 7132 { 7133 start_packet_forwarding(1); 7134 } 7135 7136 cmdline_parse_token_string_t cmd_start_tx_first_start = 7137 TOKEN_STRING_INITIALIZER(struct cmd_start_tx_first_result, start, 7138 "start"); 7139 cmdline_parse_token_string_t cmd_start_tx_first_tx_first = 7140 TOKEN_STRING_INITIALIZER(struct cmd_start_tx_first_result, 7141 tx_first, "tx_first"); 7142 7143 cmdline_parse_inst_t cmd_start_tx_first = { 7144 .f = cmd_start_tx_first_parsed, 7145 .data = NULL, 7146 .help_str = "start tx_first: Start packet forwarding, " 7147 "after sending 1 burst of packets", 7148 .tokens = { 7149 (void *)&cmd_start_tx_first_start, 7150 (void *)&cmd_start_tx_first_tx_first, 7151 NULL, 7152 }, 7153 }; 7154 7155 /* *** START FORWARDING WITH N TX BURST FIRST *** */ 7156 struct cmd_start_tx_first_n_result { 7157 cmdline_fixed_string_t start; 7158 cmdline_fixed_string_t tx_first; 7159 uint32_t tx_num; 7160 }; 7161 7162 static void 7163 cmd_start_tx_first_n_parsed(void *parsed_result, 7164 __attribute__((unused)) struct cmdline *cl, 7165 __attribute__((unused)) void *data) 7166 { 7167 struct cmd_start_tx_first_n_result *res = parsed_result; 7168 7169 start_packet_forwarding(res->tx_num); 7170 } 7171 7172 cmdline_parse_token_string_t cmd_start_tx_first_n_start = 7173 TOKEN_STRING_INITIALIZER(struct cmd_start_tx_first_n_result, 7174 start, "start"); 7175 cmdline_parse_token_string_t cmd_start_tx_first_n_tx_first = 7176 TOKEN_STRING_INITIALIZER(struct cmd_start_tx_first_n_result, 7177 tx_first, "tx_first"); 7178 cmdline_parse_token_num_t cmd_start_tx_first_n_tx_num = 7179 TOKEN_NUM_INITIALIZER(struct cmd_start_tx_first_n_result, 7180 tx_num, UINT32); 7181 7182 cmdline_parse_inst_t cmd_start_tx_first_n = { 7183 .f = cmd_start_tx_first_n_parsed, 7184 .data = NULL, 7185 .help_str = "start tx_first <num>: " 7186 "packet forwarding, after sending <num> bursts of packets", 7187 .tokens = { 7188 (void *)&cmd_start_tx_first_n_start, 7189 (void *)&cmd_start_tx_first_n_tx_first, 7190 (void *)&cmd_start_tx_first_n_tx_num, 7191 NULL, 7192 }, 7193 }; 7194 7195 /* *** SET LINK UP *** */ 7196 struct cmd_set_link_up_result { 7197 cmdline_fixed_string_t set; 7198 cmdline_fixed_string_t link_up; 7199 cmdline_fixed_string_t port; 7200 portid_t port_id; 7201 }; 7202 7203 cmdline_parse_token_string_t cmd_set_link_up_set = 7204 TOKEN_STRING_INITIALIZER(struct cmd_set_link_up_result, set, "set"); 7205 cmdline_parse_token_string_t cmd_set_link_up_link_up = 7206 TOKEN_STRING_INITIALIZER(struct cmd_set_link_up_result, link_up, 7207 "link-up"); 7208 cmdline_parse_token_string_t cmd_set_link_up_port = 7209 TOKEN_STRING_INITIALIZER(struct cmd_set_link_up_result, port, "port"); 7210 cmdline_parse_token_num_t cmd_set_link_up_port_id = 7211 TOKEN_NUM_INITIALIZER(struct cmd_set_link_up_result, port_id, UINT16); 7212 7213 static void cmd_set_link_up_parsed(__attribute__((unused)) void *parsed_result, 7214 __attribute__((unused)) struct cmdline *cl, 7215 __attribute__((unused)) void *data) 7216 { 7217 struct cmd_set_link_up_result *res = parsed_result; 7218 dev_set_link_up(res->port_id); 7219 } 7220 7221 cmdline_parse_inst_t cmd_set_link_up = { 7222 .f = cmd_set_link_up_parsed, 7223 .data = NULL, 7224 .help_str = "set link-up port <port id>", 7225 .tokens = { 7226 (void *)&cmd_set_link_up_set, 7227 (void *)&cmd_set_link_up_link_up, 7228 (void *)&cmd_set_link_up_port, 7229 (void *)&cmd_set_link_up_port_id, 7230 NULL, 7231 }, 7232 }; 7233 7234 /* *** SET LINK DOWN *** */ 7235 struct cmd_set_link_down_result { 7236 cmdline_fixed_string_t set; 7237 cmdline_fixed_string_t link_down; 7238 cmdline_fixed_string_t port; 7239 portid_t port_id; 7240 }; 7241 7242 cmdline_parse_token_string_t cmd_set_link_down_set = 7243 TOKEN_STRING_INITIALIZER(struct cmd_set_link_down_result, set, "set"); 7244 cmdline_parse_token_string_t cmd_set_link_down_link_down = 7245 TOKEN_STRING_INITIALIZER(struct cmd_set_link_down_result, link_down, 7246 "link-down"); 7247 cmdline_parse_token_string_t cmd_set_link_down_port = 7248 TOKEN_STRING_INITIALIZER(struct cmd_set_link_down_result, port, "port"); 7249 cmdline_parse_token_num_t cmd_set_link_down_port_id = 7250 TOKEN_NUM_INITIALIZER(struct cmd_set_link_down_result, port_id, UINT16); 7251 7252 static void cmd_set_link_down_parsed( 7253 __attribute__((unused)) void *parsed_result, 7254 __attribute__((unused)) struct cmdline *cl, 7255 __attribute__((unused)) void *data) 7256 { 7257 struct cmd_set_link_down_result *res = parsed_result; 7258 dev_set_link_down(res->port_id); 7259 } 7260 7261 cmdline_parse_inst_t cmd_set_link_down = { 7262 .f = cmd_set_link_down_parsed, 7263 .data = NULL, 7264 .help_str = "set link-down port <port id>", 7265 .tokens = { 7266 (void *)&cmd_set_link_down_set, 7267 (void *)&cmd_set_link_down_link_down, 7268 (void *)&cmd_set_link_down_port, 7269 (void *)&cmd_set_link_down_port_id, 7270 NULL, 7271 }, 7272 }; 7273 7274 /* *** SHOW CFG *** */ 7275 struct cmd_showcfg_result { 7276 cmdline_fixed_string_t show; 7277 cmdline_fixed_string_t cfg; 7278 cmdline_fixed_string_t what; 7279 }; 7280 7281 static void cmd_showcfg_parsed(void *parsed_result, 7282 __attribute__((unused)) struct cmdline *cl, 7283 __attribute__((unused)) void *data) 7284 { 7285 struct cmd_showcfg_result *res = parsed_result; 7286 if (!strcmp(res->what, "rxtx")) 7287 rxtx_config_display(); 7288 else if (!strcmp(res->what, "cores")) 7289 fwd_lcores_config_display(); 7290 else if (!strcmp(res->what, "fwd")) 7291 pkt_fwd_config_display(&cur_fwd_config); 7292 else if (!strcmp(res->what, "txpkts")) 7293 show_tx_pkt_segments(); 7294 } 7295 7296 cmdline_parse_token_string_t cmd_showcfg_show = 7297 TOKEN_STRING_INITIALIZER(struct cmd_showcfg_result, show, "show"); 7298 cmdline_parse_token_string_t cmd_showcfg_port = 7299 TOKEN_STRING_INITIALIZER(struct cmd_showcfg_result, cfg, "config"); 7300 cmdline_parse_token_string_t cmd_showcfg_what = 7301 TOKEN_STRING_INITIALIZER(struct cmd_showcfg_result, what, 7302 "rxtx#cores#fwd#txpkts"); 7303 7304 cmdline_parse_inst_t cmd_showcfg = { 7305 .f = cmd_showcfg_parsed, 7306 .data = NULL, 7307 .help_str = "show config rxtx|cores|fwd|txpkts", 7308 .tokens = { 7309 (void *)&cmd_showcfg_show, 7310 (void *)&cmd_showcfg_port, 7311 (void *)&cmd_showcfg_what, 7312 NULL, 7313 }, 7314 }; 7315 7316 /* *** SHOW ALL PORT INFO *** */ 7317 struct cmd_showportall_result { 7318 cmdline_fixed_string_t show; 7319 cmdline_fixed_string_t port; 7320 cmdline_fixed_string_t what; 7321 cmdline_fixed_string_t all; 7322 }; 7323 7324 static void cmd_showportall_parsed(void *parsed_result, 7325 __attribute__((unused)) struct cmdline *cl, 7326 __attribute__((unused)) void *data) 7327 { 7328 portid_t i; 7329 7330 struct cmd_showportall_result *res = parsed_result; 7331 if (!strcmp(res->show, "clear")) { 7332 if (!strcmp(res->what, "stats")) 7333 RTE_ETH_FOREACH_DEV(i) 7334 nic_stats_clear(i); 7335 else if (!strcmp(res->what, "xstats")) 7336 RTE_ETH_FOREACH_DEV(i) 7337 nic_xstats_clear(i); 7338 } else if (!strcmp(res->what, "info")) 7339 RTE_ETH_FOREACH_DEV(i) 7340 port_infos_display(i); 7341 else if (!strcmp(res->what, "summary")) { 7342 port_summary_header_display(); 7343 RTE_ETH_FOREACH_DEV(i) 7344 port_summary_display(i); 7345 } 7346 else if (!strcmp(res->what, "stats")) 7347 RTE_ETH_FOREACH_DEV(i) 7348 nic_stats_display(i); 7349 else if (!strcmp(res->what, "xstats")) 7350 RTE_ETH_FOREACH_DEV(i) 7351 nic_xstats_display(i); 7352 else if (!strcmp(res->what, "fdir")) 7353 RTE_ETH_FOREACH_DEV(i) 7354 fdir_get_infos(i); 7355 else if (!strcmp(res->what, "stat_qmap")) 7356 RTE_ETH_FOREACH_DEV(i) 7357 nic_stats_mapping_display(i); 7358 else if (!strcmp(res->what, "dcb_tc")) 7359 RTE_ETH_FOREACH_DEV(i) 7360 port_dcb_info_display(i); 7361 else if (!strcmp(res->what, "cap")) 7362 RTE_ETH_FOREACH_DEV(i) 7363 port_offload_cap_display(i); 7364 } 7365 7366 cmdline_parse_token_string_t cmd_showportall_show = 7367 TOKEN_STRING_INITIALIZER(struct cmd_showportall_result, show, 7368 "show#clear"); 7369 cmdline_parse_token_string_t cmd_showportall_port = 7370 TOKEN_STRING_INITIALIZER(struct cmd_showportall_result, port, "port"); 7371 cmdline_parse_token_string_t cmd_showportall_what = 7372 TOKEN_STRING_INITIALIZER(struct cmd_showportall_result, what, 7373 "info#summary#stats#xstats#fdir#stat_qmap#dcb_tc#cap"); 7374 cmdline_parse_token_string_t cmd_showportall_all = 7375 TOKEN_STRING_INITIALIZER(struct cmd_showportall_result, all, "all"); 7376 cmdline_parse_inst_t cmd_showportall = { 7377 .f = cmd_showportall_parsed, 7378 .data = NULL, 7379 .help_str = "show|clear port " 7380 "info|summary|stats|xstats|fdir|stat_qmap|dcb_tc|cap all", 7381 .tokens = { 7382 (void *)&cmd_showportall_show, 7383 (void *)&cmd_showportall_port, 7384 (void *)&cmd_showportall_what, 7385 (void *)&cmd_showportall_all, 7386 NULL, 7387 }, 7388 }; 7389 7390 /* *** SHOW PORT INFO *** */ 7391 struct cmd_showport_result { 7392 cmdline_fixed_string_t show; 7393 cmdline_fixed_string_t port; 7394 cmdline_fixed_string_t what; 7395 uint16_t portnum; 7396 }; 7397 7398 static void cmd_showport_parsed(void *parsed_result, 7399 __attribute__((unused)) struct cmdline *cl, 7400 __attribute__((unused)) void *data) 7401 { 7402 struct cmd_showport_result *res = parsed_result; 7403 if (!strcmp(res->show, "clear")) { 7404 if (!strcmp(res->what, "stats")) 7405 nic_stats_clear(res->portnum); 7406 else if (!strcmp(res->what, "xstats")) 7407 nic_xstats_clear(res->portnum); 7408 } else if (!strcmp(res->what, "info")) 7409 port_infos_display(res->portnum); 7410 else if (!strcmp(res->what, "summary")) { 7411 port_summary_header_display(); 7412 port_summary_display(res->portnum); 7413 } 7414 else if (!strcmp(res->what, "stats")) 7415 nic_stats_display(res->portnum); 7416 else if (!strcmp(res->what, "xstats")) 7417 nic_xstats_display(res->portnum); 7418 else if (!strcmp(res->what, "fdir")) 7419 fdir_get_infos(res->portnum); 7420 else if (!strcmp(res->what, "stat_qmap")) 7421 nic_stats_mapping_display(res->portnum); 7422 else if (!strcmp(res->what, "dcb_tc")) 7423 port_dcb_info_display(res->portnum); 7424 else if (!strcmp(res->what, "cap")) 7425 port_offload_cap_display(res->portnum); 7426 } 7427 7428 cmdline_parse_token_string_t cmd_showport_show = 7429 TOKEN_STRING_INITIALIZER(struct cmd_showport_result, show, 7430 "show#clear"); 7431 cmdline_parse_token_string_t cmd_showport_port = 7432 TOKEN_STRING_INITIALIZER(struct cmd_showport_result, port, "port"); 7433 cmdline_parse_token_string_t cmd_showport_what = 7434 TOKEN_STRING_INITIALIZER(struct cmd_showport_result, what, 7435 "info#summary#stats#xstats#fdir#stat_qmap#dcb_tc#cap"); 7436 cmdline_parse_token_num_t cmd_showport_portnum = 7437 TOKEN_NUM_INITIALIZER(struct cmd_showport_result, portnum, UINT16); 7438 7439 cmdline_parse_inst_t cmd_showport = { 7440 .f = cmd_showport_parsed, 7441 .data = NULL, 7442 .help_str = "show|clear port " 7443 "info|summary|stats|xstats|fdir|stat_qmap|dcb_tc|cap " 7444 "<port_id>", 7445 .tokens = { 7446 (void *)&cmd_showport_show, 7447 (void *)&cmd_showport_port, 7448 (void *)&cmd_showport_what, 7449 (void *)&cmd_showport_portnum, 7450 NULL, 7451 }, 7452 }; 7453 7454 /* *** SHOW QUEUE INFO *** */ 7455 struct cmd_showqueue_result { 7456 cmdline_fixed_string_t show; 7457 cmdline_fixed_string_t type; 7458 cmdline_fixed_string_t what; 7459 uint16_t portnum; 7460 uint16_t queuenum; 7461 }; 7462 7463 static void 7464 cmd_showqueue_parsed(void *parsed_result, 7465 __attribute__((unused)) struct cmdline *cl, 7466 __attribute__((unused)) void *data) 7467 { 7468 struct cmd_showqueue_result *res = parsed_result; 7469 7470 if (!strcmp(res->type, "rxq")) 7471 rx_queue_infos_display(res->portnum, res->queuenum); 7472 else if (!strcmp(res->type, "txq")) 7473 tx_queue_infos_display(res->portnum, res->queuenum); 7474 } 7475 7476 cmdline_parse_token_string_t cmd_showqueue_show = 7477 TOKEN_STRING_INITIALIZER(struct cmd_showqueue_result, show, "show"); 7478 cmdline_parse_token_string_t cmd_showqueue_type = 7479 TOKEN_STRING_INITIALIZER(struct cmd_showqueue_result, type, "rxq#txq"); 7480 cmdline_parse_token_string_t cmd_showqueue_what = 7481 TOKEN_STRING_INITIALIZER(struct cmd_showqueue_result, what, "info"); 7482 cmdline_parse_token_num_t cmd_showqueue_portnum = 7483 TOKEN_NUM_INITIALIZER(struct cmd_showqueue_result, portnum, UINT16); 7484 cmdline_parse_token_num_t cmd_showqueue_queuenum = 7485 TOKEN_NUM_INITIALIZER(struct cmd_showqueue_result, queuenum, UINT16); 7486 7487 cmdline_parse_inst_t cmd_showqueue = { 7488 .f = cmd_showqueue_parsed, 7489 .data = NULL, 7490 .help_str = "show rxq|txq info <port_id> <queue_id>", 7491 .tokens = { 7492 (void *)&cmd_showqueue_show, 7493 (void *)&cmd_showqueue_type, 7494 (void *)&cmd_showqueue_what, 7495 (void *)&cmd_showqueue_portnum, 7496 (void *)&cmd_showqueue_queuenum, 7497 NULL, 7498 }, 7499 }; 7500 7501 /* *** READ PORT REGISTER *** */ 7502 struct cmd_read_reg_result { 7503 cmdline_fixed_string_t read; 7504 cmdline_fixed_string_t reg; 7505 portid_t port_id; 7506 uint32_t reg_off; 7507 }; 7508 7509 static void 7510 cmd_read_reg_parsed(void *parsed_result, 7511 __attribute__((unused)) struct cmdline *cl, 7512 __attribute__((unused)) void *data) 7513 { 7514 struct cmd_read_reg_result *res = parsed_result; 7515 port_reg_display(res->port_id, res->reg_off); 7516 } 7517 7518 cmdline_parse_token_string_t cmd_read_reg_read = 7519 TOKEN_STRING_INITIALIZER(struct cmd_read_reg_result, read, "read"); 7520 cmdline_parse_token_string_t cmd_read_reg_reg = 7521 TOKEN_STRING_INITIALIZER(struct cmd_read_reg_result, reg, "reg"); 7522 cmdline_parse_token_num_t cmd_read_reg_port_id = 7523 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_result, port_id, UINT16); 7524 cmdline_parse_token_num_t cmd_read_reg_reg_off = 7525 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_result, reg_off, UINT32); 7526 7527 cmdline_parse_inst_t cmd_read_reg = { 7528 .f = cmd_read_reg_parsed, 7529 .data = NULL, 7530 .help_str = "read reg <port_id> <reg_off>", 7531 .tokens = { 7532 (void *)&cmd_read_reg_read, 7533 (void *)&cmd_read_reg_reg, 7534 (void *)&cmd_read_reg_port_id, 7535 (void *)&cmd_read_reg_reg_off, 7536 NULL, 7537 }, 7538 }; 7539 7540 /* *** READ PORT REGISTER BIT FIELD *** */ 7541 struct cmd_read_reg_bit_field_result { 7542 cmdline_fixed_string_t read; 7543 cmdline_fixed_string_t regfield; 7544 portid_t port_id; 7545 uint32_t reg_off; 7546 uint8_t bit1_pos; 7547 uint8_t bit2_pos; 7548 }; 7549 7550 static void 7551 cmd_read_reg_bit_field_parsed(void *parsed_result, 7552 __attribute__((unused)) struct cmdline *cl, 7553 __attribute__((unused)) void *data) 7554 { 7555 struct cmd_read_reg_bit_field_result *res = parsed_result; 7556 port_reg_bit_field_display(res->port_id, res->reg_off, 7557 res->bit1_pos, res->bit2_pos); 7558 } 7559 7560 cmdline_parse_token_string_t cmd_read_reg_bit_field_read = 7561 TOKEN_STRING_INITIALIZER(struct cmd_read_reg_bit_field_result, read, 7562 "read"); 7563 cmdline_parse_token_string_t cmd_read_reg_bit_field_regfield = 7564 TOKEN_STRING_INITIALIZER(struct cmd_read_reg_bit_field_result, 7565 regfield, "regfield"); 7566 cmdline_parse_token_num_t cmd_read_reg_bit_field_port_id = 7567 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_field_result, port_id, 7568 UINT16); 7569 cmdline_parse_token_num_t cmd_read_reg_bit_field_reg_off = 7570 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_field_result, reg_off, 7571 UINT32); 7572 cmdline_parse_token_num_t cmd_read_reg_bit_field_bit1_pos = 7573 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_field_result, bit1_pos, 7574 UINT8); 7575 cmdline_parse_token_num_t cmd_read_reg_bit_field_bit2_pos = 7576 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_field_result, bit2_pos, 7577 UINT8); 7578 7579 cmdline_parse_inst_t cmd_read_reg_bit_field = { 7580 .f = cmd_read_reg_bit_field_parsed, 7581 .data = NULL, 7582 .help_str = "read regfield <port_id> <reg_off> <bit_x> <bit_y>: " 7583 "Read register bit field between bit_x and bit_y included", 7584 .tokens = { 7585 (void *)&cmd_read_reg_bit_field_read, 7586 (void *)&cmd_read_reg_bit_field_regfield, 7587 (void *)&cmd_read_reg_bit_field_port_id, 7588 (void *)&cmd_read_reg_bit_field_reg_off, 7589 (void *)&cmd_read_reg_bit_field_bit1_pos, 7590 (void *)&cmd_read_reg_bit_field_bit2_pos, 7591 NULL, 7592 }, 7593 }; 7594 7595 /* *** READ PORT REGISTER BIT *** */ 7596 struct cmd_read_reg_bit_result { 7597 cmdline_fixed_string_t read; 7598 cmdline_fixed_string_t regbit; 7599 portid_t port_id; 7600 uint32_t reg_off; 7601 uint8_t bit_pos; 7602 }; 7603 7604 static void 7605 cmd_read_reg_bit_parsed(void *parsed_result, 7606 __attribute__((unused)) struct cmdline *cl, 7607 __attribute__((unused)) void *data) 7608 { 7609 struct cmd_read_reg_bit_result *res = parsed_result; 7610 port_reg_bit_display(res->port_id, res->reg_off, res->bit_pos); 7611 } 7612 7613 cmdline_parse_token_string_t cmd_read_reg_bit_read = 7614 TOKEN_STRING_INITIALIZER(struct cmd_read_reg_bit_result, read, "read"); 7615 cmdline_parse_token_string_t cmd_read_reg_bit_regbit = 7616 TOKEN_STRING_INITIALIZER(struct cmd_read_reg_bit_result, 7617 regbit, "regbit"); 7618 cmdline_parse_token_num_t cmd_read_reg_bit_port_id = 7619 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_result, port_id, UINT16); 7620 cmdline_parse_token_num_t cmd_read_reg_bit_reg_off = 7621 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_result, reg_off, UINT32); 7622 cmdline_parse_token_num_t cmd_read_reg_bit_bit_pos = 7623 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_result, bit_pos, UINT8); 7624 7625 cmdline_parse_inst_t cmd_read_reg_bit = { 7626 .f = cmd_read_reg_bit_parsed, 7627 .data = NULL, 7628 .help_str = "read regbit <port_id> <reg_off> <bit_x>: 0 <= bit_x <= 31", 7629 .tokens = { 7630 (void *)&cmd_read_reg_bit_read, 7631 (void *)&cmd_read_reg_bit_regbit, 7632 (void *)&cmd_read_reg_bit_port_id, 7633 (void *)&cmd_read_reg_bit_reg_off, 7634 (void *)&cmd_read_reg_bit_bit_pos, 7635 NULL, 7636 }, 7637 }; 7638 7639 /* *** WRITE PORT REGISTER *** */ 7640 struct cmd_write_reg_result { 7641 cmdline_fixed_string_t write; 7642 cmdline_fixed_string_t reg; 7643 portid_t port_id; 7644 uint32_t reg_off; 7645 uint32_t value; 7646 }; 7647 7648 static void 7649 cmd_write_reg_parsed(void *parsed_result, 7650 __attribute__((unused)) struct cmdline *cl, 7651 __attribute__((unused)) void *data) 7652 { 7653 struct cmd_write_reg_result *res = parsed_result; 7654 port_reg_set(res->port_id, res->reg_off, res->value); 7655 } 7656 7657 cmdline_parse_token_string_t cmd_write_reg_write = 7658 TOKEN_STRING_INITIALIZER(struct cmd_write_reg_result, write, "write"); 7659 cmdline_parse_token_string_t cmd_write_reg_reg = 7660 TOKEN_STRING_INITIALIZER(struct cmd_write_reg_result, reg, "reg"); 7661 cmdline_parse_token_num_t cmd_write_reg_port_id = 7662 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_result, port_id, UINT16); 7663 cmdline_parse_token_num_t cmd_write_reg_reg_off = 7664 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_result, reg_off, UINT32); 7665 cmdline_parse_token_num_t cmd_write_reg_value = 7666 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_result, value, UINT32); 7667 7668 cmdline_parse_inst_t cmd_write_reg = { 7669 .f = cmd_write_reg_parsed, 7670 .data = NULL, 7671 .help_str = "write reg <port_id> <reg_off> <reg_value>", 7672 .tokens = { 7673 (void *)&cmd_write_reg_write, 7674 (void *)&cmd_write_reg_reg, 7675 (void *)&cmd_write_reg_port_id, 7676 (void *)&cmd_write_reg_reg_off, 7677 (void *)&cmd_write_reg_value, 7678 NULL, 7679 }, 7680 }; 7681 7682 /* *** WRITE PORT REGISTER BIT FIELD *** */ 7683 struct cmd_write_reg_bit_field_result { 7684 cmdline_fixed_string_t write; 7685 cmdline_fixed_string_t regfield; 7686 portid_t port_id; 7687 uint32_t reg_off; 7688 uint8_t bit1_pos; 7689 uint8_t bit2_pos; 7690 uint32_t value; 7691 }; 7692 7693 static void 7694 cmd_write_reg_bit_field_parsed(void *parsed_result, 7695 __attribute__((unused)) struct cmdline *cl, 7696 __attribute__((unused)) void *data) 7697 { 7698 struct cmd_write_reg_bit_field_result *res = parsed_result; 7699 port_reg_bit_field_set(res->port_id, res->reg_off, 7700 res->bit1_pos, res->bit2_pos, res->value); 7701 } 7702 7703 cmdline_parse_token_string_t cmd_write_reg_bit_field_write = 7704 TOKEN_STRING_INITIALIZER(struct cmd_write_reg_bit_field_result, write, 7705 "write"); 7706 cmdline_parse_token_string_t cmd_write_reg_bit_field_regfield = 7707 TOKEN_STRING_INITIALIZER(struct cmd_write_reg_bit_field_result, 7708 regfield, "regfield"); 7709 cmdline_parse_token_num_t cmd_write_reg_bit_field_port_id = 7710 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_field_result, port_id, 7711 UINT16); 7712 cmdline_parse_token_num_t cmd_write_reg_bit_field_reg_off = 7713 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_field_result, reg_off, 7714 UINT32); 7715 cmdline_parse_token_num_t cmd_write_reg_bit_field_bit1_pos = 7716 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_field_result, bit1_pos, 7717 UINT8); 7718 cmdline_parse_token_num_t cmd_write_reg_bit_field_bit2_pos = 7719 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_field_result, bit2_pos, 7720 UINT8); 7721 cmdline_parse_token_num_t cmd_write_reg_bit_field_value = 7722 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_field_result, value, 7723 UINT32); 7724 7725 cmdline_parse_inst_t cmd_write_reg_bit_field = { 7726 .f = cmd_write_reg_bit_field_parsed, 7727 .data = NULL, 7728 .help_str = "write regfield <port_id> <reg_off> <bit_x> <bit_y> " 7729 "<reg_value>: " 7730 "Set register bit field between bit_x and bit_y included", 7731 .tokens = { 7732 (void *)&cmd_write_reg_bit_field_write, 7733 (void *)&cmd_write_reg_bit_field_regfield, 7734 (void *)&cmd_write_reg_bit_field_port_id, 7735 (void *)&cmd_write_reg_bit_field_reg_off, 7736 (void *)&cmd_write_reg_bit_field_bit1_pos, 7737 (void *)&cmd_write_reg_bit_field_bit2_pos, 7738 (void *)&cmd_write_reg_bit_field_value, 7739 NULL, 7740 }, 7741 }; 7742 7743 /* *** WRITE PORT REGISTER BIT *** */ 7744 struct cmd_write_reg_bit_result { 7745 cmdline_fixed_string_t write; 7746 cmdline_fixed_string_t regbit; 7747 portid_t port_id; 7748 uint32_t reg_off; 7749 uint8_t bit_pos; 7750 uint8_t value; 7751 }; 7752 7753 static void 7754 cmd_write_reg_bit_parsed(void *parsed_result, 7755 __attribute__((unused)) struct cmdline *cl, 7756 __attribute__((unused)) void *data) 7757 { 7758 struct cmd_write_reg_bit_result *res = parsed_result; 7759 port_reg_bit_set(res->port_id, res->reg_off, res->bit_pos, res->value); 7760 } 7761 7762 cmdline_parse_token_string_t cmd_write_reg_bit_write = 7763 TOKEN_STRING_INITIALIZER(struct cmd_write_reg_bit_result, write, 7764 "write"); 7765 cmdline_parse_token_string_t cmd_write_reg_bit_regbit = 7766 TOKEN_STRING_INITIALIZER(struct cmd_write_reg_bit_result, 7767 regbit, "regbit"); 7768 cmdline_parse_token_num_t cmd_write_reg_bit_port_id = 7769 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_result, port_id, UINT16); 7770 cmdline_parse_token_num_t cmd_write_reg_bit_reg_off = 7771 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_result, reg_off, UINT32); 7772 cmdline_parse_token_num_t cmd_write_reg_bit_bit_pos = 7773 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_result, bit_pos, UINT8); 7774 cmdline_parse_token_num_t cmd_write_reg_bit_value = 7775 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_result, value, UINT8); 7776 7777 cmdline_parse_inst_t cmd_write_reg_bit = { 7778 .f = cmd_write_reg_bit_parsed, 7779 .data = NULL, 7780 .help_str = "write regbit <port_id> <reg_off> <bit_x> 0|1: " 7781 "0 <= bit_x <= 31", 7782 .tokens = { 7783 (void *)&cmd_write_reg_bit_write, 7784 (void *)&cmd_write_reg_bit_regbit, 7785 (void *)&cmd_write_reg_bit_port_id, 7786 (void *)&cmd_write_reg_bit_reg_off, 7787 (void *)&cmd_write_reg_bit_bit_pos, 7788 (void *)&cmd_write_reg_bit_value, 7789 NULL, 7790 }, 7791 }; 7792 7793 /* *** READ A RING DESCRIPTOR OF A PORT RX/TX QUEUE *** */ 7794 struct cmd_read_rxd_txd_result { 7795 cmdline_fixed_string_t read; 7796 cmdline_fixed_string_t rxd_txd; 7797 portid_t port_id; 7798 uint16_t queue_id; 7799 uint16_t desc_id; 7800 }; 7801 7802 static void 7803 cmd_read_rxd_txd_parsed(void *parsed_result, 7804 __attribute__((unused)) struct cmdline *cl, 7805 __attribute__((unused)) void *data) 7806 { 7807 struct cmd_read_rxd_txd_result *res = parsed_result; 7808 7809 if (!strcmp(res->rxd_txd, "rxd")) 7810 rx_ring_desc_display(res->port_id, res->queue_id, res->desc_id); 7811 else if (!strcmp(res->rxd_txd, "txd")) 7812 tx_ring_desc_display(res->port_id, res->queue_id, res->desc_id); 7813 } 7814 7815 cmdline_parse_token_string_t cmd_read_rxd_txd_read = 7816 TOKEN_STRING_INITIALIZER(struct cmd_read_rxd_txd_result, read, "read"); 7817 cmdline_parse_token_string_t cmd_read_rxd_txd_rxd_txd = 7818 TOKEN_STRING_INITIALIZER(struct cmd_read_rxd_txd_result, rxd_txd, 7819 "rxd#txd"); 7820 cmdline_parse_token_num_t cmd_read_rxd_txd_port_id = 7821 TOKEN_NUM_INITIALIZER(struct cmd_read_rxd_txd_result, port_id, UINT16); 7822 cmdline_parse_token_num_t cmd_read_rxd_txd_queue_id = 7823 TOKEN_NUM_INITIALIZER(struct cmd_read_rxd_txd_result, queue_id, UINT16); 7824 cmdline_parse_token_num_t cmd_read_rxd_txd_desc_id = 7825 TOKEN_NUM_INITIALIZER(struct cmd_read_rxd_txd_result, desc_id, UINT16); 7826 7827 cmdline_parse_inst_t cmd_read_rxd_txd = { 7828 .f = cmd_read_rxd_txd_parsed, 7829 .data = NULL, 7830 .help_str = "read rxd|txd <port_id> <queue_id> <desc_id>", 7831 .tokens = { 7832 (void *)&cmd_read_rxd_txd_read, 7833 (void *)&cmd_read_rxd_txd_rxd_txd, 7834 (void *)&cmd_read_rxd_txd_port_id, 7835 (void *)&cmd_read_rxd_txd_queue_id, 7836 (void *)&cmd_read_rxd_txd_desc_id, 7837 NULL, 7838 }, 7839 }; 7840 7841 /* *** QUIT *** */ 7842 struct cmd_quit_result { 7843 cmdline_fixed_string_t quit; 7844 }; 7845 7846 static void cmd_quit_parsed(__attribute__((unused)) void *parsed_result, 7847 struct cmdline *cl, 7848 __attribute__((unused)) void *data) 7849 { 7850 cmdline_quit(cl); 7851 } 7852 7853 cmdline_parse_token_string_t cmd_quit_quit = 7854 TOKEN_STRING_INITIALIZER(struct cmd_quit_result, quit, "quit"); 7855 7856 cmdline_parse_inst_t cmd_quit = { 7857 .f = cmd_quit_parsed, 7858 .data = NULL, 7859 .help_str = "quit: Exit application", 7860 .tokens = { 7861 (void *)&cmd_quit_quit, 7862 NULL, 7863 }, 7864 }; 7865 7866 /* *** ADD/REMOVE MAC ADDRESS FROM A PORT *** */ 7867 struct cmd_mac_addr_result { 7868 cmdline_fixed_string_t mac_addr_cmd; 7869 cmdline_fixed_string_t what; 7870 uint16_t port_num; 7871 struct ether_addr address; 7872 }; 7873 7874 static void cmd_mac_addr_parsed(void *parsed_result, 7875 __attribute__((unused)) struct cmdline *cl, 7876 __attribute__((unused)) void *data) 7877 { 7878 struct cmd_mac_addr_result *res = parsed_result; 7879 int ret; 7880 7881 if (strcmp(res->what, "add") == 0) 7882 ret = rte_eth_dev_mac_addr_add(res->port_num, &res->address, 0); 7883 else if (strcmp(res->what, "set") == 0) 7884 ret = rte_eth_dev_default_mac_addr_set(res->port_num, 7885 &res->address); 7886 else 7887 ret = rte_eth_dev_mac_addr_remove(res->port_num, &res->address); 7888 7889 /* check the return value and print it if is < 0 */ 7890 if(ret < 0) 7891 printf("mac_addr_cmd error: (%s)\n", strerror(-ret)); 7892 7893 } 7894 7895 cmdline_parse_token_string_t cmd_mac_addr_cmd = 7896 TOKEN_STRING_INITIALIZER(struct cmd_mac_addr_result, mac_addr_cmd, 7897 "mac_addr"); 7898 cmdline_parse_token_string_t cmd_mac_addr_what = 7899 TOKEN_STRING_INITIALIZER(struct cmd_mac_addr_result, what, 7900 "add#remove#set"); 7901 cmdline_parse_token_num_t cmd_mac_addr_portnum = 7902 TOKEN_NUM_INITIALIZER(struct cmd_mac_addr_result, port_num, 7903 UINT16); 7904 cmdline_parse_token_etheraddr_t cmd_mac_addr_addr = 7905 TOKEN_ETHERADDR_INITIALIZER(struct cmd_mac_addr_result, address); 7906 7907 cmdline_parse_inst_t cmd_mac_addr = { 7908 .f = cmd_mac_addr_parsed, 7909 .data = (void *)0, 7910 .help_str = "mac_addr add|remove|set <port_id> <mac_addr>: " 7911 "Add/Remove/Set MAC address on port_id", 7912 .tokens = { 7913 (void *)&cmd_mac_addr_cmd, 7914 (void *)&cmd_mac_addr_what, 7915 (void *)&cmd_mac_addr_portnum, 7916 (void *)&cmd_mac_addr_addr, 7917 NULL, 7918 }, 7919 }; 7920 7921 /* *** SET THE PEER ADDRESS FOR CERTAIN PORT *** */ 7922 struct cmd_eth_peer_result { 7923 cmdline_fixed_string_t set; 7924 cmdline_fixed_string_t eth_peer; 7925 portid_t port_id; 7926 cmdline_fixed_string_t peer_addr; 7927 }; 7928 7929 static void cmd_set_eth_peer_parsed(void *parsed_result, 7930 __attribute__((unused)) struct cmdline *cl, 7931 __attribute__((unused)) void *data) 7932 { 7933 struct cmd_eth_peer_result *res = parsed_result; 7934 7935 if (test_done == 0) { 7936 printf("Please stop forwarding first\n"); 7937 return; 7938 } 7939 if (!strcmp(res->eth_peer, "eth-peer")) { 7940 set_fwd_eth_peer(res->port_id, res->peer_addr); 7941 fwd_config_setup(); 7942 } 7943 } 7944 cmdline_parse_token_string_t cmd_eth_peer_set = 7945 TOKEN_STRING_INITIALIZER(struct cmd_eth_peer_result, set, "set"); 7946 cmdline_parse_token_string_t cmd_eth_peer = 7947 TOKEN_STRING_INITIALIZER(struct cmd_eth_peer_result, eth_peer, "eth-peer"); 7948 cmdline_parse_token_num_t cmd_eth_peer_port_id = 7949 TOKEN_NUM_INITIALIZER(struct cmd_eth_peer_result, port_id, UINT16); 7950 cmdline_parse_token_string_t cmd_eth_peer_addr = 7951 TOKEN_STRING_INITIALIZER(struct cmd_eth_peer_result, peer_addr, NULL); 7952 7953 cmdline_parse_inst_t cmd_set_fwd_eth_peer = { 7954 .f = cmd_set_eth_peer_parsed, 7955 .data = NULL, 7956 .help_str = "set eth-peer <port_id> <peer_mac>", 7957 .tokens = { 7958 (void *)&cmd_eth_peer_set, 7959 (void *)&cmd_eth_peer, 7960 (void *)&cmd_eth_peer_port_id, 7961 (void *)&cmd_eth_peer_addr, 7962 NULL, 7963 }, 7964 }; 7965 7966 /* *** CONFIGURE QUEUE STATS COUNTER MAPPINGS *** */ 7967 struct cmd_set_qmap_result { 7968 cmdline_fixed_string_t set; 7969 cmdline_fixed_string_t qmap; 7970 cmdline_fixed_string_t what; 7971 portid_t port_id; 7972 uint16_t queue_id; 7973 uint8_t map_value; 7974 }; 7975 7976 static void 7977 cmd_set_qmap_parsed(void *parsed_result, 7978 __attribute__((unused)) struct cmdline *cl, 7979 __attribute__((unused)) void *data) 7980 { 7981 struct cmd_set_qmap_result *res = parsed_result; 7982 int is_rx = (strcmp(res->what, "tx") == 0) ? 0 : 1; 7983 7984 set_qmap(res->port_id, (uint8_t)is_rx, res->queue_id, res->map_value); 7985 } 7986 7987 cmdline_parse_token_string_t cmd_setqmap_set = 7988 TOKEN_STRING_INITIALIZER(struct cmd_set_qmap_result, 7989 set, "set"); 7990 cmdline_parse_token_string_t cmd_setqmap_qmap = 7991 TOKEN_STRING_INITIALIZER(struct cmd_set_qmap_result, 7992 qmap, "stat_qmap"); 7993 cmdline_parse_token_string_t cmd_setqmap_what = 7994 TOKEN_STRING_INITIALIZER(struct cmd_set_qmap_result, 7995 what, "tx#rx"); 7996 cmdline_parse_token_num_t cmd_setqmap_portid = 7997 TOKEN_NUM_INITIALIZER(struct cmd_set_qmap_result, 7998 port_id, UINT16); 7999 cmdline_parse_token_num_t cmd_setqmap_queueid = 8000 TOKEN_NUM_INITIALIZER(struct cmd_set_qmap_result, 8001 queue_id, UINT16); 8002 cmdline_parse_token_num_t cmd_setqmap_mapvalue = 8003 TOKEN_NUM_INITIALIZER(struct cmd_set_qmap_result, 8004 map_value, UINT8); 8005 8006 cmdline_parse_inst_t cmd_set_qmap = { 8007 .f = cmd_set_qmap_parsed, 8008 .data = NULL, 8009 .help_str = "set stat_qmap rx|tx <port_id> <queue_id> <map_value>: " 8010 "Set statistics mapping value on tx|rx queue_id of port_id", 8011 .tokens = { 8012 (void *)&cmd_setqmap_set, 8013 (void *)&cmd_setqmap_qmap, 8014 (void *)&cmd_setqmap_what, 8015 (void *)&cmd_setqmap_portid, 8016 (void *)&cmd_setqmap_queueid, 8017 (void *)&cmd_setqmap_mapvalue, 8018 NULL, 8019 }, 8020 }; 8021 8022 /* *** SET OPTION TO HIDE ZERO VALUES FOR XSTATS DISPLAY *** */ 8023 struct cmd_set_xstats_hide_zero_result { 8024 cmdline_fixed_string_t keyword; 8025 cmdline_fixed_string_t name; 8026 cmdline_fixed_string_t on_off; 8027 }; 8028 8029 static void 8030 cmd_set_xstats_hide_zero_parsed(void *parsed_result, 8031 __attribute__((unused)) struct cmdline *cl, 8032 __attribute__((unused)) void *data) 8033 { 8034 struct cmd_set_xstats_hide_zero_result *res; 8035 uint16_t on_off = 0; 8036 8037 res = parsed_result; 8038 on_off = !strcmp(res->on_off, "on") ? 1 : 0; 8039 set_xstats_hide_zero(on_off); 8040 } 8041 8042 cmdline_parse_token_string_t cmd_set_xstats_hide_zero_keyword = 8043 TOKEN_STRING_INITIALIZER(struct cmd_set_xstats_hide_zero_result, 8044 keyword, "set"); 8045 cmdline_parse_token_string_t cmd_set_xstats_hide_zero_name = 8046 TOKEN_STRING_INITIALIZER(struct cmd_set_xstats_hide_zero_result, 8047 name, "xstats-hide-zero"); 8048 cmdline_parse_token_string_t cmd_set_xstats_hide_zero_on_off = 8049 TOKEN_STRING_INITIALIZER(struct cmd_set_xstats_hide_zero_result, 8050 on_off, "on#off"); 8051 8052 cmdline_parse_inst_t cmd_set_xstats_hide_zero = { 8053 .f = cmd_set_xstats_hide_zero_parsed, 8054 .data = NULL, 8055 .help_str = "set xstats-hide-zero on|off", 8056 .tokens = { 8057 (void *)&cmd_set_xstats_hide_zero_keyword, 8058 (void *)&cmd_set_xstats_hide_zero_name, 8059 (void *)&cmd_set_xstats_hide_zero_on_off, 8060 NULL, 8061 }, 8062 }; 8063 8064 /* *** CONFIGURE UNICAST HASH TABLE *** */ 8065 struct cmd_set_uc_hash_table { 8066 cmdline_fixed_string_t set; 8067 cmdline_fixed_string_t port; 8068 portid_t port_id; 8069 cmdline_fixed_string_t what; 8070 struct ether_addr address; 8071 cmdline_fixed_string_t mode; 8072 }; 8073 8074 static void 8075 cmd_set_uc_hash_parsed(void *parsed_result, 8076 __attribute__((unused)) struct cmdline *cl, 8077 __attribute__((unused)) void *data) 8078 { 8079 int ret=0; 8080 struct cmd_set_uc_hash_table *res = parsed_result; 8081 8082 int is_on = (strcmp(res->mode, "on") == 0) ? 1 : 0; 8083 8084 if (strcmp(res->what, "uta") == 0) 8085 ret = rte_eth_dev_uc_hash_table_set(res->port_id, 8086 &res->address,(uint8_t)is_on); 8087 if (ret < 0) 8088 printf("bad unicast hash table parameter, return code = %d \n", ret); 8089 8090 } 8091 8092 cmdline_parse_token_string_t cmd_set_uc_hash_set = 8093 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_hash_table, 8094 set, "set"); 8095 cmdline_parse_token_string_t cmd_set_uc_hash_port = 8096 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_hash_table, 8097 port, "port"); 8098 cmdline_parse_token_num_t cmd_set_uc_hash_portid = 8099 TOKEN_NUM_INITIALIZER(struct cmd_set_uc_hash_table, 8100 port_id, UINT16); 8101 cmdline_parse_token_string_t cmd_set_uc_hash_what = 8102 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_hash_table, 8103 what, "uta"); 8104 cmdline_parse_token_etheraddr_t cmd_set_uc_hash_mac = 8105 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_uc_hash_table, 8106 address); 8107 cmdline_parse_token_string_t cmd_set_uc_hash_mode = 8108 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_hash_table, 8109 mode, "on#off"); 8110 8111 cmdline_parse_inst_t cmd_set_uc_hash_filter = { 8112 .f = cmd_set_uc_hash_parsed, 8113 .data = NULL, 8114 .help_str = "set port <port_id> uta <mac_addr> on|off)", 8115 .tokens = { 8116 (void *)&cmd_set_uc_hash_set, 8117 (void *)&cmd_set_uc_hash_port, 8118 (void *)&cmd_set_uc_hash_portid, 8119 (void *)&cmd_set_uc_hash_what, 8120 (void *)&cmd_set_uc_hash_mac, 8121 (void *)&cmd_set_uc_hash_mode, 8122 NULL, 8123 }, 8124 }; 8125 8126 struct cmd_set_uc_all_hash_table { 8127 cmdline_fixed_string_t set; 8128 cmdline_fixed_string_t port; 8129 portid_t port_id; 8130 cmdline_fixed_string_t what; 8131 cmdline_fixed_string_t value; 8132 cmdline_fixed_string_t mode; 8133 }; 8134 8135 static void 8136 cmd_set_uc_all_hash_parsed(void *parsed_result, 8137 __attribute__((unused)) struct cmdline *cl, 8138 __attribute__((unused)) void *data) 8139 { 8140 int ret=0; 8141 struct cmd_set_uc_all_hash_table *res = parsed_result; 8142 8143 int is_on = (strcmp(res->mode, "on") == 0) ? 1 : 0; 8144 8145 if ((strcmp(res->what, "uta") == 0) && 8146 (strcmp(res->value, "all") == 0)) 8147 ret = rte_eth_dev_uc_all_hash_table_set(res->port_id,(uint8_t) is_on); 8148 if (ret < 0) 8149 printf("bad unicast hash table parameter," 8150 "return code = %d \n", ret); 8151 } 8152 8153 cmdline_parse_token_string_t cmd_set_uc_all_hash_set = 8154 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_all_hash_table, 8155 set, "set"); 8156 cmdline_parse_token_string_t cmd_set_uc_all_hash_port = 8157 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_all_hash_table, 8158 port, "port"); 8159 cmdline_parse_token_num_t cmd_set_uc_all_hash_portid = 8160 TOKEN_NUM_INITIALIZER(struct cmd_set_uc_all_hash_table, 8161 port_id, UINT16); 8162 cmdline_parse_token_string_t cmd_set_uc_all_hash_what = 8163 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_all_hash_table, 8164 what, "uta"); 8165 cmdline_parse_token_string_t cmd_set_uc_all_hash_value = 8166 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_all_hash_table, 8167 value,"all"); 8168 cmdline_parse_token_string_t cmd_set_uc_all_hash_mode = 8169 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_all_hash_table, 8170 mode, "on#off"); 8171 8172 cmdline_parse_inst_t cmd_set_uc_all_hash_filter = { 8173 .f = cmd_set_uc_all_hash_parsed, 8174 .data = NULL, 8175 .help_str = "set port <port_id> uta all on|off", 8176 .tokens = { 8177 (void *)&cmd_set_uc_all_hash_set, 8178 (void *)&cmd_set_uc_all_hash_port, 8179 (void *)&cmd_set_uc_all_hash_portid, 8180 (void *)&cmd_set_uc_all_hash_what, 8181 (void *)&cmd_set_uc_all_hash_value, 8182 (void *)&cmd_set_uc_all_hash_mode, 8183 NULL, 8184 }, 8185 }; 8186 8187 /* *** CONFIGURE MACVLAN FILTER FOR VF(s) *** */ 8188 struct cmd_set_vf_macvlan_filter { 8189 cmdline_fixed_string_t set; 8190 cmdline_fixed_string_t port; 8191 portid_t port_id; 8192 cmdline_fixed_string_t vf; 8193 uint8_t vf_id; 8194 struct ether_addr address; 8195 cmdline_fixed_string_t filter_type; 8196 cmdline_fixed_string_t mode; 8197 }; 8198 8199 static void 8200 cmd_set_vf_macvlan_parsed(void *parsed_result, 8201 __attribute__((unused)) struct cmdline *cl, 8202 __attribute__((unused)) void *data) 8203 { 8204 int is_on, ret = 0; 8205 struct cmd_set_vf_macvlan_filter *res = parsed_result; 8206 struct rte_eth_mac_filter filter; 8207 8208 memset(&filter, 0, sizeof(struct rte_eth_mac_filter)); 8209 8210 rte_memcpy(&filter.mac_addr, &res->address, ETHER_ADDR_LEN); 8211 8212 /* set VF MAC filter */ 8213 filter.is_vf = 1; 8214 8215 /* set VF ID */ 8216 filter.dst_id = res->vf_id; 8217 8218 if (!strcmp(res->filter_type, "exact-mac")) 8219 filter.filter_type = RTE_MAC_PERFECT_MATCH; 8220 else if (!strcmp(res->filter_type, "exact-mac-vlan")) 8221 filter.filter_type = RTE_MACVLAN_PERFECT_MATCH; 8222 else if (!strcmp(res->filter_type, "hashmac")) 8223 filter.filter_type = RTE_MAC_HASH_MATCH; 8224 else if (!strcmp(res->filter_type, "hashmac-vlan")) 8225 filter.filter_type = RTE_MACVLAN_HASH_MATCH; 8226 8227 is_on = (strcmp(res->mode, "on") == 0) ? 1 : 0; 8228 8229 if (is_on) 8230 ret = rte_eth_dev_filter_ctrl(res->port_id, 8231 RTE_ETH_FILTER_MACVLAN, 8232 RTE_ETH_FILTER_ADD, 8233 &filter); 8234 else 8235 ret = rte_eth_dev_filter_ctrl(res->port_id, 8236 RTE_ETH_FILTER_MACVLAN, 8237 RTE_ETH_FILTER_DELETE, 8238 &filter); 8239 8240 if (ret < 0) 8241 printf("bad set MAC hash parameter, return code = %d\n", ret); 8242 8243 } 8244 8245 cmdline_parse_token_string_t cmd_set_vf_macvlan_set = 8246 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_macvlan_filter, 8247 set, "set"); 8248 cmdline_parse_token_string_t cmd_set_vf_macvlan_port = 8249 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_macvlan_filter, 8250 port, "port"); 8251 cmdline_parse_token_num_t cmd_set_vf_macvlan_portid = 8252 TOKEN_NUM_INITIALIZER(struct cmd_set_vf_macvlan_filter, 8253 port_id, UINT16); 8254 cmdline_parse_token_string_t cmd_set_vf_macvlan_vf = 8255 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_macvlan_filter, 8256 vf, "vf"); 8257 cmdline_parse_token_num_t cmd_set_vf_macvlan_vf_id = 8258 TOKEN_NUM_INITIALIZER(struct cmd_set_vf_macvlan_filter, 8259 vf_id, UINT8); 8260 cmdline_parse_token_etheraddr_t cmd_set_vf_macvlan_mac = 8261 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_vf_macvlan_filter, 8262 address); 8263 cmdline_parse_token_string_t cmd_set_vf_macvlan_filter_type = 8264 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_macvlan_filter, 8265 filter_type, "exact-mac#exact-mac-vlan" 8266 "#hashmac#hashmac-vlan"); 8267 cmdline_parse_token_string_t cmd_set_vf_macvlan_mode = 8268 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_macvlan_filter, 8269 mode, "on#off"); 8270 8271 cmdline_parse_inst_t cmd_set_vf_macvlan_filter = { 8272 .f = cmd_set_vf_macvlan_parsed, 8273 .data = NULL, 8274 .help_str = "set port <port_id> vf <vf_id> <mac_addr> " 8275 "exact-mac|exact-mac-vlan|hashmac|hashmac-vlan on|off: " 8276 "Exact match rule: exact match of MAC or MAC and VLAN; " 8277 "hash match rule: hash match of MAC and exact match of VLAN", 8278 .tokens = { 8279 (void *)&cmd_set_vf_macvlan_set, 8280 (void *)&cmd_set_vf_macvlan_port, 8281 (void *)&cmd_set_vf_macvlan_portid, 8282 (void *)&cmd_set_vf_macvlan_vf, 8283 (void *)&cmd_set_vf_macvlan_vf_id, 8284 (void *)&cmd_set_vf_macvlan_mac, 8285 (void *)&cmd_set_vf_macvlan_filter_type, 8286 (void *)&cmd_set_vf_macvlan_mode, 8287 NULL, 8288 }, 8289 }; 8290 8291 /* *** CONFIGURE VF TRAFFIC CONTROL *** */ 8292 struct cmd_set_vf_traffic { 8293 cmdline_fixed_string_t set; 8294 cmdline_fixed_string_t port; 8295 portid_t port_id; 8296 cmdline_fixed_string_t vf; 8297 uint8_t vf_id; 8298 cmdline_fixed_string_t what; 8299 cmdline_fixed_string_t mode; 8300 }; 8301 8302 static void 8303 cmd_set_vf_traffic_parsed(void *parsed_result, 8304 __attribute__((unused)) struct cmdline *cl, 8305 __attribute__((unused)) void *data) 8306 { 8307 struct cmd_set_vf_traffic *res = parsed_result; 8308 int is_rx = (strcmp(res->what, "rx") == 0) ? 1 : 0; 8309 int is_on = (strcmp(res->mode, "on") == 0) ? 1 : 0; 8310 8311 set_vf_traffic(res->port_id, (uint8_t)is_rx, res->vf_id,(uint8_t) is_on); 8312 } 8313 8314 cmdline_parse_token_string_t cmd_setvf_traffic_set = 8315 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_traffic, 8316 set, "set"); 8317 cmdline_parse_token_string_t cmd_setvf_traffic_port = 8318 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_traffic, 8319 port, "port"); 8320 cmdline_parse_token_num_t cmd_setvf_traffic_portid = 8321 TOKEN_NUM_INITIALIZER(struct cmd_set_vf_traffic, 8322 port_id, UINT16); 8323 cmdline_parse_token_string_t cmd_setvf_traffic_vf = 8324 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_traffic, 8325 vf, "vf"); 8326 cmdline_parse_token_num_t cmd_setvf_traffic_vfid = 8327 TOKEN_NUM_INITIALIZER(struct cmd_set_vf_traffic, 8328 vf_id, UINT8); 8329 cmdline_parse_token_string_t cmd_setvf_traffic_what = 8330 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_traffic, 8331 what, "tx#rx"); 8332 cmdline_parse_token_string_t cmd_setvf_traffic_mode = 8333 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_traffic, 8334 mode, "on#off"); 8335 8336 cmdline_parse_inst_t cmd_set_vf_traffic = { 8337 .f = cmd_set_vf_traffic_parsed, 8338 .data = NULL, 8339 .help_str = "set port <port_id> vf <vf_id> rx|tx on|off", 8340 .tokens = { 8341 (void *)&cmd_setvf_traffic_set, 8342 (void *)&cmd_setvf_traffic_port, 8343 (void *)&cmd_setvf_traffic_portid, 8344 (void *)&cmd_setvf_traffic_vf, 8345 (void *)&cmd_setvf_traffic_vfid, 8346 (void *)&cmd_setvf_traffic_what, 8347 (void *)&cmd_setvf_traffic_mode, 8348 NULL, 8349 }, 8350 }; 8351 8352 /* *** CONFIGURE VF RECEIVE MODE *** */ 8353 struct cmd_set_vf_rxmode { 8354 cmdline_fixed_string_t set; 8355 cmdline_fixed_string_t port; 8356 portid_t port_id; 8357 cmdline_fixed_string_t vf; 8358 uint8_t vf_id; 8359 cmdline_fixed_string_t what; 8360 cmdline_fixed_string_t mode; 8361 cmdline_fixed_string_t on; 8362 }; 8363 8364 static void 8365 cmd_set_vf_rxmode_parsed(void *parsed_result, 8366 __attribute__((unused)) struct cmdline *cl, 8367 __attribute__((unused)) void *data) 8368 { 8369 int ret = -ENOTSUP; 8370 uint16_t vf_rxmode = 0; 8371 struct cmd_set_vf_rxmode *res = parsed_result; 8372 8373 int is_on = (strcmp(res->on, "on") == 0) ? 1 : 0; 8374 if (!strcmp(res->what,"rxmode")) { 8375 if (!strcmp(res->mode, "AUPE")) 8376 vf_rxmode |= ETH_VMDQ_ACCEPT_UNTAG; 8377 else if (!strcmp(res->mode, "ROPE")) 8378 vf_rxmode |= ETH_VMDQ_ACCEPT_HASH_UC; 8379 else if (!strcmp(res->mode, "BAM")) 8380 vf_rxmode |= ETH_VMDQ_ACCEPT_BROADCAST; 8381 else if (!strncmp(res->mode, "MPE",3)) 8382 vf_rxmode |= ETH_VMDQ_ACCEPT_MULTICAST; 8383 } 8384 8385 RTE_SET_USED(is_on); 8386 8387 #ifdef RTE_LIBRTE_IXGBE_PMD 8388 if (ret == -ENOTSUP) 8389 ret = rte_pmd_ixgbe_set_vf_rxmode(res->port_id, res->vf_id, 8390 vf_rxmode, (uint8_t)is_on); 8391 #endif 8392 #ifdef RTE_LIBRTE_BNXT_PMD 8393 if (ret == -ENOTSUP) 8394 ret = rte_pmd_bnxt_set_vf_rxmode(res->port_id, res->vf_id, 8395 vf_rxmode, (uint8_t)is_on); 8396 #endif 8397 if (ret < 0) 8398 printf("bad VF receive mode parameter, return code = %d \n", 8399 ret); 8400 } 8401 8402 cmdline_parse_token_string_t cmd_set_vf_rxmode_set = 8403 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_rxmode, 8404 set, "set"); 8405 cmdline_parse_token_string_t cmd_set_vf_rxmode_port = 8406 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_rxmode, 8407 port, "port"); 8408 cmdline_parse_token_num_t cmd_set_vf_rxmode_portid = 8409 TOKEN_NUM_INITIALIZER(struct cmd_set_vf_rxmode, 8410 port_id, UINT16); 8411 cmdline_parse_token_string_t cmd_set_vf_rxmode_vf = 8412 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_rxmode, 8413 vf, "vf"); 8414 cmdline_parse_token_num_t cmd_set_vf_rxmode_vfid = 8415 TOKEN_NUM_INITIALIZER(struct cmd_set_vf_rxmode, 8416 vf_id, UINT8); 8417 cmdline_parse_token_string_t cmd_set_vf_rxmode_what = 8418 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_rxmode, 8419 what, "rxmode"); 8420 cmdline_parse_token_string_t cmd_set_vf_rxmode_mode = 8421 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_rxmode, 8422 mode, "AUPE#ROPE#BAM#MPE"); 8423 cmdline_parse_token_string_t cmd_set_vf_rxmode_on = 8424 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_rxmode, 8425 on, "on#off"); 8426 8427 cmdline_parse_inst_t cmd_set_vf_rxmode = { 8428 .f = cmd_set_vf_rxmode_parsed, 8429 .data = NULL, 8430 .help_str = "set port <port_id> vf <vf_id> rxmode " 8431 "AUPE|ROPE|BAM|MPE on|off", 8432 .tokens = { 8433 (void *)&cmd_set_vf_rxmode_set, 8434 (void *)&cmd_set_vf_rxmode_port, 8435 (void *)&cmd_set_vf_rxmode_portid, 8436 (void *)&cmd_set_vf_rxmode_vf, 8437 (void *)&cmd_set_vf_rxmode_vfid, 8438 (void *)&cmd_set_vf_rxmode_what, 8439 (void *)&cmd_set_vf_rxmode_mode, 8440 (void *)&cmd_set_vf_rxmode_on, 8441 NULL, 8442 }, 8443 }; 8444 8445 /* *** ADD MAC ADDRESS FILTER FOR A VF OF A PORT *** */ 8446 struct cmd_vf_mac_addr_result { 8447 cmdline_fixed_string_t mac_addr_cmd; 8448 cmdline_fixed_string_t what; 8449 cmdline_fixed_string_t port; 8450 uint16_t port_num; 8451 cmdline_fixed_string_t vf; 8452 uint8_t vf_num; 8453 struct ether_addr address; 8454 }; 8455 8456 static void cmd_vf_mac_addr_parsed(void *parsed_result, 8457 __attribute__((unused)) struct cmdline *cl, 8458 __attribute__((unused)) void *data) 8459 { 8460 struct cmd_vf_mac_addr_result *res = parsed_result; 8461 int ret = -ENOTSUP; 8462 8463 if (strcmp(res->what, "add") != 0) 8464 return; 8465 8466 #ifdef RTE_LIBRTE_I40E_PMD 8467 if (ret == -ENOTSUP) 8468 ret = rte_pmd_i40e_add_vf_mac_addr(res->port_num, res->vf_num, 8469 &res->address); 8470 #endif 8471 #ifdef RTE_LIBRTE_BNXT_PMD 8472 if (ret == -ENOTSUP) 8473 ret = rte_pmd_bnxt_mac_addr_add(res->port_num, &res->address, 8474 res->vf_num); 8475 #endif 8476 8477 if(ret < 0) 8478 printf("vf_mac_addr_cmd error: (%s)\n", strerror(-ret)); 8479 8480 } 8481 8482 cmdline_parse_token_string_t cmd_vf_mac_addr_cmd = 8483 TOKEN_STRING_INITIALIZER(struct cmd_vf_mac_addr_result, 8484 mac_addr_cmd,"mac_addr"); 8485 cmdline_parse_token_string_t cmd_vf_mac_addr_what = 8486 TOKEN_STRING_INITIALIZER(struct cmd_vf_mac_addr_result, 8487 what,"add"); 8488 cmdline_parse_token_string_t cmd_vf_mac_addr_port = 8489 TOKEN_STRING_INITIALIZER(struct cmd_vf_mac_addr_result, 8490 port,"port"); 8491 cmdline_parse_token_num_t cmd_vf_mac_addr_portnum = 8492 TOKEN_NUM_INITIALIZER(struct cmd_vf_mac_addr_result, 8493 port_num, UINT16); 8494 cmdline_parse_token_string_t cmd_vf_mac_addr_vf = 8495 TOKEN_STRING_INITIALIZER(struct cmd_vf_mac_addr_result, 8496 vf,"vf"); 8497 cmdline_parse_token_num_t cmd_vf_mac_addr_vfnum = 8498 TOKEN_NUM_INITIALIZER(struct cmd_vf_mac_addr_result, 8499 vf_num, UINT8); 8500 cmdline_parse_token_etheraddr_t cmd_vf_mac_addr_addr = 8501 TOKEN_ETHERADDR_INITIALIZER(struct cmd_vf_mac_addr_result, 8502 address); 8503 8504 cmdline_parse_inst_t cmd_vf_mac_addr_filter = { 8505 .f = cmd_vf_mac_addr_parsed, 8506 .data = (void *)0, 8507 .help_str = "mac_addr add port <port_id> vf <vf_id> <mac_addr>: " 8508 "Add MAC address filtering for a VF on port_id", 8509 .tokens = { 8510 (void *)&cmd_vf_mac_addr_cmd, 8511 (void *)&cmd_vf_mac_addr_what, 8512 (void *)&cmd_vf_mac_addr_port, 8513 (void *)&cmd_vf_mac_addr_portnum, 8514 (void *)&cmd_vf_mac_addr_vf, 8515 (void *)&cmd_vf_mac_addr_vfnum, 8516 (void *)&cmd_vf_mac_addr_addr, 8517 NULL, 8518 }, 8519 }; 8520 8521 /* *** ADD/REMOVE A VLAN IDENTIFIER TO/FROM A PORT VLAN RX FILTER *** */ 8522 struct cmd_vf_rx_vlan_filter { 8523 cmdline_fixed_string_t rx_vlan; 8524 cmdline_fixed_string_t what; 8525 uint16_t vlan_id; 8526 cmdline_fixed_string_t port; 8527 portid_t port_id; 8528 cmdline_fixed_string_t vf; 8529 uint64_t vf_mask; 8530 }; 8531 8532 static void 8533 cmd_vf_rx_vlan_filter_parsed(void *parsed_result, 8534 __attribute__((unused)) struct cmdline *cl, 8535 __attribute__((unused)) void *data) 8536 { 8537 struct cmd_vf_rx_vlan_filter *res = parsed_result; 8538 int ret = -ENOTSUP; 8539 8540 __rte_unused int is_add = (strcmp(res->what, "add") == 0) ? 1 : 0; 8541 8542 #ifdef RTE_LIBRTE_IXGBE_PMD 8543 if (ret == -ENOTSUP) 8544 ret = rte_pmd_ixgbe_set_vf_vlan_filter(res->port_id, 8545 res->vlan_id, res->vf_mask, is_add); 8546 #endif 8547 #ifdef RTE_LIBRTE_I40E_PMD 8548 if (ret == -ENOTSUP) 8549 ret = rte_pmd_i40e_set_vf_vlan_filter(res->port_id, 8550 res->vlan_id, res->vf_mask, is_add); 8551 #endif 8552 #ifdef RTE_LIBRTE_BNXT_PMD 8553 if (ret == -ENOTSUP) 8554 ret = rte_pmd_bnxt_set_vf_vlan_filter(res->port_id, 8555 res->vlan_id, res->vf_mask, is_add); 8556 #endif 8557 8558 switch (ret) { 8559 case 0: 8560 break; 8561 case -EINVAL: 8562 printf("invalid vlan_id %d or vf_mask %"PRIu64"\n", 8563 res->vlan_id, res->vf_mask); 8564 break; 8565 case -ENODEV: 8566 printf("invalid port_id %d\n", res->port_id); 8567 break; 8568 case -ENOTSUP: 8569 printf("function not implemented or supported\n"); 8570 break; 8571 default: 8572 printf("programming error: (%s)\n", strerror(-ret)); 8573 } 8574 } 8575 8576 cmdline_parse_token_string_t cmd_vf_rx_vlan_filter_rx_vlan = 8577 TOKEN_STRING_INITIALIZER(struct cmd_vf_rx_vlan_filter, 8578 rx_vlan, "rx_vlan"); 8579 cmdline_parse_token_string_t cmd_vf_rx_vlan_filter_what = 8580 TOKEN_STRING_INITIALIZER(struct cmd_vf_rx_vlan_filter, 8581 what, "add#rm"); 8582 cmdline_parse_token_num_t cmd_vf_rx_vlan_filter_vlanid = 8583 TOKEN_NUM_INITIALIZER(struct cmd_vf_rx_vlan_filter, 8584 vlan_id, UINT16); 8585 cmdline_parse_token_string_t cmd_vf_rx_vlan_filter_port = 8586 TOKEN_STRING_INITIALIZER(struct cmd_vf_rx_vlan_filter, 8587 port, "port"); 8588 cmdline_parse_token_num_t cmd_vf_rx_vlan_filter_portid = 8589 TOKEN_NUM_INITIALIZER(struct cmd_vf_rx_vlan_filter, 8590 port_id, UINT16); 8591 cmdline_parse_token_string_t cmd_vf_rx_vlan_filter_vf = 8592 TOKEN_STRING_INITIALIZER(struct cmd_vf_rx_vlan_filter, 8593 vf, "vf"); 8594 cmdline_parse_token_num_t cmd_vf_rx_vlan_filter_vf_mask = 8595 TOKEN_NUM_INITIALIZER(struct cmd_vf_rx_vlan_filter, 8596 vf_mask, UINT64); 8597 8598 cmdline_parse_inst_t cmd_vf_rxvlan_filter = { 8599 .f = cmd_vf_rx_vlan_filter_parsed, 8600 .data = NULL, 8601 .help_str = "rx_vlan add|rm <vlan_id> port <port_id> vf <vf_mask>: " 8602 "(vf_mask = hexadecimal VF mask)", 8603 .tokens = { 8604 (void *)&cmd_vf_rx_vlan_filter_rx_vlan, 8605 (void *)&cmd_vf_rx_vlan_filter_what, 8606 (void *)&cmd_vf_rx_vlan_filter_vlanid, 8607 (void *)&cmd_vf_rx_vlan_filter_port, 8608 (void *)&cmd_vf_rx_vlan_filter_portid, 8609 (void *)&cmd_vf_rx_vlan_filter_vf, 8610 (void *)&cmd_vf_rx_vlan_filter_vf_mask, 8611 NULL, 8612 }, 8613 }; 8614 8615 /* *** SET RATE LIMIT FOR A QUEUE OF A PORT *** */ 8616 struct cmd_queue_rate_limit_result { 8617 cmdline_fixed_string_t set; 8618 cmdline_fixed_string_t port; 8619 uint16_t port_num; 8620 cmdline_fixed_string_t queue; 8621 uint8_t queue_num; 8622 cmdline_fixed_string_t rate; 8623 uint16_t rate_num; 8624 }; 8625 8626 static void cmd_queue_rate_limit_parsed(void *parsed_result, 8627 __attribute__((unused)) struct cmdline *cl, 8628 __attribute__((unused)) void *data) 8629 { 8630 struct cmd_queue_rate_limit_result *res = parsed_result; 8631 int ret = 0; 8632 8633 if ((strcmp(res->set, "set") == 0) && (strcmp(res->port, "port") == 0) 8634 && (strcmp(res->queue, "queue") == 0) 8635 && (strcmp(res->rate, "rate") == 0)) 8636 ret = set_queue_rate_limit(res->port_num, res->queue_num, 8637 res->rate_num); 8638 if (ret < 0) 8639 printf("queue_rate_limit_cmd error: (%s)\n", strerror(-ret)); 8640 8641 } 8642 8643 cmdline_parse_token_string_t cmd_queue_rate_limit_set = 8644 TOKEN_STRING_INITIALIZER(struct cmd_queue_rate_limit_result, 8645 set, "set"); 8646 cmdline_parse_token_string_t cmd_queue_rate_limit_port = 8647 TOKEN_STRING_INITIALIZER(struct cmd_queue_rate_limit_result, 8648 port, "port"); 8649 cmdline_parse_token_num_t cmd_queue_rate_limit_portnum = 8650 TOKEN_NUM_INITIALIZER(struct cmd_queue_rate_limit_result, 8651 port_num, UINT16); 8652 cmdline_parse_token_string_t cmd_queue_rate_limit_queue = 8653 TOKEN_STRING_INITIALIZER(struct cmd_queue_rate_limit_result, 8654 queue, "queue"); 8655 cmdline_parse_token_num_t cmd_queue_rate_limit_queuenum = 8656 TOKEN_NUM_INITIALIZER(struct cmd_queue_rate_limit_result, 8657 queue_num, UINT8); 8658 cmdline_parse_token_string_t cmd_queue_rate_limit_rate = 8659 TOKEN_STRING_INITIALIZER(struct cmd_queue_rate_limit_result, 8660 rate, "rate"); 8661 cmdline_parse_token_num_t cmd_queue_rate_limit_ratenum = 8662 TOKEN_NUM_INITIALIZER(struct cmd_queue_rate_limit_result, 8663 rate_num, UINT16); 8664 8665 cmdline_parse_inst_t cmd_queue_rate_limit = { 8666 .f = cmd_queue_rate_limit_parsed, 8667 .data = (void *)0, 8668 .help_str = "set port <port_id> queue <queue_id> rate <rate_value>: " 8669 "Set rate limit for a queue on port_id", 8670 .tokens = { 8671 (void *)&cmd_queue_rate_limit_set, 8672 (void *)&cmd_queue_rate_limit_port, 8673 (void *)&cmd_queue_rate_limit_portnum, 8674 (void *)&cmd_queue_rate_limit_queue, 8675 (void *)&cmd_queue_rate_limit_queuenum, 8676 (void *)&cmd_queue_rate_limit_rate, 8677 (void *)&cmd_queue_rate_limit_ratenum, 8678 NULL, 8679 }, 8680 }; 8681 8682 /* *** SET RATE LIMIT FOR A VF OF A PORT *** */ 8683 struct cmd_vf_rate_limit_result { 8684 cmdline_fixed_string_t set; 8685 cmdline_fixed_string_t port; 8686 uint16_t port_num; 8687 cmdline_fixed_string_t vf; 8688 uint8_t vf_num; 8689 cmdline_fixed_string_t rate; 8690 uint16_t rate_num; 8691 cmdline_fixed_string_t q_msk; 8692 uint64_t q_msk_val; 8693 }; 8694 8695 static void cmd_vf_rate_limit_parsed(void *parsed_result, 8696 __attribute__((unused)) struct cmdline *cl, 8697 __attribute__((unused)) void *data) 8698 { 8699 struct cmd_vf_rate_limit_result *res = parsed_result; 8700 int ret = 0; 8701 8702 if ((strcmp(res->set, "set") == 0) && (strcmp(res->port, "port") == 0) 8703 && (strcmp(res->vf, "vf") == 0) 8704 && (strcmp(res->rate, "rate") == 0) 8705 && (strcmp(res->q_msk, "queue_mask") == 0)) 8706 ret = set_vf_rate_limit(res->port_num, res->vf_num, 8707 res->rate_num, res->q_msk_val); 8708 if (ret < 0) 8709 printf("vf_rate_limit_cmd error: (%s)\n", strerror(-ret)); 8710 8711 } 8712 8713 cmdline_parse_token_string_t cmd_vf_rate_limit_set = 8714 TOKEN_STRING_INITIALIZER(struct cmd_vf_rate_limit_result, 8715 set, "set"); 8716 cmdline_parse_token_string_t cmd_vf_rate_limit_port = 8717 TOKEN_STRING_INITIALIZER(struct cmd_vf_rate_limit_result, 8718 port, "port"); 8719 cmdline_parse_token_num_t cmd_vf_rate_limit_portnum = 8720 TOKEN_NUM_INITIALIZER(struct cmd_vf_rate_limit_result, 8721 port_num, UINT16); 8722 cmdline_parse_token_string_t cmd_vf_rate_limit_vf = 8723 TOKEN_STRING_INITIALIZER(struct cmd_vf_rate_limit_result, 8724 vf, "vf"); 8725 cmdline_parse_token_num_t cmd_vf_rate_limit_vfnum = 8726 TOKEN_NUM_INITIALIZER(struct cmd_vf_rate_limit_result, 8727 vf_num, UINT8); 8728 cmdline_parse_token_string_t cmd_vf_rate_limit_rate = 8729 TOKEN_STRING_INITIALIZER(struct cmd_vf_rate_limit_result, 8730 rate, "rate"); 8731 cmdline_parse_token_num_t cmd_vf_rate_limit_ratenum = 8732 TOKEN_NUM_INITIALIZER(struct cmd_vf_rate_limit_result, 8733 rate_num, UINT16); 8734 cmdline_parse_token_string_t cmd_vf_rate_limit_q_msk = 8735 TOKEN_STRING_INITIALIZER(struct cmd_vf_rate_limit_result, 8736 q_msk, "queue_mask"); 8737 cmdline_parse_token_num_t cmd_vf_rate_limit_q_msk_val = 8738 TOKEN_NUM_INITIALIZER(struct cmd_vf_rate_limit_result, 8739 q_msk_val, UINT64); 8740 8741 cmdline_parse_inst_t cmd_vf_rate_limit = { 8742 .f = cmd_vf_rate_limit_parsed, 8743 .data = (void *)0, 8744 .help_str = "set port <port_id> vf <vf_id> rate <rate_value> " 8745 "queue_mask <queue_mask_value>: " 8746 "Set rate limit for queues of VF on port_id", 8747 .tokens = { 8748 (void *)&cmd_vf_rate_limit_set, 8749 (void *)&cmd_vf_rate_limit_port, 8750 (void *)&cmd_vf_rate_limit_portnum, 8751 (void *)&cmd_vf_rate_limit_vf, 8752 (void *)&cmd_vf_rate_limit_vfnum, 8753 (void *)&cmd_vf_rate_limit_rate, 8754 (void *)&cmd_vf_rate_limit_ratenum, 8755 (void *)&cmd_vf_rate_limit_q_msk, 8756 (void *)&cmd_vf_rate_limit_q_msk_val, 8757 NULL, 8758 }, 8759 }; 8760 8761 /* *** ADD TUNNEL FILTER OF A PORT *** */ 8762 struct cmd_tunnel_filter_result { 8763 cmdline_fixed_string_t cmd; 8764 cmdline_fixed_string_t what; 8765 portid_t port_id; 8766 struct ether_addr outer_mac; 8767 struct ether_addr inner_mac; 8768 cmdline_ipaddr_t ip_value; 8769 uint16_t inner_vlan; 8770 cmdline_fixed_string_t tunnel_type; 8771 cmdline_fixed_string_t filter_type; 8772 uint32_t tenant_id; 8773 uint16_t queue_num; 8774 }; 8775 8776 static void 8777 cmd_tunnel_filter_parsed(void *parsed_result, 8778 __attribute__((unused)) struct cmdline *cl, 8779 __attribute__((unused)) void *data) 8780 { 8781 struct cmd_tunnel_filter_result *res = parsed_result; 8782 struct rte_eth_tunnel_filter_conf tunnel_filter_conf; 8783 int ret = 0; 8784 8785 memset(&tunnel_filter_conf, 0, sizeof(tunnel_filter_conf)); 8786 8787 ether_addr_copy(&res->outer_mac, &tunnel_filter_conf.outer_mac); 8788 ether_addr_copy(&res->inner_mac, &tunnel_filter_conf.inner_mac); 8789 tunnel_filter_conf.inner_vlan = res->inner_vlan; 8790 8791 if (res->ip_value.family == AF_INET) { 8792 tunnel_filter_conf.ip_addr.ipv4_addr = 8793 res->ip_value.addr.ipv4.s_addr; 8794 tunnel_filter_conf.ip_type = RTE_TUNNEL_IPTYPE_IPV4; 8795 } else { 8796 memcpy(&(tunnel_filter_conf.ip_addr.ipv6_addr), 8797 &(res->ip_value.addr.ipv6), 8798 sizeof(struct in6_addr)); 8799 tunnel_filter_conf.ip_type = RTE_TUNNEL_IPTYPE_IPV6; 8800 } 8801 8802 if (!strcmp(res->filter_type, "imac-ivlan")) 8803 tunnel_filter_conf.filter_type = RTE_TUNNEL_FILTER_IMAC_IVLAN; 8804 else if (!strcmp(res->filter_type, "imac-ivlan-tenid")) 8805 tunnel_filter_conf.filter_type = 8806 RTE_TUNNEL_FILTER_IMAC_IVLAN_TENID; 8807 else if (!strcmp(res->filter_type, "imac-tenid")) 8808 tunnel_filter_conf.filter_type = RTE_TUNNEL_FILTER_IMAC_TENID; 8809 else if (!strcmp(res->filter_type, "imac")) 8810 tunnel_filter_conf.filter_type = ETH_TUNNEL_FILTER_IMAC; 8811 else if (!strcmp(res->filter_type, "omac-imac-tenid")) 8812 tunnel_filter_conf.filter_type = 8813 RTE_TUNNEL_FILTER_OMAC_TENID_IMAC; 8814 else if (!strcmp(res->filter_type, "oip")) 8815 tunnel_filter_conf.filter_type = ETH_TUNNEL_FILTER_OIP; 8816 else if (!strcmp(res->filter_type, "iip")) 8817 tunnel_filter_conf.filter_type = ETH_TUNNEL_FILTER_IIP; 8818 else { 8819 printf("The filter type is not supported"); 8820 return; 8821 } 8822 8823 if (!strcmp(res->tunnel_type, "vxlan")) 8824 tunnel_filter_conf.tunnel_type = RTE_TUNNEL_TYPE_VXLAN; 8825 else if (!strcmp(res->tunnel_type, "nvgre")) 8826 tunnel_filter_conf.tunnel_type = RTE_TUNNEL_TYPE_NVGRE; 8827 else if (!strcmp(res->tunnel_type, "ipingre")) 8828 tunnel_filter_conf.tunnel_type = RTE_TUNNEL_TYPE_IP_IN_GRE; 8829 else { 8830 printf("The tunnel type %s not supported.\n", res->tunnel_type); 8831 return; 8832 } 8833 8834 tunnel_filter_conf.tenant_id = res->tenant_id; 8835 tunnel_filter_conf.queue_id = res->queue_num; 8836 if (!strcmp(res->what, "add")) 8837 ret = rte_eth_dev_filter_ctrl(res->port_id, 8838 RTE_ETH_FILTER_TUNNEL, 8839 RTE_ETH_FILTER_ADD, 8840 &tunnel_filter_conf); 8841 else 8842 ret = rte_eth_dev_filter_ctrl(res->port_id, 8843 RTE_ETH_FILTER_TUNNEL, 8844 RTE_ETH_FILTER_DELETE, 8845 &tunnel_filter_conf); 8846 if (ret < 0) 8847 printf("cmd_tunnel_filter_parsed error: (%s)\n", 8848 strerror(-ret)); 8849 8850 } 8851 cmdline_parse_token_string_t cmd_tunnel_filter_cmd = 8852 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_filter_result, 8853 cmd, "tunnel_filter"); 8854 cmdline_parse_token_string_t cmd_tunnel_filter_what = 8855 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_filter_result, 8856 what, "add#rm"); 8857 cmdline_parse_token_num_t cmd_tunnel_filter_port_id = 8858 TOKEN_NUM_INITIALIZER(struct cmd_tunnel_filter_result, 8859 port_id, UINT16); 8860 cmdline_parse_token_etheraddr_t cmd_tunnel_filter_outer_mac = 8861 TOKEN_ETHERADDR_INITIALIZER(struct cmd_tunnel_filter_result, 8862 outer_mac); 8863 cmdline_parse_token_etheraddr_t cmd_tunnel_filter_inner_mac = 8864 TOKEN_ETHERADDR_INITIALIZER(struct cmd_tunnel_filter_result, 8865 inner_mac); 8866 cmdline_parse_token_num_t cmd_tunnel_filter_innner_vlan = 8867 TOKEN_NUM_INITIALIZER(struct cmd_tunnel_filter_result, 8868 inner_vlan, UINT16); 8869 cmdline_parse_token_ipaddr_t cmd_tunnel_filter_ip_value = 8870 TOKEN_IPADDR_INITIALIZER(struct cmd_tunnel_filter_result, 8871 ip_value); 8872 cmdline_parse_token_string_t cmd_tunnel_filter_tunnel_type = 8873 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_filter_result, 8874 tunnel_type, "vxlan#nvgre#ipingre"); 8875 8876 cmdline_parse_token_string_t cmd_tunnel_filter_filter_type = 8877 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_filter_result, 8878 filter_type, "oip#iip#imac-ivlan#imac-ivlan-tenid#imac-tenid#" 8879 "imac#omac-imac-tenid"); 8880 cmdline_parse_token_num_t cmd_tunnel_filter_tenant_id = 8881 TOKEN_NUM_INITIALIZER(struct cmd_tunnel_filter_result, 8882 tenant_id, UINT32); 8883 cmdline_parse_token_num_t cmd_tunnel_filter_queue_num = 8884 TOKEN_NUM_INITIALIZER(struct cmd_tunnel_filter_result, 8885 queue_num, UINT16); 8886 8887 cmdline_parse_inst_t cmd_tunnel_filter = { 8888 .f = cmd_tunnel_filter_parsed, 8889 .data = (void *)0, 8890 .help_str = "tunnel_filter add|rm <port_id> <outer_mac> <inner_mac> " 8891 "<ip> <inner_vlan> vxlan|nvgre|ipingre oip|iip|imac-ivlan|" 8892 "imac-ivlan-tenid|imac-tenid|imac|omac-imac-tenid <tenant_id> " 8893 "<queue_id>: Add/Rm tunnel filter of a port", 8894 .tokens = { 8895 (void *)&cmd_tunnel_filter_cmd, 8896 (void *)&cmd_tunnel_filter_what, 8897 (void *)&cmd_tunnel_filter_port_id, 8898 (void *)&cmd_tunnel_filter_outer_mac, 8899 (void *)&cmd_tunnel_filter_inner_mac, 8900 (void *)&cmd_tunnel_filter_ip_value, 8901 (void *)&cmd_tunnel_filter_innner_vlan, 8902 (void *)&cmd_tunnel_filter_tunnel_type, 8903 (void *)&cmd_tunnel_filter_filter_type, 8904 (void *)&cmd_tunnel_filter_tenant_id, 8905 (void *)&cmd_tunnel_filter_queue_num, 8906 NULL, 8907 }, 8908 }; 8909 8910 /* *** CONFIGURE TUNNEL UDP PORT *** */ 8911 struct cmd_tunnel_udp_config { 8912 cmdline_fixed_string_t cmd; 8913 cmdline_fixed_string_t what; 8914 uint16_t udp_port; 8915 portid_t port_id; 8916 }; 8917 8918 static void 8919 cmd_tunnel_udp_config_parsed(void *parsed_result, 8920 __attribute__((unused)) struct cmdline *cl, 8921 __attribute__((unused)) void *data) 8922 { 8923 struct cmd_tunnel_udp_config *res = parsed_result; 8924 struct rte_eth_udp_tunnel tunnel_udp; 8925 int ret; 8926 8927 tunnel_udp.udp_port = res->udp_port; 8928 8929 if (!strcmp(res->cmd, "rx_vxlan_port")) 8930 tunnel_udp.prot_type = RTE_TUNNEL_TYPE_VXLAN; 8931 8932 if (!strcmp(res->what, "add")) 8933 ret = rte_eth_dev_udp_tunnel_port_add(res->port_id, 8934 &tunnel_udp); 8935 else 8936 ret = rte_eth_dev_udp_tunnel_port_delete(res->port_id, 8937 &tunnel_udp); 8938 8939 if (ret < 0) 8940 printf("udp tunneling add error: (%s)\n", strerror(-ret)); 8941 } 8942 8943 cmdline_parse_token_string_t cmd_tunnel_udp_config_cmd = 8944 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_udp_config, 8945 cmd, "rx_vxlan_port"); 8946 cmdline_parse_token_string_t cmd_tunnel_udp_config_what = 8947 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_udp_config, 8948 what, "add#rm"); 8949 cmdline_parse_token_num_t cmd_tunnel_udp_config_udp_port = 8950 TOKEN_NUM_INITIALIZER(struct cmd_tunnel_udp_config, 8951 udp_port, UINT16); 8952 cmdline_parse_token_num_t cmd_tunnel_udp_config_port_id = 8953 TOKEN_NUM_INITIALIZER(struct cmd_tunnel_udp_config, 8954 port_id, UINT16); 8955 8956 cmdline_parse_inst_t cmd_tunnel_udp_config = { 8957 .f = cmd_tunnel_udp_config_parsed, 8958 .data = (void *)0, 8959 .help_str = "rx_vxlan_port add|rm <udp_port> <port_id>: " 8960 "Add/Remove a tunneling UDP port filter", 8961 .tokens = { 8962 (void *)&cmd_tunnel_udp_config_cmd, 8963 (void *)&cmd_tunnel_udp_config_what, 8964 (void *)&cmd_tunnel_udp_config_udp_port, 8965 (void *)&cmd_tunnel_udp_config_port_id, 8966 NULL, 8967 }, 8968 }; 8969 8970 struct cmd_config_tunnel_udp_port { 8971 cmdline_fixed_string_t port; 8972 cmdline_fixed_string_t config; 8973 portid_t port_id; 8974 cmdline_fixed_string_t udp_tunnel_port; 8975 cmdline_fixed_string_t action; 8976 cmdline_fixed_string_t tunnel_type; 8977 uint16_t udp_port; 8978 }; 8979 8980 static void 8981 cmd_cfg_tunnel_udp_port_parsed(void *parsed_result, 8982 __attribute__((unused)) struct cmdline *cl, 8983 __attribute__((unused)) void *data) 8984 { 8985 struct cmd_config_tunnel_udp_port *res = parsed_result; 8986 struct rte_eth_udp_tunnel tunnel_udp; 8987 int ret = 0; 8988 8989 if (port_id_is_invalid(res->port_id, ENABLED_WARN)) 8990 return; 8991 8992 tunnel_udp.udp_port = res->udp_port; 8993 8994 if (!strcmp(res->tunnel_type, "vxlan")) { 8995 tunnel_udp.prot_type = RTE_TUNNEL_TYPE_VXLAN; 8996 } else if (!strcmp(res->tunnel_type, "geneve")) { 8997 tunnel_udp.prot_type = RTE_TUNNEL_TYPE_GENEVE; 8998 } else { 8999 printf("Invalid tunnel type\n"); 9000 return; 9001 } 9002 9003 if (!strcmp(res->action, "add")) 9004 ret = rte_eth_dev_udp_tunnel_port_add(res->port_id, 9005 &tunnel_udp); 9006 else 9007 ret = rte_eth_dev_udp_tunnel_port_delete(res->port_id, 9008 &tunnel_udp); 9009 9010 if (ret < 0) 9011 printf("udp tunneling port add error: (%s)\n", strerror(-ret)); 9012 } 9013 9014 cmdline_parse_token_string_t cmd_config_tunnel_udp_port_port = 9015 TOKEN_STRING_INITIALIZER(struct cmd_config_tunnel_udp_port, port, 9016 "port"); 9017 cmdline_parse_token_string_t cmd_config_tunnel_udp_port_config = 9018 TOKEN_STRING_INITIALIZER(struct cmd_config_tunnel_udp_port, config, 9019 "config"); 9020 cmdline_parse_token_num_t cmd_config_tunnel_udp_port_port_id = 9021 TOKEN_NUM_INITIALIZER(struct cmd_config_tunnel_udp_port, port_id, 9022 UINT16); 9023 cmdline_parse_token_string_t cmd_config_tunnel_udp_port_tunnel_port = 9024 TOKEN_STRING_INITIALIZER(struct cmd_config_tunnel_udp_port, 9025 udp_tunnel_port, 9026 "udp_tunnel_port"); 9027 cmdline_parse_token_string_t cmd_config_tunnel_udp_port_action = 9028 TOKEN_STRING_INITIALIZER(struct cmd_config_tunnel_udp_port, action, 9029 "add#rm"); 9030 cmdline_parse_token_string_t cmd_config_tunnel_udp_port_tunnel_type = 9031 TOKEN_STRING_INITIALIZER(struct cmd_config_tunnel_udp_port, tunnel_type, 9032 "vxlan#geneve"); 9033 cmdline_parse_token_num_t cmd_config_tunnel_udp_port_value = 9034 TOKEN_NUM_INITIALIZER(struct cmd_config_tunnel_udp_port, udp_port, 9035 UINT16); 9036 9037 cmdline_parse_inst_t cmd_cfg_tunnel_udp_port = { 9038 .f = cmd_cfg_tunnel_udp_port_parsed, 9039 .data = NULL, 9040 .help_str = "port config <port_id> udp_tunnel_port add|rm vxlan|geneve <udp_port>", 9041 .tokens = { 9042 (void *)&cmd_config_tunnel_udp_port_port, 9043 (void *)&cmd_config_tunnel_udp_port_config, 9044 (void *)&cmd_config_tunnel_udp_port_port_id, 9045 (void *)&cmd_config_tunnel_udp_port_tunnel_port, 9046 (void *)&cmd_config_tunnel_udp_port_action, 9047 (void *)&cmd_config_tunnel_udp_port_tunnel_type, 9048 (void *)&cmd_config_tunnel_udp_port_value, 9049 NULL, 9050 }, 9051 }; 9052 9053 /* *** GLOBAL CONFIG *** */ 9054 struct cmd_global_config_result { 9055 cmdline_fixed_string_t cmd; 9056 portid_t port_id; 9057 cmdline_fixed_string_t cfg_type; 9058 uint8_t len; 9059 }; 9060 9061 static void 9062 cmd_global_config_parsed(void *parsed_result, 9063 __attribute__((unused)) struct cmdline *cl, 9064 __attribute__((unused)) void *data) 9065 { 9066 struct cmd_global_config_result *res = parsed_result; 9067 struct rte_eth_global_cfg conf; 9068 int ret; 9069 9070 memset(&conf, 0, sizeof(conf)); 9071 conf.cfg_type = RTE_ETH_GLOBAL_CFG_TYPE_GRE_KEY_LEN; 9072 conf.cfg.gre_key_len = res->len; 9073 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_NONE, 9074 RTE_ETH_FILTER_SET, &conf); 9075 if (ret != 0) 9076 printf("Global config error\n"); 9077 } 9078 9079 cmdline_parse_token_string_t cmd_global_config_cmd = 9080 TOKEN_STRING_INITIALIZER(struct cmd_global_config_result, cmd, 9081 "global_config"); 9082 cmdline_parse_token_num_t cmd_global_config_port_id = 9083 TOKEN_NUM_INITIALIZER(struct cmd_global_config_result, port_id, 9084 UINT16); 9085 cmdline_parse_token_string_t cmd_global_config_type = 9086 TOKEN_STRING_INITIALIZER(struct cmd_global_config_result, 9087 cfg_type, "gre-key-len"); 9088 cmdline_parse_token_num_t cmd_global_config_gre_key_len = 9089 TOKEN_NUM_INITIALIZER(struct cmd_global_config_result, 9090 len, UINT8); 9091 9092 cmdline_parse_inst_t cmd_global_config = { 9093 .f = cmd_global_config_parsed, 9094 .data = (void *)NULL, 9095 .help_str = "global_config <port_id> gre-key-len <key_len>", 9096 .tokens = { 9097 (void *)&cmd_global_config_cmd, 9098 (void *)&cmd_global_config_port_id, 9099 (void *)&cmd_global_config_type, 9100 (void *)&cmd_global_config_gre_key_len, 9101 NULL, 9102 }, 9103 }; 9104 9105 /* *** CONFIGURE VM MIRROR VLAN/POOL RULE *** */ 9106 struct cmd_set_mirror_mask_result { 9107 cmdline_fixed_string_t set; 9108 cmdline_fixed_string_t port; 9109 portid_t port_id; 9110 cmdline_fixed_string_t mirror; 9111 uint8_t rule_id; 9112 cmdline_fixed_string_t what; 9113 cmdline_fixed_string_t value; 9114 cmdline_fixed_string_t dstpool; 9115 uint8_t dstpool_id; 9116 cmdline_fixed_string_t on; 9117 }; 9118 9119 cmdline_parse_token_string_t cmd_mirror_mask_set = 9120 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result, 9121 set, "set"); 9122 cmdline_parse_token_string_t cmd_mirror_mask_port = 9123 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result, 9124 port, "port"); 9125 cmdline_parse_token_num_t cmd_mirror_mask_portid = 9126 TOKEN_NUM_INITIALIZER(struct cmd_set_mirror_mask_result, 9127 port_id, UINT16); 9128 cmdline_parse_token_string_t cmd_mirror_mask_mirror = 9129 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result, 9130 mirror, "mirror-rule"); 9131 cmdline_parse_token_num_t cmd_mirror_mask_ruleid = 9132 TOKEN_NUM_INITIALIZER(struct cmd_set_mirror_mask_result, 9133 rule_id, UINT8); 9134 cmdline_parse_token_string_t cmd_mirror_mask_what = 9135 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result, 9136 what, "pool-mirror-up#pool-mirror-down" 9137 "#vlan-mirror"); 9138 cmdline_parse_token_string_t cmd_mirror_mask_value = 9139 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result, 9140 value, NULL); 9141 cmdline_parse_token_string_t cmd_mirror_mask_dstpool = 9142 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result, 9143 dstpool, "dst-pool"); 9144 cmdline_parse_token_num_t cmd_mirror_mask_poolid = 9145 TOKEN_NUM_INITIALIZER(struct cmd_set_mirror_mask_result, 9146 dstpool_id, UINT8); 9147 cmdline_parse_token_string_t cmd_mirror_mask_on = 9148 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result, 9149 on, "on#off"); 9150 9151 static void 9152 cmd_set_mirror_mask_parsed(void *parsed_result, 9153 __attribute__((unused)) struct cmdline *cl, 9154 __attribute__((unused)) void *data) 9155 { 9156 int ret,nb_item,i; 9157 struct cmd_set_mirror_mask_result *res = parsed_result; 9158 struct rte_eth_mirror_conf mr_conf; 9159 9160 memset(&mr_conf, 0, sizeof(struct rte_eth_mirror_conf)); 9161 9162 unsigned int vlan_list[ETH_MIRROR_MAX_VLANS]; 9163 9164 mr_conf.dst_pool = res->dstpool_id; 9165 9166 if (!strcmp(res->what, "pool-mirror-up")) { 9167 mr_conf.pool_mask = strtoull(res->value, NULL, 16); 9168 mr_conf.rule_type = ETH_MIRROR_VIRTUAL_POOL_UP; 9169 } else if (!strcmp(res->what, "pool-mirror-down")) { 9170 mr_conf.pool_mask = strtoull(res->value, NULL, 16); 9171 mr_conf.rule_type = ETH_MIRROR_VIRTUAL_POOL_DOWN; 9172 } else if (!strcmp(res->what, "vlan-mirror")) { 9173 mr_conf.rule_type = ETH_MIRROR_VLAN; 9174 nb_item = parse_item_list(res->value, "vlan", 9175 ETH_MIRROR_MAX_VLANS, vlan_list, 1); 9176 if (nb_item <= 0) 9177 return; 9178 9179 for (i = 0; i < nb_item; i++) { 9180 if (vlan_list[i] > ETHER_MAX_VLAN_ID) { 9181 printf("Invalid vlan_id: must be < 4096\n"); 9182 return; 9183 } 9184 9185 mr_conf.vlan.vlan_id[i] = (uint16_t)vlan_list[i]; 9186 mr_conf.vlan.vlan_mask |= 1ULL << i; 9187 } 9188 } 9189 9190 if (!strcmp(res->on, "on")) 9191 ret = rte_eth_mirror_rule_set(res->port_id, &mr_conf, 9192 res->rule_id, 1); 9193 else 9194 ret = rte_eth_mirror_rule_set(res->port_id, &mr_conf, 9195 res->rule_id, 0); 9196 if (ret < 0) 9197 printf("mirror rule add error: (%s)\n", strerror(-ret)); 9198 } 9199 9200 cmdline_parse_inst_t cmd_set_mirror_mask = { 9201 .f = cmd_set_mirror_mask_parsed, 9202 .data = NULL, 9203 .help_str = "set port <port_id> mirror-rule <rule_id> " 9204 "pool-mirror-up|pool-mirror-down|vlan-mirror " 9205 "<pool_mask|vlan_id[,vlan_id]*> dst-pool <pool_id> on|off", 9206 .tokens = { 9207 (void *)&cmd_mirror_mask_set, 9208 (void *)&cmd_mirror_mask_port, 9209 (void *)&cmd_mirror_mask_portid, 9210 (void *)&cmd_mirror_mask_mirror, 9211 (void *)&cmd_mirror_mask_ruleid, 9212 (void *)&cmd_mirror_mask_what, 9213 (void *)&cmd_mirror_mask_value, 9214 (void *)&cmd_mirror_mask_dstpool, 9215 (void *)&cmd_mirror_mask_poolid, 9216 (void *)&cmd_mirror_mask_on, 9217 NULL, 9218 }, 9219 }; 9220 9221 /* *** CONFIGURE VM MIRROR UPLINK/DOWNLINK RULE *** */ 9222 struct cmd_set_mirror_link_result { 9223 cmdline_fixed_string_t set; 9224 cmdline_fixed_string_t port; 9225 portid_t port_id; 9226 cmdline_fixed_string_t mirror; 9227 uint8_t rule_id; 9228 cmdline_fixed_string_t what; 9229 cmdline_fixed_string_t dstpool; 9230 uint8_t dstpool_id; 9231 cmdline_fixed_string_t on; 9232 }; 9233 9234 cmdline_parse_token_string_t cmd_mirror_link_set = 9235 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_link_result, 9236 set, "set"); 9237 cmdline_parse_token_string_t cmd_mirror_link_port = 9238 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_link_result, 9239 port, "port"); 9240 cmdline_parse_token_num_t cmd_mirror_link_portid = 9241 TOKEN_NUM_INITIALIZER(struct cmd_set_mirror_link_result, 9242 port_id, UINT16); 9243 cmdline_parse_token_string_t cmd_mirror_link_mirror = 9244 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_link_result, 9245 mirror, "mirror-rule"); 9246 cmdline_parse_token_num_t cmd_mirror_link_ruleid = 9247 TOKEN_NUM_INITIALIZER(struct cmd_set_mirror_link_result, 9248 rule_id, UINT8); 9249 cmdline_parse_token_string_t cmd_mirror_link_what = 9250 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_link_result, 9251 what, "uplink-mirror#downlink-mirror"); 9252 cmdline_parse_token_string_t cmd_mirror_link_dstpool = 9253 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_link_result, 9254 dstpool, "dst-pool"); 9255 cmdline_parse_token_num_t cmd_mirror_link_poolid = 9256 TOKEN_NUM_INITIALIZER(struct cmd_set_mirror_link_result, 9257 dstpool_id, UINT8); 9258 cmdline_parse_token_string_t cmd_mirror_link_on = 9259 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_link_result, 9260 on, "on#off"); 9261 9262 static void 9263 cmd_set_mirror_link_parsed(void *parsed_result, 9264 __attribute__((unused)) struct cmdline *cl, 9265 __attribute__((unused)) void *data) 9266 { 9267 int ret; 9268 struct cmd_set_mirror_link_result *res = parsed_result; 9269 struct rte_eth_mirror_conf mr_conf; 9270 9271 memset(&mr_conf, 0, sizeof(struct rte_eth_mirror_conf)); 9272 if (!strcmp(res->what, "uplink-mirror")) 9273 mr_conf.rule_type = ETH_MIRROR_UPLINK_PORT; 9274 else 9275 mr_conf.rule_type = ETH_MIRROR_DOWNLINK_PORT; 9276 9277 mr_conf.dst_pool = res->dstpool_id; 9278 9279 if (!strcmp(res->on, "on")) 9280 ret = rte_eth_mirror_rule_set(res->port_id, &mr_conf, 9281 res->rule_id, 1); 9282 else 9283 ret = rte_eth_mirror_rule_set(res->port_id, &mr_conf, 9284 res->rule_id, 0); 9285 9286 /* check the return value and print it if is < 0 */ 9287 if (ret < 0) 9288 printf("mirror rule add error: (%s)\n", strerror(-ret)); 9289 9290 } 9291 9292 cmdline_parse_inst_t cmd_set_mirror_link = { 9293 .f = cmd_set_mirror_link_parsed, 9294 .data = NULL, 9295 .help_str = "set port <port_id> mirror-rule <rule_id> " 9296 "uplink-mirror|downlink-mirror dst-pool <pool_id> on|off", 9297 .tokens = { 9298 (void *)&cmd_mirror_link_set, 9299 (void *)&cmd_mirror_link_port, 9300 (void *)&cmd_mirror_link_portid, 9301 (void *)&cmd_mirror_link_mirror, 9302 (void *)&cmd_mirror_link_ruleid, 9303 (void *)&cmd_mirror_link_what, 9304 (void *)&cmd_mirror_link_dstpool, 9305 (void *)&cmd_mirror_link_poolid, 9306 (void *)&cmd_mirror_link_on, 9307 NULL, 9308 }, 9309 }; 9310 9311 /* *** RESET VM MIRROR RULE *** */ 9312 struct cmd_rm_mirror_rule_result { 9313 cmdline_fixed_string_t reset; 9314 cmdline_fixed_string_t port; 9315 portid_t port_id; 9316 cmdline_fixed_string_t mirror; 9317 uint8_t rule_id; 9318 }; 9319 9320 cmdline_parse_token_string_t cmd_rm_mirror_rule_reset = 9321 TOKEN_STRING_INITIALIZER(struct cmd_rm_mirror_rule_result, 9322 reset, "reset"); 9323 cmdline_parse_token_string_t cmd_rm_mirror_rule_port = 9324 TOKEN_STRING_INITIALIZER(struct cmd_rm_mirror_rule_result, 9325 port, "port"); 9326 cmdline_parse_token_num_t cmd_rm_mirror_rule_portid = 9327 TOKEN_NUM_INITIALIZER(struct cmd_rm_mirror_rule_result, 9328 port_id, UINT16); 9329 cmdline_parse_token_string_t cmd_rm_mirror_rule_mirror = 9330 TOKEN_STRING_INITIALIZER(struct cmd_rm_mirror_rule_result, 9331 mirror, "mirror-rule"); 9332 cmdline_parse_token_num_t cmd_rm_mirror_rule_ruleid = 9333 TOKEN_NUM_INITIALIZER(struct cmd_rm_mirror_rule_result, 9334 rule_id, UINT8); 9335 9336 static void 9337 cmd_reset_mirror_rule_parsed(void *parsed_result, 9338 __attribute__((unused)) struct cmdline *cl, 9339 __attribute__((unused)) void *data) 9340 { 9341 int ret; 9342 struct cmd_set_mirror_link_result *res = parsed_result; 9343 /* check rule_id */ 9344 ret = rte_eth_mirror_rule_reset(res->port_id,res->rule_id); 9345 if(ret < 0) 9346 printf("mirror rule remove error: (%s)\n", strerror(-ret)); 9347 } 9348 9349 cmdline_parse_inst_t cmd_reset_mirror_rule = { 9350 .f = cmd_reset_mirror_rule_parsed, 9351 .data = NULL, 9352 .help_str = "reset port <port_id> mirror-rule <rule_id>", 9353 .tokens = { 9354 (void *)&cmd_rm_mirror_rule_reset, 9355 (void *)&cmd_rm_mirror_rule_port, 9356 (void *)&cmd_rm_mirror_rule_portid, 9357 (void *)&cmd_rm_mirror_rule_mirror, 9358 (void *)&cmd_rm_mirror_rule_ruleid, 9359 NULL, 9360 }, 9361 }; 9362 9363 /* ******************************************************************************** */ 9364 9365 struct cmd_dump_result { 9366 cmdline_fixed_string_t dump; 9367 }; 9368 9369 static void 9370 dump_struct_sizes(void) 9371 { 9372 #define DUMP_SIZE(t) printf("sizeof(" #t ") = %u\n", (unsigned)sizeof(t)); 9373 DUMP_SIZE(struct rte_mbuf); 9374 DUMP_SIZE(struct rte_mempool); 9375 DUMP_SIZE(struct rte_ring); 9376 #undef DUMP_SIZE 9377 } 9378 9379 static void cmd_dump_parsed(void *parsed_result, 9380 __attribute__((unused)) struct cmdline *cl, 9381 __attribute__((unused)) void *data) 9382 { 9383 struct cmd_dump_result *res = parsed_result; 9384 9385 if (!strcmp(res->dump, "dump_physmem")) 9386 rte_dump_physmem_layout(stdout); 9387 else if (!strcmp(res->dump, "dump_memzone")) 9388 rte_memzone_dump(stdout); 9389 else if (!strcmp(res->dump, "dump_struct_sizes")) 9390 dump_struct_sizes(); 9391 else if (!strcmp(res->dump, "dump_ring")) 9392 rte_ring_list_dump(stdout); 9393 else if (!strcmp(res->dump, "dump_mempool")) 9394 rte_mempool_list_dump(stdout); 9395 else if (!strcmp(res->dump, "dump_devargs")) 9396 rte_devargs_dump(stdout); 9397 else if (!strcmp(res->dump, "dump_log_types")) 9398 rte_log_dump(stdout); 9399 } 9400 9401 cmdline_parse_token_string_t cmd_dump_dump = 9402 TOKEN_STRING_INITIALIZER(struct cmd_dump_result, dump, 9403 "dump_physmem#" 9404 "dump_memzone#" 9405 "dump_struct_sizes#" 9406 "dump_ring#" 9407 "dump_mempool#" 9408 "dump_devargs#" 9409 "dump_log_types"); 9410 9411 cmdline_parse_inst_t cmd_dump = { 9412 .f = cmd_dump_parsed, /* function to call */ 9413 .data = NULL, /* 2nd arg of func */ 9414 .help_str = "Dump status", 9415 .tokens = { /* token list, NULL terminated */ 9416 (void *)&cmd_dump_dump, 9417 NULL, 9418 }, 9419 }; 9420 9421 /* ******************************************************************************** */ 9422 9423 struct cmd_dump_one_result { 9424 cmdline_fixed_string_t dump; 9425 cmdline_fixed_string_t name; 9426 }; 9427 9428 static void cmd_dump_one_parsed(void *parsed_result, struct cmdline *cl, 9429 __attribute__((unused)) void *data) 9430 { 9431 struct cmd_dump_one_result *res = parsed_result; 9432 9433 if (!strcmp(res->dump, "dump_ring")) { 9434 struct rte_ring *r; 9435 r = rte_ring_lookup(res->name); 9436 if (r == NULL) { 9437 cmdline_printf(cl, "Cannot find ring\n"); 9438 return; 9439 } 9440 rte_ring_dump(stdout, r); 9441 } else if (!strcmp(res->dump, "dump_mempool")) { 9442 struct rte_mempool *mp; 9443 mp = rte_mempool_lookup(res->name); 9444 if (mp == NULL) { 9445 cmdline_printf(cl, "Cannot find mempool\n"); 9446 return; 9447 } 9448 rte_mempool_dump(stdout, mp); 9449 } 9450 } 9451 9452 cmdline_parse_token_string_t cmd_dump_one_dump = 9453 TOKEN_STRING_INITIALIZER(struct cmd_dump_one_result, dump, 9454 "dump_ring#dump_mempool"); 9455 9456 cmdline_parse_token_string_t cmd_dump_one_name = 9457 TOKEN_STRING_INITIALIZER(struct cmd_dump_one_result, name, NULL); 9458 9459 cmdline_parse_inst_t cmd_dump_one = { 9460 .f = cmd_dump_one_parsed, /* function to call */ 9461 .data = NULL, /* 2nd arg of func */ 9462 .help_str = "dump_ring|dump_mempool <name>: Dump one ring/mempool", 9463 .tokens = { /* token list, NULL terminated */ 9464 (void *)&cmd_dump_one_dump, 9465 (void *)&cmd_dump_one_name, 9466 NULL, 9467 }, 9468 }; 9469 9470 /* *** Add/Del syn filter *** */ 9471 struct cmd_syn_filter_result { 9472 cmdline_fixed_string_t filter; 9473 portid_t port_id; 9474 cmdline_fixed_string_t ops; 9475 cmdline_fixed_string_t priority; 9476 cmdline_fixed_string_t high; 9477 cmdline_fixed_string_t queue; 9478 uint16_t queue_id; 9479 }; 9480 9481 static void 9482 cmd_syn_filter_parsed(void *parsed_result, 9483 __attribute__((unused)) struct cmdline *cl, 9484 __attribute__((unused)) void *data) 9485 { 9486 struct cmd_syn_filter_result *res = parsed_result; 9487 struct rte_eth_syn_filter syn_filter; 9488 int ret = 0; 9489 9490 ret = rte_eth_dev_filter_supported(res->port_id, 9491 RTE_ETH_FILTER_SYN); 9492 if (ret < 0) { 9493 printf("syn filter is not supported on port %u.\n", 9494 res->port_id); 9495 return; 9496 } 9497 9498 memset(&syn_filter, 0, sizeof(syn_filter)); 9499 9500 if (!strcmp(res->ops, "add")) { 9501 if (!strcmp(res->high, "high")) 9502 syn_filter.hig_pri = 1; 9503 else 9504 syn_filter.hig_pri = 0; 9505 9506 syn_filter.queue = res->queue_id; 9507 ret = rte_eth_dev_filter_ctrl(res->port_id, 9508 RTE_ETH_FILTER_SYN, 9509 RTE_ETH_FILTER_ADD, 9510 &syn_filter); 9511 } else 9512 ret = rte_eth_dev_filter_ctrl(res->port_id, 9513 RTE_ETH_FILTER_SYN, 9514 RTE_ETH_FILTER_DELETE, 9515 &syn_filter); 9516 9517 if (ret < 0) 9518 printf("syn filter programming error: (%s)\n", 9519 strerror(-ret)); 9520 } 9521 9522 cmdline_parse_token_string_t cmd_syn_filter_filter = 9523 TOKEN_STRING_INITIALIZER(struct cmd_syn_filter_result, 9524 filter, "syn_filter"); 9525 cmdline_parse_token_num_t cmd_syn_filter_port_id = 9526 TOKEN_NUM_INITIALIZER(struct cmd_syn_filter_result, 9527 port_id, UINT16); 9528 cmdline_parse_token_string_t cmd_syn_filter_ops = 9529 TOKEN_STRING_INITIALIZER(struct cmd_syn_filter_result, 9530 ops, "add#del"); 9531 cmdline_parse_token_string_t cmd_syn_filter_priority = 9532 TOKEN_STRING_INITIALIZER(struct cmd_syn_filter_result, 9533 priority, "priority"); 9534 cmdline_parse_token_string_t cmd_syn_filter_high = 9535 TOKEN_STRING_INITIALIZER(struct cmd_syn_filter_result, 9536 high, "high#low"); 9537 cmdline_parse_token_string_t cmd_syn_filter_queue = 9538 TOKEN_STRING_INITIALIZER(struct cmd_syn_filter_result, 9539 queue, "queue"); 9540 cmdline_parse_token_num_t cmd_syn_filter_queue_id = 9541 TOKEN_NUM_INITIALIZER(struct cmd_syn_filter_result, 9542 queue_id, UINT16); 9543 9544 cmdline_parse_inst_t cmd_syn_filter = { 9545 .f = cmd_syn_filter_parsed, 9546 .data = NULL, 9547 .help_str = "syn_filter <port_id> add|del priority high|low queue " 9548 "<queue_id>: Add/Delete syn filter", 9549 .tokens = { 9550 (void *)&cmd_syn_filter_filter, 9551 (void *)&cmd_syn_filter_port_id, 9552 (void *)&cmd_syn_filter_ops, 9553 (void *)&cmd_syn_filter_priority, 9554 (void *)&cmd_syn_filter_high, 9555 (void *)&cmd_syn_filter_queue, 9556 (void *)&cmd_syn_filter_queue_id, 9557 NULL, 9558 }, 9559 }; 9560 9561 /* *** queue region set *** */ 9562 struct cmd_queue_region_result { 9563 cmdline_fixed_string_t set; 9564 cmdline_fixed_string_t port; 9565 portid_t port_id; 9566 cmdline_fixed_string_t cmd; 9567 cmdline_fixed_string_t region; 9568 uint8_t region_id; 9569 cmdline_fixed_string_t queue_start_index; 9570 uint8_t queue_id; 9571 cmdline_fixed_string_t queue_num; 9572 uint8_t queue_num_value; 9573 }; 9574 9575 static void 9576 cmd_queue_region_parsed(void *parsed_result, 9577 __attribute__((unused)) struct cmdline *cl, 9578 __attribute__((unused)) void *data) 9579 { 9580 struct cmd_queue_region_result *res = parsed_result; 9581 int ret = -ENOTSUP; 9582 #ifdef RTE_LIBRTE_I40E_PMD 9583 struct rte_pmd_i40e_queue_region_conf region_conf; 9584 enum rte_pmd_i40e_queue_region_op op_type; 9585 #endif 9586 9587 if (port_id_is_invalid(res->port_id, ENABLED_WARN)) 9588 return; 9589 9590 #ifdef RTE_LIBRTE_I40E_PMD 9591 memset(®ion_conf, 0, sizeof(region_conf)); 9592 op_type = RTE_PMD_I40E_RSS_QUEUE_REGION_SET; 9593 region_conf.region_id = res->region_id; 9594 region_conf.queue_num = res->queue_num_value; 9595 region_conf.queue_start_index = res->queue_id; 9596 9597 ret = rte_pmd_i40e_rss_queue_region_conf(res->port_id, 9598 op_type, ®ion_conf); 9599 #endif 9600 9601 switch (ret) { 9602 case 0: 9603 break; 9604 case -ENOTSUP: 9605 printf("function not implemented or supported\n"); 9606 break; 9607 default: 9608 printf("queue region config error: (%s)\n", strerror(-ret)); 9609 } 9610 } 9611 9612 cmdline_parse_token_string_t cmd_queue_region_set = 9613 TOKEN_STRING_INITIALIZER(struct cmd_queue_region_result, 9614 set, "set"); 9615 cmdline_parse_token_string_t cmd_queue_region_port = 9616 TOKEN_STRING_INITIALIZER(struct cmd_queue_region_result, port, "port"); 9617 cmdline_parse_token_num_t cmd_queue_region_port_id = 9618 TOKEN_NUM_INITIALIZER(struct cmd_queue_region_result, 9619 port_id, UINT16); 9620 cmdline_parse_token_string_t cmd_queue_region_cmd = 9621 TOKEN_STRING_INITIALIZER(struct cmd_queue_region_result, 9622 cmd, "queue-region"); 9623 cmdline_parse_token_string_t cmd_queue_region_id = 9624 TOKEN_STRING_INITIALIZER(struct cmd_queue_region_result, 9625 region, "region_id"); 9626 cmdline_parse_token_num_t cmd_queue_region_index = 9627 TOKEN_NUM_INITIALIZER(struct cmd_queue_region_result, 9628 region_id, UINT8); 9629 cmdline_parse_token_string_t cmd_queue_region_queue_start_index = 9630 TOKEN_STRING_INITIALIZER(struct cmd_queue_region_result, 9631 queue_start_index, "queue_start_index"); 9632 cmdline_parse_token_num_t cmd_queue_region_queue_id = 9633 TOKEN_NUM_INITIALIZER(struct cmd_queue_region_result, 9634 queue_id, UINT8); 9635 cmdline_parse_token_string_t cmd_queue_region_queue_num = 9636 TOKEN_STRING_INITIALIZER(struct cmd_queue_region_result, 9637 queue_num, "queue_num"); 9638 cmdline_parse_token_num_t cmd_queue_region_queue_num_value = 9639 TOKEN_NUM_INITIALIZER(struct cmd_queue_region_result, 9640 queue_num_value, UINT8); 9641 9642 cmdline_parse_inst_t cmd_queue_region = { 9643 .f = cmd_queue_region_parsed, 9644 .data = NULL, 9645 .help_str = "set port <port_id> queue-region region_id <value> " 9646 "queue_start_index <value> queue_num <value>: Set a queue region", 9647 .tokens = { 9648 (void *)&cmd_queue_region_set, 9649 (void *)&cmd_queue_region_port, 9650 (void *)&cmd_queue_region_port_id, 9651 (void *)&cmd_queue_region_cmd, 9652 (void *)&cmd_queue_region_id, 9653 (void *)&cmd_queue_region_index, 9654 (void *)&cmd_queue_region_queue_start_index, 9655 (void *)&cmd_queue_region_queue_id, 9656 (void *)&cmd_queue_region_queue_num, 9657 (void *)&cmd_queue_region_queue_num_value, 9658 NULL, 9659 }, 9660 }; 9661 9662 /* *** queue region and flowtype set *** */ 9663 struct cmd_region_flowtype_result { 9664 cmdline_fixed_string_t set; 9665 cmdline_fixed_string_t port; 9666 portid_t port_id; 9667 cmdline_fixed_string_t cmd; 9668 cmdline_fixed_string_t region; 9669 uint8_t region_id; 9670 cmdline_fixed_string_t flowtype; 9671 uint8_t flowtype_id; 9672 }; 9673 9674 static void 9675 cmd_region_flowtype_parsed(void *parsed_result, 9676 __attribute__((unused)) struct cmdline *cl, 9677 __attribute__((unused)) void *data) 9678 { 9679 struct cmd_region_flowtype_result *res = parsed_result; 9680 int ret = -ENOTSUP; 9681 #ifdef RTE_LIBRTE_I40E_PMD 9682 struct rte_pmd_i40e_queue_region_conf region_conf; 9683 enum rte_pmd_i40e_queue_region_op op_type; 9684 #endif 9685 9686 if (port_id_is_invalid(res->port_id, ENABLED_WARN)) 9687 return; 9688 9689 #ifdef RTE_LIBRTE_I40E_PMD 9690 memset(®ion_conf, 0, sizeof(region_conf)); 9691 9692 op_type = RTE_PMD_I40E_RSS_QUEUE_REGION_FLOWTYPE_SET; 9693 region_conf.region_id = res->region_id; 9694 region_conf.hw_flowtype = res->flowtype_id; 9695 9696 ret = rte_pmd_i40e_rss_queue_region_conf(res->port_id, 9697 op_type, ®ion_conf); 9698 #endif 9699 9700 switch (ret) { 9701 case 0: 9702 break; 9703 case -ENOTSUP: 9704 printf("function not implemented or supported\n"); 9705 break; 9706 default: 9707 printf("region flowtype config error: (%s)\n", strerror(-ret)); 9708 } 9709 } 9710 9711 cmdline_parse_token_string_t cmd_region_flowtype_set = 9712 TOKEN_STRING_INITIALIZER(struct cmd_region_flowtype_result, 9713 set, "set"); 9714 cmdline_parse_token_string_t cmd_region_flowtype_port = 9715 TOKEN_STRING_INITIALIZER(struct cmd_region_flowtype_result, 9716 port, "port"); 9717 cmdline_parse_token_num_t cmd_region_flowtype_port_index = 9718 TOKEN_NUM_INITIALIZER(struct cmd_region_flowtype_result, 9719 port_id, UINT16); 9720 cmdline_parse_token_string_t cmd_region_flowtype_cmd = 9721 TOKEN_STRING_INITIALIZER(struct cmd_region_flowtype_result, 9722 cmd, "queue-region"); 9723 cmdline_parse_token_string_t cmd_region_flowtype_index = 9724 TOKEN_STRING_INITIALIZER(struct cmd_region_flowtype_result, 9725 region, "region_id"); 9726 cmdline_parse_token_num_t cmd_region_flowtype_id = 9727 TOKEN_NUM_INITIALIZER(struct cmd_region_flowtype_result, 9728 region_id, UINT8); 9729 cmdline_parse_token_string_t cmd_region_flowtype_flow_index = 9730 TOKEN_STRING_INITIALIZER(struct cmd_region_flowtype_result, 9731 flowtype, "flowtype"); 9732 cmdline_parse_token_num_t cmd_region_flowtype_flow_id = 9733 TOKEN_NUM_INITIALIZER(struct cmd_region_flowtype_result, 9734 flowtype_id, UINT8); 9735 cmdline_parse_inst_t cmd_region_flowtype = { 9736 .f = cmd_region_flowtype_parsed, 9737 .data = NULL, 9738 .help_str = "set port <port_id> queue-region region_id <value> " 9739 "flowtype <value>: Set a flowtype region index", 9740 .tokens = { 9741 (void *)&cmd_region_flowtype_set, 9742 (void *)&cmd_region_flowtype_port, 9743 (void *)&cmd_region_flowtype_port_index, 9744 (void *)&cmd_region_flowtype_cmd, 9745 (void *)&cmd_region_flowtype_index, 9746 (void *)&cmd_region_flowtype_id, 9747 (void *)&cmd_region_flowtype_flow_index, 9748 (void *)&cmd_region_flowtype_flow_id, 9749 NULL, 9750 }, 9751 }; 9752 9753 /* *** User Priority (UP) to queue region (region_id) set *** */ 9754 struct cmd_user_priority_region_result { 9755 cmdline_fixed_string_t set; 9756 cmdline_fixed_string_t port; 9757 portid_t port_id; 9758 cmdline_fixed_string_t cmd; 9759 cmdline_fixed_string_t user_priority; 9760 uint8_t user_priority_id; 9761 cmdline_fixed_string_t region; 9762 uint8_t region_id; 9763 }; 9764 9765 static void 9766 cmd_user_priority_region_parsed(void *parsed_result, 9767 __attribute__((unused)) struct cmdline *cl, 9768 __attribute__((unused)) void *data) 9769 { 9770 struct cmd_user_priority_region_result *res = parsed_result; 9771 int ret = -ENOTSUP; 9772 #ifdef RTE_LIBRTE_I40E_PMD 9773 struct rte_pmd_i40e_queue_region_conf region_conf; 9774 enum rte_pmd_i40e_queue_region_op op_type; 9775 #endif 9776 9777 if (port_id_is_invalid(res->port_id, ENABLED_WARN)) 9778 return; 9779 9780 #ifdef RTE_LIBRTE_I40E_PMD 9781 memset(®ion_conf, 0, sizeof(region_conf)); 9782 op_type = RTE_PMD_I40E_RSS_QUEUE_REGION_USER_PRIORITY_SET; 9783 region_conf.user_priority = res->user_priority_id; 9784 region_conf.region_id = res->region_id; 9785 9786 ret = rte_pmd_i40e_rss_queue_region_conf(res->port_id, 9787 op_type, ®ion_conf); 9788 #endif 9789 9790 switch (ret) { 9791 case 0: 9792 break; 9793 case -ENOTSUP: 9794 printf("function not implemented or supported\n"); 9795 break; 9796 default: 9797 printf("user_priority region config error: (%s)\n", 9798 strerror(-ret)); 9799 } 9800 } 9801 9802 cmdline_parse_token_string_t cmd_user_priority_region_set = 9803 TOKEN_STRING_INITIALIZER(struct cmd_user_priority_region_result, 9804 set, "set"); 9805 cmdline_parse_token_string_t cmd_user_priority_region_port = 9806 TOKEN_STRING_INITIALIZER(struct cmd_user_priority_region_result, 9807 port, "port"); 9808 cmdline_parse_token_num_t cmd_user_priority_region_port_index = 9809 TOKEN_NUM_INITIALIZER(struct cmd_user_priority_region_result, 9810 port_id, UINT16); 9811 cmdline_parse_token_string_t cmd_user_priority_region_cmd = 9812 TOKEN_STRING_INITIALIZER(struct cmd_user_priority_region_result, 9813 cmd, "queue-region"); 9814 cmdline_parse_token_string_t cmd_user_priority_region_UP = 9815 TOKEN_STRING_INITIALIZER(struct cmd_user_priority_region_result, 9816 user_priority, "UP"); 9817 cmdline_parse_token_num_t cmd_user_priority_region_UP_id = 9818 TOKEN_NUM_INITIALIZER(struct cmd_user_priority_region_result, 9819 user_priority_id, UINT8); 9820 cmdline_parse_token_string_t cmd_user_priority_region_region = 9821 TOKEN_STRING_INITIALIZER(struct cmd_user_priority_region_result, 9822 region, "region_id"); 9823 cmdline_parse_token_num_t cmd_user_priority_region_region_id = 9824 TOKEN_NUM_INITIALIZER(struct cmd_user_priority_region_result, 9825 region_id, UINT8); 9826 9827 cmdline_parse_inst_t cmd_user_priority_region = { 9828 .f = cmd_user_priority_region_parsed, 9829 .data = NULL, 9830 .help_str = "set port <port_id> queue-region UP <value> " 9831 "region_id <value>: Set the mapping of User Priority (UP) " 9832 "to queue region (region_id) ", 9833 .tokens = { 9834 (void *)&cmd_user_priority_region_set, 9835 (void *)&cmd_user_priority_region_port, 9836 (void *)&cmd_user_priority_region_port_index, 9837 (void *)&cmd_user_priority_region_cmd, 9838 (void *)&cmd_user_priority_region_UP, 9839 (void *)&cmd_user_priority_region_UP_id, 9840 (void *)&cmd_user_priority_region_region, 9841 (void *)&cmd_user_priority_region_region_id, 9842 NULL, 9843 }, 9844 }; 9845 9846 /* *** flush all queue region related configuration *** */ 9847 struct cmd_flush_queue_region_result { 9848 cmdline_fixed_string_t set; 9849 cmdline_fixed_string_t port; 9850 portid_t port_id; 9851 cmdline_fixed_string_t cmd; 9852 cmdline_fixed_string_t flush; 9853 cmdline_fixed_string_t what; 9854 }; 9855 9856 static void 9857 cmd_flush_queue_region_parsed(void *parsed_result, 9858 __attribute__((unused)) struct cmdline *cl, 9859 __attribute__((unused)) void *data) 9860 { 9861 struct cmd_flush_queue_region_result *res = parsed_result; 9862 int ret = -ENOTSUP; 9863 #ifdef RTE_LIBRTE_I40E_PMD 9864 struct rte_pmd_i40e_queue_region_conf region_conf; 9865 enum rte_pmd_i40e_queue_region_op op_type; 9866 #endif 9867 9868 if (port_id_is_invalid(res->port_id, ENABLED_WARN)) 9869 return; 9870 9871 #ifdef RTE_LIBRTE_I40E_PMD 9872 memset(®ion_conf, 0, sizeof(region_conf)); 9873 9874 if (strcmp(res->what, "on") == 0) 9875 op_type = RTE_PMD_I40E_RSS_QUEUE_REGION_ALL_FLUSH_ON; 9876 else 9877 op_type = RTE_PMD_I40E_RSS_QUEUE_REGION_ALL_FLUSH_OFF; 9878 9879 ret = rte_pmd_i40e_rss_queue_region_conf(res->port_id, 9880 op_type, ®ion_conf); 9881 #endif 9882 9883 switch (ret) { 9884 case 0: 9885 break; 9886 case -ENOTSUP: 9887 printf("function not implemented or supported\n"); 9888 break; 9889 default: 9890 printf("queue region config flush error: (%s)\n", 9891 strerror(-ret)); 9892 } 9893 } 9894 9895 cmdline_parse_token_string_t cmd_flush_queue_region_set = 9896 TOKEN_STRING_INITIALIZER(struct cmd_flush_queue_region_result, 9897 set, "set"); 9898 cmdline_parse_token_string_t cmd_flush_queue_region_port = 9899 TOKEN_STRING_INITIALIZER(struct cmd_flush_queue_region_result, 9900 port, "port"); 9901 cmdline_parse_token_num_t cmd_flush_queue_region_port_index = 9902 TOKEN_NUM_INITIALIZER(struct cmd_flush_queue_region_result, 9903 port_id, UINT16); 9904 cmdline_parse_token_string_t cmd_flush_queue_region_cmd = 9905 TOKEN_STRING_INITIALIZER(struct cmd_flush_queue_region_result, 9906 cmd, "queue-region"); 9907 cmdline_parse_token_string_t cmd_flush_queue_region_flush = 9908 TOKEN_STRING_INITIALIZER(struct cmd_flush_queue_region_result, 9909 flush, "flush"); 9910 cmdline_parse_token_string_t cmd_flush_queue_region_what = 9911 TOKEN_STRING_INITIALIZER(struct cmd_flush_queue_region_result, 9912 what, "on#off"); 9913 9914 cmdline_parse_inst_t cmd_flush_queue_region = { 9915 .f = cmd_flush_queue_region_parsed, 9916 .data = NULL, 9917 .help_str = "set port <port_id> queue-region flush on|off" 9918 ": flush all queue region related configuration", 9919 .tokens = { 9920 (void *)&cmd_flush_queue_region_set, 9921 (void *)&cmd_flush_queue_region_port, 9922 (void *)&cmd_flush_queue_region_port_index, 9923 (void *)&cmd_flush_queue_region_cmd, 9924 (void *)&cmd_flush_queue_region_flush, 9925 (void *)&cmd_flush_queue_region_what, 9926 NULL, 9927 }, 9928 }; 9929 9930 /* *** get all queue region related configuration info *** */ 9931 struct cmd_show_queue_region_info { 9932 cmdline_fixed_string_t show; 9933 cmdline_fixed_string_t port; 9934 portid_t port_id; 9935 cmdline_fixed_string_t cmd; 9936 }; 9937 9938 static void 9939 cmd_show_queue_region_info_parsed(void *parsed_result, 9940 __attribute__((unused)) struct cmdline *cl, 9941 __attribute__((unused)) void *data) 9942 { 9943 struct cmd_show_queue_region_info *res = parsed_result; 9944 int ret = -ENOTSUP; 9945 #ifdef RTE_LIBRTE_I40E_PMD 9946 struct rte_pmd_i40e_queue_regions rte_pmd_regions; 9947 enum rte_pmd_i40e_queue_region_op op_type; 9948 #endif 9949 9950 if (port_id_is_invalid(res->port_id, ENABLED_WARN)) 9951 return; 9952 9953 #ifdef RTE_LIBRTE_I40E_PMD 9954 memset(&rte_pmd_regions, 0, sizeof(rte_pmd_regions)); 9955 9956 op_type = RTE_PMD_I40E_RSS_QUEUE_REGION_INFO_GET; 9957 9958 ret = rte_pmd_i40e_rss_queue_region_conf(res->port_id, 9959 op_type, &rte_pmd_regions); 9960 9961 port_queue_region_info_display(res->port_id, &rte_pmd_regions); 9962 #endif 9963 9964 switch (ret) { 9965 case 0: 9966 break; 9967 case -ENOTSUP: 9968 printf("function not implemented or supported\n"); 9969 break; 9970 default: 9971 printf("queue region config info show error: (%s)\n", 9972 strerror(-ret)); 9973 } 9974 } 9975 9976 cmdline_parse_token_string_t cmd_show_queue_region_info_get = 9977 TOKEN_STRING_INITIALIZER(struct cmd_show_queue_region_info, 9978 show, "show"); 9979 cmdline_parse_token_string_t cmd_show_queue_region_info_port = 9980 TOKEN_STRING_INITIALIZER(struct cmd_show_queue_region_info, 9981 port, "port"); 9982 cmdline_parse_token_num_t cmd_show_queue_region_info_port_index = 9983 TOKEN_NUM_INITIALIZER(struct cmd_show_queue_region_info, 9984 port_id, UINT16); 9985 cmdline_parse_token_string_t cmd_show_queue_region_info_cmd = 9986 TOKEN_STRING_INITIALIZER(struct cmd_show_queue_region_info, 9987 cmd, "queue-region"); 9988 9989 cmdline_parse_inst_t cmd_show_queue_region_info_all = { 9990 .f = cmd_show_queue_region_info_parsed, 9991 .data = NULL, 9992 .help_str = "show port <port_id> queue-region" 9993 ": show all queue region related configuration info", 9994 .tokens = { 9995 (void *)&cmd_show_queue_region_info_get, 9996 (void *)&cmd_show_queue_region_info_port, 9997 (void *)&cmd_show_queue_region_info_port_index, 9998 (void *)&cmd_show_queue_region_info_cmd, 9999 NULL, 10000 }, 10001 }; 10002 10003 /* *** ADD/REMOVE A 2tuple FILTER *** */ 10004 struct cmd_2tuple_filter_result { 10005 cmdline_fixed_string_t filter; 10006 portid_t port_id; 10007 cmdline_fixed_string_t ops; 10008 cmdline_fixed_string_t dst_port; 10009 uint16_t dst_port_value; 10010 cmdline_fixed_string_t protocol; 10011 uint8_t protocol_value; 10012 cmdline_fixed_string_t mask; 10013 uint8_t mask_value; 10014 cmdline_fixed_string_t tcp_flags; 10015 uint8_t tcp_flags_value; 10016 cmdline_fixed_string_t priority; 10017 uint8_t priority_value; 10018 cmdline_fixed_string_t queue; 10019 uint16_t queue_id; 10020 }; 10021 10022 static void 10023 cmd_2tuple_filter_parsed(void *parsed_result, 10024 __attribute__((unused)) struct cmdline *cl, 10025 __attribute__((unused)) void *data) 10026 { 10027 struct rte_eth_ntuple_filter filter; 10028 struct cmd_2tuple_filter_result *res = parsed_result; 10029 int ret = 0; 10030 10031 ret = rte_eth_dev_filter_supported(res->port_id, RTE_ETH_FILTER_NTUPLE); 10032 if (ret < 0) { 10033 printf("ntuple filter is not supported on port %u.\n", 10034 res->port_id); 10035 return; 10036 } 10037 10038 memset(&filter, 0, sizeof(struct rte_eth_ntuple_filter)); 10039 10040 filter.flags = RTE_2TUPLE_FLAGS; 10041 filter.dst_port_mask = (res->mask_value & 0x02) ? UINT16_MAX : 0; 10042 filter.proto_mask = (res->mask_value & 0x01) ? UINT8_MAX : 0; 10043 filter.proto = res->protocol_value; 10044 filter.priority = res->priority_value; 10045 if (res->tcp_flags_value != 0 && filter.proto != IPPROTO_TCP) { 10046 printf("nonzero tcp_flags is only meaningful" 10047 " when protocol is TCP.\n"); 10048 return; 10049 } 10050 if (res->tcp_flags_value > TCP_FLAG_ALL) { 10051 printf("invalid TCP flags.\n"); 10052 return; 10053 } 10054 10055 if (res->tcp_flags_value != 0) { 10056 filter.flags |= RTE_NTUPLE_FLAGS_TCP_FLAG; 10057 filter.tcp_flags = res->tcp_flags_value; 10058 } 10059 10060 /* need convert to big endian. */ 10061 filter.dst_port = rte_cpu_to_be_16(res->dst_port_value); 10062 filter.queue = res->queue_id; 10063 10064 if (!strcmp(res->ops, "add")) 10065 ret = rte_eth_dev_filter_ctrl(res->port_id, 10066 RTE_ETH_FILTER_NTUPLE, 10067 RTE_ETH_FILTER_ADD, 10068 &filter); 10069 else 10070 ret = rte_eth_dev_filter_ctrl(res->port_id, 10071 RTE_ETH_FILTER_NTUPLE, 10072 RTE_ETH_FILTER_DELETE, 10073 &filter); 10074 if (ret < 0) 10075 printf("2tuple filter programming error: (%s)\n", 10076 strerror(-ret)); 10077 10078 } 10079 10080 cmdline_parse_token_string_t cmd_2tuple_filter_filter = 10081 TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result, 10082 filter, "2tuple_filter"); 10083 cmdline_parse_token_num_t cmd_2tuple_filter_port_id = 10084 TOKEN_NUM_INITIALIZER(struct cmd_2tuple_filter_result, 10085 port_id, UINT16); 10086 cmdline_parse_token_string_t cmd_2tuple_filter_ops = 10087 TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result, 10088 ops, "add#del"); 10089 cmdline_parse_token_string_t cmd_2tuple_filter_dst_port = 10090 TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result, 10091 dst_port, "dst_port"); 10092 cmdline_parse_token_num_t cmd_2tuple_filter_dst_port_value = 10093 TOKEN_NUM_INITIALIZER(struct cmd_2tuple_filter_result, 10094 dst_port_value, UINT16); 10095 cmdline_parse_token_string_t cmd_2tuple_filter_protocol = 10096 TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result, 10097 protocol, "protocol"); 10098 cmdline_parse_token_num_t cmd_2tuple_filter_protocol_value = 10099 TOKEN_NUM_INITIALIZER(struct cmd_2tuple_filter_result, 10100 protocol_value, UINT8); 10101 cmdline_parse_token_string_t cmd_2tuple_filter_mask = 10102 TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result, 10103 mask, "mask"); 10104 cmdline_parse_token_num_t cmd_2tuple_filter_mask_value = 10105 TOKEN_NUM_INITIALIZER(struct cmd_2tuple_filter_result, 10106 mask_value, INT8); 10107 cmdline_parse_token_string_t cmd_2tuple_filter_tcp_flags = 10108 TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result, 10109 tcp_flags, "tcp_flags"); 10110 cmdline_parse_token_num_t cmd_2tuple_filter_tcp_flags_value = 10111 TOKEN_NUM_INITIALIZER(struct cmd_2tuple_filter_result, 10112 tcp_flags_value, UINT8); 10113 cmdline_parse_token_string_t cmd_2tuple_filter_priority = 10114 TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result, 10115 priority, "priority"); 10116 cmdline_parse_token_num_t cmd_2tuple_filter_priority_value = 10117 TOKEN_NUM_INITIALIZER(struct cmd_2tuple_filter_result, 10118 priority_value, UINT8); 10119 cmdline_parse_token_string_t cmd_2tuple_filter_queue = 10120 TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result, 10121 queue, "queue"); 10122 cmdline_parse_token_num_t cmd_2tuple_filter_queue_id = 10123 TOKEN_NUM_INITIALIZER(struct cmd_2tuple_filter_result, 10124 queue_id, UINT16); 10125 10126 cmdline_parse_inst_t cmd_2tuple_filter = { 10127 .f = cmd_2tuple_filter_parsed, 10128 .data = NULL, 10129 .help_str = "2tuple_filter <port_id> add|del dst_port <value> protocol " 10130 "<value> mask <value> tcp_flags <value> priority <value> queue " 10131 "<queue_id>: Add a 2tuple filter", 10132 .tokens = { 10133 (void *)&cmd_2tuple_filter_filter, 10134 (void *)&cmd_2tuple_filter_port_id, 10135 (void *)&cmd_2tuple_filter_ops, 10136 (void *)&cmd_2tuple_filter_dst_port, 10137 (void *)&cmd_2tuple_filter_dst_port_value, 10138 (void *)&cmd_2tuple_filter_protocol, 10139 (void *)&cmd_2tuple_filter_protocol_value, 10140 (void *)&cmd_2tuple_filter_mask, 10141 (void *)&cmd_2tuple_filter_mask_value, 10142 (void *)&cmd_2tuple_filter_tcp_flags, 10143 (void *)&cmd_2tuple_filter_tcp_flags_value, 10144 (void *)&cmd_2tuple_filter_priority, 10145 (void *)&cmd_2tuple_filter_priority_value, 10146 (void *)&cmd_2tuple_filter_queue, 10147 (void *)&cmd_2tuple_filter_queue_id, 10148 NULL, 10149 }, 10150 }; 10151 10152 /* *** ADD/REMOVE A 5tuple FILTER *** */ 10153 struct cmd_5tuple_filter_result { 10154 cmdline_fixed_string_t filter; 10155 portid_t port_id; 10156 cmdline_fixed_string_t ops; 10157 cmdline_fixed_string_t dst_ip; 10158 cmdline_ipaddr_t dst_ip_value; 10159 cmdline_fixed_string_t src_ip; 10160 cmdline_ipaddr_t src_ip_value; 10161 cmdline_fixed_string_t dst_port; 10162 uint16_t dst_port_value; 10163 cmdline_fixed_string_t src_port; 10164 uint16_t src_port_value; 10165 cmdline_fixed_string_t protocol; 10166 uint8_t protocol_value; 10167 cmdline_fixed_string_t mask; 10168 uint8_t mask_value; 10169 cmdline_fixed_string_t tcp_flags; 10170 uint8_t tcp_flags_value; 10171 cmdline_fixed_string_t priority; 10172 uint8_t priority_value; 10173 cmdline_fixed_string_t queue; 10174 uint16_t queue_id; 10175 }; 10176 10177 static void 10178 cmd_5tuple_filter_parsed(void *parsed_result, 10179 __attribute__((unused)) struct cmdline *cl, 10180 __attribute__((unused)) void *data) 10181 { 10182 struct rte_eth_ntuple_filter filter; 10183 struct cmd_5tuple_filter_result *res = parsed_result; 10184 int ret = 0; 10185 10186 ret = rte_eth_dev_filter_supported(res->port_id, RTE_ETH_FILTER_NTUPLE); 10187 if (ret < 0) { 10188 printf("ntuple filter is not supported on port %u.\n", 10189 res->port_id); 10190 return; 10191 } 10192 10193 memset(&filter, 0, sizeof(struct rte_eth_ntuple_filter)); 10194 10195 filter.flags = RTE_5TUPLE_FLAGS; 10196 filter.dst_ip_mask = (res->mask_value & 0x10) ? UINT32_MAX : 0; 10197 filter.src_ip_mask = (res->mask_value & 0x08) ? UINT32_MAX : 0; 10198 filter.dst_port_mask = (res->mask_value & 0x04) ? UINT16_MAX : 0; 10199 filter.src_port_mask = (res->mask_value & 0x02) ? UINT16_MAX : 0; 10200 filter.proto_mask = (res->mask_value & 0x01) ? UINT8_MAX : 0; 10201 filter.proto = res->protocol_value; 10202 filter.priority = res->priority_value; 10203 if (res->tcp_flags_value != 0 && filter.proto != IPPROTO_TCP) { 10204 printf("nonzero tcp_flags is only meaningful" 10205 " when protocol is TCP.\n"); 10206 return; 10207 } 10208 if (res->tcp_flags_value > TCP_FLAG_ALL) { 10209 printf("invalid TCP flags.\n"); 10210 return; 10211 } 10212 10213 if (res->tcp_flags_value != 0) { 10214 filter.flags |= RTE_NTUPLE_FLAGS_TCP_FLAG; 10215 filter.tcp_flags = res->tcp_flags_value; 10216 } 10217 10218 if (res->dst_ip_value.family == AF_INET) 10219 /* no need to convert, already big endian. */ 10220 filter.dst_ip = res->dst_ip_value.addr.ipv4.s_addr; 10221 else { 10222 if (filter.dst_ip_mask == 0) { 10223 printf("can not support ipv6 involved compare.\n"); 10224 return; 10225 } 10226 filter.dst_ip = 0; 10227 } 10228 10229 if (res->src_ip_value.family == AF_INET) 10230 /* no need to convert, already big endian. */ 10231 filter.src_ip = res->src_ip_value.addr.ipv4.s_addr; 10232 else { 10233 if (filter.src_ip_mask == 0) { 10234 printf("can not support ipv6 involved compare.\n"); 10235 return; 10236 } 10237 filter.src_ip = 0; 10238 } 10239 /* need convert to big endian. */ 10240 filter.dst_port = rte_cpu_to_be_16(res->dst_port_value); 10241 filter.src_port = rte_cpu_to_be_16(res->src_port_value); 10242 filter.queue = res->queue_id; 10243 10244 if (!strcmp(res->ops, "add")) 10245 ret = rte_eth_dev_filter_ctrl(res->port_id, 10246 RTE_ETH_FILTER_NTUPLE, 10247 RTE_ETH_FILTER_ADD, 10248 &filter); 10249 else 10250 ret = rte_eth_dev_filter_ctrl(res->port_id, 10251 RTE_ETH_FILTER_NTUPLE, 10252 RTE_ETH_FILTER_DELETE, 10253 &filter); 10254 if (ret < 0) 10255 printf("5tuple filter programming error: (%s)\n", 10256 strerror(-ret)); 10257 } 10258 10259 cmdline_parse_token_string_t cmd_5tuple_filter_filter = 10260 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result, 10261 filter, "5tuple_filter"); 10262 cmdline_parse_token_num_t cmd_5tuple_filter_port_id = 10263 TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result, 10264 port_id, UINT16); 10265 cmdline_parse_token_string_t cmd_5tuple_filter_ops = 10266 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result, 10267 ops, "add#del"); 10268 cmdline_parse_token_string_t cmd_5tuple_filter_dst_ip = 10269 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result, 10270 dst_ip, "dst_ip"); 10271 cmdline_parse_token_ipaddr_t cmd_5tuple_filter_dst_ip_value = 10272 TOKEN_IPADDR_INITIALIZER(struct cmd_5tuple_filter_result, 10273 dst_ip_value); 10274 cmdline_parse_token_string_t cmd_5tuple_filter_src_ip = 10275 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result, 10276 src_ip, "src_ip"); 10277 cmdline_parse_token_ipaddr_t cmd_5tuple_filter_src_ip_value = 10278 TOKEN_IPADDR_INITIALIZER(struct cmd_5tuple_filter_result, 10279 src_ip_value); 10280 cmdline_parse_token_string_t cmd_5tuple_filter_dst_port = 10281 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result, 10282 dst_port, "dst_port"); 10283 cmdline_parse_token_num_t cmd_5tuple_filter_dst_port_value = 10284 TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result, 10285 dst_port_value, UINT16); 10286 cmdline_parse_token_string_t cmd_5tuple_filter_src_port = 10287 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result, 10288 src_port, "src_port"); 10289 cmdline_parse_token_num_t cmd_5tuple_filter_src_port_value = 10290 TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result, 10291 src_port_value, UINT16); 10292 cmdline_parse_token_string_t cmd_5tuple_filter_protocol = 10293 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result, 10294 protocol, "protocol"); 10295 cmdline_parse_token_num_t cmd_5tuple_filter_protocol_value = 10296 TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result, 10297 protocol_value, UINT8); 10298 cmdline_parse_token_string_t cmd_5tuple_filter_mask = 10299 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result, 10300 mask, "mask"); 10301 cmdline_parse_token_num_t cmd_5tuple_filter_mask_value = 10302 TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result, 10303 mask_value, INT8); 10304 cmdline_parse_token_string_t cmd_5tuple_filter_tcp_flags = 10305 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result, 10306 tcp_flags, "tcp_flags"); 10307 cmdline_parse_token_num_t cmd_5tuple_filter_tcp_flags_value = 10308 TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result, 10309 tcp_flags_value, UINT8); 10310 cmdline_parse_token_string_t cmd_5tuple_filter_priority = 10311 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result, 10312 priority, "priority"); 10313 cmdline_parse_token_num_t cmd_5tuple_filter_priority_value = 10314 TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result, 10315 priority_value, UINT8); 10316 cmdline_parse_token_string_t cmd_5tuple_filter_queue = 10317 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result, 10318 queue, "queue"); 10319 cmdline_parse_token_num_t cmd_5tuple_filter_queue_id = 10320 TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result, 10321 queue_id, UINT16); 10322 10323 cmdline_parse_inst_t cmd_5tuple_filter = { 10324 .f = cmd_5tuple_filter_parsed, 10325 .data = NULL, 10326 .help_str = "5tuple_filter <port_id> add|del dst_ip <value> " 10327 "src_ip <value> dst_port <value> src_port <value> " 10328 "protocol <value> mask <value> tcp_flags <value> " 10329 "priority <value> queue <queue_id>: Add/Del a 5tuple filter", 10330 .tokens = { 10331 (void *)&cmd_5tuple_filter_filter, 10332 (void *)&cmd_5tuple_filter_port_id, 10333 (void *)&cmd_5tuple_filter_ops, 10334 (void *)&cmd_5tuple_filter_dst_ip, 10335 (void *)&cmd_5tuple_filter_dst_ip_value, 10336 (void *)&cmd_5tuple_filter_src_ip, 10337 (void *)&cmd_5tuple_filter_src_ip_value, 10338 (void *)&cmd_5tuple_filter_dst_port, 10339 (void *)&cmd_5tuple_filter_dst_port_value, 10340 (void *)&cmd_5tuple_filter_src_port, 10341 (void *)&cmd_5tuple_filter_src_port_value, 10342 (void *)&cmd_5tuple_filter_protocol, 10343 (void *)&cmd_5tuple_filter_protocol_value, 10344 (void *)&cmd_5tuple_filter_mask, 10345 (void *)&cmd_5tuple_filter_mask_value, 10346 (void *)&cmd_5tuple_filter_tcp_flags, 10347 (void *)&cmd_5tuple_filter_tcp_flags_value, 10348 (void *)&cmd_5tuple_filter_priority, 10349 (void *)&cmd_5tuple_filter_priority_value, 10350 (void *)&cmd_5tuple_filter_queue, 10351 (void *)&cmd_5tuple_filter_queue_id, 10352 NULL, 10353 }, 10354 }; 10355 10356 /* *** ADD/REMOVE A flex FILTER *** */ 10357 struct cmd_flex_filter_result { 10358 cmdline_fixed_string_t filter; 10359 cmdline_fixed_string_t ops; 10360 portid_t port_id; 10361 cmdline_fixed_string_t len; 10362 uint8_t len_value; 10363 cmdline_fixed_string_t bytes; 10364 cmdline_fixed_string_t bytes_value; 10365 cmdline_fixed_string_t mask; 10366 cmdline_fixed_string_t mask_value; 10367 cmdline_fixed_string_t priority; 10368 uint8_t priority_value; 10369 cmdline_fixed_string_t queue; 10370 uint16_t queue_id; 10371 }; 10372 10373 static int xdigit2val(unsigned char c) 10374 { 10375 int val; 10376 if (isdigit(c)) 10377 val = c - '0'; 10378 else if (isupper(c)) 10379 val = c - 'A' + 10; 10380 else 10381 val = c - 'a' + 10; 10382 return val; 10383 } 10384 10385 static void 10386 cmd_flex_filter_parsed(void *parsed_result, 10387 __attribute__((unused)) struct cmdline *cl, 10388 __attribute__((unused)) void *data) 10389 { 10390 int ret = 0; 10391 struct rte_eth_flex_filter filter; 10392 struct cmd_flex_filter_result *res = parsed_result; 10393 char *bytes_ptr, *mask_ptr; 10394 uint16_t len, i, j = 0; 10395 char c; 10396 int val; 10397 uint8_t byte = 0; 10398 10399 if (res->len_value > RTE_FLEX_FILTER_MAXLEN) { 10400 printf("the len exceed the max length 128\n"); 10401 return; 10402 } 10403 memset(&filter, 0, sizeof(struct rte_eth_flex_filter)); 10404 filter.len = res->len_value; 10405 filter.priority = res->priority_value; 10406 filter.queue = res->queue_id; 10407 bytes_ptr = res->bytes_value; 10408 mask_ptr = res->mask_value; 10409 10410 /* translate bytes string to array. */ 10411 if (bytes_ptr[0] == '0' && ((bytes_ptr[1] == 'x') || 10412 (bytes_ptr[1] == 'X'))) 10413 bytes_ptr += 2; 10414 len = strnlen(bytes_ptr, res->len_value * 2); 10415 if (len == 0 || (len % 8 != 0)) { 10416 printf("please check len and bytes input\n"); 10417 return; 10418 } 10419 for (i = 0; i < len; i++) { 10420 c = bytes_ptr[i]; 10421 if (isxdigit(c) == 0) { 10422 /* invalid characters. */ 10423 printf("invalid input\n"); 10424 return; 10425 } 10426 val = xdigit2val(c); 10427 if (i % 2) { 10428 byte |= val; 10429 filter.bytes[j] = byte; 10430 printf("bytes[%d]:%02x ", j, filter.bytes[j]); 10431 j++; 10432 byte = 0; 10433 } else 10434 byte |= val << 4; 10435 } 10436 printf("\n"); 10437 /* translate mask string to uint8_t array. */ 10438 if (mask_ptr[0] == '0' && ((mask_ptr[1] == 'x') || 10439 (mask_ptr[1] == 'X'))) 10440 mask_ptr += 2; 10441 len = strnlen(mask_ptr, (res->len_value + 3) / 4); 10442 if (len == 0) { 10443 printf("invalid input\n"); 10444 return; 10445 } 10446 j = 0; 10447 byte = 0; 10448 for (i = 0; i < len; i++) { 10449 c = mask_ptr[i]; 10450 if (isxdigit(c) == 0) { 10451 /* invalid characters. */ 10452 printf("invalid input\n"); 10453 return; 10454 } 10455 val = xdigit2val(c); 10456 if (i % 2) { 10457 byte |= val; 10458 filter.mask[j] = byte; 10459 printf("mask[%d]:%02x ", j, filter.mask[j]); 10460 j++; 10461 byte = 0; 10462 } else 10463 byte |= val << 4; 10464 } 10465 printf("\n"); 10466 10467 if (!strcmp(res->ops, "add")) 10468 ret = rte_eth_dev_filter_ctrl(res->port_id, 10469 RTE_ETH_FILTER_FLEXIBLE, 10470 RTE_ETH_FILTER_ADD, 10471 &filter); 10472 else 10473 ret = rte_eth_dev_filter_ctrl(res->port_id, 10474 RTE_ETH_FILTER_FLEXIBLE, 10475 RTE_ETH_FILTER_DELETE, 10476 &filter); 10477 10478 if (ret < 0) 10479 printf("flex filter setting error: (%s)\n", strerror(-ret)); 10480 } 10481 10482 cmdline_parse_token_string_t cmd_flex_filter_filter = 10483 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result, 10484 filter, "flex_filter"); 10485 cmdline_parse_token_num_t cmd_flex_filter_port_id = 10486 TOKEN_NUM_INITIALIZER(struct cmd_flex_filter_result, 10487 port_id, UINT16); 10488 cmdline_parse_token_string_t cmd_flex_filter_ops = 10489 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result, 10490 ops, "add#del"); 10491 cmdline_parse_token_string_t cmd_flex_filter_len = 10492 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result, 10493 len, "len"); 10494 cmdline_parse_token_num_t cmd_flex_filter_len_value = 10495 TOKEN_NUM_INITIALIZER(struct cmd_flex_filter_result, 10496 len_value, UINT8); 10497 cmdline_parse_token_string_t cmd_flex_filter_bytes = 10498 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result, 10499 bytes, "bytes"); 10500 cmdline_parse_token_string_t cmd_flex_filter_bytes_value = 10501 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result, 10502 bytes_value, NULL); 10503 cmdline_parse_token_string_t cmd_flex_filter_mask = 10504 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result, 10505 mask, "mask"); 10506 cmdline_parse_token_string_t cmd_flex_filter_mask_value = 10507 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result, 10508 mask_value, NULL); 10509 cmdline_parse_token_string_t cmd_flex_filter_priority = 10510 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result, 10511 priority, "priority"); 10512 cmdline_parse_token_num_t cmd_flex_filter_priority_value = 10513 TOKEN_NUM_INITIALIZER(struct cmd_flex_filter_result, 10514 priority_value, UINT8); 10515 cmdline_parse_token_string_t cmd_flex_filter_queue = 10516 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result, 10517 queue, "queue"); 10518 cmdline_parse_token_num_t cmd_flex_filter_queue_id = 10519 TOKEN_NUM_INITIALIZER(struct cmd_flex_filter_result, 10520 queue_id, UINT16); 10521 cmdline_parse_inst_t cmd_flex_filter = { 10522 .f = cmd_flex_filter_parsed, 10523 .data = NULL, 10524 .help_str = "flex_filter <port_id> add|del len <value> bytes " 10525 "<value> mask <value> priority <value> queue <queue_id>: " 10526 "Add/Del a flex filter", 10527 .tokens = { 10528 (void *)&cmd_flex_filter_filter, 10529 (void *)&cmd_flex_filter_port_id, 10530 (void *)&cmd_flex_filter_ops, 10531 (void *)&cmd_flex_filter_len, 10532 (void *)&cmd_flex_filter_len_value, 10533 (void *)&cmd_flex_filter_bytes, 10534 (void *)&cmd_flex_filter_bytes_value, 10535 (void *)&cmd_flex_filter_mask, 10536 (void *)&cmd_flex_filter_mask_value, 10537 (void *)&cmd_flex_filter_priority, 10538 (void *)&cmd_flex_filter_priority_value, 10539 (void *)&cmd_flex_filter_queue, 10540 (void *)&cmd_flex_filter_queue_id, 10541 NULL, 10542 }, 10543 }; 10544 10545 /* *** Filters Control *** */ 10546 10547 /* *** deal with ethertype filter *** */ 10548 struct cmd_ethertype_filter_result { 10549 cmdline_fixed_string_t filter; 10550 portid_t port_id; 10551 cmdline_fixed_string_t ops; 10552 cmdline_fixed_string_t mac; 10553 struct ether_addr mac_addr; 10554 cmdline_fixed_string_t ethertype; 10555 uint16_t ethertype_value; 10556 cmdline_fixed_string_t drop; 10557 cmdline_fixed_string_t queue; 10558 uint16_t queue_id; 10559 }; 10560 10561 cmdline_parse_token_string_t cmd_ethertype_filter_filter = 10562 TOKEN_STRING_INITIALIZER(struct cmd_ethertype_filter_result, 10563 filter, "ethertype_filter"); 10564 cmdline_parse_token_num_t cmd_ethertype_filter_port_id = 10565 TOKEN_NUM_INITIALIZER(struct cmd_ethertype_filter_result, 10566 port_id, UINT16); 10567 cmdline_parse_token_string_t cmd_ethertype_filter_ops = 10568 TOKEN_STRING_INITIALIZER(struct cmd_ethertype_filter_result, 10569 ops, "add#del"); 10570 cmdline_parse_token_string_t cmd_ethertype_filter_mac = 10571 TOKEN_STRING_INITIALIZER(struct cmd_ethertype_filter_result, 10572 mac, "mac_addr#mac_ignr"); 10573 cmdline_parse_token_etheraddr_t cmd_ethertype_filter_mac_addr = 10574 TOKEN_ETHERADDR_INITIALIZER(struct cmd_ethertype_filter_result, 10575 mac_addr); 10576 cmdline_parse_token_string_t cmd_ethertype_filter_ethertype = 10577 TOKEN_STRING_INITIALIZER(struct cmd_ethertype_filter_result, 10578 ethertype, "ethertype"); 10579 cmdline_parse_token_num_t cmd_ethertype_filter_ethertype_value = 10580 TOKEN_NUM_INITIALIZER(struct cmd_ethertype_filter_result, 10581 ethertype_value, UINT16); 10582 cmdline_parse_token_string_t cmd_ethertype_filter_drop = 10583 TOKEN_STRING_INITIALIZER(struct cmd_ethertype_filter_result, 10584 drop, "drop#fwd"); 10585 cmdline_parse_token_string_t cmd_ethertype_filter_queue = 10586 TOKEN_STRING_INITIALIZER(struct cmd_ethertype_filter_result, 10587 queue, "queue"); 10588 cmdline_parse_token_num_t cmd_ethertype_filter_queue_id = 10589 TOKEN_NUM_INITIALIZER(struct cmd_ethertype_filter_result, 10590 queue_id, UINT16); 10591 10592 static void 10593 cmd_ethertype_filter_parsed(void *parsed_result, 10594 __attribute__((unused)) struct cmdline *cl, 10595 __attribute__((unused)) void *data) 10596 { 10597 struct cmd_ethertype_filter_result *res = parsed_result; 10598 struct rte_eth_ethertype_filter filter; 10599 int ret = 0; 10600 10601 ret = rte_eth_dev_filter_supported(res->port_id, 10602 RTE_ETH_FILTER_ETHERTYPE); 10603 if (ret < 0) { 10604 printf("ethertype filter is not supported on port %u.\n", 10605 res->port_id); 10606 return; 10607 } 10608 10609 memset(&filter, 0, sizeof(filter)); 10610 if (!strcmp(res->mac, "mac_addr")) { 10611 filter.flags |= RTE_ETHTYPE_FLAGS_MAC; 10612 rte_memcpy(&filter.mac_addr, &res->mac_addr, 10613 sizeof(struct ether_addr)); 10614 } 10615 if (!strcmp(res->drop, "drop")) 10616 filter.flags |= RTE_ETHTYPE_FLAGS_DROP; 10617 filter.ether_type = res->ethertype_value; 10618 filter.queue = res->queue_id; 10619 10620 if (!strcmp(res->ops, "add")) 10621 ret = rte_eth_dev_filter_ctrl(res->port_id, 10622 RTE_ETH_FILTER_ETHERTYPE, 10623 RTE_ETH_FILTER_ADD, 10624 &filter); 10625 else 10626 ret = rte_eth_dev_filter_ctrl(res->port_id, 10627 RTE_ETH_FILTER_ETHERTYPE, 10628 RTE_ETH_FILTER_DELETE, 10629 &filter); 10630 if (ret < 0) 10631 printf("ethertype filter programming error: (%s)\n", 10632 strerror(-ret)); 10633 } 10634 10635 cmdline_parse_inst_t cmd_ethertype_filter = { 10636 .f = cmd_ethertype_filter_parsed, 10637 .data = NULL, 10638 .help_str = "ethertype_filter <port_id> add|del mac_addr|mac_ignr " 10639 "<mac_addr> ethertype <value> drop|fw queue <queue_id>: " 10640 "Add or delete an ethertype filter entry", 10641 .tokens = { 10642 (void *)&cmd_ethertype_filter_filter, 10643 (void *)&cmd_ethertype_filter_port_id, 10644 (void *)&cmd_ethertype_filter_ops, 10645 (void *)&cmd_ethertype_filter_mac, 10646 (void *)&cmd_ethertype_filter_mac_addr, 10647 (void *)&cmd_ethertype_filter_ethertype, 10648 (void *)&cmd_ethertype_filter_ethertype_value, 10649 (void *)&cmd_ethertype_filter_drop, 10650 (void *)&cmd_ethertype_filter_queue, 10651 (void *)&cmd_ethertype_filter_queue_id, 10652 NULL, 10653 }, 10654 }; 10655 10656 /* *** deal with flow director filter *** */ 10657 struct cmd_flow_director_result { 10658 cmdline_fixed_string_t flow_director_filter; 10659 portid_t port_id; 10660 cmdline_fixed_string_t mode; 10661 cmdline_fixed_string_t mode_value; 10662 cmdline_fixed_string_t ops; 10663 cmdline_fixed_string_t flow; 10664 cmdline_fixed_string_t flow_type; 10665 cmdline_fixed_string_t ether; 10666 uint16_t ether_type; 10667 cmdline_fixed_string_t src; 10668 cmdline_ipaddr_t ip_src; 10669 uint16_t port_src; 10670 cmdline_fixed_string_t dst; 10671 cmdline_ipaddr_t ip_dst; 10672 uint16_t port_dst; 10673 cmdline_fixed_string_t verify_tag; 10674 uint32_t verify_tag_value; 10675 cmdline_fixed_string_t tos; 10676 uint8_t tos_value; 10677 cmdline_fixed_string_t proto; 10678 uint8_t proto_value; 10679 cmdline_fixed_string_t ttl; 10680 uint8_t ttl_value; 10681 cmdline_fixed_string_t vlan; 10682 uint16_t vlan_value; 10683 cmdline_fixed_string_t flexbytes; 10684 cmdline_fixed_string_t flexbytes_value; 10685 cmdline_fixed_string_t pf_vf; 10686 cmdline_fixed_string_t drop; 10687 cmdline_fixed_string_t queue; 10688 uint16_t queue_id; 10689 cmdline_fixed_string_t fd_id; 10690 uint32_t fd_id_value; 10691 cmdline_fixed_string_t mac; 10692 struct ether_addr mac_addr; 10693 cmdline_fixed_string_t tunnel; 10694 cmdline_fixed_string_t tunnel_type; 10695 cmdline_fixed_string_t tunnel_id; 10696 uint32_t tunnel_id_value; 10697 cmdline_fixed_string_t packet; 10698 char filepath[]; 10699 }; 10700 10701 static inline int 10702 parse_flexbytes(const char *q_arg, uint8_t *flexbytes, uint16_t max_num) 10703 { 10704 char s[256]; 10705 const char *p, *p0 = q_arg; 10706 char *end; 10707 unsigned long int_fld; 10708 char *str_fld[max_num]; 10709 int i; 10710 unsigned size; 10711 int ret = -1; 10712 10713 p = strchr(p0, '('); 10714 if (p == NULL) 10715 return -1; 10716 ++p; 10717 p0 = strchr(p, ')'); 10718 if (p0 == NULL) 10719 return -1; 10720 10721 size = p0 - p; 10722 if (size >= sizeof(s)) 10723 return -1; 10724 10725 snprintf(s, sizeof(s), "%.*s", size, p); 10726 ret = rte_strsplit(s, sizeof(s), str_fld, max_num, ','); 10727 if (ret < 0 || ret > max_num) 10728 return -1; 10729 for (i = 0; i < ret; i++) { 10730 errno = 0; 10731 int_fld = strtoul(str_fld[i], &end, 0); 10732 if (errno != 0 || *end != '\0' || int_fld > UINT8_MAX) 10733 return -1; 10734 flexbytes[i] = (uint8_t)int_fld; 10735 } 10736 return ret; 10737 } 10738 10739 static uint16_t 10740 str2flowtype(char *string) 10741 { 10742 uint8_t i = 0; 10743 static const struct { 10744 char str[32]; 10745 uint16_t type; 10746 } flowtype_str[] = { 10747 {"raw", RTE_ETH_FLOW_RAW}, 10748 {"ipv4", RTE_ETH_FLOW_IPV4}, 10749 {"ipv4-frag", RTE_ETH_FLOW_FRAG_IPV4}, 10750 {"ipv4-tcp", RTE_ETH_FLOW_NONFRAG_IPV4_TCP}, 10751 {"ipv4-udp", RTE_ETH_FLOW_NONFRAG_IPV4_UDP}, 10752 {"ipv4-sctp", RTE_ETH_FLOW_NONFRAG_IPV4_SCTP}, 10753 {"ipv4-other", RTE_ETH_FLOW_NONFRAG_IPV4_OTHER}, 10754 {"ipv6", RTE_ETH_FLOW_IPV6}, 10755 {"ipv6-frag", RTE_ETH_FLOW_FRAG_IPV6}, 10756 {"ipv6-tcp", RTE_ETH_FLOW_NONFRAG_IPV6_TCP}, 10757 {"ipv6-udp", RTE_ETH_FLOW_NONFRAG_IPV6_UDP}, 10758 {"ipv6-sctp", RTE_ETH_FLOW_NONFRAG_IPV6_SCTP}, 10759 {"ipv6-other", RTE_ETH_FLOW_NONFRAG_IPV6_OTHER}, 10760 {"l2_payload", RTE_ETH_FLOW_L2_PAYLOAD}, 10761 }; 10762 10763 for (i = 0; i < RTE_DIM(flowtype_str); i++) { 10764 if (!strcmp(flowtype_str[i].str, string)) 10765 return flowtype_str[i].type; 10766 } 10767 10768 if (isdigit(string[0]) && atoi(string) > 0 && atoi(string) < 64) 10769 return (uint16_t)atoi(string); 10770 10771 return RTE_ETH_FLOW_UNKNOWN; 10772 } 10773 10774 static enum rte_eth_fdir_tunnel_type 10775 str2fdir_tunneltype(char *string) 10776 { 10777 uint8_t i = 0; 10778 10779 static const struct { 10780 char str[32]; 10781 enum rte_eth_fdir_tunnel_type type; 10782 } tunneltype_str[] = { 10783 {"NVGRE", RTE_FDIR_TUNNEL_TYPE_NVGRE}, 10784 {"VxLAN", RTE_FDIR_TUNNEL_TYPE_VXLAN}, 10785 }; 10786 10787 for (i = 0; i < RTE_DIM(tunneltype_str); i++) { 10788 if (!strcmp(tunneltype_str[i].str, string)) 10789 return tunneltype_str[i].type; 10790 } 10791 return RTE_FDIR_TUNNEL_TYPE_UNKNOWN; 10792 } 10793 10794 #define IPV4_ADDR_TO_UINT(ip_addr, ip) \ 10795 do { \ 10796 if ((ip_addr).family == AF_INET) \ 10797 (ip) = (ip_addr).addr.ipv4.s_addr; \ 10798 else { \ 10799 printf("invalid parameter.\n"); \ 10800 return; \ 10801 } \ 10802 } while (0) 10803 10804 #define IPV6_ADDR_TO_ARRAY(ip_addr, ip) \ 10805 do { \ 10806 if ((ip_addr).family == AF_INET6) \ 10807 rte_memcpy(&(ip), \ 10808 &((ip_addr).addr.ipv6), \ 10809 sizeof(struct in6_addr)); \ 10810 else { \ 10811 printf("invalid parameter.\n"); \ 10812 return; \ 10813 } \ 10814 } while (0) 10815 10816 static void 10817 cmd_flow_director_filter_parsed(void *parsed_result, 10818 __attribute__((unused)) struct cmdline *cl, 10819 __attribute__((unused)) void *data) 10820 { 10821 struct cmd_flow_director_result *res = parsed_result; 10822 struct rte_eth_fdir_filter entry; 10823 uint8_t flexbytes[RTE_ETH_FDIR_MAX_FLEXLEN]; 10824 char *end; 10825 unsigned long vf_id; 10826 int ret = 0; 10827 10828 ret = rte_eth_dev_filter_supported(res->port_id, RTE_ETH_FILTER_FDIR); 10829 if (ret < 0) { 10830 printf("flow director is not supported on port %u.\n", 10831 res->port_id); 10832 return; 10833 } 10834 memset(flexbytes, 0, sizeof(flexbytes)); 10835 memset(&entry, 0, sizeof(struct rte_eth_fdir_filter)); 10836 10837 if (fdir_conf.mode == RTE_FDIR_MODE_PERFECT_MAC_VLAN) { 10838 if (strcmp(res->mode_value, "MAC-VLAN")) { 10839 printf("Please set mode to MAC-VLAN.\n"); 10840 return; 10841 } 10842 } else if (fdir_conf.mode == RTE_FDIR_MODE_PERFECT_TUNNEL) { 10843 if (strcmp(res->mode_value, "Tunnel")) { 10844 printf("Please set mode to Tunnel.\n"); 10845 return; 10846 } 10847 } else { 10848 if (!strcmp(res->mode_value, "raw")) { 10849 #ifdef RTE_LIBRTE_I40E_PMD 10850 struct rte_pmd_i40e_flow_type_mapping 10851 mapping[RTE_PMD_I40E_FLOW_TYPE_MAX]; 10852 struct rte_pmd_i40e_pkt_template_conf conf; 10853 uint16_t flow_type = str2flowtype(res->flow_type); 10854 uint16_t i, port = res->port_id; 10855 uint8_t add; 10856 10857 memset(&conf, 0, sizeof(conf)); 10858 10859 if (flow_type == RTE_ETH_FLOW_UNKNOWN) { 10860 printf("Invalid flow type specified.\n"); 10861 return; 10862 } 10863 ret = rte_pmd_i40e_flow_type_mapping_get(res->port_id, 10864 mapping); 10865 if (ret) 10866 return; 10867 if (mapping[flow_type].pctype == 0ULL) { 10868 printf("Invalid flow type specified.\n"); 10869 return; 10870 } 10871 for (i = 0; i < RTE_PMD_I40E_PCTYPE_MAX; i++) { 10872 if (mapping[flow_type].pctype & (1ULL << i)) { 10873 conf.input.pctype = i; 10874 break; 10875 } 10876 } 10877 10878 conf.input.packet = open_file(res->filepath, 10879 &conf.input.length); 10880 if (!conf.input.packet) 10881 return; 10882 if (!strcmp(res->drop, "drop")) 10883 conf.action.behavior = 10884 RTE_PMD_I40E_PKT_TEMPLATE_REJECT; 10885 else 10886 conf.action.behavior = 10887 RTE_PMD_I40E_PKT_TEMPLATE_ACCEPT; 10888 conf.action.report_status = 10889 RTE_PMD_I40E_PKT_TEMPLATE_REPORT_ID; 10890 conf.action.rx_queue = res->queue_id; 10891 conf.soft_id = res->fd_id_value; 10892 add = strcmp(res->ops, "del") ? 1 : 0; 10893 ret = rte_pmd_i40e_flow_add_del_packet_template(port, 10894 &conf, 10895 add); 10896 if (ret < 0) 10897 printf("flow director config error: (%s)\n", 10898 strerror(-ret)); 10899 close_file(conf.input.packet); 10900 #endif 10901 return; 10902 } else if (strcmp(res->mode_value, "IP")) { 10903 printf("Please set mode to IP or raw.\n"); 10904 return; 10905 } 10906 entry.input.flow_type = str2flowtype(res->flow_type); 10907 } 10908 10909 ret = parse_flexbytes(res->flexbytes_value, 10910 flexbytes, 10911 RTE_ETH_FDIR_MAX_FLEXLEN); 10912 if (ret < 0) { 10913 printf("error: Cannot parse flexbytes input.\n"); 10914 return; 10915 } 10916 10917 switch (entry.input.flow_type) { 10918 case RTE_ETH_FLOW_FRAG_IPV4: 10919 case RTE_ETH_FLOW_NONFRAG_IPV4_OTHER: 10920 entry.input.flow.ip4_flow.proto = res->proto_value; 10921 /* fall-through */ 10922 case RTE_ETH_FLOW_NONFRAG_IPV4_UDP: 10923 case RTE_ETH_FLOW_NONFRAG_IPV4_TCP: 10924 IPV4_ADDR_TO_UINT(res->ip_dst, 10925 entry.input.flow.ip4_flow.dst_ip); 10926 IPV4_ADDR_TO_UINT(res->ip_src, 10927 entry.input.flow.ip4_flow.src_ip); 10928 entry.input.flow.ip4_flow.tos = res->tos_value; 10929 entry.input.flow.ip4_flow.ttl = res->ttl_value; 10930 /* need convert to big endian. */ 10931 entry.input.flow.udp4_flow.dst_port = 10932 rte_cpu_to_be_16(res->port_dst); 10933 entry.input.flow.udp4_flow.src_port = 10934 rte_cpu_to_be_16(res->port_src); 10935 break; 10936 case RTE_ETH_FLOW_NONFRAG_IPV4_SCTP: 10937 IPV4_ADDR_TO_UINT(res->ip_dst, 10938 entry.input.flow.sctp4_flow.ip.dst_ip); 10939 IPV4_ADDR_TO_UINT(res->ip_src, 10940 entry.input.flow.sctp4_flow.ip.src_ip); 10941 entry.input.flow.ip4_flow.tos = res->tos_value; 10942 entry.input.flow.ip4_flow.ttl = res->ttl_value; 10943 /* need convert to big endian. */ 10944 entry.input.flow.sctp4_flow.dst_port = 10945 rte_cpu_to_be_16(res->port_dst); 10946 entry.input.flow.sctp4_flow.src_port = 10947 rte_cpu_to_be_16(res->port_src); 10948 entry.input.flow.sctp4_flow.verify_tag = 10949 rte_cpu_to_be_32(res->verify_tag_value); 10950 break; 10951 case RTE_ETH_FLOW_FRAG_IPV6: 10952 case RTE_ETH_FLOW_NONFRAG_IPV6_OTHER: 10953 entry.input.flow.ipv6_flow.proto = res->proto_value; 10954 /* fall-through */ 10955 case RTE_ETH_FLOW_NONFRAG_IPV6_UDP: 10956 case RTE_ETH_FLOW_NONFRAG_IPV6_TCP: 10957 IPV6_ADDR_TO_ARRAY(res->ip_dst, 10958 entry.input.flow.ipv6_flow.dst_ip); 10959 IPV6_ADDR_TO_ARRAY(res->ip_src, 10960 entry.input.flow.ipv6_flow.src_ip); 10961 entry.input.flow.ipv6_flow.tc = res->tos_value; 10962 entry.input.flow.ipv6_flow.hop_limits = res->ttl_value; 10963 /* need convert to big endian. */ 10964 entry.input.flow.udp6_flow.dst_port = 10965 rte_cpu_to_be_16(res->port_dst); 10966 entry.input.flow.udp6_flow.src_port = 10967 rte_cpu_to_be_16(res->port_src); 10968 break; 10969 case RTE_ETH_FLOW_NONFRAG_IPV6_SCTP: 10970 IPV6_ADDR_TO_ARRAY(res->ip_dst, 10971 entry.input.flow.sctp6_flow.ip.dst_ip); 10972 IPV6_ADDR_TO_ARRAY(res->ip_src, 10973 entry.input.flow.sctp6_flow.ip.src_ip); 10974 entry.input.flow.ipv6_flow.tc = res->tos_value; 10975 entry.input.flow.ipv6_flow.hop_limits = res->ttl_value; 10976 /* need convert to big endian. */ 10977 entry.input.flow.sctp6_flow.dst_port = 10978 rte_cpu_to_be_16(res->port_dst); 10979 entry.input.flow.sctp6_flow.src_port = 10980 rte_cpu_to_be_16(res->port_src); 10981 entry.input.flow.sctp6_flow.verify_tag = 10982 rte_cpu_to_be_32(res->verify_tag_value); 10983 break; 10984 case RTE_ETH_FLOW_L2_PAYLOAD: 10985 entry.input.flow.l2_flow.ether_type = 10986 rte_cpu_to_be_16(res->ether_type); 10987 break; 10988 default: 10989 break; 10990 } 10991 10992 if (fdir_conf.mode == RTE_FDIR_MODE_PERFECT_MAC_VLAN) 10993 rte_memcpy(&entry.input.flow.mac_vlan_flow.mac_addr, 10994 &res->mac_addr, 10995 sizeof(struct ether_addr)); 10996 10997 if (fdir_conf.mode == RTE_FDIR_MODE_PERFECT_TUNNEL) { 10998 rte_memcpy(&entry.input.flow.tunnel_flow.mac_addr, 10999 &res->mac_addr, 11000 sizeof(struct ether_addr)); 11001 entry.input.flow.tunnel_flow.tunnel_type = 11002 str2fdir_tunneltype(res->tunnel_type); 11003 entry.input.flow.tunnel_flow.tunnel_id = 11004 rte_cpu_to_be_32(res->tunnel_id_value); 11005 } 11006 11007 rte_memcpy(entry.input.flow_ext.flexbytes, 11008 flexbytes, 11009 RTE_ETH_FDIR_MAX_FLEXLEN); 11010 11011 entry.input.flow_ext.vlan_tci = rte_cpu_to_be_16(res->vlan_value); 11012 11013 entry.action.flex_off = 0; /*use 0 by default */ 11014 if (!strcmp(res->drop, "drop")) 11015 entry.action.behavior = RTE_ETH_FDIR_REJECT; 11016 else 11017 entry.action.behavior = RTE_ETH_FDIR_ACCEPT; 11018 11019 if (fdir_conf.mode != RTE_FDIR_MODE_PERFECT_MAC_VLAN && 11020 fdir_conf.mode != RTE_FDIR_MODE_PERFECT_TUNNEL) { 11021 if (!strcmp(res->pf_vf, "pf")) 11022 entry.input.flow_ext.is_vf = 0; 11023 else if (!strncmp(res->pf_vf, "vf", 2)) { 11024 struct rte_eth_dev_info dev_info; 11025 11026 memset(&dev_info, 0, sizeof(dev_info)); 11027 rte_eth_dev_info_get(res->port_id, &dev_info); 11028 errno = 0; 11029 vf_id = strtoul(res->pf_vf + 2, &end, 10); 11030 if (errno != 0 || *end != '\0' || 11031 vf_id >= dev_info.max_vfs) { 11032 printf("invalid parameter %s.\n", res->pf_vf); 11033 return; 11034 } 11035 entry.input.flow_ext.is_vf = 1; 11036 entry.input.flow_ext.dst_id = (uint16_t)vf_id; 11037 } else { 11038 printf("invalid parameter %s.\n", res->pf_vf); 11039 return; 11040 } 11041 } 11042 11043 /* set to report FD ID by default */ 11044 entry.action.report_status = RTE_ETH_FDIR_REPORT_ID; 11045 entry.action.rx_queue = res->queue_id; 11046 entry.soft_id = res->fd_id_value; 11047 if (!strcmp(res->ops, "add")) 11048 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_FDIR, 11049 RTE_ETH_FILTER_ADD, &entry); 11050 else if (!strcmp(res->ops, "del")) 11051 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_FDIR, 11052 RTE_ETH_FILTER_DELETE, &entry); 11053 else 11054 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_FDIR, 11055 RTE_ETH_FILTER_UPDATE, &entry); 11056 if (ret < 0) 11057 printf("flow director programming error: (%s)\n", 11058 strerror(-ret)); 11059 } 11060 11061 cmdline_parse_token_string_t cmd_flow_director_filter = 11062 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result, 11063 flow_director_filter, "flow_director_filter"); 11064 cmdline_parse_token_num_t cmd_flow_director_port_id = 11065 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result, 11066 port_id, UINT16); 11067 cmdline_parse_token_string_t cmd_flow_director_ops = 11068 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result, 11069 ops, "add#del#update"); 11070 cmdline_parse_token_string_t cmd_flow_director_flow = 11071 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result, 11072 flow, "flow"); 11073 cmdline_parse_token_string_t cmd_flow_director_flow_type = 11074 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result, 11075 flow_type, NULL); 11076 cmdline_parse_token_string_t cmd_flow_director_ether = 11077 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result, 11078 ether, "ether"); 11079 cmdline_parse_token_num_t cmd_flow_director_ether_type = 11080 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result, 11081 ether_type, UINT16); 11082 cmdline_parse_token_string_t cmd_flow_director_src = 11083 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result, 11084 src, "src"); 11085 cmdline_parse_token_ipaddr_t cmd_flow_director_ip_src = 11086 TOKEN_IPADDR_INITIALIZER(struct cmd_flow_director_result, 11087 ip_src); 11088 cmdline_parse_token_num_t cmd_flow_director_port_src = 11089 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result, 11090 port_src, UINT16); 11091 cmdline_parse_token_string_t cmd_flow_director_dst = 11092 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result, 11093 dst, "dst"); 11094 cmdline_parse_token_ipaddr_t cmd_flow_director_ip_dst = 11095 TOKEN_IPADDR_INITIALIZER(struct cmd_flow_director_result, 11096 ip_dst); 11097 cmdline_parse_token_num_t cmd_flow_director_port_dst = 11098 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result, 11099 port_dst, UINT16); 11100 cmdline_parse_token_string_t cmd_flow_director_verify_tag = 11101 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result, 11102 verify_tag, "verify_tag"); 11103 cmdline_parse_token_num_t cmd_flow_director_verify_tag_value = 11104 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result, 11105 verify_tag_value, UINT32); 11106 cmdline_parse_token_string_t cmd_flow_director_tos = 11107 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result, 11108 tos, "tos"); 11109 cmdline_parse_token_num_t cmd_flow_director_tos_value = 11110 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result, 11111 tos_value, UINT8); 11112 cmdline_parse_token_string_t cmd_flow_director_proto = 11113 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result, 11114 proto, "proto"); 11115 cmdline_parse_token_num_t cmd_flow_director_proto_value = 11116 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result, 11117 proto_value, UINT8); 11118 cmdline_parse_token_string_t cmd_flow_director_ttl = 11119 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result, 11120 ttl, "ttl"); 11121 cmdline_parse_token_num_t cmd_flow_director_ttl_value = 11122 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result, 11123 ttl_value, UINT8); 11124 cmdline_parse_token_string_t cmd_flow_director_vlan = 11125 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result, 11126 vlan, "vlan"); 11127 cmdline_parse_token_num_t cmd_flow_director_vlan_value = 11128 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result, 11129 vlan_value, UINT16); 11130 cmdline_parse_token_string_t cmd_flow_director_flexbytes = 11131 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result, 11132 flexbytes, "flexbytes"); 11133 cmdline_parse_token_string_t cmd_flow_director_flexbytes_value = 11134 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result, 11135 flexbytes_value, NULL); 11136 cmdline_parse_token_string_t cmd_flow_director_drop = 11137 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result, 11138 drop, "drop#fwd"); 11139 cmdline_parse_token_string_t cmd_flow_director_pf_vf = 11140 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result, 11141 pf_vf, NULL); 11142 cmdline_parse_token_string_t cmd_flow_director_queue = 11143 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result, 11144 queue, "queue"); 11145 cmdline_parse_token_num_t cmd_flow_director_queue_id = 11146 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result, 11147 queue_id, UINT16); 11148 cmdline_parse_token_string_t cmd_flow_director_fd_id = 11149 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result, 11150 fd_id, "fd_id"); 11151 cmdline_parse_token_num_t cmd_flow_director_fd_id_value = 11152 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result, 11153 fd_id_value, UINT32); 11154 11155 cmdline_parse_token_string_t cmd_flow_director_mode = 11156 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result, 11157 mode, "mode"); 11158 cmdline_parse_token_string_t cmd_flow_director_mode_ip = 11159 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result, 11160 mode_value, "IP"); 11161 cmdline_parse_token_string_t cmd_flow_director_mode_mac_vlan = 11162 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result, 11163 mode_value, "MAC-VLAN"); 11164 cmdline_parse_token_string_t cmd_flow_director_mode_tunnel = 11165 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result, 11166 mode_value, "Tunnel"); 11167 cmdline_parse_token_string_t cmd_flow_director_mode_raw = 11168 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result, 11169 mode_value, "raw"); 11170 cmdline_parse_token_string_t cmd_flow_director_mac = 11171 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result, 11172 mac, "mac"); 11173 cmdline_parse_token_etheraddr_t cmd_flow_director_mac_addr = 11174 TOKEN_ETHERADDR_INITIALIZER(struct cmd_flow_director_result, 11175 mac_addr); 11176 cmdline_parse_token_string_t cmd_flow_director_tunnel = 11177 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result, 11178 tunnel, "tunnel"); 11179 cmdline_parse_token_string_t cmd_flow_director_tunnel_type = 11180 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result, 11181 tunnel_type, "NVGRE#VxLAN"); 11182 cmdline_parse_token_string_t cmd_flow_director_tunnel_id = 11183 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result, 11184 tunnel_id, "tunnel-id"); 11185 cmdline_parse_token_num_t cmd_flow_director_tunnel_id_value = 11186 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result, 11187 tunnel_id_value, UINT32); 11188 cmdline_parse_token_string_t cmd_flow_director_packet = 11189 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result, 11190 packet, "packet"); 11191 cmdline_parse_token_string_t cmd_flow_director_filepath = 11192 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result, 11193 filepath, NULL); 11194 11195 cmdline_parse_inst_t cmd_add_del_ip_flow_director = { 11196 .f = cmd_flow_director_filter_parsed, 11197 .data = NULL, 11198 .help_str = "flow_director_filter <port_id> mode IP add|del|update flow" 11199 " ipv4-other|ipv4-frag|ipv4-tcp|ipv4-udp|ipv4-sctp|" 11200 "ipv6-other|ipv6-frag|ipv6-tcp|ipv6-udp|ipv6-sctp|" 11201 "l2_payload src <src_ip> dst <dst_ip> tos <tos_value> " 11202 "proto <proto_value> ttl <ttl_value> vlan <vlan_value> " 11203 "flexbytes <flexbyte_values> drop|fw <pf_vf> queue <queue_id> " 11204 "fd_id <fd_id_value>: " 11205 "Add or delete an ip flow director entry on NIC", 11206 .tokens = { 11207 (void *)&cmd_flow_director_filter, 11208 (void *)&cmd_flow_director_port_id, 11209 (void *)&cmd_flow_director_mode, 11210 (void *)&cmd_flow_director_mode_ip, 11211 (void *)&cmd_flow_director_ops, 11212 (void *)&cmd_flow_director_flow, 11213 (void *)&cmd_flow_director_flow_type, 11214 (void *)&cmd_flow_director_src, 11215 (void *)&cmd_flow_director_ip_src, 11216 (void *)&cmd_flow_director_dst, 11217 (void *)&cmd_flow_director_ip_dst, 11218 (void *)&cmd_flow_director_tos, 11219 (void *)&cmd_flow_director_tos_value, 11220 (void *)&cmd_flow_director_proto, 11221 (void *)&cmd_flow_director_proto_value, 11222 (void *)&cmd_flow_director_ttl, 11223 (void *)&cmd_flow_director_ttl_value, 11224 (void *)&cmd_flow_director_vlan, 11225 (void *)&cmd_flow_director_vlan_value, 11226 (void *)&cmd_flow_director_flexbytes, 11227 (void *)&cmd_flow_director_flexbytes_value, 11228 (void *)&cmd_flow_director_drop, 11229 (void *)&cmd_flow_director_pf_vf, 11230 (void *)&cmd_flow_director_queue, 11231 (void *)&cmd_flow_director_queue_id, 11232 (void *)&cmd_flow_director_fd_id, 11233 (void *)&cmd_flow_director_fd_id_value, 11234 NULL, 11235 }, 11236 }; 11237 11238 cmdline_parse_inst_t cmd_add_del_udp_flow_director = { 11239 .f = cmd_flow_director_filter_parsed, 11240 .data = NULL, 11241 .help_str = "flow_director_filter ... : Add or delete an udp/tcp flow " 11242 "director entry on NIC", 11243 .tokens = { 11244 (void *)&cmd_flow_director_filter, 11245 (void *)&cmd_flow_director_port_id, 11246 (void *)&cmd_flow_director_mode, 11247 (void *)&cmd_flow_director_mode_ip, 11248 (void *)&cmd_flow_director_ops, 11249 (void *)&cmd_flow_director_flow, 11250 (void *)&cmd_flow_director_flow_type, 11251 (void *)&cmd_flow_director_src, 11252 (void *)&cmd_flow_director_ip_src, 11253 (void *)&cmd_flow_director_port_src, 11254 (void *)&cmd_flow_director_dst, 11255 (void *)&cmd_flow_director_ip_dst, 11256 (void *)&cmd_flow_director_port_dst, 11257 (void *)&cmd_flow_director_tos, 11258 (void *)&cmd_flow_director_tos_value, 11259 (void *)&cmd_flow_director_ttl, 11260 (void *)&cmd_flow_director_ttl_value, 11261 (void *)&cmd_flow_director_vlan, 11262 (void *)&cmd_flow_director_vlan_value, 11263 (void *)&cmd_flow_director_flexbytes, 11264 (void *)&cmd_flow_director_flexbytes_value, 11265 (void *)&cmd_flow_director_drop, 11266 (void *)&cmd_flow_director_pf_vf, 11267 (void *)&cmd_flow_director_queue, 11268 (void *)&cmd_flow_director_queue_id, 11269 (void *)&cmd_flow_director_fd_id, 11270 (void *)&cmd_flow_director_fd_id_value, 11271 NULL, 11272 }, 11273 }; 11274 11275 cmdline_parse_inst_t cmd_add_del_sctp_flow_director = { 11276 .f = cmd_flow_director_filter_parsed, 11277 .data = NULL, 11278 .help_str = "flow_director_filter ... : Add or delete a sctp flow " 11279 "director entry on NIC", 11280 .tokens = { 11281 (void *)&cmd_flow_director_filter, 11282 (void *)&cmd_flow_director_port_id, 11283 (void *)&cmd_flow_director_mode, 11284 (void *)&cmd_flow_director_mode_ip, 11285 (void *)&cmd_flow_director_ops, 11286 (void *)&cmd_flow_director_flow, 11287 (void *)&cmd_flow_director_flow_type, 11288 (void *)&cmd_flow_director_src, 11289 (void *)&cmd_flow_director_ip_src, 11290 (void *)&cmd_flow_director_port_src, 11291 (void *)&cmd_flow_director_dst, 11292 (void *)&cmd_flow_director_ip_dst, 11293 (void *)&cmd_flow_director_port_dst, 11294 (void *)&cmd_flow_director_verify_tag, 11295 (void *)&cmd_flow_director_verify_tag_value, 11296 (void *)&cmd_flow_director_tos, 11297 (void *)&cmd_flow_director_tos_value, 11298 (void *)&cmd_flow_director_ttl, 11299 (void *)&cmd_flow_director_ttl_value, 11300 (void *)&cmd_flow_director_vlan, 11301 (void *)&cmd_flow_director_vlan_value, 11302 (void *)&cmd_flow_director_flexbytes, 11303 (void *)&cmd_flow_director_flexbytes_value, 11304 (void *)&cmd_flow_director_drop, 11305 (void *)&cmd_flow_director_pf_vf, 11306 (void *)&cmd_flow_director_queue, 11307 (void *)&cmd_flow_director_queue_id, 11308 (void *)&cmd_flow_director_fd_id, 11309 (void *)&cmd_flow_director_fd_id_value, 11310 NULL, 11311 }, 11312 }; 11313 11314 cmdline_parse_inst_t cmd_add_del_l2_flow_director = { 11315 .f = cmd_flow_director_filter_parsed, 11316 .data = NULL, 11317 .help_str = "flow_director_filter ... : Add or delete a L2 flow " 11318 "director entry on NIC", 11319 .tokens = { 11320 (void *)&cmd_flow_director_filter, 11321 (void *)&cmd_flow_director_port_id, 11322 (void *)&cmd_flow_director_mode, 11323 (void *)&cmd_flow_director_mode_ip, 11324 (void *)&cmd_flow_director_ops, 11325 (void *)&cmd_flow_director_flow, 11326 (void *)&cmd_flow_director_flow_type, 11327 (void *)&cmd_flow_director_ether, 11328 (void *)&cmd_flow_director_ether_type, 11329 (void *)&cmd_flow_director_flexbytes, 11330 (void *)&cmd_flow_director_flexbytes_value, 11331 (void *)&cmd_flow_director_drop, 11332 (void *)&cmd_flow_director_pf_vf, 11333 (void *)&cmd_flow_director_queue, 11334 (void *)&cmd_flow_director_queue_id, 11335 (void *)&cmd_flow_director_fd_id, 11336 (void *)&cmd_flow_director_fd_id_value, 11337 NULL, 11338 }, 11339 }; 11340 11341 cmdline_parse_inst_t cmd_add_del_mac_vlan_flow_director = { 11342 .f = cmd_flow_director_filter_parsed, 11343 .data = NULL, 11344 .help_str = "flow_director_filter ... : Add or delete a MAC VLAN flow " 11345 "director entry on NIC", 11346 .tokens = { 11347 (void *)&cmd_flow_director_filter, 11348 (void *)&cmd_flow_director_port_id, 11349 (void *)&cmd_flow_director_mode, 11350 (void *)&cmd_flow_director_mode_mac_vlan, 11351 (void *)&cmd_flow_director_ops, 11352 (void *)&cmd_flow_director_mac, 11353 (void *)&cmd_flow_director_mac_addr, 11354 (void *)&cmd_flow_director_vlan, 11355 (void *)&cmd_flow_director_vlan_value, 11356 (void *)&cmd_flow_director_flexbytes, 11357 (void *)&cmd_flow_director_flexbytes_value, 11358 (void *)&cmd_flow_director_drop, 11359 (void *)&cmd_flow_director_queue, 11360 (void *)&cmd_flow_director_queue_id, 11361 (void *)&cmd_flow_director_fd_id, 11362 (void *)&cmd_flow_director_fd_id_value, 11363 NULL, 11364 }, 11365 }; 11366 11367 cmdline_parse_inst_t cmd_add_del_tunnel_flow_director = { 11368 .f = cmd_flow_director_filter_parsed, 11369 .data = NULL, 11370 .help_str = "flow_director_filter ... : Add or delete a tunnel flow " 11371 "director entry on NIC", 11372 .tokens = { 11373 (void *)&cmd_flow_director_filter, 11374 (void *)&cmd_flow_director_port_id, 11375 (void *)&cmd_flow_director_mode, 11376 (void *)&cmd_flow_director_mode_tunnel, 11377 (void *)&cmd_flow_director_ops, 11378 (void *)&cmd_flow_director_mac, 11379 (void *)&cmd_flow_director_mac_addr, 11380 (void *)&cmd_flow_director_vlan, 11381 (void *)&cmd_flow_director_vlan_value, 11382 (void *)&cmd_flow_director_tunnel, 11383 (void *)&cmd_flow_director_tunnel_type, 11384 (void *)&cmd_flow_director_tunnel_id, 11385 (void *)&cmd_flow_director_tunnel_id_value, 11386 (void *)&cmd_flow_director_flexbytes, 11387 (void *)&cmd_flow_director_flexbytes_value, 11388 (void *)&cmd_flow_director_drop, 11389 (void *)&cmd_flow_director_queue, 11390 (void *)&cmd_flow_director_queue_id, 11391 (void *)&cmd_flow_director_fd_id, 11392 (void *)&cmd_flow_director_fd_id_value, 11393 NULL, 11394 }, 11395 }; 11396 11397 cmdline_parse_inst_t cmd_add_del_raw_flow_director = { 11398 .f = cmd_flow_director_filter_parsed, 11399 .data = NULL, 11400 .help_str = "flow_director_filter ... : Add or delete a raw flow " 11401 "director entry on NIC", 11402 .tokens = { 11403 (void *)&cmd_flow_director_filter, 11404 (void *)&cmd_flow_director_port_id, 11405 (void *)&cmd_flow_director_mode, 11406 (void *)&cmd_flow_director_mode_raw, 11407 (void *)&cmd_flow_director_ops, 11408 (void *)&cmd_flow_director_flow, 11409 (void *)&cmd_flow_director_flow_type, 11410 (void *)&cmd_flow_director_drop, 11411 (void *)&cmd_flow_director_queue, 11412 (void *)&cmd_flow_director_queue_id, 11413 (void *)&cmd_flow_director_fd_id, 11414 (void *)&cmd_flow_director_fd_id_value, 11415 (void *)&cmd_flow_director_packet, 11416 (void *)&cmd_flow_director_filepath, 11417 NULL, 11418 }, 11419 }; 11420 11421 struct cmd_flush_flow_director_result { 11422 cmdline_fixed_string_t flush_flow_director; 11423 portid_t port_id; 11424 }; 11425 11426 cmdline_parse_token_string_t cmd_flush_flow_director_flush = 11427 TOKEN_STRING_INITIALIZER(struct cmd_flush_flow_director_result, 11428 flush_flow_director, "flush_flow_director"); 11429 cmdline_parse_token_num_t cmd_flush_flow_director_port_id = 11430 TOKEN_NUM_INITIALIZER(struct cmd_flush_flow_director_result, 11431 port_id, UINT16); 11432 11433 static void 11434 cmd_flush_flow_director_parsed(void *parsed_result, 11435 __attribute__((unused)) struct cmdline *cl, 11436 __attribute__((unused)) void *data) 11437 { 11438 struct cmd_flow_director_result *res = parsed_result; 11439 int ret = 0; 11440 11441 ret = rte_eth_dev_filter_supported(res->port_id, RTE_ETH_FILTER_FDIR); 11442 if (ret < 0) { 11443 printf("flow director is not supported on port %u.\n", 11444 res->port_id); 11445 return; 11446 } 11447 11448 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_FDIR, 11449 RTE_ETH_FILTER_FLUSH, NULL); 11450 if (ret < 0) 11451 printf("flow director table flushing error: (%s)\n", 11452 strerror(-ret)); 11453 } 11454 11455 cmdline_parse_inst_t cmd_flush_flow_director = { 11456 .f = cmd_flush_flow_director_parsed, 11457 .data = NULL, 11458 .help_str = "flush_flow_director <port_id>: " 11459 "Flush all flow director entries of a device on NIC", 11460 .tokens = { 11461 (void *)&cmd_flush_flow_director_flush, 11462 (void *)&cmd_flush_flow_director_port_id, 11463 NULL, 11464 }, 11465 }; 11466 11467 /* *** deal with flow director mask *** */ 11468 struct cmd_flow_director_mask_result { 11469 cmdline_fixed_string_t flow_director_mask; 11470 portid_t port_id; 11471 cmdline_fixed_string_t mode; 11472 cmdline_fixed_string_t mode_value; 11473 cmdline_fixed_string_t vlan; 11474 uint16_t vlan_mask; 11475 cmdline_fixed_string_t src_mask; 11476 cmdline_ipaddr_t ipv4_src; 11477 cmdline_ipaddr_t ipv6_src; 11478 uint16_t port_src; 11479 cmdline_fixed_string_t dst_mask; 11480 cmdline_ipaddr_t ipv4_dst; 11481 cmdline_ipaddr_t ipv6_dst; 11482 uint16_t port_dst; 11483 cmdline_fixed_string_t mac; 11484 uint8_t mac_addr_byte_mask; 11485 cmdline_fixed_string_t tunnel_id; 11486 uint32_t tunnel_id_mask; 11487 cmdline_fixed_string_t tunnel_type; 11488 uint8_t tunnel_type_mask; 11489 }; 11490 11491 static void 11492 cmd_flow_director_mask_parsed(void *parsed_result, 11493 __attribute__((unused)) struct cmdline *cl, 11494 __attribute__((unused)) void *data) 11495 { 11496 struct cmd_flow_director_mask_result *res = parsed_result; 11497 struct rte_eth_fdir_masks *mask; 11498 struct rte_port *port; 11499 11500 port = &ports[res->port_id]; 11501 /** Check if the port is not started **/ 11502 if (port->port_status != RTE_PORT_STOPPED) { 11503 printf("Please stop port %d first\n", res->port_id); 11504 return; 11505 } 11506 11507 mask = &port->dev_conf.fdir_conf.mask; 11508 11509 if (fdir_conf.mode == RTE_FDIR_MODE_PERFECT_MAC_VLAN) { 11510 if (strcmp(res->mode_value, "MAC-VLAN")) { 11511 printf("Please set mode to MAC-VLAN.\n"); 11512 return; 11513 } 11514 11515 mask->vlan_tci_mask = rte_cpu_to_be_16(res->vlan_mask); 11516 } else if (fdir_conf.mode == RTE_FDIR_MODE_PERFECT_TUNNEL) { 11517 if (strcmp(res->mode_value, "Tunnel")) { 11518 printf("Please set mode to Tunnel.\n"); 11519 return; 11520 } 11521 11522 mask->vlan_tci_mask = rte_cpu_to_be_16(res->vlan_mask); 11523 mask->mac_addr_byte_mask = res->mac_addr_byte_mask; 11524 mask->tunnel_id_mask = rte_cpu_to_be_32(res->tunnel_id_mask); 11525 mask->tunnel_type_mask = res->tunnel_type_mask; 11526 } else { 11527 if (strcmp(res->mode_value, "IP")) { 11528 printf("Please set mode to IP.\n"); 11529 return; 11530 } 11531 11532 mask->vlan_tci_mask = rte_cpu_to_be_16(res->vlan_mask); 11533 IPV4_ADDR_TO_UINT(res->ipv4_src, mask->ipv4_mask.src_ip); 11534 IPV4_ADDR_TO_UINT(res->ipv4_dst, mask->ipv4_mask.dst_ip); 11535 IPV6_ADDR_TO_ARRAY(res->ipv6_src, mask->ipv6_mask.src_ip); 11536 IPV6_ADDR_TO_ARRAY(res->ipv6_dst, mask->ipv6_mask.dst_ip); 11537 mask->src_port_mask = rte_cpu_to_be_16(res->port_src); 11538 mask->dst_port_mask = rte_cpu_to_be_16(res->port_dst); 11539 } 11540 11541 cmd_reconfig_device_queue(res->port_id, 1, 1); 11542 } 11543 11544 cmdline_parse_token_string_t cmd_flow_director_mask = 11545 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result, 11546 flow_director_mask, "flow_director_mask"); 11547 cmdline_parse_token_num_t cmd_flow_director_mask_port_id = 11548 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_mask_result, 11549 port_id, UINT16); 11550 cmdline_parse_token_string_t cmd_flow_director_mask_vlan = 11551 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result, 11552 vlan, "vlan"); 11553 cmdline_parse_token_num_t cmd_flow_director_mask_vlan_value = 11554 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_mask_result, 11555 vlan_mask, UINT16); 11556 cmdline_parse_token_string_t cmd_flow_director_mask_src = 11557 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result, 11558 src_mask, "src_mask"); 11559 cmdline_parse_token_ipaddr_t cmd_flow_director_mask_ipv4_src = 11560 TOKEN_IPADDR_INITIALIZER(struct cmd_flow_director_mask_result, 11561 ipv4_src); 11562 cmdline_parse_token_ipaddr_t cmd_flow_director_mask_ipv6_src = 11563 TOKEN_IPADDR_INITIALIZER(struct cmd_flow_director_mask_result, 11564 ipv6_src); 11565 cmdline_parse_token_num_t cmd_flow_director_mask_port_src = 11566 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_mask_result, 11567 port_src, UINT16); 11568 cmdline_parse_token_string_t cmd_flow_director_mask_dst = 11569 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result, 11570 dst_mask, "dst_mask"); 11571 cmdline_parse_token_ipaddr_t cmd_flow_director_mask_ipv4_dst = 11572 TOKEN_IPADDR_INITIALIZER(struct cmd_flow_director_mask_result, 11573 ipv4_dst); 11574 cmdline_parse_token_ipaddr_t cmd_flow_director_mask_ipv6_dst = 11575 TOKEN_IPADDR_INITIALIZER(struct cmd_flow_director_mask_result, 11576 ipv6_dst); 11577 cmdline_parse_token_num_t cmd_flow_director_mask_port_dst = 11578 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_mask_result, 11579 port_dst, UINT16); 11580 11581 cmdline_parse_token_string_t cmd_flow_director_mask_mode = 11582 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result, 11583 mode, "mode"); 11584 cmdline_parse_token_string_t cmd_flow_director_mask_mode_ip = 11585 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result, 11586 mode_value, "IP"); 11587 cmdline_parse_token_string_t cmd_flow_director_mask_mode_mac_vlan = 11588 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result, 11589 mode_value, "MAC-VLAN"); 11590 cmdline_parse_token_string_t cmd_flow_director_mask_mode_tunnel = 11591 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result, 11592 mode_value, "Tunnel"); 11593 cmdline_parse_token_string_t cmd_flow_director_mask_mac = 11594 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result, 11595 mac, "mac"); 11596 cmdline_parse_token_num_t cmd_flow_director_mask_mac_value = 11597 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_mask_result, 11598 mac_addr_byte_mask, UINT8); 11599 cmdline_parse_token_string_t cmd_flow_director_mask_tunnel_type = 11600 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result, 11601 tunnel_type, "tunnel-type"); 11602 cmdline_parse_token_num_t cmd_flow_director_mask_tunnel_type_value = 11603 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_mask_result, 11604 tunnel_type_mask, UINT8); 11605 cmdline_parse_token_string_t cmd_flow_director_mask_tunnel_id = 11606 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result, 11607 tunnel_id, "tunnel-id"); 11608 cmdline_parse_token_num_t cmd_flow_director_mask_tunnel_id_value = 11609 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_mask_result, 11610 tunnel_id_mask, UINT32); 11611 11612 cmdline_parse_inst_t cmd_set_flow_director_ip_mask = { 11613 .f = cmd_flow_director_mask_parsed, 11614 .data = NULL, 11615 .help_str = "flow_director_mask ... : " 11616 "Set IP mode flow director's mask on NIC", 11617 .tokens = { 11618 (void *)&cmd_flow_director_mask, 11619 (void *)&cmd_flow_director_mask_port_id, 11620 (void *)&cmd_flow_director_mask_mode, 11621 (void *)&cmd_flow_director_mask_mode_ip, 11622 (void *)&cmd_flow_director_mask_vlan, 11623 (void *)&cmd_flow_director_mask_vlan_value, 11624 (void *)&cmd_flow_director_mask_src, 11625 (void *)&cmd_flow_director_mask_ipv4_src, 11626 (void *)&cmd_flow_director_mask_ipv6_src, 11627 (void *)&cmd_flow_director_mask_port_src, 11628 (void *)&cmd_flow_director_mask_dst, 11629 (void *)&cmd_flow_director_mask_ipv4_dst, 11630 (void *)&cmd_flow_director_mask_ipv6_dst, 11631 (void *)&cmd_flow_director_mask_port_dst, 11632 NULL, 11633 }, 11634 }; 11635 11636 cmdline_parse_inst_t cmd_set_flow_director_mac_vlan_mask = { 11637 .f = cmd_flow_director_mask_parsed, 11638 .data = NULL, 11639 .help_str = "flow_director_mask ... : Set MAC VLAN mode " 11640 "flow director's mask on NIC", 11641 .tokens = { 11642 (void *)&cmd_flow_director_mask, 11643 (void *)&cmd_flow_director_mask_port_id, 11644 (void *)&cmd_flow_director_mask_mode, 11645 (void *)&cmd_flow_director_mask_mode_mac_vlan, 11646 (void *)&cmd_flow_director_mask_vlan, 11647 (void *)&cmd_flow_director_mask_vlan_value, 11648 NULL, 11649 }, 11650 }; 11651 11652 cmdline_parse_inst_t cmd_set_flow_director_tunnel_mask = { 11653 .f = cmd_flow_director_mask_parsed, 11654 .data = NULL, 11655 .help_str = "flow_director_mask ... : Set tunnel mode " 11656 "flow director's mask on NIC", 11657 .tokens = { 11658 (void *)&cmd_flow_director_mask, 11659 (void *)&cmd_flow_director_mask_port_id, 11660 (void *)&cmd_flow_director_mask_mode, 11661 (void *)&cmd_flow_director_mask_mode_tunnel, 11662 (void *)&cmd_flow_director_mask_vlan, 11663 (void *)&cmd_flow_director_mask_vlan_value, 11664 (void *)&cmd_flow_director_mask_mac, 11665 (void *)&cmd_flow_director_mask_mac_value, 11666 (void *)&cmd_flow_director_mask_tunnel_type, 11667 (void *)&cmd_flow_director_mask_tunnel_type_value, 11668 (void *)&cmd_flow_director_mask_tunnel_id, 11669 (void *)&cmd_flow_director_mask_tunnel_id_value, 11670 NULL, 11671 }, 11672 }; 11673 11674 /* *** deal with flow director mask on flexible payload *** */ 11675 struct cmd_flow_director_flex_mask_result { 11676 cmdline_fixed_string_t flow_director_flexmask; 11677 portid_t port_id; 11678 cmdline_fixed_string_t flow; 11679 cmdline_fixed_string_t flow_type; 11680 cmdline_fixed_string_t mask; 11681 }; 11682 11683 static void 11684 cmd_flow_director_flex_mask_parsed(void *parsed_result, 11685 __attribute__((unused)) struct cmdline *cl, 11686 __attribute__((unused)) void *data) 11687 { 11688 struct cmd_flow_director_flex_mask_result *res = parsed_result; 11689 struct rte_eth_fdir_info fdir_info; 11690 struct rte_eth_fdir_flex_mask flex_mask; 11691 struct rte_port *port; 11692 uint64_t flow_type_mask; 11693 uint16_t i; 11694 int ret; 11695 11696 port = &ports[res->port_id]; 11697 /** Check if the port is not started **/ 11698 if (port->port_status != RTE_PORT_STOPPED) { 11699 printf("Please stop port %d first\n", res->port_id); 11700 return; 11701 } 11702 11703 memset(&flex_mask, 0, sizeof(struct rte_eth_fdir_flex_mask)); 11704 ret = parse_flexbytes(res->mask, 11705 flex_mask.mask, 11706 RTE_ETH_FDIR_MAX_FLEXLEN); 11707 if (ret < 0) { 11708 printf("error: Cannot parse mask input.\n"); 11709 return; 11710 } 11711 11712 memset(&fdir_info, 0, sizeof(fdir_info)); 11713 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_FDIR, 11714 RTE_ETH_FILTER_INFO, &fdir_info); 11715 if (ret < 0) { 11716 printf("Cannot get FDir filter info\n"); 11717 return; 11718 } 11719 11720 if (!strcmp(res->flow_type, "none")) { 11721 /* means don't specify the flow type */ 11722 flex_mask.flow_type = RTE_ETH_FLOW_UNKNOWN; 11723 for (i = 0; i < RTE_ETH_FLOW_MAX; i++) 11724 memset(&port->dev_conf.fdir_conf.flex_conf.flex_mask[i], 11725 0, sizeof(struct rte_eth_fdir_flex_mask)); 11726 port->dev_conf.fdir_conf.flex_conf.nb_flexmasks = 1; 11727 rte_memcpy(&port->dev_conf.fdir_conf.flex_conf.flex_mask[0], 11728 &flex_mask, 11729 sizeof(struct rte_eth_fdir_flex_mask)); 11730 cmd_reconfig_device_queue(res->port_id, 1, 1); 11731 return; 11732 } 11733 flow_type_mask = fdir_info.flow_types_mask[0]; 11734 if (!strcmp(res->flow_type, "all")) { 11735 if (!flow_type_mask) { 11736 printf("No flow type supported\n"); 11737 return; 11738 } 11739 for (i = RTE_ETH_FLOW_UNKNOWN; i < RTE_ETH_FLOW_MAX; i++) { 11740 if (flow_type_mask & (1ULL << i)) { 11741 flex_mask.flow_type = i; 11742 fdir_set_flex_mask(res->port_id, &flex_mask); 11743 } 11744 } 11745 cmd_reconfig_device_queue(res->port_id, 1, 1); 11746 return; 11747 } 11748 flex_mask.flow_type = str2flowtype(res->flow_type); 11749 if (!(flow_type_mask & (1ULL << flex_mask.flow_type))) { 11750 printf("Flow type %s not supported on port %d\n", 11751 res->flow_type, res->port_id); 11752 return; 11753 } 11754 fdir_set_flex_mask(res->port_id, &flex_mask); 11755 cmd_reconfig_device_queue(res->port_id, 1, 1); 11756 } 11757 11758 cmdline_parse_token_string_t cmd_flow_director_flexmask = 11759 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_flex_mask_result, 11760 flow_director_flexmask, 11761 "flow_director_flex_mask"); 11762 cmdline_parse_token_num_t cmd_flow_director_flexmask_port_id = 11763 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_flex_mask_result, 11764 port_id, UINT16); 11765 cmdline_parse_token_string_t cmd_flow_director_flexmask_flow = 11766 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_flex_mask_result, 11767 flow, "flow"); 11768 cmdline_parse_token_string_t cmd_flow_director_flexmask_flow_type = 11769 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_flex_mask_result, 11770 flow_type, "none#ipv4-other#ipv4-frag#ipv4-tcp#ipv4-udp#ipv4-sctp#" 11771 "ipv6-other#ipv6-frag#ipv6-tcp#ipv6-udp#ipv6-sctp#l2_payload#all"); 11772 cmdline_parse_token_string_t cmd_flow_director_flexmask_mask = 11773 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_flex_mask_result, 11774 mask, NULL); 11775 11776 cmdline_parse_inst_t cmd_set_flow_director_flex_mask = { 11777 .f = cmd_flow_director_flex_mask_parsed, 11778 .data = NULL, 11779 .help_str = "flow_director_flex_mask ... : " 11780 "Set flow director's flex mask on NIC", 11781 .tokens = { 11782 (void *)&cmd_flow_director_flexmask, 11783 (void *)&cmd_flow_director_flexmask_port_id, 11784 (void *)&cmd_flow_director_flexmask_flow, 11785 (void *)&cmd_flow_director_flexmask_flow_type, 11786 (void *)&cmd_flow_director_flexmask_mask, 11787 NULL, 11788 }, 11789 }; 11790 11791 /* *** deal with flow director flexible payload configuration *** */ 11792 struct cmd_flow_director_flexpayload_result { 11793 cmdline_fixed_string_t flow_director_flexpayload; 11794 portid_t port_id; 11795 cmdline_fixed_string_t payload_layer; 11796 cmdline_fixed_string_t payload_cfg; 11797 }; 11798 11799 static inline int 11800 parse_offsets(const char *q_arg, uint16_t *offsets, uint16_t max_num) 11801 { 11802 char s[256]; 11803 const char *p, *p0 = q_arg; 11804 char *end; 11805 unsigned long int_fld; 11806 char *str_fld[max_num]; 11807 int i; 11808 unsigned size; 11809 int ret = -1; 11810 11811 p = strchr(p0, '('); 11812 if (p == NULL) 11813 return -1; 11814 ++p; 11815 p0 = strchr(p, ')'); 11816 if (p0 == NULL) 11817 return -1; 11818 11819 size = p0 - p; 11820 if (size >= sizeof(s)) 11821 return -1; 11822 11823 snprintf(s, sizeof(s), "%.*s", size, p); 11824 ret = rte_strsplit(s, sizeof(s), str_fld, max_num, ','); 11825 if (ret < 0 || ret > max_num) 11826 return -1; 11827 for (i = 0; i < ret; i++) { 11828 errno = 0; 11829 int_fld = strtoul(str_fld[i], &end, 0); 11830 if (errno != 0 || *end != '\0' || int_fld > UINT16_MAX) 11831 return -1; 11832 offsets[i] = (uint16_t)int_fld; 11833 } 11834 return ret; 11835 } 11836 11837 static void 11838 cmd_flow_director_flxpld_parsed(void *parsed_result, 11839 __attribute__((unused)) struct cmdline *cl, 11840 __attribute__((unused)) void *data) 11841 { 11842 struct cmd_flow_director_flexpayload_result *res = parsed_result; 11843 struct rte_eth_flex_payload_cfg flex_cfg; 11844 struct rte_port *port; 11845 int ret = 0; 11846 11847 port = &ports[res->port_id]; 11848 /** Check if the port is not started **/ 11849 if (port->port_status != RTE_PORT_STOPPED) { 11850 printf("Please stop port %d first\n", res->port_id); 11851 return; 11852 } 11853 11854 memset(&flex_cfg, 0, sizeof(struct rte_eth_flex_payload_cfg)); 11855 11856 if (!strcmp(res->payload_layer, "raw")) 11857 flex_cfg.type = RTE_ETH_RAW_PAYLOAD; 11858 else if (!strcmp(res->payload_layer, "l2")) 11859 flex_cfg.type = RTE_ETH_L2_PAYLOAD; 11860 else if (!strcmp(res->payload_layer, "l3")) 11861 flex_cfg.type = RTE_ETH_L3_PAYLOAD; 11862 else if (!strcmp(res->payload_layer, "l4")) 11863 flex_cfg.type = RTE_ETH_L4_PAYLOAD; 11864 11865 ret = parse_offsets(res->payload_cfg, flex_cfg.src_offset, 11866 RTE_ETH_FDIR_MAX_FLEXLEN); 11867 if (ret < 0) { 11868 printf("error: Cannot parse flex payload input.\n"); 11869 return; 11870 } 11871 11872 fdir_set_flex_payload(res->port_id, &flex_cfg); 11873 cmd_reconfig_device_queue(res->port_id, 1, 1); 11874 } 11875 11876 cmdline_parse_token_string_t cmd_flow_director_flexpayload = 11877 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_flexpayload_result, 11878 flow_director_flexpayload, 11879 "flow_director_flex_payload"); 11880 cmdline_parse_token_num_t cmd_flow_director_flexpayload_port_id = 11881 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_flexpayload_result, 11882 port_id, UINT16); 11883 cmdline_parse_token_string_t cmd_flow_director_flexpayload_payload_layer = 11884 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_flexpayload_result, 11885 payload_layer, "raw#l2#l3#l4"); 11886 cmdline_parse_token_string_t cmd_flow_director_flexpayload_payload_cfg = 11887 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_flexpayload_result, 11888 payload_cfg, NULL); 11889 11890 cmdline_parse_inst_t cmd_set_flow_director_flex_payload = { 11891 .f = cmd_flow_director_flxpld_parsed, 11892 .data = NULL, 11893 .help_str = "flow_director_flexpayload ... : " 11894 "Set flow director's flex payload on NIC", 11895 .tokens = { 11896 (void *)&cmd_flow_director_flexpayload, 11897 (void *)&cmd_flow_director_flexpayload_port_id, 11898 (void *)&cmd_flow_director_flexpayload_payload_layer, 11899 (void *)&cmd_flow_director_flexpayload_payload_cfg, 11900 NULL, 11901 }, 11902 }; 11903 11904 /* Generic flow interface command. */ 11905 extern cmdline_parse_inst_t cmd_flow; 11906 11907 /* *** Classification Filters Control *** */ 11908 /* *** Get symmetric hash enable per port *** */ 11909 struct cmd_get_sym_hash_ena_per_port_result { 11910 cmdline_fixed_string_t get_sym_hash_ena_per_port; 11911 portid_t port_id; 11912 }; 11913 11914 static void 11915 cmd_get_sym_hash_per_port_parsed(void *parsed_result, 11916 __rte_unused struct cmdline *cl, 11917 __rte_unused void *data) 11918 { 11919 struct cmd_get_sym_hash_ena_per_port_result *res = parsed_result; 11920 struct rte_eth_hash_filter_info info; 11921 int ret; 11922 11923 if (rte_eth_dev_filter_supported(res->port_id, 11924 RTE_ETH_FILTER_HASH) < 0) { 11925 printf("RTE_ETH_FILTER_HASH not supported on port: %d\n", 11926 res->port_id); 11927 return; 11928 } 11929 11930 memset(&info, 0, sizeof(info)); 11931 info.info_type = RTE_ETH_HASH_FILTER_SYM_HASH_ENA_PER_PORT; 11932 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_HASH, 11933 RTE_ETH_FILTER_GET, &info); 11934 11935 if (ret < 0) { 11936 printf("Cannot get symmetric hash enable per port " 11937 "on port %u\n", res->port_id); 11938 return; 11939 } 11940 11941 printf("Symmetric hash is %s on port %u\n", info.info.enable ? 11942 "enabled" : "disabled", res->port_id); 11943 } 11944 11945 cmdline_parse_token_string_t cmd_get_sym_hash_ena_per_port_all = 11946 TOKEN_STRING_INITIALIZER(struct cmd_get_sym_hash_ena_per_port_result, 11947 get_sym_hash_ena_per_port, "get_sym_hash_ena_per_port"); 11948 cmdline_parse_token_num_t cmd_get_sym_hash_ena_per_port_port_id = 11949 TOKEN_NUM_INITIALIZER(struct cmd_get_sym_hash_ena_per_port_result, 11950 port_id, UINT16); 11951 11952 cmdline_parse_inst_t cmd_get_sym_hash_ena_per_port = { 11953 .f = cmd_get_sym_hash_per_port_parsed, 11954 .data = NULL, 11955 .help_str = "get_sym_hash_ena_per_port <port_id>", 11956 .tokens = { 11957 (void *)&cmd_get_sym_hash_ena_per_port_all, 11958 (void *)&cmd_get_sym_hash_ena_per_port_port_id, 11959 NULL, 11960 }, 11961 }; 11962 11963 /* *** Set symmetric hash enable per port *** */ 11964 struct cmd_set_sym_hash_ena_per_port_result { 11965 cmdline_fixed_string_t set_sym_hash_ena_per_port; 11966 cmdline_fixed_string_t enable; 11967 portid_t port_id; 11968 }; 11969 11970 static void 11971 cmd_set_sym_hash_per_port_parsed(void *parsed_result, 11972 __rte_unused struct cmdline *cl, 11973 __rte_unused void *data) 11974 { 11975 struct cmd_set_sym_hash_ena_per_port_result *res = parsed_result; 11976 struct rte_eth_hash_filter_info info; 11977 int ret; 11978 11979 if (rte_eth_dev_filter_supported(res->port_id, 11980 RTE_ETH_FILTER_HASH) < 0) { 11981 printf("RTE_ETH_FILTER_HASH not supported on port: %d\n", 11982 res->port_id); 11983 return; 11984 } 11985 11986 memset(&info, 0, sizeof(info)); 11987 info.info_type = RTE_ETH_HASH_FILTER_SYM_HASH_ENA_PER_PORT; 11988 if (!strcmp(res->enable, "enable")) 11989 info.info.enable = 1; 11990 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_HASH, 11991 RTE_ETH_FILTER_SET, &info); 11992 if (ret < 0) { 11993 printf("Cannot set symmetric hash enable per port on " 11994 "port %u\n", res->port_id); 11995 return; 11996 } 11997 printf("Symmetric hash has been set to %s on port %u\n", 11998 res->enable, res->port_id); 11999 } 12000 12001 cmdline_parse_token_string_t cmd_set_sym_hash_ena_per_port_all = 12002 TOKEN_STRING_INITIALIZER(struct cmd_set_sym_hash_ena_per_port_result, 12003 set_sym_hash_ena_per_port, "set_sym_hash_ena_per_port"); 12004 cmdline_parse_token_num_t cmd_set_sym_hash_ena_per_port_port_id = 12005 TOKEN_NUM_INITIALIZER(struct cmd_set_sym_hash_ena_per_port_result, 12006 port_id, UINT16); 12007 cmdline_parse_token_string_t cmd_set_sym_hash_ena_per_port_enable = 12008 TOKEN_STRING_INITIALIZER(struct cmd_set_sym_hash_ena_per_port_result, 12009 enable, "enable#disable"); 12010 12011 cmdline_parse_inst_t cmd_set_sym_hash_ena_per_port = { 12012 .f = cmd_set_sym_hash_per_port_parsed, 12013 .data = NULL, 12014 .help_str = "set_sym_hash_ena_per_port <port_id> enable|disable", 12015 .tokens = { 12016 (void *)&cmd_set_sym_hash_ena_per_port_all, 12017 (void *)&cmd_set_sym_hash_ena_per_port_port_id, 12018 (void *)&cmd_set_sym_hash_ena_per_port_enable, 12019 NULL, 12020 }, 12021 }; 12022 12023 /* Get global config of hash function */ 12024 struct cmd_get_hash_global_config_result { 12025 cmdline_fixed_string_t get_hash_global_config; 12026 portid_t port_id; 12027 }; 12028 12029 static char * 12030 flowtype_to_str(uint16_t ftype) 12031 { 12032 uint16_t i; 12033 static struct { 12034 char str[16]; 12035 uint16_t ftype; 12036 } ftype_table[] = { 12037 {"ipv4", RTE_ETH_FLOW_IPV4}, 12038 {"ipv4-frag", RTE_ETH_FLOW_FRAG_IPV4}, 12039 {"ipv4-tcp", RTE_ETH_FLOW_NONFRAG_IPV4_TCP}, 12040 {"ipv4-udp", RTE_ETH_FLOW_NONFRAG_IPV4_UDP}, 12041 {"ipv4-sctp", RTE_ETH_FLOW_NONFRAG_IPV4_SCTP}, 12042 {"ipv4-other", RTE_ETH_FLOW_NONFRAG_IPV4_OTHER}, 12043 {"ipv6", RTE_ETH_FLOW_IPV6}, 12044 {"ipv6-frag", RTE_ETH_FLOW_FRAG_IPV6}, 12045 {"ipv6-tcp", RTE_ETH_FLOW_NONFRAG_IPV6_TCP}, 12046 {"ipv6-udp", RTE_ETH_FLOW_NONFRAG_IPV6_UDP}, 12047 {"ipv6-sctp", RTE_ETH_FLOW_NONFRAG_IPV6_SCTP}, 12048 {"ipv6-other", RTE_ETH_FLOW_NONFRAG_IPV6_OTHER}, 12049 {"l2_payload", RTE_ETH_FLOW_L2_PAYLOAD}, 12050 {"port", RTE_ETH_FLOW_PORT}, 12051 {"vxlan", RTE_ETH_FLOW_VXLAN}, 12052 {"geneve", RTE_ETH_FLOW_GENEVE}, 12053 {"nvgre", RTE_ETH_FLOW_NVGRE}, 12054 }; 12055 12056 for (i = 0; i < RTE_DIM(ftype_table); i++) { 12057 if (ftype_table[i].ftype == ftype) 12058 return ftype_table[i].str; 12059 } 12060 12061 return NULL; 12062 } 12063 12064 static void 12065 cmd_get_hash_global_config_parsed(void *parsed_result, 12066 __rte_unused struct cmdline *cl, 12067 __rte_unused void *data) 12068 { 12069 struct cmd_get_hash_global_config_result *res = parsed_result; 12070 struct rte_eth_hash_filter_info info; 12071 uint32_t idx, offset; 12072 uint16_t i; 12073 char *str; 12074 int ret; 12075 12076 if (rte_eth_dev_filter_supported(res->port_id, 12077 RTE_ETH_FILTER_HASH) < 0) { 12078 printf("RTE_ETH_FILTER_HASH not supported on port %d\n", 12079 res->port_id); 12080 return; 12081 } 12082 12083 memset(&info, 0, sizeof(info)); 12084 info.info_type = RTE_ETH_HASH_FILTER_GLOBAL_CONFIG; 12085 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_HASH, 12086 RTE_ETH_FILTER_GET, &info); 12087 if (ret < 0) { 12088 printf("Cannot get hash global configurations by port %d\n", 12089 res->port_id); 12090 return; 12091 } 12092 12093 switch (info.info.global_conf.hash_func) { 12094 case RTE_ETH_HASH_FUNCTION_TOEPLITZ: 12095 printf("Hash function is Toeplitz\n"); 12096 break; 12097 case RTE_ETH_HASH_FUNCTION_SIMPLE_XOR: 12098 printf("Hash function is Simple XOR\n"); 12099 break; 12100 default: 12101 printf("Unknown hash function\n"); 12102 break; 12103 } 12104 12105 for (i = 0; i < RTE_ETH_FLOW_MAX; i++) { 12106 idx = i / UINT64_BIT; 12107 offset = i % UINT64_BIT; 12108 if (!(info.info.global_conf.valid_bit_mask[idx] & 12109 (1ULL << offset))) 12110 continue; 12111 str = flowtype_to_str(i); 12112 if (!str) 12113 continue; 12114 printf("Symmetric hash is %s globally for flow type %s " 12115 "by port %d\n", 12116 ((info.info.global_conf.sym_hash_enable_mask[idx] & 12117 (1ULL << offset)) ? "enabled" : "disabled"), str, 12118 res->port_id); 12119 } 12120 } 12121 12122 cmdline_parse_token_string_t cmd_get_hash_global_config_all = 12123 TOKEN_STRING_INITIALIZER(struct cmd_get_hash_global_config_result, 12124 get_hash_global_config, "get_hash_global_config"); 12125 cmdline_parse_token_num_t cmd_get_hash_global_config_port_id = 12126 TOKEN_NUM_INITIALIZER(struct cmd_get_hash_global_config_result, 12127 port_id, UINT16); 12128 12129 cmdline_parse_inst_t cmd_get_hash_global_config = { 12130 .f = cmd_get_hash_global_config_parsed, 12131 .data = NULL, 12132 .help_str = "get_hash_global_config <port_id>", 12133 .tokens = { 12134 (void *)&cmd_get_hash_global_config_all, 12135 (void *)&cmd_get_hash_global_config_port_id, 12136 NULL, 12137 }, 12138 }; 12139 12140 /* Set global config of hash function */ 12141 struct cmd_set_hash_global_config_result { 12142 cmdline_fixed_string_t set_hash_global_config; 12143 portid_t port_id; 12144 cmdline_fixed_string_t hash_func; 12145 cmdline_fixed_string_t flow_type; 12146 cmdline_fixed_string_t enable; 12147 }; 12148 12149 static void 12150 cmd_set_hash_global_config_parsed(void *parsed_result, 12151 __rte_unused struct cmdline *cl, 12152 __rte_unused void *data) 12153 { 12154 struct cmd_set_hash_global_config_result *res = parsed_result; 12155 struct rte_eth_hash_filter_info info; 12156 uint32_t ftype, idx, offset; 12157 int ret; 12158 12159 if (rte_eth_dev_filter_supported(res->port_id, 12160 RTE_ETH_FILTER_HASH) < 0) { 12161 printf("RTE_ETH_FILTER_HASH not supported on port %d\n", 12162 res->port_id); 12163 return; 12164 } 12165 memset(&info, 0, sizeof(info)); 12166 info.info_type = RTE_ETH_HASH_FILTER_GLOBAL_CONFIG; 12167 if (!strcmp(res->hash_func, "toeplitz")) 12168 info.info.global_conf.hash_func = 12169 RTE_ETH_HASH_FUNCTION_TOEPLITZ; 12170 else if (!strcmp(res->hash_func, "simple_xor")) 12171 info.info.global_conf.hash_func = 12172 RTE_ETH_HASH_FUNCTION_SIMPLE_XOR; 12173 else if (!strcmp(res->hash_func, "default")) 12174 info.info.global_conf.hash_func = 12175 RTE_ETH_HASH_FUNCTION_DEFAULT; 12176 12177 ftype = str2flowtype(res->flow_type); 12178 idx = ftype / UINT64_BIT; 12179 offset = ftype % UINT64_BIT; 12180 info.info.global_conf.valid_bit_mask[idx] |= (1ULL << offset); 12181 if (!strcmp(res->enable, "enable")) 12182 info.info.global_conf.sym_hash_enable_mask[idx] |= 12183 (1ULL << offset); 12184 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_HASH, 12185 RTE_ETH_FILTER_SET, &info); 12186 if (ret < 0) 12187 printf("Cannot set global hash configurations by port %d\n", 12188 res->port_id); 12189 else 12190 printf("Global hash configurations have been set " 12191 "successfully by port %d\n", res->port_id); 12192 } 12193 12194 cmdline_parse_token_string_t cmd_set_hash_global_config_all = 12195 TOKEN_STRING_INITIALIZER(struct cmd_set_hash_global_config_result, 12196 set_hash_global_config, "set_hash_global_config"); 12197 cmdline_parse_token_num_t cmd_set_hash_global_config_port_id = 12198 TOKEN_NUM_INITIALIZER(struct cmd_set_hash_global_config_result, 12199 port_id, UINT16); 12200 cmdline_parse_token_string_t cmd_set_hash_global_config_hash_func = 12201 TOKEN_STRING_INITIALIZER(struct cmd_set_hash_global_config_result, 12202 hash_func, "toeplitz#simple_xor#default"); 12203 cmdline_parse_token_string_t cmd_set_hash_global_config_flow_type = 12204 TOKEN_STRING_INITIALIZER(struct cmd_set_hash_global_config_result, 12205 flow_type, 12206 "ipv4#ipv4-frag#ipv4-tcp#ipv4-udp#ipv4-sctp#ipv4-other#ipv6#" 12207 "ipv6-frag#ipv6-tcp#ipv6-udp#ipv6-sctp#ipv6-other#l2_payload"); 12208 cmdline_parse_token_string_t cmd_set_hash_global_config_enable = 12209 TOKEN_STRING_INITIALIZER(struct cmd_set_hash_global_config_result, 12210 enable, "enable#disable"); 12211 12212 cmdline_parse_inst_t cmd_set_hash_global_config = { 12213 .f = cmd_set_hash_global_config_parsed, 12214 .data = NULL, 12215 .help_str = "set_hash_global_config <port_id> " 12216 "toeplitz|simple_xor|default " 12217 "ipv4|ipv4-frag|ipv4-tcp|ipv4-udp|ipv4-sctp|ipv4-other|" 12218 "ipv6|ipv6-frag|ipv6-tcp|ipv6-udp|ipv6-sctp|ipv6-other|" 12219 "l2_payload enable|disable", 12220 .tokens = { 12221 (void *)&cmd_set_hash_global_config_all, 12222 (void *)&cmd_set_hash_global_config_port_id, 12223 (void *)&cmd_set_hash_global_config_hash_func, 12224 (void *)&cmd_set_hash_global_config_flow_type, 12225 (void *)&cmd_set_hash_global_config_enable, 12226 NULL, 12227 }, 12228 }; 12229 12230 /* Set hash input set */ 12231 struct cmd_set_hash_input_set_result { 12232 cmdline_fixed_string_t set_hash_input_set; 12233 portid_t port_id; 12234 cmdline_fixed_string_t flow_type; 12235 cmdline_fixed_string_t inset_field; 12236 cmdline_fixed_string_t select; 12237 }; 12238 12239 static enum rte_eth_input_set_field 12240 str2inset(char *string) 12241 { 12242 uint16_t i; 12243 12244 static const struct { 12245 char str[32]; 12246 enum rte_eth_input_set_field inset; 12247 } inset_table[] = { 12248 {"ethertype", RTE_ETH_INPUT_SET_L2_ETHERTYPE}, 12249 {"ovlan", RTE_ETH_INPUT_SET_L2_OUTER_VLAN}, 12250 {"ivlan", RTE_ETH_INPUT_SET_L2_INNER_VLAN}, 12251 {"src-ipv4", RTE_ETH_INPUT_SET_L3_SRC_IP4}, 12252 {"dst-ipv4", RTE_ETH_INPUT_SET_L3_DST_IP4}, 12253 {"ipv4-tos", RTE_ETH_INPUT_SET_L3_IP4_TOS}, 12254 {"ipv4-proto", RTE_ETH_INPUT_SET_L3_IP4_PROTO}, 12255 {"ipv4-ttl", RTE_ETH_INPUT_SET_L3_IP4_TTL}, 12256 {"src-ipv6", RTE_ETH_INPUT_SET_L3_SRC_IP6}, 12257 {"dst-ipv6", RTE_ETH_INPUT_SET_L3_DST_IP6}, 12258 {"ipv6-tc", RTE_ETH_INPUT_SET_L3_IP6_TC}, 12259 {"ipv6-next-header", RTE_ETH_INPUT_SET_L3_IP6_NEXT_HEADER}, 12260 {"ipv6-hop-limits", RTE_ETH_INPUT_SET_L3_IP6_HOP_LIMITS}, 12261 {"udp-src-port", RTE_ETH_INPUT_SET_L4_UDP_SRC_PORT}, 12262 {"udp-dst-port", RTE_ETH_INPUT_SET_L4_UDP_DST_PORT}, 12263 {"tcp-src-port", RTE_ETH_INPUT_SET_L4_TCP_SRC_PORT}, 12264 {"tcp-dst-port", RTE_ETH_INPUT_SET_L4_TCP_DST_PORT}, 12265 {"sctp-src-port", RTE_ETH_INPUT_SET_L4_SCTP_SRC_PORT}, 12266 {"sctp-dst-port", RTE_ETH_INPUT_SET_L4_SCTP_DST_PORT}, 12267 {"sctp-veri-tag", RTE_ETH_INPUT_SET_L4_SCTP_VERIFICATION_TAG}, 12268 {"udp-key", RTE_ETH_INPUT_SET_TUNNEL_L4_UDP_KEY}, 12269 {"gre-key", RTE_ETH_INPUT_SET_TUNNEL_GRE_KEY}, 12270 {"fld-1st", RTE_ETH_INPUT_SET_FLEX_PAYLOAD_1ST_WORD}, 12271 {"fld-2nd", RTE_ETH_INPUT_SET_FLEX_PAYLOAD_2ND_WORD}, 12272 {"fld-3rd", RTE_ETH_INPUT_SET_FLEX_PAYLOAD_3RD_WORD}, 12273 {"fld-4th", RTE_ETH_INPUT_SET_FLEX_PAYLOAD_4TH_WORD}, 12274 {"fld-5th", RTE_ETH_INPUT_SET_FLEX_PAYLOAD_5TH_WORD}, 12275 {"fld-6th", RTE_ETH_INPUT_SET_FLEX_PAYLOAD_6TH_WORD}, 12276 {"fld-7th", RTE_ETH_INPUT_SET_FLEX_PAYLOAD_7TH_WORD}, 12277 {"fld-8th", RTE_ETH_INPUT_SET_FLEX_PAYLOAD_8TH_WORD}, 12278 {"none", RTE_ETH_INPUT_SET_NONE}, 12279 }; 12280 12281 for (i = 0; i < RTE_DIM(inset_table); i++) { 12282 if (!strcmp(string, inset_table[i].str)) 12283 return inset_table[i].inset; 12284 } 12285 12286 return RTE_ETH_INPUT_SET_UNKNOWN; 12287 } 12288 12289 static void 12290 cmd_set_hash_input_set_parsed(void *parsed_result, 12291 __rte_unused struct cmdline *cl, 12292 __rte_unused void *data) 12293 { 12294 struct cmd_set_hash_input_set_result *res = parsed_result; 12295 struct rte_eth_hash_filter_info info; 12296 12297 memset(&info, 0, sizeof(info)); 12298 info.info_type = RTE_ETH_HASH_FILTER_INPUT_SET_SELECT; 12299 info.info.input_set_conf.flow_type = str2flowtype(res->flow_type); 12300 info.info.input_set_conf.field[0] = str2inset(res->inset_field); 12301 info.info.input_set_conf.inset_size = 1; 12302 if (!strcmp(res->select, "select")) 12303 info.info.input_set_conf.op = RTE_ETH_INPUT_SET_SELECT; 12304 else if (!strcmp(res->select, "add")) 12305 info.info.input_set_conf.op = RTE_ETH_INPUT_SET_ADD; 12306 rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_HASH, 12307 RTE_ETH_FILTER_SET, &info); 12308 } 12309 12310 cmdline_parse_token_string_t cmd_set_hash_input_set_cmd = 12311 TOKEN_STRING_INITIALIZER(struct cmd_set_hash_input_set_result, 12312 set_hash_input_set, "set_hash_input_set"); 12313 cmdline_parse_token_num_t cmd_set_hash_input_set_port_id = 12314 TOKEN_NUM_INITIALIZER(struct cmd_set_hash_input_set_result, 12315 port_id, UINT16); 12316 cmdline_parse_token_string_t cmd_set_hash_input_set_flow_type = 12317 TOKEN_STRING_INITIALIZER(struct cmd_set_hash_input_set_result, 12318 flow_type, NULL); 12319 cmdline_parse_token_string_t cmd_set_hash_input_set_field = 12320 TOKEN_STRING_INITIALIZER(struct cmd_set_hash_input_set_result, 12321 inset_field, 12322 "ovlan#ivlan#src-ipv4#dst-ipv4#src-ipv6#dst-ipv6#" 12323 "ipv4-tos#ipv4-proto#ipv6-tc#ipv6-next-header#udp-src-port#" 12324 "udp-dst-port#tcp-src-port#tcp-dst-port#sctp-src-port#" 12325 "sctp-dst-port#sctp-veri-tag#udp-key#gre-key#fld-1st#" 12326 "fld-2nd#fld-3rd#fld-4th#fld-5th#fld-6th#fld-7th#" 12327 "fld-8th#none"); 12328 cmdline_parse_token_string_t cmd_set_hash_input_set_select = 12329 TOKEN_STRING_INITIALIZER(struct cmd_set_hash_input_set_result, 12330 select, "select#add"); 12331 12332 cmdline_parse_inst_t cmd_set_hash_input_set = { 12333 .f = cmd_set_hash_input_set_parsed, 12334 .data = NULL, 12335 .help_str = "set_hash_input_set <port_id> " 12336 "ipv4-frag|ipv4-tcp|ipv4-udp|ipv4-sctp|ipv4-other|" 12337 "ipv6-frag|ipv6-tcp|ipv6-udp|ipv6-sctp|ipv6-other|l2_payload|<flowtype_id> " 12338 "ovlan|ivlan|src-ipv4|dst-ipv4|src-ipv6|dst-ipv6|ipv4-tos|ipv4-proto|" 12339 "ipv6-tc|ipv6-next-header|udp-src-port|udp-dst-port|tcp-src-port|" 12340 "tcp-dst-port|sctp-src-port|sctp-dst-port|sctp-veri-tag|udp-key|" 12341 "gre-key|fld-1st|fld-2nd|fld-3rd|fld-4th|fld-5th|fld-6th|" 12342 "fld-7th|fld-8th|none select|add", 12343 .tokens = { 12344 (void *)&cmd_set_hash_input_set_cmd, 12345 (void *)&cmd_set_hash_input_set_port_id, 12346 (void *)&cmd_set_hash_input_set_flow_type, 12347 (void *)&cmd_set_hash_input_set_field, 12348 (void *)&cmd_set_hash_input_set_select, 12349 NULL, 12350 }, 12351 }; 12352 12353 /* Set flow director input set */ 12354 struct cmd_set_fdir_input_set_result { 12355 cmdline_fixed_string_t set_fdir_input_set; 12356 portid_t port_id; 12357 cmdline_fixed_string_t flow_type; 12358 cmdline_fixed_string_t inset_field; 12359 cmdline_fixed_string_t select; 12360 }; 12361 12362 static void 12363 cmd_set_fdir_input_set_parsed(void *parsed_result, 12364 __rte_unused struct cmdline *cl, 12365 __rte_unused void *data) 12366 { 12367 struct cmd_set_fdir_input_set_result *res = parsed_result; 12368 struct rte_eth_fdir_filter_info info; 12369 12370 memset(&info, 0, sizeof(info)); 12371 info.info_type = RTE_ETH_FDIR_FILTER_INPUT_SET_SELECT; 12372 info.info.input_set_conf.flow_type = str2flowtype(res->flow_type); 12373 info.info.input_set_conf.field[0] = str2inset(res->inset_field); 12374 info.info.input_set_conf.inset_size = 1; 12375 if (!strcmp(res->select, "select")) 12376 info.info.input_set_conf.op = RTE_ETH_INPUT_SET_SELECT; 12377 else if (!strcmp(res->select, "add")) 12378 info.info.input_set_conf.op = RTE_ETH_INPUT_SET_ADD; 12379 rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_FDIR, 12380 RTE_ETH_FILTER_SET, &info); 12381 } 12382 12383 cmdline_parse_token_string_t cmd_set_fdir_input_set_cmd = 12384 TOKEN_STRING_INITIALIZER(struct cmd_set_fdir_input_set_result, 12385 set_fdir_input_set, "set_fdir_input_set"); 12386 cmdline_parse_token_num_t cmd_set_fdir_input_set_port_id = 12387 TOKEN_NUM_INITIALIZER(struct cmd_set_fdir_input_set_result, 12388 port_id, UINT16); 12389 cmdline_parse_token_string_t cmd_set_fdir_input_set_flow_type = 12390 TOKEN_STRING_INITIALIZER(struct cmd_set_fdir_input_set_result, 12391 flow_type, 12392 "ipv4-frag#ipv4-tcp#ipv4-udp#ipv4-sctp#ipv4-other#" 12393 "ipv6-frag#ipv6-tcp#ipv6-udp#ipv6-sctp#ipv6-other#l2_payload"); 12394 cmdline_parse_token_string_t cmd_set_fdir_input_set_field = 12395 TOKEN_STRING_INITIALIZER(struct cmd_set_fdir_input_set_result, 12396 inset_field, 12397 "ivlan#ethertype#src-ipv4#dst-ipv4#src-ipv6#dst-ipv6#" 12398 "ipv4-tos#ipv4-proto#ipv4-ttl#ipv6-tc#ipv6-next-header#" 12399 "ipv6-hop-limits#udp-src-port#udp-dst-port#" 12400 "tcp-src-port#tcp-dst-port#sctp-src-port#sctp-dst-port#" 12401 "sctp-veri-tag#none"); 12402 cmdline_parse_token_string_t cmd_set_fdir_input_set_select = 12403 TOKEN_STRING_INITIALIZER(struct cmd_set_fdir_input_set_result, 12404 select, "select#add"); 12405 12406 cmdline_parse_inst_t cmd_set_fdir_input_set = { 12407 .f = cmd_set_fdir_input_set_parsed, 12408 .data = NULL, 12409 .help_str = "set_fdir_input_set <port_id> " 12410 "ipv4-frag|ipv4-tcp|ipv4-udp|ipv4-sctp|ipv4-other|" 12411 "ipv6-frag|ipv6-tcp|ipv6-udp|ipv6-sctp|ipv6-other|l2_payload " 12412 "ivlan|ethertype|src-ipv4|dst-ipv4|src-ipv6|dst-ipv6|" 12413 "ipv4-tos|ipv4-proto|ipv4-ttl|ipv6-tc|ipv6-next-header|" 12414 "ipv6-hop-limits|udp-src-port|udp-dst-port|" 12415 "tcp-src-port|tcp-dst-port|sctp-src-port|sctp-dst-port|" 12416 "sctp-veri-tag|none select|add", 12417 .tokens = { 12418 (void *)&cmd_set_fdir_input_set_cmd, 12419 (void *)&cmd_set_fdir_input_set_port_id, 12420 (void *)&cmd_set_fdir_input_set_flow_type, 12421 (void *)&cmd_set_fdir_input_set_field, 12422 (void *)&cmd_set_fdir_input_set_select, 12423 NULL, 12424 }, 12425 }; 12426 12427 /* *** ADD/REMOVE A MULTICAST MAC ADDRESS TO/FROM A PORT *** */ 12428 struct cmd_mcast_addr_result { 12429 cmdline_fixed_string_t mcast_addr_cmd; 12430 cmdline_fixed_string_t what; 12431 uint16_t port_num; 12432 struct ether_addr mc_addr; 12433 }; 12434 12435 static void cmd_mcast_addr_parsed(void *parsed_result, 12436 __attribute__((unused)) struct cmdline *cl, 12437 __attribute__((unused)) void *data) 12438 { 12439 struct cmd_mcast_addr_result *res = parsed_result; 12440 12441 if (!is_multicast_ether_addr(&res->mc_addr)) { 12442 printf("Invalid multicast addr %02X:%02X:%02X:%02X:%02X:%02X\n", 12443 res->mc_addr.addr_bytes[0], res->mc_addr.addr_bytes[1], 12444 res->mc_addr.addr_bytes[2], res->mc_addr.addr_bytes[3], 12445 res->mc_addr.addr_bytes[4], res->mc_addr.addr_bytes[5]); 12446 return; 12447 } 12448 if (strcmp(res->what, "add") == 0) 12449 mcast_addr_add(res->port_num, &res->mc_addr); 12450 else 12451 mcast_addr_remove(res->port_num, &res->mc_addr); 12452 } 12453 12454 cmdline_parse_token_string_t cmd_mcast_addr_cmd = 12455 TOKEN_STRING_INITIALIZER(struct cmd_mcast_addr_result, 12456 mcast_addr_cmd, "mcast_addr"); 12457 cmdline_parse_token_string_t cmd_mcast_addr_what = 12458 TOKEN_STRING_INITIALIZER(struct cmd_mcast_addr_result, what, 12459 "add#remove"); 12460 cmdline_parse_token_num_t cmd_mcast_addr_portnum = 12461 TOKEN_NUM_INITIALIZER(struct cmd_mcast_addr_result, port_num, UINT16); 12462 cmdline_parse_token_etheraddr_t cmd_mcast_addr_addr = 12463 TOKEN_ETHERADDR_INITIALIZER(struct cmd_mac_addr_result, address); 12464 12465 cmdline_parse_inst_t cmd_mcast_addr = { 12466 .f = cmd_mcast_addr_parsed, 12467 .data = (void *)0, 12468 .help_str = "mcast_addr add|remove <port_id> <mcast_addr>: " 12469 "Add/Remove multicast MAC address on port_id", 12470 .tokens = { 12471 (void *)&cmd_mcast_addr_cmd, 12472 (void *)&cmd_mcast_addr_what, 12473 (void *)&cmd_mcast_addr_portnum, 12474 (void *)&cmd_mcast_addr_addr, 12475 NULL, 12476 }, 12477 }; 12478 12479 /* l2 tunnel config 12480 * only support E-tag now. 12481 */ 12482 12483 /* Ether type config */ 12484 struct cmd_config_l2_tunnel_eth_type_result { 12485 cmdline_fixed_string_t port; 12486 cmdline_fixed_string_t config; 12487 cmdline_fixed_string_t all; 12488 portid_t id; 12489 cmdline_fixed_string_t l2_tunnel; 12490 cmdline_fixed_string_t l2_tunnel_type; 12491 cmdline_fixed_string_t eth_type; 12492 uint16_t eth_type_val; 12493 }; 12494 12495 cmdline_parse_token_string_t cmd_config_l2_tunnel_eth_type_port = 12496 TOKEN_STRING_INITIALIZER 12497 (struct cmd_config_l2_tunnel_eth_type_result, 12498 port, "port"); 12499 cmdline_parse_token_string_t cmd_config_l2_tunnel_eth_type_config = 12500 TOKEN_STRING_INITIALIZER 12501 (struct cmd_config_l2_tunnel_eth_type_result, 12502 config, "config"); 12503 cmdline_parse_token_string_t cmd_config_l2_tunnel_eth_type_all_str = 12504 TOKEN_STRING_INITIALIZER 12505 (struct cmd_config_l2_tunnel_eth_type_result, 12506 all, "all"); 12507 cmdline_parse_token_num_t cmd_config_l2_tunnel_eth_type_id = 12508 TOKEN_NUM_INITIALIZER 12509 (struct cmd_config_l2_tunnel_eth_type_result, 12510 id, UINT16); 12511 cmdline_parse_token_string_t cmd_config_l2_tunnel_eth_type_l2_tunnel = 12512 TOKEN_STRING_INITIALIZER 12513 (struct cmd_config_l2_tunnel_eth_type_result, 12514 l2_tunnel, "l2-tunnel"); 12515 cmdline_parse_token_string_t cmd_config_l2_tunnel_eth_type_l2_tunnel_type = 12516 TOKEN_STRING_INITIALIZER 12517 (struct cmd_config_l2_tunnel_eth_type_result, 12518 l2_tunnel_type, "E-tag"); 12519 cmdline_parse_token_string_t cmd_config_l2_tunnel_eth_type_eth_type = 12520 TOKEN_STRING_INITIALIZER 12521 (struct cmd_config_l2_tunnel_eth_type_result, 12522 eth_type, "ether-type"); 12523 cmdline_parse_token_num_t cmd_config_l2_tunnel_eth_type_eth_type_val = 12524 TOKEN_NUM_INITIALIZER 12525 (struct cmd_config_l2_tunnel_eth_type_result, 12526 eth_type_val, UINT16); 12527 12528 static enum rte_eth_tunnel_type 12529 str2fdir_l2_tunnel_type(char *string) 12530 { 12531 uint32_t i = 0; 12532 12533 static const struct { 12534 char str[32]; 12535 enum rte_eth_tunnel_type type; 12536 } l2_tunnel_type_str[] = { 12537 {"E-tag", RTE_L2_TUNNEL_TYPE_E_TAG}, 12538 }; 12539 12540 for (i = 0; i < RTE_DIM(l2_tunnel_type_str); i++) { 12541 if (!strcmp(l2_tunnel_type_str[i].str, string)) 12542 return l2_tunnel_type_str[i].type; 12543 } 12544 return RTE_TUNNEL_TYPE_NONE; 12545 } 12546 12547 /* ether type config for all ports */ 12548 static void 12549 cmd_config_l2_tunnel_eth_type_all_parsed 12550 (void *parsed_result, 12551 __attribute__((unused)) struct cmdline *cl, 12552 __attribute__((unused)) void *data) 12553 { 12554 struct cmd_config_l2_tunnel_eth_type_result *res = parsed_result; 12555 struct rte_eth_l2_tunnel_conf entry; 12556 portid_t pid; 12557 12558 entry.l2_tunnel_type = str2fdir_l2_tunnel_type(res->l2_tunnel_type); 12559 entry.ether_type = res->eth_type_val; 12560 12561 RTE_ETH_FOREACH_DEV(pid) { 12562 rte_eth_dev_l2_tunnel_eth_type_conf(pid, &entry); 12563 } 12564 } 12565 12566 cmdline_parse_inst_t cmd_config_l2_tunnel_eth_type_all = { 12567 .f = cmd_config_l2_tunnel_eth_type_all_parsed, 12568 .data = NULL, 12569 .help_str = "port config all l2-tunnel E-tag ether-type <value>", 12570 .tokens = { 12571 (void *)&cmd_config_l2_tunnel_eth_type_port, 12572 (void *)&cmd_config_l2_tunnel_eth_type_config, 12573 (void *)&cmd_config_l2_tunnel_eth_type_all_str, 12574 (void *)&cmd_config_l2_tunnel_eth_type_l2_tunnel, 12575 (void *)&cmd_config_l2_tunnel_eth_type_l2_tunnel_type, 12576 (void *)&cmd_config_l2_tunnel_eth_type_eth_type, 12577 (void *)&cmd_config_l2_tunnel_eth_type_eth_type_val, 12578 NULL, 12579 }, 12580 }; 12581 12582 /* ether type config for a specific port */ 12583 static void 12584 cmd_config_l2_tunnel_eth_type_specific_parsed( 12585 void *parsed_result, 12586 __attribute__((unused)) struct cmdline *cl, 12587 __attribute__((unused)) void *data) 12588 { 12589 struct cmd_config_l2_tunnel_eth_type_result *res = 12590 parsed_result; 12591 struct rte_eth_l2_tunnel_conf entry; 12592 12593 if (port_id_is_invalid(res->id, ENABLED_WARN)) 12594 return; 12595 12596 entry.l2_tunnel_type = str2fdir_l2_tunnel_type(res->l2_tunnel_type); 12597 entry.ether_type = res->eth_type_val; 12598 12599 rte_eth_dev_l2_tunnel_eth_type_conf(res->id, &entry); 12600 } 12601 12602 cmdline_parse_inst_t cmd_config_l2_tunnel_eth_type_specific = { 12603 .f = cmd_config_l2_tunnel_eth_type_specific_parsed, 12604 .data = NULL, 12605 .help_str = "port config <port_id> l2-tunnel E-tag ether-type <value>", 12606 .tokens = { 12607 (void *)&cmd_config_l2_tunnel_eth_type_port, 12608 (void *)&cmd_config_l2_tunnel_eth_type_config, 12609 (void *)&cmd_config_l2_tunnel_eth_type_id, 12610 (void *)&cmd_config_l2_tunnel_eth_type_l2_tunnel, 12611 (void *)&cmd_config_l2_tunnel_eth_type_l2_tunnel_type, 12612 (void *)&cmd_config_l2_tunnel_eth_type_eth_type, 12613 (void *)&cmd_config_l2_tunnel_eth_type_eth_type_val, 12614 NULL, 12615 }, 12616 }; 12617 12618 /* Enable/disable l2 tunnel */ 12619 struct cmd_config_l2_tunnel_en_dis_result { 12620 cmdline_fixed_string_t port; 12621 cmdline_fixed_string_t config; 12622 cmdline_fixed_string_t all; 12623 portid_t id; 12624 cmdline_fixed_string_t l2_tunnel; 12625 cmdline_fixed_string_t l2_tunnel_type; 12626 cmdline_fixed_string_t en_dis; 12627 }; 12628 12629 cmdline_parse_token_string_t cmd_config_l2_tunnel_en_dis_port = 12630 TOKEN_STRING_INITIALIZER 12631 (struct cmd_config_l2_tunnel_en_dis_result, 12632 port, "port"); 12633 cmdline_parse_token_string_t cmd_config_l2_tunnel_en_dis_config = 12634 TOKEN_STRING_INITIALIZER 12635 (struct cmd_config_l2_tunnel_en_dis_result, 12636 config, "config"); 12637 cmdline_parse_token_string_t cmd_config_l2_tunnel_en_dis_all_str = 12638 TOKEN_STRING_INITIALIZER 12639 (struct cmd_config_l2_tunnel_en_dis_result, 12640 all, "all"); 12641 cmdline_parse_token_num_t cmd_config_l2_tunnel_en_dis_id = 12642 TOKEN_NUM_INITIALIZER 12643 (struct cmd_config_l2_tunnel_en_dis_result, 12644 id, UINT16); 12645 cmdline_parse_token_string_t cmd_config_l2_tunnel_en_dis_l2_tunnel = 12646 TOKEN_STRING_INITIALIZER 12647 (struct cmd_config_l2_tunnel_en_dis_result, 12648 l2_tunnel, "l2-tunnel"); 12649 cmdline_parse_token_string_t cmd_config_l2_tunnel_en_dis_l2_tunnel_type = 12650 TOKEN_STRING_INITIALIZER 12651 (struct cmd_config_l2_tunnel_en_dis_result, 12652 l2_tunnel_type, "E-tag"); 12653 cmdline_parse_token_string_t cmd_config_l2_tunnel_en_dis_en_dis = 12654 TOKEN_STRING_INITIALIZER 12655 (struct cmd_config_l2_tunnel_en_dis_result, 12656 en_dis, "enable#disable"); 12657 12658 /* enable/disable l2 tunnel for all ports */ 12659 static void 12660 cmd_config_l2_tunnel_en_dis_all_parsed( 12661 void *parsed_result, 12662 __attribute__((unused)) struct cmdline *cl, 12663 __attribute__((unused)) void *data) 12664 { 12665 struct cmd_config_l2_tunnel_en_dis_result *res = parsed_result; 12666 struct rte_eth_l2_tunnel_conf entry; 12667 portid_t pid; 12668 uint8_t en; 12669 12670 entry.l2_tunnel_type = str2fdir_l2_tunnel_type(res->l2_tunnel_type); 12671 12672 if (!strcmp("enable", res->en_dis)) 12673 en = 1; 12674 else 12675 en = 0; 12676 12677 RTE_ETH_FOREACH_DEV(pid) { 12678 rte_eth_dev_l2_tunnel_offload_set(pid, 12679 &entry, 12680 ETH_L2_TUNNEL_ENABLE_MASK, 12681 en); 12682 } 12683 } 12684 12685 cmdline_parse_inst_t cmd_config_l2_tunnel_en_dis_all = { 12686 .f = cmd_config_l2_tunnel_en_dis_all_parsed, 12687 .data = NULL, 12688 .help_str = "port config all l2-tunnel E-tag enable|disable", 12689 .tokens = { 12690 (void *)&cmd_config_l2_tunnel_en_dis_port, 12691 (void *)&cmd_config_l2_tunnel_en_dis_config, 12692 (void *)&cmd_config_l2_tunnel_en_dis_all_str, 12693 (void *)&cmd_config_l2_tunnel_en_dis_l2_tunnel, 12694 (void *)&cmd_config_l2_tunnel_en_dis_l2_tunnel_type, 12695 (void *)&cmd_config_l2_tunnel_en_dis_en_dis, 12696 NULL, 12697 }, 12698 }; 12699 12700 /* enable/disable l2 tunnel for a port */ 12701 static void 12702 cmd_config_l2_tunnel_en_dis_specific_parsed( 12703 void *parsed_result, 12704 __attribute__((unused)) struct cmdline *cl, 12705 __attribute__((unused)) void *data) 12706 { 12707 struct cmd_config_l2_tunnel_en_dis_result *res = 12708 parsed_result; 12709 struct rte_eth_l2_tunnel_conf entry; 12710 12711 if (port_id_is_invalid(res->id, ENABLED_WARN)) 12712 return; 12713 12714 entry.l2_tunnel_type = str2fdir_l2_tunnel_type(res->l2_tunnel_type); 12715 12716 if (!strcmp("enable", res->en_dis)) 12717 rte_eth_dev_l2_tunnel_offload_set(res->id, 12718 &entry, 12719 ETH_L2_TUNNEL_ENABLE_MASK, 12720 1); 12721 else 12722 rte_eth_dev_l2_tunnel_offload_set(res->id, 12723 &entry, 12724 ETH_L2_TUNNEL_ENABLE_MASK, 12725 0); 12726 } 12727 12728 cmdline_parse_inst_t cmd_config_l2_tunnel_en_dis_specific = { 12729 .f = cmd_config_l2_tunnel_en_dis_specific_parsed, 12730 .data = NULL, 12731 .help_str = "port config <port_id> l2-tunnel E-tag enable|disable", 12732 .tokens = { 12733 (void *)&cmd_config_l2_tunnel_en_dis_port, 12734 (void *)&cmd_config_l2_tunnel_en_dis_config, 12735 (void *)&cmd_config_l2_tunnel_en_dis_id, 12736 (void *)&cmd_config_l2_tunnel_en_dis_l2_tunnel, 12737 (void *)&cmd_config_l2_tunnel_en_dis_l2_tunnel_type, 12738 (void *)&cmd_config_l2_tunnel_en_dis_en_dis, 12739 NULL, 12740 }, 12741 }; 12742 12743 /* E-tag configuration */ 12744 12745 /* Common result structure for all E-tag configuration */ 12746 struct cmd_config_e_tag_result { 12747 cmdline_fixed_string_t e_tag; 12748 cmdline_fixed_string_t set; 12749 cmdline_fixed_string_t insertion; 12750 cmdline_fixed_string_t stripping; 12751 cmdline_fixed_string_t forwarding; 12752 cmdline_fixed_string_t filter; 12753 cmdline_fixed_string_t add; 12754 cmdline_fixed_string_t del; 12755 cmdline_fixed_string_t on; 12756 cmdline_fixed_string_t off; 12757 cmdline_fixed_string_t on_off; 12758 cmdline_fixed_string_t port_tag_id; 12759 uint32_t port_tag_id_val; 12760 cmdline_fixed_string_t e_tag_id; 12761 uint16_t e_tag_id_val; 12762 cmdline_fixed_string_t dst_pool; 12763 uint8_t dst_pool_val; 12764 cmdline_fixed_string_t port; 12765 portid_t port_id; 12766 cmdline_fixed_string_t vf; 12767 uint8_t vf_id; 12768 }; 12769 12770 /* Common CLI fields for all E-tag configuration */ 12771 cmdline_parse_token_string_t cmd_config_e_tag_e_tag = 12772 TOKEN_STRING_INITIALIZER 12773 (struct cmd_config_e_tag_result, 12774 e_tag, "E-tag"); 12775 cmdline_parse_token_string_t cmd_config_e_tag_set = 12776 TOKEN_STRING_INITIALIZER 12777 (struct cmd_config_e_tag_result, 12778 set, "set"); 12779 cmdline_parse_token_string_t cmd_config_e_tag_insertion = 12780 TOKEN_STRING_INITIALIZER 12781 (struct cmd_config_e_tag_result, 12782 insertion, "insertion"); 12783 cmdline_parse_token_string_t cmd_config_e_tag_stripping = 12784 TOKEN_STRING_INITIALIZER 12785 (struct cmd_config_e_tag_result, 12786 stripping, "stripping"); 12787 cmdline_parse_token_string_t cmd_config_e_tag_forwarding = 12788 TOKEN_STRING_INITIALIZER 12789 (struct cmd_config_e_tag_result, 12790 forwarding, "forwarding"); 12791 cmdline_parse_token_string_t cmd_config_e_tag_filter = 12792 TOKEN_STRING_INITIALIZER 12793 (struct cmd_config_e_tag_result, 12794 filter, "filter"); 12795 cmdline_parse_token_string_t cmd_config_e_tag_add = 12796 TOKEN_STRING_INITIALIZER 12797 (struct cmd_config_e_tag_result, 12798 add, "add"); 12799 cmdline_parse_token_string_t cmd_config_e_tag_del = 12800 TOKEN_STRING_INITIALIZER 12801 (struct cmd_config_e_tag_result, 12802 del, "del"); 12803 cmdline_parse_token_string_t cmd_config_e_tag_on = 12804 TOKEN_STRING_INITIALIZER 12805 (struct cmd_config_e_tag_result, 12806 on, "on"); 12807 cmdline_parse_token_string_t cmd_config_e_tag_off = 12808 TOKEN_STRING_INITIALIZER 12809 (struct cmd_config_e_tag_result, 12810 off, "off"); 12811 cmdline_parse_token_string_t cmd_config_e_tag_on_off = 12812 TOKEN_STRING_INITIALIZER 12813 (struct cmd_config_e_tag_result, 12814 on_off, "on#off"); 12815 cmdline_parse_token_string_t cmd_config_e_tag_port_tag_id = 12816 TOKEN_STRING_INITIALIZER 12817 (struct cmd_config_e_tag_result, 12818 port_tag_id, "port-tag-id"); 12819 cmdline_parse_token_num_t cmd_config_e_tag_port_tag_id_val = 12820 TOKEN_NUM_INITIALIZER 12821 (struct cmd_config_e_tag_result, 12822 port_tag_id_val, UINT32); 12823 cmdline_parse_token_string_t cmd_config_e_tag_e_tag_id = 12824 TOKEN_STRING_INITIALIZER 12825 (struct cmd_config_e_tag_result, 12826 e_tag_id, "e-tag-id"); 12827 cmdline_parse_token_num_t cmd_config_e_tag_e_tag_id_val = 12828 TOKEN_NUM_INITIALIZER 12829 (struct cmd_config_e_tag_result, 12830 e_tag_id_val, UINT16); 12831 cmdline_parse_token_string_t cmd_config_e_tag_dst_pool = 12832 TOKEN_STRING_INITIALIZER 12833 (struct cmd_config_e_tag_result, 12834 dst_pool, "dst-pool"); 12835 cmdline_parse_token_num_t cmd_config_e_tag_dst_pool_val = 12836 TOKEN_NUM_INITIALIZER 12837 (struct cmd_config_e_tag_result, 12838 dst_pool_val, UINT8); 12839 cmdline_parse_token_string_t cmd_config_e_tag_port = 12840 TOKEN_STRING_INITIALIZER 12841 (struct cmd_config_e_tag_result, 12842 port, "port"); 12843 cmdline_parse_token_num_t cmd_config_e_tag_port_id = 12844 TOKEN_NUM_INITIALIZER 12845 (struct cmd_config_e_tag_result, 12846 port_id, UINT16); 12847 cmdline_parse_token_string_t cmd_config_e_tag_vf = 12848 TOKEN_STRING_INITIALIZER 12849 (struct cmd_config_e_tag_result, 12850 vf, "vf"); 12851 cmdline_parse_token_num_t cmd_config_e_tag_vf_id = 12852 TOKEN_NUM_INITIALIZER 12853 (struct cmd_config_e_tag_result, 12854 vf_id, UINT8); 12855 12856 /* E-tag insertion configuration */ 12857 static void 12858 cmd_config_e_tag_insertion_en_parsed( 12859 void *parsed_result, 12860 __attribute__((unused)) struct cmdline *cl, 12861 __attribute__((unused)) void *data) 12862 { 12863 struct cmd_config_e_tag_result *res = 12864 parsed_result; 12865 struct rte_eth_l2_tunnel_conf entry; 12866 12867 if (port_id_is_invalid(res->port_id, ENABLED_WARN)) 12868 return; 12869 12870 entry.l2_tunnel_type = RTE_L2_TUNNEL_TYPE_E_TAG; 12871 entry.tunnel_id = res->port_tag_id_val; 12872 entry.vf_id = res->vf_id; 12873 rte_eth_dev_l2_tunnel_offload_set(res->port_id, 12874 &entry, 12875 ETH_L2_TUNNEL_INSERTION_MASK, 12876 1); 12877 } 12878 12879 static void 12880 cmd_config_e_tag_insertion_dis_parsed( 12881 void *parsed_result, 12882 __attribute__((unused)) struct cmdline *cl, 12883 __attribute__((unused)) void *data) 12884 { 12885 struct cmd_config_e_tag_result *res = 12886 parsed_result; 12887 struct rte_eth_l2_tunnel_conf entry; 12888 12889 if (port_id_is_invalid(res->port_id, ENABLED_WARN)) 12890 return; 12891 12892 entry.l2_tunnel_type = RTE_L2_TUNNEL_TYPE_E_TAG; 12893 entry.vf_id = res->vf_id; 12894 12895 rte_eth_dev_l2_tunnel_offload_set(res->port_id, 12896 &entry, 12897 ETH_L2_TUNNEL_INSERTION_MASK, 12898 0); 12899 } 12900 12901 cmdline_parse_inst_t cmd_config_e_tag_insertion_en = { 12902 .f = cmd_config_e_tag_insertion_en_parsed, 12903 .data = NULL, 12904 .help_str = "E-tag ... : E-tag insertion enable", 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_on, 12910 (void *)&cmd_config_e_tag_port_tag_id, 12911 (void *)&cmd_config_e_tag_port_tag_id_val, 12912 (void *)&cmd_config_e_tag_port, 12913 (void *)&cmd_config_e_tag_port_id, 12914 (void *)&cmd_config_e_tag_vf, 12915 (void *)&cmd_config_e_tag_vf_id, 12916 NULL, 12917 }, 12918 }; 12919 12920 cmdline_parse_inst_t cmd_config_e_tag_insertion_dis = { 12921 .f = cmd_config_e_tag_insertion_dis_parsed, 12922 .data = NULL, 12923 .help_str = "E-tag ... : E-tag insertion disable", 12924 .tokens = { 12925 (void *)&cmd_config_e_tag_e_tag, 12926 (void *)&cmd_config_e_tag_set, 12927 (void *)&cmd_config_e_tag_insertion, 12928 (void *)&cmd_config_e_tag_off, 12929 (void *)&cmd_config_e_tag_port, 12930 (void *)&cmd_config_e_tag_port_id, 12931 (void *)&cmd_config_e_tag_vf, 12932 (void *)&cmd_config_e_tag_vf_id, 12933 NULL, 12934 }, 12935 }; 12936 12937 /* E-tag stripping configuration */ 12938 static void 12939 cmd_config_e_tag_stripping_parsed( 12940 void *parsed_result, 12941 __attribute__((unused)) struct cmdline *cl, 12942 __attribute__((unused)) void *data) 12943 { 12944 struct cmd_config_e_tag_result *res = 12945 parsed_result; 12946 struct rte_eth_l2_tunnel_conf entry; 12947 12948 if (port_id_is_invalid(res->port_id, ENABLED_WARN)) 12949 return; 12950 12951 entry.l2_tunnel_type = RTE_L2_TUNNEL_TYPE_E_TAG; 12952 12953 if (!strcmp(res->on_off, "on")) 12954 rte_eth_dev_l2_tunnel_offload_set 12955 (res->port_id, 12956 &entry, 12957 ETH_L2_TUNNEL_STRIPPING_MASK, 12958 1); 12959 else 12960 rte_eth_dev_l2_tunnel_offload_set 12961 (res->port_id, 12962 &entry, 12963 ETH_L2_TUNNEL_STRIPPING_MASK, 12964 0); 12965 } 12966 12967 cmdline_parse_inst_t cmd_config_e_tag_stripping_en_dis = { 12968 .f = cmd_config_e_tag_stripping_parsed, 12969 .data = NULL, 12970 .help_str = "E-tag ... : E-tag stripping enable/disable", 12971 .tokens = { 12972 (void *)&cmd_config_e_tag_e_tag, 12973 (void *)&cmd_config_e_tag_set, 12974 (void *)&cmd_config_e_tag_stripping, 12975 (void *)&cmd_config_e_tag_on_off, 12976 (void *)&cmd_config_e_tag_port, 12977 (void *)&cmd_config_e_tag_port_id, 12978 NULL, 12979 }, 12980 }; 12981 12982 /* E-tag forwarding configuration */ 12983 static void 12984 cmd_config_e_tag_forwarding_parsed( 12985 void *parsed_result, 12986 __attribute__((unused)) struct cmdline *cl, 12987 __attribute__((unused)) void *data) 12988 { 12989 struct cmd_config_e_tag_result *res = parsed_result; 12990 struct rte_eth_l2_tunnel_conf entry; 12991 12992 if (port_id_is_invalid(res->port_id, ENABLED_WARN)) 12993 return; 12994 12995 entry.l2_tunnel_type = RTE_L2_TUNNEL_TYPE_E_TAG; 12996 12997 if (!strcmp(res->on_off, "on")) 12998 rte_eth_dev_l2_tunnel_offload_set 12999 (res->port_id, 13000 &entry, 13001 ETH_L2_TUNNEL_FORWARDING_MASK, 13002 1); 13003 else 13004 rte_eth_dev_l2_tunnel_offload_set 13005 (res->port_id, 13006 &entry, 13007 ETH_L2_TUNNEL_FORWARDING_MASK, 13008 0); 13009 } 13010 13011 cmdline_parse_inst_t cmd_config_e_tag_forwarding_en_dis = { 13012 .f = cmd_config_e_tag_forwarding_parsed, 13013 .data = NULL, 13014 .help_str = "E-tag ... : E-tag forwarding enable/disable", 13015 .tokens = { 13016 (void *)&cmd_config_e_tag_e_tag, 13017 (void *)&cmd_config_e_tag_set, 13018 (void *)&cmd_config_e_tag_forwarding, 13019 (void *)&cmd_config_e_tag_on_off, 13020 (void *)&cmd_config_e_tag_port, 13021 (void *)&cmd_config_e_tag_port_id, 13022 NULL, 13023 }, 13024 }; 13025 13026 /* E-tag filter configuration */ 13027 static void 13028 cmd_config_e_tag_filter_add_parsed( 13029 void *parsed_result, 13030 __attribute__((unused)) struct cmdline *cl, 13031 __attribute__((unused)) void *data) 13032 { 13033 struct cmd_config_e_tag_result *res = parsed_result; 13034 struct rte_eth_l2_tunnel_conf entry; 13035 int ret = 0; 13036 13037 if (port_id_is_invalid(res->port_id, ENABLED_WARN)) 13038 return; 13039 13040 if (res->e_tag_id_val > 0x3fff) { 13041 printf("e-tag-id must be equal or less than 0x3fff.\n"); 13042 return; 13043 } 13044 13045 ret = rte_eth_dev_filter_supported(res->port_id, 13046 RTE_ETH_FILTER_L2_TUNNEL); 13047 if (ret < 0) { 13048 printf("E-tag filter is not supported on port %u.\n", 13049 res->port_id); 13050 return; 13051 } 13052 13053 entry.l2_tunnel_type = RTE_L2_TUNNEL_TYPE_E_TAG; 13054 entry.tunnel_id = res->e_tag_id_val; 13055 entry.pool = res->dst_pool_val; 13056 13057 ret = rte_eth_dev_filter_ctrl(res->port_id, 13058 RTE_ETH_FILTER_L2_TUNNEL, 13059 RTE_ETH_FILTER_ADD, 13060 &entry); 13061 if (ret < 0) 13062 printf("E-tag filter programming error: (%s)\n", 13063 strerror(-ret)); 13064 } 13065 13066 cmdline_parse_inst_t cmd_config_e_tag_filter_add = { 13067 .f = cmd_config_e_tag_filter_add_parsed, 13068 .data = NULL, 13069 .help_str = "E-tag ... : E-tag filter add", 13070 .tokens = { 13071 (void *)&cmd_config_e_tag_e_tag, 13072 (void *)&cmd_config_e_tag_set, 13073 (void *)&cmd_config_e_tag_filter, 13074 (void *)&cmd_config_e_tag_add, 13075 (void *)&cmd_config_e_tag_e_tag_id, 13076 (void *)&cmd_config_e_tag_e_tag_id_val, 13077 (void *)&cmd_config_e_tag_dst_pool, 13078 (void *)&cmd_config_e_tag_dst_pool_val, 13079 (void *)&cmd_config_e_tag_port, 13080 (void *)&cmd_config_e_tag_port_id, 13081 NULL, 13082 }, 13083 }; 13084 13085 static void 13086 cmd_config_e_tag_filter_del_parsed( 13087 void *parsed_result, 13088 __attribute__((unused)) struct cmdline *cl, 13089 __attribute__((unused)) void *data) 13090 { 13091 struct cmd_config_e_tag_result *res = parsed_result; 13092 struct rte_eth_l2_tunnel_conf entry; 13093 int ret = 0; 13094 13095 if (port_id_is_invalid(res->port_id, ENABLED_WARN)) 13096 return; 13097 13098 if (res->e_tag_id_val > 0x3fff) { 13099 printf("e-tag-id must be less than 0x3fff.\n"); 13100 return; 13101 } 13102 13103 ret = rte_eth_dev_filter_supported(res->port_id, 13104 RTE_ETH_FILTER_L2_TUNNEL); 13105 if (ret < 0) { 13106 printf("E-tag filter is not supported on port %u.\n", 13107 res->port_id); 13108 return; 13109 } 13110 13111 entry.l2_tunnel_type = RTE_L2_TUNNEL_TYPE_E_TAG; 13112 entry.tunnel_id = res->e_tag_id_val; 13113 13114 ret = rte_eth_dev_filter_ctrl(res->port_id, 13115 RTE_ETH_FILTER_L2_TUNNEL, 13116 RTE_ETH_FILTER_DELETE, 13117 &entry); 13118 if (ret < 0) 13119 printf("E-tag filter programming error: (%s)\n", 13120 strerror(-ret)); 13121 } 13122 13123 cmdline_parse_inst_t cmd_config_e_tag_filter_del = { 13124 .f = cmd_config_e_tag_filter_del_parsed, 13125 .data = NULL, 13126 .help_str = "E-tag ... : E-tag filter delete", 13127 .tokens = { 13128 (void *)&cmd_config_e_tag_e_tag, 13129 (void *)&cmd_config_e_tag_set, 13130 (void *)&cmd_config_e_tag_filter, 13131 (void *)&cmd_config_e_tag_del, 13132 (void *)&cmd_config_e_tag_e_tag_id, 13133 (void *)&cmd_config_e_tag_e_tag_id_val, 13134 (void *)&cmd_config_e_tag_port, 13135 (void *)&cmd_config_e_tag_port_id, 13136 NULL, 13137 }, 13138 }; 13139 13140 /* vf vlan anti spoof configuration */ 13141 13142 /* Common result structure for vf vlan anti spoof */ 13143 struct cmd_vf_vlan_anti_spoof_result { 13144 cmdline_fixed_string_t set; 13145 cmdline_fixed_string_t vf; 13146 cmdline_fixed_string_t vlan; 13147 cmdline_fixed_string_t antispoof; 13148 portid_t port_id; 13149 uint32_t vf_id; 13150 cmdline_fixed_string_t on_off; 13151 }; 13152 13153 /* Common CLI fields for vf vlan anti spoof enable disable */ 13154 cmdline_parse_token_string_t cmd_vf_vlan_anti_spoof_set = 13155 TOKEN_STRING_INITIALIZER 13156 (struct cmd_vf_vlan_anti_spoof_result, 13157 set, "set"); 13158 cmdline_parse_token_string_t cmd_vf_vlan_anti_spoof_vf = 13159 TOKEN_STRING_INITIALIZER 13160 (struct cmd_vf_vlan_anti_spoof_result, 13161 vf, "vf"); 13162 cmdline_parse_token_string_t cmd_vf_vlan_anti_spoof_vlan = 13163 TOKEN_STRING_INITIALIZER 13164 (struct cmd_vf_vlan_anti_spoof_result, 13165 vlan, "vlan"); 13166 cmdline_parse_token_string_t cmd_vf_vlan_anti_spoof_antispoof = 13167 TOKEN_STRING_INITIALIZER 13168 (struct cmd_vf_vlan_anti_spoof_result, 13169 antispoof, "antispoof"); 13170 cmdline_parse_token_num_t cmd_vf_vlan_anti_spoof_port_id = 13171 TOKEN_NUM_INITIALIZER 13172 (struct cmd_vf_vlan_anti_spoof_result, 13173 port_id, UINT16); 13174 cmdline_parse_token_num_t cmd_vf_vlan_anti_spoof_vf_id = 13175 TOKEN_NUM_INITIALIZER 13176 (struct cmd_vf_vlan_anti_spoof_result, 13177 vf_id, UINT32); 13178 cmdline_parse_token_string_t cmd_vf_vlan_anti_spoof_on_off = 13179 TOKEN_STRING_INITIALIZER 13180 (struct cmd_vf_vlan_anti_spoof_result, 13181 on_off, "on#off"); 13182 13183 static void 13184 cmd_set_vf_vlan_anti_spoof_parsed( 13185 void *parsed_result, 13186 __attribute__((unused)) struct cmdline *cl, 13187 __attribute__((unused)) void *data) 13188 { 13189 struct cmd_vf_vlan_anti_spoof_result *res = parsed_result; 13190 int ret = -ENOTSUP; 13191 13192 __rte_unused int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0; 13193 13194 if (port_id_is_invalid(res->port_id, ENABLED_WARN)) 13195 return; 13196 13197 #ifdef RTE_LIBRTE_IXGBE_PMD 13198 if (ret == -ENOTSUP) 13199 ret = rte_pmd_ixgbe_set_vf_vlan_anti_spoof(res->port_id, 13200 res->vf_id, is_on); 13201 #endif 13202 #ifdef RTE_LIBRTE_I40E_PMD 13203 if (ret == -ENOTSUP) 13204 ret = rte_pmd_i40e_set_vf_vlan_anti_spoof(res->port_id, 13205 res->vf_id, is_on); 13206 #endif 13207 #ifdef RTE_LIBRTE_BNXT_PMD 13208 if (ret == -ENOTSUP) 13209 ret = rte_pmd_bnxt_set_vf_vlan_anti_spoof(res->port_id, 13210 res->vf_id, is_on); 13211 #endif 13212 13213 switch (ret) { 13214 case 0: 13215 break; 13216 case -EINVAL: 13217 printf("invalid vf_id %d\n", res->vf_id); 13218 break; 13219 case -ENODEV: 13220 printf("invalid port_id %d\n", res->port_id); 13221 break; 13222 case -ENOTSUP: 13223 printf("function not implemented\n"); 13224 break; 13225 default: 13226 printf("programming error: (%s)\n", strerror(-ret)); 13227 } 13228 } 13229 13230 cmdline_parse_inst_t cmd_set_vf_vlan_anti_spoof = { 13231 .f = cmd_set_vf_vlan_anti_spoof_parsed, 13232 .data = NULL, 13233 .help_str = "set vf vlan antispoof <port_id> <vf_id> on|off", 13234 .tokens = { 13235 (void *)&cmd_vf_vlan_anti_spoof_set, 13236 (void *)&cmd_vf_vlan_anti_spoof_vf, 13237 (void *)&cmd_vf_vlan_anti_spoof_vlan, 13238 (void *)&cmd_vf_vlan_anti_spoof_antispoof, 13239 (void *)&cmd_vf_vlan_anti_spoof_port_id, 13240 (void *)&cmd_vf_vlan_anti_spoof_vf_id, 13241 (void *)&cmd_vf_vlan_anti_spoof_on_off, 13242 NULL, 13243 }, 13244 }; 13245 13246 /* vf mac anti spoof configuration */ 13247 13248 /* Common result structure for vf mac anti spoof */ 13249 struct cmd_vf_mac_anti_spoof_result { 13250 cmdline_fixed_string_t set; 13251 cmdline_fixed_string_t vf; 13252 cmdline_fixed_string_t mac; 13253 cmdline_fixed_string_t antispoof; 13254 portid_t port_id; 13255 uint32_t vf_id; 13256 cmdline_fixed_string_t on_off; 13257 }; 13258 13259 /* Common CLI fields for vf mac anti spoof enable disable */ 13260 cmdline_parse_token_string_t cmd_vf_mac_anti_spoof_set = 13261 TOKEN_STRING_INITIALIZER 13262 (struct cmd_vf_mac_anti_spoof_result, 13263 set, "set"); 13264 cmdline_parse_token_string_t cmd_vf_mac_anti_spoof_vf = 13265 TOKEN_STRING_INITIALIZER 13266 (struct cmd_vf_mac_anti_spoof_result, 13267 vf, "vf"); 13268 cmdline_parse_token_string_t cmd_vf_mac_anti_spoof_mac = 13269 TOKEN_STRING_INITIALIZER 13270 (struct cmd_vf_mac_anti_spoof_result, 13271 mac, "mac"); 13272 cmdline_parse_token_string_t cmd_vf_mac_anti_spoof_antispoof = 13273 TOKEN_STRING_INITIALIZER 13274 (struct cmd_vf_mac_anti_spoof_result, 13275 antispoof, "antispoof"); 13276 cmdline_parse_token_num_t cmd_vf_mac_anti_spoof_port_id = 13277 TOKEN_NUM_INITIALIZER 13278 (struct cmd_vf_mac_anti_spoof_result, 13279 port_id, UINT16); 13280 cmdline_parse_token_num_t cmd_vf_mac_anti_spoof_vf_id = 13281 TOKEN_NUM_INITIALIZER 13282 (struct cmd_vf_mac_anti_spoof_result, 13283 vf_id, UINT32); 13284 cmdline_parse_token_string_t cmd_vf_mac_anti_spoof_on_off = 13285 TOKEN_STRING_INITIALIZER 13286 (struct cmd_vf_mac_anti_spoof_result, 13287 on_off, "on#off"); 13288 13289 static void 13290 cmd_set_vf_mac_anti_spoof_parsed( 13291 void *parsed_result, 13292 __attribute__((unused)) struct cmdline *cl, 13293 __attribute__((unused)) void *data) 13294 { 13295 struct cmd_vf_mac_anti_spoof_result *res = parsed_result; 13296 int ret = -ENOTSUP; 13297 13298 __rte_unused int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0; 13299 13300 if (port_id_is_invalid(res->port_id, ENABLED_WARN)) 13301 return; 13302 13303 #ifdef RTE_LIBRTE_IXGBE_PMD 13304 if (ret == -ENOTSUP) 13305 ret = rte_pmd_ixgbe_set_vf_mac_anti_spoof(res->port_id, 13306 res->vf_id, is_on); 13307 #endif 13308 #ifdef RTE_LIBRTE_I40E_PMD 13309 if (ret == -ENOTSUP) 13310 ret = rte_pmd_i40e_set_vf_mac_anti_spoof(res->port_id, 13311 res->vf_id, is_on); 13312 #endif 13313 #ifdef RTE_LIBRTE_BNXT_PMD 13314 if (ret == -ENOTSUP) 13315 ret = rte_pmd_bnxt_set_vf_mac_anti_spoof(res->port_id, 13316 res->vf_id, is_on); 13317 #endif 13318 13319 switch (ret) { 13320 case 0: 13321 break; 13322 case -EINVAL: 13323 printf("invalid vf_id %d or is_on %d\n", res->vf_id, is_on); 13324 break; 13325 case -ENODEV: 13326 printf("invalid port_id %d\n", res->port_id); 13327 break; 13328 case -ENOTSUP: 13329 printf("function not implemented\n"); 13330 break; 13331 default: 13332 printf("programming error: (%s)\n", strerror(-ret)); 13333 } 13334 } 13335 13336 cmdline_parse_inst_t cmd_set_vf_mac_anti_spoof = { 13337 .f = cmd_set_vf_mac_anti_spoof_parsed, 13338 .data = NULL, 13339 .help_str = "set vf mac antispoof <port_id> <vf_id> on|off", 13340 .tokens = { 13341 (void *)&cmd_vf_mac_anti_spoof_set, 13342 (void *)&cmd_vf_mac_anti_spoof_vf, 13343 (void *)&cmd_vf_mac_anti_spoof_mac, 13344 (void *)&cmd_vf_mac_anti_spoof_antispoof, 13345 (void *)&cmd_vf_mac_anti_spoof_port_id, 13346 (void *)&cmd_vf_mac_anti_spoof_vf_id, 13347 (void *)&cmd_vf_mac_anti_spoof_on_off, 13348 NULL, 13349 }, 13350 }; 13351 13352 /* vf vlan strip queue configuration */ 13353 13354 /* Common result structure for vf mac anti spoof */ 13355 struct cmd_vf_vlan_stripq_result { 13356 cmdline_fixed_string_t set; 13357 cmdline_fixed_string_t vf; 13358 cmdline_fixed_string_t vlan; 13359 cmdline_fixed_string_t stripq; 13360 portid_t port_id; 13361 uint16_t vf_id; 13362 cmdline_fixed_string_t on_off; 13363 }; 13364 13365 /* Common CLI fields for vf vlan strip enable disable */ 13366 cmdline_parse_token_string_t cmd_vf_vlan_stripq_set = 13367 TOKEN_STRING_INITIALIZER 13368 (struct cmd_vf_vlan_stripq_result, 13369 set, "set"); 13370 cmdline_parse_token_string_t cmd_vf_vlan_stripq_vf = 13371 TOKEN_STRING_INITIALIZER 13372 (struct cmd_vf_vlan_stripq_result, 13373 vf, "vf"); 13374 cmdline_parse_token_string_t cmd_vf_vlan_stripq_vlan = 13375 TOKEN_STRING_INITIALIZER 13376 (struct cmd_vf_vlan_stripq_result, 13377 vlan, "vlan"); 13378 cmdline_parse_token_string_t cmd_vf_vlan_stripq_stripq = 13379 TOKEN_STRING_INITIALIZER 13380 (struct cmd_vf_vlan_stripq_result, 13381 stripq, "stripq"); 13382 cmdline_parse_token_num_t cmd_vf_vlan_stripq_port_id = 13383 TOKEN_NUM_INITIALIZER 13384 (struct cmd_vf_vlan_stripq_result, 13385 port_id, UINT16); 13386 cmdline_parse_token_num_t cmd_vf_vlan_stripq_vf_id = 13387 TOKEN_NUM_INITIALIZER 13388 (struct cmd_vf_vlan_stripq_result, 13389 vf_id, UINT16); 13390 cmdline_parse_token_string_t cmd_vf_vlan_stripq_on_off = 13391 TOKEN_STRING_INITIALIZER 13392 (struct cmd_vf_vlan_stripq_result, 13393 on_off, "on#off"); 13394 13395 static void 13396 cmd_set_vf_vlan_stripq_parsed( 13397 void *parsed_result, 13398 __attribute__((unused)) struct cmdline *cl, 13399 __attribute__((unused)) void *data) 13400 { 13401 struct cmd_vf_vlan_stripq_result *res = parsed_result; 13402 int ret = -ENOTSUP; 13403 13404 __rte_unused int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0; 13405 13406 if (port_id_is_invalid(res->port_id, ENABLED_WARN)) 13407 return; 13408 13409 #ifdef RTE_LIBRTE_IXGBE_PMD 13410 if (ret == -ENOTSUP) 13411 ret = rte_pmd_ixgbe_set_vf_vlan_stripq(res->port_id, 13412 res->vf_id, is_on); 13413 #endif 13414 #ifdef RTE_LIBRTE_I40E_PMD 13415 if (ret == -ENOTSUP) 13416 ret = rte_pmd_i40e_set_vf_vlan_stripq(res->port_id, 13417 res->vf_id, is_on); 13418 #endif 13419 #ifdef RTE_LIBRTE_BNXT_PMD 13420 if (ret == -ENOTSUP) 13421 ret = rte_pmd_bnxt_set_vf_vlan_stripq(res->port_id, 13422 res->vf_id, is_on); 13423 #endif 13424 13425 switch (ret) { 13426 case 0: 13427 break; 13428 case -EINVAL: 13429 printf("invalid vf_id %d or is_on %d\n", res->vf_id, is_on); 13430 break; 13431 case -ENODEV: 13432 printf("invalid port_id %d\n", res->port_id); 13433 break; 13434 case -ENOTSUP: 13435 printf("function not implemented\n"); 13436 break; 13437 default: 13438 printf("programming error: (%s)\n", strerror(-ret)); 13439 } 13440 } 13441 13442 cmdline_parse_inst_t cmd_set_vf_vlan_stripq = { 13443 .f = cmd_set_vf_vlan_stripq_parsed, 13444 .data = NULL, 13445 .help_str = "set vf vlan stripq <port_id> <vf_id> on|off", 13446 .tokens = { 13447 (void *)&cmd_vf_vlan_stripq_set, 13448 (void *)&cmd_vf_vlan_stripq_vf, 13449 (void *)&cmd_vf_vlan_stripq_vlan, 13450 (void *)&cmd_vf_vlan_stripq_stripq, 13451 (void *)&cmd_vf_vlan_stripq_port_id, 13452 (void *)&cmd_vf_vlan_stripq_vf_id, 13453 (void *)&cmd_vf_vlan_stripq_on_off, 13454 NULL, 13455 }, 13456 }; 13457 13458 /* vf vlan insert configuration */ 13459 13460 /* Common result structure for vf vlan insert */ 13461 struct cmd_vf_vlan_insert_result { 13462 cmdline_fixed_string_t set; 13463 cmdline_fixed_string_t vf; 13464 cmdline_fixed_string_t vlan; 13465 cmdline_fixed_string_t insert; 13466 portid_t port_id; 13467 uint16_t vf_id; 13468 uint16_t vlan_id; 13469 }; 13470 13471 /* Common CLI fields for vf vlan insert enable disable */ 13472 cmdline_parse_token_string_t cmd_vf_vlan_insert_set = 13473 TOKEN_STRING_INITIALIZER 13474 (struct cmd_vf_vlan_insert_result, 13475 set, "set"); 13476 cmdline_parse_token_string_t cmd_vf_vlan_insert_vf = 13477 TOKEN_STRING_INITIALIZER 13478 (struct cmd_vf_vlan_insert_result, 13479 vf, "vf"); 13480 cmdline_parse_token_string_t cmd_vf_vlan_insert_vlan = 13481 TOKEN_STRING_INITIALIZER 13482 (struct cmd_vf_vlan_insert_result, 13483 vlan, "vlan"); 13484 cmdline_parse_token_string_t cmd_vf_vlan_insert_insert = 13485 TOKEN_STRING_INITIALIZER 13486 (struct cmd_vf_vlan_insert_result, 13487 insert, "insert"); 13488 cmdline_parse_token_num_t cmd_vf_vlan_insert_port_id = 13489 TOKEN_NUM_INITIALIZER 13490 (struct cmd_vf_vlan_insert_result, 13491 port_id, UINT16); 13492 cmdline_parse_token_num_t cmd_vf_vlan_insert_vf_id = 13493 TOKEN_NUM_INITIALIZER 13494 (struct cmd_vf_vlan_insert_result, 13495 vf_id, UINT16); 13496 cmdline_parse_token_num_t cmd_vf_vlan_insert_vlan_id = 13497 TOKEN_NUM_INITIALIZER 13498 (struct cmd_vf_vlan_insert_result, 13499 vlan_id, UINT16); 13500 13501 static void 13502 cmd_set_vf_vlan_insert_parsed( 13503 void *parsed_result, 13504 __attribute__((unused)) struct cmdline *cl, 13505 __attribute__((unused)) void *data) 13506 { 13507 struct cmd_vf_vlan_insert_result *res = parsed_result; 13508 int ret = -ENOTSUP; 13509 13510 if (port_id_is_invalid(res->port_id, ENABLED_WARN)) 13511 return; 13512 13513 #ifdef RTE_LIBRTE_IXGBE_PMD 13514 if (ret == -ENOTSUP) 13515 ret = rte_pmd_ixgbe_set_vf_vlan_insert(res->port_id, res->vf_id, 13516 res->vlan_id); 13517 #endif 13518 #ifdef RTE_LIBRTE_I40E_PMD 13519 if (ret == -ENOTSUP) 13520 ret = rte_pmd_i40e_set_vf_vlan_insert(res->port_id, res->vf_id, 13521 res->vlan_id); 13522 #endif 13523 #ifdef RTE_LIBRTE_BNXT_PMD 13524 if (ret == -ENOTSUP) 13525 ret = rte_pmd_bnxt_set_vf_vlan_insert(res->port_id, res->vf_id, 13526 res->vlan_id); 13527 #endif 13528 13529 switch (ret) { 13530 case 0: 13531 break; 13532 case -EINVAL: 13533 printf("invalid vf_id %d or vlan_id %d\n", res->vf_id, res->vlan_id); 13534 break; 13535 case -ENODEV: 13536 printf("invalid port_id %d\n", res->port_id); 13537 break; 13538 case -ENOTSUP: 13539 printf("function not implemented\n"); 13540 break; 13541 default: 13542 printf("programming error: (%s)\n", strerror(-ret)); 13543 } 13544 } 13545 13546 cmdline_parse_inst_t cmd_set_vf_vlan_insert = { 13547 .f = cmd_set_vf_vlan_insert_parsed, 13548 .data = NULL, 13549 .help_str = "set vf vlan insert <port_id> <vf_id> <vlan_id>", 13550 .tokens = { 13551 (void *)&cmd_vf_vlan_insert_set, 13552 (void *)&cmd_vf_vlan_insert_vf, 13553 (void *)&cmd_vf_vlan_insert_vlan, 13554 (void *)&cmd_vf_vlan_insert_insert, 13555 (void *)&cmd_vf_vlan_insert_port_id, 13556 (void *)&cmd_vf_vlan_insert_vf_id, 13557 (void *)&cmd_vf_vlan_insert_vlan_id, 13558 NULL, 13559 }, 13560 }; 13561 13562 /* tx loopback configuration */ 13563 13564 /* Common result structure for tx loopback */ 13565 struct cmd_tx_loopback_result { 13566 cmdline_fixed_string_t set; 13567 cmdline_fixed_string_t tx; 13568 cmdline_fixed_string_t loopback; 13569 portid_t port_id; 13570 cmdline_fixed_string_t on_off; 13571 }; 13572 13573 /* Common CLI fields for tx loopback enable disable */ 13574 cmdline_parse_token_string_t cmd_tx_loopback_set = 13575 TOKEN_STRING_INITIALIZER 13576 (struct cmd_tx_loopback_result, 13577 set, "set"); 13578 cmdline_parse_token_string_t cmd_tx_loopback_tx = 13579 TOKEN_STRING_INITIALIZER 13580 (struct cmd_tx_loopback_result, 13581 tx, "tx"); 13582 cmdline_parse_token_string_t cmd_tx_loopback_loopback = 13583 TOKEN_STRING_INITIALIZER 13584 (struct cmd_tx_loopback_result, 13585 loopback, "loopback"); 13586 cmdline_parse_token_num_t cmd_tx_loopback_port_id = 13587 TOKEN_NUM_INITIALIZER 13588 (struct cmd_tx_loopback_result, 13589 port_id, UINT16); 13590 cmdline_parse_token_string_t cmd_tx_loopback_on_off = 13591 TOKEN_STRING_INITIALIZER 13592 (struct cmd_tx_loopback_result, 13593 on_off, "on#off"); 13594 13595 static void 13596 cmd_set_tx_loopback_parsed( 13597 void *parsed_result, 13598 __attribute__((unused)) struct cmdline *cl, 13599 __attribute__((unused)) void *data) 13600 { 13601 struct cmd_tx_loopback_result *res = parsed_result; 13602 int ret = -ENOTSUP; 13603 13604 __rte_unused int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0; 13605 13606 if (port_id_is_invalid(res->port_id, ENABLED_WARN)) 13607 return; 13608 13609 #ifdef RTE_LIBRTE_IXGBE_PMD 13610 if (ret == -ENOTSUP) 13611 ret = rte_pmd_ixgbe_set_tx_loopback(res->port_id, is_on); 13612 #endif 13613 #ifdef RTE_LIBRTE_I40E_PMD 13614 if (ret == -ENOTSUP) 13615 ret = rte_pmd_i40e_set_tx_loopback(res->port_id, is_on); 13616 #endif 13617 #ifdef RTE_LIBRTE_BNXT_PMD 13618 if (ret == -ENOTSUP) 13619 ret = rte_pmd_bnxt_set_tx_loopback(res->port_id, is_on); 13620 #endif 13621 #if defined RTE_LIBRTE_DPAA_BUS && defined RTE_LIBRTE_DPAA_PMD 13622 if (ret == -ENOTSUP) 13623 ret = rte_pmd_dpaa_set_tx_loopback(res->port_id, is_on); 13624 #endif 13625 13626 switch (ret) { 13627 case 0: 13628 break; 13629 case -EINVAL: 13630 printf("invalid is_on %d\n", is_on); 13631 break; 13632 case -ENODEV: 13633 printf("invalid port_id %d\n", res->port_id); 13634 break; 13635 case -ENOTSUP: 13636 printf("function not implemented\n"); 13637 break; 13638 default: 13639 printf("programming error: (%s)\n", strerror(-ret)); 13640 } 13641 } 13642 13643 cmdline_parse_inst_t cmd_set_tx_loopback = { 13644 .f = cmd_set_tx_loopback_parsed, 13645 .data = NULL, 13646 .help_str = "set tx loopback <port_id> on|off", 13647 .tokens = { 13648 (void *)&cmd_tx_loopback_set, 13649 (void *)&cmd_tx_loopback_tx, 13650 (void *)&cmd_tx_loopback_loopback, 13651 (void *)&cmd_tx_loopback_port_id, 13652 (void *)&cmd_tx_loopback_on_off, 13653 NULL, 13654 }, 13655 }; 13656 13657 /* all queues drop enable configuration */ 13658 13659 /* Common result structure for all queues drop enable */ 13660 struct cmd_all_queues_drop_en_result { 13661 cmdline_fixed_string_t set; 13662 cmdline_fixed_string_t all; 13663 cmdline_fixed_string_t queues; 13664 cmdline_fixed_string_t drop; 13665 portid_t port_id; 13666 cmdline_fixed_string_t on_off; 13667 }; 13668 13669 /* Common CLI fields for tx loopback enable disable */ 13670 cmdline_parse_token_string_t cmd_all_queues_drop_en_set = 13671 TOKEN_STRING_INITIALIZER 13672 (struct cmd_all_queues_drop_en_result, 13673 set, "set"); 13674 cmdline_parse_token_string_t cmd_all_queues_drop_en_all = 13675 TOKEN_STRING_INITIALIZER 13676 (struct cmd_all_queues_drop_en_result, 13677 all, "all"); 13678 cmdline_parse_token_string_t cmd_all_queues_drop_en_queues = 13679 TOKEN_STRING_INITIALIZER 13680 (struct cmd_all_queues_drop_en_result, 13681 queues, "queues"); 13682 cmdline_parse_token_string_t cmd_all_queues_drop_en_drop = 13683 TOKEN_STRING_INITIALIZER 13684 (struct cmd_all_queues_drop_en_result, 13685 drop, "drop"); 13686 cmdline_parse_token_num_t cmd_all_queues_drop_en_port_id = 13687 TOKEN_NUM_INITIALIZER 13688 (struct cmd_all_queues_drop_en_result, 13689 port_id, UINT16); 13690 cmdline_parse_token_string_t cmd_all_queues_drop_en_on_off = 13691 TOKEN_STRING_INITIALIZER 13692 (struct cmd_all_queues_drop_en_result, 13693 on_off, "on#off"); 13694 13695 static void 13696 cmd_set_all_queues_drop_en_parsed( 13697 void *parsed_result, 13698 __attribute__((unused)) struct cmdline *cl, 13699 __attribute__((unused)) void *data) 13700 { 13701 struct cmd_all_queues_drop_en_result *res = parsed_result; 13702 int ret = -ENOTSUP; 13703 int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0; 13704 13705 if (port_id_is_invalid(res->port_id, ENABLED_WARN)) 13706 return; 13707 13708 #ifdef RTE_LIBRTE_IXGBE_PMD 13709 if (ret == -ENOTSUP) 13710 ret = rte_pmd_ixgbe_set_all_queues_drop_en(res->port_id, is_on); 13711 #endif 13712 #ifdef RTE_LIBRTE_BNXT_PMD 13713 if (ret == -ENOTSUP) 13714 ret = rte_pmd_bnxt_set_all_queues_drop_en(res->port_id, is_on); 13715 #endif 13716 switch (ret) { 13717 case 0: 13718 break; 13719 case -EINVAL: 13720 printf("invalid is_on %d\n", is_on); 13721 break; 13722 case -ENODEV: 13723 printf("invalid port_id %d\n", res->port_id); 13724 break; 13725 case -ENOTSUP: 13726 printf("function not implemented\n"); 13727 break; 13728 default: 13729 printf("programming error: (%s)\n", strerror(-ret)); 13730 } 13731 } 13732 13733 cmdline_parse_inst_t cmd_set_all_queues_drop_en = { 13734 .f = cmd_set_all_queues_drop_en_parsed, 13735 .data = NULL, 13736 .help_str = "set all queues drop <port_id> on|off", 13737 .tokens = { 13738 (void *)&cmd_all_queues_drop_en_set, 13739 (void *)&cmd_all_queues_drop_en_all, 13740 (void *)&cmd_all_queues_drop_en_queues, 13741 (void *)&cmd_all_queues_drop_en_drop, 13742 (void *)&cmd_all_queues_drop_en_port_id, 13743 (void *)&cmd_all_queues_drop_en_on_off, 13744 NULL, 13745 }, 13746 }; 13747 13748 /* vf split drop enable configuration */ 13749 13750 /* Common result structure for vf split drop enable */ 13751 struct cmd_vf_split_drop_en_result { 13752 cmdline_fixed_string_t set; 13753 cmdline_fixed_string_t vf; 13754 cmdline_fixed_string_t split; 13755 cmdline_fixed_string_t drop; 13756 portid_t port_id; 13757 uint16_t vf_id; 13758 cmdline_fixed_string_t on_off; 13759 }; 13760 13761 /* Common CLI fields for vf split drop enable disable */ 13762 cmdline_parse_token_string_t cmd_vf_split_drop_en_set = 13763 TOKEN_STRING_INITIALIZER 13764 (struct cmd_vf_split_drop_en_result, 13765 set, "set"); 13766 cmdline_parse_token_string_t cmd_vf_split_drop_en_vf = 13767 TOKEN_STRING_INITIALIZER 13768 (struct cmd_vf_split_drop_en_result, 13769 vf, "vf"); 13770 cmdline_parse_token_string_t cmd_vf_split_drop_en_split = 13771 TOKEN_STRING_INITIALIZER 13772 (struct cmd_vf_split_drop_en_result, 13773 split, "split"); 13774 cmdline_parse_token_string_t cmd_vf_split_drop_en_drop = 13775 TOKEN_STRING_INITIALIZER 13776 (struct cmd_vf_split_drop_en_result, 13777 drop, "drop"); 13778 cmdline_parse_token_num_t cmd_vf_split_drop_en_port_id = 13779 TOKEN_NUM_INITIALIZER 13780 (struct cmd_vf_split_drop_en_result, 13781 port_id, UINT16); 13782 cmdline_parse_token_num_t cmd_vf_split_drop_en_vf_id = 13783 TOKEN_NUM_INITIALIZER 13784 (struct cmd_vf_split_drop_en_result, 13785 vf_id, UINT16); 13786 cmdline_parse_token_string_t cmd_vf_split_drop_en_on_off = 13787 TOKEN_STRING_INITIALIZER 13788 (struct cmd_vf_split_drop_en_result, 13789 on_off, "on#off"); 13790 13791 static void 13792 cmd_set_vf_split_drop_en_parsed( 13793 void *parsed_result, 13794 __attribute__((unused)) struct cmdline *cl, 13795 __attribute__((unused)) void *data) 13796 { 13797 struct cmd_vf_split_drop_en_result *res = parsed_result; 13798 int ret = -ENOTSUP; 13799 int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0; 13800 13801 if (port_id_is_invalid(res->port_id, ENABLED_WARN)) 13802 return; 13803 13804 #ifdef RTE_LIBRTE_IXGBE_PMD 13805 ret = rte_pmd_ixgbe_set_vf_split_drop_en(res->port_id, res->vf_id, 13806 is_on); 13807 #endif 13808 switch (ret) { 13809 case 0: 13810 break; 13811 case -EINVAL: 13812 printf("invalid vf_id %d or is_on %d\n", res->vf_id, is_on); 13813 break; 13814 case -ENODEV: 13815 printf("invalid port_id %d\n", res->port_id); 13816 break; 13817 case -ENOTSUP: 13818 printf("not supported on port %d\n", res->port_id); 13819 break; 13820 default: 13821 printf("programming error: (%s)\n", strerror(-ret)); 13822 } 13823 } 13824 13825 cmdline_parse_inst_t cmd_set_vf_split_drop_en = { 13826 .f = cmd_set_vf_split_drop_en_parsed, 13827 .data = NULL, 13828 .help_str = "set vf split drop <port_id> <vf_id> on|off", 13829 .tokens = { 13830 (void *)&cmd_vf_split_drop_en_set, 13831 (void *)&cmd_vf_split_drop_en_vf, 13832 (void *)&cmd_vf_split_drop_en_split, 13833 (void *)&cmd_vf_split_drop_en_drop, 13834 (void *)&cmd_vf_split_drop_en_port_id, 13835 (void *)&cmd_vf_split_drop_en_vf_id, 13836 (void *)&cmd_vf_split_drop_en_on_off, 13837 NULL, 13838 }, 13839 }; 13840 13841 /* vf mac address configuration */ 13842 13843 /* Common result structure for vf mac address */ 13844 struct cmd_set_vf_mac_addr_result { 13845 cmdline_fixed_string_t set; 13846 cmdline_fixed_string_t vf; 13847 cmdline_fixed_string_t mac; 13848 cmdline_fixed_string_t addr; 13849 portid_t port_id; 13850 uint16_t vf_id; 13851 struct ether_addr mac_addr; 13852 13853 }; 13854 13855 /* Common CLI fields for vf split drop enable disable */ 13856 cmdline_parse_token_string_t cmd_set_vf_mac_addr_set = 13857 TOKEN_STRING_INITIALIZER 13858 (struct cmd_set_vf_mac_addr_result, 13859 set, "set"); 13860 cmdline_parse_token_string_t cmd_set_vf_mac_addr_vf = 13861 TOKEN_STRING_INITIALIZER 13862 (struct cmd_set_vf_mac_addr_result, 13863 vf, "vf"); 13864 cmdline_parse_token_string_t cmd_set_vf_mac_addr_mac = 13865 TOKEN_STRING_INITIALIZER 13866 (struct cmd_set_vf_mac_addr_result, 13867 mac, "mac"); 13868 cmdline_parse_token_string_t cmd_set_vf_mac_addr_addr = 13869 TOKEN_STRING_INITIALIZER 13870 (struct cmd_set_vf_mac_addr_result, 13871 addr, "addr"); 13872 cmdline_parse_token_num_t cmd_set_vf_mac_addr_port_id = 13873 TOKEN_NUM_INITIALIZER 13874 (struct cmd_set_vf_mac_addr_result, 13875 port_id, UINT16); 13876 cmdline_parse_token_num_t cmd_set_vf_mac_addr_vf_id = 13877 TOKEN_NUM_INITIALIZER 13878 (struct cmd_set_vf_mac_addr_result, 13879 vf_id, UINT16); 13880 cmdline_parse_token_etheraddr_t cmd_set_vf_mac_addr_mac_addr = 13881 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_vf_mac_addr_result, 13882 mac_addr); 13883 13884 static void 13885 cmd_set_vf_mac_addr_parsed( 13886 void *parsed_result, 13887 __attribute__((unused)) struct cmdline *cl, 13888 __attribute__((unused)) void *data) 13889 { 13890 struct cmd_set_vf_mac_addr_result *res = parsed_result; 13891 int ret = -ENOTSUP; 13892 13893 if (port_id_is_invalid(res->port_id, ENABLED_WARN)) 13894 return; 13895 13896 #ifdef RTE_LIBRTE_IXGBE_PMD 13897 if (ret == -ENOTSUP) 13898 ret = rte_pmd_ixgbe_set_vf_mac_addr(res->port_id, res->vf_id, 13899 &res->mac_addr); 13900 #endif 13901 #ifdef RTE_LIBRTE_I40E_PMD 13902 if (ret == -ENOTSUP) 13903 ret = rte_pmd_i40e_set_vf_mac_addr(res->port_id, res->vf_id, 13904 &res->mac_addr); 13905 #endif 13906 #ifdef RTE_LIBRTE_BNXT_PMD 13907 if (ret == -ENOTSUP) 13908 ret = rte_pmd_bnxt_set_vf_mac_addr(res->port_id, res->vf_id, 13909 &res->mac_addr); 13910 #endif 13911 13912 switch (ret) { 13913 case 0: 13914 break; 13915 case -EINVAL: 13916 printf("invalid vf_id %d or mac_addr\n", res->vf_id); 13917 break; 13918 case -ENODEV: 13919 printf("invalid port_id %d\n", res->port_id); 13920 break; 13921 case -ENOTSUP: 13922 printf("function not implemented\n"); 13923 break; 13924 default: 13925 printf("programming error: (%s)\n", strerror(-ret)); 13926 } 13927 } 13928 13929 cmdline_parse_inst_t cmd_set_vf_mac_addr = { 13930 .f = cmd_set_vf_mac_addr_parsed, 13931 .data = NULL, 13932 .help_str = "set vf mac addr <port_id> <vf_id> <mac_addr>", 13933 .tokens = { 13934 (void *)&cmd_set_vf_mac_addr_set, 13935 (void *)&cmd_set_vf_mac_addr_vf, 13936 (void *)&cmd_set_vf_mac_addr_mac, 13937 (void *)&cmd_set_vf_mac_addr_addr, 13938 (void *)&cmd_set_vf_mac_addr_port_id, 13939 (void *)&cmd_set_vf_mac_addr_vf_id, 13940 (void *)&cmd_set_vf_mac_addr_mac_addr, 13941 NULL, 13942 }, 13943 }; 13944 13945 /* MACsec configuration */ 13946 13947 /* Common result structure for MACsec offload enable */ 13948 struct cmd_macsec_offload_on_result { 13949 cmdline_fixed_string_t set; 13950 cmdline_fixed_string_t macsec; 13951 cmdline_fixed_string_t offload; 13952 portid_t port_id; 13953 cmdline_fixed_string_t on; 13954 cmdline_fixed_string_t encrypt; 13955 cmdline_fixed_string_t en_on_off; 13956 cmdline_fixed_string_t replay_protect; 13957 cmdline_fixed_string_t rp_on_off; 13958 }; 13959 13960 /* Common CLI fields for MACsec offload disable */ 13961 cmdline_parse_token_string_t cmd_macsec_offload_on_set = 13962 TOKEN_STRING_INITIALIZER 13963 (struct cmd_macsec_offload_on_result, 13964 set, "set"); 13965 cmdline_parse_token_string_t cmd_macsec_offload_on_macsec = 13966 TOKEN_STRING_INITIALIZER 13967 (struct cmd_macsec_offload_on_result, 13968 macsec, "macsec"); 13969 cmdline_parse_token_string_t cmd_macsec_offload_on_offload = 13970 TOKEN_STRING_INITIALIZER 13971 (struct cmd_macsec_offload_on_result, 13972 offload, "offload"); 13973 cmdline_parse_token_num_t cmd_macsec_offload_on_port_id = 13974 TOKEN_NUM_INITIALIZER 13975 (struct cmd_macsec_offload_on_result, 13976 port_id, UINT16); 13977 cmdline_parse_token_string_t cmd_macsec_offload_on_on = 13978 TOKEN_STRING_INITIALIZER 13979 (struct cmd_macsec_offload_on_result, 13980 on, "on"); 13981 cmdline_parse_token_string_t cmd_macsec_offload_on_encrypt = 13982 TOKEN_STRING_INITIALIZER 13983 (struct cmd_macsec_offload_on_result, 13984 encrypt, "encrypt"); 13985 cmdline_parse_token_string_t cmd_macsec_offload_on_en_on_off = 13986 TOKEN_STRING_INITIALIZER 13987 (struct cmd_macsec_offload_on_result, 13988 en_on_off, "on#off"); 13989 cmdline_parse_token_string_t cmd_macsec_offload_on_replay_protect = 13990 TOKEN_STRING_INITIALIZER 13991 (struct cmd_macsec_offload_on_result, 13992 replay_protect, "replay-protect"); 13993 cmdline_parse_token_string_t cmd_macsec_offload_on_rp_on_off = 13994 TOKEN_STRING_INITIALIZER 13995 (struct cmd_macsec_offload_on_result, 13996 rp_on_off, "on#off"); 13997 13998 static void 13999 cmd_set_macsec_offload_on_parsed( 14000 void *parsed_result, 14001 __attribute__((unused)) struct cmdline *cl, 14002 __attribute__((unused)) void *data) 14003 { 14004 struct cmd_macsec_offload_on_result *res = parsed_result; 14005 int ret = -ENOTSUP; 14006 portid_t port_id = res->port_id; 14007 int en = (strcmp(res->en_on_off, "on") == 0) ? 1 : 0; 14008 int rp = (strcmp(res->rp_on_off, "on") == 0) ? 1 : 0; 14009 struct rte_eth_dev_info dev_info; 14010 14011 if (port_id_is_invalid(port_id, ENABLED_WARN)) 14012 return; 14013 if (!port_is_stopped(port_id)) { 14014 printf("Please stop port %d first\n", port_id); 14015 return; 14016 } 14017 14018 rte_eth_dev_info_get(port_id, &dev_info); 14019 if (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_MACSEC_INSERT) { 14020 #ifdef RTE_LIBRTE_IXGBE_PMD 14021 ret = rte_pmd_ixgbe_macsec_enable(port_id, en, rp); 14022 #endif 14023 } 14024 RTE_SET_USED(en); 14025 RTE_SET_USED(rp); 14026 14027 switch (ret) { 14028 case 0: 14029 ports[port_id].dev_conf.txmode.offloads |= 14030 DEV_TX_OFFLOAD_MACSEC_INSERT; 14031 cmd_reconfig_device_queue(port_id, 1, 1); 14032 break; 14033 case -ENODEV: 14034 printf("invalid port_id %d\n", port_id); 14035 break; 14036 case -ENOTSUP: 14037 printf("not supported on port %d\n", port_id); 14038 break; 14039 default: 14040 printf("programming error: (%s)\n", strerror(-ret)); 14041 } 14042 } 14043 14044 cmdline_parse_inst_t cmd_set_macsec_offload_on = { 14045 .f = cmd_set_macsec_offload_on_parsed, 14046 .data = NULL, 14047 .help_str = "set macsec offload <port_id> on " 14048 "encrypt on|off replay-protect on|off", 14049 .tokens = { 14050 (void *)&cmd_macsec_offload_on_set, 14051 (void *)&cmd_macsec_offload_on_macsec, 14052 (void *)&cmd_macsec_offload_on_offload, 14053 (void *)&cmd_macsec_offload_on_port_id, 14054 (void *)&cmd_macsec_offload_on_on, 14055 (void *)&cmd_macsec_offload_on_encrypt, 14056 (void *)&cmd_macsec_offload_on_en_on_off, 14057 (void *)&cmd_macsec_offload_on_replay_protect, 14058 (void *)&cmd_macsec_offload_on_rp_on_off, 14059 NULL, 14060 }, 14061 }; 14062 14063 /* Common result structure for MACsec offload disable */ 14064 struct cmd_macsec_offload_off_result { 14065 cmdline_fixed_string_t set; 14066 cmdline_fixed_string_t macsec; 14067 cmdline_fixed_string_t offload; 14068 portid_t port_id; 14069 cmdline_fixed_string_t off; 14070 }; 14071 14072 /* Common CLI fields for MACsec offload disable */ 14073 cmdline_parse_token_string_t cmd_macsec_offload_off_set = 14074 TOKEN_STRING_INITIALIZER 14075 (struct cmd_macsec_offload_off_result, 14076 set, "set"); 14077 cmdline_parse_token_string_t cmd_macsec_offload_off_macsec = 14078 TOKEN_STRING_INITIALIZER 14079 (struct cmd_macsec_offload_off_result, 14080 macsec, "macsec"); 14081 cmdline_parse_token_string_t cmd_macsec_offload_off_offload = 14082 TOKEN_STRING_INITIALIZER 14083 (struct cmd_macsec_offload_off_result, 14084 offload, "offload"); 14085 cmdline_parse_token_num_t cmd_macsec_offload_off_port_id = 14086 TOKEN_NUM_INITIALIZER 14087 (struct cmd_macsec_offload_off_result, 14088 port_id, UINT16); 14089 cmdline_parse_token_string_t cmd_macsec_offload_off_off = 14090 TOKEN_STRING_INITIALIZER 14091 (struct cmd_macsec_offload_off_result, 14092 off, "off"); 14093 14094 static void 14095 cmd_set_macsec_offload_off_parsed( 14096 void *parsed_result, 14097 __attribute__((unused)) struct cmdline *cl, 14098 __attribute__((unused)) void *data) 14099 { 14100 struct cmd_macsec_offload_off_result *res = parsed_result; 14101 int ret = -ENOTSUP; 14102 struct rte_eth_dev_info dev_info; 14103 portid_t port_id = res->port_id; 14104 14105 if (port_id_is_invalid(port_id, ENABLED_WARN)) 14106 return; 14107 if (!port_is_stopped(port_id)) { 14108 printf("Please stop port %d first\n", port_id); 14109 return; 14110 } 14111 14112 rte_eth_dev_info_get(port_id, &dev_info); 14113 if (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_MACSEC_INSERT) { 14114 #ifdef RTE_LIBRTE_IXGBE_PMD 14115 ret = rte_pmd_ixgbe_macsec_disable(port_id); 14116 #endif 14117 } 14118 switch (ret) { 14119 case 0: 14120 ports[port_id].dev_conf.txmode.offloads &= 14121 ~DEV_TX_OFFLOAD_MACSEC_INSERT; 14122 cmd_reconfig_device_queue(port_id, 1, 1); 14123 break; 14124 case -ENODEV: 14125 printf("invalid port_id %d\n", port_id); 14126 break; 14127 case -ENOTSUP: 14128 printf("not supported on port %d\n", port_id); 14129 break; 14130 default: 14131 printf("programming error: (%s)\n", strerror(-ret)); 14132 } 14133 } 14134 14135 cmdline_parse_inst_t cmd_set_macsec_offload_off = { 14136 .f = cmd_set_macsec_offload_off_parsed, 14137 .data = NULL, 14138 .help_str = "set macsec offload <port_id> off", 14139 .tokens = { 14140 (void *)&cmd_macsec_offload_off_set, 14141 (void *)&cmd_macsec_offload_off_macsec, 14142 (void *)&cmd_macsec_offload_off_offload, 14143 (void *)&cmd_macsec_offload_off_port_id, 14144 (void *)&cmd_macsec_offload_off_off, 14145 NULL, 14146 }, 14147 }; 14148 14149 /* Common result structure for MACsec secure connection configure */ 14150 struct cmd_macsec_sc_result { 14151 cmdline_fixed_string_t set; 14152 cmdline_fixed_string_t macsec; 14153 cmdline_fixed_string_t sc; 14154 cmdline_fixed_string_t tx_rx; 14155 portid_t port_id; 14156 struct ether_addr mac; 14157 uint16_t pi; 14158 }; 14159 14160 /* Common CLI fields for MACsec secure connection configure */ 14161 cmdline_parse_token_string_t cmd_macsec_sc_set = 14162 TOKEN_STRING_INITIALIZER 14163 (struct cmd_macsec_sc_result, 14164 set, "set"); 14165 cmdline_parse_token_string_t cmd_macsec_sc_macsec = 14166 TOKEN_STRING_INITIALIZER 14167 (struct cmd_macsec_sc_result, 14168 macsec, "macsec"); 14169 cmdline_parse_token_string_t cmd_macsec_sc_sc = 14170 TOKEN_STRING_INITIALIZER 14171 (struct cmd_macsec_sc_result, 14172 sc, "sc"); 14173 cmdline_parse_token_string_t cmd_macsec_sc_tx_rx = 14174 TOKEN_STRING_INITIALIZER 14175 (struct cmd_macsec_sc_result, 14176 tx_rx, "tx#rx"); 14177 cmdline_parse_token_num_t cmd_macsec_sc_port_id = 14178 TOKEN_NUM_INITIALIZER 14179 (struct cmd_macsec_sc_result, 14180 port_id, UINT16); 14181 cmdline_parse_token_etheraddr_t cmd_macsec_sc_mac = 14182 TOKEN_ETHERADDR_INITIALIZER 14183 (struct cmd_macsec_sc_result, 14184 mac); 14185 cmdline_parse_token_num_t cmd_macsec_sc_pi = 14186 TOKEN_NUM_INITIALIZER 14187 (struct cmd_macsec_sc_result, 14188 pi, UINT16); 14189 14190 static void 14191 cmd_set_macsec_sc_parsed( 14192 void *parsed_result, 14193 __attribute__((unused)) struct cmdline *cl, 14194 __attribute__((unused)) void *data) 14195 { 14196 struct cmd_macsec_sc_result *res = parsed_result; 14197 int ret = -ENOTSUP; 14198 int is_tx = (strcmp(res->tx_rx, "tx") == 0) ? 1 : 0; 14199 14200 #ifdef RTE_LIBRTE_IXGBE_PMD 14201 ret = is_tx ? 14202 rte_pmd_ixgbe_macsec_config_txsc(res->port_id, 14203 res->mac.addr_bytes) : 14204 rte_pmd_ixgbe_macsec_config_rxsc(res->port_id, 14205 res->mac.addr_bytes, res->pi); 14206 #endif 14207 RTE_SET_USED(is_tx); 14208 14209 switch (ret) { 14210 case 0: 14211 break; 14212 case -ENODEV: 14213 printf("invalid port_id %d\n", res->port_id); 14214 break; 14215 case -ENOTSUP: 14216 printf("not supported on port %d\n", res->port_id); 14217 break; 14218 default: 14219 printf("programming error: (%s)\n", strerror(-ret)); 14220 } 14221 } 14222 14223 cmdline_parse_inst_t cmd_set_macsec_sc = { 14224 .f = cmd_set_macsec_sc_parsed, 14225 .data = NULL, 14226 .help_str = "set macsec sc tx|rx <port_id> <mac> <pi>", 14227 .tokens = { 14228 (void *)&cmd_macsec_sc_set, 14229 (void *)&cmd_macsec_sc_macsec, 14230 (void *)&cmd_macsec_sc_sc, 14231 (void *)&cmd_macsec_sc_tx_rx, 14232 (void *)&cmd_macsec_sc_port_id, 14233 (void *)&cmd_macsec_sc_mac, 14234 (void *)&cmd_macsec_sc_pi, 14235 NULL, 14236 }, 14237 }; 14238 14239 /* Common result structure for MACsec secure connection configure */ 14240 struct cmd_macsec_sa_result { 14241 cmdline_fixed_string_t set; 14242 cmdline_fixed_string_t macsec; 14243 cmdline_fixed_string_t sa; 14244 cmdline_fixed_string_t tx_rx; 14245 portid_t port_id; 14246 uint8_t idx; 14247 uint8_t an; 14248 uint32_t pn; 14249 cmdline_fixed_string_t key; 14250 }; 14251 14252 /* Common CLI fields for MACsec secure connection configure */ 14253 cmdline_parse_token_string_t cmd_macsec_sa_set = 14254 TOKEN_STRING_INITIALIZER 14255 (struct cmd_macsec_sa_result, 14256 set, "set"); 14257 cmdline_parse_token_string_t cmd_macsec_sa_macsec = 14258 TOKEN_STRING_INITIALIZER 14259 (struct cmd_macsec_sa_result, 14260 macsec, "macsec"); 14261 cmdline_parse_token_string_t cmd_macsec_sa_sa = 14262 TOKEN_STRING_INITIALIZER 14263 (struct cmd_macsec_sa_result, 14264 sa, "sa"); 14265 cmdline_parse_token_string_t cmd_macsec_sa_tx_rx = 14266 TOKEN_STRING_INITIALIZER 14267 (struct cmd_macsec_sa_result, 14268 tx_rx, "tx#rx"); 14269 cmdline_parse_token_num_t cmd_macsec_sa_port_id = 14270 TOKEN_NUM_INITIALIZER 14271 (struct cmd_macsec_sa_result, 14272 port_id, UINT16); 14273 cmdline_parse_token_num_t cmd_macsec_sa_idx = 14274 TOKEN_NUM_INITIALIZER 14275 (struct cmd_macsec_sa_result, 14276 idx, UINT8); 14277 cmdline_parse_token_num_t cmd_macsec_sa_an = 14278 TOKEN_NUM_INITIALIZER 14279 (struct cmd_macsec_sa_result, 14280 an, UINT8); 14281 cmdline_parse_token_num_t cmd_macsec_sa_pn = 14282 TOKEN_NUM_INITIALIZER 14283 (struct cmd_macsec_sa_result, 14284 pn, UINT32); 14285 cmdline_parse_token_string_t cmd_macsec_sa_key = 14286 TOKEN_STRING_INITIALIZER 14287 (struct cmd_macsec_sa_result, 14288 key, NULL); 14289 14290 static void 14291 cmd_set_macsec_sa_parsed( 14292 void *parsed_result, 14293 __attribute__((unused)) struct cmdline *cl, 14294 __attribute__((unused)) void *data) 14295 { 14296 struct cmd_macsec_sa_result *res = parsed_result; 14297 int ret = -ENOTSUP; 14298 int is_tx = (strcmp(res->tx_rx, "tx") == 0) ? 1 : 0; 14299 uint8_t key[16] = { 0 }; 14300 uint8_t xdgt0; 14301 uint8_t xdgt1; 14302 int key_len; 14303 int i; 14304 14305 key_len = strlen(res->key) / 2; 14306 if (key_len > 16) 14307 key_len = 16; 14308 14309 for (i = 0; i < key_len; i++) { 14310 xdgt0 = parse_and_check_key_hexa_digit(res->key, (i * 2)); 14311 if (xdgt0 == 0xFF) 14312 return; 14313 xdgt1 = parse_and_check_key_hexa_digit(res->key, (i * 2) + 1); 14314 if (xdgt1 == 0xFF) 14315 return; 14316 key[i] = (uint8_t) ((xdgt0 * 16) + xdgt1); 14317 } 14318 14319 #ifdef RTE_LIBRTE_IXGBE_PMD 14320 ret = is_tx ? 14321 rte_pmd_ixgbe_macsec_select_txsa(res->port_id, 14322 res->idx, res->an, res->pn, key) : 14323 rte_pmd_ixgbe_macsec_select_rxsa(res->port_id, 14324 res->idx, res->an, res->pn, key); 14325 #endif 14326 RTE_SET_USED(is_tx); 14327 RTE_SET_USED(key); 14328 14329 switch (ret) { 14330 case 0: 14331 break; 14332 case -EINVAL: 14333 printf("invalid idx %d or an %d\n", res->idx, res->an); 14334 break; 14335 case -ENODEV: 14336 printf("invalid port_id %d\n", res->port_id); 14337 break; 14338 case -ENOTSUP: 14339 printf("not supported on port %d\n", res->port_id); 14340 break; 14341 default: 14342 printf("programming error: (%s)\n", strerror(-ret)); 14343 } 14344 } 14345 14346 cmdline_parse_inst_t cmd_set_macsec_sa = { 14347 .f = cmd_set_macsec_sa_parsed, 14348 .data = NULL, 14349 .help_str = "set macsec sa tx|rx <port_id> <idx> <an> <pn> <key>", 14350 .tokens = { 14351 (void *)&cmd_macsec_sa_set, 14352 (void *)&cmd_macsec_sa_macsec, 14353 (void *)&cmd_macsec_sa_sa, 14354 (void *)&cmd_macsec_sa_tx_rx, 14355 (void *)&cmd_macsec_sa_port_id, 14356 (void *)&cmd_macsec_sa_idx, 14357 (void *)&cmd_macsec_sa_an, 14358 (void *)&cmd_macsec_sa_pn, 14359 (void *)&cmd_macsec_sa_key, 14360 NULL, 14361 }, 14362 }; 14363 14364 /* VF unicast promiscuous mode configuration */ 14365 14366 /* Common result structure for VF unicast promiscuous mode */ 14367 struct cmd_vf_promisc_result { 14368 cmdline_fixed_string_t set; 14369 cmdline_fixed_string_t vf; 14370 cmdline_fixed_string_t promisc; 14371 portid_t port_id; 14372 uint32_t vf_id; 14373 cmdline_fixed_string_t on_off; 14374 }; 14375 14376 /* Common CLI fields for VF unicast promiscuous mode enable disable */ 14377 cmdline_parse_token_string_t cmd_vf_promisc_set = 14378 TOKEN_STRING_INITIALIZER 14379 (struct cmd_vf_promisc_result, 14380 set, "set"); 14381 cmdline_parse_token_string_t cmd_vf_promisc_vf = 14382 TOKEN_STRING_INITIALIZER 14383 (struct cmd_vf_promisc_result, 14384 vf, "vf"); 14385 cmdline_parse_token_string_t cmd_vf_promisc_promisc = 14386 TOKEN_STRING_INITIALIZER 14387 (struct cmd_vf_promisc_result, 14388 promisc, "promisc"); 14389 cmdline_parse_token_num_t cmd_vf_promisc_port_id = 14390 TOKEN_NUM_INITIALIZER 14391 (struct cmd_vf_promisc_result, 14392 port_id, UINT16); 14393 cmdline_parse_token_num_t cmd_vf_promisc_vf_id = 14394 TOKEN_NUM_INITIALIZER 14395 (struct cmd_vf_promisc_result, 14396 vf_id, UINT32); 14397 cmdline_parse_token_string_t cmd_vf_promisc_on_off = 14398 TOKEN_STRING_INITIALIZER 14399 (struct cmd_vf_promisc_result, 14400 on_off, "on#off"); 14401 14402 static void 14403 cmd_set_vf_promisc_parsed( 14404 void *parsed_result, 14405 __attribute__((unused)) struct cmdline *cl, 14406 __attribute__((unused)) void *data) 14407 { 14408 struct cmd_vf_promisc_result *res = parsed_result; 14409 int ret = -ENOTSUP; 14410 14411 __rte_unused int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0; 14412 14413 if (port_id_is_invalid(res->port_id, ENABLED_WARN)) 14414 return; 14415 14416 #ifdef RTE_LIBRTE_I40E_PMD 14417 ret = rte_pmd_i40e_set_vf_unicast_promisc(res->port_id, 14418 res->vf_id, is_on); 14419 #endif 14420 14421 switch (ret) { 14422 case 0: 14423 break; 14424 case -EINVAL: 14425 printf("invalid vf_id %d\n", res->vf_id); 14426 break; 14427 case -ENODEV: 14428 printf("invalid port_id %d\n", res->port_id); 14429 break; 14430 case -ENOTSUP: 14431 printf("function not implemented\n"); 14432 break; 14433 default: 14434 printf("programming error: (%s)\n", strerror(-ret)); 14435 } 14436 } 14437 14438 cmdline_parse_inst_t cmd_set_vf_promisc = { 14439 .f = cmd_set_vf_promisc_parsed, 14440 .data = NULL, 14441 .help_str = "set vf promisc <port_id> <vf_id> on|off: " 14442 "Set unicast promiscuous mode for a VF from the PF", 14443 .tokens = { 14444 (void *)&cmd_vf_promisc_set, 14445 (void *)&cmd_vf_promisc_vf, 14446 (void *)&cmd_vf_promisc_promisc, 14447 (void *)&cmd_vf_promisc_port_id, 14448 (void *)&cmd_vf_promisc_vf_id, 14449 (void *)&cmd_vf_promisc_on_off, 14450 NULL, 14451 }, 14452 }; 14453 14454 /* VF multicast promiscuous mode configuration */ 14455 14456 /* Common result structure for VF multicast promiscuous mode */ 14457 struct cmd_vf_allmulti_result { 14458 cmdline_fixed_string_t set; 14459 cmdline_fixed_string_t vf; 14460 cmdline_fixed_string_t allmulti; 14461 portid_t port_id; 14462 uint32_t vf_id; 14463 cmdline_fixed_string_t on_off; 14464 }; 14465 14466 /* Common CLI fields for VF multicast promiscuous mode enable disable */ 14467 cmdline_parse_token_string_t cmd_vf_allmulti_set = 14468 TOKEN_STRING_INITIALIZER 14469 (struct cmd_vf_allmulti_result, 14470 set, "set"); 14471 cmdline_parse_token_string_t cmd_vf_allmulti_vf = 14472 TOKEN_STRING_INITIALIZER 14473 (struct cmd_vf_allmulti_result, 14474 vf, "vf"); 14475 cmdline_parse_token_string_t cmd_vf_allmulti_allmulti = 14476 TOKEN_STRING_INITIALIZER 14477 (struct cmd_vf_allmulti_result, 14478 allmulti, "allmulti"); 14479 cmdline_parse_token_num_t cmd_vf_allmulti_port_id = 14480 TOKEN_NUM_INITIALIZER 14481 (struct cmd_vf_allmulti_result, 14482 port_id, UINT16); 14483 cmdline_parse_token_num_t cmd_vf_allmulti_vf_id = 14484 TOKEN_NUM_INITIALIZER 14485 (struct cmd_vf_allmulti_result, 14486 vf_id, UINT32); 14487 cmdline_parse_token_string_t cmd_vf_allmulti_on_off = 14488 TOKEN_STRING_INITIALIZER 14489 (struct cmd_vf_allmulti_result, 14490 on_off, "on#off"); 14491 14492 static void 14493 cmd_set_vf_allmulti_parsed( 14494 void *parsed_result, 14495 __attribute__((unused)) struct cmdline *cl, 14496 __attribute__((unused)) void *data) 14497 { 14498 struct cmd_vf_allmulti_result *res = parsed_result; 14499 int ret = -ENOTSUP; 14500 14501 __rte_unused int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0; 14502 14503 if (port_id_is_invalid(res->port_id, ENABLED_WARN)) 14504 return; 14505 14506 #ifdef RTE_LIBRTE_I40E_PMD 14507 ret = rte_pmd_i40e_set_vf_multicast_promisc(res->port_id, 14508 res->vf_id, is_on); 14509 #endif 14510 14511 switch (ret) { 14512 case 0: 14513 break; 14514 case -EINVAL: 14515 printf("invalid vf_id %d\n", res->vf_id); 14516 break; 14517 case -ENODEV: 14518 printf("invalid port_id %d\n", res->port_id); 14519 break; 14520 case -ENOTSUP: 14521 printf("function not implemented\n"); 14522 break; 14523 default: 14524 printf("programming error: (%s)\n", strerror(-ret)); 14525 } 14526 } 14527 14528 cmdline_parse_inst_t cmd_set_vf_allmulti = { 14529 .f = cmd_set_vf_allmulti_parsed, 14530 .data = NULL, 14531 .help_str = "set vf allmulti <port_id> <vf_id> on|off: " 14532 "Set multicast promiscuous mode for a VF from the PF", 14533 .tokens = { 14534 (void *)&cmd_vf_allmulti_set, 14535 (void *)&cmd_vf_allmulti_vf, 14536 (void *)&cmd_vf_allmulti_allmulti, 14537 (void *)&cmd_vf_allmulti_port_id, 14538 (void *)&cmd_vf_allmulti_vf_id, 14539 (void *)&cmd_vf_allmulti_on_off, 14540 NULL, 14541 }, 14542 }; 14543 14544 /* vf broadcast mode configuration */ 14545 14546 /* Common result structure for vf broadcast */ 14547 struct cmd_set_vf_broadcast_result { 14548 cmdline_fixed_string_t set; 14549 cmdline_fixed_string_t vf; 14550 cmdline_fixed_string_t broadcast; 14551 portid_t port_id; 14552 uint16_t vf_id; 14553 cmdline_fixed_string_t on_off; 14554 }; 14555 14556 /* Common CLI fields for vf broadcast enable disable */ 14557 cmdline_parse_token_string_t cmd_set_vf_broadcast_set = 14558 TOKEN_STRING_INITIALIZER 14559 (struct cmd_set_vf_broadcast_result, 14560 set, "set"); 14561 cmdline_parse_token_string_t cmd_set_vf_broadcast_vf = 14562 TOKEN_STRING_INITIALIZER 14563 (struct cmd_set_vf_broadcast_result, 14564 vf, "vf"); 14565 cmdline_parse_token_string_t cmd_set_vf_broadcast_broadcast = 14566 TOKEN_STRING_INITIALIZER 14567 (struct cmd_set_vf_broadcast_result, 14568 broadcast, "broadcast"); 14569 cmdline_parse_token_num_t cmd_set_vf_broadcast_port_id = 14570 TOKEN_NUM_INITIALIZER 14571 (struct cmd_set_vf_broadcast_result, 14572 port_id, UINT16); 14573 cmdline_parse_token_num_t cmd_set_vf_broadcast_vf_id = 14574 TOKEN_NUM_INITIALIZER 14575 (struct cmd_set_vf_broadcast_result, 14576 vf_id, UINT16); 14577 cmdline_parse_token_string_t cmd_set_vf_broadcast_on_off = 14578 TOKEN_STRING_INITIALIZER 14579 (struct cmd_set_vf_broadcast_result, 14580 on_off, "on#off"); 14581 14582 static void 14583 cmd_set_vf_broadcast_parsed( 14584 void *parsed_result, 14585 __attribute__((unused)) struct cmdline *cl, 14586 __attribute__((unused)) void *data) 14587 { 14588 struct cmd_set_vf_broadcast_result *res = parsed_result; 14589 int ret = -ENOTSUP; 14590 14591 __rte_unused int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0; 14592 14593 if (port_id_is_invalid(res->port_id, ENABLED_WARN)) 14594 return; 14595 14596 #ifdef RTE_LIBRTE_I40E_PMD 14597 ret = rte_pmd_i40e_set_vf_broadcast(res->port_id, 14598 res->vf_id, is_on); 14599 #endif 14600 14601 switch (ret) { 14602 case 0: 14603 break; 14604 case -EINVAL: 14605 printf("invalid vf_id %d or is_on %d\n", res->vf_id, is_on); 14606 break; 14607 case -ENODEV: 14608 printf("invalid port_id %d\n", res->port_id); 14609 break; 14610 case -ENOTSUP: 14611 printf("function not implemented\n"); 14612 break; 14613 default: 14614 printf("programming error: (%s)\n", strerror(-ret)); 14615 } 14616 } 14617 14618 cmdline_parse_inst_t cmd_set_vf_broadcast = { 14619 .f = cmd_set_vf_broadcast_parsed, 14620 .data = NULL, 14621 .help_str = "set vf broadcast <port_id> <vf_id> on|off", 14622 .tokens = { 14623 (void *)&cmd_set_vf_broadcast_set, 14624 (void *)&cmd_set_vf_broadcast_vf, 14625 (void *)&cmd_set_vf_broadcast_broadcast, 14626 (void *)&cmd_set_vf_broadcast_port_id, 14627 (void *)&cmd_set_vf_broadcast_vf_id, 14628 (void *)&cmd_set_vf_broadcast_on_off, 14629 NULL, 14630 }, 14631 }; 14632 14633 /* vf vlan tag configuration */ 14634 14635 /* Common result structure for vf vlan tag */ 14636 struct cmd_set_vf_vlan_tag_result { 14637 cmdline_fixed_string_t set; 14638 cmdline_fixed_string_t vf; 14639 cmdline_fixed_string_t vlan; 14640 cmdline_fixed_string_t tag; 14641 portid_t port_id; 14642 uint16_t vf_id; 14643 cmdline_fixed_string_t on_off; 14644 }; 14645 14646 /* Common CLI fields for vf vlan tag enable disable */ 14647 cmdline_parse_token_string_t cmd_set_vf_vlan_tag_set = 14648 TOKEN_STRING_INITIALIZER 14649 (struct cmd_set_vf_vlan_tag_result, 14650 set, "set"); 14651 cmdline_parse_token_string_t cmd_set_vf_vlan_tag_vf = 14652 TOKEN_STRING_INITIALIZER 14653 (struct cmd_set_vf_vlan_tag_result, 14654 vf, "vf"); 14655 cmdline_parse_token_string_t cmd_set_vf_vlan_tag_vlan = 14656 TOKEN_STRING_INITIALIZER 14657 (struct cmd_set_vf_vlan_tag_result, 14658 vlan, "vlan"); 14659 cmdline_parse_token_string_t cmd_set_vf_vlan_tag_tag = 14660 TOKEN_STRING_INITIALIZER 14661 (struct cmd_set_vf_vlan_tag_result, 14662 tag, "tag"); 14663 cmdline_parse_token_num_t cmd_set_vf_vlan_tag_port_id = 14664 TOKEN_NUM_INITIALIZER 14665 (struct cmd_set_vf_vlan_tag_result, 14666 port_id, UINT16); 14667 cmdline_parse_token_num_t cmd_set_vf_vlan_tag_vf_id = 14668 TOKEN_NUM_INITIALIZER 14669 (struct cmd_set_vf_vlan_tag_result, 14670 vf_id, UINT16); 14671 cmdline_parse_token_string_t cmd_set_vf_vlan_tag_on_off = 14672 TOKEN_STRING_INITIALIZER 14673 (struct cmd_set_vf_vlan_tag_result, 14674 on_off, "on#off"); 14675 14676 static void 14677 cmd_set_vf_vlan_tag_parsed( 14678 void *parsed_result, 14679 __attribute__((unused)) struct cmdline *cl, 14680 __attribute__((unused)) void *data) 14681 { 14682 struct cmd_set_vf_vlan_tag_result *res = parsed_result; 14683 int ret = -ENOTSUP; 14684 14685 __rte_unused int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0; 14686 14687 if (port_id_is_invalid(res->port_id, ENABLED_WARN)) 14688 return; 14689 14690 #ifdef RTE_LIBRTE_I40E_PMD 14691 ret = rte_pmd_i40e_set_vf_vlan_tag(res->port_id, 14692 res->vf_id, is_on); 14693 #endif 14694 14695 switch (ret) { 14696 case 0: 14697 break; 14698 case -EINVAL: 14699 printf("invalid vf_id %d or is_on %d\n", res->vf_id, is_on); 14700 break; 14701 case -ENODEV: 14702 printf("invalid port_id %d\n", res->port_id); 14703 break; 14704 case -ENOTSUP: 14705 printf("function not implemented\n"); 14706 break; 14707 default: 14708 printf("programming error: (%s)\n", strerror(-ret)); 14709 } 14710 } 14711 14712 cmdline_parse_inst_t cmd_set_vf_vlan_tag = { 14713 .f = cmd_set_vf_vlan_tag_parsed, 14714 .data = NULL, 14715 .help_str = "set vf vlan tag <port_id> <vf_id> on|off", 14716 .tokens = { 14717 (void *)&cmd_set_vf_vlan_tag_set, 14718 (void *)&cmd_set_vf_vlan_tag_vf, 14719 (void *)&cmd_set_vf_vlan_tag_vlan, 14720 (void *)&cmd_set_vf_vlan_tag_tag, 14721 (void *)&cmd_set_vf_vlan_tag_port_id, 14722 (void *)&cmd_set_vf_vlan_tag_vf_id, 14723 (void *)&cmd_set_vf_vlan_tag_on_off, 14724 NULL, 14725 }, 14726 }; 14727 14728 /* Common definition of VF and TC TX bandwidth configuration */ 14729 struct cmd_vf_tc_bw_result { 14730 cmdline_fixed_string_t set; 14731 cmdline_fixed_string_t vf; 14732 cmdline_fixed_string_t tc; 14733 cmdline_fixed_string_t tx; 14734 cmdline_fixed_string_t min_bw; 14735 cmdline_fixed_string_t max_bw; 14736 cmdline_fixed_string_t strict_link_prio; 14737 portid_t port_id; 14738 uint16_t vf_id; 14739 uint8_t tc_no; 14740 uint32_t bw; 14741 cmdline_fixed_string_t bw_list; 14742 uint8_t tc_map; 14743 }; 14744 14745 cmdline_parse_token_string_t cmd_vf_tc_bw_set = 14746 TOKEN_STRING_INITIALIZER 14747 (struct cmd_vf_tc_bw_result, 14748 set, "set"); 14749 cmdline_parse_token_string_t cmd_vf_tc_bw_vf = 14750 TOKEN_STRING_INITIALIZER 14751 (struct cmd_vf_tc_bw_result, 14752 vf, "vf"); 14753 cmdline_parse_token_string_t cmd_vf_tc_bw_tc = 14754 TOKEN_STRING_INITIALIZER 14755 (struct cmd_vf_tc_bw_result, 14756 tc, "tc"); 14757 cmdline_parse_token_string_t cmd_vf_tc_bw_tx = 14758 TOKEN_STRING_INITIALIZER 14759 (struct cmd_vf_tc_bw_result, 14760 tx, "tx"); 14761 cmdline_parse_token_string_t cmd_vf_tc_bw_strict_link_prio = 14762 TOKEN_STRING_INITIALIZER 14763 (struct cmd_vf_tc_bw_result, 14764 strict_link_prio, "strict-link-priority"); 14765 cmdline_parse_token_string_t cmd_vf_tc_bw_min_bw = 14766 TOKEN_STRING_INITIALIZER 14767 (struct cmd_vf_tc_bw_result, 14768 min_bw, "min-bandwidth"); 14769 cmdline_parse_token_string_t cmd_vf_tc_bw_max_bw = 14770 TOKEN_STRING_INITIALIZER 14771 (struct cmd_vf_tc_bw_result, 14772 max_bw, "max-bandwidth"); 14773 cmdline_parse_token_num_t cmd_vf_tc_bw_port_id = 14774 TOKEN_NUM_INITIALIZER 14775 (struct cmd_vf_tc_bw_result, 14776 port_id, UINT16); 14777 cmdline_parse_token_num_t cmd_vf_tc_bw_vf_id = 14778 TOKEN_NUM_INITIALIZER 14779 (struct cmd_vf_tc_bw_result, 14780 vf_id, UINT16); 14781 cmdline_parse_token_num_t cmd_vf_tc_bw_tc_no = 14782 TOKEN_NUM_INITIALIZER 14783 (struct cmd_vf_tc_bw_result, 14784 tc_no, UINT8); 14785 cmdline_parse_token_num_t cmd_vf_tc_bw_bw = 14786 TOKEN_NUM_INITIALIZER 14787 (struct cmd_vf_tc_bw_result, 14788 bw, UINT32); 14789 cmdline_parse_token_string_t cmd_vf_tc_bw_bw_list = 14790 TOKEN_STRING_INITIALIZER 14791 (struct cmd_vf_tc_bw_result, 14792 bw_list, NULL); 14793 cmdline_parse_token_num_t cmd_vf_tc_bw_tc_map = 14794 TOKEN_NUM_INITIALIZER 14795 (struct cmd_vf_tc_bw_result, 14796 tc_map, UINT8); 14797 14798 /* VF max bandwidth setting */ 14799 static void 14800 cmd_vf_max_bw_parsed( 14801 void *parsed_result, 14802 __attribute__((unused)) struct cmdline *cl, 14803 __attribute__((unused)) void *data) 14804 { 14805 struct cmd_vf_tc_bw_result *res = parsed_result; 14806 int ret = -ENOTSUP; 14807 14808 if (port_id_is_invalid(res->port_id, ENABLED_WARN)) 14809 return; 14810 14811 #ifdef RTE_LIBRTE_I40E_PMD 14812 ret = rte_pmd_i40e_set_vf_max_bw(res->port_id, 14813 res->vf_id, res->bw); 14814 #endif 14815 14816 switch (ret) { 14817 case 0: 14818 break; 14819 case -EINVAL: 14820 printf("invalid vf_id %d or bandwidth %d\n", 14821 res->vf_id, res->bw); 14822 break; 14823 case -ENODEV: 14824 printf("invalid port_id %d\n", res->port_id); 14825 break; 14826 case -ENOTSUP: 14827 printf("function not implemented\n"); 14828 break; 14829 default: 14830 printf("programming error: (%s)\n", strerror(-ret)); 14831 } 14832 } 14833 14834 cmdline_parse_inst_t cmd_vf_max_bw = { 14835 .f = cmd_vf_max_bw_parsed, 14836 .data = NULL, 14837 .help_str = "set vf tx max-bandwidth <port_id> <vf_id> <bandwidth>", 14838 .tokens = { 14839 (void *)&cmd_vf_tc_bw_set, 14840 (void *)&cmd_vf_tc_bw_vf, 14841 (void *)&cmd_vf_tc_bw_tx, 14842 (void *)&cmd_vf_tc_bw_max_bw, 14843 (void *)&cmd_vf_tc_bw_port_id, 14844 (void *)&cmd_vf_tc_bw_vf_id, 14845 (void *)&cmd_vf_tc_bw_bw, 14846 NULL, 14847 }, 14848 }; 14849 14850 static int 14851 vf_tc_min_bw_parse_bw_list(uint8_t *bw_list, 14852 uint8_t *tc_num, 14853 char *str) 14854 { 14855 uint32_t size; 14856 const char *p, *p0 = str; 14857 char s[256]; 14858 char *end; 14859 char *str_fld[16]; 14860 uint16_t i; 14861 int ret; 14862 14863 p = strchr(p0, '('); 14864 if (p == NULL) { 14865 printf("The bandwidth-list should be '(bw1, bw2, ...)'\n"); 14866 return -1; 14867 } 14868 p++; 14869 p0 = strchr(p, ')'); 14870 if (p0 == NULL) { 14871 printf("The bandwidth-list should be '(bw1, bw2, ...)'\n"); 14872 return -1; 14873 } 14874 size = p0 - p; 14875 if (size >= sizeof(s)) { 14876 printf("The string size exceeds the internal buffer size\n"); 14877 return -1; 14878 } 14879 snprintf(s, sizeof(s), "%.*s", size, p); 14880 ret = rte_strsplit(s, sizeof(s), str_fld, 16, ','); 14881 if (ret <= 0) { 14882 printf("Failed to get the bandwidth list. "); 14883 return -1; 14884 } 14885 *tc_num = ret; 14886 for (i = 0; i < ret; i++) 14887 bw_list[i] = (uint8_t)strtoul(str_fld[i], &end, 0); 14888 14889 return 0; 14890 } 14891 14892 /* TC min bandwidth setting */ 14893 static void 14894 cmd_vf_tc_min_bw_parsed( 14895 void *parsed_result, 14896 __attribute__((unused)) struct cmdline *cl, 14897 __attribute__((unused)) void *data) 14898 { 14899 struct cmd_vf_tc_bw_result *res = parsed_result; 14900 uint8_t tc_num; 14901 uint8_t bw[16]; 14902 int ret = -ENOTSUP; 14903 14904 if (port_id_is_invalid(res->port_id, ENABLED_WARN)) 14905 return; 14906 14907 ret = vf_tc_min_bw_parse_bw_list(bw, &tc_num, res->bw_list); 14908 if (ret) 14909 return; 14910 14911 #ifdef RTE_LIBRTE_I40E_PMD 14912 ret = rte_pmd_i40e_set_vf_tc_bw_alloc(res->port_id, res->vf_id, 14913 tc_num, bw); 14914 #endif 14915 14916 switch (ret) { 14917 case 0: 14918 break; 14919 case -EINVAL: 14920 printf("invalid vf_id %d or bandwidth\n", res->vf_id); 14921 break; 14922 case -ENODEV: 14923 printf("invalid port_id %d\n", res->port_id); 14924 break; 14925 case -ENOTSUP: 14926 printf("function not implemented\n"); 14927 break; 14928 default: 14929 printf("programming error: (%s)\n", strerror(-ret)); 14930 } 14931 } 14932 14933 cmdline_parse_inst_t cmd_vf_tc_min_bw = { 14934 .f = cmd_vf_tc_min_bw_parsed, 14935 .data = NULL, 14936 .help_str = "set vf tc tx min-bandwidth <port_id> <vf_id>" 14937 " <bw1, bw2, ...>", 14938 .tokens = { 14939 (void *)&cmd_vf_tc_bw_set, 14940 (void *)&cmd_vf_tc_bw_vf, 14941 (void *)&cmd_vf_tc_bw_tc, 14942 (void *)&cmd_vf_tc_bw_tx, 14943 (void *)&cmd_vf_tc_bw_min_bw, 14944 (void *)&cmd_vf_tc_bw_port_id, 14945 (void *)&cmd_vf_tc_bw_vf_id, 14946 (void *)&cmd_vf_tc_bw_bw_list, 14947 NULL, 14948 }, 14949 }; 14950 14951 static void 14952 cmd_tc_min_bw_parsed( 14953 void *parsed_result, 14954 __attribute__((unused)) struct cmdline *cl, 14955 __attribute__((unused)) void *data) 14956 { 14957 struct cmd_vf_tc_bw_result *res = parsed_result; 14958 struct rte_port *port; 14959 uint8_t tc_num; 14960 uint8_t bw[16]; 14961 int ret = -ENOTSUP; 14962 14963 if (port_id_is_invalid(res->port_id, ENABLED_WARN)) 14964 return; 14965 14966 port = &ports[res->port_id]; 14967 /** Check if the port is not started **/ 14968 if (port->port_status != RTE_PORT_STOPPED) { 14969 printf("Please stop port %d first\n", res->port_id); 14970 return; 14971 } 14972 14973 ret = vf_tc_min_bw_parse_bw_list(bw, &tc_num, res->bw_list); 14974 if (ret) 14975 return; 14976 14977 #ifdef RTE_LIBRTE_IXGBE_PMD 14978 ret = rte_pmd_ixgbe_set_tc_bw_alloc(res->port_id, tc_num, bw); 14979 #endif 14980 14981 switch (ret) { 14982 case 0: 14983 break; 14984 case -EINVAL: 14985 printf("invalid bandwidth\n"); 14986 break; 14987 case -ENODEV: 14988 printf("invalid port_id %d\n", res->port_id); 14989 break; 14990 case -ENOTSUP: 14991 printf("function not implemented\n"); 14992 break; 14993 default: 14994 printf("programming error: (%s)\n", strerror(-ret)); 14995 } 14996 } 14997 14998 cmdline_parse_inst_t cmd_tc_min_bw = { 14999 .f = cmd_tc_min_bw_parsed, 15000 .data = NULL, 15001 .help_str = "set tc tx min-bandwidth <port_id> <bw1, bw2, ...>", 15002 .tokens = { 15003 (void *)&cmd_vf_tc_bw_set, 15004 (void *)&cmd_vf_tc_bw_tc, 15005 (void *)&cmd_vf_tc_bw_tx, 15006 (void *)&cmd_vf_tc_bw_min_bw, 15007 (void *)&cmd_vf_tc_bw_port_id, 15008 (void *)&cmd_vf_tc_bw_bw_list, 15009 NULL, 15010 }, 15011 }; 15012 15013 /* TC max bandwidth setting */ 15014 static void 15015 cmd_vf_tc_max_bw_parsed( 15016 void *parsed_result, 15017 __attribute__((unused)) struct cmdline *cl, 15018 __attribute__((unused)) void *data) 15019 { 15020 struct cmd_vf_tc_bw_result *res = parsed_result; 15021 int ret = -ENOTSUP; 15022 15023 if (port_id_is_invalid(res->port_id, ENABLED_WARN)) 15024 return; 15025 15026 #ifdef RTE_LIBRTE_I40E_PMD 15027 ret = rte_pmd_i40e_set_vf_tc_max_bw(res->port_id, res->vf_id, 15028 res->tc_no, res->bw); 15029 #endif 15030 15031 switch (ret) { 15032 case 0: 15033 break; 15034 case -EINVAL: 15035 printf("invalid vf_id %d, tc_no %d or bandwidth %d\n", 15036 res->vf_id, res->tc_no, res->bw); 15037 break; 15038 case -ENODEV: 15039 printf("invalid port_id %d\n", res->port_id); 15040 break; 15041 case -ENOTSUP: 15042 printf("function not implemented\n"); 15043 break; 15044 default: 15045 printf("programming error: (%s)\n", strerror(-ret)); 15046 } 15047 } 15048 15049 cmdline_parse_inst_t cmd_vf_tc_max_bw = { 15050 .f = cmd_vf_tc_max_bw_parsed, 15051 .data = NULL, 15052 .help_str = "set vf tc tx max-bandwidth <port_id> <vf_id> <tc_no>" 15053 " <bandwidth>", 15054 .tokens = { 15055 (void *)&cmd_vf_tc_bw_set, 15056 (void *)&cmd_vf_tc_bw_vf, 15057 (void *)&cmd_vf_tc_bw_tc, 15058 (void *)&cmd_vf_tc_bw_tx, 15059 (void *)&cmd_vf_tc_bw_max_bw, 15060 (void *)&cmd_vf_tc_bw_port_id, 15061 (void *)&cmd_vf_tc_bw_vf_id, 15062 (void *)&cmd_vf_tc_bw_tc_no, 15063 (void *)&cmd_vf_tc_bw_bw, 15064 NULL, 15065 }, 15066 }; 15067 15068 15069 #if defined RTE_LIBRTE_PMD_SOFTNIC && defined RTE_LIBRTE_SCHED 15070 15071 /* *** Set Port default Traffic Management Hierarchy *** */ 15072 struct cmd_set_port_tm_hierarchy_default_result { 15073 cmdline_fixed_string_t set; 15074 cmdline_fixed_string_t port; 15075 cmdline_fixed_string_t tm; 15076 cmdline_fixed_string_t hierarchy; 15077 cmdline_fixed_string_t def; 15078 portid_t port_id; 15079 }; 15080 15081 cmdline_parse_token_string_t cmd_set_port_tm_hierarchy_default_set = 15082 TOKEN_STRING_INITIALIZER( 15083 struct cmd_set_port_tm_hierarchy_default_result, set, "set"); 15084 cmdline_parse_token_string_t cmd_set_port_tm_hierarchy_default_port = 15085 TOKEN_STRING_INITIALIZER( 15086 struct cmd_set_port_tm_hierarchy_default_result, port, "port"); 15087 cmdline_parse_token_string_t cmd_set_port_tm_hierarchy_default_tm = 15088 TOKEN_STRING_INITIALIZER( 15089 struct cmd_set_port_tm_hierarchy_default_result, tm, "tm"); 15090 cmdline_parse_token_string_t cmd_set_port_tm_hierarchy_default_hierarchy = 15091 TOKEN_STRING_INITIALIZER( 15092 struct cmd_set_port_tm_hierarchy_default_result, 15093 hierarchy, "hierarchy"); 15094 cmdline_parse_token_string_t cmd_set_port_tm_hierarchy_default_default = 15095 TOKEN_STRING_INITIALIZER( 15096 struct cmd_set_port_tm_hierarchy_default_result, 15097 def, "default"); 15098 cmdline_parse_token_num_t cmd_set_port_tm_hierarchy_default_port_id = 15099 TOKEN_NUM_INITIALIZER( 15100 struct cmd_set_port_tm_hierarchy_default_result, 15101 port_id, UINT16); 15102 15103 static void cmd_set_port_tm_hierarchy_default_parsed(void *parsed_result, 15104 __attribute__((unused)) struct cmdline *cl, 15105 __attribute__((unused)) void *data) 15106 { 15107 struct cmd_set_port_tm_hierarchy_default_result *res = parsed_result; 15108 struct rte_port *p; 15109 portid_t port_id = res->port_id; 15110 15111 if (port_id_is_invalid(port_id, ENABLED_WARN)) 15112 return; 15113 15114 p = &ports[port_id]; 15115 15116 /* Forward mode: tm */ 15117 if (strcmp(cur_fwd_config.fwd_eng->fwd_mode_name, "softnic")) { 15118 printf(" softnicfwd mode not enabled(error)\n"); 15119 return; 15120 } 15121 15122 /* Set the default tm hierarchy */ 15123 p->softport.default_tm_hierarchy_enable = 1; 15124 } 15125 15126 cmdline_parse_inst_t cmd_set_port_tm_hierarchy_default = { 15127 .f = cmd_set_port_tm_hierarchy_default_parsed, 15128 .data = NULL, 15129 .help_str = "set port tm hierarchy default <port_id>", 15130 .tokens = { 15131 (void *)&cmd_set_port_tm_hierarchy_default_set, 15132 (void *)&cmd_set_port_tm_hierarchy_default_port, 15133 (void *)&cmd_set_port_tm_hierarchy_default_tm, 15134 (void *)&cmd_set_port_tm_hierarchy_default_hierarchy, 15135 (void *)&cmd_set_port_tm_hierarchy_default_default, 15136 (void *)&cmd_set_port_tm_hierarchy_default_port_id, 15137 NULL, 15138 }, 15139 }; 15140 #endif 15141 15142 /** Set VXLAN encapsulation details */ 15143 struct cmd_set_vxlan_result { 15144 cmdline_fixed_string_t set; 15145 cmdline_fixed_string_t vxlan; 15146 cmdline_fixed_string_t pos_token; 15147 cmdline_fixed_string_t ip_version; 15148 uint32_t vlan_present:1; 15149 uint32_t vni; 15150 uint16_t udp_src; 15151 uint16_t udp_dst; 15152 cmdline_ipaddr_t ip_src; 15153 cmdline_ipaddr_t ip_dst; 15154 uint16_t tci; 15155 struct ether_addr eth_src; 15156 struct ether_addr eth_dst; 15157 }; 15158 15159 cmdline_parse_token_string_t cmd_set_vxlan_set = 15160 TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, set, "set"); 15161 cmdline_parse_token_string_t cmd_set_vxlan_vxlan = 15162 TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, vxlan, "vxlan"); 15163 cmdline_parse_token_string_t cmd_set_vxlan_vxlan_with_vlan = 15164 TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, vxlan, 15165 "vxlan-with-vlan"); 15166 cmdline_parse_token_string_t cmd_set_vxlan_ip_version = 15167 TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, pos_token, 15168 "ip-version"); 15169 cmdline_parse_token_string_t cmd_set_vxlan_ip_version_value = 15170 TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, ip_version, 15171 "ipv4#ipv6"); 15172 cmdline_parse_token_string_t cmd_set_vxlan_vni = 15173 TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, pos_token, 15174 "vni"); 15175 cmdline_parse_token_num_t cmd_set_vxlan_vni_value = 15176 TOKEN_NUM_INITIALIZER(struct cmd_set_vxlan_result, vni, UINT32); 15177 cmdline_parse_token_string_t cmd_set_vxlan_udp_src = 15178 TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, pos_token, 15179 "udp-src"); 15180 cmdline_parse_token_num_t cmd_set_vxlan_udp_src_value = 15181 TOKEN_NUM_INITIALIZER(struct cmd_set_vxlan_result, udp_src, UINT16); 15182 cmdline_parse_token_string_t cmd_set_vxlan_udp_dst = 15183 TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, pos_token, 15184 "udp-dst"); 15185 cmdline_parse_token_num_t cmd_set_vxlan_udp_dst_value = 15186 TOKEN_NUM_INITIALIZER(struct cmd_set_vxlan_result, udp_dst, UINT16); 15187 cmdline_parse_token_string_t cmd_set_vxlan_ip_src = 15188 TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, pos_token, 15189 "ip-src"); 15190 cmdline_parse_token_ipaddr_t cmd_set_vxlan_ip_src_value = 15191 TOKEN_IPADDR_INITIALIZER(struct cmd_set_vxlan_result, ip_src); 15192 cmdline_parse_token_string_t cmd_set_vxlan_ip_dst = 15193 TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, pos_token, 15194 "ip-dst"); 15195 cmdline_parse_token_ipaddr_t cmd_set_vxlan_ip_dst_value = 15196 TOKEN_IPADDR_INITIALIZER(struct cmd_set_vxlan_result, ip_dst); 15197 cmdline_parse_token_string_t cmd_set_vxlan_vlan = 15198 TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, pos_token, 15199 "vlan-tci"); 15200 cmdline_parse_token_num_t cmd_set_vxlan_vlan_value = 15201 TOKEN_NUM_INITIALIZER(struct cmd_set_vxlan_result, tci, UINT16); 15202 cmdline_parse_token_string_t cmd_set_vxlan_eth_src = 15203 TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, pos_token, 15204 "eth-src"); 15205 cmdline_parse_token_etheraddr_t cmd_set_vxlan_eth_src_value = 15206 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_vxlan_result, eth_src); 15207 cmdline_parse_token_string_t cmd_set_vxlan_eth_dst = 15208 TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, pos_token, 15209 "eth-dst"); 15210 cmdline_parse_token_etheraddr_t cmd_set_vxlan_eth_dst_value = 15211 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_vxlan_result, eth_dst); 15212 15213 static void cmd_set_vxlan_parsed(void *parsed_result, 15214 __attribute__((unused)) struct cmdline *cl, 15215 __attribute__((unused)) void *data) 15216 { 15217 struct cmd_set_vxlan_result *res = parsed_result; 15218 union { 15219 uint32_t vxlan_id; 15220 uint8_t vni[4]; 15221 } id = { 15222 .vxlan_id = rte_cpu_to_be_32(res->vni) & RTE_BE32(0x00ffffff), 15223 }; 15224 15225 if (strcmp(res->vxlan, "vxlan") == 0) 15226 vxlan_encap_conf.select_vlan = 0; 15227 else if (strcmp(res->vxlan, "vxlan-with-vlan") == 0) 15228 vxlan_encap_conf.select_vlan = 1; 15229 if (strcmp(res->ip_version, "ipv4") == 0) 15230 vxlan_encap_conf.select_ipv4 = 1; 15231 else if (strcmp(res->ip_version, "ipv6") == 0) 15232 vxlan_encap_conf.select_ipv4 = 0; 15233 else 15234 return; 15235 rte_memcpy(vxlan_encap_conf.vni, &id.vni[1], 3); 15236 vxlan_encap_conf.udp_src = rte_cpu_to_be_16(res->udp_src); 15237 vxlan_encap_conf.udp_dst = rte_cpu_to_be_16(res->udp_dst); 15238 if (vxlan_encap_conf.select_ipv4) { 15239 IPV4_ADDR_TO_UINT(res->ip_src, vxlan_encap_conf.ipv4_src); 15240 IPV4_ADDR_TO_UINT(res->ip_dst, vxlan_encap_conf.ipv4_dst); 15241 } else { 15242 IPV6_ADDR_TO_ARRAY(res->ip_src, vxlan_encap_conf.ipv6_src); 15243 IPV6_ADDR_TO_ARRAY(res->ip_dst, vxlan_encap_conf.ipv6_dst); 15244 } 15245 if (vxlan_encap_conf.select_vlan) 15246 vxlan_encap_conf.vlan_tci = rte_cpu_to_be_16(res->tci); 15247 rte_memcpy(vxlan_encap_conf.eth_src, res->eth_src.addr_bytes, 15248 ETHER_ADDR_LEN); 15249 rte_memcpy(vxlan_encap_conf.eth_dst, res->eth_dst.addr_bytes, 15250 ETHER_ADDR_LEN); 15251 } 15252 15253 cmdline_parse_inst_t cmd_set_vxlan = { 15254 .f = cmd_set_vxlan_parsed, 15255 .data = NULL, 15256 .help_str = "set vxlan ip-version ipv4|ipv6 vni <vni> udp-src" 15257 " <udp-src> udp-dst <udp-dst> ip-src <ip-src> ip-dst <ip-dst>" 15258 " eth-src <eth-src> eth-dst <eth-dst>", 15259 .tokens = { 15260 (void *)&cmd_set_vxlan_set, 15261 (void *)&cmd_set_vxlan_vxlan, 15262 (void *)&cmd_set_vxlan_ip_version, 15263 (void *)&cmd_set_vxlan_ip_version_value, 15264 (void *)&cmd_set_vxlan_vni, 15265 (void *)&cmd_set_vxlan_vni_value, 15266 (void *)&cmd_set_vxlan_udp_src, 15267 (void *)&cmd_set_vxlan_udp_src_value, 15268 (void *)&cmd_set_vxlan_udp_dst, 15269 (void *)&cmd_set_vxlan_udp_dst_value, 15270 (void *)&cmd_set_vxlan_ip_src, 15271 (void *)&cmd_set_vxlan_ip_src_value, 15272 (void *)&cmd_set_vxlan_ip_dst, 15273 (void *)&cmd_set_vxlan_ip_dst_value, 15274 (void *)&cmd_set_vxlan_eth_src, 15275 (void *)&cmd_set_vxlan_eth_src_value, 15276 (void *)&cmd_set_vxlan_eth_dst, 15277 (void *)&cmd_set_vxlan_eth_dst_value, 15278 NULL, 15279 }, 15280 }; 15281 15282 cmdline_parse_inst_t cmd_set_vxlan_with_vlan = { 15283 .f = cmd_set_vxlan_parsed, 15284 .data = NULL, 15285 .help_str = "set vxlan-with-vlan ip-version ipv4|ipv6 vni <vni>" 15286 " udp-src <udp-src> udp-dst <udp-dst> ip-src <ip-src> ip-dst" 15287 " <ip-dst> vlan-tci <vlan-tci> eth-src <eth-src> eth-dst" 15288 " <eth-dst>", 15289 .tokens = { 15290 (void *)&cmd_set_vxlan_set, 15291 (void *)&cmd_set_vxlan_vxlan_with_vlan, 15292 (void *)&cmd_set_vxlan_ip_version, 15293 (void *)&cmd_set_vxlan_ip_version_value, 15294 (void *)&cmd_set_vxlan_vni, 15295 (void *)&cmd_set_vxlan_vni_value, 15296 (void *)&cmd_set_vxlan_udp_src, 15297 (void *)&cmd_set_vxlan_udp_src_value, 15298 (void *)&cmd_set_vxlan_udp_dst, 15299 (void *)&cmd_set_vxlan_udp_dst_value, 15300 (void *)&cmd_set_vxlan_ip_src, 15301 (void *)&cmd_set_vxlan_ip_src_value, 15302 (void *)&cmd_set_vxlan_ip_dst, 15303 (void *)&cmd_set_vxlan_ip_dst_value, 15304 (void *)&cmd_set_vxlan_vlan, 15305 (void *)&cmd_set_vxlan_vlan_value, 15306 (void *)&cmd_set_vxlan_eth_src, 15307 (void *)&cmd_set_vxlan_eth_src_value, 15308 (void *)&cmd_set_vxlan_eth_dst, 15309 (void *)&cmd_set_vxlan_eth_dst_value, 15310 NULL, 15311 }, 15312 }; 15313 15314 /** Set NVGRE encapsulation details */ 15315 struct cmd_set_nvgre_result { 15316 cmdline_fixed_string_t set; 15317 cmdline_fixed_string_t nvgre; 15318 cmdline_fixed_string_t pos_token; 15319 cmdline_fixed_string_t ip_version; 15320 uint32_t tni; 15321 cmdline_ipaddr_t ip_src; 15322 cmdline_ipaddr_t ip_dst; 15323 uint16_t tci; 15324 struct ether_addr eth_src; 15325 struct ether_addr eth_dst; 15326 }; 15327 15328 cmdline_parse_token_string_t cmd_set_nvgre_set = 15329 TOKEN_STRING_INITIALIZER(struct cmd_set_nvgre_result, set, "set"); 15330 cmdline_parse_token_string_t cmd_set_nvgre_nvgre = 15331 TOKEN_STRING_INITIALIZER(struct cmd_set_nvgre_result, nvgre, "nvgre"); 15332 cmdline_parse_token_string_t cmd_set_nvgre_nvgre_with_vlan = 15333 TOKEN_STRING_INITIALIZER(struct cmd_set_nvgre_result, nvgre, 15334 "nvgre-with-vlan"); 15335 cmdline_parse_token_string_t cmd_set_nvgre_ip_version = 15336 TOKEN_STRING_INITIALIZER(struct cmd_set_nvgre_result, pos_token, 15337 "ip-version"); 15338 cmdline_parse_token_string_t cmd_set_nvgre_ip_version_value = 15339 TOKEN_STRING_INITIALIZER(struct cmd_set_nvgre_result, ip_version, 15340 "ipv4#ipv6"); 15341 cmdline_parse_token_string_t cmd_set_nvgre_tni = 15342 TOKEN_STRING_INITIALIZER(struct cmd_set_nvgre_result, pos_token, 15343 "tni"); 15344 cmdline_parse_token_num_t cmd_set_nvgre_tni_value = 15345 TOKEN_NUM_INITIALIZER(struct cmd_set_nvgre_result, tni, UINT32); 15346 cmdline_parse_token_string_t cmd_set_nvgre_ip_src = 15347 TOKEN_STRING_INITIALIZER(struct cmd_set_nvgre_result, pos_token, 15348 "ip-src"); 15349 cmdline_parse_token_num_t cmd_set_nvgre_ip_src_value = 15350 TOKEN_IPADDR_INITIALIZER(struct cmd_set_nvgre_result, ip_src); 15351 cmdline_parse_token_string_t cmd_set_nvgre_ip_dst = 15352 TOKEN_STRING_INITIALIZER(struct cmd_set_nvgre_result, pos_token, 15353 "ip-dst"); 15354 cmdline_parse_token_ipaddr_t cmd_set_nvgre_ip_dst_value = 15355 TOKEN_IPADDR_INITIALIZER(struct cmd_set_nvgre_result, ip_dst); 15356 cmdline_parse_token_string_t cmd_set_nvgre_vlan = 15357 TOKEN_STRING_INITIALIZER(struct cmd_set_nvgre_result, pos_token, 15358 "vlan-tci"); 15359 cmdline_parse_token_num_t cmd_set_nvgre_vlan_value = 15360 TOKEN_NUM_INITIALIZER(struct cmd_set_nvgre_result, tci, UINT16); 15361 cmdline_parse_token_string_t cmd_set_nvgre_eth_src = 15362 TOKEN_STRING_INITIALIZER(struct cmd_set_nvgre_result, pos_token, 15363 "eth-src"); 15364 cmdline_parse_token_etheraddr_t cmd_set_nvgre_eth_src_value = 15365 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_nvgre_result, eth_src); 15366 cmdline_parse_token_string_t cmd_set_nvgre_eth_dst = 15367 TOKEN_STRING_INITIALIZER(struct cmd_set_nvgre_result, pos_token, 15368 "eth-dst"); 15369 cmdline_parse_token_etheraddr_t cmd_set_nvgre_eth_dst_value = 15370 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_nvgre_result, eth_dst); 15371 15372 static void cmd_set_nvgre_parsed(void *parsed_result, 15373 __attribute__((unused)) struct cmdline *cl, 15374 __attribute__((unused)) void *data) 15375 { 15376 struct cmd_set_nvgre_result *res = parsed_result; 15377 union { 15378 uint32_t nvgre_tni; 15379 uint8_t tni[4]; 15380 } id = { 15381 .nvgre_tni = rte_cpu_to_be_32(res->tni) & RTE_BE32(0x00ffffff), 15382 }; 15383 15384 if (strcmp(res->nvgre, "nvgre") == 0) 15385 nvgre_encap_conf.select_vlan = 0; 15386 else if (strcmp(res->nvgre, "nvgre-with-vlan") == 0) 15387 nvgre_encap_conf.select_vlan = 1; 15388 if (strcmp(res->ip_version, "ipv4") == 0) 15389 nvgre_encap_conf.select_ipv4 = 1; 15390 else if (strcmp(res->ip_version, "ipv6") == 0) 15391 nvgre_encap_conf.select_ipv4 = 0; 15392 else 15393 return; 15394 rte_memcpy(nvgre_encap_conf.tni, &id.tni[1], 3); 15395 if (nvgre_encap_conf.select_ipv4) { 15396 IPV4_ADDR_TO_UINT(res->ip_src, nvgre_encap_conf.ipv4_src); 15397 IPV4_ADDR_TO_UINT(res->ip_dst, nvgre_encap_conf.ipv4_dst); 15398 } else { 15399 IPV6_ADDR_TO_ARRAY(res->ip_src, nvgre_encap_conf.ipv6_src); 15400 IPV6_ADDR_TO_ARRAY(res->ip_dst, nvgre_encap_conf.ipv6_dst); 15401 } 15402 if (nvgre_encap_conf.select_vlan) 15403 nvgre_encap_conf.vlan_tci = rte_cpu_to_be_16(res->tci); 15404 rte_memcpy(nvgre_encap_conf.eth_src, res->eth_src.addr_bytes, 15405 ETHER_ADDR_LEN); 15406 rte_memcpy(nvgre_encap_conf.eth_dst, res->eth_dst.addr_bytes, 15407 ETHER_ADDR_LEN); 15408 } 15409 15410 cmdline_parse_inst_t cmd_set_nvgre = { 15411 .f = cmd_set_nvgre_parsed, 15412 .data = NULL, 15413 .help_str = "set nvgre ip-version <ipv4|ipv6> tni <tni> ip-src" 15414 " <ip-src> ip-dst <ip-dst> eth-src <eth-src>" 15415 " eth-dst <eth-dst>", 15416 .tokens = { 15417 (void *)&cmd_set_nvgre_set, 15418 (void *)&cmd_set_nvgre_nvgre, 15419 (void *)&cmd_set_nvgre_ip_version, 15420 (void *)&cmd_set_nvgre_ip_version_value, 15421 (void *)&cmd_set_nvgre_tni, 15422 (void *)&cmd_set_nvgre_tni_value, 15423 (void *)&cmd_set_nvgre_ip_src, 15424 (void *)&cmd_set_nvgre_ip_src_value, 15425 (void *)&cmd_set_nvgre_ip_dst, 15426 (void *)&cmd_set_nvgre_ip_dst_value, 15427 (void *)&cmd_set_nvgre_eth_src, 15428 (void *)&cmd_set_nvgre_eth_src_value, 15429 (void *)&cmd_set_nvgre_eth_dst, 15430 (void *)&cmd_set_nvgre_eth_dst_value, 15431 NULL, 15432 }, 15433 }; 15434 15435 cmdline_parse_inst_t cmd_set_nvgre_with_vlan = { 15436 .f = cmd_set_nvgre_parsed, 15437 .data = NULL, 15438 .help_str = "set nvgre-with-vlan ip-version <ipv4|ipv6> tni <tni>" 15439 " ip-src <ip-src> ip-dst <ip-dst> vlan-tci <vlan-tci>" 15440 " eth-src <eth-src> eth-dst <eth-dst>", 15441 .tokens = { 15442 (void *)&cmd_set_nvgre_set, 15443 (void *)&cmd_set_nvgre_nvgre_with_vlan, 15444 (void *)&cmd_set_nvgre_ip_version, 15445 (void *)&cmd_set_nvgre_ip_version_value, 15446 (void *)&cmd_set_nvgre_tni, 15447 (void *)&cmd_set_nvgre_tni_value, 15448 (void *)&cmd_set_nvgre_ip_src, 15449 (void *)&cmd_set_nvgre_ip_src_value, 15450 (void *)&cmd_set_nvgre_ip_dst, 15451 (void *)&cmd_set_nvgre_ip_dst_value, 15452 (void *)&cmd_set_nvgre_vlan, 15453 (void *)&cmd_set_nvgre_vlan_value, 15454 (void *)&cmd_set_nvgre_eth_src, 15455 (void *)&cmd_set_nvgre_eth_src_value, 15456 (void *)&cmd_set_nvgre_eth_dst, 15457 (void *)&cmd_set_nvgre_eth_dst_value, 15458 NULL, 15459 }, 15460 }; 15461 15462 /** Set L2 encapsulation details */ 15463 struct cmd_set_l2_encap_result { 15464 cmdline_fixed_string_t set; 15465 cmdline_fixed_string_t l2_encap; 15466 cmdline_fixed_string_t pos_token; 15467 cmdline_fixed_string_t ip_version; 15468 uint32_t vlan_present:1; 15469 uint16_t tci; 15470 struct ether_addr eth_src; 15471 struct ether_addr eth_dst; 15472 }; 15473 15474 cmdline_parse_token_string_t cmd_set_l2_encap_set = 15475 TOKEN_STRING_INITIALIZER(struct cmd_set_l2_encap_result, set, "set"); 15476 cmdline_parse_token_string_t cmd_set_l2_encap_l2_encap = 15477 TOKEN_STRING_INITIALIZER(struct cmd_set_l2_encap_result, l2_encap, "l2_encap"); 15478 cmdline_parse_token_string_t cmd_set_l2_encap_l2_encap_with_vlan = 15479 TOKEN_STRING_INITIALIZER(struct cmd_set_l2_encap_result, l2_encap, 15480 "l2_encap-with-vlan"); 15481 cmdline_parse_token_string_t cmd_set_l2_encap_ip_version = 15482 TOKEN_STRING_INITIALIZER(struct cmd_set_l2_encap_result, pos_token, 15483 "ip-version"); 15484 cmdline_parse_token_string_t cmd_set_l2_encap_ip_version_value = 15485 TOKEN_STRING_INITIALIZER(struct cmd_set_l2_encap_result, ip_version, 15486 "ipv4#ipv6"); 15487 cmdline_parse_token_string_t cmd_set_l2_encap_vlan = 15488 TOKEN_STRING_INITIALIZER(struct cmd_set_l2_encap_result, pos_token, 15489 "vlan-tci"); 15490 cmdline_parse_token_num_t cmd_set_l2_encap_vlan_value = 15491 TOKEN_NUM_INITIALIZER(struct cmd_set_l2_encap_result, tci, UINT16); 15492 cmdline_parse_token_string_t cmd_set_l2_encap_eth_src = 15493 TOKEN_STRING_INITIALIZER(struct cmd_set_l2_encap_result, pos_token, 15494 "eth-src"); 15495 cmdline_parse_token_etheraddr_t cmd_set_l2_encap_eth_src_value = 15496 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_l2_encap_result, eth_src); 15497 cmdline_parse_token_string_t cmd_set_l2_encap_eth_dst = 15498 TOKEN_STRING_INITIALIZER(struct cmd_set_l2_encap_result, pos_token, 15499 "eth-dst"); 15500 cmdline_parse_token_etheraddr_t cmd_set_l2_encap_eth_dst_value = 15501 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_l2_encap_result, eth_dst); 15502 15503 static void cmd_set_l2_encap_parsed(void *parsed_result, 15504 __attribute__((unused)) struct cmdline *cl, 15505 __attribute__((unused)) void *data) 15506 { 15507 struct cmd_set_l2_encap_result *res = parsed_result; 15508 15509 if (strcmp(res->l2_encap, "l2_encap") == 0) 15510 l2_encap_conf.select_vlan = 0; 15511 else if (strcmp(res->l2_encap, "l2_encap-with-vlan") == 0) 15512 l2_encap_conf.select_vlan = 1; 15513 if (strcmp(res->ip_version, "ipv4") == 0) 15514 l2_encap_conf.select_ipv4 = 1; 15515 else if (strcmp(res->ip_version, "ipv6") == 0) 15516 l2_encap_conf.select_ipv4 = 0; 15517 else 15518 return; 15519 if (l2_encap_conf.select_vlan) 15520 l2_encap_conf.vlan_tci = rte_cpu_to_be_16(res->tci); 15521 rte_memcpy(l2_encap_conf.eth_src, res->eth_src.addr_bytes, 15522 ETHER_ADDR_LEN); 15523 rte_memcpy(l2_encap_conf.eth_dst, res->eth_dst.addr_bytes, 15524 ETHER_ADDR_LEN); 15525 } 15526 15527 cmdline_parse_inst_t cmd_set_l2_encap = { 15528 .f = cmd_set_l2_encap_parsed, 15529 .data = NULL, 15530 .help_str = "set l2_encap ip-version ipv4|ipv6" 15531 " eth-src <eth-src> eth-dst <eth-dst>", 15532 .tokens = { 15533 (void *)&cmd_set_l2_encap_set, 15534 (void *)&cmd_set_l2_encap_l2_encap, 15535 (void *)&cmd_set_l2_encap_ip_version, 15536 (void *)&cmd_set_l2_encap_ip_version_value, 15537 (void *)&cmd_set_l2_encap_eth_src, 15538 (void *)&cmd_set_l2_encap_eth_src_value, 15539 (void *)&cmd_set_l2_encap_eth_dst, 15540 (void *)&cmd_set_l2_encap_eth_dst_value, 15541 NULL, 15542 }, 15543 }; 15544 15545 cmdline_parse_inst_t cmd_set_l2_encap_with_vlan = { 15546 .f = cmd_set_l2_encap_parsed, 15547 .data = NULL, 15548 .help_str = "set l2_encap-with-vlan ip-version ipv4|ipv6" 15549 " vlan-tci <vlan-tci> eth-src <eth-src> eth-dst <eth-dst>", 15550 .tokens = { 15551 (void *)&cmd_set_l2_encap_set, 15552 (void *)&cmd_set_l2_encap_l2_encap_with_vlan, 15553 (void *)&cmd_set_l2_encap_ip_version, 15554 (void *)&cmd_set_l2_encap_ip_version_value, 15555 (void *)&cmd_set_l2_encap_vlan, 15556 (void *)&cmd_set_l2_encap_vlan_value, 15557 (void *)&cmd_set_l2_encap_eth_src, 15558 (void *)&cmd_set_l2_encap_eth_src_value, 15559 (void *)&cmd_set_l2_encap_eth_dst, 15560 (void *)&cmd_set_l2_encap_eth_dst_value, 15561 NULL, 15562 }, 15563 }; 15564 15565 /** Set L2 decapsulation details */ 15566 struct cmd_set_l2_decap_result { 15567 cmdline_fixed_string_t set; 15568 cmdline_fixed_string_t l2_decap; 15569 cmdline_fixed_string_t pos_token; 15570 uint32_t vlan_present:1; 15571 }; 15572 15573 cmdline_parse_token_string_t cmd_set_l2_decap_set = 15574 TOKEN_STRING_INITIALIZER(struct cmd_set_l2_decap_result, set, "set"); 15575 cmdline_parse_token_string_t cmd_set_l2_decap_l2_decap = 15576 TOKEN_STRING_INITIALIZER(struct cmd_set_l2_decap_result, l2_decap, 15577 "l2_decap"); 15578 cmdline_parse_token_string_t cmd_set_l2_decap_l2_decap_with_vlan = 15579 TOKEN_STRING_INITIALIZER(struct cmd_set_l2_decap_result, l2_decap, 15580 "l2_decap-with-vlan"); 15581 15582 static void cmd_set_l2_decap_parsed(void *parsed_result, 15583 __attribute__((unused)) struct cmdline *cl, 15584 __attribute__((unused)) void *data) 15585 { 15586 struct cmd_set_l2_decap_result *res = parsed_result; 15587 15588 if (strcmp(res->l2_decap, "l2_decap") == 0) 15589 l2_decap_conf.select_vlan = 0; 15590 else if (strcmp(res->l2_decap, "l2_decap-with-vlan") == 0) 15591 l2_decap_conf.select_vlan = 1; 15592 } 15593 15594 cmdline_parse_inst_t cmd_set_l2_decap = { 15595 .f = cmd_set_l2_decap_parsed, 15596 .data = NULL, 15597 .help_str = "set l2_decap", 15598 .tokens = { 15599 (void *)&cmd_set_l2_decap_set, 15600 (void *)&cmd_set_l2_decap_l2_decap, 15601 NULL, 15602 }, 15603 }; 15604 15605 cmdline_parse_inst_t cmd_set_l2_decap_with_vlan = { 15606 .f = cmd_set_l2_decap_parsed, 15607 .data = NULL, 15608 .help_str = "set l2_decap-with-vlan", 15609 .tokens = { 15610 (void *)&cmd_set_l2_decap_set, 15611 (void *)&cmd_set_l2_decap_l2_decap_with_vlan, 15612 NULL, 15613 }, 15614 }; 15615 15616 /** Set MPLSoGRE encapsulation details */ 15617 struct cmd_set_mplsogre_encap_result { 15618 cmdline_fixed_string_t set; 15619 cmdline_fixed_string_t mplsogre; 15620 cmdline_fixed_string_t pos_token; 15621 cmdline_fixed_string_t ip_version; 15622 uint32_t vlan_present:1; 15623 uint32_t label; 15624 cmdline_ipaddr_t ip_src; 15625 cmdline_ipaddr_t ip_dst; 15626 uint16_t tci; 15627 struct ether_addr eth_src; 15628 struct ether_addr eth_dst; 15629 }; 15630 15631 cmdline_parse_token_string_t cmd_set_mplsogre_encap_set = 15632 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_encap_result, set, 15633 "set"); 15634 cmdline_parse_token_string_t cmd_set_mplsogre_encap_mplsogre_encap = 15635 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_encap_result, mplsogre, 15636 "mplsogre_encap"); 15637 cmdline_parse_token_string_t cmd_set_mplsogre_encap_mplsogre_encap_with_vlan = 15638 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_encap_result, 15639 mplsogre, "mplsogre_encap-with-vlan"); 15640 cmdline_parse_token_string_t cmd_set_mplsogre_encap_ip_version = 15641 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_encap_result, 15642 pos_token, "ip-version"); 15643 cmdline_parse_token_string_t cmd_set_mplsogre_encap_ip_version_value = 15644 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_encap_result, 15645 ip_version, "ipv4#ipv6"); 15646 cmdline_parse_token_string_t cmd_set_mplsogre_encap_label = 15647 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_encap_result, 15648 pos_token, "label"); 15649 cmdline_parse_token_num_t cmd_set_mplsogre_encap_label_value = 15650 TOKEN_NUM_INITIALIZER(struct cmd_set_mplsogre_encap_result, label, 15651 UINT32); 15652 cmdline_parse_token_string_t cmd_set_mplsogre_encap_ip_src = 15653 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_encap_result, 15654 pos_token, "ip-src"); 15655 cmdline_parse_token_ipaddr_t cmd_set_mplsogre_encap_ip_src_value = 15656 TOKEN_IPADDR_INITIALIZER(struct cmd_set_mplsogre_encap_result, ip_src); 15657 cmdline_parse_token_string_t cmd_set_mplsogre_encap_ip_dst = 15658 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_encap_result, 15659 pos_token, "ip-dst"); 15660 cmdline_parse_token_ipaddr_t cmd_set_mplsogre_encap_ip_dst_value = 15661 TOKEN_IPADDR_INITIALIZER(struct cmd_set_mplsogre_encap_result, ip_dst); 15662 cmdline_parse_token_string_t cmd_set_mplsogre_encap_vlan = 15663 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_encap_result, 15664 pos_token, "vlan-tci"); 15665 cmdline_parse_token_num_t cmd_set_mplsogre_encap_vlan_value = 15666 TOKEN_NUM_INITIALIZER(struct cmd_set_mplsogre_encap_result, tci, 15667 UINT16); 15668 cmdline_parse_token_string_t cmd_set_mplsogre_encap_eth_src = 15669 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_encap_result, 15670 pos_token, "eth-src"); 15671 cmdline_parse_token_etheraddr_t cmd_set_mplsogre_encap_eth_src_value = 15672 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_mplsogre_encap_result, 15673 eth_src); 15674 cmdline_parse_token_string_t cmd_set_mplsogre_encap_eth_dst = 15675 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_encap_result, 15676 pos_token, "eth-dst"); 15677 cmdline_parse_token_etheraddr_t cmd_set_mplsogre_encap_eth_dst_value = 15678 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_mplsogre_encap_result, 15679 eth_dst); 15680 15681 static void cmd_set_mplsogre_encap_parsed(void *parsed_result, 15682 __attribute__((unused)) struct cmdline *cl, 15683 __attribute__((unused)) void *data) 15684 { 15685 struct cmd_set_mplsogre_encap_result *res = parsed_result; 15686 union { 15687 uint32_t mplsogre_label; 15688 uint8_t label[4]; 15689 } id = { 15690 .mplsogre_label = rte_cpu_to_be_32(res->label<<12), 15691 }; 15692 15693 if (strcmp(res->mplsogre, "mplsogre_encap") == 0) 15694 mplsogre_encap_conf.select_vlan = 0; 15695 else if (strcmp(res->mplsogre, "mplsogre_encap-with-vlan") == 0) 15696 mplsogre_encap_conf.select_vlan = 1; 15697 if (strcmp(res->ip_version, "ipv4") == 0) 15698 mplsogre_encap_conf.select_ipv4 = 1; 15699 else if (strcmp(res->ip_version, "ipv6") == 0) 15700 mplsogre_encap_conf.select_ipv4 = 0; 15701 else 15702 return; 15703 rte_memcpy(mplsogre_encap_conf.label, &id.label, 3); 15704 if (mplsogre_encap_conf.select_ipv4) { 15705 IPV4_ADDR_TO_UINT(res->ip_src, mplsogre_encap_conf.ipv4_src); 15706 IPV4_ADDR_TO_UINT(res->ip_dst, mplsogre_encap_conf.ipv4_dst); 15707 } else { 15708 IPV6_ADDR_TO_ARRAY(res->ip_src, mplsogre_encap_conf.ipv6_src); 15709 IPV6_ADDR_TO_ARRAY(res->ip_dst, mplsogre_encap_conf.ipv6_dst); 15710 } 15711 if (mplsogre_encap_conf.select_vlan) 15712 mplsogre_encap_conf.vlan_tci = rte_cpu_to_be_16(res->tci); 15713 rte_memcpy(mplsogre_encap_conf.eth_src, res->eth_src.addr_bytes, 15714 ETHER_ADDR_LEN); 15715 rte_memcpy(mplsogre_encap_conf.eth_dst, res->eth_dst.addr_bytes, 15716 ETHER_ADDR_LEN); 15717 } 15718 15719 cmdline_parse_inst_t cmd_set_mplsogre_encap = { 15720 .f = cmd_set_mplsogre_encap_parsed, 15721 .data = NULL, 15722 .help_str = "set mplsogre_encap ip-version ipv4|ipv6 label <label>" 15723 " ip-src <ip-src> ip-dst <ip-dst> eth-src <eth-src>" 15724 " eth-dst <eth-dst>", 15725 .tokens = { 15726 (void *)&cmd_set_mplsogre_encap_set, 15727 (void *)&cmd_set_mplsogre_encap_mplsogre_encap, 15728 (void *)&cmd_set_mplsogre_encap_ip_version, 15729 (void *)&cmd_set_mplsogre_encap_ip_version_value, 15730 (void *)&cmd_set_mplsogre_encap_label, 15731 (void *)&cmd_set_mplsogre_encap_label_value, 15732 (void *)&cmd_set_mplsogre_encap_ip_src, 15733 (void *)&cmd_set_mplsogre_encap_ip_src_value, 15734 (void *)&cmd_set_mplsogre_encap_ip_dst, 15735 (void *)&cmd_set_mplsogre_encap_ip_dst_value, 15736 (void *)&cmd_set_mplsogre_encap_eth_src, 15737 (void *)&cmd_set_mplsogre_encap_eth_src_value, 15738 (void *)&cmd_set_mplsogre_encap_eth_dst, 15739 (void *)&cmd_set_mplsogre_encap_eth_dst_value, 15740 NULL, 15741 }, 15742 }; 15743 15744 cmdline_parse_inst_t cmd_set_mplsogre_encap_with_vlan = { 15745 .f = cmd_set_mplsogre_encap_parsed, 15746 .data = NULL, 15747 .help_str = "set mplsogre_encap-with-vlan ip-version ipv4|ipv6" 15748 " label <label> ip-src <ip-src> ip-dst <ip-dst>" 15749 " vlan-tci <vlan-tci> eth-src <eth-src> eth-dst <eth-dst>", 15750 .tokens = { 15751 (void *)&cmd_set_mplsogre_encap_set, 15752 (void *)&cmd_set_mplsogre_encap_mplsogre_encap_with_vlan, 15753 (void *)&cmd_set_mplsogre_encap_ip_version, 15754 (void *)&cmd_set_mplsogre_encap_ip_version_value, 15755 (void *)&cmd_set_mplsogre_encap_label, 15756 (void *)&cmd_set_mplsogre_encap_label_value, 15757 (void *)&cmd_set_mplsogre_encap_ip_src, 15758 (void *)&cmd_set_mplsogre_encap_ip_src_value, 15759 (void *)&cmd_set_mplsogre_encap_ip_dst, 15760 (void *)&cmd_set_mplsogre_encap_ip_dst_value, 15761 (void *)&cmd_set_mplsogre_encap_vlan, 15762 (void *)&cmd_set_mplsogre_encap_vlan_value, 15763 (void *)&cmd_set_mplsogre_encap_eth_src, 15764 (void *)&cmd_set_mplsogre_encap_eth_src_value, 15765 (void *)&cmd_set_mplsogre_encap_eth_dst, 15766 (void *)&cmd_set_mplsogre_encap_eth_dst_value, 15767 NULL, 15768 }, 15769 }; 15770 15771 /** Set MPLSoGRE decapsulation details */ 15772 struct cmd_set_mplsogre_decap_result { 15773 cmdline_fixed_string_t set; 15774 cmdline_fixed_string_t mplsogre; 15775 cmdline_fixed_string_t pos_token; 15776 cmdline_fixed_string_t ip_version; 15777 uint32_t vlan_present:1; 15778 }; 15779 15780 cmdline_parse_token_string_t cmd_set_mplsogre_decap_set = 15781 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_decap_result, set, 15782 "set"); 15783 cmdline_parse_token_string_t cmd_set_mplsogre_decap_mplsogre_decap = 15784 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_decap_result, mplsogre, 15785 "mplsogre_decap"); 15786 cmdline_parse_token_string_t cmd_set_mplsogre_decap_mplsogre_decap_with_vlan = 15787 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_decap_result, 15788 mplsogre, "mplsogre_decap-with-vlan"); 15789 cmdline_parse_token_string_t cmd_set_mplsogre_decap_ip_version = 15790 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_decap_result, 15791 pos_token, "ip-version"); 15792 cmdline_parse_token_string_t cmd_set_mplsogre_decap_ip_version_value = 15793 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_decap_result, 15794 ip_version, "ipv4#ipv6"); 15795 15796 static void cmd_set_mplsogre_decap_parsed(void *parsed_result, 15797 __attribute__((unused)) struct cmdline *cl, 15798 __attribute__((unused)) void *data) 15799 { 15800 struct cmd_set_mplsogre_decap_result *res = parsed_result; 15801 15802 if (strcmp(res->mplsogre, "mplsogre_decap") == 0) 15803 mplsogre_decap_conf.select_vlan = 0; 15804 else if (strcmp(res->mplsogre, "mplsogre_decap-with-vlan") == 0) 15805 mplsogre_decap_conf.select_vlan = 1; 15806 if (strcmp(res->ip_version, "ipv4") == 0) 15807 mplsogre_decap_conf.select_ipv4 = 1; 15808 else if (strcmp(res->ip_version, "ipv6") == 0) 15809 mplsogre_decap_conf.select_ipv4 = 0; 15810 } 15811 15812 cmdline_parse_inst_t cmd_set_mplsogre_decap = { 15813 .f = cmd_set_mplsogre_decap_parsed, 15814 .data = NULL, 15815 .help_str = "set mplsogre_decap ip-version ipv4|ipv6", 15816 .tokens = { 15817 (void *)&cmd_set_mplsogre_decap_set, 15818 (void *)&cmd_set_mplsogre_decap_mplsogre_decap, 15819 (void *)&cmd_set_mplsogre_decap_ip_version, 15820 (void *)&cmd_set_mplsogre_decap_ip_version_value, 15821 NULL, 15822 }, 15823 }; 15824 15825 cmdline_parse_inst_t cmd_set_mplsogre_decap_with_vlan = { 15826 .f = cmd_set_mplsogre_decap_parsed, 15827 .data = NULL, 15828 .help_str = "set mplsogre_decap-with-vlan ip-version ipv4|ipv6", 15829 .tokens = { 15830 (void *)&cmd_set_mplsogre_decap_set, 15831 (void *)&cmd_set_mplsogre_decap_mplsogre_decap_with_vlan, 15832 (void *)&cmd_set_mplsogre_decap_ip_version, 15833 (void *)&cmd_set_mplsogre_decap_ip_version_value, 15834 NULL, 15835 }, 15836 }; 15837 15838 /** Set MPLSoUDP encapsulation details */ 15839 struct cmd_set_mplsoudp_encap_result { 15840 cmdline_fixed_string_t set; 15841 cmdline_fixed_string_t mplsoudp; 15842 cmdline_fixed_string_t pos_token; 15843 cmdline_fixed_string_t ip_version; 15844 uint32_t vlan_present:1; 15845 uint32_t label; 15846 uint16_t udp_src; 15847 uint16_t udp_dst; 15848 cmdline_ipaddr_t ip_src; 15849 cmdline_ipaddr_t ip_dst; 15850 uint16_t tci; 15851 struct ether_addr eth_src; 15852 struct ether_addr eth_dst; 15853 }; 15854 15855 cmdline_parse_token_string_t cmd_set_mplsoudp_encap_set = 15856 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_encap_result, set, 15857 "set"); 15858 cmdline_parse_token_string_t cmd_set_mplsoudp_encap_mplsoudp_encap = 15859 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_encap_result, mplsoudp, 15860 "mplsoudp_encap"); 15861 cmdline_parse_token_string_t cmd_set_mplsoudp_encap_mplsoudp_encap_with_vlan = 15862 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_encap_result, 15863 mplsoudp, "mplsoudp_encap-with-vlan"); 15864 cmdline_parse_token_string_t cmd_set_mplsoudp_encap_ip_version = 15865 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_encap_result, 15866 pos_token, "ip-version"); 15867 cmdline_parse_token_string_t cmd_set_mplsoudp_encap_ip_version_value = 15868 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_encap_result, 15869 ip_version, "ipv4#ipv6"); 15870 cmdline_parse_token_string_t cmd_set_mplsoudp_encap_label = 15871 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_encap_result, 15872 pos_token, "label"); 15873 cmdline_parse_token_num_t cmd_set_mplsoudp_encap_label_value = 15874 TOKEN_NUM_INITIALIZER(struct cmd_set_mplsoudp_encap_result, label, 15875 UINT32); 15876 cmdline_parse_token_string_t cmd_set_mplsoudp_encap_udp_src = 15877 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_encap_result, 15878 pos_token, "udp-src"); 15879 cmdline_parse_token_num_t cmd_set_mplsoudp_encap_udp_src_value = 15880 TOKEN_NUM_INITIALIZER(struct cmd_set_mplsoudp_encap_result, udp_src, 15881 UINT16); 15882 cmdline_parse_token_string_t cmd_set_mplsoudp_encap_udp_dst = 15883 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_encap_result, 15884 pos_token, "udp-dst"); 15885 cmdline_parse_token_num_t cmd_set_mplsoudp_encap_udp_dst_value = 15886 TOKEN_NUM_INITIALIZER(struct cmd_set_mplsoudp_encap_result, udp_dst, 15887 UINT16); 15888 cmdline_parse_token_string_t cmd_set_mplsoudp_encap_ip_src = 15889 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_encap_result, 15890 pos_token, "ip-src"); 15891 cmdline_parse_token_ipaddr_t cmd_set_mplsoudp_encap_ip_src_value = 15892 TOKEN_IPADDR_INITIALIZER(struct cmd_set_mplsoudp_encap_result, ip_src); 15893 cmdline_parse_token_string_t cmd_set_mplsoudp_encap_ip_dst = 15894 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_encap_result, 15895 pos_token, "ip-dst"); 15896 cmdline_parse_token_ipaddr_t cmd_set_mplsoudp_encap_ip_dst_value = 15897 TOKEN_IPADDR_INITIALIZER(struct cmd_set_mplsoudp_encap_result, ip_dst); 15898 cmdline_parse_token_string_t cmd_set_mplsoudp_encap_vlan = 15899 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_encap_result, 15900 pos_token, "vlan-tci"); 15901 cmdline_parse_token_num_t cmd_set_mplsoudp_encap_vlan_value = 15902 TOKEN_NUM_INITIALIZER(struct cmd_set_mplsoudp_encap_result, tci, 15903 UINT16); 15904 cmdline_parse_token_string_t cmd_set_mplsoudp_encap_eth_src = 15905 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_encap_result, 15906 pos_token, "eth-src"); 15907 cmdline_parse_token_etheraddr_t cmd_set_mplsoudp_encap_eth_src_value = 15908 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_mplsoudp_encap_result, 15909 eth_src); 15910 cmdline_parse_token_string_t cmd_set_mplsoudp_encap_eth_dst = 15911 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_encap_result, 15912 pos_token, "eth-dst"); 15913 cmdline_parse_token_etheraddr_t cmd_set_mplsoudp_encap_eth_dst_value = 15914 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_mplsoudp_encap_result, 15915 eth_dst); 15916 15917 static void cmd_set_mplsoudp_encap_parsed(void *parsed_result, 15918 __attribute__((unused)) struct cmdline *cl, 15919 __attribute__((unused)) void *data) 15920 { 15921 struct cmd_set_mplsoudp_encap_result *res = parsed_result; 15922 union { 15923 uint32_t mplsoudp_label; 15924 uint8_t label[4]; 15925 } id = { 15926 .mplsoudp_label = rte_cpu_to_be_32(res->label<<12), 15927 }; 15928 15929 if (strcmp(res->mplsoudp, "mplsoudp_encap") == 0) 15930 mplsoudp_encap_conf.select_vlan = 0; 15931 else if (strcmp(res->mplsoudp, "mplsoudp_encap-with-vlan") == 0) 15932 mplsoudp_encap_conf.select_vlan = 1; 15933 if (strcmp(res->ip_version, "ipv4") == 0) 15934 mplsoudp_encap_conf.select_ipv4 = 1; 15935 else if (strcmp(res->ip_version, "ipv6") == 0) 15936 mplsoudp_encap_conf.select_ipv4 = 0; 15937 else 15938 return; 15939 rte_memcpy(mplsoudp_encap_conf.label, &id.label, 3); 15940 mplsoudp_encap_conf.udp_src = rte_cpu_to_be_16(res->udp_src); 15941 mplsoudp_encap_conf.udp_dst = rte_cpu_to_be_16(res->udp_dst); 15942 if (mplsoudp_encap_conf.select_ipv4) { 15943 IPV4_ADDR_TO_UINT(res->ip_src, mplsoudp_encap_conf.ipv4_src); 15944 IPV4_ADDR_TO_UINT(res->ip_dst, mplsoudp_encap_conf.ipv4_dst); 15945 } else { 15946 IPV6_ADDR_TO_ARRAY(res->ip_src, mplsoudp_encap_conf.ipv6_src); 15947 IPV6_ADDR_TO_ARRAY(res->ip_dst, mplsoudp_encap_conf.ipv6_dst); 15948 } 15949 if (mplsoudp_encap_conf.select_vlan) 15950 mplsoudp_encap_conf.vlan_tci = rte_cpu_to_be_16(res->tci); 15951 rte_memcpy(mplsoudp_encap_conf.eth_src, res->eth_src.addr_bytes, 15952 ETHER_ADDR_LEN); 15953 rte_memcpy(mplsoudp_encap_conf.eth_dst, res->eth_dst.addr_bytes, 15954 ETHER_ADDR_LEN); 15955 } 15956 15957 cmdline_parse_inst_t cmd_set_mplsoudp_encap = { 15958 .f = cmd_set_mplsoudp_encap_parsed, 15959 .data = NULL, 15960 .help_str = "set mplsoudp_encap ip-version ipv4|ipv6 label <label>" 15961 " udp-src <udp-src> udp-dst <udp-dst> ip-src <ip-src>" 15962 " ip-dst <ip-dst> eth-src <eth-src> eth-dst <eth-dst>", 15963 .tokens = { 15964 (void *)&cmd_set_mplsoudp_encap_set, 15965 (void *)&cmd_set_mplsoudp_encap_mplsoudp_encap, 15966 (void *)&cmd_set_mplsoudp_encap_ip_version, 15967 (void *)&cmd_set_mplsoudp_encap_ip_version_value, 15968 (void *)&cmd_set_mplsoudp_encap_label, 15969 (void *)&cmd_set_mplsoudp_encap_label_value, 15970 (void *)&cmd_set_mplsoudp_encap_udp_src, 15971 (void *)&cmd_set_mplsoudp_encap_udp_src_value, 15972 (void *)&cmd_set_mplsoudp_encap_udp_dst, 15973 (void *)&cmd_set_mplsoudp_encap_udp_dst_value, 15974 (void *)&cmd_set_mplsoudp_encap_ip_src, 15975 (void *)&cmd_set_mplsoudp_encap_ip_src_value, 15976 (void *)&cmd_set_mplsoudp_encap_ip_dst, 15977 (void *)&cmd_set_mplsoudp_encap_ip_dst_value, 15978 (void *)&cmd_set_mplsoudp_encap_eth_src, 15979 (void *)&cmd_set_mplsoudp_encap_eth_src_value, 15980 (void *)&cmd_set_mplsoudp_encap_eth_dst, 15981 (void *)&cmd_set_mplsoudp_encap_eth_dst_value, 15982 NULL, 15983 }, 15984 }; 15985 15986 cmdline_parse_inst_t cmd_set_mplsoudp_encap_with_vlan = { 15987 .f = cmd_set_mplsoudp_encap_parsed, 15988 .data = NULL, 15989 .help_str = "set mplsoudp_encap-with-vlan ip-version ipv4|ipv6" 15990 " label <label> udp-src <udp-src> udp-dst <udp-dst>" 15991 " ip-src <ip-src> ip-dst <ip-dst> vlan-tci <vlan-tci>" 15992 " eth-src <eth-src> eth-dst <eth-dst>", 15993 .tokens = { 15994 (void *)&cmd_set_mplsoudp_encap_set, 15995 (void *)&cmd_set_mplsoudp_encap_mplsoudp_encap_with_vlan, 15996 (void *)&cmd_set_mplsoudp_encap_ip_version, 15997 (void *)&cmd_set_mplsoudp_encap_ip_version_value, 15998 (void *)&cmd_set_mplsoudp_encap_label, 15999 (void *)&cmd_set_mplsoudp_encap_label_value, 16000 (void *)&cmd_set_mplsoudp_encap_udp_src, 16001 (void *)&cmd_set_mplsoudp_encap_udp_src_value, 16002 (void *)&cmd_set_mplsoudp_encap_udp_dst, 16003 (void *)&cmd_set_mplsoudp_encap_udp_dst_value, 16004 (void *)&cmd_set_mplsoudp_encap_ip_src, 16005 (void *)&cmd_set_mplsoudp_encap_ip_src_value, 16006 (void *)&cmd_set_mplsoudp_encap_ip_dst, 16007 (void *)&cmd_set_mplsoudp_encap_ip_dst_value, 16008 (void *)&cmd_set_mplsoudp_encap_vlan, 16009 (void *)&cmd_set_mplsoudp_encap_vlan_value, 16010 (void *)&cmd_set_mplsoudp_encap_eth_src, 16011 (void *)&cmd_set_mplsoudp_encap_eth_src_value, 16012 (void *)&cmd_set_mplsoudp_encap_eth_dst, 16013 (void *)&cmd_set_mplsoudp_encap_eth_dst_value, 16014 NULL, 16015 }, 16016 }; 16017 16018 /** Set MPLSoUDP decapsulation details */ 16019 struct cmd_set_mplsoudp_decap_result { 16020 cmdline_fixed_string_t set; 16021 cmdline_fixed_string_t mplsoudp; 16022 cmdline_fixed_string_t pos_token; 16023 cmdline_fixed_string_t ip_version; 16024 uint32_t vlan_present:1; 16025 }; 16026 16027 cmdline_parse_token_string_t cmd_set_mplsoudp_decap_set = 16028 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_decap_result, set, 16029 "set"); 16030 cmdline_parse_token_string_t cmd_set_mplsoudp_decap_mplsoudp_decap = 16031 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_decap_result, mplsoudp, 16032 "mplsoudp_decap"); 16033 cmdline_parse_token_string_t cmd_set_mplsoudp_decap_mplsoudp_decap_with_vlan = 16034 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_decap_result, 16035 mplsoudp, "mplsoudp_decap-with-vlan"); 16036 cmdline_parse_token_string_t cmd_set_mplsoudp_decap_ip_version = 16037 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_decap_result, 16038 pos_token, "ip-version"); 16039 cmdline_parse_token_string_t cmd_set_mplsoudp_decap_ip_version_value = 16040 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_decap_result, 16041 ip_version, "ipv4#ipv6"); 16042 16043 static void cmd_set_mplsoudp_decap_parsed(void *parsed_result, 16044 __attribute__((unused)) struct cmdline *cl, 16045 __attribute__((unused)) void *data) 16046 { 16047 struct cmd_set_mplsoudp_decap_result *res = parsed_result; 16048 16049 if (strcmp(res->mplsoudp, "mplsoudp_decap") == 0) 16050 mplsoudp_decap_conf.select_vlan = 0; 16051 else if (strcmp(res->mplsoudp, "mplsoudp_decap-with-vlan") == 0) 16052 mplsoudp_decap_conf.select_vlan = 1; 16053 if (strcmp(res->ip_version, "ipv4") == 0) 16054 mplsoudp_decap_conf.select_ipv4 = 1; 16055 else if (strcmp(res->ip_version, "ipv6") == 0) 16056 mplsoudp_decap_conf.select_ipv4 = 0; 16057 } 16058 16059 cmdline_parse_inst_t cmd_set_mplsoudp_decap = { 16060 .f = cmd_set_mplsoudp_decap_parsed, 16061 .data = NULL, 16062 .help_str = "set mplsoudp_decap ip-version ipv4|ipv6", 16063 .tokens = { 16064 (void *)&cmd_set_mplsoudp_decap_set, 16065 (void *)&cmd_set_mplsoudp_decap_mplsoudp_decap, 16066 (void *)&cmd_set_mplsoudp_decap_ip_version, 16067 (void *)&cmd_set_mplsoudp_decap_ip_version_value, 16068 NULL, 16069 }, 16070 }; 16071 16072 cmdline_parse_inst_t cmd_set_mplsoudp_decap_with_vlan = { 16073 .f = cmd_set_mplsoudp_decap_parsed, 16074 .data = NULL, 16075 .help_str = "set mplsoudp_decap-with-vlan ip-version ipv4|ipv6", 16076 .tokens = { 16077 (void *)&cmd_set_mplsoudp_decap_set, 16078 (void *)&cmd_set_mplsoudp_decap_mplsoudp_decap_with_vlan, 16079 (void *)&cmd_set_mplsoudp_decap_ip_version, 16080 (void *)&cmd_set_mplsoudp_decap_ip_version_value, 16081 NULL, 16082 }, 16083 }; 16084 16085 /* Strict link priority scheduling mode setting */ 16086 static void 16087 cmd_strict_link_prio_parsed( 16088 void *parsed_result, 16089 __attribute__((unused)) struct cmdline *cl, 16090 __attribute__((unused)) void *data) 16091 { 16092 struct cmd_vf_tc_bw_result *res = parsed_result; 16093 int ret = -ENOTSUP; 16094 16095 if (port_id_is_invalid(res->port_id, ENABLED_WARN)) 16096 return; 16097 16098 #ifdef RTE_LIBRTE_I40E_PMD 16099 ret = rte_pmd_i40e_set_tc_strict_prio(res->port_id, res->tc_map); 16100 #endif 16101 16102 switch (ret) { 16103 case 0: 16104 break; 16105 case -EINVAL: 16106 printf("invalid tc_bitmap 0x%x\n", res->tc_map); 16107 break; 16108 case -ENODEV: 16109 printf("invalid port_id %d\n", res->port_id); 16110 break; 16111 case -ENOTSUP: 16112 printf("function not implemented\n"); 16113 break; 16114 default: 16115 printf("programming error: (%s)\n", strerror(-ret)); 16116 } 16117 } 16118 16119 cmdline_parse_inst_t cmd_strict_link_prio = { 16120 .f = cmd_strict_link_prio_parsed, 16121 .data = NULL, 16122 .help_str = "set tx strict-link-priority <port_id> <tc_bitmap>", 16123 .tokens = { 16124 (void *)&cmd_vf_tc_bw_set, 16125 (void *)&cmd_vf_tc_bw_tx, 16126 (void *)&cmd_vf_tc_bw_strict_link_prio, 16127 (void *)&cmd_vf_tc_bw_port_id, 16128 (void *)&cmd_vf_tc_bw_tc_map, 16129 NULL, 16130 }, 16131 }; 16132 16133 /* Load dynamic device personalization*/ 16134 struct cmd_ddp_add_result { 16135 cmdline_fixed_string_t ddp; 16136 cmdline_fixed_string_t add; 16137 portid_t port_id; 16138 char filepath[]; 16139 }; 16140 16141 cmdline_parse_token_string_t cmd_ddp_add_ddp = 16142 TOKEN_STRING_INITIALIZER(struct cmd_ddp_add_result, ddp, "ddp"); 16143 cmdline_parse_token_string_t cmd_ddp_add_add = 16144 TOKEN_STRING_INITIALIZER(struct cmd_ddp_add_result, add, "add"); 16145 cmdline_parse_token_num_t cmd_ddp_add_port_id = 16146 TOKEN_NUM_INITIALIZER(struct cmd_ddp_add_result, port_id, UINT16); 16147 cmdline_parse_token_string_t cmd_ddp_add_filepath = 16148 TOKEN_STRING_INITIALIZER(struct cmd_ddp_add_result, filepath, NULL); 16149 16150 static void 16151 cmd_ddp_add_parsed( 16152 void *parsed_result, 16153 __attribute__((unused)) struct cmdline *cl, 16154 __attribute__((unused)) void *data) 16155 { 16156 struct cmd_ddp_add_result *res = parsed_result; 16157 uint8_t *buff; 16158 uint32_t size; 16159 char *filepath; 16160 char *file_fld[2]; 16161 int file_num; 16162 int ret = -ENOTSUP; 16163 16164 if (!all_ports_stopped()) { 16165 printf("Please stop all ports first\n"); 16166 return; 16167 } 16168 16169 filepath = strdup(res->filepath); 16170 if (filepath == NULL) { 16171 printf("Failed to allocate memory\n"); 16172 return; 16173 } 16174 file_num = rte_strsplit(filepath, strlen(filepath), file_fld, 2, ','); 16175 16176 buff = open_file(file_fld[0], &size); 16177 if (!buff) { 16178 free((void *)filepath); 16179 return; 16180 } 16181 16182 #ifdef RTE_LIBRTE_I40E_PMD 16183 if (ret == -ENOTSUP) 16184 ret = rte_pmd_i40e_process_ddp_package(res->port_id, 16185 buff, size, 16186 RTE_PMD_I40E_PKG_OP_WR_ADD); 16187 #endif 16188 16189 if (ret == -EEXIST) 16190 printf("Profile has already existed.\n"); 16191 else if (ret < 0) 16192 printf("Failed to load profile.\n"); 16193 else if (file_num == 2) 16194 save_file(file_fld[1], buff, size); 16195 16196 close_file(buff); 16197 free((void *)filepath); 16198 } 16199 16200 cmdline_parse_inst_t cmd_ddp_add = { 16201 .f = cmd_ddp_add_parsed, 16202 .data = NULL, 16203 .help_str = "ddp add <port_id> <profile_path[,backup_profile_path]>", 16204 .tokens = { 16205 (void *)&cmd_ddp_add_ddp, 16206 (void *)&cmd_ddp_add_add, 16207 (void *)&cmd_ddp_add_port_id, 16208 (void *)&cmd_ddp_add_filepath, 16209 NULL, 16210 }, 16211 }; 16212 16213 /* Delete dynamic device personalization*/ 16214 struct cmd_ddp_del_result { 16215 cmdline_fixed_string_t ddp; 16216 cmdline_fixed_string_t del; 16217 portid_t port_id; 16218 char filepath[]; 16219 }; 16220 16221 cmdline_parse_token_string_t cmd_ddp_del_ddp = 16222 TOKEN_STRING_INITIALIZER(struct cmd_ddp_del_result, ddp, "ddp"); 16223 cmdline_parse_token_string_t cmd_ddp_del_del = 16224 TOKEN_STRING_INITIALIZER(struct cmd_ddp_del_result, del, "del"); 16225 cmdline_parse_token_num_t cmd_ddp_del_port_id = 16226 TOKEN_NUM_INITIALIZER(struct cmd_ddp_del_result, port_id, UINT16); 16227 cmdline_parse_token_string_t cmd_ddp_del_filepath = 16228 TOKEN_STRING_INITIALIZER(struct cmd_ddp_del_result, filepath, NULL); 16229 16230 static void 16231 cmd_ddp_del_parsed( 16232 void *parsed_result, 16233 __attribute__((unused)) struct cmdline *cl, 16234 __attribute__((unused)) void *data) 16235 { 16236 struct cmd_ddp_del_result *res = parsed_result; 16237 uint8_t *buff; 16238 uint32_t size; 16239 int ret = -ENOTSUP; 16240 16241 if (!all_ports_stopped()) { 16242 printf("Please stop all ports first\n"); 16243 return; 16244 } 16245 16246 buff = open_file(res->filepath, &size); 16247 if (!buff) 16248 return; 16249 16250 #ifdef RTE_LIBRTE_I40E_PMD 16251 if (ret == -ENOTSUP) 16252 ret = rte_pmd_i40e_process_ddp_package(res->port_id, 16253 buff, size, 16254 RTE_PMD_I40E_PKG_OP_WR_DEL); 16255 #endif 16256 16257 if (ret == -EACCES) 16258 printf("Profile does not exist.\n"); 16259 else if (ret < 0) 16260 printf("Failed to delete profile.\n"); 16261 16262 close_file(buff); 16263 } 16264 16265 cmdline_parse_inst_t cmd_ddp_del = { 16266 .f = cmd_ddp_del_parsed, 16267 .data = NULL, 16268 .help_str = "ddp del <port_id> <backup_profile_path>", 16269 .tokens = { 16270 (void *)&cmd_ddp_del_ddp, 16271 (void *)&cmd_ddp_del_del, 16272 (void *)&cmd_ddp_del_port_id, 16273 (void *)&cmd_ddp_del_filepath, 16274 NULL, 16275 }, 16276 }; 16277 16278 /* Get dynamic device personalization profile info */ 16279 struct cmd_ddp_info_result { 16280 cmdline_fixed_string_t ddp; 16281 cmdline_fixed_string_t get; 16282 cmdline_fixed_string_t info; 16283 char filepath[]; 16284 }; 16285 16286 cmdline_parse_token_string_t cmd_ddp_info_ddp = 16287 TOKEN_STRING_INITIALIZER(struct cmd_ddp_info_result, ddp, "ddp"); 16288 cmdline_parse_token_string_t cmd_ddp_info_get = 16289 TOKEN_STRING_INITIALIZER(struct cmd_ddp_info_result, get, "get"); 16290 cmdline_parse_token_string_t cmd_ddp_info_info = 16291 TOKEN_STRING_INITIALIZER(struct cmd_ddp_info_result, info, "info"); 16292 cmdline_parse_token_string_t cmd_ddp_info_filepath = 16293 TOKEN_STRING_INITIALIZER(struct cmd_ddp_info_result, filepath, NULL); 16294 16295 static void 16296 cmd_ddp_info_parsed( 16297 void *parsed_result, 16298 __attribute__((unused)) struct cmdline *cl, 16299 __attribute__((unused)) void *data) 16300 { 16301 struct cmd_ddp_info_result *res = parsed_result; 16302 uint8_t *pkg; 16303 uint32_t pkg_size; 16304 int ret = -ENOTSUP; 16305 #ifdef RTE_LIBRTE_I40E_PMD 16306 uint32_t i, j, n; 16307 uint8_t *buff; 16308 uint32_t buff_size = 0; 16309 struct rte_pmd_i40e_profile_info info; 16310 uint32_t dev_num = 0; 16311 struct rte_pmd_i40e_ddp_device_id *devs; 16312 uint32_t proto_num = 0; 16313 struct rte_pmd_i40e_proto_info *proto = NULL; 16314 uint32_t pctype_num = 0; 16315 struct rte_pmd_i40e_ptype_info *pctype; 16316 uint32_t ptype_num = 0; 16317 struct rte_pmd_i40e_ptype_info *ptype; 16318 uint8_t proto_id; 16319 16320 #endif 16321 16322 pkg = open_file(res->filepath, &pkg_size); 16323 if (!pkg) 16324 return; 16325 16326 #ifdef RTE_LIBRTE_I40E_PMD 16327 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size, 16328 (uint8_t *)&info, sizeof(info), 16329 RTE_PMD_I40E_PKG_INFO_GLOBAL_HEADER); 16330 if (!ret) { 16331 printf("Global Track id: 0x%x\n", info.track_id); 16332 printf("Global Version: %d.%d.%d.%d\n", 16333 info.version.major, 16334 info.version.minor, 16335 info.version.update, 16336 info.version.draft); 16337 printf("Global Package name: %s\n\n", info.name); 16338 } 16339 16340 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size, 16341 (uint8_t *)&info, sizeof(info), 16342 RTE_PMD_I40E_PKG_INFO_HEADER); 16343 if (!ret) { 16344 printf("i40e Profile Track id: 0x%x\n", info.track_id); 16345 printf("i40e Profile Version: %d.%d.%d.%d\n", 16346 info.version.major, 16347 info.version.minor, 16348 info.version.update, 16349 info.version.draft); 16350 printf("i40e Profile name: %s\n\n", info.name); 16351 } 16352 16353 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size, 16354 (uint8_t *)&buff_size, sizeof(buff_size), 16355 RTE_PMD_I40E_PKG_INFO_GLOBAL_NOTES_SIZE); 16356 if (!ret && buff_size) { 16357 buff = (uint8_t *)malloc(buff_size); 16358 if (buff) { 16359 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size, 16360 buff, buff_size, 16361 RTE_PMD_I40E_PKG_INFO_GLOBAL_NOTES); 16362 if (!ret) 16363 printf("Package Notes:\n%s\n\n", buff); 16364 free(buff); 16365 } 16366 } 16367 16368 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size, 16369 (uint8_t *)&dev_num, sizeof(dev_num), 16370 RTE_PMD_I40E_PKG_INFO_DEVID_NUM); 16371 if (!ret && dev_num) { 16372 buff_size = dev_num * sizeof(struct rte_pmd_i40e_ddp_device_id); 16373 devs = (struct rte_pmd_i40e_ddp_device_id *)malloc(buff_size); 16374 if (devs) { 16375 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size, 16376 (uint8_t *)devs, buff_size, 16377 RTE_PMD_I40E_PKG_INFO_DEVID_LIST); 16378 if (!ret) { 16379 printf("List of supported devices:\n"); 16380 for (i = 0; i < dev_num; i++) { 16381 printf(" %04X:%04X %04X:%04X\n", 16382 devs[i].vendor_dev_id >> 16, 16383 devs[i].vendor_dev_id & 0xFFFF, 16384 devs[i].sub_vendor_dev_id >> 16, 16385 devs[i].sub_vendor_dev_id & 0xFFFF); 16386 } 16387 printf("\n"); 16388 } 16389 free(devs); 16390 } 16391 } 16392 16393 /* get information about protocols and packet types */ 16394 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size, 16395 (uint8_t *)&proto_num, sizeof(proto_num), 16396 RTE_PMD_I40E_PKG_INFO_PROTOCOL_NUM); 16397 if (ret || !proto_num) 16398 goto no_print_return; 16399 16400 buff_size = proto_num * sizeof(struct rte_pmd_i40e_proto_info); 16401 proto = (struct rte_pmd_i40e_proto_info *)malloc(buff_size); 16402 if (!proto) 16403 goto no_print_return; 16404 16405 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size, (uint8_t *)proto, 16406 buff_size, 16407 RTE_PMD_I40E_PKG_INFO_PROTOCOL_LIST); 16408 if (!ret) { 16409 printf("List of used protocols:\n"); 16410 for (i = 0; i < proto_num; i++) 16411 printf(" %2u: %s\n", proto[i].proto_id, 16412 proto[i].name); 16413 printf("\n"); 16414 } 16415 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size, 16416 (uint8_t *)&pctype_num, sizeof(pctype_num), 16417 RTE_PMD_I40E_PKG_INFO_PCTYPE_NUM); 16418 if (ret || !pctype_num) 16419 goto no_print_pctypes; 16420 16421 buff_size = pctype_num * sizeof(struct rte_pmd_i40e_ptype_info); 16422 pctype = (struct rte_pmd_i40e_ptype_info *)malloc(buff_size); 16423 if (!pctype) 16424 goto no_print_pctypes; 16425 16426 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size, (uint8_t *)pctype, 16427 buff_size, 16428 RTE_PMD_I40E_PKG_INFO_PCTYPE_LIST); 16429 if (ret) { 16430 free(pctype); 16431 goto no_print_pctypes; 16432 } 16433 16434 printf("List of defined packet classification types:\n"); 16435 for (i = 0; i < pctype_num; i++) { 16436 printf(" %2u:", pctype[i].ptype_id); 16437 for (j = 0; j < RTE_PMD_I40E_PROTO_NUM; j++) { 16438 proto_id = pctype[i].protocols[j]; 16439 if (proto_id != RTE_PMD_I40E_PROTO_UNUSED) { 16440 for (n = 0; n < proto_num; n++) { 16441 if (proto[n].proto_id == proto_id) { 16442 printf(" %s", proto[n].name); 16443 break; 16444 } 16445 } 16446 } 16447 } 16448 printf("\n"); 16449 } 16450 printf("\n"); 16451 free(pctype); 16452 16453 no_print_pctypes: 16454 16455 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size, (uint8_t *)&ptype_num, 16456 sizeof(ptype_num), 16457 RTE_PMD_I40E_PKG_INFO_PTYPE_NUM); 16458 if (ret || !ptype_num) 16459 goto no_print_return; 16460 16461 buff_size = ptype_num * sizeof(struct rte_pmd_i40e_ptype_info); 16462 ptype = (struct rte_pmd_i40e_ptype_info *)malloc(buff_size); 16463 if (!ptype) 16464 goto no_print_return; 16465 16466 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size, (uint8_t *)ptype, 16467 buff_size, 16468 RTE_PMD_I40E_PKG_INFO_PTYPE_LIST); 16469 if (ret) { 16470 free(ptype); 16471 goto no_print_return; 16472 } 16473 printf("List of defined packet types:\n"); 16474 for (i = 0; i < ptype_num; i++) { 16475 printf(" %2u:", ptype[i].ptype_id); 16476 for (j = 0; j < RTE_PMD_I40E_PROTO_NUM; j++) { 16477 proto_id = ptype[i].protocols[j]; 16478 if (proto_id != RTE_PMD_I40E_PROTO_UNUSED) { 16479 for (n = 0; n < proto_num; n++) { 16480 if (proto[n].proto_id == proto_id) { 16481 printf(" %s", proto[n].name); 16482 break; 16483 } 16484 } 16485 } 16486 } 16487 printf("\n"); 16488 } 16489 free(ptype); 16490 printf("\n"); 16491 16492 ret = 0; 16493 no_print_return: 16494 if (proto) 16495 free(proto); 16496 #endif 16497 if (ret == -ENOTSUP) 16498 printf("Function not supported in PMD driver\n"); 16499 close_file(pkg); 16500 } 16501 16502 cmdline_parse_inst_t cmd_ddp_get_info = { 16503 .f = cmd_ddp_info_parsed, 16504 .data = NULL, 16505 .help_str = "ddp get info <profile_path>", 16506 .tokens = { 16507 (void *)&cmd_ddp_info_ddp, 16508 (void *)&cmd_ddp_info_get, 16509 (void *)&cmd_ddp_info_info, 16510 (void *)&cmd_ddp_info_filepath, 16511 NULL, 16512 }, 16513 }; 16514 16515 /* Get dynamic device personalization profile info list*/ 16516 #define PROFILE_INFO_SIZE 48 16517 #define MAX_PROFILE_NUM 16 16518 16519 struct cmd_ddp_get_list_result { 16520 cmdline_fixed_string_t ddp; 16521 cmdline_fixed_string_t get; 16522 cmdline_fixed_string_t list; 16523 portid_t port_id; 16524 }; 16525 16526 cmdline_parse_token_string_t cmd_ddp_get_list_ddp = 16527 TOKEN_STRING_INITIALIZER(struct cmd_ddp_get_list_result, ddp, "ddp"); 16528 cmdline_parse_token_string_t cmd_ddp_get_list_get = 16529 TOKEN_STRING_INITIALIZER(struct cmd_ddp_get_list_result, get, "get"); 16530 cmdline_parse_token_string_t cmd_ddp_get_list_list = 16531 TOKEN_STRING_INITIALIZER(struct cmd_ddp_get_list_result, list, "list"); 16532 cmdline_parse_token_num_t cmd_ddp_get_list_port_id = 16533 TOKEN_NUM_INITIALIZER(struct cmd_ddp_get_list_result, port_id, UINT16); 16534 16535 static void 16536 cmd_ddp_get_list_parsed( 16537 __attribute__((unused)) void *parsed_result, 16538 __attribute__((unused)) struct cmdline *cl, 16539 __attribute__((unused)) void *data) 16540 { 16541 #ifdef RTE_LIBRTE_I40E_PMD 16542 struct cmd_ddp_get_list_result *res = parsed_result; 16543 struct rte_pmd_i40e_profile_list *p_list; 16544 struct rte_pmd_i40e_profile_info *p_info; 16545 uint32_t p_num; 16546 uint32_t size; 16547 uint32_t i; 16548 #endif 16549 int ret = -ENOTSUP; 16550 16551 #ifdef RTE_LIBRTE_I40E_PMD 16552 size = PROFILE_INFO_SIZE * MAX_PROFILE_NUM + 4; 16553 p_list = (struct rte_pmd_i40e_profile_list *)malloc(size); 16554 if (!p_list) 16555 printf("%s: Failed to malloc buffer\n", __func__); 16556 16557 if (ret == -ENOTSUP) 16558 ret = rte_pmd_i40e_get_ddp_list(res->port_id, 16559 (uint8_t *)p_list, size); 16560 16561 if (!ret) { 16562 p_num = p_list->p_count; 16563 printf("Profile number is: %d\n\n", p_num); 16564 16565 for (i = 0; i < p_num; i++) { 16566 p_info = &p_list->p_info[i]; 16567 printf("Profile %d:\n", i); 16568 printf("Track id: 0x%x\n", p_info->track_id); 16569 printf("Version: %d.%d.%d.%d\n", 16570 p_info->version.major, 16571 p_info->version.minor, 16572 p_info->version.update, 16573 p_info->version.draft); 16574 printf("Profile name: %s\n\n", p_info->name); 16575 } 16576 } 16577 16578 free(p_list); 16579 #endif 16580 16581 if (ret < 0) 16582 printf("Failed to get ddp list\n"); 16583 } 16584 16585 cmdline_parse_inst_t cmd_ddp_get_list = { 16586 .f = cmd_ddp_get_list_parsed, 16587 .data = NULL, 16588 .help_str = "ddp get list <port_id>", 16589 .tokens = { 16590 (void *)&cmd_ddp_get_list_ddp, 16591 (void *)&cmd_ddp_get_list_get, 16592 (void *)&cmd_ddp_get_list_list, 16593 (void *)&cmd_ddp_get_list_port_id, 16594 NULL, 16595 }, 16596 }; 16597 16598 /* Configure input set */ 16599 struct cmd_cfg_input_set_result { 16600 cmdline_fixed_string_t port; 16601 cmdline_fixed_string_t cfg; 16602 portid_t port_id; 16603 cmdline_fixed_string_t pctype; 16604 uint8_t pctype_id; 16605 cmdline_fixed_string_t inset_type; 16606 cmdline_fixed_string_t opt; 16607 cmdline_fixed_string_t field; 16608 uint8_t field_idx; 16609 }; 16610 16611 static void 16612 cmd_cfg_input_set_parsed( 16613 __attribute__((unused)) void *parsed_result, 16614 __attribute__((unused)) struct cmdline *cl, 16615 __attribute__((unused)) void *data) 16616 { 16617 #ifdef RTE_LIBRTE_I40E_PMD 16618 struct cmd_cfg_input_set_result *res = parsed_result; 16619 enum rte_pmd_i40e_inset_type inset_type = INSET_NONE; 16620 struct rte_pmd_i40e_inset inset; 16621 #endif 16622 int ret = -ENOTSUP; 16623 16624 if (!all_ports_stopped()) { 16625 printf("Please stop all ports first\n"); 16626 return; 16627 } 16628 16629 #ifdef RTE_LIBRTE_I40E_PMD 16630 if (!strcmp(res->inset_type, "hash_inset")) 16631 inset_type = INSET_HASH; 16632 else if (!strcmp(res->inset_type, "fdir_inset")) 16633 inset_type = INSET_FDIR; 16634 else if (!strcmp(res->inset_type, "fdir_flx_inset")) 16635 inset_type = INSET_FDIR_FLX; 16636 ret = rte_pmd_i40e_inset_get(res->port_id, res->pctype_id, 16637 &inset, inset_type); 16638 if (ret) { 16639 printf("Failed to get input set.\n"); 16640 return; 16641 } 16642 16643 if (!strcmp(res->opt, "get")) { 16644 ret = rte_pmd_i40e_inset_field_get(inset.inset, 16645 res->field_idx); 16646 if (ret) 16647 printf("Field index %d is enabled.\n", res->field_idx); 16648 else 16649 printf("Field index %d is disabled.\n", res->field_idx); 16650 return; 16651 } else if (!strcmp(res->opt, "set")) 16652 ret = rte_pmd_i40e_inset_field_set(&inset.inset, 16653 res->field_idx); 16654 else if (!strcmp(res->opt, "clear")) 16655 ret = rte_pmd_i40e_inset_field_clear(&inset.inset, 16656 res->field_idx); 16657 if (ret) { 16658 printf("Failed to configure input set field.\n"); 16659 return; 16660 } 16661 16662 ret = rte_pmd_i40e_inset_set(res->port_id, res->pctype_id, 16663 &inset, inset_type); 16664 if (ret) { 16665 printf("Failed to set input set.\n"); 16666 return; 16667 } 16668 #endif 16669 16670 if (ret == -ENOTSUP) 16671 printf("Function not supported\n"); 16672 } 16673 16674 cmdline_parse_token_string_t cmd_cfg_input_set_port = 16675 TOKEN_STRING_INITIALIZER(struct cmd_cfg_input_set_result, 16676 port, "port"); 16677 cmdline_parse_token_string_t cmd_cfg_input_set_cfg = 16678 TOKEN_STRING_INITIALIZER(struct cmd_cfg_input_set_result, 16679 cfg, "config"); 16680 cmdline_parse_token_num_t cmd_cfg_input_set_port_id = 16681 TOKEN_NUM_INITIALIZER(struct cmd_cfg_input_set_result, 16682 port_id, UINT16); 16683 cmdline_parse_token_string_t cmd_cfg_input_set_pctype = 16684 TOKEN_STRING_INITIALIZER(struct cmd_cfg_input_set_result, 16685 pctype, "pctype"); 16686 cmdline_parse_token_num_t cmd_cfg_input_set_pctype_id = 16687 TOKEN_NUM_INITIALIZER(struct cmd_cfg_input_set_result, 16688 pctype_id, UINT8); 16689 cmdline_parse_token_string_t cmd_cfg_input_set_inset_type = 16690 TOKEN_STRING_INITIALIZER(struct cmd_cfg_input_set_result, 16691 inset_type, 16692 "hash_inset#fdir_inset#fdir_flx_inset"); 16693 cmdline_parse_token_string_t cmd_cfg_input_set_opt = 16694 TOKEN_STRING_INITIALIZER(struct cmd_cfg_input_set_result, 16695 opt, "get#set#clear"); 16696 cmdline_parse_token_string_t cmd_cfg_input_set_field = 16697 TOKEN_STRING_INITIALIZER(struct cmd_cfg_input_set_result, 16698 field, "field"); 16699 cmdline_parse_token_num_t cmd_cfg_input_set_field_idx = 16700 TOKEN_NUM_INITIALIZER(struct cmd_cfg_input_set_result, 16701 field_idx, UINT8); 16702 16703 cmdline_parse_inst_t cmd_cfg_input_set = { 16704 .f = cmd_cfg_input_set_parsed, 16705 .data = NULL, 16706 .help_str = "port config <port_id> pctype <pctype_id> hash_inset|" 16707 "fdir_inset|fdir_flx_inset get|set|clear field <field_idx>", 16708 .tokens = { 16709 (void *)&cmd_cfg_input_set_port, 16710 (void *)&cmd_cfg_input_set_cfg, 16711 (void *)&cmd_cfg_input_set_port_id, 16712 (void *)&cmd_cfg_input_set_pctype, 16713 (void *)&cmd_cfg_input_set_pctype_id, 16714 (void *)&cmd_cfg_input_set_inset_type, 16715 (void *)&cmd_cfg_input_set_opt, 16716 (void *)&cmd_cfg_input_set_field, 16717 (void *)&cmd_cfg_input_set_field_idx, 16718 NULL, 16719 }, 16720 }; 16721 16722 /* Clear input set */ 16723 struct cmd_clear_input_set_result { 16724 cmdline_fixed_string_t port; 16725 cmdline_fixed_string_t cfg; 16726 portid_t port_id; 16727 cmdline_fixed_string_t pctype; 16728 uint8_t pctype_id; 16729 cmdline_fixed_string_t inset_type; 16730 cmdline_fixed_string_t clear; 16731 cmdline_fixed_string_t all; 16732 }; 16733 16734 static void 16735 cmd_clear_input_set_parsed( 16736 __attribute__((unused)) void *parsed_result, 16737 __attribute__((unused)) struct cmdline *cl, 16738 __attribute__((unused)) void *data) 16739 { 16740 #ifdef RTE_LIBRTE_I40E_PMD 16741 struct cmd_clear_input_set_result *res = parsed_result; 16742 enum rte_pmd_i40e_inset_type inset_type = INSET_NONE; 16743 struct rte_pmd_i40e_inset inset; 16744 #endif 16745 int ret = -ENOTSUP; 16746 16747 if (!all_ports_stopped()) { 16748 printf("Please stop all ports first\n"); 16749 return; 16750 } 16751 16752 #ifdef RTE_LIBRTE_I40E_PMD 16753 if (!strcmp(res->inset_type, "hash_inset")) 16754 inset_type = INSET_HASH; 16755 else if (!strcmp(res->inset_type, "fdir_inset")) 16756 inset_type = INSET_FDIR; 16757 else if (!strcmp(res->inset_type, "fdir_flx_inset")) 16758 inset_type = INSET_FDIR_FLX; 16759 16760 memset(&inset, 0, sizeof(inset)); 16761 16762 ret = rte_pmd_i40e_inset_set(res->port_id, res->pctype_id, 16763 &inset, inset_type); 16764 if (ret) { 16765 printf("Failed to clear input set.\n"); 16766 return; 16767 } 16768 16769 #endif 16770 16771 if (ret == -ENOTSUP) 16772 printf("Function not supported\n"); 16773 } 16774 16775 cmdline_parse_token_string_t cmd_clear_input_set_port = 16776 TOKEN_STRING_INITIALIZER(struct cmd_clear_input_set_result, 16777 port, "port"); 16778 cmdline_parse_token_string_t cmd_clear_input_set_cfg = 16779 TOKEN_STRING_INITIALIZER(struct cmd_clear_input_set_result, 16780 cfg, "config"); 16781 cmdline_parse_token_num_t cmd_clear_input_set_port_id = 16782 TOKEN_NUM_INITIALIZER(struct cmd_clear_input_set_result, 16783 port_id, UINT16); 16784 cmdline_parse_token_string_t cmd_clear_input_set_pctype = 16785 TOKEN_STRING_INITIALIZER(struct cmd_clear_input_set_result, 16786 pctype, "pctype"); 16787 cmdline_parse_token_num_t cmd_clear_input_set_pctype_id = 16788 TOKEN_NUM_INITIALIZER(struct cmd_clear_input_set_result, 16789 pctype_id, UINT8); 16790 cmdline_parse_token_string_t cmd_clear_input_set_inset_type = 16791 TOKEN_STRING_INITIALIZER(struct cmd_clear_input_set_result, 16792 inset_type, 16793 "hash_inset#fdir_inset#fdir_flx_inset"); 16794 cmdline_parse_token_string_t cmd_clear_input_set_clear = 16795 TOKEN_STRING_INITIALIZER(struct cmd_clear_input_set_result, 16796 clear, "clear"); 16797 cmdline_parse_token_string_t cmd_clear_input_set_all = 16798 TOKEN_STRING_INITIALIZER(struct cmd_clear_input_set_result, 16799 all, "all"); 16800 16801 cmdline_parse_inst_t cmd_clear_input_set = { 16802 .f = cmd_clear_input_set_parsed, 16803 .data = NULL, 16804 .help_str = "port config <port_id> pctype <pctype_id> hash_inset|" 16805 "fdir_inset|fdir_flx_inset clear all", 16806 .tokens = { 16807 (void *)&cmd_clear_input_set_port, 16808 (void *)&cmd_clear_input_set_cfg, 16809 (void *)&cmd_clear_input_set_port_id, 16810 (void *)&cmd_clear_input_set_pctype, 16811 (void *)&cmd_clear_input_set_pctype_id, 16812 (void *)&cmd_clear_input_set_inset_type, 16813 (void *)&cmd_clear_input_set_clear, 16814 (void *)&cmd_clear_input_set_all, 16815 NULL, 16816 }, 16817 }; 16818 16819 /* show vf stats */ 16820 16821 /* Common result structure for show vf stats */ 16822 struct cmd_show_vf_stats_result { 16823 cmdline_fixed_string_t show; 16824 cmdline_fixed_string_t vf; 16825 cmdline_fixed_string_t stats; 16826 portid_t port_id; 16827 uint16_t vf_id; 16828 }; 16829 16830 /* Common CLI fields show vf stats*/ 16831 cmdline_parse_token_string_t cmd_show_vf_stats_show = 16832 TOKEN_STRING_INITIALIZER 16833 (struct cmd_show_vf_stats_result, 16834 show, "show"); 16835 cmdline_parse_token_string_t cmd_show_vf_stats_vf = 16836 TOKEN_STRING_INITIALIZER 16837 (struct cmd_show_vf_stats_result, 16838 vf, "vf"); 16839 cmdline_parse_token_string_t cmd_show_vf_stats_stats = 16840 TOKEN_STRING_INITIALIZER 16841 (struct cmd_show_vf_stats_result, 16842 stats, "stats"); 16843 cmdline_parse_token_num_t cmd_show_vf_stats_port_id = 16844 TOKEN_NUM_INITIALIZER 16845 (struct cmd_show_vf_stats_result, 16846 port_id, UINT16); 16847 cmdline_parse_token_num_t cmd_show_vf_stats_vf_id = 16848 TOKEN_NUM_INITIALIZER 16849 (struct cmd_show_vf_stats_result, 16850 vf_id, UINT16); 16851 16852 static void 16853 cmd_show_vf_stats_parsed( 16854 void *parsed_result, 16855 __attribute__((unused)) struct cmdline *cl, 16856 __attribute__((unused)) void *data) 16857 { 16858 struct cmd_show_vf_stats_result *res = parsed_result; 16859 struct rte_eth_stats stats; 16860 int ret = -ENOTSUP; 16861 static const char *nic_stats_border = "########################"; 16862 16863 if (port_id_is_invalid(res->port_id, ENABLED_WARN)) 16864 return; 16865 16866 memset(&stats, 0, sizeof(stats)); 16867 16868 #ifdef RTE_LIBRTE_I40E_PMD 16869 if (ret == -ENOTSUP) 16870 ret = rte_pmd_i40e_get_vf_stats(res->port_id, 16871 res->vf_id, 16872 &stats); 16873 #endif 16874 #ifdef RTE_LIBRTE_BNXT_PMD 16875 if (ret == -ENOTSUP) 16876 ret = rte_pmd_bnxt_get_vf_stats(res->port_id, 16877 res->vf_id, 16878 &stats); 16879 #endif 16880 16881 switch (ret) { 16882 case 0: 16883 break; 16884 case -EINVAL: 16885 printf("invalid vf_id %d\n", res->vf_id); 16886 break; 16887 case -ENODEV: 16888 printf("invalid port_id %d\n", res->port_id); 16889 break; 16890 case -ENOTSUP: 16891 printf("function not implemented\n"); 16892 break; 16893 default: 16894 printf("programming error: (%s)\n", strerror(-ret)); 16895 } 16896 16897 printf("\n %s NIC statistics for port %-2d vf %-2d %s\n", 16898 nic_stats_border, res->port_id, res->vf_id, nic_stats_border); 16899 16900 printf(" RX-packets: %-10"PRIu64" RX-missed: %-10"PRIu64" RX-bytes: " 16901 "%-"PRIu64"\n", 16902 stats.ipackets, stats.imissed, stats.ibytes); 16903 printf(" RX-errors: %-"PRIu64"\n", stats.ierrors); 16904 printf(" RX-nombuf: %-10"PRIu64"\n", 16905 stats.rx_nombuf); 16906 printf(" TX-packets: %-10"PRIu64" TX-errors: %-10"PRIu64" TX-bytes: " 16907 "%-"PRIu64"\n", 16908 stats.opackets, stats.oerrors, stats.obytes); 16909 16910 printf(" %s############################%s\n", 16911 nic_stats_border, nic_stats_border); 16912 } 16913 16914 cmdline_parse_inst_t cmd_show_vf_stats = { 16915 .f = cmd_show_vf_stats_parsed, 16916 .data = NULL, 16917 .help_str = "show vf stats <port_id> <vf_id>", 16918 .tokens = { 16919 (void *)&cmd_show_vf_stats_show, 16920 (void *)&cmd_show_vf_stats_vf, 16921 (void *)&cmd_show_vf_stats_stats, 16922 (void *)&cmd_show_vf_stats_port_id, 16923 (void *)&cmd_show_vf_stats_vf_id, 16924 NULL, 16925 }, 16926 }; 16927 16928 /* clear vf stats */ 16929 16930 /* Common result structure for clear vf stats */ 16931 struct cmd_clear_vf_stats_result { 16932 cmdline_fixed_string_t clear; 16933 cmdline_fixed_string_t vf; 16934 cmdline_fixed_string_t stats; 16935 portid_t port_id; 16936 uint16_t vf_id; 16937 }; 16938 16939 /* Common CLI fields clear vf stats*/ 16940 cmdline_parse_token_string_t cmd_clear_vf_stats_clear = 16941 TOKEN_STRING_INITIALIZER 16942 (struct cmd_clear_vf_stats_result, 16943 clear, "clear"); 16944 cmdline_parse_token_string_t cmd_clear_vf_stats_vf = 16945 TOKEN_STRING_INITIALIZER 16946 (struct cmd_clear_vf_stats_result, 16947 vf, "vf"); 16948 cmdline_parse_token_string_t cmd_clear_vf_stats_stats = 16949 TOKEN_STRING_INITIALIZER 16950 (struct cmd_clear_vf_stats_result, 16951 stats, "stats"); 16952 cmdline_parse_token_num_t cmd_clear_vf_stats_port_id = 16953 TOKEN_NUM_INITIALIZER 16954 (struct cmd_clear_vf_stats_result, 16955 port_id, UINT16); 16956 cmdline_parse_token_num_t cmd_clear_vf_stats_vf_id = 16957 TOKEN_NUM_INITIALIZER 16958 (struct cmd_clear_vf_stats_result, 16959 vf_id, UINT16); 16960 16961 static void 16962 cmd_clear_vf_stats_parsed( 16963 void *parsed_result, 16964 __attribute__((unused)) struct cmdline *cl, 16965 __attribute__((unused)) void *data) 16966 { 16967 struct cmd_clear_vf_stats_result *res = parsed_result; 16968 int ret = -ENOTSUP; 16969 16970 if (port_id_is_invalid(res->port_id, ENABLED_WARN)) 16971 return; 16972 16973 #ifdef RTE_LIBRTE_I40E_PMD 16974 if (ret == -ENOTSUP) 16975 ret = rte_pmd_i40e_reset_vf_stats(res->port_id, 16976 res->vf_id); 16977 #endif 16978 #ifdef RTE_LIBRTE_BNXT_PMD 16979 if (ret == -ENOTSUP) 16980 ret = rte_pmd_bnxt_reset_vf_stats(res->port_id, 16981 res->vf_id); 16982 #endif 16983 16984 switch (ret) { 16985 case 0: 16986 break; 16987 case -EINVAL: 16988 printf("invalid vf_id %d\n", res->vf_id); 16989 break; 16990 case -ENODEV: 16991 printf("invalid port_id %d\n", res->port_id); 16992 break; 16993 case -ENOTSUP: 16994 printf("function not implemented\n"); 16995 break; 16996 default: 16997 printf("programming error: (%s)\n", strerror(-ret)); 16998 } 16999 } 17000 17001 cmdline_parse_inst_t cmd_clear_vf_stats = { 17002 .f = cmd_clear_vf_stats_parsed, 17003 .data = NULL, 17004 .help_str = "clear vf stats <port_id> <vf_id>", 17005 .tokens = { 17006 (void *)&cmd_clear_vf_stats_clear, 17007 (void *)&cmd_clear_vf_stats_vf, 17008 (void *)&cmd_clear_vf_stats_stats, 17009 (void *)&cmd_clear_vf_stats_port_id, 17010 (void *)&cmd_clear_vf_stats_vf_id, 17011 NULL, 17012 }, 17013 }; 17014 17015 /* port config pctype mapping reset */ 17016 17017 /* Common result structure for port config pctype mapping reset */ 17018 struct cmd_pctype_mapping_reset_result { 17019 cmdline_fixed_string_t port; 17020 cmdline_fixed_string_t config; 17021 portid_t port_id; 17022 cmdline_fixed_string_t pctype; 17023 cmdline_fixed_string_t mapping; 17024 cmdline_fixed_string_t reset; 17025 }; 17026 17027 /* Common CLI fields for port config pctype mapping reset*/ 17028 cmdline_parse_token_string_t cmd_pctype_mapping_reset_port = 17029 TOKEN_STRING_INITIALIZER 17030 (struct cmd_pctype_mapping_reset_result, 17031 port, "port"); 17032 cmdline_parse_token_string_t cmd_pctype_mapping_reset_config = 17033 TOKEN_STRING_INITIALIZER 17034 (struct cmd_pctype_mapping_reset_result, 17035 config, "config"); 17036 cmdline_parse_token_num_t cmd_pctype_mapping_reset_port_id = 17037 TOKEN_NUM_INITIALIZER 17038 (struct cmd_pctype_mapping_reset_result, 17039 port_id, UINT16); 17040 cmdline_parse_token_string_t cmd_pctype_mapping_reset_pctype = 17041 TOKEN_STRING_INITIALIZER 17042 (struct cmd_pctype_mapping_reset_result, 17043 pctype, "pctype"); 17044 cmdline_parse_token_string_t cmd_pctype_mapping_reset_mapping = 17045 TOKEN_STRING_INITIALIZER 17046 (struct cmd_pctype_mapping_reset_result, 17047 mapping, "mapping"); 17048 cmdline_parse_token_string_t cmd_pctype_mapping_reset_reset = 17049 TOKEN_STRING_INITIALIZER 17050 (struct cmd_pctype_mapping_reset_result, 17051 reset, "reset"); 17052 17053 static void 17054 cmd_pctype_mapping_reset_parsed( 17055 void *parsed_result, 17056 __attribute__((unused)) struct cmdline *cl, 17057 __attribute__((unused)) void *data) 17058 { 17059 struct cmd_pctype_mapping_reset_result *res = parsed_result; 17060 int ret = -ENOTSUP; 17061 17062 if (port_id_is_invalid(res->port_id, ENABLED_WARN)) 17063 return; 17064 17065 #ifdef RTE_LIBRTE_I40E_PMD 17066 ret = rte_pmd_i40e_flow_type_mapping_reset(res->port_id); 17067 #endif 17068 17069 switch (ret) { 17070 case 0: 17071 break; 17072 case -ENODEV: 17073 printf("invalid port_id %d\n", res->port_id); 17074 break; 17075 case -ENOTSUP: 17076 printf("function not implemented\n"); 17077 break; 17078 default: 17079 printf("programming error: (%s)\n", strerror(-ret)); 17080 } 17081 } 17082 17083 cmdline_parse_inst_t cmd_pctype_mapping_reset = { 17084 .f = cmd_pctype_mapping_reset_parsed, 17085 .data = NULL, 17086 .help_str = "port config <port_id> pctype mapping reset", 17087 .tokens = { 17088 (void *)&cmd_pctype_mapping_reset_port, 17089 (void *)&cmd_pctype_mapping_reset_config, 17090 (void *)&cmd_pctype_mapping_reset_port_id, 17091 (void *)&cmd_pctype_mapping_reset_pctype, 17092 (void *)&cmd_pctype_mapping_reset_mapping, 17093 (void *)&cmd_pctype_mapping_reset_reset, 17094 NULL, 17095 }, 17096 }; 17097 17098 /* show port pctype mapping */ 17099 17100 /* Common result structure for show port pctype mapping */ 17101 struct cmd_pctype_mapping_get_result { 17102 cmdline_fixed_string_t show; 17103 cmdline_fixed_string_t port; 17104 portid_t port_id; 17105 cmdline_fixed_string_t pctype; 17106 cmdline_fixed_string_t mapping; 17107 }; 17108 17109 /* Common CLI fields for pctype mapping get */ 17110 cmdline_parse_token_string_t cmd_pctype_mapping_get_show = 17111 TOKEN_STRING_INITIALIZER 17112 (struct cmd_pctype_mapping_get_result, 17113 show, "show"); 17114 cmdline_parse_token_string_t cmd_pctype_mapping_get_port = 17115 TOKEN_STRING_INITIALIZER 17116 (struct cmd_pctype_mapping_get_result, 17117 port, "port"); 17118 cmdline_parse_token_num_t cmd_pctype_mapping_get_port_id = 17119 TOKEN_NUM_INITIALIZER 17120 (struct cmd_pctype_mapping_get_result, 17121 port_id, UINT16); 17122 cmdline_parse_token_string_t cmd_pctype_mapping_get_pctype = 17123 TOKEN_STRING_INITIALIZER 17124 (struct cmd_pctype_mapping_get_result, 17125 pctype, "pctype"); 17126 cmdline_parse_token_string_t cmd_pctype_mapping_get_mapping = 17127 TOKEN_STRING_INITIALIZER 17128 (struct cmd_pctype_mapping_get_result, 17129 mapping, "mapping"); 17130 17131 static void 17132 cmd_pctype_mapping_get_parsed( 17133 void *parsed_result, 17134 __attribute__((unused)) struct cmdline *cl, 17135 __attribute__((unused)) void *data) 17136 { 17137 struct cmd_pctype_mapping_get_result *res = parsed_result; 17138 int ret = -ENOTSUP; 17139 #ifdef RTE_LIBRTE_I40E_PMD 17140 struct rte_pmd_i40e_flow_type_mapping 17141 mapping[RTE_PMD_I40E_FLOW_TYPE_MAX]; 17142 int i, j, first_pctype; 17143 #endif 17144 17145 if (port_id_is_invalid(res->port_id, ENABLED_WARN)) 17146 return; 17147 17148 #ifdef RTE_LIBRTE_I40E_PMD 17149 ret = rte_pmd_i40e_flow_type_mapping_get(res->port_id, mapping); 17150 #endif 17151 17152 switch (ret) { 17153 case 0: 17154 break; 17155 case -ENODEV: 17156 printf("invalid port_id %d\n", res->port_id); 17157 return; 17158 case -ENOTSUP: 17159 printf("function not implemented\n"); 17160 return; 17161 default: 17162 printf("programming error: (%s)\n", strerror(-ret)); 17163 return; 17164 } 17165 17166 #ifdef RTE_LIBRTE_I40E_PMD 17167 for (i = 0; i < RTE_PMD_I40E_FLOW_TYPE_MAX; i++) { 17168 if (mapping[i].pctype != 0ULL) { 17169 first_pctype = 1; 17170 17171 printf("pctype: "); 17172 for (j = 0; j < RTE_PMD_I40E_PCTYPE_MAX; j++) { 17173 if (mapping[i].pctype & (1ULL << j)) { 17174 printf(first_pctype ? 17175 "%02d" : ",%02d", j); 17176 first_pctype = 0; 17177 } 17178 } 17179 printf(" -> flowtype: %02d\n", mapping[i].flow_type); 17180 } 17181 } 17182 #endif 17183 } 17184 17185 cmdline_parse_inst_t cmd_pctype_mapping_get = { 17186 .f = cmd_pctype_mapping_get_parsed, 17187 .data = NULL, 17188 .help_str = "show port <port_id> pctype mapping", 17189 .tokens = { 17190 (void *)&cmd_pctype_mapping_get_show, 17191 (void *)&cmd_pctype_mapping_get_port, 17192 (void *)&cmd_pctype_mapping_get_port_id, 17193 (void *)&cmd_pctype_mapping_get_pctype, 17194 (void *)&cmd_pctype_mapping_get_mapping, 17195 NULL, 17196 }, 17197 }; 17198 17199 /* port config pctype mapping update */ 17200 17201 /* Common result structure for port config pctype mapping update */ 17202 struct cmd_pctype_mapping_update_result { 17203 cmdline_fixed_string_t port; 17204 cmdline_fixed_string_t config; 17205 portid_t port_id; 17206 cmdline_fixed_string_t pctype; 17207 cmdline_fixed_string_t mapping; 17208 cmdline_fixed_string_t update; 17209 cmdline_fixed_string_t pctype_list; 17210 uint16_t flow_type; 17211 }; 17212 17213 /* Common CLI fields for pctype mapping update*/ 17214 cmdline_parse_token_string_t cmd_pctype_mapping_update_port = 17215 TOKEN_STRING_INITIALIZER 17216 (struct cmd_pctype_mapping_update_result, 17217 port, "port"); 17218 cmdline_parse_token_string_t cmd_pctype_mapping_update_config = 17219 TOKEN_STRING_INITIALIZER 17220 (struct cmd_pctype_mapping_update_result, 17221 config, "config"); 17222 cmdline_parse_token_num_t cmd_pctype_mapping_update_port_id = 17223 TOKEN_NUM_INITIALIZER 17224 (struct cmd_pctype_mapping_update_result, 17225 port_id, UINT16); 17226 cmdline_parse_token_string_t cmd_pctype_mapping_update_pctype = 17227 TOKEN_STRING_INITIALIZER 17228 (struct cmd_pctype_mapping_update_result, 17229 pctype, "pctype"); 17230 cmdline_parse_token_string_t cmd_pctype_mapping_update_mapping = 17231 TOKEN_STRING_INITIALIZER 17232 (struct cmd_pctype_mapping_update_result, 17233 mapping, "mapping"); 17234 cmdline_parse_token_string_t cmd_pctype_mapping_update_update = 17235 TOKEN_STRING_INITIALIZER 17236 (struct cmd_pctype_mapping_update_result, 17237 update, "update"); 17238 cmdline_parse_token_string_t cmd_pctype_mapping_update_pc_type = 17239 TOKEN_STRING_INITIALIZER 17240 (struct cmd_pctype_mapping_update_result, 17241 pctype_list, NULL); 17242 cmdline_parse_token_num_t cmd_pctype_mapping_update_flow_type = 17243 TOKEN_NUM_INITIALIZER 17244 (struct cmd_pctype_mapping_update_result, 17245 flow_type, UINT16); 17246 17247 static void 17248 cmd_pctype_mapping_update_parsed( 17249 void *parsed_result, 17250 __attribute__((unused)) struct cmdline *cl, 17251 __attribute__((unused)) void *data) 17252 { 17253 struct cmd_pctype_mapping_update_result *res = parsed_result; 17254 int ret = -ENOTSUP; 17255 #ifdef RTE_LIBRTE_I40E_PMD 17256 struct rte_pmd_i40e_flow_type_mapping mapping; 17257 unsigned int i; 17258 unsigned int nb_item; 17259 unsigned int pctype_list[RTE_PMD_I40E_PCTYPE_MAX]; 17260 #endif 17261 17262 if (port_id_is_invalid(res->port_id, ENABLED_WARN)) 17263 return; 17264 17265 #ifdef RTE_LIBRTE_I40E_PMD 17266 nb_item = parse_item_list(res->pctype_list, "pctypes", 17267 RTE_PMD_I40E_PCTYPE_MAX, pctype_list, 1); 17268 mapping.flow_type = res->flow_type; 17269 for (i = 0, mapping.pctype = 0ULL; i < nb_item; i++) 17270 mapping.pctype |= (1ULL << pctype_list[i]); 17271 ret = rte_pmd_i40e_flow_type_mapping_update(res->port_id, 17272 &mapping, 17273 1, 17274 0); 17275 #endif 17276 17277 switch (ret) { 17278 case 0: 17279 break; 17280 case -EINVAL: 17281 printf("invalid pctype or flow type\n"); 17282 break; 17283 case -ENODEV: 17284 printf("invalid port_id %d\n", res->port_id); 17285 break; 17286 case -ENOTSUP: 17287 printf("function not implemented\n"); 17288 break; 17289 default: 17290 printf("programming error: (%s)\n", strerror(-ret)); 17291 } 17292 } 17293 17294 cmdline_parse_inst_t cmd_pctype_mapping_update = { 17295 .f = cmd_pctype_mapping_update_parsed, 17296 .data = NULL, 17297 .help_str = "port config <port_id> pctype mapping update" 17298 " <pctype_id_0,[pctype_id_1]*> <flowtype_id>", 17299 .tokens = { 17300 (void *)&cmd_pctype_mapping_update_port, 17301 (void *)&cmd_pctype_mapping_update_config, 17302 (void *)&cmd_pctype_mapping_update_port_id, 17303 (void *)&cmd_pctype_mapping_update_pctype, 17304 (void *)&cmd_pctype_mapping_update_mapping, 17305 (void *)&cmd_pctype_mapping_update_update, 17306 (void *)&cmd_pctype_mapping_update_pc_type, 17307 (void *)&cmd_pctype_mapping_update_flow_type, 17308 NULL, 17309 }, 17310 }; 17311 17312 /* ptype mapping get */ 17313 17314 /* Common result structure for ptype mapping get */ 17315 struct cmd_ptype_mapping_get_result { 17316 cmdline_fixed_string_t ptype; 17317 cmdline_fixed_string_t mapping; 17318 cmdline_fixed_string_t get; 17319 portid_t port_id; 17320 uint8_t valid_only; 17321 }; 17322 17323 /* Common CLI fields for ptype mapping get */ 17324 cmdline_parse_token_string_t cmd_ptype_mapping_get_ptype = 17325 TOKEN_STRING_INITIALIZER 17326 (struct cmd_ptype_mapping_get_result, 17327 ptype, "ptype"); 17328 cmdline_parse_token_string_t cmd_ptype_mapping_get_mapping = 17329 TOKEN_STRING_INITIALIZER 17330 (struct cmd_ptype_mapping_get_result, 17331 mapping, "mapping"); 17332 cmdline_parse_token_string_t cmd_ptype_mapping_get_get = 17333 TOKEN_STRING_INITIALIZER 17334 (struct cmd_ptype_mapping_get_result, 17335 get, "get"); 17336 cmdline_parse_token_num_t cmd_ptype_mapping_get_port_id = 17337 TOKEN_NUM_INITIALIZER 17338 (struct cmd_ptype_mapping_get_result, 17339 port_id, UINT16); 17340 cmdline_parse_token_num_t cmd_ptype_mapping_get_valid_only = 17341 TOKEN_NUM_INITIALIZER 17342 (struct cmd_ptype_mapping_get_result, 17343 valid_only, UINT8); 17344 17345 static void 17346 cmd_ptype_mapping_get_parsed( 17347 void *parsed_result, 17348 __attribute__((unused)) struct cmdline *cl, 17349 __attribute__((unused)) void *data) 17350 { 17351 struct cmd_ptype_mapping_get_result *res = parsed_result; 17352 int ret = -ENOTSUP; 17353 #ifdef RTE_LIBRTE_I40E_PMD 17354 int max_ptype_num = 256; 17355 struct rte_pmd_i40e_ptype_mapping mapping[max_ptype_num]; 17356 uint16_t count; 17357 int i; 17358 #endif 17359 17360 if (port_id_is_invalid(res->port_id, ENABLED_WARN)) 17361 return; 17362 17363 #ifdef RTE_LIBRTE_I40E_PMD 17364 ret = rte_pmd_i40e_ptype_mapping_get(res->port_id, 17365 mapping, 17366 max_ptype_num, 17367 &count, 17368 res->valid_only); 17369 #endif 17370 17371 switch (ret) { 17372 case 0: 17373 break; 17374 case -ENODEV: 17375 printf("invalid port_id %d\n", res->port_id); 17376 break; 17377 case -ENOTSUP: 17378 printf("function not implemented\n"); 17379 break; 17380 default: 17381 printf("programming error: (%s)\n", strerror(-ret)); 17382 } 17383 17384 #ifdef RTE_LIBRTE_I40E_PMD 17385 if (!ret) { 17386 for (i = 0; i < count; i++) 17387 printf("%3d\t0x%08x\n", 17388 mapping[i].hw_ptype, mapping[i].sw_ptype); 17389 } 17390 #endif 17391 } 17392 17393 cmdline_parse_inst_t cmd_ptype_mapping_get = { 17394 .f = cmd_ptype_mapping_get_parsed, 17395 .data = NULL, 17396 .help_str = "ptype mapping get <port_id> <valid_only>", 17397 .tokens = { 17398 (void *)&cmd_ptype_mapping_get_ptype, 17399 (void *)&cmd_ptype_mapping_get_mapping, 17400 (void *)&cmd_ptype_mapping_get_get, 17401 (void *)&cmd_ptype_mapping_get_port_id, 17402 (void *)&cmd_ptype_mapping_get_valid_only, 17403 NULL, 17404 }, 17405 }; 17406 17407 /* ptype mapping replace */ 17408 17409 /* Common result structure for ptype mapping replace */ 17410 struct cmd_ptype_mapping_replace_result { 17411 cmdline_fixed_string_t ptype; 17412 cmdline_fixed_string_t mapping; 17413 cmdline_fixed_string_t replace; 17414 portid_t port_id; 17415 uint32_t target; 17416 uint8_t mask; 17417 uint32_t pkt_type; 17418 }; 17419 17420 /* Common CLI fields for ptype mapping replace */ 17421 cmdline_parse_token_string_t cmd_ptype_mapping_replace_ptype = 17422 TOKEN_STRING_INITIALIZER 17423 (struct cmd_ptype_mapping_replace_result, 17424 ptype, "ptype"); 17425 cmdline_parse_token_string_t cmd_ptype_mapping_replace_mapping = 17426 TOKEN_STRING_INITIALIZER 17427 (struct cmd_ptype_mapping_replace_result, 17428 mapping, "mapping"); 17429 cmdline_parse_token_string_t cmd_ptype_mapping_replace_replace = 17430 TOKEN_STRING_INITIALIZER 17431 (struct cmd_ptype_mapping_replace_result, 17432 replace, "replace"); 17433 cmdline_parse_token_num_t cmd_ptype_mapping_replace_port_id = 17434 TOKEN_NUM_INITIALIZER 17435 (struct cmd_ptype_mapping_replace_result, 17436 port_id, UINT16); 17437 cmdline_parse_token_num_t cmd_ptype_mapping_replace_target = 17438 TOKEN_NUM_INITIALIZER 17439 (struct cmd_ptype_mapping_replace_result, 17440 target, UINT32); 17441 cmdline_parse_token_num_t cmd_ptype_mapping_replace_mask = 17442 TOKEN_NUM_INITIALIZER 17443 (struct cmd_ptype_mapping_replace_result, 17444 mask, UINT8); 17445 cmdline_parse_token_num_t cmd_ptype_mapping_replace_pkt_type = 17446 TOKEN_NUM_INITIALIZER 17447 (struct cmd_ptype_mapping_replace_result, 17448 pkt_type, UINT32); 17449 17450 static void 17451 cmd_ptype_mapping_replace_parsed( 17452 void *parsed_result, 17453 __attribute__((unused)) struct cmdline *cl, 17454 __attribute__((unused)) void *data) 17455 { 17456 struct cmd_ptype_mapping_replace_result *res = parsed_result; 17457 int ret = -ENOTSUP; 17458 17459 if (port_id_is_invalid(res->port_id, ENABLED_WARN)) 17460 return; 17461 17462 #ifdef RTE_LIBRTE_I40E_PMD 17463 ret = rte_pmd_i40e_ptype_mapping_replace(res->port_id, 17464 res->target, 17465 res->mask, 17466 res->pkt_type); 17467 #endif 17468 17469 switch (ret) { 17470 case 0: 17471 break; 17472 case -EINVAL: 17473 printf("invalid ptype 0x%8x or 0x%8x\n", 17474 res->target, res->pkt_type); 17475 break; 17476 case -ENODEV: 17477 printf("invalid port_id %d\n", res->port_id); 17478 break; 17479 case -ENOTSUP: 17480 printf("function not implemented\n"); 17481 break; 17482 default: 17483 printf("programming error: (%s)\n", strerror(-ret)); 17484 } 17485 } 17486 17487 cmdline_parse_inst_t cmd_ptype_mapping_replace = { 17488 .f = cmd_ptype_mapping_replace_parsed, 17489 .data = NULL, 17490 .help_str = 17491 "ptype mapping replace <port_id> <target> <mask> <pkt_type>", 17492 .tokens = { 17493 (void *)&cmd_ptype_mapping_replace_ptype, 17494 (void *)&cmd_ptype_mapping_replace_mapping, 17495 (void *)&cmd_ptype_mapping_replace_replace, 17496 (void *)&cmd_ptype_mapping_replace_port_id, 17497 (void *)&cmd_ptype_mapping_replace_target, 17498 (void *)&cmd_ptype_mapping_replace_mask, 17499 (void *)&cmd_ptype_mapping_replace_pkt_type, 17500 NULL, 17501 }, 17502 }; 17503 17504 /* ptype mapping reset */ 17505 17506 /* Common result structure for ptype mapping reset */ 17507 struct cmd_ptype_mapping_reset_result { 17508 cmdline_fixed_string_t ptype; 17509 cmdline_fixed_string_t mapping; 17510 cmdline_fixed_string_t reset; 17511 portid_t port_id; 17512 }; 17513 17514 /* Common CLI fields for ptype mapping reset*/ 17515 cmdline_parse_token_string_t cmd_ptype_mapping_reset_ptype = 17516 TOKEN_STRING_INITIALIZER 17517 (struct cmd_ptype_mapping_reset_result, 17518 ptype, "ptype"); 17519 cmdline_parse_token_string_t cmd_ptype_mapping_reset_mapping = 17520 TOKEN_STRING_INITIALIZER 17521 (struct cmd_ptype_mapping_reset_result, 17522 mapping, "mapping"); 17523 cmdline_parse_token_string_t cmd_ptype_mapping_reset_reset = 17524 TOKEN_STRING_INITIALIZER 17525 (struct cmd_ptype_mapping_reset_result, 17526 reset, "reset"); 17527 cmdline_parse_token_num_t cmd_ptype_mapping_reset_port_id = 17528 TOKEN_NUM_INITIALIZER 17529 (struct cmd_ptype_mapping_reset_result, 17530 port_id, UINT16); 17531 17532 static void 17533 cmd_ptype_mapping_reset_parsed( 17534 void *parsed_result, 17535 __attribute__((unused)) struct cmdline *cl, 17536 __attribute__((unused)) void *data) 17537 { 17538 struct cmd_ptype_mapping_reset_result *res = parsed_result; 17539 int ret = -ENOTSUP; 17540 17541 if (port_id_is_invalid(res->port_id, ENABLED_WARN)) 17542 return; 17543 17544 #ifdef RTE_LIBRTE_I40E_PMD 17545 ret = rte_pmd_i40e_ptype_mapping_reset(res->port_id); 17546 #endif 17547 17548 switch (ret) { 17549 case 0: 17550 break; 17551 case -ENODEV: 17552 printf("invalid port_id %d\n", res->port_id); 17553 break; 17554 case -ENOTSUP: 17555 printf("function not implemented\n"); 17556 break; 17557 default: 17558 printf("programming error: (%s)\n", strerror(-ret)); 17559 } 17560 } 17561 17562 cmdline_parse_inst_t cmd_ptype_mapping_reset = { 17563 .f = cmd_ptype_mapping_reset_parsed, 17564 .data = NULL, 17565 .help_str = "ptype mapping reset <port_id>", 17566 .tokens = { 17567 (void *)&cmd_ptype_mapping_reset_ptype, 17568 (void *)&cmd_ptype_mapping_reset_mapping, 17569 (void *)&cmd_ptype_mapping_reset_reset, 17570 (void *)&cmd_ptype_mapping_reset_port_id, 17571 NULL, 17572 }, 17573 }; 17574 17575 /* ptype mapping update */ 17576 17577 /* Common result structure for ptype mapping update */ 17578 struct cmd_ptype_mapping_update_result { 17579 cmdline_fixed_string_t ptype; 17580 cmdline_fixed_string_t mapping; 17581 cmdline_fixed_string_t reset; 17582 portid_t port_id; 17583 uint8_t hw_ptype; 17584 uint32_t sw_ptype; 17585 }; 17586 17587 /* Common CLI fields for ptype mapping update*/ 17588 cmdline_parse_token_string_t cmd_ptype_mapping_update_ptype = 17589 TOKEN_STRING_INITIALIZER 17590 (struct cmd_ptype_mapping_update_result, 17591 ptype, "ptype"); 17592 cmdline_parse_token_string_t cmd_ptype_mapping_update_mapping = 17593 TOKEN_STRING_INITIALIZER 17594 (struct cmd_ptype_mapping_update_result, 17595 mapping, "mapping"); 17596 cmdline_parse_token_string_t cmd_ptype_mapping_update_update = 17597 TOKEN_STRING_INITIALIZER 17598 (struct cmd_ptype_mapping_update_result, 17599 reset, "update"); 17600 cmdline_parse_token_num_t cmd_ptype_mapping_update_port_id = 17601 TOKEN_NUM_INITIALIZER 17602 (struct cmd_ptype_mapping_update_result, 17603 port_id, UINT16); 17604 cmdline_parse_token_num_t cmd_ptype_mapping_update_hw_ptype = 17605 TOKEN_NUM_INITIALIZER 17606 (struct cmd_ptype_mapping_update_result, 17607 hw_ptype, UINT8); 17608 cmdline_parse_token_num_t cmd_ptype_mapping_update_sw_ptype = 17609 TOKEN_NUM_INITIALIZER 17610 (struct cmd_ptype_mapping_update_result, 17611 sw_ptype, UINT32); 17612 17613 static void 17614 cmd_ptype_mapping_update_parsed( 17615 void *parsed_result, 17616 __attribute__((unused)) struct cmdline *cl, 17617 __attribute__((unused)) void *data) 17618 { 17619 struct cmd_ptype_mapping_update_result *res = parsed_result; 17620 int ret = -ENOTSUP; 17621 #ifdef RTE_LIBRTE_I40E_PMD 17622 struct rte_pmd_i40e_ptype_mapping mapping; 17623 #endif 17624 if (port_id_is_invalid(res->port_id, ENABLED_WARN)) 17625 return; 17626 17627 #ifdef RTE_LIBRTE_I40E_PMD 17628 mapping.hw_ptype = res->hw_ptype; 17629 mapping.sw_ptype = res->sw_ptype; 17630 ret = rte_pmd_i40e_ptype_mapping_update(res->port_id, 17631 &mapping, 17632 1, 17633 0); 17634 #endif 17635 17636 switch (ret) { 17637 case 0: 17638 break; 17639 case -EINVAL: 17640 printf("invalid ptype 0x%8x\n", res->sw_ptype); 17641 break; 17642 case -ENODEV: 17643 printf("invalid port_id %d\n", res->port_id); 17644 break; 17645 case -ENOTSUP: 17646 printf("function not implemented\n"); 17647 break; 17648 default: 17649 printf("programming error: (%s)\n", strerror(-ret)); 17650 } 17651 } 17652 17653 cmdline_parse_inst_t cmd_ptype_mapping_update = { 17654 .f = cmd_ptype_mapping_update_parsed, 17655 .data = NULL, 17656 .help_str = "ptype mapping update <port_id> <hw_ptype> <sw_ptype>", 17657 .tokens = { 17658 (void *)&cmd_ptype_mapping_update_ptype, 17659 (void *)&cmd_ptype_mapping_update_mapping, 17660 (void *)&cmd_ptype_mapping_update_update, 17661 (void *)&cmd_ptype_mapping_update_port_id, 17662 (void *)&cmd_ptype_mapping_update_hw_ptype, 17663 (void *)&cmd_ptype_mapping_update_sw_ptype, 17664 NULL, 17665 }, 17666 }; 17667 17668 /* Common result structure for file commands */ 17669 struct cmd_cmdfile_result { 17670 cmdline_fixed_string_t load; 17671 cmdline_fixed_string_t filename; 17672 }; 17673 17674 /* Common CLI fields for file commands */ 17675 cmdline_parse_token_string_t cmd_load_cmdfile = 17676 TOKEN_STRING_INITIALIZER(struct cmd_cmdfile_result, load, "load"); 17677 cmdline_parse_token_string_t cmd_load_cmdfile_filename = 17678 TOKEN_STRING_INITIALIZER(struct cmd_cmdfile_result, filename, NULL); 17679 17680 static void 17681 cmd_load_from_file_parsed( 17682 void *parsed_result, 17683 __attribute__((unused)) struct cmdline *cl, 17684 __attribute__((unused)) void *data) 17685 { 17686 struct cmd_cmdfile_result *res = parsed_result; 17687 17688 cmdline_read_from_file(res->filename); 17689 } 17690 17691 cmdline_parse_inst_t cmd_load_from_file = { 17692 .f = cmd_load_from_file_parsed, 17693 .data = NULL, 17694 .help_str = "load <filename>", 17695 .tokens = { 17696 (void *)&cmd_load_cmdfile, 17697 (void *)&cmd_load_cmdfile_filename, 17698 NULL, 17699 }, 17700 }; 17701 17702 /* Get Rx offloads capabilities */ 17703 struct cmd_rx_offload_get_capa_result { 17704 cmdline_fixed_string_t show; 17705 cmdline_fixed_string_t port; 17706 portid_t port_id; 17707 cmdline_fixed_string_t rx_offload; 17708 cmdline_fixed_string_t capabilities; 17709 }; 17710 17711 cmdline_parse_token_string_t cmd_rx_offload_get_capa_show = 17712 TOKEN_STRING_INITIALIZER 17713 (struct cmd_rx_offload_get_capa_result, 17714 show, "show"); 17715 cmdline_parse_token_string_t cmd_rx_offload_get_capa_port = 17716 TOKEN_STRING_INITIALIZER 17717 (struct cmd_rx_offload_get_capa_result, 17718 port, "port"); 17719 cmdline_parse_token_num_t cmd_rx_offload_get_capa_port_id = 17720 TOKEN_NUM_INITIALIZER 17721 (struct cmd_rx_offload_get_capa_result, 17722 port_id, UINT16); 17723 cmdline_parse_token_string_t cmd_rx_offload_get_capa_rx_offload = 17724 TOKEN_STRING_INITIALIZER 17725 (struct cmd_rx_offload_get_capa_result, 17726 rx_offload, "rx_offload"); 17727 cmdline_parse_token_string_t cmd_rx_offload_get_capa_capabilities = 17728 TOKEN_STRING_INITIALIZER 17729 (struct cmd_rx_offload_get_capa_result, 17730 capabilities, "capabilities"); 17731 17732 static void 17733 print_rx_offloads(uint64_t offloads) 17734 { 17735 uint64_t single_offload; 17736 int begin; 17737 int end; 17738 int bit; 17739 17740 if (offloads == 0) 17741 return; 17742 17743 begin = __builtin_ctzll(offloads); 17744 end = sizeof(offloads) * CHAR_BIT - __builtin_clzll(offloads); 17745 17746 single_offload = 1ULL << begin; 17747 for (bit = begin; bit < end; bit++) { 17748 if (offloads & single_offload) 17749 printf(" %s", 17750 rte_eth_dev_rx_offload_name(single_offload)); 17751 single_offload <<= 1; 17752 } 17753 } 17754 17755 static void 17756 cmd_rx_offload_get_capa_parsed( 17757 void *parsed_result, 17758 __attribute__((unused)) struct cmdline *cl, 17759 __attribute__((unused)) void *data) 17760 { 17761 struct cmd_rx_offload_get_capa_result *res = parsed_result; 17762 struct rte_eth_dev_info dev_info; 17763 portid_t port_id = res->port_id; 17764 uint64_t queue_offloads; 17765 uint64_t port_offloads; 17766 17767 rte_eth_dev_info_get(port_id, &dev_info); 17768 queue_offloads = dev_info.rx_queue_offload_capa; 17769 port_offloads = dev_info.rx_offload_capa ^ queue_offloads; 17770 17771 printf("Rx Offloading Capabilities of port %d :\n", port_id); 17772 printf(" Per Queue :"); 17773 print_rx_offloads(queue_offloads); 17774 17775 printf("\n"); 17776 printf(" Per Port :"); 17777 print_rx_offloads(port_offloads); 17778 printf("\n\n"); 17779 } 17780 17781 cmdline_parse_inst_t cmd_rx_offload_get_capa = { 17782 .f = cmd_rx_offload_get_capa_parsed, 17783 .data = NULL, 17784 .help_str = "show port <port_id> rx_offload capabilities", 17785 .tokens = { 17786 (void *)&cmd_rx_offload_get_capa_show, 17787 (void *)&cmd_rx_offload_get_capa_port, 17788 (void *)&cmd_rx_offload_get_capa_port_id, 17789 (void *)&cmd_rx_offload_get_capa_rx_offload, 17790 (void *)&cmd_rx_offload_get_capa_capabilities, 17791 NULL, 17792 } 17793 }; 17794 17795 /* Get Rx offloads configuration */ 17796 struct cmd_rx_offload_get_configuration_result { 17797 cmdline_fixed_string_t show; 17798 cmdline_fixed_string_t port; 17799 portid_t port_id; 17800 cmdline_fixed_string_t rx_offload; 17801 cmdline_fixed_string_t configuration; 17802 }; 17803 17804 cmdline_parse_token_string_t cmd_rx_offload_get_configuration_show = 17805 TOKEN_STRING_INITIALIZER 17806 (struct cmd_rx_offload_get_configuration_result, 17807 show, "show"); 17808 cmdline_parse_token_string_t cmd_rx_offload_get_configuration_port = 17809 TOKEN_STRING_INITIALIZER 17810 (struct cmd_rx_offload_get_configuration_result, 17811 port, "port"); 17812 cmdline_parse_token_num_t cmd_rx_offload_get_configuration_port_id = 17813 TOKEN_NUM_INITIALIZER 17814 (struct cmd_rx_offload_get_configuration_result, 17815 port_id, UINT16); 17816 cmdline_parse_token_string_t cmd_rx_offload_get_configuration_rx_offload = 17817 TOKEN_STRING_INITIALIZER 17818 (struct cmd_rx_offload_get_configuration_result, 17819 rx_offload, "rx_offload"); 17820 cmdline_parse_token_string_t cmd_rx_offload_get_configuration_configuration = 17821 TOKEN_STRING_INITIALIZER 17822 (struct cmd_rx_offload_get_configuration_result, 17823 configuration, "configuration"); 17824 17825 static void 17826 cmd_rx_offload_get_configuration_parsed( 17827 void *parsed_result, 17828 __attribute__((unused)) struct cmdline *cl, 17829 __attribute__((unused)) void *data) 17830 { 17831 struct cmd_rx_offload_get_configuration_result *res = parsed_result; 17832 struct rte_eth_dev_info dev_info; 17833 portid_t port_id = res->port_id; 17834 struct rte_port *port = &ports[port_id]; 17835 uint64_t port_offloads; 17836 uint64_t queue_offloads; 17837 uint16_t nb_rx_queues; 17838 int q; 17839 17840 printf("Rx Offloading Configuration of port %d :\n", port_id); 17841 17842 port_offloads = port->dev_conf.rxmode.offloads; 17843 printf(" Port :"); 17844 print_rx_offloads(port_offloads); 17845 printf("\n"); 17846 17847 rte_eth_dev_info_get(port_id, &dev_info); 17848 nb_rx_queues = dev_info.nb_rx_queues; 17849 for (q = 0; q < nb_rx_queues; q++) { 17850 queue_offloads = port->rx_conf[q].offloads; 17851 printf(" Queue[%2d] :", q); 17852 print_rx_offloads(queue_offloads); 17853 printf("\n"); 17854 } 17855 printf("\n"); 17856 } 17857 17858 cmdline_parse_inst_t cmd_rx_offload_get_configuration = { 17859 .f = cmd_rx_offload_get_configuration_parsed, 17860 .data = NULL, 17861 .help_str = "show port <port_id> rx_offload configuration", 17862 .tokens = { 17863 (void *)&cmd_rx_offload_get_configuration_show, 17864 (void *)&cmd_rx_offload_get_configuration_port, 17865 (void *)&cmd_rx_offload_get_configuration_port_id, 17866 (void *)&cmd_rx_offload_get_configuration_rx_offload, 17867 (void *)&cmd_rx_offload_get_configuration_configuration, 17868 NULL, 17869 } 17870 }; 17871 17872 /* Enable/Disable a per port offloading */ 17873 struct cmd_config_per_port_rx_offload_result { 17874 cmdline_fixed_string_t port; 17875 cmdline_fixed_string_t config; 17876 portid_t port_id; 17877 cmdline_fixed_string_t rx_offload; 17878 cmdline_fixed_string_t offload; 17879 cmdline_fixed_string_t on_off; 17880 }; 17881 17882 cmdline_parse_token_string_t cmd_config_per_port_rx_offload_result_port = 17883 TOKEN_STRING_INITIALIZER 17884 (struct cmd_config_per_port_rx_offload_result, 17885 port, "port"); 17886 cmdline_parse_token_string_t cmd_config_per_port_rx_offload_result_config = 17887 TOKEN_STRING_INITIALIZER 17888 (struct cmd_config_per_port_rx_offload_result, 17889 config, "config"); 17890 cmdline_parse_token_num_t cmd_config_per_port_rx_offload_result_port_id = 17891 TOKEN_NUM_INITIALIZER 17892 (struct cmd_config_per_port_rx_offload_result, 17893 port_id, UINT16); 17894 cmdline_parse_token_string_t cmd_config_per_port_rx_offload_result_rx_offload = 17895 TOKEN_STRING_INITIALIZER 17896 (struct cmd_config_per_port_rx_offload_result, 17897 rx_offload, "rx_offload"); 17898 cmdline_parse_token_string_t cmd_config_per_port_rx_offload_result_offload = 17899 TOKEN_STRING_INITIALIZER 17900 (struct cmd_config_per_port_rx_offload_result, 17901 offload, "vlan_strip#ipv4_cksum#udp_cksum#tcp_cksum#tcp_lro#" 17902 "qinq_strip#outer_ipv4_cksum#macsec_strip#" 17903 "header_split#vlan_filter#vlan_extend#jumbo_frame#" 17904 "crc_strip#scatter#timestamp#security#keep_crc"); 17905 cmdline_parse_token_string_t cmd_config_per_port_rx_offload_result_on_off = 17906 TOKEN_STRING_INITIALIZER 17907 (struct cmd_config_per_port_rx_offload_result, 17908 on_off, "on#off"); 17909 17910 static uint64_t 17911 search_rx_offload(const char *name) 17912 { 17913 uint64_t single_offload; 17914 const char *single_name; 17915 int found = 0; 17916 unsigned int bit; 17917 17918 single_offload = 1; 17919 for (bit = 0; bit < sizeof(single_offload) * CHAR_BIT; bit++) { 17920 single_name = rte_eth_dev_rx_offload_name(single_offload); 17921 if (!strcasecmp(single_name, name)) { 17922 found = 1; 17923 break; 17924 } 17925 single_offload <<= 1; 17926 } 17927 17928 if (found) 17929 return single_offload; 17930 17931 return 0; 17932 } 17933 17934 static void 17935 cmd_config_per_port_rx_offload_parsed(void *parsed_result, 17936 __attribute__((unused)) struct cmdline *cl, 17937 __attribute__((unused)) void *data) 17938 { 17939 struct cmd_config_per_port_rx_offload_result *res = parsed_result; 17940 portid_t port_id = res->port_id; 17941 struct rte_eth_dev_info dev_info; 17942 struct rte_port *port = &ports[port_id]; 17943 uint64_t single_offload; 17944 uint16_t nb_rx_queues; 17945 int q; 17946 17947 if (port->port_status != RTE_PORT_STOPPED) { 17948 printf("Error: Can't config offload when Port %d " 17949 "is not stopped\n", port_id); 17950 return; 17951 } 17952 17953 single_offload = search_rx_offload(res->offload); 17954 if (single_offload == 0) { 17955 printf("Unknown offload name: %s\n", res->offload); 17956 return; 17957 } 17958 17959 rte_eth_dev_info_get(port_id, &dev_info); 17960 nb_rx_queues = dev_info.nb_rx_queues; 17961 if (!strcmp(res->on_off, "on")) { 17962 port->dev_conf.rxmode.offloads |= single_offload; 17963 for (q = 0; q < nb_rx_queues; q++) 17964 port->rx_conf[q].offloads |= single_offload; 17965 } else { 17966 port->dev_conf.rxmode.offloads &= ~single_offload; 17967 for (q = 0; q < nb_rx_queues; q++) 17968 port->rx_conf[q].offloads &= ~single_offload; 17969 } 17970 17971 cmd_reconfig_device_queue(port_id, 1, 1); 17972 } 17973 17974 cmdline_parse_inst_t cmd_config_per_port_rx_offload = { 17975 .f = cmd_config_per_port_rx_offload_parsed, 17976 .data = NULL, 17977 .help_str = "port config <port_id> rx_offload vlan_strip|ipv4_cksum|" 17978 "udp_cksum|tcp_cksum|tcp_lro|qinq_strip|outer_ipv4_cksum|" 17979 "macsec_strip|header_split|vlan_filter|vlan_extend|" 17980 "jumbo_frame|crc_strip|scatter|timestamp|security|keep_crc " 17981 "on|off", 17982 .tokens = { 17983 (void *)&cmd_config_per_port_rx_offload_result_port, 17984 (void *)&cmd_config_per_port_rx_offload_result_config, 17985 (void *)&cmd_config_per_port_rx_offload_result_port_id, 17986 (void *)&cmd_config_per_port_rx_offload_result_rx_offload, 17987 (void *)&cmd_config_per_port_rx_offload_result_offload, 17988 (void *)&cmd_config_per_port_rx_offload_result_on_off, 17989 NULL, 17990 } 17991 }; 17992 17993 /* Enable/Disable a per queue offloading */ 17994 struct cmd_config_per_queue_rx_offload_result { 17995 cmdline_fixed_string_t port; 17996 portid_t port_id; 17997 cmdline_fixed_string_t rxq; 17998 uint16_t queue_id; 17999 cmdline_fixed_string_t rx_offload; 18000 cmdline_fixed_string_t offload; 18001 cmdline_fixed_string_t on_off; 18002 }; 18003 18004 cmdline_parse_token_string_t cmd_config_per_queue_rx_offload_result_port = 18005 TOKEN_STRING_INITIALIZER 18006 (struct cmd_config_per_queue_rx_offload_result, 18007 port, "port"); 18008 cmdline_parse_token_num_t cmd_config_per_queue_rx_offload_result_port_id = 18009 TOKEN_NUM_INITIALIZER 18010 (struct cmd_config_per_queue_rx_offload_result, 18011 port_id, UINT16); 18012 cmdline_parse_token_string_t cmd_config_per_queue_rx_offload_result_rxq = 18013 TOKEN_STRING_INITIALIZER 18014 (struct cmd_config_per_queue_rx_offload_result, 18015 rxq, "rxq"); 18016 cmdline_parse_token_num_t cmd_config_per_queue_rx_offload_result_queue_id = 18017 TOKEN_NUM_INITIALIZER 18018 (struct cmd_config_per_queue_rx_offload_result, 18019 queue_id, UINT16); 18020 cmdline_parse_token_string_t cmd_config_per_queue_rx_offload_result_rxoffload = 18021 TOKEN_STRING_INITIALIZER 18022 (struct cmd_config_per_queue_rx_offload_result, 18023 rx_offload, "rx_offload"); 18024 cmdline_parse_token_string_t cmd_config_per_queue_rx_offload_result_offload = 18025 TOKEN_STRING_INITIALIZER 18026 (struct cmd_config_per_queue_rx_offload_result, 18027 offload, "vlan_strip#ipv4_cksum#udp_cksum#tcp_cksum#tcp_lro#" 18028 "qinq_strip#outer_ipv4_cksum#macsec_strip#" 18029 "header_split#vlan_filter#vlan_extend#jumbo_frame#" 18030 "crc_strip#scatter#timestamp#security#keep_crc"); 18031 cmdline_parse_token_string_t cmd_config_per_queue_rx_offload_result_on_off = 18032 TOKEN_STRING_INITIALIZER 18033 (struct cmd_config_per_queue_rx_offload_result, 18034 on_off, "on#off"); 18035 18036 static void 18037 cmd_config_per_queue_rx_offload_parsed(void *parsed_result, 18038 __attribute__((unused)) struct cmdline *cl, 18039 __attribute__((unused)) void *data) 18040 { 18041 struct cmd_config_per_queue_rx_offload_result *res = parsed_result; 18042 struct rte_eth_dev_info dev_info; 18043 portid_t port_id = res->port_id; 18044 uint16_t queue_id = res->queue_id; 18045 struct rte_port *port = &ports[port_id]; 18046 uint64_t single_offload; 18047 18048 if (port->port_status != RTE_PORT_STOPPED) { 18049 printf("Error: Can't config offload when Port %d " 18050 "is not stopped\n", port_id); 18051 return; 18052 } 18053 18054 rte_eth_dev_info_get(port_id, &dev_info); 18055 if (queue_id >= dev_info.nb_rx_queues) { 18056 printf("Error: input queue_id should be 0 ... " 18057 "%d\n", dev_info.nb_rx_queues - 1); 18058 return; 18059 } 18060 18061 single_offload = search_rx_offload(res->offload); 18062 if (single_offload == 0) { 18063 printf("Unknown offload name: %s\n", res->offload); 18064 return; 18065 } 18066 18067 if (!strcmp(res->on_off, "on")) 18068 port->rx_conf[queue_id].offloads |= single_offload; 18069 else 18070 port->rx_conf[queue_id].offloads &= ~single_offload; 18071 18072 cmd_reconfig_device_queue(port_id, 1, 1); 18073 } 18074 18075 cmdline_parse_inst_t cmd_config_per_queue_rx_offload = { 18076 .f = cmd_config_per_queue_rx_offload_parsed, 18077 .data = NULL, 18078 .help_str = "port <port_id> rxq <queue_id> rx_offload " 18079 "vlan_strip|ipv4_cksum|" 18080 "udp_cksum|tcp_cksum|tcp_lro|qinq_strip|outer_ipv4_cksum|" 18081 "macsec_strip|header_split|vlan_filter|vlan_extend|" 18082 "jumbo_frame|crc_strip|scatter|timestamp|security|keep_crc " 18083 "on|off", 18084 .tokens = { 18085 (void *)&cmd_config_per_queue_rx_offload_result_port, 18086 (void *)&cmd_config_per_queue_rx_offload_result_port_id, 18087 (void *)&cmd_config_per_queue_rx_offload_result_rxq, 18088 (void *)&cmd_config_per_queue_rx_offload_result_queue_id, 18089 (void *)&cmd_config_per_queue_rx_offload_result_rxoffload, 18090 (void *)&cmd_config_per_queue_rx_offload_result_offload, 18091 (void *)&cmd_config_per_queue_rx_offload_result_on_off, 18092 NULL, 18093 } 18094 }; 18095 18096 /* Get Tx offloads capabilities */ 18097 struct cmd_tx_offload_get_capa_result { 18098 cmdline_fixed_string_t show; 18099 cmdline_fixed_string_t port; 18100 portid_t port_id; 18101 cmdline_fixed_string_t tx_offload; 18102 cmdline_fixed_string_t capabilities; 18103 }; 18104 18105 cmdline_parse_token_string_t cmd_tx_offload_get_capa_show = 18106 TOKEN_STRING_INITIALIZER 18107 (struct cmd_tx_offload_get_capa_result, 18108 show, "show"); 18109 cmdline_parse_token_string_t cmd_tx_offload_get_capa_port = 18110 TOKEN_STRING_INITIALIZER 18111 (struct cmd_tx_offload_get_capa_result, 18112 port, "port"); 18113 cmdline_parse_token_num_t cmd_tx_offload_get_capa_port_id = 18114 TOKEN_NUM_INITIALIZER 18115 (struct cmd_tx_offload_get_capa_result, 18116 port_id, UINT16); 18117 cmdline_parse_token_string_t cmd_tx_offload_get_capa_tx_offload = 18118 TOKEN_STRING_INITIALIZER 18119 (struct cmd_tx_offload_get_capa_result, 18120 tx_offload, "tx_offload"); 18121 cmdline_parse_token_string_t cmd_tx_offload_get_capa_capabilities = 18122 TOKEN_STRING_INITIALIZER 18123 (struct cmd_tx_offload_get_capa_result, 18124 capabilities, "capabilities"); 18125 18126 static void 18127 print_tx_offloads(uint64_t offloads) 18128 { 18129 uint64_t single_offload; 18130 int begin; 18131 int end; 18132 int bit; 18133 18134 if (offloads == 0) 18135 return; 18136 18137 begin = __builtin_ctzll(offloads); 18138 end = sizeof(offloads) * CHAR_BIT - __builtin_clzll(offloads); 18139 18140 single_offload = 1ULL << begin; 18141 for (bit = begin; bit < end; bit++) { 18142 if (offloads & single_offload) 18143 printf(" %s", 18144 rte_eth_dev_tx_offload_name(single_offload)); 18145 single_offload <<= 1; 18146 } 18147 } 18148 18149 static void 18150 cmd_tx_offload_get_capa_parsed( 18151 void *parsed_result, 18152 __attribute__((unused)) struct cmdline *cl, 18153 __attribute__((unused)) void *data) 18154 { 18155 struct cmd_tx_offload_get_capa_result *res = parsed_result; 18156 struct rte_eth_dev_info dev_info; 18157 portid_t port_id = res->port_id; 18158 uint64_t queue_offloads; 18159 uint64_t port_offloads; 18160 18161 rte_eth_dev_info_get(port_id, &dev_info); 18162 queue_offloads = dev_info.tx_queue_offload_capa; 18163 port_offloads = dev_info.tx_offload_capa ^ queue_offloads; 18164 18165 printf("Tx Offloading Capabilities of port %d :\n", port_id); 18166 printf(" Per Queue :"); 18167 print_tx_offloads(queue_offloads); 18168 18169 printf("\n"); 18170 printf(" Per Port :"); 18171 print_tx_offloads(port_offloads); 18172 printf("\n\n"); 18173 } 18174 18175 cmdline_parse_inst_t cmd_tx_offload_get_capa = { 18176 .f = cmd_tx_offload_get_capa_parsed, 18177 .data = NULL, 18178 .help_str = "show port <port_id> tx_offload capabilities", 18179 .tokens = { 18180 (void *)&cmd_tx_offload_get_capa_show, 18181 (void *)&cmd_tx_offload_get_capa_port, 18182 (void *)&cmd_tx_offload_get_capa_port_id, 18183 (void *)&cmd_tx_offload_get_capa_tx_offload, 18184 (void *)&cmd_tx_offload_get_capa_capabilities, 18185 NULL, 18186 } 18187 }; 18188 18189 /* Get Tx offloads configuration */ 18190 struct cmd_tx_offload_get_configuration_result { 18191 cmdline_fixed_string_t show; 18192 cmdline_fixed_string_t port; 18193 portid_t port_id; 18194 cmdline_fixed_string_t tx_offload; 18195 cmdline_fixed_string_t configuration; 18196 }; 18197 18198 cmdline_parse_token_string_t cmd_tx_offload_get_configuration_show = 18199 TOKEN_STRING_INITIALIZER 18200 (struct cmd_tx_offload_get_configuration_result, 18201 show, "show"); 18202 cmdline_parse_token_string_t cmd_tx_offload_get_configuration_port = 18203 TOKEN_STRING_INITIALIZER 18204 (struct cmd_tx_offload_get_configuration_result, 18205 port, "port"); 18206 cmdline_parse_token_num_t cmd_tx_offload_get_configuration_port_id = 18207 TOKEN_NUM_INITIALIZER 18208 (struct cmd_tx_offload_get_configuration_result, 18209 port_id, UINT16); 18210 cmdline_parse_token_string_t cmd_tx_offload_get_configuration_tx_offload = 18211 TOKEN_STRING_INITIALIZER 18212 (struct cmd_tx_offload_get_configuration_result, 18213 tx_offload, "tx_offload"); 18214 cmdline_parse_token_string_t cmd_tx_offload_get_configuration_configuration = 18215 TOKEN_STRING_INITIALIZER 18216 (struct cmd_tx_offload_get_configuration_result, 18217 configuration, "configuration"); 18218 18219 static void 18220 cmd_tx_offload_get_configuration_parsed( 18221 void *parsed_result, 18222 __attribute__((unused)) struct cmdline *cl, 18223 __attribute__((unused)) void *data) 18224 { 18225 struct cmd_tx_offload_get_configuration_result *res = parsed_result; 18226 struct rte_eth_dev_info dev_info; 18227 portid_t port_id = res->port_id; 18228 struct rte_port *port = &ports[port_id]; 18229 uint64_t port_offloads; 18230 uint64_t queue_offloads; 18231 uint16_t nb_tx_queues; 18232 int q; 18233 18234 printf("Tx Offloading Configuration of port %d :\n", port_id); 18235 18236 port_offloads = port->dev_conf.txmode.offloads; 18237 printf(" Port :"); 18238 print_tx_offloads(port_offloads); 18239 printf("\n"); 18240 18241 rte_eth_dev_info_get(port_id, &dev_info); 18242 nb_tx_queues = dev_info.nb_tx_queues; 18243 for (q = 0; q < nb_tx_queues; q++) { 18244 queue_offloads = port->tx_conf[q].offloads; 18245 printf(" Queue[%2d] :", q); 18246 print_tx_offloads(queue_offloads); 18247 printf("\n"); 18248 } 18249 printf("\n"); 18250 } 18251 18252 cmdline_parse_inst_t cmd_tx_offload_get_configuration = { 18253 .f = cmd_tx_offload_get_configuration_parsed, 18254 .data = NULL, 18255 .help_str = "show port <port_id> tx_offload configuration", 18256 .tokens = { 18257 (void *)&cmd_tx_offload_get_configuration_show, 18258 (void *)&cmd_tx_offload_get_configuration_port, 18259 (void *)&cmd_tx_offload_get_configuration_port_id, 18260 (void *)&cmd_tx_offload_get_configuration_tx_offload, 18261 (void *)&cmd_tx_offload_get_configuration_configuration, 18262 NULL, 18263 } 18264 }; 18265 18266 /* Enable/Disable a per port offloading */ 18267 struct cmd_config_per_port_tx_offload_result { 18268 cmdline_fixed_string_t port; 18269 cmdline_fixed_string_t config; 18270 portid_t port_id; 18271 cmdline_fixed_string_t tx_offload; 18272 cmdline_fixed_string_t offload; 18273 cmdline_fixed_string_t on_off; 18274 }; 18275 18276 cmdline_parse_token_string_t cmd_config_per_port_tx_offload_result_port = 18277 TOKEN_STRING_INITIALIZER 18278 (struct cmd_config_per_port_tx_offload_result, 18279 port, "port"); 18280 cmdline_parse_token_string_t cmd_config_per_port_tx_offload_result_config = 18281 TOKEN_STRING_INITIALIZER 18282 (struct cmd_config_per_port_tx_offload_result, 18283 config, "config"); 18284 cmdline_parse_token_num_t cmd_config_per_port_tx_offload_result_port_id = 18285 TOKEN_NUM_INITIALIZER 18286 (struct cmd_config_per_port_tx_offload_result, 18287 port_id, UINT16); 18288 cmdline_parse_token_string_t cmd_config_per_port_tx_offload_result_tx_offload = 18289 TOKEN_STRING_INITIALIZER 18290 (struct cmd_config_per_port_tx_offload_result, 18291 tx_offload, "tx_offload"); 18292 cmdline_parse_token_string_t cmd_config_per_port_tx_offload_result_offload = 18293 TOKEN_STRING_INITIALIZER 18294 (struct cmd_config_per_port_tx_offload_result, 18295 offload, "vlan_insert#ipv4_cksum#udp_cksum#tcp_cksum#" 18296 "sctp_cksum#tcp_tso#udp_tso#outer_ipv4_cksum#" 18297 "qinq_insert#vxlan_tnl_tso#gre_tnl_tso#" 18298 "ipip_tnl_tso#geneve_tnl_tso#macsec_insert#" 18299 "mt_lockfree#multi_segs#mbuf_fast_free#security#" 18300 "match_metadata"); 18301 cmdline_parse_token_string_t cmd_config_per_port_tx_offload_result_on_off = 18302 TOKEN_STRING_INITIALIZER 18303 (struct cmd_config_per_port_tx_offload_result, 18304 on_off, "on#off"); 18305 18306 static uint64_t 18307 search_tx_offload(const char *name) 18308 { 18309 uint64_t single_offload; 18310 const char *single_name; 18311 int found = 0; 18312 unsigned int bit; 18313 18314 single_offload = 1; 18315 for (bit = 0; bit < sizeof(single_offload) * CHAR_BIT; bit++) { 18316 single_name = rte_eth_dev_tx_offload_name(single_offload); 18317 if (single_name == NULL) 18318 break; 18319 if (!strcasecmp(single_name, name)) { 18320 found = 1; 18321 break; 18322 } else if (!strcasecmp(single_name, "UNKNOWN")) 18323 break; 18324 single_offload <<= 1; 18325 } 18326 18327 if (found) 18328 return single_offload; 18329 18330 return 0; 18331 } 18332 18333 static void 18334 cmd_config_per_port_tx_offload_parsed(void *parsed_result, 18335 __attribute__((unused)) struct cmdline *cl, 18336 __attribute__((unused)) void *data) 18337 { 18338 struct cmd_config_per_port_tx_offload_result *res = parsed_result; 18339 portid_t port_id = res->port_id; 18340 struct rte_eth_dev_info dev_info; 18341 struct rte_port *port = &ports[port_id]; 18342 uint64_t single_offload; 18343 uint16_t nb_tx_queues; 18344 int q; 18345 18346 if (port->port_status != RTE_PORT_STOPPED) { 18347 printf("Error: Can't config offload when Port %d " 18348 "is not stopped\n", port_id); 18349 return; 18350 } 18351 18352 single_offload = search_tx_offload(res->offload); 18353 if (single_offload == 0) { 18354 printf("Unknown offload name: %s\n", res->offload); 18355 return; 18356 } 18357 18358 rte_eth_dev_info_get(port_id, &dev_info); 18359 nb_tx_queues = dev_info.nb_tx_queues; 18360 if (!strcmp(res->on_off, "on")) { 18361 port->dev_conf.txmode.offloads |= single_offload; 18362 for (q = 0; q < nb_tx_queues; q++) 18363 port->tx_conf[q].offloads |= single_offload; 18364 } else { 18365 port->dev_conf.txmode.offloads &= ~single_offload; 18366 for (q = 0; q < nb_tx_queues; q++) 18367 port->tx_conf[q].offloads &= ~single_offload; 18368 } 18369 18370 cmd_reconfig_device_queue(port_id, 1, 1); 18371 } 18372 18373 cmdline_parse_inst_t cmd_config_per_port_tx_offload = { 18374 .f = cmd_config_per_port_tx_offload_parsed, 18375 .data = NULL, 18376 .help_str = "port config <port_id> tx_offload " 18377 "vlan_insert|ipv4_cksum|udp_cksum|tcp_cksum|" 18378 "sctp_cksum|tcp_tso|udp_tso|outer_ipv4_cksum|" 18379 "qinq_insert|vxlan_tnl_tso|gre_tnl_tso|" 18380 "ipip_tnl_tso|geneve_tnl_tso|macsec_insert|" 18381 "mt_lockfree|multi_segs|mbuf_fast_free|security|" 18382 "match_metadata on|off", 18383 .tokens = { 18384 (void *)&cmd_config_per_port_tx_offload_result_port, 18385 (void *)&cmd_config_per_port_tx_offload_result_config, 18386 (void *)&cmd_config_per_port_tx_offload_result_port_id, 18387 (void *)&cmd_config_per_port_tx_offload_result_tx_offload, 18388 (void *)&cmd_config_per_port_tx_offload_result_offload, 18389 (void *)&cmd_config_per_port_tx_offload_result_on_off, 18390 NULL, 18391 } 18392 }; 18393 18394 /* Enable/Disable a per queue offloading */ 18395 struct cmd_config_per_queue_tx_offload_result { 18396 cmdline_fixed_string_t port; 18397 portid_t port_id; 18398 cmdline_fixed_string_t txq; 18399 uint16_t queue_id; 18400 cmdline_fixed_string_t tx_offload; 18401 cmdline_fixed_string_t offload; 18402 cmdline_fixed_string_t on_off; 18403 }; 18404 18405 cmdline_parse_token_string_t cmd_config_per_queue_tx_offload_result_port = 18406 TOKEN_STRING_INITIALIZER 18407 (struct cmd_config_per_queue_tx_offload_result, 18408 port, "port"); 18409 cmdline_parse_token_num_t cmd_config_per_queue_tx_offload_result_port_id = 18410 TOKEN_NUM_INITIALIZER 18411 (struct cmd_config_per_queue_tx_offload_result, 18412 port_id, UINT16); 18413 cmdline_parse_token_string_t cmd_config_per_queue_tx_offload_result_txq = 18414 TOKEN_STRING_INITIALIZER 18415 (struct cmd_config_per_queue_tx_offload_result, 18416 txq, "txq"); 18417 cmdline_parse_token_num_t cmd_config_per_queue_tx_offload_result_queue_id = 18418 TOKEN_NUM_INITIALIZER 18419 (struct cmd_config_per_queue_tx_offload_result, 18420 queue_id, UINT16); 18421 cmdline_parse_token_string_t cmd_config_per_queue_tx_offload_result_txoffload = 18422 TOKEN_STRING_INITIALIZER 18423 (struct cmd_config_per_queue_tx_offload_result, 18424 tx_offload, "tx_offload"); 18425 cmdline_parse_token_string_t cmd_config_per_queue_tx_offload_result_offload = 18426 TOKEN_STRING_INITIALIZER 18427 (struct cmd_config_per_queue_tx_offload_result, 18428 offload, "vlan_insert#ipv4_cksum#udp_cksum#tcp_cksum#" 18429 "sctp_cksum#tcp_tso#udp_tso#outer_ipv4_cksum#" 18430 "qinq_insert#vxlan_tnl_tso#gre_tnl_tso#" 18431 "ipip_tnl_tso#geneve_tnl_tso#macsec_insert#" 18432 "mt_lockfree#multi_segs#mbuf_fast_free#security"); 18433 cmdline_parse_token_string_t cmd_config_per_queue_tx_offload_result_on_off = 18434 TOKEN_STRING_INITIALIZER 18435 (struct cmd_config_per_queue_tx_offload_result, 18436 on_off, "on#off"); 18437 18438 static void 18439 cmd_config_per_queue_tx_offload_parsed(void *parsed_result, 18440 __attribute__((unused)) struct cmdline *cl, 18441 __attribute__((unused)) void *data) 18442 { 18443 struct cmd_config_per_queue_tx_offload_result *res = parsed_result; 18444 struct rte_eth_dev_info dev_info; 18445 portid_t port_id = res->port_id; 18446 uint16_t queue_id = res->queue_id; 18447 struct rte_port *port = &ports[port_id]; 18448 uint64_t single_offload; 18449 18450 if (port->port_status != RTE_PORT_STOPPED) { 18451 printf("Error: Can't config offload when Port %d " 18452 "is not stopped\n", port_id); 18453 return; 18454 } 18455 18456 rte_eth_dev_info_get(port_id, &dev_info); 18457 if (queue_id >= dev_info.nb_tx_queues) { 18458 printf("Error: input queue_id should be 0 ... " 18459 "%d\n", dev_info.nb_tx_queues - 1); 18460 return; 18461 } 18462 18463 single_offload = search_tx_offload(res->offload); 18464 if (single_offload == 0) { 18465 printf("Unknown offload name: %s\n", res->offload); 18466 return; 18467 } 18468 18469 if (!strcmp(res->on_off, "on")) 18470 port->tx_conf[queue_id].offloads |= single_offload; 18471 else 18472 port->tx_conf[queue_id].offloads &= ~single_offload; 18473 18474 cmd_reconfig_device_queue(port_id, 1, 1); 18475 } 18476 18477 cmdline_parse_inst_t cmd_config_per_queue_tx_offload = { 18478 .f = cmd_config_per_queue_tx_offload_parsed, 18479 .data = NULL, 18480 .help_str = "port <port_id> txq <queue_id> tx_offload " 18481 "vlan_insert|ipv4_cksum|udp_cksum|tcp_cksum|" 18482 "sctp_cksum|tcp_tso|udp_tso|outer_ipv4_cksum|" 18483 "qinq_insert|vxlan_tnl_tso|gre_tnl_tso|" 18484 "ipip_tnl_tso|geneve_tnl_tso|macsec_insert|" 18485 "mt_lockfree|multi_segs|mbuf_fast_free|security " 18486 "on|off", 18487 .tokens = { 18488 (void *)&cmd_config_per_queue_tx_offload_result_port, 18489 (void *)&cmd_config_per_queue_tx_offload_result_port_id, 18490 (void *)&cmd_config_per_queue_tx_offload_result_txq, 18491 (void *)&cmd_config_per_queue_tx_offload_result_queue_id, 18492 (void *)&cmd_config_per_queue_tx_offload_result_txoffload, 18493 (void *)&cmd_config_per_queue_tx_offload_result_offload, 18494 (void *)&cmd_config_per_queue_tx_offload_result_on_off, 18495 NULL, 18496 } 18497 }; 18498 18499 /* *** configure tx_metadata for specific port *** */ 18500 struct cmd_config_tx_metadata_specific_result { 18501 cmdline_fixed_string_t port; 18502 cmdline_fixed_string_t keyword; 18503 uint16_t port_id; 18504 cmdline_fixed_string_t item; 18505 uint32_t value; 18506 }; 18507 18508 static void 18509 cmd_config_tx_metadata_specific_parsed(void *parsed_result, 18510 __attribute__((unused)) struct cmdline *cl, 18511 __attribute__((unused)) void *data) 18512 { 18513 struct cmd_config_tx_metadata_specific_result *res = parsed_result; 18514 18515 if (port_id_is_invalid(res->port_id, ENABLED_WARN)) 18516 return; 18517 ports[res->port_id].tx_metadata = rte_cpu_to_be_32(res->value); 18518 /* Add/remove callback to insert valid metadata in every Tx packet. */ 18519 if (ports[res->port_id].tx_metadata) 18520 add_tx_md_callback(res->port_id); 18521 else 18522 remove_tx_md_callback(res->port_id); 18523 } 18524 18525 cmdline_parse_token_string_t cmd_config_tx_metadata_specific_port = 18526 TOKEN_STRING_INITIALIZER(struct cmd_config_tx_metadata_specific_result, 18527 port, "port"); 18528 cmdline_parse_token_string_t cmd_config_tx_metadata_specific_keyword = 18529 TOKEN_STRING_INITIALIZER(struct cmd_config_tx_metadata_specific_result, 18530 keyword, "config"); 18531 cmdline_parse_token_num_t cmd_config_tx_metadata_specific_id = 18532 TOKEN_NUM_INITIALIZER(struct cmd_config_tx_metadata_specific_result, 18533 port_id, UINT16); 18534 cmdline_parse_token_string_t cmd_config_tx_metadata_specific_item = 18535 TOKEN_STRING_INITIALIZER(struct cmd_config_tx_metadata_specific_result, 18536 item, "tx_metadata"); 18537 cmdline_parse_token_num_t cmd_config_tx_metadata_specific_value = 18538 TOKEN_NUM_INITIALIZER(struct cmd_config_tx_metadata_specific_result, 18539 value, UINT32); 18540 18541 cmdline_parse_inst_t cmd_config_tx_metadata_specific = { 18542 .f = cmd_config_tx_metadata_specific_parsed, 18543 .data = NULL, 18544 .help_str = "port config <port_id> tx_metadata <value>", 18545 .tokens = { 18546 (void *)&cmd_config_tx_metadata_specific_port, 18547 (void *)&cmd_config_tx_metadata_specific_keyword, 18548 (void *)&cmd_config_tx_metadata_specific_id, 18549 (void *)&cmd_config_tx_metadata_specific_item, 18550 (void *)&cmd_config_tx_metadata_specific_value, 18551 NULL, 18552 }, 18553 }; 18554 18555 /* *** display tx_metadata per port configuration *** */ 18556 struct cmd_show_tx_metadata_result { 18557 cmdline_fixed_string_t cmd_show; 18558 cmdline_fixed_string_t cmd_port; 18559 cmdline_fixed_string_t cmd_keyword; 18560 portid_t cmd_pid; 18561 }; 18562 18563 static void 18564 cmd_show_tx_metadata_parsed(void *parsed_result, 18565 __attribute__((unused)) struct cmdline *cl, 18566 __attribute__((unused)) void *data) 18567 { 18568 struct cmd_show_tx_metadata_result *res = parsed_result; 18569 18570 if (!rte_eth_dev_is_valid_port(res->cmd_pid)) { 18571 printf("invalid port id %u\n", res->cmd_pid); 18572 return; 18573 } 18574 if (!strcmp(res->cmd_keyword, "tx_metadata")) { 18575 printf("Port %u tx_metadata: %u\n", res->cmd_pid, 18576 rte_be_to_cpu_32(ports[res->cmd_pid].tx_metadata)); 18577 } 18578 } 18579 18580 cmdline_parse_token_string_t cmd_show_tx_metadata_show = 18581 TOKEN_STRING_INITIALIZER(struct cmd_show_tx_metadata_result, 18582 cmd_show, "show"); 18583 cmdline_parse_token_string_t cmd_show_tx_metadata_port = 18584 TOKEN_STRING_INITIALIZER(struct cmd_show_tx_metadata_result, 18585 cmd_port, "port"); 18586 cmdline_parse_token_num_t cmd_show_tx_metadata_pid = 18587 TOKEN_NUM_INITIALIZER(struct cmd_show_tx_metadata_result, 18588 cmd_pid, UINT16); 18589 cmdline_parse_token_string_t cmd_show_tx_metadata_keyword = 18590 TOKEN_STRING_INITIALIZER(struct cmd_show_tx_metadata_result, 18591 cmd_keyword, "tx_metadata"); 18592 18593 cmdline_parse_inst_t cmd_show_tx_metadata = { 18594 .f = cmd_show_tx_metadata_parsed, 18595 .data = NULL, 18596 .help_str = "show port <port_id> tx_metadata", 18597 .tokens = { 18598 (void *)&cmd_show_tx_metadata_show, 18599 (void *)&cmd_show_tx_metadata_port, 18600 (void *)&cmd_show_tx_metadata_pid, 18601 (void *)&cmd_show_tx_metadata_keyword, 18602 NULL, 18603 }, 18604 }; 18605 18606 /* ******************************************************************************** */ 18607 18608 /* list of instructions */ 18609 cmdline_parse_ctx_t main_ctx[] = { 18610 (cmdline_parse_inst_t *)&cmd_help_brief, 18611 (cmdline_parse_inst_t *)&cmd_help_long, 18612 (cmdline_parse_inst_t *)&cmd_quit, 18613 (cmdline_parse_inst_t *)&cmd_load_from_file, 18614 (cmdline_parse_inst_t *)&cmd_showport, 18615 (cmdline_parse_inst_t *)&cmd_showqueue, 18616 (cmdline_parse_inst_t *)&cmd_showportall, 18617 (cmdline_parse_inst_t *)&cmd_showcfg, 18618 (cmdline_parse_inst_t *)&cmd_start, 18619 (cmdline_parse_inst_t *)&cmd_start_tx_first, 18620 (cmdline_parse_inst_t *)&cmd_start_tx_first_n, 18621 (cmdline_parse_inst_t *)&cmd_set_link_up, 18622 (cmdline_parse_inst_t *)&cmd_set_link_down, 18623 (cmdline_parse_inst_t *)&cmd_reset, 18624 (cmdline_parse_inst_t *)&cmd_set_numbers, 18625 (cmdline_parse_inst_t *)&cmd_set_log, 18626 (cmdline_parse_inst_t *)&cmd_set_txpkts, 18627 (cmdline_parse_inst_t *)&cmd_set_txsplit, 18628 (cmdline_parse_inst_t *)&cmd_set_fwd_list, 18629 (cmdline_parse_inst_t *)&cmd_set_fwd_mask, 18630 (cmdline_parse_inst_t *)&cmd_set_fwd_mode, 18631 (cmdline_parse_inst_t *)&cmd_set_fwd_retry_mode, 18632 (cmdline_parse_inst_t *)&cmd_set_burst_tx_retry, 18633 (cmdline_parse_inst_t *)&cmd_set_promisc_mode_one, 18634 (cmdline_parse_inst_t *)&cmd_set_promisc_mode_all, 18635 (cmdline_parse_inst_t *)&cmd_set_allmulti_mode_one, 18636 (cmdline_parse_inst_t *)&cmd_set_allmulti_mode_all, 18637 (cmdline_parse_inst_t *)&cmd_set_flush_rx, 18638 (cmdline_parse_inst_t *)&cmd_set_link_check, 18639 (cmdline_parse_inst_t *)&cmd_set_bypass_mode, 18640 (cmdline_parse_inst_t *)&cmd_set_bypass_event, 18641 (cmdline_parse_inst_t *)&cmd_set_bypass_timeout, 18642 (cmdline_parse_inst_t *)&cmd_show_bypass_config, 18643 #ifdef RTE_LIBRTE_PMD_BOND 18644 (cmdline_parse_inst_t *) &cmd_set_bonding_mode, 18645 (cmdline_parse_inst_t *) &cmd_show_bonding_config, 18646 (cmdline_parse_inst_t *) &cmd_set_bonding_primary, 18647 (cmdline_parse_inst_t *) &cmd_add_bonding_slave, 18648 (cmdline_parse_inst_t *) &cmd_remove_bonding_slave, 18649 (cmdline_parse_inst_t *) &cmd_create_bonded_device, 18650 (cmdline_parse_inst_t *) &cmd_set_bond_mac_addr, 18651 (cmdline_parse_inst_t *) &cmd_set_balance_xmit_policy, 18652 (cmdline_parse_inst_t *) &cmd_set_bond_mon_period, 18653 (cmdline_parse_inst_t *) &cmd_set_lacp_dedicated_queues, 18654 (cmdline_parse_inst_t *) &cmd_set_bonding_agg_mode_policy, 18655 #endif 18656 (cmdline_parse_inst_t *)&cmd_vlan_offload, 18657 (cmdline_parse_inst_t *)&cmd_vlan_tpid, 18658 (cmdline_parse_inst_t *)&cmd_rx_vlan_filter_all, 18659 (cmdline_parse_inst_t *)&cmd_rx_vlan_filter, 18660 (cmdline_parse_inst_t *)&cmd_tx_vlan_set, 18661 (cmdline_parse_inst_t *)&cmd_tx_vlan_set_qinq, 18662 (cmdline_parse_inst_t *)&cmd_tx_vlan_reset, 18663 (cmdline_parse_inst_t *)&cmd_tx_vlan_set_pvid, 18664 (cmdline_parse_inst_t *)&cmd_csum_set, 18665 (cmdline_parse_inst_t *)&cmd_csum_show, 18666 (cmdline_parse_inst_t *)&cmd_csum_tunnel, 18667 (cmdline_parse_inst_t *)&cmd_tso_set, 18668 (cmdline_parse_inst_t *)&cmd_tso_show, 18669 (cmdline_parse_inst_t *)&cmd_tunnel_tso_set, 18670 (cmdline_parse_inst_t *)&cmd_tunnel_tso_show, 18671 (cmdline_parse_inst_t *)&cmd_gro_enable, 18672 (cmdline_parse_inst_t *)&cmd_gro_flush, 18673 (cmdline_parse_inst_t *)&cmd_gro_show, 18674 (cmdline_parse_inst_t *)&cmd_gso_enable, 18675 (cmdline_parse_inst_t *)&cmd_gso_size, 18676 (cmdline_parse_inst_t *)&cmd_gso_show, 18677 (cmdline_parse_inst_t *)&cmd_link_flow_control_set, 18678 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_rx, 18679 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_tx, 18680 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_hw, 18681 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_lw, 18682 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_pt, 18683 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_xon, 18684 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_macfwd, 18685 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_autoneg, 18686 (cmdline_parse_inst_t *)&cmd_priority_flow_control_set, 18687 (cmdline_parse_inst_t *)&cmd_config_dcb, 18688 (cmdline_parse_inst_t *)&cmd_read_reg, 18689 (cmdline_parse_inst_t *)&cmd_read_reg_bit_field, 18690 (cmdline_parse_inst_t *)&cmd_read_reg_bit, 18691 (cmdline_parse_inst_t *)&cmd_write_reg, 18692 (cmdline_parse_inst_t *)&cmd_write_reg_bit_field, 18693 (cmdline_parse_inst_t *)&cmd_write_reg_bit, 18694 (cmdline_parse_inst_t *)&cmd_read_rxd_txd, 18695 (cmdline_parse_inst_t *)&cmd_stop, 18696 (cmdline_parse_inst_t *)&cmd_mac_addr, 18697 (cmdline_parse_inst_t *)&cmd_set_fwd_eth_peer, 18698 (cmdline_parse_inst_t *)&cmd_set_qmap, 18699 (cmdline_parse_inst_t *)&cmd_set_xstats_hide_zero, 18700 (cmdline_parse_inst_t *)&cmd_operate_port, 18701 (cmdline_parse_inst_t *)&cmd_operate_specific_port, 18702 (cmdline_parse_inst_t *)&cmd_operate_attach_port, 18703 (cmdline_parse_inst_t *)&cmd_operate_detach_port, 18704 (cmdline_parse_inst_t *)&cmd_set_port_setup_on, 18705 (cmdline_parse_inst_t *)&cmd_config_speed_all, 18706 (cmdline_parse_inst_t *)&cmd_config_speed_specific, 18707 (cmdline_parse_inst_t *)&cmd_config_loopback_all, 18708 (cmdline_parse_inst_t *)&cmd_config_loopback_specific, 18709 (cmdline_parse_inst_t *)&cmd_config_rx_tx, 18710 (cmdline_parse_inst_t *)&cmd_config_mtu, 18711 (cmdline_parse_inst_t *)&cmd_config_max_pkt_len, 18712 (cmdline_parse_inst_t *)&cmd_config_rx_mode_flag, 18713 (cmdline_parse_inst_t *)&cmd_config_rss, 18714 (cmdline_parse_inst_t *)&cmd_config_rxtx_ring_size, 18715 (cmdline_parse_inst_t *)&cmd_config_rxtx_queue, 18716 (cmdline_parse_inst_t *)&cmd_config_deferred_start_rxtx_queue, 18717 (cmdline_parse_inst_t *)&cmd_setup_rxtx_queue, 18718 (cmdline_parse_inst_t *)&cmd_config_rss_reta, 18719 (cmdline_parse_inst_t *)&cmd_showport_reta, 18720 (cmdline_parse_inst_t *)&cmd_config_burst, 18721 (cmdline_parse_inst_t *)&cmd_config_thresh, 18722 (cmdline_parse_inst_t *)&cmd_config_threshold, 18723 (cmdline_parse_inst_t *)&cmd_set_uc_hash_filter, 18724 (cmdline_parse_inst_t *)&cmd_set_uc_all_hash_filter, 18725 (cmdline_parse_inst_t *)&cmd_vf_mac_addr_filter, 18726 (cmdline_parse_inst_t *)&cmd_set_vf_macvlan_filter, 18727 (cmdline_parse_inst_t *)&cmd_queue_rate_limit, 18728 (cmdline_parse_inst_t *)&cmd_tunnel_filter, 18729 (cmdline_parse_inst_t *)&cmd_tunnel_udp_config, 18730 (cmdline_parse_inst_t *)&cmd_global_config, 18731 (cmdline_parse_inst_t *)&cmd_set_mirror_mask, 18732 (cmdline_parse_inst_t *)&cmd_set_mirror_link, 18733 (cmdline_parse_inst_t *)&cmd_reset_mirror_rule, 18734 (cmdline_parse_inst_t *)&cmd_showport_rss_hash, 18735 (cmdline_parse_inst_t *)&cmd_showport_rss_hash_key, 18736 (cmdline_parse_inst_t *)&cmd_config_rss_hash_key, 18737 (cmdline_parse_inst_t *)&cmd_dump, 18738 (cmdline_parse_inst_t *)&cmd_dump_one, 18739 (cmdline_parse_inst_t *)&cmd_ethertype_filter, 18740 (cmdline_parse_inst_t *)&cmd_syn_filter, 18741 (cmdline_parse_inst_t *)&cmd_2tuple_filter, 18742 (cmdline_parse_inst_t *)&cmd_5tuple_filter, 18743 (cmdline_parse_inst_t *)&cmd_flex_filter, 18744 (cmdline_parse_inst_t *)&cmd_add_del_ip_flow_director, 18745 (cmdline_parse_inst_t *)&cmd_add_del_udp_flow_director, 18746 (cmdline_parse_inst_t *)&cmd_add_del_sctp_flow_director, 18747 (cmdline_parse_inst_t *)&cmd_add_del_l2_flow_director, 18748 (cmdline_parse_inst_t *)&cmd_add_del_mac_vlan_flow_director, 18749 (cmdline_parse_inst_t *)&cmd_add_del_tunnel_flow_director, 18750 (cmdline_parse_inst_t *)&cmd_add_del_raw_flow_director, 18751 (cmdline_parse_inst_t *)&cmd_flush_flow_director, 18752 (cmdline_parse_inst_t *)&cmd_set_flow_director_ip_mask, 18753 (cmdline_parse_inst_t *)&cmd_set_flow_director_mac_vlan_mask, 18754 (cmdline_parse_inst_t *)&cmd_set_flow_director_tunnel_mask, 18755 (cmdline_parse_inst_t *)&cmd_set_flow_director_flex_mask, 18756 (cmdline_parse_inst_t *)&cmd_set_flow_director_flex_payload, 18757 (cmdline_parse_inst_t *)&cmd_get_sym_hash_ena_per_port, 18758 (cmdline_parse_inst_t *)&cmd_set_sym_hash_ena_per_port, 18759 (cmdline_parse_inst_t *)&cmd_get_hash_global_config, 18760 (cmdline_parse_inst_t *)&cmd_set_hash_global_config, 18761 (cmdline_parse_inst_t *)&cmd_set_hash_input_set, 18762 (cmdline_parse_inst_t *)&cmd_set_fdir_input_set, 18763 (cmdline_parse_inst_t *)&cmd_flow, 18764 (cmdline_parse_inst_t *)&cmd_show_port_meter_cap, 18765 (cmdline_parse_inst_t *)&cmd_add_port_meter_profile_srtcm, 18766 (cmdline_parse_inst_t *)&cmd_add_port_meter_profile_trtcm, 18767 (cmdline_parse_inst_t *)&cmd_del_port_meter_profile, 18768 (cmdline_parse_inst_t *)&cmd_create_port_meter, 18769 (cmdline_parse_inst_t *)&cmd_enable_port_meter, 18770 (cmdline_parse_inst_t *)&cmd_disable_port_meter, 18771 (cmdline_parse_inst_t *)&cmd_del_port_meter, 18772 (cmdline_parse_inst_t *)&cmd_set_port_meter_profile, 18773 (cmdline_parse_inst_t *)&cmd_set_port_meter_dscp_table, 18774 (cmdline_parse_inst_t *)&cmd_set_port_meter_policer_action, 18775 (cmdline_parse_inst_t *)&cmd_set_port_meter_stats_mask, 18776 (cmdline_parse_inst_t *)&cmd_show_port_meter_stats, 18777 (cmdline_parse_inst_t *)&cmd_mcast_addr, 18778 (cmdline_parse_inst_t *)&cmd_config_l2_tunnel_eth_type_all, 18779 (cmdline_parse_inst_t *)&cmd_config_l2_tunnel_eth_type_specific, 18780 (cmdline_parse_inst_t *)&cmd_config_l2_tunnel_en_dis_all, 18781 (cmdline_parse_inst_t *)&cmd_config_l2_tunnel_en_dis_specific, 18782 (cmdline_parse_inst_t *)&cmd_config_e_tag_insertion_en, 18783 (cmdline_parse_inst_t *)&cmd_config_e_tag_insertion_dis, 18784 (cmdline_parse_inst_t *)&cmd_config_e_tag_stripping_en_dis, 18785 (cmdline_parse_inst_t *)&cmd_config_e_tag_forwarding_en_dis, 18786 (cmdline_parse_inst_t *)&cmd_config_e_tag_filter_add, 18787 (cmdline_parse_inst_t *)&cmd_config_e_tag_filter_del, 18788 (cmdline_parse_inst_t *)&cmd_set_vf_vlan_anti_spoof, 18789 (cmdline_parse_inst_t *)&cmd_set_vf_mac_anti_spoof, 18790 (cmdline_parse_inst_t *)&cmd_set_vf_vlan_stripq, 18791 (cmdline_parse_inst_t *)&cmd_set_vf_vlan_insert, 18792 (cmdline_parse_inst_t *)&cmd_set_tx_loopback, 18793 (cmdline_parse_inst_t *)&cmd_set_all_queues_drop_en, 18794 (cmdline_parse_inst_t *)&cmd_set_vf_split_drop_en, 18795 (cmdline_parse_inst_t *)&cmd_set_macsec_offload_on, 18796 (cmdline_parse_inst_t *)&cmd_set_macsec_offload_off, 18797 (cmdline_parse_inst_t *)&cmd_set_macsec_sc, 18798 (cmdline_parse_inst_t *)&cmd_set_macsec_sa, 18799 (cmdline_parse_inst_t *)&cmd_set_vf_traffic, 18800 (cmdline_parse_inst_t *)&cmd_set_vf_rxmode, 18801 (cmdline_parse_inst_t *)&cmd_vf_rate_limit, 18802 (cmdline_parse_inst_t *)&cmd_vf_rxvlan_filter, 18803 (cmdline_parse_inst_t *)&cmd_set_vf_mac_addr, 18804 (cmdline_parse_inst_t *)&cmd_set_vf_promisc, 18805 (cmdline_parse_inst_t *)&cmd_set_vf_allmulti, 18806 (cmdline_parse_inst_t *)&cmd_set_vf_broadcast, 18807 (cmdline_parse_inst_t *)&cmd_set_vf_vlan_tag, 18808 (cmdline_parse_inst_t *)&cmd_vf_max_bw, 18809 (cmdline_parse_inst_t *)&cmd_vf_tc_min_bw, 18810 (cmdline_parse_inst_t *)&cmd_vf_tc_max_bw, 18811 (cmdline_parse_inst_t *)&cmd_strict_link_prio, 18812 (cmdline_parse_inst_t *)&cmd_tc_min_bw, 18813 #if defined RTE_LIBRTE_PMD_SOFTNIC && defined RTE_LIBRTE_SCHED 18814 (cmdline_parse_inst_t *)&cmd_set_port_tm_hierarchy_default, 18815 #endif 18816 (cmdline_parse_inst_t *)&cmd_set_vxlan, 18817 (cmdline_parse_inst_t *)&cmd_set_vxlan_with_vlan, 18818 (cmdline_parse_inst_t *)&cmd_set_nvgre, 18819 (cmdline_parse_inst_t *)&cmd_set_nvgre_with_vlan, 18820 (cmdline_parse_inst_t *)&cmd_set_l2_encap, 18821 (cmdline_parse_inst_t *)&cmd_set_l2_encap_with_vlan, 18822 (cmdline_parse_inst_t *)&cmd_set_l2_decap, 18823 (cmdline_parse_inst_t *)&cmd_set_l2_decap_with_vlan, 18824 (cmdline_parse_inst_t *)&cmd_set_mplsogre_encap, 18825 (cmdline_parse_inst_t *)&cmd_set_mplsogre_encap_with_vlan, 18826 (cmdline_parse_inst_t *)&cmd_set_mplsogre_decap, 18827 (cmdline_parse_inst_t *)&cmd_set_mplsogre_decap_with_vlan, 18828 (cmdline_parse_inst_t *)&cmd_set_mplsoudp_encap, 18829 (cmdline_parse_inst_t *)&cmd_set_mplsoudp_encap_with_vlan, 18830 (cmdline_parse_inst_t *)&cmd_set_mplsoudp_decap, 18831 (cmdline_parse_inst_t *)&cmd_set_mplsoudp_decap_with_vlan, 18832 (cmdline_parse_inst_t *)&cmd_ddp_add, 18833 (cmdline_parse_inst_t *)&cmd_ddp_del, 18834 (cmdline_parse_inst_t *)&cmd_ddp_get_list, 18835 (cmdline_parse_inst_t *)&cmd_ddp_get_info, 18836 (cmdline_parse_inst_t *)&cmd_cfg_input_set, 18837 (cmdline_parse_inst_t *)&cmd_clear_input_set, 18838 (cmdline_parse_inst_t *)&cmd_show_vf_stats, 18839 (cmdline_parse_inst_t *)&cmd_clear_vf_stats, 18840 (cmdline_parse_inst_t *)&cmd_ptype_mapping_get, 18841 (cmdline_parse_inst_t *)&cmd_ptype_mapping_replace, 18842 (cmdline_parse_inst_t *)&cmd_ptype_mapping_reset, 18843 (cmdline_parse_inst_t *)&cmd_ptype_mapping_update, 18844 18845 (cmdline_parse_inst_t *)&cmd_pctype_mapping_get, 18846 (cmdline_parse_inst_t *)&cmd_pctype_mapping_reset, 18847 (cmdline_parse_inst_t *)&cmd_pctype_mapping_update, 18848 (cmdline_parse_inst_t *)&cmd_queue_region, 18849 (cmdline_parse_inst_t *)&cmd_region_flowtype, 18850 (cmdline_parse_inst_t *)&cmd_user_priority_region, 18851 (cmdline_parse_inst_t *)&cmd_flush_queue_region, 18852 (cmdline_parse_inst_t *)&cmd_show_queue_region_info_all, 18853 (cmdline_parse_inst_t *)&cmd_show_port_tm_cap, 18854 (cmdline_parse_inst_t *)&cmd_show_port_tm_level_cap, 18855 (cmdline_parse_inst_t *)&cmd_show_port_tm_node_cap, 18856 (cmdline_parse_inst_t *)&cmd_show_port_tm_node_type, 18857 (cmdline_parse_inst_t *)&cmd_show_port_tm_node_stats, 18858 (cmdline_parse_inst_t *)&cmd_add_port_tm_node_shaper_profile, 18859 (cmdline_parse_inst_t *)&cmd_del_port_tm_node_shaper_profile, 18860 (cmdline_parse_inst_t *)&cmd_add_port_tm_node_shared_shaper, 18861 (cmdline_parse_inst_t *)&cmd_del_port_tm_node_shared_shaper, 18862 (cmdline_parse_inst_t *)&cmd_add_port_tm_node_wred_profile, 18863 (cmdline_parse_inst_t *)&cmd_del_port_tm_node_wred_profile, 18864 (cmdline_parse_inst_t *)&cmd_set_port_tm_node_shaper_profile, 18865 (cmdline_parse_inst_t *)&cmd_add_port_tm_nonleaf_node, 18866 (cmdline_parse_inst_t *)&cmd_add_port_tm_leaf_node, 18867 (cmdline_parse_inst_t *)&cmd_del_port_tm_node, 18868 (cmdline_parse_inst_t *)&cmd_set_port_tm_node_parent, 18869 (cmdline_parse_inst_t *)&cmd_suspend_port_tm_node, 18870 (cmdline_parse_inst_t *)&cmd_resume_port_tm_node, 18871 (cmdline_parse_inst_t *)&cmd_port_tm_hierarchy_commit, 18872 (cmdline_parse_inst_t *)&cmd_port_tm_mark_ip_ecn, 18873 (cmdline_parse_inst_t *)&cmd_port_tm_mark_ip_dscp, 18874 (cmdline_parse_inst_t *)&cmd_port_tm_mark_vlan_dei, 18875 (cmdline_parse_inst_t *)&cmd_cfg_tunnel_udp_port, 18876 (cmdline_parse_inst_t *)&cmd_rx_offload_get_capa, 18877 (cmdline_parse_inst_t *)&cmd_rx_offload_get_configuration, 18878 (cmdline_parse_inst_t *)&cmd_config_per_port_rx_offload, 18879 (cmdline_parse_inst_t *)&cmd_config_per_queue_rx_offload, 18880 (cmdline_parse_inst_t *)&cmd_tx_offload_get_capa, 18881 (cmdline_parse_inst_t *)&cmd_tx_offload_get_configuration, 18882 (cmdline_parse_inst_t *)&cmd_config_per_port_tx_offload, 18883 (cmdline_parse_inst_t *)&cmd_config_per_queue_tx_offload, 18884 #ifdef RTE_LIBRTE_BPF 18885 (cmdline_parse_inst_t *)&cmd_operate_bpf_ld_parse, 18886 (cmdline_parse_inst_t *)&cmd_operate_bpf_unld_parse, 18887 #endif 18888 (cmdline_parse_inst_t *)&cmd_config_tx_metadata_specific, 18889 (cmdline_parse_inst_t *)&cmd_show_tx_metadata, 18890 NULL, 18891 }; 18892 18893 /* read cmdline commands from file */ 18894 void 18895 cmdline_read_from_file(const char *filename) 18896 { 18897 struct cmdline *cl; 18898 18899 cl = cmdline_file_new(main_ctx, "testpmd> ", filename); 18900 if (cl == NULL) { 18901 printf("Failed to create file based cmdline context: %s\n", 18902 filename); 18903 return; 18904 } 18905 18906 cmdline_interact(cl); 18907 cmdline_quit(cl); 18908 18909 cmdline_free(cl); 18910 18911 printf("Read CLI commands from %s\n", filename); 18912 } 18913 18914 /* prompt function, called from main on MASTER lcore */ 18915 void 18916 prompt(void) 18917 { 18918 /* initialize non-constant commands */ 18919 cmd_set_fwd_mode_init(); 18920 cmd_set_fwd_retry_mode_init(); 18921 18922 testpmd_cl = cmdline_stdin_new(main_ctx, "testpmd> "); 18923 if (testpmd_cl == NULL) 18924 return; 18925 cmdline_interact(testpmd_cl); 18926 cmdline_stdin_exit(testpmd_cl); 18927 } 18928 18929 void 18930 prompt_exit(void) 18931 { 18932 if (testpmd_cl != NULL) 18933 cmdline_quit(testpmd_cl); 18934 } 18935 18936 static void 18937 cmd_reconfig_device_queue(portid_t id, uint8_t dev, uint8_t queue) 18938 { 18939 if (id == (portid_t)RTE_PORT_ALL) { 18940 portid_t pid; 18941 18942 RTE_ETH_FOREACH_DEV(pid) { 18943 /* check if need_reconfig has been set to 1 */ 18944 if (ports[pid].need_reconfig == 0) 18945 ports[pid].need_reconfig = dev; 18946 /* check if need_reconfig_queues has been set to 1 */ 18947 if (ports[pid].need_reconfig_queues == 0) 18948 ports[pid].need_reconfig_queues = queue; 18949 } 18950 } else if (!port_id_is_invalid(id, DISABLED_WARN)) { 18951 /* check if need_reconfig has been set to 1 */ 18952 if (ports[id].need_reconfig == 0) 18953 ports[id].need_reconfig = dev; 18954 /* check if need_reconfig_queues has been set to 1 */ 18955 if (ports[id].need_reconfig_queues == 0) 18956 ports[id].need_reconfig_queues = queue; 18957 } 18958 } 18959